/
DrawViewSection.h
209 lines (168 loc) · 7.94 KB
/
DrawViewSection.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/***************************************************************************
* Copyright (c) 2007 Jürgen Riegel <juergen.riegel@web.de> *
* Copyright (c) 2013 Luke Parry <l.parry@warwick.ac.uk> *
* Copyright (c) 2016 WandererFan <wandererfan@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 DrawViewSection_h_
#define DrawViewSection_h_
#include <gp_Ax2.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Shape.hxx>
#include <App/DocumentObject.h>
#include <App/FeaturePython.h>
#include <App/PropertyFile.h>
#include <App/PropertyLinks.h>
#include <Mod/TechDraw/TechDrawGlobal.h>
#include "DrawViewPart.h"
class Bnd_Box;
class gp_Pln;
class gp_Pnt;
class TopoDS_Face;
class TopoDS_Wire;
class gp_Ax2;
namespace TechDraw
{
class Face;
}
namespace TechDraw
{
class DrawProjGroupItem;
class DrawGeomHatch;
class PATLineSpec;
class LineSet;
class DashSet;
//changes in direction of complex section line. also marks at arrow positions.
class ChangePoint
{
public:
ChangePoint(QPointF location, QPointF preDirection, QPointF postDirection);
ChangePoint(gp_Pnt location, gp_Dir preDirection, gp_Dir postDirection);
~ChangePoint() = default;
QPointF getLocation() const { return m_location; }
void setLocation(QPointF newLocation) { m_location = newLocation; }
QPointF getPreDirection() const { return m_preDirection; }
QPointF getPostDirection() const { return m_postDirection; }
void scale(double scaleFactor);
private:
QPointF m_location;
QPointF m_preDirection;
QPointF m_postDirection;
};
using ChangePointVector = std::vector<ChangePoint>;
class TechDrawExport DrawViewSection : public DrawViewPart
{
PROPERTY_HEADER_WITH_OVERRIDE(Part::DrawViewSection);
public:
DrawViewSection();
~DrawViewSection() override;
App::PropertyLink BaseView;
App::PropertyVector SectionNormal;
App::PropertyVector SectionOrigin;
App::PropertyString SectionSymbol;
App::PropertyEnumeration SectionDirection; //to be made obsolete eventually
App::PropertyEnumeration CutSurfaceDisplay; //new v019
App::PropertyFile FileHatchPattern;
App::PropertyFile FileGeomPattern; //new v019
App::PropertyFileIncluded SvgIncluded;
App::PropertyFileIncluded PatIncluded;
App::PropertyString NameGeomPattern;
App::PropertyFloat HatchScale;
App::PropertyBool FuseBeforeCut;
App::PropertyBool TrimAfterCut; //new v021
bool isReallyInBox (const Base::Vector3d v, const Base::BoundBox3d bb) const;
bool isReallyInBox (const gp_Pnt p, const Bnd_Box& bb) const;
App::DocumentObjectExecReturn *execute() override;
void onChanged(const App::Property* prop) override;
const char* getViewProviderName() const override {
return "TechDrawGui::ViewProviderViewSection";
}
void unsetupObject() override;
short mustExecute() const override;
void sectionExec(TopoDS_Shape& s);
virtual void makeSectionCut(TopoDS_Shape &baseShape);
void postHlrTasks(void) override;
virtual void postSectionCutTasks();
void waitingForCut(bool s) { m_waitingForCut = s; }
bool waitingForCut(void) const { return m_waitingForCut; }
bool waitingForResult() const override;
virtual TopoDS_Shape makeCuttingTool(double shapeSize);
virtual TopoDS_Shape getShapeToCut();
virtual bool isBaseValid() const;
virtual TopoDS_Shape prepareShape(const TopoDS_Shape& rawShape,
double shapeSize);
virtual TopoDS_Shape getShapeToPrepare() const { return m_cutPieces; }
//CS related methods
gp_Ax2 getProjectionCS(Base::Vector3d pt = Base::Vector3d(0.0, 0.0, 0.0)) const override;
void setCSFromBase(const std::string sectionName);
void setCSFromBase(Base::Vector3d localUnit);
void setCSFromLocalUnit(const Base::Vector3d localUnit);
virtual gp_Ax2 getCSFromBase(const std::string sectionName) const;
gp_Ax2 getSectionCS() const;
Base::Vector3d getXDirection() const override; //don't use XDirection.getValue()
TechDraw::DrawViewPart* getBaseDVP() const;
TechDraw::DrawProjGroupItem* getBaseDPGI() const;
//section face related methods
TopoDS_Compound getSectionTFaces() { return m_sectionTopoDSFaces;}
std::vector<TechDraw::FacePtr> getTDFaceGeometry() {return m_tdSectionFaces;}
TopoDS_Face getSectionTopoDSFace(int i);
virtual TopoDS_Compound alignSectionFaces(TopoDS_Shape faceIntersections);
TopoDS_Compound mapToPage(TopoDS_Shape& shapeToAlign);
virtual std::vector<TechDraw::FacePtr> makeTDSectionFaces(TopoDS_Compound topoDSFaces);
virtual TopoDS_Shape getShapeToIntersect() { return m_cutPieces; }
void makeLineSets(void) ;
std::vector<LineSet> getDrawableLines(int i = 0);
std::vector<PATLineSpec> getDecodedSpecsFromFile(std::string fileSpec, std::string myPattern);
TopoDS_Shape getCutShape() {return m_cutShape;}
static const char* SectionDirEnums[];
static const char* CutSurfaceEnums[];
virtual std::pair<Base::Vector3d, Base::Vector3d> sectionLineEnds();
virtual ChangePointVector getChangePointsFromSectionLine();
bool showSectionEdges(void);
public Q_SLOTS:
void onSectionCutFinished(void);
protected:
TopoDS_Compound m_sectionTopoDSFaces; //needed for hatching
std::vector<LineSet> m_lineSets;
std::vector<TechDraw::FacePtr> m_tdSectionFaces;
virtual gp_Pln getSectionPlane() const;
virtual TopoDS_Compound findSectionPlaneIntersections(const TopoDS_Shape& shape);
void getParameters();
bool debugSection() const;
int prefCutSurface() const;
bool trimAfterCut() const;
TopoDS_Shape m_cutShape;
void onDocumentRestored() override;
void setupObject() override;
void replaceSvgIncluded(std::string newSvgFile);
void replacePatIncluded(std::string newPatFile);
TopoDS_Shape m_cutPieces; //the shape after cutting, but before centering & scaling
gp_Ax2 m_projectionCS;
TopoDS_Shape m_preparedShape; //the shape after cutting, centering, scaling etc
QMetaObject::Connection connectCutWatcher;
QFutureWatcher<void> m_cutWatcher;
QFuture<void> m_cutFuture;
bool m_waitingForCut;
TopoDS_Shape m_cuttingTool;
double m_shapeSize;
};
using DrawViewSectionPython = App::FeaturePythonT<DrawViewSection>;
} //namespace TechDraw
#endif