VPTissue Reference Manual
NodeItem.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 Universiteit Antwerpen
3  *
4  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
5  * the European Commission - subsequent versions of the EUPL (the "Licence");
6  * You may not use this work except in compliance with the Licence.
7  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the Licence is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the Licence for the specific language governing
13  * permissions and limitations under the Licence.
14  */
20 #include "../../cpp_simptshell/mesh_drawer/NodeItem.h"
21 
22 #include <QGraphicsScene>
23 #include <QGraphicsItem>
24 #include <QPainter>
25 #include <QStyleOption>
26 #include <Qt>
27 
28 namespace SimPT_Shell {
29 
30 using SimPT_Sim::Node;
31 
32 NodeItem::NodeItem(Node* n, double mag)
33  : m_node(n)
34 {
35  brush = Qt::darkGray;
36  ellipsesize = QRectF(-1 * mag, -1 * mag, 2 * mag, 2 * mag);
37 }
38 
39 void NodeItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
40 {
41  painter->setBrush(brush);
42  painter->setPen(Qt::NoPen);
43  painter->drawEllipse(ellipsesize);
44 }
45 
46 QPainterPath NodeItem::shape() const
47 {
48  QPainterPath path;
49  path.addEllipse(ellipsesize);
50  return path;
51 }
52 
53 QRectF NodeItem::boundingRect() const
54 {
55  qreal penwidth = 0; // painter->pen()->widthF();
56  return QRectF(ellipsesize.x() - penwidth / 2., ellipsesize.y() - penwidth / 2.,
57  ellipsesize.width() + penwidth, ellipsesize.height() + penwidth);
58 }
59 
60 void NodeItem::setColor()
61 {
62  static QColor indian_red("IndianRed");
63  static QColor deep_sky_blue("DeepSkyBlue");
64  static QColor purple("Purple");
65  Node& n = getNode();
66 
67  if (n.IsSam()) {
68  setBrush(purple);
69  } else {
70  if (n.IsAtBoundary()) {
71  setBrush(deep_sky_blue);
72  } else {
73  setBrush(indian_red);
74  }
75  }
76 }
77 
78 } // namespace
Node in cell wall.
Definition: Node.h:39
Namespace for SimPT shell package.
Definition: Client.cpp:50
see the online Qt documentation