Changeset 8548d739 in sasview
- Timestamp:
- Nov 29, 2016 6:08:29 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:
- ded2ce3
- Parents:
- adf81b8
- git-author:
- Piotr Rozyczko <rozyczko@…> (11/29/16 06:04:46)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (11/29/16 06:08:29)
- Location:
- src/sas/qtgui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/DataExplorer.py
radf81b8 r8548d739 23 23 from sas.qtgui.Plotter2D import Plotter2D 24 24 from sas.qtgui.DroppableDataLoadWidget import DroppableDataLoadWidget 25 26 # This is how to get data1/2D from the model item27 # data = [selected_items[0].child(0).data().toPyObject()]28 25 29 26 class DataExplorerWindow(DroppableDataLoadWidget): … … 629 626 630 627 try: 631 is1D = isinstance( item.child(0).data().toPyObject(), Data1D)628 is1D = isinstance(GuiUtils.dataFromItem(item), Data1D) 632 629 except AttributeError: 633 630 msg = "Bad structure of the data model." … … 643 640 644 641 try: 645 is1D = isinstance( item.child(0).data().toPyObject(), Data1D)642 is1D = isinstance(GuiUtils.dataFromItem(item), Data1D) 646 643 except AttributeError: 647 644 msg = "Bad structure of the data model." … … 657 654 item.setCheckState(QtCore.Qt.Unchecked) 658 655 try: 659 is2D = isinstance( item.child(0).data().toPyObject(), Data2D)656 is2D = isinstance(GuiUtils.dataFromItem(item), Data2D) 660 657 except AttributeError: 661 658 msg = "Bad structure of the data model." … … 671 668 672 669 try: 673 is2D = isinstance( item.child(0).data().toPyObject(), Data2D)670 is2D = isinstance(GuiUtils.dataFromItem(item), Data2D) 674 671 except AttributeError: 675 672 msg = "Bad structure of the data model." … … 715 712 if orig_index: 716 713 # Check the data to enable/disable actions 717 is_2D = isinstance( model_item.child(0).data().toPyObject(), Data2D)714 is_2D = isinstance(GuiUtils.dataFromItem(model_item), Data2D) 718 715 self.actionQuick3DPlot.setEnabled(is_2D) 719 716 self.actionEditMask.setEnabled(is_2D) … … 727 724 index = self.treeView.selectedIndexes()[0] 728 725 model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index)) 729 data = model_item.child(0).data().toPyObject()726 data = GuiUtils.dataFromItem(model_item) 730 727 if isinstance(data, Data1D): 731 728 text_to_show = GuiUtils.retrieveData1d(data) … … 754 751 index = self.treeView.selectedIndexes()[0] 755 752 model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index)) 756 data = model_item.child(0).data().toPyObject()753 data = GuiUtils.dataFromItem(model_item) 757 754 if isinstance(data, Data1D): 758 755 GuiUtils.saveData1D(data) … … 766 763 index = self.treeView.selectedIndexes()[0] 767 764 model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index)) 768 data = model_item.child(0).data().toPyObject()765 data = GuiUtils.dataFromItem(model_item) 769 766 770 767 dimension = 1 if isinstance(data, Data1D) else 2 -
src/sas/qtgui/GuiUtils.py
r31c5b58 r8548d739 230 230 231 231 232 def updateModelItem (item, update_data, name=""):232 def updateModelItemWithPlot(item, update_data, name=""): 233 233 """ 234 234 Adds a checkboxed row named "name" to QStandardItem … … 264 264 # Append the new row to the main item 265 265 item.appendRow(checkbox_item) 266 267 def updateModelItem(item, update_data, name=""): 268 """ 269 Adds a simple named child to QStandardItem 270 """ 271 assert isinstance(item, QtGui.QStandardItem) 272 assert isinstance(update_data, list) 273 274 # Add the actual Data1D/Data2D object 275 object_item = QtGui.QStandardItem() 276 object_item.setText(name) 277 object_item.setData(QtCore.QVariant(update_data)) 278 279 # Append the new row to the main item 280 item.appendRow(object_item) 281 266 282 267 283 def plotsFromCheckedItems(model_item): … … 564 580 except: 565 581 pass 582 583 def dataFromItem(item): 584 """ 585 Retrieve Data1D/2D component from QStandardItem. 586 The assumption - data stored in SasView standard, in child 0 587 """ 588 return item.child(0).data().toPyObject() -
src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py
r31c5b58 r8548d739 275 275 276 276 # This needs to run in the main thread 277 reactor.callFromThread(GuiUtils.updateModelItem, self._model_item, variant_item, title) 277 reactor.callFromThread(GuiUtils.updateModelItemWithPlot, 278 self._model_item, variant_item, title) 278 279 279 280 if self._high_extrapolate: … … 297 298 variant_item = QtCore.QVariant(high_out_data) 298 299 # This needs to run in the main thread 299 reactor.callFromThread(GuiUtils.updateModelItem, self._model_item, variant_item, title) 300 reactor.callFromThread(GuiUtils.updateModelItemWithPlot, 301 self._model_item, variant_item, title) 300 302 301 303 item = QtGui.QStandardItem(str(float('%.5g'% volume_fraction))) … … 531 533 532 534 # Extract data on 1st child - this is the Data1D/2D component 533 data = self._model_item.child(0).data().toPyObject()535 data = GuiUtils.dataFromItem(self._model_item) 534 536 self.model.item(WIDGETS.W_FILENAME).setData(QtCore.QVariant(self._model_item.text())) 535 537 -
src/sas/qtgui/UnitTesting/GuiUtilsTest.py
r31c5b58 r8548d739 73 73 self.assertIn(signal, dir(com)) 74 74 75 76 def testUpdateModelItem(self): 77 """ 78 Test the QModelItem update method 75 def testupdateModelItem(self): 76 """ 77 Test the generic QModelItem update method 78 """ 79 test_item = QtGui.QStandardItem() 80 test_list = ['aa', 4, True, ] 81 name = "Black Sabbath" 82 83 # update the item 84 updateModelItem(test_item, test_list, name) 85 86 # Make sure test_item got all data added 87 self.assertEqual(test_item.child(0).text(), name) 88 list_from_item = test_item.child(0).data().toList() 89 self.assertIsInstance(list_from_item, list) 90 self.assertEqual(list_from_item[0].toPyObject(), test_list[0]) 91 self.assertEqual(list_from_item[1].toPyObject(), test_list[1]) 92 self.assertEqual(list_from_item[2].toPyObject(), test_list[2]) 93 94 def testupdateModelItemWithPlot(self): 95 """ 96 Test the QModelItem checkbox update method 79 97 """ 80 98 test_item = QtGui.QStandardItem() … … 84 102 85 103 # update the item 86 updateModelItem (test_item, update_data, name)104 updateModelItemWithPlot(test_item, update_data, name) 87 105 88 106 # Make sure test_item got all data added
Note: See TracChangeset
for help on using the changeset viewer.