// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
//
// File : PrimitiveGUI.cxx
// Author : Damien COQUERET
// Module : GEOM
-// $Header:
+// $Header$
+
-using namespace std;
#include "PrimitiveGUI.h"
+#include "GeometryGUI.h"
-#include "SALOMEGUI_QtCatchCorbaException.hxx"
-#include <Precision.hxx>
+#include "SUIT_Session.h"
+#include "SUIT_Desktop.h"
+
+#include "SalomeApp_Application.h"
#include "PrimitiveGUI_BoxDlg.h" // Method BOX
#include "PrimitiveGUI_CylinderDlg.h" // Method CYLINDER
#include "PrimitiveGUI_TorusDlg.h" // Method TORUS
#include "PrimitiveGUI_ConeDlg.h" // Method CONE
+using namespace std;
+
//=======================================================================
// 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)
+bool PrimitiveGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
{
- PrimitiveGUI* aPrimitiveGUI = new PrimitiveGUI();
- aPrimitiveGUI->myGeomGUI->EmitSignalDeactivateDialog();
- SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
+ SalomeApp_Application* app = getGeometryGUI()->getApp();
+ if (!app) return false;
+
+ getGeometryGUI()->EmitSignalDeactivateDialog();
+
+ QDialog* aDlg = NULL;
+
switch (theCommandID)
- {
+ {
case 4021: // BOX
- {
- PrimitiveGUI_BoxDlg* aDlg = new PrimitiveGUI_BoxDlg(parent, "", aPrimitiveGUI, Sel);
+ aDlg = new PrimitiveGUI_BoxDlg(getGeometryGUI(), parent, "");
break;
- }
case 4022: // CYLINDER
- {
- PrimitiveGUI_CylinderDlg* aDlg = new PrimitiveGUI_CylinderDlg(parent, "", aPrimitiveGUI, Sel);
+ aDlg = new PrimitiveGUI_CylinderDlg(getGeometryGUI(), parent, "");
break;
- }
case 4023: // SPHERE
- {
- PrimitiveGUI_SphereDlg* aDlg = new PrimitiveGUI_SphereDlg(parent, "", aPrimitiveGUI, Sel);
+ aDlg = new PrimitiveGUI_SphereDlg(getGeometryGUI(), parent, "");
break;
- }
case 4024: // TORUS
- {
- PrimitiveGUI_TorusDlg* aDlg = new PrimitiveGUI_TorusDlg(parent, "", aPrimitiveGUI, Sel);
+ aDlg = new PrimitiveGUI_TorusDlg(getGeometryGUI(), parent, "");
break;
- }
case 4025: // CONE
- {
- PrimitiveGUI_ConeDlg* aDlg = new PrimitiveGUI_ConeDlg(parent, "", aPrimitiveGUI, Sel);
+ aDlg = new PrimitiveGUI_ConeDlg(getGeometryGUI(), parent, "");
break;
- }
default:
- {
- parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
+ app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
break;
- }
}
- return true;
-}
+ if (aDlg != NULL)
+ aDlg->show();
-//=======================================================================
-// function : MakeBoxAndDisplay()
-// purpose :
-//=======================================================================
-void PrimitiveGUI::MakeBoxAndDisplay(const gp_Pnt P1, const gp_Pnt P2)
-{
- 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);
- }
-}
-
-
-//=====================================================================================
-// 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;
-
- 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;
}
//=====================================================================================
extern "C"
{
- bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
- {return PrimitiveGUI::OnGUIEvent(theCommandID, parent);}
+#ifdef WNT
+ __declspec( dllexport )
+#endif
+ GEOMGUI* GetLibGUI( GeometryGUI* parent )
+ {
+ return new PrimitiveGUI( parent );
+ }
}