Skip to content

Commit

Permalink
added ability for user to add custom slip system definition in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
shankinsMechEng committed Nov 12, 2024
1 parent 99f7b5f commit 738171d
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 160 deletions.
44 changes: 30 additions & 14 deletions python/FIERRO-GUI/fierro_gui/Bulk_Forming.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PySide6.QtWidgets import (QTableWidgetItem, QMessageBox, QApplication, QFileDialog, QWidget, QHBoxLayout, QVBoxLayout, QLabel, QLineEdit, QTableWidget, QPushButton)
from PySide6.QtWidgets import (QTableWidgetItem, QMessageBox, QApplication, QFileDialog, QWidget, QHBoxLayout, QVBoxLayout, QLabel, QLineEdit, QTableWidget, QPushButton, QTreeWidgetItem, QAbstractItemView)
from PySide6.QtCore import (QCoreApplication, QProcess, Qt)
from PySide6.QtGui import (QColor, QBrush, QFont)
import numpy as np
Expand Down Expand Up @@ -614,13 +614,16 @@ def delete_material_2():
# View details about a slip system
def slip_system_details():
selected_items = self.TSlipSystems.selectedItems()
selected_item = selected_items[0]
if selected_item.parent() is not None:
page = selected_item.text(0).split('.', 1)[0]
self.SlipSystemInfo.setCurrentIndex(int(page))
self.PlasticProperties.setCurrentIndex(2)
else:
if not selected_items:
warning_message("ERROR: Please select a specific slip system to view it's details.")
else:
selected_item = selected_items[0]
if selected_item.parent() is not None:
page = selected_item.text(0).split('.', 1)[0]
self.SlipSystemInfo.setCurrentIndex(int(page))
self.PlasticProperties.setCurrentIndex(2)
else:
warning_message("ERROR: Please select a specific slip system to view it's details.")
self.BSlipSystemDetails.clicked.connect(slip_system_details)

# Add slip system(s) to list
Expand Down Expand Up @@ -728,16 +731,18 @@ def remove_row():
# Function to add the slip system to table
def add_custom_system():
# Check that everything is completely filled out
warning_flag = 0
if not self.line_edit.text().strip():
warning_message("ERROR: Please assign a name to custom slip system.")
warning_flag = 0
return
for row in range(self.table.rowCount()):
for col in range(self.table.columnCount()):
item = self.table.item(row,col)
if item is None or not item.text().strip():
warning_flag = 1
if warning_flag == 1:
warning_message("ERROR: Ensure custom slip system is completely filled out, and delete any unused rows.")
return
# If there are no errors, add custom slip system to the table
else:
# count the number of slip systems already defined in the table
Expand All @@ -747,12 +752,23 @@ def add_custom_system():
num_children += top_level_item.childCount()
# Find the custom heading and add the new system to it
custom_label = self.TSlipSystems.findItems("CUSTOM", Qt.MatchExactly, 0)
# custom_item = next((item for item in matching_items if item.parent() is None), None)
# if custom_item:
# # Add a subitem to the found "custom" item
# new_subitem = QTreeWidgetItem(custom_item, [subitem_name])
# custom_item.addChild(new_subitem)
# self.BSubmit.clicked.connect(add_custom_system)
custom_item = next((item for item in custom_label if item.parent() is None), None)
if custom_item:
# Add a subitem to the found "custom" item
custom_name = str(num_children+1) + '. ' + self.line_edit.text().strip()
new_subitem = QTreeWidgetItem(custom_item, [custom_name])
custom_item.addChild(new_subitem)
# Disable things so people can't change them after it has been added
self.BSubmit.setEnabled(False)
self.line_edit.setEnabled(False)
self.BAddRow.setEnabled(False)
self.BRemoverow.setEnabled(False)
self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
# Go back to main slip system screen
self.PlasticProperties.setCurrentIndex(1)
# Expand custom definition
self.TSlipSystems.expandItem(custom_label[0])
self.BSubmit.clicked.connect(add_custom_system)

# Setup New Page
new_page.setLayout(page_layout)
Expand Down
52 changes: 21 additions & 31 deletions python/FIERRO-GUI/fierro_gui/FIERRO_GUI.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1326</width>
<height>1144</height>
<width>1355</width>
<height>1154</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -299,7 +299,7 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<item alignment="Qt::AlignTop">
<widget class="QStackedWidget" name="ToolWindow">
<property name="enabled">
<bool>true</bool>
Expand Down Expand Up @@ -352,7 +352,7 @@
<number>1</number>
</property>
<property name="currentIndex">
<number>4</number>
<number>2</number>
</property>
<widget class="QWidget" name="TitleTool">
<layout class="QVBoxLayout" name="verticalLayout_2">
Expand Down Expand Up @@ -810,7 +810,7 @@
</item>
</widget>
</item>
<item>
<item alignment="Qt::AlignTop">
<widget class="QFrame" name="frame_31">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
Expand Down Expand Up @@ -942,7 +942,7 @@
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down Expand Up @@ -981,27 +981,27 @@
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="widgetResizable">
<bool>false</bool>
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>368</width>
<height>700</height>
<width>376</width>
<height>541</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>200</verstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>700</height>
<height>0</height>
</size>
</property>
<property name="acceptDrops">
Expand Down Expand Up @@ -1029,7 +1029,7 @@
<item>
<widget class="QStackedWidget" name="GeometryOptions">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down Expand Up @@ -2226,6 +2226,12 @@ li.checked::marker { content: &quot;\2612&quot;; }
</layout>
</widget>
<widget class="QWidget" name="page_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QLabel" name="label">
Expand Down Expand Up @@ -2587,19 +2593,6 @@ li.checked::marker { content: &quot;\2612&quot;; }
</widget>
</widget>
</item>
<item>
<spacer name="verticalSpacer_21">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QTableWidget" name="TParts">
<property name="enabled">
Expand Down Expand Up @@ -11494,8 +11487,8 @@ li.checked::marker { content: &quot;\2612&quot;; }
<rect>
<x>0</x>
<y>0</y>
<width>1326</width>
<height>37</height>
<width>1355</width>
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuHelp">
Expand Down Expand Up @@ -11609,12 +11602,10 @@ li.checked::marker { content: &quot;\2612&quot;; }
<tabstop>INResultRegion</tabstop>
<tabstop>BOpenParaview</tabstop>
<tabstop>THomogenization</tabstop>
<tabstop>SAGeometryScrollArea</tabstop>
<tabstop>INPipelineSelection</tabstop>
<tabstop>INSelectGeometry</tabstop>
<tabstop>INSelectGeometryImport</tabstop>
<tabstop>INPartName</tabstop>
<tabstop>BUploadGeometryFile</tabstop>
<tabstop>INNumberOfVoxelsX</tabstop>
<tabstop>INNumberOfVoxelsY</tabstop>
<tabstop>INNumberOfVoxelsZ</tabstop>
Expand All @@ -11637,7 +11628,6 @@ li.checked::marker { content: &quot;\2612&quot;; }
<tabstop>INBoxy2</tabstop>
<tabstop>INBoxz1</tabstop>
<tabstop>INBoxz2</tabstop>
<tabstop>TParts</tabstop>
<tabstop>BDeleteGeometry</tabstop>
<tabstop>INElementType</tabstop>
<tabstop>INCoordinateSystem</tabstop>
Expand Down
1 change: 1 addition & 0 deletions python/FIERRO-GUI/fierro_gui/FIERRO_Setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class FierroSetup(QDialog, Ui_Dialog):

def __init__(self, main_window, parent=None):
super().__init__(parent)
self.setWindowFlags(Qt.Window | Qt.WindowStaysOnTopHint)
self.setupUi(self)
self.MainWindow = main_window

Expand Down
18 changes: 9 additions & 9 deletions python/FIERRO-GUI/fierro_gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ def __init__(self):
app.setWindowIcon(QIcon(':/Logos/Logos/FierroAppIcon.png'))
app.setApplicationDisplayName("Fierro")
start = time.perf_counter()
print ("Splash Screen")
pixmap = QPixmap(":/Logos/Logos/FIERRO.png")
pixmap = pixmap.scaledToWidth(500)
print (pixmap)
splash = QSplashScreen(pixmap)
print (splash)
splash.setWindowFlag(QtCore.Qt.WindowStaysOnTopHint)
# print ("Splash Screen")
# pixmap = QPixmap(":/Logos/Logos/FIERRO.png")
# pixmap = pixmap.scaledToWidth(500)
# print (pixmap)
# splash = QSplashScreen(pixmap)
# print (splash)
# splash.setWindowFlag(QtCore.Qt.WindowStaysOnTopHint)
#splash.showMessage("Loaded modules")
splash.show()
# splash.show()
#for i in range(100000):
#app.processEvents()
window = MainWindow()
window.show()
splash.finish(window)
# splash.finish(window)


sys.exit(app.exec())
Expand Down
Loading

0 comments on commit 738171d

Please sign in to comment.