Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / VISUGUI / VisuGUI_CutPlanesDlg.cxx
index 185a6c819fda94950ca889842f74c29b0dfc379c..c4072907cd942daefde932fd03132643960e4129 100644 (file)
@@ -62,16 +62,16 @@ using namespace std;
 
 //extern VisuGUI *visuGUI;
 
-VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent/*, SUIT_ViewManager* theMgr*/)
-     : QFrame(theParent), myPreviewActor(0)//, myMgr(theMgr)
+VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent)
+     : QFrame(theParent), myPreviewActor(0)
 {
   QGridLayout* TopLayout = new QGridLayout( this );
   TopLayout->setSpacing( 6 );
   TopLayout->setMargin( 10 );
 
-  QButtonGroup* SelPlane = new QButtonGroup( tr( "Orientation" ), this, "SelPlane" );
-  SelPlane->setTitle( tr( "Orientation" ) );
-  SelPlane->setColumnLayout(0, Qt::Vertical );
+  QButtonGroup* SelPlane = new QButtonGroup (tr("TXT_ORIENTATION"), this, "SelPlane");
+  //SelPlane->setTitle(tr("TXT_ORIENTATION"));
+  SelPlane->setColumnLayout(0, Qt::Vertical);
   SelPlane->layout()->setSpacing( 0 );
   SelPlane->layout()->setMargin( 0 );
   QGridLayout* SelPlaneLayout = new QGridLayout( SelPlane->layout() );
@@ -79,20 +79,20 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent/*, SUIT_ViewMan
   SelPlaneLayout->setSpacing( 6 );
   SelPlaneLayout->setMargin( 11 );
 
-  RBxy = new QRadioButton( tr( "// X-Y" ), SelPlane, "RBxy" );
-  RByz = new QRadioButton( tr( "// Y-Z" ), SelPlane, "RByz" );
-  RBzx = new QRadioButton( tr( "// Z-X" ), SelPlane, "RBzx" );
+  RBxy = new QRadioButton (tr("PARALLEL_XOY"), SelPlane, "RBxy");
+  RByz = new QRadioButton (tr("PARALLEL_YOZ"), SelPlane, "RByz");
+  RBzx = new QRadioButton (tr("PARALLEL_ZOX"), SelPlane, "RBzx");
   SelPlaneLayout->addWidget( RBxy, 0, 0 );
   SelPlaneLayout->addWidget( RByz, 0, 1 );
   SelPlaneLayout->addWidget( RBzx, 0, 2 );
 
-  QLabel* LabelPosi_3 = new QLabel( tr( "Number of planes:" ), this, "LabelPosi_3" );
+  QLabel* LabelPosi_3 = new QLabel (tr("LBL_NB_PLANS"), this, "LabelPosi_3");
 
   nbPlan = new QSpinBox( 1, 100, 1, this, "nbPlan" );
   nbPlan->setValue( 1 );
   nbPlan->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
 
-  myPosTable = new QTable(this, "Positions of planes" );
+  myPosTable = new QTable (this, "Positions of planes");
   myPosTable->setMaximumHeight( 227 );
   myPosTable->setMinimumWidth( 294 );
   myPosTable->setNumCols(2);
@@ -104,8 +104,8 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent/*, SUIT_ViewMan
   th->setLabel( 1, "Set default" );
   th->setStyle("QStyle::CE_PushButton");
 
-  QGroupBox* GBrot = new QGroupBox( tr( "Rotations" ), this, "GBrot" );
-  GBrot->setColumnLayout(0, Qt::Vertical );
+  QGroupBox* GBrot = new QGroupBox (tr("LBL_ROTATION"), this, "GBrot");
+  GBrot->setColumnLayout(0, Qt::Vertical);
   GBrot->layout()->setSpacing( 0 );
   GBrot->layout()->setMargin( 0 );
   QGridLayout* GBrotLayout = new QGridLayout( GBrot->layout() );
@@ -113,7 +113,7 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent/*, SUIT_ViewMan
   GBrotLayout->setSpacing( 6 );
   GBrotLayout->setMargin( 11 );
 
-  LabelRot1 = new QLabel( tr( "Rotation around X (Y to Z):" ), GBrot, "LabelRot1" );
+  LabelRot1 = new QLabel (tr("LBL_ROT_X"), GBrot, "LabelRot1");
   GBrotLayout->addWidget( LabelRot1, 0, 0 );
 
   Rot1 = new QtxDblSpinBox( -180, 180, 10, GBrot );
@@ -122,7 +122,7 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent/*, SUIT_ViewMan
   connect( Rot1, SIGNAL( valueChanged( double )), this, SLOT( onRotation( double ) ) );
   GBrotLayout->addWidget( Rot1, 0, 1 );
 
-  LabelRot2 = new QLabel( tr( "Rotation around Y (Z to X):" ), GBrot, "LabelRot2" );
+  LabelRot2 = new QLabel (tr("LBL_ROT_Y"), GBrot, "LabelRot2");
   GBrotLayout->addWidget( LabelRot2, 1, 0 );
 
   Rot2 = new QtxDblSpinBox( -180, 180, 10, GBrot );
@@ -166,6 +166,7 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent/*, SUIT_ViewMan
 
 VisuGUI_CutPlanesPane::~VisuGUI_CutPlanesPane()
 {
+  cout<<"### VisuGUI_CutPlanesPane::~VisuGUI_CutPlanesPane"<<endl;
   deletePlanes();
   if (myCutPlanes)
     myCutPlanes->Destroy();
@@ -198,11 +199,11 @@ void VisuGUI_CutPlanesPane::createPlanes()
   if (myPreviewActor != 0) return;
 
   vtkAppendPolyData* aPolyData = myCutPlanes->GetCutPlanesPL()->GetAppendPolyData();
-  vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
   if (!aPolyData->GetOutput()->GetNumberOfCells()) {
     onPreviewCheck(false);
     return;
   }
+  vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
   aPlaneMapper->SetInput(aPolyData->GetOutput());
   aPlaneMapper->ScalarVisibilityOff();
 
@@ -236,14 +237,14 @@ int VisuGUI_CutPlanesPane::storeToPrsObject (VISU::CutPlanes_i* thePrs)
 void VisuGUI_CutPlanesPane::orientationChanged (int Id)
 {
   if (Id == 0) { // RBxy->isChecked()
-    LabelRot1->setText( tr( "Rotation around X (Y to Z):" ) );
-    LabelRot2->setText( tr( "Rotation around Y (Z to X):" ) );
+    LabelRot1->setText(tr("LBL_ROT_X"));
+    LabelRot2->setText(tr("LBL_ROT_Y"));
   } else if (Id == 1) { // RByz->isChecked()
-    LabelRot1->setText( tr( "Rotation around Y (Z to X):" ) );
-    LabelRot2->setText( tr( "Rotation around Z (X to Y):" ) );
+    LabelRot1->setText(tr("LBL_ROT_Y"));
+    LabelRot2->setText(tr("LBL_ROT_Z"));
   } else {
-    LabelRot1->setText( tr( "Rotation around Z (X to Y):" ) );
-    LabelRot2->setText( tr( "Rotation around X (Y to Z):" ) );
+    LabelRot1->setText(tr("LBL_ROT_Z"));
+    LabelRot2->setText(tr("LBL_ROT_X"));
   }
   DrawTable();
 }
@@ -454,22 +455,15 @@ void VisuGUI_CutPlanesPane::onPreviewCheck (bool thePreview)
 //###################################################################
 
 
-
 /*!
   Constructor
 */
-VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg (QWidget* parent, bool theIsCreation, bool theIsModal)
-     : QDialog(parent, "VisuGUI_CutPlanesDlg", theIsModal, WStyle_Customize |
-               WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
-       //,myMgr(VisuGUI::application()->activeViewManager())
+VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg (SalomeApp_Module* theModule)
+     : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutPlanesDlg", false,
+               WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
 {
-  //myStudyWnd = myMgr->getActiveView();
-  if (!theIsModal) {
-    setWFlags(getWFlags() | WDestructiveClose);
-  }
   setCaption("Cut Planes Definition");
   setSizeGripEnabled(true);
-  myIsCreation = theIsCreation;
 
   QVBoxLayout* TopLayout = new QVBoxLayout (this);
   TopLayout->setSpacing(6);
@@ -516,49 +510,34 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg (QWidget* parent, bool theIsCreation,
   //        this, SLOT(onWindowActivated(SUIT_ViewWindow*)));
 }
 
-void VisuGUI_CutPlanesDlg::accept() {
+void VisuGUI_CutPlanesDlg::initFromPrsObject (VISU::CutPlanes_i* thePrs)
+{
+  myPrs = thePrs;
+  myScalarPane->initFromPrsObject(thePrs);
+  myCutPane->initFromPrsObject(thePrs);
+}
+
+int VisuGUI_CutPlanesDlg::storeToPrsObject (VISU::CutPlanes_i* thePrs)
+{
+  return (myScalarPane->storeToPrsObject(thePrs) &&
+          myCutPane->storeToPrsObject(thePrs));
+}
+
+void VisuGUI_CutPlanesDlg::accept()
+{
+  //if ( !VisuGUI::CheckActiveStudyLock() ) {
+  //  reject();
+  //  return;
+  //}
   if (myScalarPane->check())
-    QDialog::accept();
-/*
-  if (myScalarPane->check()) {
-    if (!isModal()) {
-      if (storeToPrsObject(myPrs)) {
-       if (myIsCreation) {
-         if (VISU::GetViewWindow() != NULL) {
-           try {
-           visuGUI->CreateActor(myPrs);
-           }
-           catch (...) {
-             reject();
-             return;
-           }
-           VISU::GetViewWindow()->onFitAll();
-         }
-       } else {
-         visuGUI->RecreateActor(myPrs);
-         if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
-            if (vf->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
-             vf->getRenderer()->ResetCameraClippingRange();
-             vf->Repaint();
-           }
-         }
-       }
-      } else {
-       if (myIsCreation) {
-         visuGUI->DeletePresentation(myPrs);
-       }
-      }
+    {
+      myScalarPane->deletePreview();
+      QDialog::accept();
     }
-    QDialog::accept();
-  }
-*/
 }
 
 void VisuGUI_CutPlanesDlg::reject() {
-  //if (myIsCreation && (!isModal())) {
-  //  visuGUI->DeletePresentation(myPrs);
-  //  VisuGUI::application()->objectBrowser()->updateTree();
-  //}
+  myScalarPane->deletePreview();
   QDialog::reject();
 }