def onFiducialListSelected(self, node): if node: self.fiducialsWidget.currentNode = node self.fiducialsWidget.currentNode.AddObserver( slicer.vtkMRMLMarkupsNode().PointPositionDefinedEvent, self.onEndTargetPlacement) self.fiducialsWidget.currentNode.AddObserver( slicer.vtkMRMLMarkupsNode().PointPositionUndefinedEvent, self.onEndTargetRemove)
def setupFiducialWidgetAndTableWidget(self): self.targetingPlugin.fiducialsWidget.addEventObserver( slicer.vtkMRMLMarkupsNode().PointPositionDefinedEvent, self.updateAffectiveZoneAndDistance) self.targetingPlugin.fiducialsWidget.addEventObserver( slicer.vtkMRMLMarkupsNode().PointPositionUndefinedEvent, self.updateAffectiveZoneAndDistance) self.targetingPlugin.targetTablePlugin.addEventObserver( self.targetingPlugin.targetTablePlugin.TargetPosUpdatedEvent, self.updateAffectiveZoneAndDistance)
def onEndTargetPlacement(self, interactionNode=None, event=None): if self.fiducialsWidget.currentNode: currentTargetIndex = self.fiducialsWidget.currentNode.GetNumberOfFiducials( ) - 1 guidance = self.targetTablePlugin.targetTableModel.getOrCreateNewGuidanceComputation( self.fiducialsWidget.currentNode) needleSnapPosition = guidance.getNeedleEndPos(currentTargetIndex) self.fiducialsWidget.currentNode.SetNthFiducialPositionFromArray( currentTargetIndex, needleSnapPosition) self.session.displayForTargets[ self.fiducialsWidget.currentNode.GetNthMarkupID( currentTargetIndex)] = qt.Qt.Unchecked self.session.needleTypeForTargets[ self.fiducialsWidget.currentNode.GetNthMarkupID( currentTargetIndex)] = self.session.ISSEEDTYPE self.fiducialsWidget.invokeEvent( slicer.vtkMRMLMarkupsNode().PointPositionDefinedEvent) pass
def onEndTargetRemove(self, caller, event, callData): tempCheckBoxList = self.targetTablePlugin.checkBoxList.copy() tempComboBoxList = self.targetTablePlugin.comboBoxList.copy() tempDisplayForTargets = self.session.displayForTargets.copy() tempNeedleTypeForTargets = self.session.needleTypeForTargets.copy() self.targetTablePlugin.checkBoxList.clear() self.targetTablePlugin.comboBoxList.clear() self.session.displayForTargets.clear() self.session.needleTypeForTargets.clear() for index in range( self.fiducialsWidget.currentNode.GetNumberOfFiducials()): key = self.fiducialsWidget.currentNode.GetNthMarkupID(index) if key is not None: self.targetTablePlugin.checkBoxList[ key] = tempCheckBoxList.get(key) self.targetTablePlugin.comboBoxList[ key] = tempComboBoxList.get(key) self.session.displayForTargets[ key] = tempDisplayForTargets.get(key) self.session.needleTypeForTargets[ key] = tempNeedleTypeForTargets.get(key) self.fiducialsWidget.invokeEvent( slicer.vtkMRMLMarkupsNode().PointRemovedEvent)