ensight.core module

Parent Previous Next

The EnSight 'ensight.core' module

CEI provides ensight base objects located in the directory $CEI_HOME/ensight{version}/site_preferences/extensions/core. This module is loaded by default (see the __init__.py file for details) as the module ‘ensight.core’. In that directory are the base classes for various operations and many EnSight specific helper classes.

Python stdout/stderr redirection

In EnSight, the Python stdout and stderr systems are redirected into the Command window Python tab by default.  This operation is controls by objects in ensight.core. Specifically, ensight.core.ENS_stdout_instance and ENS_stderr_instance are the wrappers for the Python interpreter output. EnSight 9.0 has added ‘resume()’ and ‘suspend()’ methods which allows output to be redirected to the console instead of the command dialog Python tab. For example:

import ensight.core

ensight.core.ENS_stdout_instance.suspend()

ensight.core.ENS_stderr_instance.suspend()


will disable the redirection of Python text output to the Python tab window.

Core: Extension Base Classes

The core_extension

Basic extension of the command language.  All EnSight extensions inherit from this base class. The class provides basic metadata for the objects: Name, description, version, vendor, release date, etc.  It also provides basic support for parent/child hierarchies of extensions (e.g. for dependent extensions or simple display hierarchies). There is a notion that the core object will be called back whenever the EnSight license changes and when the EnSight GUI is considered to be fully up and running. The core of the language translation system is in this base class.  Every extension is given a name in EnSight command language and the system by which it can be called from command language and record its own actions in command language. Finally, there is a hook so that the user can call any extension from the command line and pass parameters to it using the '-E' option and the command language name of the extension.

type = “core”

The guibase_extension (core_extension)

Command language + common GUI elements.  This class includes some basic help features. The programmer can set a URL (external website) or HTML text as the help for this extension and can check for the existence of help as well as display it (possibly in a web browser).

type = “guibase”

Drag and drop support

The guibase_extension supports drag and drop operations.  There are a number of methods that must be overridden to make this work. When an extension wants to start a drag, it calls self.dragStart(widget,'str') or self.dragStart(widget,[ensobjlist]).  This will cause the target to have a string or a list of ensight objects potentially dropped on it. If the drag was dropped on one or more EnSight objects, self.dragHandler(str,objlist,executeflag) will be called on the extension.  This asks the extension if it is ok to apply the information in 'str' onto the objectlist.  The method should return True if the operation is allowed or False if it is not.  If executeflag is True, the operation should actually be performed by the extension.  The default implementation of guibase_extension.dragHandler() will interpret the string as a dictionary and call obj.setattrs(dict,record=1) on all of the objects in the object list.  It also filters the drop based on matches in the attribute keys in the source dictionary and the target objects.

There are a host of additional utilities for working with EnSight drag and drop object lists and other MIME types in the file guibase_extension.py.  The user is encouraged to explore the source for details.

The gui_extension (guibase_extension)

A full user-defined GUI

type = “gui”

Note: cmdExec/ has been overridden to include “activate_gui” message

Useful module functions:

Currently defined gui_event() messages include:

If desired, a gui_extension subclass can allow EnSight to try to handle the event by calling: ensight.int_message(message,targetlist) in the doGuiEvent() method. The subclass doGuiEvent() method gives the gui a chance to filter the events before EnSight sees them.

Note: cmdExec/ has been overridden to include “activate_gui”

The tool_extension (guibase_extension)

Base class for an EnSight user-defined tool.  A user-defined tool typically displays a top-level widget that the user can interact with. The widget can be modal or non-modal.

type = “tool”

The panel_extension (guibase_extension)

Base class for an EnSight user-defined panel.  A panel controls a widget that can be docked into the EnSight GUI. It's status will be remembered and EnSight will try to re-open them at startup. Generally this will be a non-modal panel that reflects some status of the session and allows for unique interaction. Panels can allow a single GUI instance or multiple instances of the GUI.

type = “panel”

The menu_extension (guibase_extension)

Base class for an EnSight popup menu.

type = “menu”

Note: the _info attribute is set to the “context” of the operation that started the menu operation. It is a dictionary. Some fields are pre-defined, depending on the EnSight RMB context.

The pre-defined _info fields are:


Common to all modes


pick: CVF_CURSOR_TOOL


pick: CVF_LINE_TOOL


pick: CVF_PLANE_TOOL


pick: CVF_CYLINDER_TOOL


pick: CVF_CONE_TOOL


pick: CVF_SPHERE_TOOL


pick: CVF_REVO_TOOL


pick: CVF_POLYLINE


pick: CVF_LEGEND


pick: CVF_ANNOT


pick: CVF_PART


pick: CVF_VIEWPORT


pick: CVF_PLOTTER


pick: CVF_IQ_QUERY_PROBE


Other useful menu functions

Note: with this latter function, the caller needs to create the _info dictionary. One special key has been defined: ‘mode’. If this key is present, it will override the current EnSight mode value for validFilter() filtering. 

d = {'pick': ensight.CVF_PART, 'item': partid, 'target': partobj, 
     'pos': (0,0,0), 'mousepos': (-1,-1) }
ensight.core.userdefinedmenus.doPopup(d)


The feature_extension (guibase_extension)


Base class for an EnSight feature dialog content area.

type = “feature”

This object represents an EnSight "feature".  It can include a "feature" icon for the feature toolbar, a collection of "action" icons for the edit toolbar and a panel that will be placed in the "edit properties" (FDE) dialog when the feature is active or when specific objects have edit selected on them. See feature_extension.py for details.