Eidolon
|
Inherits TaskQueue.
Public Member Functions | |
def | __init__ (self, win, conf) |
def | taskExcept (self, ex, msg, title) |
def | getCurrentTask (self) |
def | runTasks (self, tasks, resFuture=None, isSequential=False) |
def | execScriptsTask (self, scripts) |
def | loadFilesTask (self, files) |
def | execBatchProgramTask (self, exefile, exeargs, kwargs) |
def | setTaskStatus (self, msgOrTask, progress=0, progressmax=0) |
def | getPlugin (self, name) |
def | getPluginNames (self) |
def | addRuntimePlugin (self, plug) |
def | createProjectObj (self, name, rootdir, projconst) |
def | deleteProjectObj (self) |
def | execScript (self, filename, updateLocals=True, tryHard=False) |
def | execLastScript (self) |
def | getUserAppDir (self) |
def | getUserAppFile (self, filename) |
def | getUserTempDir (self, dirname) |
def | quit (self) |
def | callThreadSafe (self, func, args, kwargs) |
def | proxyThreadSafe (self, func) |
def | checkFutureResult (self, future) |
def | logMsg (self, msgs, kwargs) |
def | logError (self, msgs, kwargs) |
def | showExcept (self, ex, msg='', title='Exception Caught', format_exc=None) |
def | showMsg (self, msg, title='Message', text=None, doLog=True, width=600, height=300) |
def | showTextBox (self, msg, title, text, width=600, height=300) |
def | showStatusBarMsg (self, msg, timeout=1000) |
def | showTimeDialog (self, doShow=None, timestepMin=None, timestepMax=None, timestepSpan=None) |
def | isTimeDialogShown (self) |
def | create2DView (self, name=None, constr=Camera2DView) |
def | createDockWidget (self, constr, title, w=200, h=200) |
def | setTimestep (self, ts) |
def | incTimestep (self) |
def | decTimestep (self) |
def | setTimeFPS (self, fps) |
def | setTimeStepsPerSec (self, sps) |
def | play (self) |
def | stop (self) |
def | addEventHandler (self, name, cb, isPriority=False, isPostEvent=False) |
def | removeEventHandler (self, cb) |
def | createCamera (self, name=None, isSecondary=False) |
def | removeCamera (self, camera) |
def | setSingleFreeCamera (self) |
def | setCameraController (self, controller) |
def | setCameraOrtho (self, ortho) |
def | setCameraWire (self, wire) |
def | setCameraZLocked (self, zlock) |
def | setCameraConfig (self, fov=None, nearclip=None, farclip=None) |
def | setCameraSeeAll (self) |
def | resetCamera (self) |
def | setAmbientLight (self, col) |
def | setBackgroundColor (self, col) |
def | setAxesType (self, axestype) |
def | setCenterType (self, centertype) |
def | saveScreenshot (self, filename, camera_or_widget=None, width=0, height=0, stereoOffset=0, tformat=TF_RGB24) |
def | saveTimestepScreenshots (self, fileprefix, stepvalue=1.0, start=0.0, end=None, camera_or_widget=None, width=0, height=0, extension='.png', stereoOffset=0, tformat=TF_RGB24) |
def | getSceneCode (self) |
def | repaint (self, renderHighQual=True) |
def | setAlwaysHighQual (self, val) |
def | addSceneObject (self, obj, category=None) |
def | addSceneObjectTask (self, obj, category=None) |
def | addSceneObjectRepr (self, rep) |
def | enumSceneObjects (self) |
def | enumSceneObjectReprs (self) |
def | enumAllObjects (self) |
def | findObject (self, name_or_fn) |
def | getUniqueObjName (self, name, spacer='_') |
def | getSceneAABB (self) |
def | updateSceneObjectRepr (self, rep, task=None) |
def | renameSceneObject (self, obj, newname) |
def | showBoundBox (self, rep, doShow=True, matname='BoundBoxes') |
def | isBoundBoxShown (self, rep) |
def | showHandle (self, rep, doShow=True) |
def | isHandleShown (self, rep) |
def | removeHandle (self, rep) |
def | setReprProps (self, rep, props) |
def | removeSceneObject (self, obj) |
def | removeSceneObjectRepr (self, rep) |
def | clearScene (self) |
def | loadTextureFile (self, filename) |
def | createTexture (self, name, width, height, depth, format) |
def | getTexture (self, name, isFilename=False) |
def | listTextureNames (self) |
def | removeTexture (self, texture) |
def | createLight (self, lighttype, name=None, position=vec3(), direction=vec3(1, 0, 0)) |
def | removeLight (self, light) |
def | getLight (self, name) |
def | loadGPUScriptFile (self, filename, progtype, name=None, profiles=None, lang=None, entry=None, ignoreError=False) |
def | createGPUProgram (self, name, progtype, src=None, profiles=None, lang=None, entry=None) |
def | listGPUProgramNames (self, progtype=None) |
def | getGPUProgram (self, name) |
def | createMaterial (self, matname) |
def | getMaterial (self, matname) |
def | listMaterialNames (self) |
def | removeMaterial (self, mat) |
def | applyMaterial (self, mat) |
def | cloneMaterial (self, mat, name=None) |
def | createSpectrum (self, specname) |
def | getSpectrum (self, specname) |
def | listSpectrumNames (self) |
def | cloneSpectrum (self, spec, name=None) |
def | removeSpectrum (self, spec) |
Static Public Attributes | |
mgrName | |
Private Member Functions | |
def | _windowConnect (self) |
def | _updateUI (self) |
def | _updateManagedObjects (self) |
def | _mousePressHandleCheck (self, e) |
def | _mouseMoveHandleCheck (self, e) |
def | _mouseReleaseHandleCheck (self, e) |
def | _keyPressEvent (self, e) |
def | _processTasks (self) |
def | _playerThread (self) |
def | _repaintEvent (self, _) |
def | _triggerEvent (self, name, args) |
def | _repaintHighQual (self) |
def | _collect (self) |
def | _newProjectButton (self) |
def | _newSpectrumButton (self) |
def | _newMaterialButton (self) |
def | _newLightButton (self) |
def | _removeObjectButton (self) |
def | _renameObjectButton (self) |
def | _clearSceneButton (self) |
def | _cloneAssetButton (self) |
def | _removeAssetButton (self) |
def | _openProjectButton (self) |
def | _openScriptButton (self) |
def | _rerunScriptButton (self) |
def | _saveProjectButton (self) |
def | _saveScriptButton (self) |
def | _loadTextureButton (self) |
def | _loadGPUScriptButton (self) |
def | _saveScreenshotAction (self) |
The manager object for scene objects, assets, and UI. It represents the link between the UI and the scene itself, containing the code to change the scene as directed by interaction with the UI, ie. part of the controller part of MVC. Most of the functionality for performing operatiosn and calculating data is defined in plugins and controller objects instead which include both UI and algorithm code. The purpose of the SceneManager is to be the central point of interaction with the system without becoming a god object by including too much functionality. It also manages the task thread and the playing of time-dependent data.
def __init__ | ( | self, | |
win, | |||
conf | |||
) |
|
private |
|
private |
Clones the selected asset.
|
private |
|
private |
Keypress event handler for the render widget.
|
private |
|
private |
Brings up the file choose dialog and then loads a texture.
|
private |
Checks if a handle has been clicked on, sending it the event and returning true if so. This assumes this function is the first event handler for moves.
|
private |
Checks if a mouse click is on a handle, if so send the event to the handle and return true so no other events are processed. This assumes this function is the first event handler for clicks.
|
private |
|
private |
Opens the UI dialog to choose a new light name, and then creates a new light.
|
private |
Opens the UI dialog to choose a new material name, and then creates a new material.
|
private |
|
private |
Opens the UI dialog to choose a new spectrum name, and then creates a new spectrum.
|
private |
|
private |
|
private |
Thread implementing timestep animation, this must be executed in a daemon thread.
|
private |
Takes tasks from the queue and runs them. This is executed in a separate daemon thread and should not be called.
|
private |
Removes the selected asset.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Executed before each redraw, this is used to set scene objects/figures that are managed by this object.
|
private |
|
private |
Initializes all the UI control code, mostly connecting slots with action functions.
def addEventHandler | ( | self, | |
name, | |||
cb, | |||
isPriority = False , |
|||
isPostEvent = False |
|||
) |
def addRuntimePlugin | ( | self, | |
plug | |||
) |
Add a plugin to the system at runtime. Typically plugins are loaded at load time and their init() method just after the SceneManager is created. This method is used to load plugins which can be initialized at a later time.
def addSceneObject | ( | self, | |
obj, | |||
category = None |
|||
) |
Adds the SceneObject instance to the scene. If `obj' has no plugin, the appropriate default is assigned. If the name of `obj' is not unique, it will be changed to a unique name by suffixing a number. (`category' not used). The `obj' value can be either a SceneObject or a Future which eventually contains one.
def addSceneObjectRepr | ( | self, | |
rep | |||
) |
Adds the SceneObjectRepr instance to the scene.
def addSceneObjectTask | ( | self, | |
obj, | |||
category = None |
|||
) |
Adds a task to the task queue which adds `obj' to the scene.
def applyMaterial | ( | self, | |
mat | |||
) |
Applies the given material to any representation that uses it by invoking applyMaterial() on each.
def callThreadSafe | ( | self, | |
func, | |||
args, | |||
kwargs | |||
) |
Forces 'func' to be called by the main/UI thread, which is necessary for many graphics operations. The values 'args' and 'kwargs' are used as the arguments, and the return value of the function is returned when the main thread has completed the call. If there is no window then the function is called directly in this thread. This blocks until the call completes, and is both thread-safe and thread-reentrant if there is a UI window.
def checkFutureResult | ( | self, | |
future | |||
) |
Enqueues a task to check the resulting value in Future `future', showing an exception if one is raised.
def clearScene | ( | self | ) |
Removes any Project and all SceneObject objects from the scene.
def cloneMaterial | ( | self, | |
mat, | |||
name = None |
|||
) |
Creates a new material with all the properties of the given material 'mat'. The new material's name is 'name' or a generated one if 'name' is None. The argument 'mat' may be a material object or a material's name.
def cloneSpectrum | ( | self, | |
spec, | |||
name = None |
|||
) |
Creates a new spectrum from `spec' (either name or Spectrum object). The new spectrum's name is `name' or a generated one if `name' is None.
def create2DView | ( | self, | |
name = None , |
|||
constr = Camera2DView |
|||
) |
Create a 2D view, add it to a dock in the main window, and return the dock object. This expects `constr' to be a callable accepting self and a newly created Camera object, and returning the 2D view object. By default this is Camera2DView so without modification this method creates a generic 2D view, the expectation is that `constr' can be set to a subtype of Camera2DView although any widget subtype with the expected signature would work.
def createCamera | ( | self, | |
name = None , |
|||
isSecondary = False |
|||
) |
def createDockWidget | ( | self, | |
constr, | |||
title, | |||
w = 200 , |
|||
h = 200 |
|||
) |
Create a widget and add it to a dock widget in the main window, returning the dock object. This expects `constr' to be callable with no arguments and return the widget object to add to the dock, it will be called in the main thread. If self.win is None then this method instead does nothing.
def createGPUProgram | ( | self, | |
name, | |||
progtype, | |||
src = None , |
|||
profiles = None , |
|||
lang = None , |
|||
entry = None |
|||
) |
def createLight | ( | self, | |
lighttype, | |||
name = None , |
|||
position = vec3() , |
|||
direction = vec3(1,0,0) |
|||
) |
def createMaterial | ( | self, | |
matname | |||
) |
Creates a new material with the given name, which will be made unique amongst material names.
def createProjectObj | ( | self, | |
name, | |||
rootdir, | |||
projconst | |||
) |
Creates a new Project object, saving the old one if it existed. The new project object is created by calling `projconst' with `name', `rootdir', and self as the arguments. This callable is expected to be a constructor that returns a Project type.
def createSpectrum | ( | self, | |
specname | |||
) |
def createTexture | ( | self, | |
name, | |||
width, | |||
height, | |||
depth, | |||
format | |||
) |
def decTimestep | ( | self | ) |
def deleteProjectObj | ( | self | ) |
def enumAllObjects | ( | self | ) |
Yields a SceneObject followed by each of its representations, then the same for every subsequent SceneObject.
def enumSceneObjectReprs | ( | self | ) |
Yields each SceneObjectRepr present in the scene.
def enumSceneObjects | ( | self | ) |
Yields each SceneObject added to the scene.
def execBatchProgramTask | ( | self, | |
exefile, | |||
exeargs, | |||
kwargs | |||
) |
Executes the program `exefile' with the string arguments `exeargs'. This is done in a task so the result is a Future object which will contain a (returncode,output) pair if the program is run successfully, or an exception otherwise. The integer return code is taken from the program, in the usual case 0 indicating a correct execution and any other value indicating failure, and the output is a string of the merged stdout and stderr text. If the program requires input it will deadlock, this is a batch operation routine only. A keyword value `timeout' can be given indicating how long to wait for the program in seconds before killing it, otherwise the task will wait forever.
def execLastScript | ( | self | ) |
Rerun the last script executed with the arguments passed to execScript().
def execScript | ( | self, | |
filename, | |||
updateLocals = True , |
|||
tryHard = False |
|||
) |
Executes the given script file using internal environment, updates local/console variables if `updateLocals'.
def execScriptsTask | ( | self, | |
scripts | |||
) |
Enqueues a task which will execute the given script files in sequence when run. If a directory is present in `scripts' containing a .py file of the same, the file is assumed to be a project script and is run instead.
def findObject | ( | self, | |
name_or_fn | |||
) |
Finds an object with the given name or which matches the given selector function.
def getCurrentTask | ( | self | ) |
Returns the current Task object if called within the task execution thread, None otherwise.
def getGPUProgram | ( | self, | |
name | |||
) |
def getLight | ( | self, | |
name | |||
) |
def getMaterial | ( | self, | |
matname | |||
) |
Returns the material object with the given, or None if not found.
def getPlugin | ( | self, | |
name | |||
) |
Returns the named plugin if found, None otherwise.
def getPluginNames | ( | self | ) |
Returns the names of loaded plugins.
def getSceneAABB | ( | self | ) |
Returns the AABB containing all visible repr objects.
def getSceneCode | ( | self | ) |
Returns the code representation of the current scene as can be constructed by plugins.
def getSpectrum | ( | self, | |
specname | |||
) |
Returns the spectrum object with the given, or None if not found.
def getTexture | ( | self, | |
name, | |||
isFilename = False |
|||
) |
Returns the first texture found with the given name, or filename if 'isFilename' is true. If no texture is found, returns None.
def getUniqueObjName | ( | self, | |
name, | |||
spacer = '_' |
|||
) |
def getUserAppDir | ( | self | ) |
Returns the per-user application directory as defined by ConfVars.userappdir in the config object.
def getUserAppFile | ( | self, | |
filename | |||
) |
Returns the path to a file named `filename' in the per-user application directory. This file may not exist.
def getUserTempDir | ( | self, | |
dirname | |||
) |
Create a temporary directory (deleted on exit) in the per-user application directory and return its path.
def incTimestep | ( | self | ) |
def isBoundBoxShown | ( | self, | |
rep | |||
) |
Returns true if the bound box for 'rep' is visible.
def isHandleShown | ( | self, | |
rep | |||
) |
def isTimeDialogShown | ( | self | ) |
Returns True if the time dialog box is visible.
def listGPUProgramNames | ( | self, | |
progtype = None |
|||
) |
def listMaterialNames | ( | self | ) |
Returns a list of all material names.
def listSpectrumNames | ( | self | ) |
Returns a list of all material names.
def listTextureNames | ( | self | ) |
Returns a list of all texture names.
def loadFilesTask | ( | self, | |
files | |||
) |
Loads the given data files, script files, or directories. Each file in `files' is loaded in the order given. If the file is a Python script, this is executed. If a project directory (ie. a directory containing a Python script with the same name) the contained script file is executed. For any other file, the first plugin whose acceptFile() method returns true is tasked to load the file through its loadObject() method.
def loadGPUScriptFile | ( | self, | |
filename, | |||
progtype, | |||
name = None , |
|||
profiles = None , |
|||
lang = None , |
|||
entry = None , |
|||
ignoreError = False |
|||
) |
def loadTextureFile | ( | self, | |
filename | |||
) |
Loads the given texture file and adds it to the asset list in the UI.
def logError | ( | self, | |
msgs, | |||
kwargs | |||
) |
Writes a log entry composed of the string representations of the members of 'msgs' as well as to stderr. If 'nl' is present in 'kwargs' and is False, no newline appears at the end of the stderr write.
def logMsg | ( | self, | |
msgs, | |||
kwargs | |||
) |
Writes a log entry composed of the string representations of the members of 'msgs' as well as to stdout. If 'nl' is present in 'kwargs' and is False, no newline appears at the end of the stdout write.
def play | ( | self | ) |
Play timestepping animation, do nothing if the steps/s is too large or frames/s is too small.
def proxyThreadSafe | ( | self, | |
func | |||
) |
Returns a proxy function which calls `func' in the main thread when invoked. This method can be a decorator.
def quit | ( | self | ) |
Quit the program after all tasks have completed. Ensures thread-safety with the UI thread.
def removeCamera | ( | self, | |
camera | |||
) |
def removeEventHandler | ( | self, | |
cb | |||
) |
def removeHandle | ( | self, | |
rep | |||
) |
Remove and delete the handle(s) for representation `rep'.
def removeLight | ( | self, | |
light | |||
) |
def removeMaterial | ( | self, | |
mat | |||
) |
Removes the material object from the scene and UI.
def removeSceneObject | ( | self, | |
obj | |||
) |
Removes the SceneObject instance an its representations from the scene.
def removeSceneObjectRepr | ( | self, | |
rep | |||
) |
Removes the SceneObjectRepr instance from the scene.
def removeSpectrum | ( | self, | |
spec | |||
) |
def removeTexture | ( | self, | |
texture | |||
) |
Removes the given texture object from the scene and UI.
def renameSceneObject | ( | self, | |
obj, | |||
newname | |||
) |
def repaint | ( | self, | |
renderHighQual = True |
|||
) |
Forces the scene to redraw. if `renderHighQual' is true a high quality render is done.
def resetCamera | ( | self | ) |
Resets the camera's rotational values but does not move its look-at position.
def runTasks | ( | self, | |
tasks, | |||
resFuture = None , |
|||
isSequential = False |
|||
) |
Executes the given list of tasks if `isSequential' or if the call was made in the task execution thread. When all the tasks have been executed, the Future object 'resFuture' is queried for its value, which is returned. If neither condition is true the tasks are added to the task queue instead and `resFuture' is returned. The argument `resFuture' is expected to be a Future object which the tasks will provide an object for, or None. This allows functions to add multiple tasks to the queue and then return a Future object, as well as permit tasks to call such functions and execute tasks immediately and thus avoid deadlock.
def saveScreenshot | ( | self, | |
filename, | |||
camera_or_widget = None , |
|||
width = 0 , |
|||
height = 0 , |
|||
stereoOffset = 0 , |
|||
tformat = TF_RGB24 |
|||
) |
def saveTimestepScreenshots | ( | self, | |
fileprefix, | |||
stepvalue = 1.0 , |
|||
start = 0.0 , |
|||
end = None , |
|||
camera_or_widget = None , |
|||
width = 0 , |
|||
height = 0 , |
|||
extension = '.png' , |
|||
stereoOffset = 0 , |
|||
tformat = TF_RGB24 |
|||
) |
def setAlwaysHighQual | ( | self, | |
val | |||
) |
def setAmbientLight | ( | self, | |
col | |||
) |
Sets the scene's ambient light value.
def setAxesType | ( | self, | |
axestype | |||
) |
Sets the axes type and handles finalizing the necessary figures.
def setBackgroundColor | ( | self, | |
col | |||
) |
Sets the scene's background color value by calling setBGColor() on all primary cameras.
def setCameraConfig | ( | self, | |
fov = None , |
|||
nearclip = None , |
|||
farclip = None |
|||
) |
def setCameraController | ( | self, | |
controller | |||
) |
Sets the current camera controller to the given one, setting up cameras as needed must be done elsewhere.
def setCameraOrtho | ( | self, | |
ortho | |||
) |
def setCameraSeeAll | ( | self | ) |
Tells the current controller to reposition itself to see every visible object in the scene.
def setCameraWire | ( | self, | |
wire | |||
) |
def setCameraZLocked | ( | self, | |
zlock | |||
) |
def setCenterType | ( | self, | |
centertype | |||
) |
Sets the center indicator type and handles finalizing the necessary figures.
def setReprProps | ( | self, | |
rep, | |||
props | |||
) |
Sets various properties of `rep' in a thread-safe way. If `parent' is present, set `rep' to have this object as its parent. If `trans' is present, set `rep' to have this transform. The purpose of this method is to provide a convenient thread-safe way of setting these properties, specifically in auto-generated scripts.
def setSingleFreeCamera | ( | self | ) |
Creates main camera if none exist, creates a AxesCameraController object which is assed to self.controller and self.singleController, and is then returned. This object is used to control the main camera as the single view.
def setTaskStatus | ( | self, | |
msgOrTask, | |||
progress = 0 , |
|||
progressmax = 0 |
|||
) |
Sets the task status bar of the window if present, otherwise does nothing.
def setTimeFPS | ( | self, | |
fps | |||
) |
def setTimestep | ( | self, | |
ts | |||
) |
Set the timestep `ts' for every representation clamped within the range [self.timestepMin,self.timestepMax].
def setTimeStepsPerSec | ( | self, | |
sps | |||
) |
def showBoundBox | ( | self, | |
rep, | |||
doShow = True , |
|||
matname = 'BoundBoxes' |
|||
) |
Controls the drawing of bound boxes of representations. Given the representation object 'rep', a box using the given material is show if 'doShow' is true, if 'doShow' is false an existing boundbox is hidden or nothing is done if one wasn't already visible. This method is thread-safe
def showExcept | ( | self, | |
ex, | |||
msg = '' , |
|||
title = 'Exception Caught' , |
|||
format_exc = None |
|||
) |
Shows the given exception and writes information to the log file.
def showHandle | ( | self, | |
rep, | |||
doShow = True |
|||
) |
Show or hide the control handle(s) for the representation `rep'. There may be just the one transform handle or multiple point handles (or other custom types) so this routine will show or hide all at once. This method is thread-safe.
def showMsg | ( | self, | |
msg, | |||
title = 'Message' , |
|||
text = None , |
|||
doLog = True , |
|||
width = 600 , |
|||
height = 300 |
|||
) |
Shows the given message in a message window if the UI is present, and writes it to the log file.
def showStatusBarMsg | ( | self, | |
msg, | |||
timeout = 1000 |
|||
) |
Set the status bar message to `msg' with a timeout in milliseconds before it disappears.
def showTextBox | ( | self, | |
msg, | |||
title, | |||
text, | |||
width = 600 , |
|||
height = 300 |
|||
) |
Shows the given `text' string in a large textbox widget in a window, this is intended for large text blocks.
def showTimeDialog | ( | self, | |
doShow = None , |
|||
timestepMin = None , |
|||
timestepMax = None , |
|||
timestepSpan = None |
|||
) |
Set the time dialog visibility and settings. If 'doShow' is None then a check is made to see if there are time-dependent representations. If 'doShow' is a boolean value, then visibility is set to that value. This also sets the `timestepMin' and `timestepMax' member.
def stop | ( | self | ) |
Stop animation.
def taskExcept | ( | self, | |
ex, | |||
msg, | |||
title | |||
) |
def updateSceneObjectRepr | ( | self, | |
rep, | |||
task = None |
|||
) |
Causes the SceneObjectRepr object to update its data through prepareBuffers() and update(). Updating occurs in a task which first calls rep.prepareBuffers() in its thread expecting `rep' to setup all data to be loaded into figures, then rep.update() is called in the main thread where `rep' is expected to create figures and load them with data. Once this is done the UI refreshes itself, the scene redraws, and the objectUpdated event is sent.
ambientColor |
backgroundColor |
bbmap |
cameras |
conf |
controller |
evtHandler |
handlemap |
imageplugin |
lastScript |
lightcontrol |
lights |
matcontrol |
mats |
meshplugin |
|
static |
multiController |
objs |
player |
playerEvent |
progcontrol |
programs |
project |
scene |
scriptlocals |
singleController |
specs |
taskthread |
textures |
timeFPS |
timestep |
timestepMax |
timestepMin |
timestepSpan |
timeStepsPerSec |
updatethread |
win |