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 
33 class SeqLineWidget : public QGraphicsLineItem
34 {
35 public:
36  SeqLineWidget(UMLScene *scene, ObjectWidget * pObject);
37  virtual ~SeqLineWidget();
38 
39  bool onWidget(const QPointF& p);
40 
41  bool onDestructionBox(const QPointF& p);
42 
43  void cleanup();
44 
45  void setupDestructionBox();
46 
47  void setStartPoint(int startX, int startY);
48 
54  int getLineLength() {
55  return m_nLengthY;
56  }
57 
64  return m_pObject;
65  }
66 
67  void setEndOfLine(int yPosition);
68  void setLineColorCmd(const QColor &color);
69 
70 protected:
71  void cleanupDestructionBox();
72 
73  void moveDestructionBox();
74 
77 
78  struct DestructionBox {
79  QGraphicsLineItem * line1{nullptr};
80  QGraphicsLineItem * line2{nullptr};
81  void setLineColorCmd(const QColor &color)
82  {
83  if (!line1)
84  return;
85  QPen pen = line1->pen();
86  pen.setColor(color);
87  line1->setPen(pen);
88  line2->setPen(pen);
89  }
90 
91  void setLine1Points(QRect rect) {
92  line1->setLine(rect.x(), rect.y(),
93  rect.x() + rect.width(), rect.y() + rect.height());
94  }
95  void setLine2Points(QRect rect) {
96  line2->setLine(rect.x(), rect.y() + rect.height(),
97  rect.x() + rect.width(), rect.y());
98  }
100 
102 
103  static int const m_nMouseDownEpsilonX;
104  void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);
105 };
106 
107 #endif
Displays an instance of a Concept.
Definition: objectwidget.h:33
Widget class for graphical representation of sequence lines.
Definition: seqlinewidget.h:34
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:101
ObjectWidget * m_pObject
ObjectWidget associated with this sequence line.
Definition: seqlinewidget.h:75
ObjectWidget * getObjectWidget()
Definition: seqlinewidget.h:63
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:54
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:76
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:103
Definition: umlscene.h:70
Definition: seqlinewidget.h:78
QGraphicsLineItem * line1
Definition: seqlinewidget.h:79
void setLine1Points(QRect rect)
Definition: seqlinewidget.h:91
QGraphicsLineItem * line2
Definition: seqlinewidget.h:80
void setLine2Points(QRect rect)
Definition: seqlinewidget.h:95
void setLineColorCmd(const QColor &color)
Definition: seqlinewidget.h:81