Eidolon
Public Member Functions | Public Attributes | Private Member Functions | List of all members
ScenePlugin Class Reference
Inheritance diagram for ScenePlugin:
Inheritance graph
Collaboration diagram for ScenePlugin:
Collaboration graph

Public Member Functions

def __init__ (self, name)
 
def init (self, plugid, win, mgr)
 
def cleanup (self)
 
def findObject (self, name, assertFound=True)
 
def removeFilesTask (self, fileglob)
 
def getScriptCode (self, obj, kwargs)
 
def getIcon (self, obj)
 
def getMenu (self, obj)
 
def getHelp (self)
 
def acceptFile (self, filename)
 
def loadObject (self, filename, name=None, kwargs)
 
def saveObject (self, obj, path, overwrite=False, setFilenames=False, kwargs)
 
def checkFileOverwrite (self, obj, dirpath, name=None)
 
def getObjFiles (self, obj)
 
def renameObjFiles (self, obj, oldname, overwrite=False)
 
def copyObjFiles (self, obj, sdir, overwrite=False)
 
def removeObject (self, obj)
 
def createRepr (self, obj, reprtype, kwargs)
 
def getReprParams (self, obj, reprtype)
 
def getReprParamHelp (self, obj, reprtype)
 
def getReprTypes (self, obj)
 
def createHandles (self, rep, kwargs)
 
def updateObjPropBox (self, obj, prop)
 
def updateReprPropBox (self, rep, prop)
 
def createObjPropBox (self, obj)
 
def createReprPropBox (self, rep)
 
def addSceneObject (self, obj)
 
def addSceneObjectRepr (self, rep)
 
def applyMaterial (self, rep, mat, kwargs)
 
def objectMenuItem (self, obj, item)
 

Public Attributes

 plugid
 
 win
 
 mgr
 
 name
 

Private Member Functions

def _getUIReprParams (self, obj, prop)
 
def _createReprButton (self, obj, prop)
 
def _applyMaterialButton (self, rep, prop)
 
def _setReprVisibleCheckbox (self, rep)
 
def _setParent (self, rep, prop)
 

Detailed Description

Base class for all plugins, includes code for a basic properties box for scene objects and representations.

The file interface is defined by these methods, overriding any one is optional unless specified otherwise:
    - acceptFile - returns True if the given file can be loaded with loadObject (which must also be overridden)
    - loadObject - load a file(s)
    - saveObject - save an object to file(s)
    - checkFileOverwrite - check whether saving an object would overwrite files
    - copyObjFiles - copies an object's file(s)
    - renameObjFiles - renames an object's file(s)
    - getObjFiles - get the files the given object was loaded from

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  name 
)

Member Function Documentation

◆ _applyMaterialButton()

def _applyMaterialButton (   self,
  rep,
  prop 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _createReprButton()

def _createReprButton (   self,
  obj,
  prop 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _getUIReprParams()

def _getUIReprParams (   self,
  obj,
  prop 
)
private
Returns a pair `(args,kwargs)', where `args' is the list of position arguments and `kwargs' is the keyword
argument dictionary, for the call obj.createRepr(). This method is called by _createReprButton() only and is
used to create the arguments for the createRepr() from the UI.
Here is the caller graph for this function:

◆ _setParent()

def _setParent (   self,
  rep,
  prop 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _setReprVisibleCheckbox()

def _setReprVisibleCheckbox (   self,
  rep 
)
private
Here is the caller graph for this function:

◆ acceptFile()

def acceptFile (   self,
  filename 
)
Return True if `filename' is a file which can be loaded by this plugin, and if other preconditions are met.
When a file is given on the command line which isn't a script file, the file path is pass to this method with
every loaded plugin as a receiver. The first plugin to return True then loads the file through loadObject().

◆ addSceneObject()

def addSceneObject (   self,
  obj 
)
Called by the manager when a scene object is added, returns the properties dialog box and an update function.
If no 'self.win' object is present, return (None,None).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addSceneObjectRepr()

def addSceneObjectRepr (   self,
  rep 
)
Called by the manager when a representation is added, returns the properties dialog box, update function for
that dialog, and a function to call when a representation is double-clicked (typically toggles visibility).
If no 'self.win' object is present, return (None,None,None).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyMaterial()

def applyMaterial (   self,
  rep,
  mat,
  kwargs 
)
Apply material `mat' to the representation `rep', which may make internal copies of the material with differing
properties. Users should not rely on changing materials to have an effect on representations after application.
The argument `mat' must be a material object. The named argument `field' is used to specify what field to use
for coloration or vector determination. The value of this argument should be a RealMatrix object containing
the data field, or the name of the data field stored by the representation's SceneObject parent. 
Here is the caller graph for this function:

◆ checkFileOverwrite()

def checkFileOverwrite (   self,
  obj,
  dirpath,
  name = None 
)
Returns the list of file paths which would be overwritten if `obj' was saved to the directory `dirpath' with
its current name replaced with `name' if not None. An empty list means saving this object or moving files to
use the name `name' would not overwrite any existing files. This must function even if the `obj' was not loaded
from files.

◆ cleanup()

def cleanup (   self)
Called when shutting down, use this to clear and close resources.

◆ copyObjFiles()

def copyObjFiles (   self,
  obj,
  sdir,
  overwrite = False 
)
Copy the object `obj' to directory `sdir' and set its internal representation to match the filename(s). This
will raise an IOError and do nothing if files need to be overwritten and `overwrite' is False. This requires
that `obj' was previously loaded from or saved to files.

◆ createHandles()

def createHandles (   self,
  rep,
  kwargs 
)
Create a list of Handle objects for representation `rep'. By default this creates a single TransFormHandle
object on every call. This method must safely return the handle list regardless of how many times its called.

◆ createObjPropBox()

def createObjPropBox (   self,
  obj 
)
Creates a properties dialog box for SceneObject 'obj'. This should be a new instance of a QWidget subclass.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createRepr()

def createRepr (   self,
  obj,
  reprtype,
  kwargs 
)
Returns a representation of 'obj' SceneObject instance as defined by the 'reprtype' type and
other arguments. This is typically called by the method of 'obj' of the same name rather than directly.

◆ createReprPropBox()

def createReprPropBox (   self,
  rep 
)
Creates a properties dialog box for SceneObjectRepr 'rep'. This should be a new instance of a QWidget subclass.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findObject()

def findObject (   self,
  name,
  assertFound = True 
)
Attempt to find the file specified by `name', which is a str or a Future containing one, otherwise it's returned
instead of a found object. If `name' is an existing filename, the basename without extension is used as the
name. If an object with the given name can't be found and `assertFound' is True, then an assertion error is
raised. The found object is returned or None if not found.
Here is the caller graph for this function:

◆ getHelp()

def getHelp (   self)
Return a help text block.

◆ getIcon()

def getIcon (   self,
  obj 
)
Returns the icon name for `obj' (which will likely be a member of IconName), or None for the default.

◆ getMenu()

def getMenu (   self,
  obj 
)
Returns the menu structure for `obj' and the callback for when an item is clicked, typically self.objectMenuItem.
The menu structure is a list whose first element is the menu title, followed by values satisfying createMenu().
The callback take two arguments, the object associated with the menu and the text of the menu item clicked.
Here is the call graph for this function:

◆ getObjFiles()

def getObjFiles (   self,
  obj 
)
Get the paths to the files `obj' was loaded from. Returns [] if `obj' wasn't loaded from files but can be
saved to files, or the default None if it can't be saved to a file (ie. a transitive object with no data).

◆ getReprParamHelp()

def getReprParamHelp (   self,
  obj,
  reprtype 
)
Get the help text for the parameters for `obj' and representation type `reprtype'.
Here is the call graph for this function:

◆ getReprParams()

def getReprParams (   self,
  obj,
  reprtype 
)
Returns the list of ParamDef objects defining the parameters for the given given representation type.
Here is the caller graph for this function:

◆ getReprTypes()

def getReprTypes (   self,
  obj 
)
Return the ReprType identifiers for the valid representations of this object.
Here is the caller graph for this function:

◆ getScriptCode()

def getScriptCode (   self,
  obj,
  kwargs 
)
Return the Python code string to create, load, or initialize the given object. This is called by ScriptWriter
to write plugin-specific loading code to a script. The object `obj' is expected to be a SceneObject or
SceneObjectRepr instance whose plugin is the receiver object (ie. obj.plugin==self).

The `kwargs' value will contain important information about what code to generate:
 - "namemap" is keyed to the object->variable  dictionary used to determine what variable name refers to `obj'
   and other objects such as materials. This must be used to get variable names for all objects, simply
   declaring a new variable can lead to conflicts in other parts of the code.
 - "configSection" is True if code to configure an object is to be generated rather than creation code
 - "setMaterial" is True if the material for a rep object should be set in configuration code.
 - "scriptdir" may be present in `kwargs', if so then a script file is being generated and all file paths
   should be specified relative to the variable of the same name. A convenience function keyed to "convertPath"
   may be present in `kwargs' which accepts a path and returns code stating the path relative to "scriptdir".

Code should not assume these values are present always, use "kwargs.get()" with an appropriate default value.
The default implementation of this method provides the config code for a SceneObjectRepr object, other
functionality must be provided by overrides.

◆ init()

def init (   self,
  plugid,
  win,
  mgr 
)
Called when the manager is being initialized.

◆ loadObject()

def loadObject (   self,
  filename,
  name = None,
  kwargs 
)
Load SceneObject(s) from the file `filename' and gives the object the name `name' or one based off the filename
if this is None. Additional arguments can be given in later overrides of this method. The filename can be a
prefix for a number of filenames or one of multiple files needed to load the object, this isn't necessarily
the only file read. An IOError should be thrown if any loading cannot be completed correctly, other exceptions
if the data is incorrect. A SceneObject is returned or an iterable thereof if multiple objects can be loaded.
The return value varies by plugin and can be a Future object.
Here is the caller graph for this function:

◆ objectMenuItem()

def objectMenuItem (   self,
  obj,
  item 
)
Called when the right-click menu for `obj' is clicked on item `item'. Override this to handle such events.
Here is the caller graph for this function:

◆ removeFilesTask()

def removeFilesTask (   self,
  fileglob 
)
Deletes the files matching the regular expression string `fileglob' in a task.
Here is the caller graph for this function:

◆ removeObject()

def removeObject (   self,
  obj 
)
This should be called if another plugin takes responsibility for `obj' away from the current one.

◆ renameObjFiles()

def renameObjFiles (   self,
  obj,
  oldname,
  overwrite = False 
)
Rename files for object `obj' so that their names match the current name, previous name being `oldname'. This
will overwrite files only if `overwrite' is True, if not then an IOError is raised and nothing is done if files
would have to be overwritten. This requires that `obj' was previously loaded from or saved to files.

◆ saveObject()

def saveObject (   self,
  obj,
  path,
  overwrite = False,
  setFilenames = False,
  kwargs 
)
Save a SceneObject `obj' to the file or directory `path'. The plugin for `obj' need not necessarily be `self' if
a plugin wants to handle saving arbitrary objects of the right type. If the plugin must be `self' then raise a
ValueError if it's not. Files are written into the directory component of `path' which must exist, the name of
the files will be derived from that of `obj' if `path' is a directory and not a full filename. An IOError is
raised if files would be overwritten and `overwrite' is False, in which case no files must be created or altered.
The internal representation of `obj' should be changed to record what the saved filenames are if `setFilenames'
is True, it's up to the plugin to determine how. The return value varies by plugin and can be a Future object.
Here is the caller graph for this function:

◆ updateObjPropBox()

def updateObjPropBox (   self,
  obj,
  prop 
)
Updates the properties dialog 'prop' for SceneObject 'obj'. Usually only called by the UI when refreshing.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateReprPropBox()

def updateReprPropBox (   self,
  rep,
  prop 
)
Updates the properties dialog 'prop' for SceneObjectRepr 'Rep'. Usually only called by the UI when refreshing.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mgr

mgr

◆ name

name

◆ plugid

plugid

◆ win

win

The documentation for this class was generated from the following file: