Salome HOME
[Bug PAL7444] display mesh takes a lot of more memory in 2.1.0 than in 2.0.0.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ClippingDlg.cxx
index d98228dde97b9bb7bbc93a283cf3b76406fa4808..2190ea2d545a1b4a6942f3ad93b581efb9cf10d1 100644 (file)
 #include "SALOME_InteractiveObject.hxx"
 #include "SMESH_ActorUtils.h"
 
+#include "VTKViewer_ViewFrame.h"
+#include "VTKViewer_RenderWindow.h"
+
+#include <vtkRenderer.h>
+
 using namespace std;
 
 
@@ -151,8 +156,6 @@ protected:
     myActor->SetInfinitive(true);
     myActor->SetMapper( myMapper );
 
-    static float anOpacity = 0.75;
-
     vtkProperty* aProp = vtkProperty::New();
     float anRGB[3];
     anRGB[0] = SMESH::GetFloat("SMESH:SettingsFillColorRed", 0)/255.;
@@ -375,16 +378,11 @@ SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg( QWidget* parent,
 SMESHGUI_ClippingDlg::~SMESHGUI_ClippingDlg()
 {
   // no need to delete child widgets, Qt does it all for us
-  //cout<<"SMESHGUI_ClippingDlg::~SMESHGUI_ClippingDlg\n";
   std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false));
-  SMESH::GetCurrentVtkView()->Repaint();
+  SMESH::RenderViewFrame(SMESH::GetCurrentVtkView());
 }
 
 
-//=======================================================================
-// function : ClickOnApply()
-// purpose  :
-//=======================================================================
 void SMESHGUI_ClippingDlg::ClickOnApply()
 {
   if (!myActor)
@@ -393,23 +391,17 @@ void SMESHGUI_ClippingDlg::ClickOnApply()
   if ( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
     QAD_WaitCursor wc;
     
-    vtkImplicitBoolean* aBoolean = myActor->GetPlaneContainer();
-    vtkImplicitFunctionCollection* aCollection = aBoolean->GetFunction();
-    aCollection->RemoveAllItems();
-    aBoolean->Modified(); // VTK bug
-    aCollection->InitTraversal();
-    
+    myActor->RemoveAllClippingPlanes();
+
     SMESH::TPlanes::iterator anIter = myPlanes.begin();
     for (;anIter != myPlanes.end();anIter++){
       OrientedPlane* anOrientedPlane = OrientedPlane::New();
       anOrientedPlane->ShallowCopy(anIter->GetPointer());
-      aCollection->AddItem(anOrientedPlane);
+      myActor->AddClippingPlane(anOrientedPlane);
       anOrientedPlane->Delete();
     }
-    
-    myActor->SetVisibility(myActor->GetVisibility());
-    
-    SMESH::GetCurrentVtkView()->Repaint();
+
+    SMESH::RenderViewFrame(SMESH::GetCurrentVtkView());
   }
 }
 
@@ -446,27 +438,29 @@ void SMESHGUI_ClippingDlg::onSelectionChanged()
       Handle(SALOME_InteractiveObject) IOS = mySelection->firstIObject();
       myActor = SMESH::FindActorByEntry(IOS->getEntry());
       if ( myActor ){
-       vtkImplicitBoolean* aBoolean = myActor->GetPlaneContainer();
-       vtkImplicitFunctionCollection* aCollection = aBoolean->GetFunction();
-       aCollection->InitTraversal();
        std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false));
        myPlanes.clear();
-       while(vtkImplicitFunction* aFunction = aCollection->GetNextItem()){
-         if(OrientedPlane* aPlane = OrientedPlane::SafeDownCast(aFunction)){
-           OrientedPlane* anOrientedPlane = OrientedPlane::New(SMESH::GetActiveStudy());
-           SMESH::TVTKPlane aTVTKPlane(anOrientedPlane);
-           anOrientedPlane->Delete();
-           aTVTKPlane->ShallowCopy(aPlane);
-           myPlanes.push_back(aTVTKPlane);
+
+       vtkIdType anId = 0, anEnd = myActor->GetNumberOfClippingPlanes();
+       for(; anId < anEnd; anId++){
+         if(vtkImplicitFunction* aFunction = myActor->GetClippingPlane(anId)){
+           if(OrientedPlane* aPlane = OrientedPlane::SafeDownCast(aFunction)){
+             OrientedPlane* anOrientedPlane = OrientedPlane::New(SMESH::GetActiveStudy());
+             SMESH::TVTKPlane aTVTKPlane(anOrientedPlane);
+             anOrientedPlane->Delete();
+             aTVTKPlane->ShallowCopy(aPlane);
+             myPlanes.push_back(aTVTKPlane);
+           }
          }
        }
+
        std::for_each(myPlanes.begin(),myPlanes.end(),
                      TSetVisiblity(PreviewCheckBox->isChecked()));
       }
     }
   }
   Sinchronize();
-  SMESH::GetCurrentVtkView()->Repaint();
+  SMESH::RenderViewFrame(SMESH::GetCurrentVtkView());
 }
 
 
@@ -484,8 +478,7 @@ void SMESHGUI_ClippingDlg::onSelectPlane(int theIndex)
   // Orientation
   SMESH::Orientation anOrientation = aPlane->GetOrientation();
   
-  // Distance and Rotations
-  float aDistance;
+  // Rotations
   double aRot[2] = {aPlane->myAngle[0], aPlane->myAngle[1]};
 
   // Set plane parameters in the dialog
@@ -550,7 +543,7 @@ void SMESHGUI_ClippingDlg::ClickOnDelete()
     ClickOnApply();
 
   Sinchronize();
-  SMESH::GetCurrentVtkView()->Repaint();
+  SMESH::RenderViewFrame(SMESH::GetCurrentVtkView());
 }
 
 
@@ -635,7 +628,9 @@ void SMESHGUI_ClippingDlg::setRotation( const double theRot1, const double theRo
 // function : SetCurrentPlaneParam
 // purpose  :
 //=======================================================================
-void SMESHGUI_ClippingDlg::SetCurrentPlaneParam()
+void
+SMESHGUI_ClippingDlg::
+SetCurrentPlaneParam()
 {
   if(myPlanes.empty() || myIsSelectPlane)
     return;
@@ -702,7 +697,6 @@ void SMESHGUI_ClippingDlg::SetCurrentPlaneParam()
   
   myActor->SetPlaneParam(aNormal, getDistance(), aPlane);
 
-  float* anOrig = aPlane->GetOrigin();
   vtkDataSet* aDataSet = myActor->GetInput();
   float *aPnt = aDataSet->GetCenter();
 
@@ -746,11 +740,11 @@ void SMESHGUI_ClippingDlg::SetCurrentPlaneParam()
   if(AutoApplyCheckBox->isChecked())
     ClickOnApply();
   
-  SMESH::GetCurrentVtkView()->Repaint();
+  SMESH::RenderViewFrame(SMESH::GetCurrentVtkView());
 }
 
 
 void SMESHGUI_ClippingDlg::OnPreviewToggle(bool theIsToggled){
   std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theIsToggled));
-  SMESH::GetCurrentVtkView()->Repaint();
+  SMESH::RenderViewFrame(SMESH::GetCurrentVtkView());
 }