Eidolon
|
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) |
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
def __init__ | ( | self, | |
name | |||
) |
|
private |
|
private |
|
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.
|
private |
|
private |
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().
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).
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).
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.
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.
def cleanup | ( | self | ) |
Called when shutting down, use this to clear and close resources.
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.
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.
def createObjPropBox | ( | self, | |
obj | |||
) |
Creates a properties dialog box for SceneObject 'obj'. This should be a new instance of a QWidget subclass.
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.
def createReprPropBox | ( | self, | |
rep | |||
) |
Creates a properties dialog box for SceneObjectRepr 'rep'. This should be a new instance of a QWidget subclass.
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.
def getHelp | ( | self | ) |
Return a help text block.
def getIcon | ( | self, | |
obj | |||
) |
Returns the icon name for `obj' (which will likely be a member of IconName), or None for the default.
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.
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).
def getReprParamHelp | ( | self, | |
obj, | |||
reprtype | |||
) |
Get the help text for the parameters for `obj' and representation type `reprtype'.
def getReprParams | ( | self, | |
obj, | |||
reprtype | |||
) |
Returns the list of ParamDef objects defining the parameters for the given given representation type.
def getReprTypes | ( | self, | |
obj | |||
) |
Return the ReprType identifiers for the valid representations of this object.
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.
def init | ( | self, | |
plugid, | |||
win, | |||
mgr | |||
) |
Called when the manager is being initialized.
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.
def objectMenuItem | ( | self, | |
obj, | |||
item | |||
) |
Called when the right-click menu for `obj' is clicked on item `item'. Override this to handle such events.
def removeFilesTask | ( | self, | |
fileglob | |||
) |
Deletes the files matching the regular expression string `fileglob' in a task.
def removeObject | ( | self, | |
obj | |||
) |
This should be called if another plugin takes responsibility for `obj' away from the current one.
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.
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.
def updateObjPropBox | ( | self, | |
obj, | |||
prop | |||
) |
Updates the properties dialog 'prop' for SceneObject 'obj'. Usually only called by the UI when refreshing.
def updateReprPropBox | ( | self, | |
rep, | |||
prop | |||
) |
Updates the properties dialog 'prop' for SceneObjectRepr 'Rep'. Usually only called by the UI when refreshing.
mgr |
name |
plugid |
win |