Skip to content

Commit

Permalink
Added 'validate' button to the UI, disabled when 'Auto-update Solver …
Browse files Browse the repository at this point in the history
…Validation' is on.

Do not update the Solver model when the Solver is executing.
Connect signal/slots when solver widgets update to make sure the info is updated (if we have 'auto-update solver validation' on).
  • Loading branch information
david-cattermole committed Oct 2, 2019
1 parent bec3a5e commit 04a1e49
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 22 deletions.
43 changes: 41 additions & 2 deletions python/mmSolver/tools/solver/widget/solver_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import Qt.QtWidgets as QtWidgets

import mmSolver.logger
import mmSolver.api as mmapi
import mmSolver.tools.solver.lib.state as lib_state
import mmSolver.tools.solver.lib.collectionstate as lib_col_state
import mmSolver.tools.solver.widget.ui_solver_widget as ui_solver_widget
Expand Down Expand Up @@ -84,14 +85,25 @@ def __init__(self, parent=None, *args, **kwargs):
self.legacy_widget
]

# Set defaults for info text fields.
self.info_label.setHidden(False)
self.validate_pushButton.setEnabled(False)

self.tabWidget.currentChanged.connect(self._tabChanged)
self.basic_widget.dataChanged.connect(self._dataChanged)
self.standard_widget.dataChanged.connect(self._dataChanged)
self.legacy_widget.dataChanged.connect(self._dataChanged)
self.standard_widget.sendWarning.connect(self._sendWarningToUser)
self.standard_widget.sendWarning.connect(self._sendWarningToUser)

self.basic_widget.frameRange_widget.rangeTypeChanged.connect(self.updateInfo)
self.basic_widget.frameRange_widget.framesChanged.connect(self.updateInfo)
self.basic_widget.frameRange_widget.incrementByFrameChanged.connect(self.updateInfo)
self.standard_widget.frameRange_widget.rangeTypeChanged.connect(self.updateInfo)
self.validate_pushButton.clicked.connect(self.runUpdateInfo)

# First time we open this UI, we should update the solver info text.
value = lib_state.get_auto_update_solver_validation_state()
if value is False:
self.validate_pushButton.clicked.emit()
return

def getSolverTabValue(self, col):
Expand Down Expand Up @@ -128,6 +140,9 @@ def _getTabWidget(self, idx):
return widget

def updateModel(self):
is_running = mmapi.is_solver_running()
if is_running is True:
return
col = lib_state.get_active_collection()
if col is not None:
tab_name = self.getSolverTabValue(col)
Expand All @@ -147,16 +162,40 @@ def updateModel(self):
self.info_label,
]
_populateWidgetsEnabled(widgets)
self.updateInfo()
return

def updateInfo(self):
LOG.debug('RUN solver_widget updateInfo')
is_running = mmapi.is_solver_running()
if is_running is True:
return

value = lib_state.get_auto_update_solver_validation_state()
self.validate_pushButton.setEnabled(not value)
if value is not True:
return

self.runUpdateInfo()
return

def runUpdateInfo(self):
LOG.debug('RUN solver_widget runUpdateInfo B')
idx = self.tabWidget.currentIndex()
tab_widget = self._getTabWidget(idx)
text = tab_widget.queryInfo()
self.info_label.setText(text)
return

@QtCore.Slot(bool)
def autoUpdateSolverValidationChanged(self, value):
LOG.debug('autoUpdateSolverValidationChanged: %r', value)
lib_state.set_auto_update_solver_validation_state(value)
self.updateInfo()
return

@QtCore.Slot(str)
def _sendWarningToUser(self, value):
LOG.debug('sendWarningToUser: %r', value)
self.sendWarning.emit(value)
return
82 changes: 62 additions & 20 deletions python/mmSolver/tools/solver/widget/solver_widget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
Expand Down Expand Up @@ -49,16 +64,16 @@
<number>1</number>
</property>
<property name="leftMargin">
<number>5</number>
<number>1</number>
</property>
<property name="topMargin">
<number>5</number>
<number>1</number>
</property>
<property name="rightMargin">
<number>5</number>
<number>1</number>
</property>
<property name="bottomMargin">
<number>5</number>
<number>1</number>
</property>
<item>
<layout class="QVBoxLayout" name="basic_layout">
Expand All @@ -78,16 +93,16 @@
<number>1</number>
</property>
<property name="leftMargin">
<number>5</number>
<number>1</number>
</property>
<property name="topMargin">
<number>5</number>
<number>1</number>
</property>
<property name="rightMargin">
<number>5</number>
<number>1</number>
</property>
<property name="bottomMargin">
<number>5</number>
<number>1</number>
</property>
<item>
<layout class="QVBoxLayout" name="standard_layout">
Expand All @@ -107,16 +122,16 @@
<number>1</number>
</property>
<property name="leftMargin">
<number>5</number>
<number>1</number>
</property>
<property name="topMargin">
<number>5</number>
<number>1</number>
</property>
<property name="rightMargin">
<number>5</number>
<number>1</number>
</property>
<property name="bottomMargin">
<number>5</number>
<number>1</number>
</property>
<item>
<layout class="QVBoxLayout" name="legacy_layout">
Expand All @@ -130,14 +145,41 @@
</widget>
</item>
<item>
<widget class="QLabel" name="info_label">
<property name="text">
<string>INFORMATION</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<layout class="QHBoxLayout" name="info_layout" stretch="0,0,1">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="validate_pushButton">
<property name="text">
<string>Validate</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="info_label">
<property name="text">
<string>INFORMATION</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down

0 comments on commit 04a1e49

Please sign in to comment.