OpenLexocad  27.1
UIDocument.h
Go to the documentation of this file.
1 // //
3 // LEXOCAD API //
4 // //
5 // ©2005-2016 Cadwork Informatik. All rights reserved. //
6 // //
7 // ONLY INCLUDE OTHER INTERFACES! //
8 // Lexocad provides API Classes for public use and //
9 // Implementation Classes for private use. //
10 // //
11 // - Do ONLY include and use the LEXOCAD API in this header. //
12 // - Do not change existing interfaces. //
13 // - Document your code! //
14 // //
15 // - All types from Base, Core, Geom, Topo are allowed here. //
16 // - In the Gui modules the use of Qt types is allowed. //
17 // //
19 
20 #pragma once
21 
22 #include <Base/String.h>
23 #include <Core/DocObject.h>
24 #include <Geom/Dir.h>
25 #include <Geom/Pnt.h>
26 #include <Gui/AbstractPreview.h>
27 #include <Gui/Action.h>
28 #include <Gui/PickingService.h>
29 #include <Gui/PropertyTree.h>
30 #include <Gui/SceneGraphInterface.h>
31 #include <OpenLxApp/Application.h>
33 #include <OpenLxApp/Document.h>
34 #include <OpenLxApp/Element.h>
35 #include <OpenLxApp/Geometry.h>
36 #include <OpenLxApp/Globals.h>
37 #include <OpenLxUI/ActiveEdge.h>
38 #include <OpenLxUI/ActiveFace.h>
39 #include <OpenLxUI/ActiveVertex.h>
40 
41 #include <OpenLxUI/Selection.h>
42 #include <OpenLxUI/UIElement.h>
43 
44 #include <vector>
45 
46 
47 
48 namespace OpenLxUI
49 {
50 class UIDocumentP;
51 
58 class LX_OPENLXUI_EXPORT UIDocument
59 {
60 public:
61  friend class UIApplication;
62 
63  std::shared_ptr<OpenLxApp::Document> getDocument() const;
64  std::shared_ptr<OpenLxUI::Selection> getSelection() const;
65 
66  //
67  std::shared_ptr<OpenLxUI::UIElement> getUIElement(std::shared_ptr<OpenLxApp::DocObject> aObj) const;
68  std::shared_ptr<OpenLxUI::UIElement> getUIElement(Core::DocObject* aObj) const;
69 
70  // PICKING
71  bool pickPoint();
72  Geom::Pnt getPickedPoint();
73  std::shared_ptr<OpenLxApp::Element> getPickedElement();
74  bool hasPickedNormal();
75  Geom::Dir getPickedNormal();
76  Gui::PickingService* getPickingService();
77  void setIntersectionPicking(bool onoff);
78  bool isIntersectionPickingEnabled();
79 
80 
81  // SNAPPING
82  enum SnapMode
83  {
84  NOPOINT = 1 << 1,
85  NEARESTPOINT = 1 << 2,
86  MIDPOINT = 1 << 3,
87  ENDPOINT = 1 << 4,
88  GRIDPOINT = 1 << 5,
89  BBOXPOINT = 1 << 6,
90  INTERSECTIONPOINT = 1 << 7,
91  EDGEPOINT = 1 << 8,
92  ONLYVERTICES = 1 << 9,
93  ONLYVIRTUALGEO = 1 << 10,
94  CONTROLPOINT = 1 << 11,
95  INVISIBLECONTROLPOINT = 1 << 12,
96  AUXILIARYPOINT = 1 << 13
97  };
98 
99  unsigned long getSnapMode();
100  unsigned long getSnapfor2dElements();
101  void setSnapMode(unsigned long mode);
102 
103  // MISC
104  static bool getPlaneMode(Geom::Pln& p);
105  void moveMouseToWorldPnt(const Geom::Pnt& pntTo);
106  std::shared_ptr<OpenLxApp::CartesianPoint> getMidPoint(unsigned long snapMode);
107 
108 
109  // PREVIEW AND HIGHLIGHTING
110  void drawRubberBand(const Geom::Pnt& fromPnt);
111  void removeRubberBand();
112  void highlightByShapeType(Topo::ShapeType shapeType);
113  void stopHighlightByShapeType();
114  void drawElementPositionPreview(std::shared_ptr<OpenLxApp::Element> aElem, const Geom::Pnt& startPnt);
115  // LX_OPENLXUI_EXPORT void showElementAttributesInViewer(const Gui::ShowAttributesFlags& flags, const Base::Color& color = Base::Color(128, 0, 255),
116  // int pointSize = 20, bool bold = false);
117  void hideElementAttributesInViewer();
118  Gui::AbstractTangentArcPreview* createTangentArcPreview(const Geom::Pnt& pnt, const Geom::Vec& tangent);
119  Gui::AbstractLinePreview* createLinePreview(const Geom::Pnt& startPnt);
120  Gui::AbstractArc3PointsPreview* createArc3PointsPreview(
121  const Geom::Pnt& startPnt,
122  const Geom::Pnt& fixedPnt,
123  Gui::AbstractArc3PointsPreview::PreviewMode mode = Gui::AbstractArc3PointsPreview::ENDPOINT_CHANGES);
124  void drawPreview(Gui::AbstractPreview* preview);
125  void removePreview(Gui::AbstractPreview* preview);
126  void removeAllPreviews();
127  void getAllPreviews(std::set<Gui::AbstractPreview*>& pw);
128  void enablePreview(Gui::AbstractPreview* preview);
129  void disablePreview(Gui::AbstractPreview* preview);
130 
131  void drawAngle(const Geom::Pnt& center, const Geom::Dir& normal, double angle);
132  void removeAngle();
133 
134  enum class Justification
135  {
136  LEFT = 1,
137  RIGHT,
138  CENTER
139  };
140 
141  Gui::SG_Node drawOwnText2(const Geom::Pnt& pnt,
142  const Base::String& text,
143  const Base::Color& color = Base::Color(255, 0, 0),
144  float fontSize = 32,
145  const Base::String& fontName = Base::String(L"Arial"),
146  bool bold = false,
147  Justification ju = Justification::CENTER);
148  Gui::SG_Node drawOwnText2(const std::vector<Geom::Pnt>& pnts,
149  const Base::String& text,
150  const Base::Color& color = Base::Color(255, 0, 0),
151  float fontSize = 32,
152  const Base::String& fontName = Base::String(L"Arial"),
153  bool bold = false,
154  Justification ju = Justification::CENTER);
155  void removeOwnText2(Gui::SG_Node aNode);
156 
157  void drawHelpPoint(const Geom::Pnt& p);
158  void drawHelpVector(const Geom::Pnt& p, const Geom::Vec& v);
159  void drawHelpAx2(const Geom::Ax2& axis2, const double& magnitude);
160  void removeHelpObjects();
161 
162  Gui::SG_Node drawOwnDirection(const Geom::Pnt& pnt, const Geom::Dir& dir, const Base::Color& color = Base::Color(255, 0, 0));
163  Gui::SG_Node drawOwnDirectionToPoint(const Geom::Pnt& pnt, const Geom::Dir& dir, const Base::Color& color = Base::Color(255, 0, 0));
164  void removeOwnDirection(Gui::SG_Node ownDirection);
165 
166  Gui::SG_Node drawOwnLine(const std::vector<Geom::Pnt>& pnts,
167  int thickenss,
168  const Base::Color& color = Base::Color(255, 0, 0),
169  bool dashed = false);
170  Gui::SG_Node drawOwnOverlayLine(const std::vector<Geom::Pnt>& pnts,
171  int thickenss,
172  const Base::Color& color = Base::Color(255, 0, 0),
173  bool dashed = false);
174  void removeOwnLine(Gui::SG_Node ownLine);
175 
176  Gui::SG_Node drawOwnMesh(const std::vector<Geom::Pnt>& points,
177  const std::vector<int>& model,
178  const Base::Color& color,
179  int transparency,
180  const Base::Color& emissiveColor = Base::Color(0, 0, 0));
181  void removeOwnMesh(Gui::SG_Node ownMesh);
182 
183  void drawAuxiliaryLine(const Geom::Pnt& orgin, const Geom::Dir& dir);
184  void drawHelpPointMeasure(const std::string& name, const Geom::Pnt& pos, float red = 1.0f, float green = 1.0f, float blue = 0.0f);
185  void removeHelpPointsMeasure();
186 
187  std::vector<std::shared_ptr<OpenLxApp::Element>> getVisibleElements() const;
188  std::vector<std::shared_ptr<OpenLxApp::Element>> getSelectedElements() const;
189 
190  std::shared_ptr<OpenLxApp::Element> getActiveElement() const;
191  std::shared_ptr<OpenLxApp::SubElement> getActiveSubElement() const;
192  bool hasActivePoint() const;
193  Geom::Pnt getActivePoint() const;
194  std::shared_ptr<ActiveVertex> getActiveVertex() const;
195  std::shared_ptr<ActiveEdge> getActiveEdge() const;
196  std::shared_ptr<ActiveFace> getActiveFace() const;
197 
198  ~UIDocument();
199 
200 private:
201  UIDocument(std::shared_ptr<OpenLxApp::Document> aDoc);
202  UIDocument() {}
203  std::shared_ptr<OpenLxUI::UIDocumentP> _pimpl;
204 };
205 } // namespace OpenLxUI
Definition: Color.h:45
Definition: Pln.h:57
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:43
Core::PropertyText name
Definition: CoreDocument.h:167
Definition: UIDocument.h:58
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:23
ShapeType
Definition: Shape.h:46
Definition: Ax2.h:67
Justification
Definition: UIDocument.h:134
Definition: Dir.h:45
Definition: ActiveEdge.h:25
Definition: UIApplication.h:49
Defines a non-persistent vector in 3D space.
Definition: Vec.h:44
SnapMode
Definition: UIDocument.h:82
Definition: DocObject.h:51