Пример #1
0
 def subprobEditCB(self, gtkobj, path=None, col=None):
     subproblemname = self.currentFullSubProblemName()
     if subproblemname:
         menuitem = mainmenu.OOF.Subproblem.Edit
         subpctxt = ooflib.engine.subproblemcontext.subproblems[
             subproblemname]
         subpparam = menuitem.get_arg('subproblem')
         subpparam.set(subpctxt.subptype)
         extra_params = []
         extra_params.append(whoville.WhoParameter(subpctxt.name(), subpctxt, subpctxt.path()))
         if parameterwidgets.getParameters(
             subpparam, title="Edit Subproblem definition", scope=self, hidden_params=extra_params):
             menuitem.callWithDefaults(name=subproblemname)
Пример #2
0
def buildImageModMenu():
    imagemodmenu.clearMenu()
    for registration in imagemodifier.ImageModifier.registry:
        try:
            help = registration.tip
        except AttributeError:
            help = None
        params = [whoville.WhoParameter('image', whoville.getClass('Image'),
                                        tip=parameter.emptyTipString)] \
                 + registration.params
        menuitem = imagemodmenu.addItem(
            oofmenu.OOFMenuItem(registration.name(),
                                callback=imagemodifier.doImageMod,
                                params=params,
                                help=help,
                                discussion=registration.discussion))
        menuitem.data = registration
Пример #3
0
        skeleton=skel,
        elementdict=edict,
        materialfactory=skeletonelement.SkeletonElement.realmaterial)
    meshctxt.createDefaultSubProblem()


meshmenu.addItem(
    OOFMenuItem(
        'New',
        callback=_newMesh,
        params=[
            parameter.StringParameter('name', tip="Name for the Mesh."),
            parameter.ListOfStringsParameter('masterelems',
                                             tip="Names of Master Elements."),
            whoville.WhoParameter('skeleton',
                                  skeletoncontext.skeletonContexts,
                                  tip=parameter.emptyTipString)
        ],
        help="Load a Mesh. Used internally in Mesh data files.",
        discussion="<para>Load a &mesh; from a datafile.</para>"))


def _newSubProblem(menuitem, mesh, name, subproblem):
    meshcontext = ooflib.engine.mesh.meshes[mesh]
    meshcontext.reserve()
    meshcontext.begin_writing()
    try:
        subpobj = subproblem.create()
        meshcontext.newSubProblem(subpobj, subproblem,
                                  labeltree.makePath(mesh) + [name])
    finally:
Пример #4
0
                dependencysubp.subptype.add_dependent(copyname)

            for dep in copyctxt.subptype.get_dependencies():
                ooflib.engine.subproblemcontext.subproblems[
                    dep].update_consistency()

            copyctxt.propagate_consistency([copyname])

subproblemMenu.addItem(
    oofmenu.OOFMenuItem(
        'Copy',
        callback=_copy_subproblem,
        threadable=oofmenu.THREADABLE,
        params=parameter.ParameterGroup(
            whoville.WhoParameter('subproblem',
                                  ooflib.engine.subproblemcontext.subproblems,
                                  tip='The subproblem to be copied.'),
            SyncMeshParameter('mesh', tip='The copy will be in this mesh.'),
            whoville.AutoWhoNameParameter('name',
                                          value=automatic.automatic,
                                          resolver=subproblemNameResolver,
                                          tip="Name to give to the copy")),
        help="Copy a subproblem.",
        discussion="""<para>
    Copy a &subproblem;, possibly to another &mesh;.  If the original
    &subproblem; is defined in terms of objects (&pixelgroups;,
    &materials;, <foreignphrase>etc.</foreignphrase> that don't exist
    in the destination &mesh;, then the copied &subproblem; will
    contain no &elems;.
    </para>"""))
Пример #5
0
def buildSelectionModMenu():
    selmodmenu.clearMenu()
    selmodmenu.addItem(
        oofmenu.OOFMenuItem('Undo',
                            params=[
                                whoville.WhoParameter(
                                    'microstructure',
                                    microstructure.microStructures,
                                    tip=parameter.emptyTipString)
                            ],
                            callback=pixelselectionmod.undo,
                            help="Undo the latest selection.",
                            discussion=xmlmenudump.loadFile(
                                'DISCUSSIONS/common/menu/undo_pixsel.xml')))

    selmodmenu.addItem(
        oofmenu.OOFMenuItem('Redo',
                            params=[
                                whoville.WhoParameter(
                                    'microstructure',
                                    microstructure.microStructures,
                                    tip=parameter.emptyTipString)
                            ],
                            callback=pixelselectionmod.redo,
                            help="Redo the latest undone selection.",
                            discussion=xmlmenudump.loadFile(
                                'DISCUSSIONS/common/menu/redo_pixsel.xml')))

    selmodmenu.addItem(
        oofmenu.OOFMenuItem(
            'Clear',
            params=[
                whoville.WhoParameter('microstructure',
                                      microstructure.microStructures,
                                      tip=parameter.emptyTipString)
            ],
            callback=pixelselectionmod.clear,
            help="Clear the current selection.",
            discussion="<para>Clear the current selection.</para>"))

    for registration in pixelselectionmod.SelectionModifier.registry:
        # Help string
        try:
            help = registration.tip
        except AttributeError:
            help = None
        # Discussion
        try:
            discussion = registration.discussion
        except AttributeError:
            discussion = None
        menuitem = selmodmenu.addItem(
            oofmenu.OOFMenuItem(
                utils.space2underscore(registration.name()),
                callback=pixelselectionmod.doSelectionMod,
                threadable=oofmenu.THREADABLE,
                params=[
                    whoville.WhoParameter('microstructure',
                                          microstructure.microStructures,
                                          tip=parameter.emptyTipString)
                ] + registration.params,
                help=help,
                discussion=discussion))
        menuitem.data = registration
Пример #6
0
        # copied.  We don't need to know it here.
        meshctxt = ooflib.engine.mesh.meshes[self.mesh]
        meshctxt.restoreCachedData(meshctxt.getTime(self.time))
        try:
            meshobj = meshctxt.getObject()
            femesh.init_field(meshobj.skeleton, meshobj, field)
        finally:
            meshctxt.releaseCachedData()

    def shortrepr(self):
        return "mesh=%s" % self.mesh


othermeshparams = [
    whoville.WhoParameter('mesh',
                          ooflib.engine.mesh.meshes,
                          tip='Copy field values from this Mesh.'),
    placeholder.TimeParameter(
        'time',
        value=placeholder.latest,
        tip='Use values at this time in the source Mesh.')
]


class ScalarOtherMeshInit(OtherMeshFieldInit, ScalarFieldInit):
    pass


registeredclass.Registration(
    "Other Mesh",
    ScalarFieldInit,
Пример #7
0
            switchboard.notify("new pixel group", grp)
        return grp

    reporter.report("Failed to create group", name, "in microstructure",
                    microstructure)


ipcpixgrpmenu.addItem(
    OOFMenuItem(
        'New',
        callback=newPixelGroup_parallel,
        threadable=oofmenu.PARALLEL_THREADABLE,
        params=parameter.ParameterGroup(
            StringParameter('name', tip="Group name."),
            whoville.WhoParameter(
                'microstructure',
                whoville.getClass('Microstructure'),
                tip="Microstructure in which to create this PixelGroup.")),
        help='Create a new PixelGroup in the given Microstructure.',
        discussion="""<para>

    Create a new &pixelgroup;.  The <varname>name</varname> of the
    group must be unique within the &micro;.  If it is not unique, a
    suffix of the form <userinput>&lt;x&gt;</userinput> will be
    appended, for some integer <userinput>x</userinput>.

    </para>"""))

##########################


def renamePixelGroup_parallel(menuitem, microstructure, group, new_name):
Пример #8
0
##############################


class CopyActiveArea(ActiveAreaModifier):
    def __init__(self, source):
        self.source = source  # source Microstructure

    def __call__(self, microstructure):
        sourceMS = ooflib.common.microstructure.microStructures[self.source]
        microstructure.activearea.start()
        microstructure.activearea.getObject().setFromGroup(
            sourceMS.getObject().activearea.getPixelSet())
        ## TODO OPT: Does this have to send "pixel selection changed"?


registeredclass.Registration(
    'Copy',
    ActiveAreaModifier,
    CopyActiveArea,
    ordering=5.0,
    params=[
        whoville.WhoParameter(
            'source',
            ooflib.common.microstructure.microStructures,
            tip='Copy the active area from this Microstructure.')
    ],
    tip="Copy the active area from another Microstructure.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/common/menu/copy_activearea.xml'))
Пример #9
0
    tip="Gray image data.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/image/reg/graydata8.xml'))


def _newImage(menuitem, name, microstructure, pixels):
    ms = ooflib.common.microstructure.microStructures[microstructure].getObject()
    image = oofimage.newImageFromData(name, ms.sizeInPixels(), pixels.values())
    image.setSize(ms.size())
    imagemenu.loadImageIntoMS(image, microstructure)
    
imgmenu.addItem(oofmenu.OOFMenuItem(
    'New',
    callback=_newImage,
    params=[
    parameter.StringParameter('name', tip="Name for the Image."),
    whoville.WhoParameter('microstructure',whoville.getClass('Microstructure'),
                          tip=parameter.emptyTipString),
    parameter.RegisteredParameter('pixels', ImageData,
                                  tip=parameter.emptyTipString)],
    help="Load an Image.",
    discussion="<para>Load an &image; from a saved &micro;.</para>"
    ))



def writeImage(datafile, imagecontext):
    datafile.startCmd(mainmenu.OOF.LoadData.Image.New)
    datafile.argument('name', imagecontext.name())
    datafile.argument('microstructure', imagecontext.getMicrostructure().name())
    datafile.argument('pixels', RGBData8(imagecontext.getObject().getPixels()))
    datafile.endCmd()
Пример #10
0
        endtime = meshctxt.getTime(finish)
        for t in meshctxt.cachedTimes():
            if starttime <= t <= endtime:
                yield t


registeredclass.Registration(
    "Times From One Mesh",
    animationtimes.AnimationTimes,
    MeshTimes,
    ordering=0,
    ## TODO 3.1: Restrict to meshes actually displayed in the gfx
    ## window!  This might be hard to do.
    params=[
        whoville.WhoParameter('mesh',
                              ooflib.engine.mesh.meshes,
                              tip="The name of the Mesh.")
    ],
    tip="Get frame times from stored data in a Mesh.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/meshtimes.xml'))


class AllMeshTimes(animationtimes.AnimationTimes):
    # Use times stored in all animated Meshes in the window
    def times(self, start, finish, gfxwindow):
        # Return a list of times between start and finish for all the
        # animatable layers in the graphics window.
        thymes = gfxwindow.findAnimationTimes()
        if thymes:
            if start is placeholder.earliest:
                if finish is placeholder.latest:
Пример #11
0
        parameter.BooleanParameter("front_back_periodicity", value=False,
            tip="Whether or not the skeleton is periodic in the third direction"))


skeletonmenu.addItem(oofmenu.OOFMenuItem(
    'Auto',
    callback=autoskeleton.autoSkeleton,
    threadable=oofmenu.THREADABLE,
    no_log=True,                        # because it calls other menu items
    params=parameter.ParameterGroup(
    parameter.AutomaticNameParameter('name',
                           value=automatic.automatic,
                           resolver=skeletonNameResolver,
                           tip="Name of the new skeleton."),
    whoville.WhoParameter('microstructure',
                          ooflib.common.microstructure.microStructures,
                          tip=parameter.emptyTipString)) +
    periodicityParams +
    parameter.ParameterGroup(
    parameter.FloatParameter('maxscale', value=1.0,
                             tip="Rough size of the largest elements."),
    parameter.FloatParameter("minscale", value=1.0,
                             tip="Rough size of the smallest elements."),
    enum.EnumParameter('units', ooflib.common.units.Units, value='Physical',
                       tip="Units for minscale and maxscale."),
    parameter.FloatRangeParameter('threshold', (0.0, 1.0, 0.01),
                                  value=0.90,
                                  tip="Minimum acceptable homogeneity")
    ),                                  # end of ParameterGroup
    help="Automatically create and refine a &skel;.",
    discussion=xmlmenudump.loadFile("DISCUSSIONS/engine/menu/autoskel.xml")
Пример #12
0

# This resolver can return "None" in the skelname==None case, which
# occurs when the registeredclassfactory switches around.
def bdynameresolver(param, startname):
    if param.automatic():
        basename = 'boundary'
    else:
        basename = startname
    skelname = param.group['skeleton'].value
    skelcontext = skeletoncontext.skeletonContexts[skelname]
    return skelcontext.uniqueBoundaryName(basename)


skeletonparam = whoville.WhoParameter(
    'skeleton',
    skeletoncontext.skeletonContexts,
    tip="The Skeleton containing the  boundary.")

nameparam = parameter.AutomaticNameParameter('name',
                                             bdynameresolver,
                                             value=automatic.automatic,
                                             tip="Name for this boundary.")

paramgroup = parameter.ParameterGroup(skeletonparam, nameparam)

# ## ### #### ##### ###### ####### ######## ####### ###### ##### #### ### ## #


class BoundaryConstructor(registeredclass.RegisteredClass):
    registry = []
    tip = "Tools to build Skeleton boundaries."
Пример #13
0
        "Deselect all pixels within a given distance of the boundaries of the current selection.",
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/common/menu/shrink_pixsel.xml'))
#############################


class CopyPixelSelection(SelectionModifier):
    def __init__(self, source):
        self.source = source

    def __call__(self, ms, selection):
        selection.start()
        sourceMS = ooflib.common.microstructure.microStructures[self.source]
        selection.selectFromGroup(
            sourceMS.getObject().pixelselection.getSelectionAsGroup())


registeredclass.Registration(
    'Copy',
    SelectionModifier,
    CopyPixelSelection,
    ordering=4.0,
    params=[
        whoville.WhoParameter(
            'source',
            ooflib.common.microstructure.microStructures,
            tip="Copy the current selection from this Microstructure.")
    ],
    tip="Copy the current selection from another Microstructure.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/common/menu/copy_pixsel.xml'))
Пример #14
0
 def __init__(self, gfxwindow):
     toolbox.Toolbox.__init__(self, 'Pin_Nodes', gfxwindow)
     self.skeleton_param = whoville.WhoParameter(
         'skeleton',
         whoville.getClass('Skeleton'),
         tip=parameter.emptyTipString)
Пример #15
0
    themesh.begin_writing()
    try:
        themesh.rename(name, exclude=oldmeshpath[-1])
    finally:
        themesh.end_writing()
        themesh.cancel_reservation()


ipcmeshmenu.addItem(
    oofmenu.OOFMenuItem(
        'Rename',
        callback=renameMesh_parallel,
        threadable=oofmenu.PARALLEL_THREADABLE,
        params=[
            whoville.WhoParameter('mesh',
                                  ooflib.engine.mesh.meshes,
                                  tip=parameter.emptyTipString),
            parameter.StringParameter('name', '', tip='New name for the mesh.')
        ]))

#######################################


def deleteMesh_parallel(menuitem, mesh):
    meshctxt = ooflib.engine.mesh.meshes[mesh]

    subproblems = meshctxt.subproblems()
    for subproblem in subproblems:
        subproblem.begin_writing()
        try:
            subproblem.destroy()
Пример #16
0
def makeMenu():
    pinnodesmenu.clearMenu()

    pinnodesmenu.addItem(
        oofmenu.OOFMenuItem('Undo',
                            callback=pinnodesmodifier.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=pinnodesmodifier.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=pinnodesmodifier.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=pinnodesmodifier.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=pinnodesmodifier.pinnodesmod,
                params=[
                    whoville.WhoParameter('skeleton',
                                          skeletoncontext.skeletonContexts,
                                          tip=parameter.emptyTipString)
                ] + registration.params,
                help=help,
                discussion=discussion))
        menuitem.data = registration
Пример #17
0
def buildActiveAreaModMenu():
    aamodmenu.clearMenu()
                                                                                
    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Undo',
        callback=_undo,
        params=[whoville.WhoParameter('microstructure',
                                      ooflib.common.microstructure.microStructures,
                                      tip=parameter.emptyTipString)
                ],
        help="Undo the latest active area modification.",
        discussion="""<para>
        Revert to the previous &active; in the given
        &micro;.</para>"""
        ))
                                                                                
    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Redo',
        callback=_redo,
        params=[whoville.WhoParameter('microstructure',
                                      ooflib.common.microstructure.microStructures,
                                      tip=parameter.emptyTipString)
                ],
        help="Redo the latest undone active area modification.",
        discussion="""<para>
        Undo the latest <xref linkend='MenuItem-OOF.ActiveArea.Undo'/>.
        </para>"""))

    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Override',
        params=[parameter.BooleanParameter('override', 0,
                                           tip="Whether to override or not."),
                whoville.WhoParameter('microstructure',
                                      ooflib.common.microstructure.microStructures,
                                      tip=parameter.emptyTipString)
                ],
        callback=_override,
        help="Temporarily activate the entire Microstructure.",
        discussion=xmlmenudump.loadFile('DISCUSSIONS/common/menu/activearea_override.xml')))

    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Store',
        callback=_store,
        params=parameter.ParameterGroup(
        whoville.WhoParameter('microstructure',
                              ooflib.common.microstructure.microStructures,
                              tip=parameter.emptyTipString),
        parameter.AutomaticNameParameter('name', value=automatic.automatic,
                                         resolver=activeAreaNameResolver,
                                         tip = "The name of the active are to be stored")),
        help="Store the current active area.",
        discussion="""<para>

        Give the current &active; a <varname>name</varname>, and store
        it for future use.  This makes it easy to switch between
        different active regions of a &micro;.  If the given
        <varname>name</varname> is already being used for another
        &active; in the same &micro;, then
        <userinput>&lt;x&gt;</userinput> will be appended to it, where
        <userinput>x</userinput> is an integer chosen to make the name
        unique.

        </para>"""))

    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Restore',
        callback=_restore,
        params=[whoville.WhoParameter('microstructure',
                                      ooflib.common.microstructure.microStructures,
                                      tip=parameter.emptyTipString),
                parameter.StringParameter('name', tip="The name of the active area to be restored.")],
        help="Restore a named active area.",
        discussion="""<para>
        Set the current &active; to the given <link
        linkend='MenuItem-OOF.ActiveArea.Store'>stored</link>
        &active;.
        </para>"""))
    
    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Rename',
        callback=_rename,
        params=[
        whoville.WhoParameter('microstructure',
                              ooflib.common.microstructure.microStructures,
                              tip=parameter.emptyTipString),
        parameter.StringParameter('oldname',
                                  tip="The name of a stored active area."),
        parameter.StringParameter('newname', '',
                                  tip='A new name for the active area.')
        ],
        help="Rename the stored active area.",
        discussion="<para>Assign a new name to a stored active area.</para>"))
    
    aamodmenu.addItem(oofmenu.OOFMenuItem(
        'Delete',
        callback=_delete,
        params=[
        whoville.WhoParameter('microstructure',
                              ooflib.common.microstructure.microStructures,
                              tip=parameter.emptyTipString),
        parameter.StringParameter('name', tip="The name of the active area to be deleted.")],
        help="Delete a stored active area.",
        discussion="""<para>
        Delete a <link
        linkend='MenuItem-OOF.ActiveArea.Store'>stored</link> active
        area.  This only deletes the stored copy of the active area.
        It does not affect the activity of any pixels.
        </para>"""))
    
                           
                                                                                
    for registration in activeareamod.ActiveAreaModifier.registry:
        # registration tip string => menuitem help string
        try:
            help = registration.tip
        except AttributeError:
            help = None
        # registration discussion => menuitem discussion
        try:
            discussion = registration.discussion
        except AttributeError:
            discussion = None
        menuitem = aamodmenu.addItem(
            oofmenu.OOFMenuItem(utils.space2underscore(registration.name()),
                                callback=activeareamod.modify,
                                params=[
            whoville.WhoParameter('microstructure',
                                  ooflib.common.microstructure.microStructures,
                                  tip=parameter.emptyTipString)
            ] + registration.params,
                                help=help,
                                discussion=discussion))
        menuitem.data = registration
Пример #18
0
from ooflib.engine import namedanalysis
from ooflib.engine.IO import analyzemenu
from ooflib.engine.IO import meshmenu
from ooflib.engine.IO import meshparameters
from ooflib.engine.IO import outputdestination
import ooflib.engine.mesh
import string
import types

bdyanalysismenu = meshmenu.meshmenu.addItem(
    oofmenu.OOFMenuItem(
        'Boundary_Analysis',
        help="Compute properties of the solution on boundaries."))

mesh_param = whoville.WhoParameter(
    'mesh',
    ooflib.engine.mesh.meshes,
    tip="The mesh on which to perform the analysis.")

time_param = placeholder.TimeParameter(
    'time', tip='Time at which to perform the analysis.')

bdy_param = meshparameters.MeshEdgeBdyParameter('boundary',
                                                tip="The boundary to analyze.")

analyzer_param = parameter.RegisteredParameter(
    'analyzer',
    meshbdyanalysis.MeshBdyAnalyzer,
    tip="Operation to perform on the boundary.")

destination_param = outputdestination.OutputDestinationParameter(
    'destination',
Пример #19
0
def makeMenu(menu, modifier, selection_name):
    menu.clearMenu()

    objname = selection_name[:-9]  # 'node', 'segment', or 'element'

    undo_item = menu.addItem(
        oofmenu.OOFMenuItem(
            "Undo",
            callback=_undo,
            params=[
                whoville.WhoParameter("skeleton",
                                      whoville.getClass('Skeleton'),
                                      tip=parameter.emptyTipString)
            ],
            help="Undo the latest Skeleton %s selection operation." % objname,
            discussion=xmlmenudump.loadFile(
                'DISCUSSIONS/engine/menu/%s_undo.xml' % objname)))
    undo_item.data = selection_name

    redo_item = menu.addItem(oofmenu.OOFMenuItem(
        "Redo", callback=_redo,
              params = [
        whoville.WhoParameter("skeleton",
                              whoville.getClass('Skeleton'),
                              tip=parameter.emptyTipString)],
        help="Redo the latest undone Skeleton %s selection operation."\
        % objname,
        discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/menu/%s_redo.xml'
                                        % objname)
        ))
    redo_item.data = selection_name

    clear_item = menu.addItem(
        oofmenu.OOFMenuItem(
            "Clear",
            callback=_clear,
            params=[
                whoville.WhoParameter("skeleton",
                                      whoville.getClass('Skeleton'),
                                      tip=parameter.emptyTipString)
            ],
            help="Clear the current Skeleton %s selection." % objname,
            discussion="<para>Unselect all %ss in the &skel;.</para>" %
            objname))
    clear_item.data = selection_name

    invert_item = menu.addItem(
        oofmenu.OOFMenuItem(
            "Invert",
            callback=_invert,
            params=[
                whoville.WhoParameter("skeleton",
                                      whoville.getClass('Skeleton'),
                                      tip=parameter.emptyTipString)
            ],
            help="Invert the current Skeleton %s selection." % objname,
            discussion="""<para>
        Select the unselected %ss, and unselect the selected %ss in the &skel;.
        </para>""" % (objname, objname)))
    invert_item.data = selection_name

    for r in modifier.registry:
        # For help
        try:
            help = r.tip
        except AttributeError:
            help = None
        # For discussion
        try:
            discussion = r.discussion
        except AttributeError:
            discussion = None
        menuitem = menu.addItem(
            oofmenu.OOFMenuItem(
                utils.space2underscore(r.name()),
                callback=skeletonselectionmod.modify,
                params=[
                    whoville.WhoParameter("skeleton",
                                          whoville.getClass('Skeleton'),
                                          tip=parameter.emptyTipString)
                ] + r.params,
                help=help,
                discussion=discussion))
        menuitem.data = r
Пример #20
0
    def __call__(self, ms, selection):
        skel = skeletoncontext.skeletonContexts[self.skeleton].getObject()
        selection.start()
        for el in skel.elements:
            if el.selected:
                selection.select(ElementSelection(ms, el))


registeredclass.Registration(
    'Select Element Pixels',
    registeredclass=pixelselectionmod.SelectionModifier,
    subclass=SelectPixelsInElement,
    ordering=100,
    params=[
        whoville.WhoParameter('skeleton',
                              skeletoncontext.skeletonContexts,
                              tip=parameter.emptyTipString)
    ],
    tip="Select the pixels lying under the selected elements.",
    discussion="""<para>
    Select all pixels that intersect the currently selected &skel; elements.
    </para>""")

SegmentSelection = pixelselectioncouriere.SegmentSelection


class SelectPixelsUnderSegment(pixelselectionmod.SelectionModifier):
    def __init__(self, skeleton):
        self.skeleton = skeleton

    def __call__(self, ms, selection):
Пример #21
0
                         corientation.COrientABG(*orientations[count]))
        count += 1
    orientmapdata.registerOrientMap(microstructure, od)
    orientmapplugin = mscontext.getObject().getPlugIn('OrientationMap')
    orientmapplugin.set_data(od, filename)
    orientmapplugin.timestamp.increment()
    orientmapdata.orientationmapNotify(ms)


microstructureIO.micromenu.addItem(
    oofmenu.OOFMenuItem(
        'OrientationMap',
        callback=_loadOrientationMap,
        params=[
            whoville.WhoParameter('microstructure',
                                  ooflib.common.microstructure.microStructures,
                                  tip=parameter.emptyTipString),
            parameter.StringParameter('filename',
                                      tip="File from which the map was read."),
            parameter.ListOfListOfFloatsParameter(
                'orientations', tip='Tuples containing ABG values.')
        ],
        help="Load an Orientation Map.  Used internally in data files.",
        discussion="""<para>

    Load an <classname>Orientation Map</classname> into a &micro;.
    This command is used only in data files, and is only available if
    &oof2; was built with the
    <userinput>--enable-orientationmap</userinput> option.

    </para>"""))
Пример #22
0
        for name in active_areas:
            aal.add(aa_dict[name])
            px_dict[name].append(p)

    for name in active_areas:
        aa_dict[name].add_pixels(px_dict[name])


# This item is a sub-item of OOF.LoadData.Microstructure.DefineCategory.
microstructureIO.categorymenu.addItem(
    oofmenu.OOFMenuItem(
        'NamedActiveArea',
        callback=_namedactivearea,
        params=[
            whoville.WhoParameter('microstructure',
                                  ms_module.microStructures,
                                  tip=parameter.emptyTipString),
            parameter.IntParameter('category', tip=parameter.emptyTipString),
            parameter.ListOfStringsParameter('active_areas',
                                             tip=parameter.emptyTipString)
        ],
        help="Create a named active area in a microstructure",
        discussion="""<para> Creates a named active area when
    loading a microstructure from
    a file.  This menu item is only used in data files.</para>"""))


def _newactivearea(menuitem, microstructure, name):
    ms_obj = ms_module.getMicrostructure(microstructure)
    new_aa = activearea.ActiveArea(ms_obj.sizeInPixels(), ms_obj.size(),
                                   ms_obj)
Пример #23
0
        meshcontext = ooflib.engine.mesh.meshes[meshpath]
        return meshcontext.uniqueBCName(basename)


bcmenu.addItem(
    oofmenu.OOFMenuItem(
        'New',
        callback=_buildbc,
        params=parameter.ParameterGroup(
            parameter.AutomaticNameParameter(
                'name',
                value=automatic.automatic,
                tip="Name of the new boundary condition",
                resolver=bcnameResolver),
            whoville.WhoParameter(
                'mesh',
                ooflib.engine.mesh.meshes,
                tip='Mesh to which to apply the boundary condition.'),
            parameter.RegisteredParameter("condition",
                                          bdycondition.BC,
                                          tip="The new boundary condition.")),
        help='Create a new boundary condition.',
        discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/menu/new_bc.xml')))


def _bcrename(menuitem, mesh, bc, name):
    if parallel_enable.enabled():
        boundaryconditionIPC.ipcbcmenu.Rename(mesh=mesh, bc=bc, name=name)
    else:
        meshcontext = ooflib.engine.mesh.meshes[mesh]
        meshcontext.renameBdyCondition(bc, name)
Пример #24
0
if config.dimension() == 2:

    def loadImage(menuitem, filename, microstructure, height, width):
        if filename:
            # Read file and create an OOFImage object
            image = autoReadImage(filename, height, width, depth=0)
            loadImageIntoMS(image, microstructure)
            switchboard.notify("redraw")

    imageparams = parameter.ParameterGroup(
        filenameparam.ReadFileNameParameter('filename',
                                            'image',
                                            tip="Name of the image file."),
        whoville.WhoParameter('microstructure',
                              whoville.getClass('Microstructure'),
                              tip=parameter.emptyTipString))

elif config.dimension() == 3:

    def loadImage(menuitem, filenames, microstructure, height, width, depth):
        if filenames:
            # Read file and create an OOFImage3D object
            image = autoReadImage(filenames, height, width, depth)
            loadImageIntoMS(image, microstructure)
            switchboard.notify("redraw")

    imageparams = parameter.ParameterGroup(
        parameter.RegisteredParameter("filenames",
                                      oofimage.ThreeDImageSpecification),
        whoville.WhoParameter('microstructure',
Пример #25
0
        imageobj = image.getObject()
        ms = image.getMicrostructure()
        selection.start()
        selection.clearAndSelect(
            pixelselectioncourieri.ColorSelection(ms, imageobj, self.reference,
                                                  self.range))


registeredclass.Registration(
    'Color Range',
    pixelselectionmod.SelectionModifier,
    ColorRange,
    ordering=3.14,
    params=[
        whoville.WhoParameter('image',
                              whoville.getClass('Image'),
                              tip=parameter.emptyTipString),
        color.NewColorParameter('reference', tip='Reference color.'),
        colordiffparameter.ColorDifferenceParameter(
            'range', tip='Deviation from the reference color.')
    ],
    tip="Select all pixels similar to a reference color.",
    discussion="""<para>

    Select all pixels in an &image; within a given
    <varname>range</varname> of a given <varname>refererence</varname>
    color.  This command basically does the same thing that <xref
    linkend='MenuItem:OOF.Graphics_n.Toolbox.Pixel_Select.Color'/>
    does except the latter takes its <varname>reference</varname>
    input from a mouse click in the Graphics window.
Пример #26
0
    meshctxt.begin_writing()
    try:
        meshctxt.outputSchedule.add(name, output)
        output.setSchedule(schedule, scheduletype)
        output.setDestination(destination)
    finally:
        meshctxt.end_writing()
    switchboard.notify("new scheduled output", meshctxt, name)
    

outputmenu.addItem(oofmenu.OOFMenuItem(
    'New',
    callback=_newOutput,
    params=parameter.ParameterGroup(
            whoville.WhoParameter(
                'mesh', ooflib.engine.mesh.meshes,
                tip='Define an output operation on this mesh.'),
            parameter.AutomaticNameParameter(
                'name', resolver=outputNameResolver,
                value=automatic.automatic,
                tip="A name for the new output operation."),
            parameter.RegisteredParameter(
                'output',
                scheduledoutput.ScheduledOutput,
                tip="The output operation."))
    + parameter.ParameterGroup(
        parameter.RegisteredParameter(
            'scheduletype',
            outputschedule.ScheduleType,
            tip='How to interpret the schedule.'),
        outputschedule.OutputScheduleParameter(
Пример #27
0
 def sourceParams(self):
     return [
         whoville.WhoParameter('skeleton',
                               whoville.getClass('Skeleton'),
                               tip=parameter.emptyTipString)
     ]
Пример #28
0
    help="Compute properties of the solution.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/menu/analyze.xml'))

mainmenu.OOF.Mesh.addItem(ops_menu)

## OOF.LoadData.IPC.Analyze
if parallel_enable.enabled():
    from ooflib.common.IO import parallelmainmenu
    ipcops_menu = parallelmainmenu.ipcmenu.addItem(
        oofmenu.OOFMenuItem('Analyze', secret=1, no_log=1)
        )

# Parameters to all the menu items.

mesh_param =  whoville.WhoParameter(
    'mesh', ooflib.engine.mesh.meshes,
    tip="The mesh on which to compute the output")

time_param = placeholder.TimeParameter(
    'time', tip='Time at which to perform the analysis.')

output_param = output.ValueOutputParameter(
    'data', tip="The output data source.")

domain_param = parameter.RegisteredParameter(
    'domain', analysisdomain.Domain,
    tip="Where on the mesh to compute the data.")

sample_param = parameter.RegisteredParameter(
    'sampling', analysissample.SampleSet,
    tip="How to sample the domain.")
Пример #29
0
    # Gets the default name from the object being copied (or renamed).
    def getBasename(self, param, startname):
        if param.automatic():
            return param.group['group'].value
        return startname
    
#######################################    

# Node-specific menu items:

new = oofmenu.OOFMenuItem(
    "New_Group",
    cli_only=1,
    callback=_new_group,
    params=parameter.ParameterGroup(
    whoville.WhoParameter("skeleton", whoville.getClass('Skeleton'),
                          tip=parameter.emptyTipString),
    AutomaticNameParameter("name", value=automatic.automatic,
                           resolver=NewGroupNameResolver("nodegroup",
                                                         "nodegroups"),
                           tip="Name of the group to be created.")),
    help="Create a new node group.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/menu/newnodegroup.xml')
    )
new.data = "nodegroups"
nodegroupmenu.addItem(new)


auto = oofmenu.OOFMenuItem(
    "Auto_Group",
    cli_only=1,
    callback=_auto_group,
Пример #30
0
def parallel_new_subproblem(menuitem, name, mesh, subproblem):
    debug.fmsg()
    meshcontext = ooflib.engine.mesh.meshes[mesh]
    meshcontext.newSubProblem(subproblem, labeltree.makePath(mesh) + [name])


ipcsubproblemmenu.addItem(
    oofmenu.OOFMenuItem(
        'New',
        callback=parallel_new_subproblem,
        threadable=oofmenu.PARALLEL_THREADABLE,
        params=[
            parameter.StringParameter('name'),
            whoville.WhoParameter('mesh',
                                  ooflib.engine.mesh.meshes,
                                  tip=parameter.emptyTipString),
            parameter.RegisteredParameter('subproblem',
                                          csubproblem.CSubProblemPtr,
                                          tip=parameter.emptyTipString)
        ]))

#############

## TODO MER: The code in _copy_subproblem and _edit_subproblem is
## virtually identical and should be shared.


def parallel_copy_subproblem(menuitem, subproblem, mesh, name):
    debug.fmsg()
    sourcectxt = ooflib.engine.subproblemcontext.subproblems[subproblem]