26 #include <QStyleOptionGraphicsItem>
30 const QColor EditableNodeItem::DEFAULT_HIGHLIGHT_COLOR(230,0,0,255);
34 m_highlight_color(DEFAULT_HIGHLIGHT_COLOR), m_prev_pos((*node)[0], (*node)[1]), m_radius(radius)
36 setPos((*node)[0], (*node)[1]);
37 setFlag(QGraphicsItem::ItemSendsGeometryChanges);
38 setAcceptHoverEvents(
true);
45 return m_node->IsAtBoundary();
50 return m_node == node;
55 QPen pen(this->pen());
59 setBrush(m_highlight_color);
70 m_highlight_color = color;
75 toolTip.append(QString(
"ID: ") + QString::number(m_node->GetIndex()) +
"\n\n");
76 toolTip.append(QString(
"fixed: ") + (m_node->IsFixed() ?
"true" :
"false") +
'\n');
77 toolTip.append(QString(
"sam: ") + (m_node->IsFixed() ?
"true" :
"false") +
"\n\n");
78 toolTip.append(
"cells: ");
80 toolTip.append(QString::number(c->GetIndex()) +
' ');
83 toolTip.append(
"walls: ");
85 toolTip.append(QString::number(w->GetIndex()) +
' ');
103 setPos((*m_node)[0], (*m_node)[1]);
107 QVariant EditableNodeItem::itemChange(GraphicsItemChange change,
const QVariant &value)
109 if (change == QGraphicsItem::ItemPositionChange) {
115 return QGraphicsItem::itemChange(change, value);
118 void EditableNodeItem::paint(QPainter* painter,
const QStyleOptionGraphicsItem* option,
QWidget* widget)
120 if (flags().testFlag(QGraphicsItem::ItemIsSelectable)) {
121 setBrush(QBrush(QColor(220,220,220,255)));
122 setRect(-m_radius, -m_radius, 2*m_radius, 2*m_radius);
125 setBrush(QBrush(QColor(255,255,255,255)));
126 setRect(-0.5, -0.5, 1, 1);
130 QStyleOptionGraphicsItem noRectBorder(*option);
131 noRectBorder.state &= !QStyle::State_Selected;
132 QGraphicsEllipseItem::paint(painter, &noRectBorder, widget);
virtual void SetHighlightColor(const QColor &color=DEFAULT_HIGHLIGHT_COLOR)
Set the color the item should get when it gets highlighted.
void Moved()
Emitted when this node has been moved in the scene.
A cell contains walls and nodes.
Namespace for SimPT tissue editor package.
SimPT_Sim::Node * Node() const
Get the node associated with this item.
virtual ~EditableNodeItem()
Destructor.
void Update()
Update the node.
virtual bool IsAtBoundary() const
Checks whether the node is at the boundary of the complex.
void SetToolTip(std::list< SimPT_Sim::Cell * > cells, std::list< SimPT_Sim::Wall * > walls)
Update the tool tip of this item.
see the online Qt documentation
bool Contains(SimPT_Sim::Node *node) const
Checks whether this item represents the given node.
virtual void Highlight(bool highlighted)
Highlights the node in the canvas.
Interface for EditableNodeItem.
void Revert()
Revert the node to its previous position.
see the online Qt documentation
A cell wall, runs between cell corner points and consists of wall elements.
EditableNodeItem(SimPT_Sim::Node *node, double radius)
Constructor.