Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
edge.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
23 #ifndef EDGE_H
24 #define EDGE_H
25 
26 #include <QGraphicsObject>
27 #include <memory>
28 #include "latexLink.h"
29 
30 class QAction;
31 namespace Qt{
32 class QGraphicsSceneMouseEvent;
33 }
34 
35 class Node;
36 class Diagram;
37 class DiagramWidget;
38 class Proxy;
39 
40 class Edge: public QGraphicsObject
41 {
42  Q_OBJECT
43 
44  friend class DiagramWidget;
45 
46 public:
48 
49  Edge(Diagram *DiagramWidget,
50  Node *t_first,
51  Node *t_second);
52 
53  virtual ~Edge() override;
54 
55  QString getName() const;
56  qint32 getLineWidth() const { return lineWidth; }
57 
58  const Node* getFirst() const;
59  const Node* getSecond() const;
60  Node* getFirst();
61  Node* getSecond();
62 
63  bool isConnectedTo(Node const* node) const;
64  bool isFlipped() const { return flippedLabel; }
65  bool hasFocusInGraph() const;
66  void focusInGraph();
67  void unFocusInGraph();
68  void wheelEventCustom(int delta);
69 
70  bool getSign() const { return particleType > 0; }
71  qint32 getParticleType() { return std::abs(particleType); }
72  QColor getColor() const;
73  QColor getPaintColor() const;
74  qreal length() const;
75  double getCurve() const;
76  void setCurve(double t_curve);
77  qreal getCurvature() const;
78  void setCurvature(double curvature);
79 
80  void setDiagramWidget(DiagramWidget *t_widget) {
81  widget = t_widget;
82  }
83  void setSides(Node *t_first,
84  Node *t_second);
85  void flipLabel() {
86  setFlipped(!flippedLabel);
87  }
88  void setColor(QColor t_color) {
89  color = t_color;
90  }
91 
92  void setParticleType(qint32 t_type);
93 
94  enum { Type = static_cast<int>(UserType) + 2 };
95  int type() const override { return Type; }
96 
97  QRectF boundingRect() const override;
98  QPainterPath shape() const override;
99  void paint(QPainter *painter,
100  QStyleOptionGraphicsItem const*option,
101  QWidget *widget) override;
102 
103  void paintLine(QPainter *painter) const;
104  void paintDashedLine(QPainter *painter) const;
105  void paintDotLine(QPainter *painter) const;
106  void paintSinusoid(QPainter *painter) const;
107  void paintCycloid(QPainter *painter) const;
108  void paintArrow(QPainter *painter) const;
109 
110 public slots:
111 
112  void changeColor();
113  void changeName();
114  void setName(QString const& t_name);
115  void setLineWidth(qint32 t_lineWidth);
116  void setFlipped(bool t_flipped) {
117  flippedLabel = t_flipped;
118  setName(getName());
119  }
120  void release();
121  void nodeMoved();
122  void changeEdgeType(QAction *action);
123 
124 protected:
125  void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
126  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
127  void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
128  void keyPressEvent(QKeyEvent *event) override;
129 
130 public:
131 
132  Proxy *label = nullptr;
133 
134 private:
135 
136  Diagram *graph;
137  DiagramWidget *widget;
138  Node *first;
139  Node *second;
140  bool flippedLabel;
141  QColor color;
142  mutable int signCurvature = 0;
143  mutable qreal curvature;
144  qint32 lineWidth;
145  qint32 amplitude;
146  qint32 particleType;
147  bool selected;
148 };
149 
150 #endif // EDGE_H
Definition: node.h:39
Type
Definition: curvature.cpp:21
Definition: edge.h:40
Definition: diagram.h:52
Definition: edge.h:31
Definition: diagramwidget.h:43
Type
Different types of gauge ficing parameter for gauge boson propagators.
Definition: gaugedGroup.h:92
Definition: diagram.h:243
Definition: amplitudeSimplification.h:38