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 <AIS_KindOfInteractive.hxx>
19 #include <Aspect_TypeOfLine.hxx>
20 #include <Aspect_TypeOfMarker.hxx>
21 #include <Draw_Interpretor.hxx>
22 #include <Standard_Integer.hxx>
23 #include <Standard_CString.hxx>
24 #include <Standard_DefineAlloc.hxx>
25 #include <Standard_Macro.hxx>
26 #include <TColStd_HArray1OfTransient.hxx>
27 #include <TopTools_ListOfShape.hxx>
28 #include <TopTools_HArray1OfShape.hxx>
29 #include <Quantity_Color.hxx>
31 class AIS_InteractiveContext;
32 class AIS_InteractiveObject;
33 class TCollection_AsciiString;
38 class ViewerTest_EventManager;
47 //! Loads all Draw commands of V2d & V3d. Used for plugin.
48 Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
50 //! Creates view with default or custom name
51 //! and add this name in map to manage muliple views
52 //! implemented in ViewerTest_ViewerCommands.cxx
53 Standard_EXPORT static TCollection_AsciiString ViewerInit (const Standard_Integer thePxLeft = 0,
54 const Standard_Integer thePxTop = 0,
55 const Standard_Integer thePxWidth = 0,
56 const Standard_Integer thePxHeight = 0,
57 const Standard_CString theViewName = "",
58 const Standard_CString theDisplayName = "");
60 Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName);
62 Standard_EXPORT static void InitViewName (const TCollection_AsciiString& theName,
63 const Handle(V3d_View)& theView);
65 Standard_EXPORT static TCollection_AsciiString GetCurrentViewName();
67 //! Removes view and clear all maps
68 //! with information about its resources if necessary
69 Standard_EXPORT static void RemoveView (const TCollection_AsciiString& theViewName,
70 const Standard_Boolean theToRemoveContext = Standard_True);
72 //! Removes view and clear all maps
73 //! with information about its resources if necessary
74 Standard_EXPORT static void RemoveView (const Handle(V3d_View)& theView,
75 const Standard_Boolean theToRemoveContext = Standard_True);
77 //! Display AIS object in active Viewer and register it in the map of Interactive Objects with specified name.
78 //! @param theName key to be associated to displayed interactive object
79 //! @param theObject object to display
80 //! @param theToUpdate redraw viewer after displaying object
81 //! @param theReplaceIfExists replace the object assigned to specified key
82 //! @return true if new object has been displayed
83 Standard_EXPORT static Standard_Boolean Display (const TCollection_AsciiString& theName,
84 const Handle(AIS_InteractiveObject)& theObject,
85 const Standard_Boolean theToUpdate = Standard_True,
86 const Standard_Boolean theReplaceIfExists = Standard_True);
88 //! waits until a shape of type <aType> is picked in the AIS Viewer and returns it.
89 //! if <aType> == TopAbs_Shape, any shape can be picked...
90 //! MaxPick is the Max number before exiting, if no pick is successful
91 Standard_EXPORT static TopoDS_Shape PickShape (const TopAbs_ShapeEnum aType,
92 const Standard_Integer MaxPick = 5);
94 //! wait until the array is filled with picked shapes.
95 //! returns True if the array is filled.
96 //! exit if number of unsuccessful picks = <MaxPick>
97 Standard_EXPORT static Standard_Boolean PickShapes (const TopAbs_ShapeEnum aType,
98 Handle(TopTools_HArray1OfShape)& thepicked,
99 const Standard_Integer MaxPick = 5);
101 //! waits until an interactive object of a given Type
102 //! and signature is picked (default values authorize
103 //! selection of any Interactive Object)
104 //! exit if number of unsuccessful picks = <MaxPick>
105 Standard_EXPORT static Handle(AIS_InteractiveObject) PickObject (const AIS_KindOfInteractive Type = AIS_KOI_None,
106 const Standard_Integer Signature = -1,
107 const Standard_Integer MaxPick = 5);
109 //! selection of several interactive objects.
110 //! Number is given by the size of <thepicked>
111 //! exit if number of unsuccesfull picks = <MaxPick>
112 Standard_EXPORT static Standard_Boolean PickObjects (Handle(TColStd_HArray1OfTransient)& thepicked,
113 const AIS_KindOfInteractive Type = AIS_KOI_None,
114 const Standard_Integer Signature = -1,
115 const Standard_Integer MaxPick = 5);
117 Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
119 Standard_EXPORT static void ViewerCommands (Draw_Interpretor& theCommands);
121 Standard_EXPORT static void MyCommands (Draw_Interpretor& theCommands);
123 Standard_EXPORT static void RelationCommands (Draw_Interpretor& theCommands);
125 Standard_EXPORT static void ObjectCommands (Draw_Interpretor& theCommands);
127 Standard_EXPORT static void FilletCommands (Draw_Interpretor& theCommands);
129 Standard_EXPORT static void OpenGlCommands (Draw_Interpretor& theCommands);
131 Standard_EXPORT static void GetMousePosition (Standard_Integer& xpix, Standard_Integer& ypix);
133 Standard_EXPORT static Handle(V3d_Viewer) GetViewerFromContext();
135 Standard_EXPORT static Handle(V3d_Viewer) GetCollectorFromContext();
137 Standard_EXPORT static const Handle(AIS_InteractiveContext)& GetAISContext();
139 Standard_EXPORT static void SetAISContext (const Handle(AIS_InteractiveContext)& aContext);
141 Standard_EXPORT static const Handle(V3d_View)& CurrentView();
143 Standard_EXPORT static void CurrentView (const Handle(V3d_View)& aViou);
145 Standard_EXPORT static void Clear();
147 //! puts theMgr as current eventmanager (the move,select,...will be applied to theMgr)
148 Standard_EXPORT static void SetEventManager (const Handle(ViewerTest_EventManager)& theMgr);
150 //! removes the last EventManager from the list.
151 Standard_EXPORT static void UnsetEventManager();
153 //! clear the list of EventManagers and
154 //! sets the default EventManager as current
155 Standard_EXPORT static void ResetEventManager();
157 Standard_EXPORT static Handle(ViewerTest_EventManager) CurrentEventManager();
159 Standard_EXPORT static void RemoveSelected();
161 Standard_EXPORT static void StandardModeActivation (const Standard_Integer Mode);
163 Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name);
165 //! Parses color argument(s) specified within theArgVec[0], theArgVec[1] and theArgVec[2].
166 //! Handles either color specified by name (single argument)
167 //! or by RGB components (3 arguments) in range 0..1.
168 //! The result is stored in theColor on success.
169 //! Returns number of handled arguments (1 or 3) or 0 on syntax error.
170 Standard_EXPORT static Standard_Integer ParseColor (Standard_Integer theArgNb,
171 const char** theArgVec,
172 Quantity_Color& theColor);
174 //! redraws all defined views.
175 Standard_EXPORT static void RedrawAllViews();
177 //! Splits "parameter=value" string into separate
178 //! parameter and value strings.
179 //! @return TRUE if the string matches pattern "<string>=<empty or string>"
180 Standard_EXPORT static Standard_Boolean SplitParameter (const TCollection_AsciiString& theString,
181 TCollection_AsciiString& theName,
182 TCollection_AsciiString& theValue);
184 //! Parses boolean argument.
185 //! Handles either flag specified by 0|1 or on|off.
186 Standard_EXPORT static Standard_Boolean ParseOnOff (Standard_CString theArg,
187 Standard_Boolean& theIsOn);
189 //! Returns list of selected shapes.
190 Standard_EXPORT static void GetSelectedShapes (TopTools_ListOfShape& theShapes);
192 //! Parses line type argument.
193 //! Handles either enumeration (integer) value or string constant.
194 Standard_EXPORT static Standard_Boolean ParseLineType (Standard_CString theArg,
195 Aspect_TypeOfLine& theType);
197 //! Parses marker type argument.
198 //! Handles either enumeration (integer) value or string constant.
199 Standard_EXPORT static Standard_Boolean ParseMarkerType (Standard_CString theArg,
200 Aspect_TypeOfMarker& theType,
201 Handle(Image_PixMap)& theImage);
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.
211 static const Handle(Standard_Transient)& WClass();
214 #endif // _ViewerTest_HeaderFile