Beispiel #1
0
    def _initCropListView(self):
        if self.topLevelOperatorView.Crops.value != {}:
            self._cropControlUi.cropListModel = CropListModel()
            crops = self.topLevelOperatorView.Crops.value
            for key in sorted(crops):
                newRow = self._cropControlUi.cropListModel.rowCount()
                crop = Crop(
                    key, [(crops[key]["time"][0], crops[key]["starts"][0],
                           crops[key]["starts"][1], crops[key]["starts"][2]),
                          (crops[key]["time"][1], crops[key]["stops"][0],
                           crops[key]["stops"][1], crops[key]["stops"][2])],
                    QColor(crops[key]["cropColor"][0],
                           crops[key]["cropColor"][1],
                           crops[key]["cropColor"][2]),
                    pmapColor=QColor(crops[key]["pmapColor"][0],
                                     crops[key]["pmapColor"][1],
                                     crops[key]["pmapColor"][2]))
                self._cropControlUi.cropListModel.insertRow(newRow, crop)

            self._cropControlUi.cropListModel.elementSelected.connect(
                self._onCropSelected)
            self._cropControlUi.cropListView.setModel(
                self._cropControlUi.cropListModel)
            self._cropControlUi.cropListView.updateGeometry()
            self._cropControlUi.cropListView.update()
            self._cropControlUi.cropListView.selectRow(0)
            self._maxCropNumUsed = len(crops)
        else:
            self.editor.cropModel.set_volume_shape_3d(
                self.editor.dataShape[1:4])
            self.newCrop()
            self.setCrop()
Beispiel #2
0
    def _updateCropShortcuts(self):
        numShortcuts = len(self._cropShortcuts)
        numRows = len(self._cropControlUi.cropListModel)

        mgr = ShortcutManager()
        ActionInfo = ShortcutManager.ActionInfo
        # Add any shortcuts we don't have yet.
        for i in range(numShortcuts, numRows):
            toolTipObject = CropListModel.EntryToolTipAdapter(
                self._cropControlUi.cropListModel, i)
            action_info = ActionInfo(
                "Cropping",
                "Select Crop {}".format(i + 1),
                "Select Crop {}".format(i + 1),
                partial(self._cropControlUi.cropListView.selectRow, i),
                self._cropControlUi.cropListView,
                toolTipObject,
            )
            mgr.register(str(i + 1), action_info)
            self._cropShortcuts.append(action_info)

        # Make sure that all shortcuts have an appropriate description
        for i in range(numRows):
            action_info = self._cropShortcuts[i]
            description = "Select " + self._cropControlUi.cropListModel[i].name
            new_action_info = mgr.update_description(action_info, description)
            self._cropShortcuts[i] = new_action_info
Beispiel #3
0
 def createWidget(self, parent):
     red = QColor(255, 0, 0)
     green = QColor(0, 255, 0)
     blue = QColor(0, 0, 255)
     model = CropListModel(
         [Crop("Crop 1", red),
          Crop("Crop 2", green),
          Crop("Crop 3", blue)])
     a = CropListView(parent)
     a.setModel(model)
     return a
    def _initCropUic(self, drawerUiPath):

        self.cropSelectionWidget = CropSelectionWidget()

        self._cropControlUi = self.cropSelectionWidget

        # Initialize the crop list model
        model = CropListModel()
        self._cropControlUi.cropListView.setModel(model)
        self._cropControlUi.cropListModel=model
        self._cropControlUi.cropListModel.rowsRemoved.connect(self._onCropRemoved)
        self._cropControlUi.cropListModel.elementSelected.connect(self._onCropSelected)
        self._cropControlUi.cropListModel.dataChanged.connect(self.onCropListDataChanged)
        self.toolButtons = None