-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
QGIViewPart.h
151 lines (119 loc) · 5.52 KB
/
QGIViewPart.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
/***************************************************************************
* Copyright (c) 2013 Luke Parry <l.parry@warwick.ac.uk> *
* *
* 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 DRAWINGGUI_QGRAPHICSITEMVIEWPART_H
#define DRAWINGGUI_QGRAPHICSITEMVIEWPART_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <Mod/TechDraw/App/Geometry.h>
#include <Mod/TechDraw/App/LineGenerator.h>
#include <QPainter>
#include <QStyleOptionGraphicsItem>
#include "QGIView.h"
namespace TechDraw {
class DrawViewPart;
class DrawViewSection;
class DrawHatch;
class DrawGeomHatch;
class DrawViewDetail;
class DrawView;
class LineGenerator;
}
namespace TechDrawGui
{
class QGIFace;
class QGIEdge;
class QGIHighlight;
class PathBuilder;
class TechDrawGuiExport QGIViewPart : public QGIView
{
public:
explicit QGIViewPart();
~QGIViewPart() override;
enum {Type = QGraphicsItem::UserType + 102};
int type() const override { return Type;}
void paint( QPainter * painter,
const QStyleOptionGraphicsItem * option,
QWidget * widget = nullptr ) override;
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
void toggleCache(bool state) override;
void toggleCosmeticLines(bool state);
void setViewPartFeature(TechDraw::DrawViewPart *obj);
void updateView(bool update = false) override;
void tidy();
QRectF boundingRect() const override;
virtual void drawAllFaces();
virtual void drawAllEdges();
virtual void drawAllVertexes();
bool showThisEdge(TechDraw::BaseGeomPtr geom);
virtual void drawAllSectionLines();
virtual void drawSectionLine(TechDraw::DrawViewSection* s, bool b);
virtual void drawComplexSectionLine(TechDraw::DrawViewSection* viewSection, bool b);
virtual void drawCenterLines(bool b);
virtual void drawAllHighlights();
virtual void drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b);
virtual void drawMatting();
bool showSection;
void draw() override;
void rotateView() override;
virtual void highlightMoved(QGIHighlight* highlight, QPointF newPos);
static QPainterPath geomToPainterPath(TechDraw::BaseGeomPtr baseGeom, double rotation = 0.0);
/// Helper for pathArc()
/*!
* x_axis_rotation is in radian
*/
static void pathArcSegment(QPainterPath &path, double xc, double yc, double th0,
double th1, double rx, double ry, double xAxisRotation);
/// Draws an arc using QPainterPath path
/*!
* x_axis_rotation is in radian
*/
static void pathArc(QPainterPath &path, double rx, double ry, double x_axis_rotation,
bool large_arc_flag, bool sweep_flag,
double x, double y,
double curx, double cury);
bool getGroupSelection() override;
void setGroupSelection(bool isSelected) override;
void setGroupSelection(bool isSelected, const std::vector<std::string> &subNames) override;
virtual QGraphicsItem *getQGISubItemByName(const std::string &subName) const;
virtual bool removeSelectedCosmetic() const;
protected:
QPainterPath drawPainterPath(TechDraw::BaseGeomPtr baseGeom) const;
void drawViewPart();
QGIFace* drawFace(TechDraw::FacePtr f, int idx);
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
TechDraw::DrawHatch* faceIsHatched(int i, std::vector<TechDraw::DrawHatch*> hatchObjs) const;
TechDraw::DrawGeomHatch* faceIsGeomHatched(int i, std::vector<TechDraw::DrawGeomHatch*> geomObjs) const;
void dumpPath(const char* text, QPainterPath path);
void removePrimitives();
void removeDecorations();
bool prefFaceEdges();
bool prefPrintCenters();
bool formatGeomFromCosmetic(std::string cTag, QGIEdge* item);
bool formatGeomFromCenterLine(std::string cTag, QGIEdge* item);
bool showCenterMarks();
bool showVertices();
private:
QList<QGraphicsItem*> deleteItems;
PathBuilder* m_pathBuilder;
TechDraw::LineGenerator* m_dashedLineGenerator;
};
} // namespace
#endif // DRAWINGGUI_QGRAPHICSITEMVIEWPART_H