ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvDisplayTools.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "ecvGLMatrix.h"
12 #include "ecvGenericDisplayTools.h"
13 #include "ecvGuiParameters.h"
14 #include "ecvHObject.h"
15 #include "ecvViewportParameters.h"
16 
17 // QT
18 #include <QApplication> // Added for QApplication::primaryScreen()
19 #include <QElapsedTimer>
20 #include <QMainWindow>
21 #include <QObject>
22 #include <QRect>
23 #include <QScreen> // Added for QScreen
24 #include <QTimer>
25 
26 // System
27 #include <list>
28 #include <unordered_set>
29 #include <vector>
30 
31 namespace cloudViewer {
32 namespace geometry {
33 class LineSet;
34 }
35 } // namespace cloudViewer
36 
37 class ccPolyline;
38 class ccInteractor;
39 class ccGenericMesh;
40 class ecvOrientedBBox;
41 
45 
46 // ============================================================================
47 // Axes Grid Properties Structure (ParaView-compatible)
48 // ============================================================================
49 
55  // Basic properties
56  bool visible = false;
57  CCVector3 color = CCVector3(255, 255, 255); // White (RGB 0-255)
58  double lineWidth = 1.0;
59  double spacing = 1.0;
60  int subdivisions = 10;
61  bool showLabels = true;
62  double opacity = 1.0;
63 
64  // Extended properties (ParaView-style)
65  bool showGrid = false; // Show grid lines (default OFF like ParaView)
66  QString xTitle = "X-Axis";
67  QString yTitle = "Y-Axis";
68  QString zTitle = "Z-Axis";
69  bool xUseCustomLabels = false;
70  bool yUseCustomLabels = false;
71  bool zUseCustomLabels = false;
72  bool useCustomBounds = false;
73 
74  // Custom labels (ParaView-style: value -> label string)
75  QList<QPair<double, QString>> xCustomLabels;
76  QList<QPair<double, QString>> yCustomLabels;
77  QList<QPair<double, QString>> zCustomLabels;
78 
79  // Custom bounds (ParaView-style: explicit min/max for each axis)
80  double xMin = 0.0, xMax = 1.0;
81  double yMin = 0.0, yMax = 1.0;
82  double zMin = 0.0, zMax = 1.0;
83 
84  // Constructor with defaults
85  AxesGridProperties() = default;
86 };
87 
88 class CV_DB_LIB_API ecvDisplayTools : public QObject,
89  public ecvGenericDisplayTools {
90  Q_OBJECT
91 public:
95  static void Init(ecvDisplayTools* displayTools,
96  QMainWindow* win,
97  bool stereoMode = false);
99 
100  static void ReleaseInstance();
101 
103  virtual ~ecvDisplayTools() override;
104 
106 
110  void scheduleFullRedraw(unsigned maxDelay_ms);
111 
114 
115 public:
128  };
129 
132 
133  // no interaction
134  INTERACT_NONE = 0,
135 
136  // camera interactions
137  INTERACT_ROTATE = 1,
138  INTERACT_PAN = 2,
139  INTERACT_CTRL_PAN = 4,
140  INTERACT_ZOOM_CAMERA = 8,
141  INTERACT_2D_ITEMS = 16, // labels, etc.
142  INTERACT_CLICKABLE_ITEMS = 32, // hot zone
143 
144  // options / modifiers
145  INTERACT_TRANSFORM_ENTITIES = 64,
146 
147  // signals
148  INTERACT_SIG_RB_CLICKED = 128, // right button clicked
149  INTERACT_SIG_LB_CLICKED = 256, // left button clicked
150  INTERACT_SIG_MOUSE_MOVED =
151  512, // mouse moved (only if a button is clicked)
152  INTERACT_SIG_BUTTON_RELEASED = 1024, // mouse button released
153  INTERACT_SIG_MB_CLICKED = 2048, // middle button clicked
154  INTERACT_SEND_ALL_SIGNALS =
155  INTERACT_SIG_RB_CLICKED | INTERACT_SIG_LB_CLICKED |
156  INTERACT_SIG_MB_CLICKED | INTERACT_SIG_MOUSE_MOVED |
157  INTERACT_SIG_BUTTON_RELEASED,
158 
159  // default modes
160  MODE_PAN_ONLY = INTERACT_PAN | INTERACT_ZOOM_CAMERA |
161  INTERACT_2D_ITEMS | INTERACT_CLICKABLE_ITEMS,
162  MODE_TRANSFORM_CAMERA = INTERACT_ROTATE | MODE_PAN_ONLY,
163  MODE_TRANSFORM_ENTITIES =
164  INTERACT_ROTATE | INTERACT_PAN | INTERACT_ZOOM_CAMERA |
165  INTERACT_TRANSFORM_ENTITIES | INTERACT_CLICKABLE_ITEMS,
166  };
167  Q_DECLARE_FLAGS(INTERACTION_FLAGS, INTERACTION_FLAG)
168 
169  // Default interaction modes (with the mouse!)
170  static INTERACTION_FLAGS PAN_ONLY();
171  static INTERACTION_FLAGS TRANSFORM_CAMERA();
172  static INTERACTION_FLAGS TRANSFORM_ENTITIES();
173 
179  };
180 
182  enum MessageType {
192  };
193 
199  };
200 
204  : messageValidity_sec(0),
205  position(LOWER_LEFT_MESSAGE),
206  type(CUSTOM_MESSAGE) {}
207 
209  QString message;
216  };
217 
219  std::list<MessageToDisplay> m_messagesToDisplay;
220 
224  : zNear(0.0),
225  zFar(0.0),
226  cameraToBBCenterDist(0.0),
227  bbHalfDiag(0.0) {}
228 
229  double zNear;
230  double zFar;
232  double bbHalfDiag;
233  };
234 
237  // display font
238  QFont font;
239  // text height
241  // text shift
243  // default color
244  unsigned char color[3];
245 
246  // bubble-view label rect.
247  QString bbv_label;
248  // bubble-view label rect.
250  // bubble-view row width
252 
253  // fullscreen label rect.
254  QString fs_label;
255  // fullscreen label rect.
257  // fullscreen row width
259 
260  // point size label
261  QString psi_label;
262  // point size label rect.
264  // point size row width
266 
267  // line size label
268  QString lsi_label;
269  // line size label rect.
271  // line size row width
273 
274  int margin;
275  int iconSize;
276  QPoint topCorner;
278 
279  explicit HotZone(QWidget* win)
280  : textHeight(0),
281  yTextBottomLineShift(0),
282  bbv_label("bubble-view mode"),
283  fs_label("fullscreen mode"),
284  psi_label("default point size"),
285  lsi_label("default line width"),
286  margin(16) // 16|10
287  ,
288  iconSize(16) // 16
289  ,
290  topCorner(0, 0),
291  pixelDeviceRatio(1.0) {
295 
296  updateInternalVariables(win);
297  }
298 
299  void updateInternalVariables(QWidget* win) {
300  if (win) {
301  font = win->font();
302  pixelDeviceRatio = GetPlatformAwareDPIScale();
303  int fontSize = GetOptimizedFontSize(12);
304  if (fontSize != pixelDeviceRatio) {
305  font.setPointSize(fontSize);
306  } else {
307  font.setPointSize(12 * pixelDeviceRatio);
308  }
309  CVLog::Print(QString("pixelDeviceRatio: %1 and fontSize %2")
310  .arg(pixelDeviceRatio)
311  .arg(fontSize));
312  margin *= pixelDeviceRatio;
313  iconSize *= pixelDeviceRatio;
314  font.setBold(true);
315  }
316 
317  QFontMetrics metrics(font);
318  bbv_labelRect = metrics.boundingRect(bbv_label);
319  fs_labelRect = metrics.boundingRect(fs_label);
320  psi_labelRect = metrics.boundingRect(psi_label);
321  lsi_labelRect = metrics.boundingRect(lsi_label);
322 
323  psi_totalWidth = /*margin() + */ psi_labelRect.width() + margin +
324  iconSize + margin + iconSize /* + margin*/;
325  lsi_totalWidth = /*margin() + */ lsi_labelRect.width() + margin +
326  iconSize + margin + iconSize /* + margin*/;
327  bbv_totalWidth = /*margin() + */ bbv_labelRect.width() + margin +
328  iconSize /* + margin*/;
329  fs_totalWidth = /*margin() + */ fs_labelRect.width() + margin +
330  iconSize /* + margin*/;
331 
332  textHeight =
333  std::max(psi_labelRect.height(), bbv_labelRect.height());
334  textHeight = std::max(lsi_labelRect.height(), textHeight);
335  textHeight = std::max(fs_labelRect.height(), textHeight);
336  textHeight = (3 * textHeight) /
337  4; // --> factor: to recenter the baseline a little
338  yTextBottomLineShift = (iconSize / 2) + (textHeight / 2);
339  }
340 
341  QRect rect(bool clickableItemsVisible,
342  bool bubbleViewModeEnabled,
343  bool fullScreenEnabled) const {
344  // total hot zone area size (without margin)
345  int totalWidth = 0;
346  if (clickableItemsVisible)
347  totalWidth = std::max(psi_totalWidth, lsi_totalWidth);
348  if (bubbleViewModeEnabled)
349  totalWidth = std::max(totalWidth, bbv_totalWidth);
350  if (fullScreenEnabled)
351  totalWidth = std::max(totalWidth, fs_totalWidth);
352 
353 #ifdef Q_OS_MAC
354  // fix the hot zone width on mac
355  totalWidth = totalWidth + 3 * (margin + iconSize);
356 #endif
357  QPoint minAreaCorner(
358  0, std::min(0, yTextBottomLineShift - textHeight));
359  QPoint maxAreaCorner(totalWidth,
360  std::max(iconSize, yTextBottomLineShift));
361  int rowCount = clickableItemsVisible ? 2 : 0;
362  rowCount += bubbleViewModeEnabled ? 1 : 0;
363  rowCount += fullScreenEnabled ? 1 : 0;
364  maxAreaCorner.setY(maxAreaCorner.y() +
365  (iconSize + margin) * (rowCount - 1));
366 
367  QRect areaRect(minAreaCorner - QPoint(margin, margin) / 2,
368  maxAreaCorner + QPoint(margin, margin) / 2);
369 
370  return areaRect;
371  }
372  };
373 
375 
383  static void DisplayText(const QString& text,
384  int x,
385  int y,
386  unsigned char align = ALIGN_DEFAULT,
387  float bkgAlpha = 0.0f,
388  const unsigned char* rgbColor = nullptr,
389  const QFont* font = nullptr,
390  const QString& id = "");
391 
392  static void DisplayText(const CC_DRAW_CONTEXT& CONTEXT) {
393  TheInstance()->displayText(CONTEXT);
394  }
395  inline virtual void displayText(
396  const CC_DRAW_CONTEXT& CONTEXT) { /* do nothing */ }
397 
399 
404  static void Display3DLabel(const QString& str,
405  const CCVector3& pos3D,
406  const ecvColor::Rgbub* color = nullptr,
407  const QFont& font = QFont());
408 
409 public:
410  static void SetFocusToScreen();
411  static void ToBeRefreshed();
412  static void RefreshDisplay(bool only2D = false, bool forceRedraw = true);
413  static void RedrawDisplay(bool only2D = false, bool forceRedraw = true);
414  static void CheckIfRemove();
415  inline static void Draw(const CC_DRAW_CONTEXT& context,
416  const ccHObject* obj) {
417  TheInstance()->draw(context, obj);
418  }
419  inline virtual void draw(const CC_DRAW_CONTEXT& context,
420  const ccHObject* obj) { /* do nothing */ }
421 
422  inline static void UpdateMeshTextures(const CC_DRAW_CONTEXT& context,
423  const ccGenericMesh* mesh) {
424  TheInstance()->updateMeshTextures(context, mesh);
425  }
426  inline virtual void updateMeshTextures(
427  const CC_DRAW_CONTEXT& context,
428  const ccGenericMesh* mesh) { /* do nothing */ }
429 
430  inline static void DrawBBox(const CC_DRAW_CONTEXT& context,
431  const ccBBox* bbox) {
432  TheInstance()->drawBBox(context, bbox);
433  }
434  inline virtual void drawBBox(const CC_DRAW_CONTEXT& context,
435  const ccBBox* bbox) { /* do nothing */ }
436 
437  inline static void DrawOrientedBBox(const CC_DRAW_CONTEXT& context,
438  const ecvOrientedBBox* obb) {
439  TheInstance()->drawOrientedBBox(context, obb);
440  }
441  inline virtual void drawOrientedBBox(
442  const CC_DRAW_CONTEXT& context,
443  const ecvOrientedBBox* obb) { /* do nothing */ }
444 
446  static void RemoveBB(const QString& viewId);
447  static void ChangeEntityProperties(PROPERTY_PARAM& propertyParam,
448  bool autoUpdate = true);
449  inline virtual void changeEntityProperties(
450  PROPERTY_PARAM& propertyParam) { /* do nothing */ }
451  static void DrawWidgets(const WIDGETS_PARAMETER& param,
452  bool update = false);
453  inline virtual void drawWidgets(
454  const WIDGETS_PARAMETER& param) { /* do nothing */ }
455  static void RemoveWidgets(const WIDGETS_PARAMETER& param,
456  bool update = false);
457  static void RemoveAllWidgets(bool update = true);
458  static void Remove3DLabel(const QString& view_id);
459 
460  inline static void DrawCoordinates(double scale = 1.0,
461  const std::string& id = "reference",
462  int viewport = 0) {
463  TheInstance()->drawCoordinates(scale, id, viewport);
464  }
465 
466  inline virtual void drawCoordinates(double scale = 1.0,
467  const std::string& id = "reference",
468  int viewport = 0) { /* do nothing */ }
469 
477  inline static void RotateWithAxis(const CCVector2i& pos,
478  const CCVector3d& axis,
479  double angle,
480  int viewport = 0) {
481  TheInstance()->rotateWithAxis(pos, axis, angle, viewport);
482  }
483 
484  inline virtual void rotateWithAxis(const CCVector2i& pos,
485  const CCVector3d& axis,
486  double angle,
487  int viewport = 0) { /* do nothing */ }
488 
489  inline static void ToggleOrientationMarker(bool state = true) {
490  TheInstance()->toggleOrientationMarker(state);
491  UpdateScreen();
492  }
493  inline virtual void toggleOrientationMarker(
494  bool state = true) { /* do nothing */ }
495 
496  inline static bool OrientationMarkerShown() {
497  return TheInstance()->orientationMarkerShown();
498  }
499  inline virtual bool orientationMarkerShown() {
500  return false; /* do nothing */
501  }
502 
503  // ========================================================================
504  // ParaView-style Axes Grid Support (Unified Interface with
505  // AxesGridProperties)
506  // ========================================================================
507 
518  inline static void SetDataAxesGridProperties(
519  const QString& viewID,
520  const AxesGridProperties& props,
521  int viewport = 0) {
522  TheInstance()->setDataAxesGridProperties(viewID, props, viewport);
523  UpdateScreen();
524  }
525 
530  inline virtual void setDataAxesGridProperties(
531  const QString& viewID,
532  const AxesGridProperties& props,
533  int viewport = 0) { /* do nothing */ }
534 
542  inline static void GetDataAxesGridProperties(const QString& viewID,
543  AxesGridProperties& props,
544  int viewport = 0) {
545  TheInstance()->getDataAxesGridProperties(viewID, props, viewport);
546  }
547 
552  inline virtual void getDataAxesGridProperties(const QString& viewID,
553  AxesGridProperties& props,
554  int viewport = 0) const {
555  // Default implementation
556  props = AxesGridProperties();
557  }
558 
560  inline static void SetViewAxesGridVisible(bool visible, int viewport = 0) {
561  TheInstance()->setViewAxesGridVisible(visible, viewport);
562  UpdateScreen();
563  }
564  inline virtual void setViewAxesGridVisible(
565  bool visible, int viewport = 0) { /* do nothing */ }
566 
568  inline static void SetViewAxesGridProperties(bool visible,
569  const CCVector3& color,
570  double lineWidth,
571  double spacing,
572  int subdivisions,
573  bool showLabels,
574  double opacity,
575  int viewport = 0) {
576  TheInstance()->setViewAxesGridProperties(visible, color, lineWidth,
577  spacing, subdivisions,
578  showLabels, opacity, viewport);
579  UpdateScreen();
580  }
581  inline virtual void setViewAxesGridProperties(
582  bool visible,
583  const CCVector3& color,
584  double lineWidth,
585  double spacing,
586  int subdivisions,
587  bool showLabels,
588  double opacity,
589  int viewport = 0) { /* do nothing */ }
590 
592  inline virtual void getViewAxesGridProperties(bool& visible,
593  CCVector3& color,
594  double& lineWidth,
595  double& spacing,
596  int& subdivisions,
597  bool& showLabels,
598  double& opacity,
599  int viewport = 0) const {
600  // Default values
601  visible = false;
602  color = CCVector3(179, 179, 179);
603  lineWidth = 1.0;
604  spacing = 1.0;
605  subdivisions = 10;
606  showLabels = true;
607  opacity = 0.3;
608  }
609 
611  inline static void SetCenterAxesVisible(bool visible, int viewport = 0) {
612  TheInstance()->setCenterAxesVisible(visible, viewport);
613  UpdateScreen();
614  }
615  inline virtual void setCenterAxesVisible(
616  bool visible, int viewport = 0) { /* do nothing */ }
617 
620  inline static void ToggleCameraOrientationWidget(bool show) {
621  TheInstance()->toggleCameraOrientationWidget(show);
622  UpdateScreen();
623  }
624  inline virtual void toggleCameraOrientationWidget(
625  bool show) { /* do nothing */ }
626 
628  inline static bool IsCameraOrientationWidgetShown() {
629  return TheInstance()->isCameraOrientationWidgetShown();
630  }
631  inline virtual bool isCameraOrientationWidgetShown() const { return false; }
632 
636  inline static void SetLightIntensity(double intensity) {
637  TheInstance()->setLightIntensity(intensity);
638  UpdateScreen();
639  }
640  inline virtual void setLightIntensity(double intensity) { /* do nothing */ }
641 
644  inline static double GetLightIntensity() {
645  return TheInstance()->getLightIntensity();
646  }
647  inline virtual double getLightIntensity() const { return 1.0; }
648 
649 private:
650  static void Draw3D(CC_DRAW_CONTEXT& CONTEXT);
651 
652 public: // main interface
654  return TheInstance()->getVisualizer3D();
655  }
657  return nullptr; /* do nothing */
658  }
660  return TheInstance()->getVisualizer2D();
661  }
663  return nullptr; /* do nothing */
664  }
665 
666  inline static QWidget* GetCurrentScreen() {
667  if (!TheInstance()) return nullptr;
668  return TheInstance()->m_currentScreen;
669  }
670  static void SetCurrentScreen(QWidget* widget);
671  inline static QWidget* GetMainScreen() {
672  if (!TheInstance()) return nullptr;
673  return TheInstance()->m_mainScreen;
674  }
675  inline static void SetMainScreen(QWidget* widget) {
676  TheInstance()->m_mainScreen = widget;
677  }
678 
679  inline static QMainWindow* GetMainWindow() { return TheInstance()->m_win; }
680  inline static void SetMainWindow(QMainWindow* win) {
681  TheInstance()->m_win = win;
682  }
683 
684  static QPointF ToCenteredGLCoordinates(int x, int y);
685  static CCVector3d ToVtkCoordinates(int x, int y, int z = 0);
686  static void ToVtkCoordinates(CCVector3d& sP);
687  static void ToVtkCoordinates(CCVector2i& sP);
688 
690  inline static ccHObject* GetOwnDB() { return TheInstance()->m_winDBRoot; }
692 
695  static void AddToOwnDB(ccHObject* obj, bool noDependency = true);
696 
698  static void RemoveFromOwnDB(ccHObject* obj);
699 
700  static void SetSceneDB(ccHObject* root);
701  inline static ccHObject* GetSceneDB() {
702  return TheInstance()->m_globalDBRoot;
703  }
704 
705  static void UpdateNamePoseRecursive();
706 
707  static void SetRedrawRecursive(bool redraw = false);
708  static void SetRedrawRecursive(ccHObject* obj, bool redraw = false);
709 
711  static void GetVisibleObjectsBB(ccBBox& box);
712 
714 
719  static void RotateBaseViewMat(const ccGLMatrixd& rotMat);
720 
721  inline static ccGLMatrixd& GetBaseViewMat() {
722  return TheInstance()->m_viewportParams.viewMat;
723  }
724  static void SetBaseViewMat(ccGLMatrixd& mat);
725 
726  static void SetRemoveViewIDs(std::vector<removeInfo>& removeinfos);
727  inline static void SetRemoveAllFlag(bool state) {
728  TheInstance()->m_removeAllFlag = state;
729  }
730 
731  inline static void TransformCameraView(const ccGLMatrixd& viewMat) {
732  TheInstance()->transformCameraView(viewMat);
733  }
734  inline virtual void transformCameraView(
735  const ccGLMatrixd& viewMat) { /* do nothing */ }
736  inline static void TransformCameraProjection(const ccGLMatrixd& projMat) {
737  TheInstance()->transformCameraProjection(projMat);
738  }
739  inline virtual void transformCameraProjection(
740  const ccGLMatrixd& projMat) { /* do nothing */ }
741 
742  static inline int GetDevicePixelRatio() {
743  // return TheInstance()->getDevicePixelRatio();
744  return GetMainWindow()->devicePixelRatio();
745  }
746 
747  // New: Cross-platform font size optimization function
748  static inline int GetOptimizedFontSize(int baseFontSize = 12) {
749  QWidget* win = GetMainWindow();
750  if (!win) {
751  return baseFontSize;
752  }
753 
754  int dpiScale = win->devicePixelRatio();
755  QScreen* screen = QApplication::primaryScreen();
756  if (!screen) {
757  return baseFontSize;
758  }
759 
760  // Get screen resolution information
761  QSize screenSize = screen->size();
762  int screenWidth = screenSize.width();
763  int screenHeight = screenSize.height();
764  int screenDPI = screen->physicalDotsPerInch();
765 
766  // Platform-specific base font size adjustment
767  int platformBaseSize = baseFontSize;
768 #ifdef Q_OS_MAC
769  // macOS: Default font is slightly larger, but need to consider Retina
770  // display over-scaling
771  platformBaseSize = baseFontSize;
772  if (dpiScale > 1) {
773  // Retina display: Use smaller font to avoid over-scaling
774  platformBaseSize = std::max(8, baseFontSize - (dpiScale - 1) * 2);
775  }
776 #elif defined(Q_OS_WIN)
777  // Windows: Adjust font size according to DPI
778  if (screenDPI > 120) {
779  // High DPI display
780  platformBaseSize = std::max(8, baseFontSize - 1);
781  } else if (screenDPI < 96) {
782  // Low DPI display
783  platformBaseSize = baseFontSize + 1;
784  }
785 #elif defined(Q_OS_LINUX)
786  // Linux: Adjust according to screen resolution
787  if (screenWidth >= 1920 && screenHeight >= 1080) {
788  // High resolution display
789  platformBaseSize = std::max(8, baseFontSize - 1);
790  } else if (screenWidth < 1366) {
791  // Low resolution display
792  platformBaseSize = baseFontSize + 1;
793  }
794 #endif
795 
796  // Resolution-specific adjustment
797  int resolutionFactor = 1;
798  if (screenWidth >= 2560 && screenHeight >= 1440) {
799  // 2K and above resolution
800  resolutionFactor = 0;
801  } else if (screenWidth >= 1920 && screenHeight >= 1080) {
802  // 1080p resolution
803  resolutionFactor = 0;
804  } else if (screenWidth < 1366) {
805  // Low resolution
806  resolutionFactor = 1;
807  }
808 
809  // Final font size calculation
810  int finalSize = platformBaseSize + resolutionFactor;
811 
812  // Ensure font size is within reasonable range
813  finalSize = std::max(6, std::min(24, finalSize));
814 
815  return finalSize;
816  }
817 
818  // New: Cross-platform DPI scaling handling function
819  static inline double GetPlatformAwareDPIScale() {
820  QWidget* win = GetMainWindow();
821  if (!win) {
822  return 1.0;
823  }
824 
825  int dpiScale = win->devicePixelRatio();
826  QScreen* screen = QApplication::primaryScreen();
827  if (!screen) {
828  return static_cast<double>(dpiScale);
829  }
830 
831  // Get screen information
832  QSize screenSize = screen->size();
833  int screenWidth = screenSize.width();
834  int screenHeight = screenSize.height();
835  int screenDPI = screen->physicalDotsPerInch();
836 
837  // Platform-specific DPI scaling adjustment
838  double adjustedScale = static_cast<double>(dpiScale);
839 
840 #ifdef Q_OS_MAC
841  // macOS: Retina displays need special handling
842  if (dpiScale > 1) {
843  // For UI elements, use smaller scaling to avoid over-scaling
844  adjustedScale = 1.0 + (dpiScale - 1.0) * 0.5;
845  }
846 #elif defined(Q_OS_WIN)
847  // Windows: Adjust according to DPI settings
848  if (screenDPI > 120) {
849  // High DPI display, appropriately reduce scaling
850  adjustedScale = std::min(adjustedScale, 1.5);
851  } else if (screenDPI < 96) {
852  // Low DPI display, appropriately increase scaling
853  adjustedScale = std::max(adjustedScale, 1.0);
854  }
855 #elif defined(Q_OS_LINUX)
856  // Linux: Adjust according to resolution
857  if (screenWidth >= 2560 && screenHeight >= 1440) {
858  // Ultra-high resolution, reduce scaling
859  adjustedScale = std::min(adjustedScale, 1.3);
860  } else if (screenWidth < 1366) {
861  // Low resolution, increase scaling
862  adjustedScale = std::max(adjustedScale, 1.0);
863  }
864 #endif
865 
866  // Ensure scaling is within reasonable range
867  adjustedScale = std::max(0.5, std::min(2.0, adjustedScale));
868 
869  return adjustedScale;
870  }
871 
872  inline static QRect GetScreenRect() {
873  QRect screenRect = GetCurrentScreen()->geometry();
874  QPoint globalPosition =
875  GetCurrentScreen()->mapToGlobal(screenRect.topLeft());
876  screenRect.setTopLeft(globalPosition);
877  return screenRect;
878  }
879  inline static void SetScreenSize(int xw, int yw) {
880  GetCurrentScreen()->resize(QSize(xw, yw));
881  }
882  inline static void DoResize(int xw, int yw) { SetScreenSize(xw, yw); }
883  inline static void DoResize(const QSize& size) {
884  SetScreenSize(size.width(), size.height());
885  }
886  inline static QSize GetScreenSize() { return GetCurrentScreen()->size(); }
887 
888  inline static void SetRenderWindowSize(int xw, int yw) {
889  TheInstance()->setRenderWindowSize(xw, yw);
890  }
891  inline virtual void setRenderWindowSize(int xw, int yw) { /* do nothing */ }
892 
893  inline static void FullScreen(bool state) {
894  TheInstance()->fullScreen(state);
895  }
896  inline virtual void fullScreen(bool state) { /* do nothing */ }
897 
898  static void ZoomCamera(double zoomFactor, int viewport = 0);
899  inline virtual void zoomCamera(double zoomFactor, int viewport = 0) {}
900  inline static double GetCameraFocalDistance(int viewport = 0) {
901  return TheInstance()->getCameraFocalDistance(viewport);
902  }
903  inline virtual double getCameraFocalDistance(int viewport = 0) {
904  return 100.0; /* do nothing */
905  }
906 
907  inline static void SetCameraFocalDistance(double focal_distance,
908  int viewport = 0) {
909  TheInstance()->setCameraFocalDistance(focal_distance, viewport);
910  }
911  inline virtual void setCameraFocalDistance(
912  double focal_distance, int viewport = 0) { /* do nothing */ }
913 
914  inline static void GetCameraPos(double* pos, int viewport = 0) {
915  TheInstance()->getCameraPos(pos, viewport);
916  }
917  inline virtual void getCameraPos(double* pos,
918  int viewport = 0) { /* do nothing */ }
919  inline static void GetCameraFocal(double* focal, int viewport = 0) {
920  TheInstance()->getCameraFocal(focal, viewport);
921  }
922  inline virtual void getCameraFocal(double* focal,
923  int viewport = 0) { /* do nothing */ }
924  inline static void GetCameraUp(double* up, int viewport = 0) {
925  TheInstance()->getCameraUp(up, viewport);
926  }
927  virtual void getCameraUp(double* up, int viewport = 0) { /* do nothing */ }
928 
929  inline static void SetCameraPosition(const CCVector3d& pos,
930  int viewport = 0) {
931  TheInstance()->setCameraPosition(pos, viewport);
932  }
933  inline virtual void setCameraPosition(const CCVector3d& pos,
934  int viewport = 0) { /* do nothing */ }
935  inline static void SetCameraPosition(const double* pos,
936  const double* focal,
937  const double* up,
938  int viewport = 0) {
939  TheInstance()->setCameraPosition(pos, focal, up, viewport);
940  }
941  inline virtual void setCameraPosition(const double* pos,
942  const double* focal,
943  const double* up,
944  int viewport = 0) { /* do nothing */ }
945  inline static void SetCameraPosition(const double* pos,
946  const double* up,
947  int viewport = 0) {
948  TheInstance()->setCameraPosition(pos, up, viewport);
949  }
950  inline virtual void setCameraPosition(const double* pos,
951  const double* up,
952  int viewport = 0) { /* do nothing */ }
953  inline static void SetCameraPosition(double pos_x,
954  double pos_y,
955  double pos_z,
956  double view_x,
957  double view_y,
958  double view_z,
959  double up_x,
960  double up_y,
961  double up_z,
962  int viewport = 0) {
963  TheInstance()->setCameraPosition(pos_x, pos_y, pos_z, view_x, view_y,
964  view_z, up_x, up_y, up_z, viewport);
965  }
966  inline virtual void setCameraPosition(double pos_x,
967  double pos_y,
968  double pos_z,
969  double view_x,
970  double view_y,
971  double view_z,
972  double up_x,
973  double up_y,
974  double up_z,
975  int viewport = 0) { /* do nothing */ }
976 
977  // set and get clip distances (near and far)
978  inline static void GetCameraClip(double* clipPlanes, int viewport = 0) {
979  TheInstance()->getCameraClip(clipPlanes, viewport);
980  }
981  virtual void getCameraClip(double* clipPlanes,
982  int viewport = 0) { /* do nothing */ }
983  inline static void SetCameraClip(double znear,
984  double zfar,
985  int viewport = 0) {
986  TheInstance()->m_viewportParams.zNear = znear;
987  TheInstance()->m_viewportParams.zFar = zfar;
988  TheInstance()->setCameraClip(znear, zfar, viewport);
989  }
990  virtual void setCameraClip(double znear,
991  double zfar,
992  int viewport = 0) { /* do nothing */ }
993 
994  inline static void ResetCameraClippingRange(int viewport = 0) {
995  TheInstance()->resetCameraClippingRange(viewport);
996  }
997  inline virtual void resetCameraClippingRange(
998  int viewport = 0) { /* do nothing */ }
999 
1000  // set and get view angle in y direction
1001  inline static double GetCameraFovy(int viewport = 0) {
1002  return TheInstance()->getCameraFovy(viewport);
1003  }
1004  inline virtual double getCameraFovy(int viewport = 0) {
1005  return 0; /* do nothing */
1006  }
1007  inline static void SetCameraFovy(double fovy, int viewport = 0) {
1008  TheInstance()->m_viewportParams.fov_deg = static_cast<float>(fovy);
1009  TheInstance()->setCameraFovy(cloudViewer::DegreesToRadians(fovy),
1010  viewport);
1011  }
1012  inline virtual void setCameraFovy(double fovy,
1013  int viewport = 0) { /* do nothing */ }
1014 
1015  inline static void GetViewerPos(int* viewPos, int viewport = 0) {
1016  viewPos[0] = 0;
1017  viewPos[1] = 0;
1018  viewPos[2] = Width();
1019  viewPos[3] = Height();
1020  }
1021 
1025  inline static void SaveScreenshot(const std::string& file) {
1026  TheInstance()->saveScreenshot(file);
1027  }
1028  inline virtual void saveScreenshot(
1029  const std::string& file) { /* do nothing */ }
1030 
1034  inline static void SaveCameraParameters(const std::string& file) {
1035  TheInstance()->saveCameraParameters(file);
1036  }
1037  inline virtual void saveCameraParameters(
1038  const std::string& file) { /* do nothing */ }
1039 
1040  inline static void LoadCameraParameters(const std::string& file) {
1041  TheInstance()->loadCameraParameters(file);
1042  }
1043  inline virtual void loadCameraParameters(
1044  const std::string& file) { /* do nothing */ }
1045 
1046  inline static void ShowOrientationMarker() {
1047  TheInstance()->showOrientationMarker();
1048  UpdateScreen();
1049  }
1050  inline virtual void showOrientationMarker() { /* do nothing */ }
1051 
1052  inline static void SetOrthoProjection(int viewport = 0) {
1053  TheInstance()->setOrthoProjection(viewport);
1054  UpdateScreen();
1055  }
1056  inline virtual void setOrthoProjection(int viewport = 0) { /* do nothing */
1057  }
1058  inline static void SetPerspectiveProjection(int viewport = 0) {
1059  TheInstance()->setPerspectiveProjection(viewport);
1060  UpdateScreen();
1061  }
1062  inline virtual void setPerspectiveProjection(
1063  int viewport = 0) { /* do nothing */ }
1064 
1070  inline static void SetUseVbos(bool useVbos) {
1071  TheInstance()->setUseVbos(useVbos);
1072  }
1073  inline virtual void setUseVbos(bool useVbos) { /* do nothing */ }
1074 
1078  inline static void SetLookUpTableID(const std::string& viewID) {
1079  TheInstance()->setLookUpTableID(viewID);
1080  }
1081  inline virtual void setLookUpTableID(
1082  const std::string& viewID) { /* do nothing */ }
1083 
1084  inline static void GetProjectionMatrix(double* projArray,
1085  int viewport = 0) {
1086  TheInstance()->getProjectionMatrix(projArray, viewport);
1087  }
1088  inline virtual void getProjectionMatrix(double* projArray,
1089  int viewport = 0) { /* do nothing */
1090  }
1091  inline static void GetViewMatrix(double* viewArray, int viewport = 0) {
1092  TheInstance()->getViewMatrix(viewArray, viewport);
1093  }
1094  inline virtual void getViewMatrix(double* viewArray,
1095  int viewport = 0) { /* do nothing */ }
1096 
1097  inline static void SetViewMatrix(const ccGLMatrixd& viewMat,
1098  int viewport = 0) {
1099  TheInstance()->setViewMatrix(viewMat, viewport);
1100  }
1101  inline virtual void setViewMatrix(const ccGLMatrixd& viewMat,
1102  int viewport = 0) { /* do nothing */ }
1103 
1104  static bool HideShowEntities(const ccHObject* obj, bool visible);
1105  inline static bool HideShowEntities(const CC_DRAW_CONTEXT& CONTEXT) {
1106  return TheInstance()->hideShowEntities(CONTEXT);
1107  }
1108  inline virtual bool hideShowEntities(const CC_DRAW_CONTEXT& CONTEXT) {
1109  return true; /* do nothing */
1110  }
1111  static void HideShowEntities(const QStringList& viewIDs,
1112  ENTITY_TYPE hideShowEntityType,
1113  bool visibility = false);
1114 
1115  static void RemoveEntities(const ccHObject* obj);
1116  static void RemoveEntities(const QStringList& viewIDs,
1117  ENTITY_TYPE removeEntityType);
1118  inline static void RemoveEntities(const CC_DRAW_CONTEXT& CONTEXT) {
1119  TheInstance()->removeEntities(CONTEXT);
1120  }
1121  inline virtual void removeEntities(
1122  const CC_DRAW_CONTEXT& CONTEXT) { /* do nothing */ }
1123 
1124  static void DrawBackground(CC_DRAW_CONTEXT& CONTEXT);
1125  static void DrawForeground(CC_DRAW_CONTEXT& CONTEXT);
1126  static void Update2DLabel(bool immediateUpdate = false);
1127  static void Pick2DLabel(int x, int y);
1128  virtual QString pick2DLabel(int x, int y) {
1129  return QString(); /* do nothing */
1130  }
1131  static void Redraw2DLabel();
1132 
1133  static QString Pick3DItem(int x = -1, int y = -1) {
1134  return TheInstance()->pick3DItem(x, y);
1135  }
1136  virtual QString pick3DItem(int x = -1, int y = -1) {
1137  return QString(); /* do nothing */
1138  }
1139  static QString PickObject(double x = -1, double y = -1) {
1140  return TheInstance()->pickObject(x, y);
1141  }
1142  virtual QString pickObject(double x = -1, double y = -1) {
1143  return QString(); /* do nothing */
1144  }
1145 
1148 
1149  inline virtual void setBackgroundColor(
1150  const CC_DRAW_CONTEXT& CONTEXT) { /* do nothing */ }
1151 
1164  inline static void CreateViewPort(
1165  double xmin, double ymin, double xmax, double ymax, int& viewport) {
1166  TheInstance()->createViewPort(xmin, ymin, xmax, ymax, viewport);
1167  }
1168  inline virtual void createViewPort(double xmin,
1169  double ymin,
1170  double xmax,
1171  double ymax,
1172  int& viewport) { /* do nothing */ }
1173 
1174  inline static void ResetCameraViewpoint(const std::string& viewID) {
1175  TheInstance()->resetCameraViewpoint(viewID);
1176  }
1177  inline virtual void resetCameraViewpoint(
1178  const std::string& viewID) { /* do nothing */ }
1179 
1180  static void SetPointSize(float size, bool silent = false, int viewport = 0);
1181  static void SetPointSizeRecursive(int size);
1182 
1184 
1186  static void SetLineWidth(float width,
1187  bool silent = false,
1188  int viewport = 0);
1190 
1191  inline static void Toggle2Dviewer(bool state) {
1192  TheInstance()->toggle2Dviewer(state);
1193  }
1194  inline virtual void toggle2Dviewer(bool state) { /* do nothing */ }
1195 
1196 public: // visualization matrix transformation
1198 
1206  static void DisplayNewMessage(const QString& message,
1207  MessagePosition pos,
1208  bool append = false,
1209  int displayMaxDelay_sec = 2,
1210  MessageType type = CUSTOM_MESSAGE);
1211 
1213 
1216 
1219 
1221 
1222  static void SetupProjectiveViewport(const ccGLMatrixd& cameraMatrix,
1223  float fov_deg = 0.0f,
1224  float ar = 1.0f,
1225  bool viewerBasedPerspective = true,
1226  bool bubbleViewMode = false);
1227 
1229 
1231  static void SetAspectRatio(float ar);
1232 
1234 
1236  static void ResizeGL(int w, int h);
1237  static void UpdateScreenSize();
1238  inline static void Update() {
1239  GetCurrentScreen()->update();
1240  UpdateCamera();
1241  }
1242  inline static void UpdateScreen() {
1243  GetCurrentScreen()->update();
1244  UpdateScene();
1245  }
1246  inline static void ResetCamera(const ccBBox* bbox) {
1247  TheInstance()->resetCamera(bbox);
1248  UpdateScreen();
1249  }
1250  inline virtual void resetCamera(const ccBBox* bbox) { /* do nothing */ }
1251  inline static void ResetCamera() {
1252  TheInstance()->resetCamera();
1253  UpdateScreen();
1254  }
1255  inline virtual void resetCamera() { /* do nothing */ }
1256  inline static void UpdateCamera() {
1257  TheInstance()->updateCamera();
1258  UpdateScreen();
1259  }
1260  inline virtual void updateCamera() { /* do nothing */ }
1261 
1262  inline static void UpdateScene() { TheInstance()->updateScene(); }
1263  inline virtual void updateScene() { /* do nothing */ }
1264 
1265  inline static void SetAutoUpateCameraPos(bool state) {
1266  TheInstance()->setAutoUpateCameraPos(state);
1267  }
1268  inline virtual void setAutoUpateCameraPos(bool state) { /* do nothing */ }
1269 
1273  inline static void GetCenterOfRotation(double center[3]) {
1274  TheInstance()->getCenterOfRotation(center);
1275  }
1276  inline static void GetCenterOfRotation(CCVector3d& center) {
1277  TheInstance()->getCenterOfRotation(center.u);
1278  }
1279  inline virtual void getCenterOfRotation(double center[3]) { /* do nothing */
1280  }
1281 
1285  inline static void ResetCenterOfRotation(int viewport = 0) {
1286  TheInstance()->resetCenterOfRotation(viewport);
1287  UpdateScreen();
1288  }
1289  inline virtual void resetCenterOfRotation(
1290  int viewport = 0) { /* do nothing */ }
1291 
1298  inline static void SetCenterOfRotation(double x, double y, double z) {
1299  TheInstance()->setCenterOfRotation(x, y, z);
1300  }
1301  inline virtual void setCenterOfRotation(double x,
1302  double y,
1303  double z) { /* do nothing */ }
1304 
1305  inline static void SetCenterOfRotation(const double xyz[3]) {
1306  SetCenterOfRotation(xyz[0], xyz[1], xyz[2]);
1307  }
1308 
1309  inline static void SetCenterOfRotation(const CCVector3d& center) {
1310  SetCenterOfRotation(center.u);
1311  }
1312 
1313  inline static double GetGLDepth(int x, int y) {
1314  return TheInstance()->getGLDepth(x, y);
1315  }
1316  inline virtual double getGLDepth(int x, int y) {
1317  return 1.0; /* do nothing */
1318  }
1319 
1320  inline static void ChangeOpacity(double opacity,
1321  const std::string& viewID,
1322  int viewport = 0) {
1323  TheInstance()->changeOpacity(opacity, viewID, viewport);
1324  UpdateScreen();
1325  }
1326  inline virtual void changeOpacity(double opacity,
1327  const std::string& viewID,
1328  int viewport = 0) {
1329  /* do nothing */
1330  }
1331 
1333 
1336 
1338 
1341  static void UpdateActiveItemsList(int x,
1342  int y,
1343  bool extendToSelectedLabels = false);
1344 
1346  inline static void SetGLViewport(int x, int y, int w, int h) {
1347  SetGLViewport(QRect(x, y, w, h));
1348  }
1350  static void SetGLViewport(const QRect& rect);
1351 
1352  // Graphical features controls
1353  static void drawCross();
1354  static void drawTrihedron();
1355 
1357  static bool RenderToFile(QString filename,
1358  float zoomFactor = 1.0f,
1359  bool dontScaleFeatures = false,
1360  bool renderOverlayItems = false);
1361 
1362  inline static QImage RenderToImage(int zoomFactor = 1,
1363  bool renderOverlayItems = false,
1364  bool silent = false,
1365  int viewport = 0) {
1366  return TheInstance()->renderToImage(zoomFactor, renderOverlayItems,
1367  silent, viewport);
1368  }
1369  inline virtual QImage renderToImage(int zoomFactor = 1,
1370  bool renderOverlayItems = false,
1371  bool silent = false,
1372  int viewport = 0) {
1373  return QImage(); /* do nothing */
1374  }
1375 
1376  inline static void SetScaleBarVisible(bool visible) {
1377  return TheInstance()->setScaleBarVisible(visible);
1378  }
1379  inline virtual void setScaleBarVisible(bool visible) { /* do nothing */ }
1380 
1381  static void DisplayTexture2DPosition(QImage image,
1382  const QString& id,
1383  int x,
1384  int y,
1385  int w,
1386  int h,
1387  unsigned char alpha = 255);
1390  static void DrawClickableItems(int xStart, int& yStart);
1391  static void RenderText(
1392  int x,
1393  int y,
1394  const QString& str,
1395  const QFont& font = QFont(),
1397  const QString& id = "");
1398  static void RenderText(
1399  double x,
1400  double y,
1401  double z,
1402  const QString& str,
1403  const QFont& font = QFont(),
1405  const QString& id = "");
1406 
1408  inline static void ToggleExclusiveFullScreen(bool state) {
1409  TheInstance()->toggleExclusiveFullScreen(state);
1410  }
1411  inline virtual void toggleExclusiveFullScreen(
1412  bool state) { /* in this do nothing */ }
1413 
1415  inline static bool ExclusiveFullScreen() {
1416  return TheInstance()->m_exclusiveFullscreen;
1417  }
1418  inline static void SetExclusiveFullScreenFlage(bool state) {
1419  TheInstance()->m_exclusiveFullscreen = state;
1420  }
1421 
1423 
1425  static void SetPixelSize(float pixelSize);
1426 
1428 
1431  static void UpdateConstellationCenterAndZoom(const ccBBox* aBox = nullptr,
1432  bool redraw = true);
1433 
1435  static void GetContext(CC_DRAW_CONTEXT& CONTEXT);
1436 
1439 
1440  static void SetInteractionMode(INTERACTION_FLAGS flags);
1442  static INTERACTION_FLAGS GetInteractionMode();
1443 
1444  static void SetView(CC_VIEW_ORIENTATION orientation, ccBBox* bbox);
1445  static void SetView(CC_VIEW_ORIENTATION orientation,
1446  bool forceRedraw = false);
1447 
1450 
1454 
1456 
1465  static void SetPerspectiveState(bool state, bool objectCenteredView);
1466 
1467  static bool GetPerspectiveState(int viewport = 0) {
1468  return TheInstance()->getPerspectiveState(viewport);
1469  }
1470  inline virtual bool getPerspectiveState(int viewport = 0) const override {
1471  return TheInstance()->m_viewportParams.perspectiveView;
1472  }
1473 
1478 
1481  static float ComputePerspectiveZoom();
1482 
1484 
1486  static void SetFov(float fov);
1488  static float GetFov();
1489 
1490  inline static void ZoomGlobal() { UpdateConstellationCenterAndZoom(); }
1491 
1493 
1497 
1499 
1503 
1505 
1507  static void SetCameraPos(const CCVector3d& P);
1508 
1510 
1516  static void MoveCamera(float dx, float dy, float dz);
1518 
1525  inline static void MoveCamera(const CCVector3d& v) {
1526  MoveCamera(v.x, v.y, v.z);
1527  }
1528 
1529  static void SetPickingMode(PICKING_MODE mode = DEFAULT_PICKING);
1531 
1533 
1535  static void LockPickingMode(bool state);
1536 
1538  static bool IsPickingModeLocked();
1539 
1541 
1543  static void SetZoom(float value);
1544 
1546 
1548  static void UpdateZoom(float zoomFactor);
1549 
1551 
1553  static void SetPivotPoint(const CCVector3d& P,
1554  bool autoUpdateCameraPos = false,
1555  bool verbose = false);
1556 
1559  static void SetPivotVisibility(bool state) {
1560  TheInstance()->setPivotVisibility(state);
1561  }
1562  virtual void setPivotVisibility(bool state) { /*do nothing here*/ }
1563 
1566  return TheInstance()->m_pivotVisibility;
1567  }
1568 
1570 
1575  static void ShowPivotSymbol(bool state);
1576 
1579 
1580  // return value (in rad)
1581  inline static double GetParallelScale(int viewport = 0) {
1582  return TheInstance()->getParallelScale(viewport);
1583  }
1584  inline virtual double getParallelScale(int viewport = 0) { return -1.0; }
1585 
1586  // scale (in rad)
1587  inline static void SetParallelScale(double scale, int viewport = 0) {
1588  TheInstance()->setParallelScale(scale, viewport);
1589  }
1590  inline virtual void setParallelScale(double scale,
1591  int viewport = 0) { /*do nothing here*/
1592  }
1593 
1596 
1597  static void UpdateModelViewMatrix();
1598  static void UpdateProjectionMatrix();
1599 
1603 
1609  bool withGLfeatures,
1610  ProjectionMetrics* metrics = nullptr,
1611  double* eyeOffset = nullptr);
1612 
1613  inline static void Deprecate3DLayer() { TheInstance()->m_updateFBO = true; }
1614  inline static void InvalidateViewport() {
1615  TheInstance()->m_validProjectionMatrix = false;
1616  }
1617  inline static void InvalidateVisualization() {
1618  TheInstance()->m_validModelviewMatrix = false;
1619  }
1620 
1622 
1625 
1627  static double ComputeActualPixelSize();
1628 
1631 
1633  static void SetRectangularPickingAllowed(bool state);
1634 
1636 
1643  static void SetBubbleViewMode(bool state);
1645  inline static bool BubbleViewModeEnabled() {
1646  return TheInstance()->m_bubbleViewModeEnabled;
1647  }
1649  static void SetBubbleViewFov(float fov_deg);
1650 
1653  inline static void ShowCursorCoordinates(bool state) {
1654  TheInstance()->m_showCursorCoordinates = state;
1655  }
1658  inline static bool CursorCoordinatesShown() {
1659  return TheInstance()->m_showCursorCoordinates;
1660  }
1661 
1664  static void SetAutoPickPivotAtCenter(bool state);
1665  static void SendAutoPickPivotAtCenter(bool state) {
1666  emit TheInstance() -> autoPickPivot(state);
1667  }
1669  inline static bool AutoPickPivotAtCenter() {
1670  return TheInstance()->m_autoPickPivotAtCenter;
1671  }
1672 
1674  static void LockRotationAxis(bool state, const CCVector3d& axis);
1675 
1677  inline static bool IsRotationAxisLocked() {
1678  return TheInstance()->m_rotationAxisLocked;
1679  }
1680 
1682  static bool GetClick3DPos(int x, int y, CCVector3d& P3D);
1683 
1684  static void DrawPivot();
1685 
1686  // debug traces on screen
1688  inline static void EnableDebugTrace(bool state) {
1689  TheInstance()->m_showDebugTraces = state;
1690  }
1691 
1693  inline static void ToggleDebugTrace() {
1694  TheInstance()->m_showDebugTraces = !TheInstance()->m_showDebugTraces;
1695  }
1696 
1700  PickingParameters(PICKING_MODE _mode = NO_PICKING,
1701  int _centerX = 0,
1702  int _centerY = 0,
1703  int _pickWidth = 5,
1704  int _pickHeight = 5,
1705  bool _pickInSceneDB = true,
1706  bool _pickInLocalDB = true)
1707  : mode(_mode),
1708  centerX(_centerX),
1709  centerY(_centerY),
1710  pickWidth(_pickWidth),
1711  pickHeight(_pickHeight),
1712  pickInSceneDB(_pickInSceneDB),
1713  pickInLocalDB(_pickInLocalDB) {}
1714 
1716  int centerX;
1717  int centerY;
1722  };
1723 
1725 
1727  static bool ProcessClickableItems(int x, int y);
1728 
1730 
1732  static void SetZNearCoef(double coef);
1733 
1735 
1738 
1740 
1743 
1746 
1749  const PickingParameters& params,
1750  ccHObject* pickedEntity,
1751  int pickedItemIndex,
1752  const CCVector3* nearestPoint = nullptr,
1753  const std::unordered_set<int>* selectedIDs = nullptr);
1754 
1756 
1759  inline static void SetFontPointSize(int pixelSize) {
1760  TheInstance()->m_font.setPointSize(pixelSize);
1761  }
1763  static int GetFontPointSize();
1766 
1767  static void SetClickableItemsVisible(bool state) {
1768  TheInstance()->m_clickableItemsVisible = state;
1769  }
1771  return TheInstance()->m_clickableItemsVisible;
1772  }
1773 
1774  // takes rendering zoom into account!
1775  static QFont GetLabelDisplayFont();
1776  // takes rendering zoom into account!
1777  inline static QFont GetTextDisplayFont() { return TheInstance()->m_font; }
1778 
1780 
1782  static const int DefaultPickRadius = 5;
1783 
1785  inline static void SetPickingRadius(int radius) {
1786  TheInstance()->m_pickRadius = radius;
1787  }
1789  inline static int GetPickingRadius() { return TheInstance()->m_pickRadius; }
1790 
1793  static void DisplayOverlayEntities(bool state);
1794 
1797  inline static bool OverlayEntitiesAreDisplayed() {
1798  return TheInstance()->m_displayOverlayEntities;
1799  }
1800 
1802 
1804  std::list<ccInteractor*> m_activeItems;
1805 
1806 protected:
1807  ecvDisplayTools() = default;
1809  virtual void registerVisualizer(QMainWindow* win,
1810  bool stereoMode = false) = 0;
1811 
1813  QWidget* m_mainScreen;
1814  QMainWindow* m_win;
1815 
1816 public:
1819 
1821  struct ClickableItem {
1822  enum Role {
1830  };
1831 
1832  ClickableItem() : role(NO_ROLE) {}
1833  ClickableItem(Role _role, QRect _area) : role(_role), area(_area) {}
1834 
1836  QRect area;
1837  };
1838 
1840  std::vector<ClickableItem> m_clickableItems;
1841 
1844 
1846  INTERACTION_FLAGS m_interactionFlags;
1847 
1851 
1853  QElapsedTimer m_timer;
1854 
1859 
1864 
1867 
1870 
1873 
1876 
1880 
1884 
1887 
1890 
1893 
1896 
1899 
1902 
1907 
1920 
1923 
1926 
1929 
1932 
1934 
1937 
1940 
1943  std::vector<removeInfo> m_removeInfos;
1944 
1947 
1951 
1953 
1955  float m_sunLightPos[4];
1956 
1959 
1961 
1963  float m_customLightPos[4];
1964 
1967 
1970 
1973 
1976 
1979 
1981  QFont m_font;
1982 
1987  : enabled(false), zoomFactor(1.0f), renderOverlayItems(false) {}
1988 
1989  bool enabled;
1990  float zoomFactor;
1992  };
1993 
1996 
1999 
2000 public: // event representation
2001  static bool USE_2D;
2002  static bool USE_VTK_PICK;
2003 
2005  int m_last_point_index = -1;
2006  QString m_last_picked_id = QString();
2007 
2010 
2013 
2016 
2018 
2019  QStringList m_diagStrings;
2020 
2025 
2028 
2032 
2033  static int Width() { return size().width(); }
2034  static int Height() { return size().height(); }
2035  static QSize size() { return GetScreenSize(); }
2036 
2038  static int GlWidth() { return TheInstance()->m_glViewport.width(); }
2040  static int GlHeight() { return TheInstance()->m_glViewport.height(); }
2042  static QSize GlSize() { return TheInstance()->m_glViewport.size(); }
2043 
2044  static void ClearBubbleView();
2045 
2046 public slots:
2047 
2049  void onItemPickedFast(ccHObject* pickedEntity,
2050  int pickedItemIndex,
2051  int x,
2052  int y);
2053 
2054  void onPointPicking(const CCVector3& p, int index, const std::string& id);
2055 
2058 
2061  void doPicking();
2062 
2063  // called when receiving mouse wheel is rotated
2064  void onWheelEvent(float wheelDelta_deg);
2065 
2066 signals:
2067 
2071  void entitiesSelectionChanged(std::unordered_set<int> entIDs);
2072 
2074 
2080  void itemPicked(ccHObject* entity,
2081  unsigned subEntityID,
2082  int x,
2083  int y,
2084  const CCVector3& P);
2085 
2087 
2092  void itemPickedFast(ccHObject* entity, int subEntityID, int x, int y);
2093 
2096 
2097  /*** Camera link mode (interactive modifications of the view/camera are
2098  * echoed to other windows) ***/
2099 
2102  void viewMatRotated(const ccGLMatrixd& rotMat);
2104  void cameraDisplaced(float ddx, float ddy);
2106  void mouseWheelRotated(float wheelDelta_deg);
2107  void mouseWheelChanged(QWheelEvent* event);
2108 
2112 
2114  void baseViewMatChanged(const ccGLMatrixd& newViewMat);
2115 
2117  void pixelSizeChanged(float pixelSize);
2118 
2120  void fovChanged(float fov);
2121 
2123  void zNearCoefChanged(float coef);
2124 
2127 
2130 
2132  void translation(const CCVector3d& t);
2133 
2135 
2137  void rotation(const ccGLMatrixd& rotMat);
2138 
2140 
2144  void leftButtonClicked(int x, int y);
2145 
2147 
2151  void rightButtonClicked(int x, int y);
2152 
2154 
2158  void doubleButtonClicked(int x, int y);
2159 
2161 
2165  void mouseMoved(int x, int y, Qt::MouseButtons buttons);
2166 
2168 
2171 
2173 
2176  void drawing3D();
2177 
2179  void filesDropped(const QStringList& filenames, bool displayDialog);
2180 
2182  void newLabel(ccHObject* obj);
2183 
2185  void exclusiveFullScreenToggled(bool exclusive);
2186  void autoPickPivot(bool state);
2187 
2188  void labelmove2D(int x, int y, int dx, int dy);
2189 
2190  void mousePosChanged(const QPoint& pos);
2191 
2192  void pointPicked(double x, double y, double z);
2193 
2195 };
2196 
2197 Q_DECLARE_OPERATORS_FOR_FLAGS(ecvDisplayTools::INTERACTION_FLAGS);
MouseEvent event
CC_VIEW_ORIENTATION
View orientation.
Definition: CVConst.h:102
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
Definition: CVGeom.h:798
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Definition: CVTypes.h:97
std::string filename
#define CV_DB_LIB_API
Definition: CV_db.h:15
std::shared_ptr< core::Tensor > image
int width
int size
char type
math::float4 color
math::float3 position
#define slots
#define signals
cmdLineReadable * params[]
static bool Print(const char *format,...)
Prints out a formatted message in console.
Definition: CVLog.cpp:113
Type y
Definition: CVGeom.h:137
Type u[3]
Definition: CVGeom.h:139
Type x
Definition: CVGeom.h:137
Type z
Definition: CVGeom.h:137
2D Vector
Definition: CVGeom.h:32
Bounding box structure.
Definition: ecvBBox.h:25
Double version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:56
Generic mesh interface.
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
Definition: ecvHObject.h:337
Interactor interface (entity that can be dragged or clicked in a 3D view)
Definition: ecvInteractor.h:20
Colored polyline.
Definition: ecvPolyline.h:24
LineSet define a sets of lines in 3D. A typical application is to display the point cloud corresponde...
Definition: LineSet.h:29
RGB color structure.
Definition: ecvColorTypes.h:49
virtual void setLookUpTableID(const std::string &viewID)
void doubleButtonClicked(int x, int y)
Signal emitted when the double mouse button is cliked on the window.
static void UpdateNamePoseRecursive()
static void SetSceneDB(ccHObject *root)
static bool RenderToFile(QString filename, float zoomFactor=1.0f, bool dontScaleFeatures=false, bool renderOverlayItems=false)
Renders screen to a file.
static void CreateViewPort(double xmin, double ymin, double xmax, double ymax, int &viewport)
Create a new viewport from [xmin,ymin] -> [xmax,ymax].
ccGLMatrixd m_viewMatd
Complete visualization matrix (GL style - double version)
static void SetPerspectiveProjection(int viewport=0)
static ccGLMatrixd ComputeModelViewMatrix()
Computes the model view matrix.
virtual ecvGenericVisualizer2D * getVisualizer2D()
static void StartOpenGLPicking(const PickingParameters &params)
Performs the picking with OpenGL.
static void ShowPivotSymbol(bool state)
Shows or hide the pivot symbol.
static void RemoveBB(const QString &viewId)
void cameraPosChanged(const CCVector3d &)
Signal emitted when the camera position is changed.
static void GetDataAxesGridProperties(const QString &viewID, AxesGridProperties &props, int viewport=0)
Get Data Axes Grid properties (Unified Interface)
QTimer m_deferredPickingTimer
Deferred picking.
static void SetCurrentScreen(QWidget *widget)
static void GetGLCameraParameters(ccGLCameraParameters &params)
Returns the current OpenGL camera parameters.
static double GetLightIntensity()
static void RenderText(int x, int y, const QString &str, const QFont &font=QFont(), const ecvColor::Rgbub &color=ecvColor::defaultLabelBkgColor, const QString &id="")
static int GetDevicePixelRatio()
virtual void setCameraPosition(double pos_x, double pos_y, double pos_z, double view_x, double view_y, double view_z, double up_x, double up_y, double up_z, int viewport=0)
bool m_displayOverlayEntities
Whether to display overlay entities or not (scale, tetrahedron, etc.)
static CCVector3d GetCurrentViewDir()
Returns current viewing direction.
static void GetCameraUp(double *up, int viewport=0)
virtual void toggle2Dviewer(bool state)
static void RemoveFromOwnDB(ccHObject *obj)
Removes an entity from window own DB.
static void SetRemoveViewIDs(std::vector< removeInfo > &removeinfos)
virtual void loadCameraParameters(const std::string &file)
static void GetViewerPos(int *viewPos, int viewport=0)
static INTERACTION_FLAGS GetInteractionMode()
Returns the current interaction flags.
virtual void transformCameraView(const ccGLMatrixd &viewMat)
static void SetRenderWindowSize(int xw, int yw)
static bool ExclusiveFullScreen()
Returns whether the window is in exclusive full screen mode or not.
static void UpdateModelViewMatrix()
static ccGLMatrixd ComputeProjectionMatrix(bool withGLfeatures, ProjectionMetrics *metrics=nullptr, double *eyeOffset=nullptr)
Computes the projection matrix.
bool m_customLightEnabled
Whether custom light is enabled or not.
static int GetOptimizedFontSize(int baseFontSize=12)
static void ClearBubbleView()
bool m_autoRefresh
Auto-refresh mode.
ecvDisplayTools()=default
bool m_validProjectionMatrix
Whether the projection matrix is valid (or need to be recomputed)
static bool CursorCoordinatesShown()
float m_bubbleViewFov_deg
Bubble-view mode f.o.v. (degrees)
bool m_ignoreMouseReleaseEvent
Ignore next mouse release event.
bool m_rotationAxisLocked
Wheter the rotation axis is locked or not.
static CCVector3d GetCurrentUpDir()
Returns current up direction.
static void Draw(const CC_DRAW_CONTEXT &context, const ccHObject *obj)
ccHObject * m_globalDBRoot
CV main DB.
static void Display3DLabel(const QString &str, const CCVector3 &pos3D, const ecvColor::Rgbub *color=nullptr, const QFont &font=QFont())
Displays a string at a given 3D position.
static bool ObjectPerspectiveEnabled()
Shortcut: returns whether object-based perspective mode is enabled.
void drawing3D()
Signal emitted during 3D pass of OpenGL display process.
static void ChangeEntityProperties(PROPERTY_PARAM &propertyParam, bool autoUpdate=true)
static void AddToOwnDB(ccHObject *obj, bool noDependency=true)
Adds an entity to window own DB.
virtual void getViewAxesGridProperties(bool &visible, CCVector3 &color, double &lineWidth, double &spacing, int &subdivisions, bool &showLabels, double &opacity, int viewport=0) const
Get view axes grid properties.
static void Update()
virtual void drawCoordinates(double scale=1.0, const std::string &id="reference", int viewport=0)
virtual void transformCameraProjection(const ccGLMatrixd &projMat)
static void SetAutoPickPivotAtCenter(bool state)
void cameraParamChanged()
static float ComputePerspectiveZoom()
static double GetParallelScale(int viewport=0)
static void Init(ecvDisplayTools *displayTools, QMainWindow *win, bool stereoMode=false)
static void Toggle2Dviewer(bool state)
static void StartCPUBasedPointPicking(const PickingParameters &params)
Starts OpenGL picking process.
void newLabel(ccHObject *obj)
Signal emitted when a new label is created.
static void UpdateDisplayParameters()
static void SetCameraPosition(const double *pos, const double *focal, const double *up, int viewport=0)
static const ecvGui::ParamStruct & GetDisplayParameters()
Returns current parameters for this display (const version)
static void SetGLViewport(const QRect &rect)
Sets the OpenGL viewport.
void onItemPickedFast(ccHObject *pickedEntity, int pickedItemIndex, int x, int y)
Reacts to the itemPickedFast signal.
static ccGLMatrixd & GetProjectionMatrix()
static QPointF ToCenteredGLCoordinates(int x, int y)
static PICKING_MODE GetPickingMode()
void zNearCoefChanged(float coef)
Signal emitted when the zNear coef changes.
static void SetBubbleViewFov(float fov_deg)
Set bubble-view f.o.v. (in degrees)
std::vector< removeInfo > m_removeInfos
static double GetGLDepth(int x, int y)
static void SetDisplayParameters(const ecvGui::ParamStruct &params)
Sets current parameters for this display.
static void RemoveEntities(const ccHObject *obj)
static void DrawOrientedBBox(const CC_DRAW_CONTEXT &context, const ecvOrientedBBox *obb)
static void StartPicking(PickingParameters &params)
Starts picking process.
virtual QString pick3DItem(int x=-1, int y=-1)
virtual double getCameraFovy(int viewport=0)
bool m_overridenDisplayParametersEnabled
Whether display parameters are overidden for this window.
virtual QString pick2DLabel(int x, int y)
void entitiesSelectionChanged(std::unordered_set< int > entIDs)
Signal emitted when multiple entities are selected in the 3D view.
virtual void resetCamera()
static void LockRotationAxis(bool state, const CCVector3d &axis)
Lock the rotation axis.
static void SetOrthoProjection(int viewport=0)
static void SetMainWindow(QMainWindow *win)
virtual void getCameraFocal(double *focal, int viewport=0)
static bool GetClick3DPos(int x, int y, CCVector3d &P3D)
Returns the approximate 3D position of the clicked pixel.
virtual void setCameraFocalDistance(double focal_distance, int viewport=0)
virtual void createViewPort(double xmin, double ymin, double xmax, double ymax, int &viewport)
virtual void saveScreenshot(const std::string &file)
static void ShowOrientationMarker()
static void SetCenterAxesVisible(bool visible, int viewport=0)
Enable/disable center axes visualization.
double m_bbHalfDiag
Half size of the displayed objects bounding-box.
void cancelScheduledRedraw()
Cancels any scheduled redraw.
virtual void toggleOrientationMarker(bool state=true)
static void DrawClickableItems(int xStart, int &yStart)
static ccHObject * GetPickedEntity(const PickingParameters &params)
static void SetParallelScale(double scale, int viewport=0)
void leftButtonClicked(int x, int y)
Signal emitted when the left mouse button is cliked on the window.
void entitySelectionChanged(ccHObject *entity)
Signal emitted when an entity is selected in the 3D view.
static QFont GetTextDisplayFont()
void onWheelEvent(float wheelDelta_deg)
static void SetViewMatrix(const ccGLMatrixd &viewMat, int viewport=0)
void perspectiveStateChanged()
static void SetRemoveAllFlag(bool state)
INTERACTION_FLAGS m_interactionFlags
Current intercation flags.
QFont m_font
Default font.
static bool HideShowEntities(const ccHObject *obj, bool visible)
static void UpdateScreenSize()
static void ResetCameraViewpoint(const std::string &viewID)
qreal m_touchBaseDist
Touch gesture initial distance.
virtual void rotateWithAxis(const CCVector2i &pos, const CCVector3d &axis, double angle, int viewport=0)
static void InvalidateViewport()
PICKING_MODE
Picking mode.
@ POINT_OR_TRIANGLE_OR_LABEL_PICKING
static const ecvViewportParameters & GetViewportParameters()
bool m_touchInProgress
Touch event in progress.
static bool ViewerPerspectiveEnabled()
Shortcut: returns whether viewer-based perspective mode is enabled.
virtual void displayText(const CC_DRAW_CONTEXT &CONTEXT)
static void ToggleOrientationMarker(bool state=true)
std::vector< ClickableItem > m_clickableItems
Currently displayed clickable items.
static CCVector3d ToVtkCoordinates(int x, int y, int z=0)
static bool HideShowEntities(const CC_DRAW_CONTEXT &CONTEXT)
static int GetPickingRadius()
Returns the current picking radius.
ecvViewportParameters m_preBubbleViewParameters
Pre-bubble-view camera parameters (backup)
CaptureModeOptions m_captureMode
Display capturing mode options.
static void GetContext(CC_DRAW_CONTEXT &CONTEXT)
Returns context information.
CCVector3d m_lockedRotationAxis
Locked rotation axis.
ecvGui::ParamStruct m_overridenDisplayParameters
Overridden display parameter.
virtual bool getPerspectiveState(int viewport=0) const override
static void RotateBaseViewMat(const ccGLMatrixd &rotMat)
Rotates the base view matrix.
MessageType
Message type.
virtual void setViewAxesGridProperties(bool visible, const CCVector3 &color, double lineWidth, double spacing, int subdivisions, bool showLabels, double opacity, int viewport=0)
static void SetZNearCoef(double coef)
Sets current camera 'zNear' coefficient.
std::list< ccInteractor * > m_activeItems
Currently active items.
virtual void setOrthoProjection(int viewport=0)
void viewMatRotated(const ccGLMatrixd &rotMat)
static void SetFocusToScreen()
Draws the main 3D layer.
static bool USE_2D
static void UpdateCamera()
static void SetDataAxesGridProperties(const QString &viewID, const AxesGridProperties &props, int viewport=0)
Set Data Axes Grid properties (Unified Interface) Each ccHObject has its own Data Axes Grid bound to ...
static int Height()
static void SetGLViewport(int x, int y, int w, int h)
Sets the OpenGL viewport (shortut)
static double GetCameraFovy(int viewport=0)
static bool BubbleViewModeEnabled()
Returns whether bubble-view mode is enabled or no.
static ccHObject * GetSceneDB()
static void ResetCamera(const ccBBox *bbox)
HotZone * m_hotZone
Hot zone.
static QMainWindow * GetMainWindow()
static void RemoveEntities(const QStringList &viewIDs, ENTITY_TYPE removeEntityType)
static void Pick2DLabel(int x, int y)
static void DrawForeground(CC_DRAW_CONTEXT &CONTEXT)
void rotation(const ccGLMatrixd &rotMat)
Signal emitted when the selected object is rotated by the user.
QTimer m_scheduleTimer
Scheduler timer.
static void DrawBBox(const CC_DRAW_CONTEXT &context, const ccBBox *bbox)
static void RemoveAllWidgets(bool update=true)
static void SetCameraPosition(double pos_x, double pos_y, double pos_z, double view_x, double view_y, double view_z, double up_x, double up_y, double up_z, int viewport=0)
virtual void drawWidgets(const WIDGETS_PARAMETER &param)
QMainWindow * m_win
void mouseWheelChanged(QWheelEvent *event)
static void GetCameraFocal(double *focal, int viewport=0)
ccHObject * m_winDBRoot
Window own DB.
virtual QString pickObject(double x=-1, double y=-1)
virtual void resetCameraClippingRange(int viewport=0)
MessagePosition
Default message positions on screen.
static void ResetCenterOfRotation(int viewport=0)
static int GlWidth()
Returns the OpenGL context width.
void mousePosChanged(const QPoint &pos)
static QString PickObject(double x=-1, double y=-1)
static void SetLightIntensity(double intensity)
virtual double getGLDepth(int x, int y)
static void SetCameraPos(const CCVector3d &P)
Sets camera position.
void mouseMoved(int x, int y, Qt::MouseButtons buttons)
Signal emitted when the mouse is moved.
static CCVector3d ConvertMousePositionToOrientation(int x, int y)
Converts a given (mouse) position in pixels to an orientation.
static void ToBeRefreshed()
PivotVisibility
Pivot symbol visibility.
virtual ecvGenericVisualizer3D * getVisualizer3D()
void mouseWheelRotated(float wheelDelta_deg)
Signal emitted when the mouse wheel is rotated.
static QRect GetScreenRect()
static void UpdateZoom(float zoomFactor)
Updates current zoom.
static void SetCenterOfRotation(const double xyz[3])
static void SetCameraFovy(double fovy, int viewport=0)
static void ResizeGL(int w, int h)
Sets current zoom.
bool m_allowRectangularEntityPicking
Whether rectangular picking is allowed or not.
int m_uniqueID
Unique ID.
static int Width()
virtual void getViewMatrix(double *viewArray, int viewport=0)
static void SetLookUpTableID(const std::string &viewID)
Set the ID of a cloud or shape to be used for LUT display.
static double GetCameraFocalDistance(int viewport=0)
void baseViewMatChanged(const ccGLMatrixd &newViewMat)
Signal emitted when the window 'base view' matrix is changed.
virtual void setViewMatrix(const ccGLMatrixd &viewMat, int viewport=0)
double m_cameraToBBCenterDist
Distance between the camera and the displayed objects bounding-box.
virtual void setCenterAxesVisible(bool visible, int viewport=0)
static void Deprecate3DLayer()
static void ToVtkCoordinates(CCVector3d &sP)
static int GetFontPointSize()
Returns current font size.
static void EnableDebugTrace(bool state)
Shows debug info on screen.
virtual void setDataAxesGridProperties(const QString &viewID, const AxesGridProperties &props, int viewport=0)
Set Data Axes Grid properties (Virtual interface for derived classes)
static void ChangeOpacity(double opacity, const std::string &viewID, int viewport=0)
static void DisplayOverlayEntities(bool state)
bool m_validModelviewMatrix
Whether the model veiw matrix is valid (or need to be recomputed)
static void ZoomCamera(double zoomFactor, int viewport=0)
static void SetFontPointSize(int pixelSize)
Sets current font size.
CCVector3d m_autoPivotCandidate
Candidate pivot point (will be used when the mouse is released)
QRect m_glViewport
viewport
ecvViewportParameters m_viewportParams
Viewport parameters (zoom, etc.)
virtual void drawBBox(const CC_DRAW_CONTEXT &context, const ccBBox *bbox)
void fovChanged(float fov)
Signal emitted when the f.o.v. changes.
static void ResetCameraClippingRange(int viewport=0)
static void ToggleCameraOrientationWidget(bool show)
virtual void getDataAxesGridProperties(const QString &viewID, AxesGridProperties &props, int viewport=0) const
Get Data Axes Grid properties (Virtual interface for derived classes)
static ecvDisplayTools * TheInstance()
static bool IsRectangularPickingAllowed()
Returns whether rectangular picking is allowed or not.
virtual void toggleExclusiveFullScreen(bool state)
void itemPicked(ccHObject *entity, unsigned subEntityID, int x, int y, const CCVector3 &P)
Signal emitted when a point (or a triangle) is picked.
void pointPicked(double x, double y, double z)
virtual QImage renderToImage(int zoomFactor=1, bool renderOverlayItems=false, bool silent=false, int viewport=0)
cloudViewer::geometry::LineSet * m_scale_lineset
void onPointPicking(const CCVector3 &p, int index, const std::string &id)
static bool OrientationMarkerShown()
static void SetupProjectiveViewport(const ccGLMatrixd &cameraMatrix, float fov_deg=0.0f, float ar=1.0f, bool viewerBasedPerspective=true, bool bubbleViewMode=false)
static void SetViewportParameters(const ecvViewportParameters &params)
static int GlHeight()
Returns the OpenGL context height.
bool m_sunLightEnabled
Whether sun light is enabled or not.
static void SetView(CC_VIEW_ORIENTATION orientation, ccBBox *bbox)
static void TransformCameraView(const ccGLMatrixd &viewMat)
virtual void setViewAxesGridVisible(bool visible, int viewport=0)
static void UpdateProjectionMatrix()
static void LockPickingMode(bool state)
Locks picking mode.
static void CheckIfRemove()
bool m_exclusiveFullscreen
Wether exclusive full screen is enabled or not.
virtual bool isCameraOrientationWidgetShown() const
static void SetBubbleViewMode(bool state)
Sets bubble-view mode state.
static void SetRedrawRecursive(ccHObject *obj, bool redraw=false)
virtual void removeEntities(const CC_DRAW_CONTEXT &CONTEXT)
virtual void changeEntityProperties(PROPERTY_PARAM &propertyParam)
bool m_pickingModeLocked
Whether picking mode is locked or not.
static QSize GetScreenSize()
virtual void setPivotVisibility(bool state)
virtual void setRenderWindowSize(int xw, int yw)
static PivotVisibility GetPivotVisibility()
Returns pivot visibility.
static void SetZoom(float value)
Sets current zoom.
static void Redraw2DLabel()
virtual void setBackgroundColor(const CC_DRAW_CONTEXT &CONTEXT)
virtual bool hideShowEntities(const CC_DRAW_CONTEXT &CONTEXT)
void scheduleFullRedraw(unsigned maxDelay_ms)
Schedules a full redraw.
virtual double getLightIntensity() const
static void SetCameraClip(double znear, double zfar, int viewport=0)
static void SetCameraPosition(const CCVector3d &pos, int viewport=0)
virtual void setAutoUpateCameraPos(bool state)
QStringList m_diagStrings
bool m_shouldBeRefreshed
Whether the display should be refreshed on next call to 'refresh'.
static void SetBaseViewMat(ccGLMatrixd &mat)
INTERACTION_FLAG
Interaction flags (mostly with the mouse)
static void SetInteractionMode(INTERACTION_FLAGS flags)
virtual void resetCamera(const ccBBox *bbox)
virtual void showOrientationMarker()
static double ComputeActualPixelSize()
bool m_mouseMoved
Whether the mouse (cursor) has moved after being pressed or not.
static void TransformCameraProjection(const ccGLMatrixd &projMat)
virtual void setCameraClip(double znear, double zfar, int viewport=0)
virtual void updateScene()
static void RotateWithAxis(const CCVector2i &pos, const CCVector3d &axis, double angle, int viewport=0)
static void ProcessPickingResult(const PickingParameters &params, ccHObject *pickedEntity, int pickedItemIndex, const CCVector3 *nearestPoint=nullptr, const std::unordered_set< int > *selectedIDs=nullptr)
Processes the picking process result and sends the corresponding signal.
void checkScheduledRedraw()
Checks for scheduled redraw.
static void DrawWidgets(const WIDGETS_PARAMETER &param, bool update=false)
qint64 m_scheduledFullRedrawTime
Scheduled full redraw (no LOD)
static void SetRectangularPickingAllowed(bool state)
Sets whether rectangular picking is allowed or not.
static void GetCameraClip(double *clipPlanes, int viewport=0)
static void MoveCamera(float dx, float dy, float dz)
Displaces camera.
virtual void getCameraUp(double *up, int viewport=0)
static bool GetPerspectiveState(int viewport=0)
virtual double getCameraFocalDistance(int viewport=0)
static int GetLabelFontPointSize()
Returns current font size for labels.
ccPolyline * m_rectPickingPoly
Rectangular picking polyline.
static ccGLMatrixd GenerateViewMat(CC_VIEW_ORIENTATION orientation)
static void RenderText(double x, double y, double z, const QString &str, const QFont &font=QFont(), const ecvColor::Rgbub &color=ecvColor::defaultLabelBkgColor, const QString &id="")
static void UpdateActiveItemsList(int x, int y, bool extendToSelectedLabels=false)
Updates currently active items list (m_activeItems)
static QWidget * GetCurrentScreen()
static void SetView(CC_VIEW_ORIENTATION orientation, bool forceRedraw=false)
virtual void getCameraPos(double *pos, int viewport=0)
static void SetRedrawRecursive(bool redraw=false)
static void FilterByEntityType(ccHObject::Container &labels, CV_CLASS_ENUM type)
virtual void setCameraFovy(double fovy, int viewport=0)
std::list< MessageToDisplay > m_messagesToDisplay
List of messages to display.
virtual void setPerspectiveProjection(int viewport=0)
static bool ProcessClickableItems(int x, int y)
Processes the clickable items.
static ccGLMatrixd & GetBaseViewMat()
static bool USE_VTK_PICK
static bool OverlayEntitiesAreDisplayed()
static void ToggleDebugTrace()
Toggles debug info on screen.
virtual void setScaleBarVisible(bool visible)
static ccHObject * GetOwnDB()
Returns window own DB.
static void SetCameraPosition(const double *pos, const double *up, int viewport=0)
bool m_bubbleViewModeEnabled
Bubble-view mode state.
static void SetAutoUpateCameraPos(bool state)
static void DrawCoordinates(double scale=1.0, const std::string &id="reference", int viewport=0)
static void UpdateMeshTextures(const CC_DRAW_CONTEXT &context, const ccGenericMesh *mesh)
static void drawCross()
virtual void fullScreen(bool state)
static CCVector3d GetRealCameraCenter()
virtual ~ecvDisplayTools() override
Destructor.
QElapsedTimer m_timer
Internal timer.
void translation(const CCVector3d &t)
Signal emitted when the selected object is translated by the user.
static void SetPickingRadius(int radius)
Sets picking radius.
static QSize GlSize()
Returns the OpenGL context size.
static void SetViewAxesGridProperties(bool visible, const CCVector3 &color, double lineWidth, double spacing, int subdivisions, bool showLabels, double opacity, int viewport=0)
Configure view axes grid properties.
void exclusiveFullScreenToggled(bool exclusive)
Signal emitted when the exclusive fullscreen is toggled.
static QWidget * GetMainScreen()
virtual void setCenterOfRotation(double x, double y, double z)
virtual void updateMeshTextures(const CC_DRAW_CONTEXT &context, const ccGenericMesh *mesh)
static float GetFov()
Returns the current f.o.v. (field of view) in degrees.
void itemPickedFast(ccHObject *entity, int subEntityID, int x, int y)
Signal emitted when an item is picked (FAST_PICKING mode only)
static void SetPerspectiveState(bool state, bool objectCenteredView)
Set perspective state/mode.
void filesDropped(const QStringList &filenames, bool displayDialog)
Signal emitted when files are dropped on the window.
QWidget * m_mainScreen
virtual void setCameraPosition(const double *pos, const double *focal, const double *up, int viewport=0)
static void RemoveBB(CC_DRAW_CONTEXT context)
virtual void registerVisualizer(QMainWindow *win, bool stereoMode=false)=0
register visualizer callback function
static void SetMainScreen(QWidget *widget)
virtual void resetCenterOfRotation(int viewport=0)
CCVector3 m_last_picked_point
virtual void getCameraClip(double *clipPlanes, int viewport=0)
void pixelSizeChanged(float pixelSize)
Signal emitted when the pixel size is changed.
static void DrawBackground(CC_DRAW_CONTEXT &CONTEXT)
static void SaveCameraParameters(const std::string &file)
Save or Load the current rendered camera parameters to disk or current camera.
static void GetCameraPos(double *pos, int viewport=0)
virtual double getParallelScale(int viewport=0)
void cameraDisplaced(float ddx, float ddy)
Signal emitted when the camera is interactively displaced.
PivotVisibility m_pivotVisibility
Pivot symbol visibility.
bool m_pivotSymbolShown
Whether pivot symbol should be shown or not.
void labelmove2D(int x, int y, int dx, int dy)
static void SetCenterOfRotation(double x, double y, double z)
static void GetCenterOfRotation(double center[3])
virtual void setParallelScale(double scale, int viewport=0)
static ecvGenericVisualizer3D * GetVisualizer3D()
static void Remove3DLabel(const QString &view_id)
static ENTITY_TYPE ConvertToEntityType(const CV_CLASS_ENUM &type)
virtual void setUseVbos(bool useVbos)
static void SetFov(float fov)
Sets current camera f.o.v. (field of view) in degrees.
ccGLMatrixd m_projMatd
Projection matrix (GL style - double version)
static void SetViewAxesGridVisible(bool visible, int viewport=0)
Enable/disable view axes grid (aligned with camera/view)
static void SetScaleBarVisible(bool visible)
int m_pickRadius
Picking radius (pixels)
virtual void changeOpacity(double opacity, const std::string &viewID, int viewport=0)
void autoPickPivot(bool state)
virtual void drawOrientedBBox(const CC_DRAW_CONTEXT &context, const ecvOrientedBBox *obb)
bool m_mouseButtonPressed
Whether the mouse is currently pressed or not.
static void SaveScreenshot(const std::string &file)
Save the current rendered image to disk, as a PNG screenshot.
static void SetAspectRatio(float ar)
Sets current camera aspect ratio (width/height)
virtual void draw(const CC_DRAW_CONTEXT &context, const ccHObject *obj)
static void SetPickingMode(PICKING_MODE mode=DEFAULT_PICKING)
void fastPickingFinished()
Signal emitted when fast picking is finished (FAST_PICKING mode only)
static void UpdateScene()
static void UpdateScreen()
static void Update2DLabel(bool immediateUpdate=false)
static void DisplayText(const QString &text, int x, int y, unsigned char align=ALIGN_DEFAULT, float bkgAlpha=0.0f, const unsigned char *rgbColor=nullptr, const QFont *font=nullptr, const QString &id="")
Displays a string at a given 2D position.
void buttonReleased()
Signal emitted when a mouse button is released (cursor on the window)
static bool GetClickableItemsVisible()
static void DisplayText(const CC_DRAW_CONTEXT &CONTEXT)
static void SetLineWithRecursive(PointCoordinateType with)
static void SetPivotPoint(const CCVector3d &P, bool autoUpdateCameraPos=false, bool verbose=false)
Sets pivot point.
static void SetPivotVisibility(bool state)
static void SetScreenSize(int xw, int yw)
static void SetPointSize(float size, bool silent=false, int viewport=0)
static QImage RenderToImage(int zoomFactor=1, bool renderOverlayItems=false, bool silent=false, int viewport=0)
static void DisplayTexture2DPosition(QImage image, const QString &id, int x, int y, int w, int h, unsigned char alpha=255)
static void DrawPivot()
virtual void resetCameraViewpoint(const std::string &viewID)
static void GetCenterOfRotation(CCVector3d &center)
static void SetPointSizeRecursive(int size)
static bool IsRotationAxisLocked()
Returns whether the rotation axis is locaked or not.
static void SetExclusiveFullScreenFlage(bool state)
virtual void zoomCamera(double zoomFactor, int viewport=0)
static double GetPlatformAwareDPIScale()
static void HideShowEntities(const QStringList &viewIDs, ENTITY_TYPE hideShowEntityType, bool visibility=false)
void pivotPointChanged(const CCVector3d &)
Signal emitted when the pivot point is changed.
static void ToggleExclusiveFullScreen(bool state)
Toggles (exclusive) full-screen mode.
virtual void getProjectionMatrix(double *projArray, int viewport=0)
QWidget * m_currentScreen
static void GetViewMatrix(double *viewArray, int viewport=0)
static void DoResize(int xw, int yw)
static void ToVtkCoordinates(CCVector2i &sP)
QPoint m_lastMousePos
Last mouse position.
bool m_alwaysUseFBO
Whether to always use FBO or only for GL filters.
static void DisplayNewMessage(const QString &message, MessagePosition pos, bool append=false, int displayMaxDelay_sec=2, MessageType type=CUSTOM_MESSAGE)
Displays a status message in the bottom-left corner.
static ccGLMatrixd & GetModelViewMatrix()
static void RefreshDisplay(bool only2D=false, bool forceRedraw=true)
virtual void setCameraPosition(const CCVector3d &pos, int viewport=0)
virtual bool orientationMarkerShown()
static void DoResize(const QSize &size)
static void SetCameraFocalDistance(double focal_distance, int viewport=0)
static void SetUseVbos(bool useVbos)
Use Vertex Buffer Objects renderers. This is an optimization for the obsolete OpenGL backend....
static QString Pick3DItem(int x=-1, int y=-1)
void rightButtonClicked(int x, int y)
Signal emitted when the right mouse button is cliked on the window.
static void SetClickableItemsVisible(bool state)
static QFont GetLabelDisplayFont()
static void RemoveEntities(const CC_DRAW_CONTEXT &CONTEXT)
static QSize size()
static void FullScreen(bool state)
static void MoveCamera(const CCVector3d &v)
Displaces camera.
static void ShowCursorCoordinates(bool state)
static void ReleaseInstance()
static void drawTrihedron()
static ecvGenericVisualizer2D * GetVisualizer2D()
static void SetPixelSize(float pixelSize)
Sets pixel size (i.e. zoom base)
virtual void getCenterOfRotation(double center[3])
virtual void updateCamera()
qint64 m_lastClickTime_ticks
Last click time (msec)
static bool AutoPickPivotAtCenter()
Whether the pivot point is automatically set at the center of the screen.
static bool IsCameraOrientationWidgetShown()
Check if Camera Orientation Widget is shown.
static void InvalidateVisualization()
static void UpdateConstellationCenterAndZoom(const ccBBox *aBox=nullptr, bool redraw=true)
Center and zoom on a given bounding box.
PICKING_MODE m_pickingMode
static void SetLineWidth(float width, bool silent=false, int viewport=0)
Sets line width.
static void SetCenterOfRotation(const CCVector3d &center)
virtual void saveCameraParameters(const std::string &file)
static void RedrawDisplay(bool only2D=false, bool forceRedraw=true)
static void ResetCamera()
virtual void setCameraPosition(const double *pos, const double *up, int viewport=0)
static void LoadCameraParameters(const std::string &file)
static bool IsPickingModeLocked()
Returns whether picking mode is locked or not.
static void ZoomGlobal()
virtual void toggleCameraOrientationWidget(bool show)
static void GetVisibleObjectsBB(ccBBox &box)
Returns the visible objects bounding-box.
static void SetPivotVisibility(PivotVisibility vis)
Sets pivot visibility.
static void GetProjectionMatrix(double *projArray, int viewport=0)
static void RemoveWidgets(const WIDGETS_PARAMETER &param, bool update=false)
bool m_clickableItemsVisible
Whether clickable items are visible (= mouse over) or not.
static void SendAutoPickPivotAtCenter(bool state)
virtual void setLightIntensity(double intensity)
bool m_showDebugTraces
Debug traces visibility.
Generic display tools.
Generic visualizer 2D interface.
Generic visualizer 3D interface.
Generic visualizer interface.
Standard parameters for GL displays/viewports.
int min(int a, int b)
Definition: cutil_math.h:53
int max(int a, int b)
Definition: cutil_math.h:48
Q_DECLARE_OPERATORS_FOR_FLAGS(ecvDisplayTools::INTERACTION_FLAGS)
ENTITY_TYPE
ImGuiContext * context
Definition: Window.cpp:76
Generic file read and write utility for python interface.
float DegreesToRadians(int degrees)
Convert degrees to radians.
Definition: CVMath.h:98
constexpr Rgbub defaultLabelBkgColor(MAX, MAX, MAX)
void UpdateCamera(int ncam, const avec< Float > &camera, const avec< Float > &delta, avec< Float > &new_camera)
Data Axes Grid properties structure Encapsulates all properties for vtkCubeAxesActor configuration.
QList< QPair< double, QString > > xCustomLabels
QList< QPair< double, QString > > yCustomLabels
QList< QPair< double, QString > > zCustomLabels
AxesGridProperties()=default
OpenGL camera parameters.
Display context.
Display capturing mode options.
CaptureModeOptions()
Default constructor.
ClickableItem(Role _role, QRect _area)
Precomputed stuff for the 'hot zone'.
QRect rect(bool clickableItemsVisible, bool bubbleViewModeEnabled, bool fullScreenEnabled) const
Temporary Message to display in the lower-left corner.
MessagePosition position
Message position on screen.
qint64 messageValidity_sec
Message end time (sec)
MessageType type
Message type.
PickingParameters(PICKING_MODE _mode=NO_PICKING, int _centerX=0, int _centerY=0, int _pickWidth=5, int _pickHeight=5, bool _pickInSceneDB=true, bool _pickInLocalDB=true)
Default constructor.
Optional output metrics (from computeProjectionMatrix)
GUI parameters.
Definition: lsd.c:1170