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... | |
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().
|
protected |
Constructor.
Module may be connected to objects of given type.
|
protectedvirtual |
Destructor.
void HxCompModule::applyTransformToResult | ( | ) |
Apply transformation of the source object to the object created by this module.
|
virtual |
Checks if given data object can be reconstructed.
data | The data object. |
createCmd | The command. |
|
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.
id | The result id. |
result | The result. |
|
protected |
Copy material bundles from module input to output.
output | output data of module |
|
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.
input | The input. |
output | The output. |
scale | The scaling value (1.0f by default). |
offset | The offset value (0.0f by default). |
|
protectedvirtual |
Create result associated with the specified name.
By default, this method tries to find a port action to trigger a compute.
name | The name. |
|
protected |
Add or update the Apply commands of the resultData's last step in HistoryLog.
This should be called after recordNewResultInHistoryLog() or recordInputUpdateInHistoryLog().
resultData | is the result we want to update the HistoryLog. |
customApplyCommand | is the custom apply command. |
|
protected |
Sets a flag indicates whether the material bundles of module input should be copied to the output or not.
isEnabled | to know if copy of material bundle is enabled or not |
|
protected |
Sets a flag indicates whether the range calibration of module input should be copied to the output or not.
enable | The flag value. |
|
protected |
Finds the result slot by id.
id | The id. |
|
protected |
Finds the result slot from data.
data | The data. |
|
protected |
Finds the result slot from string.
str | The string. |
|
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.
shouldCompute | If true, the compute method is called. |
bool HxCompModule::getApplyTransfOfSourceToResult | ( | ) |
Gets if transformation of source data should be applied to result data of this module.
|
virtual |
Compute modules are #F97C7A.
|
protected |
Return the touch time.
int HxCompModule::getNewResultSlotID | ( | ) | const |
Returns a free and valid result slot id.
int HxCompModule::getNumResultSlots | ( | ) | const |
Gets 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.
id | The 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
name | The 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.
id | The result id. |
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.
pos | The index. |
result | The result. |
mask | The mask (0xffffffff by default). |
|
protected |
Indicates whether the material bundles of module input should be copied to the output or not.
|
protected |
Indicates whether the range calibration of module input should be copied to the output or not.
|
virtual |
Tcl-command interface.
interpreter | The interpreter. |
argc | The number of arguments. |
argv | The arguments. |
|
protected |
In case of modules that modify the input, this method can be used to record the input modification step in the input HistoryLog.
inputPort | is the connection port to which the input data is connected. |
|
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.
id | The number of the result slot. |
res | The 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.
pos | The index. |
|
virtual |
This method is called after a new result is connected to the module.
The id indicates which result slot has been modified.
id | The result id. |
|
virtual |
Overrides HxObjects's saveUpdate.
Saves state of the compute module.
fp | The file. |
void HxCompModule::setApplyTransfOfSourceToResult | ( | bool | apply | ) |
Sets module to apply transformation of source data to result data.
apply | The 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.
id | The result id. |
name | The 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.
id | The result id. |
result | The result. |
mask | The 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.
result | The result. |
mask | The 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.
name | The name. |
result | The result. |
mask | The mask (0xffffffff by default). |
|
virtual |
Updates user interface of the module.
|
protected |
Updates the State command of the resultData's last step in HistoryLog.
This should be called after recordNewResultInHistoryLog() or recordInputUpdateInHistoryLog().
inputPort | is the connection port to which the input data is connected. |