OpenLexocad  27.1
Viewer.h
Go to the documentation of this file.
1 // //
3 // LEXOCAD API //
4 // //
5 // ©2005-2021 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 <OpenLxApp/Element.h>
23 #include <OpenLxUI/SceneView.h>
24 
25 namespace Gui
26 {
27 class Viewer;
28 }
29 
30 
31 namespace OpenLxUI
32 {
33 class ViewerP;
34 
41 class LX_OPENLXUI_EXPORT Viewer
42 {
43 public:
44  Viewer(Gui::Viewer& aViewer);
45  Viewer() = delete;
46  virtual ~Viewer(); // Must be polymorphic for SWIG
47 
48  enum class EViewDirection
49  {
50  UNDEFINED,
51  TOP,
52  BOTTOM,
53  FRONT,
54  BACK,
55  LEFT,
56  RIGHT,
57  AXO,
58  AXOLEFT,
59  AXOBACKRIGHT,
60  AXOBACKLEFT
61  };
62 
63  void lookAt(const Geom::Pnt& fromPnt, const Geom::Pnt& toPnt, const Geom::Vec& upVector);
64 
65  void viewLast();
66  OpenLxUI::SceneView getCurrentSceneView();
67  void saveSceneView(OpenLxUI::SceneView& view);
68  void setSceneView(const OpenLxUI::SceneView& view, bool forceNotAnimated = false);
69 
70  bool isZoomViewAvailable() const;
71  void saveZoomView();
72  void viewLastZoomView();
73  void clearZoomViews();
74 
75  double getZGroundPlate() const;
76  void setZGroundPlate(bool aOn, double val);
77 
78  bool getProjectAllToZGroundPlate() const;
79  void setProjectAllToZGroundPlate(bool aOn);
80  bool getProjectAllToWPlane() const;
81  void setProjectAllToWPlane(bool aOn);
82 
83  void enablePlaneMode();
84  void enablePlaneMode(const Geom::Pln& aPln);
85  void disablePlaneMode();
86  bool getPlaneMode(Geom::Pln& p);
87  void setPlaneMode(const Geom::Pln& aPln);
88  void setActive(bool on);
89  void loadVisibility() const;
90 
91  void viewAll(float animationTime = 0.f, const Geom::Dir& upVec = Geom::Dir(0, 1, 0), Geom::Bnd_Box* bbox = 0);
92  void viewElement(std::shared_ptr<OpenLxApp::Element> e, float animationTime = 0.f, const Geom::Dir& upVec = Geom::Dir(0, 1, 0));
93  void viewBoundingBox(Geom::Bnd_Box bbox, float animationTime = 0.f, const Geom::Dir& upVec = Geom::Dir(0, 1, 0));
94  void view(EViewDirection direction,
95  float animationTime = 0.f,
96  const Geom::Dir& upVec = Geom::Dir(0, 1, 0),
97  Geom::Bnd_Box* bbox = 0,
98  double rotZ = 0);
99 
100  void viewOrthogonal();
101  void viewPerspective();
102 
103  void zoom(const float diffvalue);
104  void zoomToPoint(Geom::Pnt p, double radius, double animateTime);
105  void redraw();
106 
108  void animateActiveCamera(const Geom::Vec& toPosition,
109  const Geom::Vec& toViewpoint,
110  float animationLength,
111  const double* toFov = 0,
112  const double* toRotation = 0);
114  void setBackgroundColor(const Base::Color& aColor);
116  Base::Color getBackgroundColor() const;
117 
118  bool centeringZoom(float& ppdst, Geom::Ax2 coordsys, bool smallmode = false);
119  void zoomToCursor(Geom::Ax2 coordsys, bool forward);
120  void walkThruMove(int dir, bool orbit, double speed = 0.);
121 
122  void setElementVisibilityInViewer(std::shared_ptr<OpenLxApp::Element> e, bool visible);
123  void setElementsVisibilityInViewer(const std::vector<std::shared_ptr<OpenLxApp::Element>>& elems, bool visible);
124 
125  void enableShading(bool on);
126  bool isShading();
127 
128  /*void highlightDetail(bool aOn, CA_Detail::Type type);
129  void highlightByType(bool aOn, Base::Type type);
130  void setNotHighlightedNotSelectable(bool aOn);
131  void setNoSelectedElement(bool on);
132  void setOnlySelectedElement(bool on);
133  void setOnlySelectedDetail(bool on);*/
134 
135  Geom::Pnt2d mapToGlobal(const Geom::Pnt2d& in);
136  bool offScreenSaveImage(const std::string& filename);
137  bool offScreenSaveImage(const std::string& filename,
138  int viewportwidth,
139  int viewportheight,
140  const Base::Color& bgColor,
141  bool smoothing,
142  int smoothingPasses);
143 
144  bool saveScreenImage(const Base::String& aFileName);
145  bool saveScreenImage(const Base::String& aFileName, int width, int height, const Base::Color& backgroundColor);
146  bool renderWebThumbnail(const Base::String& aFileName, int width, int height, const Base::Color& backgroundColor);
147 
148 
149  std::string getDefaultCursor();
150  void setDefaultCursor(const std::string& c);
151  void setDraggingRestriction(bool on);
152  void checkForCameraUpConstrain();
153  Geom::Bnd_Box getSceneBoundingBox();
154 
155  bool hasAutomaticFocalDistance() const;
156  void setAutomaticFocalDistance(bool on);
157  double getOldFocalDistance() const;
158  void setOldFocalDistance(double d);
159 
160  void setBlockRedraw(bool on);
161  void blockRedrawAfterRedrawing(bool on);
162 
163 private:
164  std::unique_ptr<OpenLxUI::ViewerP> mPimpl;
165 };
166 } // namespace OpenLxUI
LX_OPENLXUI_EXPORT void lookAt(int aViewerId, const Geom::Pnt &aFromPnt, const Geom::Pnt &aToPnt, const Geom::Vec &aUpVector)
Definition: Color.h:45
Definition: Pln.h:57
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:43
Definition: SceneView.h:19
Definition: Bnd_Box.h:63
LX_OPENLXUI_EXPORT void viewAll(int aViewerId, int aAnimationTime=0)
VIEWER.
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:23
Definition: Viewer.h:41
Definition: Ax2.h:67
Definition: Dir.h:45
Core::PropertyText filename
Definition: CoreDocument.h:176
Definition: ActiveEdge.h:25
Defines a non-persistent vector in 3D space.
Definition: Vec.h:44
LX_OPENLXUI_EXPORT void view(int aViewerId, OpenLxApp::View_Direction aViewDirection, int aAnimationTime=0)
EViewDirection
Definition: Viewer.h:48
LX_OPENLXUI_EXPORT void viewOrthogonal(int aViewerId)
Defines a non-persistent 2D cartesian point.
Definition: Pnt2d.h:33
LX_OPENLXUI_EXPORT void viewPerspective(int aViewerId)