/
QGIViewBalloon.h
177 lines (146 loc) · 5.84 KB
/
QGIViewBalloon.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/***************************************************************************
* Copyright (c) 2013 Luke Parry <l.parry@warwick.ac.uk> *
* Copyright (c) 2019 Franck Jullien <franck.jullien@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef TECHDRAWGUI_QGIVBALLOON_H
#define TECHDRAWGUI_QGIVBALLOON_H
#include <QObject>
#include <QGraphicsView>
#include <QStyleOptionGraphicsItem>
#include <QGraphicsItem>
#include <QGraphicsObject>
#include <QColor>
#include <QFont>
#include <Base/Vector3D.h>
#include "QGIView.h"
#include "QGIViewPart.h"
#include "QGCustomText.h"
#include "QGIViewDimension.h"
namespace TechDraw {
class DrawViewBalloon;
}
namespace TechDraw {
class BaseGeom;
class AOC;
}
namespace TechDrawGui
{
class QGIArrow;
class QGIDimLines;
class QGIViewBalloon;
class QGIBalloonLabel : public QGraphicsObject
{
Q_OBJECT
public:
QGIBalloonLabel();
virtual ~QGIBalloonLabel() = default;
enum {Type = QGraphicsItem::UserType + 141};
int type() const override { return Type;}
virtual QRectF boundingRect() const override;
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
virtual void paint( QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr ) override;
void setLabelCenter();
void setPosFromCenter(const double &xCenter, const double &yCenter);
double X() const { return posX; }
double Y() const { return posY; } //minus posY?
void setFont(QFont f);
QFont getFont(void) { return m_labelText->font(); }
void setDimString(QString t);
void setDimString(QString t, qreal maxWidth);
void setPrettySel(void);
void setPrettyPre(void);
void setPrettyNormal(void);
void setColor(QColor c);
bool verticalSep;
std::vector<int> seps;
QGCustomText* getDimText(void) { return m_labelText; }
void setDimText(QGCustomText* newText) { m_labelText = newText; }
bool hasHover;
QGIViewBalloon *parent;
Q_SIGNALS:
void dragging(bool);
void hover(bool state);
void selected(bool state);
void dragFinished();
protected:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
// virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event) override;
QGCustomText* m_labelText;
QColor m_colNormal;
bool m_ctrl;
double posX;
double posY;
private:
};
//*******************************************************************
class TechDrawGuiExport QGIViewBalloon : public QGIView
{
Q_OBJECT
public:
enum {Type = QGraphicsItem::UserType + 140};
explicit QGIViewBalloon();
virtual ~QGIViewBalloon() = default;
void setViewPartFeature(TechDraw::DrawViewBalloon *obj);
int type() const override { return Type;}
virtual void drawBorder() override;
virtual void updateView(bool update = false) override;
virtual void paint( QPainter * painter,
const QStyleOptionGraphicsItem * option,
QWidget * widget = 0 ) override;
virtual QColor getNormalColor(void) override;
QString getLabelText(void);
void draw_modifier(bool modifier);
void placeBalloon(QPointF pos);
TechDraw::DrawViewBalloon *dvBalloon;
public Q_SLOTS:
void balloonLabelDragged(bool ctrl);
void balloonLabelDragFinished(void);
void select(bool state);
void hover(bool state);
void updateBalloon(bool obtuse = false);
protected:
void draw() override;
virtual QVariant itemChange( GraphicsItemChange change,
const QVariant &value ) override;
virtual void setSvgPens(void);
virtual void setPens(void);
QString getPrecision(void);
protected:
bool hasHover;
QGIBalloonLabel* balloonLabel;
QGIDimLines* balloonLines;
QGIDimLines* balloonShape;
QGIArrow* arrow;
double m_lineWidth;
bool m_obtuse;
void parentViewMousePressed(QGIView *view, QPointF pos);
QPointF *oldLabelCenter;
QGIView *parent;
};
} // namespace
#endif // TECHDRAWGUI_QGIVBALLOON_H