Salome HOME
3c49de5370de2dae754cd06add4b6c06d5d9114b
[modules/geom.git] / src / MeasureGUI / MeasureGUI_AnnotationInteractor.h
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : MeasureGUI_AnnotationInteractor.h
25 // Author : Anton POLETAEV, Open CASCADE S.A.S.
26 //
27 #ifndef MEASUREGUI_ANNOTATIONINTERACTOR_H
28 #define MEASUREGUI_ANNOTATIONINTERACTOR_H
29
30 #include <GEOM_Annotation.hxx>
31 #include <SelectMgr_EntityOwner.hxx>
32 #include <SelectMgr_SequenceOfOwner.hxx>
33 #include <QObject>
34 #include <QPoint>
35
36 class GeometryGUI;
37 class OCCViewer_Viewer;
38 class OCCViewer_ViewManager;
39 class OCCViewer_ViewPort3d;
40 class SUIT_ViewWindow;
41
42 /*!
43  * \class MeasureGUI_AnnotationInteractor
44  * \brief Class implementing logical layer for interactive dragging of annotation
45  *        labels. It includes two components: listener for GUI events occurring
46  *        inside of OCCT 3D viewer and processor for hooked events to perform
47  *        interactive modification of the selected annotation within current
48  *        AIS context.
49  */
50 class MeasureGUI_AnnotationInteractor : public QObject
51 {
52   Q_OBJECT
53
54 public:
55
56   //! Constructor.
57   //! Connects to existing viewer/view windows to process events.
58   //! \param theGUI [in] the geometry module's GUI interface.
59   //! \param theOwner [in] the owner of the instance.
60   MeasureGUI_AnnotationInteractor( GeometryGUI* theGUI, QObject* theOwner );
61
62   //! Destructor.
63   virtual ~MeasureGUI_AnnotationInteractor();
64
65 public:
66
67   //! Enables event processing and interaction handlers.
68   void Enable();
69
70   //! Disables event processing and interaction handlers.
71   void Disable();
72
73   //! Set entry of allowed annotation presentations.
74   void SetEditEntry( const QString& theEntry ) { myEditEntry = theEntry; }
75
76 protected:
77
78   //! Connect interactor's event handler to the view window given.
79   void ConnectView( SUIT_ViewWindow* theWindow );
80
81   //! Disconnect interactor's event handler from the view window given.
82   void DisconnectView( SUIT_ViewWindow* theWindow );
83
84 signals:
85
86   //! Emitted when interactor begins modification of the interactive object.
87   void SignalInteractionStarted( Handle_GEOM_Annotation theIO );
88
89   //! Emitted when interactor finished modification of the interactive object.
90   void SignalInteractionFinished( Handle_GEOM_Annotation theIO );
91
92 protected slots:
93
94   //! Handler for signal coming from GUI layer.
95   void OnViewCreated( SUIT_ViewWindow* );
96
97   //! Handler for signal coming from GUI layer.
98   void OnViewRemoved( SUIT_ViewWindow* );
99
100 protected:
101
102   //! Hooks and process events from OCCT viewer prior to their coming into the base viewer class.
103   //! It handles the events coming to viewport and identifies whether the events can
104   //! invoke an interaction operation or not. If yes, the operation is performed within the
105   //! interactor class and events are "accepted". Otherwise, the events are passed to
106   //! viewer's subroutines.
107   virtual bool eventFilter( QObject*, QEvent* );
108
109 private:
110
111   GeometryGUI*              myGeomGUI;
112   bool                      myIsEnabled;
113   OCCViewer_ViewManager*    myVM;
114   OCCViewer_Viewer*         myViewer;
115   OCCViewer_ViewPort3d*     myActiveViewPort;
116   Handle(GEOM_Annotation)   myActiveIO;
117   SelectMgr_SequenceOfOwner mySelection;
118   QPoint                    myStartPoint;
119   QString                   myEditEntry;
120 };
121
122 #endif