TinkerCell Core 1.0
TinkerCell's Core library providing all basic functionalities
Public Member Functions | Public Attributes | Protected Attributes
Tinkercell::ItemHandle Class Reference

The ItemHandle represents a complete object in the network, whether it is a node or a connection. The ItemHandle contains the name of the object and pointers to all the QGraphicsItems that are used to represent the object. Tools associated with the object can be stored within the ItemHandle as well. The ItemHandle can also optionally contain an ItemFamily, which can be used to distinguish different types of nodes or connections, if needed. Each ItemHandle can contain one parent. Several functions are available for convinently getting the parents and children of an ItemHandle. More...

#include <ItemHandle.h>

Inheritance diagram for Tinkercell::ItemHandle:
Inheritance graph
[legend]
Collaboration diagram for Tinkercell::ItemHandle:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ItemHandle (const QString &name=QString())
 default constructor
 ItemHandle (const ItemHandle &)
 copy constructor
virtual ItemHandleoperator= (const ItemHandle &)
 operator =
virtual ~ItemHandle ()
 destructor -- does nothing
virtual ItemHandleclone () const
 clone the data and lists
virtual ItemFamilyfamily () const
 family that this items belongs in. Used for characterizing the nodes and connections.
virtual void setFamily (ItemFamily *, bool useCommand=true)
 set the family that this items belongs in.
virtual bool isA (const ItemFamily *family) const
 determines whether this handle belongs to the speicific family.
virtual bool isA (const QString &family) const
 determines whether this handle belongs to the speicific family.
virtual QString fullName (const QString &sep=QString(".")) const
 The full name includes all the parent names appended using a dot.
virtual void setParent (ItemHandle *parent, bool useCommand=true)
 Set the parent for this handle.
virtual void rename (const QString &)
 set name of this handle and also adds undo command to history window and emits associated signal(s)
virtual void changeData (const QString &hashstring, const NumericalDataTable *newdata)
 change numerical data table and also adds undo command to history window and emits associated signal(s)
virtual void changeData (const QString &hashstring, const TextDataTable *newdata)
 change text data table and also adds undo command to history window and emits associated signal(s)
virtual ItemHandleroot (const QString &family=QString("")) const
 get the top-level handle such that it is of the specified family. If no family is specified, then gets the top-level handle
virtual ItemHandleparentOfFamily (const QString &family) const
 get the bottom-most parent handle such that it is of the specified family. If no family is specified, then gets the top-level handle
virtual bool isChildOf (ItemHandle *handle) const
 checks if an item is the parent or parent's parent, or parent's parent's parent, etc. Note: self->isChildOf(self) is false
virtual int depth () const
 counts the number of parents that have to be traversed in order to reach the root handle. If this handle has no parents, the values returned is 0. If its parent has no parent, then the value is 1, and so on.
virtual QList< QGraphicsItem * > allGraphicsItems () const
 gets the graphics items belonging to this handle and all child handes
virtual QList< ItemHandle * > allChildren () const
 gets the all child handles and their child handles
QStringList numericalDataNames () const
 all the numerical data table names
QStringList textDataNames () const
 all the numerical text table names
bool hasNumericalData (const QString &name) const
 does this handle have a numerical data table with this name?
bool hasTextData (const QString &name) const
 does this handle have a text data table with this name?
qreal numericalData (const QString &name, int row=0, int column=0) const
 gets a numerical attribute with the given name, row, column
qreal numericalData (const QString &name, const QString &row, const QString &column=QString()) const
 gets a numerical attribute with the given name, row, column
QString textData (const QString &name, int row=0, int column=0) const
 gets a text attribute with the given name, row, column
QString textData (const QString &name, const QString &row, const QString &column=QString()) const
 gets a text attribute with the given name, row, column
qreal & numericalData (const QString &name, int row=0, int column=0)
 gets a reference to the numerical attribute with the given name, row, column
qreal & numericalData (const QString &name, const QString &row, const QString &column=QString())
 gets a reference to the numerical attribute with the given name, row, column
QString & textData (const QString &name, int row=0, int column=0)
 gets a reference to the text attribute with the given name, row, column
QString & textData (const QString &name, const QString &row, const QString &column=QString())
 gets a reference to the text attribute with the given name, row, column
NumericalDataTablenumericalDataTable (const QString &name)
 gets reference to a numerical table with the given name. Makes the table if needed
TextDataTabletextDataTable (const QString &name)
 gets reference to a text table with the given name. Makes the table if needed
virtual void copyDataTablesFrom (ItemHandle *)
 copy data from one handle to another

Public Attributes

QString name
 name of this item
QList< QGraphicsItem * > graphicsItems
 list of graphical items used to draw this handle
QList< Tool * > tools
 list of tools associated with this handle
NetworkHandlenetwork
 the network that this item belongs in
ItemHandleparent
 this handles immediate parent (main parent if there are more than one)
QList< ItemHandle * > children
 child handles that have this handle as a parent
int type
 type of this handle (sub-classes can specify type)

Protected Attributes

ItemDatadata
 the data (from each tool) for this handle

Detailed Description

The ItemHandle represents a complete object in the network, whether it is a node or a connection. The ItemHandle contains the name of the object and pointers to all the QGraphicsItems that are used to represent the object. Tools associated with the object can be stored within the ItemHandle as well. The ItemHandle can also optionally contain an ItemFamily, which can be used to distinguish different types of nodes or connections, if needed. Each ItemHandle can contain one parent. Several functions are available for convinently getting the parents and children of an ItemHandle.

Use setHandle and getHandle functions to get and set the handles for QGraphicsItems. Use h->data->numericalData[string] or h->data->textData[string] to get the DataTable with the particular name. Alternatively, h->numericalData(string) or h->textData(string) can be used to access the data conviniently.

The SymbolsTable is used to store all the handles in a network.

Definition at line 83 of file ItemHandle.h.


Constructor & Destructor Documentation

Tinkercell::ItemHandle::ItemHandle ( const QString &  name = QString())

default constructor

Parameters:
QStringname

Definition at line 178 of file ItemHandle.cpp.

Here is the caller graph for this function:

Tinkercell::ItemHandle::ItemHandle ( const ItemHandle copy)

copy constructor

Parameters:
ItemHandle&handle to copy

Definition at line 187 of file ItemHandle.cpp.

Here is the call graph for this function:

Tinkercell::ItemHandle::~ItemHandle ( ) [virtual]

destructor -- does nothing

Definition at line 141 of file ItemHandle.cpp.

Here is the call graph for this function:


Member Function Documentation

QList< ItemHandle * > Tinkercell::ItemHandle::allChildren ( ) const [virtual]

gets the all child handles and their child handles

Returns:
QList<ItemHandle*> list of handles

Definition at line 593 of file ItemHandle.cpp.

Here is the caller graph for this function:

QList< QGraphicsItem * > Tinkercell::ItemHandle::allGraphicsItems ( ) const [virtual]

gets the graphics items belonging to this handle and all child handes

Returns:
QList<QGraphicsItem*> list of graphics items

Definition at line 415 of file ItemHandle.cpp.

Here is the caller graph for this function:

void Tinkercell::ItemHandle::changeData ( const QString &  hashstring,
const NumericalDataTable newdata 
) [virtual]

change numerical data table and also adds undo command to history window and emits associated signal(s)

Definition at line 255 of file ItemHandle.cpp.

Here is the call graph for this function:

virtual void Tinkercell::ItemHandle::changeData ( const QString &  hashstring,
const TextDataTable newdata 
) [virtual]

change text data table and also adds undo command to history window and emits associated signal(s)

ItemHandle * Tinkercell::ItemHandle::clone ( ) const [virtual]

clone the data and lists

Reimplemented in Tinkercell::NodeHandle, and Tinkercell::ConnectionHandle.

Definition at line 235 of file ItemHandle.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Tinkercell::ItemHandle::copyDataTablesFrom ( ItemHandle copy) [virtual]

copy data from one handle to another

Parameters:
ItemHandle* handle to copy from

Definition at line 225 of file ItemHandle.cpp.

int Tinkercell::ItemHandle::depth ( ) const [virtual]

counts the number of parents that have to be traversed in order to reach the root handle. If this handle has no parents, the values returned is 0. If its parent has no parent, then the value is 1, and so on.

Returns:
int

Definition at line 327 of file ItemHandle.cpp.

ItemFamily * Tinkercell::ItemHandle::family ( ) const [virtual]

family that this items belongs in. Used for characterizing the nodes and connections.

Reimplemented in Tinkercell::NodeHandle, and Tinkercell::ConnectionHandle.

Definition at line 240 of file ItemHandle.cpp.

Here is the caller graph for this function:

QString Tinkercell::ItemHandle::fullName ( const QString &  sep = QString(".")) const [virtual]

The full name includes all the parent names appended using a dot.

Parameters:
QStringreplace the dot with some other separator

Definition at line 340 of file ItemHandle.cpp.

Here is the caller graph for this function:

bool Tinkercell::ItemHandle::hasNumericalData ( const QString &  name) const

does this handle have a numerical data table with this name?

Parameters:
QStringname of tool, e.g. "Numerical Attributes"
Returns:
bool true = has a numerical table by this name. false = does not have a numerical table by this name

Definition at line 405 of file ItemHandle.cpp.

Here is the caller graph for this function:

bool Tinkercell::ItemHandle::hasTextData ( const QString &  name) const

does this handle have a text data table with this name?

Parameters:
QStringname of tool, e.g. "Text Attributes"
Returns:
bool true = has a text table by this name. false = does not have a text table by this name

Definition at line 410 of file ItemHandle.cpp.

Here is the caller graph for this function:

bool Tinkercell::ItemHandle::isA ( const ItemFamily family) const [virtual]

determines whether this handle belongs to the speicific family.

Parameters:
QStringthe family

Definition at line 355 of file ItemHandle.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Tinkercell::ItemHandle::isA ( const QString &  family) const [virtual]

determines whether this handle belongs to the speicific family.

Parameters:
QStringthe family name

Definition at line 360 of file ItemHandle.cpp.

Here is the call graph for this function:

bool Tinkercell::ItemHandle::isChildOf ( ItemHandle handle) const [virtual]

checks if an item is the parent or parent's parent, or parent's parent's parent, etc. Note: self->isChildOf(self) is false

Parameters:
ItemHandle*parent handle
Returns:
Boolean is child

Definition at line 313 of file ItemHandle.cpp.

qreal Tinkercell::ItemHandle::numericalData ( const QString &  name,
const QString &  row,
const QString &  column = QString() 
) const

gets a numerical attribute with the given name, row, column

Parameters:
QStringname of tool, e.g. "Numerical Attributes"
QStringrow name in data table
QStringcolumn name data table
Returns:
double value

Definition at line 444 of file ItemHandle.cpp.

qreal Tinkercell::ItemHandle::numericalData ( const QString &  name,
int  row = 0,
int  column = 0 
) const

gets a numerical attribute with the given name, row, column

Parameters:
QStringname of tool, e.g. "Numerical Attributes"
introw in data table
intcolumn in data table
Returns:
double value

Definition at line 434 of file ItemHandle.cpp.

qreal & Tinkercell::ItemHandle::numericalData ( const QString &  name,
int  row = 0,
int  column = 0 
)

gets a reference to the numerical attribute with the given name, row, column

Parameters:
QStringname of tool, e.g. "Numerical Attributes"
introw in data table
intcolumn in data table
Returns:
double reference value

Definition at line 497 of file ItemHandle.cpp.

qreal & Tinkercell::ItemHandle::numericalData ( const QString &  name,
const QString &  row,
const QString &  column = QString() 
)

gets a reference to the numerical attribute with the given name, row, column

Parameters:
QStringname of tool, e.g. "Numerical Attributes"
QStringrow name in data table
QStringcolumn name data table
Returns:
double reference value

Definition at line 510 of file ItemHandle.cpp.

QStringList Tinkercell::ItemHandle::numericalDataNames ( ) const

all the numerical data table names

Returns:
QStringList

Definition at line 391 of file ItemHandle.cpp.

DataTable< qreal > & Tinkercell::ItemHandle::numericalDataTable ( const QString &  name)

gets reference to a numerical table with the given name. Makes the table if needed

Parameters:
QStringname of tool, e.g. "Numerical Attributes"
Returns:
DataTable<double>& reference of table

Definition at line 567 of file ItemHandle.cpp.

Here is the caller graph for this function:

ItemHandle & Tinkercell::ItemHandle::operator= ( const ItemHandle copy) [virtual]

operator =

Definition at line 203 of file ItemHandle.cpp.

Here is the call graph for this function:

ItemHandle * Tinkercell::ItemHandle::parentOfFamily ( const QString &  family) const [virtual]

get the bottom-most parent handle such that it is of the specified family. If no family is specified, then gets the top-level handle

Parameters:
ItemHandle*the family name

Definition at line 380 of file ItemHandle.cpp.

Here is the call graph for this function:

void Tinkercell::ItemHandle::rename ( const QString &  s) [virtual]

set name of this handle and also adds undo command to history window and emits associated signal(s)

Definition at line 249 of file ItemHandle.cpp.

Here is the call graph for this function:

ItemHandle * Tinkercell::ItemHandle::root ( const QString &  family = QString("")) const [virtual]

get the top-level handle such that it is of the specified family. If no family is specified, then gets the top-level handle

Parameters:
ItemHandle*the family name

Definition at line 365 of file ItemHandle.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Tinkercell::ItemHandle::setFamily ( ItemFamily ,
bool  useCommand = true 
) [virtual]

set the family that this items belongs in.

Reimplemented in Tinkercell::NodeHandle, and Tinkercell::ConnectionHandle.

Definition at line 245 of file ItemHandle.cpp.

void Tinkercell::ItemHandle::setParent ( ItemHandle parent,
bool  useCommand = true 
) [virtual]

Set the parent for this handle.

Parameters:
ItemHandle* parent
bool(optional) whether to call network's set parent command, which will update the history stack
ItemHandle*parent handle

Definition at line 293 of file ItemHandle.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QString Tinkercell::ItemHandle::textData ( const QString &  name,
const QString &  row,
const QString &  column = QString() 
) const

gets a text attribute with the given name, row, column

Parameters:
QStringname of tool, e.g. "Text Attributes"
QStringrow name in data table
QStringcolumn name data table
Returns:
QString value

Definition at line 476 of file ItemHandle.cpp.

QString Tinkercell::ItemHandle::textData ( const QString &  name,
int  row = 0,
int  column = 0 
) const

gets a text attribute with the given name, row, column

Parameters:
QStringname of tool, e.g. "Text Attributes"
introw in data table
intcolumn in data table
Returns:
QString value

Definition at line 465 of file ItemHandle.cpp.

QString & Tinkercell::ItemHandle::textData ( const QString &  name,
int  row = 0,
int  column = 0 
)

gets a reference to the text attribute with the given name, row, column

Parameters:
QStringname of tool, e.g. "Text Attributes"
introw in data table
intcolumn in data table
Returns:
QString reference value

Definition at line 532 of file ItemHandle.cpp.

QString & Tinkercell::ItemHandle::textData ( const QString &  name,
const QString &  row,
const QString &  column = QString() 
)

gets a reference to the text attribute with the given name, row, column

Parameters:
QStringname of tool, e.g. "Text Attributes"
QStringrow name in data table
QStringcolumn name data table
Returns:
QString& reference value

Definition at line 545 of file ItemHandle.cpp.

QStringList Tinkercell::ItemHandle::textDataNames ( ) const

all the numerical text table names

Returns:
QStringList

Definition at line 398 of file ItemHandle.cpp.

DataTable< QString > & Tinkercell::ItemHandle::textDataTable ( const QString &  name)

gets reference to a text table with the given name. Makes the table if needed

Parameters:
QStringname of tool, e.g. "Numerical Attributes"
Returns:
TextDataTable& reference of table

Definition at line 580 of file ItemHandle.cpp.

Here is the caller graph for this function:


Member Data Documentation

child handles that have this handle as a parent

Definition at line 112 of file ItemHandle.h.

the data (from each tool) for this handle

See also:
ItemData

Definition at line 90 of file ItemHandle.h.

list of graphical items used to draw this handle

Definition at line 103 of file ItemHandle.h.

name of this item

Definition at line 101 of file ItemHandle.h.

the network that this item belongs in

Definition at line 108 of file ItemHandle.h.

this handles immediate parent (main parent if there are more than one)

Definition at line 110 of file ItemHandle.h.

list of tools associated with this handle

Definition at line 105 of file ItemHandle.h.

type of this handle (sub-classes can specify type)

Definition at line 114 of file ItemHandle.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines