umbrello  2.32.3
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
seqlinewidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  * This program is free software; you can redistribute it and/or modify *
3  * it under the terms of the GNU General Public License as published by *
4  * the Free Software Foundation; either version 2 of the License, or *
5  * (at your option) any later version. *
6  * *
7  * copyright (C) 2002-2020 *
8  * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
9  ***************************************************************************/
10 
11 #ifndef SEQLINEWIDGET_H
12 #define SEQLINEWIDGET_H
13 
14 #include <QGraphicsLineItem>
15 
16 #include <QPen>
17 
18 class ObjectWidget;
19 class UMLScene;
20 
26 class SeqLineWidget : public QGraphicsLineItem
27 {
28 public:
29  SeqLineWidget(UMLScene *scene, ObjectWidget * pObject);
30  virtual ~SeqLineWidget();
31 
32  bool onWidget(const QPointF& p);
33 
34  bool onDestructionBox(const QPointF& p);
35 
36  void cleanup();
37 
38  void setupDestructionBox();
39 
40  void setStartPoint(int startX, int startY);
41 
47  int getLineLength() {
48  return m_nLengthY;
49  }
50 
57  return m_pObject;
58  }
59 
60  void setEndOfLine(int yPosition);
61  void setLineColorCmd(const QColor &color);
62 
63 protected:
64  void cleanupDestructionBox();
65 
66  void moveDestructionBox();
67 
70 
71  struct DestructionBox {
72  QGraphicsLineItem * line1{nullptr};
73  QGraphicsLineItem * line2{nullptr};
74  void setLineColorCmd(const QColor &color)
75  {
76  if (!line1)
77  return;
78  QPen pen = line1->pen();
79  pen.setColor(color);
80  line1->setPen(pen);
81  line2->setPen(pen);
82  }
83 
84  void setLine1Points(QRect rect) {
85  line1->setLine(rect.x(), rect.y(),
86  rect.x() + rect.width(), rect.y() + rect.height());
87  }
88  void setLine2Points(QRect rect) {
89  line2->setLine(rect.x(), rect.y() + rect.height(),
90  rect.x() + rect.width(), rect.y());
91  }
93 
94  int m_nLengthY;
95 
96  static int const m_nMouseDownEpsilonX;
97  void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);
98 };
99 
100 #endif
Displays an instance of a Concept.
Definition: objectwidget.h:33
Widget class for graphical representation of sequence lines.
Definition: seqlinewidget.h:27
bool onDestructionBox(const QPointF &p)
Definition: seqlinewidget.cpp:82
void cleanupDestructionBox()
Definition: seqlinewidget.cpp:125
int m_nLengthY
the length of the line
Definition: seqlinewidget.h:94
ObjectWidget * m_pObject
ObjectWidget associated with this sequence line.
Definition: seqlinewidget.h:68
ObjectWidget * getObjectWidget()
Definition: seqlinewidget.h:56
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Definition: seqlinewidget.cpp:211
virtual ~SeqLineWidget()
Definition: seqlinewidget.cpp:49
void moveDestructionBox()
Definition: seqlinewidget.cpp:168
struct SeqLineWidget::DestructionBox m_DestructionBox
the destruction box
int getLineLength()
Definition: seqlinewidget.h:47
void cleanup()
Definition: seqlinewidget.cpp:103
void setLineColorCmd(const QColor &color)
Definition: seqlinewidget.cpp:203
SeqLineWidget(UMLScene *scene, ObjectWidget *pObject)
Definition: seqlinewidget.cpp:33
UMLScene * m_scene
scene displayed on
Definition: seqlinewidget.h:69
void setupDestructionBox()
Definition: seqlinewidget.cpp:138
bool onWidget(const QPointF &p)
Definition: seqlinewidget.cpp:61
void setStartPoint(int startX, int startY)
Definition: seqlinewidget.cpp:114
void setEndOfLine(int yPosition)
Definition: seqlinewidget.cpp:187
static int const m_nMouseDownEpsilonX
margin used for mouse clicks
Definition: seqlinewidget.h:96
Definition: umlscene.h:69
Definition: seqlinewidget.h:71
QGraphicsLineItem * line1
Definition: seqlinewidget.h:72
void setLine1Points(QRect rect)
Definition: seqlinewidget.h:84
QGraphicsLineItem * line2
Definition: seqlinewidget.h:73
void setLine2Points(QRect rect)
Definition: seqlinewidget.h:88
void setLineColorCmd(const QColor &color)
Definition: seqlinewidget.h:74