0032886: Visualization, V3d_View - introduce interface for creating a subview
[occt.git] / src / V3d / V3d_View.hxx
index aa4159e..abea2dd 100644 (file)
@@ -76,7 +76,7 @@ DEFINE_STANDARD_HANDLE(V3d_View, Standard_Transient)
 //! View->Move(15.,-5.,0.,False)    (Next motion)
 class V3d_View : public Standard_Transient
 {
-
+  DEFINE_STANDARD_RTTIEXT(V3d_View, Standard_Transient)
 public:
 
   //! Initializes the view.
@@ -97,6 +97,25 @@ public:
   Standard_EXPORT void SetWindow (const Handle(Aspect_Window)& theWindow,
                                   const Aspect_RenderingContext theContext = NULL);
 
+  //! Activates the view as subview of another view.
+  //! @param[in] theParentView parent view to put subview into
+  //! @param[in] theSize subview dimensions;
+  //!                    values >= 2   define size in pixels,
+  //!                    values <= 1.0 define size as a fraction of parent view
+  //! @param[in] theCorner corner within parent view
+  //! @param[in] theOffset offset from the corner;
+  //!                      values >= 1   define offset in pixels,
+  //!                      values <  1.0 define offset as a fraction of parent view
+  //! @param[in] theMargins subview margins in pixels
+  //!
+  //! Example: to split parent view horizontally into 2 subview,
+  //! define one subview with Size=(0.5,1.0),Offset=(0.0,0.0), and 2nd with Size=(0.5,1.0),Offset=(5.0,0.0);
+  Standard_EXPORT void SetWindow (const Handle(V3d_View)& theParentView,
+                                  const Graphic3d_Vec2d& theSize,
+                                  Aspect_TypeOfTriedronPosition theCorner = Aspect_TOTP_LEFT_UPPER,
+                                  const Graphic3d_Vec2d& theOffset = Graphic3d_Vec2d(),
+                                  const Graphic3d_Vec2i& theMargins = Graphic3d_Vec2i());
+
   Standard_EXPORT void SetMagnify (const Handle(Aspect_Window)& theWindow,
                                    const Handle(V3d_View)& thePreviousView,
                                    const Standard_Integer theX1,
@@ -953,7 +972,25 @@ public:
   //! Dumps the content of me into the stream
   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
 
-  DEFINE_STANDARD_RTTIEXT(V3d_View,Standard_Transient)
+public: //! @name subvew management
+
+  //! Return TRUE if this is a subview of another view.
+  bool IsSubview() const { return myParentView != nullptr; }
+
+  //! Return parent View or NULL if this is not a subview.
+  V3d_View* ParentView() { return myParentView; }
+
+  //! Return subview list.
+  const NCollection_Sequence<Handle(V3d_View)>& Subviews() const { return mySubviews; }
+
+  //! Pick subview from the given 2D point.
+  Standard_EXPORT Handle(V3d_View) PickSubview (const Graphic3d_Vec2i& thePnt) const;
+
+  //! Add subview to the list.
+  Standard_EXPORT void AddSubview (const Handle(V3d_View)& theView);
+
+  //! Remove subview from the list.
+  Standard_EXPORT bool RemoveSubview (const V3d_View* theView);
 
 public: //! @name deprecated methods
 
@@ -1033,6 +1070,10 @@ protected:
 private:
 
   V3d_Viewer* MyViewer;
+
+  NCollection_Sequence<Handle(V3d_View)> mySubviews;
+  V3d_View* myParentView;
+
   V3d_ListOfLight myActiveLights;
   gp_Dir myDefaultViewAxis;
   gp_Pnt myDefaultViewPoint;