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 | |
32 | ViewerTest_EventManager::ViewerTest_EventManager |
33 | (const Handle(V3d_View)& aView, |
34 | const Handle(AIS_InteractiveContext)& Ctx) |
35 | : myView (aView), |
36 | myCtx (Ctx), |
37 | myX (-1), |
38 | myY (-1) |
39 | {} |
40 | |
41 | //======================================================================= |
42 | //function : MoveTo |
43 | //purpose : |
44 | //======================================================================= |
45 | |
46 | void 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 | |
63 | void 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 | |
81 | void 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 | |
99 | void 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 | |
113 | void 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 | } |