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

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...
 

Detailed Description

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().

Constructor & Destructor Documentation

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 HxConnection::~HxConnection ( )
virtual

Destructor.

Member Function Documentation

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.

Parameters
tThe type.
void HxConnection::allowEditing ( bool  onOff)

Allows or disallows interactive editing of a connection.

Parameters
onOffThe state.
HxINTERNAL bool HxConnection::canSaveConnection ( ) const

Tells if the connection can be saved.

Returns
true if the connection can be saved in any case, false otherwise.
void HxConnection::clearTypes ( )

Clears the allowed source types list.

void HxConnection::commonInit ( )
protected

Common init.

HxINTERNAL void HxConnection::confirm ( HxObject *  object)

Called when finishing edit session.

Parameters
objectThe object.
virtual bool HxConnection::connect ( HxObject *  src)
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()).

Parameters
srcThe connected object.
Returns
True if the connect is enabled, otherwise false.
virtual void HxConnection::createWidget ( QWidget *  w)
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.

Parameters
wThe widget.
virtual void HxConnection::disconnect ( bool  disconnectedDuringConnection = false)
virtual

Removes connection.

Parameters
disconnectedDuringConnectionDisconnected during connection state (default value is false).
virtual HxINTERNAL void HxConnection::drawConnection ( QPainter *  p,
std::map< HxObject *, McDArray< std::pair< QPointF, QColor > > > &  connectors 
)
virtual

Draw connection line.

Parameters
pThe painter.
connectorsThe connectors.
void HxConnection::enableNotificationOnConnect ( bool  flag)

Enables/disables notification on connection.

See connect() for details.

Parameters
flagNotification 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.

Returns
The "Go to" tool button.
HxINTERNAL QxConnectionGUIUpdater* HxConnection::getGUIUpdater ( ) const

To get the associated GUI updater.

Returns
The associated GUI updater.
HxObject* HxConnection::getSource ( ) const

Returns object the port is connected to.

Returns
The 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 .

Parameters
tThe type.
Returns
Null if the port is not connected to any source object or if the source object is not of 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.

Parameters
userDataThe user data.
Returns
the current source check callback with its associated userData.
HxINTERNAL QComboBox* HxConnection::getSourcesListCB ( ) const

To get the sources list combo box.

Returns
The sources list combo box.
virtual void HxConnection::getState ( QString &  state) const
virtual

Returns current state in ascii string.

Parameters
stateThe current state in ascii string.
const TypeInfoArray& HxConnection::getValidTypes ( ) const

Return the list of allowed object types to connect to this port.

Returns
The list of allowed object types to connect to this port.
virtual void HxConnection::guiCallback ( )
protectedvirtual

Gui callback method.

virtual void HxConnection::initFrom ( HxPort *  refPort)
virtual

Copy values from refPort and update GUI.

Parameters
refPortThe reference port.
virtual HxINTERNAL int HxConnection::intersect ( int  x,
int  y 
)
virtual

Check if connection is hit by x, y coordinates.

Parameters
x,yThe coordinates.
Returns
If the line isn't hit at all 0 is returned. If the anchor point at the source object is hit the method returns -1. Otherwise it returns a number indicating the proximity between the point and the line. The larger the number the closer the point and the line.
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.

Returns
True if the connection can be edited.
bool HxConnection::isNotificationOnConnectEnabled ( ) const

Returns true if the notification on connection is enabled.

See connect() for details.

Returns
True if the notification on connection is enabled, otherwise false.
bool HxConnection::isOptional ( )

Returns true if the connection is optional and false if it's mandatory.

Default is false (mandatory).

Returns
True if the connection is optional and false if it's 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.

Returns
The tightness flag value.
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.

Returns
The visibility of the "Go to" tool button.
HxINTERNAL int HxConnection::mustBeDisplayedBeforeOtherPorts ( ) const

To know if the connection gui must be displayed before the others ports.

Returns
True if the connection gui must be displayed before the others ports, otherwise false.
virtual int HxConnection::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.
virtual void HxConnection::saveState ( FILE *  fp)
virtual

Overloaded save state method.

Parameters
fpThe file.
void HxConnection::setAcceptCyclicConnection ( const bool  cyclicConnectionAccepted)

Sets the flag indicating if this connection accepts data connected to a downstream connection of its owner.

Parameters
cyclicConnectionAcceptedThe cyclic connection accepted state.
virtual void HxConnection::setLabel ( const QString &  text)
virtual

Sets the label.

Parameters
textThe label.
void HxConnection::setMustBeDisplayedBeforeOtherPorts ( bool  force = true)
inline

Control if the connection gui must be displayed before the others ports.

Parameters
forceIf 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).

Parameters
inFlagThe optional state.
HxINTERNAL void HxConnection::setSaveConnection ( bool  canSaveConnection)

Set the connection as savable (or not).

Parameters
canSaveConnectiontells 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:

typedef int (*SourceCheck)(void* userData, HxObject* src);

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 int HxConnection::setState ( const QString &  state)
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.

Parameters
onOffThe 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.

Parameters
visibleThe 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().

Parameters
srcThe source object.
Returns
True if src is a valid source, otherwise false.

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