1 // Copyright (C) 2023 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <pqSelectionReaction.h>
24 #include <vtkSmartPointer.h>
25 #include <vtkWeakPointer.h>
30 #include <QPushButton>
37 class pqDataRepresentation;
38 class vtkSMRepresentationProxy;
39 class vtkSMSourceProxy;
42 * SPV3D_CADSelection handles various selection modes available on
43 * RenderViews. Simply create multiple instances of
44 * SPV3D_CADSelection to handle selection modes for that RenderView.
45 * SPV3D_CADSelection uses internal static members to ensure that
46 * at most 1 view (and 1 type of selection) is in selection-mode at any given
49 class SPV3D_CADSelection : public QObject
63 * If \c view is nullptr, this reaction will track the active-view maintained by
66 SPV3D_CADSelection(QObject *parent, pqRenderView* view, SelectionMode mode);
68 ~SPV3D_CADSelection() override;
71 * Set the selectionMode
73 void SetMode(const SPV3D_CADSelection::SelectionMode mode);
77 * For checkable actions, this calls this->beginSelection() or
78 * this->endSelection() is val is true or false, respectively. For
79 * non-checkable actions, this call this->beginSelection() and
80 * this->endSelection() in that order.
82 virtual void actionTriggered(bool val);
86 * Called when this object was created with nullptr as the view and the active
89 void setView(pqView* view);
92 * Called when the active representation changes.
94 void setRepresentation(pqDataRepresentation* representation);
97 * starts the selection i.e. setup render view in selection mode.
99 void beginSelection();
102 * finishes the selection. Doesn't cause the selection, just returns the
103 * render view to previous interaction mode.
107 void updateEnableState();
111 * Disable preselection during rotation using the right button.
113 void onRightButtonPress();
114 void onRightButtonRelease();
120 * callback called when the vtkPVRenderView is done with selection.
122 void selectionChanged(vtkObject*, unsigned long, void* calldata);
125 * callback called for mouse move events when in 'interactive selection'
131 * callback called for click events when in 'interactive selection' modes.
133 void onLeftButtonRelease();
135 // Get the current state of selection modifier
136 int getSelectionModifier();
139 * makes fast selection.
141 void fastSelection(bool presel = false);
144 * cleans up observers.
146 void cleanupObservers();
148 Q_DISABLE_COPY(SPV3D_CADSelection)
149 QPointer<pqRenderView> View;
150 QPointer<pqDataRepresentation> Representation;
151 QMetaObject::Connection RepresentationConnection;
152 vtkSMRepresentationProxy* CurrentRepresentation = nullptr;
154 int PreviousRenderViewMode;
155 vtkWeakPointer<vtkObject> ObservedObject;
156 unsigned long ObserverIds[4];
157 int MousePosition[2];
158 QComboBox* selectionComboBox;
159 bool DisablePreSelection = false;