Port representing inter-object connections. More...
#include <HxConnection.h>
Inherits HxPort.
Public Member Functions | |
HxConnection (HxObject *, const QString &name, const QString &label) | |
Constructor without source type. More... | |
HxConnection (HxObject *, const QString &name, const QString &label, const McTypeInfo *t) | |
Constructor with single source type. More... | |
HxConnection (HxEditor *editor, const QString &name, const QString &label) | |
Constructor without source type. More... | |
HxConnection (HxEditor *editor, const QString &name, const QString &label, const McTypeInfo *t) | |
Constructor with single source type. More... | |
virtual | ~HxConnection () |
Destructor. More... | |
int | validSource (HxObject *src) |
Returns true if src is a valid source. More... | |
virtual bool | connect (HxObject *src) |
Establishes connection. More... | |
void | enableNotificationOnConnect (bool flag) |
Enables/disables notification on connection. More... | |
bool | isNotificationOnConnectEnabled () const |
Returns true if the notification on connection is enabled. More... | |
virtual void | disconnect (bool disconnectedDuringConnection=false) |
Removes connection. More... | |
HxObject * | getSource () const |
Returns object the port is connected to. More... | |
McTypedObject * | getSource (const McTypeInfo *t) const |
Returns pointer to source object or interface of type t . More... | |
bool | isOptional () |
Returns true if the connection is optional and false if it's mandatory. More... | |
void | setOptional (bool inFlag) |
Sets a connection mandatory inFlag false or optional inFlag true. More... | |
HxINTERNAL bool | isEditable () const |
Returns true if the connection can be edited. More... | |
void | allowEditing (bool onOff) |
Allows or disallows interactive editing of a connection. More... | |
void | setVisibility (int cnxVisibility, bool popupCnxItemVisibility=true) |
Sets visibility flag. More... | |
HxINTERNAL bool | isPopupCnxItemVisible () const |
Tell if the item representing a connection within the popup menu of a module even if a connection has been done. More... | |
void | setTightness (bool onOff) |
Sets tightness flag. More... | |
int | isTight () const |
Returns tightness flag. More... | |
void | addType (const McTypeInfo *t) |
Adds t to the list of allowed source types. More... | |
void | clearTypes () |
Clears the allowed source types list. More... | |
void | setSourceCheck (SourceCheck cb, void *userData) |
Sets alternative source check method. More... | |
SourceCheck | getSourceCheck (void *&userData) |
Returns current source check callback with its associated userData. More... | |
void | sourceCheckChanged () |
Notifies the connection that its source filter has been changed. More... | |
virtual int | parse (Tcl_Interp *interpreter, int argc, char **argv) |
Tcl command interface. More... | |
virtual void | saveState (FILE *fp) |
Overloaded save state method. More... | |
virtual void | getState (QString &state) const |
Returns current state in ascii string. More... | |
virtual int | setState (const QString &state) |
Inherited from HxPort. More... | |
virtual HxINTERNAL void | drawConnection (QPainter *p, std::map< HxObject *, McDArray< std::pair< QPointF, QColor > > > &connectors) |
Draw connection line. More... | |
virtual HxINTERNAL int | intersect (int x, int y) |
Check if connection is hit by x, y coordinates. More... | |
HxINTERNAL void | feedback (QPainter *, int x, int y, HxObject *object) |
Generate graphical feedback when editing connection. More... | |
HxINTERNAL void | confirm (HxObject *object) |
Called when finishing edit session. More... | |
HxINTERNAL int | mustBeDisplayedBeforeOtherPorts () const |
To know if the connection gui must be displayed before the others ports. More... | |
HxINTERNAL QComboBox * | getSourcesListCB () const |
To get the sources list combo box. More... | |
HxINTERNAL QToolButton * | getGoToCurrentSourceBtn () const |
To get the "Go to" tool button. More... | |
HxINTERNAL void | setVisibleGoToCurrentSourceBtn (bool visible) |
Sets the visibility of the "Go to" tool button. More... | |
HxINTERNAL bool | isVisibleGoToCurrentSourceBtn () |
Return the visibility of the "Go to" tool button. More... | |
HxINTERNAL QxConnectionGUIUpdater * | getGUIUpdater () const |
To get the associated GUI updater. More... | |
virtual void | setLabel (const QString &text) |
Sets the label. More... | |
const TypeInfoArray & | getValidTypes () const |
Return the list of allowed object types to connect to this port. More... | |
virtual void | initFrom (HxPort *refPort) |
Copy values from refPort and update GUI. More... | |
void | setMustBeDisplayedBeforeOtherPorts (bool force=true) |
Control if the connection gui must be displayed before the others ports. More... | |
void | setAcceptCyclicConnection (const bool cyclicConnectionAccepted) |
Sets the flag indicating if this connection accepts data connected to a downstream connection of its owner. More... | |
bool | acceptCyclicConnection () const |
Indicates if this connection accepts data connected to a downstream connection of its owner. More... | |
HxINTERNAL void | setSaveConnection (bool canSaveConnection) |
Set the connection as savable (or not). More... | |
HxINTERNAL bool | canSaveConnection () const |
Tells if the connection can be saved. More... | |
Protected Member Functions | |
virtual void | createWidget (QWidget *w) |
The gui is composed of a combo box (list of available sources) and a "Go to" tool button used to select the current source. More... | |
void | commonInit () |
Common init. More... | |
virtual void | guiCallback () |
Gui callback method. More... | |
Port representing inter-object connections.
In contrast to other ports connections usually have no gui elements (derived connections like HxPortColormap again do have gui elements). Instead, connections are listed in the popup menu over the tiny little connection area of the object's icon. A connection port can only be connected to objects of a certain type. Allowed types must be indicated in the constructor or must be added to the list of allowed types using addType().
HxConnection::HxConnection | ( | HxObject * | , |
const QString & | name, | ||
const QString & | label | ||
) |
Constructor without source type.
A connection port is created, but the list of allowed source types is not yet specified. An object may call addType() to specify what objects are allowed to connect to the port.
HxConnection::HxConnection | ( | HxObject * | , |
const QString & | name, | ||
const QString & | label, | ||
const McTypeInfo * | t | ||
) |
Constructor with single source type.
Creates a connection port which can be connected to all objects of type t
. The list of allowed source types may be extended by calling addType().
HxConnection::HxConnection | ( | HxEditor * | editor, |
const QString & | name, | ||
const QString & | label | ||
) |
Constructor without source type.
A connection port is created, but the list of allowed source types is not yet specified. An object may call addType() to specify what objects are allowed to connect to the port.
HxConnection::HxConnection | ( | HxEditor * | editor, |
const QString & | name, | ||
const QString & | label, | ||
const McTypeInfo * | t | ||
) |
Constructor with single source type.
Creates a connection port which can be connected to all objects of type t
. The list of allowed source types may be extended by calling addType().
|
virtual |
Destructor.
bool HxConnection::acceptCyclicConnection | ( | ) | const |
Indicates if this connection accepts data connected to a downstream connection of its owner.
void HxConnection::addType | ( | const McTypeInfo * | t | ) |
Adds t
to the list of allowed source types.
t | The type. |
void HxConnection::allowEditing | ( | bool | onOff | ) |
Allows or disallows interactive editing of a connection.
onOff | The state. |
HxINTERNAL bool HxConnection::canSaveConnection | ( | ) | const |
Tells if the connection can be saved.
void HxConnection::clearTypes | ( | ) |
Clears the allowed source types list.
|
protected |
Common init.
HxINTERNAL void HxConnection::confirm | ( | HxObject * | object | ) |
Called when finishing edit session.
object | The object. |
|
virtual |
Establishes connection.
This method calls HxObject::notifyConnect() on the connected object (i.e. src) if the notification on connection is enabled (cf. enableNotificationOnConnect() / isNotificationOnConnectEnabled()).
src | The connected object. |
|
protectedvirtual |
The gui is composed of a combo box (list of available sources) and a "Go to" tool button used to select the current source.
w | The widget. |
|
virtual |
Removes connection.
disconnectedDuringConnection | Disconnected during connection state (default value is false). |
|
virtual |
Draw connection line.
p | The painter. |
connectors | The connectors. |
void HxConnection::enableNotificationOnConnect | ( | bool | flag | ) |
Enables/disables notification on connection.
See connect() for details.
flag | Notification on connection state. |
HxINTERNAL void HxConnection::feedback | ( | QPainter * | , |
int | x, | ||
int | y, | ||
HxObject * | object | ||
) |
Generate graphical feedback when editing connection.
HxINTERNAL QToolButton* HxConnection::getGoToCurrentSourceBtn | ( | ) | const |
To get the "Go to" tool button.
HxINTERNAL QxConnectionGUIUpdater* HxConnection::getGUIUpdater | ( | ) | const |
To get the associated GUI updater.
HxObject* HxConnection::getSource | ( | ) | const |
Returns object the port is connected to.
McTypedObject* HxConnection::getSource | ( | const McTypeInfo * | t | ) | const |
Returns pointer to source object or interface of type t
.
For more information about interfaces refer to HxInterface .
t | The type. |
t
and if it not contains an interface of type t
. SourceCheck HxConnection::getSourceCheck | ( | void *& | userData | ) |
Returns current source check callback with its associated userData.
userData | The user data. |
HxINTERNAL QComboBox* HxConnection::getSourcesListCB | ( | ) | const |
To get the sources list combo box.
|
virtual |
Returns current state in ascii string.
state | The current state in ascii string. |
const TypeInfoArray& HxConnection::getValidTypes | ( | ) | const |
Return the list of allowed object types to connect to this port.
|
protectedvirtual |
Gui callback method.
|
virtual |
Copy values from refPort and update GUI.
refPort | The reference port. |
|
virtual |
Check if connection is hit by x, y coordinates.
x,y | The coordinates. |
HxINTERNAL bool HxConnection::isEditable | ( | ) | const |
Returns true if the connection can be edited.
Editing means that the user is able to pick the connection line displayed in the object pool and drag it onto some other input object. Non-editable connections are displayed in grey instead blue.
bool HxConnection::isNotificationOnConnectEnabled | ( | ) | const |
Returns true if the notification on connection is enabled.
See connect() for details.
bool HxConnection::isOptional | ( | ) |
Returns true if the connection is optional and false if it's mandatory.
Default is false (mandatory).
HxINTERNAL bool HxConnection::isPopupCnxItemVisible | ( | ) | const |
Tell if the item representing a connection within the popup menu of a module even if a connection has been done.
Mainly used by #theObjectPool
.
int HxConnection::isTight | ( | ) | const |
Returns tightness flag.
HxINTERNAL bool HxConnection::isVisibleGoToCurrentSourceBtn | ( | ) |
Return the visibility of the "Go to" tool button.
If the "Go to" button don't exist, it's the saved visibility which is returned.
HxINTERNAL int HxConnection::mustBeDisplayedBeforeOtherPorts | ( | ) | const |
To know if the connection gui must be displayed before the others ports.
|
virtual |
Tcl command interface.
interpreter | The interpreter. |
argc | The number of arguments. |
argv | The arguments. |
|
virtual |
Overloaded save state method.
fp | The file. |
void HxConnection::setAcceptCyclicConnection | ( | const bool | cyclicConnectionAccepted | ) |
Sets the flag indicating if this connection accepts data connected to a downstream connection of its owner.
cyclicConnectionAccepted | The cyclic connection accepted state. |
|
virtual |
Sets the label.
text | The label. |
|
inline |
Control if the connection gui must be displayed before the others ports.
force | If true (default), the connection is displayed first. |
void HxConnection::setOptional | ( | bool | inFlag | ) |
Sets a connection mandatory inFlag false or optional inFlag true.
Default is false (mandatory).
During the deletion of a HxObject the corresponding owners of all its downstream connections will be deleted automatically if they are not of type HxData. However if a downstream connection is optional it will only be disconnected but not deleted.
Imagine you have a display module additionally connected to a 'SelectROI' module and you don't want to have the display module deleted whenever the 'SelectROI' module will be deleted. In that particular case you would set the connection of the 'SelectROI' module to optional (true).
inFlag | The optional state. |
HxINTERNAL void HxConnection::setSaveConnection | ( | bool | canSaveConnection | ) |
Set the connection as savable (or not).
canSaveConnection | tells if the connection can be saved. |
void HxConnection::setSourceCheck | ( | SourceCheck | cb, |
void * | userData | ||
) |
Sets alternative source check method.
SourceCheck
is defined in the following way:
The source check method should return 1 if the port can be connected to the object pointed to by src
. Otherwise, it should return 0.
|
virtual |
Inherited from HxPort.
To restore the current state from a string.
void HxConnection::setTightness | ( | bool | onOff | ) |
Sets tightness flag.
If a connection is marked as tight, no connection line will be drawn in the object pool. Instead, the icon of the object the connection belongs to will be drawn right under the icon of the source object.
onOff | The state. |
void HxConnection::setVisibility | ( | int | cnxVisibility, |
bool | popupCnxItemVisibility = true |
||
) |
Sets visibility flag.
If a connection is invisible (cnxVisibility
), no connection line will be drawn in the object pool. Sometimes this might be useful for clarity. Use the parameter popupCnxItemVisibility
to never display the item representing a connection within the popup menu of a module even if a connection has been done. If you want to see the connection item when a module is connected to this connection port and, hide the connection item when a module isn't connected, use setVisible
instead. On default, all connections will be visible.
HxINTERNAL void HxConnection::setVisibleGoToCurrentSourceBtn | ( | bool | visible | ) |
Sets the visibility of the "Go to" tool button.
If the "Go to" button don't exist, the visibility is saved and applied when the button is created.
visible | The visible state. |
void HxConnection::sourceCheckChanged | ( | ) |
Notifies the connection that its source filter has been changed.
int HxConnection::validSource | ( | HxObject * | src | ) |
Returns true if src
is a valid source.
An object is considered to be a valid source if it is derived from one of the types contained in the list of allowed types or if it contains an interface (see HxInterface ) matching one of the types contained in that list. Alternatively, a user-defined check function can be defined using setSourceCheck().
src | The source object. |
src
is a valid source, otherwise false.