Beispiel #1
0
    def makeMenu(self, menu):
        self.menu = menu
        if config.dimension() == 2:
            pixelname = 'pixel'
        else:
            pixelname = 'voxel'
        positionparams = [
            pointparameter.PointParameter(
                'point', tip='The position of the queried %s.' % pixelname)
            ]
        if config.dimension() == 3:
            positionparams.append(view.ViewParameter('view'))
        # positionparams=[
        #     parameter.IntParameter('x', 0, tip="The x coordinate."),
        #     parameter.IntParameter('y', 0, tip="The y coordinate.")]
        # if config.dimension() == 3:
        #     positionparams.append(
        #         parameter.IntParameter('z', 0, tip="The z coordinate."))
        helpstring = "Query the %s at the given point." % pixelname

        menu.addItem(oofmenu.OOFMenuItem(
            'Query',
            callback=self.queryPixel,
            params=positionparams,
            help=helpstring,
            discussion="""<para>
            Display information about the %s at the given screen
            coordinate.  In GUI mode, the information appears in the
            <link linkend='Section:Graphics:PixelInfo'>Pixel
            Info</link> toolbox in the graphics window.  This command
            has no effect when the GUI is not running.
            </para>""" % pixelname
            ))
        menu.addItem(oofmenu.OOFMenuItem(
                'QueryDirectly',
                callback=self.queryPixelDirectly,
                params=[pointparameter.PointParameter(
                        'voxel', tip="The coordinates of the queried voxel.")],
                help="Query the voxel at the given position in the image.",
                discussion="""<para>
                Display information about the voxel at the given
                position.  In GUI mode, the information appears in the
                <link linkend='Section:Graphics:PixelInfo'>PIxel
                Info</link> toolbox in the graphics window.  This
                command has no effect when the GUI is not running.
                </para>"""
                ))
        menu.addItem(oofmenu.OOFMenuItem(
            'Clear',
            callback=self.clearPixel,
            params=[],
            help="Reset the pixel info toolbox.",
            discussion="""<para>
            Clear any displayed information from previous mouse clicks.
            In GUI mode, this clears the <link
            linkend='Section:Graphics:PixelInfo'>Pixel Info</link>
            toolbox in the graphics window.  This command has no
            effect if the GUI is not running.
            </para>"""
            ))
Beispiel #2
0
 def makeMenu(self, menu):
     self.menu = menu
     menu.addItem(
         oofmenu.OOFMenuItem('MoveNode',
                             callback=self.moveNode,
                             params=[
                                 parameter.IntParameter(
                                     'node',
                                     tip='Index of the node to be moved.'),
                                 pointparameter.PointParameter(
                                     'destination',
                                     tip=parameter.emptyTipString)
                             ],
                             help="Move a node to another positon.",
                             discussion=xmlmenudump.loadFile(
                                 'DISCUSSIONS/engine/menu/move_node.xml')))
     menu.addItem(
         oofmenu.OOFMenuItem(
             'SelectNode',
             callback=self.selectNode,
             params=[
                 pointparameter.PointParameter(
                     'position', tip=parameter.emptyTipString),
                 view.ViewParameter('view')
             ],
             help="Select a node to move.",
             discussion=xmlmenudump.loadFile(
                 'DISCUSSIONS/engine/menu/select_move_node.xml')))
     menu.addItem(
         oofmenu.OOFMenuItem(
             'AllowIllegal',
             callback=self.allowIllegal,
             params=[
                 parameter.BooleanParameter('allowed',
                                            0,
                                            tip=parameter.emptyTipString)
             ],
             help="Are illegal elements allowed?",
             discussion=xmlmenudump.loadFile(
                 'DISCUSSIONS/engine/menu/allow_illegal.xml')))
        # consisting only of points beneath the mouse and doesn't use
        # the same vtkPoints as the skeleton, so it can't compute the
        # Node index.
        node = skelctxt.getObject().nearestNode(self.point)
        clist, plist = selection.trackerlist()
        courier = skeletonselectioncourier.SingleObjectCourier(
            skelctxt.getObject(), node, clist, plist)
        self.operator.operate(selection, courier)


NodeSelectionMethodRegistration(
    'Single Node',
    SingleNodeSelect,
    ordering=0,
    params=[
        parameter.passive(pointparameter.PointParameter('point')),
        selectionoperators.SelectionOperatorParam('operator', passive=1)
    ],
    tip="Select a single node.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/single_node.xml'))

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#

# Segment selection is like node selection, except for details.


class SingleSegmentSelect(SegmentSelectionMethod):
    def __init__(self, nodes, operator):
        self.nodes = nodes
        self.operator = operator
Beispiel #4
0
    except KeyError:
        pass
    else:
        oldms.lockAndDelete()
    ms = ooflib.SWIG.common.cmicrostructure.CMicrostructure(name, isize, size)


micromenu.addItem(
    oofmenu.OOFMenuItem(
        'New',
        callback=_newMicrostructure,
        params=[
            parameter.StringParameter('name', tip="Name of Microstructure."),
            pointparameter.iPointParameter(
                'isize', tip="Pixel resolution of Microstructure."),
            pointparameter.PointParameter(
                'size', tip="Physical size of Microstructure.")
        ],
        help="Create a new Microstructure.  Used internally in data files.",
        discussion="""<para>Create a new <quote>empty</quote> &micro;,
    containing no data other than its size.  This command is used only
    in <link linkend='MenuItem:OOF.LoadData.Microstructure'>data
    files</link>.</para>"""))

##########


def _newpixelgroup(menuitem, microstructure, group, meshable):
    mscontext = ooflib.common.microstructure.microStructures[microstructure]
    ms = mscontext.getObject()
    mscontext.begin_writing()
    try:
Beispiel #5
0
class SinglePoint(BulkDomain):
    def __init__(self, point):
        self.point = point

    def get_points(self):
        return [self.point]


registeredclass.Registration(
    'Single Point',
    Domain,
    SinglePoint,
    ordering=0.5,
    params=[
        pointparameter.PointParameter(
            'point', tip='Undisplaced position of the sample point.')
    ],
    sampling=(analysissample.PointSampleSet, ),
    tip='Use a single point for the post-processing domain.',
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/pointdomain.xml'))

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#

# Using an edge boundary as a domain doesn't make sense in 3D, because
# it's not possible to specify which elements to use.

## TODO OPT: Actually, it's possible to evaluate Fields if the nodes
## aren't split, and it's possible to evaluate Fluxes if we don't care
## which bulk element is used to do the computation.

## TODO MER: This hasn't been updated to work with the new (5/14)
Beispiel #6
0
def makeMenu():
    pinnodesmenu.clearMenu()

    skelparam = whoville.WhoParameter('skeleton',
                                      skeletoncontext.skeletonContexts,
                                      tip=parameter.emptyTipString)

    pinnodesmenu.addItem(oofmenu.OOFMenuItem(
        'Pin',
        callback=pin,
        params=[skelparam,
                pointparameter.PointParameter('node')],
        help="Pin the node at the given point and unpin all others."))

    pinnodesmenu.addItem(oofmenu.OOFMenuItem(
        'AddPin',
        callback=addpin,
        params=[skelparam,
                pointparameter.PointParameter('node')],
        help="Pin the node at the given point without unpinning all others."))

    pinnodesmenu.addItem(oofmenu.OOFMenuItem(
        'UnPin',
        callback=unpin,
        params=[skelparam,
                pointparameter.PointParameter('node')],
        help="Unpin the node at the given point."))

    pinnodesmenu.addItem(oofmenu.OOFMenuItem(
        'TogglePin',
        callback=toggle,
        params=[skelparam,
                pointparameter.PointParameter('node')],
        help="Pin the node at the given point if it's unpinned, and vice versa."
    ))

    pinnodesmenu.addItem(oofmenu.OOFMenuItem(
        'Undo',
        callback=undo,
        params=[whoville.WhoParameter('skeleton',
                                      skeletoncontext.skeletonContexts,
                                      tip=parameter.emptyTipString)],
        help="Undo the pinning operation.",
        discussion=xmlmenudump.loadFile(
                'DISCUSSIONS/engine/menu/pinnodes_undo.xml')
        ))
    
    pinnodesmenu.addItem(oofmenu.OOFMenuItem(
        'Redo',
        callback=redo,
        params=[whoville.WhoParameter('skeleton',
                                      skeletoncontext.skeletonContexts,
                                      tip=parameter.emptyTipString)],
        help="Undo the undone pinning operation.",
        discussion=xmlmenudump.loadFile(
                'DISCUSSIONS/engine/menu/pinnodes_redo.xml')
        ))
        
    pinnodesmenu.addItem(oofmenu.OOFMenuItem(
        'UnPinAll',
        callback=unpinall,
        params=[whoville.WhoParameter('skeleton',
                                      skeletoncontext.skeletonContexts,
                                      tip=parameter.emptyTipString)],
        help="Unpin all nodes of the Skeleton.",
        discussion="""<para>
        Unpin all of the <link
        linkend='MenuItem-OOF.Skeleton.PinNodes'>pinned</link> &nodes;
        in the given &skel;.
        </para>"""
        ))
    
    pinnodesmenu.addItem(oofmenu.OOFMenuItem(
        'Invert',
        callback=invert,
        params=[whoville.WhoParameter('skeleton',
                                      skeletoncontext.skeletonContexts,
                                      tip=parameter.emptyTipString)],
        help="Pin the unpinned and unpin the pinned.",
        discussion="""<para>
        Invert the status of <link
        linkend='MenuItem-OOF.Skeleton.PinNodes'>pinned</link> &nodes;
        in the given &skel;. Pinned &nodes; will be released and free
        nodes will be pinned.
        </para>"""))

    for registration in pinnodesmodifier.PinNodesModifier.registry:
        try:
            help = registration.tip
        except AttributeError:
            help = None
        try:
            discussion = registration.discussion
        except AttributeError:
            discussion = None
        menuitem = pinnodesmenu.addItem(
            oofmenu.OOFMenuItem(
            utils.space2underscore(registration.name()),
            callback=pinnodesmod,
            params=[whoville.WhoParameter('skeleton',
                                          skeletoncontext.skeletonContexts,
                                          tip=parameter.emptyTipString)]
            +registration.params,
            help=help,
            discussion=discussion))
        menuitem.data = registration
    discussion=xmlmenudump.loadFile('DISCUSSIONS/common/reg/pointselect.xml'))

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#


class RectangularPrismSelector(pixelselection.VoxelSelectionMethod):
    def __init__(self, corner0, corner1, operator):
        self.corner0 = corner0
        self.corner1 = corner1
        self.operator = operator

    def select(self, source, selection):
        ms = source.getMicrostructure()
        self.operator.operate(
            selection,
            pixelselectioncourier.BoxSelection(
                ms, geometry.CRectangularPrism(self.corner0, self.corner1)))


pixelselection.VoxelSelectionMethodRegistration(
    'Box',
    RectangularPrismSelector,
    ordering=0.2,
    params=[
        parameter.passive(pointparameter.PointParameter('corner0')),
        parameter.passive(pointparameter.PointParameter('corner1')),
        selectionoperators.SelectionOperatorParam('operator')
    ],
    whoclasses=['Microstructure', 'Image'],
    tip="Click to select a box-shaped region.")
Beispiel #8
0
from ooflib.common import registeredclass
from ooflib.common.IO import parameter
from ooflib.common.IO import pointparameter
from ooflib.common.IO import xmlmenudump

# Anticipating lots of different sorts of these, we make CrossSection
# a registered class.

class MeshCrossSection(registeredclass.RegisteredClass):
    registry = []

MeshCrossSection.tip = "Paths within a Mesh for post-processing."
MeshCrossSection.discussion = xmlmenudump.loadFile(
    "DISCUSSIONS/engine/reg/meshcrosssection.xml")

class StraightCrossSection(MeshCrossSection):
    # start and end should be primitives.Point objects...
    def __init__(self, start, end):
        self.start = start
        self.end = end
        

registeredclass.Registration(
    'Straight', MeshCrossSection, StraightCrossSection, 1,
    params=[pointparameter.PointParameter('start', tip="Starting point."),
            pointparameter.PointParameter('end', tip="Ending point.")],
    tip="Cross section defined by two points.",
    discussion="""<para>
    A Cross Section which is a straight line, defined by its endpoints.
    </para>""")