Пример #1
0
  def updateLandmarkArray(self):
    """Rebuild the list of buttons based on current landmarks"""
    # reset the widget
    if self.landmarkGroupBox:
      self.landmarkGroupBox.setParent(None)
    self.landmarkGroupBox = qt.QGroupBox("Landmarks")
    self.landmarkGroupBox.setLayout(qt.QFormLayout())
    # add the action buttons at the top
    actionButtons = qt.QHBoxLayout()
    # add button - http://www.clipartbest.com/clipart-jTxpEM8Bc
    self.addButton = qt.QPushButton("Add")
    self.addButton.setIcon(qt.QIcon(os.path.join(os.path.dirname(slicer.modules.landmarkregistration.path), 'Resources/Icons/', "icon_Add.png")))
    self.addButton.connect('clicked()', self.addLandmark)
    actionButtons.addWidget(self.addButton)
    self.renameButton = qt.QPushButton("Rename")
    self.renameButton.connect('clicked()', self.renameLandmark)
    self.renameButton.enabled = False
    actionButtons.addWidget(self.renameButton)
    self.landmarkGroupBox.layout().addRow(actionButtons)

    # for now, hide
    self.renameButton.hide()

    # make a button for each current landmark
    self.labels = {}
    landmarks = self.logic.landmarksForVolumes(self.volumeNodes)
    keys = landmarks.keys()
    keys.sort()
    for landmarkName in keys:
      row = qt.QWidget()
      rowLayout = qt.QHBoxLayout()
      rowLayout.setMargin(0)

      label = qt.QLabel(landmarkName)
      rowLayout.addWidget(label, 8)

      # active button - https://thenounproject.com/term/crosshair/4434/
      activeButton = qt.QPushButton()
      activeButton.setIcon(qt.QIcon(os.path.join(os.path.dirname(slicer.modules.landmarkregistration.path), 'Resources/Icons/', "icon_Active.png")))
      activeButton.connect('clicked()', lambda l=landmarkName: self.pickLandmark(l))
      rowLayout.addWidget(activeButton, 1)

      if landmarkName == self.selectedLandmark:
        label.setStyleSheet("QWidget{font-weight: bold;}")
        activeButton.setEnabled(False)

      # remove button - http://findicons.com/icon/158288/trash_recyclebin_empty_closed_w
      removeButton = qt.QPushButton()
      removeButton.setIcon(qt.QIcon(os.path.join(os.path.dirname(slicer.modules.landmarkregistration.path), 'Resources/Icons/', "icon_Trash.png")))
      removeButton.connect('clicked()', lambda l=landmarkName: self.removeLandmark(l))
      rowLayout.addWidget(removeButton, 1)

      row.setLayout(rowLayout)

      self.landmarkGroupBox.layout().addRow( row )
      self.labels[landmarkName] = [label, activeButton]
    self.landmarkArrayHolder.layout().addWidget(self.landmarkGroupBox)

    # observe manipulation of the landmarks
    self.addLandmarkObservers()
 def icon(self, itemID):
     import os
     iconPath = None
     pluginHandlerSingleton = slicer.qSlicerSubjectHierarchyPluginHandler.instance(
     )
     shNode = pluginHandlerSingleton.subjectHierarchyNode()
     associatedNode = shNode.GetItemDataNode(itemID)
     if associatedNode is not None and associatedNode.IsA(
             "vtkMRMLScriptedModuleNode"):
         if associatedNode.GetAttribute("ModuleName") == "HeartValve":
             iconPath = os.path.join(
                 os.path.dirname(__file__),
                 '../Resources/Icons/ValveAnnulusAnalysis.png')
         elif associatedNode.GetAttribute(
                 "ModuleName") == "HeartValveMeasurement":
             iconPath = os.path.join(
                 os.path.dirname(__file__),
                 '../../ValveQuantification/Resources/Icons/ValveQuantification.png'
             )
         elif associatedNode.GetAttribute(
                 "ModuleName") == "CardiacDeviceAnalysis":
             iconPath = os.path.join(
                 os.path.dirname(__file__),
                 '../../CardiacModelGenerator/Resources/Icons/CardiacModelGenerator.png'
             )
         elif associatedNode.GetAttribute("ModuleName") == "ValveFEMExport":
             iconPath = os.path.join(
                 os.path.dirname(__file__),
                 '../Resources/Icons/ValveAnnulusAnalysis.png')
     if iconPath and os.path.exists(iconPath):
         return qt.QIcon(iconPath)
     # Item unknown by plugin
     return qt.QIcon()
 def icon(self):
     # It should not be necessary to modify this method
     iconPath = os.path.join(os.path.dirname(__file__),
                             'Resources/Icons/MaskVolume.png')
     if os.path.exists(iconPath):
         return qt.QIcon(iconPath)
     return qt.QIcon()
Пример #4
0
 def icon(self):
     # It should not be necessary to modify this method
     iconPath = os.path.join(os.path.dirname(__file__),
                             'SegmentEditorEffect.png')
     if os.path.exists(iconPath):
         return qt.QIcon(iconPath)
     return qt.QIcon()
Пример #5
0
    def setup(self):
        self.mainFrame = qt.QFrame()
        frameLayout = qt.QGridLayout()
        self.mainFrame.setLayout(frameLayout)
        self.layout.addWidget(self.mainFrame)

        self.saveButton = ctk.ctkPushButton()
        self.saveButton.text = "Save"
        self.saveButton.toolTip = "Save the current table"
        self.saveButton.objectName = "reportSaveButton"
        self.saveButton.setIcon(qt.QIcon("{0}/Save.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.saveButton.setIconSize(qt.QSize(24, 24))
        frameLayout.addWidget(self.saveButton, 0, 0)

        self.openButton = ctk.ctkPushButton()
        self.openButton.text = "Open"
        self.openButton.toolTip = "Open all the results saved"
        self.openButton.objectName = "reportOpenButton"
        self.openButton.setIcon(qt.QIcon("{0}/open_file.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.openButton.setIconSize(qt.QSize(24,24))
        frameLayout.addWidget(self.openButton, 0, 1)

        self.exportButton = ctk.ctkPushButton()
        self.exportButton.text = "Export"
        self.exportButton.toolTip = "Export all the saved results to a CSV file"
        self.exportButton.objectName = "reportExportButton"
        self.exportButton.setIcon(qt.QIcon("{0}/export-csv.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.exportButton.setIconSize(qt.QSize(24,24))
        frameLayout.addWidget(self.exportButton, 0, 2)

        self.removeButton = ctk.ctkPushButton()
        self.removeButton.setIcon(qt.QIcon("{0}/delete.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.removeButton.setIconSize(qt.QSize(24,24))
        self.removeButton.text = "Clean cache"
        frameLayout.addWidget(self.removeButton, 0, 3)

        self.printButton = ctk.ctkPushButton()
        self.printButton.text = "Print"
        self.printButton.toolTip = "Print report"
        self.printButton.objectName = "reportPrintButton"
        self.printButton.setIcon(qt.QIcon("{0}/print.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.printButton.setIconSize(qt.QSize(24,24))
        self.printButton.setVisible(False)  # By default, this button will be hidden
        frameLayout.addWidget(self.printButton, 0, 4)

        self.additionalComentsLabel = qt.QLabel("Additional comments:")
        self.additionalComentsLabel.setStyleSheet("margin-top: 3px")
        frameLayout.addWidget(self.additionalComentsLabel, 1, 0, 1, 2)
        self.additionalComentsTextEdit = CollapsibleMultilineText()
        frameLayout.addWidget(self.additionalComentsTextEdit, 1, 1, 1, 3)

        self.openButton.connect('clicked()', self.onShowStoredData)
        self.saveButton.connect('clicked()', self.onSave)
        self.exportButton.connect('clicked()', self.onExport)
        self.printButton.connect('clicked()', self.onPrintReport)
        self.removeButton.connect('clicked()', self.onRemoveStoredData)
    def __init__(self, scriptedEffect):
        scriptedEffect.name = 'Mask volume'
        scriptedEffect.perSegment = True  # this effect operates on a single selected segment
        self.updatingGUIFromMRML = False
        self.visibleIcon = qt.QIcon(":/Icons/Small/SlicerVisible.png")
        self.invisibleIcon = qt.QIcon(":/Icons/Small/SlicerInvisible.png")
        AbstractScriptedSegmentEditorEffect.__init__(self, scriptedEffect)

        #Effect-specific members
        self.buttonToOperationNameMap = {}
Пример #7
0
    def __init__(self, parent):
        """
        Window that display the data
        :param parent: CaseReportsWidget object
        """
        super(CaseReportsWindow, self).__init__()

        self.mainLayout = qt.QVBoxLayout(self)
        self.setLayout(self.mainLayout)
        self.resize(400, 300)

        self.label = qt.QLabel("Data stored in the module: ")
        self.label.setStyleSheet("margin: 10px 0 15px 0")
        self.mainLayout.addWidget(self.label)

        self.tableView = slicer.qMRMLTableView()
        self.tableView.setColumnWidth(0, 125)
        self.tableView.setMRMLTableNode(parent.logic.tableNode)
        self.tableView.setFirstRowLocked(True)  # First row will be headers
        self.tableView.setSortingEnabled(True)

        self.tableView.setSizePolicy(qt.QSizePolicy.Expanding,
                                     qt.QSizePolicy.Expanding)
        self.mainLayout.addWidget(self.tableView)

        self.expandRowsButton = ctk.ctkPushButton()
        self.expandRowsButton.text = "Expand rows"
        self.expandRowsButton.toolTip = "Change the height of the rows to show/hide all the multiline data"
        self.expandRowsButton.setFixedWidth(150)
        self.expandRowsButton.setIcon(
            qt.QIcon("{0}/reload.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.expandRowsButton.setIconSize(qt.QSize(24, 24))
        self.mainLayout.addWidget(self.expandRowsButton)

        self.exportButton = ctk.ctkPushButton()
        self.exportButton.text = "Export"
        self.exportButton.toolTip = "Export to a CVS file"
        self.exportButton.setFixedWidth(150)
        self.exportButton.setIcon(
            qt.QIcon("{0}/export-csv.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.exportButton.setIconSize(qt.QSize(24, 24))
        self.mainLayout.addWidget(self.exportButton)

        self.removeButton = ctk.ctkPushButton()
        self.removeButton.text = "Clean"
        self.removeButton.setIcon(
            qt.QIcon("{0}/delete.png".format(SlicerUtil.CIP_ICON_DIR)))
        self.removeButton.setIconSize(qt.QSize(24, 24))
        self.removeButton.setFixedWidth(150)
        self.mainLayout.addWidget(self.removeButton)

        self.expandRowsButton.connect('clicked()', parent.onExpandRows)
        self.exportButton.connect('clicked()', parent.onExport)
        self.removeButton.connect('clicked()', parent.onRemoveStoredData)
Пример #8
0
    def updateGUIFromMRML(self):
        self.fillValueEdit.setValue(
            float(self.scriptedEffect.parameter("FillValue")))
        self.binaryMaskFillOutsideEdit.setValue(
            float(self.scriptedEffect.parameter("BinaryMaskFillValueOutside")))
        self.binaryMaskFillInsideEdit.setValue(
            float(self.scriptedEffect.parameter("BinaryMaskFillValueInside")))
        operationButton = [
            key for key, value in self.buttonToOperationNameMap.iteritems()
            if value == self.scriptedEffect.parameter("Operation")
        ][0]
        operationButton.setChecked(True)

        inputVisible = self.scriptedEffect.parameter("InputVisibility")
        outputVisible = self.scriptedEffect.parameter("OutputVisibility")
        inputVolume = self.inputVolumeSelector.currentNode()
        if inputVolume is None:
            inputVolume = self.scriptedEffect.parameterSetNode(
            ).GetMasterVolumeNode()
        outputVolume = self.outputVolumeSelector.currentNode()
        masterVolume = self.scriptedEffect.parameterSetNode(
        ).GetMasterVolumeNode()
        visibleIcon = qt.QIcon(":/Icons/Small/SlicerVisible.png")
        invisibleIcon = qt.QIcon(":/Icons/Small/SlicerInvisible.png")
        if inputVisible == "True" and outputVisible == "True":
            self.inputVisibilityButton.setIcon(visibleIcon)
            self.outputVisibilityButton.setIcon(visibleIcon)
            slicer.util.setSliceViewerLayers(background=inputVolume)
        elif inputVisible == "True":
            self.inputVisibilityButton.setIcon(visibleIcon)
            self.outputVisibilityButton.setIcon(invisibleIcon)
            slicer.util.setSliceViewerLayers(background=inputVolume)
        elif outputVisible == "True":
            self.outputVisibilityButton.setIcon(visibleIcon)
            self.inputVisibilityButton.setIcon(invisibleIcon)
            slicer.util.setSliceViewerLayers(background=outputVolume)
        else:
            self.outputVisibilityButton.setIcon(invisibleIcon)
            self.inputVisibilityButton.setIcon(invisibleIcon)
            slicer.util.setSliceViewerLayers(background=masterVolume)
            self.inputVisibilityButton.setEnabled(False)

        self.inputVisibilityButton.setEnabled(not (
            inputVolume is masterVolume and inputVisible == "True"))
        self.outputVisibilityButton.setEnabled(not (
            (outputVolume is masterVolume and outputVisible == "True")
            or outputVolume is None))

        self.inputVisibilityButton.setChecked(
            self.inputVisibilityButton.isEnabled() and inputVisible == "True")
        self.outputVisibilityButton.setChecked(
            self.outputVisibilityButton.isEnabled()
            and outputVisible == "True")
Пример #9
0
    def __init__(self, parent):
        import string
        parent.title = "Editor"
        parent.categories = ["", "Segmentation"]
        parent.contributors = ["Steve Pieper (Isomics)"]
        parent.helpText = string.Template("""
The Editor allows label maps to be created and edited. The active label map will be modified by the Editor.

See <a href=\"$a/Documentation/$b.$c/Modules/Editor\">the documentation</a> for more information.

The Master Volume refers to the background grayscale volume to be edited (used, for example, when thresholding).  The Merge Volume refers to a volume that contains several different label values corresponding to different structures.\n\nBasic usage: selecting the Master and Merge Volume give access to the editor tools.  Each tool has a help icon to bring up a dialog with additional information.  Hover your mouse pointer over buttons and options to view Balloon Help (tool tips).  Use these to define the Label Map.\n\nAdvanced usage: open the Per-Structure Volumes tab to create independent Label Maps for each color you wish to edit.  Since many editor tools (such as threshold) will operate on the entire volume, you can use the Per-Structure Volumes feature to isolate these operations on a structure-by-structure basis.  Use the Split Merge Volume button to create a set of volumes with independent labels.  Use the Add Structure button to add a new volume.  Delete Structures will remove all the independent structure volumes.  Merge All will assemble the current structures into the Merge Volume.  Merge And Build will invoke the Model Maker module on the Merge Volume.
    """).substitute({
            'a': parent.slicerWikiUrl,
            'b': slicer.app.majorVersion,
            'c': slicer.app.minorVersion
        })
        parent.acknowledgementText = """
This work is supported by NA-MIC, NAC, BIRN, NCIGT, and the Slicer Community. See <a>http://www.slicer.org</a> for details.  Module implemented by Steve Pieper.
This work is partially supported by PAR-07-249: R01CA131718 NA-MIC Virtual Colonoscopy (See <a href=http://www.slicer.org>http://www.na-mic.org/Wiki/index.php/NA-MIC_NCBC_Collaboration:NA-MIC_virtual_colonoscopy</a>).
    """
        self.parent = parent

        if slicer.mrmlScene.GetTagByClassName(
                "vtkMRMLScriptedModuleNode") != 'ScriptedModule':
            node = vtkMRMLScriptedModuleNode()
            slicer.mrmlScene.RegisterNodeClass(node)
            node.Delete()

        parent.icon = qt.QIcon("%s/ToolbarEditorToolbox.png" %
                               EditorLib.ICON_DIR)
Пример #10
0
    def __init__(self, parent):
        ScriptedLoadableModule.__init__(self, parent)

        import string
        self.parent.title = "DICOM"
        self.parent.categories = ["", "Informatics"]  # top level module
        self.parent.contributors = ["Steve Pieper (Isomics)"]
        self.parent.helpText = """
The DICOM module integrates DICOM classes from CTK (based on DCMTK).
"""
        self.parent.helpText += self.getDefaultModuleDocumentationLink()
        self.parent.acknowledgementText = """
This work is supported by NA-MIC, NAC, BIRN, NCIGT, and the Slicer Community. See <a href=http://www.slicer.org>http://www.slicer.org</a> for details.  Module implemented by Steve Pieper.  Based on work from CommonTK (http://www.commontk.org).
"""
        self.parent.icon = qt.QIcon(':Icons/Medium/SlicerLoadDICOM.png')
        self.parent.dependencies = ["SubjectHierarchy"]

        self.detailsPopup = None
        self.viewWidget = None
        self.browserSettingsWidget = None
        self.currentViewArrangement = 0

        # Tasks to execute after the application has started up
        slicer.app.connect("startupCompleted()",
                           self.performPostModuleDiscoveryTasks)
Пример #11
0
    def __init__(self, parent):
        self.parent = parent
        self.moduleName = self.__class__.__name__

        parent.title = ""
        parent.categories = []
        parent.dependencies = []
        parent.contributors = [
            "Andras Lasso (PerkLab, Queen's University), Steve Pieper (Isomics)"
        ]
        parent.helpText = """
This module was created from a template and the help section has not yet been updated.
"""

        parent.acknowledgementText = """
This work is supported by NA-MIC, NAC, BIRN, NCIGT, and the Slicer Community. See <a>http://www.slicer.org</a> for details.
This work is partially supported by PAR-07-249: R01CA131718 NA-MIC Virtual Colonoscopy (See <a href=http://www.slicer.org>http://www.na-mic.org/Wiki/index.php/NA-MIC_NCBC_Collaboration:NA-MIC_virtual_colonoscopy</a>).
"""

        # Set module icon from Resources/Icons/<ModuleName>.png
        moduleDir = os.path.dirname(self.parent.path)
        iconPath = os.path.join(moduleDir, 'Resources/Icons',
                                self.moduleName + '.png')
        if os.path.isfile(iconPath):
            parent.icon = qt.QIcon(iconPath)

        # Add this test to the SelfTest module's list for discovery when the module
        # is created.  Since this module may be discovered before SelfTests itself,
        # create the list if it doesn't already exist.
        try:
            slicer.selfTests
        except AttributeError:
            slicer.selfTests = {}
        slicer.selfTests[self.moduleName] = self.runTest
Пример #12
0
    def __init__(self, parent):
        import string
        parent.title = "Sample Data"
        parent.categories = ["Informatics"]
        parent.contributors = [
            "Steve Pieper (Isomics), Benjamin Long (Kitware), Jean-Christophe Fillion-Robin (Kitware)"
        ]
        parent.helpText = string.Template("""
The SampleData module can be used to download data for working with in slicer.  Use of this module requires an active network connection.
See <a href=\"$a/Documentation/$b.$c/Modules/SampleData\">$a/Documentation/$b.$c/Modules/SampleData</a> for more information.
    """).substitute({
            'a': parent.slicerWikiUrl,
            'b': slicer.app.majorVersion,
            'c': slicer.app.minorVersion
        })
        parent.acknowledgementText = """
This work is supported by NA-MIC, NAC, BIRN, NCIGT, and the Slicer Community. See <a>http://www.slicer.org</a> for details.  Module implemented by Steve Pieper.
    """
        parent.icon = qt.QIcon(':Icons/XLarge/SlicerDownloadMRHead.png')
        self.parent = parent

        if slicer.mrmlScene.GetTagByClassName(
                "vtkMRMLScriptedModuleNode") != 'ScriptedModule':
            slicer.mrmlScene.RegisterNodeClass(vtkMRMLScriptedModuleNode())

        # Trigger the menu to be added when application has started up
        if not slicer.app.commandOptions().noMainWindow:
            qt.QTimer.singleShot(0, self.addMenu)

        # allow other modules to register sample data sources by appending
        # instances or subclasses SampleDataSource objects on this list
        try:
            slicer.modules.sampleDataSources
        except AttributeError:
            slicer.modules.sampleDataSources = {}
Пример #13
0
    def __init__(self, parent, logic, configurationName='Default'):

        # init guidelet
        Guidelet.__init__(self, parent, logic, configurationName)

        # module intrinsics
        self.logic.addValuesToDefaultConfiguration()
        self.modulePath = os.path.dirname(slicer.modules.usregistration.path)
        self.moduleTransformsPath = os.path.join(self.modulePath,
                                                 'Resources/Transforms')
        self.moduleModelsPath = os.path.join(self.modulePath,
                                             'Resources/Models')
        self.moduleIconsPath = os.path.join(self.modulePath, 'Resources/Icons')

        self.referenceInView = False
        self.probeInView = False
        self.stylusInView = False

        # set up main frame
        self.sliceletDockWidget.setObjectName('USRegistration')
        self.sliceletDockWidget.setWindowTitle('Skull US Registration')
        self.mainWindow.setWindowTitle('Skull US Registration')
        self.mainWindow.windowIcon = qt.QIcon(
            os.path.join(self.moduleIconsPath, 'USRegistration.png'))

        # hide slicer status bar
        slicer.util.mainWindow().statusBar().hide()

        # setup
        self.setupScene()

        # tool visibility icons
        self.setupToolWatchdog()
Пример #14
0
class ConventionalSliceLayoutButton(LayoutButton):
    """ LayoutButton inherited class which represents a button for the ConventionalSliceLayoutButton including the icon.

  Args:
    text (str, optional): text to be displayed for the button
    parent (qt.QWidget, optional): parent of the button

  .. code-block:: python

    from VentriculostomyPlanningUtils.buttons import ConventionalSliceLayoutButton

    button = ConventionalSliceLayoutButton()
    button.show()
  """
    iconFileName = os.path.join(
        os.path.dirname(
            os.path.normpath(os.path.dirname(os.path.realpath(__file__)))),
        'Resources', 'Icons', 'LayoutConventionalSliceView.png')
    _ICON = qt.QIcon(iconFileName)
    LAYOUT = slicer.vtkMRMLLayoutNode.SlicerLayoutConventionalView

    def __init__(self, text="", parent=None, **kwargs):
        super(ConventionalSliceLayoutButton,
              self).__init__(text, parent, **kwargs)
        self.toolTip = "Conventional Slice Only Layout"
Пример #15
0
    def __init__(self, parent):
        parent.title = "Editor"
        parent.category = ""
        parent.contributor = "Steve Pieper"
        parent.helpText = """
The Editor allows label maps to be created and edited. The active label map will be modified by the Editor.  See <a>http://www.slicer.org/slicerWiki/index.php/Modules:Editor-Documentation-4.0</a>.\n\nThe Master Volume refers to the background grayscale volume to be edited (used, for example, when thresholding).  The Merge Volume refers to a volume that contains several different label values corresponding to different structures.\n\nBasic usage: selecting the Master and Merge Volume give access to the editor tools.  Each tool has a help icon to bring up a dialog with additional information.  Hover your mouse pointer over buttons and options to view Balloon Help (tool tips).  Use these to define the Label Map.\n\nAdvanced usage: open the Per-Structure Volumes tab to create independent Label Maps for each color you wish to edit.  Since many editor tools (such as threshold) will operate on the entire volume, you can use the Per-Structure Volumes feature to isolate these operations on a structure-by-structure basis.  Use the Split Merge Volume button to create a set of volumes with independent labels.  Use the Add Structure button to add a new volume.  Delete Structures will remove all the independent structure volumes.  Merge All will assemble the current structures into the Merge Volume.  Merge And Build will invoke the Model Maker module on the Merge Volume.
    """
        parent.acknowledgementText = """
This work is supported by NA-MIC, NAC, BIRN, NCIGT, and the Slicer Community. See <a>http://www.slicer.org</a> for details.  Module implemented by Steve Pieper.
This work is partially supported by PAR-07-249: R01CA131718 NA-MIC Virtual Colonoscopy (See <a>http://www.na-mic.org/Wiki/index.php/NA-MIC_NCBC_Collaboration:NA-MIC_virtual_colonoscopy</a>).
    """
        self.parent = parent

        if slicer.mrmlScene.GetTagByClassName(
                "vtkMRMLScriptedModuleNode") != 'ScriptedModule':
            slicer.mrmlScene.RegisterNodeClass(vtkMRMLScriptedModuleNode())

        if tcl('info exists ::Editor(singleton)') != '':
            # TODO: cannot call dialog.exec from pythonqt... This is just a warning anyway
            #dialog = qt.QErrorMessage()
            #dialog.showMessage("Error: editor singleton already created - Editor initialized twice.")
            pass
        tcl('set ::Editor(singleton) this')
        tcl('set ::Editor(checkPointsEnabled) 1')

        iconDir = slicer.app.slicerHome + '/' + os.environ[
            'SLICER_SHARE_DIR'] + '/Tcl/ImageData'
        parent.icon = qt.QIcon("%s/ToolbarEditorToolbox.png" % iconDir)
Пример #16
0
    def modifyWindowUI(self):
        slicer.util.setModuleHelpSectionVisible(False)

        mainToolBar = slicer.util.findChild(slicer.util.mainWindow(),
                                            'MainToolBar')

        self.CustomToolBar = qt.QToolBar("CustomToolBar")
        self.CustomToolBar.name = "CustomToolBar"
        slicer.util.mainWindow().insertToolBar(mainToolBar, self.CustomToolBar)

        #     central = slicer.util.findChild(slicer.util.mainWindow(), name='CentralWidget')
        #     central.setStyleSheet("background-color: #464449")

        gearIcon = qt.QIcon(self.resourcePath('Icons/Gears.png'))
        self.settingsAction = self.CustomToolBar.addAction(gearIcon, "")

        self.settingsDialog = slicer.util.loadUI(
            self.resourcePath('UI/Settings.ui'))
        self.settingsUI = slicer.util.childWidgetVariables(self.settingsDialog)

        self.settingsUI.CustomUICheckBox.toggled.connect(self.toggleUI)
        self.settingsUI.CustomStyleCheckBox.toggled.connect(self.toggleStyle)

        self.settingsAction.triggered.connect(self.raiseSettings)
        self.hideSlicerUI()
Пример #17
0
 def getIcon(cls):
     if cls.ID:
         pngFile = os.path.join(cls.RESOURCES_PATH, "Icons",
                                cls.ID + ".png")
         if os.path.exists(pngFile):
             return qt.QIcon(qt.QPixmap(pngFile))
     return None
Пример #18
0
    def __init__(self, parent):
        ScriptedLoadableModule.__init__(self, parent)

        import string
        self.parent.title = "DICOM"
        self.parent.categories = ["", "Informatics"]  # top level module
        self.parent.contributors = [
            "Steve Pieper (Isomics)", "Andras Lasso (PerkLab)"
        ]
        self.parent.helpText = """
This module allows importing, loading, and exporting DICOM files, and sending receiving data using DICOM networking.
"""
        self.parent.helpText += self.getDefaultModuleDocumentationLink()
        self.parent.acknowledgementText = """
This work is supported by NA-MIC, NAC, BIRN, NCIGT, and the Slicer Community.
"""
        self.parent.icon = qt.QIcon(':Icons/Medium/SlicerLoadDICOM.png')
        self.parent.dependencies = ["SubjectHierarchy"]

        self.viewWidget = None  # Widget used in the layout manager (contains just label and browser widget)
        self.browserWidget = None  # SlicerDICOMBrowser instance (ctkDICOMBrowser with additional section for loading the selected items)
        self.browserSettingsWidget = None
        self.currentViewArrangement = 0
        # This variable is set to true if we temporarily
        # hide the data probe (and so we need to restore its visibility).
        self.dataProbeHasBeenTemporarilyHidden = False
Пример #19
0
    def __init__(self, parent):
        ScriptedLoadableModule.__init__(self, parent)
        import string
        self.parent.title = "DICOM"
        self.parent.categories = ["", "Informatics"]  # top level module
        self.parent.contributors = ["Steve Pieper (Isomics)"]
        self.parent.helpText = string.Template("""
The DICOM module integrates DICOM classes from CTK (based on DCMTK).  See <a href=\"$a/Documentation/$b.$c/Modules/DICOM\">the documentaiton</a> for more information.
""").substitute({
            'a': parent.slicerWikiUrl,
            'b': slicer.app.majorVersion,
            'c': slicer.app.minorVersion
        })
        self.parent.acknowledgementText = """
This work is supported by NA-MIC, NAC, BIRN, NCIGT, and the Slicer Community. See <a href=http://www.slicer.org>http://www.slicer.org</a> for details.  Module implemented by Steve Pieper.  Based on work from CommonTK (http://www.commontk.org).
    """
        self.parent.icon = qt.QIcon(':Icons/Medium/SlicerLoadDICOM.png')
        self.parent.dependencies = ["SubjectHierarchy"]

        if slicer.mrmlScene.GetTagByClassName(
                "vtkMRMLScriptedModuleNode") != 'ScriptedModule':
            slicer.mrmlScene.RegisterNodeClass(vtkMRMLScriptedModuleNode())

        # initialize the dicom infrastructure
        slicer.dicomDatabase = None
        settings = qt.QSettings()
        # the dicom database is a global object for slicer
        if settings.contains('DatabaseDirectory'):
            databaseDirectory = settings.value('DatabaseDirectory')
            if databaseDirectory:
                slicer.dicomDatabase = ctk.ctkDICOMDatabase()
                slicer.dicomDatabase.openDatabase(
                    databaseDirectory + "/ctkDICOM.sql", "SLICER")
                if not slicer.dicomDatabase.isOpen:
                    # can't open the database, so prompt the user later if they enter module
                    slicer.dicomDatabase = None
                else:
                    # the dicom listener is also global, but only started on app start if
                    # the user so chooses
                    if settings.contains('DICOM/RunListenerAtStart'):
                        if settings.value(
                                'DICOM/RunListenerAtStart') == 'true':
                            if not hasattr(slicer, 'dicomListener'):
                                try:
                                    slicer.dicomListener = DICOMLib.DICOMListener(
                                        slicer.dicomDatabase)
                                    slicer.dicomListener.start()
                                except (UserWarning, OSError) as message:
                                    logging.error(
                                        'Problem trying to start DICOMListener:\n %s'
                                        % message)
                if slicer.dicomDatabase:
                    slicer.app.setDICOMDatabase(slicer.dicomDatabase)

        # Trigger the menu to be added when application has started up
        if not slicer.app.commandOptions().noMainWindow:
            qt.QTimer.singleShot(0, self.addMenu)
        # set the dicom pre-cache tags once all plugin classes have been initialized
        qt.QTimer.singleShot(0, DICOMLib.setDatabasePrecacheTags)
 def icon(self, itemID):
     # As this plugin cannot own any items, it doesn't have an icon either
     # import os
     # iconPath = os.path.join(os.path.dirname(__file__), 'Resources/Icons/MyIcon.png')
     # if self.canOwnSubjectHierarchyItem(itemID) > 0.0 and os.path.exists(iconPath):
     # return qt.QIcon(iconPath)
     # Item unknown by plugin
     return qt.QIcon()
Пример #21
0
 def buttonIcon(self):
     if not self.FILE_NAME:
         return None
     iconPath = os.path.join(
         os.path.dirname(inspect.getfile(self.__class__)),
         '../Resources/Icons', self.FILE_NAME)
     pixmap = qt.QPixmap(iconPath)
     return qt.QIcon(pixmap)
Пример #22
0
 def icon(self, itemID):
     import os
     pluginHandlerSingleton = slicer.qSlicerSubjectHierarchyPluginHandler.instance()
     shNode = pluginHandlerSingleton.subjectHierarchyNode()
     associatedNode = shNode.GetItemDataNode(itemID)
     if associatedNode is not None:
         # ROI
         if associatedNode.IsA("vtkMRMLAnnotationROINode"):
             roiIconPath = os.path.join(os.path.dirname(__file__), '../Resources/Icons/AnnotationROI.png')
             if os.path.exists(roiIconPath):
                 return qt.QIcon(roiIconPath)
         # Ruler
         if associatedNode.IsA("vtkMRMLAnnotationRulerNode"):
             rulerIconPath = os.path.join(os.path.dirname(__file__), '../Resources/Icons/AnnotationDistance.png')
             if os.path.exists(rulerIconPath):
                 return qt.QIcon(rulerIconPath)
     # Item unknown by plugin
     return qt.QIcon()
Пример #23
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)

        # Load UI file
        moduleName = 'Home'
        scriptedModulesPath = os.path.dirname(
            slicer.util.modulePath(moduleName))
        path = os.path.join(scriptedModulesPath, 'Resources', 'UI',
                            moduleName + '.ui')

        self.Widget = slicer.util.loadUI(path)
        self.layout.addWidget(self.Widget)

        # Setup data buttons
        numberOfColumns = 2
        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)

        buttonsLayout = self.get('DataCollapsibleGroupBox').layout()
        columnIndex = 0
        rowIndex = 0

        files = {
            'annotation_25':
            os.path.join(scriptedModulesPath, 'CellLocatorData',
                         'annotation_25.nrrd'),
            'annotation_50':
            os.path.join(scriptedModulesPath, 'CellLocatorData',
                         'annotation_50.nrrd')
        }
        for (file, filepath) in files.iteritems():
            button = qt.QToolButton()
            button.setText(file)

            # Set thumbnail
            thumbnailFileName = os.path.join(scriptedModulesPath, 'Resources',
                                             'Icons', file + '.png')
            button.setIcon(qt.QIcon(thumbnailFileName))
            button.setIconSize(iconSize)
            button.setToolButtonStyle(qt.Qt.ToolButtonTextUnderIcon)
            qSize = qt.QSizePolicy()
            qSize.setHorizontalPolicy(qt.QSizePolicy.Expanding)
            button.setSizePolicy(qSize)

            button.name = '%sPushButton' % file
            buttonsLayout.addWidget(button, rowIndex, columnIndex)
            columnIndex += 1
            if columnIndex == numberOfColumns:
                rowIndex += 1
                columnIndex = 0
            button.connect('clicked()',
                           lambda p=filepath: slicer.util.loadVolume(p))
Пример #24
0
 def __init__(self, parent):
   ScriptedLoadableModule.__init__(self, parent)
   self.parent.title = "DVH Comparison"
   self.parent.categories = ["Radiotherapy"]
   self.parent.dependencies = ["DoseVolumeHistogram"]
   self.parent.contributors = ["Kyle Sunderland (Queen's University), Csaba Pinter (Queen's University)"]
   self.parent.helpText = """This module compares two Dose Volume Histograms from corresponding Table nodes."""
   self.parent.acknowledgementText = """ """
   iconPath = os.path.join(os.path.dirname(self.parent.path), 'Resources/Icons', self.moduleName+'.png')
   parent.icon = qt.QIcon(iconPath)
Пример #25
0
    def __init__(self, parent):
        ScriptedLoadableModule.__init__(self, parent)

        import string
        self.parent.title = "DICOM"
        self.parent.categories = ["", "Informatics"]  # top level module
        self.parent.contributors = ["Steve Pieper (Isomics)"]
        self.parent.helpText = """
The DICOM module integrates DICOM classes from CTK (based on DCMTK).
"""
        self.parent.helpText += self.getDefaultModuleDocumentationLink()
        self.parent.acknowledgementText = """
This work is supported by NA-MIC, NAC, BIRN, NCIGT, and the Slicer Community. See <a href=http://www.slicer.org>http://www.slicer.org</a> for details.  Module implemented by Steve Pieper.  Based on work from CommonTK (http://www.commontk.org).
"""
        self.parent.icon = qt.QIcon(':Icons/Medium/SlicerLoadDICOM.png')
        self.parent.dependencies = ["SubjectHierarchy"]

        if slicer.mrmlScene.GetTagByClassName(
                "vtkMRMLScriptedModuleNode") != 'ScriptedModule':
            slicer.mrmlScene.RegisterNodeClass(vtkMRMLScriptedModuleNode())

        # initialize the dicom infrastructure
        slicer.dicomDatabase = None
        settings = qt.QSettings()
        # the dicom database is a global object for slicer
        if settings.contains('DatabaseDirectory'):
            databaseDirectory = settings.value('DatabaseDirectory')
            if databaseDirectory:
                slicer.dicomDatabase = ctk.ctkDICOMDatabase()
                slicer.dicomDatabase.openDatabase(
                    databaseDirectory + "/ctkDICOM.sql", "SLICER")
                if not slicer.dicomDatabase.isOpen:
                    # can't open the database, so prompt the user later if they enter module
                    slicer.dicomDatabase = None
                else:
                    # the dicom listener is also global, but only started on app start if
                    # the user so chooses
                    if settings.contains('DICOM/RunListenerAtStart'):
                        if settings.value(
                                'DICOM/RunListenerAtStart') == 'true':
                            if not hasattr(slicer, 'dicomListener'):
                                try:
                                    slicer.dicomListener = DICOMLib.DICOMListener(
                                        slicer.dicomDatabase)
                                    slicer.dicomListener.start()
                                except (UserWarning, OSError) as message:
                                    logging.error(
                                        'Problem trying to start DICOMListener:\n %s'
                                        % message)
                if slicer.dicomDatabase:
                    slicer.app.setDICOMDatabase(slicer.dicomDatabase)

        # Tasks to execute after the application has started up
        slicer.app.connect("startupCompleted()",
                           self.performPostModuleDiscoveryTasks)
Пример #26
0
    def __init__(self):
        super().__init__()

        effectPixmap = qt.QPixmap(
            os.path.join(
                os.path.split(WarpDrive.__file__)[0], 'Resources', 'Icons',
                'Add.png'))
        effectIcon = qt.QIcon(effectPixmap)
        self.addButton = qt.QToolButton()
        self.addButton.setToolButtonStyle(qt.Qt.ToolButtonTextUnderIcon)
        self.addButton.setIcon(effectIcon)
        self.addButton.setIconSize(effectPixmap.rect().size())
        self.addButton.setEnabled(True)
        self.addButton.setSizePolicy(qt.QSizePolicy.MinimumExpanding,
                                     qt.QSizePolicy.Maximum)
        self.addButton.clicked.connect(self.onAddButton)

        effectPixmap = qt.QPixmap(
            os.path.join(
                os.path.split(WarpDrive.__file__)[0], 'Resources', 'Icons',
                'Delete.png'))
        effectIcon = qt.QIcon(effectPixmap)
        self.removeButton = qt.QToolButton()
        self.removeButton.setToolButtonStyle(qt.Qt.ToolButtonTextUnderIcon)
        self.removeButton.setIcon(effectIcon)
        self.removeButton.setText('Delete')
        self.removeButton.setIconSize(effectPixmap.rect().size())
        self.removeButton.setEnabled(True)
        self.removeButton.setSizePolicy(qt.QSizePolicy.MinimumExpanding,
                                        qt.QSizePolicy.Maximum)
        self.removeButton.clicked.connect(self.onRemoveButton)

        self.buttonsFrame = qt.QFrame()
        self.buttonsFrame.setSizePolicy(qt.QSizePolicy.Preferred,
                                        qt.QSizePolicy.Minimum)
        self.buttonsFrame.setLayout(qt.QHBoxLayout())
        self.buttonsFrame.layout().addWidget(self.addButton, 1)
        self.buttonsFrame.layout().addWidget(self.removeButton, 1)

        layout = qt.QVBoxLayout(self)
        layout.addWidget(self.buttonsFrame)
        layout.addWidget(self.view)
Пример #27
0
    def modifyWindowUI(self):
        mainToolBar = slicer.util.findChild(slicer.util.mainWindow(),
                                            'MainToolBar')

        self.CustomToolBar = qt.QToolBar("CustomToolBar")
        self.CustomToolBar.name = "CustomToolBar"
        slicer.util.mainWindow().insertToolBar(mainToolBar, self.CustomToolBar)

        moduleIcon = qt.QIcon(":/Icons/Restyle.png")
        self.StyleAction = self.CustomToolBar.addAction(moduleIcon, "")
        self.StyleAction.triggered.connect(self.toggleStyle)
 def build_icon_button(icon_path, on_click, width=50, tooltip=None):
     path = slicer.os.path.dirname(
         slicer.os.path.abspath(inspect.getfile(
             inspect.currentframe()))) + icon_path
     icon = qt.QPixmap(path).scaled(qt.QSize(16, 16), qt.Qt.KeepAspectRatio,
                                    qt.Qt.SmoothTransformation)
     b = qt.QToolButton()
     b.setIcon(qt.QIcon(icon))
     b.setFixedSize(width, 24)
     if tooltip is not None: b.setToolTip(tooltip)
     b.connect('clicked(bool)', on_click)
     return b
Пример #29
0
    def dialogBoxFunction(self):
        self.deleteAllMsgBox = qt.QDialog(slicer.util.mainWindow())
        # self.deleteAllMsgBox.setWindowTitle("Delete All Fiducials?")
        self.deleteAllMsgBox.setFixedSize(200, 100)
        self.deleteAllMsgBox.show()
        self.deleteAllMsgBox.setLayout(qt.QVBoxLayout())

        messageLabel = qt.QLabel("Delete All Fiducials?")
        font = qt.QFont()
        font.setPointSize(10)
        messageLabel.setFont(font)
        self.deleteAllMsgBox.layout().addWidget(messageLabel, 0, 4)

        yesNoBox = qt.QFrame()
        yesNoBox.setLayout(qt.QHBoxLayout())
        self.deleteAllMsgBox.layout().addWidget(yesNoBox, 0, 4)

        #
        # OK button
        #
        okButton = qt.QPushButton()
        okButton.setText("YES")
        okButton.enabled = True
        okIcon = qt.QIcon(":/Icons/AnnotationOkDone.png")
        okButton.setIcon(okIcon)
        yesNoBox.layout().addWidget(okButton)

        #
        # NO button
        #
        noButton = qt.QPushButton()
        noButton.setText("NO")
        noButton.enabled = True
        noIcon = qt.QIcon(":/Icons/AnnotationCancel.png")
        noButton.setIcon(noIcon)
        yesNoBox.layout().addWidget(noButton)

        # Connections
        okButton.connect("clicked()", self.onDeleteAllButton)
        noButton.connect("clicked()", self.deleteAllMsgBox.hide)
Пример #30
0
    def setupToolWatchdog(self):
        logging.debug('USRegistrationGuidelet.setupToolVisibilityIcons')
        self.ui.referenceVisButton.setIcon(
            qt.QIcon(
                os.path.join(self.moduleIconsPath, 'TrackingStatusRed.svg')))
        self.ui.referenceVisLabel.setStyleSheet("color: red")

        self.ui.probeVisButton.setIcon(
            qt.QIcon(
                os.path.join(self.moduleIconsPath, 'TrackingStatusRed.svg')))
        self.ui.probeVisLabel.setStyleSheet("color: red")

        self.ui.stylusVisButton.setIcon(
            qt.QIcon(
                os.path.join(self.moduleIconsPath, 'TrackingStatusRed.svg')))
        self.ui.stylusVisLabel.setStyleSheet("color: red")

        self.watchdog = slicer.mrmlScene.GetFirstNodeByClass(
            'vtkMRMLWatchdogNode')
        if self.watchdog is None:
            self.watchdog = slicer.vtkMRMLWatchdogNode()
            self.watchdog.SetName('TrackingWatchdog')
            slicer.mrmlScene.AddNode(self.watchdog)
        else:
            self.watchdog.RemoveAllDisplayNodeIDs()

        self.watchdog.AddWatchedNode(self.referenceToTracker, 'Reference', 0)
        self.watchdog.AddWatchedNode(self.probeToTracker, 'Probe', 0)
        self.watchdog.AddWatchedNode(self.stylusToTracker, 'Stylus', 0)

        watchdogDisplayNode = slicer.vtkMRMLWatchdogDisplayNode()
        watchdogDisplayNode.SetName('TrackingWatchdogDisplay')
        slicer.mrmlScene.AddNode(watchdogDisplayNode)
        watchdogDisplayNode.AddViewNodeID('vtkMRMLViewNode')
        self.watchdog.SetAndObserveDisplayNodeID(watchdogDisplayNode.GetID())

        qt.QTimer.singleShot(
            200, lambda: self.watchdog.AddObserver(
                vtk.vtkCommand.ModifiedEvent, self.updateToolVisibility))