OpenLexocad  28.0
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();
68  void setSceneView(const OpenLxUI::SceneView& view, bool forceNotAnimated = false);
69 
70  bool isZoomViewAvailable() const;
71  void saveZoomView();
74 
75  double getZGroundPlate() const;
76  void setZGroundPlate(bool aOn, double val);
77 
80  bool getProjectAllToWPlane() const;
81  void setProjectAllToWPlane(bool aOn);
82 
84  void enablePlaneMode(const Geom::Pln& aPln);
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 
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);
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 
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);
154 
157  double getOldFocalDistance() const;
158  void setOldFocalDistance(double d);
159 
160  void setBlockRedraw(bool on);
162 
163 private:
164  std::unique_ptr<OpenLxUI::ViewerP> mPimpl;
165 };
166 } // namespace OpenLxUI
Element.h
Geom::Bnd_Box
Definition: Bnd_Box.h:67
Base::Color
Definition: Color.h:39
OpenLxUI::Viewer::getDefaultCursor
std::string getDefaultCursor()
OpenLxUI::Viewer::setOldFocalDistance
void setOldFocalDistance(double d)
OpenLxUI::Viewer::saveZoomView
void saveZoomView()
OpenLxUI::Viewer::viewBoundingBox
void viewBoundingBox(Geom::Bnd_Box bbox, float animationTime=0.f, const Geom::Dir &upVec=Geom::Dir(0, 1, 0))
OpenLxUI::Viewer::viewAll
void viewAll(float animationTime=0.f, const Geom::Dir &upVec=Geom::Dir(0, 1, 0), Geom::Bnd_Box *bbox=0)
OpenLxUI::Viewer::loadVisibility
void loadVisibility() const
OpenLxUI::Viewer::offScreenSaveImage
bool offScreenSaveImage(const std::string &filename, int viewportwidth, int viewportheight, const Base::Color &bgColor, bool smoothing, int smoothingPasses)
OpenLxUI::Viewer::centeringZoom
bool centeringZoom(float &ppdst, Geom::Ax2 coordsys, bool smallmode=false)
OpenLxUI::SceneView
Definition: SceneView.h:20
OpenLxUI::Viewer::setZGroundPlate
void setZGroundPlate(bool aOn, double val)
Geom::Vec
Defines a non-persistent vector in 3D space.
Definition: Vec.h:41
OpenLxUI::Viewer::blockRedrawAfterRedrawing
void blockRedrawAfterRedrawing(bool on)
OpenLxUI::Viewer::viewElement
void viewElement(std::shared_ptr< OpenLxApp::Element > e, float animationTime=0.f, const Geom::Dir &upVec=Geom::Dir(0, 1, 0))
OpenLxUI::Viewer::hasAutomaticFocalDistance
bool hasAutomaticFocalDistance() const
OpenLxUI::Viewer
Definition: Viewer.h:42
OpenLxUI::Viewer::viewLastZoomView
void viewLastZoomView()
OpenLxUI::Viewer::setPlaneMode
void setPlaneMode(const Geom::Pln &aPln)
OpenLxUI::Viewer::setSceneView
void setSceneView(const OpenLxUI::SceneView &view, bool forceNotAnimated=false)
OpenLxUI::Viewer::isZoomViewAvailable
bool isZoomViewAvailable() const
OpenLxUI::Viewer::setBlockRedraw
void setBlockRedraw(bool on)
OpenLxUI::Viewer::setActive
void setActive(bool on)
OpenLxUI::Viewer::redraw
void redraw()
Geom::Dir
Definition: Dir.h:45
OpenLxUI::Viewer::getOldFocalDistance
double getOldFocalDistance() const
OpenLxUI::Viewer::saveScreenImage
bool saveScreenImage(const Base::String &aFileName)
OpenLxUI::Viewer::zoomToPoint
void zoomToPoint(Geom::Pnt p, double radius, double animateTime)
Geom::Pln
Definition: Pln.h:52
OpenLxUI::Viewer::viewPerspective
void viewPerspective()
OpenLxUI::Viewer::isShading
bool isShading()
OpenLxUI::Viewer::lookAt
void lookAt(const Geom::Pnt &fromPnt, const Geom::Pnt &toPnt, const Geom::Vec &upVector)
OpenLxUI::Viewer::mapToGlobal
Geom::Pnt2d mapToGlobal(const Geom::Pnt2d &in)
OpenLxUI::Viewer::getSceneBoundingBox
Geom::Bnd_Box getSceneBoundingBox()
OpenLxUI::Viewer::setAutomaticFocalDistance
void setAutomaticFocalDistance(bool on)
Geom::Pnt
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:44
OpenLxUI::Viewer::zoom
void zoom(const float diffvalue)
OpenLxUI::Viewer::getZGroundPlate
double getZGroundPlate() const
Geom::Ax2
Definition: Ax2.h:66
OpenLxUI::Viewer::getPlaneMode
bool getPlaneMode(Geom::Pln &p)
OpenLxUI::Viewer::view
void view(EViewDirection direction, float animationTime=0.f, const Geom::Dir &upVec=Geom::Dir(0, 1, 0), Geom::Bnd_Box *bbox=0, double rotZ=0)
OpenLxUI::Viewer::enablePlaneMode
void enablePlaneMode()
OpenLxUI::Viewer::setProjectAllToZGroundPlate
void setProjectAllToZGroundPlate(bool aOn)
OpenLxUI::Viewer::enablePlaneMode
void enablePlaneMode(const Geom::Pln &aPln)
OpenLxUI::Viewer::setDraggingRestriction
void setDraggingRestriction(bool on)
OpenLxUI::Viewer::setElementVisibilityInViewer
void setElementVisibilityInViewer(std::shared_ptr< OpenLxApp::Element > e, bool visible)
OpenLxUI::view
LX_OPENLXUI_EXPORT void view(int aViewerId, OpenLxApp::View_Direction aViewDirection, int aAnimationTime=0)
OpenLxUI::Viewer::clearZoomViews
void clearZoomViews()
OpenLxUI::Viewer::setBackgroundColor
void setBackgroundColor(const Base::Color &aColor)
OpenLxUI::Viewer::viewOrthogonal
void viewOrthogonal()
SceneView.h
OpenLxUI::Viewer::renderWebThumbnail
bool renderWebThumbnail(const Base::String &aFileName, int width, int height, const Base::Color &backgroundColor)
OpenLxUI::Viewer::setElementsVisibilityInViewer
void setElementsVisibilityInViewer(const std::vector< std::shared_ptr< OpenLxApp::Element >> &elems, bool visible)
OpenLxUI::Viewer::Viewer
Viewer(Gui::Viewer &aViewer)
OpenLxUI::Viewer::setProjectAllToWPlane
void setProjectAllToWPlane(bool aOn)
OpenLxUI::Viewer::offScreenSaveImage
bool offScreenSaveImage(const std::string &filename)
OpenLxUI::Viewer::checkForCameraUpConstrain
void checkForCameraUpConstrain()
OpenLxUI::Viewer::getCurrentSceneView
OpenLxUI::SceneView getCurrentSceneView()
OpenLxUI::Viewer::animateActiveCamera
void animateActiveCamera(const Geom::Vec &toPosition, const Geom::Vec &toViewpoint, float animationLength, const double *toFov=0, const double *toRotation=0)
OpenLxUI::Viewer::EViewDirection
EViewDirection
Definition: Viewer.h:49
OpenLxUI::Viewer::Viewer
Viewer()=delete
OpenLxUI::Viewer::enableShading
void enableShading(bool on)
OpenLxUI::Viewer::getProjectAllToWPlane
bool getProjectAllToWPlane() const
OpenLxUI::Viewer::saveScreenImage
bool saveScreenImage(const Base::String &aFileName, int width, int height, const Base::Color &backgroundColor)
OpenLxUI::Viewer::~Viewer
virtual ~Viewer()
OpenLxUI::Viewer::viewLast
void viewLast()
Base::String
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:18
OpenLxUI::Viewer::zoomToCursor
void zoomToCursor(Geom::Ax2 coordsys, bool forward)
Geom::Pnt2d
Defines a non-persistent 2D cartesian point.
Definition: Pnt2d.h:34
OpenLxUI
Definition: ActiveEdge.h:26
OpenLxUI::Viewer::setDefaultCursor
void setDefaultCursor(const std::string &c)
OpenLxUI::Viewer::saveSceneView
void saveSceneView(OpenLxUI::SceneView &view)
OpenLxUI::Viewer::disablePlaneMode
void disablePlaneMode()
OpenLxUI::Viewer::getProjectAllToZGroundPlate
bool getProjectAllToZGroundPlate() const
OpenLxUI::Viewer::walkThruMove
void walkThruMove(int dir, bool orbit, double speed=0.)
OpenLxUI::Viewer::getBackgroundColor
Base::Color getBackgroundColor() const