Esempio n. 1
0
        self.microstructure = None

    def getMicrostructure(self):
        return self.microstructure

    def getSelectionContext(self):
        # Returns the object that holds the pixel selection, not the
        # selection itself.
        if self.microstructure is not None:
            return self.microstructure.pixelselection

    def writeImage(self, datafile):
        from ooflib.image.IO import imageIO  # delayed import to avoid loops
        imageIO.writeImage(datafile, self)

    def size(self):
        return self.getObject().size()


## The imageContexts is a WhoDoUndoClass that hosts
## a set of instances of the ImageContext class, which
## which are subclasses of the WhoDoUndo class.
## Each ImageContext object contains an actual OOFImage[3D] object.
## Please also see the note on microsctructure.microStructures
imageContexts = whoville.WhoDoUndoClass(
    'Image',
    100,
    parentClass=ooflib.common.microstructure.microStructures,
    instanceClass=ImageContext,
    proxyClasses=['<topmost>', '<top bitmap>'])
Esempio n. 2
0
        path = labeltree.makePath(self.path())
        if not path:
            # path can be None if we're still in the process o
            # building a new SkeletonContext.  In that case, there are
            # no Meshes.
            return []
        meshnames = mesh.meshes.keys(
            path, condition=lambda x: not isinstance(x, whoville.WhoProxy))
        return [mesh.meshes[path + name] for name in meshnames]

    def __repr__(self):
        return 'SkeletonContext("%s")' % self.name()

skeletonContexts = whoville.WhoDoUndoClass(
    'Skeleton',
    ordering=200,
    parentClass=microstructure.microStructures,
    instanceClass=SkeletonContext,
    proxyClasses=['<topmost>'])

utils.OOFdefine('skeletonContexts', skeletonContexts)


def getSkeleton(ms, name):
    # ms is a Microstructure.  Returns a SkeletonContext
    return skeletonContexts[[ms.name(), name]]


def extractSkeletonPath(somepath):
    #Calling labeltree.makePath may be a more formal way to do this.
    pathlist = string.split(somepath, ":")
    if len(pathlist) < 2:
Esempio n. 3
0
    def getPixelSet(self):
        obj = self.getObject()
        if obj is not None:
            return self.getObject().getPixelGroup()

    def getBounds(self):
        obj = self.getObject()
        if obj is not None:
            return self.getObject().getBounds()


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

pixelselectionWhoClass = whoville.WhoDoUndoClass(
    'Pixel Selection',
    instanceClass=PixelSelectionContext,
    ordering=999,
    secret=0,
    proxyClasses=['<top microstructure>'])

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

defaultPixelSelectionColor = color.RGBColor(1.0, 0.22, 0.09)
defaultTintOpacity = 0.9


def _setDefaultPixelSelectionParams(menuitem, color, tintOpacity):
    global defaultPixelSelectionColor
    global defaultTintOpacity
    defaultPixelSelectionColor = color
    defaultTintOpacity = tintopacity