Exemplo n.º 1
0
  def __init__(self, parent):
    ScriptedLoadableModuleWidget.__init__(self, parent)
    VTKObservationMixin.__init__(self)

    # Members
    self.parameterSetNode = None
    self.editor = None
Exemplo n.º 2
0
 def __init__(self, parent=None):
     """
 Called when the user opens the module the first time and the widget is initialized.
 """
     ScriptedLoadableModuleWidget.__init__(self, parent)
     VTKObservationMixin.__init__(
         self)  # needed for parameter node observation
     self.logic = None
     self._parameterNode = None
     # Create segment editor to get access to effects
     segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
     # To show segment editor widget (useful for debugging): segmentEditorWidget.show()
     segmentEditorWidget.setMRMLScene(slicer.mrmlScene)
     if not segmentEditorWidget.effectByName("Wrap Solidify"):
         if slicer.util.confirmOkCancelDisplay(
                 "SegmentEndocranium requires installation of the SurfaceWrapSolidify extension.\nClick OK to install and restart the application."
         ):
             extensionName = 'SurfaceWrapSolidify'
             em = slicer.app.extensionsManagerModel()
             if not em.isExtensionInstalled(extensionName):
                 extensionMetaData = em.retrieveExtensionMetadataByName(
                     extensionName)
                 url = f"{em.serverUrl().toString()}/api/v1/item/{extensionMetaData['_id']}/download"
                 extensionPackageFilename = slicer.app.temporaryPath + '/' + extensionMetaData[
                     '_id']
                 slicer.util.downloadFile(url, extensionPackageFilename)
                 em.interactive = False  # Disable popups (automatically install dependencies)
                 em.installExtension(extensionPackageFilename)
                 slicer.util.restart()
Exemplo n.º 3
0
  def __init__(self, parent=None):
    VTKObservationMixin.__init__(self)

    self.editUtil = EditUtil() # Kept for backward compatibility

    # mrml volume node instances
    self.master = None
    self.masterWhenMergeWasSet = None
    # Editor color LUT
    self.colorNodeID = None
    # string
    self.createMergeOptions = ""
    self.mergeVolumePostfix = "-label"
    # slicer helper class
    self.volumesLogic = slicer.modules.volumes.logic()
    # widgets that are dynamically created on demand
    # pseudo signals
    # - python callable that gets True or False
    self.selectCommand = None

    if not parent:
      self.parent = slicer.qMRMLWidget()
      self.parent.setLayout(qt.QVBoxLayout())
      self.parent.setMRMLScene(slicer.mrmlScene)
      self.create()
      self.parent.show()
    else:
      self.parent = parent
      self.create()
 def __init__(self):
   ScriptedLoadableModuleLogic.__init__(self)
   VTKObservationMixin.__init__(self)  # needed for parameter node observation
   self._parameterNode = None
   self._volumeNode = None
   self._markupsNode = None
   self._mode = "None"
Exemplo n.º 5
0
    def __init__(self, parent):
        ScriptedLoadableModuleWidget.__init__(self, parent)
        VTKObservationMixin.__init__(self)

        # Members
        self.parameterSetNode = None
        self.editor = None
Exemplo n.º 6
0
    def __init__(self, parent=None):
        VTKObservationMixin.__init__(self)
        self.parent = parent
        self.updatingGUI = False
        self.widgets = []
        self.parameterNode = None
        self.parameterNodeTag = None
        self.editUtil = EditUtil()  # Kept for backward compatibility
        self.tools = []

        # connections is a list of widget/signal/slot tripples
        # for the options gui that can be connected/disconnected
        # as needed to prevent triggering mrml updates while
        # updating the state of the gui
        # - each level of the inheritance tree can add entries
        #   to this list for use by the connectWidgets
        #   and disconnectWidgets methods
        self.connections = []
        self.connectionsConnected = False

        # 1) find the parameter node in the scene and observe it
        # 2) set the defaults (will only set them if they are not
        # already set)
        self.updateParameterNode(self.parameterNode,
                                 vtk.vtkCommand.ModifiedEvent)

        # TODO: change this to look for specfic events (added, removed...)
        # but this requires being able to access events by number from wrapped code
        self.addObserver(slicer.mrmlScene, vtk.vtkCommand.ModifiedEvent,
                         self.updateParameterNode)
Exemplo n.º 7
0
    def __init__(self, parent=None):
        VTKObservationMixin.__init__(self)

        self.editUtil = EditUtil()  # Kept for backward compatibility

        # mrml volume node instances
        self.master = None
        self.masterWhenMergeWasSet = None
        # Editor color LUT
        self.colorNodeID = None
        # string
        self.createMergeOptions = ""
        self.mergeVolumePostfix = "-label"
        # slicer helper class
        self.volumesLogic = slicer.modules.volumes.logic()
        # widgets that are dynamically created on demand
        # pseudo signals
        # - python callable that gets True or False
        self.selectCommand = None

        if not parent:
            self.parent = slicer.qMRMLWidget()
            self.parent.setLayout(qt.QVBoxLayout())
            self.parent.setMRMLScene(slicer.mrmlScene)
            self.create()
            self.parent.show()
        else:
            self.parent = parent
            self.create()
 def __init__(self, parent=None):
     """
     Called when the user opens the module the first time and the widget is initialized.
     """
     ScriptedLoadableModuleWidget.__init__(self, parent)
     VTKObservationMixin.__init__(self)
     self.logic = None
Exemplo n.º 9
0
  def __init__(self, dicomBrowser=None, parent="mainWindow"):
    VTKObservationMixin.__init__(self)
    qt.QWidget.__init__(self, slicer.util.mainWindow() if parent == "mainWindow" else parent)

    self.pluginInstances = {}
    self.fileLists = []
    self.extensionCheckPending = False

    self.settings = qt.QSettings()

    self.dicomBrowser = dicomBrowser if dicomBrowser is not None else slicer.app.createDICOMBrowserForMainDatabase()

    self.browserPersistent = settingsValue('DICOM/BrowserPersistent', False, converter=toBool)
    self.advancedView = settingsValue('DICOM/advancedView', 0, converter=int)
    self.horizontalTables = settingsValue('DICOM/horizontalTables', 0, converter=int)

    self.setup()

    self.dicomBrowser.connect('directoryImported()', self.onDirectoryImported)
    self.dicomBrowser.connect('sendRequested(QStringList)', self.onSend)

    # Load when double-clicked on an item in the browser
    self.dicomBrowser.dicomTableManager().connect('patientsDoubleClicked(QModelIndex)', self.patientStudySeriesDoubleClicked)
    self.dicomBrowser.dicomTableManager().connect('studiesDoubleClicked(QModelIndex)', self.patientStudySeriesDoubleClicked)
    self.dicomBrowser.dicomTableManager().connect('seriesDoubleClicked(QModelIndex)', self.patientStudySeriesDoubleClicked)
Exemplo n.º 10
0
  def __init__(self, parent=None):
    VTKObservationMixin.__init__(self)
    self.parent = parent
    self.updatingGUI = False
    self.widgets = []
    self.parameterNode = None
    self.parameterNodeTag = None
    self.editUtil = EditUtil() # Kept for backward compatibility
    self.tools = []

    # connections is a list of widget/signal/slot tripples
    # for the options gui that can be connected/disconnected
    # as needed to prevent triggering mrml updates while
    # updating the state of the gui
    # - each level of the inheritance tree can add entries
    #   to this list for use by the connectWidgets
    #   and disconnectWidgets methods
    self.connections = []
    self.connectionsConnected = False

    # 1) find the parameter node in the scene and observe it
    # 2) set the defaults (will only set them if they are not
    # already set)
    self.updateParameterNode(self.parameterNode, vtk.vtkCommand.ModifiedEvent)

    # TODO: change this to look for specfic events (added, removed...)
    # but this requires being able to access events by number from wrapped code
    self.addObserver(slicer.mrmlScene, vtk.vtkCommand.ModifiedEvent, self.updateParameterNode)
    def __init__(self, parent):
        ScriptedLoadableModuleWidget.__init__(self, parent)
        VTKObservationMixin.__init__(self)

        self.logic = BiplaneRegistrationLogic()
        self.xTransformObserver = None
        self.yTransformObserver = None
Exemplo n.º 12
0
  def __init__(self):

    toolTip = 'None. Disable Effects.'
    AbstractToolWidget.__init__(self, 'None', toolTip)
    VTKObservationMixin.__init__(self)

    interactionNode = slicer.mrmlScene.GetFirstNodeByClass('vtkMRMLInteractionNode')
    self.addObserver(interactionNode, interactionNode.InteractionModeChangedEvent, self.onInteractionModeChanged) 
Exemplo n.º 13
0
 def __init__(self, parent=None):
     ScriptedLoadableModuleWidget.__init__(self, parent)
     VTKObservationMixin.__init__(
         self)  # needed for parameter node observation
     self.logic = None
     self._parameterNode = None
     self._inputCurveNode = None
     self._updatingParameterNodeFromGUI = False
 def __init__(self, parent=None):
   """
   Called when the user opens the module the first time and the widget is initialized.
   """
   ScriptedLoadableModuleWidget.__init__(self, parent)
   VTKObservationMixin.__init__(self)  # needed for parameter node observation
   self.logic = None
   self._parameterNode = None
Exemplo n.º 15
0
 def __init__(self, anglePlanes):
     VTKObservationMixin.__init__(self)
     self.addObserver(slicer.mrmlScene, slicer.vtkMRMLScene.NodeAddedEvent,
                      self.nodeAddedCallback)
     self.addObserver(slicer.mrmlScene,
                      slicer.vtkMRMLScene.NodeRemovedEvent,
                      self.nodeRemovedCallback)
     self.anglePlanes = anglePlanes
Exemplo n.º 16
0
 def __init__(self, parent):
     ScriptedLoadableModuleWidget.__init__(self, parent)
     # needed for event observation:
     VTKObservationMixin.__init__(self)
     self.firstLoad = True
     self.activeEditorTools = None
     self.inputVolume = None
     self.outputSegmentation = None
     self.labelmapVolumeNode = None
Exemplo n.º 17
0
 def __init__(self, interface):
     logging.debug("----- Bone Texture logic init -----")
     ScriptedLoadableModuleLogic.__init__(self)
     VTKObservationMixin.__init__(self)
     self.interface = interface
     # Outputs:
     self.featuresGLCM = None
     self.featuresGLRLM = None
     self.featuresBM = None
Exemplo n.º 18
0
    def __init__(self):
        VTKObservationMixin.__init__(self)

        cli = slicer.vtkMRMLCommandLineModuleNode()
        self.StatusModifiedEvent = cli.StatusModifiedEvent
        self.StatusEvents = []

        self.ExecutionFinished = False
        self.StatusEventCallback = None
  def __init__(self, interface):
    VTKObservationMixin.__init__(self)

    self.interface = interface
    self.StatusModifiedEvent = slicer.vtkMRMLCommandLineModuleNode().StatusModifiedEvent
    self.shape4D_module = slicer.modules.shape4d
    self.shape4D_cli_node = slicer.cli.createNode(self.shape4D_module)
    shape4D_cli_node_name = "Shape4D"
    self.shape4D_cli_node.SetName(shape4D_cli_node_name)
Exemplo n.º 20
0
  def __init__(self):
    VTKObservationMixin.__init__(self)

    cli = slicer.vtkMRMLCommandLineModuleNode()
    self.StatusModifiedEvent = cli.StatusModifiedEvent
    self.StatusEvents = []

    self.ExecutionFinished = False
    self.StatusEventCallback = None
Exemplo n.º 21
0
 def __init__(self, parent):
     ScriptedLoadableModule.__init__(self, parent)
     VTKObservationMixin.__init__(self)
     self.parent.title = "Curve Comparison"
     self.parent.categories = [""]
     self.parent.dependencies = []
     self.parent.contributors = [""]
     self.parent.helpText = """"""
     self.parent.helpText += self.getDefaultModuleDocumentationLink()
     self.parent.acknowledgementText = """"""
Exemplo n.º 22
0
  def __init__(self, parent=None):
    """
    Called when the user opens the module the first time and the widget is initialized.
    """
    ScriptedLoadableModuleWidget.__init__(self, parent)
    VTKObservationMixin.__init__(self)  # needed for parameter node observation
    self.logic = None
    self._parameterNode = None
    self._updatingGUIFromParameterNode = False

    self.ultrasoundControlsLayout = None
Exemplo n.º 23
0
 def __init__(self):
     VTKObservationMixin.__init__(self)
     WarpDriveCorrectionsTable.__init__(self)
     self.sourceFiducialNodeID = ""
     self.targetFiducialNodeID = ""
     self._updatingFiducials = False
     self.targetFiducialObservers = []
     self.sourceFiducialObservers = []
     self.parameterNode = WarpDrive.WarpDriveLogic().getParameterNode()
     self.addObserver(self.parameterNode, vtk.vtkCommand.ModifiedEvent,
                      self.updateNodesListeners)
 def __init__(self):
     qt.QWidget.__init__(self)
     VTKObservationMixin.__init__(self)
     self._cmdSetParameter = None
     self._cmdGetParameter = None
     self._interactionInProgress = False
     self._deviceID = ""
     self._parameterName = ""
     self._connectorNode = None
     self._periodicParameterTimer = qt.QTimer()
     self._periodicParameterTimer.connect(
         "timeout()", self.sendGetUltrasoundParameterCommand)
Exemplo n.º 25
0
 def __init__(self, parent=None):
     # Init methods provided by Slicer
     ScriptedLoadableModuleWidget.__init__(self, parent)
     VTKObservationMixin.__init__(self)
     self.ui = None
     self.featureStorage = None
     self.featureStoragePath = None
     self.predictionStorage = None
     self.predictionStoragePath = None
     self.total_time = None
     self.messageBox = None
     self.checkedIdx = 0
Exemplo n.º 26
0
 def __init__(self, parent=None):
     """
     Called when the user opens the module the first time and the widget is initialized.
     """
     ScriptedLoadableModuleWidget.__init__(self, parent)
     VTKObservationMixin.__init__(self)  # needed for parameter node observation
     self.logic = None
     self._parameterNode = None
     self._rightLungFiducials = None
     self._leftLungFiducials = None
     self._tracheaFiducials = None
     self._updatingGUIFromParameterNode = False
     self.createDetailedAirways = False
Exemplo n.º 27
0
  def __init__(self, parent = None):
    ScriptedLoadableModuleLogic.__init__(self, parent)
    VTKObservationMixin.__init__(self)

    # Define member variables
    self.defaultSceneSavePath = os.path.join(qt.QDir.toNativeSeparators(qt.QDir.home().absolutePath()), 'FirstTask', 'Snapshots')
    self.fileDir = os.path.dirname(__file__)

    # Setup scene
    self.setupScene()

    # Setup keyboard shortcuts
    self.setupKeyboardShortcuts()
Exemplo n.º 28
0
  def __init__(self, parent=None):
    """
    Called when the user opens the module the first time and the widget is initialized.
    """
    ScriptedLoadableModuleWidget.__init__(self, parent)
    VTKObservationMixin.__init__(self)  # needed for parameter node observation
    self.logic = None
    self._parameterNode = None
    self._updatingGUIFromParameterNode = False

    self.tbl_selected_sid = ""
    self.tblSelectedIndex = None
    self.table_lock = False
Exemplo n.º 29
0
  def __init__(self,dicomBrowser=None):
    VTKObservationMixin.__init__(self)
    self.dicomBrowser = dicomBrowser

    # initialize the dicomDatabase
    #   - pick a default and let the user know
    if not slicer.dicomDatabase:
      self.promptForDatabaseDirectory()

    if self.dicomBrowser is None:
      # This creates a DICOM database in the current working directory if nothing else
      # is specified in the settings, therefore promptForDatabaseDirectory must be called before this.
      self.dicomBrowser = ctk.ctkDICOMBrowser()

    self.browserPersistent = settingsValue('DICOM/BrowserPersistent', False, converter=toBool)
    self.tableDensity = settingsValue('DICOM/tableDensity', 'Compact')
    self.popupGeometry = settingsValue('DICOM/detailsPopup.geometry', qt.QRect())
    self.advancedView = settingsValue('DICOM/advancedView', 0, converter=int)
    self.horizontalTables = settingsValue('DICOM/horizontalTables', 0, converter=int)
    self.volumeNameTemplate = settingsValue('DICOM/volumeNameTemplate', "")

    self.create()
    self.popupPositioned = False
    self.pluginInstances = {}
    self.fileLists = []

    setDatabasePrecacheTags(self.dicomBrowser)

    self.dicomBrowser.connect('databaseDirectoryChanged(QString)', self.onDatabaseDirectoryChanged)

    # Update visibility
    for name in [
      'ActionImport', 'ActionExport', 'ActionQuery', 'ActionSend', 'ActionRemove', 'ActionRepair',
      'ActionViewMetadata',
      'AdvancedViewCheckBox', 'HorizontalViewCheckBox', 'BrowserPersistentCheckBox'
    ]:
      visible = settingsValue('DICOM/%s.visible' % name, True, converter=toBool)
      control = self._findChildren(name)
      control.visible = visible

    # Define set of widgets that should be hidden/shown together
    self.settingsWidgetNames = {
      'DatabaseButton' : ('DatabaseNameLabel', 'DirectoryButton'),
      'TableDensityComboBox' : ('tablesDensityLabel', 'tableDensityComboBox')
    }

    # Hide the settings button if all associated widgets should be hidden
    settingsButtonHidden = True
    for groupName in self.settingsWidgetNames.keys():
      settingsButtonHidden = settingsButtonHidden and not settingsValue('DICOM/%s.visible' % groupName, True, converter=toBool)
    self.settingsButton.visible = not settingsButtonHidden
Exemplo n.º 30
0
  def __init__(self, parent=None):
    """
    Called when the user opens the module the first time and the widget is initialized.
    """
    ScriptedLoadableModuleWidget.__init__(self, parent)
    VTKObservationMixin.__init__(self)  # needed for parameter node observation

    self.logic = None
    self._parameterNode = None
    self._updatingGUIFromParameterNode = False
    self._nodeAddedObserverTag = None

    self._inputSegmentationNodeSelector = None
    self._resectionsTableView = None
Exemplo n.º 31
0
 def __init__(self, parent=None):
     """
 Called when the user opens the module the first time and the widget is initialized.
 """
     ScriptedLoadableModuleWidget.__init__(self, parent)
     VTKObservationMixin.__init__(
         self)  # needed for parameter node observation
     self.logic = None
     self._parameterNode = None
     self._updatingGUIFromParameterNode = False
     # Widget level observations to update module UI. Logic class has its own.
     self.widgetMarkupPointsObservations = []
     # Remove observers on previous path when currrent node has changed
     self.currentPathNode = None
    def __init__(self, parent=None):
        """
    Called when the user opens the module the first time and the widget is initialized.
    """
        ScriptedLoadableModuleWidget.__init__(self, parent)
        VTKObservationMixin.__init__(
            self)  # needed for parameter node observation
        self.logic = None
        self._parameterNode = None

        # Class Parameters
        self.calibrationErrorThresholdMm = 0.9
        self.PIVOT_CALIBRATION = 0
        self.SPIN_CALIBRATION = 1
Exemplo n.º 33
0
  def __init__(self,dicomBrowser=None):
    VTKObservationMixin.__init__(self)
    self.dicomBrowser = dicomBrowser
    
    # initialize the dicomDatabase
    #   - pick a default and let the user know
    if not slicer.dicomDatabase:
      self.promptForDatabaseDirectory()
    
    if self.dicomBrowser == None:
      # This creates a DICOM database in the current working directory if nothing else
      # is specified in the settings, therefore promptForDatabaseDirectory must be called before this.
      self.dicomBrowser = ctk.ctkDICOMBrowser()

    self.browserPersistent = settingsValue('DICOM/BrowserPersistent', False, converter=toBool)
    self.tableDensity = settingsValue('DICOM/tableDensity', 'Compact')
    self.popupGeometry = settingsValue('DICOM/detailsPopup.geometry', qt.QRect())
    self.advancedView = settingsValue('DICOM/advancedView', 0, converter=int)
    self.horizontalTables = settingsValue('DICOM/horizontalTables', 0, converter=int)

    self.create()
    self.popupPositioned = False
    self.pluginInstances = {}
    self.fileLists = []

    setDatabasePrecacheTags(self.dicomBrowser)

    self.dicomBrowser.connect('databaseDirectoryChanged(QString)', self.onDatabaseDirectoryChanged)

    # Update visibility
    for name in [
        'ActionImport', 'ActionExport', 'ActionQuery', 'ActionSend', 'ActionRemove', 'ActionRepair',
        'ActionViewMetadata',
        'AdvancedViewCheckBox', 'HorizontalViewCheckBox', 'BrowserPersistentCheckBox'
        ]:
      visible = settingsValue('DICOM/%s.visible' % name, True, converter=toBool)
      control = self._findChildren(name)
      control.visible = visible

    # Define set of widgets that should be hidden/shown together
    self.settingsWidgetNames = {
      'DatabaseButton' : ('DatabaseNameLabel', 'DirectoryButton'),
      'TableDensityComboBox' : ('tablesDensityLabel', 'tableDensityComboBox')
      }

    # Hide the settings button if all associated widgets should be hidden
    settingsButtonHidden = True
    for groupName in self.settingsWidgetNames.keys():
      settingsButtonHidden = settingsButtonHidden and not settingsValue('DICOM/%s.visible' % groupName, True, converter=toBool)
    self.settingsButton.visible = not settingsButtonHidden
Exemplo n.º 34
0
  def __init__(self, parent=None):
    ScriptedLoadableModuleWidget.__init__(self, parent)
    VTKObservationMixin.__init__(self)  # needed for parameter node observation
    self.logic = None
    self._parameterNode = None
    self.unet_model = None
    self.predicting = False
    self.inputModifiedObserver = None
    self.inputImageNode = None
    self.outputImageNode = None
    self.slicer_to_model_scaling = 1.0
    self.model_to_slicer_scaling = 1.0

    self.apply_logarithmic_transformation = True
    self.logarithmic_transformation_decimals = 4
Exemplo n.º 35
0
 def __init__(self, parent=0, parameter='label',colorNode=None):
   VTKObservationMixin.__init__(self)
   self.parameterNode = None
   self.parameterNodeTag = None
   self.parameter = parameter
   self.colorBox = None
   self.colorNode = colorNode
   if parent == 0:
     self.parent = slicer.qMRMLWidget()
     self.parent.setLayout(qt.QVBoxLayout())
     self.parent.setMRMLScene(slicer.mrmlScene)
     self.create()
     self.parent.show()
   else:
     self.parent = parent
     self.create()
Exemplo n.º 36
0
 def __init__(self, parent=0, parameter='label', colorNode=None):
     VTKObservationMixin.__init__(self)
     self.parameterNode = None
     self.parameterNodeTag = None
     self.parameter = parameter
     self.colorBox = None
     self.colorNode = colorNode
     if parent == 0:
         self.parent = slicer.qMRMLWidget()
         self.parent.setLayout(qt.QVBoxLayout())
         self.parent.setMRMLScene(slicer.mrmlScene)
         self.create()
         self.parent.show()
     else:
         self.parent = parent
         self.create()
Exemplo n.º 37
0
  def __init__(self, ModuleNodeName):
    VTKObservationMixin.__init__(self)

    self.InputCases = list()
    self.allCaseStartTime = 0

    # Dictionaries
    self.pipeline = {}
    self.completed = {}

    # Status
    self.Node = slicer.vtkMRMLCommandLineModuleNode()
    self.Node.SetStatus(self.Node.Idle)
    self.Node.SetName(ModuleNodeName)
    self.ProgressBar = slicer.qSlicerCLIProgressBar()
    self.ProgressBar.setCommandLineModuleNode(self.Node)
    self.ProgressBar.setNameVisibility(slicer.qSlicerCLIProgressBar.AlwaysVisible)
    self.ErrorMessage = 'Unexpected error'
Exemplo n.º 38
0
  def __init__(self, parent=None, showVolumesFrame=True):
    VTKObservationMixin.__init__(self)
    self.shortcuts = []
    self.toolsBox = None

    # set attributes from ctor parameters
    self.showVolumesFrame = showVolumesFrame

    self.editUtil = EditUtil() # Kept for backward compatibility

    if not parent:
      self.parent = slicer.qMRMLWidget()
      self.parent.setLayout(qt.QVBoxLayout())
      self.parent.setMRMLScene(slicer.mrmlScene)
      self.layout = self.parent.layout()
    else:
      self.parent = parent
      self.layout = parent.layout()

    ScriptedLoadableModuleWidget.__init__(self, parent)
Exemplo n.º 39
0
  def __init__(self, scene=None):
    """Add observers to the mrmlScene and also to all the nodes of the scene"""
    VTKObservationMixin.__init__(self)

    if scene:
      self._scene = scene
    else:
      self._scene = slicer.mrmlScene
    self.addObserver(scene, scene.NodeAddedEvent, self.onNodeAdded)
    self.addObserver(scene, scene.NodeRemovedEvent, self.onNodeRemoved)

    scene.InitTraversal()
    node = scene.GetNextNode()
    while node:
      self._observeNode(node)
      node = scene.GetNextNode()

    # a dictionary of (nodeKey,eventKey) -> callback
    # where nodeKey is classname "vtkMRML{nodeKey}Node"
    # and eventKey is tested for equality to "{eventKey}Event"
    self._triggers = {}
Exemplo n.º 40
0
  def __init__(self, pipelineID, CaseInput, interface):

    VTKObservationMixin.__init__(self)

    self.pipelineID = pipelineID
    self.strPipelineID = "_" + str(self.pipelineID)
    self.CaseInput = CaseInput

    # Pipeline computation time
    self.pipelineStartTime = 0
    self.pipelineEndTime = 0

    # Status
    self.StatusModifiedEvent = slicer.vtkMRMLCommandLineModuleNode().StatusModifiedEvent
    self.Node = slicer.vtkMRMLCommandLineModuleNode()
    self.Node.SetStatus(self.Node.Idle)
    self.Node.SetName('Case ' + str(self.pipelineID))
    self.currentCLINode = None
    self.ProgressBar = slicer.qSlicerCLIProgressBar()
    self.ProgressBar.setCommandLineModuleNode(self.Node)
    self.ProgressBar.setNameVisibility(slicer.qSlicerCLIProgressBar.AlwaysVisible)
    self.ErrorMessage = 'Unexpected error'
 def __init__(self, anglePlanes):
     VTKObservationMixin.__init__(self)
     self.addObserver(slicer.mrmlScene, slicer.vtkMRMLScene.NodeAddedEvent, self.nodeAddedCallback)
     self.addObserver(slicer.mrmlScene, slicer.vtkMRMLScene.NodeRemovedEvent, self.nodeRemovedCallback)
     self.anglePlanes = anglePlanes
Exemplo n.º 42
0
  def __init__(self, layoutManager=None):
    VTKObservationMixin.__init__(self)
    self.hasVTKPVScalarBarActor = hasattr(slicer, 'vtkPVScalarBarActor')
    if not self.hasVTKPVScalarBarActor:
      slicer.logging.warning("SliceAnnotations: Disable features relying on vtkPVScalarBarActor")

    self.layoutManager = layoutManager
    if self.layoutManager is None:
      self.layoutManager = slicer.app.layoutManager()
    self.layoutManager.connect("destroyed()", self.onLayoutManagerDestroyed)

    self.dataProbeUtil = DataProbeUtil.DataProbeUtil()

    self.dicomVolumeNode = 0
    self.sliceViewNames = []
    self.popupGeometry = qt.QRect()
    self.cornerTexts =[]
    # Bottom Left Corner Text
    self.cornerTexts.append({
      '1-Label':{'text':'','category':'A'},
      '2-Foreground':{'text':'','category':'A'},
      '3-Background':{'text':'','category':'A'}
      })
    # Bottom Right Corner Text
    # Not used - orientation figure may be drawn there
    self.cornerTexts.append({
      '1-TR':{'text':'','category':'A'},
      '2-TE':{'text':'','category':'A'}
      })
    # Top Left Corner Text
    self.cornerTexts.append({
      '1-PatientName':{'text':'','category':'B'},
      '2-PatientID':{'text':'','category':'A'},
      '3-PatientInfo':{'text':'','category':'B'},
      '4-Bg-SeriesDate':{'text':'','category':'B'},
      '5-Fg-SeriesDate':{'text':'','category':'B'},
      '6-Bg-SeriesTime':{'text':'','category':'C'},
      '7-Bg-SeriesTime':{'text':'','category':'C'},
      '8-Bg-SeriesDescription':{'text':'','category':'C'},
      '9-Fg-SeriesDescription':{'text':'','category':'C'}
      })
    # Top Right Corner Text
    self.cornerTexts.append({
      '1-Institution-Name':{'text':'','category':'B'},
      '2-Referring-Phisycian':{'text':'','category':'B'},
      '3-Manufacturer':{'text':'','category':'C'},
      '4-Model':{'text':'','category':'C'},
      '5-Patient-Position':{'text':'','category':'A'},
      '6-TR':{'text':'','category':'A'},
      '7-TE':{'text':'','category':'A'}
      })

    self.annotationsDisplayAmount = 0

    #
    self.scene = slicer.mrmlScene
    self.sliceViews = {}

    # If there are no user settings load defaults
    self.sliceViewAnnotationsEnabled = settingsValue('DataProbe/sliceViewAnnotations.enabled', 1, converter=int)

    self.bottomLeft = settingsValue('DataProbe/sliceViewAnnotations.bottomLeft', 1, converter=int)
    self.topLeft = settingsValue('DataProbe/sliceViewAnnotations.topLeft', 0, converter=int)
    self.topRight = settingsValue('DataProbe/sliceViewAnnotations.topRight', 0, converter=int)
    self.fontFamily = settingsValue('DataProbe/sliceViewAnnotations.fontFamily', 'Times')
    self.fontSize = settingsValue('DataProbe/sliceViewAnnotations.fontSize', 14, converter=int)
    self.backgroundDICOMAnnotationsPersistence = settingsValue(
        'DataProbe/sliceViewAnnotations.bgDICOMAnnotationsPersistence', 0, converter=int)

    self.scalarBarEnabled = settingsValue('DataProbe/sliceViewAnnotations.scalarBarEnabled', 0, converter=int)
    self.scalarBarEnabledLastStatus = self.scalarBarEnabled
    self.scalarBarSelectedLayer = 'background'
    self.rangeLabelFormat = settingsValue('DataProbe/sliceViewAnnotations.rangeLabelFormat', '%G')

    self.parameter = 'sliceViewAnnotationsEnabled'
    self.parameterNode = self.dataProbeUtil.getParameterNode()
    self.addObserver(self.parameterNode, vtk.vtkCommand.ModifiedEvent, self.updateGUIFromMRML)

    self.maximumTextLength= 35

    self.create()

    if self.sliceViewAnnotationsEnabled:
      self.updateSliceViewFromGUI()
Exemplo n.º 43
0
  def __init__(self, parent=None, optionsFrame=None):
    VTKObservationMixin.__init__(self)
    self.effects = []
    self.effectButtons = {}
    self.effectCursors = {}
    self.effectActionGroup = qt.QActionGroup(parent)
    self.effectActionGroup.connect('triggered(QAction*)', self._onEffectActionTriggered)
    self.effectActionGroup.exclusive = True
    self.currentEffect = None
    self.undoRedo = UndoRedo()
    self.undoRedo.stateChangedCallback = self.updateUndoRedoButtons
    self.toggleShortcut = None

    # check for extensions - if none have been registered, just create the empty dictionary
    try:
      slicer.modules.editorExtensions
    except AttributeError:
      slicer.modules.editorExtensions = {}

    # register the builtin extensions
    self.editorBuiltins = {}
    self.editorBuiltins["PaintEffect"] = EditorLib.PaintEffect
    self.editorBuiltins["DrawEffect"] = EditorLib.DrawEffect
    self.editorBuiltins["ThresholdEffect"] = EditorLib.ThresholdEffect
    self.editorBuiltins["RectangleEffect"] = EditorLib.RectangleEffect
    self.editorBuiltins["LevelTracingEffect"] = EditorLib.LevelTracingEffect
    self.editorBuiltins["MakeModelEffect"] = EditorLib.MakeModelEffect
    self.editorBuiltins["ErodeEffect"] = EditorLib.ErodeEffect
    self.editorBuiltins["DilateEffect"] = EditorLib.DilateEffect
    self.editorBuiltins["ChangeLabelEffect"] = EditorLib.ChangeLabelEffect
    self.editorBuiltins["RemoveIslandsEffect"] = EditorLib.RemoveIslandsEffect
    self.editorBuiltins["IdentifyIslandsEffect"] = EditorLib.IdentifyIslandsEffect
    self.editorBuiltins["SaveIslandEffect"] = EditorLib.SaveIslandEffect
    self.editorBuiltins["ChangeIslandEffect"] = EditorLib.ChangeIslandEffect
    self.editorBuiltins["GrowCutEffect"] = EditorLib.GrowCutEffect
    self.editorBuiltins["WatershedFromMarkerEffect"] = EditorLib.WatershedFromMarkerEffect
    self.editorBuiltins["FastMarchingEffect"] = EditorLib.FastMarchingEffect
    self.editorBuiltins["WandEffect"] = EditorLib.WandEffect

    # frame that holds widgets specific for each effect
    if not optionsFrame:
      self.optionsFrame = qt.QFrame(self.parent)
      self.optionsFrame.objectName = 'OptionsFrame'
    else:
      self.optionsFrame = optionsFrame

    # state variables for selected effect in the box
    # - currentOption is an instance of an option GUI
    # - currentTools is a list of EffectTool instances
    self.currentOption = None
    self.currentTools = []

    # listen for changes in the Interaction Mode
    interactionNode = slicer.app.applicationLogic().GetInteractionNode()
    self.addObserver(interactionNode, interactionNode.InteractionModeChangedEvent, self.onInteractionModeChanged)

    # Listen for changed on the Parameter node
    self.addObserver(EditUtil.getParameterNode(), vtk.vtkCommand.ModifiedEvent, self._onParameterNodeModified)

    if not parent:
      self.parent = qt.QFrame()
      self.parent.setLayout( qt.QVBoxLayout() )
      self.create()
      self.parent.show()
    else:
      self.parent = parent
      self.create()
 def __init__(self):
   VTKObservationMixin.__init__(self)
   self.ModifiedEventCount = {}
Exemplo n.º 45
0
 def __init__(self, parent=None):
   ScriptedLoadableModuleWidget.__init__(self, parent)
   VTKObservationMixin.__init__(self)
   self.logic = None
   self._parameterNode = None