예제 #1
0
파일: movenode.py 프로젝트: song2001/OOF2
 def makeMenu(self, menu):
     self.menu = menu
     menu.addItem(oofmenu.OOFMenuItem(
         'MoveNode',
         threadable=oofmenu.THREADABLE,
         callback = self.moveNode,
         params=[primitives.PointParameter('origin',
                                           tip=parameter.emptyTipString),
                 primitives.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=[primitives.PointParameter('position',
                                           tip=parameter.emptyTipString)],
         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')
         ))
예제 #2
0
def DirectSampleSetRegistration(name,
                                subclass,
                                ordering,
                                params=[],
                                secret=0,
                                tip=None,
                                discussion=None,
                                **kwargs):
    class NonDirectSubclass(subclass):
        def get_col_names(self):
            return []

    NonDirectSubclass.__name__ = "Stat" + subclass.__name__

    non_direct_params = params[:]

    ## TODO: Do we still need the Stat sample sets?

    registeredclass.Registration(name,
                                 SampleSet,
                                 NonDirectSubclass,
                                 ordering,
                                 params=non_direct_params,
                                 secret=secret,
                                 tip=tip,
                                 direct=False,
                                 discussion="""<para>
        <classname>%(statname)s</classname> is a version of <xref
        linkend='RegisteredClass-%(name)s'/> that is used when the
        <link linkend='MenuItem-OOF.Mesh.Analyze'>analysis
        operation</link> is one of the statistics functions.  It is
        identical, except that it does not have the
        <varname>show_*</varname> parameters, which would be
        meaningless in this context.
        </para>""" % {
                                     'name': subclass.__name__,
                                     'statname': NonDirectSubclass.__name__
                                 },
                                 **kwargs)

    # Now pile on the extra parameters.
    for c_name in subclass.containedClass.columnNames:
        params.append(
            parameter.BooleanParameter(
                _attr_from_colname(c_name),
                1,
                default=1,
                tip="Include or exclude this data from the output."))

    return registeredclass.Registration(name,
                                        SampleSet,
                                        subclass,
                                        ordering,
                                        params,
                                        secret,
                                        tip,
                                        discussion,
                                        direct=True,
                                        **kwargs)
예제 #3
0
def DiscreteSampleSetRegistration(name,
                                  subclass,
                                  ordering,
                                  params=[],
                                  secret=False,
                                  tip=None,
                                  discussion=None,
                                  **kwargs):
    # Create a trivial subclass that doesn't have Parameters or data
    # columns for the Sample-identifying data, for use in the
    # "non-direct" DataOperations that combine multiple samples.
    class NonDirectSubclass(subclass):
        def get_col_names(self):
            return []

    NonDirectSubclass.__name__ = "Stat" + subclass.__name__
    non_direct_params = params[:]
    SampleSetRegistration(name,
                          subclass=NonDirectSubclass,
                          ordering=ordering,
                          params=non_direct_params,
                          secret=secret,
                          tip=tip,
                          direct=False,
                          discussion="""<para>
        <classname>%(statname)s</classname> is a version of <xref
        linkend='RegisteredClass-%(name)s'/> that is used when the
        <link linkend='MenuItem-OOF.Mesh.Analyze'>analysis
        operation</link> is one of the statistics functions.  It is
        identical, except that it does not have the
        <varname>show_*</varname> parameters, which would be
        meaningless in this context.
        </para>""" % {
                              'name': subclass.__name__,
                              'statname': NonDirectSubclass.__name__
                          },
                          **kwargs)

    for colname in subclass.columnNames:
        params.append(
            parameter.BooleanParameter(
                _attr_from_colname(colname),
                True,
                default=True,
                tip="Include or exclude this data from the output."))
    SampleSetRegistration(name,
                          subclass,
                          ordering,
                          params=params,
                          secret=secret,
                          direct=True,
                          tip=tip,
                          discussion=discussion,
                          **kwargs)
예제 #4
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')))
예제 #5
0
    class ContrastImage(ImageModifier):
        def __init__(self, sharpen):
            self.sharpen = sharpen

        def __call__(self, image):
            image.contrast(self.sharpen)

    registeredclass.Registration(
        'Contrast',
        ImageModifier,
        ContrastImage,
        ordering=2.02,
        params=[
            parameter.BooleanParameter('sharpen',
                                       1,
                                       tip='false to dull, true to sharpen')
        ],
        tip="Enhance intensity differences.",
        discussion=xmlmenudump.loadFile('DISCUSSIONS/image/reg/contrast.xml'))

elif config.dimension() == 3:

    class ContrastImage(ImageModifier):
        def __init__(self, factor):
            self.factor = factor

        def __call__(self, image):
            image.contrast(self.factor)

    registeredclass.Registration(
예제 #6
0
    "Redo",
    callback=_redo,
    params=[WhoParameter('skeleton',
                         skeletoncontext.skeletonContexts,
                         tip=parameter.emptyTipString)],
    help="Redo a Skeleton modification.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/menu/skeleton_redo.xml')
    ))

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

# AutoSkeleton creation

if config.dimension() == 2:
    periodicityParams = parameter.ParameterGroup(
        parameter.BooleanParameter('left_right_periodicity', value=False,
            tip="Whether or not the skeleton is periodic in the horizontal direction"),
        parameter.BooleanParameter("top_bottom_periodicity", value=False,
            tip="Whether or not the skeleton is periodic in the vertical direction"))
if config.dimension() == 3:
    periodicityParams = parameter.ParameterGroup(
        parameter.BooleanParameter('left_right_periodicity', value=False,
            tip="Whether or not the skeleton is periodic in the horizontal direction"),
        parameter.BooleanParameter("top_bottom_periodicity", value=False,
            tip="Whether or not the skeleton is periodic in the vertical direction"),
        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,
예제 #7
0
            allnodes = self.getAllNodes(skeleton)
            selected = self.getInternalNodes(skeleton, allnodes)
        else:
            selected = []
        selection.start()
        selection.clear()
        selection.select(selected)


registeredclass.Registration(
    'Select from Selected Elements',
    NodeSelectionModifier,
    NodeFromSelectedElements,
    ordering=1,
    params=[
        parameter.BooleanParameter('internal', 0,
                                   tip='Select interior nodes?'),
        parameter.BooleanParameter('boundary', 1, tip='Select exterior nodes?')
    ],
    tip="Select nodes from selected elements.",
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/engine/menu/nodes_from_elements.xml'))

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


class SelectInternalBoundaryNodes(NodeSelectionModifier):
    def __init__(self, ignorePBC=False):
        self.ignorePBC = ignorePBC

    def __call__(self, skeleton, selection):
        skel = skeleton.getObject()
예제 #8
0
                           AngleUnits,
                           'Radians',
                           tip="The units used for angles in the input file."),
        parameter.FloatParameter(
            'angle_offset',
            0,
            tip="An xy-plane rotation to apply to all input orientations,"
            " in degrees.  In the Abg format, the angle is added to gamma."
            " In Bunge, it's subtracted from phi1."),
        parameter.PositiveIntParameter('xy_column',
                                       4,
                                       tip='First column of position data.'),
        parameter.FloatParameter(
            'scale_factor',
            1.0,
            tip="All x and y values will be multiplied by this factor."),
        parameter.BooleanParameter('flip_x',
                                   False,
                                   tip='Flip data in the x direction.'),
        parameter.BooleanParameter('flip_y',
                                   True,
                                   tip='Flip data in the y direction.'),
        GroupColumnParameter(
            "groups", [],
            tip="Templates for creating pixel groups from column data. "
            "Pixels with different values in the column will be put into "
            "different pixel groups.  A '%s' in the groupname will be "
            "replaced by the contents of the column.")
    ],
    tip="Generic EBSD data reader.")
예제 #9
0
    for n in notifications:
        switchboard.notify(*n)


ipcmeshmenu.addItem(
    oofmenu.OOFMenuItem(
        'Copy',
        callback=copyMesh_parallel,
        threadable=oofmenu.PARALLEL_THREADABLE,
        params=parameter.ParameterGroup(
            whoville.WhoParameter('mesh',
                                  ooflib.engine.mesh.meshes,
                                  tip=parameter.emptyTipString),
            parameter.StringParameter('name'),
            parameter.BooleanParameter('copy_field',
                                       value=1,
                                       tip='Copy fields?'),
            parameter.BooleanParameter('copy_equation',
                                       value=1,
                                       tip='Copy equation?'),
            parameter.BooleanParameter('copy_bc',
                                       value=1,
                                       tip='Copy boundary conditions?'))))

########################################################################
# Field (Define/Undefine, Activate/Deactivate, In_Plane/Out_of_Plane)
########################################################################

## OOF.LoadData.IPC.Field
ipcfieldmenu = parallelmainmenu.ipcmenu.addItem(
    oofmenu.OOFMenuItem('Field', secret=1, no_log=1))
예제 #10
0
    else:
        dblevel = 0
    global _recording
    _recording = True
    gtklogger.start(filename, debugLevel=dblevel, logger_comments=use_gui)


guidebugmenu.addItem(
    oofmenu.OOFMenuItem(
        'Record',
        callback=startLog,
        params=[
            filenameparam.WriteFileNameParameter('filename',
                                                 ident='guilog',
                                                 tip="Name of the file."),
            parameter.BooleanParameter(
                'use_gui', True, tip="Use the logger gui to insert comments?")
        ],
        ellipsis=1,
        help="Save GUI events in a Python script",
    ))

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


def stopLog(menuitem):
    debug.mainthreadTest()
    global _recording
    _recording = False
    menuitem.root().removeOption('post_hook')
    gtklogger.stop()
예제 #11
0
         "Pixels within this many standard deviations of a group's mean"
         " will be added to the group."),
     parameter.FloatParameter(
         'gamma',
         value=2.0,
         tip="Groups within this many standard deviations of each other's"
         " means will be merged."),
     parameter.IntParameter(
         'minsize',
         value=0,
         tip="Don't create groups or isolated parts of groups with fewer"
         " than this many pixels.  Instead, assign pixels to the nearest"
         " large group.  Set minsize=0 to skip this step."),
     parameter.BooleanParameter(
         'contiguous',
         value=True,
         tip="Create only contiguous groups.  Similar pixels that aren't"
         " connected to one another will be put into separate groups."),
     parameter.StringParameter("name_template",
                               value="group_%n",
                               tip="Name for the new pixel groups."
                               " '%n' will be replaced by an integer."),
     parameter.BooleanParameter(
         "clear",
         value=True,
         tip="Clear pre-existing groups before adding pixels to them."
         " This will NOT clear groups to which no pixels are being added."
     )
 ],
 help=
 "Put all pixels into pixel groups, sorted by color or orientation.",
예제 #12
0
        # time stamp update
        meshcontext.changed("Copied.")


# Trivial parameter for skeletons of the mesh -- it will have a custom
# chooser widget.
class MeshSkeletonParameter(parameter.StringParameter):
    pass


registeredclass.Registration(
    'Revert Mesh',
    meshmod.MeshModification,
    RevertMesh,
    ordering=3,
    params=[
        MeshSkeletonParameter('base_skeleton',
                              tip="Name of the base Skeleton."),
        parameter.BooleanParameter('init_field',
                                   1,
                                   default=1,
                                   tip="Initialize fields?")
    ],
    tip="Undo adaptive mesh refinement.",
    discussion="""<para>
    Refined &mesh; can be reverted back to its pre-refined stages, in case
    the refinement was not satisfactory. Field values (solution) may not be
    recovered properly in some cases.
    </para>""")
예제 #13
0
                        if segment.active(skeleton):
                            self.markSegment(segment, divisions, markedEdges)
                if prog.stopped():
                    return
                prog.setFraction(1.0 * (i + 1) / n)
                prog.setMessage("checked %d/%d elements" % (i + 1, n))

    registeredclass.Registration(
        'Aspect Ratio',
        RefinementTarget,
        CheckAspectRatio,
        ordering=2.5,
        params=[
            parameter.FloatParameter(
                'threshold',
                value=5.0,
                tip=
                "Refine the long edges of elements whose aspect ratio is greater than this"
            ),
            parameter.BooleanParameter(
                'only_quads',
                value=True,
                tip="Restrict the refinement to quadrilaterals?")
        ],
        tip="Divide elements with extreme aspect ratios.",
        ## TODO: explain only_quads in the manual!
        discussion=xmlmenudump.loadFile(
            'DISCUSSIONS/engine/reg/check_aspect.xml'))

    ##################################################
예제 #14
0
def _checkSymmetryC(menuitem, subproblem, material, symmetric):
    _checkSymmetry(subproblem, material,
                   lambda sub, mat: mat.is_symmetric_C(sub), symmetric)


def _checkSymmetryM(menuitem, subproblem, material, symmetric):
    _checkSymmetry(subproblem, material,
                   lambda sub, mat: mat.is_symmetric_M(sub), symmetric)


_symTestParams = [
    whoville.WhoParameter('subproblem',
                          ooflib.engine.subproblemcontext.subproblems),
    parameter.StringParameter('material'),
    parameter.BooleanParameter('symmetric')
]

_symmetryTestMenu.addItem(
    oofmenu.OOFMenuItem('K',
                        callback=_checkSymmetryK,
                        params=_symTestParams,
                        help="Check K matrix symmetry.",
                        secret=True,
                        no_doc=True))

_symmetryTestMenu.addItem(
    oofmenu.OOFMenuItem('C',
                        callback=_checkSymmetryC,
                        params=_symTestParams,
                        help="Check K matrix symmetry.",
예제 #15
0
    def _newSkelPeriodic(menuitem,
                         name,
                         microstructure,
                         left_right_periodicity=False,
                         top_bottom_periodicity=False):
        skeleton.newEmptySkeleton(name, microstructure, left_right_periodicity,
                                  top_bottom_periodicity)

    periodicparams = [
        parameter.StringParameter('name', tip="Name for the Skeleton."),
        whoville.WhoParameter('microstructure',
                              ooflib.common.microstructure.microStructures,
                              tip=parameter.emptyTipString),
        parameter.BooleanParameter(
            'left_right_periodicity',
            tip="Whether the skeleton is periodic in the horizontal direction"
        ),
        parameter.BooleanParameter(
            'top_bottom_periodicity',
            tip="Whether the skeleton is periodic in the vertical direction")
    ]

elif config.dimension() == 3:

    def _newSkelPeriodic(menuitem,
                         name,
                         microstructure,
                         left_right_periodicity=False,
                         top_bottom_periodicity=False,
                         front_back_periodicity=False):
        skeleton.newEmptySkeleton(name, microstructure, left_right_periodicity,
예제 #16
0
                            WhoParameter('skeleton',
                                         skeletoncontext.skeletonContexts,
                                         tip=parameter.emptyTipString)
                        ],
                        help="Redo a Skeleton modification.",
                        discussion=xmlmenudump.loadFile(
                            'DISCUSSIONS/engine/menu/skeleton_redo.xml')))

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

# AutoSkeleton creation

if config.dimension() == 2:
    periodicityParams = parameter.ParameterGroup(
        parameter.BooleanParameter(
            'x_periodicity',
            value=False,
            tip="Whether or not the skeleton is periodic in the x direction"),
        parameter.BooleanParameter(
            "y_periodicity",
            value=False,
            tip="Whether or not the skeleton is periodic in the y direction"))
if config.dimension() == 3:
    ## TODO 3.1: 3D autoskeleton is probably completely untested.  The
    ## periodicity args are certainly irrelevant because 3D periodic
    ## skeletons aren't supported yet.
    periodicityParams = parameter.ParameterGroup(
        parameter.BooleanParameter(
            'x_periodicity',
            value=False,
            tip="Whether or not the skeleton is periodic in the x direction"),
        parameter.BooleanParameter(
예제 #17
0
            'DISCUSSIONS/engine/menu/rewalldests.xml')
    ))

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

def _enableOutput(menuitem, mesh, output, enable):
    meshctxt = ooflib.engine.mesh.meshes[mesh]
    meshctxt.begin_writing()
    try:
        meshctxt.outputSchedule.getByName(output).activate(enable)
    finally:
        meshctxt.end_writing()
    switchboard.notify("scheduled outputs changed", meshctxt)

outputmenu.addItem(oofmenu.OOFMenuItem(
    'Enable',
    callback=_enableOutput,
    params=[
        whoville.WhoParameter(
                'mesh', ooflib.engine.mesh.meshes,
                tip=parameter.emptyTipString),
        scheduledoutput.ScheduledOutputParameter(
                'output', tip='Name of the output.'),
        parameter.BooleanParameter(
                'enable', value=True, default=True,
                tip='True if output is enabled, false otherwise.')],
    help="Enable or disable a scheduled output operation.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/menu/enableout.xml')
    ))

예제 #18
0
# own file to avoid import loops.


from ooflib.common import debug
from ooflib.common.IO import mainmenu
from ooflib.common.IO import oofmenu
from ooflib.common.IO import parameter
from ooflib.common.IO import filenameparam
from ooflib.common.IO import reporter

def saveMessages(menuitem, filename, mode, **messagetypes):
    file = open(filename, mode.string())
    for message in reporter.messagemanager.all_messages():
        if messagetypes[message[1]]:
            print >> file, message[0]
    file.close()

mainmenu.OOF.File.Save.addItem(oofmenu.OOFMenuItem(
    "Messages",
    help="Save the message logs from the message windows to a file.",
    callback=saveMessages,
    ordering=20,
    params=[filenameparam.WriteFileNameParameter('filename',
                                                 tip="Name of the file."),
            filenameparam.WriteModeParameter('mode',
                                             tip="'w' to (over)write and 'a' to append")] +
    [parameter.BooleanParameter(name, True,
                                tip="True to include and False to not.")
     for name in reporter.messageclasses],
    discussion="Unlike other <link linkend='MenuItem:OOF.File.Save'>OOF.File.Save</link> menu varieties, messages are saved only in an <emphasis>ascii</emphasis> format for an obvious reason."))
예제 #19
0
    if newness:
        switchboard.notify("new pixel group", grp)


micromenu.addItem(
    oofmenu.OOFMenuItem(
        'PixelGroup',
        callback=_newpixelgroup,
        params=[
            whoville.WhoParameter('microstructure',
                                  ooflib.common.microstructure.microStructures,
                                  tip=parameter.emptyTipString),
            parameter.StringParameter('group', tip="Name of the pixel group."),
            parameter.BooleanParameter(
                'meshable',
                tip="1 (true) for meshable or 0 (false) for non-meshable.")
        ],
        help="Create a pixel group. Used internally in data files.",
        discussion="""<para>Create <link
    linkend='Section:Concepts:Microstructure:Pixel_Group'>pixel
    groups</link> in a &micro; <link
    linkend='MenuItem:OOF.LoadData.Microstructure'>data
    file</link>.  This command is only used in data files.</para>"""))

##########

## TODO OPT: The category map should be passed directly in to C++
## once.  Then different pixel attributes (such as ActiveArea) could
## use it in C++ and wouldn't have to pass in lists of pixels (as
## ActiveArea.add_pixels() does).
예제 #20
0
        return internal

    def __call__(self, skeleton):
        skelcontext = skeletoncontext.skeletonContexts[skeleton]
        pinnednodes = skelcontext.pinnednodes
        if self.internal and self.boundary:
            nodes = self.getAllNodes(skelcontext)
        elif not self.internal and self.boundary:
            nodes = self.getBoundaryNodes(skelcontext)
        elif self.internal and not self.boundary:
            allnodes = self.getAllNodes(skelcontext)
            nodes = self.getInternalNodes(skelcontext, allnodes)
        else:
            nodes = []
        pinnednodes.start()
        pinnednodes.pin(nodes)
        pinnednodes.signal()

registeredclass.Registration(
    'Pin Selected Elements',
    PinNodesModifier,
    PinSelectedElements,
    ordering=5,
    params=[parameter.BooleanParameter('internal', 0,
                                       tip='Select internal nodes.'),
            parameter.BooleanParameter('boundary', 1,
                                       tip='Select boundary nodes.')],
    tip="Pin nodes of selected elements.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/engine/reg/pinelements.xml')
    )
예제 #21
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
예제 #22
0
    def _newSkelPeriodic(menuitem,
                         name,
                         microstructure,
                         left_right_periodicity=False,
                         top_bottom_periodicity=False):
        cskeleton2.newEmptySkeleton(name, microstructure,
                                    left_right_periodicity,
                                    top_bottom_periodicity)

    periodicparams = [
        parameter.StringParameter('name', tip="Name for the Skeleton."),
        whoville.WhoParameter('microstructure',
                              ooflib.common.microstructure.microStructures,
                              tip=parameter.emptyTipString),
        parameter.BooleanParameter(
            'left_right_periodicity',
            tip="Whether the skeleton is periodic in the horizontal direction"
        ),
        parameter.BooleanParameter(
            'top_bottom_periodicity',
            tip="Whether the skeleton is periodic in the vertical direction")
    ]

elif config.dimension() == 3:

    def _newSkelPeriodic(menuitem,
                         name,
                         microstructure,
                         x_periodicity=False,
                         y_periodicity=False,
                         z_periodicity=False):
        cskeleton2.newEmptySkeleton(name, microstructure, x_periodicity,
예제 #23
0
    shutil.rmtree(temp_directory) #removes the temporary directory
    
    reporterGUI.window.destroy()

# end openReportError
    
def newReportError():
    return ReportError

errorreportermenu = mainmenu.OOF.Help.addItem(oofmenu.OOFMenuItem(
    'Report_Error',
    callback= openReportError,
    params=[
        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"))   
예제 #24
0
    def rebuildMenus(self):
        # Put all the selection methods in the menu.
        if self.menu is not None:
            self.menu.clearSubMenu()
            sourceparams = self.sourceParams()
            self.menu.addItem(oofmenu.OOFMenuItem(
                'Clear',
                params=sourceparams,
                callback=self.clearCB,
                help="Clear the selection.",
                discussion="""<para>
                Unselect all %(object)ss in a %(source)s.  The
                <varname>%(param)s</varname> parameter is the
                %(source)s in which the %(object)ss are to be
                deselected.
                </para>""" % {'object':self.objName(),
                              'source':self.sourceName(),
                              'param':self.sourceParamName()}
                ))
            self.menu.addItem(oofmenu.OOFMenuItem(
                'Undo',
                params=sourceparams,
                callback=self.undoCB,
                help="Undo the selection.",
                discussion="""<para>
                Undo the previous %(object)s selection in the
                %(source)s named by the <varname>%(param)s</varname>
                parameter.  Previous selections are stored on a stack,
                and the <command>Undo</command> pops off the top of
                the stack.  The popped selection is not lost, however.
                It can be recovered with the <link
                linkend='MenuItem-%(parent)s.Redo'><command>Redo</command></link>
                command.

                </para><para>
                The stack has a finite size.  Once it is full, old
                selections will be lost when new selections are made.
                </para>""" % {'object':self.objName(),
                              'source':self.sourceName(),
                              'param':self.sourceParamName(),
                              'parent':self.menu.path()}
                ))
            self.menu.addItem(oofmenu.OOFMenuItem(
                'Redo',
                params=sourceparams,
                callback=self.redoCB,
                help="Redo the latest undone selection.",
                discussion="""<para>
                Redo the previously undone %(object)s selection in the
                %(source)s named in the <varname>%(param)s</varname>
                parameter.  Selections are stored on a stack, and the
                <link
                linkend='MenuItem-%(parent)s.Undo'><command>Undo</command></link>
                pops a selection off the stack.  The
                <command>Redo</command> places a selection back onto
                the stack.
                </para>
                <para>
                It's only possible to <command>Redo</command> a
                selection if no other %(object)ss have been selected
                since the last <link
                linkend='MenuItem-%(parent)s.Undo'><command>Undo</command></link>.
                </para>""" % {'object':self.objName(),
                              'source':self.sourceName(),
                              'param':self.sourceParamName(),
                              'parent':self.menu.path()}
                ))
            self.menu.addItem(oofmenu.OOFMenuItem(
                'Invert',
                params=sourceparams,
                callback=self.invertCB,
                help="Invert the selection.",
                discussion="""<para>
                Invert the current %(object)s selection in the
                %(source)s named by the <varname>%(param)s</varname>
                parameter.  All of the currently selected %(object)ss
                will be unselected and all of the currently unselected
                ones will be selected.
                </para>""" % {'object':self.objName(),
                              'source':self.sourceName(),
                              'param':self.sourceParamName()}
                ))
            for registration in self.method.registry:
                try:
                    help=registration.tip
                except AttributeError:
                    help = None
                params = sourceparams + registration.params + [
                    primitives.ListOfPointsParameter('points',
                                                     tip=parameter.emptyTipString),
                    parameter.BooleanParameter('shift', 0,
                                               tip="True for addition."),
                    parameter.BooleanParameter('ctrl', 0,
                                               tip="True for toggle.")
                    ]
                menuitem = self.menu.addItem(
                    oofmenu.OOFMenuItem(registration.name(),
                                        callback=self.selectCB,
                                        threadable=oofmenu.THREADABLE,
                                        params=params,
                                        help=help,
                                        discussion=registration.discussion))
                menuitem.data = registration
예제 #25
0
    color.ColorParameter(
        'face_color', 
        defaultVoxelRegionSelectionFaceColor,
        tip="Color of the faces of the box."),                   
    parameter.FloatRangeParameter(
        'face_opacity', 
        opacityRange,                                                 
        defaultVoxelRegionSelectionFaceOpacity,
        tip="Opacity of the faces of the box.  Probably best left at 1.0."),
    parameter.FloatRangeParameter(
        'other_opacity',
        opacityRange,
        defaultVoxelRegionSelectionOtherOpacity,
        tip="Opacity of other objects while editing the box."),
    parameter.BooleanParameter(
        'hide_inactive', defaultHideInactive,
        tip='Hide the widget when the toolbox is inactive.'),
    parameter.FloatRangeParameter(
        'dim_inactive', opacityRange, defaultDimInactive,
        tip='Factor by which to decrease the opacity of an inactive widget')

]

mainmenu.gfxdefaultsmenu.Voxel_Selection.addItem(oofmenu.OOFMenuItem(
    "Voxel_Region_Selection",
    callback=_setDefaultVoxelRegionSelectionParams,
    ordering=1,
    params=voxelregionselectionparams,
    help="Set default parameters for voxel region selection tools.",
    discussion="""<para>
예제 #26
0
파일: tsl.py 프로젝트: song2001/OOF2
                        ' '.join(substrings[10:])))  # phase name
            count += 1  # count actual file lines, comments and all
            prog.setMessage("read %d/%d lines" % (count, nlines))
            prog.setFraction(float(count) / nlines)
        npts = len(data)
        debug.fmsg("read %d lines, %d data points" % (count, npts))
        return data, None  # None ==> hexgrid not detected yet


orientmapdata.OrientMapRegistration(
    'TSL',
    TSLreader,
    ordering=2,
    params=[
        parameter.BooleanParameter('flip_x',
                                   False,
                                   tip='Flip data, swapping x and -x.'),
        parameter.BooleanParameter('flip_y',
                                   True,
                                   tip='Flip data, swapping y and -y.'),
        parameter.FloatParameter(
            'angle_offset',
            0,
            tip='Subtract this angle (in degrees) from phi1.')
    ],
    tip="TSL .ang file (old format)")

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


class TSLreader2(TSLreaderBase):
예제 #27
0
    ordering=1.11,
    params=[
        parameter.FloatRangeParameter(
            'local_flammability',
            range=(0, 180., 0.1),
            value=10,
            tip=
            "Maximum misorientation angle, in degrees, between neighboring pixels, across which a burn will extend."
        ),
        parameter.FloatRangeParameter(
            'global_flammability',
            range=(0, 180., 0.1),
            value=10,
            tip=
            "Misorientation, in degrees measured from initial point, beyond which a burn will not spread."
        ),
        latticesystem.LatticeSymmetryParameter(
            'lattice_symmetry',
            tip=
            "Assume that the material at each point has this symmetry, making some orientations equivalent."
        ),
        parameter.BooleanParameter('next_nearest',
                                   value=False,
                                   tip="Burn next-nearest neighbors?")
    ],
    whoclasses=['Microstructure', 'Image'],
    events=['up'],
    tip=
    'Select a contiguous set of similarly oriented pixels, using a forest fire algorithm on an orientation map.'
)
예제 #28
0
        self.two = two
        self.operator = operator

    def select(self, skelctxt, selection):
        clist, plist = selection.trackerlist()
        courier = skeletonselectioncourier.SegmentsFromNodesCourier(
            skelctxt.getObject(), self.one, self.two,
            skelctxt.nodeselection.currentSelectionTracker(), clist, plist)
        self.operator.operate(selection, courier)


SegmentSelectionModRegistration(
    "From Selected Nodes",
    SegFromSelectedNodes,
    params=[
        parameter.BooleanParameter(
            'one', value=True, tip='Select segments with one selected node.'),
        parameter.BooleanParameter(
            'two', value=True, tip='Select segments with two selected nodes.'),
        selectionoperators.SelectionOperatorParam('operator')
    ],
    ordering=_selectFromNodesOrdering,
    tip="Select segments from the selected nodes.")

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


class SegFromSelectedFaces(SegmentSelectionModifier):
    def __init__(self, coverage, operator):
        self.coverage = coverage
        self.operator = operator