Public Member Functions | Protected Member Functions | List of all members
HxCompModule Class Reference

Base class for compute modules. More...

#include <HxCompModule.h>

Inherits HxBatchModule.

Public Member Functions

void setNameOfResultSlot (int id, const char *name)
 Associates a custom name with a result id. More...
 
void setResult (int id, HxData *result, unsigned int mask=0xffffffff)
 Registers a data object as a result object. More...
 
void insertResult (int pos, HxData *result, unsigned int mask=0xffffffff)
 Inserts a data object as a result object at the given result-slot index pos. More...
 
void removeResult (int pos)
 Remove the result slots at position pos. More...
 
void setResult (HxData *result, unsigned int mask=0xffffffff)
 Registers a data object as the default result. More...
 
void setResult (const char *name, HxData *result, unsigned int mask=0xffffffff)
 Registers a data object as a result object. More...
 
HxData * getResult (int id=0) const
 Returns the result object associated with the specified id. More...
 
HxData * getResult (const char *name) const
 Returns the result object associated with the specified name. More...
 
int getTouchTime (int id=0) const
 Returns the touch time of a result slot. More...
 
virtual int checkResult (int &id, HxData *result)
 Checks if a data object can be used as a result. More...
 
virtual void resultChanged (int id)
 This method is called after a new result is connected to the module. More...
 
virtual void fire (int shouldCompute=1)
 Custom fire method. More...
 
virtual McColor getIconColor ()
 Compute modules are #F97C7A. More...
 
virtual int parse (Tcl_Interp *interpreter, int argc, char **argv)
 Tcl-command interface. More...
 
virtual void saveUpdate (FILE *fp)
 Overrides HxObjects's saveUpdate. More...
 
int getNumResultSlots () const
 Gets the number of result slots. More...
 
int getNewResultSlotID () const
 Returns a free and valid result slot id. More...
 
void setApplyTransfOfSourceToResult (bool apply)
 Sets module to apply transformation of source data to result data. More...
 
bool getApplyTransfOfSourceToResult ()
 Gets if transformation of source data should be applied to result data of this module. More...
 
void applyTransformToResult ()
 Apply transformation of the source object to the object created by this module. More...
 
virtual void update ()
 Updates user interface of the module. More...
 
virtual bool canCreateData (HxData *data, QString &createCmd)
 Checks if given data object can be reconstructed. More...
 

Protected Member Functions

 HxCompModule (const McTypeInfo *dataType, McInterfaceOwner *owner=0, QxObjectNotifier *notifier=0)
 Constructor. More...
 
virtual ~HxCompModule ()
 Destructor. More...
 
virtual HxData * createResult (const QString &name)
 Create result associated with the specified name. More...
 
HxINTERNAL ResultSlot * findResultSlot (int id) const
 Finds the result slot by id. More...
 
HxINTERNAL ResultSlot * findResultSlotFromString (const char *str) const
 Finds the result slot from string. More...
 
HxINTERNAL ResultSlot * findResultSlotFromData (HxData *data) const
 Finds the result slot from data. More...
 
HxINTERNAL void recordNewResultInHistoryLog (int id, HxData *res)
 Record the result in a HistoryLog bundle. More...
 
HxINTERNAL void recordInputUpdateInHistoryLog (HxConnection *inputPort)
 In case of modules that modify the input, this method can be used to record the input modification step in the input HistoryLog. More...
 
HxINTERNAL void customizeApplyCommandInHistoryLog (HxData *resultData, QString customApplyCommand)
 Add or update the Apply commands of the resultData's last step in HistoryLog. More...
 
HxINTERNAL void updateInputStateCommandInHistoryLog (HxConnection *inputPort)
 Updates the State command of the resultData's last step in HistoryLog. More...
 
HxINTERNAL int getModuleTouchTime ()
 Return the touch time. More...
 
bool isRangeCalibrationCopyEnabled () const
 Indicates whether the range calibration of module input should be copied to the output or not. More...
 
void enableRangeCalibrationCopy (bool enable)
 Sets a flag indicates whether the range calibration of module input should be copied to the output or not. More...
 
virtual void copyRangeCalibration (const HxData *input, HxData *output, float scale=1.0f, float offset=0.0f) const
 This method copy the range calibration existing in input to output, scaling and offsetting if required. More...
 
bool isMaterialBundlesCopyEnabled () const
 Indicates whether the material bundles of module input should be copied to the output or not. More...
 
void enableMaterialBundlesCopy (bool isEnabled)
 Sets a flag indicates whether the material bundles of module input should be copied to the output or not. More...
 
void copyMaterialBundles (HxData *output) const
 Copy material bundles from module input to output. More...
 

Detailed Description

Base class for compute modules.

Base class for compute modules like HxResample, HxArithmetic, or HxMagnitude. Compute modules take one or multiple input objects and compute one or multiple output objects of type HxData. The output objects should be registered by calling setResult(). setResult() connects the master connection of the data object to the compute module, so that the result is downstream with respect to the compute module. Multiple output objects can be registered by using an optional id when calling setResult(). Each id defines a so-called result slot. With each result slot a name can be associated by calling setNameOfResultSlot().

Compute modules are colored indian red and are usually placed in the middle region of the object pool. Since this class is derived from HxBatchModule it is possible to submit a background thread using HxBatchModule::runBatch().

Constructor & Destructor Documentation

HxCompModule::HxCompModule ( const McTypeInfo *  dataType,
McInterfaceOwner *  owner = 0,
QxObjectNotifier *  notifier = 0 
)
protected

Constructor.

Module may be connected to objects of given type.

virtual HxCompModule::~HxCompModule ( )
protectedvirtual

Destructor.

Member Function Documentation

void HxCompModule::applyTransformToResult ( )

Apply transformation of the source object to the object created by this module.

virtual bool HxCompModule::canCreateData ( HxData *  data,
QString &  createCmd 
)
virtual

Checks if given data object can be reconstructed.

Parameters
dataThe data object.
createCmdThe command.
Returns
True if the given data object can be reconstructed, otherwise false.
virtual int HxCompModule::checkResult ( int &  id,
HxData *  result 
)
virtual

Checks if a data object can be used as a result.

The method is called before a new result is actually connected to a compute module. For backward compatibility the default implementation simply returns 1, which means that any data object can be connected to the module. Derived classes may change this behaviour by overloading the method. If the result can not be used as a result for the slot specified by id but for some other slot, the check method may change the value of id and still return 1.

Parameters
idThe result id.
resultThe result.
Returns
The checked result.
void HxCompModule::copyMaterialBundles ( HxData *  output) const
protected

Copy material bundles from module input to output.

Parameters
outputoutput data of module
virtual void HxCompModule::copyRangeCalibration ( const HxData *  input,
HxData *  output,
float  scale = 1.0f,
float  offset = 0.0f 
) const
protectedvirtual

This method copy the range calibration existing in input to output, scaling and offsetting if required.

The copy occurs only if the range calibration is enabled. The copy is done by calling HxRangeCalibrationCompliantData::copy().

This method should be overridden by derived class that need to set a scale and/or an offset different from default values.

Parameters
inputThe input.
outputThe output.
scaleThe scaling value (1.0f by default).
offsetThe offset value (0.0f by default).
virtual HxData* HxCompModule::createResult ( const QString &  name)
protectedvirtual

Create result associated with the specified name.

By default, this method tries to find a port action to trigger a compute.

Parameters
nameThe name.
Returns
The associated result.
HxINTERNAL void HxCompModule::customizeApplyCommandInHistoryLog ( HxData *  resultData,
QString  customApplyCommand 
)
protected

Add or update the Apply commands of the resultData's last step in HistoryLog.

This should be called after recordNewResultInHistoryLog() or recordInputUpdateInHistoryLog().

Parameters
resultDatais the result we want to update the HistoryLog.
customApplyCommandis the custom apply command.
void HxCompModule::enableMaterialBundlesCopy ( bool  isEnabled)
protected

Sets a flag indicates whether the material bundles of module input should be copied to the output or not.

Parameters
isEnabledto know if copy of material bundle is enabled or not
void HxCompModule::enableRangeCalibrationCopy ( bool  enable)
protected

Sets a flag indicates whether the range calibration of module input should be copied to the output or not.

Parameters
enableThe flag value.
HxINTERNAL ResultSlot* HxCompModule::findResultSlot ( int  id) const
protected

Finds the result slot by id.

Parameters
idThe id.
Returns
The result slot.
HxINTERNAL ResultSlot* HxCompModule::findResultSlotFromData ( HxData *  data) const
protected

Finds the result slot from data.

Parameters
dataThe data.
Returns
The result slot.
HxINTERNAL ResultSlot* HxCompModule::findResultSlotFromString ( const char *  str) const
protected

Finds the result slot from string.

Parameters
strThe string.
Returns
The result slot.
virtual void HxCompModule::fire ( int  shouldCompute = 1)
virtual

Custom fire method.

The method simply calls the fire method of the parent class HxBatchModule. However, before it resets the variable resultTouchTime if at least one port is new. If the network is saved after a port has changed but before the results have been recomputed, an overloaded HxObject::canCreateData method should return false. Note, that the touch times of the individual result slots as returned by getTouchTime will not be reset by the fire method.

Parameters
shouldComputeIf true, the compute method is called.
bool HxCompModule::getApplyTransfOfSourceToResult ( )

Gets if transformation of source data should be applied to result data of this module.

Returns
The apply transformation of source to result state.
virtual McColor HxCompModule::getIconColor ( )
virtual

Compute modules are #F97C7A.

Returns
The color.
HxINTERNAL int HxCompModule::getModuleTouchTime ( )
protected

Return the touch time.

Returns
the touch time.
int HxCompModule::getNewResultSlotID ( ) const

Returns a free and valid result slot id.

Returns
The number of result slots id.
int HxCompModule::getNumResultSlots ( ) const

Gets the number of result slots.

Returns
The number of result slots.
HxData* HxCompModule::getResult ( int  id = 0) const

Returns the result object associated with the specified id.

If no result object is connected to the specified result slot the method returns null.

Parameters
idThe result id (0 by default).
HxData* HxCompModule::getResult ( const char *  name) const

Returns the result object associated with the specified name.

If no result object is connected to the specified result slot the method returns 0

Parameters
nameThe name.
Returns
The result object associated with the specified name.
int HxCompModule::getTouchTime ( int  id = 0) const

Returns the touch time of a result slot.

The touch time is set when registering a result using setResult(). Usually the touch time will only be evaluated in an overloaded implementation of HxObject::canCreateData.

See also
HxData::getTouchTime
Parameters
idThe result id.
Returns
The touch time of a result slot.
void HxCompModule::insertResult ( int  pos,
HxData *  result,
unsigned int  mask = 0xffffffff 
)

Inserts a data object as a result object at the given result-slot index pos.

All results-slots after the newly created one will be right-shifted.

Parameters
posThe index.
resultThe result.
maskThe mask (0xffffffff by default).
bool HxCompModule::isMaterialBundlesCopyEnabled ( ) const
protected

Indicates whether the material bundles of module input should be copied to the output or not.

Returns
true if copy enabled, false otherwise
bool HxCompModule::isRangeCalibrationCopyEnabled ( ) const
protected

Indicates whether the range calibration of module input should be copied to the output or not.

Returns
True if the range calibration of module input should be copied to the output, otherwise false.
virtual int HxCompModule::parse ( Tcl_Interp *  interpreter,
int  argc,
char **  argv 
)
virtual

Tcl-command interface.

Parameters
interpreterThe interpreter.
argcThe number of arguments.
argvThe arguments.
Returns
1 if parse is done without error.
HxINTERNAL void HxCompModule::recordInputUpdateInHistoryLog ( HxConnection inputPort)
protected

In case of modules that modify the input, this method can be used to record the input modification step in the input HistoryLog.

Parameters
inputPortis the connection port to which the input data is connected.
HxINTERNAL void HxCompModule::recordNewResultInHistoryLog ( int  id,
HxData *  res 
)
protected

Record the result in a HistoryLog bundle.

The bundle added will define a new step in the scenario, corresponding to the use of the current module.

Parameters
idThe number of the result slot.
resThe result data.
void HxCompModule::removeResult ( int  pos)

Remove the result slots at position pos.

All results slots at the right of the deleted one will be left-shifted.

Parameters
posThe index.
virtual void HxCompModule::resultChanged ( int  id)
virtual

This method is called after a new result is connected to the module.

The id indicates which result slot has been modified.

Parameters
idThe result id.
virtual void HxCompModule::saveUpdate ( FILE *  fp)
virtual

Overrides HxObjects's saveUpdate.

Saves state of the compute module.

Parameters
fpThe file.
void HxCompModule::setApplyTransfOfSourceToResult ( bool  apply)

Sets module to apply transformation of source data to result data.

Parameters
applyThe apply state.
void HxCompModule::setNameOfResultSlot ( int  id,
const char *  name 
)

Associates a custom name with a result id.

The name is used when connecting a data object to a compute module in a script or via the graphical user-interface.

Parameters
idThe result id.
nameThe name.
void HxCompModule::setResult ( int  id,
HxData *  result,
unsigned int  mask = 0xffffffff 
)

Registers a data object as a result object.

The method first adds the result to the object pool, if it was not already added before. It then connects the master connection of the data object to this module, thereby possibly disconnecting it from some other compute module or editor. It also touches the result using the specified mask and stores the result's touch time, so that it can be retrieved later on using getTouchTime(). It also stores the module's touch time in the result slot. This is useful in order to decide whether a result can be recomputed later on. For details see HxObject::canCreateData. The result is associated with the specified id. If a new id is used a new result slot will be created on the fly.

Parameters
idThe result id.
resultThe result.
maskThe mask (0xffffffff by default).
void HxCompModule::setResult ( HxData *  result,
unsigned int  mask = 0xffffffff 
)

Registers a data object as the default result.

The default result slot has id==0 and is created for every compute module.

Parameters
resultThe result.
maskThe mask (0xffffffff by default).
void HxCompModule::setResult ( const char *  name,
HxData *  result,
unsigned int  mask = 0xffffffff 
)

Registers a data object as a result object.

A result slot with the given name name is used. The parameter name must not be 0.

Parameters
nameThe name.
resultThe result.
maskThe mask (0xffffffff by default).
virtual void HxCompModule::update ( )
virtual

Updates user interface of the module.

HxINTERNAL void HxCompModule::updateInputStateCommandInHistoryLog ( HxConnection inputPort)
protected

Updates the State command of the resultData's last step in HistoryLog.

This should be called after recordNewResultInHistoryLog() or recordInputUpdateInHistoryLog().

Parameters
inputPortis the connection port to which the input data is connected.

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