14bbbdcb |
1 | // Created on: 2017-06-16 |
2 | // Created by: Natalia ERMOLAEVA |
3 | // Copyright (c) 2017 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
0cb512c0 |
16 | #include <inspector/VInspector_CallBack.hxx> |
14bbbdcb |
17 | |
18 | #include <AIS_InteractiveContext.hxx> |
19 | #include <AIS_InteractiveObject.hxx> |
20 | |
21 | #include <SelectMgr_EntityOwner.hxx> |
22 | #include <Standard_Version.hxx> |
23 | |
0cb512c0 |
24 | #include <inspector/VInspector_CallBackMode.hxx> |
25 | #include <inspector/VInspector_Tools.hxx> |
26 | #include <inspector/VInspector_ViewModelHistory.hxx> |
14bbbdcb |
27 | |
14bbbdcb |
28 | #if OCC_VERSION_HEX <= 0x060901 |
29 | IMPLEMENT_STANDARD_HANDLE(VInspector_CallBack, Standard_Transient) |
30 | IMPLEMENT_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack) |
31 | #else |
32 | IMPLEMENT_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack) |
33 | #endif |
34 | |
35 | // ======================================================================= |
36 | // function : Activate |
37 | // purpose : |
38 | // ======================================================================= |
39 | void VInspector_CallBack::Activate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode) |
40 | { |
41 | QList<QVariant> anInfo = VInspector_Tools::GetInfo (thePrs); |
42 | anInfo[0] = QString ("%1: %2").arg (anInfo[0].toString()).arg (theMode); |
43 | myHistoryModel->AddElement (VInspector_CallBackMode_Activate, anInfo); |
44 | } |
45 | |
46 | // ======================================================================= |
47 | // function : AddOrRemoveSelected |
48 | // purpose : |
49 | // ======================================================================= |
50 | void VInspector_CallBack::AddOrRemoveSelected (const TopoDS_Shape& theShape) |
51 | { |
52 | QList<QVariant> aValues; |
53 | aValues.append (""); // Name |
54 | aValues.append (""); // Pointer |
55 | aValues.append (VInspector_Tools::GetShapeTypeInfo (theShape.ShapeType()).ToCString()); // Shape Type |
56 | aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo |
57 | myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelectedShape, aValues); |
58 | } |
59 | |
60 | // ======================================================================= |
61 | // function : AddOrRemoveSelected |
62 | // purpose : |
63 | // ======================================================================= |
64 | void VInspector_CallBack::AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs) |
65 | { |
66 | QList<QVariant> aValues = VInspector_Tools::GetInfo (thePrs); |
67 | aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo |
68 | myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelected, aValues); |
69 | } |
70 | |
71 | // ======================================================================= |
72 | // function : AddOrRemoveSelected |
73 | // purpose : |
74 | // ======================================================================= |
75 | void VInspector_CallBack::AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner) |
76 | { |
77 | QList<QVariant> aValues; |
78 | aValues.append (""); // Name |
79 | aValues.append (VInspector_Tools::GetPointerInfo (theOwner, true).ToCString()); // Pointer |
80 | aValues.append (""); // Shape type |
81 | aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo |
82 | |
83 | myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelectedOwner, aValues); |
84 | } |
85 | |
86 | // ======================================================================= |
87 | // function : ClearSelected |
88 | // purpose : |
89 | // ======================================================================= |
90 | void VInspector_CallBack::ClearSelected() |
91 | { |
92 | QList<QVariant> aValues; |
93 | myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, aValues); |
94 | } |
95 | |
96 | // ======================================================================= |
97 | // function : MoveTo |
98 | // purpose : |
99 | // ======================================================================= |
100 | void VInspector_CallBack::MoveTo (const Standard_Integer/* theXPix*/, const Standard_Integer/* theYPix*/) |
101 | { |
102 | QList<QVariant> aValues; |
103 | aValues = VInspector_Tools::GetHighlightInfo (myContext); |
104 | myHistoryModel->AddElement (VInspector_CallBackMode_MoveTo, aValues); |
105 | } |
106 | |
107 | // ======================================================================= |
108 | // function : Select |
109 | // purpose : |
110 | // ======================================================================= |
111 | void VInspector_CallBack::Select() |
112 | { |
113 | QList<QVariant> aValues; |
114 | aValues = VInspector_Tools::GetSelectedInfo (myContext); |
115 | myHistoryModel->AddElement (VInspector_CallBackMode_Select, aValues); |
116 | } |
117 | |
118 | // ======================================================================= |
119 | // function : ShiftSelect |
120 | // purpose : |
121 | // ======================================================================= |
122 | void VInspector_CallBack::ShiftSelect() |
123 | { |
124 | QList<QVariant> aValues; |
125 | aValues = VInspector_Tools::GetSelectedInfo (myContext); |
126 | myHistoryModel->AddElement (VInspector_CallBackMode_ShiftSelect, aValues); |
127 | } |
128 | |
129 | // ======================================================================= |
130 | // function : GetInfo |
131 | // purpose : |
132 | // ======================================================================= |
133 | QString VInspector_CallBack::GetInfo (const VInspector_CallBackMode& theMode) |
134 | { |
135 | switch (theMode) |
136 | { |
137 | case VInspector_CallBackMode_None: return "None"; |
138 | case VInspector_CallBackMode_Display: return "Display"; |
139 | case VInspector_CallBackMode_Redisplay: return "Redisplay"; |
140 | case VInspector_CallBackMode_Remove: return "Remove"; |
141 | case VInspector_CallBackMode_Load: return "Load"; |
142 | case VInspector_CallBackMode_ActivatedModes: return "ActivatedModes"; |
143 | case VInspector_CallBackMode_Activate: return "Activate"; |
144 | case VInspector_CallBackMode_Deactivate: return "Deactivate"; |
145 | case VInspector_CallBackMode_AddOrRemoveSelectedShape: return "AddOrRemoveSelectedShape"; |
146 | case VInspector_CallBackMode_AddOrRemoveSelected: return "AddOrRemoveSelected"; |
147 | case VInspector_CallBackMode_AddOrRemoveSelectedOwner: return "AddOrRemoveSelectedOwner"; |
148 | case VInspector_CallBackMode_ClearSelected: return "ClearSelected"; |
149 | case VInspector_CallBackMode_MoveTo: return "MoveTo"; |
150 | case VInspector_CallBackMode_SetSelected: return "SetSelected"; |
151 | case VInspector_CallBackMode_Select: return "Select"; |
152 | case VInspector_CallBackMode_ShiftSelect: return "ShiftSelect"; |
153 | default: break; |
154 | } |
155 | return QString(); |
156 | } |