Example #1
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):
    ms = mscontext.getObject()
    data = orientmapdata.getOrientationMap(mscontext.getObject())
    if data:
Example #2
0
        def makeMenu(self, menu):
            self.menu = menu
            dollymenu = menu.addItem(oofmenu.OOFMenuItem("Dolly", cli_only=1))
            dollymenu.addItem(
                oofmenu.OOFMenuItem(
                    "In",
                    callback=self.dollyIn,
                    threadable=oofmenu.UNTHREADABLE,
                    params=[parameter.FloatParameter("factor")]))
            dollymenu.addItem(
                oofmenu.OOFMenuItem(
                    "Out",
                    callback=self.dollyOut,
                    threadable=oofmenu.UNTHREADABLE,
                    params=[parameter.FloatParameter("factor")]))
            dollymenu.addItem(
                oofmenu.OOFMenuItem("Fill",
                                    threadable=oofmenu.UNTHREADABLE,
                                    callback=self.dollyFill))
            trackmenu = menu.addItem(oofmenu.OOFMenuItem("Track", cli_only=1))
            trackmenu.addItem(
                oofmenu.OOFMenuItem(
                    "Horizontal",
                    callback=self.trackHoriz,
                    threadable=oofmenu.UNTHREADABLE,
                    params=[parameter.FloatParameter("distance")]))
            trackmenu.addItem(
                oofmenu.OOFMenuItem(
                    "Vertical",
                    callback=self.trackVert,
                    threadable=oofmenu.UNTHREADABLE,
                    params=[parameter.FloatParameter("distance")]))
            trackmenu.addItem(
                oofmenu.OOFMenuItem("Recenter",
                                    callback=self.recenter,
                                    threadable=oofmenu.UNTHREADABLE))

            rotatemenu = menu.addItem(oofmenu.OOFMenuItem("Rotate",
                                                          cli_only=1))
            rotatemenu.addItem(
                oofmenu.OOFMenuItem("Roll",
                                    callback=self.roll,
                                    threadable=oofmenu.UNTHREADABLE,
                                    params=[parameter.FloatParameter("angle")
                                            ]))
            rotatemenu.addItem(
                oofmenu.OOFMenuItem("Azimuth",
                                    callback=self.azimuth,
                                    threadable=oofmenu.UNTHREADABLE,
                                    params=[parameter.FloatParameter("angle")
                                            ]))
            rotatemenu.addItem(
                oofmenu.OOFMenuItem("Elevation",
                                    callback=self.elevation,
                                    threadable=oofmenu.UNTHREADABLE,
                                    params=[parameter.FloatParameter("angle")
                                            ]))
            rotatemenu.addItem(
                oofmenu.OOFMenuItem("Yaw",
                                    callback=self.yaw,
                                    threadable=oofmenu.UNTHREADABLE,
                                    params=[parameter.FloatParameter("angle")
                                            ]))
            rotatemenu.addItem(
                oofmenu.OOFMenuItem("Pitch",
                                    callback=self.pitch,
                                    threadable=oofmenu.UNTHREADABLE,
                                    params=[parameter.FloatParameter("angle")
                                            ]))

            zoommenu = menu.addItem(oofmenu.OOFMenuItem("Zoom", cli_only=1))
            zoommenu.addItem(
                oofmenu.OOFMenuItem(
                    "In",
                    callback=self.zoomIn,
                    threadable=oofmenu.UNTHREADABLE,
                    params=[parameter.FloatParameter("factor")]))
            zoommenu.addItem(
                oofmenu.OOFMenuItem(
                    "Out",
                    callback=self.zoomOut,
                    threadable=oofmenu.UNTHREADABLE,
                    params=[parameter.FloatParameter("factor")]))
            zoommenu.addItem(
                oofmenu.OOFMenuItem("Fill",
                                    threadable=oofmenu.UNTHREADABLE,
                                    callback=self.zoomFill))

            clipmenu = menu.addItem(oofmenu.OOFMenuItem("Clip", cli_only=1))
            clipmenu.addItem(
                oofmenu.OOFMenuItem(
                    "New",
                    callback=self.newClipCB,
                    params=[
                        parameter.ConvertibleRegisteredParameter(
                            "normal", direction.Direction,
                            direction.DirectionX()),
                        parameter.FloatParameter("offset", 0.0)
                    ]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem(
                    "Edit",
                    callback=self.editClipCB,
                    params=[
                        parameter.IntParameter("plane"),
                        parameter.ConvertibleRegisteredParameter(
                            "normal", direction.Direction),
                        parameter.FloatParameter("offset")
                    ]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Delete",
                                    callback=self.delClipCB,
                                    params=[parameter.IntParameter("plane")]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Enable",
                                    callback=self.clipEnableCB,
                                    params=[parameter.IntParameter("plane")]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Disable",
                                    callback=self.clipDisableCB,
                                    params=[parameter.IntParameter("plane")]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Flip",
                                    callback=self.clipFlipCB,
                                    params=[parameter.IntParameter("plane")]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Unflip",
                                    callback=self.clipUnflipCB,
                                    params=[parameter.IntParameter("plane")]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("InvertOn", callback=self.clipInvertOnCB))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("InvertOff",
                                    callback=self.clipInvertOffCB))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("SuppressOn",
                                    callback=self.clipSuppressOnCB))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("SuppressOff",
                                    callback=self.clipSuppressOffCB))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Select",
                                    callback=self.clipSelectCB,
                                    params=[parameter.IntParameter("plane")]))
            clipmenu.addItem(
                oofmenu.OOFMenuItem("Unselect", callback=self.clipUnselectCB))

            menu.addItem(
                oofmenu.OOFMenuItem("Restore_View",
                                    callback=self.restoreView,
                                    params=[view.ViewParameter("view")]))
            menu.addItem(
                oofmenu.OOFMenuItem("Restore_Named_View",
                                    callback=self._restoreNamedView,
                                    params=[ViewNameParameter("view")]))
            menu.addItem(
                oofmenu.OOFMenuItem("Save_View",
                                    callback=self.saveView,
                                    params=[parameter.StringParameter("name")
                                            ]))
            menu.addItem(
                oofmenu.OOFMenuItem(
                    "Delete_View",
                    callback=self.deleteView,
                    params=[
                        ViewNameParameter(
                            "view", tip="The name of the View to delete.")
                    ]))
Example #3
0
from ooflib.common import debug
from ooflib.common import primitives
from ooflib.common.IO import automatic
from ooflib.common.IO import oofmenu
from ooflib.common.IO import parallelmainmenu
from ooflib.common.IO import parameter
from ooflib.common.IO import socket2me
from ooflib.SWIG.common import mpitools
import ooflib.common.microstructure

_rank = mpitools.Rank()
_size = mpitools.Size()

# OOF.LoadData.IPC.Microstructure
msmenu = parallelmainmenu.ipcmenu.addItem(
    oofmenu.OOFMenuItem('Microstructure', secret=1, no_log=1))


def newMicrostructure_Parallel(menuitem, name, width, height, width_in_pixels,
                               height_in_pixels):
    # Only for the back-end processes
    global _rank
    if _rank == 0:
        return

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


msmenu.addItem(
Example #4
0
# Recipients of this software assume all responsibilities associated
# with its operation, modification and maintenance. However, to
# facilitate maintenance we ask that before distributing modified
# versions of this software, you first contact the authors at
# [email protected].

# Settable parameters controlling the output format

from ooflib.common import enum
from ooflib.common.IO import mainmenu
from ooflib.common.IO import oofmenu
from ooflib.common.IO import parameter

settingsmenu = mainmenu.OOF.Settings.addItem(
    oofmenu.OOFMenuItem(
        'Output_Formatting',
        help="Formatting options for post-processing analysis output."))

# The menuitems just set the parameter values, so they just have a
# dummy callback function.


def _dummy(*args, **kwargs):
    pass


class Separator(enum.EnumClass("space", "comma", "tab")):
    tip = "Characters used between columns in output files."
    discussion = """<para>
    The commands in the <xref linkend='MenuItem:OOF.Mesh.Analyze'/>
    menu write columns of data to output files.  The commands have a
Example #5
0
# versions of this software, you first contact the authors at
# [email protected].

## TODO: Print tutorials

from ooflib.SWIG.common import switchboard
from ooflib.common import debug
from ooflib.common import utils

from ooflib.common.IO import oofmenu
from ooflib.common.IO import mainmenu

allTutorials = {}

tutorialMenu = mainmenu.OOF.Help.addItem(
    oofmenu.OOFMenuItem('Tutorials', gui_only=1, no_log=1, ordering=-10))


def start_tutorial(tutorial, progress):  # redefined in GUI mode
    pass


def startTutorial(menuitem):
    start_tutorial(menuitem.data, 0)


class TutorialClass:
    def __init__(self, subject, ordering, lessons):
        self.subject = subject
        self.lessons = lessons
        self.ordering = ordering
Example #6
0
RegisteredParameter = parameter.RegisteredParameter
IntParameter = parameter.IntParameter
StringParameter = parameter.StringParameter
AutomaticNameParameter = parameter.AutomaticNameParameter
microStructures = microstructure.microStructures
SkeletonModifier = skeletonmodifier.SkeletonModifier

## General definitions
#RCL: OOF does not seem to be referenced in this file
OOF = mainmenu.OOF
_rank = mpitools.Rank()
_size = mpitools.Size()

## OOF.LoadData.IPC.Skeleton
smenu = parallelmainmenu.ipcmenu.addItem(
    oofmenu.OOFMenuItem('Skeleton', secret=1, no_log=1))


# OOF.LoadData.IPC.Skeleton.Initialize
def _parallel_init(menuitem, name, microstructure, x_elements, y_elements,
                   skeleton_geometry):
    initializer = InitializeSkeletonParallel(name, microstructure, x_elements,
                                             y_elements, skeleton_geometry)
    skel = initializer.create()
    ##    if _rank == 0:
    ##        initializer.report_skeleton()
    mpitools.Barrier()

    mscontext = microStructures[microstructure]
    import ooflib.engine.skeletoncontext
    skeletoncontext.skeletonContexts.add([microstructure, name],
Example #7
0
from ooflib.SWIG.common import mpitools

_rank = mpitools.Rank()
_size = mpitools.Size()
## Two main menus are created here, a public one and a secret one:

## --OOF.Windows.Parallel holds all the parallel menu items that the user can
## apply for his/her convenience. OOF.Parallel can call internally
## any OOF.Windows.

## --OOF.LoadData.IPC hosts all the Inter Processor Communication menu items
## which are used by the developer to coordinate interprocessor actions

## OOF.Windows.Parallel Menu
menusystem = mainmenu.OOF.Windows.addItem(
    oofmenu.OOFMenuItem('Parallel', secret=0, no_log=0))

## OOF.LoadData.IPC Menu
ipcmenu = mainmenu.OOF.LoadData.addItem(
    oofmenu.OOFMenuItem('IPC', secret=1, no_log=1))

## Add the MenuKey and ObjKey menus to keep the parser happy
ipcmenu.addItem(
    oofmenu.OOFMenuItem('MenuKey',
                        callback=binarydata.menuKeyCB,
                        secret=1,
                        params=[
                            parameter.StringParameter('path'),
                            parameter.IntParameter('key')
                        ]))
ipcmenu.addItem(
Example #8
0
from ooflib.common.IO import automatic
from ooflib.common.IO import filenameparam
from ooflib.common.IO import mainmenu
from ooflib.common.IO import microstructuremenu
from ooflib.common.IO import oofmenu
from ooflib.common.IO import reporter
from ooflib.common.IO import parameter
from ooflib.common.IO import whoville
from ooflib.common.IO import xmlmenudump
from ooflib.image.IO import imagemenu
import ooflib.common.microstructure
import os

orientmapmenu = oofmenu.OOFMenuItem(
    'OrientationMap',
    cli_only=False,
    help='Commands for working with Orientation Maps.',
    discussion=xmlmenudump.loadFile(
        'DISCUSSIONS/orientationmap/menu/orientmapmenu.xml'))

## TODO 3.1: Uncomment this after adding support for 3D EBSD images.
#mainmenu.OOF.addItem(orientmapmenu)

## Parameters for listing only those Microstructures that have or
## don't have Orientation Map data.  The two classes are identical
## here, but have different widgets.


class MicrostructureWithOrientMapParameter(whoville.WhoParameter):
    def __init__(self, name, value=None, default=None, tip=None):
        whoville.WhoParameter.__init__(self,
                                       name,
Example #9
0
from ooflib.common.IO.GUI import gtkutils
from ooflib.common.IO.GUI import quit
from ooflib.common.IO.GUI import subWindow
from ooflib.common.IO.GUI import tooltips
from ooflib.common.IO.GUI import whowidget
from ooflib.common.IO.GUI import widgetscope
from ooflib.engine import mesh
from ooflib.engine.IO.GUI import outputvalwidgets
import gtk
import ooflib.engine.IO.output

import sys

allMeshDataWindows = []

mdWindowMenu = mainmenu.OOF.Windows.addItem(oofmenu.OOFMenuItem("Mesh_Data"))

class MeshDataGUI(widgetscope.WidgetScope):
    count = 1
    def __init__(self, gfxwindow, time, position, output=None):
        mainthread.runBlock(self.__init__thread,
                            (gfxwindow, time, position, output))

    def __init__thread(self, gfxwindow, time, position, output):
        debug.mainthreadTest()
        allMeshDataWindows.append(self)
        widgetscope.WidgetScope.__init__(self, None)

        current_count = MeshDataGUI.count
        MeshDataGUI.count += 1
        self._name = "Mesh_Data_%d" % current_count
Example #10
0
# [email protected]. 

from ooflib.common.IO import mainmenu
from ooflib.common.IO import oofmenu
from ooflib.common.IO import parameter
from ooflib.common.IO import progressbar_delay
from ooflib.common.threadmanager import threadManager

activityviewermenu = mainmenu.OOF.addItem(oofmenu.OOFMenuItem(
    'ActivityViewer',
    secret=1,
    help='Control the Activity Viewer Window.',
    discussion="""<para>

    In GUI mode, the <link
    linkend='Section-Windows-ActivityViewer'>Activity Viewer</link>
    window displays progress bars for monitoring &oof2; tasks and
    <guilabel>Stop</guilabel> buttons for interrupting them.  In text
    mode, progress bars are drawn with asterisks in a terminal window,
    and typing control-C interrupts tasks.

    </para>"""
    
    ))

# The "File" menu item is visible in the ActivityViewer window in
# GUI mode -- GUI-only menu items are added to it at that time.
# It has to be created here in order to be the first in the sequence on
# the menubar.
filemenu = activityviewermenu.addItem(oofmenu.OOFMenuItem('File', no_doc=1))

settingsmenu = activityviewermenu.addItem(oofmenu.OOFMenuItem(
Example #11
0
    defaultLineWidth = line_width


pixelinfoparams = [color.ColorParameter('color', defaultPixelInfoColor,
                                        tip="Color for the queried pixel."),
                   parameter.IntRangeParameter('line_width', widthRange,
                                               defaultLineWidth,
                                               tip="Line width.")]

mainmenu.gfxdefaultsmenu.Pixels.addItem(oofmenu.OOFMenuItem(
    "Pixel_Info",
    callback=_setDefaultPixelParams,
    ordering=2,
    params=pixelinfoparams,
    help="Set default parameters for the Pixel Info display.",
    discussion="""<para>

    Set default parameters for <link linkend="RegisteredClass:PixelInfoDisplay"><classname>PixelInfoDisplays</classname></link>.
    See <xref linkend="RegisteredClass:PixelInfoDisplay"/> for the details.
    This command may be placed in the &oof2rc; file to set a default value
    for all &oof2; sessions.

    </para>"""))

pixelInfoDisplay = registeredclass.Registration(
    'Pixel Info',
    display.DisplayMethod,
    PixelInfoDisplay,
    params=pixelinfoparams,
    ordering=2.70,
    layerordering=display.PointLike(0.5),
    whoclasses=('Image','Microstructure', 'Top Bitmap'),
Example #12
0
    def makeMenu(self, menu):
        self.menu = menu
        if config.dimension() == 2:
            pinparams = [
                self.skeleton_param,
                primitives.PointParameter('point', tip='Target point.')
            ]
        else:  # 3D
            pinparams = [
                self.skeleton_param,
                primitives.PointParameter('point', tip='Target point'),
                view.ViewParameter('view')
            ]

        menu.addItem(
            oofmenu.OOFMenuItem(
                'Pin',
                callback=self.pin,
                params=pinparams,
                help="Pin the node closest to the given point.",
                discussion=xmlmenudump.loadFile(
                    'DISCUSSIONS/engine/menu/pin.xml')))
        menu.addItem(
            oofmenu.OOFMenuItem(
                'UnPin',
                callback=self.unpin,
                params=pinparams,
                help="Unpin the node closest to the given point.",
                discussion=xmlmenudump.loadFile(
                    'DISCUSSIONS/engine/menu/unpin.xml')))
        menu.addItem(
            oofmenu.OOFMenuItem(
                'TogglePin',
                callback=self.togglepin,
                params=pinparams,
                help=
                "Toggle the pinnedness of the node closest to the given point.",
                discussion=xmlmenudump.loadFile(
                    'DISCUSSIONS/engine/menu/toggle_pin.xml')))
        menu.addItem(
            oofmenu.OOFMenuItem('UnPinAll',
                                callback=pinnodesmodifier.unpinall,
                                params=[self.skeleton_param],
                                help="Unpin all nodes.",
                                discussion=xmlmenudump.loadFile(
                                    'DISCUSSIONS/engine/menu/unpin_all.xml')))
        menu.addItem(
            oofmenu.OOFMenuItem('Invert',
                                callback=pinnodesmodifier.invert,
                                params=[self.skeleton_param],
                                help="Invert pinned nodes.",
                                discussion=xmlmenudump.loadFile(
                                    'DISCUSSIONS/engine/menu/invert_pin.xml')))

        menu.addItem(
            oofmenu.OOFMenuItem('Undo',
                                callback=pinnodesmodifier.undo,
                                params=[self.skeleton_param],
                                help="Undo the latest pin.",
                                discussion=xmlmenudump.loadFile(
                                    'DISCUSSIONS/engine/menu/undo_pin.xml')))
        menu.addItem(
            oofmenu.OOFMenuItem('Redo',
                                callback=pinnodesmodifier.redo,
                                params=[self.skeleton_param],
                                help="Redo the latest undone pin.",
                                discussion=xmlmenudump.loadFile(
                                    'DISCUSSIONS/engine/menu/redo_pin.xml')))
Example #13
0
import ooflib.common.units
import sys

OOF = mainmenu.OOF
RegisteredParameter = parameter.RegisteredParameter
IntParameter = parameter.IntParameter
WhoParameter = whoville.WhoParameter
microStructures = microstructure.microStructures
AutoWhoNameParameter = whoville.AutoWhoNameParameter
WhoNameParameter = whoville.WhoNameParameter

skeletonmenu = OOF.addItem(
    oofmenu.OOFMenuItem('Skeleton',
                        cli_only=1,
                        help='Create and modify mesh Skeletons.',
                        discussion="""<para>
    The <command>Skeleton</command> menu contains tools to create and
    modify &skels;.
    </para>"""))

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


def skeletonNameResolver(param, startname):
    if param.automatic():
        basename = 'skeleton'
    else:
        basename = startname
    msname = param.group['microstructure'].value
    mspath = labeltree.makePath(msname)
    # In the command-line case, msname may not be set yet -- return
Example #14
0

def versionCB(menuitem, number, format):
    if format == BINARY:
        menuitem.parser.binaryMode()


versionCmd = oofmenu.OOFMenuItem(
    'FileVersion',
    callback=versionCB,
    params=[
        parameter.FloatParameter('number', tip='file format version number'),
        enum.EnumParameter('format',
                           DataFileFormat,
                           tip='format for the data file.')
    ],
    help="Identify data file format.  Used internally in data files.",
    discussion="""
    <para>&oof2; data files must begin with a FileVersion command.
    The <varname>number</varname> parameter is used to maintain
    compatibility with older data files.  For now, its value should be
    <userinput>1.0</userinput>.  The <varname>format</varname>
    parameter must be one of the values discussed in <xref
    linkend='Section:Concepts:FileFormats'/>.</para>
    """)

mainmenu.OOF.LoadData.addItem(versionCmd)


class AsciiDataFile:
    def __init__(self, file, format):
        self.format = format
Example #15
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
Example #16
0
    def __init__thread(self, gfxwindow, time, position, output):
        debug.mainthreadTest()
        allMeshDataWindows.append(self)
        widgetscope.WidgetScope.__init__(self, None)

        current_count = MeshDataGUI.count
        MeshDataGUI.count += 1
        self._name = "Mesh_Data_%d" % current_count
        self.output = output
        self.time = time
        self.position = position
        self.sbcallbacks = []
        self.gsbcallbacks = []          # callbacks from a specific gfx window
        self.updateLock = lock.Lock()

        self.outputparam = \
                     ooflib.engine.IO.output.ValueOutputParameter('output')

        # Although it's not displayed, we need a mesh widget in the
        # widgetscope, or the OutputParameterWidget won't work.
        # TODO 3.1: Is this ugly, or what?
        self.meshWidget = whowidget.WhoWidget(mesh.meshes, scope=self,
                                              name="Godot")

        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        title = utils.underscore2space(self._name)
        self.gtk.set_title(title)
        gtklogger.newTopLevelWidget(self.gtk, title)
        gtklogger.connect_passive(self.gtk, 'delete-event')
        gtklogger.connect_passive(self.gtk, 'configure-event')
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

        # Put this window into the Windows menu.  The menu item can't
        # be logged, since the creation and operation of the window
        # aren't logged, so scripts shouldn't refer to it at all.
        mainmenu.OOF.Windows.Mesh_Data.addItem(oofmenu.OOFMenuItem(
            self._name,
            no_log=1,
            help="Raise Mesh Data window %d." % current_count,
            threadable=oofmenu.UNTHREADABLE,
            callback=self.raiseWindow))

        expander = gtk.Expander("Source")
        gtklogger.setWidgetName(expander, 'ViewSource')
        gtklogger.connect_passive_after(expander, 'activate')
        self.mainbox.pack_start(expander)
        expander.set_expanded(1)
        
        self.table = gtk.Table(rows=config.dimension()+4, columns=2)
        expander.add(self.table)

        label = gtk.Label("Source Window:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 0,1, xpadding=3, xoptions=gtk.FILL)
        tooltips.set_tooltip_text(label,
            "Display data for mouse clicks in this Graphics window.")

        self.gfxWindowChooser = chooser.ChooserWidget([],
                                                      callback=self.chooserCB,
                                                      name='GfxWindow')
        self.table.attach(self.gfxWindowChooser.gtk, 1,2, 0,1,
                     xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)


        label = gtk.Label("Mesh:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 1,2,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        tooltips.set_tooltip_text(label,
                                  "Data is displayed for values on this mesh.")

        self.meshText = gtk.Entry()
        gtklogger.setWidgetName(self.meshText, "meshname")
        self.meshText.set_editable(False)
        self.meshText.set_size_request(12*guitop.top().charsize, -1)
        self.table.attach(self.meshText, 1,2, 1,2,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)

        # Position controls
        label = gtk.Label("position x:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 2,3,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        self.xText = gtk.Entry()
        gtklogger.setWidgetName(self.xText, 'x')
        self.xText.set_size_request(12*guitop.top().digitsize, -1)
        self.table.attach(self.xText, 1,2, 2,3,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        self.xsignal = gtklogger.connect(self.xText, 'changed',
                                         self.posChangedCB)

        label = gtk.Label("position y:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 3,4,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        self.yText = gtk.Entry()
        gtklogger.setWidgetName(self.yText, 'y')
        self.yText.set_size_request(12*guitop.top().digitsize, -1)
        self.table.attach(self.yText, 1,2, 3,4,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        self.ysignal = gtklogger.connect(self.yText, 'changed',
                                         self.posChangedCB)

        if config.dimension() == 3:
            label = gtk.Label("position z:")
            label.set_alignment(1.0, 0.5)
            self.table.attach(label, 0,1, 4,5,
                              xpadding=3, xoptions=gtk.FILL, yoptions=0)
            self.zText = gtk.Entry()
            gtklogger.setWidgetName(self.zText, 'z')
            self.zText.set_size_request(12*guitop.top().digitsize, -1)
            self.table.attach(self.zText, 1,2, 4,5, xpadding=3, 
                              xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
            self.zsignal = gtklogger.connect(self.zText, 'changed', 
                                             self.posChangedCB)
            timerow = 5
        else:
            timerow = 6

        # Time controls.  Typing in the time widget does not
        # immediately update the displayed data, because interpolating
        # to a new time is an expensive computation, and shouldn't be
        # done while the user is in the middle of typing.  Instead,
        # the time widget is normally desensitized and uneditable.
        # When the user clicks the "Edit" button, the widget becomes
        # editable, the rest of the window is desensitized, and the
        # "Edit" button changes do a "Done" button.  When the user
        # clicks "Done" the data is updated and the time widget
        # becomes uneditable again.
        label = gtk.Label("time:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, timerow,timerow+1,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        tBox = gtk.HBox(spacing=3)
        self.table.attach(tBox, 1,2, timerow,timerow+1,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        self.tText = gtk.Entry()
        self.tText.set_editable(False)
        self.tText.set_sensitive(False)
        tBox.pack_start(self.tText, expand=1, fill=1)
        gtklogger.setWidgetName(self.tText, 't')
        self.tText.set_size_request(12*guitop.top().digitsize, -1)
        self.tEditButton = gtk.Button("Edit")
        tBox.pack_start(self.tEditButton, expand=0, fill=0)
        gtklogger.setWidgetName(self.tEditButton, "tEdit")
        gtklogger.connect(self.tEditButton, 'clicked', self.tEditCB)
        self.tEditMode = False
 
        # Output selection
        label = gtk.Label("Output:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, timerow+2,timerow+3,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        tooltips.set_tooltip_text(label,"Choose which data is displayed.")
        
        self.outputwidget = self.outputparam.makeWidget(scope=self)
        self.table.attach(self.outputwidget.gtk, 1,2, timerow+2,timerow+3,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        switchboard.requestCallback(self.outputwidget, self.outputwidgetCB)

        # Data display panel
        hbox = gtk.HBox()
        self.mainbox.pack_start(hbox, expand=1, fill=1, padding=5)
        frame = gtk.Frame("Data")
        gtklogger.setWidgetName(frame, 'Data')
        frame.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(frame, expand=1, fill=1, padding=5)
        vbox = gtk.VBox()
        frame.add(vbox)
        self.databox = gtk.HBox()
        vbox.pack_start(self.databox, expand=1, fill=1, padding=3)
        self.datawidget = None       # set by updateData

        # Buttons at the bottom of the window
        buttonbox = gtk.HBox()
        self.mainbox.pack_start(buttonbox, expand=0, fill=0, padding=3)
        # Freeze buttons 
        freezeframe = gtk.Frame("Freeze")
        gtklogger.setWidgetName(freezeframe, "Freeze")
        buttonbox.pack_start(freezeframe, expand=1, fill=1, padding=3)
        hbox = gtk.HBox()
        freezeframe.add(hbox)
        # Freeze Space button
        self.freezeSpaceFlag = False
        self.freezeSpaceButton = gtk.CheckButton('Space')
        gtklogger.setWidgetName(self.freezeSpaceButton, 'Space')
        hbox.pack_start(self.freezeSpaceButton, expand=1, fill=0, padding=0)
        self.freezeSpaceButton.set_active(self.freezeSpaceFlag)
        gtklogger.connect(self.freezeSpaceButton, 'clicked', 
                          self.freezeSpaceButtonCB)
        tooltips.set_tooltip_text(self.freezeSpaceButton,
                        "Prevent the data in this window from being updated when the sample position changes.")
        # Freeze Time button
        self.freezeTimeFlag = False
        self.freezeTimeButton = gtk.CheckButton('Time')
        gtklogger.setWidgetName(self.freezeTimeButton, "Time")
        hbox.pack_start(self.freezeTimeButton, expand=1, fill=0, padding=0)
        self.freezeTimeButton.set_active(self.freezeTimeFlag)
        gtklogger.connect(self.freezeTimeButton,'clicked',
                          self.freezeTimeButtonCB)
        tooltips.set_tooltip_text(self.freezeTimeButton,
            "Prevent the data in this window from being updated when the Mesh's time changes.")

        # Clone button
        self.cloneButton = gtkutils.StockButton(gtk.STOCK_COPY, 'Clone')
        gtklogger.setWidgetName(self.cloneButton, 'Clone')
        gtklogger.connect(self.cloneButton, 'clicked', self.cloneButtonCB)
        buttonbox.pack_start(self.cloneButton, expand=0, fill=0, padding=3)
        tooltips.set_tooltip_text(self.cloneButton,
            "Make a copy of this window with its current settings.")

        # Close button
        self.closeButton = gtk.Button(stock=gtk.STOCK_CLOSE)
        gtklogger.setWidgetName(self.closeButton, 'Close')
        gtklogger.connect(self.closeButton, 'clicked', self.closeButtonCB)
        buttonbox.pack_end(self.closeButton, expand=0, fill=0, padding=3)

        self.gtk.connect('destroy', self.destroyCB)

        self.updateGfxWindowChooser()
        if gfxwindow:
            self.gfxWindowChooser.set_state(gfxwindow.name)
        if position is not None:
            self.updatePosition(position)
        self.currentMesh = None
        self.updateMesh()

        self.setupSwitchboard()         # gfx window dependent callbacks
        self.sbcallbacks += [
            switchboard.requestCallbackMain('open graphics window',
                                            self.gfxwindowChanged),
            switchboard.requestCallbackMain('close graphics window',
                                            self.gfxwindowChanged),
            switchboard.requestCallbackMain('mesh data changed',
                                            self.meshDataChanged),
            switchboard.requestCallbackMain((gfxwindow, "time changed"),
                                            self.timeChanged)
            ]

        
        self.gtk.show_all()
Example #17
0
                         tip="Color for the selected elements."),
    parameter.FloatRangeParameter('opacity', (0., 1., 0.01),
                                  defaultSelectedElementOpacity,
                                  tip="Opacity of the selected elements.")
]

mainmenu.gfxdefaultsmenu.Skeletons.addItem(
    oofmenu.OOFMenuItem(
        'Selected_Elements',
        callback=_setSelectedElementParams,
        ordering=1,
        params=selectedElementParams,
        help=
        "Set default parameters for displaying selected skeleton elements.",
        discussion="""<para>

    Set default parameters for the
    <xref linkend="RegisteredClass-SkeletonElementSelectionDisplay"/>,
    which displays the currently selected &skel; &elems; in the graphics
    window.  See
    <xref linkend="RegisteredClass-SkeletonElementSelectionDisplay"/>
    for a discussion of the parameters. This command may be put in the
    &oof2rc; file to set defaults for all &oof2; sessions.
    
    </para>"""))

elementSelectDisplay = registeredclass.Registration(
    'Selected Elements',
    display.DisplayMethod,
    SkeletonElementSelectionDisplay,
    params=selectedElementParams,
    ordering=2.0,
Example #18
0
from ooflib.SWIG.common import switchboard
from ooflib.common import debug
from ooflib.common import microstructure
from ooflib.common import pixelselectionmod
from ooflib.common import utils
from ooflib.common.IO import parameter
from ooflib.common.IO import mainmenu
from ooflib.common.IO import oofmenu
from ooflib.common.IO import whoville
from ooflib.common.IO import xmlmenudump

selmodmenu = mainmenu.OOF.addItem(
    oofmenu.OOFMenuItem('PixelSelection',
                        help='Tools for selecting pixels.',
                        discussion=xmlmenudump.loadFile(
                            'DISCUSSIONS/common/menu/pixelselection.xml'),
                        cli_only=1))


def buildSelectionModMenu():
    selmodmenu.clearMenu()
    selmodmenu.addItem(
        oofmenu.OOFMenuItem('Undo',
                            params=[
                                whoville.WhoParameter(
                                    'microstructure',
                                    microstructure.microStructures,
                                    tip=parameter.emptyTipString)
                            ],
                            callback=pixelselectionmod.undo,
Example #19
0
from ooflib.common.IO import parallelmainmenu
from ooflib.common.IO import parameter
from ooflib.common.IO import socket2me
from ooflib.common.IO import whoville
from ooflib.image import imagemodifier
from ooflib.image.IO import imagemenu
import ooflib.common.microstructure


_rank = mpitools.Rank()
_size = mpitools.Size()

## OOF.LoadData.IPC.Image
imenu = parallelmainmenu.ipcmenu.addItem(
    oofmenu.OOFMenuItem('Image',
                        secret=1,
                        no_log=1)
    )

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

def createMSFromImage_Parallel(menuitem, msname, image):
    if _rank==0:
        return
    #Already done in imagemenu for process 0
    imagepath = labeltree.makePath(image)
    imagecontext = oofimage.imageContexts[image]
    immidge = imagecontext.getObject().clone(imagepath[-1])
    ms = ooflib.common.microstructure.Microstructure(msname,
                                                   immidge.sizeInPixels(),
                                                   immidge.size())
Example #20
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
Example #21
0
            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)
    new_aa.rename(name)
    ms_obj.namedActiveAreas.append(new_aa)
Example #22
0
    for mode in SkeletonSelectionMode.modes:
        if mode.name == name:
            return mode


def firstMode():
    if SkeletonSelectionMode.modes:
        return SkeletonSelectionMode.modes[0]


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

bufsizmenu = mainmenu.OOF.Settings.UndoBuffer_Size.addItem(
    oofmenu.OOFMenuItem(
        'Skeleton_Selection',
        help=
        "Set the size of history buffers for Skeleton selection operations",
        ordering=1))

_stacksize = 50


def _allBufSizesCB(menuitem, size):
    _stacksize = size
    for mode in SkeletonSelectionMode.modes:
        mode.setUndoBufferSize(menuitem, size)


_stacksize_params = [
    parameter.IntParameter('size',
                           _stacksize,
Example #23
0
    global defaultSkelBdyLineWidth
    global defaultSkelBdyGlyphSize
    global defaultSkelBdyGlyphResolution
    defaultSkelBdyColor = color
    defaultSkelBdyLineWidth = linewidth
    defaultSkelBdyGlyphSize = glyphsize
    defaultSkelBdyGlyphResolution = resolution

mainmenu.gfxdefaultsmenu.Skeletons.addItem(oofmenu.OOFMenuItem(
    "Boundary",
    callback=_setSkelBdyParams,
    params=skelbdyparams,
    ordering=4.5,
    help="Set default parameters for displaying skeleton boundaries.",
    discussion="""<para>

    This command sets the default parameters for the
    <xref linkend="RegisteredClass-SelectedSkeletonBoundaryDisplay"/>,
    which displays the currently
    <link linkend="Section-Tasks-SkeletonBoundaries">selected
    <classname>Skeleton</classname> boundaries</link>.  Put this command
    in the &oof2rc; file to set default values for all &oof2; sessions.
    
    </para>"""))

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

# Registrations for boundary displays

registeredclass.Registration(
    'Boundaries',
    display.DisplayMethod,
Example #24
0
from ooflib.common.IO import mainmenu
from ooflib.engine.IO import meshIO
from ooflib.common.IO import oofmenu
from ooflib.common.IO import parameter
from ooflib.common.IO import whoville
from ooflib.common.IO import xmlmenudump
from ooflib.engine.IO import scheduledoutput
from ooflib.engine.IO import outputdestination
from ooflib.engine import outputschedule
import ooflib.engine.mesh
import ooflib.engine.IO.meshmenu # makes sure OOF.Mesh is defined first

outputmenu = mainmenu.OOF.Mesh.addItem(
    oofmenu.OOFMenuItem(
        'Scheduled_Output',
        help="Define output operations to be performed during time evolution calculations.",
        discussion=xmlmenudump.loadFile(
            "DISCUSSIONS/engine/menu/scheduledoutput.xml")))

outputIOmenu = meshIO.meshmenu.addItem(oofmenu.OOFMenuItem(
        'Scheduled_Output',
        help="Scheduled Output operations. Used internally in Mesh data files.",
        discussion='<para>Load <xref linkend="RegisteredClass-ScheduledOutput"/>s from a data file.</para>'
        ))

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

def outputNameResolver(param, name):
    if param.automatic():
        output = param.group['output'].value
        basename = automatic.AutomaticName(output.defaultName())
Example #25
0
#     import ooflib.engine.skeleton as skeleton
# elif config.dimension() == 3:
#     import ooflib.engine.skeleton3d as skeleton
import types

AutomaticNameParameter = parameter.AutomaticNameParameter
NodeGroupParameter = skeletongroupparams.NodeGroupParameter
SegmentGroupParameter = skeletongroupparams.SegmentGroupParameter
ElementGroupParameter = skeletongroupparams.ElementGroupParameter
if config.dimension() == 3:
    FaceGroupParameter = skeletongroupparams.FaceGroupParameter

nodegroupmenu = oofmenu.OOFMenuItem(
    "NodeGroup",
    cli_only=1,
    help='Create and manage NodeGroups.',
    discussion="""<para>
    &nodegroups; provide a convenient way of operating on many &skel;
    &nodes; simultaneously.
    </para>""")

segmentgroupmenu = oofmenu.OOFMenuItem(
    "SegmentGroup",
    cli_only=1,
    help='Create and manage SegmentGroups.',
    discussion="""<para>
    &sgmtgroups; provide a convenient way of operating on many &skel;
    &sgmts; simultaneously.
    </para>""")

elementgroupmenu = oofmenu.OOFMenuItem(
    "ElementGroup",
Example #26
0
## 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,
Example #27
0
from ooflib.common.IO import mainmenu
from ooflib.common.IO import microstructureIO
from ooflib.common.IO import oofmenu
from ooflib.common.IO import parameter
from ooflib.common.IO import whoville
from ooflib.common.IO import xmlmenudump
from ooflib.image import imagecontext
import ooflib.common.microstructure
from types import *

if parallel_enable.enabled():
    from ooflib.common.IO import microstructureIPC

micromenu = mainmenu.OOF.addItem(
    oofmenu.OOFMenuItem('Microstructure',
                        help="Create and manipulate &micro; objects.",
                        cli_only=1))
#######################

if config.dimension() == 2:
    sizeparams = parameter.ParameterGroup(
        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.'))

    def newMicrostructure(menuitem, name, width, height, width_in_pixels,
                          height_in_pixels):
        if width <= 0 or height <= 0 or width_in_pixels <= 0 or height_in_pixels <= 0:
Example #28
0
OOF = mainmenu.OOF

cmdformat = ">i"
cmdsize = struct.calcsize(cmdformat)

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


def menuKeyCB(menuitem, path, key):
    menuitem.parser.mode.defineMenuKey(path, key)


OOF.LoadData.addItem(
    oofmenu.OOFMenuItem('MenuKey',
                        callback=menuKeyCB,
                        params=[
                            parameter.StringParameter('path'),
                            parameter.IntParameter('key')
                        ]))


def objectKeyCB(menuitem, obj, key):
    menuitem.parser.mode.defineObjKey(utils.OOFeval_r(obj), key)


OOF.LoadData.addItem(
    oofmenu.OOFMenuItem('ObjKey',
                        callback=objectKeyCB,
                        params=[
                            parameter.StringParameter('obj'),
                            parameter.IntParameter('key')
                        ]))
Example #29
0
                                defaultNodeSize,
                                tip="Node size."),
    parameter.IntRangeParameter('element_width',
                                widthRange,
                                defaultElementWidth,
                                tip="Line thickness for element edge.")
]

mainmenu.gfxdefaultsmenu.Meshes.addItem(
    oofmenu.OOFMenuItem("Mesh_Info",
                        callback=_setMeshInfoParams,
                        params=meshinfoparams,
                        ordering=1,
                        help="Set default parameters for Mesh Info displays.",
                        discussion="""<para>

    Set default parameters for
    <link linkend="RegisteredClass-MeshInfoDisplay"><classname>MeshInfoDisplays</classname></link>.
    See <xref linkend="RegisteredClass-MeshInfoDisplay"/> for the details.
    This command may be placed in the &oof2rc; file to set a default value
    for all &oof2; sessions.
    
    </para>"""))

meshInfoDisplay = registeredclass.Registration(
    'Info',
    display.DisplayMethod,
    MeshInfoDisplay,
    params=meshinfoparams,
    ordering=4.0,
    layerordering=display.PointLike(100),
    whoclasses=('Mesh', ),
Example #30
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."))