X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPrimitiveGUI%2FPrimitiveGUI.cxx;h=4e74a168c319a1a77070d1f1a34a4e2ab82805a7;hb=b0fbfd05c463a14c0d926a53711aafdf2c0b6fad;hp=343759a6ab32a02093e93c1e8db0106a3e25dc2a;hpb=c577ca78d7a6e286526662cf54df6de1f4f2f449;p=modules%2Fgeom.git diff --git a/src/PrimitiveGUI/PrimitiveGUI.cxx b/src/PrimitiveGUI/PrimitiveGUI.cxx index 343759a6a..4e74a168c 100644 --- a/src/PrimitiveGUI/PrimitiveGUI.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI.cxx @@ -1,249 +1,117 @@ -// GEOM GEOMGUI : GUI for Geometry component +// Copyright (C) 2007-2012 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. // +// 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 : PrimitiveGUI.cxx -// Author : Damien COQUERET -// Module : GEOM -// $Header: -using namespace std; +// GEOM GEOMGUI : GUI for Geometry component +// File : PrimitiveGUI.cxx +// Author : Damien COQUERET, Open CASCADE S.A.S. +// #include "PrimitiveGUI.h" -#include "SALOMEGUI_QtCatchCorbaException.hxx" -#include +#include +#include "GeometryGUI_Operations.h" + +#include +#include #include "PrimitiveGUI_BoxDlg.h" // Method BOX #include "PrimitiveGUI_CylinderDlg.h" // Method CYLINDER #include "PrimitiveGUI_SphereDlg.h" // Method SPHERE #include "PrimitiveGUI_TorusDlg.h" // Method TORUS #include "PrimitiveGUI_ConeDlg.h" // Method CONE +#include "PrimitiveGUI_FaceDlg.h" // Method FACE +#include "PrimitiveGUI_DiskDlg.h" // Method DISK //======================================================================= // function : PrimitiveGUI() // purpose : Constructor //======================================================================= -PrimitiveGUI::PrimitiveGUI() : - QObject() +PrimitiveGUI::PrimitiveGUI( GeometryGUI* parent ) : GEOMGUI( parent ) { - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeom = myGeomGUI->myComponentGeom; } - //======================================================================= -// function : ~PrimitiveGUI() +// function : ~PrimitiveGUI // purpose : Destructor //======================================================================= PrimitiveGUI::~PrimitiveGUI() { } - //======================================================================= // function : OnGUIEvent() // purpose : //======================================================================= -bool PrimitiveGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) -{ - PrimitiveGUI* aPrimitiveGUI = new PrimitiveGUI(); - aPrimitiveGUI->myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - switch (theCommandID) - { - case 4021: // BOX - { - PrimitiveGUI_BoxDlg* aDlg = new PrimitiveGUI_BoxDlg(parent, "", aPrimitiveGUI, Sel); - break; - } - case 4022: // CYLINDER - { - PrimitiveGUI_CylinderDlg* aDlg = new PrimitiveGUI_CylinderDlg(parent, "", aPrimitiveGUI, Sel); - break; - } - case 4023: // SPHERE - { - PrimitiveGUI_SphereDlg* aDlg = new PrimitiveGUI_SphereDlg(parent, "", aPrimitiveGUI, Sel); - break; - } - case 4024: // TORUS - { - PrimitiveGUI_TorusDlg* aDlg = new PrimitiveGUI_TorusDlg(parent, "", aPrimitiveGUI, Sel); - break; - } - case 4025: // CONE - { - PrimitiveGUI_ConeDlg* aDlg = new PrimitiveGUI_ConeDlg(parent, "", aPrimitiveGUI, Sel); - break; - } - default: - { - parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); - break; - } - } - return true; -} - - -//======================================================================= -// function : MakeBoxAndDisplay() -// purpose : -//======================================================================= -void PrimitiveGUI::MakeBoxAndDisplay(const gp_Pnt P1, const gp_Pnt P2) +bool PrimitiveGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) { - try { - GEOM::GEOM_Shape_var box = myGeom->MakeBox(P1.X(), P1.Y(), P1.Z(), P2.X(), P2.Y(), P2.Z()); - box->NameType(tr("GEOM_BOX")); - if(myGeomBase->Display(box)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + + getGeometryGUI()->EmitSignalDeactivateDialog(); + + QDialog* aDlg = NULL; + + switch ( theCommandID ) { + case GEOMOp::OpBox: // BOX + aDlg = new PrimitiveGUI_BoxDlg( getGeometryGUI(), parent ); + break; + case GEOMOp::OpCylinder: // CYLINDER + aDlg = new PrimitiveGUI_CylinderDlg( getGeometryGUI(), parent ); + break; + case GEOMOp::OpSphere: // SPHERE + aDlg = new PrimitiveGUI_SphereDlg( getGeometryGUI(), parent ); + break; + case GEOMOp::OpTorus: // TORUS + aDlg = new PrimitiveGUI_TorusDlg( getGeometryGUI(), parent ); + break; + case GEOMOp::OpCone: // CONE + aDlg = new PrimitiveGUI_ConeDlg( getGeometryGUI(), parent); + break; + case GEOMOp::OpRectangle: // FACE + aDlg = new PrimitiveGUI_FaceDlg( getGeometryGUI(), parent); + break; + case GEOMOp::OpDisk: // DISK + aDlg = new PrimitiveGUI_DiskDlg( getGeometryGUI(), parent); + break; + default: + app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); + break; } -} - -//===================================================================================== -// function : MakeCylinderAndDisplay() -// purpose : -//===================================================================================== -void PrimitiveGUI::MakeCylinderAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, - const double Radius, const double aHeight) -{ - try { - if(Radius <= Precision::Confusion() || aHeight <= Precision::Confusion()) - return; + if ( aDlg != NULL ) + aDlg->show(); - GEOM::PointStruct pstruct = myGeom->MakePointStruct(BasePoint.X(), BasePoint.Y(), BasePoint.Z()); - GEOM::PointStruct d = myGeom->MakePointStruct(aDir.X(), aDir.Y(), aDir.Z()); - GEOM::DirStruct dstruct = myGeom->MakeDirection(d); - - GEOM::GEOM_Shape_var result = myGeom->MakeCylinder(pstruct, dstruct, Radius, aHeight); - if (result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_CYLINDER")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeSphere() -// purpose : -//===================================================================================== -void PrimitiveGUI::MakeSphereAndDisplay(const gp_Pnt aCenterPoint, const double aRadius) -{ - try { - if(aRadius <= Precision::Confusion()) - return; - - GEOM::GEOM_Shape_ptr result = myGeom->MakeSphere(aCenterPoint.X(),aCenterPoint.Y(),aCenterPoint.Z(), aRadius); - result->NameType(tr("GEOM_SPHERE")); - if (myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeTorusAndDisplay() -// purpose : -//===================================================================================== -void PrimitiveGUI::MakeTorusAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, - const double Radius1, const double Radius2) -{ - try { - if(Radius1 <= Precision::Confusion() || Radius2 <= Precision::Confusion()) - return; - - GEOM::PointStruct pstruct = myGeom->MakePointStruct(BasePoint.X(), BasePoint.Y(), BasePoint.Z()); - GEOM::PointStruct d = myGeom ->MakePointStruct(aDir.X(), aDir.Y(), aDir.Z()); - GEOM::DirStruct dstruct = myGeom->MakeDirection(d); - - GEOM::GEOM_Shape_var result = myGeom->MakeTorus(pstruct, dstruct, Radius1, Radius2); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_TORUS")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeConeAndDisplay() -// purpose : -//===================================================================================== -void PrimitiveGUI::MakeConeAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, - const double Radius1, const double Radius2, const double aHeight) -{ - try { - if((Radius1 <= Precision::Confusion() && Radius2 <= Precision::Confusion()) || aHeight <= Precision::Confusion()) - return; - - GEOM::PointStruct pstruct = myGeom->MakePointStruct(BasePoint.X(), BasePoint.Y(), BasePoint.Z()); - GEOM::PointStruct d = myGeom->MakePointStruct(aDir.X(), aDir.Y(), aDir.Z()); - GEOM::DirStruct dstruct = myGeom->MakeDirection(d); - - GEOM::GEOM_Shape_var result = myGeom->MakeCone(pstruct, dstruct, Radius1, Radius2, aHeight); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_CONE")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; + return true; } - //===================================================================================== // EXPORTED METHODS //===================================================================================== extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - {return PrimitiveGUI::OnGUIEvent(theCommandID, parent);} +#ifdef WIN32 + __declspec( dllexport ) +#endif + GEOMGUI* GetLibGUI( GeometryGUI* parent ) + { + return new PrimitiveGUI( parent ); + } }