0024171: Eliminate CLang compiler warning -Wreorder
[occt.git] / src / ViewerTest / ViewerTest_EventManager.cxx
CommitLineData
b311480e 1// Created on: 1998-08-27
2// Created by: Robert COUBLANC
3// Copyright (c) 1998-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22
23#include <ViewerTest_EventManager.ixx>
24#include <AIS_InteractiveContext.hxx>
25#include <NIS_View.hxx>
26
27//=======================================================================
28//function : ViewerTest_EventManager
29//purpose :
30//=======================================================================
31
32ViewerTest_EventManager::ViewerTest_EventManager
33 (const Handle(V3d_View)& aView,
34 const Handle(AIS_InteractiveContext)& Ctx)
eafb234b 35 : myCtx (Ctx),
36 myView (aView),
7fd59977 37 myX (-1),
38 myY (-1)
39{}
40
41//=======================================================================
42//function : MoveTo
43//purpose :
44//=======================================================================
45
46void ViewerTest_EventManager::MoveTo(const Standard_Integer XPix,
47 const Standard_Integer YPix)
48{
49 if(!myCtx.IsNull() && !myView.IsNull())
50 myCtx->MoveTo(XPix,YPix,myView);
51 myX = XPix;
52 myY = YPix;
53 const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
54 if (!aView.IsNull())
55 aView->DynamicHilight (XPix, YPix);
56}
57
58//=======================================================================
59//function : Select
60//purpose :
61//=======================================================================
62
63void ViewerTest_EventManager::Select(const Standard_Integer XPMin,
64 const Standard_Integer YPMin,
65 const Standard_Integer XPMax,
66 const Standard_Integer YPMax)
67{
68#define IS_FULL_INCLUSION Standard_True
69 if(!myCtx.IsNull() && !myView.IsNull())
70 myCtx->Select(XPMin,YPMin,XPMax,YPMax,myView);
71 const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
72 if (!aView.IsNull())
73 aView->Select(XPMin,YPMin,XPMax,YPMax, Standard_False, IS_FULL_INCLUSION);
74}
75
76//=======================================================================
77//function : ShiftSelect
78//purpose :
79//=======================================================================
80
81void ViewerTest_EventManager::ShiftSelect(const Standard_Integer XPMin,
82 const Standard_Integer YPMin,
83 const Standard_Integer XPMax,
84 const Standard_Integer YPMax)
85{
86 if(!myCtx.IsNull() && !myView.IsNull())
87 myCtx->AIS_InteractiveContext::ShiftSelect(XPMin,YPMin,XPMax,YPMax,myView,
88 Standard_True);
89 const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
90 if (!aView.IsNull())
91 aView->Select(XPMin,YPMin,XPMax,YPMax, Standard_True, IS_FULL_INCLUSION);
92}
93
94//=======================================================================
95//function : Select
96//purpose :
97//=======================================================================
98
99void ViewerTest_EventManager::Select()
100{
101 if (!myCtx.IsNull() && !myView.IsNull())
102 myCtx->Select();
103 const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
104 if (!aView.IsNull())
105 aView->Select(myX, myY);
106}
107
108//=======================================================================
109//function : ShiftSelect
110//purpose :
111//=======================================================================
112
113void ViewerTest_EventManager::ShiftSelect()
114{
115 if(!myCtx.IsNull() && !myView.IsNull())
116 myCtx->ShiftSelect(Standard_True);
117 const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
118 if (!aView.IsNull())
119 aView->Select(myX, myY, Standard_True);
120}
4754e164 121
122//=======================================================================
123//function : Select
124//purpose : Selection with polyline
125//=======================================================================
126
127void ViewerTest_EventManager::Select(const TColgp_Array1OfPnt2d& thePolyline)
128{
129 if(!myCtx.IsNull() && !myView.IsNull())
130 myCtx->Select(thePolyline,myView);
131 const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
132 if (!aView.IsNull())
133 {
134 NCollection_List<gp_XY> aPolylist;
135 for(Standard_Integer anIter = thePolyline.Lower();anIter <= thePolyline.Upper();++anIter)
136 {
137 aPolylist.Append(gp_XY(thePolyline.Value(anIter).X(),
138 thePolyline.Value(anIter).Y()));
139 }
140 aView->Select(aPolylist);
141 }
142}
143
144//=======================================================================
145//function : ShiftSelect
146//purpose : Selection with polyline without erasing of current selection
147//=======================================================================
148
149void ViewerTest_EventManager::ShiftSelect(const TColgp_Array1OfPnt2d& thePolyline)
150{
151 if(!myCtx.IsNull() && !myView.IsNull())
152 myCtx->ShiftSelect(thePolyline,myView);
153 const Handle(NIS_View) aView = Handle(NIS_View)::DownCast(myView);
154 if (!aView.IsNull())
155 {
156 NCollection_List<gp_XY> aPolylist;
157 for(Standard_Integer anIter = thePolyline.Lower();anIter <= thePolyline.Upper();++anIter)
158 {
159 aPolylist.Append(gp_XY(thePolyline.Value(anIter).X(),
160 thePolyline.Value(anIter).Y()));
161 }
162 aView->Select(aPolylist, Standard_True);
163 }
164}