0022785: Draw Harness - add possibility to remove a text drawn by the command vdrawtext
[occt.git] / src / ViewerTest / ViewerTest.hxx
CommitLineData
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>
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>
38
39class TCollection_AsciiString;
40class V3d_View;
41class MMgt_TShared;
42class TopoDS_Shape;
43class TopTools_HArray1OfShape;
44class AIS_InteractiveObject;
45class TColStd_HArray1OfTransient;
46class V3d_Viewer;
47class AIS_InteractiveContext;
48class ViewerTest_EventManager;
49class ViewerTest_EventManager;
50class ViewerTest_DoubleMapOfInteractiveAndName;
51class ViewerTest_DoubleMapNodeOfDoubleMapOfInteractiveAndName;
52class ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName;
53class Quantity_Color;
54
55class ViewerTest
56{
57public:
58
59 DEFINE_STANDARD_ALLOC
60
61 //! Loads all Draw commands of V2d & V3d. Used for plugin.
62 Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
63
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 = "");
73
74 Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName);
75
76 Standard_EXPORT static void InitViewName (const TCollection_AsciiString& theName,
77 const Handle(V3d_View)& theView);
78
79 Standard_EXPORT static TCollection_AsciiString GetCurrentViewName();
80
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);
85
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);
90
29e2c6d2 91 //! Display AIS object in active Viewer and register it in the map of Interactive Objects with specified name.
92 //! @param theName key to be associated to displayed interactive object
93 //! @param theObject object to display
94 //! @param theToUpdate redraw viewer after displaying object
95 //! @param theReplaceIfExists replace the object assigned to specified key
96 //! @return true if new object has been displayed
97 Standard_EXPORT static Standard_Boolean Display (const TCollection_AsciiString& theName,
98 const Handle(AIS_InteractiveObject)& theObject,
99 const Standard_Boolean theToUpdate = Standard_True,
100 const Standard_Boolean theReplaceIfExists = Standard_True);
101
536d98e2 102 //! waits until a shape of type <aType> is picked in the AIS Viewer and returns it.
103 //! if <aType> == TopAbs_Shape, any shape can be picked...
104 //! MaxPick is the Max number before exiting, if no pick is successful
105 Standard_EXPORT static TopoDS_Shape PickShape (const TopAbs_ShapeEnum aType,
106 const Standard_Integer MaxPick = 5);
107
108 //! wait until the array is filled with picked shapes.
109 //! returns True if the array is filled.
110 //! exit if number of unsuccessful picks = <MaxPick>
111 Standard_EXPORT static Standard_Boolean PickShapes (const TopAbs_ShapeEnum aType,
112 Handle(TopTools_HArray1OfShape)& thepicked,
113 const Standard_Integer MaxPick = 5);
114
115 //! waits until an interactive object of a given Type
116 //! and signature is picked (default values authorize
117 //! selection of any Interactive Object)
118 //! exit if number of unsuccessful picks = <MaxPick>
119 Standard_EXPORT static Handle(AIS_InteractiveObject) PickObject (const AIS_KindOfInteractive Type = AIS_KOI_None,
120 const Standard_Integer Signature = -1,
121 const Standard_Integer MaxPick = 5);
122
123 //! selection of several interactive objects.
124 //! Number is given by the size of <thepicked>
125 //! exit if number of unsuccesfull picks = <MaxPick>
126 Standard_EXPORT static Standard_Boolean PickObjects (Handle(TColStd_HArray1OfTransient)& thepicked,
127 const AIS_KindOfInteractive Type = AIS_KOI_None,
128 const Standard_Integer Signature = -1,
129 const Standard_Integer MaxPick = 5);
130
131 Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
132
133 Standard_EXPORT static void AviCommands (Draw_Interpretor& theCommands);
134
135 Standard_EXPORT static void ViewerCommands (Draw_Interpretor& theCommands);
136
137 Standard_EXPORT static void MyCommands (Draw_Interpretor& theCommands);
138
139 Standard_EXPORT static void RelationCommands (Draw_Interpretor& theCommands);
140
141 Standard_EXPORT static void ObjectCommands (Draw_Interpretor& theCommands);
142
143 Standard_EXPORT static void FilletCommands (Draw_Interpretor& theCommands);
144
145 Standard_EXPORT static void VoxelCommands (Draw_Interpretor& theCommands);
146
147 Standard_EXPORT static void OpenGlCommands (Draw_Interpretor& theCommands);
148
149 Standard_EXPORT static void GetMousePosition (Standard_Integer& xpix, Standard_Integer& ypix);
150
151 Standard_EXPORT static Handle(V3d_Viewer) GetViewerFromContext();
152
153 Standard_EXPORT static Handle(V3d_Viewer) GetCollectorFromContext();
154
155 Standard_EXPORT static const Handle(AIS_InteractiveContext)& GetAISContext();
156
157 Standard_EXPORT static NIS_InteractiveContext& GetNISContext();
158
159 Standard_EXPORT static void SetAISContext (const Handle(AIS_InteractiveContext)& aContext);
160
161 Standard_EXPORT static void SetNISContext (const NIS_InteractiveContext& aContext);
162
163 Standard_EXPORT static const Handle(V3d_View)& CurrentView();
164
165 Standard_EXPORT static void CurrentView (const Handle(V3d_View)& aViou);
166
167 Standard_EXPORT static void Clear();
168
169 //! puts theMgr as current eventmanager (the move,select,...will be applied to theMgr)
170 Standard_EXPORT static void SetEventManager (const Handle(ViewerTest_EventManager)& theMgr);
171
172 //! removes the last EventManager from the list.
173 Standard_EXPORT static void UnsetEventManager();
174
175 //! clear the list of EventManagers and
176 //! sets the default EventManager as current
177 Standard_EXPORT static void ResetEventManager();
178
179 Standard_EXPORT static Handle(ViewerTest_EventManager) CurrentEventManager();
180
181 Standard_EXPORT static void RemoveSelected();
182
183 Standard_EXPORT static void StandardModeActivation (const Standard_Integer Mode);
184
185 Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name);
186
187 //! Parses color argument(s) specified within theArgVec[0], theArgVec[1] and theArgVec[2].
188 //! Handles either color specified by name (single argument)
189 //! or by RGB components (3 arguments) in range 0..1.
190 //! The result is stored in theColor on success.
191 //! Returns number of handled arguments (1 or 3) or 0 on syntax error.
192 Standard_EXPORT static Standard_Integer ParseColor (Standard_Integer theArgNb,
193 const char** theArgVec,
194 Quantity_Color& theColor);
195
196 //! redraws all defined views.
197 Standard_EXPORT static void RedrawAllViews();
198
199 //! Splits "parameter=value" string into separate
200 //! parameter and value strings.
201 //! @return TRUE if the string matches pattern "<string>=<empty or string>"
202 Standard_EXPORT static Standard_Boolean SplitParameter (const TCollection_AsciiString& theString,
203 TCollection_AsciiString& theName,
204 TCollection_AsciiString& theValue);
205
206private:
207
208 //! Returns a window class that implements standard behavior of
209 //! all windows of the ViewerTest. This includes usual Open CASCADE
210 //! view conventions for mouse buttons (e.g. Ctrl+MB1 for zoom,
211 //! Ctrl+MB2 for pan, etc) and keyboard shortcuts.
212 //! This method is relevant for MS Windows only and respectively
213 //! returns WNT_WClass handle.
214 Standard_EXPORT static const Handle(MMgt_TShared)& WClass();
215
216friend class ViewerTest_EventManager;
217friend class ViewerTest_DoubleMapOfInteractiveAndName;
218friend class ViewerTest_DoubleMapNodeOfDoubleMapOfInteractiveAndName;
219friend class ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName;
220
221};
222
223#endif // _ViewerTest_HeaderFile