![]() |
TinkerCell Core 1.0
TinkerCell's Core library providing all basic functionalities
|
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>
Public Member Functions | |
ItemHandle (const QString &name=QString()) | |
default constructor | |
ItemHandle (const ItemHandle &) | |
copy constructor | |
virtual ItemHandle & | operator= (const ItemHandle &) |
operator = | |
virtual | ~ItemHandle () |
destructor -- does nothing | |
virtual ItemHandle * | clone () const |
clone the data and lists | |
virtual ItemFamily * | family () 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 ItemHandle * | root (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 ItemHandle * | parentOfFamily (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 | |
NumericalDataTable & | numericalDataTable (const QString &name) |
gets reference to a numerical table with the given name. Makes the table if needed | |
TextDataTable & | textDataTable (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 | |
NetworkHandle * | network |
the network that this item belongs in | |
ItemHandle * | parent |
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 | |
ItemData * | data |
the data (from each tool) for this handle |
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.
Tinkercell::ItemHandle::ItemHandle | ( | const QString & | name = QString() | ) |
default constructor
QString | name |
Definition at line 178 of file ItemHandle.cpp.
Tinkercell::ItemHandle::ItemHandle | ( | const ItemHandle & | copy | ) |
copy constructor
ItemHandle& | handle to copy |
Definition at line 187 of file ItemHandle.cpp.
Tinkercell::ItemHandle::~ItemHandle | ( | ) | [virtual] |
destructor -- does nothing
Definition at line 141 of file ItemHandle.cpp.
QList< ItemHandle * > Tinkercell::ItemHandle::allChildren | ( | ) | const [virtual] |
gets the all child handles and their child handles
Definition at line 593 of file ItemHandle.cpp.
QList< QGraphicsItem * > Tinkercell::ItemHandle::allGraphicsItems | ( | ) | const [virtual] |
gets the graphics items belonging to this handle and all child handes
Definition at line 415 of file ItemHandle.cpp.
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.
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.
void Tinkercell::ItemHandle::copyDataTablesFrom | ( | ItemHandle * | copy | ) | [virtual] |
copy data from one handle to another
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.
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.
QString Tinkercell::ItemHandle::fullName | ( | const QString & | sep = QString(".") | ) | const [virtual] |
The full name includes all the parent names appended using a dot.
QString | replace the dot with some other separator |
Definition at line 340 of file ItemHandle.cpp.
bool Tinkercell::ItemHandle::hasNumericalData | ( | const QString & | name | ) | const |
does this handle have a numerical data table with this name?
QString | name of tool, e.g. "Numerical Attributes" |
Definition at line 405 of file ItemHandle.cpp.
bool Tinkercell::ItemHandle::hasTextData | ( | const QString & | name | ) | const |
does this handle have a text data table with this name?
QString | name of tool, e.g. "Text Attributes" |
Definition at line 410 of file ItemHandle.cpp.
bool Tinkercell::ItemHandle::isA | ( | const ItemFamily * | family | ) | const [virtual] |
determines whether this handle belongs to the speicific family.
QString | the family |
Definition at line 355 of file ItemHandle.cpp.
bool Tinkercell::ItemHandle::isA | ( | const QString & | family | ) | const [virtual] |
determines whether this handle belongs to the speicific family.
QString | the family name |
Definition at line 360 of file ItemHandle.cpp.
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
ItemHandle* | parent handle |
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
QString | name of tool, e.g. "Numerical Attributes" |
QString | row name in data table |
QString | column name data table |
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
QString | name of tool, e.g. "Numerical Attributes" |
int | row in data table |
int | column in data table |
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
QString | name of tool, e.g. "Numerical Attributes" |
int | row in data table |
int | column in data table |
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
QString | name of tool, e.g. "Numerical Attributes" |
QString | row name in data table |
QString | column name data table |
Definition at line 510 of file ItemHandle.cpp.
QStringList Tinkercell::ItemHandle::numericalDataNames | ( | ) | const |
all the numerical data table names
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
QString | name of tool, e.g. "Numerical Attributes" |
Definition at line 567 of file ItemHandle.cpp.
ItemHandle & Tinkercell::ItemHandle::operator= | ( | const ItemHandle & | copy | ) | [virtual] |
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
ItemHandle* | the family name |
Definition at line 380 of file ItemHandle.cpp.
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.
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
ItemHandle* | the family name |
Definition at line 365 of file ItemHandle.cpp.
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.
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.
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
QString | name of tool, e.g. "Text Attributes" |
QString | row name in data table |
QString | column name data table |
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
QString | name of tool, e.g. "Text Attributes" |
int | row in data table |
int | column in data table |
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
QString | name of tool, e.g. "Text Attributes" |
int | row in data table |
int | column in data table |
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
QString | name of tool, e.g. "Text Attributes" |
QString | row name in data table |
QString | column name data table |
Definition at line 545 of file ItemHandle.cpp.
QStringList Tinkercell::ItemHandle::textDataNames | ( | ) | const |
all the numerical text table names
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
QString | name of tool, e.g. "Numerical Attributes" |
Definition at line 580 of file ItemHandle.cpp.
child handles that have this handle as a parent
Definition at line 112 of file ItemHandle.h.
ItemData* Tinkercell::ItemHandle::data [protected] |
the data (from each tool) for this handle
Definition at line 90 of file ItemHandle.h.
QList<QGraphicsItem*> Tinkercell::ItemHandle::graphicsItems |
list of graphical items used to draw this handle
Definition at line 103 of file ItemHandle.h.
QString Tinkercell::ItemHandle::name |
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.
QList<Tool*> Tinkercell::ItemHandle::tools |
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.