ccPropertiesTreeDelegate.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. //##########################################################################
  2. //# #
  3. //# CLOUDCOMPARE #
  4. //# #
  5. //# This program is free software; you can redistribute it and/or modify #
  6. //# it under the terms of the GNU General Public License as published by #
  7. //# the Free Software Foundation; version 2 or later of the License. #
  8. //# #
  9. //# This program is distributed in the hope that it will be useful, #
  10. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  11. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  12. //# GNU General Public License for more details. #
  13. //# #
  14. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  15. //# #
  16. //##########################################################################
  17. #ifndef CC_ITEM_DELEGATE_HEADER
  18. #define CC_ITEM_DELEGATE_HEADER
  19. //qCC_db
  20. #include <ccArray.h>
  21. #include <ccPointCloud.h>
  22. //Qt
  23. #include <QStyledItemDelegate>
  24. class cc2DLabel;
  25. class cc2DViewportObject;
  26. class ccCameraSensor;
  27. class ccFacet;
  28. class ccGBLSensor;
  29. class ccGenericMesh;
  30. class ccGenericPointCloud;
  31. class ccGenericPrimitive;
  32. class ccHObject;
  33. class ccImage;
  34. class ccIndexedTransformationBuffer;
  35. class ccKdTree;
  36. class ccMaterialSet;
  37. class ccOctree;
  38. class ccPlanarEntityInterface;
  39. class ccPolyline;
  40. class ccSensor;
  41. class CCShareable;
  42. class ccShiftedObject;
  43. class ccCoordinateSystem;
  44. class QAbstractItemView;
  45. class QStandardItem;
  46. class QStandardItemModel;
  47. //! GUI properties list dialog element
  48. class ccPropertiesTreeDelegate : public QStyledItemDelegate
  49. {
  50. Q_OBJECT
  51. public:
  52. //! Delegate items roles
  53. enum CC_PROPERTY_ROLE { OBJECT_NO_PROPERTY = 0 ,
  54. OBJECT_NAME ,
  55. OBJECT_VISIBILITY ,
  56. OBJECT_CURRENT_DISPLAY ,
  57. OBJECT_NORMALS_SHOWN ,
  58. OBJECT_COLOR_SOURCE ,
  59. OBJECT_POLYLINE_WIDTH ,
  60. OBJECT_SENSOR_DRAW_FRUSTUM ,
  61. OBJECT_SENSOR_DRAW_FRUSTUM_PLANES ,
  62. OBJECT_SF_SHOW_SCALE ,
  63. OBJECT_OCTREE_LEVEL ,
  64. OBJECT_OCTREE_TYPE ,
  65. OBJECT_MESH_WIRE ,
  66. OBJECT_MESH_STIPPLING ,
  67. OBJECT_CURRENT_SCALAR_FIELD ,
  68. OBJECT_CURRENT_COLOR_RAMP ,
  69. OBJECT_IMAGE_ALPHA ,
  70. OBJECT_APPLY_IMAGE_VIEWPORT ,
  71. OBJECT_APPLY_SENSOR_VIEWPORT ,
  72. OBJECT_CLOUD_SF_EDITOR ,
  73. OBJECT_SENSOR_MATRIX_EDITOR ,
  74. OBJECT_SENSOR_DISPLAY_SCALE ,
  75. OBJECT_SENSOR_UNCERTAINTY ,
  76. OBJECT_COLOR_RAMP_STEPS ,
  77. OBJECT_MATERIALS ,
  78. OBJECT_APPLY_LABEL_VIEWPORT ,
  79. OBJECT_UPDATE_LABEL_VIEWPORT ,
  80. OBJECT_LABEL_DISP_2D ,
  81. OBJECT_LABEL_POINT_LEGEND ,
  82. OBJECT_PRIMITIVE_PRECISION ,
  83. OBJECT_SPHERE_RADIUS ,
  84. OBJECT_CONE_HEIGHT ,
  85. OBJECT_CONE_BOTTOM_RADIUS ,
  86. OBJECT_CONE_TOP_RADIUS ,
  87. OBJECT_CLOUD_POINT_SIZE ,
  88. OBJECT_NAME_IN_3D ,
  89. OBJECT_FACET_CONTOUR ,
  90. OBJECT_FACET_MESH ,
  91. OBJECT_PLANE_NORMAL_VECTOR ,
  92. OBJECT_SENSOR_INDEX ,
  93. OBJECT_SHOW_TRANS_BUFFER_PATH ,
  94. OBJECT_SHOW_TRANS_BUFFER_TRIHDERONS ,
  95. OBJECT_TRANS_BUFFER_TRIHDERONS_SCALE ,
  96. OBJECT_HISTORY_MATRIX_EDITOR ,
  97. OBJECT_GLTRANS_MATRIX_EDITOR ,
  98. OBJECT_COORDINATE_SYSTEM_DISP_PLANES ,
  99. OBJECT_COORDINATE_SYSTEM_DISP_AXES ,
  100. OBJECT_COORDINATE_SYSTEM_AXES_WIDTH ,
  101. OBJECT_COORDINATE_SYSTEM_DISP_SCALE ,
  102. TREE_VIEW_HEADER ,
  103. OBJECT_CLOUD_NORMAL_COLOR ,
  104. OBJECT_CLOUD_NORMAL_LENGTH ,
  105. OBJECT_CLOUD_DRAW_NORMALS ,
  106. };
  107. //! Default constructor
  108. ccPropertiesTreeDelegate(QStandardItemModel* _model, QAbstractItemView* _view, QObject *parent = nullptr);
  109. //! Default destructor
  110. ~ccPropertiesTreeDelegate() override;
  111. //inherited from QStyledItemDelegate
  112. QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index ) const override;
  113. QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
  114. void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
  115. void setEditorData(QWidget *editor, const QModelIndex &index) const override;
  116. void unbind();
  117. //! Fill property view with QItems corresponding to object's type
  118. void fillModel(ccHObject* hObject);
  119. //! Returns currently bound object
  120. ccHObject* getCurrentObject();
  121. Q_SIGNALS:
  122. void ccObjectPropertiesChanged(ccHObject* hObject) const;
  123. void ccObjectAppearanceChanged(ccHObject* hObject) const;
  124. void ccObjectAndChildrenAppearanceChanged(ccHObject* hObject) const;
  125. private:
  126. static const char* s_noneString;
  127. static const char* s_rgbColor;
  128. static const char* s_sfColor;
  129. static const char* s_defaultPointSizeString;
  130. static const char* s_defaultPolyWidthSizeString;
  131. void updateItem(QStandardItem*);
  132. void scalarFieldChanged(int);
  133. void colorScaleChanged(int);
  134. void colorRampStepsChanged(int);
  135. void spawnColorRampEditor();
  136. void octreeDisplayModeChanged(int);
  137. void octreeDisplayedLevelChanged(int);
  138. void primitivePrecisionChanged(int);
  139. void sphereRadiusChanged(double);
  140. void coneHeightChanged(double);
  141. void coneBottomRadiusChanged(double);
  142. void coneTopRadiusChanged(double);
  143. void imageAlphaChanged(int);
  144. void applyImageViewport();
  145. void applySensorViewport();
  146. void applyLabelViewport();
  147. void updateLabelViewport();
  148. void updateDisplay();
  149. void objectDisplayChanged(const QString &);
  150. void colorSourceChanged(const QString &);
  151. void sensorScaleChanged(double);
  152. void coordinateSystemDisplayScaleChanged(double);
  153. void sensorUncertaintyChanged();
  154. void sensorIndexChanged(double);
  155. void cloudPointSizeChanged(int);
  156. void polyineWidthChanged(int);
  157. void coordinateSystemAxisWidthChanged(int);
  158. void trihedronsScaleChanged(double);
  159. void normalColorChanged(int colorIdx);
  160. void normalLengthChanged(double length);
  161. void addSeparator(const QString& title);
  162. void appendRow(QStandardItem* leftItem, QStandardItem* rightItem, bool openPersistentEditor = false);
  163. void appendWideRow(QStandardItem* item, bool openPersistentEditor = true);
  164. void fillWithHObject(ccHObject*);
  165. void fillWithPointCloud(ccGenericPointCloud*);
  166. void fillWithDrawNormals(ccGenericPointCloud*);
  167. void fillSFWithPointCloud(ccGenericPointCloud*);
  168. void fillWithMesh(const ccGenericMesh*);
  169. void fillWithFacet(const ccFacet*);
  170. void fillWithPlanarEntity(const ccPlanarEntityInterface*);
  171. void fillWithSensor(const ccSensor*);
  172. void fillWithTransBuffer(const ccIndexedTransformationBuffer*);
  173. void fillWithPolyline(const ccPolyline*);
  174. void fillWithPrimitive(const ccGenericPrimitive*);
  175. void fillWithPointOctree(const ccOctree*);
  176. void fillWithPointKdTree(const ccKdTree*);
  177. void fillWithImage(const ccImage*);
  178. void fillWithLabel(const cc2DLabel*);
  179. void fillWithViewportObject(const cc2DViewportObject*);
  180. void fillWithGBLSensor(const ccGBLSensor*);
  181. void fillWithCameraSensor(const ccCameraSensor*);
  182. void fillWithMaterialSet(const ccMaterialSet*);
  183. void fillWithShareable(const CCShareable*);
  184. void fillWithMetaData(const ccObject*);
  185. void fillWithShifted(const ccShiftedObject*);
  186. void fillWithCoordinateSystem(const ccCoordinateSystem*);
  187. template<class Type, int N, class ComponentType>
  188. void fillWithCCArray(const ccArray<Type, N, ComponentType>*);
  189. //! Returns whether the editor is wide (i.e. spans on two columns) or not
  190. bool isWideEditor(int itemData) const;
  191. //! Updates the current model (assuming object is the same)
  192. void updateModel();
  193. ccHObject* m_currentObject;
  194. QStandardItemModel* m_model;
  195. QAbstractItemView* m_view;
  196. CC_PROPERTY_ROLE m_lastFocusItemRole;
  197. };
  198. #endif