Base class of all data objects, modules, and editors. More...
#include <HxBase.h>
Inherits McInterface.
Public Types |
Public Member Functions | |
virtual void | setLabel (const QString &label) |
Set a unique label or name for the object. More... | |
virtual void | setDisplayLabel (const QString &displayLabel) |
Set a display label for the object. More... | |
const QString & | getDisplayLabel () const |
Returns the object's display label. More... | |
const QString & | getLabel (bool withDoubleQuotes=false) const |
Returns the object's label. More... | |
const char * | getName (bool withDoubleQuotes=false) const |
This is identical to the object's label. More... | |
const QString & | getCamelCaseLabel () const |
Return the Camel Case label of the object. More... | |
virtual bool | isCamelCaseSupported () const |
Indicates whether the object has a Camel Case label or not. More... | |
void | composeLabel (const QString &otherLabel, const QString &replacement) |
Composes a label from otherLabel by replacing the suffix. More... | |
virtual void | setViewerMask (int mask, int masterMask=0xffffffff) |
Defines in which viewer geometry is visible. More... | |
int | getViewerMask () const |
Returns viewer mask ANDed with viewer master mask. More... | |
int | getViewerMaskAsIs () const |
Returns the viewer mask of the object. More... | |
int | getViewerMasterMask () const |
Returns the viewer master mask of the object. More... | |
void | copyViewerVisibility (unsigned int fromViewerId, unsigned int toViewerId) |
Sets the viewer visibility flag of the viewer fromViewerId to toViewerId . More... | |
void | showGeom (SoNode *node, HxSpatialData *controllData) |
Adds geometry to the viewers. More... | |
virtual void | showGeom (SoNode *node) |
Calls showGeom(node,0); overridden in HxModule, HxEditor. More... | |
void | hideGeom (SoNode *node) |
Removes geometry node from the viewers. More... | |
virtual void | clipGeom (HxPlanarModBase *planarMod, int viewerMask=0xffff) |
Clip geometry by planar module. More... | |
virtual void | unclipGeom (HxPlanarModBase *planarMod) |
Unset geometry clipping. More... | |
bool | isClipped () const |
Returns true if an HxPlanarMod is clipping this object. More... | |
int | getClipperMask (HxPlanarModBase *planarMod) |
Returns viewer mask in which planarMod clips this object. More... | |
virtual int | parse (Tcl_Interp *interpreter, int argc, char **argv) |
Tcl command interface of the object. More... | |
void | setControllingData (HxSpatialData *data) |
Specifies the data object from which the local transformation is taken from. More... | |
HxSpatialData * | getControllingData () const |
Returns data object which defines the local coord transform. More... | |
void | showPinButtons (bool showIt) |
Hides or shows pin buttons of all ports. More... | |
int | getNumPorts () const |
Returns number of ports. More... | |
HxPort * | getPort (int i) const |
Returns specified port. More... | |
HxPort * | getPort (const QString &name) const |
Returns port corresponding to given name. More... | |
HxPort * | getPortByLabel (const QString &label) const |
Returns port with the given label. More... | |
HxPort * | getPortOfType (const McTypeInfo *type, bool ignoreInvisible=true) const |
Returns the first port corresponding to given type. More... | |
HxINTERNAL void | saveTclMemberVars (FILE *fp) |
Needed internally for save network. More... | |
bool | getTclMemberVar (const char *name, QString &result) const |
Gets value of tcl member variable with name. More... | |
void | setTclMemberVar (const char *name, const char *value) |
sets value of tcl member variable with name More... | |
HxINTERNAL int | setTclMemberVarSerialize (const char *name, bool serialize) |
Save this tcl member variable in network file (standard) or not. More... | |
SoSeparator * | getSeparator () const |
Returns the separator containing all the geometry of the object. More... | |
virtual void | checkRemoteMode () |
Checks if VR mode or TeamWork mode is activated. More... | |
virtual HxINTERNAL int | getGeometryWeight () |
Get geometry weight. More... | |
void | setRequiresPolygonOffset (bool value) |
Sets or unsets interest in a global polygon offset. More... | |
bool | requiresPolygonOffset () const |
Checks if this object requires a global polygon offset or not. More... | |
virtual void | setDisplayViewers (const std::set< int > &visibleAreas) |
Restricts the rendering of this module to a specific list of VR screens or viewers. More... | |
void | setDisplayViewers (const McDArray< int > &visibleAreas) |
Provided for convenience. More... | |
void | getDisplayViewers (std::set< int > &visibleAreas) const |
Return the list of of VR screens or viewers which are allowed to display the representation of this module. More... | |
void | setDisplay (HxDisplay *display) |
Sets class managing projection and shadowing options. More... | |
HxDisplay * | getDisplay () |
Gets class managing projection and shadowing options. More... | |
virtual const QxBaseNotifier * | getNotifier () const |
To get the associated Qt notifier which enables to track all Qt signal emitted by HxBase objects. More... | |
QxGlobalDisplayUnitsChangesListener< HxBase > * | getDisplayUnitsChangesListener () const |
Units management. More... | |
virtual void | globalUnitChanged (const int &oldUnit, const int &newUnit) |
Called by m_displayUnitsChangesListener when a global display unit has changed. More... | |
virtual void | globalCoordinatesUnitChanged (const int &oldUnit, const int &newUnit) |
Called by m_displayUnitsChangesListener when the global coordinates display unit has changed. More... | |
bool | getFlag (unsigned int flag) const |
Returns flag value. More... | |
void | setFlag (unsigned int flag, bool value) |
Sets flag with corresponding value. More... | |
HxINTERNAL HxPort * | createOnTheFlyPortFromClassName (const QString &className, const QString &name, const QString &label) |
Create a port of determined type. More... | |
virtual HxINTERNAL HxPort * | createOnTheFlyPort (const HxPortTypeInfo *typeInfo, const QString &name, const QString &label) |
Create a port of determined type. More... | |
HxINTERNAL void | removeOnTheFlyPort (HxPort *port) |
Remove an on-the-fly port. More... | |
HxINTERNAL void | removeAllOnTheFlyPorts () |
Remove all on-the-fly ports. More... | |
HxINTERNAL void | internalSetLabel (const char *label) |
internal use only More... | |
void | notifyPortAdded (HxPort *port) |
Called to notify when a port has been added/removed to/from the HxBase instance. More... | |
Static Public Member Functions | |
static QString | convertToCamelCase (const char *name) |
Converts a nil terminated C-style string to Camel Case wrt Avizo convention. More... | |
static int | getDefaultViewerMask () |
Returns the viewer mask, which had been used to initialize viewerMask . More... | |
static int | getNumInstances () |
Returns the total number of class instances. More... | |
static void | addForbiddenLabel (const char *forbiddenLabel) |
Adds a forbidden label, stores a copy of the string. More... | |
static void | removeForbiddenLabel (const char *forbiddenLabel) |
Removes a forbidden label. More... | |
static void | removeAllForbiddenLabels () |
Removes all forbidden labels. More... | |
static bool | polygonOffsetRequired () |
Returns true if a global polygon offset is needed by at least one module. More... | |
static QString | translate (const char *context, const char *sourceText, const char *disambiguation=0) |
Returns the translation text for sourceText, by querying the installed translation files. More... | |
Protected Member Functions | |
HxINTERNAL | HxBase (McInterfaceOwner *owner=0, QxBaseNotifier *notifier=0) |
Constructor. More... | |
virtual HxINTERNAL | ~HxBase () |
Destructor. More... | |
void | useWorldCoords (int trueOrFalse=1) |
Derived classes should call this if they want to use world coords. More... | |
virtual void | updateTransform () |
Inserts transform nodes into root as necessary. More... | |
virtual void | projectionActivated () |
This method is called whenever a projection is activated. More... | |
virtual void | projectionDeactivated () |
This method is called whenever a projection is deactivated. More... | |
bool | containsNode () |
Checks if the scene graph managed by this instance contains a node. More... | |
HxINTERNAL void | deleteSceneGraph () |
Remove root from #theController and delete root and raSwitch . More... | |
virtual void | addRootToController (SoSeparator *rootSep, int rootViewerMask=0xffff) |
Add rootSep to a controller. More... | |
virtual void | removeRootFromController (SoSeparator *rootSep) |
Remove rootSep from a controller. More... | |
virtual int | renderAreaSwitchCB (SoSwitch *traversingSwitch, HxRenderArea *renderArea, SoAction *action) |
The render area switch callback. More... | |
HxINTERNAL int | handleRenderAreaSwitchTraversing (const std::set< int > &visibleAreas, SoSwitch *traversingSwitch, HxRenderArea *renderArea, SoAction *action) |
This method is called by renderAreaSwitchCB(SoSwitch* traversingSwitch, HxRenderArea* renderArea, SoAction* action) in order to know which child has to be traversed according to visibleAreas . More... | |
HxINTERNAL void | handleNewDisplayViewersList (std::set< int > &visibleAreas) |
This helper is called by setDisplayViewers(const std::set<int>& visibleAreas) More... | |
virtual void | initScenegraph () |
Initializes the scene graph. More... | |
Static Protected Member Functions | |
static int | staticParse (ClientData data, Tcl_Interp *interpreter, int argc, char **argv) |
Interface to Tcl scripting language. More... | |
static HxINTERNAL int | renderAreaSwitchStaticCB (void *localUserData, HxBase *moduleBase, SoSwitch *traversingSwitch, HxRenderArea *renderArea, SoAction *action) |
The render area switch callback. More... | |
static HxINTERNAL void | raSwitchOnSensorCB (void *data, SoSensor *sensor) |
Use to setting up some necessary OIV cache properties when raSwitch is started. More... | |
Base class of all data objects, modules, and editors.
It provides the following features:
HxBase
object is created a global Tcl command is registered with the same name as the object itself. By invoking this command the parse method is called. This method checks the arguments of the command and triggers the required actions. It is ensured that every base object has a unique name.#theController
. In this way they can cause all other objects to be transformed simultaneously. Finally, the local coordinate system is defined by a transformation matrix which can be stored for each object of type HxSpatialData. This matrix can be modified interactively using the transformation editor. The same matrix can be shared between multiple data objects using the method setControllingData(). For example, typically all display modules attached to a data object will share its transformation matrix, so that the geometry generated by these modules is transformed when you transform the data itself. NOTE: If you derive your class from HxBase
you must use special macros in your class declaration and definition.
enum HxBase::Flags |
Flags.
Enumerator | |
---|---|
CAN_COPY_VIEWER_VISIBILITY |
Object can be clipped by other modules. Default is true |
CAN_HAVE_CONSOLE_COMPLETION |
Object visibility can be copied from one viewer to another. Checked in HxBase::copyViewerVisibility. Default is true. |
CONSOLE_COMPLETION_ACTIVATED |
Object can have console completion. Default is true. |
NUM_HXBASE_FLAGS |
The console completion is currently activated on object. Default is false. The console completion will be automatically activated/deactivated when adding/removing an object to/from |
|
protected |
Constructor.
Constructor is protected - this is an abstract class.
To add signals/slots for inherited classes, a new class QxNewClassNotifier which inherits from QxBaseNotifier must be implemented. Then the notifier must be given to the constructor of HxBase, and the function getNotifier() must be overridden. In inherited class, getNotifier() must return the type of the new notifier.
|
protectedvirtual |
Destructor.
Destructor, declared virtual.
|
static |
Adds a forbidden label, stores a copy of the string.
forbiddenLabel | The forbidden label. |
|
protectedvirtual |
Add rootSep
to a controller.
When adding rootSep
, it's possible to set its default visibility by setting rootViewerMask
. This method can be re-implemented in case you would like to use your own controller.
rootSep | The root separator. |
rootViewerMask | The root viewer mask (default value is 0xffff). |
|
virtual |
Checks if VR mode or TeamWork mode is activated.
|
virtual |
Clip geometry by planar module.
You can optionally specify in which viewer (viewerMask
) this object must be clipped by planarMod
.
planarMod | The planar mod. |
viewerMask | The viewer mask (default value is 0xffff). |
void HxBase::composeLabel | ( | const QString & | otherLabel, |
const QString & | replacement | ||
) |
Composes a label from otherLabel
by replacing the suffix.
Example:
otherLabel:
motor.amreplacement:
"-simplified" => "motor-simplified" otherLabel | The other label. |
replacement | The replacement. |
|
protected |
Checks if the scene graph managed by this instance contains a node.
|
static |
Converts a nil terminated C-style string to Camel Case wrt Avizo convention.
This class method converts the input parameter to Camel Case with respect to internal conventions. First letter of the result string is lower case. All blank and '-' characters are removed from the string; words those characters were separating are lower cased, excepted their first letter which is upper cased. Other special characters are replaced by '_'; several '_' following one after the other are reduced to only one '_'. First letter following a '_' is upper cased. For example: input string: "Ortho Slice" *** result: "orthoSlice" input string: "Ortho-Slice" *** result: "orthoSlice" input string: "OrthoSlice" *** result: "orthoSlice" input string: "Ortho@Slice" *** result: "ortho_Slice" input string: "Ortho@@@Slice" *** result: "ortho_Slice"
name | C-style nil terminated string to convert. |
void HxBase::copyViewerVisibility | ( | unsigned int | fromViewerId, |
unsigned int | toViewerId | ||
) |
Sets the viewer visibility flag of the viewer fromViewerId
to toViewerId
.
It enables to show/hide object of the pool for a particular viewer.
fromViewerId | The src viewer id. |
toViewerId | The dest viewer id. |
|
virtual |
Create a port of determined type.
This method is intended to be overridden (HxObject and HxEditor do). By default, it will throw an exception as HxBase can't instantiate a port.
typeInfo | HxPortTypeInfo structure referring to the C++ class name of port to instantiate. |
name | Name of the port. (tcl name) |
label | of the port. (text displayed py the port Gui) |
HxINTERNAL HxPort* HxBase::createOnTheFlyPortFromClassName | ( | const QString & | className, |
const QString & | name, | ||
const QString & | label | ||
) |
Create a port of determined type.
className | string containing the C++ class name of port to instantiate. |
name | Name of the port. (tcl name) |
label | of the port. (text displayed by the port Gui) |
|
protected |
Remove root
from #theController
and delete root
and raSwitch
.
const QString& HxBase::getCamelCaseLabel | ( | ) | const |
Return the Camel Case label of the object.
int HxBase::getClipperMask | ( | HxPlanarModBase * | planarMod | ) |
Returns viewer mask in which planarMod
clips this object.
planarMod | The planar mod. |
planarMod
. HxSpatialData* HxBase::getControllingData | ( | ) | const |
Returns data object which defines the local coord transform.
|
static |
Returns the viewer mask, which had been used to initialize viewerMask
.
Note that the default viewer masks differ for different products e.g. Amira, Avizo
HxDisplay* HxBase::getDisplay | ( | ) |
Gets class managing projection and shadowing options.
|
inline |
Returns the object's display label.
QxGlobalDisplayUnitsChangesListener<HxBase>* HxBase::getDisplayUnitsChangesListener | ( | ) | const |
Units management.
Return display units changes listener.
void HxBase::getDisplayViewers | ( | std::set< int > & | visibleAreas | ) | const |
Return the list of of VR screens or viewers which are allowed to display the representation of this module.
If the size of the returned list is 0, it means that all viewers are allowed to display the representation.
visibleAreas | The visible areas. |
bool HxBase::getFlag | ( | unsigned int | flag | ) | const |
Returns flag value.
flag | The flag. |
|
virtual |
Get geometry weight.
const QString& HxBase::getLabel | ( | bool | withDoubleQuotes = false | ) | const |
Returns the object's label.
withDoubleQuotes | If it is set to true, a quotation mark is added as first and last character of the label. The default value is false. |
const char* HxBase::getName | ( | bool | withDoubleQuotes = false | ) | const |
This is identical to the object's label.
withDoubleQuotes | If it is set to true, a quotation mark is added as first and last character of the label. The default value is false. |
|
virtual |
To get the associated Qt notifier which enables to track all Qt signal emitted by HxBase objects.
Must be inherited to specify the return type.
|
static |
Returns the total number of class instances.
int HxBase::getNumPorts | ( | ) | const |
Returns number of ports.
HxPort* HxBase::getPort | ( | int | i | ) | const |
Returns specified port.
i | The port index number. |
HxPort* HxBase::getPort | ( | const QString & | name | ) | const |
Returns port corresponding to given name.
name | The port name. |
HxPort* HxBase::getPortByLabel | ( | const QString & | label | ) | const |
Returns port with the given label.
label | The port label. |
HxPort* HxBase::getPortOfType | ( | const McTypeInfo * | type, |
bool | ignoreInvisible = true |
||
) | const |
Returns the first port corresponding to given type.
type | The port type. |
ignoreInvisible | Specifies if invisible ports should be ignored during the search (default value is true). |
SoSeparator* HxBase::getSeparator | ( | ) | const |
Returns the separator containing all the geometry of the object.
If the object does not display any geometry, i.e., if it has never called showGeom(), a null pointer is returned.
bool HxBase::getTclMemberVar | ( | const char * | name, |
QString & | result | ||
) | const |
Gets value of tcl member variable with name.
name | The name. |
result | The associated value. |
int HxBase::getViewerMask | ( | ) | const |
Returns viewer mask ANDed with viewer master mask.
This combination decides if an object is actually visible or not.
int HxBase::getViewerMaskAsIs | ( | ) | const |
Returns the viewer mask of the object.
int HxBase::getViewerMasterMask | ( | ) | const |
Returns the viewer master mask of the object.
|
virtual |
Called by m_displayUnitsChangesListener when the global coordinates display unit has changed.
Must be overloaded by derivated classes which need to track coordinates display unit changes.
oldUnit | The old unit. |
newUnit | The new unit. |
|
virtual |
Called by m_displayUnitsChangesListener when a global display unit has changed.
Must be overloaded by derivated classes which need to track display unit changes.
oldUnit | The old unit. |
newUnit | The new unit. |
|
protected |
This helper is called by setDisplayViewers(const std::set<int>& visibleAreas)
It is in charge of: -updating the visibleAreas
list in order to add appropriated SO_SWITCH_NONE or SO_SWITCH_ALL, -ensuring that the root
and raSwitch
exist, -starting or stopping the raSwitch
filtering process. Re-implementing this method is useful when you want to mix the user defined m_visibleAreas
list with your own one.
|
protected |
This method is called by renderAreaSwitchCB(SoSwitch* traversingSwitch, HxRenderArea* renderArea, SoAction* action)
in order to know which child has to be traversed according to visibleAreas
.
void HxBase::hideGeom | ( | SoNode * | node | ) |
Removes geometry node from the viewers.
The reference count of node
is decreased by one.
node | The node. |
|
protectedvirtual |
Initializes the scene graph.
HxINTERNAL void HxBase::internalSetLabel | ( | const char * | label | ) |
internal use only
|
virtual |
Indicates whether the object has a Camel Case label or not.
This method always returns false in this implementation; it must be overloaded by classes supporting Camel Case labels.
bool HxBase::isClipped | ( | ) | const |
Returns true if an HxPlanarMod is clipping this object.
void HxBase::notifyPortAdded | ( | HxPort * | port | ) |
Called to notify when a port has been added/removed to/from the HxBase instance.
port | The port. |
|
virtual |
Tcl command interface of the object.
interpreter | The interpreter. |
argc | The number of arguments. |
argv | The arguments. |
|
static |
Returns true if a global polygon offset is needed by at least one module.
At least one module must have called setRequiresPolygonOffset() with value==true, otherwise the method returns false.
|
protectedvirtual |
This method is called whenever a projection is activated.
|
protectedvirtual |
This method is called whenever a projection is deactivated.
|
staticprotected |
Use to setting up some necessary OIV cache properties when raSwitch
is started.
|
static |
Removes all forbidden labels.
HxINTERNAL void HxBase::removeAllOnTheFlyPorts | ( | ) |
Remove all on-the-fly ports.
|
static |
Removes a forbidden label.
forbiddenLabel | The forbidden label. |
HxINTERNAL void HxBase::removeOnTheFlyPort | ( | HxPort * | port | ) |
Remove an on-the-fly port.
The | port. |
|
protectedvirtual |
Remove rootSep
from a controller.
This method can be re-implemented in case you would like to use your own controller.
rootSep | The root separator. |
|
protectedvirtual |
The render area switch callback.
This callback is activated only when the "setScreen" TCL command or the "setDisplayViewers" method has been called.
traversingSwitch | The Transversing switch. |
renderArea | The render area. |
action | The action. |
|
staticprotected |
The render area switch callback.
This callback is activated only when the "setScreen" TCL command or the "setDisplayViewers" method has been called.
bool HxBase::requiresPolygonOffset | ( | ) | const |
Checks if this object requires a global polygon offset or not.
HxINTERNAL void HxBase::saveTclMemberVars | ( | FILE * | fp | ) |
Needed internally for save network.
fp | The file. |
void HxBase::setControllingData | ( | HxSpatialData * | data | ) |
Specifies the data object from which the local transformation is taken from.
data | The spatial data. |
void HxBase::setDisplay | ( | HxDisplay * | display | ) |
Sets class managing projection and shadowing options.
Warning: display
will be deleted by this class.
display | The display. |
|
virtual |
Set a display label for the object.
This label does not have to be unique. It will be the label displayed in the GUI.
|
virtual |
Restricts the rendering of this module to a specific list of VR screens or viewers.
By default, all viewers are allowed to display the representation of this module.
visibleAreas | The visible areas. |
void HxBase::setDisplayViewers | ( | const McDArray< int > & | visibleAreas | ) |
Provided for convenience.
See setDisplayViewers(const std::set<int>& visibleAreas)
for more info.
visibleAreas | The visible areas. |
void HxBase::setFlag | ( | unsigned int | flag, |
bool | value | ||
) |
Sets flag with corresponding value.
flag | The flag. |
value | The flag value. |
|
virtual |
Set a unique label or name for the object.
The label is displayed at the object's icon. For every label there is also a Tcl command, which corresponds to the object. The setLabel()
method might append some digits to the label in order to make it unique.
label | The label name. |
void HxBase::setRequiresPolygonOffset | ( | bool | value | ) |
Sets or unsets interest in a global polygon offset.
Some modules like HxSurfaceIsolines require surfaces to be rendered using a polygon offset towards the back so that lines can be drawn directly onto the surface without z-buffer artifacts. However, since a polygon offset might introduce other rendering artifacts at sharp polygon boundaries it should only be enabled if necessary. Thus, if some module requires polygon offset to be enabled it may request so by calling this method with value==true
. If polygon offset is no longer needed the method should be called with value==false
. The method will be called automatically with value==false
in the destructor of a HxBase object. The method should only be called from the main thread.
value | The polygon offset state. |
void HxBase::setTclMemberVar | ( | const char * | name, |
const char * | value | ||
) |
sets value of tcl member variable with name
name | The name. |
value | The value. |
HxINTERNAL int HxBase::setTclMemberVarSerialize | ( | const char * | name, |
bool | serialize | ||
) |
Save this tcl member variable in network file (standard) or not.
name | The name. |
serialize | The serialize value. |
|
virtual |
Defines in which viewer geometry is visible.
The viewer mask of Amira objects can be modified interactively using the orange viewer toggles displayed in the work area. Each bit of the mask is associated with a particular viewer. Note, that even if the viewer mask is set an object may be invisible because the master viewer mask is not set. The master viewer mask is changed whenever the viewer mask of an upstream data object is modified.
mask | The bit mask. |
masterMask | The master bit mask (default value is 0xffffffff). |
void HxBase::showGeom | ( | SoNode * | node, |
HxSpatialData * | controllData | ||
) |
Adds geometry to the viewers.
node
may point to an arbitrary Open Inventor scene graph. This graph will become visible in all viewers defined in the viewer mask. The reference count of node
will be increased by one. If controllData
is non-zero the geometry will be transformed by the local transformation matrix of controllData
.
node | The node. |
controllData | The spatial data. |
|
virtual |
Calls showGeom(node,0); overridden in HxModule, HxEditor.
node | The node. |
void HxBase::showPinButtons | ( | bool | showIt | ) |
Hides or shows pin buttons of all ports.
showIt | The show state. |
|
staticprotected |
Interface to Tcl scripting language.
data | The data. |
interpreter | The interpreter. |
argc | The number of arguments. |
argv | The arguments. |
|
static |
Returns the translation text for sourceText, by querying the installed translation files.
context | The context. |
sourceText | The source text. |
disambiguation | The disambiguation (default value is 0). |
|
virtual |
Unset geometry clipping.
planarMod | The planar mod. |
|
protectedvirtual |
Inserts transform nodes into root as necessary.
|
protected |
Derived classes should call this if they want to use world coords.
trueOrFalse | The value. |