ccTracePolylineTool.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #pragma once
  2. //##########################################################################
  3. //# #
  4. //# CLOUDCOMPARE #
  5. //# #
  6. //# This program is free software; you can redistribute it and/or modify #
  7. //# it under the terms of the GNU General Public License as published by #
  8. //# the Free Software Foundation; version 2 or later of the License. #
  9. //# #
  10. //# This program is distributed in the hope that it will be useful, #
  11. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  12. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  13. //# GNU General Public License for more details. #
  14. //# #
  15. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  16. //# #
  17. //##########################################################################
  18. //Local
  19. #include "ccOverlayDialog.h"
  20. #include "ccPickingListener.h"
  21. //qCC_db
  22. #include <ccGenericGLDisplay.h>
  23. //system
  24. #include <vector>
  25. class ccPolyline;
  26. class ccPointCloud;
  27. class ccGLWindowInterface;
  28. class ccPickingHub;
  29. namespace Ui
  30. {
  31. class TracePolyLineDlg;
  32. }
  33. //! Graphical Polyline Tracing tool
  34. class ccTracePolylineTool : public ccOverlayDialog, public ccPickingListener
  35. {
  36. Q_OBJECT
  37. public:
  38. //! Default constructor
  39. explicit ccTracePolylineTool(ccPickingHub* pickingHub, QWidget* parent);
  40. //! Destructor
  41. virtual ~ccTracePolylineTool();
  42. //inherited from ccOverlayDialog
  43. virtual bool linkWith(ccGLWindowInterface* win) override;
  44. virtual bool start() override;
  45. virtual void stop(bool accepted) override;
  46. protected:
  47. void apply();
  48. void cancel();
  49. void exportLine();
  50. inline void continueEdition() { restart(false); }
  51. inline void resetLine() { restart(true); }
  52. void closePolyLine(int x = 0, int y = 0); //arguments for compatibility with ccGlWindow::rightButtonClicked signal
  53. void updatePolyLineTip(int x, int y, Qt::MouseButtons buttons);
  54. void onWidthSizeChanged(int);
  55. //! To capture overridden shortcuts (pause button, etc.)
  56. void onShortcutTriggered(int);
  57. //! Inherited from ccPickingListener
  58. virtual void onItemPicked(const PickedItem& pi) override;
  59. protected:
  60. //! Restarts the edition mode
  61. void restart(bool reset);
  62. //! Viewport parameters (used for picking)
  63. struct SegmentGLParams
  64. {
  65. SegmentGLParams() {}
  66. SegmentGLParams(ccGenericGLDisplay* display, int x, int y);
  67. ccGLCameraParameters params;
  68. CCVector2d clickPos;
  69. };
  70. //! Oversamples the active 3D polyline
  71. ccPolyline* polylineOverSampling(unsigned steps) const;
  72. //! 2D polyline (for the currently edited part)
  73. ccPolyline* m_polyTip;
  74. //! 2D polyline vertices
  75. ccPointCloud* m_polyTipVertices;
  76. //! 3D polyline
  77. ccPolyline* m_poly3D;
  78. //! 3D polyline vertices
  79. ccPointCloud* m_poly3DVertices;
  80. //! Viewport parameters use to draw each segment of the polyline
  81. std::vector<SegmentGLParams> m_segmentParams;
  82. //! Current process state
  83. bool m_done;
  84. //! Picking hub
  85. ccPickingHub* m_pickingHub;
  86. Ui::TracePolyLineDlg* m_ui;
  87. };