def setupOutputSection(self):
     self.outputCollapsibleButton = ctk.ctkCollapsibleButton()
     self.outputCollapsibleButton.objectName = "Output"
     self.outputCollapsibleButton.text = "Output"
     self.layout.addWidget(self.outputCollapsibleButton)
     self.outputCollapsibleButton.connect(
         'toggled(bool)', lambda toggle: self.onWorkflowStepChanged(
             self.outputCollapsibleButton, toggle))
     outputFormLayout = qt.QFormLayout(self.outputCollapsibleButton)
     self.computeStatusTextEdit = qt.QPlainTextEdit()
     self.computeStatusTextEdit.setTextInteractionFlags(
         qt.Qt.TextSelectableByMouse)
     self.computeStatusTextEdit.maximumHeight = 75
     outputFormLayout.addRow(self.computeStatusTextEdit)
     self.measurementTree = slicer.qMRMLSubjectHierarchyTreeView()
     self.measurementTree.setMRMLScene(slicer.mrmlScene)
     qSize = qt.QSizePolicy()
     qSize.setHorizontalPolicy(qt.QSizePolicy.MinimumExpanding)
     qSize.setVerticalPolicy(qt.QSizePolicy.MinimumExpanding)
     qSize.setVerticalStretch(1)
     self.measurementTree.setSizePolicy(qSize)
     self.measurementTree.setColumnHidden(
         self.measurementTree.model().idColumn, True)
     self.measurementTree.setColumnHidden(
         self.measurementTree.model().transformColumn, True)
     outputFormLayout.addRow(self.measurementTree)
示例#2
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.logic = ExtensionStatsLogic()
        self.logic.setStatusCallback(self.setStatusText)

        self.queryInProgress = False

        # Instantiate and connect widgets ...

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        self.extensionNameEdit = qt.QLineEdit()
        self.extensionNameEdit.setText('')
        parametersFormLayout.addRow("Extension name: ", self.extensionNameEdit)

        self.midasQueryUrlEdit = qt.QLineEdit()
        self.midasQueryUrlEdit.setText(
            'http://slicer.kitware.com/midas3/api/json')
        parametersFormLayout.addRow("MIDAS json query URL: ",
                                    self.midasQueryUrlEdit)

        self.applyButton = qt.QPushButton("Get download statistics")
        self.applyButton.toolTip = "Get download statistics"
        parametersFormLayout.addRow(self.applyButton)

        self.statusText = qt.QLabel()
        parametersFormLayout.addRow("Status:", self.statusText)

        # Stats table
        self.statsTable = qt.QTableWidget()
        self.statsTable.setSelectionBehavior(qt.QAbstractItemView.SelectRows)
        parametersFormLayout.addRow("Statistics:", self.statsTable)
        self.statsTableHeader = ['Revision', 'Downloads']
        policy = qt.QSizePolicy()
        policy.setVerticalStretch(1)
        policy.setHorizontalPolicy(qt.QSizePolicy.Expanding)
        policy.setVerticalPolicy(qt.QSizePolicy.Expanding)
        self.statsTable.setSizePolicy(policy)

        # Copy to clipboard button
        self.copyToClipboardButton = qt.QPushButton("Copy table to clipboard")
        parametersFormLayout.addRow('', self.copyToClipboardButton)

        # connections
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.copyToClipboardButton.connect('clicked()',
                                           self.copyTableToClipboard)
示例#3
0
    def createMainMenuDockWidget(self):
        # Set up main frame
        self.mainMenuDockWidget = qt.QDockWidget(self.parent)
        self.mainMenuDockWidget.setTitleBarWidget(
            qt.QWidget())  # hide title bar
        self.mainMenuDockWidget.setObjectName('FirstTaskPanel')
        self.mainMenuDockWidget.setWindowTitle('First Task')

        # self.mainMenuDockWidget.setStyleSheet(self.styleSheet)
        self.mainMenuDockWidget.setFeatures(
            qt.QDockWidget.DockWidgetMovable
            | qt.QDockWidget.DockWidgetFloatable)  # not closable

        mainWindow = slicer.util.mainWindow()
        self.mainMenuDockWidget.setParent(mainWindow)

        # Setup scroll area
        self.mainFrame = qt.QFrame(self.mainMenuDockWidget)
        self.mainLayout = qt.QVBoxLayout(self.mainFrame)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.spacing = 0

        self.mainScrollArea = qt.QScrollArea(self.mainFrame)
        self.mainScrollArea.widgetResizable = True
        self.mainScrollArea.sizeAdjustPolicy = qt.QAbstractScrollArea.AdjustToContentsOnFirstShow
        self.mainScrollArea.horizontalScrollBarPolicy = qt.Qt.ScrollBarAlwaysOff
        self.mainScrollArea.setSizePolicy(
            qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Expanding))
        self.mainScrollArea.frameShape = qt.QFrame.NoFrame

        # Slicelet panel
        self.sliceletPanel = qt.QFrame(self.mainFrame)
        self.sliceletPanelLayout = qt.QVBoxLayout(self.sliceletPanel)
        self.sliceletPanelLayout.spacing = 0
        self.mainScrollArea.setWidget(self.sliceletPanel)

        self.mainLayout.addWidget(self.mainScrollArea)
        self.mainMenuDockWidget.setWidget(self.mainFrame)

        # Setup feature panel
        self.setupUi()

        self.sliceletPanelLayout.addStretch(1)

        self.setupSettingsPanel()

        self.mainScrollArea.minimumWidth = self.sliceletPanel.sizeHint.width()
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.logic = ExtensionStatsLogic()
        self.logic.setStatusCallback(self.setStatusText)

        self.queryInProgress = False

        # Instantiate and connect widgets ...

        #
        # Parameters Area
        #
        parametersCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCollapsibleButton.text = "Parameters"
        self.layout.addWidget(parametersCollapsibleButton)

        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        extensionNameBox = qt.QHBoxLayout()

        self.extensionNameEdit = qt.QLineEdit()
        self.extensionNameEdit.setText('')
        extensionNameBox.addWidget(self.extensionNameEdit)

        self.extensionNameAllButton = qt.QPushButton()
        self.extensionNameAllButton.text = "all"
        self.extensionNameAllButton.toolTip = "Get statistics for all extensions"
        extensionNameBox.addWidget(self.extensionNameAllButton)
        self.populateExtensionNameEdit()

        parametersFormLayout.addRow("Extension name: ", extensionNameBox)

        self.applyButton = qt.QPushButton("Get download statistics")
        self.applyButton.toolTip = "Get download statistics"
        parametersFormLayout.addRow(self.applyButton)

        self.statusText = qt.QLabel()
        parametersFormLayout.addRow("Status:", self.statusText)

        # Stats table
        self.statsTableWidget = slicer.qMRMLTableView()
        self.statsTableWidget.setMRMLScene(slicer.mrmlScene)
        parametersFormLayout.addRow("Statistics:", self.statsTableWidget)
        policy = qt.QSizePolicy()
        policy.setVerticalStretch(1)
        policy.setHorizontalPolicy(qt.QSizePolicy.Expanding)
        policy.setVerticalPolicy(qt.QSizePolicy.Expanding)
        self.statsTableWidget.setSizePolicy(policy)

        self.statsTableNode = slicer.vtkMRMLTableNode()
        self.statsTableNode.SetName('ExtensionStats')
        self.statsTableNode.SetUseColumnNameAsColumnHeader(True)
        self.statsTableNode.SetUseFirstColumnAsRowHeader(True)
        slicer.mrmlScene.AddNode(self.statsTableNode)
        self.statsTableWidget.setMRMLTableNode(self.statsTableNode)

        # Copy to clipboard button
        self.copyToClipboardButton = qt.QPushButton("Copy table to clipboard")
        parametersFormLayout.addRow('', self.copyToClipboardButton)

        # connections
        self.extensionNameAllButton.connect('clicked()',
                                            self.populateExtensionNameEdit)
        self.applyButton.connect('clicked(bool)', self.onApplyButton)
        self.copyToClipboardButton.connect('clicked()',
                                           self.copyTableToClipboard)
示例#5
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        print "-------Mesh Statistic Widget Setup-------"
        self.moduleName = 'MeshStatistics'
        scriptedModulesPath = eval('slicer.modules.%s.path' %
                                   self.moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)

        libPath = os.path.join(scriptedModulesPath)
        sys.path.insert(0, libPath)

        # import the external library that contain the functions comon to all DCBIA modules
        import ShapeQuantifierCore
        reload(ShapeQuantifierCore)

        # -------------------------------------------------------------------------------------
        self.ShapeQuantifierCore = ShapeQuantifierCore.ShapeQuantifierCore(
            interface=self)
        self.logic = MeshStatisticsLogic(self, ShapeQuantifierCore)
        self.modelList = list()
        self.fieldList = list()
        self.ROIList = list()
        self.ROIDict = dict()  # Key = Name of ROI
        # Value = Dictionary of Fields (key = Name of Field
        #                               Value = dictionary of shapes
        #                                             key = name of shapes
        #                                             value = Statistics store()

        # ---------------------------------------------------------------- #
        # ---------------- Definition of the UI interface ---------------- #
        # ---------------------------------------------------------------- #

        # ------------ Loading of the .ui file ---------- #

        loader = qt.QUiLoader()
        path = os.path.join(scriptedModulesPath, 'Resources', 'UI',
                            '%s.ui' % self.moduleName)
        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile, self.parent)
        self.layout = self.parent.layout()
        self.widget = widget
        self.layout.addWidget(widget)

        # ------------------------------------------------------------------------------------
        #                                    SHAPES INPUT
        # ------------------------------------------------------------------------------------
        self.inputComboBox = self.ShapeQuantifierCore.get("inputComboBox")
        self.inputComboBox.setMRMLScene(slicer.mrmlScene)
        self.inputComboBox.connect('checkedNodesChanged()',
                                   self.onInputComboBoxCheckedNodesChanged)
        # ------------------------------------------------------------------------------------
        #                                  ROI TABLE
        # ------------------------------------------------------------------------------------
        self.ROIComboBox = self.ShapeQuantifierCore.get("ROIComboBox")
        self.ROICheckBox = self.ShapeQuantifierCore.get("ROICheckBox")
        self.ROICheckBox.connect('stateChanged(int)',
                                 self.onROICheckBoxStateChanged)
        # ------------------------------------------------------------------------------------
        #                                  FIELD TABLE
        # ------------------------------------------------------------------------------------
        self.tableField = self.ShapeQuantifierCore.get("tableField")
        self.tableField.setColumnCount(2)
        self.tableField.setMinimumHeight(250)
        self.tableField.setHorizontalHeaderLabels([' ', ' Field Name '])
        self.tableField.setColumnWidth(0, 20)
        self.tableField.setColumnWidth(1, 260)
        self.tableField.setSizePolicy(qt.QSizePolicy().Expanding,
                                      qt.QSizePolicy().Expanding)
        # ------------------------------------------------------------------------------------
        #                                    RUN
        # ------------------------------------------------------------------------------------
        self.runButton = self.ShapeQuantifierCore.get("runButton")
        self.runButton.connect('clicked()', self.onRunButton)

        # ------------------------------------------------------------------------------------
        #                          Statistics Table - Export
        # ------------------------------------------------------------------------------------
        self.mainLayout = self.ShapeQuantifierCore.get("mainLayout")
        self.tabROI = qt.QTabWidget()
        self.tabROI.setTabPosition(0)
        self.tabROI.adjustSize()
        # ---------------------------- Directory - Export Button -----------------------------
        self.directoryExport = ctk.ctkDirectoryButton()
        self.exportCheckBox = qt.QCheckBox('Separate Files')
        self.exportCheckBox.setChecked(True)
        self.exportButton = qt.QPushButton(' Export ')
        self.exportButton.enabled = True
        self.exportPointValueCheckBox = qt.QCheckBox(
            'Export Value on Each Point')

        self.exportLayout = qt.QVBoxLayout()
        self.directoryAndExportLayout = qt.QHBoxLayout()
        self.directoryAndExportLayout.addWidget(self.directoryExport)
        self.directoryAndExportLayout.addWidget(self.exportCheckBox)
        self.directoryAndExportLayout.addWidget(self.exportPointValueCheckBox)
        self.exportButtonsLayout = qt.QHBoxLayout()
        self.exportButtonsLayout.addWidget(self.exportButton)

        self.exportLayout.addLayout(self.directoryAndExportLayout)
        self.exportLayout.addLayout(self.exportButtonsLayout)

        self.layout.addStretch(1)
        self.logic.updateInterface(self.tableField, self.ROIComboBox,
                                   self.ROIList, self.modelList,
                                   self.mainLayout)

        # ------------------------------------------------------------------------------------
        #                                   OBSERVERS
        # ------------------------------------------------------------------------------------

        slicer.mrmlScene.AddObserver(slicer.mrmlScene.EndCloseEvent,
                                     self.onCloseScene)
    def setup(self):
        self.dir = os.path.dirname(os.path.realpath(__file__))

        #
        # Setup
        #
        setupWindow = ctk.ctkCollapsibleButton()
        setupWindow.text = 'Setup'
        self.layout.addWidget(setupWindow)
        self.setupLayout = qt.QFormLayout(setupWindow)

        # Input box
        inputBox = ctk.ctkCollapsibleGroupBox()
        inputBox.setTitle('Input:')
        self.setupLayout.addRow(inputBox)
        self.inputBoxLayout = qt.QFormLayout(inputBox)

        # Bevel angle slider
        self.bevelAngleSlider = ctk.ctkSliderWidget()
        self.bevelAngleSlider.connect('valueChanged(double)', self.bevel_angle_changed)
        self.bevelAngleSlider.decimals = 0
        self.bevelAngleSlider.minimum = 0
        self.bevelAngleSlider.maximum = 360
        self.inputBoxLayout.addRow("Bevel Angle:", self.bevelAngleSlider)

        # R-Axis Entry Error
        self.entryErrR = qt.QLineEdit()
        self.entryErrR.setPlaceholderText("Enter length (mm)")
        self.inputBoxLayout.addRow("R-Axis Entry Error:", self.entryErrR)

        # A-Axis Entry Error
        self.entryErrA = qt.QLineEdit()
        self.entryErrA.setPlaceholderText("Enter length (mm)")
        self.inputBoxLayout.addRow("A-Axis Entry Error:", self.entryErrA)

        # S-Axis Entry Error
        self.entryErrS = qt.QLineEdit()
        self.entryErrS.setPlaceholderText("Enter length (mm)")
        self.inputBoxLayout.addRow("S-Axis Entry Error:", self.entryErrS)

        # Curve Radius
        self.curveRadius = qt.QLineEdit()
        self.curveRadius.setPlaceholderText("Enter length (mm)")
        self.inputBoxLayout.addRow("Curve Radius:", self.curveRadius)

        # Insertion Length
        self.insertionLength = qt.QLineEdit()
        self.insertionLength.setPlaceholderText("Enter length (mm)")
        self.inputBoxLayout.addRow("Insertion Length:", self.insertionLength)

        # Needle length in prostate
        self.len1 = qt.QLineEdit()
        self.len1.setPlaceholderText("Enter length (mm)")
        self.inputBoxLayout.addRow("Needle length in prostate:", self.len1)

        # Needle Length in pelvic diaphragm
        self.len2 = qt.QLineEdit()
        self.len2.setPlaceholderText("Enter length (mm)")
        self.inputBoxLayout.addRow("Needle length in pelvic diaphragm:", self.len2)

        # Needle length in bulbospongiosus
        self.len3 = qt.QLineEdit()
        self.len3.setPlaceholderText("Enter length (mm)")
        self.inputBoxLayout.addRow("Needle length in bulbospongiousus:", self.len3)

        # Needle length in ischiocavernosus
        self.len4 = qt.QLineEdit()
        self.len4.setPlaceholderText("Enter length (mm)")
        self.inputBoxLayout.addRow("Needle length in ischiocavernosus:", self.len4)

        # Needle length in unsegmented tissue
        self.len5 = qt.QLineEdit()
        self.len5.setPlaceholderText("Enter length (mm)")
        self.inputBoxLayout.addRow("Needle length in unsegmented tissue:", self.len5)

        # Calculate Error
        self.calculateError = qt.QPushButton("Calculate Error")
        self.calculateError.clicked.connect(self.run_regressions)
        self.setupLayout.addWidget(self.calculateError)

        # Disable calculation until data is entered
        self.calculateError.setEnabled(0)
        self.calculateError.setText('Enter all data first!')

        #
        # Output
        #
        outputWindow = ctk.ctkCollapsibleButton()
        outputWindow.text = 'Output'
        self.layout.addWidget(outputWindow)
        self.outputLayout = qt.QFormLayout(outputWindow)

        # Output box
        outputBoxCollapsible = ctk.ctkCollapsibleGroupBox()
        outputBoxCollapsible.setTitle('Output')
        self.outputLayout.addRow(outputBoxCollapsible)
        self.outputBox = qt.QFormLayout(outputBoxCollapsible)

        # Initial output text
        self.outputLabel = qt.QLabel("")
        self.outputBox.addRow(self.outputLabel)
        self.outputLabel.setText("The needle has a probability of 00.00% to hit the \ntarget, a probability of 00.00% "
                                 "to deflect to the right,\nand a probability of 00.00% to deflect to the top.")
        # Initial visual output
        image = qt.QPixmap(self.dir + "/NeedleDeviationPredictor GUI/empty.png")
        self.label1 = qt.QLabel("")

        # Scaling and sizing
        self.label1.setScaledContents(True)
        self.label1.setMargin(0)
        self.label1.setPixmap(image)
        qSize = qt.QSizePolicy()
        self.label1.setSizePolicy(qSize)
        self.outputBox.addRow(self.label1)

        # Vertical spacer
        self.layout.addStretch(1)

        # Check all entered values are floats
        values = [self.entryErrR, self.entryErrA, self.entryErrS, self.curveRadius,
                  self.insertionLength, self.len1, self.len2, self.len3, self.len4, self.len5]
        for value in values:
            value.textChanged.connect(self.check_inputs)
示例#7
0
    def setup(self):
        # Instantiate and connect widgets ...

        # reload button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadButton = qt.QPushButton("Reload")
        self.reloadButton.toolTip = "Reload this module."
        self.reloadButton.name = "MurineTrial Reload"
        self.layout.addWidget(self.reloadButton)
        self.reloadButton.connect('clicked()', self.onReload)

        # reload and test button
        # (use this during development, but remove it when delivering
        #  your module to users)
        self.reloadAndTestButton = qt.QPushButton("Reload and Test")
        self.reloadAndTestButton.toolTip = "Reload this module and then run the self tests."
        self.layout.addWidget(self.reloadAndTestButton)
        self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)

        # Collapsible button
        measurementsCollapsibleButton = ctk.ctkCollapsibleButton()
        measurementsCollapsibleButton.text = "Materials"
        self.layout.addWidget(measurementsCollapsibleButton)

        # Layout within the measurements collapsible button
        measurementsFormLayout = qt.QFormLayout(measurementsCollapsibleButton)

        # list of materials in the trial
        measurementsFormLayout.addWidget(qt.QLabel("Individual Segmentations"))
        self.materialsScrollArea = qt.QScrollArea()
        measurementsFormLayout.addWidget(self.materialsScrollArea)
        self.materialsListWidget = qt.QListWidget()
        self.materialsScrollArea.setWidget(self.materialsListWidget)
        self.materialsScrollArea.setWidgetResizable(True)
        self.materialsListWidget.setProperty(
            'SH_ItemView_ActivateItemOnSingleClick', 1)
        self.materialsListWidget.connect('activated(QModelIndex)',
                                         self.onMaterialActivated)
        # populate it
        materialKeys = self.logic.materials.keys()
        materialKeys.sort()
        for materialKey in materialKeys:
            self.materialsListWidget.addItem(materialKey)

        # list of sampleIDs in the trial
        measurementsFormLayout.addWidget(
            qt.QLabel("Segmentation Comparisions"))
        self.sampleIDsScrollArea = qt.QScrollArea()
        measurementsFormLayout.addWidget(self.sampleIDsScrollArea)
        self.sampleIDsListWidget = qt.QListWidget()
        self.sampleIDsScrollArea.setWidget(self.sampleIDsListWidget)
        self.sampleIDsScrollArea.setWidgetResizable(True)
        self.sampleIDsListWidget.setProperty(
            'SH_ItemView_ActivateItemOnSingleClick', 1)
        self.sampleIDsListWidget.connect('activated(QModelIndex)',
                                         self.onSampleIDActivated)
        # populate it
        for sampleID in self.logic.gigSegComparisonSampleIDs():
            self.sampleIDsListWidget.addItem(sampleID)

        # list of retestIDs in the trial
        measurementsFormLayout.addWidget(qt.QLabel("Repeatability Tests"))
        self.retestIDsScrollArea = qt.QScrollArea()
        measurementsFormLayout.addWidget(self.retestIDsScrollArea)
        self.retestIDsListWidget = qt.QListWidget()
        self.retestIDsScrollArea.setWidget(self.retestIDsListWidget)
        self.retestIDsScrollArea.setWidgetResizable(True)
        self.retestIDsListWidget.setProperty(
            'SH_ItemView_ActivateItemOnSingleClick', 1)
        self.retestIDsListWidget.connect('activated(QModelIndex)',
                                         self.onRetestActivated)
        # populate it
        for retestID in self.logic.retestComparisonSampleIDs():
            self.retestIDsListWidget.addItem(retestID)

        # process all  button
        processAllButton = qt.QPushButton("Process All")
        processAllButton.toolTip = "Loads all subjecs at all timepoints."
        measurementsFormLayout.addWidget(processAllButton)
        processAllButton.connect('clicked(bool)', self.logic.processAll)

        # results area
        self.resultsView = qt.QWebView()
        self.resultsView.minimumSize = qt.QSize(100, 100)
        policy = qt.QSizePolicy()
        policy.setHorizontalPolicy(qt.QSizePolicy.Ignored)
        self.resultsView.setSizePolicy(policy)
        self.layout.addWidget(self.resultsView)

        # Add vertical spacer
        self.layout.addStretch(1)
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        print("-------Mesh Statistic Widget Setup-------")
        # -------------------------------------------------------------------------------------
        self.modelList = list()
        self.fieldList = list()
        self.ROIList = list()
        self.ROIDict = dict()  # Key = Name of ROI
                               # Value = Dictionary of Fields (key = Name of Field
                               #                               Value = dictionary of shapes
                               #                                             key = name of shapes
                               #                                             value = Statistics store()

        self.logic = MeshStatisticsLogic(self)

        # ---------------------------------------------------------------- #
        # ---------------- Definition of the UI interface ---------------- #
        # ---------------------------------------------------------------- #

        # ------------ Loading of the .ui file ---------- #

        modulePath = os.path.dirname(slicer.util.modulePath(self.moduleName))
        path = os.path.join(modulePath, 'Resources', 'UI', '%s.ui' % self.moduleName)

        self.layout = self.parent.layout()
        self.widget = slicer.util.loadUI(path)
        self.layout.addWidget(self.widget)

        # ------------------------------------------------------------------------------------
        #                                    SHAPES INPUT
        # ------------------------------------------------------------------------------------
        self.inputComboBox = self.logic.get("inputComboBox")
        self.inputComboBox.setMRMLScene(slicer.mrmlScene)
        self.inputComboBox.connect('checkedNodesChanged()', self.onInputComboBoxCheckedNodesChanged)
        # ------------------------------------------------------------------------------------
        #                                  ROI TABLE
        # ------------------------------------------------------------------------------------
        self.ROIComboBox = self.logic.get("ROIComboBox")
        self.ROICheckBox = self.logic.get("ROICheckBox")
        self.ROICheckBox.connect('stateChanged(int)', self.onROICheckBoxStateChanged)
        # ------------------------------------------------------------------------------------
        #                                  FIELD TABLE
        # ------------------------------------------------------------------------------------
        self.tableField = self.logic.get("tableField")
        self.tableField.setColumnCount(2)
        self.tableField.setMinimumHeight(250)
        self.tableField.setHorizontalHeaderLabels([' ', ' Field Name '])
        self.tableField.setColumnWidth(0, 20)
        self.tableField.setColumnWidth(1, 260)
        self.tableField.setSizePolicy(qt.QSizePolicy().Expanding, qt.QSizePolicy().Expanding)
        # ------------------------------------------------------------------------------------
        #                                    RUN
        # ------------------------------------------------------------------------------------
        self.runButton = self.logic.get("runButton")
        self.runButton.connect('clicked()', self.onRunButton)

        # ------------------------------------------------------------------------------------
        #                          Statistics Table - Export
        # ------------------------------------------------------------------------------------
        self.mainLayout = self.logic.get("mainLayout")
        self.tabROI = qt.QTabWidget()
        self.tabROI.setTabPosition(0)
        self.tabROI.adjustSize()
        # ---------------------------- Directory - Export Button -----------------------------
        self.directoryExport = ctk.ctkDirectoryButton()
        self.exportCheckBox = qt.QCheckBox('Separate Files')
        self.exportCheckBox.setChecked(True)
        self.exportButton = qt.QPushButton(' Export ')
        self.exportButton.enabled = True
        self.exportPointValueCheckBox = qt.QCheckBox('Export Value on Each Point')
        
        self.exportLayout = qt.QVBoxLayout()
        self.directoryAndExportLayout = qt.QHBoxLayout()
        self.directoryAndExportLayout.addWidget(self.directoryExport)
        self.directoryAndExportLayout.addWidget(self.exportCheckBox)
        self.directoryAndExportLayout.addWidget(self.exportPointValueCheckBox)
        self.exportButtonsLayout = qt.QHBoxLayout()
        self.exportButtonsLayout.addWidget(self.exportButton)
        

        self.exportLayout.addLayout(self.directoryAndExportLayout)
        self.exportLayout.addLayout(self.exportButtonsLayout)
        
        self.layout.addStretch(1)
        self.logic.updateInterface(self.tableField, self.ROIComboBox, self.ROIList, self.modelList, self.mainLayout)

        # ------------------------------------------------------------------------------------
        #                                   OBSERVERS
        # ------------------------------------------------------------------------------------

        slicer.mrmlScene.AddObserver(slicer.mrmlScene.EndCloseEvent, self.onCloseScene)
示例#9
0
    def setup(self):
        self.developerMode = False
        ScriptedLoadableModuleWidget.setup(self)

        annotationsCollapsibleButton = ctk.ctkCollapsibleButton()
        annotationsCollapsibleButton.text = "Astro Annotations"
        self.layout.addWidget(annotationsCollapsibleButton)
        # Layout within the dummy collapsible button
        annotationsFormLayout = qt.QVBoxLayout(annotationsCollapsibleButton)

        # Color
        horizontalLayout_1 = qt.QHBoxLayout()
        horizontalLayout_1.setObjectName("horizontalLayout_1")

        self.colorLabel = qt.QLabel()
        self.colorLabel.setText("Annotations color:")
        self.colorLabel.setFixedSize(qt.QSize(120, 30))
        horizontalLayout_1.addWidget(self.colorLabel)

        self.colorSelector = ctk.ctkColorPickerButton()
        self.colorSelector.setObjectName("ColorPickerButton")
        sizePolicy = qt.QSizePolicy()
        sizePolicy.setHorizontalPolicy(qt.QSizePolicy.Expanding)
        sizePolicy.setVerticalPolicy(qt.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.colorSelector.sizePolicy.hasHeightForWidth())
        self.colorSelector.setSizePolicy(sizePolicy)
        self.colorSelector.setMinimumSize(qt.QSize(0, 30))
        self.colorSelector.setIconSize(qt.QSize(32, 32))
        self.colorSelector.setColor(qt.QColor(255, 187, 20))
        self.colorSelector.setDisplayColorName(0)
        horizontalLayout_1.addWidget(self.colorSelector)

        annotationsFormLayout.addLayout(horizontalLayout_1)

        # Font Style
        horizontalLayout_2 = qt.QHBoxLayout()
        horizontalLayout_2.setObjectName("horizontalLayout_2")

        self.fontStyleLabel = qt.QLabel()
        self.fontStyleLabel.setText("Font style:")
        self.fontStyleLabel.setFixedSize(qt.QSize(120, 30))
        horizontalLayout_2.addWidget(self.fontStyleLabel)

        self.styleComboBox = qt.QComboBox()
        self.styleComboBox.addItem("Arial")
        self.styleComboBox.addItem("Courier")
        self.styleComboBox.addItem("Times")
        sizePolicy.setHeightForWidth(
            self.styleComboBox.sizePolicy.hasHeightForWidth())
        self.styleComboBox.setMinimumSize(qt.QSize(0, 30))
        horizontalLayout_2.addWidget(self.styleComboBox)

        annotationsFormLayout.addLayout(horizontalLayout_2)

        # Font size
        horizontalLayout_3 = qt.QHBoxLayout()
        horizontalLayout_3.setObjectName("horizontalLayout_3")

        self.fontSizeLabel = qt.QLabel()
        self.fontSizeLabel.setText("Font size:")
        self.fontSizeLabel.setFixedSize(qt.QSize(120, 30))
        horizontalLayout_3.addWidget(self.fontSizeLabel)

        self.sizeSpinBox = qt.QSpinBox()
        sizePolicy.setHeightForWidth(
            self.sizeSpinBox.sizePolicy.hasHeightForWidth())
        self.sizeSpinBox.setMinimumSize(qt.QSize(0, 30))
        self.sizeSpinBox.minimum = 1
        self.sizeSpinBox.maximum = 30
        self.sizeSpinBox.setValue(12)
        self.sizeSpinBox.setToolTip(
            "This value is multiplied for 1.5 if the ruler is set to thick.")

        horizontalLayout_3.addWidget(self.sizeSpinBox)

        annotationsFormLayout.addLayout(horizontalLayout_3)

        verticalSpacer = qt.QSpacerItem(200, 200, qt.QSizePolicy.Minimum,
                                        qt.QSizePolicy.Expanding)
        self.layout.addItem(verticalSpacer)

        # Connections
        self.colorSelector.connect('colorChanged(QColor)',
                                   self.onAnnotationsColorChanged)

        self.styleComboBox.connect('currentTextChanged(QString)',
                                   self.onAnnotationsFontStyleChanged)

        self.sizeSpinBox.connect('valueChanged(int)',
                                 self.onAnnotationsFontSizeChanged)