OpenLexocad  28.0
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();
73  std::shared_ptr<OpenLxApp::Element> getPickedElement();
76  Gui::PickingService* getPickingService();
77  void setIntersectionPicking(bool onoff);
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);
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);
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);
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);
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);
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;
194  std::shared_ptr<ActiveVertex> getActiveVertex() const;
195  std::shared_ptr<ActiveEdge> getActiveEdge() const;
196  std::shared_ptr<ActiveFace> getActiveFace() const;
197 
199 
200 private:
201  UIDocument(std::shared_ptr<OpenLxApp::Document> aDoc);
202  UIDocument() {}
203  std::shared_ptr<OpenLxUI::UIDocumentP> _pimpl;
204 };
205 } // namespace OpenLxUI
Topo::ShapeType
ShapeType
Definition: Shape.h:38
OpenLxUI::UIDocument::disablePreview
void disablePreview(Gui::AbstractPreview *preview)
OpenLxUI::UIDocument::hideElementAttributesInViewer
void hideElementAttributesInViewer()
Element.h
OpenLxUI::UIDocument::getSnapfor2dElements
unsigned long getSnapfor2dElements()
OpenLxUI::UIDocument::getActiveSubElement
std::shared_ptr< OpenLxApp::SubElement > getActiveSubElement() const
Base::Color
Definition: Color.h:39
OpenLxUI::UIDocument::getActiveEdge
std::shared_ptr< ActiveEdge > getActiveEdge() const
OpenLxUI::UIDocument::getVisibleElements
std::vector< std::shared_ptr< OpenLxApp::Element > > getVisibleElements() const
OpenLxUI::UIDocument::getDocument
std::shared_ptr< OpenLxApp::Document > getDocument() const
OpenLxUI::UIDocument::removeAllPreviews
void removeAllPreviews()
OpenLxUI::UIDocument::removeOwnLine
void removeOwnLine(Gui::SG_Node ownLine)
OpenLxUI::UIDocument::drawElementPositionPreview
void drawElementPositionPreview(std::shared_ptr< OpenLxApp::Element > aElem, const Geom::Pnt &startPnt)
Geom::Vec
Defines a non-persistent vector in 3D space.
Definition: Vec.h:41
OpenLxUI::UIDocument::removeHelpObjects
void removeHelpObjects()
OpenLxUI::UIDocument::getPickedNormal
Geom::Dir getPickedNormal()
OpenLxUI::UIDocument::enablePreview
void enablePreview(Gui::AbstractPreview *preview)
DocObject.h
OpenLxUI::UIDocument::getActivePoint
Geom::Pnt getActivePoint() const
OpenLxUI::UIDocument::~UIDocument
~UIDocument()
OpenLxUI::UIDocument::removeAngle
void removeAngle()
OpenLxUI::UIDocument::removeHelpPointsMeasure
void removeHelpPointsMeasure()
OpenLxUI::UIDocument::createTangentArcPreview
Gui::AbstractTangentArcPreview * createTangentArcPreview(const Geom::Pnt &pnt, const Geom::Vec &tangent)
OpenLxUI::UIDocument::drawHelpPoint
void drawHelpPoint(const Geom::Pnt &p)
OpenLxUI::UIDocument::removeOwnMesh
void removeOwnMesh(Gui::SG_Node ownMesh)
ActiveFace.h
OpenLxUI::UIDocument::getActiveElement
std::shared_ptr< OpenLxApp::Element > getActiveElement() const
OpenLxUI::UIDocument::drawOwnLine
Gui::SG_Node drawOwnLine(const std::vector< Geom::Pnt > &pnts, int thickenss, const Base::Color &color=Base::Color(255, 0, 0), bool dashed=false)
OpenLxUI::UIDocument::drawOwnOverlayLine
Gui::SG_Node drawOwnOverlayLine(const std::vector< Geom::Pnt > &pnts, int thickenss, const Base::Color &color=Base::Color(255, 0, 0), bool dashed=false)
OpenLxUI::UIDocument::pickPoint
bool pickPoint()
OpenLxUI::UIDocument::drawOwnDirectionToPoint
Gui::SG_Node drawOwnDirectionToPoint(const Geom::Pnt &pnt, const Geom::Dir &dir, const Base::Color &color=Base::Color(255, 0, 0))
OpenLxUI::UIDocument::removeRubberBand
void removeRubberBand()
Geom::Dir
Definition: Dir.h:45
OpenLxUI::UIDocument::drawHelpAx2
void drawHelpAx2(const Geom::Ax2 &axis2, const double &magnitude)
OpenLxUI::UIDocument::setSnapMode
void setSnapMode(unsigned long mode)
ActiveVertex.h
OpenLxUI::UIDocument::getAllPreviews
void getAllPreviews(std::set< Gui::AbstractPreview * > &pw)
OpenLxUI::UIDocument::hasActivePoint
bool hasActivePoint() const
Globals.h
Core::DocObject
Definition: DocObject.h:54
OpenLxUI::UIDocument::getPickingService
Gui::PickingService * getPickingService()
Geom::Pln
Definition: Pln.h:52
OpenLxUI::UIDocument::drawOwnText2
Gui::SG_Node drawOwnText2(const std::vector< Geom::Pnt > &pnts, const Base::String &text, const Base::Color &color=Base::Color(255, 0, 0), float fontSize=32, const Base::String &fontName=Base::String(L"Arial"), bool bold=false, Justification ju=Justification::CENTER)
OpenLxUI::UIDocument::removeOwnDirection
void removeOwnDirection(Gui::SG_Node ownDirection)
OpenLxUI::UIDocument::hasPickedNormal
bool hasPickedNormal()
OpenLxUI::UIDocument::getPickedPoint
Geom::Pnt getPickedPoint()
OpenLxUI::UIDocument::stopHighlightByShapeType
void stopHighlightByShapeType()
OpenLxUI::UIDocument::drawRubberBand
void drawRubberBand(const Geom::Pnt &fromPnt)
OpenLxUI::UIDocument::createArc3PointsPreview
Gui::AbstractArc3PointsPreview * createArc3PointsPreview(const Geom::Pnt &startPnt, const Geom::Pnt &fixedPnt, Gui::AbstractArc3PointsPreview::PreviewMode mode=Gui::AbstractArc3PointsPreview::ENDPOINT_CHANGES)
OpenLxUI::UIDocument::drawOwnMesh
Gui::SG_Node drawOwnMesh(const std::vector< Geom::Pnt > &points, const std::vector< int > &model, const Base::Color &color, int transparency, const Base::Color &emissiveColor=Base::Color(0, 0, 0))
OpenLxUI::UIDocument::Justification
Justification
Definition: UIDocument.h:135
Geom::Pnt
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:44
Geom::Ax2
Definition: Ax2.h:66
OpenLxUI::UIDocument::drawAngle
void drawAngle(const Geom::Pnt &center, const Geom::Dir &normal, double angle)
OpenLxUI::UIDocument::drawOwnText2
Gui::SG_Node drawOwnText2(const Geom::Pnt &pnt, const Base::String &text, const Base::Color &color=Base::Color(255, 0, 0), float fontSize=32, const Base::String &fontName=Base::String(L"Arial"), bool bold=false, Justification ju=Justification::CENTER)
Application.h
Pnt.h
OpenLxUI::UIDocument::getUIElement
std::shared_ptr< OpenLxUI::UIElement > getUIElement(Core::DocObject *aObj) const
Selection.h
OpenLxUI::UIDocument::getSelectedElements
std::vector< std::shared_ptr< OpenLxApp::Element > > getSelectedElements() const
OpenLxUI::UIDocument::drawPreview
void drawPreview(Gui::AbstractPreview *preview)
String.h
OpenLxUI::UIDocument::getMidPoint
std::shared_ptr< OpenLxApp::CartesianPoint > getMidPoint(unsigned long snapMode)
OpenLxUI::UIApplication
Definition: UIApplication.h:55
UIElement.h
OpenLxUI::UIDocument::getActiveFace
std::shared_ptr< ActiveFace > getActiveFace() const
OpenLxUI::UIDocument::removeOwnText2
void removeOwnText2(Gui::SG_Node aNode)
OpenLxUI::UIDocument::getSelection
std::shared_ptr< OpenLxUI::Selection > getSelection() const
OpenLxUI::UIDocument::moveMouseToWorldPnt
void moveMouseToWorldPnt(const Geom::Pnt &pntTo)
OpenLxUI::UIDocument::removePreview
void removePreview(Gui::AbstractPreview *preview)
OpenLxUI::UIDocument::SnapMode
SnapMode
Definition: UIDocument.h:83
OpenLxUI::UIDocument::getUIElement
std::shared_ptr< OpenLxUI::UIElement > getUIElement(std::shared_ptr< OpenLxApp::DocObject > aObj) const
OpenLxUI::UIDocument::drawHelpVector
void drawHelpVector(const Geom::Pnt &p, const Geom::Vec &v)
Base::String
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:18
OpenLxUI::UIDocument::isIntersectionPickingEnabled
bool isIntersectionPickingEnabled()
CartesianPoint.h
OpenLxUI::UIDocument::setIntersectionPicking
void setIntersectionPicking(bool onoff)
OpenLxUI::UIDocument::getPlaneMode
static bool getPlaneMode(Geom::Pln &p)
OpenLxUI::UIDocument::createLinePreview
Gui::AbstractLinePreview * createLinePreview(const Geom::Pnt &startPnt)
OpenLxUI::UIDocument::drawOwnDirection
Gui::SG_Node drawOwnDirection(const Geom::Pnt &pnt, const Geom::Dir &dir, const Base::Color &color=Base::Color(255, 0, 0))
OpenLxUI
Definition: ActiveEdge.h:26
Dir.h
Geometry.h
OpenLxUI::UIDocument::getPickedElement
std::shared_ptr< OpenLxApp::Element > getPickedElement()
Document.h
ActiveEdge.h
OpenLxUI::UIDocument::getSnapMode
unsigned long getSnapMode()
OpenLxUI::UIDocument::drawHelpPointMeasure
void drawHelpPointMeasure(const std::string &name, const Geom::Pnt &pos, float red=1.0f, float green=1.0f, float blue=0.0f)
OpenLxUI::UIDocument
Definition: UIDocument.h:59
OpenLxUI::UIDocument::highlightByShapeType
void highlightByShapeType(Topo::ShapeType shapeType)
OpenLxUI::UIDocument::getActiveVertex
std::shared_ptr< ActiveVertex > getActiveVertex() const
OpenLxUI::UIDocument::drawAuxiliaryLine
void drawAuxiliaryLine(const Geom::Pnt &orgin, const Geom::Dir &dir)