0029076: Visualization - implement element shrinking Shader
[occt.git] / src / ViewerTest / ViewerTest.hxx
index 8e77511..2c5cdcd 100644 (file)
 #ifndef _ViewerTest_HeaderFile
 #define _ViewerTest_HeaderFile
 
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Macro.hxx>
-
+#include <AIS_KindOfInteractive.hxx>
+#include <Aspect_TypeOfLine.hxx>
+#include <Aspect_TypeOfMarker.hxx>
 #include <Draw_Interpretor.hxx>
+#include <Graphic3d_TypeOfShadingModel.hxx>
 #include <Standard_Integer.hxx>
 #include <Standard_CString.hxx>
-#include <Handle_V3d_View.hxx>
-#include <Standard_Boolean.hxx>
-#include <Handle_MMgt_TShared.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-#include <Handle_TopTools_HArray1OfShape.hxx>
-#include <Handle_AIS_InteractiveObject.hxx>
-#include <AIS_KindOfInteractive.hxx>
-#include <Handle_TColStd_HArray1OfTransient.hxx>
-#include <Handle_V3d_Viewer.hxx>
-#include <Handle_AIS_InteractiveContext.hxx>
-#include <NIS_InteractiveContext.hxx>
-#include <Handle_ViewerTest_EventManager.hxx>
-#include <Quantity_NameOfColor.hxx>
-
-class TCollection_AsciiString;
-class V3d_View;
-class MMgt_TShared;
-class TopoDS_Shape;
-class TopTools_HArray1OfShape;
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Macro.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TColStd_HArray1OfTransient.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_HArray1OfShape.hxx>
+#include <Quantity_ColorRGBA.hxx>
+
+class AIS_InteractiveContext;
 class AIS_InteractiveObject;
-class TColStd_HArray1OfTransient;
+class Image_PixMap;
+class V3d_View;
 class V3d_Viewer;
-class AIS_InteractiveContext;
-class ViewerTest_EventManager;
 class ViewerTest_EventManager;
-class ViewerTest_DoubleMapOfInteractiveAndName;
-class ViewerTest_DoubleMapNodeOfDoubleMapOfInteractiveAndName;
-class ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName;
-class Quantity_Color;
+class TopoDS_Shape;
 
 class ViewerTest
 {
@@ -62,14 +48,22 @@ public:
   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,
-                                                             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);
 
@@ -112,26 +106,8 @@ public:
                                                       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 AviCommands (Draw_Interpretor& theCommands);
-
   Standard_EXPORT static void ViewerCommands (Draw_Interpretor& theCommands);
 
   Standard_EXPORT static void MyCommands (Draw_Interpretor& theCommands);
@@ -142,8 +118,6 @@ public:
 
   Standard_EXPORT static void FilletCommands (Draw_Interpretor& theCommands);
 
-  Standard_EXPORT static void VoxelCommands (Draw_Interpretor& theCommands);
-
   Standard_EXPORT static void OpenGlCommands (Draw_Interpretor& theCommands);
 
   Standard_EXPORT static void GetMousePosition (Standard_Integer& xpix, Standard_Integer& ypix);
@@ -154,12 +128,8 @@ public:
 
   Standard_EXPORT static const Handle(AIS_InteractiveContext)& GetAISContext();
 
-  Standard_EXPORT static NIS_InteractiveContext& GetNISContext();
-
   Standard_EXPORT static void SetAISContext (const Handle(AIS_InteractiveContext)& aContext);
 
-  Standard_EXPORT static void SetNISContext (const NIS_InteractiveContext& aContext);
-
   Standard_EXPORT static const Handle(V3d_View)& CurrentView();
 
   Standard_EXPORT static void CurrentView (const Handle(V3d_View)& aViou);
@@ -180,18 +150,34 @@ public:
 
   Standard_EXPORT static void RemoveSelected();
 
-  Standard_EXPORT static void StandardModeActivation (const Standard_Integer Mode);
-
   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)
-  //! 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.
+  //! 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.
-  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();
@@ -203,21 +189,49 @@ public:
                                                           TCollection_AsciiString&       theName,
                                                           TCollection_AsciiString&       theValue);
 
+  //! Parses boolean argument.
+  //! Handles either flag specified by 0|1 or on|off.
+  Standard_EXPORT static Standard_Boolean ParseOnOff (Standard_CString  theArg,
+                                                      Standard_Boolean& theIsOn);
+
+  //! 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 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);
+
 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);
+
   //! 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();
-
-friend class ViewerTest_EventManager;
-friend class ViewerTest_DoubleMapOfInteractiveAndName;
-friend class ViewerTest_DoubleMapNodeOfDoubleMapOfInteractiveAndName;
-friend class ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName;
-
+  static const Handle(Standard_Transient)& WClass();
 };
 
 #endif // _ViewerTest_HeaderFile