Changeset 8cb6cd6 in sasview for src/sas/qtgui/DataExplorer.py
- Timestamp:
- Jul 12, 2016 8:44:53 AM (8 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- e3ae090
- Parents:
- a95260d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/DataExplorer.py
r0cd8612 r8cb6cd6 13 13 14 14 # SAS 15 import GuiUtils16 from Plotter import Plotter17 15 from sas.sascalc.dataloader.loader import Loader 18 16 from sas.sasgui.guiframe.data_manager import DataManager … … 20 18 from sas.sasgui.guiframe.dataFitting import Data2D 21 19 20 import GuiUtils 21 import PlotHelper 22 from Plotter import Plotter 22 23 from DroppableDataLoadWidget import DroppableDataLoadWidget 23 24 … … 46 47 # Be careful with twisted threads. 47 48 self.mutex = QMutex() 49 50 # Active plots 51 self.active_plots = [] 48 52 49 53 # Connect the buttons … … 54 58 self.cmdSendTo.clicked.connect(self.sendData) 55 59 self.cmdNew.clicked.connect(self.newPlot) 60 self.cmdAppend.clicked.connect(self.appendPlot) 56 61 self.cmdHelp.clicked.connect(self.displayHelp) 57 62 self.cmdHelp_2.clicked.connect(self.displayHelp) … … 76 81 self.communicator = self.parent.communicator() 77 82 self.communicator.fileReadSignal.connect(self.loadFromURL) 83 self.communicator.activeGraphsSignal.connect(self.updateGraphCombo) 84 self.cbgraph.editTextChanged.connect(self.enableGraphCombo) 85 self.cbgraph.currentIndexChanged.connect(self.enableGraphCombo) 78 86 79 87 # Proxy model for showing a subset of Data1D/Data2D content … … 97 105 self.freezeView.setModel(self.theory_proxy) 98 106 107 self.enableGraphCombo(None) 108 99 109 def closeEvent(self, event): 100 110 """ … … 110 120 self._helpView.load(QtCore.QUrl(_TreeLocation)) 111 121 self._helpView.show() 122 123 def enableGraphCombo(self, combo_text): 124 """ 125 Enables/disables "Assign Plot" elements 126 """ 127 self.cbgraph.setEnabled(len(PlotHelper.currentPlots()) > 0) 128 self.cmdAppend.setEnabled(len(PlotHelper.currentPlots()) > 0) 112 129 113 130 def loadFromURL(self, url): … … 187 204 delete_msg = "This operation will delete the checked data sets and all the dependents." +\ 188 205 "\nDo you want to continue?" 189 reply = QtGui.QMessageBox.question(self, 'Warning', delete_msg, 190 QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) 206 reply = QtGui.QMessageBox.question(self, 207 'Warning', 208 delete_msg, 209 QtGui.QMessageBox.Yes, 210 QtGui.QMessageBox.No) 191 211 192 212 if reply == QtGui.QMessageBox.No: … … 263 283 if not outer_item: 264 284 continue 265 for inner_index in xrange(outer_item.rowCount()): # Should be just two rows: data and Info 285 # Should be just two rows: data and Info 286 for inner_index in xrange(outer_item.rowCount()): 266 287 subitem = outer_item.child(inner_index) 267 if subitem and subitem.isCheckable() and subitem.checkState() == QtCore.Qt.Checked: 288 if subitem and \ 289 subitem.isCheckable() and \ 290 subitem.checkState() == QtCore.Qt.Checked: 268 291 theories_copied += 1 269 292 new_item = self.recursivelyCloneItem(subitem) 270 293 # Append a "unique" descriptor to the name 271 time_bit = str(time.time())[7:-1].replace('.', '')294 time_bit = str(time.time())[7:-1].replace('.', '') 272 295 new_name = new_item.text() + '_@' + time_bit 273 296 new_item.setText(new_name) … … 300 323 return new_item 301 324 325 def updateGraphCombo(self, graph_list): 326 """ 327 Modify Graph combo box on graph add/delete 328 """ 329 orig_text = self.cbgraph.currentText() 330 self.cbgraph.clear() 331 graph_titles = [] 332 for graph in graph_list: 333 graph_titles.append("Graph"+str(graph)) 334 self.cbgraph.insertItems(0, graph_titles) 335 ind = self.cbgraph.findText(orig_text) 336 if ind > 0: 337 self.cbgraph.setCurrentIndex(ind) 338 pass 339 302 340 def newPlot(self): 303 341 """ … … 306 344 TODO: Add 2D-functionality 307 345 """ 308 309 346 plots = GuiUtils.plotsFromCheckedItems(self.model) 310 347 311 348 # Call show on requested plots 312 new_plot = Plotter( )349 new_plot = Plotter(self) 313 350 for plot_set in plots: 314 351 new_plot.data(plot_set) 315 352 new_plot.plot() 316 353 354 # Update the global plot counter 355 title = "Graph"+str(PlotHelper.idOfPlot(new_plot)) 356 new_plot.setWindowTitle(title) 357 358 # Add the plot to the workspace 359 self.parent.workspace().addWindow(new_plot) 360 361 # Show the plot 317 362 new_plot.show() 363 364 # Update the active chart list 365 self.active_plots.append(title) 366 367 def appendPlot(self): 368 """ 369 Add data set(s) to the existing matplotlib chart 370 371 TODO: Add 2D-functionality 372 """ 373 # new plot data 374 new_plots = GuiUtils.plotsFromCheckedItems(self.model) 375 376 # old plot data 377 plot_id = self.cbgraph.currentText() 378 plot_id = int(plot_id[5:]) 379 380 assert plot_id in PlotHelper.currentPlots(), "No such plot: Graph%s"%str(plot_id) 381 382 old_plot = PlotHelper.plotById(plot_id) 383 384 # Add new data to the old plot 385 for plot_set in new_plots: 386 old_plot.data(plot_set) 387 old_plot.plot() 318 388 319 389 def chooseFiles(self): … … 424 494 else: 425 495 error_message += "%s\n" % str(p_file) 426 info = "error"427 496 428 497 current_percentage = int(100.0* index/number_of_files) … … 563 632 Post message to status bar and update the data manager 564 633 """ 565 assert type(output) == tuple634 assert isinstance(output, tuple) 566 635 567 636 # Reset the model so the view gets updated.
Note: See TracChangeset
for help on using the changeset viewer.