Salome HOME
0021787: [CEA 621] Desactivate preview for partition and boolean operations in prefer...
[modules/geom.git] / src / OperationGUI / OperationGUI_ExtrudedFeatureDlg.cxx
index b9f0bb8f442055309c9eb51d806eb665d1382b30..135a8532ddcceb993d69a42c180de182765c6350 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 #include <GEOM_Object.hxx>
 
 // OCCT Includes
-// #include <TopoDS_Shape.hxx>
-// #include <TopoDS_Edge.hxx>
-// #include <TopoDS.hxx>
-// #include <TopExp.hxx>
-// #include <TColStd_IndexedMapOfInteger.hxx>
-// #include <TopTools_IndexedMapOfShape.hxx>
-// #include <Precision.hxx>
 #include <TColStd_HSequenceOfTransient.hxx>
 
 #include <GEOMImpl_Types.hxx>
@@ -69,16 +62,19 @@ OperationGUI_ExtrudedFeatureDlg::OperationGUI_ExtrudedFeatureDlg(const int theOp
   QPixmap image0;
   QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
   QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICO_DRAFT")));
+  QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_CHANGE_DIRECTION")));
   QString aTitle;
   switch (myOperation) 
   {
     case OperationGUI::BOSS:
       image0 = QPixmap(aResMgr->loadPixmap("GEOM", tr("ICO_EXTRUDED_BOSS")));
-      aTitle = tr("GEOM_EXTRUDED_BOSS");
+      aTitle = tr("GEOM_EXTRUDED_BOSS_TITLE");
+      setHelpFileName("extruded_boss_operation_page.html");
       break;
     case OperationGUI::CUT:
       image0 = QPixmap( aResMgr->loadPixmap("GEOM", tr("ICO_EXTRUDED_CUT")));
-      aTitle = tr("GEOM_EXTRUDED_CUT");
+      aTitle = tr("GEOM_EXTRUDED_CUT_TITLE");
+      setHelpFileName("extruded_cut_operation_page.html");
       break;
   }
     
@@ -92,15 +88,21 @@ OperationGUI_ExtrudedFeatureDlg::OperationGUI_ExtrudedFeatureDlg(const int theOp
   
   mainFrame()->RadioButton1->setChecked(true);
   
-  myGroup = new DlgRef_2Sel2Spin1Push(centralWidget());
+  myGroup = new DlgRef_2Sel2Spin2Push(centralWidget());
+  
+  myGroup->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
+  
   myGroup->PushButton1->setIcon(image1);
   myGroup->PushButton2->setIcon(image1);
   myGroup->PushButton3->setIcon(image2);
+  myGroup->PushButton4->setIcon(image3);
   myGroup->LineEdit1->setReadOnly(true);
   myGroup->LineEdit2->setReadOnly(true);
   myGroup->TextLabel1->setText(tr("GEOM_INIT_SHAPE"));
-  myGroup->TextLabel2->setText(tr("GEOM_SKETCH"));
+  myGroup->TextLabel2->setText(tr("GEOM_PROFILE"));
   myGroup->TextLabel3->setText(tr("GEOM_HEIGHT"));
+  myGroup->TextLabel4->setText(tr("GEOM_DRAFT_ANGLE"));
+  myGroup->TextLabel5->setText(tr("GEOM_CHANGE_DIRECTION"));
  
   
   QVBoxLayout* layout = new QVBoxLayout(centralWidget());
@@ -151,6 +153,7 @@ void OperationGUI_ExtrudedFeatureDlg::Init()
   connect(myGroup->PushButton1, SIGNAL(clicked()),     this, SLOT(SetEditCurrentArgument()));
   connect(myGroup->PushButton2, SIGNAL(clicked()),     this, SLOT(SetEditCurrentArgument()));
   connect(myGroup->PushButton3, SIGNAL(clicked(bool)), this, SLOT(ButtonClicked(bool)));
+  connect(myGroup->PushButton4, SIGNAL(clicked(bool)), this, SLOT(ButtonClicked(bool)));
   connect(myGroup->SpinBox_DX,  SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
   connect(myGroup->SpinBox_DY,  SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
   
@@ -158,11 +161,19 @@ void OperationGUI_ExtrudedFeatureDlg::Init()
   connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
            SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
   
-  initName(mainFrame()->GroupConstructors->title());
+  switch (myOperation) 
+  {
+    case OperationGUI::BOSS:
+      initName(tr("GEOM_EXTRUDED_BOSS"));     
+      break;
+    case OperationGUI::CUT:
+      initName(tr("GEOM_EXTRUDED_CUT"));  
+      break;
+  }
   
   mainFrame()->RadioButton1->setFocus();
   
-  globalSelection(GEOM_ALLSHAPES); //TODO à changer
+  globalSelection(GEOM_ALLSHAPES);
   
   myGroup->PushButton1->click();
   SelectionIntoArgument();
@@ -203,7 +214,7 @@ bool OperationGUI_ExtrudedFeatureDlg::ClickOnApply()
 void OperationGUI_ExtrudedFeatureDlg::SetEditCurrentArgument()
 {
   QPushButton* send = (QPushButton*)sender();
-
+  
   if (send == myGroup->PushButton1) {
     myEditCurrentArgument = myGroup->LineEdit1;
 
@@ -216,7 +227,7 @@ void OperationGUI_ExtrudedFeatureDlg::SetEditCurrentArgument()
     myGroup->PushButton1->setDown(false);
     myGroup->LineEdit1->setEnabled(false);
   }
-
+  
   // enable line edit
   myEditCurrentArgument->setEnabled(true);
   myEditCurrentArgument->setFocus();
@@ -244,7 +255,7 @@ void OperationGUI_ExtrudedFeatureDlg::SelectionIntoArgument()
   if (myEditCurrentArgument == myGroup->LineEdit2)
   {
     types.clear();
-    types << TopAbs_EDGE << TopAbs_WIRE;
+    types << TopAbs_EDGE << TopAbs_WIRE << TopAbs_FACE;
   }
 
   GEOM::GeomObjPtr aSelectedObject = getSelected( types );
@@ -317,7 +328,10 @@ void OperationGUI_ExtrudedFeatureDlg::ValueChangedInSpinBox()
 //=================================================================================
 void OperationGUI_ExtrudedFeatureDlg::ButtonClicked(bool checked)
 {
-  myGroup->SpinBox_DY->setEnabled(checked);
+  QPushButton* send = (QPushButton*)sender();
+  if (send == myGroup->PushButton3)
+    myGroup->SpinBox_DY->setEnabled(checked);
   displayPreview(true);
 }
 
@@ -345,38 +359,40 @@ bool OperationGUI_ExtrudedFeatureDlg::isValid (QString&)
 //=================================================================================
 bool OperationGUI_ExtrudedFeatureDlg::execute (ObjectList& objects)
 {
-//   GEOM::GEOM_Object_var anObj;
-
   GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
   
   double angle=0.0;
+  double aHeight = myGroup->SpinBox_DX->value();
+  
   if (myGroup->PushButton3->isChecked())
     angle=myGroup->SpinBox_DY->value();
+  
+  if (myGroup->PushButton4->isChecked())
+  {
+    aHeight = -aHeight;
+    angle   = -angle;
+  }
     
   bool isProtrusion = (myOperation == OperationGUI::BOSS);  
   
+  // Hide the initial shape in order to see the modifications on the preview
+  erase(myObject1.get(),false); 
+  
   GEOM::GEOM_Object_var anObj = anOper->MakeDraftPrism(myObject1.get(), myObject2.get(), 
-                                                       myGroup->SpinBox_DX->value(),
+                                                       aHeight,
                                                        angle,
                                                        isProtrusion);
-//    switch (myOperation) 
-//   {
-//     case OperationGUI::BOSS:
-//       anObj = anOper->MakeDraftPrism(myObject1.get(), myObject2.get(),myGroup->SpinBox_DX->value(),angle, true);
-//       break;
-//     case OperationGUI::CUT:
-//       anObj = anOper->MakeDraftPrism(myObject1.get(), myObject2.get(),myGroup->SpinBox_DX->value(),angle, false);
-//       break;
-//   }
   if (!anObj->_is_nil())
     objects.push_back(anObj._retn());
 
   return true;
 }
 
-
-
-
-  
-
-     
\ No newline at end of file
+// //=================================================================================
+// // function : addSubshapeToStudy
+// // purpose  : virtual method to add new SubObjects if local selection
+// //=================================================================================
+// void OperationGUI_ExtrudedFeatureDlg::addSubshapesToStudy()
+// {
+//   GEOMBase::PublishSubObject( myObject2.get() );
+// }