コード例 #1
0
    def __init__(self, widget, parent=None, **kwargs):
        super().__init__(parent, **kwargs)
        self.widget = widget
        widget.setParent(self)

        self._scraper = None
        self._doc_thread = threading.Thread(target=self._create_scraper)
        self._doc_thread.start()

        output = qt.QTextEdit(parent=self)
        output.setReadOnly(True)
        clear_output = qt.QPushButton(parent=self,
                                      text='Clear',
                                      clicked=output.clear)
        clear_output.setAutoDefault(False)

        doc = qt.QTextEdit(parent=self)

        members = qt.QTreeWidget(parent=self)
        members.setHeaderHidden(True)
        members.itemClicked.connect(partial(self._show_doc, doc))
        self._populate_members(members, widget)

        HBox(
            self,
            margin=10,
            children=[
                # Left side
                VBox(children=[50, widget, 50, output, clear_output]),
                # Right side
                VBox(children=[members, doc])
            ])

        self._connect_widget_signals(output)
コード例 #2
0
ファイル: Home.py プロジェクト: phcerdan/SlicerSALT
    def setup(self):

        # TEXT
        text = """
<br>
<u>Workflow quick-reference:</u><br>
<br>
The drop-down Modules are ordered to follow the basic workflow for choosing and using data.  As a quick reference, the basic steps involve:<br>
<br>
&nbsp; 1. Use the <a href="#"><b>Data importer</b></a> module to load your segmentations from FreeSurf, FSL, Autoseg, or a bunch of vtp's<br><br>
&nbsp; 2. Use <a href="#"><b>Shape Population Viewer</b></a> to do a quality check on the imported data<br><br>
&nbsp; 3. Use <a href="#"><b>SPHARM Shape Analysis Module</b></a> to do spherical harmonics based analysis<br><br>
&nbsp; 4. Use the <a href="#"><b>Study-specific Shape Analysis</b></a> module.<br><br>
&nbsp; 5. Use the <a href="#"><b>S-Rep Shape Analysis</b></a> module to do shape analysis via skeletal representations.<br><br>
&nbsp; 6. Use the <a href="#"><b>Shape Evaluator</b></a> module to compute a mean shape and see how the population varies.<br><br>
&nbsp; 7. Use <a href="#"><b>Shape Regressions</b></a> module to do regression based analysis.<br><br>
&nbsp; 8. Use the <a href="#"><b>Shape Statistics</b></a> module.<br><br>
"""

        # TEXTEDIT
        self.HomeTextSection = qt.QTextEdit()
        self.HomeTextSection.setReadOnly(True)
        self.HomeTextSection.setText(text)
        self.HomeTextSection.setMinimumHeight(400)
        self.HomeTextSection.connect('cursorPositionChanged()', self.slot)
        self.layout.addWidget(self.HomeTextSection)

        # SPACER
        self.layout.addStretch()
コード例 #3
0
ファイル: SampleData.py プロジェクト: viboen/Slicer
    def setup(self):
        samples = (
            ('MRHead', self.logic.downloadMRHead),
            ('CTChest', self.logic.downloadCTChest),
            ('CTACardio', self.logic.downloadCTACardio),
            ('DTIBrain', self.logic.downloadDTIBrain),
            ('MRBrainTumor Time Point 1', self.logic.downloadMRBrainTumor1),
            ('MRBrainTumor Time Point 2', self.logic.downloadMRBrainTumor2),
            ('Baseline Volume',
             self.logic.downloadWhiteMatterExplorationBaselineVolume),
            ('DTI Volume', self.logic.downloadWhiteMatterExplorationDTIVolume),
            ('DWI Volume', self.logic.downloadDiffusionMRIDWIVolume),
            ('CTAbdomen', self.logic.downloadAbdominalCTVolume),
            ('CBCTDentalSurgery', self.logic.downloadDentalSurgery),
        )
        for sample in samples:
            b = qt.QPushButton('Download %s' % sample[0])
            b.setObjectName('%sPushButton' % sample[0].replace(' ', ''))
            self.layout.addWidget(b)
            b.connect('clicked()', sample[1])

        self.log = qt.QTextEdit()
        self.log.readOnly = True
        self.layout.addWidget(self.log)
        self.logMessage('<p>Status: <i>Idle</i>\n')

        # Add spacer to layout
        self.layout.addStretch(1)
    def __init__(self, parent):
        vLayout = qt.QVBoxLayout(parent)
        formLayout = qt.QFormLayout()

        self.nameEdit = qt.QLineEdit()
        formLayout.addRow("Name:", self.nameEdit)

        self.categoryEdit = qt.QLineEdit()
        formLayout.addRow("Category:", self.categoryEdit)

        self.descriptionEdit = qt.QTextEdit()
        self.descriptionEdit.acceptRichText = False
        formLayout.addRow("Description:", self.descriptionEdit)

        self.contributorsList = EditableTreeWidget()
        self.contributorsList.rootIsDecorated = False
        self.contributorsList.selectionBehavior = qt.QAbstractItemView.SelectRows
        self.contributorsList.selectionMode = qt.QAbstractItemView.ExtendedSelection
        self.contributorsList.setHeaderLabels(["Name", "Organization"])
        formLayout.addRow("Contributors:", self.contributorsList)

        vLayout.addLayout(formLayout)
        vLayout.addStretch(1)

        self.buttonBox = qt.QDialogButtonBox()
        self.buttonBox.setStandardButtons(qt.QDialogButtonBox.Ok
                                          | qt.QDialogButtonBox.Cancel)
        vLayout.addWidget(self.buttonBox)
コード例 #5
0
    def setup(self):

        categories = slicer.modules.sampleDataSources.keys()
        categories.sort()
        if 'BuiltIn' in categories:
            categories.remove('BuiltIn')
        categories.insert(0, 'BuiltIn')
        for category in categories:
            frame = ctk.ctkCollapsibleGroupBox(self.parent)
            self.layout.addWidget(frame)
            frame.title = category
            frame.name = '%sCollapsibleGroupBox' % category
            layout = qt.QVBoxLayout(frame)
            for source in slicer.modules.sampleDataSources[category]:
                name = source.sampleName
                if not name:
                    name = source.nodeNames[0]
                b = qt.QPushButton('Download %s' % name)
                b.name = '%sPushButton' % name
                layout.addWidget(b)
                if source.customDownloader:
                    b.connect('clicked()', source.customDownloader)
                else:
                    b.connect(
                        'clicked()',
                        lambda s=source: self.logic.downloadFromSource(s))

        self.log = qt.QTextEdit()
        self.log.readOnly = True
        self.layout.addWidget(self.log)
        self.logMessage('<p>Status: <i>Idle</i>\n')

        # Add spacer to layout
        self.layout.addStretch(1)
コード例 #6
0
ファイル: PerformanceTests.py プロジェクト: Leengit/Slicer
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        tests = (
            ('Get Sample Data', self.downloadMRHead),
            ('Reslicing', self.reslicing),
            ('Crosshair Jump', self.crosshairJump),
            ('Web View Test', self.webViewTest),
            ('Fill Out Web Form Test', self.webViewFormTest),
            ('Memory Check', self.memoryCheck),
        )

        for test in tests:
            b = qt.QPushButton(test[0])
            self.layout.addWidget(b)
            b.connect('clicked()', test[1])

        self.log = qt.QTextEdit()
        self.log.readOnly = True
        self.layout.addWidget(self.log)
        self.log.insertHtml('<p>Status: <i>Idle</i>\n')
        self.log.insertPlainText('\n')
        self.log.ensureCursorVisible()

        # Add spacer to layout
        self.layout.addStretch(1)
コード例 #7
0
    def setup(self):

        # TEXT
        text = """
<br>
<u>Workflow quick-reference:</u><br>
<br>
The drop-down Modules are ordered to follow the basic workflow for processing DICOMS from conventional imaging modalities which are then used in optical image reconstruction.  As a quick reference, the basic steps involve:<br>
<br>
&nbsp; 1. Use the <a href="#"><b>DICOM</b></a> module to load your MRI/CT/US DICOMS<br><br>
&nbsp; 2. Use <a href="#"><b>Volume Rendering</b></a> to view a 3D rendering of your DICOM images<br><br>
&nbsp; 3. <a href="#"><b>Crop</b></a> the image volume to the tissue region of interest for which you will reconstruct optical images.<br><br>
&nbsp; 4. Use the <a href="#"><b>Segment Editor</b></a> module to segment the tissue into different tissue types which can guide the optical image reconstruction routines<br><br>
&nbsp; 5. Use the <a href="#"><b>Markups</b></a> module to place optical source and detector positions.<br><br>
&nbsp; 6. Use the <a href="#"><b>Create Mesh</b></a> module to generate a NIRFAST-compatible mesh from the segmented tissue (label maps)<br><br>
&nbsp; 7. After creating the mesh, follow tutorials on reconstructing optical images in the NIRFAST Matlab window<br><br>
&nbsp; 8. Once optical properties have been reconstructed, open the resulting volumetric mesh in NIRFAST-Slicer and use the <a href="#"><b>Models</b></a> module to visualize the data overlaid on the original DICOM: in the Display menu, check 'Slice Intersections Visible' from the Visibility submenu, and select the parameters to display in the Scalars submenu.<br>
"""

        # TEXTEDIT
        self.HomeTextSection = qt.QTextEdit()
        self.HomeTextSection.setReadOnly(True)
        self.HomeTextSection.setText(text)
        self.HomeTextSection.setMinimumHeight(400)
        self.HomeTextSection.connect('cursorPositionChanged()', self.slot)
        self.layout.addWidget(self.HomeTextSection)

        # SPACER
        self.layout.addStretch()
コード例 #8
0
    def __init__(self, parent=None, name=None, fl=0):
        qt.QWidget.__init__(self, parent, name, fl)

        # AsyncResult to return values
        self._async_result = None

        # Layout
        qt.QVBoxLayout(self)
        main_layout = self.layout()
        main_layout.setSpacing(10)
        main_layout.setMargin(6)
        self.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding)

        self.setCaption("GPhL Workflow parameters")

        # Info box
        self.info_gbox = qt.QVGroupBox("Info", self, "info_gbox")
        main_layout.addWidget(self.info_gbox)
        self.info_text = qt.QTextEdit(self.info_gbox, "info_text")
        self.info_text.setTextFormat(0)  # PlainText
        self.info_text.setFont(qt.QFont("Courier"))
        self.info_text.setReadOnly(True)

        # Special parameter box
        self.cplx_gbox = qt.QVGroupBox("Indexing solution", self, "cplx_gbox")
        main_layout.addWidget(self.cplx_gbox)
        self.cplx_widget = None

        # Parameter box
        self.parameter_gbox = qt.QVGroupBox("Parameters", self,
                                            "parameter_gbox")
        main_layout.addWidget(self.parameter_gbox)
        self.params_widget = None

        # Button bar
        button_layout = qt.QHBoxLayout(None, 0, 6, "button_layout")
        hspacer = qt.QSpacerItem(1, 20, qt.QSizePolicy.Expanding,
                                 qt.QSizePolicy.Minimum)
        button_layout.addItem(hspacer)
        self.continue_button = qt.QPushButton("Continue", self,
                                              "continue_button")
        button_layout.addWidget(self.continue_button)
        self.cancel_button = qt.QPushButton("Abort", self, "cancel_button")
        button_layout.addWidget(self.cancel_button)
        main_layout.addLayout(button_layout)

        qt.QObject.connect(self.continue_button, qt.SIGNAL("clicked()"),
                           self.continue_button_click)

        qt.QObject.connect(self.cancel_button, qt.SIGNAL("clicked()"),
                           self.cancel_button_click)

        self.resize(qt.QSize(1018, 472).expandedTo(self.minimumSizeHint()))
        self.clearWState(qt.Qt.WState_Polished)
コード例 #9
0
    def __init__(self, parent=None, name="log_bar_widget", fl=0):
        qt.QWidget.__init__(self, parent, name, fl)

        self.text_edit = qt.QTextEdit(self, "text_edit")
        self.text_edit.setMinimumSize(qt.QSize(0, 55))
        self.text_edit.setMaximumSize(qt.QSize(32767, 55))
        self.text_edit.setTextFormat(qt.QTextEdit.RichText)
        self.text_edit.setReadOnly(True)

        main_layout = qt.QHBoxLayout(self)
        main_layout.addWidget(self.text_edit)
コード例 #10
0
    def __init__(self):

        self.ArduinoNode = slicer.mrmlScene.GetFirstNodeByName("arduinoNode")
        sceneModifiedObserverTag = self.ArduinoNode.AddObserver(
            vtk.vtkCommand.ModifiedEvent, self.addLine)

        self.monitor = qt.QTextEdit()
        self.monitor.setWindowTitle("Arduino monitor")
        self.monitor.setReadOnly(True)
        self.monitor.show()

        self.messageLenghtLimit = 50
コード例 #11
0
    def updateSampleDataTab(self, moduleName):
        currentSampleDataLogic = slicer.modules.sampledata.widgetRepresentation(
        ).self().logic
        categoryLayout = self.sampleDataModuleTab.layout()
        tutorialTextBrowser = ctk.ctkFittedTextBrowser()
        tutorialTextBrowser.frameShape = qt.QFrame.NoFrame
        tutorialTextBrowser.openExternalLinks = True
        if moduleName == "Home":
            # Tutorial link
            tutorialHtml = \
                "See <a href=\"https://salt.slicer.org/documentation/\">https://salt.slicer.org/documentation/</a> " \
                "for overall documentation.<br/>" \
                "<br/>" \
                "Module specific tutorials and associated data are available in the Tutorials tab specific to each module."
            # SampleData
            SampleDataWidget.setCategoriesFromSampleDataSources(
                categoryLayout, {}, currentSampleDataLogic)
        else:
            # Tutorial link
            if moduleName in self.tutorials:
                tutorialHtml = "Click <a href=\"%s\">here</a> to read tutorial. <br/>" % self.tutorials[
                    moduleName]
            else:
                tutorialHtml = \
                  "There is no tutorial for this module. " \
                  "Consider asking questions on the <a href=\"https://discourse.slicer.org/c/community/slicer-salt\">SlicerSALT forum</a>. <br/>"
            # SampleData
            if moduleName not in self.moduleNameToSampleDataCategory:
                SampleDataWidget.setCategoriesFromSampleDataSources(
                    categoryLayout, {}, currentSampleDataLogic)
                tutorialHtml += \
                    "<br/>" \
                    "There is no SampleData available for this module. <br/>"
            else:
                category = self.moduleNameToSampleDataCategory[moduleName]
                sources = {
                    category: slicer.modules.sampleDataSources[category]
                }
                SampleDataWidget.setCategoriesFromSampleDataSources(
                    categoryLayout, sources, currentSampleDataLogic)
                tutorialHtml += ""
            # Download status
            log = qt.QTextEdit()
            log.readOnly = True
            categoryLayout.addWidget(log)
            log.insertHtml('<p>Status: <i>Idle</i></p>')
            self.sampleDataTabTextEdit = log

        tutorialTextBrowser.setHtml(tutorialHtml)
        categoryLayout.insertWidget(0, tutorialTextBrowser)
コード例 #12
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # This module is often used in developer mode, therefore
        # collapse reload & test section by default.
        if hasattr(self, "reloadCollapsibleButton"):
            self.reloadCollapsibleButton.collapsed = True

        self.observerTags = []
        self.logic = SampleDataLogic(self.logMessage)

        categories = slicer.modules.sampleDataSources.keys()
        categories.sort()
        if 'BuiltIn' in categories:
            categories.remove('BuiltIn')
        categories.insert(0, 'BuiltIn')
        for category in categories:
            frame = ctk.ctkCollapsibleGroupBox(self.parent)
            self.layout.addWidget(frame)
            frame.title = category
            frame.name = '%sCollapsibleGroupBox' % category
            layout = qt.QVBoxLayout(frame)
            for source in slicer.modules.sampleDataSources[category]:
                name = source.sampleName
                if not name:
                    name = source.nodeNames[0]
                b = qt.QPushButton('Download %s' % name)
                b.name = '%sPushButton' % name
                layout.addWidget(b)
                if source.customDownloader:
                    b.connect('clicked()', source.customDownloader)
                else:
                    b.connect(
                        'clicked()',
                        lambda s=source: self.logic.downloadFromSource(s))

        self.log = qt.QTextEdit()
        self.log.readOnly = True
        self.layout.addWidget(self.log)
        self.logMessage('<p>Status: <i>Idle</i>\n')

        # Add spacer to layout
        self.layout.addStretch(1)
コード例 #13
0
    def setup(self):
        samples = (
            ('MRHead', self.downloadMRHead),
            ('CTChest', self.downloadCTChest),
            ('CTACardio', self.downloadCTACardio),
            ('DTIBrain', self.downloadDTIBrain),
            ('MRBrainTumor Time Point 1', self.downloadMRBrainTumor1),
            ('MRBrainTumor Time Point 2', self.downloadMRBrainTumor2),
        )
        for sample in samples:
            b = qt.QPushButton('Download %s' % sample[0])
            self.layout.addWidget(b)
            b.connect('clicked()', sample[1])

        self.log = qt.QTextEdit()
        self.log.readOnly = True
        self.layout.addWidget(self.log)
        self.logMessage('<p>Status: <i>Idle</i>\n')

        # Add spacer to layout
        self.layout.addStretch(1)
コード例 #14
0
ファイル: WebServer.py プロジェクト: Leengit/Slicer
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # start button
        self.startServerButton = qt.QPushButton("Start server")
        self.startServerButton.name = "StartWebServer"
        self.startServerButton.toolTip = "Start web server with the selected options."
        self.layout.addWidget(self.startServerButton)

        # stop button
        self.stopServerButton = qt.QPushButton("Stop server")
        self.stopServerButton.name = "StopWebServer"
        self.stopServerButton.toolTip = "Start web server with the selected options."
        self.layout.addWidget(self.stopServerButton)

        # open browser page
        self.localConnectionButton = qt.QPushButton(
            "Open static pages in external browser")
        self.localConnectionButton.toolTip = "Open a connection to the server on the local machine with your system browser."
        self.layout.addWidget(self.localConnectionButton)

        # open slicer widget
        self.localQtConnectionButton = qt.QPushButton(
            "Open static pages in internal browser")
        self.localQtConnectionButton.toolTip = "Open a connection with Qt to the server on the local machine."
        self.layout.addWidget(self.localQtConnectionButton)

        # log window
        self.log = qt.QTextEdit()
        self.log.setSizePolicy(qt.QSizePolicy.Expanding,
                               qt.QSizePolicy.Expanding)
        self.log.readOnly = True
        self.layout.addWidget(self.log)
        self.logMessage('<p>Status: <i>Idle</i>\n')

        # clear log button
        self.clearLogButton = qt.QPushButton("Clear Log")
        self.clearLogButton.toolTip = "Clear the log window."
        self.layout.addWidget(self.clearLogButton)

        # TODO: warning dialog on first connect
        # TODO: config option for port
        # TODO: config option for optional plugins
        # TODO: config option for certfile (https)

        self.advancedCollapsibleButton = ctk.ctkCollapsibleButton()
        self.advancedCollapsibleButton.text = "Advanced"
        self.layout.addWidget(self.advancedCollapsibleButton)
        advancedFormLayout = qt.QFormLayout(self.advancedCollapsibleButton)
        self.advancedCollapsibleButton.collapsed = True

        # handlers

        self.enableSlicerHandler = qt.QCheckBox()
        self.enableSlicerHandler.toolTip = "Enable remote control of Slicer application (stop server to change option)"
        advancedFormLayout.addRow('Slicer API: ', self.enableSlicerHandler)

        self.enableSlicerHandlerExec = qt.QCheckBox()
        self.enableSlicerHandlerExec.toolTip = "Enable execution of arbitrary Python command using Slicer API. It only has effect if Slicer API is enabled, too (stop server to change option)."
        advancedFormLayout.addRow('Slicer API exec: ',
                                  self.enableSlicerHandlerExec)

        self.enableDICOMHandler = qt.QCheckBox()
        self.enableDICOMHandler.toolTip = "Enable serving Slicer DICOM database content via DICOMweb (stop server to change option)"
        if hasattr(slicer.modules, "dicom"):
            advancedFormLayout.addRow('DICOMweb API: ',
                                      self.enableDICOMHandler)

        self.enableStaticPagesHandler = qt.QCheckBox()
        self.enableStaticPagesHandler.toolTip = "Enable serving static pages (stop server to change option)"
        advancedFormLayout.addRow('Static pages: ',
                                  self.enableStaticPagesHandler)

        # log to console
        self.logToConsole = qt.QCheckBox()
        self.logToConsole.toolTip = "Copy log messages to the python console and parent terminal (disable to improve performance)"
        advancedFormLayout.addRow('Log to Console: ', self.logToConsole)

        # log to GUI
        self.logToGUI = qt.QCheckBox()
        self.logToGUI.toolTip = "Copy log messages to the log widget (disable to improve performance)"
        advancedFormLayout.addRow('Log to GUI: ', self.logToGUI)

        # Initialize GUI
        self.updateGUIFromSettings()
        self.updateGUIFromLogic()

        # Connections
        self.startServerButton.connect('clicked(bool)', self.startServer)
        self.stopServerButton.connect('clicked(bool)', self.stopServer)
        self.enableSlicerHandler.connect('clicked()',
                                         self.updateHandlersFromGUI)
        self.enableSlicerHandlerExec.connect('clicked()',
                                             self.updateHandlersFromGUI)
        self.enableDICOMHandler.connect('clicked()',
                                        self.updateHandlersFromGUI)
        self.enableStaticPagesHandler.connect('clicked()',
                                              self.updateHandlersFromGUI)
        self.localConnectionButton.connect('clicked()',
                                           self.openLocalConnection)
        self.localQtConnectionButton.connect('clicked()',
                                             self.openQtLocalConnection)
        self.clearLogButton.connect('clicked()', self.log.clear)
        self.logToConsole.connect('clicked()', self.updateLoggingFromGUI)
        self.logToGUI.connect('clicked()', self.updateLoggingFromGUI)

        self.updateLoggingFromGUI()
コード例 #15
0
  def setup(self):
    ScriptedLoadableModuleWidget.setup(self)
    self.logic = WebSocketLogic(self)

    # Websocket
    self.host = "localhost"
    self.port = 8180
    self.socket = None



    # Instantiate and connect widgets ...
    #
    # Parameters Area
    #
    websocketCollapsibleButton = ctk.ctkCollapsibleButton()
    websocketCollapsibleButton.text = "Websocket"
    self.layout.addWidget(websocketCollapsibleButton)

    # Layout within the dummy collapsible button
    parametersFormLayout = qt.QFormLayout(websocketCollapsibleButton)

    #
    # Apply Button
    #
    self.connectButton = qt.QPushButton("Connect")
    self.connectButton.toolTip = "Run the algorithm."
    parametersFormLayout.addRow(self.connectButton)

    #
    # Disconnect Button
    #
    self.disconnectButton = qt.QPushButton("Disconnect")
    parametersFormLayout.addRow(self.disconnectButton)

    #
    # Python Console
    #
    self.pythonConsole = qt.QTextEdit()
    self.pythonConsole.readOnly = True
    parametersFormLayout.addRow(self.pythonConsole)

    # connections
    self.connectButton.connect('clicked(bool)', self.onConnectButton)
    self.disconnectButton.connect('clicked(bool)', self.onDisconnectButton)
    # self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
    # self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)

    # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # =-=-=-=-=-=-=-=-=-= QT SOCKET =-=-=-=-=-=-=-=-=-=
    # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # Doc: http://pyqt.sourceforge.net/Docs/PyQt4/qabstractsocket.html

    self.socket = qt.QTcpSocket()
    self.socket.connect('connected()', self.on_connect)
    self.socket.connect('disconnected()', self.on_disconnect)
    self.socket.connect('hostFound()', self.on_hostFound)
    self.socket.connect('readyRead()', self.handleRead)

    # Need to be fixed
    self.socket.connect("error( ::QAbstractSocket::SocketError)", self.on_error)
    # self.socket.connect('bytesWritten()', self.on_written)

    # Add vertical spacer
    self.layout.addStretch(1)
コード例 #16
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.logic = PFileParserLogic()

        # Instantiate and connect widgets ...

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

        # Layout within the dummy collapsible button
        parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)

        #
        # input volume selector
        #
        self.inputSelector = slicer.qMRMLNodeComboBox()
        self.inputSelector.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.inputSelector.selectNodeUponCreation = True
        self.inputSelector.addEnabled = False
        self.inputSelector.removeEnabled = False
        self.inputSelector.noneEnabled = False
        self.inputSelector.showHidden = False
        self.inputSelector.showChildNodeTypes = False
        self.inputSelector.setMRMLScene(slicer.mrmlScene)
        self.inputSelector.setToolTip("Pick the input to the algorithm.")
        parametersFormLayout.addRow("Input Volume: ", self.inputSelector)

        # %%%%%%%%%%%%%%%  Read PFile button section %%%%%%%%%%%%%%

        # Collapsible bar
        pCollapsibleBar = ctk.ctkCollapsibleButton()
        pCollapsibleBar.text = "fMRSI data"
        self.layout.addWidget(pCollapsibleBar)

        # Layout within the sample collapsible button
        formLayout = qt.QFormLayout(pCollapsibleBar)

        # Frame input edit sub-layout
        frameLayout = qt.QHBoxLayout(pCollapsibleBar)

        pStartAtFrameText = self.createFrameText(
            frameLayout, "From frame: ", 100,
            "First frame to be read from fMRSI file (1 = first).")

        # Add spacer
        frameLayout.addStretch(1)

        # Text input frame end
        pStopAtFrameText = self.createFrameText(
            frameLayout, "To frame: ", 100,
            "Last frame to be read from fMRSI file.")

        # Add horizontal frame to form layout
        formLayout.addRow(frameLayout)

        # ============== Buttons ==============
        # Button widget code
        pFileButton = qt.QPushButton("Read PFile...")
        pFileButton.toolTip = "Load raw PFile (.7) data"
        pFileButton.enabled = False
        formLayout.addRow(pFileButton)

        # =============== Radio Buttons ========
        self.units = ("ppm", "hz", "points")

        pUnitsBox = qt.QGroupBox("Units")
        pUnitsBox.enabled = False
        pUnitsBox.setLayout(qt.QFormLayout())
        pUnitsButtons = {}
        for units in self.units:
            pUnitsButtons[units] = qt.QRadioButton()
            pUnitsButtons[units].text = units
            pUnitsBox.layout().addRow(pUnitsButtons[units])

        self.selectedUnits = self.units[0]
        pUnitsButtons[self.selectedUnits].checked = True
        formLayout.addRow(pUnitsBox)

        # =============== Sliders ==============

        # Frame slider
        pFrameSlider = ctk.ctkSliderWidget()
        pFrameSlider.decimals = 0
        pFrameSlider.minimum = 1
        pFrameSlider.maximum = 1
        pFrameSlider.enabled = False
        formLayout.addRow("Frame:", pFrameSlider)

        # X axis Slider
        pXAxisRange = ctk.ctkRangeWidget()
        pXAxisRange.enabled = False
        pXAxisRange.minimum = 0.0
        pXAxisRange.maximum = 0.0

        formLayout.addRow("X axis range:", pXAxisRange)

        # Button widget code
        pPlotSpectrumButton = qt.QPushButton("Plot Spectrum...")
        pPlotSpectrumButton.toolTip = "Plot mean single voxel spectrum from PFile (.7) data"
        pPlotSpectrumButton.enabled = False
        formLayout.addRow(pPlotSpectrumButton)

        # ============== Info Text ==============
        # Text Info
        pInfoText = qt.QTextEdit()
        pInfoText.setReadOnly(True)
        pInfoText.setToolTip("Data read from fMRSI file.")
        formLayout.addRow(pInfoText)

        # connections
        pFileButton.connect('clicked(bool)', self.onPFileButtonClicked)
        pPlotSpectrumButton.connect('clicked(bool)',
                                    self.onPlotSpectrumButtonClicked)
        self.inputSelector.connect('currentNodeChanged(vtkMRMLNode*)',
                                   self.onSelect)

        for units in self.units:
            pUnitsButtons[units].connect(
                'clicked()', lambda u=units: self.onPUnitsButtonsClicked(u))

        # Set local var as instance attribute
        self.pFileButton = pFileButton
        self.pPlotSpectrumButton = pPlotSpectrumButton
        self.pInfoText = pInfoText
        self.pStartAtFrameText = pStartAtFrameText
        self.pStopAtFrameText = pStopAtFrameText
        self.pFrameSlider = pFrameSlider
        self.pXAxisRange = pXAxisRange
        self.pUnitsBox = pUnitsBox
        self.pUnitsButtons = pUnitsButtons

        # Add spacer
        self.layout.addStretch(1)

        # Refresh button status
        self.onSelect()
コード例 #17
0
ファイル: logconsole.py プロジェクト: bopopescu/faraday-1
 def __init__(self, parent, caption=""):
     qt.QVBox.__init__(self, parent)
     self.setName(caption)
     self._text_edit = qt.QTextEdit(self, caption)
     self._text_edit.setTextFormat(qt.Qt.LogText)
コード例 #18
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        self.caseInfoCollapsibleButton = ctk.ctkCollapsibleButton()
        self.caseInfoCollapsibleButton.text = "Case information"
        self.caseInfoCollapsibleButton.collapsed = False
        self.layout.addWidget(self.caseInfoCollapsibleButton)
        self.caseAreaLayout = qt.QGridLayout(self.caseInfoCollapsibleButton)
        # Select case
        row = 0
        self.loadCaseButton = ctk.ctkPushButton()
        self.loadCaseButton.text = "Load case"
        self.loadCaseButton.toolTip = "Load a case folder"
        self.caseAreaLayout.addWidget(self.loadCaseButton, row, 0)

        # Reset button
        self.resetButton = ctk.ctkPushButton()
        self.resetButton.text = "Close case"
        self.resetButton.toolTip = "Close the current case"
        self.caseAreaLayout.addWidget(self.resetButton, row, 1)

        # Case info
        row += 1
        self.caseInfoFrame = qt.QFrame()
        self.caseInfoFrame.setFrameStyle(0x0002 | 0x0010)
        self.caseInfoFrame.lineWidth = 2
        self.caseInfoFrame.setStyleSheet(
            "background-color: #EEEEEE; margin: 10px")
        self.caseAreaLayout.addWidget(self.caseInfoFrame, row, 0, 1, 2)

        self.caseInfoFrameLayout = qt.QGridLayout()
        self.caseInfoFrame.setLayout(self.caseInfoFrameLayout)

        self.caseIdLabel = qt.QLabel("Case id: ")
        self.caseIdLabel.setStyleSheet("font-weight: bold")
        self.caseInfoFrameLayout.addWidget(self.caseIdLabel, 0, 0)

        self.showEnhancementCheckboxGroup = qt.QButtonGroup()
        self.showJustOriginalButton = qt.QRadioButton("Original only")
        self.showJustOriginalButton.setChecked(True)
        self.showEnhancementCheckboxGroup.addButton(
            self.showJustOriginalButton, 0)
        self.caseInfoFrameLayout.addWidget(self.showJustOriginalButton, 1, 0)

        self.showOriginalPlusEnhancedButton = qt.QRadioButton(
            "Original and enhanced")
        self.showEnhancementCheckboxGroup.addButton(
            self.showOriginalPlusEnhancedButton, 1)
        self.caseInfoFrameLayout.addWidget(self.showOriginalPlusEnhancedButton,
                                           2, 0)

        self.showJustEnhancedButton = qt.QRadioButton("Enhanced only")
        self.showEnhancementCheckboxGroup.addButton(
            self.showJustEnhancedButton, 2)
        self.caseInfoFrameLayout.addWidget(self.showJustEnhancedButton, 3, 0)

        # Center Volumes button
        self.centerVolumesButton = ctk.ctkPushButton()
        self.centerVolumesButton.text = "Center image/s"
        self.centerVolumesButton.toolTip = "Center all the current visible images"
        self.centerVolumesButton.setFixedWidth(200)
        # self.centerVolumesButton.toolTip = "Load a case folder"
        self.caseInfoFrameLayout.addWidget(self.centerVolumesButton, 4, 0)

        # Enhancement fine tuning
        self.vascularFactorLabel = qt.QLabel("Vascular factor")
        self.vascularFactorLabel.setStyleSheet("font-weight: bold")
        self.caseInfoFrameLayout.addWidget(self.vascularFactorLabel, 0, 1)
        self.vascularFactorSlider = qt.QSlider()
        self.vascularFactorSlider.orientation = 2  # Vertical
        self.vascularFactorSlider.value = 5
        self.vascularFactorSlider.minimum = 0
        self.vascularFactorSlider.maximum = 10
        # self.vascularFactorSlider.setStyleSheet("margin-top:10px;padding-top:20px")
        # self.vascularFactorSlider.setToolTip("Move the slider for a fine tuning segmentation")
        self.caseInfoFrameLayout.addWidget(self.vascularFactorSlider, 1, 1, 4,
                                           1, 0x0004)

        self.enhancementFactorLabel = qt.QLabel("Enhancement factor")
        self.enhancementFactorLabel.setStyleSheet("font-weight: bold")
        self.caseInfoFrameLayout.addWidget(self.enhancementFactorLabel, 0, 2)
        self.enhancementFactorSlider = qt.QSlider()
        self.enhancementFactorSlider.orientation = 2  # Vertical
        self.enhancementFactorSlider.minimum = 0
        self.enhancementFactorSlider.maximum = 10
        self.enhancementFactorSlider.value = 5
        # self.vascularFactorSlider.setStyleSheet("margin-top:10px;padding-top:20px")
        # self.vascularFactorSlider.setToolTip("Move the slider for a fine tuning segmentation")
        self.caseInfoFrameLayout.addWidget(self.enhancementFactorSlider, 1, 2,
                                           4, 1, 0x0004)

        # Editor
        row += 1
        self.editorWidget = ui.CustomEditorWidget(self.parent)
        self.editorWidget.setup()
        self.editorCollapsibleButton = self.editorWidget.editLabelMapsFrame
        self.editorCollapsibleButton.text = "Edit the current eye image"
        self.editorCollapsibleButton.collapsed = False
        self.editorWidget.toolsColor.terminologyCollapsibleButton.setVisible(
            False)
        self.layout.addWidget(self.editorCollapsibleButton)

        ### DIAGNOSIS
        self.diagnosisCollapsibleButton = ctk.ctkCollapsibleButton()
        self.diagnosisCollapsibleButton.text = "Diagnosis"
        self.diagnosisCollapsibleButton.collapsed = False
        self.layout.addWidget(self.diagnosisCollapsibleButton)
        self.diagnosisAreaLayout = qt.QVBoxLayout(
            self.diagnosisCollapsibleButton)

        # Visual Acuity
        label = qt.QLabel("Visual acuity (VA): ")
        label.setStyleSheet("margin: 10px 0 0 10px; font-weight: bold")
        self.diagnosisAreaLayout.addWidget(label)
        self.vaFrame = qt.QFrame()
        self.vaFrame.setFrameStyle(0x0002 | 0x0010)
        self.vaFrame.lineWidth = 2
        self.vaFrame.setStyleSheet("background-color: #EEEEEE; margin: 10px")
        self.vaFrame.setFixedWidth(240)
        self.diagnosisAreaLayout.addWidget(self.vaFrame)

        self.vaFrameLayout = qt.QGridLayout(self.vaFrame)
        self.vaFrameLayout.addWidget(qt.QLabel("OS"), 0, 0)
        self.osLineEdit = qt.QLineEdit()
        self.osLineEdit.setFixedWidth(80)
        self.osLineEdit.setStyleSheet("background-color: white")
        self.vaFrameLayout.addWidget(self.osLineEdit, 0, 1)

        self.vaFrameLayout.addWidget(qt.QLabel("OD"), 1, 0)
        self.odLineEdit = qt.QLineEdit()
        self.odLineEdit.setFixedWidth(80)
        self.odLineEdit.setStyleSheet("background-color: white")
        self.vaFrameLayout.addWidget(self.odLineEdit, 1, 1)

        self.vaModalityButtonGroup = qt.QButtonGroup()
        self.scvaRadioButton = qt.QRadioButton()
        self.scvaRadioButton.setText("SCVA")
        self.vaFrameLayout.addWidget(self.scvaRadioButton, 0, 2)
        self.vaModalityButtonGroup.addButton(self.scvaRadioButton)

        self.bcvaRadioButton = qt.QRadioButton()
        self.bcvaRadioButton.setText("BCVA")
        self.vaFrameLayout.addWidget(self.bcvaRadioButton, 1, 2)
        self.vaModalityButtonGroup.addButton(self.bcvaRadioButton)

        self.ucvaRadioButton = qt.QRadioButton()
        self.ucvaRadioButton.setText("UCVA")
        self.vaFrameLayout.addWidget(self.ucvaRadioButton, 2, 2)
        self.vaModalityButtonGroup.addButton(self.ucvaRadioButton)

        # Problems detected
        label = qt.QLabel("Problems detected: ")
        label.setStyleSheet("margin: 10px 0 0 10px; font-weight: bold")
        self.diagnosisAreaLayout.addWidget(label)

        self.problemsFrame = qt.QFrame()
        self.problemsFrame.setFrameStyle(0x0002 | 0x0010)
        self.problemsFrame.lineWidth = 2
        self.problemsFrame.setStyleSheet(
            "background-color: #EEEEEE; margin: 10px")
        self.diagnosisAreaLayout.addWidget(self.problemsFrame)

        self.problemsFrameLayout = qt.QGridLayout()
        self.problemsFrame.setLayout(self.problemsFrameLayout)
        self.problemsButtons = []

        self.microaneurysmsCheckbox = qt.QCheckBox()
        self.microaneurysmsCheckbox.setText("Microaneurysms")
        self.problemsFrameLayout.addWidget(self.microaneurysmsCheckbox, 0, 0)
        self.problemsButtons.append(self.microaneurysmsCheckbox)

        self.exudatesCheckbox = qt.QCheckBox()
        self.exudatesCheckbox.setText("Exudates")
        self.problemsFrameLayout.addWidget(self.exudatesCheckbox, 0, 1)
        self.problemsButtons.append(self.exudatesCheckbox)

        self.haemorrhagesCheckbox = qt.QCheckBox()
        self.haemorrhagesCheckbox.setText("Haemorrhages")
        self.problemsFrameLayout.addWidget(self.haemorrhagesCheckbox, 0, 2)
        self.problemsButtons.append(self.haemorrhagesCheckbox)

        self.cottonWoolSpotsCheckbox = qt.QCheckBox()
        self.cottonWoolSpotsCheckbox.setText("Cotton wool spots")
        self.problemsFrameLayout.addWidget(self.cottonWoolSpotsCheckbox, 1, 0)
        self.problemsButtons.append(self.cottonWoolSpotsCheckbox)

        self.NeovascularisationCheckbox = qt.QCheckBox()
        self.NeovascularisationCheckbox.setText("Neovascularisation")
        self.problemsFrameLayout.addWidget(self.NeovascularisationCheckbox, 1,
                                           1)
        self.problemsButtons.append(self.NeovascularisationCheckbox)

        label = qt.QLabel("Diabetic retinopathy diagnosis: ")
        label.setStyleSheet("margin: 10px 0 0 10px; font-weight: bold")
        self.diagnosisAreaLayout.addWidget(label)

        # Diabetic Retinopathy diagnosis
        self.diabeticRetinopathyDiagnosisFrame = qt.QFrame()
        self.diabeticRetinopathyDiagnosisFrame.setFrameStyle(0x0002 | 0x0010)
        self.diabeticRetinopathyDiagnosisFrame.lineWidth = 2
        self.diabeticRetinopathyDiagnosisFrame.setStyleSheet(
            "background-color: #EEEEEE; margin: 10px")
        self.diagnosisAreaLayout.addWidget(
            self.diabeticRetinopathyDiagnosisFrame)

        self.diabeticRetinopathyDiagnosisFrameLayout = qt.QHBoxLayout()
        self.diabeticRetinopathyDiagnosisFrame.setLayout(
            self.diabeticRetinopathyDiagnosisFrameLayout)

        self.diagnosisRadioButtonGroup = qt.QButtonGroup()
        for i in range(5):
            rb = qt.QRadioButton(str(i))
            self.diagnosisRadioButtonGroup.addButton(rb, i)
            self.diabeticRetinopathyDiagnosisFrameLayout.addWidget(rb)
        self.diagnosisRadioButtonGroup.buttons()[0].setChecked(True)

        # Additional comments
        label = qt.QLabel("Additional comments:")
        label.setStyleSheet("margin: 10px 0 0 10px; font-weight: bold")
        self.diagnosisAreaLayout.addWidget(label)
        row += 1

        self.additionalCommentsText = qt.QTextEdit()
        self.additionalCommentsText.setStyleSheet("margin: 10px")
        self.diagnosisAreaLayout.addWidget(self.additionalCommentsText)

        self.saveReportButton = ctk.ctkPushButton()
        self.saveReportButton.text = "Save report"
        self.saveReportButton.setFixedWidth(300)
        self.diagnosisAreaLayout.addWidget(self.saveReportButton)

        self.printReportButton = ctk.ctkPushButton()
        self.printReportButton.text = "Save and generate PDF"
        self.printReportButton.setFixedWidth(300)
        self.diagnosisAreaLayout.addWidget(self.printReportButton)

        self.expertModeCollapsibleButton = ctk.ctkCollapsibleButton()
        self.expertModeCollapsibleButton.text = "Expert mode"
        self.expertModeCollapsibleButton.collapsed = True
        self.layout.addWidget(self.expertModeCollapsibleButton)
        self.expertModeLayout = qt.QVBoxLayout(
            self.expertModeCollapsibleButton)
        self.expertModeCheckbox = qt.QCheckBox("Activate expert mode")
        self.expertModeCheckbox.checked = False
        self.expertModeLayout.addWidget(self.expertModeCheckbox)
        self.layout.addStretch(1)

        # Connections
        self.loadCaseButton.connect('clicked()', self.__onLoadCaseClicked__)
        # self.loadReportButton.connect('clicked()', self.__onLoadReportClicked__)
        self.showEnhancementCheckboxGroup.connect(
            "buttonClicked (int)", self.__onEnhancementButtonGroupClicked__)
        self.centerVolumesButton.connect('clicked()',
                                         SlicerUtil.centerAllVolumes)
        self.vascularFactorSlider.connect('sliderReleased()',
                                          self.__onEnhancementFineTuning__)
        self.enhancementFactorSlider.connect('sliderReleased()',
                                             self.__onEnhancementFineTuning__)
        self.saveReportButton.connect('clicked()',
                                      self.__onSaveReportClicked__)
        self.printReportButton.connect('clicked()',
                                       self.__onPrintReportClicked__)
        self.resetButton.connect('clicked()', self.reset)
        self.expertModeCheckbox.connect("stateChanged(int)",
                                        self.__onExpertModeStateChanged__)
        slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.EndCloseEvent,
                                     self.__onSceneClosed__)

        # Set default layout Red
        SlicerUtil.changeLayoutRedSingle()

        self.refreshUI()
コード例 #19
0
ファイル: TraceAndSelect.py プロジェクト: FastSlice/Extension
    def create(self):
        super(TraceAndSelectOptions, self).create()

        ## Custom threshold box
        # Note: This is needed because other tools can disable, hide, or manipulate the default threshold box
        # We need one unique to our tool
        self.threshLabel = qt.QLabel("Threshold", self.frame)
        self.threshLabel.setToolTip(
            "In threshold mode, the label will only be set if the background value is within this range."
        )
        self.frame.layout().addWidget(self.threshLabel)
        self.widgets.append(self.threshLabel)
        self.thresh = ctk.ctkRangeWidget(self.frame)
        self.thresh.spinBoxAlignment = 0xff  # put enties on top
        self.thresh.singleStep = 0.01
        self.setRangeWidgetToBackgroundRange(self.thresh)
        self.frame.layout().addWidget(self.thresh)
        self.widgets.append(self.thresh)
        ## End custom threshold box

        ## Preview checkbox
        self.preview = qt.QCheckBox("Preview outlines", self.frame)
        self.preview.setToolTip(
            "Preview the outline of a selection with right-click.")
        self.frame.layout().addWidget(self.preview)
        ## End preview checkbox

        self.modeButtons = qt.QButtonGroup(self.frame)
        self.tissueRadioButton = qt.QRadioButton("Tissue Mode", self.frame)
        self.boneRadioButton = qt.QRadioButton("Bone/Nerve Mode", self.frame)
        self.hbox = qt.QHBoxLayout()
        self.hbox.addWidget(self.boneRadioButton)
        self.hbox.addWidget(self.tissueRadioButton)
        self.frame.layout().addLayout(self.hbox)
        self.modeButtons.addButton(self.boneRadioButton)
        self.modeButtons.addButton(self.tissueRadioButton)

        self.widgets.append(self.tissueRadioButton)
        self.widgets.append(self.boneRadioButton)

        ## ERROR MESSAGE FRAME
        self.errorMessageFrame = qt.QTextEdit(self.frame)
        self.frame.layout().addWidget(self.errorMessageFrame)
        #self.errorMessageFrame.setLayout(qt.QHBoxLayout)
        self.errorMessageFrame.setFixedWidth(280)
        self.errorMessageFrame.setReadOnly(True)
        self.errorMessageFrame.setText('No Error Detected')
        self.errorMessageFrame.setStyleSheet("QTextEdit {color:green}")
        self.widgets.append(self.errorMessageFrame)
        ## END ERROR MESSAGE FRAME

        ## For the offset value selection process
        self.offsetvalueFrame = qt.QFrame(self.frame)
        self.offsetvalueFrame.setLayout(qt.QHBoxLayout())
        self.frame.layout().addWidget(self.offsetvalueFrame)
        self.widgets.append(self.offsetvalueFrame)
        self.offsetvalueLabel = qt.QLabel("Offset Value:",
                                          self.offsetvalueFrame)
        self.offsetvalueLabel.setToolTip(
            "Set the offset value shift upon an action")
        self.offsetvalueFrame.layout().addWidget(self.offsetvalueLabel)
        self.widgets.append(self.offsetvalueLabel)
        self.offsetvalueSpinBox = qt.QDoubleSpinBox(self.offsetvalueFrame)
        self.offsetvalueSpinBox.setToolTip(
            "Set the offset value shift upon an action")
        self.offsetvalueSpinBox.minimum = -1000
        self.offsetvalueSpinBox.maximum = 1000
        self.offsetvalueSpinBox.suffix = ""
        self.offsetvalueFrame.layout().addWidget(self.offsetvalueSpinBox)
        self.widgets.append(self.offsetvalueSpinBox)
        ## End offset value selection

        self.maxPixelsFrame = qt.QFrame(self.frame)
        self.maxPixelsFrame.setLayout(qt.QHBoxLayout())
        self.frame.layout().addWidget(self.maxPixelsFrame)
        self.widgets.append(self.maxPixelsFrame)
        self.maxPixelsLabel = qt.QLabel("Max Pixels per click:",
                                        self.maxPixelsFrame)
        self.maxPixelsLabel.setToolTip("Set the maxPixels for each click")
        self.maxPixelsFrame.layout().addWidget(self.maxPixelsLabel)
        self.widgets.append(self.maxPixelsLabel)
        self.maxPixelsSpinBox = qt.QDoubleSpinBox(self.maxPixelsFrame)
        self.maxPixelsSpinBox.setToolTip("Set the maxPixels for each click")
        self.maxPixelsSpinBox.minimum = 1
        self.maxPixelsSpinBox.maximum = 100000
        self.maxPixelsSpinBox.suffix = ""
        self.maxPixelsFrame.layout().addWidget(self.maxPixelsSpinBox)
        self.widgets.append(self.maxPixelsSpinBox)

        # Help Browser
        self.helpBrowser = qt.QPushButton("Visit the Webpage")

        # End Help Browser
        self.frame.layout().addWidget(self.helpBrowser)

        HelpButton(
            self.frame,
            "Use this tool to help you label all voxels enclosed in an area bounded by the the largest path of pixels within the specified threshold."
        )

        # don't connect the signals and slots directly - instead, add these
        # to the list of connections so that gui callbacks can be cleanly
        # disabled while the gui is being updated.  This allows several gui
        # elements to be interlinked with signal/slots but still get updated
        # as a unit to the new value of the mrml node.
        # self.thresholdPaint.hide()
        self.connections.append((self.maxPixelsSpinBox, 'valueChanged(double)',
                                 self.onMaxPixelsSpinBoxChanged))
        self.connections.append(
            (self.preview, "clicked()", self.onPreviewChanged))

        self.connections.append(
            (self.tissueRadioButton, "clicked()", self.onTissueButtonChanged))
        self.connections.append(
            (self.boneRadioButton, "clicked()", self.onBoneButtonChanged))

        self.connections.append(
            (self.offsetvalueSpinBox, 'valueChanged(double)',
             self.onOffsetValueSpinBoxChanged))
        self.connections.append((self.thresh, "valuesChanged(double,double)",
                                 self.onThreshValuesChange))

        self.connections.append(
            (self.helpBrowser, "clicked()", self.onHelpBrowserPressed))

        # Add vertical spacer
        self.frame.layout().addStretch(1)
コード例 #20
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Instantiate and connect widgets ...

        # Set up tabs to split workflow
        tabsWidget = qt.QTabWidget()
        curvesTab = qt.QWidget()
        curvesTabLayout = qt.QFormLayout(curvesTab)
        fiducialsTab = qt.QWidget()
        fiducialsTabLayout = qt.QFormLayout(fiducialsTab)
        batchTab = qt.QWidget()
        batchTabLayout = qt.QFormLayout(batchTab)

        tabsWidget.addTab(curvesTab, "Merge Curves")
        tabsWidget.addTab(fiducialsTab, "Merge Landmark Sets")
        tabsWidget.addTab(batchTab, "Batch Merge Landmark Sets")
        self.layout.addWidget(tabsWidget)
        ################## Curves Tab
        #
        # Parameters Area
        #
        parametersCurveCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersCurveCollapsibleButton.text = "Curve Viewer"
        curvesTabLayout.addRow(parametersCurveCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersCurveFormLayout = qt.QFormLayout(
            parametersCurveCollapsibleButton)

        #
        # check box to trigger taking screen shots for later use in tutorials
        #
        self.continuousCurvesCheckBox = qt.QCheckBox()
        self.continuousCurvesCheckBox.checked = 0
        self.continuousCurvesCheckBox.setToolTip(
            "If checked, redundant points will be removed on merging.")
        parametersCurveFormLayout.addRow("Contiuous curves",
                                         self.continuousCurvesCheckBox)

        #
        # markups view
        #
        self.markupsView = slicer.qMRMLSubjectHierarchyTreeView()
        self.markupsView.setMRMLScene(slicer.mrmlScene)
        self.markupsView.setMultiSelection(True)
        self.markupsView.setAlternatingRowColors(True)
        self.markupsView.setDragDropMode(qt.QAbstractItemView().DragDrop)
        self.markupsView.setColumnHidden(
            self.markupsView.model().transformColumn, True)
        self.markupsView.sortFilterProxyModel().setNodeTypes(
            ["vtkMRMLMarkupsCurveNode"])
        parametersCurveFormLayout.addRow(self.markupsView)

        #
        # Merge Button
        #
        self.mergeButton = qt.QPushButton("Merge highlighted nodes")
        self.mergeButton.toolTip = "Generate a single merged markup file from the selected nodes"
        self.mergeButton.enabled = False
        parametersCurveFormLayout.addRow(self.mergeButton)

        # connections
        self.mergeButton.connect('clicked(bool)', self.onMergeButton)
        self.markupsView.connect('currentItemChanged(vtkIdType)',
                                 self.updateMergeButton)

        ################ Landmark Set Tab
        #
        # Parameters Area
        #
        parametersLMCollapsibleButton = ctk.ctkCollapsibleButton()
        parametersLMCollapsibleButton.text = "Landmark Viewer"
        fiducialsTabLayout.addRow(parametersLMCollapsibleButton)

        # Layout within the dummy collapsible button
        parametersLMFormLayout = qt.QGridLayout(parametersLMCollapsibleButton)

        #
        # markups view
        #
        self.markupsFiducialView = slicer.qMRMLSubjectHierarchyTreeView()
        self.markupsFiducialView.setMRMLScene(slicer.mrmlScene)
        self.markupsFiducialView.setMultiSelection(True)
        self.markupsFiducialView.setAlternatingRowColors(True)
        self.markupsFiducialView.setDragDropMode(
            qt.QAbstractItemView().DragDrop)
        self.markupsFiducialView.setColumnHidden(
            self.markupsView.model().transformColumn, True)
        self.markupsFiducialView.sortFilterProxyModel().setNodeTypes(
            ["vtkMRMLMarkupsFiducialNode"])
        parametersLMFormLayout.addWidget(self.markupsFiducialView, 0, 0, 1, 3)

        #
        # Set landmark type menu
        #
        boxLabel = qt.QLabel("Select landmark type description to apply: ")
        self.LandmarkTypeSelection = qt.QComboBox()
        self.LandmarkTypeSelection.addItems(
            ["Select", "Fixed", "Semi", "No description"])
        parametersLMFormLayout.addWidget(boxLabel, 1, 0)
        parametersLMFormLayout.addWidget(self.LandmarkTypeSelection, 1, 1)

        #
        # Apply Landmark Type Button
        #
        self.ApplyLMButton = qt.QPushButton("Apply to highlighted nodes")
        self.ApplyLMButton.toolTip = "Apply the selected landmark type to points in the the selected nodes"
        self.ApplyLMButton.enabled = False
        parametersLMFormLayout.addWidget(self.ApplyLMButton, 1, 2)

        #
        # Merge Button
        #
        self.mergeLMButton = qt.QPushButton("Merge highlighted nodes")
        self.mergeLMButton.toolTip = "Generate a single merged markup file from the selected nodes"
        self.mergeLMButton.enabled = False
        parametersLMFormLayout.addWidget(self.mergeLMButton, 2, 0, 1, 3)

        # connections
        self.mergeLMButton.connect('clicked(bool)', self.onMergeLMButton)
        self.ApplyLMButton.connect('clicked(bool)', self.onApplyLMButton)
        self.markupsFiducialView.connect('currentItemChanged(vtkIdType)',
                                         self.updateMergeLMButton)
        self.LandmarkTypeSelection.connect('currentIndexChanged(int)',
                                           self.updateApplyLMButton)

        ################ Batch Run LM Merge Tab
        #
        # Fixed LM Area
        #
        fixedBatchCollapsibleButton = ctk.ctkCollapsibleButton()
        fixedBatchCollapsibleButton.text = "Fixed LM File Selection"
        batchTabLayout.addRow(fixedBatchCollapsibleButton)

        # Layout within the dummy collapsible button
        fixedBatchLayout = qt.QFormLayout(fixedBatchCollapsibleButton)

        #
        # Browse Fixed LM Button
        #
        self.browseFixedLMButton = qt.QPushButton("Select files...")
        self.browseFixedLMButton.toolTip = "Select one fixed landmark file for each subject"
        self.browseFixedLMButton.enabled = True
        fixedBatchLayout.addRow(self.browseFixedLMButton)

        #
        # File viewer box
        #
        self.fixedFileTable = qt.QTextEdit()
        fixedBatchLayout.addRow(self.fixedFileTable)

        #
        # Semi LM Area
        #
        semiBatchCollapsibleButton = ctk.ctkCollapsibleButton()
        semiBatchCollapsibleButton.text = "Semi LM File Selection"
        batchTabLayout.addRow(semiBatchCollapsibleButton)

        # Layout within the dummy collapsible button
        semiBatchLayout = qt.QFormLayout(semiBatchCollapsibleButton)

        #
        # Browse Fixed LM Button
        #
        self.browseSemiLMButton = qt.QPushButton("Select files...")
        self.browseSemiLMButton.toolTip = "Select one semi-landmark file for each subject, in the same order as the fixed landmarks"
        self.browseSemiLMButton.enabled = True
        semiBatchLayout.addRow(self.browseSemiLMButton)

        #
        # File viewer box
        #
        self.semiFileTable = qt.QTextEdit()
        semiBatchLayout.addRow(self.semiFileTable)

        #
        # Merge LM Area
        #
        batchMergeCollapsibleButton = ctk.ctkCollapsibleButton()
        batchMergeCollapsibleButton.text = "Run merge"
        batchTabLayout.addRow(batchMergeCollapsibleButton)

        # Layout within the dummy collapsible button
        batchMergeLayout = qt.QFormLayout(batchMergeCollapsibleButton)

        #
        # Select output landmark directory
        #
        self.outputDirectorySelector = ctk.ctkPathLineEdit()
        self.outputDirectorySelector.filters = ctk.ctkPathLineEdit.Dirs
        self.outputDirectorySelector.toolTip = "Select the output directory where the merged landmark nodes will be saved"
        batchMergeLayout.addRow("Select output landmark directory: ",
                                self.outputDirectorySelector)

        #
        # Batch Merge Button
        #
        self.batchMergeButton = qt.QPushButton(
            "Merge fixed and semi-landmark nodes")
        self.batchMergeButton.toolTip = "Generate a single merged markup file from the selected nodes"
        self.batchMergeButton.enabled = False
        batchMergeLayout.addRow(self.batchMergeButton)

        #
        # Clear Button
        #
        self.clearButton = qt.QPushButton("Clear landmark file selections")
        self.clearButton.toolTip = "Clear the landmark files selected in the viewer boxes"
        self.clearButton.enabled = False
        batchMergeLayout.addRow(self.clearButton)

        # connections
        self.browseFixedLMButton.connect('clicked(bool)',
                                         self.addFixedByBrowsing)
        self.browseSemiLMButton.connect('clicked(bool)',
                                        self.addSemiByBrowsing)
        self.outputDirectorySelector.connect('validInputChanged(bool)',
                                             self.onSelectDirectory)
        self.batchMergeButton.connect('clicked(bool)', self.onBatchMergeButton)
        self.clearButton.connect('clicked(bool)', self.onClearButton)

        # Add vertical spacer
        self.layout.addStretch(1)
コード例 #21
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # This module is often used in developer mode, therefore
        # collapse reload & test section by default.
        if hasattr(self, "reloadCollapsibleButton"):
            self.reloadCollapsibleButton.collapsed = True

        self.observerTags = []
        self.logic = SampleDataLogic(self.logMessage)

        numberOfColumns = 3
        iconPath = os.path.join(
            os.path.dirname(__file__).replace('\\', '/'), 'Resources', 'Icons')
        desktop = qt.QDesktopWidget()
        mainScreenSize = desktop.availableGeometry(desktop.primaryScreen)
        iconSize = qt.QSize(mainScreenSize.width() / 15,
                            mainScreenSize.height() / 10)

        categories = slicer.modules.sampleDataSources.keys()
        categories.sort()
        if 'BuiltIn' in categories:
            categories.remove('BuiltIn')
        categories.insert(0, 'BuiltIn')
        for category in categories:
            frame = ctk.ctkCollapsibleGroupBox(self.parent)
            self.layout.addWidget(frame)
            frame.title = category
            frame.name = '%sCollapsibleGroupBox' % category
            layout = qt.QGridLayout(frame)
            columnIndex = 0
            rowIndex = 0
            for source in slicer.modules.sampleDataSources[category]:
                name = source.sampleName
                if not name:
                    name = source.nodeNames[0]

                b = qt.QToolButton()
                b.setText(name)

                # Set thumbnail
                if source.thumbnailFileName:
                    # Thumbnail provided
                    thumbnailImage = source.thumbnailFileName
                else:
                    # Look for thumbnail image with the name of any node name with .png extension
                    thumbnailImage = None
                    for nodeName in source.nodeNames:
                        if not nodeName:
                            continue
                        thumbnailImageAttempt = os.path.join(
                            iconPath, nodeName + '.png')
                        if os.path.exists(thumbnailImageAttempt):
                            thumbnailImage = thumbnailImageAttempt
                            break
                if thumbnailImage and os.path.exists(thumbnailImage):
                    b.setIcon(qt.QIcon(thumbnailImage))

                b.setIconSize(iconSize)
                b.setToolButtonStyle(qt.Qt.ToolButtonTextUnderIcon)
                qSize = qt.QSizePolicy()
                qSize.setHorizontalPolicy(qt.QSizePolicy.Expanding)
                b.setSizePolicy(qSize)

                b.name = '%sPushButton' % name
                layout.addWidget(b, rowIndex, columnIndex)
                columnIndex += 1
                if columnIndex == numberOfColumns:
                    rowIndex += 1
                    columnIndex = 0
                if source.customDownloader:
                    b.connect('clicked()', source.customDownloader)
                else:
                    b.connect(
                        'clicked()',
                        lambda s=source: self.logic.downloadFromSource(s))

        self.log = qt.QTextEdit()
        self.log.readOnly = True
        self.layout.addWidget(self.log)
        self.logMessage('<p>Status: <i>Idle</i>\n')

        # Add spacer to layout
        self.layout.addStretch(1)
コード例 #22
0
 def _createTextEdit(self, title, **kwargs):
   textEdit = qt.QTextEdit(title)
   return self._extendQtGuiElementProperties(textEdit, **kwargs)