536d98e2 |
1 | // Copyright (c) 1997-1999 Matra Datavision |
2 | // Copyright (c) 1999-2015 OPEN CASCADE SAS |
3 | // |
4 | // This file is part of Open CASCADE Technology software library. |
5 | // |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
11 | // |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
14 | |
15 | #ifndef _ViewerTest_HeaderFile |
16 | #define _ViewerTest_HeaderFile |
17 | |
18 | #include <Standard.hxx> |
19 | #include <Standard_DefineAlloc.hxx> |
20 | #include <Standard_Macro.hxx> |
21 | |
22 | #include <Draw_Interpretor.hxx> |
23 | #include <Standard_Integer.hxx> |
24 | #include <Standard_CString.hxx> |
536d98e2 |
25 | #include <Standard_Boolean.hxx> |
536d98e2 |
26 | #include <TopAbs_ShapeEnum.hxx> |
b7c077b9 |
27 | #include <TopTools_HArray1OfShape.hxx> |
404c8936 |
28 | #include <TopTools_ListOfShape.hxx> |
536d98e2 |
29 | #include <AIS_KindOfInteractive.hxx> |
3a4a3962 |
30 | #include <Aspect_TypeOfLine.hxx> |
b7c077b9 |
31 | #include <TColStd_HArray1OfTransient.hxx> |
536d98e2 |
32 | #include <Quantity_NameOfColor.hxx> |
33 | |
3a4a3962 |
34 | |
536d98e2 |
35 | class TCollection_AsciiString; |
36 | class V3d_View; |
37 | class MMgt_TShared; |
38 | class TopoDS_Shape; |
536d98e2 |
39 | class AIS_InteractiveObject; |
536d98e2 |
40 | class V3d_Viewer; |
41 | class AIS_InteractiveContext; |
42 | class ViewerTest_EventManager; |
43 | class ViewerTest_EventManager; |
536d98e2 |
44 | class Quantity_Color; |
45 | |
46 | class ViewerTest |
47 | { |
48 | public: |
49 | |
50 | DEFINE_STANDARD_ALLOC |
51 | |
52 | //! Loads all Draw commands of V2d & V3d. Used for plugin. |
53 | Standard_EXPORT static void Factory (Draw_Interpretor& theDI); |
54 | |
55 | //! Creates view with default or custom name |
56 | //! and add this name in map to manage muliple views |
57 | //! implemented in ViewerTest_ViewerCommands.cxx |
58 | Standard_EXPORT static TCollection_AsciiString ViewerInit (const Standard_Integer thePxLeft = 0, |
59 | const Standard_Integer thePxTop = 0, |
60 | const Standard_Integer thePxWidth = 0, |
61 | const Standard_Integer thePxHeight = 0, |
62 | const Standard_CString theViewName = "", |
63 | const Standard_CString theDisplayName = ""); |
64 | |
65 | Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName); |
66 | |
67 | Standard_EXPORT static void InitViewName (const TCollection_AsciiString& theName, |
68 | const Handle(V3d_View)& theView); |
69 | |
70 | Standard_EXPORT static TCollection_AsciiString GetCurrentViewName(); |
71 | |
72 | //! Removes view and clear all maps |
73 | //! with information about its resources if necessary |
74 | Standard_EXPORT static void RemoveView (const TCollection_AsciiString& theViewName, |
75 | const Standard_Boolean theToRemoveContext = Standard_True); |
76 | |
77 | //! Removes view and clear all maps |
78 | //! with information about its resources if necessary |
79 | Standard_EXPORT static void RemoveView (const Handle(V3d_View)& theView, |
80 | const Standard_Boolean theToRemoveContext = Standard_True); |
81 | |
29e2c6d2 |
82 | //! Display AIS object in active Viewer and register it in the map of Interactive Objects with specified name. |
83 | //! @param theName key to be associated to displayed interactive object |
84 | //! @param theObject object to display |
85 | //! @param theToUpdate redraw viewer after displaying object |
86 | //! @param theReplaceIfExists replace the object assigned to specified key |
87 | //! @return true if new object has been displayed |
88 | Standard_EXPORT static Standard_Boolean Display (const TCollection_AsciiString& theName, |
89 | const Handle(AIS_InteractiveObject)& theObject, |
90 | const Standard_Boolean theToUpdate = Standard_True, |
91 | const Standard_Boolean theReplaceIfExists = Standard_True); |
92 | |
536d98e2 |
93 | //! waits until a shape of type <aType> is picked in the AIS Viewer and returns it. |
94 | //! if <aType> == TopAbs_Shape, any shape can be picked... |
95 | //! MaxPick is the Max number before exiting, if no pick is successful |
96 | Standard_EXPORT static TopoDS_Shape PickShape (const TopAbs_ShapeEnum aType, |
97 | const Standard_Integer MaxPick = 5); |
98 | |
99 | //! wait until the array is filled with picked shapes. |
100 | //! returns True if the array is filled. |
101 | //! exit if number of unsuccessful picks = <MaxPick> |
102 | Standard_EXPORT static Standard_Boolean PickShapes (const TopAbs_ShapeEnum aType, |
103 | Handle(TopTools_HArray1OfShape)& thepicked, |
104 | const Standard_Integer MaxPick = 5); |
105 | |
106 | //! waits until an interactive object of a given Type |
107 | //! and signature is picked (default values authorize |
108 | //! selection of any Interactive Object) |
109 | //! exit if number of unsuccessful picks = <MaxPick> |
110 | Standard_EXPORT static Handle(AIS_InteractiveObject) PickObject (const AIS_KindOfInteractive Type = AIS_KOI_None, |
111 | const Standard_Integer Signature = -1, |
112 | const Standard_Integer MaxPick = 5); |
113 | |
114 | //! selection of several interactive objects. |
115 | //! Number is given by the size of <thepicked> |
116 | //! exit if number of unsuccesfull picks = <MaxPick> |
117 | Standard_EXPORT static Standard_Boolean PickObjects (Handle(TColStd_HArray1OfTransient)& thepicked, |
118 | const AIS_KindOfInteractive Type = AIS_KOI_None, |
119 | const Standard_Integer Signature = -1, |
120 | const Standard_Integer MaxPick = 5); |
121 | |
122 | Standard_EXPORT static void Commands (Draw_Interpretor& theCommands); |
123 | |
536d98e2 |
124 | Standard_EXPORT static void ViewerCommands (Draw_Interpretor& theCommands); |
125 | |
126 | Standard_EXPORT static void MyCommands (Draw_Interpretor& theCommands); |
127 | |
128 | Standard_EXPORT static void RelationCommands (Draw_Interpretor& theCommands); |
129 | |
130 | Standard_EXPORT static void ObjectCommands (Draw_Interpretor& theCommands); |
131 | |
132 | Standard_EXPORT static void FilletCommands (Draw_Interpretor& theCommands); |
133 | |
536d98e2 |
134 | Standard_EXPORT static void OpenGlCommands (Draw_Interpretor& theCommands); |
135 | |
136 | Standard_EXPORT static void GetMousePosition (Standard_Integer& xpix, Standard_Integer& ypix); |
137 | |
138 | Standard_EXPORT static Handle(V3d_Viewer) GetViewerFromContext(); |
139 | |
140 | Standard_EXPORT static Handle(V3d_Viewer) GetCollectorFromContext(); |
141 | |
142 | Standard_EXPORT static const Handle(AIS_InteractiveContext)& GetAISContext(); |
143 | |
536d98e2 |
144 | Standard_EXPORT static void SetAISContext (const Handle(AIS_InteractiveContext)& aContext); |
145 | |
536d98e2 |
146 | Standard_EXPORT static const Handle(V3d_View)& CurrentView(); |
147 | |
148 | Standard_EXPORT static void CurrentView (const Handle(V3d_View)& aViou); |
149 | |
150 | Standard_EXPORT static void Clear(); |
151 | |
152 | //! puts theMgr as current eventmanager (the move,select,...will be applied to theMgr) |
153 | Standard_EXPORT static void SetEventManager (const Handle(ViewerTest_EventManager)& theMgr); |
154 | |
155 | //! removes the last EventManager from the list. |
156 | Standard_EXPORT static void UnsetEventManager(); |
157 | |
158 | //! clear the list of EventManagers and |
159 | //! sets the default EventManager as current |
160 | Standard_EXPORT static void ResetEventManager(); |
161 | |
162 | Standard_EXPORT static Handle(ViewerTest_EventManager) CurrentEventManager(); |
163 | |
164 | Standard_EXPORT static void RemoveSelected(); |
165 | |
166 | Standard_EXPORT static void StandardModeActivation (const Standard_Integer Mode); |
167 | |
168 | Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name); |
169 | |
170 | //! Parses color argument(s) specified within theArgVec[0], theArgVec[1] and theArgVec[2]. |
171 | //! Handles either color specified by name (single argument) |
172 | //! or by RGB components (3 arguments) in range 0..1. |
173 | //! The result is stored in theColor on success. |
174 | //! Returns number of handled arguments (1 or 3) or 0 on syntax error. |
175 | Standard_EXPORT static Standard_Integer ParseColor (Standard_Integer theArgNb, |
176 | const char** theArgVec, |
177 | Quantity_Color& theColor); |
178 | |
179 | //! redraws all defined views. |
180 | Standard_EXPORT static void RedrawAllViews(); |
181 | |
182 | //! Splits "parameter=value" string into separate |
183 | //! parameter and value strings. |
184 | //! @return TRUE if the string matches pattern "<string>=<empty or string>" |
185 | Standard_EXPORT static Standard_Boolean SplitParameter (const TCollection_AsciiString& theString, |
186 | TCollection_AsciiString& theName, |
187 | TCollection_AsciiString& theValue); |
188 | |
a5565a3c |
189 | //! Parses boolean argument. |
190 | //! Handles either flag specified by 0|1 or on|off. |
191 | Standard_EXPORT static Standard_Boolean ParseOnOff (Standard_CString theArg, |
192 | Standard_Boolean& theIsOn); |
3a4a3962 |
193 | |
404c8936 |
194 | //! Returns list of selected shapes. |
195 | Standard_EXPORT static void GetSelectedShapes (TopTools_ListOfShape& theShapes); |
196 | |
197 | |
3a4a3962 |
198 | //! Parses line type argument. |
199 | //! Handles either enumeration (integer) value or string constant. |
200 | Standard_EXPORT static Standard_Boolean ParseLineType (Standard_CString theArg, |
201 | Aspect_TypeOfLine& theType); |
202 | |
536d98e2 |
203 | private: |
204 | |
205 | //! Returns a window class that implements standard behavior of |
206 | //! all windows of the ViewerTest. This includes usual Open CASCADE |
207 | //! view conventions for mouse buttons (e.g. Ctrl+MB1 for zoom, |
208 | //! Ctrl+MB2 for pan, etc) and keyboard shortcuts. |
209 | //! This method is relevant for MS Windows only and respectively |
210 | //! returns WNT_WClass handle. |
ad03c234 |
211 | static const Handle(Standard_Transient)& WClass(); |
536d98e2 |
212 | }; |
213 | |
214 | #endif // _ViewerTest_HeaderFile |