コード例 #1
0
    def section_MarkupsPlaceWidget(self):
        self.delayDisplay("Test MarkupsPlaceWidget", self.delayMs)

        placeWidget = slicer.qSlicerMarkupsPlaceWidget()
        self.assertIsNone(placeWidget.interactionNode())
        placeWidget.setMRMLScene(slicer.mrmlScene)
        placeWidget.setCurrentNode(self.markupsNode1)
        placeWidget.show()

        placeWidget.buttonsVisible = False
        self.assertFalse(placeWidget.buttonsVisible)
        placeWidget.buttonsVisible = True
        self.assertTrue(placeWidget.buttonsVisible)

        placeWidget.deleteAllControlPointsOptionVisible = False
        self.assertFalse(placeWidget.deleteAllControlPointsOptionVisible)
        placeWidget.deleteAllControlPointsOptionVisible = True
        self.assertTrue(placeWidget.deleteAllControlPointsOptionVisible)

        placeWidget.unsetLastControlPointOptionVisible = False
        self.assertFalse(placeWidget.unsetLastControlPointOptionVisible)
        placeWidget.unsetLastControlPointOptionVisible = True
        self.assertTrue(placeWidget.unsetLastControlPointOptionVisible)

        placeWidget.unsetAllControlPointsOptionVisible = False
        self.assertFalse(placeWidget.unsetAllControlPointsOptionVisible)
        placeWidget.unsetAllControlPointsOptionVisible = True
        self.assertTrue(placeWidget.unsetAllControlPointsOptionVisible)

        placeWidget.placeMultipleMarkups = slicer.qSlicerMarkupsPlaceWidget.ForcePlaceSingleMarkup
        placeWidget.placeModeEnabled = True
        self.assertFalse(placeWidget.placeModePersistency)

        placeWidget.placeMultipleMarkups = slicer.qSlicerMarkupsPlaceWidget.ForcePlaceMultipleMarkups
        placeWidget.placeModeEnabled = False
        placeWidget.placeModeEnabled = True
        self.assertTrue(placeWidget.placeModePersistency)

        self.assertEqual(placeWidget.interactionNode(),
                         slicer.app.applicationLogic().GetInteractionNode())
        otherInteractionNode = slicer.vtkMRMLInteractionNode()
        otherInteractionNode.SetSingletonOff()
        slicer.mrmlScene.AddNode(otherInteractionNode)
        placeWidget.setInteractionNode(otherInteractionNode)
        self.assertEqual(placeWidget.interactionNode(), otherInteractionNode)
コード例 #2
0
  def section_MarkupsPlaceWidget(self):
    self.delayDisplay("Test MarkupsPlaceWidget",self.delayMs)

    placeWidget = slicer.qSlicerMarkupsPlaceWidget()
    self.assertIsNone(placeWidget.interactionNode())
    placeWidget.setMRMLScene(slicer.mrmlScene)
    placeWidget.setCurrentNode(self.markupsNode1)
    placeWidget.show()

    placeWidget.buttonsVisible = False
    self.assertFalse(placeWidget.buttonsVisible)
    placeWidget.buttonsVisible = True
    self.assertTrue(placeWidget.buttonsVisible)

    placeWidget.deleteAllMarkupsOptionVisible = False
    self.assertFalse(placeWidget.deleteAllMarkupsOptionVisible)
    placeWidget.deleteAllMarkupsOptionVisible = True
    self.assertTrue(placeWidget.deleteAllMarkupsOptionVisible)

    placeWidget.deleteAllMarkupsOptionVisible = False
    self.assertFalse(placeWidget.deleteAllMarkupsOptionVisible)
    placeWidget.deleteAllMarkupsOptionVisible = True
    self.assertTrue(placeWidget.deleteAllMarkupsOptionVisible)

    placeWidget.placeMultipleMarkups = slicer.qSlicerMarkupsPlaceWidget.ForcePlaceSingleMarkup
    placeWidget.placeModeEnabled = True
    self.assertFalse(placeWidget.placeModePersistency)

    placeWidget.placeMultipleMarkups = slicer.qSlicerMarkupsPlaceWidget.ForcePlaceMultipleMarkups
    placeWidget.placeModeEnabled = False
    placeWidget.placeModeEnabled = True
    self.assertTrue(placeWidget.placeModePersistency)

    self.assertEqual(placeWidget.interactionNode(), slicer.app.applicationLogic().GetInteractionNode())
    otherInteractionNode = slicer.vtkMRMLInteractionNode()
    otherInteractionNode.SetSingletonOff()
    slicer.mrmlScene.AddNode(otherInteractionNode)
    placeWidget.setInteractionNode(otherInteractionNode)
    self.assertEqual(placeWidget.interactionNode(), otherInteractionNode)
コード例 #3
0
    def section_SimpleMarkupsWidget(self):
        self.delayDisplay("Test SimpleMarkupsWidget", self.delayMs)

        simpleMarkupsWidget = slicer.qSlicerSimpleMarkupsWidget()
        nodeSelector = slicer.util.findChildren(simpleMarkupsWidget,
                                                "MarkupsNodeComboBox")[0]
        self.assertIsNone(simpleMarkupsWidget.interactionNode())
        simpleMarkupsWidget.setMRMLScene(slicer.mrmlScene)
        simpleMarkupsWidget.show()

        placeWidget = simpleMarkupsWidget.markupsPlaceWidget()
        self.assertIsNotNone(placeWidget)

        simpleMarkupsWidget.setCurrentNode(None)
        simpleMarkupsWidget.enterPlaceModeOnNodeChange = False
        placeWidget.placeModeEnabled = False
        nodeSelector.setCurrentNode(self.markupsNode1)
        self.assertFalse(placeWidget.placeModeEnabled)

        simpleMarkupsWidget.enterPlaceModeOnNodeChange = True
        nodeSelector.setCurrentNode(self.markupsNode2)
        self.assertTrue(placeWidget.placeModeEnabled)

        simpleMarkupsWidget.jumpToSliceEnabled = True
        self.assertTrue(simpleMarkupsWidget.jumpToSliceEnabled)
        simpleMarkupsWidget.jumpToSliceEnabled = False
        self.assertFalse(simpleMarkupsWidget.jumpToSliceEnabled)

        simpleMarkupsWidget.nodeSelectorVisible = False
        self.assertFalse(simpleMarkupsWidget.nodeSelectorVisible)
        simpleMarkupsWidget.nodeSelectorVisible = True
        self.assertTrue(simpleMarkupsWidget.nodeSelectorVisible)

        simpleMarkupsWidget.optionsVisible = False
        self.assertFalse(simpleMarkupsWidget.optionsVisible)
        simpleMarkupsWidget.optionsVisible = True
        self.assertTrue(simpleMarkupsWidget.optionsVisible)

        defaultColor = qt.QColor(0, 255, 0)
        simpleMarkupsWidget.defaultNodeColor = defaultColor
        self.assertEqual(simpleMarkupsWidget.defaultNodeColor, defaultColor)

        self.markupsNode3 = nodeSelector.addNode()
        displayNode3 = self.markupsNode3.GetDisplayNode()
        color3 = displayNode3.GetColor()
        self.assertEqual(color3[0] * 255, defaultColor.red())
        self.assertEqual(color3[1] * 255, defaultColor.green())
        self.assertEqual(color3[2] * 255, defaultColor.blue())

        numberOfFiducialsAdded = 5
        for i in range(numberOfFiducialsAdded):
            self.markupsLogic.AddFiducial()

        tableWidget = simpleMarkupsWidget.tableWidget()
        self.assertEqual(tableWidget.rowCount, numberOfFiducialsAdded)

        self.assertEqual(simpleMarkupsWidget.interactionNode(),
                         slicer.app.applicationLogic().GetInteractionNode())
        otherInteractionNode = slicer.vtkMRMLInteractionNode()
        otherInteractionNode.SetSingletonOff()
        slicer.mrmlScene.AddNode(otherInteractionNode)
        simpleMarkupsWidget.setInteractionNode(otherInteractionNode)
        self.assertEqual(simpleMarkupsWidget.interactionNode(),
                         otherInteractionNode)
コード例 #4
0
  def section_SimpleMarkupsWidget(self):
    self.delayDisplay("Test SimpleMarkupsWidget",self.delayMs)

    simpleMarkupsWidget = slicer.qSlicerSimpleMarkupsWidget()
    nodeSelector = slicer.util.findChildren(simpleMarkupsWidget,"MarkupsFiducialNodeComboBox")[0]
    self.assertIsNone(simpleMarkupsWidget.interactionNode())
    simpleMarkupsWidget.setMRMLScene(slicer.mrmlScene)
    simpleMarkupsWidget.show()

    placeWidget = simpleMarkupsWidget.markupsPlaceWidget()
    self.assertIsNotNone(placeWidget)

    simpleMarkupsWidget.setCurrentNode(None)
    simpleMarkupsWidget.enterPlaceModeOnNodeChange = False
    placeWidget.placeModeEnabled = False
    nodeSelector.setCurrentNode(self.markupsNode1)
    self.assertFalse(placeWidget.placeModeEnabled)

    simpleMarkupsWidget.enterPlaceModeOnNodeChange = True
    nodeSelector.setCurrentNode(self.markupsNode2)
    self.assertTrue(placeWidget.placeModeEnabled)

    simpleMarkupsWidget.jumpToSliceEnabled = True
    self.assertTrue(simpleMarkupsWidget.jumpToSliceEnabled)
    simpleMarkupsWidget.jumpToSliceEnabled = False
    self.assertFalse(simpleMarkupsWidget.jumpToSliceEnabled)

    simpleMarkupsWidget.nodeSelectorVisible = False
    self.assertFalse(simpleMarkupsWidget.nodeSelectorVisible)
    simpleMarkupsWidget.nodeSelectorVisible = True
    self.assertTrue(simpleMarkupsWidget.nodeSelectorVisible)

    simpleMarkupsWidget.optionsVisible = False
    self.assertFalse(simpleMarkupsWidget.optionsVisible)
    simpleMarkupsWidget.optionsVisible = True
    self.assertTrue(simpleMarkupsWidget.optionsVisible)

    defaultColor = qt.QColor(0,255,0)
    simpleMarkupsWidget.defaultNodeColor = defaultColor
    self.assertEqual(simpleMarkupsWidget.defaultNodeColor, defaultColor)

    self.markupsNode3 = nodeSelector.addNode()
    displayNode3 = self.markupsNode3.GetDisplayNode()
    color3 = displayNode3.GetColor()
    self.assertEqual(color3[0]*255, defaultColor.red())
    self.assertEqual(color3[1]*255, defaultColor.green())
    self.assertEqual(color3[2]*255, defaultColor.blue())

    numberOfFiducialsAdded = 5
    for i in range(numberOfFiducialsAdded):
      self.markupsLogic.AddFiducial()

    tableWidget = simpleMarkupsWidget.tableWidget()
    self.assertEqual(tableWidget.rowCount, numberOfFiducialsAdded)

    self.assertEqual(simpleMarkupsWidget.interactionNode(), slicer.app.applicationLogic().GetInteractionNode())
    otherInteractionNode = slicer.vtkMRMLInteractionNode()
    otherInteractionNode.SetSingletonOff()
    slicer.mrmlScene.AddNode(otherInteractionNode)
    simpleMarkupsWidget.setInteractionNode(otherInteractionNode)
    self.assertEqual(simpleMarkupsWidget.interactionNode(), otherInteractionNode)