Skip to content

Commit af93b6a

Browse files
committed
Add an extra button to split compute and save
1 parent f250908 commit af93b6a

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

src/sas/qtgui/Calculators/DataOperationUtilityPanel.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def __init__(self, parent=None):
5353
self.cmdSaveData.clicked.connect(self.onSaveData)
5454

5555
self.cmdCompute.setEnabled(False)
56+
self.cmdSaveData.setEnabled(False)
57+
5658

5759
# validator for coefficient
5860
self.txtNumber.setValidator(GuiUtils.DoubleValidator())
@@ -147,16 +149,18 @@ def onCompute(self):
147149

148150
def onSaveData(self):
149151
""" Save current output in data file and add it to the DataExplorer"""
150-
# add outputname to self.filenames
151-
self.list_data_items.append(str(self.txtOutputData.text()))
152-
# send result to DataExplorer
153-
self.onPrepareOutputData()
154-
# Add the new plot to the comboboxes
155-
self.cbData1.addItem(self.output.name)
156-
self.cbData2.addItem(self.output.name)
157-
if self.filenames is None:
158-
self.filenames = {}
159-
self.filenames[self.output.name] = self.output
152+
# if outputname was unused, proceed to save files
153+
if self.onCheckOutputName():
154+
# add outputname to self.filenames
155+
self.list_data_items.append(str(self.txtOutputData.text()))
156+
# send result to DataExplorer
157+
self.onPrepareOutputData()
158+
# Add the new plot to the comboboxes
159+
self.cbData1.addItem(self.output.name)
160+
self.cbData2.addItem(self.output.name)
161+
if self.filenames is None:
162+
self.filenames = {}
163+
self.filenames[self.output.name] = self.output
160164

161165
def onPrepareOutputData(self):
162166
""" Prepare datasets to be added to DataExplorer and DataManager """
@@ -187,6 +191,7 @@ def onReset(self):
187191

188192
self.txtNumber.setEnabled(False)
189193
self.cmdCompute.setEnabled(False)
194+
self.cmdSaveData.setEnabled(False)
190195

191196
self.cbData1.setCurrentIndex(0)
192197
self.cbData2.setCurrentIndex(0)
@@ -212,6 +217,7 @@ def onSelectData1(self):
212217
self.data1 = None
213218
self.data1OK = False
214219
self.cmdCompute.setEnabled(False) # self.onCheckChosenData())
220+
self.cmdSaveData.setEnabled(False)
215221
return
216222

217223
else:
@@ -223,8 +229,9 @@ def onSelectData1(self):
223229
self.updatePlot(self.graphData1, self.layoutData1, self.data1)
224230
# plot default for output graph
225231
self.newPlot(self.graphOutput, self.layoutOutput)
226-
# Enable Compute button only if Data2 is defined and data compatible
232+
# Enable Compute and SaveData buttons only if Data2 is defined and data compatible
227233
self.cmdCompute.setEnabled(self.onCheckChosenData())
234+
self.cmdSaveData.setEnabled(self.onCheckChosenData())
228235

229236
def onSelectData2(self):
230237
""" Plot for selection of Data2 """
@@ -237,15 +244,17 @@ def onSelectData2(self):
237244
self.data2OK = False
238245
self.onCheckChosenData()
239246
self.cmdCompute.setEnabled(False)
247+
self.cmdSaveData.setEnabled(False)
240248
return
241249

242250
elif choice_data2 == 'Number':
243251
self.data2OK = True
244252
self.txtNumber.setEnabled(True)
245253
self.data2 = float(self.txtNumber.text())
246254

247-
# Enable Compute button only if Data1 defined and compatible data
255+
# Enable Compute and SaveData buttons only if Data1 defined and compatible data
248256
self.cmdCompute.setEnabled(self.onCheckChosenData())
257+
self.cmdSaveData.setEnabled(self.onCheckChosenData())
249258
# Display value of coefficient in graphData2
250259
self.updatePlot(self.graphData2, self.layoutData2, self.data2)
251260
# plot default for output graph
@@ -258,6 +267,7 @@ def onSelectData2(self):
258267
key_id2 = self._findId(choice_data2)
259268
self.data2 = self._extractData(key_id2)
260269
self.cmdCompute.setEnabled(self.onCheckChosenData())
270+
self.cmdSaveData.setEnabled(self.onCheckChosenData())
261271

262272
# plot Data2
263273
self.updatePlot(self.graphData2, self.layoutData2, self.data2)
@@ -434,6 +444,8 @@ def updatePlot(self, graph, layout, data):
434444

435445
plotter.plot(data=data, hide_error=True, marker='.')
436446

447+
layout.setContentsMargins(0, 0, 0, 0)
448+
437449
plotter.show()
438450

439451
elif float(data) and self.cbData2.currentText() == 'Number':

src/sas/qtgui/Calculators/UI/DataOperationUtilityUI.ui

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@
9191
<property name="text">
9292
<string>Save</string>
9393
</property>
94+
<property name="autoDefault">
95+
<bool>false</bool>
96+
</property>
9497
</widget>
9598
</item>
9699
<item>

src/sas/qtgui/Plotting/PlotterBase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(self, parent=None, manager=None, quickplot=False):
4545
# Set the layout and place the canvas widget in it.
4646
layout = QtWidgets.QVBoxLayout()
4747
# FIXME setMargin -> setContentsMargins in qt5 with 4 args
48-
layout.setContentsMargins(0, 0, 0, 0)
48+
#layout.setContentsMargins(0, 0, 0, 0)
4949
layout.setSpacing(0)
5050
layout.addWidget(self.canvas)
5151

0 commit comments

Comments
 (0)