1 // Copyright (c) 2016-2019 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13 
14 #ifndef _AIS_ViewInputBuffer_HeaderFile
15 #define _AIS_ViewInputBuffer_HeaderFile
16 
17 #include <Aspect_ScrollDelta.hxx>
18 
19 #include <AIS_SelectionScheme.hxx>
20 #include <Graphic3d_Vec2.hxx>
21 #include <NCollection_Sequence.hxx>
22 #include <V3d_TypeOfOrientation.hxx>
23 
24 //! Selection mode
25 enum AIS_ViewSelectionTool
26 {
27   AIS_ViewSelectionTool_Picking,    //!< pick to select
28   AIS_ViewSelectionTool_RubberBand, //!< rubber-band to select
29   AIS_ViewSelectionTool_Polygon,    //!< polyline to select
30   AIS_ViewSelectionTool_ZoomWindow, //!< zoom-in window (no selection)
31 };
32 
33 //! Input buffer type.
34 enum AIS_ViewInputBufferType
35 {
36   AIS_ViewInputBufferType_UI, //!< input buffer for filling from UI thread
37   AIS_ViewInputBufferType_GL, //!< input buffer accessible  from GL thread
38 };
39 
40 //! Auxiliary structure defining viewer events
41 class AIS_ViewInputBuffer
42 {
43 public:
44 
45   bool IsNewGesture;     //!< transition from one action to another
46 
47   NCollection_Sequence<Aspect_ScrollDelta> ZoomActions; //!< the queue with zoom actions
48 
49   struct _orientation
50   {
51     bool                  ToFitAll;         //!< perform FitAll operation
52     bool                  ToSetViewOrient;  //!< set new view orientation
53     V3d_TypeOfOrientation ViewOrient;       //!< new view orientation
54 
_orientationAIS_ViewInputBuffer::_orientation55     _orientation() : ToFitAll (false), ToSetViewOrient (false), ViewOrient (V3d_Xpos) {}
56   } Orientation;
57 
58   struct _highlighting
59   {
60     bool            ToHilight; //!< perform dynamic highlighting at specified point
61     Graphic3d_Vec2i Point;     //!< the new point for dynamic highlighting
62 
_highlightingAIS_ViewInputBuffer::_highlighting63     _highlighting() : ToHilight (false) {}
64   } MoveTo;
65 
66   struct _selection
67   {
68     AIS_ViewSelectionTool Tool;          //!< perform selection
69     AIS_SelectionScheme   Scheme;        //!< selection scheme
70     NCollection_Sequence<Graphic3d_Vec2i>
71                           Points;        //!< the points for selection
72     bool                  ToApplyTool;   //!< apply rubber-band selection tool
73 
_selectionAIS_ViewInputBuffer::_selection74     _selection() : Tool (AIS_ViewSelectionTool_Picking), Scheme (AIS_SelectionScheme_UNKNOWN), ToApplyTool (false) {}
75   } Selection;
76 
77   struct _panningParams
78   {
79     bool            ToStart;    //!< start panning
80     Graphic3d_Vec2i PointStart; //!< panning start point
81     bool            ToPan;      //!< perform panning
82     Graphic3d_Vec2i Delta;      //!< panning delta
83 
_panningParamsAIS_ViewInputBuffer::_panningParams84     _panningParams() : ToStart (false), ToPan (false) {}
85   } Panning;
86 
87   struct _draggingParams
88   {
89     bool            ToStart;    //!< start dragging
90     bool            ToStop;     //!< stop  dragging
91     bool            ToAbort;    //!< abort dragging (restore previous position)
92     Graphic3d_Vec2i PointStart; //!< drag start point
93     Graphic3d_Vec2i PointTo;    //!< drag end point
94 
_draggingParamsAIS_ViewInputBuffer::_draggingParams95     _draggingParams() : ToStart (false), ToStop (false), ToAbort (false) {}
96   } Dragging;
97 
98   struct _orbitRotation
99   {
100     bool            ToStart;    //!< start orbit rotation
101     Graphic3d_Vec2d PointStart; //!< orbit rotation start point
102     bool            ToRotate;   //!< perform orbit rotation
103     Graphic3d_Vec2d PointTo;    //!< orbit rotation end point
104 
_orbitRotationAIS_ViewInputBuffer::_orbitRotation105     _orbitRotation() : ToStart (false), ToRotate (false) {}
106   } OrbitRotation;
107 
108   struct _viewRotation
109   {
110     bool            ToStart;    //!< start view rotation
111     Graphic3d_Vec2d PointStart; //!< view rotation start point
112     bool            ToRotate;   //!< perform view rotation
113     Graphic3d_Vec2d PointTo;    //!< view rotation end point
114 
_viewRotationAIS_ViewInputBuffer::_viewRotation115     _viewRotation() : ToStart (false), ToRotate (false) {}
116   } ViewRotation;
117 
118   struct _zrotateParams
119   {
120     Graphic3d_Vec2i Point;    //!< Z rotation start point
121     double          Angle;    //!< Z rotation angle
122     bool            ToRotate; //!< start Z rotation
123 
_zrotateParamsAIS_ViewInputBuffer::_zrotateParams124     _zrotateParams() : Angle (0.0), ToRotate (false) {}
125   } ZRotate;
126 
127 public:
128 
AIS_ViewInputBuffer()129   AIS_ViewInputBuffer()
130   : IsNewGesture (false) {}
131 
132   //! Reset events buffer.
Reset()133   void Reset()
134   {
135     Orientation.ToFitAll = false;
136     Orientation.ToSetViewOrient = false;
137     MoveTo.ToHilight = false;
138     Selection.ToApplyTool = false;
139     IsNewGesture     = false;
140     ZoomActions.Clear();
141     Panning.ToStart  = false;
142     Panning.ToPan    = false;
143     Dragging.ToStart = false;
144     Dragging.ToStop  = false;
145     Dragging.ToAbort = false;
146     OrbitRotation.ToStart  = false;
147     OrbitRotation.ToRotate = false;
148     ViewRotation.ToStart   = false;
149     ViewRotation.ToRotate  = false;
150     ZRotate.ToRotate = false;
151   }
152 
153 };
154 
155 #endif // _AIS_ViewInputBuffer_HeaderFile
156