0030537: Visualization - wrapping text in font text formatter
[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
33cc703b 18#include <AIS_KindOfInteractive.hxx>
19#include <Aspect_TypeOfLine.hxx>
20#include <Aspect_TypeOfMarker.hxx>
536d98e2 21#include <Draw_Interpretor.hxx>
dc89236f 22#include <Graphic3d_TypeOfShadingModel.hxx>
55c8f0f7 23#include <Graphic3d_ZLayerId.hxx>
9e04ccdc 24#include <TCollection_AsciiString.hxx>
b7c077b9 25#include <TColStd_HArray1OfTransient.hxx>
33cc703b 26#include <TopTools_ListOfShape.hxx>
27#include <TopTools_HArray1OfShape.hxx>
2a332745 28#include <Quantity_ColorRGBA.hxx>
3a4a3962 29
33cc703b 30class AIS_InteractiveContext;
31class AIS_InteractiveObject;
33cc703b 32class Image_PixMap;
33class V3d_View;
536d98e2 34class V3d_Viewer;
536d98e2 35class ViewerTest_EventManager;
33cc703b 36class TopoDS_Shape;
1bd04b5a 37class WNT_WClass;
536d98e2 38
39class ViewerTest
40{
41public:
42
43 DEFINE_STANDARD_ALLOC
44
45 //! Loads all Draw commands of V2d & V3d. Used for plugin.
46 Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
47
48 //! Creates view with default or custom name
9e04ccdc 49 //! and adds this name in map to manage multiple views.
50 //! Implemented in ViewerTest_ViewerCommands.cxx.
51 //! @param thePxLeft left position of newly created window
52 //! @param thePxTop top position of newly created window
53 //! @param thePxWidth width of newly created window
54 //! @param thePxHeight height of newly created window
55 //! @param theViewName name of newly created View
56 //! @oaram theDisplayName display name
57 //! @param theViewToClone when specified, the new View will copy properties of existing one
536d98e2 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,
9e04ccdc 62 const TCollection_AsciiString& theViewName = "",
63 const TCollection_AsciiString& theDisplayName = "",
64 const Handle(V3d_View)& theViewToClone = Handle(V3d_View)());
536d98e2 65
66 Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName);
67
68 Standard_EXPORT static void InitViewName (const TCollection_AsciiString& theName,
69 const Handle(V3d_View)& theView);
70
71 Standard_EXPORT static TCollection_AsciiString GetCurrentViewName();
72
73 //! Removes view and clear all maps
74 //! with information about its resources if necessary
75 Standard_EXPORT static void RemoveView (const TCollection_AsciiString& theViewName,
76 const Standard_Boolean theToRemoveContext = Standard_True);
77
78 //! Removes view and clear all maps
79 //! with information about its resources if necessary
80 Standard_EXPORT static void RemoveView (const Handle(V3d_View)& theView,
81 const Standard_Boolean theToRemoveContext = Standard_True);
82
29e2c6d2 83 //! Display AIS object in active Viewer and register it in the map of Interactive Objects with specified name.
84 //! @param theName key to be associated to displayed interactive object
85 //! @param theObject object to display
86 //! @param theToUpdate redraw viewer after displaying object
87 //! @param theReplaceIfExists replace the object assigned to specified key
88 //! @return true if new object has been displayed
89 Standard_EXPORT static Standard_Boolean Display (const TCollection_AsciiString& theName,
90 const Handle(AIS_InteractiveObject)& theObject,
91 const Standard_Boolean theToUpdate = Standard_True,
92 const Standard_Boolean theReplaceIfExists = Standard_True);
93
536d98e2 94 //! waits until a shape of type <aType> is picked in the AIS Viewer and returns it.
95 //! if <aType> == TopAbs_Shape, any shape can be picked...
96 //! MaxPick is the Max number before exiting, if no pick is successful
97 Standard_EXPORT static TopoDS_Shape PickShape (const TopAbs_ShapeEnum aType,
98 const Standard_Integer MaxPick = 5);
99
100 //! wait until the array is filled with picked shapes.
101 //! returns True if the array is filled.
102 //! exit if number of unsuccessful picks = <MaxPick>
103 Standard_EXPORT static Standard_Boolean PickShapes (const TopAbs_ShapeEnum aType,
104 Handle(TopTools_HArray1OfShape)& thepicked,
105 const Standard_Integer MaxPick = 5);
106
536d98e2 107 Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
108
536d98e2 109 Standard_EXPORT static void ViewerCommands (Draw_Interpretor& theCommands);
110
111 Standard_EXPORT static void MyCommands (Draw_Interpretor& theCommands);
112
113 Standard_EXPORT static void RelationCommands (Draw_Interpretor& theCommands);
114
115 Standard_EXPORT static void ObjectCommands (Draw_Interpretor& theCommands);
116
117 Standard_EXPORT static void FilletCommands (Draw_Interpretor& theCommands);
118
536d98e2 119 Standard_EXPORT static void OpenGlCommands (Draw_Interpretor& theCommands);
120
121 Standard_EXPORT static void GetMousePosition (Standard_Integer& xpix, Standard_Integer& ypix);
122
123 Standard_EXPORT static Handle(V3d_Viewer) GetViewerFromContext();
124
125 Standard_EXPORT static Handle(V3d_Viewer) GetCollectorFromContext();
126
127 Standard_EXPORT static const Handle(AIS_InteractiveContext)& GetAISContext();
128
536d98e2 129 Standard_EXPORT static void SetAISContext (const Handle(AIS_InteractiveContext)& aContext);
130
536d98e2 131 Standard_EXPORT static const Handle(V3d_View)& CurrentView();
132
133 Standard_EXPORT static void CurrentView (const Handle(V3d_View)& aViou);
134
135 Standard_EXPORT static void Clear();
136
137 //! puts theMgr as current eventmanager (the move,select,...will be applied to theMgr)
138 Standard_EXPORT static void SetEventManager (const Handle(ViewerTest_EventManager)& theMgr);
139
140 //! removes the last EventManager from the list.
141 Standard_EXPORT static void UnsetEventManager();
142
143 //! clear the list of EventManagers and
144 //! sets the default EventManager as current
145 Standard_EXPORT static void ResetEventManager();
146
147 Standard_EXPORT static Handle(ViewerTest_EventManager) CurrentEventManager();
148
149 Standard_EXPORT static void RemoveSelected();
150
536d98e2 151 //! redraws all defined views.
152 Standard_EXPORT static void RedrawAllViews();
153
154 //! Splits "parameter=value" string into separate
155 //! parameter and value strings.
156 //! @return TRUE if the string matches pattern "<string>=<empty or string>"
157 Standard_EXPORT static Standard_Boolean SplitParameter (const TCollection_AsciiString& theString,
158 TCollection_AsciiString& theName,
159 TCollection_AsciiString& theValue);
160
404c8936 161 //! Returns list of selected shapes.
162 Standard_EXPORT static void GetSelectedShapes (TopTools_ListOfShape& theShapes);
163
3a4a3962 164 //! Parses line type argument.
165 //! Handles either enumeration (integer) value or string constant.
3f1675c9 166 Standard_EXPORT static Standard_Boolean ParseLineType (Standard_CString theArg,
167 Aspect_TypeOfLine& theType,
168 uint16_t& thePattern);
169
170 //! Parses line type argument.
171 //! Handles either enumeration (integer) value or string constant.
172 static Standard_Boolean ParseLineType (Standard_CString theArg,
173 Aspect_TypeOfLine& theType)
174 {
175 uint16_t aPattern = 0xFFFF;
176 return ParseLineType (theArg, theType, aPattern);
177 }
3a4a3962 178
33cc703b 179 //! Parses marker type argument.
180 //! Handles either enumeration (integer) value or string constant.
181 Standard_EXPORT static Standard_Boolean ParseMarkerType (Standard_CString theArg,
182 Aspect_TypeOfMarker& theType,
183 Handle(Image_PixMap)& theImage);
184
dc89236f 185 //! Parses shading model argument.
186 //! Handles either enumeration (integer) value or string constant.
187 Standard_EXPORT static Standard_Boolean ParseShadingModel (Standard_CString theArg,
188 Graphic3d_TypeOfShadingModel& theModel);
189
55c8f0f7
BB
190 //! Parses ZLayer name.
191 //! @param theArg [in] layer name or enumeration alias
192 //! @param theLayer [out] layer index
193 //! @return TRUE if layer has been identified, note that Graphic3d_ZLayerId_UNKNOWN is also valid value
194 static Standard_Boolean ParseZLayerName (Standard_CString theArg,
195 Graphic3d_ZLayerId& theLayer)
196 {
197 return parseZLayer (theArg, false, theLayer);
198 }
199
200 //! Parses ZLayer name.
201 //! @param theArg [in] layer name, enumeration alias or index (of existing Layer)
202 //! @param theLayer [out] layer index
203 //! @return TRUE if layer has been identified, note that Graphic3d_ZLayerId_UNKNOWN is also valid value
204 static Standard_Boolean ParseZLayer (Standard_CString theArg,
205 Graphic3d_ZLayerId& theLayer)
206 {
207 return parseZLayer (theArg, true, theLayer);
208 }
209
dae2a922 210public: //! @name deprecated methods
536d98e2 211
2a332745 212 //! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3].
dae2a922 213 Standard_DEPRECATED("Method has been moved to Draw::ParseColor()")
214 Standard_EXPORT static Standard_Integer ParseColor (const Standard_Integer theArgNb,
215 const char* const* const theArgVec,
216 Quantity_ColorRGBA& theColor);
217
218 //! Parses RGB color argument(s).
219 //! Returns number of handled arguments (1 or 3) or 0 on syntax error.
220 Standard_DEPRECATED("Method has been moved to Draw::ParseColor()")
221 Standard_EXPORT static Standard_Integer ParseColor (const Standard_Integer theArgNb,
222 const char* const* const theArgVec,
223 Quantity_Color& theColor);
224
225 //! Parses boolean argument.
226 //! Handles either flag specified by 0|1 or on|off.
227 Standard_DEPRECATED("Method has been moved to Draw::ParseOnOff()")
228 Standard_EXPORT static Standard_Boolean ParseOnOff (Standard_CString theArg,
229 Standard_Boolean& theIsOn);
230
231 Standard_DEPRECATED("Method has been moved to Quantity_Color::ColorFromName()")
232 Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name);
233
234private:
2a332745 235
55c8f0f7
BB
236 //! Parses ZLayer name.
237 //! @param theArg [in] layer name, enumeration alias or index (of existing Layer)
238 //! @param theToAllowInteger [in] when TRUE, the argument will be checked for existing layer index
239 //! @param theLayer [out] layer index
240 //! @return TRUE if layer has been identified, note that Graphic3d_ZLayerId_UNKNOWN is also valid value
241 Standard_EXPORT static Standard_Boolean parseZLayer (Standard_CString theArg,
242 Standard_Boolean theToAllowInteger,
243 Graphic3d_ZLayerId& theLayer);
244
536d98e2 245 //! Returns a window class that implements standard behavior of
246 //! all windows of the ViewerTest. This includes usual Open CASCADE
247 //! view conventions for mouse buttons (e.g. Ctrl+MB1 for zoom,
248 //! Ctrl+MB2 for pan, etc) and keyboard shortcuts.
249 //! This method is relevant for MS Windows only and respectively
250 //! returns WNT_WClass handle.
1bd04b5a 251 static const Handle(WNT_WClass)& WClass();
536d98e2 252};
253
254#endif // _ViewerTest_HeaderFile