ccColorScaleEditorDlg.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. #include "CCPluginAPI.h"
  19. //qCC_db
  20. #include <ccColorScale.h>
  21. //Qt
  22. #include <QDialog>
  23. class ccScalarField;
  24. class ccColorScaleEditorWidget;
  25. class ccColorScalesManager;
  26. class ccMainAppInterface;
  27. namespace Ui
  28. {
  29. class ColorScaleEditorDlg;
  30. }
  31. //! Dialog to edit/create color scales
  32. class CCPLUGIN_LIB_API ccColorScaleEditorDialog : public QDialog
  33. {
  34. Q_OBJECT
  35. public:
  36. //! Default constructor
  37. ccColorScaleEditorDialog( ccColorScalesManager* manager,
  38. ccMainAppInterface* mainApp,
  39. ccColorScale::Shared currentScale = ccColorScale::Shared(nullptr),
  40. QWidget* parent = nullptr);
  41. //! Destructor
  42. ~ccColorScaleEditorDialog() override;
  43. //! Sets associated scalar field (optional)
  44. void setAssociatedScalarField(ccScalarField* sf);
  45. //! Sets active scale
  46. void setActiveScale(ccColorScale::Shared currentScale);
  47. //! Returns active scale
  48. ccColorScale::Shared getActiveScale() { return m_colorScale; }
  49. protected:
  50. void colorScaleChanged(int);
  51. void relativeModeChanged(int);
  52. void onStepSelected(int);
  53. void onStepModified(int);
  54. void deletecSelectedStep();
  55. void changeSelectedStepColor();
  56. void changeSelectedStepValue(double);
  57. void onCustomLabelsListChanged();
  58. void toggleCustomLabelsList(bool);
  59. void copyCurrentScale();
  60. bool saveCurrentScale();
  61. void deleteCurrentScale();
  62. void renameCurrentScale();
  63. void exportCurrentScale();
  64. void importScale();
  65. void createNewScale();
  66. void onApply();
  67. void onClose();
  68. protected:
  69. //! Updates main combox box with color scales manager
  70. void updateMainComboBox();
  71. //! Sets modification flag state
  72. void setModified(bool state);
  73. //! If the current scale has been modified, ask the user what to do
  74. /** \return whether user allows the change or not
  75. **/
  76. bool canChangeCurrentScale();
  77. //! Returns whether current edited scale is 'relative' (true) or 'absolute' (false)
  78. /** Warning: may not be the same state as the current scale (m_colorScale)
  79. If current modifications have not been saved yet!
  80. **/
  81. bool isRelativeMode() const;
  82. //! Sets current mode for active scale between 'relative' (true) or 'absolute' (false)
  83. /** Warning: may not be the same state as the current scale (m_colorScale)
  84. If current modifications have not been saved yet!
  85. **/
  86. void setScaleModeToRelative(bool isRelative);
  87. //! Checks the custom labels list
  88. bool checkCustomLabelsList(bool showWarnings);
  89. //! Exports the custom labels list
  90. /** \return Error description (if any)
  91. **/
  92. QString exportCustomLabelsList(ccColorScale::LabelSet& labels) const;
  93. //! Color scale manager
  94. ccColorScalesManager* m_manager;
  95. //! Current active color scale
  96. ccColorScale::Shared m_colorScale;
  97. //! Color scale editor widget
  98. ccColorScaleEditorWidget* m_scaleWidget;
  99. //! Associated scalar field
  100. ccScalarField* m_associatedSF;
  101. //! Modification flag
  102. bool m_modified;
  103. //! Current min boundary for absolute scales
  104. double m_minAbsoluteVal;
  105. //! Current max boundary for absolute scales
  106. double m_maxAbsoluteVal;
  107. //! Associated application (interface)
  108. ccMainAppInterface* m_mainApp;
  109. Ui::ColorScaleEditorDlg* m_ui;
  110. };