VPTissue Reference Manual
EditableEdgeItem.h
Go to the documentation of this file.
1 #ifndef SIMPT_EDITOR_EDITABLE_EDGE_ITEM_H_INCLUDED
2 #define SIMPT_EDITOR_EDITABLE_EDGE_ITEM_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include "editor/EditableItem.h"
23 #include "bio/Edge.h"
24 
25 #include <QGraphicsLineItem>
26 #include <QGraphicsScene>
27 
28 namespace SimPT_Editor {
29 
30 class EditableNodeItem;
31 
36 {
37  Q_OBJECT
38 public:
47 
51  virtual ~EditableEdgeItem();
52 
56  EditableNodeItem* First() const { return m_endpoint1; };
57 
61  EditableNodeItem* Second() const { return m_endpoint2; };
62 
68  virtual bool IsAtBoundary() const;
69 
76  bool ContainsEndpoint(EditableNodeItem* endpoint) const;
77 
85  bool ContainsEndpoints(EditableNodeItem* endpoint1, EditableNodeItem* endpoint2) const;
86 
94 
100  SimPT_Sim::Edge Edge() const;
101 
107  virtual void Highlight(bool highlighted);
108 
114  virtual void SetHighlightColor(const QColor& color = DEFAULT_HIGHLIGHT_COLOR);
115 
124 
131  std::pair<EditableEdgeItem*, EditableEdgeItem*> SplitEdge(EditableNodeItem* node);
132 
133 
134 signals:
142  void EdgeSplitted(EditableEdgeItem* oldEdge, EditableEdgeItem* edge1, EditableEdgeItem* edge2);
143 
151  void EdgeMerged(EditableEdgeItem* oldEdge1, EditableEdgeItem* oldEdge2, EditableEdgeItem* edge);
152 
153 public slots:
157  virtual void Update();
158 
159 private:
163  virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
164 
165 
169  EditableNodeItem* m_endpoint1;
170  EditableNodeItem* m_endpoint2;
171 
172  QColor m_highlight_color;
173 
174 private:
175  static const QColor DEFAULT_HIGHLIGHT_COLOR;
176 };
177 
178 } // namespace
179 
180 #endif // end_of_include_guard
virtual void Highlight(bool highlighted)
Highlights the edge in the canvas.
EditableNodeItem * Second() const
Returns the second endpoint of the edge item.
Interface for an editable graphical representation.
Definition: EditableItem.h:30
Namespace for SimPT tissue editor package.
Definition: Cell.h:32
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.
Definition: Edge.h:31
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.
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. ...
Interface for Edge.
Interface for EditableItem.
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.