Restraining from selecting more than one point


I have been developing a extension where I need to select multiple points and then based on an algorithm transforming the volume. For this purpose, I have used qSlicerSimpleMarkupsWidget() and qSlicerMarkupsPlaceWidget. The algorithm is working perfect. Except for the situation where the user starts selecting more than one point for the same name. This breaks the algorithm as the matrix condition is not satisfied.

I am attaching the code:

    self.a = slicer.qSlicerSimpleMarkupsWidget()
    self.a.objectName = "a"
    self.a.toolTip = "Select a fiducial to use as the ASIS left point."
    self.a.defaultNodeColor = qt.QColor(255, 255, 0)
    self.a.markupsSelectorComboBox().noneEnabled = True
    self.a.markupsPlaceWidget().placeMultipleMarkups = (
    self.a.markupsPlaceWidget().buttonsVisible = False

    inputsFormLayout.addRow("a:", self.a)
    self.parent.connect("mrmlSceneChanged(vtkMRMLScene*)", self.a)

    self.b = slicer.qSlicerSimpleMarkupsWidget()
    self.b.objectName = "b"
    self.b.toolTip = "Select a fiducial to use as the ASIS right point."
    self.b.defaultNodeColor = qt.QColor(255, 0, 0)
    self.b.markupsSelectorComboBox().noneEnabled = True
    self.b.markupsPlaceWidget().placeMultipleMarkups = (
    self.b.markupsPlaceWidget().buttonsVisible = False

    inputsFormLayout.addRow("b:", self.b)


For example, here in capture the node a is selected once as shown in red window. but in capture2, we are again able to select the node a. For the algorithm to work properly, the module must restrict the user from selecting more than one node for the same name.

Please let me know if the question is clear from my side.


In recent Slicer Preview Releases you can specify a template with predefined control point names and restrict the user to place only those points. Probably all you need is to create a markup fiducial node, add a control point to it (set its name, set its position status to PositionUndefined), and enable set the number of control points to fixed (SetFixedNumberOfControlPoints(True)).

We’ll improve the simple markups widget to work similarly as the point list in Markups module’s Control points section. Then you could just add a single markups fiducial node and use that point list widget to place all your points.