26 #include <QGraphicsPolygonItem>
27 #include <QStyleOptionGraphicsItem>
36 const QColor EditableEdgeItem::DEFAULT_HIGHLIGHT_COLOR(230,0,0,255);
39 :
QGraphicsLineItem(), m_endpoint1(node1), m_endpoint2(node2), m_highlight_color(DEFAULT_HIGHLIGHT_COLOR)
45 connect(m_endpoint1, SIGNAL(Moved()),
this, SLOT(
Update()));
46 connect(m_endpoint2, SIGNAL(Moved()),
this, SLOT(
Update()));
58 return (m_endpoint1 == endpoint || m_endpoint2 == endpoint);
68 if (m_endpoint1 == edge->m_endpoint1 || m_endpoint1 == edge->m_endpoint2) {
71 else if (m_endpoint2 == edge->m_endpoint1 || m_endpoint2 == edge->m_endpoint2) {
86 QPen pen(this->pen());
88 pen.setBrush(m_highlight_color);
95 m_highlight_color = color;
104 assert(connectedNode !=
nullptr &&
"The edges don't have a connecting point.");
107 if (m_endpoint1 != connectedNode) {
108 firstNode = m_endpoint1;
111 firstNode = m_endpoint2;
113 if (edge->
First() != connectedNode) {
114 secondNode = edge->
First();
117 secondNode = edge->
Second();
131 return std::make_pair(edge1, edge2);
136 setLine(QLineF(m_endpoint1->pos(), m_endpoint2->pos()));
139 void EditableEdgeItem::paint(QPainter* painter,
const QStyleOptionGraphicsItem* option,
QWidget* widget)
141 QPen pen(this->pen());
142 if (flags().testFlag(QGraphicsItem::ItemIsSelectable)) {
143 pen.setBrush(QBrush(QColor(190,190,190,255)));
147 pen.setBrush(QBrush(QColor(0,0,0,255)));
153 QStyleOptionGraphicsItem noRectBorder(*option);
154 noRectBorder.state &= !QStyle::State_Selected;
155 QGraphicsLineItem::paint(painter, &noRectBorder, widget);
virtual void Highlight(bool highlighted)
Highlights the edge in the canvas.
EditableNodeItem * Second() const
Returns the second endpoint of the edge item.
Namespace for SimPT tissue editor package.
SimPT_Sim::Node * Node() const
Get the node associated with this item.
virtual bool IsAtBoundary() const
Checks whether the node is at the boundary of the complex.
bool ContainsEndpoint(EditableNodeItem *endpoint) const
Checks whether the given endpoint is an endpoint of this edge.
see the online Qt documentation
virtual void SetHighlightColor(const QColor &color=DEFAULT_HIGHLIGHT_COLOR)
Set the color the item should get when it gets highlighted.
SimPT_Sim::Edge Edge() const
Returns the edge associated with this item.
virtual void Update()
Update the edge.
An Edge connects two nodes and is ambidextrous.
EditableEdgeItem * MergeEdge(EditableEdgeItem *edge)
Merge the given edge with this edge into one.
void EdgeMerged(EditableEdgeItem *oldEdge1, EditableEdgeItem *oldEdge2, EditableEdgeItem *edge)
Emitted when the two given edges should be replaced by the new edge.
Editable graphical representation for Edge.
EditableEdgeItem(EditableNodeItem *node1, EditableNodeItem *node2)
Constructor.
Editable graphical representation for Node.
EditableNodeItem * First() const
Returns the first endpoint of the edge item.
Interface for EditableNodeItem.
EditableNodeItem * ConnectingNode(EditableEdgeItem *edge) const
Returns the connecting node when this edge and the given edge connect.
bool ContainsEndpoints(EditableNodeItem *endpoint1, EditableNodeItem *endpoint2) const
Checks whether the given endpoints match the endpoints of this edge.
std::pair< EditableEdgeItem *, EditableEdgeItem * > SplitEdge(EditableNodeItem *node)
Split the edge in two edges on the given node.
virtual bool IsAtBoundary() const
Checks whether the endpoints of the edge are at the boundary of the cell complex. ...
see the online Qt documentation
virtual ~EditableEdgeItem()
Destructor.
void EdgeSplitted(EditableEdgeItem *oldEdge, EditableEdgeItem *edge1, EditableEdgeItem *edge2)
Emitted when a given edge should be replaced with two other edges.
Interface for EditableEdgeItem.