1 // Copyright (c) 1997-1999 Matra Datavision
2 // Copyright (c) 1999-2015 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _ViewerTest_HeaderFile
16 #define _ViewerTest_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Macro.hxx>
22 #include <Draw_Interpretor.hxx>
23 #include <Standard_Integer.hxx>
24 #include <Standard_CString.hxx>
25 #include <Handle_V3d_View.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Handle_MMgt_TShared.hxx>
28 #include <TopAbs_ShapeEnum.hxx>
29 #include <Handle_TopTools_HArray1OfShape.hxx>
30 #include <Handle_AIS_InteractiveObject.hxx>
31 #include <AIS_KindOfInteractive.hxx>
32 #include <Handle_TColStd_HArray1OfTransient.hxx>
33 #include <Handle_V3d_Viewer.hxx>
34 #include <Handle_AIS_InteractiveContext.hxx>
35 #include <NIS_InteractiveContext.hxx>
36 #include <Handle_ViewerTest_EventManager.hxx>
37 #include <Quantity_NameOfColor.hxx>
39 class TCollection_AsciiString;
43 class TopTools_HArray1OfShape;
44 class AIS_InteractiveObject;
45 class TColStd_HArray1OfTransient;
47 class AIS_InteractiveContext;
48 class ViewerTest_EventManager;
49 class ViewerTest_EventManager;
50 class ViewerTest_DoubleMapOfInteractiveAndName;
51 class ViewerTest_DoubleMapNodeOfDoubleMapOfInteractiveAndName;
52 class ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName;
61 //! Loads all Draw commands of V2d & V3d. Used for plugin.
62 Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
64 //! Creates view with default or custom name
65 //! and add this name in map to manage muliple views
66 //! implemented in ViewerTest_ViewerCommands.cxx
67 Standard_EXPORT static TCollection_AsciiString ViewerInit (const Standard_Integer thePxLeft = 0,
68 const Standard_Integer thePxTop = 0,
69 const Standard_Integer thePxWidth = 0,
70 const Standard_Integer thePxHeight = 0,
71 const Standard_CString theViewName = "",
72 const Standard_CString theDisplayName = "");
74 Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName);
76 Standard_EXPORT static void InitViewName (const TCollection_AsciiString& theName,
77 const Handle(V3d_View)& theView);
79 Standard_EXPORT static TCollection_AsciiString GetCurrentViewName();
81 //! Removes view and clear all maps
82 //! with information about its resources if necessary
83 Standard_EXPORT static void RemoveView (const TCollection_AsciiString& theViewName,
84 const Standard_Boolean theToRemoveContext = Standard_True);
86 //! Removes view and clear all maps
87 //! with information about its resources if necessary
88 Standard_EXPORT static void RemoveView (const Handle(V3d_View)& theView,
89 const Standard_Boolean theToRemoveContext = Standard_True);
91 //! waits until a shape of type <aType> is picked in the AIS Viewer and returns it.
92 //! if <aType> == TopAbs_Shape, any shape can be picked...
93 //! MaxPick is the Max number before exiting, if no pick is successful
94 Standard_EXPORT static TopoDS_Shape PickShape (const TopAbs_ShapeEnum aType,
95 const Standard_Integer MaxPick = 5);
97 //! wait until the array is filled with picked shapes.
98 //! returns True if the array is filled.
99 //! exit if number of unsuccessful picks = <MaxPick>
100 Standard_EXPORT static Standard_Boolean PickShapes (const TopAbs_ShapeEnum aType,
101 Handle(TopTools_HArray1OfShape)& thepicked,
102 const Standard_Integer MaxPick = 5);
104 //! waits until an interactive object of a given Type
105 //! and signature is picked (default values authorize
106 //! selection of any Interactive Object)
107 //! exit if number of unsuccessful picks = <MaxPick>
108 Standard_EXPORT static Handle(AIS_InteractiveObject) PickObject (const AIS_KindOfInteractive Type = AIS_KOI_None,
109 const Standard_Integer Signature = -1,
110 const Standard_Integer MaxPick = 5);
112 //! selection of several interactive objects.
113 //! Number is given by the size of <thepicked>
114 //! exit if number of unsuccesfull picks = <MaxPick>
115 Standard_EXPORT static Standard_Boolean PickObjects (Handle(TColStd_HArray1OfTransient)& thepicked,
116 const AIS_KindOfInteractive Type = AIS_KOI_None,
117 const Standard_Integer Signature = -1,
118 const Standard_Integer MaxPick = 5);
120 Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
122 Standard_EXPORT static void AviCommands (Draw_Interpretor& theCommands);
124 Standard_EXPORT static void ViewerCommands (Draw_Interpretor& theCommands);
126 Standard_EXPORT static void MyCommands (Draw_Interpretor& theCommands);
128 Standard_EXPORT static void RelationCommands (Draw_Interpretor& theCommands);
130 Standard_EXPORT static void ObjectCommands (Draw_Interpretor& theCommands);
132 Standard_EXPORT static void FilletCommands (Draw_Interpretor& theCommands);
134 Standard_EXPORT static void VoxelCommands (Draw_Interpretor& theCommands);
136 Standard_EXPORT static void OpenGlCommands (Draw_Interpretor& theCommands);
138 Standard_EXPORT static void GetMousePosition (Standard_Integer& xpix, Standard_Integer& ypix);
140 Standard_EXPORT static Handle(V3d_Viewer) GetViewerFromContext();
142 Standard_EXPORT static Handle(V3d_Viewer) GetCollectorFromContext();
144 Standard_EXPORT static const Handle(AIS_InteractiveContext)& GetAISContext();
146 Standard_EXPORT static NIS_InteractiveContext& GetNISContext();
148 Standard_EXPORT static void SetAISContext (const Handle(AIS_InteractiveContext)& aContext);
150 Standard_EXPORT static void SetNISContext (const NIS_InteractiveContext& aContext);
152 Standard_EXPORT static const Handle(V3d_View)& CurrentView();
154 Standard_EXPORT static void CurrentView (const Handle(V3d_View)& aViou);
156 Standard_EXPORT static void Clear();
158 //! puts theMgr as current eventmanager (the move,select,...will be applied to theMgr)
159 Standard_EXPORT static void SetEventManager (const Handle(ViewerTest_EventManager)& theMgr);
161 //! removes the last EventManager from the list.
162 Standard_EXPORT static void UnsetEventManager();
164 //! clear the list of EventManagers and
165 //! sets the default EventManager as current
166 Standard_EXPORT static void ResetEventManager();
168 Standard_EXPORT static Handle(ViewerTest_EventManager) CurrentEventManager();
170 Standard_EXPORT static void RemoveSelected();
172 Standard_EXPORT static void StandardModeActivation (const Standard_Integer Mode);
174 Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name);
176 //! Parses color argument(s) specified within theArgVec[0], theArgVec[1] and theArgVec[2].
177 //! Handles either color specified by name (single argument)
178 //! or by RGB components (3 arguments) in range 0..1.
179 //! The result is stored in theColor on success.
180 //! Returns number of handled arguments (1 or 3) or 0 on syntax error.
181 Standard_EXPORT static Standard_Integer ParseColor (Standard_Integer theArgNb,
182 const char** theArgVec,
183 Quantity_Color& theColor);
185 //! redraws all defined views.
186 Standard_EXPORT static void RedrawAllViews();
188 //! Splits "parameter=value" string into separate
189 //! parameter and value strings.
190 //! @return TRUE if the string matches pattern "<string>=<empty or string>"
191 Standard_EXPORT static Standard_Boolean SplitParameter (const TCollection_AsciiString& theString,
192 TCollection_AsciiString& theName,
193 TCollection_AsciiString& theValue);
197 //! Returns a window class that implements standard behavior of
198 //! all windows of the ViewerTest. This includes usual Open CASCADE
199 //! view conventions for mouse buttons (e.g. Ctrl+MB1 for zoom,
200 //! Ctrl+MB2 for pan, etc) and keyboard shortcuts.
201 //! This method is relevant for MS Windows only and respectively
202 //! returns WNT_WClass handle.
203 Standard_EXPORT static const Handle(MMgt_TShared)& WClass();
205 friend class ViewerTest_EventManager;
206 friend class ViewerTest_DoubleMapOfInteractiveAndName;
207 friend class ViewerTest_DoubleMapNodeOfDoubleMapOfInteractiveAndName;
208 friend class ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName;
212 #endif // _ViewerTest_HeaderFile