示例#1
0
 def createWindowImages(self):
   widgetPixmapL = qt.QPixmap.grabWidget(self.leftWidgets)
   file = qt.QFile("C:/Work/data/left.jpg")
   file.open(qt.QIODevice.WriteOnly)
   widgetPixmapL.save(file, "JPEG", 100)
   
   if (self.stereoMode is True):
     widgetPixmapR = qt.QPixmap.grabWidget(self.rightWidgets)
     fileR = qt.QFile("C:/Work/data/right.jpg")
     fileR.open(qt.QIODevice.WriteOnly)
     widgetPixmapR.save(fileR, "JPEG", 100)
示例#2
0
 def loadUIFile(self, fileName):
     """ Return the object defined in the Qt Designer file """
     uiloader = qt.QUiLoader()
     qfile = qt.QFile(os.path.join(__slicer_module__, fileName))
     qfile.open(qt.QFile.ReadOnly)
     try:
         return uiloader.load(qfile)
     finally:
         qfile.close()
示例#3
0
  def loadStyleSheet(self):
    styleFilePath = os.path.join(self.logic.fileDir, 'Resources', 'StyleSheets', 'FirstTaskStyle.qss')
    f = qt.QFile(styleFilePath)
    if not f.exists():
      logging.error("Unable to load stylesheet, file not found")
      return ""

    f.open(qt.QFile.ReadOnly | qt.QFile.Text)
    ts = qt.QTextStream(f)
    stylesheet = ts.readAll()
    return stylesheet
示例#4
0
 def loadStyleSheet(self):
     moduleDir = os.path.dirname(__file__)
     style = self.parameterNode.GetParameter('StyleSheet')
     styleFile = os.path.join(moduleDir, 'Resources', 'StyleSheets', style)
     f = qt.QFile(styleFile)
     if not f.exists():
         logging.debug("Unable to load stylesheet, file not found")
         return ""
     else:
         f.open(qt.QFile.ReadOnly | qt.QFile.Text)
         ts = qt.QTextStream(f)
         stylesheet = ts.readAll()
         return stylesheet
示例#5
0
    def setup(self):

        loader = qt.QUiLoader()
        moduleName = 'ScenePerformance'  #scriptedModulesPath = '/Users/exxos/Work/Slicer/Slicer4/Slicer-Debug/Slicer-build/lib/Slicer-4.2/qt-scripted-modules'
        scriptedModulesPath = eval('slicer.modules.%s.path' %
                                   moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)
        path = os.path.join(scriptedModulesPath, 'Resources', 'UI',
                            'ScenePerformance.ui')

        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile, self.parent)
        self.layout = self.parent.layout()
        self.layout.addWidget(widget)

        self.reloadButton = qt.QPushButton("Reload")
        self.reloadButton.toolTip = "Reload this module."
        self.reloadButton.name = "ScenePerformance Reload"
        self.layout.addWidget(self.reloadButton)
        self.reloadButton.connect('clicked()', self.reloadModule)

        self.runTestsButton = qt.QPushButton("Run tests")
        self.runTestsButton.toolTip = "Run all the tests."
        self.runTestsButton.name = "Run tests"
        self.layout.addWidget(self.runTestsButton)
        self.runTestsButton.connect('clicked()', self.runTests)

        self.TimePushButton = self.findWidget(self.parent, 'TimePushButton')
        self.ActionComboBox = self.findWidget(self.parent, 'ActionComboBox')
        self.ActionPathLineEdit = self.findWidget(self.parent,
                                                  'ActionPathLineEdit')
        self.ResultsTextEdit = self.findWidget(self.parent, 'ResultsTextEdit')
        self.URLLineEdit = self.findWidget(self.parent, 'URLLineEdit')
        self.URLFileNameLineEdit = self.findWidget(self.parent,
                                                   'URLFileNameLineEdit')
        self.SceneViewSpinBox = self.findWidget(self.parent,
                                                'SceneViewSpinBox')
        self.LayoutSpinBox = self.findWidget(self.parent, 'LayoutSpinBox')
        self.MRMLNodeComboBox = self.findWidget(self.parent,
                                                'MRMLNodeComboBox')
        self.RepeatSpinBox = self.findWidget(self.parent, 'RepeatSpinBox')

        widget.setMRMLScene(slicer.mrmlScene)
        #self.MRMLNodeComboBox.setMRMLScene(slicer.mrmlScene)

        self.TimePushButton.connect('clicked()', self.timeAction)
        self.ActionComboBox.connect('currentIndexChanged(int)',
                                    self.updateActionProperties)
        self.updateActionProperties()
示例#6
0
  def loadUi(self, uiFileName):
    loader = qt.QUiLoader()
    scriptedModulesPath = eval('slicer.modules.%s.path' % self.moduleName.replace(" ", "").lower())
    scriptedModulesPath = os.path.dirname(scriptedModulesPath)
    path = os.path.join(scriptedModulesPath, 'Resources', 'UI', uiFileName)

    qfile = qt.QFile(path)
    qfile.open(qt.QFile.ReadOnly)
    uiWidget = loader.load(qfile)
    uiWidget.setAutoFillBackground(False)
    uiWidget.setPalette(slicer.app.palette())

    self.layout.setContentsMargins(0,0,0,0)
    self.layout.addWidget(uiWidget)
    self.widget = uiWidget
示例#7
0
    def loadUi(self, uiFileName):
        loader = qt.QUiLoader()
        moduleName = 'Workflow'
        scriptedModulesPath = eval('slicer.modules.%s.path' %
                                   moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)
        path = os.path.join(scriptedModulesPath, 'Widgets', 'Resources', 'UI',
                            uiFileName)

        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile)
        widget.setAutoFillBackground(False)
        widget.setPalette(slicer.app.palette())

        return widget
    def createUserInterface(self):

        font = qt.QFont("Sans Serif", 12, qt.QFont.Bold)
        self.__layout = self.__parent.createUserInterface()
        self.__layout = qt.QFormLayout(self)
        loader = qt.QUiLoader()
        path = 'C:\Users\Camilo_Q\Documents\GitHub\simuladorTornillosPediculares\Interfaz Grafica\MenuProfesor.ui'
        moduleName = 'simuladorTornillosPediculares'
        scriptedModulesPath = eval(
            'slicer.modules.%s.path' %
            moduleName.lower())  # devuelve la ruta del .py
        scriptedModulesPath = os.path.dirname(
            scriptedModulesPath)  # lleva a la carpeta del modulo

        path = os.path.join(scriptedModulesPath, 'Interfaz Grafica',
                            '%s.ui' % self.stepid)
        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile)
        self.widget = widget
        self.__layout.addWidget(widget)
        self.widget.setMRMLScene(slicer.mrmlScene)

        self.seleccionDeEstudianteComboBox = self.findWidget(
            self.widget, 'seleccionDeEstudianteComboBox')
        self.cargarPushButton = self.findWidget(self.widget,
                                                'cargarPushButton')

        self.cargarPushButton.connect('clicked(bool)', self.onApplyCargar)

        con = mysql.connector.connect(user="******",
                                      password="******",
                                      host="127.0.0.1",
                                      database="basedatos_simulador_ttp")
        cursor = con.cursor()
        estudiantes = []
        cursor.execute("SELECT * FROM estudiantes")
        rows = cursor.fetchall()
        for row in rows:
            estudiantes.append(row)
        for i in range(0, len(estudiantes)):
            self.seleccionDeEstudianteComboBox.addItem(estudiantes[i][1])
示例#9
0
 def __init__(self):
     '''
     Constructor
     '''
     """
     path=slicer.modules.usguidedprocedure.path
     modulePath=os.path.dirname(path)
     loadedDataGUIfile=os.path.join(modulePath,"USGuidedWizard/loadedData.ui")
     f = qt.QFile(loadedDataGUIfile)
     #f = qt.QFile('C:/Users/Usuario/devel/slicelets/USGuidedProcedure/USGuidedWizard/fiducials.ui')
     f.open(qt.QFile.ReadOnly)
     loader = qt.QUiLoader()
     self.loadedDataWidget = loader.load(f)
     f.close()
     """
     
     # UI   from QtDesigner  -----------------------------------------------------------------------------
     path=slicer.modules.stylusbasedusprobecalibration.path
     modulePath=os.path.dirname(path)
     fiducialsStepGUIfile=os.path.join(modulePath,"GUI/fiducials.ui")
     f = qt.QFile(fiducialsStepGUIfile)
     #f = qt.QFile('C:/Users/Usuario/devel/slicelets/USGuidedProcedure/USGuidedWizard/fiducials.ui')
     f.open(qt.QFile.ReadOnly)
     loader = qt.QUiLoader()
     self.fiducialsWidget = loader.load(f)
     f.close()
     
     # connect signals and slots
     self.fiducialsWidget.fiducialsList.connect('cellChanged(int ,int )', self.onFiducialNameChanged) 
     self.fiducialsWidget.placeFiducialButton.connect('clicked(bool)', self.onPlaceFiducialButtomClicked) 
     self.fiducialsWidget.removeFiducialButton.connect('clicked(bool)', self.onRemoveFiducialButtonClicked)
     self.fiducialsWidget.clearFiducialsListButton.connect('clicked(bool)', self.onClearFiducialsListButtonClicked)
     self.fiducialsWidget.fiducialsList.itemClicked.connect(self.onFiducialsListClicked)
 
     #listeners
     #self.listenToAnnotations()
     self.updatingList = False
     self.placeImageFiducialStep=False
     pixmap=qt.QPixmap("Resources/Icons/AnnotationPointWithArrow.png")
     self.placeFiducialCursor= qt.QCursor(pixmap)
示例#10
0
    def setup(self):
        import imp, sys, os, slicer
        loader = qt.QUiLoader()
        moduleName = 'SkinModelMaker'
        scriptedModulesPath = eval('slicer.modules.%s.path' %
                                   moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)
        path = os.path.join(scriptedModulesPath, 'Resources', 'UI',
                            'SkinModelMaker.ui')

        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile, self.parent)
        self.layout = self.parent.layout()
        self.widget = widget
        self.layout.addWidget(widget)

        # Uncomment this vvvv and reloadModule function for faster development
        # self.reloadButton = qt.QPushButton("Reload")
        # self.reloadButton.toolTip = "Reload this module."
        # self.reloadButton.name = "SkinModelMaker Reload"
        # self.layout.addWidget(self.reloadButton)
        # self.reloadButton.connect('clicked()', self.reloadModule)

        # Logic
        self.Logic = SkinModelMakerLogic()

        #
        # Signals / Slots
        #

        self.get('ApplyPushButton').connect('clicked(bool)', self.onApply)

        # --------------------------------------------------------------------------
        # Initialize all the MRML aware GUI elements.
        # Lots of setup methods are called from this line
        self.widget.setMRMLScene(slicer.mrmlScene)
示例#11
0
    def createUserInterface(self):

        font = qt.QFont("Sans Serif", 12, qt.QFont.Bold)
        self.__layout = self.__parent.createUserInterface()
        self.__layout = qt.QFormLayout(self)

        moduleName = 'simuladorTornillosPediculares'
        scriptedModulesPath = eval(
            'slicer.modules.%s.path' %
            moduleName.lower())  # devuelve la ruta del .py
        scriptedModulesPath = os.path.dirname(
            scriptedModulesPath)  # lleva a la carpeta del modulo

        path = os.path.join(scriptedModulesPath, 'Interfaz Grafica',
                            '%s.ui' % self.stepid)
        loader = qt.QUiLoader()
        #path1='C:\Users\Camilo_Q\Documents\GitHub\simuladorTornillosPediculares\Interfaz Grafica\Inicio.ui'
        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile)
        self.widget = widget
        self.__layout.addWidget(widget)
        self.widget.setMRMLScene(slicer.mrmlScene)

        self.nombreEditText = self.findWidget(self.widget, 'nombreEditText')
        self.contrasenaEditText = self.findWidget(self.widget,
                                                  'contrasenaEditText')
        self.profesorCheckBox = self.findWidget(self.widget,
                                                'profesorCheckBox')
        self.estudianteCheckBox = self.findWidget(self.widget,
                                                  'estudianteCheckBox')
        self.eresNuevoCheckBox = self.findWidget(self.widget,
                                                 'eresNuevoCheckBox')

        self.nombreEditText.textChanged.connect(self.textchanged1)
        self.contrasenaEditText.textChanged.connect(self.textchanged2)
示例#12
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        print "-------Easy Clip Widget Setup---------"
        # GLOBALS:
        self.logic = EasyClipLogic(self)
        self.ignoredNodeNames = ('Red Volume Slice', 'Yellow Volume Slice',
                                 'Green Volume Slice')
        self.colorSliceVolumes = dict()
        self.dictionnaryModel = dict()
        self.hardenModelIDdict = dict()
        self.landmarkDescriptionDict = dict()
        self.planeControlsDictionary = {}
        # Instantiate and connect widgets
        #
        # Interface
        #
        loader = qt.QUiLoader()
        moduleName = 'EasyClip'
        scriptedModulesPath = eval('slicer.modules.%s.path' %
                                   moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)
        path = os.path.join(scriptedModulesPath, 'Resources', 'UI',
                            '%s.ui' % moduleName)

        qfile = qt.QFile(path)
        qfile.open(qt.QFile.ReadOnly)
        widget = loader.load(qfile, self.parent)
        self.layout = self.parent.layout()
        self.widget = widget
        self.layout.addWidget(widget)
        ##--------------------------- Scene --------------------------#
        self.SceneCollapsibleButton = self.logic.get(
            "SceneCollapsibleButton"
        )  # this atribute is usefull for Longitudinal quantification extension
        treeView = self.logic.get("treeView")
        treeView.setMRMLScene(slicer.app.mrmlScene())
        treeView.sceneModel().setHorizontalHeaderLabels(["Models"])
        treeView.sortFilterProxyModel().nodeTypes = ['vtkMRMLModelNode']
        treeView.header().setVisible(False)
        self.autoChangeLayout = self.logic.get("autoChangeLayout")
        self.computeBox = self.logic.get("computeBox")
        self.computeBox.connect('clicked()', self.onComputeBox)
        #--------------------------- Clipping Part --------------------------#
        # CLIPPING BUTTONS

        self.red_plane_box = self.logic.get("red_plane_box")
        self.radio_red_Neg = self.logic.get("radio_red_Neg")
        self.radio_red_Neg.setIcon(qt.QIcon(":/Icons/RedSpaceNegative.png"))
        self.radio_red_Pos = self.logic.get("radio_red_Pos")
        self.radio_red_Pos.setIcon(qt.QIcon(":/Icons/RedSpacePositive.png"))
        self.red_plane_box.connect(
            'clicked(bool)', lambda: self.logic.onCheckBoxClicked(
                'Red', self.red_plane_box, self.radio_red_Neg))
        self.red_plane_box.connect(
            'clicked(bool)', lambda: self.updateSliceState(
                "vtkMRMLSliceNodeRed", self.red_plane_box.isChecked(),
                self.radio_red_Neg.isChecked(), self.radio_red_Pos.isChecked())
        )
        self.radio_red_Neg.connect(
            'clicked(bool)', lambda: self.updateSliceState(
                "vtkMRMLSliceNodeRed", self.red_plane_box.isChecked(),
                self.radio_red_Neg.isChecked(), self.radio_red_Pos.isChecked())
        )
        self.radio_red_Pos.connect(
            'clicked(bool)', lambda: self.updateSliceState(
                "vtkMRMLSliceNodeRed", self.red_plane_box.isChecked(),
                self.radio_red_Neg.isChecked(), self.radio_red_Pos.isChecked())
        )
        self.yellow_plane_box = self.logic.get("yellow_plane_box")
        self.radio_yellow_Neg = self.logic.get("radio_yellow_Neg")
        self.radio_yellow_Neg.setIcon(
            qt.QIcon(":/Icons/YellowSpaceNegative.png"))
        self.radio_yellow_Pos = self.logic.get("radio_yellow_Pos")
        self.radio_yellow_Pos.setIcon(
            qt.QIcon(":/Icons/YellowSpacePositive.png"))
        self.yellow_plane_box.connect(
            'clicked(bool)', lambda: self.logic.onCheckBoxClicked(
                'Yellow', self.yellow_plane_box, self.radio_yellow_Neg))
        self.yellow_plane_box.connect(
            'clicked(bool)', lambda: self.updateSliceState(
                "vtkMRMLSliceNodeYellow", self.yellow_plane_box.isChecked(),
                self.radio_yellow_Neg.isChecked(),
                self.radio_yellow_Pos.isChecked()))
        self.radio_yellow_Neg.connect(
            'clicked(bool)', lambda: self.updateSliceState(
                "vtkMRMLSliceNodeYellow", self.yellow_plane_box.isChecked(),
                self.radio_yellow_Neg.isChecked(),
                self.radio_yellow_Pos.isChecked()))
        self.radio_yellow_Pos.connect(
            'clicked(bool)', lambda: self.updateSliceState(
                "vtkMRMLSliceNodeYellow", self.yellow_plane_box.isChecked(),
                self.radio_yellow_Neg.isChecked(),
                self.radio_yellow_Pos.isChecked()))
        self.green_plane_box = self.logic.get("green_plane_box")
        self.radio_green_Neg = self.logic.get("radio_green_Neg")
        self.radio_green_Neg.setIcon(
            qt.QIcon(":/Icons/GreenSpaceNegative.png"))
        self.radio_green_Pos = self.logic.get("radio_green_Pos")
        self.radio_green_Pos.setIcon(
            qt.QIcon(":/Icons/GreenSpacePositive.png"))
        self.green_plane_box.connect(
            'clicked(bool)', lambda: self.logic.onCheckBoxClicked(
                'Green', self.green_plane_box, self.radio_green_Neg))
        self.green_plane_box.connect(
            'clicked(bool)', lambda: self.updateSliceState(
                "vtkMRMLSliceNodeGreen", self.green_plane_box.isChecked(),
                self.radio_green_Neg.isChecked(),
                self.radio_green_Pos.isChecked()))
        self.radio_green_Neg.connect(
            'clicked(bool)', lambda: self.updateSliceState(
                "vtkMRMLSliceNodeGreen", self.green_plane_box.isChecked(),
                self.radio_green_Neg.isChecked(),
                self.radio_green_Pos.isChecked()))
        self.radio_green_Pos.connect(
            'clicked(bool)', lambda: self.updateSliceState(
                "vtkMRMLSliceNodeGreen", self.green_plane_box.isChecked(),
                self.radio_green_Neg.isChecked(),
                self.radio_green_Pos.isChecked()))
        self.ClippingButton = self.logic.get("ClippingButton")
        self.ClippingButton.connect('clicked()', self.ClippingButtonClicked)
        self.UndoButton = self.logic.get("UndoButton")
        self.UndoButton.connect('clicked()', self.UndoButtonClicked)
        # -------------------------------- PLANES --------------------------------#
        self.CollapsibleButton3 = self.logic.get("CollapsibleButton3")
        self.save = self.logic.get("save")
        self.read = self.logic.get("read")
        self.save.connect('clicked(bool)', self.savePlane)
        self.read.connect('clicked(bool)', self.readPlane)
        #-------------------- onCloseScene ----------------------#
        slicer.mrmlScene.AddObserver(slicer.mrmlScene.EndCloseEvent,
                                     self.onCloseScene)
示例#13
0
    def setup(self):
        ScriptedLoadableModuleWidget.setup(self)
        print "-------Mesh Statistic Widget Setup-------"
        self.moduleName = 'MeshStatistics'
        scriptedModulesPath = eval('slicer.modules.%s.path' %
                                   self.moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)

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

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

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

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

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

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

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

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

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

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

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

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

        slicer.mrmlScene.AddObserver(slicer.mrmlScene.EndCloseEvent,
                                     self.onCloseScene)
    def setup(self):
        slicer.ScriptedLoadableModule.ScriptedLoadableModuleWidget.setup(self)
        print "----- Shape Quantifier widget setup -----"
        self.moduleName = 'ShapeQuantifier'
        scriptedModulesPath = eval('slicer.modules.%s.path' % self.moduleName.lower())
        scriptedModulesPath = os.path.dirname(scriptedModulesPath)

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

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

        # ------ Initialisation of Shape Quantifier and its logic ----- #
        self.ShapeQuantifierCore = ShapeQuantifierCore.ShapeQuantifierCore(interface = self)
        self.logic = ShapeQuantifierLogic(self, self.ShapeQuantifierCore)

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

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

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

        # ------ Scene Collapsible Button ----- #
        self.SceneCollapsibleButton = self.ShapeQuantifierCore.get("SceneCollapsibleButton")
        treeView = self.ShapeQuantifierCore.get("treeView")
        treeView.setMRMLScene(slicer.app.mrmlScene())
        treeView.sortFilterProxyModel().nodeTypes = ['vtkMRMLModelNode','vtkMRMLMarkupsFiducialNode']
        sceneModel = treeView.sceneModel()
        sceneModel.colorColumn = 1
        sceneModel.opacityColumn = 2
        treeViewHeader = treeView.header()
        treeViewHeader.setVisible(False)
        treeViewHeader.setStretchLastSection(False)
        treeViewHeader.setResizeMode(sceneModel.nameColumn,qt.QHeaderView.Stretch)
        treeViewHeader.setResizeMode(sceneModel.colorColumn,qt.QHeaderView.ResizeToContents)
        treeViewHeader.setResizeMode(sceneModel.opacityColumn,qt.QHeaderView.ResizeToContents)
        self.computeBoxPushButton = self.ShapeQuantifierCore.get("computeBoxPushButton")

        # ------ Step Group Box ----- #
        self.ModelRadioGroupBox = self.ShapeQuantifierCore.get("ModelRadioGroupBox")
        self.ModelRadioGroupBox.hide()
        self.Model1RadioButton = self.ShapeQuantifierCore.get("Model1RadioButton")
        self.ShapeQuantifierCore.get("verticalLayout_4").setAlignment(0x84)
        self.Model2RadioButton = self.ShapeQuantifierCore.get("Model2RadioButton")
        self.ShapeQuantifierCore.get("verticalLayout_5").setAlignment(0x84)

        # ------ Data selection Collapsible Button ----- #
        self.DataSelectionCollapsibleButton = self.ShapeQuantifierCore.get("DataSelectionCollapsibleButton")
        self.SingleModelRadioButton = self.ShapeQuantifierCore.get("SingleModelRadioButton")
        self.TwoModelsRadioButton = self.ShapeQuantifierCore.get("TwoModelsRadioButton")
        self.ShapeQuantifierCore.get("verticalLayout_6").setAlignment(0x84)
        self.ShapeQuantifierCore.get("verticalLayout_7").setAlignment(0x84)
        self.Model1groupBox = self.ShapeQuantifierCore.get("Model1groupBox")
        self.Model1MRMLNodeComboBox = self.ShapeQuantifierCore.get("Model1MRMLNodeComboBox")
        self.Model1MRMLNodeComboBox.setMRMLScene(slicer.mrmlScene)
        self.FidList1MRMLNodeComboBox = self.ShapeQuantifierCore.get("FidList1MRMLNodeComboBox")
        self.FidList1MRMLNodeComboBox.setMRMLScene(slicer.mrmlScene)
        self.Model2groupBox = self.ShapeQuantifierCore.get("Model2groupBox")
        self.Model2MRMLNodeComboBox = self.ShapeQuantifierCore.get("Model2MRMLNodeComboBox")
        self.Model2MRMLNodeComboBox.setMRMLScene(slicer.mrmlScene)
        self.FidList2MRMLNodeComboBox = self.ShapeQuantifierCore.get("FidList2MRMLNodeComboBox")
        self.FidList2MRMLNodeComboBox.setMRMLScene(slicer.mrmlScene)

        self.ExternalModuleTabDict = dict()
        # ------ Eternal Modules Selections ----- #
        listOfTab = ["Preprocessing","Quantification","Analysis"]
        for tab in listOfTab:
            self.ExternalModuleTabDict[tab] = ExternalModuleTab()
            self.ExternalModuleTabDict[tab].collapsibleButton = self.ShapeQuantifierCore.get(tab + "CollapsibleButton")
            self.ExternalModuleTabDict[tab].layout = self.ShapeQuantifierCore.get(tab + "Layout")
            self.ExternalModuleTabDict[tab].choiceComboBox = self.ShapeQuantifierCore.get(tab + "ChoiceComboBox")

        # ------------------------------------------------------------------------------ #
        # ---------------- Setup and initialisation of global variables ---------------- #
        # ------------------------------------------------------------------------------ #

        # ------ Initialisation of the other modules is Slicer, if that's not already done ----- #
        if not hasattr(slicer.modules, 'AnglePlanesWidget'):
            slicer.modules.angleplanes.createNewWidgetRepresentation()
        if not hasattr(slicer.modules, 'EasyClipWidget'):
            slicer.modules.easyclip.createNewWidgetRepresentation()
        if not hasattr(slicer.modules, 'MeshStatisticsWidget'):
            slicer.modules.meshstatistics.createNewWidgetRepresentation()
        if not hasattr(slicer.modules, 'PickAndPaintWidget'):
            slicer.modules.pickandpaint.createNewWidgetRepresentation()
        if not hasattr(slicer.modules, 'Q3DCWidget'):
            slicer.modules.q3dc.createNewWidgetRepresentation()
        if not hasattr(slicer.modules, 'SurfaceRegistrationWidget'):
            slicer.modules.surfaceregistration.createNewWidgetRepresentation()

        # ------ Creation of a dictionary that will contain the pythons modules ----- #
        self.ExternalPythonModules = dict()
        self.ExternalPythonModules["Angle Planes"] = slicer.modules.AnglePlanesWidget
        self.ExternalPythonModules["Easy Clip"] = slicer.modules.EasyClipWidget
        self.ExternalPythonModules["Mesh Statistics"] = slicer.modules.MeshStatisticsWidget
        self.ExternalPythonModules["Pick and Paint"] = slicer.modules.PickAndPaintWidget
        self.ExternalPythonModules["Q3DC"] = slicer.modules.Q3DCWidget
        self.ExternalPythonModules["Surface Registration"] = slicer.modules.SurfaceRegistrationWidget

        # ------ Creation of a dictionary that will contain the CLI modules ----- #
        self.ExternalCLIModules = dict()
        self.ExternalCLIModules["Model to Model Distance"] = slicer.modules.modeltomodeldistance
        self.ExternalCLIModules["Shape Population Viewer"] = slicer.modules.launcher

        # ------ Creation of a dictionary that will contain all the modules ----- #
        self.ExternalModulesDict = dict(self.ExternalPythonModules, **self.ExternalCLIModules)

        # ------ Setup of the external Python modules ------ #
        # Hiding of the scene tabs and the input tabs in
        # all the external modules to avoid redundancies
        # and make this module as clear and simple as possible

            #This part of the setup is now made in the enter function

        # ------ Setup of the external CLI modules ------ #
        # Setting the size to the good value

        for key, value in self.ExternalCLIModules.iteritems():
            value.widgetRepresentation().setSizePolicy(1,1)
            value.widgetRepresentation().adjustSize()

        # --------------------------------------------- #
        # ---------------- Connections ---------------- #
        # --------------------------------------------- #

        # ------ Scene Collapsible Button ----- #
        self.SceneCollapsibleButton.\
            connect('clicked()', lambda: self.onSelectedCollapsibleButtonChanged(self.SceneCollapsibleButton))
        self.computeBoxPushButton.connect('clicked()', self.ExternalModulesDict["Easy Clip"].onComputeBox)

        # ------ Step Group Box ----- #
        self.Model1RadioButton.connect('clicked()', self.propagationOfInputDataToExternalModules)
        self.Model2RadioButton.connect('clicked()', self.propagationOfInputDataToExternalModules)

        # ------ Data selection Collapsible Button ----- #
        self.DataSelectionCollapsibleButton.\
            connect('clicked()', lambda: self.onSelectedCollapsibleButtonChanged(self.DataSelectionCollapsibleButton))
        self.SingleModelRadioButton.connect('clicked()', lambda: self.onNumberOfModelForMeasureChange(True))
        self.TwoModelsRadioButton.connect('clicked()', lambda: self.onNumberOfModelForMeasureChange(False))
        self.Model1MRMLNodeComboBox.connect('currentNodeChanged(vtkMRMLNode*)', self.propagationOfInputDataToExternalModules)
        self.FidList1MRMLNodeComboBox.connect('currentNodeChanged(vtkMRMLNode*)', self.propagationOfInputDataToExternalModules)
        self.Model2MRMLNodeComboBox.connect('currentNodeChanged(vtkMRMLNode*)', self.propagationOfInputDataToExternalModules)
        self.FidList2MRMLNodeComboBox.connect('currentNodeChanged(vtkMRMLNode*)', self.propagationOfInputDataToExternalModules)

        # ------ Eternal Modules Selections ----- #
        for key, ExternalModule in self.ExternalModuleTabDict.iteritems():
            ExternalModule.collapsibleButton.connect('clicked()',
                                                     lambda currentCollapsibleButton = ExternalModule.collapsibleButton:
                                                     self.onSelectedCollapsibleButtonChanged(currentCollapsibleButton))
            ExternalModule.choiceComboBox.connect('currentIndexChanged(QString)',
                                                  lambda newModule, currentCombobox = ExternalModule.choiceComboBox:
                                                  self.onExternalModuleChangement(newModule, currentCombobox))

        # ------ Closing of the scene -----#
        slicer.mrmlScene.AddObserver(slicer.mrmlScene.EndCloseEvent, self.onCloseScene)
        self.enter()
示例#15
0
  def create(self):
    # Instantiate and connect widgets ...

    loader = qt.QUiLoader()
    path = os.path.join(os.path.dirname(__file__), 'Resources', 'UI','settings.ui')
    qfile = qt.QFile(path)
    qfile.open(qt.QFile.ReadOnly)
    self.window = loader.load(qfile)

    self.cornerTextParametersCollapsibleButton = slicer.util.findChildren(self.window,
       'cornerTextParametersCollapsibleButton')[0]
    self.sliceViewAnnotationsCheckBox = slicer.util.findChildren(self.window,
       'sliceViewAnnotationsCheckBox')[0]
    self.sliceViewAnnotationsCheckBox.checked = self.showSliceViewAnnotations

    self.activateCornersGroupBox = slicer.util.findChildren(self.window,
       'activateCornersGroupBox')[0]
    self.topLeftActivationCheckbox = slicer.util.findChildren(self.window,
       'topLeftActivationCheckbox')[0]
    self.topLeftActivationCheckbox.checked = self.topLeftAnnotationDisplay
    self.topRightActivationCheckbox = slicer.util.findChildren(self.window,
       'topRightActivationCheckbox')[0]
    self.topRightActivationCheckbox.checked = self.topRightAnnotationDisplay
    self.bottomLeftActivationCheckbox = slicer.util.findChildren(self.window,
       'bottomLeftActivationCheckbox')[0]
    self.bottomLeftActivationCheckbox.checked = self.bottomLeftAnnotationDisplay

    self.level1RadioButton = slicer.util.findChildren(self.window,
       'level1RadioButton')[0]
    self.level2RadioButton = slicer.util.findChildren(self.window,
       'level2RadioButton')[0]
    self.level3RadioButton = slicer.util.findChildren(self.window,
       'level3RadioButton')[0]

    self.fontPropertiesGroupBox = slicer.util.findChildren(self.window,
       'fontPropertiesGroupBox')[0]
    self.timesFontRadioButton = slicer.util.findChildren(self.window,
       'timesFontRadioButton')[0]
    self.arialFontRadioButton = slicer.util.findChildren(self.window,
       'arialFontRadioButton')[0]
    if self.fontFamily == 'Times':
      self.timesFontRadioButton.checked = True
    else:
      self.arialFontRadioButton.checked = True

    self.fontSizeSpinBox = slicer.util.findChildren(self.window,
       'fontSizeSpinBox')[0]
    self.fontSizeSpinBox.value = self.fontSize

    self.backgroundLayerPersistenceCheckbox = slicer.util.findChildren(self.window,
       'backgroundLayerPersistenceCheckbox')[0]
    self.backgroundLayerPersistenceCheckbox.checked = self.backgroundDicomAnnotationsPersistence

    self.annotationsAmountGroupBox = slicer.util.findChildren(self.window,
       'annotationsAmountGroupBox')[0]
    self.scalingRulerCollapsibleButton = slicer.util.findChildren(self.window,
       'scalingRulerCollapsibleButton')[0]
    self.showScalingRulerCheckBox = slicer.util.findChildren(self.window,
       'showScalingRulerCheckBox')[0]
    self.showScalingRulerCheckBox.checked = self.showScalingRuler

    self.colorScalarBarCollapsibleButton = slicer.util.findChildren(self.window,
       'colorScalarBarCollapsibleButton')[0]
    self.showColorScalarBarCheckBox = slicer.util.findChildren(self.window,
        'showColorScalarBarCheckBox')[0]
    self.showColorScalarBarCheckBox.checked = self.showColorScalarBar
    self.colorBarLayerSelectionGroupBox = slicer.util.findChildren(self.window,
       'colorBarLayerSelectionGroupBox')[0]

    self.backgroundRadioButton = slicer.util.findChildren(self.window,
       'backgroundRadioButton')[0]
    self.backgroundRadioButton.checked = True
    self.foregroundRadioButton = slicer.util.findChildren(self.window,
       'foregroundRadioButton')[0]

    self.colorScalarBarMaxWidthSlider = slicer.util.findChildren(self.window,
       'colorScalarBarMaxWidthSlider')[0]

    restorDefaultsButton = slicer.util.findChildren(self.window,
        'restoreDefaultsButton')[0]

    # connections
    self.sliceViewAnnotationsCheckBox.connect('clicked()', self.onSliceViewAnnotationsCheckbox)
    self.topLeftActivationCheckbox.connect('clicked()', self.onCornerTextsActivationCheckbox)
    self.topRightActivationCheckbox.connect('clicked()', self.onCornerTextsActivationCheckbox)
    self.bottomLeftActivationCheckbox.connect('clicked()', self.onCornerTextsActivationCheckbox)
    self.timesFontRadioButton.connect('clicked()', self.onFontFamilyRadioButton)
    self.arialFontRadioButton.connect('clicked()', self.onFontFamilyRadioButton)
    self.fontSizeSpinBox.connect('valueChanged(int)', self.onFontSizeSpinBox)

    self.level1RadioButton.connect('clicked()', self.updateSliceViewFromGUI)
    self.level2RadioButton.connect('clicked()', self.updateSliceViewFromGUI)
    self.level3RadioButton.connect('clicked()', self.updateSliceViewFromGUI)

    self.backgroundLayerPersistenceCheckbox.connect('clicked()', self.onBackgroundLayerPersistenceCheckbox)

    self.showScalingRulerCheckBox.connect('clicked()', self.onShowScalingRulerCheckbox)

    self.showColorScalarBarCheckBox.connect('clicked()', self.onShowColorScalarBarCheckbox)
    self.backgroundRadioButton.connect('clicked()',self.onLayerSelectionRadioButton)
    self.foregroundRadioButton.connect('clicked()',self.onLayerSelectionRadioButton)
    self.colorScalarBarMaxWidthSlider.connect('valueChanged(double)', self.updateSliceViewFromGUI)

    restorDefaultsButton.connect('clicked()', self.restoreDefaultValues)