ms = skeleton.getMicrostructure() skel = skeleton.getObject() pxlgrp = ms.findGroup(self.group) for element in skel.element_iterator(): where = ms.getRepresentativePixel(element.dominantPixel(skel.MS)) grpnames = pixelgroup.pixelGroupNames(ms, where) if self.group in grpnames: selected.append(element) selection.start() selection.clear() selection.select(selected) registeredclass.Registration( 'Select by Pixel Group', ElementSelectionModifier, ElementByPixelGroup, ordering=8, params=[ pixelgroupparam.PixelGroupParameter('group', tip='The name of a pixel group.') ], tip="Select all Elements whose dominant pixel is in a given pixel group.", discussion="""<para> This command selects all &skel; &elems; whose <link linkend="Section-Concepts-Skeleton-Homogeneity">dominant pixel</link> is a member of the given &pixelgroup;. </para>""")
grp = microstructure.findGroup(self.group) if grp: activearea = microstructure.activearea activearea.start() activearea.clear() activearea.invert() activearea.activate(GroupSelection(microstructure, grp)) registeredclass.Registration( 'Activate Pixel Group Only', ActiveAreaModifier, ActivateOnlyGroup, ordering=0.6, params=[ pixelgroupparam.PixelGroupParameter( 'group', tip="A pixel group to be activated.") ], tip= "Activate only the pixels in the given pixel group, deactivating everything else.", discussion=xmlmenudump.loadFile( 'DISCUSSIONS/common/menu/activate_pixel_group_only.xml')) class ActivateGroup(ActiveAreaModifier): def __init__(self, group): self.group = group def __call__(self, microstructure): grp = microstructure.findGroup(self.group) if grp: activearea = microstructure.activearea
# The selection needs to be cloned before calling # clearAndSelect, or else it will be empty by the time the # intersection is actually computed. The clone has to be # stored in a variable here, so that it won't be garbage # collected until the calculation is complete. selgrp = selection.getSelectionAsGroup().clone() selection.clearAndSelect(IntersectSelection(ms, selgrp, group)) registeredclass.Registration('Select Group', SelectionModifier, GroupSelectionModifier, ordering=1.0, params=[ pixelgroupparam.PixelGroupParameter( 'group', tip='Select pixels in this group.'), ], tip='Select all pixels in the given group.', discussion="""<para> Deselect all pixels, and then select the pixels in the given group. Compare to <xref linkend='MenuItem-OOF.PixelSelection.Add_Group'/>. </para>""") registeredclass.Registration( 'Add Group', SelectionModifier, GroupTooSelectionModifier,
def __call__(self, ms, selection): group = ms.findGroup(self.group) if group is not None: selection.start() self.operator.operate( selection, pixelselectioncourier.GroupSelection(ms, group)) registeredclass.Registration( 'Group', SelectionModifier, GroupSelector, ordering=1, params=[ pixelgroupparam.PixelGroupParameter('group', tip='Pixel group to work with.'), parameter.RegisteredParameter( 'operator', PixelSelectionOperator, tip="How to use the group to modify the current selection.") ], tip="Modify the current selection via boolean operations" " with the pixels in a pixel group.") #=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=# ## Geometrical selection. These will have GUI counterparts ## when we figure out how to click and drag on the 3D canvas. # The selection methods operate upon sets of pixels defined by shapes # from the SelectionShape class. The SelectionShape subclasses don't