0028895: Visualization, V3d_View::SetComputedMode() - HLR calculation is performed...
[occt.git] / src / PrsMgr / PrsMgr_Presentation.cxx
index facc71e..17ff1c2 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <PrsMgr_Presentation.ixx>
-#include <PrsMgr_PresentationManager.hxx>
-#include <PrsMgr_Prs.hxx>
-#include <PrsMgr_ModedPresentation.hxx>
+#include <PrsMgr_Presentation.hxx>
 
+#include <Geom_Transformation.hxx>
+#include <Graphic3d_DataStructureManager.hxx>
 #include <Graphic3d_Structure.hxx>
-#include <Visual3d_View.hxx>
 #include <Precision.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Projector.hxx>
+#include <PrsMgr_ModedPresentation.hxx>
+#include <PrsMgr_PresentableObject.hxx>
+#include <PrsMgr_PresentationManager.hxx>
+#include <PrsMgr_Prs.hxx>
+#include <Quantity_Color.hxx>
+#include <Standard_Type.hxx>
+#include <Graphic3d_CView.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(PrsMgr_Presentation, Standard_Transient)
 
 namespace
 {
@@ -30,7 +40,7 @@ namespace
     State_Visible
   };
 
-  static BeforeHighlightState StructureState(const Handle(PrsMgr_Prs) theStructure)
+  static BeforeHighlightState StructureState(const Handle(Prs3d_Presentation)& theStructure)
   {
     return !theStructure->IsDisplayed() ?
       State_Empty : !theStructure->IsVisible() ?
@@ -61,15 +71,15 @@ PrsMgr_Presentation::PrsMgr_Presentation (const Handle(PrsMgr_PresentationManage
 //=======================================================================
 void PrsMgr_Presentation::Display()
 {
-  Display (Standard_False);
+  display (Standard_False);
   myBeforeHighlightState = State_Visible;
 }
 
 //=======================================================================
-//function : Display
+//function : display
 //purpose  :
 //=======================================================================
-void PrsMgr_Presentation::Display (const Standard_Boolean theIsHighlight)
+void PrsMgr_Presentation::display (const Standard_Boolean theIsHighlight)
 {
   if (!myStructure->IsDisplayed())
   {
@@ -116,15 +126,15 @@ void PrsMgr_Presentation::SetVisible (const Standard_Boolean theValue)
 //function : Highlight
 //purpose  :
 //=======================================================================
-void PrsMgr_Presentation::Highlight()
+void PrsMgr_Presentation::Highlight (const Handle(Prs3d_Drawer)& theStyle)
 {
   if (!IsHighlighted())
   {
     myBeforeHighlightState = StructureState (myStructure);
   }
 
-  Display (Standard_True);
-  myStructure->Highlight();
+  display (Standard_True);
+  myStructure->Highlight (theStyle);
 }
 
 //=======================================================================
@@ -169,30 +179,6 @@ void PrsMgr_Presentation::Clear()
   myStructure->RemoveAll();
 }
 
-//=======================================================================
-//function : Color
-//purpose  :
-//=======================================================================
-void PrsMgr_Presentation::Color (const Quantity_NameOfColor theColor)
-{
-  if (!IsHighlighted())
-  {
-    myBeforeHighlightState = StructureState (myStructure);
-  }
-
-  Display (Standard_True);
-  myStructure->Color (theColor);
-}
-
-//=======================================================================
-//function : BoundBox
-//purpose  :
-//=======================================================================
-void PrsMgr_Presentation::BoundBox() const
-{
-  myStructure->BoundBox();
-}
-
 //=======================================================================
 //function : IsDisplayed
 //purpose  :
@@ -240,52 +226,12 @@ void PrsMgr_Presentation::Connect (const Handle(PrsMgr_Presentation)& theOther)
 }
 
 //=======================================================================
-//function : Transform
+//function : SetTransformation
 //purpose  :
 //=======================================================================
-void PrsMgr_Presentation::Transform (const Handle(Geom_Transformation)& theTrsf) const
+void PrsMgr_Presentation::SetTransformation (const Handle(Geom_Transformation)& theTrsf) const
 {
-  myStructure->Transform (theTrsf);
-}
-
-//=======================================================================
-//function : Place
-//purpose  :
-//=======================================================================
-void PrsMgr_Presentation::Place (const Quantity_Length theX,
-                                 const Quantity_Length theY,
-                                 const Quantity_Length theZ) const
-{
-  myStructure->Place (theX, theY, theZ);
-}
-
-//=======================================================================
-//function : Multiply
-//purpose  :
-//=======================================================================
-void PrsMgr_Presentation::Multiply (const Handle(Geom_Transformation)& theTrsf) const
-{
-  myStructure->Multiply (theTrsf);
-}
-
-//=======================================================================
-//function : Move
-//purpose  :
-//=======================================================================
-void PrsMgr_Presentation::Move (const Quantity_Length theX,
-                                const Quantity_Length theY,
-                                const Quantity_Length theZ) const
-{
-  myStructure->Move (theX, theY, theZ);
-}
-
-//=======================================================================
-//function : SetShadingAspect
-//purpose  :
-//=======================================================================
-void PrsMgr_Presentation::SetShadingAspect (const Handle(Prs3d_ShadingAspect)& theShadingAspect) const
-{
-  myStructure->SetShadingAspect (theShadingAspect);
+  myStructure->SetTransformation (theTrsf);
 }
 
 //=======================================================================
@@ -329,7 +275,7 @@ void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)&
                                    const Handle(Graphic3d_Structure)&            theStructToFill)
 {
   theStructToFill->Clear();
-  const Handle(Prs3d_Presentation)& aPrs = *((Handle(Prs3d_Presentation)* )&theStructToFill);
+  Handle(Prs3d_Presentation) aPrs (Handle(Prs3d_Presentation)::DownCast (theStructToFill));
   myPresentableObject->Compute (Projector (theProjector), aPrs);
 }
 
@@ -341,31 +287,7 @@ Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d
                                                           const Handle(Geom_Transformation)&            theTrsf)
 {
   Handle(Prs3d_Presentation) aPrs3d = new Prs3d_Presentation (myPresentationManager->StructureManager());
-  if (theTrsf->Form() == gp_Translation)
-  {
-    myPresentableObject->Compute (Projector (theProjector), aPrs3d);
-    aPrs3d->Transform (theTrsf);
-    return aPrs3d;
-  }
-
-  // waiting that something is done in gp_Trsf...rob
-  for (Standard_Integer i = 1; i <= 3; ++i)
-  {
-    for (Standard_Integer j = 1; j <= 3; ++j)
-    {
-      if (i != j)
-      {
-        if (Abs (theTrsf->Value (i, j)) > Precision::Confusion())
-        {
-          myPresentableObject->Compute (Projector (theProjector), theTrsf, aPrs3d);
-          return aPrs3d;
-        }
-      }
-    }
-  }
-
-  myPresentableObject->Compute (Projector (theProjector), aPrs3d);
-  aPrs3d->Transform (theTrsf);
+  myPresentableObject->Compute (Projector (theProjector), theTrsf, aPrs3d);
   return aPrs3d;
 }
 
@@ -378,7 +300,7 @@ void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)&
                                    const Handle(Graphic3d_Structure)&            theStructToFill)
 {
   // recompute HLR after transformation in all the case
-  Handle(Prs3d_Presentation) aPrs = *((Handle(Prs3d_Presentation)*)&theStructToFill);
+  Handle(Prs3d_Presentation) aPrs = Handle(Prs3d_Presentation)::DownCast (theStructToFill);
   theStructToFill->Clear();
   myPresentableObject->Compute (Projector (theProjector), theTrsf, aPrs);
 }
@@ -389,7 +311,7 @@ void PrsMgr_Presentation::Compute (const Handle(Graphic3d_DataStructureManager)&
 //=======================================================================
 Handle(Prs3d_Projector) PrsMgr_Presentation::Projector (const Handle(Graphic3d_DataStructureManager)& theProjector)
 {
-  const Handle(Graphic3d_Camera)& aCamera = Handle(Visual3d_View)::DownCast (theProjector)->Camera();
+  Handle(Graphic3d_Camera) aCamera = Handle(Graphic3d_CView)::DownCast (theProjector)->Camera();
   const gp_Dir aDir = aCamera->Direction().Reversed();
   const gp_Pnt anAt = aCamera->Center();
   const gp_Dir anUp = aCamera->Up();
@@ -402,10 +324,10 @@ Handle(Prs3d_Projector) PrsMgr_Presentation::Projector (const Handle(Graphic3d_D
 }
 
 //=======================================================================
-//function : Destroy
+//function : ~PrsMgr_Presentation
 //purpose  :
 //=======================================================================
-void PrsMgr_Presentation::Destroy()
+PrsMgr_Presentation::~PrsMgr_Presentation()
 {
   Erase();
 }