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 <Standard_Boolean.hxx>
26 #include <TopAbs_ShapeEnum.hxx>
27 #include <TopTools_HArray1OfShape.hxx>
28 #include <AIS_KindOfInteractive.hxx>
29 #include <TColStd_HArray1OfTransient.hxx>
30 #include <Quantity_NameOfColor.hxx>
32 class TCollection_AsciiString;
36 class AIS_InteractiveObject;
38 class AIS_InteractiveContext;
39 class ViewerTest_EventManager;
40 class ViewerTest_EventManager;
49 //! Loads all Draw commands of V2d & V3d. Used for plugin.
50 Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
52 //! Creates view with default or custom name
53 //! and add this name in map to manage muliple views
54 //! implemented in ViewerTest_ViewerCommands.cxx
55 Standard_EXPORT static TCollection_AsciiString ViewerInit (const Standard_Integer thePxLeft = 0,
56 const Standard_Integer thePxTop = 0,
57 const Standard_Integer thePxWidth = 0,
58 const Standard_Integer thePxHeight = 0,
59 const Standard_CString theViewName = "",
60 const Standard_CString theDisplayName = "");
62 Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName);
64 Standard_EXPORT static void InitViewName (const TCollection_AsciiString& theName,
65 const Handle(V3d_View)& theView);
67 Standard_EXPORT static TCollection_AsciiString GetCurrentViewName();
69 //! Removes view and clear all maps
70 //! with information about its resources if necessary
71 Standard_EXPORT static void RemoveView (const TCollection_AsciiString& theViewName,
72 const Standard_Boolean theToRemoveContext = Standard_True);
74 //! Removes view and clear all maps
75 //! with information about its resources if necessary
76 Standard_EXPORT static void RemoveView (const Handle(V3d_View)& theView,
77 const Standard_Boolean theToRemoveContext = Standard_True);
79 //! Display AIS object in active Viewer and register it in the map of Interactive Objects with specified name.
80 //! @param theName key to be associated to displayed interactive object
81 //! @param theObject object to display
82 //! @param theToUpdate redraw viewer after displaying object
83 //! @param theReplaceIfExists replace the object assigned to specified key
84 //! @return true if new object has been displayed
85 Standard_EXPORT static Standard_Boolean Display (const TCollection_AsciiString& theName,
86 const Handle(AIS_InteractiveObject)& theObject,
87 const Standard_Boolean theToUpdate = Standard_True,
88 const Standard_Boolean theReplaceIfExists = Standard_True);
90 //! waits until a shape of type <aType> is picked in the AIS Viewer and returns it.
91 //! if <aType> == TopAbs_Shape, any shape can be picked...
92 //! MaxPick is the Max number before exiting, if no pick is successful
93 Standard_EXPORT static TopoDS_Shape PickShape (const TopAbs_ShapeEnum aType,
94 const Standard_Integer MaxPick = 5);
96 //! wait until the array is filled with picked shapes.
97 //! returns True if the array is filled.
98 //! exit if number of unsuccessful picks = <MaxPick>
99 Standard_EXPORT static Standard_Boolean PickShapes (const TopAbs_ShapeEnum aType,
100 Handle(TopTools_HArray1OfShape)& thepicked,
101 const Standard_Integer MaxPick = 5);
103 //! waits until an interactive object of a given Type
104 //! and signature is picked (default values authorize
105 //! selection of any Interactive Object)
106 //! exit if number of unsuccessful picks = <MaxPick>
107 Standard_EXPORT static Handle(AIS_InteractiveObject) PickObject (const AIS_KindOfInteractive Type = AIS_KOI_None,
108 const Standard_Integer Signature = -1,
109 const Standard_Integer MaxPick = 5);
111 //! selection of several interactive objects.
112 //! Number is given by the size of <thepicked>
113 //! exit if number of unsuccesfull picks = <MaxPick>
114 Standard_EXPORT static Standard_Boolean PickObjects (Handle(TColStd_HArray1OfTransient)& thepicked,
115 const AIS_KindOfInteractive Type = AIS_KOI_None,
116 const Standard_Integer Signature = -1,
117 const Standard_Integer MaxPick = 5);
119 Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
121 Standard_EXPORT static void ViewerCommands (Draw_Interpretor& theCommands);
123 Standard_EXPORT static void MyCommands (Draw_Interpretor& theCommands);
125 Standard_EXPORT static void RelationCommands (Draw_Interpretor& theCommands);
127 Standard_EXPORT static void ObjectCommands (Draw_Interpretor& theCommands);
129 Standard_EXPORT static void FilletCommands (Draw_Interpretor& theCommands);
131 Standard_EXPORT static void OpenGlCommands (Draw_Interpretor& theCommands);
133 Standard_EXPORT static void GetMousePosition (Standard_Integer& xpix, Standard_Integer& ypix);
135 Standard_EXPORT static Handle(V3d_Viewer) GetViewerFromContext();
137 Standard_EXPORT static Handle(V3d_Viewer) GetCollectorFromContext();
139 Standard_EXPORT static const Handle(AIS_InteractiveContext)& GetAISContext();
141 Standard_EXPORT static void SetAISContext (const Handle(AIS_InteractiveContext)& aContext);
143 Standard_EXPORT static const Handle(V3d_View)& CurrentView();
145 Standard_EXPORT static void CurrentView (const Handle(V3d_View)& aViou);
147 Standard_EXPORT static void Clear();
149 //! puts theMgr as current eventmanager (the move,select,...will be applied to theMgr)
150 Standard_EXPORT static void SetEventManager (const Handle(ViewerTest_EventManager)& theMgr);
152 //! removes the last EventManager from the list.
153 Standard_EXPORT static void UnsetEventManager();
155 //! clear the list of EventManagers and
156 //! sets the default EventManager as current
157 Standard_EXPORT static void ResetEventManager();
159 Standard_EXPORT static Handle(ViewerTest_EventManager) CurrentEventManager();
161 Standard_EXPORT static void RemoveSelected();
163 Standard_EXPORT static void StandardModeActivation (const Standard_Integer Mode);
165 Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name);
167 //! Parses color argument(s) specified within theArgVec[0], theArgVec[1] and theArgVec[2].
168 //! Handles either color specified by name (single argument)
169 //! or by RGB components (3 arguments) in range 0..1.
170 //! The result is stored in theColor on success.
171 //! Returns number of handled arguments (1 or 3) or 0 on syntax error.
172 Standard_EXPORT static Standard_Integer ParseColor (Standard_Integer theArgNb,
173 const char** theArgVec,
174 Quantity_Color& theColor);
176 //! redraws all defined views.
177 Standard_EXPORT static void RedrawAllViews();
179 //! Splits "parameter=value" string into separate
180 //! parameter and value strings.
181 //! @return TRUE if the string matches pattern "<string>=<empty or string>"
182 Standard_EXPORT static Standard_Boolean SplitParameter (const TCollection_AsciiString& theString,
183 TCollection_AsciiString& theName,
184 TCollection_AsciiString& theValue);
186 //! Parses boolean argument.
187 //! Handles either flag specified by 0|1 or on|off.
188 Standard_EXPORT static Standard_Boolean ParseOnOff (Standard_CString theArg,
189 Standard_Boolean& theIsOn);
192 //! Returns a window class that implements standard behavior of
193 //! all windows of the ViewerTest. This includes usual Open CASCADE
194 //! view conventions for mouse buttons (e.g. Ctrl+MB1 for zoom,
195 //! Ctrl+MB2 for pan, etc) and keyboard shortcuts.
196 //! This method is relevant for MS Windows only and respectively
197 //! returns WNT_WClass handle.
198 Standard_EXPORT static const Handle(MMgt_TShared)& WClass();
201 #endif // _ViewerTest_HeaderFile