21 #include <QActionGroup>
31 cvSelectionToolController::cvSelectionToolController(QObject* parent)
33 m_parentWidget(nullptr),
35 m_selectionToolsActive(false),
36 m_modifierGroup(nullptr) {
40 QOverload<const cvSelectionData&>::of(
54 cvSelectionToolController::~cvSelectionToolController() {
56 for (
auto reaction : m_reactions) {
68 m_parentWidget = parent;
71 "[cvSelectionToolController] Initialized with parent widget");
83 for (
auto reaction : m_reactions) {
85 reaction->setVisualizer(viewer);
90 QString(
"[cvSelectionToolController] Visualizer set, updated %1 "
92 .arg(m_reactions.size()));
100 "[cvSelectionToolController] Cannot register null action "
125 if (action->isCheckable()) {
126 connect(action, &QAction::toggled,
this, [
this, mode](
bool checked) {
128 QString(
"[cvSelectionToolController] Action (new) for mode "
130 .arg(
static_cast<int>(mode))
131 .arg(checked ?
"checked" :
"unchecked"));
139 bool anyActive =
false;
140 for (
auto it = m_reactions.constBegin();
141 it != m_reactions.constEnd(); ++it) {
147 QPointer<cvRenderViewSelectionReaction> r = it.value();
148 if (r && r->parentAction() &&
149 r->parentAction()->isCheckable() &&
150 r->parentAction()->isChecked()) {
161 m_reactions[mode] = reaction;
164 QString(
"[cvSelectionToolController] Registered action for "
166 .arg(
static_cast<int>(mode)));
173 QAction* subtractAction,
174 QAction* toggleAction) {
175 m_addAction = addAction;
176 m_subtractAction = subtractAction;
177 m_toggleAction = toggleAction;
181 m_modifierGroup =
new QActionGroup(
this);
184 m_modifierGroup->setExclusive(
false);
187 addAction->setCheckable(
true);
190 m_modifierGroup->addAction(addAction);
192 if (subtractAction) {
193 subtractAction->setCheckable(
true);
194 subtractAction->setData(
196 m_modifierGroup->addAction(subtractAction);
199 toggleAction->setCheckable(
true);
200 toggleAction->setData(
202 m_modifierGroup->addAction(toggleAction);
207 connect(m_modifierGroup, &QActionGroup::triggered,
this,
211 "[cvSelectionToolController] Registered modifier actions");
216 QAction* growAction, QAction* shrinkAction, QAction* clearAction) {
217 m_growAction = growAction;
218 m_shrinkAction = shrinkAction;
219 m_clearAction = clearAction;
235 "[cvSelectionToolController] Registered manipulation actions "
236 "(using new architecture)");
243 for (
auto reaction : m_reactions) {
244 if (reaction && reaction != except && reaction->
isActive()) {
245 if (reaction->parentAction() &&
246 reaction->parentAction()->isCheckable()) {
247 reaction->parentAction()->blockSignals(
true);
248 reaction->parentAction()->setChecked(
false);
249 reaction->parentAction()->blockSignals(
false);
258 if (except ==
nullptr) {
289 auto uncheckAction = [](QAction* action) {
290 if (action && action->isCheckable() && action->isChecked()) {
291 action->blockSignals(
true);
292 action->setChecked(
false);
293 action->blockSignals(
false);
312 "[cvSelectionToolController] ESC key handled - disabled all "
330 if (m_selectionToolsActive != active) {
331 m_selectionToolsActive = active;
345 m_manager->blockSignals(
true);
347 m_manager->blockSignals(
false);
351 bool hasSelection = !selectionData.
isEmpty();
353 m_growAction->setEnabled(hasSelection);
355 if (m_shrinkAction) {
356 m_shrinkAction->setEnabled(hasSelection);
359 m_clearAction->setEnabled(hasSelection);
363 if (m_selectionToolsActive) {
371 QString(
"[cvSelectionToolController] Selection finished: %1 %2")
372 .arg(selectionData.
count())
388 if (!action->isCheckable()) {
395 if (action->isChecked()) {
398 if (m_modifierGroup) {
399 for (QAction* groupAction : m_modifierGroup->actions()) {
400 if (groupAction != action && groupAction->isChecked()) {
401 groupAction->blockSignals(
true);
402 groupAction->setChecked(
false);
403 groupAction->blockSignals(
false);
410 QVariant
data = action->data();
411 if (
data.isValid()) {
416 switch (
data.toInt()) {
417 case static_cast<int>(
419 modeName =
"ADD (Ctrl)";
421 case static_cast<int>(
423 modeName =
"SUBTRACT (Shift)";
426 modeName =
"TOGGLE (Ctrl+Shift)";
429 modeName =
"DEFAULT";
433 QString(
"[cvSelectionToolController] Selection "
444 "[cvSelectionToolController] Selection modifier: DEFAULT");
455 #ifdef USE_PCL_BACKEND
545 "[cvSelectionToolController] All selection actions registered "
546 "(using new ParaView-aligned architecture)");
554 "[cvSelectionToolController] Highlighter connection established "
566 "[cvSelectionToolController] Selection cache invalidated "
567 "(scene content changed)");
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static bool PrintVerbose(const char *format,...)
Prints out a verbose formatted message in console.
cvRenderViewSelectionReaction handles all selection modes in a single class
static cvRenderViewSelectionReaction * activeReaction()
Get the currently active reaction (static)
void zoomToBoxCompleted(int xmin, int ymin, int xmax, int ymax)
Emitted when zoom to box is completed.
void selectionFinished(const cvSelectionData &selectionData)
Emitted when selection is finished.
bool isActive() const
Check if this reaction's selection is currently active.
void setVisualizer(ecvGenericVisualizer3D *viewer)
Set the visualizer for selection operations.
static void endActiveSelection()
Force end any active selection.
ecvGenericVisualizer3D * getVisualizer() const
Get the visualizer instance.
Encapsulates selection data without exposing VTK types.
QString fieldTypeString() const
Get human-readable field type string.
bool isEmpty() const
Check if selection is empty.
int count() const
Get number of selected items.
Helper class for highlighting selected elements in the visualizer.
Selection pipeline abstraction layer.
void invalidateCachedSelection()
Clear selection cache and invalidate cached buffers.
Central manager for all selection operations in the view.
void setCurrentSelection(const cvSelectionData &selectionData, bool resetLayers=true)
Set the current selection data.
void setSelectionModifier(SelectionModifier modifier)
Set the selection modifier.
cvSelectionPipeline * getPipeline()
Get the selection pipeline.
void setVisualizer(ecvGenericVisualizer3D *viewer) override
Set the visualizer for all selection operations.
void setSourceObject(ccHObject *obj)
Set the source object for selection operations.
cvSelectionHighlighter * getHighlighter()
Get the shared highlighter.
SelectionMode getCurrentMode() const
Get the current active selection mode.
void selectionChanged()
Emitted when the selection has changed (legacy - for backward compatibility)
Generic visualizer 3D interface.
Simplified selection reaction class aligned with ParaView architecture.
@ SELECT_BLOCKS
Select blocks (rectangle)
@ SELECT_FRUSTUM_BLOCKS
Select blocks in frustum.
@ SELECT_FRUSTUM_POINTS
Select points in frustum.
@ SELECT_SURFACE_POINTS
Select points on surface (rectangle)
@ HOVER_CELLS_TOOLTIP
Show cell data tooltip on hover (read-only)
@ SELECT_SURFACE_POINTS_POLYGON
Select points on surface (polygon)
@ GROW_SELECTION
Expand selection by one layer.
@ SHRINK_SELECTION
Shrink selection by one layer.
@ SELECT_SURFACE_POINTS_INTERACTIVELY
@ SELECT_SURFACE_CELLS
Select cells on surface (rectangle)
@ SELECT_SURFACE_CELLS_INTERACTIVELY
@ HOVER_POINTS_TOOLTIP
Show point data tooltip on hover (read-only)
@ ZOOM_TO_BOX
Zoom to box region.
@ SELECT_SURFACE_CELLS_POLYGON
Select cells on surface (polygon)
@ SELECT_FRUSTUM_CELLS
Select cells in frustum.
@ CLEAR_SELECTION
Clear current selection.
@ SELECTION_TOGGLE
Toggle selection (Ctrl+Shift)
@ SELECTION_DEFAULT
Replace selection (default)
@ SELECTION_ADDITION
Add to selection (Ctrl)
@ SELECTION_SUBTRACTION
Subtract from selection (Shift)