Ejemplo n.º 1
0
 def makeMenu(self, menu):
     self.menu = menu
     menu.addItem(oofmenu.OOFMenuItem(
             'Query',
             callback=self.queryObj,
             params=[
                 parameter.StringParameter(
                     'mode', tip="The type of object being queried."),
                 parameter.IntParameter(
                     'index', tip="The queried object's index.")],
             help="Query the object with the given index."))
     menu.addItem(oofmenu.OOFMenuItem(
             "Peek",
             callback=self.peekObj,
             params=[
                 parameter.StringParameter(
                     'mode', tip="The type of object being queried."),
                 parameter.IntParameter(
                     'index', tip="The queried object's index.")],
             help="Query the object with the given index."))
     menu.addItem(oofmenu.OOFMenuItem(
             'Prev',
             callback=self.prevQuery,
             help="Go to the previous query."))
     menu.addItem(oofmenu.OOFMenuItem(
             'Next',
             callback=self.nextQuery,
             help="Go to the next query."))
     menu.addItem(oofmenu.OOFMenuItem(
             'Clear',
             callback=self.clear,
             help='Clear the toolbox.'))
Ejemplo n.º 2
0
def fakeFileSelector(mode, ident=None, title=None, filename=None, params=None):
    nameparam = parameter.StringParameter('filename')
    parameters = [nameparam]
    if params:
        parameters.extend(params)
    if parameterwidgets.getParameters(title='Fake FileSelector', *parameters):
        return nameparam.value
Ejemplo n.º 3
0
 def named_copy(self, name, instance_params=[], secret=None):
     if secret is None:
         secret = self._secret
     old_params = instance_params or self.params
     new_params = [parameter.StringParameter('name',name)] + \
                  [p.clone() for p in old_params]
     return NamedPropertyRegistration(self, name, self.subclass,
                                      self.modulename, self.ordering,
                                      new_params, secret)
Ejemplo n.º 4
0
 def newdirCB(self, button):
     dirnameparam = parameter.StringParameter('directory name')
     if parameterwidgets.getParameters(dirnameparam, title="New Directory"):
         if dirnameparam.value[0] != os.sep:
             dirname = os.path.join(self.cwd(), dirnameparam.value)
         else:
             dirname = dirnameparam.value
         os.mkdir(dirname)  # raises exception if file exists
         self.dirHistory.push(dirname)
         self.switchDir(dirname)
Ejemplo n.º 5
0
 def named_copy(self, name, instance_params=[], secret=None):
     if secret is None:
         secret = self._secret
     # Don't clone the name parameter, since the new property has a new name.
     non_name_params = instance_params or self.params[1:]
     new_params = [parameter.StringParameter('name', name)] + \
                  [p.clone() for p in non_name_params]
     return NamedPropertyRegistration(self.parent, name, self.subclass,
                                      self.modulename, self.parent.ordering,
                                      new_params, secret)
Ejemplo n.º 6
0
def buildImageModMenu_Parallel():
    modmenu.clearMenu()
    for registration in imagemodifier.ImageModifier.registry:
        params = [parameter.StringParameter('image')] \
                 + registration.params
        menuitem = modmenu.addItem(
            oofmenu.OOFMenuItem(registration.name(),
                                callback=doImageMod_Parallel,
                                secret=1,
                                no_log=1,
                                threadable=oofmenu.PARALLEL_THREADABLE,
                                params=params))
        menuitem.data = registration
Ejemplo n.º 7
0
from ooflib.engine import skeletoncontext
try:
    from ooflib.SWIG.common import mpitools
except ImportError:
    pass

## General definitions
_rank = mpitools.Rank()
_size = mpitools.Size()

def _parallel_init(self, skeleton, _id = None):
    ## here, skeleton is the name of the skeleton
    if _rank == 0:
        id = parallel_object_manager.parallelObjectManager.add(self)
        deputymenu.Create(skeleton = skeleton, id = id) ## back-end call
    else:
        parallel_object_manager.parallelObjectManager.add(self, _id)
        
deputymenu = parallelmainmenu.ipcmenu.addItem(oofmenu.OOFMenuItem('Deputy', secret=1, no_log=1))


def _create_deputy(menuitem, skeleton, id):
    ## skeleton skeleton is the full name of the skeleton
    global _rank
    if _rank != 0:
        skel = skeletoncontext.skeletonContexts[skeleton].getObject()
        deputy = skel.deputyCopy() ## creates back-end deputy with the correct id
        parallel_object_manager.parallelObjectManager.add(deputy, id)

deputymenu.addItem(oofmenu.OOFMenuItem('Create', callback = _create_deputy, secret=1, no_log=1, threadable = oofmenu.PARALLEL_UNTHREADABLE, params=[parameter.StringParameter('skeleton'), parameter.IntParameter('id')] ))
Ejemplo n.º 8
0
    <para>
    Commands for setting parameters that don't belong anywhere else.
    </para>"""))

fontmenu = settingsmenu.addItem(OOFMenuItem(
    "Fonts",
    help="Set fonts used in the GUI."
    ))

def setFont(menuitem, fontname):
    switchboard.notify('change font', fontname)

fontmenu.addItem(OOFMenuItem(
    "Widgets",
    callback=setFont,
    params=[parameter.StringParameter('fontname', tip="The name of a font.")],
    help="Set the font to use for labels, menus, buttons, etc. in the graphical user interface.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/common/menu/widgetfont.xml')
    ))

def setFixedFont(menuitem, fontname):
    switchboard.notify('change fixed font', fontname)

fontmenu.addItem(OOFMenuItem(
    "Fixed",
    callback=setFixedFont,
    params=[parameter.StringParameter('fontname', tip='The name of a font.')],
    help="Set the fixed-width font to use in text displays.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/common/menu/textfont.xml')
    ))
Ejemplo n.º 9
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
Ejemplo n.º 10
0
&pixelgroup; will be added to a &nodegroup; with the same name as the
&pixelgroup;. New groups will be created if necessary.</para>"""
    )
auto.data = "nodegroups"
auto.iterator = skeleton.Skeleton.node_iterator
nodegroupmenu.addItem(auto)


rename = oofmenu.OOFMenuItem(
    "Rename_Group", cli_only=1,
    callback=_rename_group,
    params=parameter.ParameterGroup(
    whoville.WhoParameter("skeleton", whoville.getClass('Skeleton'),
                          tip=parameter.emptyTipString),
    NodeGroupParameter("group", tip="Name of the group to be renamed."),
    parameter.StringParameter("new_name", "",
                              tip="New name for the node group")),
    help="Rename a node group.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/menu/renamenodegroup.xml')
    )
rename.data = "nodegroups"
nodegroupmenu.addItem(rename)


copy = oofmenu.OOFMenuItem(
    "Copy_Group",
    cli_only=1,
    callback=_copy_group,
    params=parameter.ParameterGroup(
    whoville.WhoParameter("skeleton", whoville.getClass('Skeleton'),
                          tip=parameter.emptyTipString),
    NodeGroupParameter("group", tip="Name of the group to be copied."),
Ejemplo n.º 11
0
        return

    ms = ooflib.common.microstructure.Microstructure(
        name, primitives.iPoint(width_in_pixels, height_in_pixels),
        primitives.Point(width, height))


msmenu.addItem(
    oofmenu.OOFMenuItem(
        'New_Parallel',
        callback=newMicrostructure_Parallel,
        secret=1,
        no_log=1,
        threadable=oofmenu.PARALLEL_THREADABLE,
        params=[
            parameter.StringParameter('name'),
            parameter.FloatParameter('width',
                                     1.,
                                     tip='Width in physical units.'),
            parameter.FloatParameter('height',
                                     1.,
                                     tip='Height in physical units.'),
            parameter.IntParameter('width_in_pixels',
                                   10,
                                   tip='Width in pixels.'),
            parameter.IntParameter('height_in_pixels',
                                   10,
                                   tip='Height in pixels.')
        ]))

### OOF.LoadData.IPC.Microstructure.Initialize
Ejemplo n.º 12
0
    parameter.ListOfUnsignedShortsParameter('grayvalues', tip="Gray values.")],
    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()))
Ejemplo n.º 13
0

def getSeparator():
    return _separator_strings[separator_param.value]


settingsmenu.addItem(
    oofmenu.OOFMenuItem(
        'Separator',
        callback=_dummy,
        params=[separator_param],
        help="Set the character to appear between columns in output files."))

comment_char_param = parameter.StringParameter(
    "comment_character",
    "#",
    default="#",
    tip="The string used to mark comments in output files.")


def getCommentChar():
    return comment_char_param.value


settingsmenu.addItem(
    oofmenu.OOFMenuItem(
        'Comment_Character',
        callback=_dummy,
        params=[comment_char_param],
        help="Set the string used to mark comments in output files."))
Ejemplo n.º 14
0
        boundaryconditionIPC.ipcbcmenu.Rename(mesh=mesh, bc=bc, name=name)
    else:
        meshcontext = ooflib.engine.mesh.meshes[mesh]
        meshcontext.renameBdyCondition(bc, name)


bcmenu.addItem(
    oofmenu.OOFMenuItem(
        "Rename",
        callback=_bcrename,
        params=parameter.ParameterGroup(
            whoville.WhoParameter("mesh",
                                  ooflib.engine.mesh.meshes,
                                  tip=parameter.emptyTipString),
            BCNameParameter('bc', tip='Old name of the boundary condition'),
            parameter.StringParameter(
                'name', tip='New name of the boundary condition')),
        help="Give a boundary condition a new name.",
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/engine/menu/rename_bc.xml')))


# Remove a boundary condition from the given mesh.
def _bcremove(self, mesh, name):
    if parallel_enable.enabled():
        boundaryconditionIPC.ipcbcmenu.Delete(mesh=mesh, name=name)
    else:
        meshcontext = ooflib.engine.mesh.meshes[mesh]
        meshcontext.rmBdyConditionByName(name)
        switchboard.notify("mesh changed", ooflib.engine.mesh.meshes[mesh])

Ejemplo n.º 15
0
    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>"""))


def writeOrientationMap(datafile, mscontext):
Ejemplo n.º 16
0
#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#


class GroupColumnParameter(parameter.ListOfStringIntTuplesParameter):
    pass


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

orientmapdata.OrientMapRegistration(
    'Generic',
    GenericReader,
    ordering=0,
    params=[
        parameter.StringParameter(
            "comment_character",
            '#',
            tip="Skip input lines beginning with this character."),
        parameter.RegisteredParameter(
            "separator",
            formatchars.InputSeparator,
            formatchars.WhiteSpaceSeparator(),
            tip="How columns are divided in the input file."),
        parameter.PositiveIntParameter('angle_column',
                                       1,
                                       tip='First column of angle data.'),
        parameter.MetaRegisteredParameter(
            'angle_type',
            orientationmatrix.Orientation,
            orientationmatrix.Bunge,
            tip="The way in which orientations are specified in the input file."
        ),
Ejemplo n.º 17
0
    ))

def _renameCB(menuitem, microstructure, interface, name):
    msobj = ooflib.common.microstructure.microStructures[microstructure].getObject()
    interfacemsplugin=msobj.getPlugIn("Interfaces")
    interfacemsplugin.renameInterface(interface,name)

_interfacemenu.addItem(oofmenu.OOFMenuItem(
    "Rename",
    callback=_renameCB,
    help="Rename an interface.",
    params=[
    whoville.WhoParameter('microstructure',
                          ooflib.common.microstructure.microStructures,
                          tip=parameter.emptyTipString),
    parameter.StringParameter('interface', tip="Interface to be renamed."),
    parameter.StringParameter('name', tip="New name.")
    ],
    discussion="""<para>
    Give the interface definition another name.
    </para>"""
    ))

def _deleteCB(menuitem, microstructure, interface):
    msobj = ooflib.common.microstructure.microStructures[microstructure].getObject()
    interfacemsplugin=msobj.getPlugIn("Interfaces")
    interfacemsplugin.removeInterface(interface)

_interfacemenu.addItem(oofmenu.OOFMenuItem(
    "Delete",
    callback=_deleteCB,
Ejemplo n.º 18
0
            timedriver.apply(solver, subpcontext)
        except ooferror.ErrProcessAborted:
            pass
        ## solved flag is set even if solution did NOT
        ## converge in order to show how far the solution
        ## went.
        subpcontext.solved()

    finally:
        subpcontext.cancel_reservation()


## OOF.LoadData.IPC.Solver.Solve
ipcsolvermenu.addItem(
    oofmenu.OOFMenuItem(
        'Solve',
        callback=parallel_solve,
        threadable=oofmenu.PARALLEL_THREADABLE,
        params=[
            ##    whoville.WhoParameter('subproblem',
            ##                          ooflib.engine.subproblemcontext.subproblems,
            ##                          tip=parameter.emptyTipString),
            parameter.StringParameter('subproblem'),
            ##    whoville.WhoParameter('mesh',
            ##                          ooflib.engine.mesh.meshes,
            ##                          tip="Deprecated.  Use subproblem instead."),
            parameter.RegisteredParameter('solver',
                                          solverdriver.Driver,
                                          tip=parameter.emptyTipString)
        ]))
Ejemplo n.º 19
0
            parameter.AutomaticNameParameter(
                'name',
                resolver=namedanalysis.bdynameResolver,
                value=automatic.automatic,
                tip="The name of the analysis."), bdy_param, analyzer_param
        ],
        help="Assign a name to a set of boundary analysis parameters.",
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/engine/menu/newnamedbdyanal.xml')))

mainmenu.OOF.LoadData.addItem(
    oofmenu.OOFMenuItem(
        'NamedBdyAnalysis',
        callback=_nameAnalysis,
        params=[
            parameter.StringParameter('name', tip=parameter.emptyTipString),
            bdy_param, analyzer_param
        ],
        help="Create a named boundary analysis. Used internally in data files.",
        discussion="<para>Create a named boundary analysis.</para>"))


def _deleteAnalysis(menuitem, name):
    namedanalysis.getNamedBdyAnalysis(name).destroy()
    switchboard.notify("named boundary analyses changed")


bdyanalysismenu.addItem(
    oofmenu.OOFMenuItem(
        "Delete",
        callback=_deleteAnalysis,
Ejemplo n.º 20
0
    def __init__(self):
        self.materialmanager = None  # Set by materialmanager when it starts up.
        self.data = labeltree.LabelTree()

        # Need to own the references to the key objects, which are
        # only weakly referenced in LabelTree, and used to identify
        # menus.  This allows the menus to disappear automatically
        # when the PropertyManager is destroyed.  (Why bother?  The
        # PropertyManager isn't destroyed until the program quits.)
        self.parametrizekey = parametrizeKey
        self.loadkey = loadKey

        def paramcopy(object):
            # This routine is a callback function passed to
            # LabelTree.makeOOFMenu. makeOOFMenu uses it to get the
            # list of parameters for each menuitem that it creates.
            # The 'object' argument is the PropertyRegistration for
            # which the menu item is being built.

            # It's tempting to simply return the
            # PropertyRegistration's list of Parameters, so that the
            # registration and the menu item share Parameter objects,
            # and eliminating the need to copy values back and forth.
            # This temptation must be resisted.  If the Parameters are
            # shared, then loading a named Property from a data file
            # will change the settings of an already parametrized
            # unnamed Property.
            if object:
                return [p.clone() for p in object.getDefaultParams()]
            return []

        def kwarg_func(object):  # Extra kwargs for OOFMenuItem ctor.
            if object and object.secret():
                return {'secret': 1, 'no_doc': 1}
            return {}

        # Menu items are put into OOF.Property for scripts and
        # OOF.LoadData.Property for data files.  The menus are created
        # automatically by the LabelTree, which uses the given key to
        # distinguish them.
        OOF.Property.addItem(
            self.data.makeOOFMenu(
                # The name 'Parametrize' is also used in _parametrizeDiscussion.
                # Don't change it here without changing it there.
                name='Parametrize',
                key=self.parametrizekey,
                param_func=paramcopy,
                kwarg_func=kwarg_func,
                callback=self.parametrizercallback,
                help=xmlmenudump.DiscussionFunc(_parametrizeHelp),
                discussion=xmlmenudump.DiscussionFunc(_parametrizeDiscussion)))

        OOF.LoadData.addItem(
            self.data.makeOOFMenu(
                name='Property',
                key=self.loadkey,
                param_func=paramcopy,
                kwarg_func=kwarg_func,
                callback=self.creatorcallback,
                params=[
                    parameter.StringParameter('name', tip="Name of Property.")
                ],
                discussion=xmlmenudump.DiscussionFunc(_loadDiscussion),
                help=xmlmenudump.DiscussionFunc(_loadHelp)))
Ejemplo n.º 21
0
        filenameparam.WriteFileNameParameter(
            'filename',tip="Name of the report file."),
        parameter.BooleanParameter(
            'pythonlog', True), 
        parameter.BooleanParameter(
            'pythonlogandoutputs', True),
        parameter.BooleanParameter(
            'installationlog', True),
        parameter.ListOfStringsParameter(
            'inputfiles', tip="Names of input files"),
        parameter.ListOfStringsParameter(
            'outputfiles', tip="Names of output files"),
        parameter.ListOfStringsParameter(
            'deletedfiles',
            tip="Names of input/output files no longer on the system"),
        parameter.StringParameter('comments')],
    no_log=1,
    help ="Choose information to send as an error report"))   

def addInputFile(menuitem, reporter, filename):
    if filename is not None and filename not in infiles:
       filenamePath = os.path.basename(filename)
       infiles.append(filename)
       reporter.update()
    
errorreportermenu.addItem(oofmenu.OOFMenuItem(
    'Add_Input_File',
    callback=addInputFile,
    params=[filenameparam.FileOrDirectoryParameter(
        'filename', ident="add", tip="Name of the input file or directory.")],
    ellipsis=1,
Ejemplo n.º 22
0
    </para>"""))


# Rename an existing material.
def _renamematerial(menuitem, material, name):
    if parallel_enable.enabled():
        materialmenuIPC.ipcmaterialmenu.Rename(material=material, name=name)
    else:
        matmanager.rename(material, name)


_materialmenu.addItem(
    OOFMenuItem('Rename',
                callback=_renamematerial,
                params=[
                    parameter.StringParameter('material',
                                              tip='Old name of the material.'),
                    parameter.AutomaticNameParameter(
                        'name',
                        resolver=materialNameResolver,
                        value=automatic.automatic,
                        tip='New name for the material.')
                ],
                help='Rename a Material.',
                discussion="""<para>
    Rename the indicated &material;.  It will remain present in any
    &micros; in which it occurs, but will get a new name.
    </para>"""))


# Delete the named material.
def _deletematerial(menuitem, name):
Ejemplo n.º 23
0
    newimagecontext = oofimage.imageContexts.add([msname, immidge.name()],
                                                 immidge,
                                                 parent=ooflib.common.microstructure.microStructures[msname])
    ms.addImage(newimagecontext)

imenu.addItem(oofmenu.OOFMenuItem(
    'Create_From_Image_Parallel',
    callback = createMSFromImage_Parallel,
    secret = 1,
    no_log = 1,
    threadable = oofmenu.PARALLEL_THREADABLE,
    params = parameter.ParameterGroup(
    parameter.AutomaticNameParameter('msname', imagemenu.msImageNameResolver,
                                     automatic.automatic,
                                     tip="Name of the new Microstructure."),
    parameter.StringParameter('image'))
    ))

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

def createImage(msname, imagename, origin=0):
    if _rank == origin:
        image = oofimage.getImage([msname, imagename])
        destinations = range(1,_size)
        oofimage.Send_Image(image, destinations)
    else:
        image = oofimage.Recv_Image(origin)
    return image

def createMSFromImageFile_Parallel(menuitem, msname, imagename):
    # Create image for the rear-end processes.
Ejemplo n.º 24
0
settingsmenu = menu.addItem(OOFMenuItem('Settings'))


# In these menu items, "window" is a string with the name
# of the window in it -- this name is exposed in the UI.
def newLayerSetCB(menuitem, window):
    openLayerEditor()
    layerEditor.newLayerSetCB(window)


layermenu.addItem(
    OOFMenuItem(
        'New',
        callback=newLayerSetCB,
        params=[parameter.StringParameter('window', tip="Which window.")],
        help="Create a new layer set.",
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/common/menu/newlayerset.xml')))


def loadLayerCB(menuitem, window, layer_number):
    openLayerEditor()
    layerEditor.loadLayerCB(window, layer_number)


layermenu.addItem(
    OOFMenuItem('Edit',
                callback=loadLayerCB,
                params=[
                    parameter.StringParameter('window', tip="Which window."),
Ejemplo n.º 25
0
# Subclasses have to have two data members.  "tag" is a string that
# appears in the Status box on the Solver page.  "solvable" is a bool
# that says whether or not the mesh can be solved in its current
# state.  It's used to sensitize the "Solve" button on the Solver
# page.

class Unsolved(MeshStatus):
    tag = "Unsolved"
    solvable = True

registeredclass.Registration(
    "Unsolved",
    MeshStatus,
    Unsolved,
    params=[parameter.StringParameter("details")],
    ordering=0,
    tip=parameter.emptyTipString)

class Unsolvable(MeshStatus):
    tag = "Unsolvable"
    solvable = False

registeredclass.Registration(
    "Unsolvable",
    MeshStatus,
    Unsolvable,
    params=[parameter.StringParameter("details")],
    ordering=1,
    tip=parameter.emptyTipString)
Ejemplo n.º 26
0
    meshctxt = ooflib.engine.mesh.meshes.add(
        labeltree.makePath(skeleton) + [name],
        femesh,
        parent=skeletoncontext.skeletonContexts[skeleton],
        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:
Ejemplo n.º 27
0
tutorial.start_tutorial = start_class


# Resume a tutorial from a saved script.
def resume_tutorial(menuitem, subject, progress):
    tutor = tutorial.allTutorials[subject]
    mainthread.runBlock(start_class, (tutor, progress))


mainmenu.OOF.Help.Tutorials.addItem(
    oofmenu.OOFMenuItem(
        'Resume',
        callback=resume_tutorial,
        secret=1,
        params=[
            parameter.StringParameter('subject'),
            parameter.IntParameter('progress')
        ],
        help=
        "Resume a tutorial.  This command is only used when tutorials are saved."
    ))


def raise_tutorial(menuitem):
    debug.mainthreadTest()
    tutorialInProgress.raise_window()


mainmenu.OOF.Windows.addItem(
    oofmenu.OOFMenuItem('Tutorial',
                        help="Raise the tutorial window.",
Ejemplo n.º 28
0
    sys.stdout.flush()
    try:
        oldms = ooflib.common.microstructure.microStructures[name]
    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."),
            primitives.iPointParameter(
                'isize', tip="Pixel resolution of Microstructure."),
            primitives.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):
Ejemplo n.º 29
0

def _renameCB(menuitem, skeleton, boundary, name):
    skelctxt = skeletoncontext.skeletonContexts[skeleton]
    skelctxt.renameBoundary(boundary, name)


boundarymenu.addItem(
    oofmenu.OOFMenuItem("Rename",
                        callback=_renameCB,
                        help="Rename a Skeleton boundary.",
                        params=[
                            boundarybuilder.skeletonparam,
                            skeletongroupparams.SkeletonBoundaryParameter(
                                'boundary', tip="Boundary to be renamed."),
                            parameter.StringParameter('name', tip="New name.")
                        ],
                        discussion=xmlmenudump.loadFile(
                            'DISCUSSIONS/engine/menu/boundary_rename.xml')))

### Boundary construction, very important...


def _constructCB(menuitem, skeleton, name, constructor):
    skelctxt = skeletoncontext.skeletonContexts[skeleton]
    constructor(skelctxt, name)


#Uniqueness of boundary names is built into boundarybuilder.nameparam
boundarymenu.addItem(
    oofmenu.OOFMenuItem(
Ejemplo n.º 30
0
    if parallel_enable.enabled():
        from ooflib.engine.IO import propertymenuIPC
        propertymenuIPC.ipcpropmenu.Copy(property=property, new_name=new_name)
    else:
        try:
            AllProperties.new_prop(property, new_name)
        except ooferror.ErrUserError, e:
            print e


OOF.Property.addItem(
    oofmenu.OOFMenuItem(
        'Copy',
        callback=_copywrapper,
        params=parameter.ParameterGroup(
            parameter.StringParameter('property',
                                      tip="Name of the source Property."),
            parameter.RestrictedAutomaticNameParameter(
                'new_name',
                exclude=':',
                resolver=propertyNameResolver,
                value=automatic.automatic,
                tip="Name for the new Property.")),
        help="Copy a Property.",
        discussion="""<para>

    Make a copy of an existing &property;, with the same parameters.
    The source &property; can be a named &property; or one of the
    predefined unnamed &properties;.

    </para>"""))