Salome HOME
Fix for the 0052398: TC7.4.0: fatal error during redo in the "3D Sketch
[modules/geom.git] / src / GenerationGUI / GenerationGUI.cxx
index 78bc4fdeb7bacf76a83607a3ed47bb18eb1991a7..b5aec7548600d2eb002f29f06dac4ccd29f5658d 100644 (file)
@@ -1,54 +1,52 @@
-//  GEOM GEOMGUI : GUI for Geometry component
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-//  File   : GenerationGUI.cxx
-//  Author : Damien COQUERET
-//  Module : GEOM
-//  $Header: 
 
-using namespace std;
+// GEOM GEOMGUI : GUI for Geometry component
+// File   : GenerationGUI.cxx
+// Author : Damien COQUERET, Open CASCADE S.A.S.
+
 #include "GenerationGUI.h"
 
-#include "SALOMEGUI_QtCatchCorbaException.hxx"
+#include <GeometryGUI.h>
+#include "GeometryGUI_Operations.h"
+
+#include <SUIT_Desktop.h>
+#include <SalomeApp_Application.h>
 
 #include "GenerationGUI_PrismDlg.h"     // Method PRISM
 #include "GenerationGUI_RevolDlg.h"     // Method REVOL
 #include "GenerationGUI_FillingDlg.h"   // Method FILLING
 #include "GenerationGUI_PipeDlg.h"      // Method PIPE
+#include "GenerationGUI_PipePathDlg.h"  // Method RESTORE PATH
 
 //=======================================================================
 // function : GenerationGUI()
 // purpose  : Constructor
 //=======================================================================
-GenerationGUI::GenerationGUI() :
-  QObject()
+GenerationGUI::GenerationGUI( GeometryGUI* parent )
+  : GEOMGUI( parent )
 {
-  myGeomBase = new GEOMBase();
-  myGeomGUI = GEOMContext::GetGeomGUI();
-  myGeom = myGeomGUI->myComponentGeom;
 }
 
-
 //=======================================================================
 // function : ~GenerationGUI()
 // purpose  : Destructor
@@ -62,164 +60,29 @@ GenerationGUI::~GenerationGUI()
 // function : OnGUIEvent()
 // purpose  : 
 //=======================================================================
-bool GenerationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
+bool GenerationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
 {
-  GenerationGUI* myGenerationGUI = new GenerationGUI();
-  myGenerationGUI->myGeomGUI->EmitSignalDeactivateDialog();
-  SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
-
-  switch (theCommandID)
-    {
-    case 4031: // PRISM
-      {        
-       GenerationGUI_PrismDlg *aDlg = new GenerationGUI_PrismDlg(parent, "", myGenerationGUI, Sel);
-       break;
-      }
-    case 4032: // REVOL
-      {        
-       GenerationGUI_RevolDlg *aDlg = new GenerationGUI_RevolDlg(parent, "", myGenerationGUI, Sel);
-       break;
-      }
-    case 4033: // FILLING
-      {        
-       GenerationGUI_FillingDlg *aDlg = new GenerationGUI_FillingDlg(parent, "", myGenerationGUI, Sel);
-       break;
-      }
-    case 4034: // PIPE
-      {        
-       GenerationGUI_PipeDlg *aDlg = new  GenerationGUI_PipeDlg(parent, "", myGenerationGUI, Sel);
-       break;
-      }
-    default:
-      {
-       parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
-       break;
-      }
-    }
-  return true;
-}
-
-
-//=======================================================================
-// function : MakePrismAndDisplay()
-// purpose  : P1 and P2 is to define a vector for prism
-//=======================================================================
-void GenerationGUI::MakePrismAndDisplay(GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2)
-{
-  try {
-    if(BaseShape->_is_nil()) {
-      QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); 
-      return;
-    }
-
-    GEOM::PointStruct PS1 = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z());
-    GEOM::PointStruct PS2 = myGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z());
-    GEOM::GEOM_Shape_ptr result = myGeom->MakePrism(BaseShape, PS1, PS2);
-    if(result->_is_nil()) {
-      QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); 
-      return;
-    }  
-
-    TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result);
-    Standard_CString type;
-    myGeomBase->GetShapeTypeString(S,type);
-    result->NameType(type);
-
-    if(myGeomBase->Display(result))
-      QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
-  }
-  catch(const SALOME::SALOME_Exception& S_ex) {
-    QtCatchCorbaException(S_ex);
-  }
-  return;
-}
+  SalomeApp_Application* app = getGeometryGUI()->getApp();
+  if ( !app ) return false;
 
+  getGeometryGUI()->EmitSignalDeactivateDialog();
 
-//=======================================================================================
-// function : MakeRevolutionAndDisplay()
-// purpose  :
-//=======================================================================================
-void GenerationGUI::MakeRevolutionAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir, const Standard_Real revolAngle)
-{
-  try {
-    GEOM::AxisStruct axis = myGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z());
-    GEOM::GEOM_Shape_ptr result = myGeom->MakeRevolution(Shape, axis, revolAngle) ;
-    if(result->_is_nil()) {
-      QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
-      return;
-    }
-
-    TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result);
-    Standard_CString type;
-    myGeomBase->GetShapeTypeString(S,type);
-    result->NameType(type);
-
-    if(myGeomBase->Display(result))
-      QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
-  }
-  catch(const SALOME::SALOME_Exception& S_ex) {
-    QtCatchCorbaException(S_ex);
-  }
-  return;
-}
+  QDialog* aDlg = NULL;
 
-
-//=====================================================================================
-// function : MakeFillingAndDisplay()
-// purpose  :
-//=====================================================================================
-void GenerationGUI::MakeFillingAndDisplay(GEOM::GEOM_Shape_ptr SectionShape, const short mindeg,
-                                         const short maxdeg, const double tol3d,
-                                         const double tol2d, const short nbiter)
-{  
-  try {
-    GEOM::GEOM_Shape_ptr result = myGeom->MakeFilling(SectionShape, mindeg, maxdeg,
-                                                     tol3d, tol2d, nbiter);
-    if(result->_is_nil()) {
-      QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); 
-      return;
-    }  
-
-    TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result);
-    Standard_CString type;
-    myGeomBase->GetShapeTypeString(S,type);
-    result->NameType(type);
-
-    if(myGeomBase->Display(result))
-      QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
-    return;  
-  } 
-  catch(const SALOME::SALOME_Exception& S_ex) {
-    QtCatchCorbaException(S_ex);
+  switch ( theCommandID ) {
+  case GEOMOp::OpPrism:      aDlg = new GenerationGUI_PrismDlg   ( getGeometryGUI(), parent ); break;
+  case GEOMOp::OpRevolution: aDlg = new GenerationGUI_RevolDlg   ( getGeometryGUI(), parent ); break;
+  case GEOMOp::OpFilling:    aDlg = new GenerationGUI_FillingDlg ( getGeometryGUI(), parent ); break;
+  case GEOMOp::OpPipe:       aDlg = new GenerationGUI_PipeDlg    ( getGeometryGUI(), parent ); break;
+  case GEOMOp::OpPipePath:   aDlg = new GenerationGUI_PipePathDlg( getGeometryGUI(), parent ); break;
+    
+  default: app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); break;
   }
-  return;
-}
 
+  if (aDlg != NULL )
+    aDlg->show();
 
-//=====================================================================================
-// function : MakePipeAndDisplay()
-// purpose  :
-//=====================================================================================
-void GenerationGUI::MakePipeAndDisplay(GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase) 
-{
-  try {
-    GEOM::GEOM_Shape_ptr result = myGeom->MakePipe(aPath, aBase);
-    if (!result->_is_nil() && myGeomBase->Display(result)) {
-      TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result);
-      Standard_CString type;
-      myGeomBase->GetShapeTypeString(S,type);
-      result->NameType(type);
-
-      QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
-    }
-    else {
-      QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
-    }
-  }
-  catch (const SALOME::SALOME_Exception& S_ex) {
-    QtCatchCorbaException(S_ex);
-  }
-  return;
+  return true;
 }
 
 
@@ -228,6 +91,11 @@ void GenerationGUI::MakePipeAndDisplay(GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Sh
 //=====================================================================================
 extern "C"
 {
-  bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
-  {return GenerationGUI::OnGUIEvent(theCommandID, parent);}
+#ifdef WIN32
+  __declspec( dllexport )
+#endif
+  GEOMGUI* GetLibGUI( GeometryGUI* parent )
+  {
+    return new GenerationGUI( parent );
+  }
 }