0030523: Visualization - Highlighting does not work anymore
[occt.git] / src / ViewerTest / ViewerTest.hxx
index 1e16d9a..a4d1165 100644 (file)
 #ifndef _ViewerTest_HeaderFile
 #define _ViewerTest_HeaderFile
 
 #ifndef _ViewerTest_HeaderFile
 #define _ViewerTest_HeaderFile
 
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Macro.hxx>
-
-#include <Draw_Interpretor.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_CString.hxx>
-#include <Standard_Boolean.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-#include <TopTools_HArray1OfShape.hxx>
-#include <TopTools_ListOfShape.hxx>
 #include <AIS_KindOfInteractive.hxx>
 #include <Aspect_TypeOfLine.hxx>
 #include <AIS_KindOfInteractive.hxx>
 #include <Aspect_TypeOfLine.hxx>
+#include <Aspect_TypeOfMarker.hxx>
+#include <Draw_Interpretor.hxx>
+#include <Graphic3d_TypeOfShadingModel.hxx>
+#include <Graphic3d_ZLayerId.hxx>
+#include <TCollection_AsciiString.hxx>
 #include <TColStd_HArray1OfTransient.hxx>
 #include <TColStd_HArray1OfTransient.hxx>
-#include <Quantity_NameOfColor.hxx>
-
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_HArray1OfShape.hxx>
+#include <Quantity_ColorRGBA.hxx>
 
 
-class TCollection_AsciiString;
-class V3d_View;
-class MMgt_TShared;
-class TopoDS_Shape;
+class AIS_InteractiveContext;
 class AIS_InteractiveObject;
 class AIS_InteractiveObject;
+class Image_PixMap;
+class V3d_View;
 class V3d_Viewer;
 class V3d_Viewer;
-class AIS_InteractiveContext;
 class ViewerTest_EventManager;
 class ViewerTest_EventManager;
-class ViewerTest_EventManager;
-class Quantity_Color;
+class TopoDS_Shape;
 
 class ViewerTest
 {
 
 class ViewerTest
 {
@@ -53,14 +45,22 @@ public:
   Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
 
   //! Creates view with default or custom name
   Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
 
   //! Creates view with default or custom name
-  //! and add this name in map to manage muliple views
-  //! implemented in ViewerTest_ViewerCommands.cxx
+  //! and adds this name in map to manage multiple views.
+  //! Implemented in ViewerTest_ViewerCommands.cxx.
+  //! @param thePxLeft      left position of newly created window
+  //! @param thePxTop       top  position of newly created window
+  //! @param thePxWidth     width of newly created window
+  //! @param thePxHeight    height of newly created window
+  //! @param theViewName    name of newly created View
+  //! @oaram theDisplayName display name
+  //! @param theViewToClone when specified, the new View will copy properties of existing one
   Standard_EXPORT static TCollection_AsciiString ViewerInit (const Standard_Integer thePxLeft   = 0,
                                                              const Standard_Integer thePxTop    = 0,
                                                              const Standard_Integer thePxWidth  = 0,
                                                              const Standard_Integer thePxHeight = 0,
   Standard_EXPORT static TCollection_AsciiString ViewerInit (const Standard_Integer thePxLeft   = 0,
                                                              const Standard_Integer thePxTop    = 0,
                                                              const Standard_Integer thePxWidth  = 0,
                                                              const Standard_Integer thePxHeight = 0,
-                                                             const Standard_CString theViewName = "",
-                                                             const Standard_CString theDisplayName = "");
+                                                             const TCollection_AsciiString& theViewName = "",
+                                                             const TCollection_AsciiString& theDisplayName = "",
+                                                             const Handle(V3d_View)& theViewToClone = Handle(V3d_View)());
 
   Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName);
 
 
   Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName);
 
@@ -103,22 +103,6 @@ public:
                                                       Handle(TopTools_HArray1OfShape)& thepicked,
                                                       const Standard_Integer           MaxPick = 5);
 
                                                       Handle(TopTools_HArray1OfShape)& thepicked,
                                                       const Standard_Integer           MaxPick = 5);
 
-  //! waits until an interactive object of a given Type
-  //! and signature is picked (default values authorize
-  //! selection of any Interactive Object)
-  //! exit if number of unsuccessful picks =  <MaxPick>
-  Standard_EXPORT static Handle(AIS_InteractiveObject) PickObject (const AIS_KindOfInteractive Type      = AIS_KOI_None,
-                                                                   const Standard_Integer      Signature = -1,
-                                                                   const Standard_Integer      MaxPick   = 5);
-
-  //! selection of several interactive objects.
-  //! Number is given by the size of <thepicked>
-  //! exit if number of unsuccesfull picks =  <MaxPick>
-  Standard_EXPORT static Standard_Boolean PickObjects (Handle(TColStd_HArray1OfTransient)& thepicked,
-                                                       const AIS_KindOfInteractive         Type = AIS_KOI_None,
-                                                       const Standard_Integer              Signature = -1,
-                                                       const Standard_Integer              MaxPick = 5);
-
   Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
 
   Standard_EXPORT static void ViewerCommands (Draw_Interpretor& theCommands);
   Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
 
   Standard_EXPORT static void ViewerCommands (Draw_Interpretor& theCommands);
@@ -163,18 +147,34 @@ public:
 
   Standard_EXPORT static void RemoveSelected();
 
 
   Standard_EXPORT static void RemoveSelected();
 
-  Standard_EXPORT static void StandardModeActivation (const Standard_Integer Mode);
-
   Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name);
 
   Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name);
 
-  //! Parses color argument(s) specified within theArgVec[0], theArgVec[1] and theArgVec[2].
+  //! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3].
   //! Handles either color specified by name (single argument)
   //! Handles either color specified by name (single argument)
-  //! or by RGB components (3 arguments) in range 0..1.
+  //! or by RGB(A) components (3-4 arguments) in range 0..1.
   //! The result is stored in theColor on success.
   //! The result is stored in theColor on success.
+  //! Returns number of handled arguments (1, 3 or 4) or 0 on syntax error.
+  static Standard_Integer ParseColor (Standard_Integer  theArgNb,
+                                      const char**      theArgVec,
+                                      Quantity_ColorRGBA& theColor)
+  {
+    return parseColor (theArgNb, theArgVec, theColor, true);
+  }
+
+  //! Parses RGB color argument(s).
   //! Returns number of handled arguments (1 or 3) or 0 on syntax error.
   //! Returns number of handled arguments (1 or 3) or 0 on syntax error.
-  Standard_EXPORT static Standard_Integer ParseColor (Standard_Integer theArgNb,
-                                                      const char**     theArgVec,
-                                                      Quantity_Color&  theColor);
+  static Standard_Integer ParseColor (Standard_Integer theArgNb,
+                                      const char**     theArgVec,
+                                      Quantity_Color&  theColor)
+  {
+    Quantity_ColorRGBA anRgba;
+    Standard_Integer aNbParsed = parseColor (theArgNb, theArgVec, anRgba, false);
+    if (aNbParsed != 0)
+    {
+      theColor = anRgba.GetRGB();
+    }
+    return aNbParsed;
+  }
 
   //! redraws all defined views.
   Standard_EXPORT static void RedrawAllViews();
 
   //! redraws all defined views.
   Standard_EXPORT static void RedrawAllViews();
@@ -194,21 +194,70 @@ public:
   //! Returns list of selected shapes.
   Standard_EXPORT static void GetSelectedShapes (TopTools_ListOfShape& theShapes);
 
   //! Returns list of selected shapes.
   Standard_EXPORT static void GetSelectedShapes (TopTools_ListOfShape& theShapes);
 
-
   //! Parses line type argument.
   //! Handles either enumeration (integer) value or string constant.
   Standard_EXPORT static Standard_Boolean ParseLineType (Standard_CString   theArg,
                                                          Aspect_TypeOfLine& theType);
 
   //! Parses line type argument.
   //! Handles either enumeration (integer) value or string constant.
   Standard_EXPORT static Standard_Boolean ParseLineType (Standard_CString   theArg,
                                                          Aspect_TypeOfLine& theType);
 
+  //! Parses marker type argument.
+  //! Handles either enumeration (integer) value or string constant.
+  Standard_EXPORT static Standard_Boolean ParseMarkerType (Standard_CString theArg,
+                                                           Aspect_TypeOfMarker& theType,
+                                                           Handle(Image_PixMap)& theImage);
+
+  //! Parses shading model argument.
+  //! Handles either enumeration (integer) value or string constant.
+  Standard_EXPORT static Standard_Boolean ParseShadingModel (Standard_CString              theArg,
+                                                             Graphic3d_TypeOfShadingModel& theModel);
+
+  //! Parses ZLayer name.
+  //! @param theArg [in] layer name or enumeration alias
+  //! @param theLayer [out] layer index
+  //! @return TRUE if layer has been identified, note that Graphic3d_ZLayerId_UNKNOWN is also valid value
+  static Standard_Boolean ParseZLayerName (Standard_CString theArg,
+                                           Graphic3d_ZLayerId& theLayer)
+  {
+    return parseZLayer (theArg, false, theLayer);
+  }
+
+  //! Parses ZLayer name.
+  //! @param theArg [in] layer name, enumeration alias or index (of existing Layer)
+  //! @param theLayer [out] layer index
+  //! @return TRUE if layer has been identified, note that Graphic3d_ZLayerId_UNKNOWN is also valid value
+  static Standard_Boolean ParseZLayer (Standard_CString theArg,
+                                       Graphic3d_ZLayerId& theLayer)
+  {
+    return parseZLayer (theArg, true, theLayer);
+  }
+
 private:
 
 private:
 
+  //! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3].
+  //! Handles either color specified by name (single argument)
+  //! or by RGB(A) components (3-4 arguments) in range 0..1.
+  //! The result is stored in theColor on success.
+  //! Returns number of handled arguments (1, 3 or 4) or 0 on syntax error.
+  Standard_EXPORT static Standard_Integer parseColor (Standard_Integer  theArgNb,
+                                                      const char**      theArgVec,
+                                                      Quantity_ColorRGBA& theColor,
+                                                      bool theToParseAlpha);
+
+  //! Parses ZLayer name.
+  //! @param theArg [in] layer name, enumeration alias or index (of existing Layer)
+  //! @param theToAllowInteger [in] when TRUE, the argument will be checked for existing layer index
+  //! @param theLayer [out] layer index
+  //! @return TRUE if layer has been identified, note that Graphic3d_ZLayerId_UNKNOWN is also valid value
+  Standard_EXPORT static Standard_Boolean parseZLayer (Standard_CString theArg,
+                                                       Standard_Boolean theToAllowInteger,
+                                                       Graphic3d_ZLayerId& theLayer);
+
   //! Returns a window class that implements standard behavior of
   //! all windows of the ViewerTest. This includes usual Open CASCADE
   //! view conventions for mouse buttons (e.g. Ctrl+MB1 for zoom,
   //! Ctrl+MB2 for pan, etc) and keyboard shortcuts.
   //! This method is relevant for MS Windows only and respectively
   //! returns WNT_WClass handle.
   //! Returns a window class that implements standard behavior of
   //! all windows of the ViewerTest. This includes usual Open CASCADE
   //! view conventions for mouse buttons (e.g. Ctrl+MB1 for zoom,
   //! Ctrl+MB2 for pan, etc) and keyboard shortcuts.
   //! This method is relevant for MS Windows only and respectively
   //! returns WNT_WClass handle.
-  Standard_EXPORT static const Handle(MMgt_TShared)& WClass();
+  static const Handle(Standard_Transient)& WClass();
 };
 
 #endif // _ViewerTest_HeaderFile
 };
 
 #endif // _ViewerTest_HeaderFile