ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cvSelectionLabelPropertiesDialog.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 // clang-format off
11 // Qt - must be included first for MOC to work correctly on Windows
12 #include <QtCore/QObject>
13 #include <QtWidgets/QDialog>
14 #include <QtGui/QColor>
15 #include <QtGui/QFont>
16 // clang-format on
17 
18 #include "qPCL.h"
19 
20 // Include full definition for FontProperties struct
22 
23 class QSlider;
24 class QSpinBox;
25 class QDoubleSpinBox;
26 class QLineEdit;
27 class QPushButton;
28 class QToolButton;
29 class QCheckBox;
30 
43  Q_OBJECT
44 
45 public:
49  struct LabelProperties {
50  // General
51  double opacity = 1.0;
52  int pointSize = 5;
53  int lineWidth = 2;
54 
55  // Cell Label Font
56  QString cellLabelFontFamily = "Arial";
57  int cellLabelFontSize = 18;
58  QColor cellLabelColor = QColor(0, 255, 0); // Green
59  bool cellLabelBold = false;
60  bool cellLabelItalic = false;
61  bool cellLabelShadow = false;
62  double cellLabelOpacity = 1.0;
63  QString cellLabelHorizontalJustification =
64  "Left"; // "Left", "Center", "Right"
65  QString cellLabelVerticalJustification =
66  "Bottom"; // "Top", "Center", "Bottom"
67  QString cellLabelFormat; // e.g., "%s" for ID
68 
69  // Point Label Font
70  QString pointLabelFontFamily = "Arial";
71  int pointLabelFontSize = 18;
72  QColor pointLabelColor = QColor(255, 255, 0); // Yellow
73  bool pointLabelBold = false;
74  bool pointLabelItalic = false;
75  bool pointLabelShadow = false;
76  double pointLabelOpacity = 1.0;
77  QString pointLabelHorizontalJustification =
78  "Left"; // "Left", "Center", "Right"
79  QString pointLabelVerticalJustification =
80  "Bottom"; // "Top", "Center", "Bottom"
81  QString pointLabelFormat; // e.g., "%s" for ID
82 
83  // Tooltip Settings
84  bool showTooltips = true;
85  int maxTooltipAttributes = 15;
86  };
87 
88  explicit cvSelectionLabelPropertiesDialog(QWidget* parent = nullptr,
89  bool isInteractive = false);
91 
95  void setProperties(const LabelProperties& props);
96 
100  LabelProperties properties() const;
101 
102 signals:
106  void propertiesApplied(const LabelProperties& props);
107 
108 private slots:
109  void onApplyClicked();
110  void onResetClicked();
111  void onOpacitySliderChanged(int value);
112  void onCellFontPropertiesChanged();
113  void onPointFontPropertiesChanged();
114 
115 private:
116  void setupUi();
117  void loadDefaults();
118  void updatePropertiesFromWidgets();
119 
120  // Helper functions to reduce code duplication (implemented in .cpp)
122  labelPropertiesToFontProperties(const LabelProperties& props,
123  bool isCellLabel);
124  static void fontPropertiesToLabelProperties(
125  const ecvFontPropertyWidget::FontProperties& fontProps,
126  LabelProperties& props,
127  bool isCellLabel);
128 
129 private:
130  bool m_isInteractive;
131  LabelProperties m_properties;
132  LabelProperties m_defaultProperties;
133 
134  // General settings
135  QSlider* m_opacitySlider = nullptr;
136  QDoubleSpinBox* m_opacitySpin = nullptr;
137  QSpinBox* m_pointSizeSpin = nullptr;
138  QSpinBox* m_lineWidthSpin = nullptr;
139 
140  // Cell Label Font Widget
141  ecvFontPropertyWidget* m_cellFontWidget = nullptr;
142  QLineEdit* m_cellFormatEdit = nullptr;
143 
144  // Point Label Font Widget
145  ecvFontPropertyWidget* m_pointFontWidget = nullptr;
146  QLineEdit* m_pointFormatEdit = nullptr;
147 
148  // Tooltip Settings
149  QCheckBox* m_showTooltipsCheckBox = nullptr;
150  QSpinBox* m_maxTooltipAttributesSpin = nullptr;
151 
152  // Dialog buttons
153  QToolButton* m_refreshButton = nullptr;
154  QToolButton* m_saveButton = nullptr;
155  QPushButton* m_applyButton = nullptr;
156  QPushButton* m_resetButton = nullptr;
157  QPushButton* m_cancelButton = nullptr;
158  QPushButton* m_okButton = nullptr;
159 };
#define slots
#define signals
Dialog for editing selection label properties.
void propertiesApplied(const LabelProperties &props)
Emitted when Apply is clicked.
A reusable font property widget matching ParaView's font editor style.
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15
Font property structure for convenience.