From 7f6a21ec4672cd16e6962564272fc7b2256ddd07 Mon Sep 17 00:00:00 2001 From: yfr Date: Thu, 25 Sep 2003 15:49:07 +0000 Subject: [PATCH] DCQ : New Architecture... --- src/GEOMGUI/BooleanGUI.cxx | 128 + src/GEOMGUI/BooleanGUI.h | 58 + src/GEOMGUI/GeometryGUI.cxx | 5711 ++++++++++----------- src/GEOMGUI/GeometryGUI.h | 226 +- src/GEOMGUI/GeometryGUI_1Sel1Spin.cxx | 13 +- src/GEOMGUI/GeometryGUI_1Sel4Spin.cxx | 30 +- src/GEOMGUI/GeometryGUI_1Spin.cxx | 56 + src/GEOMGUI/GeometryGUI_1Spin.h | 47 + src/GEOMGUI/GeometryGUI_1Spin_QTD.cxx | 68 + src/GEOMGUI/GeometryGUI_1Spin_QTD.h | 40 + src/GEOMGUI/GeometryGUI_2Sel1Spin.cxx | 13 +- src/GEOMGUI/GeometryGUI_2Sel2Spin.cxx | 57 + src/GEOMGUI/GeometryGUI_2Sel2Spin.h | 48 + src/GEOMGUI/GeometryGUI_2Sel2Spin_QTD.cxx | 116 + src/GEOMGUI/GeometryGUI_2Sel2Spin_QTD.h | 51 + src/GEOMGUI/GeometryGUI_2Sel3Spin.cxx | 60 + src/GEOMGUI/GeometryGUI_2Sel3Spin.h | 49 + src/GEOMGUI/GeometryGUI_2Sel3Spin_QTD.cxx | 127 + src/GEOMGUI/GeometryGUI_2Sel3Spin_QTD.h | 53 + src/GEOMGUI/GeometryGUI_2Spin.cxx | 60 + src/GEOMGUI/GeometryGUI_2Spin.h | 48 + src/GEOMGUI/GeometryGUI_2Spin_QTD.cxx | 79 + src/GEOMGUI/GeometryGUI_2Spin_QTD.h | 42 + src/GEOMGUI/GeometryGUI_3Spin.cxx | 24 +- src/GEOMGUI/GeometryGUI_BoxDlg.cxx | 17 +- src/GEOMGUI/GeometryGUI_BoxDlg.h | 8 +- src/GEOMGUI/GeometryGUI_CommonDlg.cxx | 460 +- src/GEOMGUI/GeometryGUI_CommonDlg.h | 83 +- src/GEOMGUI/GeometryGUI_ConeDlg.cxx | 824 +-- src/GEOMGUI/GeometryGUI_ConeDlg.h | 132 +- src/GEOMGUI/GeometryGUI_CutDlg.cxx | 451 +- src/GEOMGUI/GeometryGUI_CutDlg.h | 82 +- src/GEOMGUI/GeometryGUI_CylinderDlg.cxx | 708 +-- src/GEOMGUI/GeometryGUI_CylinderDlg.h | 122 +- src/GEOMGUI/GeometryGUI_FuseDlg.cxx | 13 +- src/GEOMGUI/GeometryGUI_FuseDlg.h | 18 +- src/GEOMGUI/GeometryGUI_SectionDlg.cxx | 453 +- src/GEOMGUI/GeometryGUI_SectionDlg.h | 82 +- src/GEOMGUI/GeometryGUI_Skeleton.cxx | 16 +- src/GEOMGUI/GeometryGUI_SphereDlg.cxx | 530 +- src/GEOMGUI/GeometryGUI_SphereDlg.h | 99 +- src/GEOMGUI/GeometryGUI_TorusDlg.cxx | 680 +-- src/GEOMGUI/GeometryGUI_TorusDlg.h | 122 +- src/GEOMGUI/Makefile.in | 20 + src/GEOMGUI/PrimitiveGUI.cxx | 239 + src/GEOMGUI/PrimitiveGUI.h | 65 + 46 files changed, 5798 insertions(+), 6630 deletions(-) create mode 100644 src/GEOMGUI/BooleanGUI.cxx create mode 100644 src/GEOMGUI/BooleanGUI.h create mode 100644 src/GEOMGUI/GeometryGUI_1Spin.cxx create mode 100644 src/GEOMGUI/GeometryGUI_1Spin.h create mode 100644 src/GEOMGUI/GeometryGUI_1Spin_QTD.cxx create mode 100644 src/GEOMGUI/GeometryGUI_1Spin_QTD.h create mode 100644 src/GEOMGUI/GeometryGUI_2Sel2Spin.cxx create mode 100644 src/GEOMGUI/GeometryGUI_2Sel2Spin.h create mode 100644 src/GEOMGUI/GeometryGUI_2Sel2Spin_QTD.cxx create mode 100644 src/GEOMGUI/GeometryGUI_2Sel2Spin_QTD.h create mode 100644 src/GEOMGUI/GeometryGUI_2Sel3Spin.cxx create mode 100644 src/GEOMGUI/GeometryGUI_2Sel3Spin.h create mode 100644 src/GEOMGUI/GeometryGUI_2Sel3Spin_QTD.cxx create mode 100644 src/GEOMGUI/GeometryGUI_2Sel3Spin_QTD.h create mode 100644 src/GEOMGUI/GeometryGUI_2Spin.cxx create mode 100644 src/GEOMGUI/GeometryGUI_2Spin.h create mode 100644 src/GEOMGUI/GeometryGUI_2Spin_QTD.cxx create mode 100644 src/GEOMGUI/GeometryGUI_2Spin_QTD.h create mode 100644 src/GEOMGUI/PrimitiveGUI.cxx create mode 100644 src/GEOMGUI/PrimitiveGUI.h diff --git a/src/GEOMGUI/BooleanGUI.cxx b/src/GEOMGUI/BooleanGUI.cxx new file mode 100644 index 000000000..b311a8d13 --- /dev/null +++ b/src/GEOMGUI/BooleanGUI.cxx @@ -0,0 +1,128 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// 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 +// +// +// +// File : BooleanGUI.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "BooleanGUI.h" + +#include "QAD_Application.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + +#include "GeometryGUI_FuseDlg.h" // Method FUSE +#include "GeometryGUI_CommonDlg.h" // Method COMMON +#include "GeometryGUI_CutDlg.h" // Method CUT +#include "GeometryGUI_SectionDlg.h" // Method SECTION + +//======================================================================= +// function : BooleanGUI() +// purpose : Constructor +//======================================================================= +BooleanGUI::BooleanGUI() : + QObject() +{ + myGeomGUI = GeometryGUI::GetGeometryGUI(); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); +} + + +//======================================================================= +// function : ~BooleanGUI() +// purpose : Destructor +//======================================================================= +BooleanGUI::~BooleanGUI() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool BooleanGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + switch (theCommandID) + { + case 4011: // FUSE + { + GeometryGUI_FuseDlg *aDlg = new GeometryGUI_FuseDlg(parent, "", this, Sel); + break; + } + case 4012: // COMMON + { + GeometryGUI_CommonDlg *aDlg = new GeometryGUI_CommonDlg(parent, "", this, Sel); + break; + } + case 4013: // CUT + { + GeometryGUI_CutDlg *aDlg = new GeometryGUI_CutDlg(parent, "", this, Sel); + break; + } + case 4014: // SECTION + { + GeometryGUI_SectionDlg *aDlg = new GeometryGUI_SectionDlg(parent, "", this, Sel); + break; + } + default: + { + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + } + return true; +} + + +//======================================================================= +// function : MakeBooleanAndDisplay() +// purpose : +//======================================================================= +void BooleanGUI::MakeBooleanAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2, const short operation) +{ + try { + GEOM::GEOM_Shape_ptr result = myGeom->MakeBoolean(Shape1, Shape2, operation); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + result->NameType(type); + + if (myGeomGUI->Display(result, "")) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} diff --git a/src/GEOMGUI/BooleanGUI.h b/src/GEOMGUI/BooleanGUI.h new file mode 100644 index 000000000..bfc348c08 --- /dev/null +++ b/src/GEOMGUI/BooleanGUI.h @@ -0,0 +1,58 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// 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 +// +// +// +// File : BooleanGUI.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef BOOLEANGUI_H +#define BOOLEANGUI_H + +#include "GeometryGUI.h" + +//================================================================================= +// class : BooleanGUI +// purpose : +//================================================================================= +class BooleanGUI : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + BooleanGUI(); + ~BooleanGUI(); + + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + + void MakeBooleanAndDisplay(GEOM::GEOM_Shape_ptr Shape1, + GEOM::GEOM_Shape_ptr Shape2, + const short operation); + +private: + GeometryGUI* myGeomGUI; + GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + +}; + +#endif diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 3130e612a..d16a2e41e 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -156,7 +156,7 @@ using namespace std; #include "VTKViewer_RenderWindowInteractor.h" #include "VTKViewer_ViewFrame.h" #include "GEOM_Actor.h" -#include "GEOM_Client.hxx" +//#include "GEOM_Client.hxx" #include "GEOM_AISShape.hxx" #include "GEOM_AssemblyBuilder.h" #include "GEOM_InteractiveObject.hxx" @@ -165,19 +165,14 @@ using namespace std; #include "GeometryGUI_aParameterDlg.h" #include "GeometryGUI_PointDlg.h" // Method POINT -#include "GeometryGUI_BoxDlg.h" // Method BOX + #include "GeometryGUI_VectorDlg.h" // Method VECTOR #include "GeometryGUI_PlaneDlg.h" // Method PLANE #include "GeometryGUI_PrismDlg.h" // Method PRISM -#include "GeometryGUI_FuseDlg.h" // Method FUSE -#include "GeometryGUI_CommonDlg.h" // Method COMMON -#include "GeometryGUI_CutDlg.h" // Method CUT -#include "GeometryGUI_SectionDlg.h" // Method SECTION - #include "GeometryGUI_LineDlg.h" // Method LINE #include "GeometryGUI_ScaleDlg.h" // Method SCALE #include "GeometryGUI_MirrorDlg.h" // Method MIRROR -#include "GeometryGUI_SphereDlg.h" // Method SPHERE + #include "GeometryGUI_CircleDlg.h" // Method CIRCLE #include "GeometryGUI_EllipseDlg.h" // Method ELLIPSE #include "GeometryGUI_RevolDlg.h" // Method REVOL @@ -187,9 +182,6 @@ using namespace std; #include "GeometryGUI_MultiRotationDlg.h" // Method MULTI ROTATION #include "GeometryGUI_ArcDlg.h" // Method ARC #include "GeometryGUI_PipeDlg.h" // Method PIPE -#include "GeometryGUI_CylinderDlg.h" // Method CYLINDER -#include "GeometryGUI_ConeDlg.h" // Method CONE -#include "GeometryGUI_TorusDlg.h" // Method TORUS #include "GeometryGUI_FillingDlg.h" // Method FILLING #include "GeometryGUI_SewingDlg.h" // Method SEWING #include "GeometryGUI_CompoundDlg.h" // Method GEOM::COMPOUND @@ -219,22 +211,16 @@ using namespace std; #include "GeometryGUI_DistanceDlg.h" // Method DISTANCE #include "GeometryGUI_SuppressHoleDlg.h" // Method SUPPRESS HOLE +#include "BooleanGUI.h" +#include "PrimitiveGUI.h" static Handle(AIS_Shape) theConstructionShape = new AIS_Shape(TopoDS_Shape()); static Handle(GEOM_AISShape) theSelectedShape = new GEOM_AISShape(TopoDS_Shape(), ""); -static AIS_ListOfInteractive ListDisplayedObject; - -static bool Settings_AddInStudy = false; -static bool Settings_Copy = false; -static Standard_CString Fatherior = ""; -static GEOM_Client ShapeReader; - /* The object itself created in the static method 'GetOrCreateGeometryGUI()' */ static GeometryGUI* GeomGUI = 0; - //======================================================================= // class : CustomItem // purpose : Set Font to a text. @@ -271,6 +257,9 @@ private: GeometryGUI::GeometryGUI() : QObject() { + mySettings_AddInStudy = false; + mySettings_Copy = false; + myFatherior = ""; } //======================================================================= @@ -373,6 +362,7 @@ GeometryGUI* GeometryGUI::GetOrCreateGeometryGUI( QAD_Desktop* desktop ) /* study may have changed */ GeomGUI->myActiveStudy = desktop->getActiveStudy(); } + return GeomGUI; } @@ -437,7 +427,7 @@ bool GeometryGUI::GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds) Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); /* case SObject */ if ( IO->hasEntry() ) { - SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument(); + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() ); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeIOR_var anIOR; @@ -677,7 +667,7 @@ GEOM_Actor* GeometryGUI::ConvertIORinGEOMActor( const char * IOR, Standard_Boolean& testResult, bool onlyInActiveView ) { - int nbSf = GeomGUI->myActiveStudy->getStudyFramesCount(); + int nbSf = myActiveStudy->getStudyFramesCount(); for ( int i = 0; i < nbSf; i++ ) { QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); if ( sf->getTypeView() == VIEW_VTK ) { @@ -693,7 +683,7 @@ GEOM_Actor* GeometryGUI::ConvertIORinGEOMActor( const char * IOR, Standard_CString theIOR = GIO->getIOR(); if ( strcmp( IOR, theIOR ) == 0 ) { if ( onlyInActiveView ) { - if ( sf == GeomGUI->myActiveStudy->getActiveStudyFrame() ) { + if ( sf == myActiveStudy->getActiveStudyFrame() ) { testResult = true; return anActor; } @@ -724,7 +714,7 @@ GEOM::GEOM_Shape_ptr GeometryGUI::ConvertIOinGEOMShape( const Handle(SALOME_Inte /* case SObject */ if ( IO->hasEntry() ) { - SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument(); + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() ); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeIOR_var anIOR; @@ -766,7 +756,7 @@ void GeometryGUI::ConvertListOfIOInListOfIOR( const SALOME_ListIO& aList, if ( IObject->hasEntry() ) { - SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument(); + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeIOR_var anIOR; @@ -877,7 +867,7 @@ bool GeometryGUI::GetShapeTypeString( const TopoDS_Shape& aShape, Standard_CStri //================================================================================= bool GeometryGUI::CreateArrowForLinearEdge( const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone ) { - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC || tds.ShapeType() != TopAbs_EDGE ) + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC || tds.ShapeType() != TopAbs_EDGE ) return false; OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort(); @@ -1003,23 +993,7 @@ void GeometryGUI::MakeVectorAndDisplay( const gp_Pnt P1, const gp_Pnt P2 ) } -//======================================================================= -// function : MakeBoxAndDisplay() -// purpose : -//======================================================================= -void GeometryGUI::MakeBoxAndDisplay( const gp_Pnt P1, const gp_Pnt P2 ) -{ - try { - GEOM::GEOM_Shape_var box = myComponentGeom->MakeBox( P1.X(), P1.Y(), P1.Z(), P2.X(), P2.Y(), P2.Z() ); - box->NameType(tr("GEOM_BOX")); - if ( Display( box, "") ) { - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -} + @@ -1057,8 +1031,8 @@ void GeometryGUI::MakePlaneAndDisplay( const gp_Pnt P1, const Standard_Re //======================================================================= void GeometryGUI::MakeWorkingPlane( const gp_Pnt P, const gp_Dir D) { - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC) { - GeomGUI->myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ; + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC) { + myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ; return ; } OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort(); @@ -1089,7 +1063,7 @@ void GeometryGUI::MakePrismAndDisplay( GEOM::GEOM_Shape_ptr BaseShape, const gp_ return ; } - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); Standard_CString type; GetShapeTypeString(S,type); result->NameType( type ); @@ -1154,155 +1128,14 @@ void GeometryGUI::MakeLineAndDisplay( const gp_Pnt InitPoint, const gp_Pnt LastP -//======================================================================= -// function : MakeBooleanAndDisplay() -// purpose : -//======================================================================= -void GeometryGUI::MakeBooleanAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2, const short operation ) -{ - try { - GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeBoolean( Shape1, Shape2, operation ) ; - if (result->_is_nil()) { - myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result); - Standard_CString type; - GetShapeTypeString(S,type); - result->NameType( type ); - - if ( Display( result, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} -//===================================================================================== -// function : MakeSphere() -// purpose : -//===================================================================================== -void GeometryGUI::MakeSphereAndDisplay( const gp_Pnt aCenterPoint, const double aRadius ) -{ - try { - if( aRadius <= Precision::Confusion() ) { - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("GEOM_WRN_WARNING"), - tr ("GEOM_WRN_RADIUS_NULL"), tr ("GEOM_BUT_YES") ); - return ; - } - GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeSphere(aCenterPoint.X(),aCenterPoint.Y(),aCenterPoint.Z(), aRadius); - result->NameType(tr("GEOM_SPHERE")); - if ( Display( result, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} -//===================================================================================== -// function : MakeConeAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::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 = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ; - GEOM::PointStruct d = myComponentGeom->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ; - GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ; - - GEOM::GEOM_Shape_var result = myComponentGeom->MakeCone( pstruct, dstruct, Radius1, Radius2, aHeight ) ; - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - return ; - } - result->NameType(tr("GEOM_CONE")); - if ( Display( result, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} -//===================================================================================== -// function : MakeCylinderAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::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 = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ; - GEOM::PointStruct d = myComponentGeom ->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ; - GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ; - - GEOM::GEOM_Shape_var result = myComponentGeom->MakeCylinder(pstruct, dstruct, Radius, aHeight) ; - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - return ; - } - result->NameType(tr("GEOM_CYLINDER")); - if ( Display( result, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} -//===================================================================================== -// function : MakeTorusAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::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 = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ; - GEOM::PointStruct d = myComponentGeom ->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ; - GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ; - - GEOM::GEOM_Shape_var result = myComponentGeom->MakeTorus(pstruct, dstruct, Radius1, Radius2) ; - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - return ; - } - result->NameType(tr("GEOM_TORUS")); - if ( Display( result, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - //===================================================================================== // function : MakePipeAndDisplay() @@ -1314,7 +1147,7 @@ void GeometryGUI::MakePipeAndDisplay( GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Sha GEOM::GEOM_Shape_ptr result = myComponentGeom->MakePipe(aPath, aBase); if ( !result->_is_nil() && Display( result, "") ) { - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); Standard_CString type; GetShapeTypeString(S,type); result->NameType( type ); @@ -1352,7 +1185,7 @@ void GeometryGUI::MakeFillingAndDisplay( GEOM::GEOM_Shape_ptr SectionShape, return ; } - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); Standard_CString type; GetShapeTypeString(S,type); result->NameType( type ); @@ -1405,7 +1238,7 @@ void GeometryGUI::MakeSewingAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR return ; } - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); Standard_CString type; GetShapeTypeString(S,type); result->NameType( type ); @@ -1600,7 +1433,7 @@ void GeometryGUI::MakeRevolutionAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp return ; } - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); Standard_CString type; GetShapeTypeString(S,type); result->NameType( type ); @@ -1992,6 +1825,16 @@ QAD_Desktop* GeometryGUI::GetDesktop() } +//======================================================================= +// function : GetShapeReader() +// purpose : +//======================================================================= +GEOM_Client& GeometryGUI::GetShapeReader() +{ + return this->myShapeReader ; +} + + //===================================================================================== // function : OnSubShapeGetAll() // purpose : Explode a shape in all sub shapes with a SubShapeType @@ -2033,12 +1876,12 @@ bool GeometryGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Sh QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); op->start(); - TopoDS_Shape mainTopo = ShapeReader.GetShape(myComponentGeom, aShape); + TopoDS_Shape mainTopo = myShapeReader.GetShape(myComponentGeom, aShape); TopoDS_Shape mainShape; bool main = false; while ( !main ) { if ( aShape->IsMainShape() ) { - mainShape = ShapeReader.GetShape(myComponentGeom, aShape); + mainShape = myShapeReader.GetShape(myComponentGeom, aShape); main = true; } else aShape = myComponentGeom->GetIORFromString( aShape->MainName() ); @@ -2050,7 +1893,7 @@ bool GeometryGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Sh /* Get each sub shape extracted CORBA and OCC */ aResult = listGeomShapes[j] ; - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, aResult); if ( S.IsNull() ) { myDesktop->putInfo (tr("GEOM_PRP_ABORT")); @@ -2081,12 +1924,12 @@ bool GeometryGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Sh bool allreadyexist = false; - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); Handle(GEOM_AISShape) result = new GEOM_AISShape( S, nameG ); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM"); + Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), myFatherior, "GEOM"); MESSAGE ( "SO->_is_nil() " << SO->_is_nil() ) @@ -2142,14 +1985,14 @@ bool GeometryGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Sh if ( !allreadyexist ) ic->Display(result); - } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + } else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); int themode = myRenderInter->GetDisplayMode(); - vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior,"GEOM"); + Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), myFatherior,"GEOM"); if ( SO->_is_nil() ) { SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj ); @@ -2313,13 +2156,13 @@ bool GeometryGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo, } GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR ); - TopoDS_Shape mainTopo = ShapeReader.GetShape(myComponentGeom, aShape); + TopoDS_Shape mainTopo = myShapeReader.GetShape(myComponentGeom, aShape); TopoDS_Shape mainShape; bool main = false; while ( !main ) { if ( aShape->IsMainShape() ) { - mainShape = ShapeReader.GetShape(myComponentGeom, aShape); + mainShape = myShapeReader.GetShape(myComponentGeom, aShape); main = true; } else aShape = myComponentGeom->GetIORFromString( aShape->MainName() ); @@ -2380,7 +2223,7 @@ bool GeometryGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo, sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ ); } result = new GEOM_AISShape( Exp.Current(), nameG ); - IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM"); + IO = new GEOM_InteractiveObject(aResult->Name(), myFatherior, "GEOM"); } } else { @@ -2392,7 +2235,7 @@ bool GeometryGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo, sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ ); } result = new GEOM_AISShape( compound, nameG ); - IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM"); + IO = new GEOM_InteractiveObject(aResult->Name(), myFatherior, "GEOM"); } SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() ); @@ -2544,7 +2387,7 @@ bool GeometryGUI::OnSuppressFaces( const TopoDS_Shape& ShapeTopo, for( int i=0; ilength(); i++ ) { GEOM::GEOM_Shape_var aShellOrFace = listGeomShapes[i] ; - TopoDS_Shape S = ShapeReader.GetShape( this->myComponentGeom, aShellOrFace ); + TopoDS_Shape S = myShapeReader.GetShape( this->myComponentGeom, aShellOrFace ); if( S.IsNull() ) { return false ; @@ -2594,7 +2437,7 @@ bool GeometryGUI::OnSuppressHole( const char* ShapeTopoIOR, GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR ); GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHole( aShape, ListOfIdFace, ListOfIdWire, ListOfIdEndFace ) ; - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, aResult); Standard_CString type; GetShapeTypeString(S,type); aResult->NameType( type ); @@ -2626,7 +2469,7 @@ bool GeometryGUI::OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR, GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR ); GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHolesInFaceOrShell( aShape, ListOfIdWires ) ; - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, aResult); Standard_CString type; GetShapeTypeString(S,type); aResult->NameType( type ); @@ -2642,43 +2485,7 @@ bool GeometryGUI::OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR, -//======================================================================= -// function : activeStudyChanged() -// purpose : static -//======================================================================= -void GeometryGUI::activeStudyChanged( QAD_Desktop* parent ) -{ - MESSAGE ("GeometryGUI::activeStudyChanged init.") - /* Create or retrieve an object GeomGUI */ - GeometryGUI::GetOrCreateGeometryGUI(parent); - if(GeomGUI != 0) { - if (GeomGUI->myState == CURRENT_SKETCH) { - GeomGUI->mySketcher.Clear(); - GeomGUI->ResetState(); - } - - QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar(); - bool ViewOCC = false; - if ( GeomGUI->myDesktop->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) - ViewOCC = true; - - Mb->setItemEnabled( 312, ViewOCC); //Sketch - Mb->setItemEnabled( 309, ViewOCC); //SuppressFace - Mb->setItemEnabled( 314, ViewOCC); //SuppressHole - - Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings - Mb->setItemEnabled( 704, ViewOCC);// Isos Settings - - GeomGUI->EraseSimulationShape() ; - GeomGUI->EmitSignalCloseAllDialogs() ; - GeomGUI = 0 ; - } - - // GeomGUI->SetSettings( parent ); - // MESSAGE ("GeometryGUI::activeStudyChanged done.") - return ; -} //======================================================================= @@ -2694,1742 +2501,6 @@ bool GeometryGUI::DefineDlgPosition(QWidget* aDlg, int& x, int& y) return true ; } -//======================================================================= -// function : OnGUIEvent() [static] -// purpose : manage all events on GUI -//======================================================================= -bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) -{ - /* Create or retrieve an object GeomGUI */ - GeometryGUI::GetOrCreateGeometryGUI(parent); - - SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - - OCCViewer_Viewer3d* v3d; - Handle(AIS_InteractiveContext) ic; - vtkRenderer* Renderer; - - QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar(); - - bool ViewOCC = false; - - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - ic = v3d->getAISContext(); - ViewOCC = true; - Mb->setItemEnabled( 312, ViewOCC);//Sketch - Mb->setItemEnabled( 309, ViewOCC);//SuppressFace - Mb->setItemEnabled( 314, ViewOCC);//SuppressHole - - Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings - Mb->setItemEnabled( 704, ViewOCC);// Isos Settings - - } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - Renderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - - // OnSuppressFaces, OnSuppressHole, SETTINGS - SHADING COLOR, SETTINGS - ISOS, SETTINGS : STEP VALUE FOR SPIN BOXES, SKETCHER, ISOS - POPUP VIEWER, - Mb->setItemEnabled( 312, ViewOCC);//Sketch - Mb->setItemEnabled( 309, ViewOCC);//SuppressFace - Mb->setItemEnabled( 314, ViewOCC);//SuppressHole - - Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings - Mb->setItemEnabled( 704, ViewOCC);// Isos Settings - } else { - return 0; - } - - if (GeomGUI->myState == CURRENT_SKETCH && theCommandID != 10000 && theCommandID != 10001 && theCommandID != 10002 && theCommandID != 10003 && theCommandID != 10004 && theCommandID != 10006 && theCommandID != 10007 && theCommandID != 10008 && theCommandID != 10010 && theCommandID != 10011 && theCommandID != 10012 && theCommandID != 10013 && theCommandID != 10014 && theCommandID != 3133 && theCommandID != 3134) - return false; - - switch (theCommandID) - { - case 31: // COPY - GeomGUI->OnEditCopy(); - break; - - case 33: // DELETE - GeomGUI->OnEditDelete(); - break; - - case 111: - { - GeomGUI->SetState(111); - GeomGUI->Import(); - GeomGUI->ResetState(); - break; - } - case 112: - { - GeomGUI->SetState(112); - GeomGUI->Import(); - GeomGUI->ResetState(); - break; - } - case 113: // IMPORT STEP - { - GeomGUI->SetState(113); - GeomGUI->Import(); - GeomGUI->ResetState(); - break; - } - - case 121: // EXPORT BREP - { - GeomGUI->SetState(121); - GeomGUI->Export(); - GeomGUI->ResetState(); - break; - } - - case 122: // EXPORT IGES - { - GeomGUI->SetState(122); - GeomGUI->Export(); - GeomGUI->ResetState(); - break; - } - - case 123: // EXPORT STEP - { - GeomGUI->SetState(123); - GeomGUI->Export(); - GeomGUI->ResetState(); - break; - } - - case 303: // EXPLODE : use ic - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_SubShapeDlg *aDlg = new GeometryGUI_SubShapeDlg( parent, "", Sel, ic ) ; - break ; - } - - case 304: // GEOM::EDGE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_EdgeDlg *aDlg = new GeometryGUI_EdgeDlg( parent, "", Sel ) ; - break ; - } - - case 305: // GEOM::WIRE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_WireDlg *aDlg = new GeometryGUI_WireDlg( parent, "", Sel ) ; - break ; - } - - case 306: // GEOM::FACE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_FaceDlg *aDlg = new GeometryGUI_FaceDlg ( parent, "", Sel ) ; - break ; - } - - case 315: // GEOM::SHELL - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_ShellDlg *aDlg = new GeometryGUI_ShellDlg ( parent, "", Sel ) ; - break ; - } - - case 316: // GEOM::SOLID - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_SolidDlg *aDlg = new GeometryGUI_SolidDlg ( parent, "", Sel ) ; - break ; - } - - case 308: // GEOM::COMPOUND - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_CompoundDlg *aDlg = new GeometryGUI_CompoundDlg ( parent, "", Sel ) ; - break ; - } - - case 309: // SUPPRESS FACES : use ic - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_SuppressFacesDlg *aDlg = new GeometryGUI_SuppressFacesDlg( parent, "", Sel, ic ) ; - break ; - } - - case 314: // SUPPRESS HOLES : use ic - { - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_SuppressHoleDlg *aDlg = new GeometryGUI_SuppressHoleDlg( parent, "", Sel, ic ) ; - } - else { - GeomGUI->myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ; - } - break ; - } - case 501: // SEWING - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_SewingDlg *aDlg = new GeometryGUI_SewingDlg ( parent, "", Sel ) ; - break ; - } - - case 502: // ORIENTATION - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_OrientationDlg *aDlg = new GeometryGUI_OrientationDlg( parent, "", Sel ) ; - break ; - } - - case 601: // PROPERTIES (Length, surface, volume) - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_PropertiesDlg *aDlg = new GeometryGUI_PropertiesDlg( parent, "", Sel ) ; - break ; - } - - case 604: // CDG : Center of mass - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_CenterMassDlg *aDlg = new GeometryGUI_CenterMassDlg ( parent, "", Sel ) ; - break ; - } - - case 605: // INERTIA - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_InertiaDlg *aDlg = new GeometryGUI_InertiaDlg( parent, "", Sel ) ; - break ; - } - - case 607: // MAXTOLERANCE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_MaxToleranceDlg *aDlg = new GeometryGUI_MaxToleranceDlg( parent, "", Sel ) ; - break ; - } - - case 608: // WHATIS - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_WhatisDlg *aDlg = new GeometryGUI_WhatisDlg( parent, "", Sel ) ; - break ; - } - - case 609: // CHECKSHAPE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_CheckShape *aDlg = new GeometryGUI_CheckShape( parent, "", Sel ) ; - break ; - } - - case 701: // SETTINGS - COPY - { - QMenuData* pp; - QMenuItem* item = parent->menuBar()->findItem(701,&pp); - bool check = !pp->isItemChecked(701); - pp->setItemChecked(701,check); - Settings_Copy = check; - QAD_CONFIG->addSetting( "Geometry:SettingsCopy", Settings_Copy ); - break; - } - - case 702: // SETTINGS - ADD IN STUDY - { - QMenuData* pp; - QMenuItem* item = parent->menuBar()->findItem(702,&pp); - bool check = !pp->isItemChecked(702); - pp->setItemChecked(702,check); - Settings_AddInStudy = check; - - QAD_CONFIG->addSetting( "Geometry:SettingsAddInStudy", Settings_AddInStudy ); - break; - } - - case 703: // SETTINGS - SHADING COLOR - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - - QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed"); - QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen"); - QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue"); - QColor color; - if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() ) { - color = QColor (SCr.toInt(), - SCg.toInt(), - SCb.toInt()); - } else { - Quantity_Color Default = Quantity_Color(); - color = QColor ( (int)Default.Red() * 255.0, - (int)Default.Green()* 255.0, - (int)Default.Blue() * 255.0 ); - } - - QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() ); - if ( c.isValid() ) { - GeomGUI->myShadingColor = Quantity_Color(c.red() / 255.0, - c.green()/ 255.0, - c.blue() / 255.0, - Quantity_TOC_RGB); - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListOfInteractive List1; - ic->ObjectsInCollector(List1); - List.Append(List1); - - AIS_ListIteratorOfListOfInteractive ite(List); - while (ite.More()) { - if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - aSh->SetShadingColor( GeomGUI->myShadingColor ); - ic->Redisplay( aSh, Standard_True, Standard_True); - } - ite.Next(); - } - - ic->UpdateCurrentViewer(); - - QAD_CONFIG->addSetting("Geometry:SettingsShadingColorRed", c.red() ); - QAD_CONFIG->addSetting("Geometry:SettingsShadingColorGreen", c.green() ); - QAD_CONFIG->addSetting("Geometry:SettingsShadingColorBlue", c.blue() ); - } - break; - } - - - case 704: // SETTINGS - ISOS - { - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - - QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); - QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); - if ( !IsoU.isEmpty() ) - ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt()); - else - IsoU = "1"; - if ( !IsoV.isEmpty() ) - ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt()); - else - IsoV = "1"; - - GeometryGUI_NbIsosDlg * NbIsosDlg = new GeometryGUI_NbIsosDlg( QAD_Application::getDesktop(), - tr("GEOM_MEN_ISOS"), TRUE ); - int UIso = IsoU.toInt(); - int VIso = IsoV.toInt(); - - NbIsosDlg->SpinBoxU->setValue(UIso) ; - NbIsosDlg->SpinBoxV->setValue(VIso) ; - - if ( NbIsosDlg->exec() ) { - UIso = NbIsosDlg->SpinBoxU->text().toInt() ; - VIso = NbIsosDlg->SpinBoxV->text().toInt() ; - - ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso); - ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso); - QAD_CONFIG->addSetting( "Geometry:SettingsIsoU", NbIsosDlg->SpinBoxU->text() ); /* text format */ - QAD_CONFIG->addSetting( "Geometry:SettingsIsoV", NbIsosDlg->SpinBoxV->text() ); /* text format */ - } - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListOfInteractive List1; - ic->ObjectsInCollector(List1); - List.Append(List1); - - AIS_ListIteratorOfListOfInteractive ite(List); - ic->InitCurrent(); - if ( ic->NbCurrents() ) - while (ite.More()) { - if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - Handle (AIS_Drawer) CurDrawer; - CurDrawer = aSh->Attributes(); - CurDrawer->UIsoAspect()->SetNumber( UIso ); - CurDrawer->VIsoAspect()->SetNumber( VIso ); - ic->SetLocalAttributes(aSh, CurDrawer); - ic->Redisplay(aSh); - } - ite.Next(); - } - ic->UpdateCurrentViewer(); - break; - } - - case 705: // SETTINGS : STEP VALUE FOR SPIN BOXES - { - //NRI if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - //NRI break; - - QString step = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ); - if( step.isEmpty() ) - step = "100.0" ; - - Standard_Boolean res = false ; - double dd = Parameter( res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3 ) ; - if( res ) { - QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", QString("%1").arg(dd) ) ; - - /* Emit signal to GeometryGUI_SpinBoxes */ - GeomGUI->SignalDefaultStepValueChanged( dd ) ; - } - else - parent->putInfo(tr("GEOM_PRP_ABORT")); - - break ; - } - - case 801: // ADD IN STUDY - POPUP VIEWER - { - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - const SALOME_ListIO& ListSelected = Sel->StoredIObjects(); - SALOME_ListIteratorOfListIO It( ListSelected ); - for ( ; It.More(); It.Next() ) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - GeomGUI->AddInStudy(true, IObject); - } - /* Is set on the dialog box */ - QApplication::restoreOverrideCursor(); - break; - } - - case 901: // RENAME - { - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - for ( ; It.More(); It.Next() ) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - if ( !obj->_is_nil() ) { - if (obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - - QString nm = QString( aName->Value() ); - nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), nm ); - if ( !nm.isEmpty() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - GeomGUI->myActiveStudy->renameIObject( IObject, nm ); - QApplication::restoreOverrideCursor(); - } - } - } - } - break; - } - - case 903: // DISPLAY OBJECT BROWSER - { - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - // VTK - QApplication::setOverrideCursor( Qt::waitCursor ); - - SALOMEDS::SObject_var fatherSF = - aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry()); - - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); - - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - - if(myRenderInter->isInViewer(IObject)) { - myRenderInter->Display(IObject); - } - else { - // Create new actor - if ( !obj->_is_nil() ) { - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape); - - if (obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* theAllActors = theRenderer->GetActors(); - theAllActors->InitTraversal(); - vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); - Handle(SALOME_InteractiveObject) anIObj; - // don't create new study object if it already exists - bool isDisplayed = false; - while(!(actor==NULL)) { - SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor); - if (Gactor!=NULL) { - if (Gactor->hasIO()) { - if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) { - isDisplayed = true; - anIObj = Gactor->getIO(); - if (!anIObj.IsNull()) myRenderInter->Display(anIObj); - } - } - } - actor=(vtkActor*)(theAllActors->GetNextActor()); - } - if (!isDisplayed) { - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy ); - op->start(); - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, obj); - // commit transaction - op->finish(); - - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - int themode = myRenderInter->GetDisplayMode(); - - vtkActorCollection* theActors = - GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True); - theActors->InitTraversal(); - vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); - while(!(anActor==NULL)) { - GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor ); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM"); - IO->setEntry(obj->GetID()); - GActor->setIO( IO ); - GActor->setName( IObject->getName() ); - - theRenderer->AddActor(GActor); - renWin->Render(); - anActor = (vtkActor*)theActors->GetNextActor(); - } - } - } - // next item iteration - if (useSubItems) { - anIter->Next(); - anAttr = SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - } - GeomGUI->myActiveStudy->updateObjBrowser( true ); - QApplication::restoreOverrideCursor(); - - } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - - SALOMEDS::SObject_var fatherSF = - aStudy->FindObjectID( GeomGUI->myActiveStudy->getActiveStudyFrame()->entry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - - if ( v3d->isInViewer( IObject, true ) ) { - Standard_Boolean found; - Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( IObject, found, true ); - if ( found ) { - ic->Display(aSh); - ic->AddOrRemoveCurrentObject(aSh, true); - } - - } else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); - if ( !obj->_is_nil() ) { - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape); - if (obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - // searchin for already displayed objects with the same shape - AIS_ListOfInteractive aDisplayed; - ic->DisplayedObjects(aDisplayed); - AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); - Handle(AIS_Shape) anAISShape; - for(;anIObjects.More();anIObjects.Next()) { - anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); - if (!anAISShape.IsNull()) { - if (anAISShape->Shape().IsSame(Shape)) break; - anAISShape.Nullify(); - } - } - if (!anAISShape.IsNull()) { - if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape); - } else { - if (!useSubItems) { - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy ); - op->start(); - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, obj); - // commit transaction - op->finish(); - } - - Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value()); - aSh->SetShadingColor( GeomGUI->myShadingColor ); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), - Fatherior, - "GEOM"); - IO->setEntry(obj->GetID()); - aSh->setIO( IO ); - aSh->setName( aName->Value() ); - ic->Display (aSh); - if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, true); - } - } - // next item iteration - if (useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - } - GeomGUI->myActiveStudy->updateObjBrowser( true ); - QApplication::restoreOverrideCursor(); - } - break; - } - - case 3011: // POINT - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_PointDlg *aDlg = new GeometryGUI_PointDlg( parent, "", Sel, ic ) ; - break; - } - - case 3012: // LINE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_LineDlg *aDlg = new GeometryGUI_LineDlg( parent, "", Sel ) ; - break ; - } - - case 3013: // CIRCLE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_CircleDlg *aDlg = new GeometryGUI_CircleDlg( parent, "", Sel ) ; - break ; - } - - case 3014: // ELLIPSE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_EllipseDlg *aDlg = new GeometryGUI_EllipseDlg( parent, "", Sel ) ; - break ; - } - - case 3015: // ARC - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_ArcDlg *aDlg = new GeometryGUI_ArcDlg( parent, "", Sel ) ; - break ; - } - - case 3016: // VECTOR - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_VectorDlg *aDlg = new GeometryGUI_VectorDlg( parent, "", Sel ) ; - break; - } - - case 3017: // PLANE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_PlaneDlg *aDlg = new GeometryGUI_PlaneDlg( parent, "", Sel ) ; - break; - } - - case 3018: // WORKING PLANE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_WorkingPlaneDlg *aDlg = new GeometryGUI_WorkingPlaneDlg( parent, "", Sel ) ; - break; - } - - case 312: // SKETCHER - { - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - break; - - GeomGUI->EmitSignalDeactivateDialog() ; - - ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTop(); // DCQ : 28/02/2002 - - GeomGUI->mySketcher = Sketch( v3d->getViewer3d() ); - GeomGUI->SetState(CURRENT_SKETCH); - - QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar(); - QMenuData* pp; - - QMenuItem* item = Mb->findItem(10010,&pp); - GeomGUI->mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010)); - item = Mb->findItem(10011,&pp); - GeomGUI->mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011)); - item = Mb->findItem(10012,&pp); - GeomGUI->mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012)); - item = Mb->findItem(10013,&pp); - GeomGUI->mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013)); - item = Mb->findItem(10014,&pp); - GeomGUI->mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014)); - - GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT); - item = Mb->findItem(3133,&pp); - pp->setItemChecked(3133,false); - item = Mb->findItem(3134,&pp); - pp->setItemChecked(3134,false); - break; - } - - case 3021: // BOX - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_BoxDlg *aDlg = new GeometryGUI_BoxDlg( parent, "", Sel ) ; - break; - } - - case 3022: // CYLINDER - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_CylinderDlg *aDlg = new GeometryGUI_CylinderDlg( parent, "", Sel ) ; - break; - } - - case 3023: // SPHERE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_SphereDlg *aDlg = new GeometryGUI_SphereDlg( parent, "", Sel ) ; - break; - } - - case 3024: // TORUS - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_TorusDlg *aDlg = new GeometryGUI_TorusDlg( parent, "", Sel ) ; - break; - } - - case 3025: // CONE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_ConeDlg *aDlg = new GeometryGUI_ConeDlg( parent, "", Sel ) ; - break; - } - - case 3131: - { - break; - } - - case 3133: // sketcher - { - QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(3133,&pp); - pp->setItemChecked(3133,!pp->isItemChecked(3133)); - if (pp->isItemChecked(3133) == true) - GeomGUI->mySketcher.SetTransitionStatus(TANGENT); - else - GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT); - - pp->setItemChecked(3134,false); - break; - } - - case 3134: // sketcher - { - QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(3134,&pp); - pp->setItemChecked(3134,!pp->isItemChecked(3134)); - if (pp->isItemChecked(3134) == true) - GeomGUI->mySketcher.SetTransitionStatus(PERPENDICULAR); - else - GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT); - - pp->setItemChecked(3133,false); - break; - } - - case 4011: // FUSE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_FuseDlg *aDlg = new GeometryGUI_FuseDlg( parent, "", Sel ) ; - break; - } - - case 4012: // COMMON - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_CommonDlg *aDlg = new GeometryGUI_CommonDlg( parent, "", Sel ) ; - break; - } - - case 4013: // CUT - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_CutDlg *aDlg = new GeometryGUI_CutDlg( parent, "", Sel ) ; - break; - } - - case 4014: // SECTION - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_SectionDlg *aDlg = new GeometryGUI_SectionDlg( parent, "", Sel ) ; - break; - } - - case 4021: // TRANSLATION - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_TranslationDlg *aDlg = new GeometryGUI_TranslationDlg( parent, "", Sel ) ; - break; - } - - case 4022: // ROTATION - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_RotationDlg *aDlg = new GeometryGUI_RotationDlg( parent, "", Sel ) ; - break; - } - - case 4030: // MULTI TRANSLATION - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_MultiTranslationDlg *aDlg = new GeometryGUI_MultiTranslationDlg( parent, "", Sel ) ; - break; - } - - case 4040: // MULTI ROTATION - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_MultiRotationDlg *aDlg = new GeometryGUI_MultiRotationDlg( parent, "", Sel ) ; - break; - } - - case 4023: // MIRROR - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_MirrorDlg *aDlg = new GeometryGUI_MirrorDlg( parent, "", Sel ) ; - break; - } - - case 4024: // SCALE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_ScaleDlg *aDlg = new GeometryGUI_ScaleDlg( parent, "", Sel ) ; - break; - } - - case 4025: // PARTITION - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_PartitionDlg *aDlg = new GeometryGUI_PartitionDlg( parent, "", Sel ) ; - break; - } - - case 4026: // ARCHIMEDE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_ArchimedeDlg *aDlg = new GeometryGUI_ArchimedeDlg( parent, "", Sel ) ; - break; - } - - case 4027: // FILLET - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_FilletDlg *aDlg = new GeometryGUI_FilletDlg( parent, "", Sel, ic ) ; - break; - } - - case 4028: // CHAMFER - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_ChamferDlg *aDlg = new GeometryGUI_ChamferDlg( parent, "", Sel, ic ) ; - break; - } - - case 4031: // PRISM - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_PrismDlg *aDlg = new GeometryGUI_PrismDlg( parent, "", Sel ) ; - break; - } - - case 4032: // REVOL - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_RevolDlg *aDlg = new GeometryGUI_RevolDlg( parent, "", Sel ) ; - break; - } - - case 4033: // FILLING - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_FillingDlg *aDlg = new GeometryGUI_FillingDlg( parent, "", Sel ) ; - break; - } - - case 4034: // PIPE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_PipeDlg *aDlg = new GeometryGUI_PipeDlg(parent, "", Sel ) ; - break; - } - - case 5001: // CHECK GEOMETRY - { - QAD_PyEditor* PyEditor = GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getPyEditor(); - PyEditor->setText("from GEOM_usinggeom import *\n"); - PyEditor->setText(">>> "); - PyEditor->handleReturn(); - break; - } - - case 6021: // SHADING - WIREFRAME - { - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - VTKViewer_RenderWindowInteractor* myRenderInter= - ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - QApplication::setOverrideCursor(waitCursor); - - int themode = myRenderInter->GetDisplayMode(); - if( themode==0 ) { - myRenderInter->SetDisplayMode(1); - GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") ); - } else { - myRenderInter->SetDisplayMode(0); - GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") ); - } - - QApplication::restoreOverrideCursor(); - - } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - AIS_DisplayMode mode = ( AIS_DisplayMode )ic->DisplayMode(); - QApplication::setOverrideCursor( Qt::waitCursor ); - AIS_DisplayMode newmode = (mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame); - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListOfInteractive List1; - ic->ObjectsInCollector(List1); - List.Append(List1); - - AIS_ListIteratorOfListOfInteractive ite(List); - while (ite.More()) { - if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - ic->SetDisplayMode(aSh,Standard_Integer(newmode),true); - } - ite.Next(); - } - - ic->SetDisplayMode( newmode, Standard_False); - if ( newmode == 1 ) - GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") ); - else - GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") ); - - QApplication::restoreOverrideCursor(); - } - break; - } - - case 6022: // DISPLAY ALL - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) - //VTK - ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->DisplayAll(); - else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) - GeomGUI->OnDisplayAll(); - break; - } - - case 6023: // DISPLAY ONLY - case 8023: // DISPLAY ONLY - POPUP VIEWER - { - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - // VTK - GeomGUI->OnVTKDisplayOnly(); - } - else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) - GeomGUI->OnDisplayOnly(); - break; - } - - case 6024: // ERASE ALL - { - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - //VTK - ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->EraseAll(); - } - else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - ic->EraseAll(Standard_True, Standard_False); - ic->Display(v3d->getTrihedron()); - } - - //NRI SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - //NRI Sel->ClearInteractiveObjects(); - break; - } - - case 6025 : // ERASE ONLY - case 8022 : // ERASE - POPUP VIEWER - { - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - // VTK - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - if(myRenderInter->isInViewer(anIObject)) { - myRenderInter->Erase(anIObject); - } else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape); - if (obj->FindAttribute(anAttr, "AttributeName")) { - // searchin for already displayed objects with the same shape - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* theAllActors = theRenderer->GetActors(); - theAllActors->InitTraversal(); - vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); - Handle(SALOME_InteractiveObject) anIObj; - // don't create new study object if it already exists - bool isDisplayed = false; - while(!(actor==NULL)) { - SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor); - if (Gactor!=NULL) { - if (Gactor->hasIO()) { - if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) { - isDisplayed = true; - anIObj = Gactor->getIO(); - if (!anIObj.IsNull()) myRenderInter->Erase(anIObj); - } - } - } - actor=(vtkActor*)(theAllActors->GetNextActor()); - } - } - if (useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - } -// SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); -// for(;It.More();It.Next()) { -// Handle(SALOME_InteractiveObject) IOS = It.Value(); - // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);; - } - else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - // OCC - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - if ( v3d->isInViewer( anIObject, true ) ) { - Standard_Boolean found; - Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( anIObject, found, true ); - if ( found ) { - ic->Erase(aSh); - ic->AddOrRemoveCurrentObject(aSh, true); - } - } else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape); - if (obj->FindAttribute(anAttr, "AttributeName")) { - // searchin for already displayed objects with the same shape - AIS_ListOfInteractive aDisplayed; - ic->DisplayedObjects(aDisplayed); - AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); - Handle(AIS_Shape) anAISShape; - for(;anIObjects.More();anIObjects.Next()) { - anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); - if (!anAISShape.IsNull()) { - if (anAISShape->Shape().IsSame(Shape)) break; - anAISShape.Nullify(); - } - } - if (!anAISShape.IsNull()) { - if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape); - } - } - if (useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - } - } - Sel->ClearIObjects(); - break; - } - - - case 6060: // BOUNDING BOX - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_BndBoxDlg *aDlg = new GeometryGUI_BndBoxDlg(parent, "", Sel ) ; - break ; - } - - case 6061: // MIN DISTANCE - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_DistanceDlg *aDlg = new GeometryGUI_DistanceDlg(parent, "", Sel ) ; - break ; - } - - case 8021: // WIREFRAME-SHADING - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - // VTK - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - - QApplication::setOverrideCursor( Qt::waitCursor ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IOS = It.Value(); - myRenderInter->SwitchRepresentation(IOS, false); - } - myRenderInter->Render(); - QApplication::restoreOverrideCursor(); - } - else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape( IObject, found, true ); - if (!Shape.IsNull()) { - AIS_DisplayMode mode = ( AIS_DisplayMode )Shape->DisplayMode(); - if ( mode == -1 ) - mode = ( AIS_DisplayMode )ic->DisplayMode(); - - QApplication::setOverrideCursor( Qt::waitCursor ); - ic->SetDisplayMode(Shape, mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame, false); - } - QApplication::restoreOverrideCursor(); - } - ic->UpdateCurrentViewer(); - } - QApplication::restoreOverrideCursor(); - break; - } - - case 8031: // COLOR - POPUP VIEWER - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - // VTK - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - - Handle(SALOME_InteractiveObject) FirstIOS = Sel->firstIObject(); - if(!FirstIOS.IsNull()) { - - QColor initcolor = myRenderInter->GetColor(FirstIOS); - - QColor c = QColorDialog::getColor( initcolor, - QAD_Application::getDesktop() ); - - if ( c.isValid() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IOS = It.Value(); - myRenderInter->SetColor(IOS,c); - } - } - QApplication::restoreOverrideCursor(); - } - } - else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); - Standard_Boolean found; - Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape(IO, found, true); - if ( found ) { - Quantity_Color CSFColor; - Shape->Color( CSFColor ); - - QColor c = QColorDialog::getColor( QColor(CSFColor.Red() * 255.0, - CSFColor.Green()* 255.0, - CSFColor.Blue() * 255.0 ), - QAD_Application::getDesktop() ); - - if ( c.isValid() ) { - CSFColor = Quantity_Color ( c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB ); - QApplication::setOverrideCursor( Qt::waitCursor ); - - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape(IObject, found, true); - if ( found ) { - Shape->SetColor ( CSFColor ); - Shape->SetShadingColor ( CSFColor ); - } - } - } - } - } - QApplication::restoreOverrideCursor(); - break; - } - - case 8032: // TRANSPARENCY - POPUP VIEWER - { - GeomGUI->EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - GeometryGUI_TransparencyDlg *aDlg = new GeometryGUI_TransparencyDlg( parent, "", Sel, ic ) ; - break ; - } - - case 8033: // ISOS - POPUP VIEWER - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - else { - ic->InitCurrent(); - if ( ic->MoreCurrent() ) { - Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); - QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); - QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); - - if ( !IsoU.isEmpty() ) - ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt()); - else - IsoU = "1"; - if ( !IsoV.isEmpty() ) - ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt()); - else - IsoV = "1"; - - GeometryGUI_NbIsosDlg * NbIsosDlg = - new GeometryGUI_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE ); - - NbIsosDlg->SpinBoxU->setValue(IsoU.toInt()); - NbIsosDlg->SpinBoxV->setValue(IsoV.toInt()); - - if ( NbIsosDlg->exec() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - for ( ; ic->MoreCurrent (); ic->NextCurrent () ) { - Handle (AIS_Drawer) CurDrawer; - - CurDrawer = ic->Current()->Attributes(); - CurDrawer->UIsoAspect()->SetNumber( NbIsosDlg->SpinBoxU->text().toInt() ); - CurDrawer->VIsoAspect()->SetNumber( NbIsosDlg->SpinBoxV->text().toInt() ); - - ic->SetLocalAttributes(CurObject, CurDrawer); - ic->Redisplay(CurObject); - } - } - } - } - QApplication::restoreOverrideCursor(); - break; - } - - case 9022 : // ERASE - OBJBROSER POPUP - { - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - // VTK - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - -// Handle(SALOME_InteractiveObject) IObject; - if(myRenderInter->isInViewer(anIObject)) { - myRenderInter->Erase(anIObject); - } else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape); - if (obj->FindAttribute(anAttr, "AttributeName")) { - // searchin for already displayed objects with the same shape - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* theAllActors = theRenderer->GetActors(); - theAllActors->InitTraversal(); - vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); - Handle(SALOME_InteractiveObject) anIObj; - // don't create new study object if it already exists - bool isDisplayed = false; - while(!(actor==NULL)) { - SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor); - if (Gactor!=NULL) { - if (Gactor->hasIO()) { - if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) { - isDisplayed = true; - anIObj = Gactor->getIO(); - if (!anIObj.IsNull()) myRenderInter->Erase(anIObj); - } - } - } - actor=(vtkActor*)(theAllActors->GetNextActor()); - } - } - if (useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } -// SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); -// for(;It.More();It.Next()) { -// Handle(SALOME_InteractiveObject) IOS = It.Value(); -// GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);; - } -// SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); -// for(;It.More();It.Next()) { -// Handle(SALOME_InteractiveObject) IOS = It.Value(); -// GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);; -// } - } - else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - // OCC - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - if ( v3d->isInViewer( anIObject, true ) ) { - Standard_Boolean found; - Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( anIObject, found, true ); - if ( found ) { - ic->Erase(aSh); - ic->AddOrRemoveCurrentObject(aSh, true); - } - } else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape); - if (obj->FindAttribute(anAttr, "AttributeName")) { - // searchin for already displayed objects with the same shape - AIS_ListOfInteractive aDisplayed; - ic->DisplayedObjects(aDisplayed); - AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); - Handle(AIS_Shape) anAISShape; - for(;anIObjects.More();anIObjects.Next()) { - anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); - if (!anAISShape.IsNull()) { - if (anAISShape->Shape().IsSame(Shape)) break; - anAISShape.Nullify(); - } - } - if (!anAISShape.IsNull()) { - if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape); - } - } - if (useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - } -// QAD_Viewer3d* v3d = GeomGUI->myActiveStudy->getActiveStudyFrame()->getViewerOCC(); -// Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); -// myContext->EraseSelected(); - } - - Sel->ClearIObjects(); - break; - } - - case 9023 : // DISPLAY ONLY - OBJBROSER POPUP - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) - GeomGUI->OnVTKDisplayOnly(); - else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) - GeomGUI->OnDisplayOnly(); - break; - } - - case 9024 : // OPEN - OBJBROSER POPUP - { - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); - SALOMEDS::AttributePersistentRef_var aPersist; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj); - SALOMEDS::GenericAttribute_var anAttr; - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) { - useSubItems = true; - obj = subobj; - } - else anIter->Next(); - } - obj->FindAttribute(anAttr, "AttributePersistentRef"); - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - if (!obj->FindAttribute(anAttr, "AttributeIOR") && - obj->FindAttribute(anAttr, "AttributePersistentRef")) { - // load - Engines::Component_var comp = GeomGUI->myDesktop->getEngine("FactoryServer","GEOM"); - if (!CORBA::is_nil(comp)) { - SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp); - - - SALOMEDS::StudyBuilder_var aStudyBuilder = GeomGUI->myActiveStudy->getStudyDocument()->NewBuilder(); - aStudyBuilder->LoadWith(GeomGUI->myActiveStudy->getStudyDocument()->FindComponent("GEOM"),driver); - - } else { - MESSAGE("Component is null"); - } - } - if (useSubItems) { - anIter->Next(); - obj = anIter->Value(); - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - break; - } - - case 10000 : // SKETCH Segment - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - GeomGUI->OnSketchSegment(); - break; - } - case 10001 : // SKETCH Arc - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - GeomGUI->OnSketchArc(); - break; - } - case 10002 : // SKETCH Set Angle - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - GeomGUI->OnSketchSetAngle(); - break; - } - case 10003 : // SKETCH Set X - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - GeomGUI->OnSketchSetx(); - break; - } - case 10004 : // SKETCH Set Y - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - GeomGUI->OnSketchSety(); - break; - } - case 10006 : // SKETCH Delete - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - GeomGUI->OnSketchDelete(); - break; - } - case 10007 : // SKETCH End - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - GeomGUI->OnSketchEnd(); - break; - } - case 10008 : // SKETCH Close - { - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - GeomGUI->OnSketchClose(); - break; - } - case 10010 : // SKETCH OptionsOnofflengthdimension - { - GeomGUI->OnSketchOptionsOnofflengthdimension(); - break; - } - case 10011 : // SKETCH OptionsOnoffangledimension - { - GeomGUI->OnSketchOptionsOnoffangledimension(); - break; - } - case 10012 : // SKETCH OptionsOnoffradiusdimension - { - GeomGUI->OnSketchOptionsOnoffradiusdimension(); - break; - } - case 10013 : // SKETCH OptionsOnoffxdimension - { - GeomGUI->OnSketchOptionsOnoffxdimension(); - break; - } - case 10014 : // SKETCH OptionsOnoffydimension - { - GeomGUI->OnSketchOptionsOnoffydimension(); - break; - } - - default: - { - parent->putInfo( tr("GEOM_PRP_COMMAND").arg(theCommandID ) ); - break; - } - } - - return true ; -} //======================================================================= // function : ConvertClickToPoint() @@ -4464,87 +2535,7 @@ gp_Pnt GeometryGUI::ConvertClickToPoint( Standard_Real x, -//================================================================================== -// function : 0nMousePress() -// purpose : [static] manage mouse events -//================================================================================== -bool GeometryGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) -{ - MESSAGE ( "GeometryGUI::OnMousePress") - GeometryGUI::GetOrCreateGeometryGUI(parent); - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - return false; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort(); - - /* Get the clicked or selected point */ - gp_Pnt thePoint; - - if ( GeomGUI->myState == CURRENT_SKETCH) { - GeomGUI->mySketcher.ValidateEdge(); - if (GeomGUI->mySketcher.GetmyEdgesNumber() == 1 ) { - QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(313,&pp); - pp->setItemEnabled( 313, true); // SKETCH CONTRAINTS - } - } else if( GeomGUI->myState == POINT_METHOD ) { - - GeomGUI->EraseSimulationShape() ; - GeometryGUI_PointDlg *DialogPt = (GeometryGUI_PointDlg*)(GeomGUI->myActiveDialogBox) ; - - if ( DialogPt->UseLocalContext() ) { - ic->InitSelected(); - if ( pe->state() == Qt::ShiftButton ) - v3d->getAISSelector()->shiftSelect(); /* Append selection */ - else - v3d->getAISSelector()->select(); /* New selection */ - - if ( ic->MoreSelected() ) { - thePoint = BRep_Tool::Pnt( TopoDS::Vertex(ic->SelectedShape()) ); - } - else - thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() ); - } - else - thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() ); - - if( DialogPt != 0 ) { - DialogPt->PointIntoCoordinates(thePoint, true) ; /* display point */ - } - else { - // MESSAGE ("On Mouse Press : myActiveDialogBox is null" << endl) ; - GeomGUI->myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - } - } - - return false ; -} - - -//======================================================================= -// function : OnMouseMove() -// purpose : [static] manage mouse events -//======================================================================= -bool GeometryGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) -{ - GeometryGUI::GetOrCreateGeometryGUI(parent); - - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort(); - - if ( GeomGUI->myState == CURRENT_SKETCH) - GeomGUI->mySketcher.MakeCurrentEdge( pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView() ); - - return true; -} //================================================================================ @@ -4557,10 +2548,10 @@ void GeometryGUI::SetDisplayedObjectList() return; OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - ListDisplayedObject.Clear(); + myListDisplayedObject.Clear(); Handle (AIS_InteractiveContext) aContext = v3d->getAISContext(); - aContext->DisplayedObjects( ListDisplayedObject ); + aContext->DisplayedObjects( myListDisplayedObject ); } @@ -4596,7 +2587,7 @@ void GeometryGUI::OnDisplayAll(bool onlyPreviousDisplayedObject) ite1.Next(); } } else { - AIS_ListIteratorOfListOfInteractive ite(ListDisplayedObject); + AIS_ListIteratorOfListOfInteractive ite(myListDisplayedObject); while (ite.More()) { if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); @@ -4626,7 +2617,7 @@ void GeometryGUI::OnVTKDisplayOnly() QApplication::setOverrideCursor( Qt::waitCursor ); - vtkRenderer* aren = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkRenderer* aren = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); vtkActorCollection* theActors = aren->GetActors(); theActors->InitTraversal(); vtkActor *ac = theActors->GetNextActor(); @@ -4641,19 +2632,19 @@ void GeometryGUI::OnVTKDisplayOnly() // Display selection SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry()); + SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry()); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; SALOMEDS::AttributeIOR_var anIOR; - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); for(;It.More();It.Next()) { Handle(SALOME_InteractiveObject) IObject = It.Value(); SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); if(myRenderInter->isInViewer(IObject)) { myRenderInter->Display(IObject); @@ -4664,18 +2655,18 @@ void GeometryGUI::OnVTKDisplayOnly() if ( !obj->FindAttribute(anAttr, "AttributeIOR")) break; // If selected object contains displayable subobjects, then do nothing - SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj); + SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); SALOMEDS::GenericAttribute_var aTmpAttr; anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value()); + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); if (CORBA::is_nil(aShape)) continue; - TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape); + TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); if (obj->FindAttribute(anAttr, "AttributeName")) { aName = SALOMEDS::AttributeName::_narrow(anAttr); // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy ); + QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); op->start(); SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); @@ -4683,7 +2674,7 @@ void GeometryGUI::OnVTKDisplayOnly() // commit transaction op->finish(); - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); int themode = myRenderInter->GetDisplayMode(); vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True); @@ -4696,7 +2687,7 @@ void GeometryGUI::OnVTKDisplayOnly() theRenderer->AddActor(GActor); vtkRenderWindow *renWin - = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()->GetRenderWindow(); + = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()->GetRenderWindow(); renWin->Render(); anActor = (vtkActor*)theActors->GetNextActor(); } @@ -4704,7 +2695,7 @@ void GeometryGUI::OnVTKDisplayOnly() } } } - GeomGUI->myActiveStudy->updateObjBrowser( true ); + myActiveStudy->updateObjBrowser( true ); QApplication::restoreOverrideCursor(); } @@ -4777,7 +2768,7 @@ void GeometryGUI::OnDisplayOnly() anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() ); if (CORBA::is_nil(aShape)) continue; - TopoDS_Shape Shape = ShapeReader.GetShape(myComponentGeom, aShape); + TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom, aShape); if (obj->FindAttribute(anAttr, "AttributeName")) { aName = SALOMEDS::AttributeName::_narrow(anAttr); @@ -4792,7 +2783,7 @@ void GeometryGUI::OnDisplayOnly() } Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value()); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM"); + Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), myFatherior,"GEOM"); IO->setEntry(obj->GetID()); aSh->setIO( IO ); @@ -4833,7 +2824,7 @@ void GeometryGUI::OnEditDelete() for(;It.More();It.Next()) { Handle(SALOME_InteractiveObject) IObject = It.Value(); if ( IObject->hasEntry() ) { - SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument(); + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() ); /* Erase child graphical objects */ @@ -4844,20 +2835,20 @@ void GeometryGUI::OnEditDelete() anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); /* Delete child(s) shape in Client : */ const TCollection_AsciiString ASCior(anIOR->Value()) ; - ShapeReader.RemoveShapeFromBuffer( ASCior ) ; + myShapeReader.RemoveShapeFromBuffer( ASCior ) ; for ( int i = 0; i < nbSf; i++ ) { QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); if ( sf->getTypeView() == VIEW_OCC ) { OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer(); Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); - Handle(GEOM_AISShape) Result = GeomGUI->ConvertIORinGEOMAISShape( anIOR->Value(), found ); + Handle(GEOM_AISShape) Result = ConvertIORinGEOMAISShape( anIOR->Value(), found ); if ( found ) myContext->Erase( Result, true, false ); } else if ( sf->getTypeView() == VIEW_VTK ) { //vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor(); - GEOM_Actor* ac = GeomGUI->ConvertIORinGEOMActor( anIOR->Value(), found ); + GEOM_Actor* ac = ConvertIORinGEOMActor( anIOR->Value(), found ); if ( found ) { //Renderer->RemoveActor(ac); if ( ac->hasIO() ) @@ -4874,7 +2865,7 @@ void GeometryGUI::OnEditDelete() if ( sf->getTypeView() == VIEW_OCC ) { OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer(); Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); - Handle(GEOM_AISShape) Result = GeomGUI->ConvertIOinGEOMAISShape( IObject, found ); + Handle(GEOM_AISShape) Result = ConvertIOinGEOMAISShape( IObject, found ); if ( found ) myContext->Erase( Result, true, false ); } else if ( sf->getTypeView() == VIEW_VTK ) { @@ -4887,7 +2878,7 @@ void GeometryGUI::OnEditDelete() if (SO->FindAttribute(anAttr, "AttributeIOR") ) { anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); const TCollection_AsciiString ASCIor(anIOR->Value()) ; - ShapeReader.RemoveShapeFromBuffer( ASCIor ) ; + myShapeReader.RemoveShapeFromBuffer( ASCIor ) ; } /* Erase objects in Study */ @@ -4919,7 +2910,7 @@ void GeometryGUI::OnEditCopy() const SALOME_ListIO& List = Sel->StoredIObjects(); - GeomGUI->ConvertListOfIOInListOfIOR( List, listIOR); + ConvertListOfIOInListOfIOR( List, listIOR); Sel->ClearIObjects(); @@ -4939,23 +2930,6 @@ void GeometryGUI::OnEditCopy() } - -//===================================================================================== -// function : OnKeyPress() -// purpose : [static] -//===================================================================================== -bool GeometryGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) -{ - GeometryGUI::GetOrCreateGeometryGUI(parent); - - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - - return true ; -} - - - //===================================================================================== // function : DisplaySimulationShape() // purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape @@ -5028,7 +3002,7 @@ bool GeometryGUI::Import( ) QString file; QStringList filtersList ; - switch ( GeomGUI->myState ) + switch ( myState ) { case 111 : // Import BREP { @@ -5122,7 +3096,7 @@ bool GeometryGUI::Import( ) } // if (aLocked) return false; aStudyBuilder->DefineComponentInstance( father, myComponentGeom ); - father->ComponentIOR( Fatherior ); + father->ComponentIOR( myFatherior ); QString nameShape = QAD_Tools::getFileNameFromPath(file,false) + QString("_%1").arg(this->myNbGeom++); @@ -5154,7 +3128,7 @@ bool GeometryGUI::Export( ) SALOME_Selection* Sel = SALOME_Selection::Selection( this->myActiveStudy->getSelection() ); SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - switch ( GeomGUI->myState ) + switch ( myState ) { case 121 : { @@ -5162,7 +3136,7 @@ bool GeometryGUI::Export( ) QApplication::restoreOverrideCursor(); Handle(SALOME_InteractiveObject) IObject = It.Value(); Standard_Boolean found; - GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found); + GEOM::GEOM_Shape_var aShape = ConvertIOinGEOMShape(IObject, found); // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true); if ( found ) { QString file = QAD_FileDlg::getFileName(myDesktop, @@ -5174,7 +3148,7 @@ bool GeometryGUI::Export( ) QApplication::setOverrideCursor( Qt::waitCursor ); // Standard_Boolean result = BRepTools::Write(Shape->Shape(), strdup(file.latin1()) ); try { - GeomGUI->myComponentGeom->ExportBREP(strdup( file.latin1()), aShape); + myComponentGeom->ExportBREP(strdup( file.latin1()), aShape); } catch (const SALOME::SALOME_Exception& S_ex) { QtCatchCorbaException(S_ex); @@ -5190,7 +3164,7 @@ bool GeometryGUI::Export( ) QApplication::restoreOverrideCursor(); Handle(SALOME_InteractiveObject) IObject = It.Value(); Standard_Boolean found; - GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found); + GEOM::GEOM_Shape_var aShape = ConvertIOinGEOMShape(IObject, found); // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true); if ( found ) { QString file = QAD_FileDlg::getFileName(myDesktop, @@ -5201,7 +3175,7 @@ bool GeometryGUI::Export( ) if ( !file.isEmpty() && !aShape->_is_nil() ) { QApplication::setOverrideCursor( Qt::waitCursor ); try { - GeomGUI->myComponentGeom->ExportIGES(strdup( file.latin1()), aShape); + myComponentGeom->ExportIGES(strdup( file.latin1()), aShape); } catch (const SALOME::SALOME_Exception& S_ex) { QtCatchCorbaException(S_ex); @@ -5231,11 +3205,11 @@ bool GeometryGUI::Export( ) QString file; for( ; It.More(); It.Next() ) { -// GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found); +// GEOM::GEOM_Shape_var aShape = ConvertIOinGEOMShape(IObject, found); QApplication::restoreOverrideCursor(); Handle(SALOME_InteractiveObject) IObject = It.Value(); Standard_Boolean found; - GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found); + GEOM::GEOM_Shape_var aShape = ConvertIOinGEOMShape(IObject, found); // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true); if ( found ) { file = QAD_FileDlg::getFileName(myDesktop, @@ -5247,7 +3221,7 @@ bool GeometryGUI::Export( ) QApplication::setOverrideCursor( Qt::waitCursor ) ; try { - GeomGUI->myComponentGeom->ExportSTEP(strdup( file.latin1()), aShape); + myComponentGeom->ExportSTEP(strdup( file.latin1()), aShape); } catch (const SALOME::SALOME_Exception& S_ex) { QtCatchCorbaException(S_ex); @@ -5296,7 +3270,7 @@ bool GeometryGUI::Display( GEOM::GEOM_Shape_ptr aShape, return false ; } - TopoDS_Shape shape = ShapeReader.GetShape(myComponentGeom, aShape); + TopoDS_Shape shape = myShapeReader.GetShape(myComponentGeom, aShape); if ( shape.IsNull() ) return false; @@ -5329,7 +3303,7 @@ bool GeometryGUI::Display( GEOM::GEOM_Shape_ptr aShape, // if (aLocked) return false; aStudyBuilder->DefineComponentInstance( father, myComponentGeom ); - father->ComponentIOR( Fatherior ); + father->ComponentIOR( myFatherior ); TCollection_AsciiString nameG(""); Standard_CString Type; @@ -5339,18 +3313,18 @@ bool GeometryGUI::Display( GEOM::GEOM_Shape_ptr aShape, GetShapeTypeString(shape,type); aShape->NameType( type ); nameG += TCollection_AsciiString( type ) + TCollection_AsciiString("_") + - TCollection_AsciiString( GeomGUI->myNbGeom++ ) + TCollection_AsciiString("\0"); + TCollection_AsciiString( myNbGeom++ ) + TCollection_AsciiString("\0"); } else nameG += TCollection_AsciiString( aShape->NameType()) + TCollection_AsciiString("_") + - TCollection_AsciiString( GeomGUI->myNbGeom++ ) + TCollection_AsciiString("\0"); + TCollection_AsciiString( myNbGeom++ ) + TCollection_AsciiString("\0"); } else nameG = TCollection_AsciiString(name); // VTK if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); int themode = myRenderInter->GetDisplayMode(); vtkActorCollection* theActors = @@ -5359,7 +3333,7 @@ bool GeometryGUI::Display( GEOM::GEOM_Shape_ptr aShape, vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); IO = new GEOM_InteractiveObject(aShape->Name(), - Fatherior, + myFatherior, "GEOM"); while(!(anActor==NULL)) { GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor ); @@ -5377,7 +3351,7 @@ bool GeometryGUI::Display( GEOM::GEOM_Shape_ptr aShape, Handle(GEOM_AISShape) theResult = new GEOM_AISShape( shape, nameG.ToCString() ); theResult->SetShadingColor( myShadingColor ); IO = new GEOM_InteractiveObject(aShape->Name(), - Fatherior, + myFatherior, "GEOM"); theResult->setIO( IO ); theResult->setName( nameG.ToCString() ); @@ -5395,8 +3369,8 @@ bool GeometryGUI::Display( GEOM::GEOM_Shape_ptr aShape, Sel->AddIObject( IO, false ); myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Repaint(); - if ( Settings_AddInStudy ) - GeomGUI->AddInStudy( false, IO ); + if ( mySettings_AddInStudy ) + AddInStudy( false, IO ); return true; } @@ -5410,7 +3384,7 @@ bool GeometryGUI::AddInStudy( bool selection, const Handle(SALOME_InteractiveObject)& anIO) { SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - if ( !( !Settings_AddInStudy || selection ) ) { + if ( !( !mySettings_AddInStudy || selection ) ) { Sel->ClearIObjects(); } @@ -5443,7 +3417,7 @@ bool GeometryGUI::AddInStudy( bool selection, // if (aLocked) return false; aStudyBuilder->DefineComponentInstance( father, myComponentGeom ); - father->ComponentIOR( Fatherior ); + father->ComponentIOR( myFatherior ); SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry()); @@ -5510,7 +3484,7 @@ bool GeometryGUI::AddInStudy( bool selection, return false; } - if ( !Settings_AddInStudy || selection ) { + if ( !mySettings_AddInStudy || selection ) { QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), anIO->getName() ); if ( !Name.isEmpty() ) { // VTK @@ -5611,7 +3585,7 @@ bool GeometryGUI::AddInStudy( bool selection, op->finish(); - if ( !Settings_AddInStudy || selection ) { + if ( !mySettings_AddInStudy || selection ) { myActiveStudy->updateObjBrowser(); } else { myActiveStudy->updateObjBrowser(false); @@ -5640,781 +3614,12 @@ TopoDS_Shape GeometryGUI::GetShapeFromIOR( QString IOR ) return result; GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( IOR ); if (!aShape->_is_nil()) { - result = ShapeReader.GetShape( myComponentGeom, aShape ); + result = myShapeReader.GetShape( myComponentGeom, aShape ); } return result; } -//===================================================================================== -// function : SetSettings() -// purpose : [static] -//===================================================================================== -bool GeometryGUI::SetSettings( QAD_Desktop* parent ) -{ - /* Create or retrieve an object GeomGUI */ - GeometryGUI::GetOrCreateGeometryGUI(parent); - - //DCQ parent->menuBar()->setItemEnabled( 504, false); // CORRECTING - //DCQ parent->menuBar()->setItemEnabled( 6062, false); // RADIUS - //VSR parent->menuBar()->setItemEnabled( 701, false); // AUTOMATIC COPY - parent->menuBar()->setItemEnabled( 313, false); // SKETCH CONTRAINTS - parent->menuBar()->setItemEnabled( 3131, false); // SKETCH SET PLAN - - /* Shading Color */ - QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed"); - QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen"); - QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue"); - if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() ) - GeomGUI->myShadingColor = Quantity_Color ( SCr.toInt()/255., SCg.toInt()/255., SCb.toInt()/255., - Quantity_TOC_RGB ); - - /* Wireframe or Shading */ - int DisplayMode = 0; - if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - DisplayMode = ic->DisplayMode(); - } else if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - DisplayMode = myRenderInter->GetDisplayMode(); - } - - if ( DisplayMode == 1 ) - parent->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") ); - else - parent->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") ); - - /* Copy */ -// QString Copy = QAD_CONFIG->getSetting("Geometry:SettingsCopy"); -// if ( !Copy.isEmpty() ) { -// Settings_Copy = Copy.toInt(); -// QMenuData* pp; -// parent->menuBar()->findItem(701,&pp); -// pp->setItemChecked(701, Settings_Copy); -// } - QMenuData* pp; - if ( parent->menuBar()->findItem(701,&pp) ) - pp->removeItem(701); - - /* Add in Study */ - QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy"); - if ( !AddInStudy.isEmpty() ) - Settings_AddInStudy = AddInStudy.toInt(); - else - Settings_AddInStudy = 1; - parent->menuBar()->findItem(702,&pp); - pp->setItemChecked(702, Settings_AddInStudy); - - /* step value */ - QString S = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ); - if( S.isEmpty() ) - QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", "100" ); - - /* isos */ - QAD_Study* ActiveStudy = parent->getActiveStudy(); - int count = ActiveStudy->getStudyFramesCount(); - - bool ViewOCC = false; - for ( int i = 0; i < count; i++ ) { - if ( ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); - QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); - if ( !IsoU.isEmpty() ) - ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt()); - if ( !IsoV.isEmpty() ) - ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt()); - - ViewOCC = true; - } - } - - QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar(); - - Mb->setItemEnabled( 312, ViewOCC); //Sketch - Mb->setItemEnabled( 309, ViewOCC); //SuppressFace - Mb->setItemEnabled( 314, ViewOCC); //SuppressHole - - Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings - Mb->setItemEnabled( 704, ViewOCC);// Isos Settings - - return true; -} - - -//===================================================================================== -// function : DefinePopup() -// purpose : [static] -//===================================================================================== -void GeometryGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject ) -{ - /* Create or retrieve an object GeomGUI */ - GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop()); - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - - theObject = ""; - if ( Sel->IObjectCount() == 1 ) - { - Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); - if (IO->hasEntry()) - { - SALOMEDS::SObject_var sobj = GeomGUI->myActiveStudy->getStudyDocument()->FindObjectID(IO->getEntry()); - if (!sobj->_is_nil()) - { - SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent(); - if (strcmp(scomp->GetID(), IO->getEntry()) == 0) - { - // component is selected - theObject = "Component"; - } - } - } - } - - if ( ( theParent.compare("Viewer")==0 ) ) - { - if ( GeomGUI->myState == CURRENT_SKETCH ) - theContext = "Sketch"; - else - { - if ( Sel->IObjectCount() > 0 ) - theContext = ""; - else - theContext = "NothingSelected"; - } - } - else - theContext = ""; - -} - -//===================================================================================== -// function : CustomPopup() -// purpose : [static] -//===================================================================================== -bool GeometryGUI::CustomPopup( QAD_Desktop* parent, - QPopupMenu* popup, - const QString& theContext, - const QString& theParent, - const QString& theObject ) -{ - /* Create or retrieve an object GeomGUI */ - GeometryGUI::GetOrCreateGeometryGUI(parent); - - /* Deactivate any non modal dialog box to get the neutral point */ - GeomGUI->EmitSignalDeactivateDialog() ; - - SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() ); - int nbSel = Sel->IObjectCount(); - - if ( (nbSel == 0) && ( theContext.compare("Sketch")!=0 ) ) - return false; - - - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) - { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()-> - getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - if ( theParent.compare("Viewer")==0 ) - { - if ( theContext.compare("Sketch")==0 ) - { - SketchStatus myCS = GeomGUI->mySketcher.GetCurrentStatus(); - popup->setCheckable(TRUE); - if (myCS==SEGMENT) - { - popup->setItemChecked(10000,true); - popup->setItemChecked(10001,false); - } - else if (myCS==ARC_CHORD) - { - popup->setItemChecked(10000,false); - popup->setItemChecked(10001,true); - } - - return true; - } - else - if (theObject.compare("Component") == 0) - { - popup->removeItem(QAD_DisplayOnly_Popup_ID); - return true; - } - else - { - QFont f = QApplication::font(); - f.setBold( TRUE ); - if (nbSel==1) - { - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - popup->removeItem(QAD_TopLabel_Popup_ID); - popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 ); - if ( IObject->hasEntry() ) - popup->setItemEnabled( 801, false ); - else - popup->setItemEnabled( 801, true ); - - if (IObject->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) - { - Standard_Boolean found; - Handle(GEOM_AISShape) Result = GeomGUI->ConvertIOinGEOMAISShape(IObject, found, true); - - if ( found ) - { - if ( Result->DisplayMode() == 1 ) - popup->changeItem(8021, tr("GEOM_MEN_WIREFRAME") ); - else - popup->changeItem(8021, tr("GEOM_MEN_SHADING") ); - } - } - - if ( !(v3d->isInViewer( IObject ) && v3d->isVisible( IObject )) ) - popup->removeItem(QAD_Erase_Popup_ID); - else - popup->removeItem(QAD_Display_Popup_ID); - - } - else - { - popup->removeItem(QAD_DisplayOnly_Popup_ID); - popup->removeItem(QAD_TopLabel_Popup_ID); - popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ), - QAD_TopLabel_Popup_ID, 0 ); - popup->setItemEnabled( 801, false ); - } - } - return true; - } - else - if ( theParent.compare("ObjectBrowser")==0 ) - { - popup->removeItem(QAD_TopLabel_Popup_ID); - int id = popup->idAt(0); // separator - if (id < 0) popup->removeItem(id); - - // checking for GEOM label in the selected list - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - Handle(SALOME_InteractiveObject) anIObject; - - bool useSubItems = false; - bool needOpen = false; - bool needDisplay = false; - bool needErase = false; - SALOMEDS::GenericAttribute_var aTmpAttr; - for(;It.More();It.Next()) - { - anIObject = It.Value(); - if (!anIObject->hasEntry()) - continue; - - if (v3d->isInViewer(anIObject) && v3d->isVisible(anIObject)) - needErase = true; - else - needDisplay = true; - SALOMEDS::SObject_var obj = - GeomGUI->myActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() ); - if (!obj->_is_nil()) - { - GEOM::GEOM_Shape_var aShape; - if (obj->FindAttribute(aTmpAttr, "AttributeIOR")) { - char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value(); - if (str && strlen(str)) - aShape = GeomGUI->myComponentGeom-> GetIORFromString(str); - } - else - if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef")) - needOpen = true; - if (aShape->_is_nil()) - { - SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy-> - getStudyDocument()->NewChildIterator(obj); - while (anIter->More()) - { - SALOMEDS::SObject_var subobj = anIter->Value(); - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) - { - useSubItems = true; - needErase = true; - needDisplay = true; - } - else - if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef")) - { - needOpen = true; - useSubItems = true; - } - anIter->Next(); - } - } - } - } - // remove useless popup items - if (nbSel != 1) popup->removeItem(901); // rename - if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only - if (!needOpen) - { - int index = popup->indexOf(9024); - popup->removeItem(9024); // open - popup->removeItemAt(index); // separator under Open - - if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID); - if (!needErase) popup->removeItem(QAD_Erase_Popup_ID); - if (!needDisplay && !needErase) - { - int id = popup->idAt(popup->count()-1); // last item - popup->removeItem(id); // separator - } - } - else - { - popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only - popup->removeItem(QAD_Display_Popup_ID); - popup->removeItem(QAD_Erase_Popup_ID); - if (nbSel!=1) - { - int id = popup->idAt(popup->count()-1); // last item - popup->removeItem(id); // separator - } - } - return true; - } - // MESSAGE ( " CUSTOM POPUP VIEWER OCC done. ") - } - else - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) - { - // MESSAGE ( " CUSTOM POPUP VIEWER VTK ") - if ( ( theParent.compare("Viewer")==0 ) ) - { - - popup->setItemEnabled( 8033, false ); - if (theObject.compare("Component") == 0) - { - popup->removeItem(QAD_DisplayOnly_Popup_ID); - return true; - } - - //int id = popup->idAt(0); - QFont f = QApplication::font(); - f.setBold( TRUE ); - - if (nbSel==1) - { - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - popup->removeItem(QAD_TopLabel_Popup_ID); - popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 ); - if ( IObject->hasEntry() ) - { - popup->setItemEnabled( 801, false ); - SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !SO->_is_nil() ) - { - if (SO->FindAttribute(anAttr, "AttributeIOR") ) - { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - Standard_Boolean found; - GEOM_Actor* Result = GeomGUI->ConvertIORinGEOMActor(anIOR->Value(), found, true); - if ( found ) - { - if ( Result->getDisplayMode() == 1 ) - popup->changeItem(8021, "Wireframe" ); - else - popup->changeItem(8021, "Shading" ); - - if ( !Result->GetVisibility() ) - popup->removeItem(QAD_Erase_Popup_ID); - else - popup->removeItem(QAD_Display_Popup_ID); - } - else - popup->removeItem(QAD_Erase_Popup_ID); - } - } - } - else - popup->setItemEnabled( 801, true ); - } - else - { - popup->removeItem(QAD_DisplayOnly_Popup_ID); - popup->removeItem(QAD_TopLabel_Popup_ID); - popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ), QAD_TopLabel_Popup_ID, 0 ); - popup->setItemEnabled( 801, false ); - } - return true; - } - else - if ( theParent.compare("ObjectBrowser")==0 ) - { - popup->removeItem(QAD_TopLabel_Popup_ID); - int id = popup->idAt(0); // separator - if (id < 0) popup->removeItem(id); - - // checking for GEOM label in the selected list - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - Handle(SALOME_InteractiveObject) anIObject; - - bool useSubItems = false; - bool needOpen = false; - bool needDisplay = false; - bool needErase = false; - SALOMEDS::GenericAttribute_var aTmpAttr; - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy-> - getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - for(;It.More();It.Next()) - { - anIObject = It.Value(); - if ( !anIObject->hasEntry() ) - continue; - - if (myRenderInter->isInViewer(anIObject) && myRenderInter->isVisible(anIObject)) - needErase = true; - else - needDisplay = true; - - SALOMEDS::SObject_var obj = GeomGUI->myActiveStudy->getStudyDocument() - ->FindObjectID( anIObject->getEntry() ); - if (!obj->_is_nil()) { - GEOM::GEOM_Shape_var aShape; - if (obj->FindAttribute(aTmpAttr, "AttributeIOR")){ - char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value(); - if (str && strlen(str)) - aShape = GeomGUI->myComponentGeom->GetIORFromString(str); - } - else - if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef")) - needOpen = true; - if (aShape->_is_nil()) - { - SALOMEDS::ChildIterator_var anIter = - GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj); - while (anIter->More()) - { - SALOMEDS::SObject_var subobj = anIter->Value(); - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) - { - useSubItems = true; - needDisplay = true; - needErase = true; - } - else - if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef")) - { - needOpen = true; - useSubItems = true; - } - anIter->Next(); - } - } - } - } - // remove useless popup items - if (nbSel != 1) popup->removeItem(901); // rename - if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only - if (!needOpen) - { - int index = popup->indexOf(9024); - popup->removeItem(9024); // open - popup->removeItemAt(index); // separator under Open - - if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID); - if (!needErase) popup->removeItem(QAD_Erase_Popup_ID); - if (!needDisplay && !needErase) - { - int id = popup->idAt(popup->count()-1); // last item - popup->removeItem(id); // separator - } - } - else - { - popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only - popup->removeItem(QAD_Display_Popup_ID); - popup->removeItem(QAD_Erase_Popup_ID); - if (nbSel!=1) - { - int id = popup->idAt(popup->count()-1); // last item - popup->removeItem(id); // separator - } - } - return true; - // MESSAGE ( " CUSTOM POPUP VIEWER VTK done.") - } - } else - { // other viewer types not supported. - while (1) - { - int id = popup->idAt(0); - if (id <= QAD_TopLabel_Popup_ID && id != -1) - popup->removeItemAt(0); - else - break; - } - popup->removeItem(QAD_DisplayOnly_Popup_ID); - popup->removeItem(QAD_Display_Popup_ID); - popup->removeItem(QAD_Erase_Popup_ID); - int id = popup->idAt(popup->count()-1); // last item - if (id < 0 && id != -1) popup->removeItem(id); // separator - return false; - } - return false; -} - -void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) -{ - /* Create or retrieve an object GeomGUI */ - GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop()); - - SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - - OCCViewer_Viewer3d* v3d; - Handle(AIS_InteractiveContext) ic; - vtkRenderer* Renderer; - - if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - ic = v3d->getAISContext(); - } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - Renderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - } else - return; - - if (theIO.IsNull()) - MESSAGE("BuildPresentation(): null SALOME_InteractiveObject passed") - - if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - // VTK - - SALOMEDS::SObject_var fatherSF = - aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry()); - - SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() ); - - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - - if(myRenderInter->isInViewer(theIO)) { - myRenderInter->Display(theIO, false); - } - else { - // Create new actor - if ( !obj->_is_nil() ) { - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - - bool useSubItems = false; - SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj); - if (GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) { - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - if (!GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } else anIter->Next(); - } - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape); - - if (obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* theAllActors = theRenderer->GetActors(); - theAllActors->InitTraversal(); - vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); - Handle(SALOME_InteractiveObject) anIObj; - // don't create new study object if it already exists - bool isDisplayed = false; - while(!(actor==NULL)) { - SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor); - if (Gactor!=NULL) { - if (Gactor->hasIO()) { - if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) { - isDisplayed = true; - anIObj = Gactor->getIO(); - if (!anIObj.IsNull()) myRenderInter->Display(anIObj, false); - } - } - } - actor=(vtkActor*)(theAllActors->GetNextActor()); - } - if (!isDisplayed) { - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy ); - op->start(); - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, obj); - // commit transaction - op->finish(); - - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - int themode = myRenderInter->GetDisplayMode(); - - vtkActorCollection* theActors = - GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True); - theActors->InitTraversal(); - vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); - while(!(anActor==NULL)) { - GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor ); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM"); - IO->setEntry(obj->GetID()); - GActor->setIO( IO ); - GActor->setName( theIO->getName() ); - - theRenderer->AddActor(GActor); - // renWin->Render(); - anActor = (vtkActor*)theActors->GetNextActor(); - } - } - } - // next item iteration - if (useSubItems) { - anIter->Next(); - anAttr = SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - // No viewer update should be done here! - //myRenderInter->Render(); - //GeomGUI->myActiveStudy->updateObjBrowser( true ); - } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - SALOMEDS::SObject_var fatherSF = - aStudy->FindObjectID( GeomGUI->myActiveStudy->getActiveStudyFrame()->entry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - - if ( v3d->isInViewer( theIO, true ) ) { - Standard_Boolean found; - Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( theIO, found, true ); - if ( found ) { - ic->Display(aSh, false); - ic->AddOrRemoveCurrentObject(aSh, false); - } - - } else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() ); - if ( !obj->_is_nil() ) { - MESSAGE("BuildPresentation(): SObject not null") - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - MESSAGE("BuildPresentation(): SObject has IOR") - // this SObject may be GEOM module root SObject - - bool useSubItems = false; - SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj); - if (GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) { - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - if (!GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } else anIter->Next(); - } - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape); - if (Shape.IsNull()) - MESSAGE("BuildPresentation(): TopoDS_Shape is null!") - if (obj->FindAttribute(anAttr, "AttributeName")) { - MESSAGE("BuildPresentation(): SObject has Name") - aName = SALOMEDS::AttributeName::_narrow(anAttr); - // searchin for already displayed objects with the same shape - AIS_ListOfInteractive aDisplayed; - ic->DisplayedObjects(aDisplayed); - AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); - Handle(AIS_Shape) anAISShape; - for(;anIObjects.More();anIObjects.Next()) { - anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); - if (!anAISShape.IsNull()) { - if (anAISShape->Shape().IsSame(Shape)) break; - anAISShape.Nullify(); - } - } - if (!anAISShape.IsNull()) { - if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape, false); - } else { - if (!useSubItems) { - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy ); - op->start(); - if (fatherSF->_is_nil()) - MESSAGE("BuildPresentation(): fatherSF is nil!") - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, obj); - // commit transaction - op->finish(); - } - Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value()); - aSh->SetShadingColor( GeomGUI->myShadingColor ); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), - Fatherior, - "GEOM"); - IO->setEntry(obj->GetID()); - aSh->setIO( IO ); - aSh->setName( aName->Value() ); - ic->Display (aSh, false); - if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, false); - } - } - // next item iteration - if (useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else - anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - // No viewer update should be done here! - //GeomGUI->myActiveStudy->updateObjBrowser( true ); - //ic->UpdateCurrentViewer(); - } -} //======================================================================= // function : Parameter() @@ -6556,16 +3761,16 @@ void GeometryGUI::OnSketchSety() //======================================================================= void GeometryGUI::OnSketchDelete() { - if (GeomGUI->mySketcher.GetmyEdgesNumber() == 1 ) { - QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar(); + if (mySketcher.GetmyEdgesNumber() == 1 ) { + QMenuBar* Mb = myDesktop->getMainMenuBar(); QMenuData* pp; QMenuItem* item = Mb->findItem(313,&pp); pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS - GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT); + mySketcher.SetTransitionStatus(NOCONSTRAINT); } if (this->mySketcher.Delete()) - GeomGUI->ResetState(); + ResetState(); } @@ -6641,7 +3846,7 @@ void GeometryGUI::OnSketchClose() Ex.Next(); } GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ; - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, Wire); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, Wire); Standard_CString type; GetShapeTypeString(S,type); Wire->NameType( type ); @@ -6650,12 +3855,12 @@ void GeometryGUI::OnSketchClose() QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); } } - GeomGUI->ResetState(); + ResetState(); QMenuBar* Mb = this->myDesktop->getMainMenuBar(); QMenuData* pp; QMenuItem* item = Mb->findItem(313,&pp); pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS - GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT); + mySketcher.SetTransitionStatus(NOCONSTRAINT); } @@ -6733,7 +3938,7 @@ void GeometryGUI::OnSketchEnd() } GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ; - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, Wire); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, Wire); Standard_CString type; GetShapeTypeString(S,type); Wire->NameType( type ); @@ -6742,12 +3947,12 @@ void GeometryGUI::OnSketchEnd() QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); } } - GeomGUI->ResetState(); + ResetState(); QMenuBar* Mb = this->myDesktop->getMainMenuBar(); QMenuData* pp; QMenuItem* item = Mb->findItem(313,&pp); pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS - GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT); + mySketcher.SetTransitionStatus(NOCONSTRAINT); } //======================================================================= @@ -6857,9 +4062,9 @@ void GeometryGUI::Archimede( const Handle(SALOME_InteractiveObject)& IO, if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast( IO ); - GEOM::GEOM_Shape_var Shape = GeomGUI->myComponentGeom->GetIORFromString( GIO->getIOR() ); + GEOM::GEOM_Shape_var Shape = myComponentGeom->GetIORFromString( GIO->getIOR() ); - GEOM::GEOM_Shape_var Result = GeomGUI->myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection); + GEOM::GEOM_Shape_var Result = myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection); Result->NameType(tr("GEOM_PLANE")); if ( Display(Result, "") ) { QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); @@ -6867,15 +4072,15 @@ void GeometryGUI::Archimede( const Handle(SALOME_InteractiveObject)& IO, return; } if ( IO->hasEntry() ) { - SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument(); + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() ); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeIOR_var anIOR; if ( !obj->_is_nil() ) { if (obj->FindAttribute(anAttr, "AttributeIOR")) { anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var Shape = GeomGUI->myComponentGeom->GetIORFromString( anIOR->Value() ); - GEOM::GEOM_Shape_var Result = GeomGUI->myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection); + GEOM::GEOM_Shape_var Shape = myComponentGeom->GetIORFromString( anIOR->Value() ); + GEOM::GEOM_Shape_var Result = myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection); Result->NameType(tr("GEOM_PLANE")); if ( Display(Result, "") ) { QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); @@ -6891,65 +4096,6 @@ void GeometryGUI::Archimede( const Handle(SALOME_InteractiveObject)& IO, } -//===================================================================================== -// EXPORTED METHODS -//===================================================================================== -extern "C" -{ - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - { - return GeometryGUI::OnGUIEvent(theCommandID, parent); - } - - bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) - { - return GeometryGUI::OnKeyPress (pe, parent, studyFrame); - } - - bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) - { - return GeometryGUI::OnMousePress (pe, parent, studyFrame); - } - - bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) - { - return GeometryGUI::OnMouseMove (pe, parent, studyFrame); - } - - bool SetSettings ( QAD_Desktop* parent ) - { - return GeometryGUI::SetSettings( parent ); - } - - bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, - const QString & theParent, const QString & theObject ) - { - return GeometryGUI::CustomPopup( parent, popup, theContext, theParent, theObject ); - } - - void definePopup ( QString & theContext, QString & theParent, QString & theObject ) - { - GeometryGUI::DefinePopup( theContext, theParent, theObject ); - } - - bool activeStudyChanged ( QAD_Desktop* parent ) - { - GeometryGUI::activeStudyChanged( parent ); - } - - void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO ) - { - GeometryGUI::BuildPresentation(theIO); - } - - void supportedViewType(int* buffer, int bufferSize) - { - if (!buffer || !bufferSize) return; - buffer[0] = (int)VIEW_OCC; - if (--bufferSize) buffer[1] = (int)VIEW_VTK; - } -} - //===================================================================================== // function : OnFilletGetAll() // purpose : @@ -6976,7 +4122,7 @@ bool GeometryGUI::OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Rad myDesktop->putInfo(tr("GEOM_PRP_ABORT")); return false; } - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); Standard_CString type; GetShapeTypeString(S,type); result->NameType( type ); @@ -7051,7 +4197,7 @@ bool GeometryGUI::OnFilletGetSelected(const TopoDS_Shape& ShapeTopo, ic->CloseLocalContext(aLocalContextId) ; myUseLocalContext = false ; - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, aResult); Standard_CString type; GetShapeTypeString(S,type); aResult->NameType( type ); @@ -7105,7 +4251,7 @@ bool GeometryGUI::OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1 return false; } - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); Standard_CString type; GetShapeTypeString(S,type); result->NameType( type ); @@ -7179,7 +4325,7 @@ bool GeometryGUI::OnChamferGetSelected(const TopoDS_Shape& ShapeTopo, ic->CloseLocalContext(aLocalContextId) ; myUseLocalContext = false ; - TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult); + TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, aResult); Standard_CString type; GetShapeTypeString(S,type); aResult->NameType( type ); @@ -7227,7 +4373,7 @@ void GeometryGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape) } bool GeometryGUI::SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR) { - SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument(); + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(theFatherObject); SALOMEDS::SObject_var RefSO; SALOMEDS::GenericAttribute_var anAttr; @@ -7249,3 +4395,2626 @@ bool GeometryGUI::SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char } return false; } + + +//======================================================================= +// function : OnGUIEvent() [static] +// purpose : manage all events on GUI +//======================================================================= +bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + + OCCViewer_Viewer3d* v3d; + Handle(AIS_InteractiveContext) ic; + vtkRenderer* Renderer; + + QMenuBar* Mb = myDesktop->getMainMenuBar(); + + bool ViewOCC = false; + + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + ic = v3d->getAISContext(); + ViewOCC = true; + Mb->setItemEnabled( 312, ViewOCC);//Sketch + Mb->setItemEnabled( 309, ViewOCC);//SuppressFace + Mb->setItemEnabled( 314, ViewOCC);//SuppressHole + + Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings + Mb->setItemEnabled( 704, ViewOCC);// Isos Settings + + } else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + Renderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + + // OnSuppressFaces, OnSuppressHole, SETTINGS - SHADING COLOR, SETTINGS - ISOS, SETTINGS : STEP VALUE FOR SPIN BOXES, SKETCHER, ISOS - POPUP VIEWER, + Mb->setItemEnabled( 312, ViewOCC);//Sketch + Mb->setItemEnabled( 309, ViewOCC);//SuppressFace + Mb->setItemEnabled( 314, ViewOCC);//SuppressHole + + Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings + Mb->setItemEnabled( 704, ViewOCC);// Isos Settings + } else { + return 0; + } + + if (myState == CURRENT_SKETCH && theCommandID != 10000 && theCommandID != 10001 && theCommandID != 10002 && theCommandID != 10003 && theCommandID != 10004 && theCommandID != 10006 && theCommandID != 10007 && theCommandID != 10008 && theCommandID != 10010 && theCommandID != 10011 && theCommandID != 10012 && theCommandID != 10013 && theCommandID != 10014 && theCommandID != 3133 && theCommandID != 3134) + return false; + + +// QString theCommandID_str = itoa(theCommandID); +// theCommandID_str.truncate(3); +// int theCommandID_Group = theCommandID_str.toInt(); + if (theCommandID == 3021 || theCommandID == 3022 || theCommandID == 3023 || theCommandID == 3024 || theCommandID == 3025) { + PrimitiveGUI* myPrimitiveGUI = new PrimitiveGUI(); + myPrimitiveGUI->OnGUIEvent(theCommandID, parent); + return true ; + } + if (theCommandID == 4011 || theCommandID == 4012 || theCommandID == 4013 || theCommandID == 4014) { + BooleanGUI* myBooleanGUI = new BooleanGUI(); + myBooleanGUI->OnGUIEvent(theCommandID, parent); + return true ; + } + + + switch (theCommandID) + { + case 31: // COPY + OnEditCopy(); + break; + + case 33: // DELETE + OnEditDelete(); + break; + + case 111: + { + SetState(111); + Import(); + ResetState(); + break; + } + case 112: + { + SetState(112); + Import(); + ResetState(); + break; + } + case 113: // IMPORT STEP + { + SetState(113); + Import(); + ResetState(); + break; + } + + case 121: // EXPORT BREP + { + SetState(121); + Export(); + ResetState(); + break; + } + + case 122: // EXPORT IGES + { + SetState(122); + Export(); + ResetState(); + break; + } + + case 123: // EXPORT STEP + { + SetState(123); + Export(); + ResetState(); + break; + } + + case 303: // EXPLODE : use ic + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_SubShapeDlg *aDlg = new GeometryGUI_SubShapeDlg( parent, "", Sel, ic ) ; + break ; + } + + case 304: // GEOM::EDGE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_EdgeDlg *aDlg = new GeometryGUI_EdgeDlg( parent, "", Sel ) ; + break ; + } + + case 305: // GEOM::WIRE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_WireDlg *aDlg = new GeometryGUI_WireDlg( parent, "", Sel ) ; + break ; + } + + case 306: // GEOM::FACE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_FaceDlg *aDlg = new GeometryGUI_FaceDlg ( parent, "", Sel ) ; + break ; + } + + case 315: // GEOM::SHELL + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_ShellDlg *aDlg = new GeometryGUI_ShellDlg ( parent, "", Sel ) ; + break ; + } + + case 316: // GEOM::SOLID + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_SolidDlg *aDlg = new GeometryGUI_SolidDlg ( parent, "", Sel ) ; + break ; + } + + case 308: // GEOM::COMPOUND + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_CompoundDlg *aDlg = new GeometryGUI_CompoundDlg ( parent, "", Sel ) ; + break ; + } + + case 309: // SUPPRESS FACES : use ic + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_SuppressFacesDlg *aDlg = new GeometryGUI_SuppressFacesDlg( parent, "", Sel, ic ) ; + break ; + } + + case 314: // SUPPRESS HOLES : use ic + { + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_SuppressHoleDlg *aDlg = new GeometryGUI_SuppressHoleDlg( parent, "", Sel, ic ) ; + } + else { + myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ; + } + break ; + } + case 501: // SEWING + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_SewingDlg *aDlg = new GeometryGUI_SewingDlg ( parent, "", Sel ) ; + break ; + } + + case 502: // ORIENTATION + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_OrientationDlg *aDlg = new GeometryGUI_OrientationDlg( parent, "", Sel ) ; + break ; + } + + case 601: // PROPERTIES (Length, surface, volume) + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_PropertiesDlg *aDlg = new GeometryGUI_PropertiesDlg( parent, "", Sel ) ; + break ; + } + + case 604: // CDG : Center of mass + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_CenterMassDlg *aDlg = new GeometryGUI_CenterMassDlg ( parent, "", Sel ) ; + break ; + } + + case 605: // INERTIA + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_InertiaDlg *aDlg = new GeometryGUI_InertiaDlg( parent, "", Sel ) ; + break ; + } + + case 607: // MAXTOLERANCE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_MaxToleranceDlg *aDlg = new GeometryGUI_MaxToleranceDlg( parent, "", Sel ) ; + break ; + } + + case 608: // WHATIS + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_WhatisDlg *aDlg = new GeometryGUI_WhatisDlg( parent, "", Sel ) ; + break ; + } + + case 609: // CHECKSHAPE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_CheckShape *aDlg = new GeometryGUI_CheckShape( parent, "", Sel ) ; + break ; + } + + case 701: // SETTINGS - COPY + { + QMenuData* pp; + QMenuItem* item = parent->menuBar()->findItem(701,&pp); + bool check = !pp->isItemChecked(701); + pp->setItemChecked(701,check); + mySettings_Copy = check; + QAD_CONFIG->addSetting( "Geometry:SettingsCopy", mySettings_Copy ); + break; + } + + case 702: // SETTINGS - ADD IN STUDY + { + QMenuData* pp; + QMenuItem* item = parent->menuBar()->findItem(702,&pp); + bool check = !pp->isItemChecked(702); + pp->setItemChecked(702,check); + mySettings_AddInStudy = check; + + QAD_CONFIG->addSetting( "Geometry:SettingsAddInStudy", mySettings_AddInStudy ); + break; + } + + case 703: // SETTINGS - SHADING COLOR + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + break; + + QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed"); + QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen"); + QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue"); + QColor color; + if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() ) { + color = QColor (SCr.toInt(), + SCg.toInt(), + SCb.toInt()); + } else { + Quantity_Color Default = Quantity_Color(); + color = QColor ( (int)Default.Red() * 255.0, + (int)Default.Green()* 255.0, + (int)Default.Blue() * 255.0 ); + } + + QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() ); + if ( c.isValid() ) { + myShadingColor = Quantity_Color(c.red() / 255.0, + c.green()/ 255.0, + c.blue() / 255.0, + Quantity_TOC_RGB); + + AIS_ListOfInteractive List; + ic->DisplayedObjects(List); + AIS_ListOfInteractive List1; + ic->ObjectsInCollector(List1); + List.Append(List1); + + AIS_ListIteratorOfListOfInteractive ite(List); + while (ite.More()) { + if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); + aSh->SetShadingColor( myShadingColor ); + ic->Redisplay( aSh, Standard_True, Standard_True); + } + ite.Next(); + } + + ic->UpdateCurrentViewer(); + + QAD_CONFIG->addSetting("Geometry:SettingsShadingColorRed", c.red() ); + QAD_CONFIG->addSetting("Geometry:SettingsShadingColorGreen", c.green() ); + QAD_CONFIG->addSetting("Geometry:SettingsShadingColorBlue", c.blue() ); + } + break; + } + + + case 704: // SETTINGS - ISOS + { + if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + break; + + QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); + QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); + if ( !IsoU.isEmpty() ) + ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt()); + else + IsoU = "1"; + if ( !IsoV.isEmpty() ) + ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt()); + else + IsoV = "1"; + + GeometryGUI_NbIsosDlg * NbIsosDlg = new GeometryGUI_NbIsosDlg( QAD_Application::getDesktop(), + tr("GEOM_MEN_ISOS"), TRUE ); + int UIso = IsoU.toInt(); + int VIso = IsoV.toInt(); + + NbIsosDlg->SpinBoxU->setValue(UIso) ; + NbIsosDlg->SpinBoxV->setValue(VIso) ; + + if ( NbIsosDlg->exec() ) { + UIso = NbIsosDlg->SpinBoxU->text().toInt() ; + VIso = NbIsosDlg->SpinBoxV->text().toInt() ; + + ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso); + ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso); + QAD_CONFIG->addSetting( "Geometry:SettingsIsoU", NbIsosDlg->SpinBoxU->text() ); /* text format */ + QAD_CONFIG->addSetting( "Geometry:SettingsIsoV", NbIsosDlg->SpinBoxV->text() ); /* text format */ + } + + AIS_ListOfInteractive List; + ic->DisplayedObjects(List); + AIS_ListOfInteractive List1; + ic->ObjectsInCollector(List1); + List.Append(List1); + + AIS_ListIteratorOfListOfInteractive ite(List); + ic->InitCurrent(); + if ( ic->NbCurrents() ) + while (ite.More()) { + if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); + Handle (AIS_Drawer) CurDrawer; + CurDrawer = aSh->Attributes(); + CurDrawer->UIsoAspect()->SetNumber( UIso ); + CurDrawer->VIsoAspect()->SetNumber( VIso ); + ic->SetLocalAttributes(aSh, CurDrawer); + ic->Redisplay(aSh); + } + ite.Next(); + } + ic->UpdateCurrentViewer(); + break; + } + + case 705: // SETTINGS : STEP VALUE FOR SPIN BOXES + { + //NRI if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + //NRI break; + + QString step = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ); + if( step.isEmpty() ) + step = "100.0" ; + + Standard_Boolean res = false ; + double dd = Parameter( res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3 ) ; + if( res ) { + QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", QString("%1").arg(dd) ) ; + + /* Emit signal to GeometryGUI_SpinBoxes */ + SignalDefaultStepValueChanged( dd ) ; + } + else + parent->putInfo(tr("GEOM_PRP_ABORT")); + + break ; + } + + case 801: // ADD IN STUDY - POPUP VIEWER + { + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + const SALOME_ListIO& ListSelected = Sel->StoredIObjects(); + SALOME_ListIteratorOfListIO It( ListSelected ); + for ( ; It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + AddInStudy(true, IObject); + } + /* Is set on the dialog box */ + QApplication::restoreOverrideCursor(); + break; + } + + case 901: // RENAME + { + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + + QString nm = QString( aName->Value() ); + nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), nm ); + if ( !nm.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + myActiveStudy->renameIObject( IObject, nm ); + QApplication::restoreOverrideCursor(); + } + } + } + } + break; + } + + case 903: // DISPLAY OBJECT BROWSER + { + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + // VTK + QApplication::setOverrideCursor( Qt::waitCursor ); + + SALOMEDS::SObject_var fatherSF = + aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry()); + + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); + + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + + if(myRenderInter->isInViewer(IObject)) { + myRenderInter->Display(IObject); + } + else { + // Create new actor + if ( !obj->_is_nil() ) { + if ( obj->FindAttribute(anAttr, "AttributeIOR")) { + // this SObject may be GEOM module root SObject + SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); + bool useSubItems = false; + while (anIter->More() && !useSubItems) { + SALOMEDS::SObject_var subobj = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttr; + if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { + anAttr = aTmpAttr; + obj = subobj; + useSubItems = true; + } else anIter->Next(); + } + + while(useSubItems?anIter->More():!anAttr->_is_nil()) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); + TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); + + if (obj->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + + vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* theAllActors = theRenderer->GetActors(); + theAllActors->InitTraversal(); + vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); + Handle(SALOME_InteractiveObject) anIObj; + // don't create new study object if it already exists + bool isDisplayed = false; + while(!(actor==NULL)) { + SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor); + if (Gactor!=NULL) { + if (Gactor->hasIO()) { + if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) { + isDisplayed = true; + anIObj = Gactor->getIO(); + if (!anIObj.IsNull()) myRenderInter->Display(anIObj); + } + } + } + actor=(vtkActor*)(theAllActors->GetNextActor()); + } + if (!isDisplayed) { + // open transaction + QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); + op->start(); + + SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); + aStudyBuilder->Addreference(newObj1, obj); + // commit transaction + op->finish(); + + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + int themode = myRenderInter->GetDisplayMode(); + + vtkActorCollection* theActors = + GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True); + theActors->InitTraversal(); + vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); + while(!(anActor==NULL)) { + GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor ); + Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), myFatherior,"GEOM"); + IO->setEntry(obj->GetID()); + GActor->setIO( IO ); + GActor->setName( IObject->getName() ); + + theRenderer->AddActor(GActor); + renWin->Render(); + anActor = (vtkActor*)theActors->GetNextActor(); + } + } + } + // next item iteration + if (useSubItems) { + anIter->Next(); + anAttr = SALOMEDS::GenericAttribute::_nil(); + while (anIter->More() && anAttr->_is_nil()) { + SALOMEDS::SObject_var subobject = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttribute; + if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { + anAttr = aTmpAttribute; + obj = subobject; + } else anIter->Next(); + } + } else anAttr = SALOMEDS::GenericAttribute::_nil(); + } + } + } + } + } + myActiveStudy->updateObjBrowser( true ); + QApplication::restoreOverrideCursor(); + + } else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + + SALOMEDS::SObject_var fatherSF = + aStudy->FindObjectID( myActiveStudy->getActiveStudyFrame()->entry()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + + if ( v3d->isInViewer( IObject, true ) ) { + Standard_Boolean found; + Handle(GEOM_AISShape) aSh = ConvertIOinGEOMAISShape( IObject, found, true ); + if ( found ) { + ic->Display(aSh); + ic->AddOrRemoveCurrentObject(aSh, true); + } + + } else { + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); + if ( !obj->_is_nil() ) { + if ( obj->FindAttribute(anAttr, "AttributeIOR")) { + // this SObject may be GEOM module root SObject + SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); + bool useSubItems = false; + while (anIter->More() && !useSubItems) { + SALOMEDS::SObject_var subobj = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttr; + if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { + anAttr = aTmpAttr; + obj = subobj; + useSubItems = true; + } else anIter->Next(); + } + while(useSubItems?anIter->More():!anAttr->_is_nil()) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); + TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); + if (obj->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + // searchin for already displayed objects with the same shape + AIS_ListOfInteractive aDisplayed; + ic->DisplayedObjects(aDisplayed); + AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); + Handle(AIS_Shape) anAISShape; + for(;anIObjects.More();anIObjects.Next()) { + anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); + if (!anAISShape.IsNull()) { + if (anAISShape->Shape().IsSame(Shape)) break; + anAISShape.Nullify(); + } + } + if (!anAISShape.IsNull()) { + if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape); + } else { + if (!useSubItems) { + // open transaction + QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); + op->start(); + + SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); + aStudyBuilder->Addreference(newObj1, obj); + // commit transaction + op->finish(); + } + + Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value()); + aSh->SetShadingColor( myShadingColor ); + Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), + myFatherior, + "GEOM"); + IO->setEntry(obj->GetID()); + aSh->setIO( IO ); + aSh->setName( aName->Value() ); + ic->Display (aSh); + if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, true); + } + } + // next item iteration + if (useSubItems) { + anIter->Next(); + anAttr=SALOMEDS::GenericAttribute::_nil(); + while (anIter->More() && anAttr->_is_nil()) { + SALOMEDS::SObject_var subobject = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttribute; + if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { + anAttr = aTmpAttribute; + obj = subobject; + } else anIter->Next(); + } + } else anAttr = SALOMEDS::GenericAttribute::_nil(); + } + } + } + } + } + myActiveStudy->updateObjBrowser( true ); + QApplication::restoreOverrideCursor(); + } + break; + } + + case 3011: // POINT + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_PointDlg *aDlg = new GeometryGUI_PointDlg( parent, "", Sel, ic ) ; + break; + } + + case 3012: // LINE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_LineDlg *aDlg = new GeometryGUI_LineDlg( parent, "", Sel ) ; + break ; + } + + case 3013: // CIRCLE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_CircleDlg *aDlg = new GeometryGUI_CircleDlg( parent, "", Sel ) ; + break ; + } + + case 3014: // ELLIPSE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_EllipseDlg *aDlg = new GeometryGUI_EllipseDlg( parent, "", Sel ) ; + break ; + } + + case 3015: // ARC + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_ArcDlg *aDlg = new GeometryGUI_ArcDlg( parent, "", Sel ) ; + break ; + } + + case 3016: // VECTOR + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_VectorDlg *aDlg = new GeometryGUI_VectorDlg( parent, "", Sel ) ; + break; + } + + case 3017: // PLANE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_PlaneDlg *aDlg = new GeometryGUI_PlaneDlg( parent, "", Sel ) ; + break; + } + + case 3018: // WORKING PLANE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_WorkingPlaneDlg *aDlg = new GeometryGUI_WorkingPlaneDlg( parent, "", Sel ) ; + break; + } + + case 312: // SKETCHER + { + if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + break; + + EmitSignalDeactivateDialog() ; + + ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTop(); // DCQ : 28/02/2002 + + mySketcher = Sketch( v3d->getViewer3d() ); + SetState(CURRENT_SKETCH); + + QMenuBar* Mb = myDesktop->getMainMenuBar(); + QMenuData* pp; + + QMenuItem* item = Mb->findItem(10010,&pp); + mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010)); + item = Mb->findItem(10011,&pp); + mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011)); + item = Mb->findItem(10012,&pp); + mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012)); + item = Mb->findItem(10013,&pp); + mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013)); + item = Mb->findItem(10014,&pp); + mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014)); + + mySketcher.SetTransitionStatus(NOCONSTRAINT); + item = Mb->findItem(3133,&pp); + pp->setItemChecked(3133,false); + item = Mb->findItem(3134,&pp); + pp->setItemChecked(3134,false); + break; + } + + + + case 3131: + { + break; + } + + case 3133: // sketcher + { + QMenuBar* Mb = myDesktop->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(3133,&pp); + pp->setItemChecked(3133,!pp->isItemChecked(3133)); + if (pp->isItemChecked(3133) == true) + mySketcher.SetTransitionStatus(TANGENT); + else + mySketcher.SetTransitionStatus(NOCONSTRAINT); + + pp->setItemChecked(3134,false); + break; + } + + case 3134: // sketcher + { + QMenuBar* Mb = myDesktop->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(3134,&pp); + pp->setItemChecked(3134,!pp->isItemChecked(3134)); + if (pp->isItemChecked(3134) == true) + mySketcher.SetTransitionStatus(PERPENDICULAR); + else + mySketcher.SetTransitionStatus(NOCONSTRAINT); + + pp->setItemChecked(3133,false); + break; + } + + case 4021: // TRANSLATION + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_TranslationDlg *aDlg = new GeometryGUI_TranslationDlg( parent, "", Sel ) ; + break; + } + + case 4022: // ROTATION + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_RotationDlg *aDlg = new GeometryGUI_RotationDlg( parent, "", Sel ) ; + break; + } + + case 4030: // MULTI TRANSLATION + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_MultiTranslationDlg *aDlg = new GeometryGUI_MultiTranslationDlg( parent, "", Sel ) ; + break; + } + + case 4040: // MULTI ROTATION + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_MultiRotationDlg *aDlg = new GeometryGUI_MultiRotationDlg( parent, "", Sel ) ; + break; + } + + case 4023: // MIRROR + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_MirrorDlg *aDlg = new GeometryGUI_MirrorDlg( parent, "", Sel ) ; + break; + } + + case 4024: // SCALE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_ScaleDlg *aDlg = new GeometryGUI_ScaleDlg( parent, "", Sel ) ; + break; + } + + case 4025: // PARTITION + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_PartitionDlg *aDlg = new GeometryGUI_PartitionDlg( parent, "", Sel ) ; + break; + } + + case 4026: // ARCHIMEDE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_ArchimedeDlg *aDlg = new GeometryGUI_ArchimedeDlg( parent, "", Sel ) ; + break; + } + + case 4027: // FILLET + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_FilletDlg *aDlg = new GeometryGUI_FilletDlg( parent, "", Sel, ic ) ; + break; + } + + case 4028: // CHAMFER + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_ChamferDlg *aDlg = new GeometryGUI_ChamferDlg( parent, "", Sel, ic ) ; + break; + } + + case 4031: // PRISM + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_PrismDlg *aDlg = new GeometryGUI_PrismDlg( parent, "", Sel ) ; + break; + } + + case 4032: // REVOL + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_RevolDlg *aDlg = new GeometryGUI_RevolDlg( parent, "", Sel ) ; + break; + } + + case 4033: // FILLING + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_FillingDlg *aDlg = new GeometryGUI_FillingDlg( parent, "", Sel ) ; + break; + } + + case 4034: // PIPE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_PipeDlg *aDlg = new GeometryGUI_PipeDlg(parent, "", Sel ) ; + break; + } + + case 5001: // CHECK GEOMETRY + { + QAD_PyEditor* PyEditor = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getPyEditor(); + PyEditor->setText("from GEOM_usinggeom import *\n"); + PyEditor->setText(">>> "); + PyEditor->handleReturn(); + break; + } + + case 6021: // SHADING - WIREFRAME + { + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + VTKViewer_RenderWindowInteractor* myRenderInter= + ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + QApplication::setOverrideCursor(waitCursor); + + int themode = myRenderInter->GetDisplayMode(); + if( themode==0 ) { + myRenderInter->SetDisplayMode(1); + GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") ); + } else { + myRenderInter->SetDisplayMode(0); + GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") ); + } + + QApplication::restoreOverrideCursor(); + + } else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + AIS_DisplayMode mode = ( AIS_DisplayMode )ic->DisplayMode(); + QApplication::setOverrideCursor( Qt::waitCursor ); + AIS_DisplayMode newmode = (mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame); + + AIS_ListOfInteractive List; + ic->DisplayedObjects(List); + AIS_ListOfInteractive List1; + ic->ObjectsInCollector(List1); + List.Append(List1); + + AIS_ListIteratorOfListOfInteractive ite(List); + while (ite.More()) { + if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); + ic->SetDisplayMode(aSh,Standard_Integer(newmode),true); + } + ite.Next(); + } + + ic->SetDisplayMode( newmode, Standard_False); + if ( newmode == 1 ) + GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") ); + else + GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") ); + + QApplication::restoreOverrideCursor(); + } + break; + } + + case 6022: // DISPLAY ALL + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) + //VTK + ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->DisplayAll(); + else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) + OnDisplayAll(); + break; + } + + case 6023: // DISPLAY ONLY + case 8023: // DISPLAY ONLY - POPUP VIEWER + { + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + // VTK + OnVTKDisplayOnly(); + } + else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) + OnDisplayOnly(); + break; + } + + case 6024: // ERASE ALL + { + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + //VTK + ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->EraseAll(); + } + else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + ic->EraseAll(Standard_True, Standard_False); + ic->Display(v3d->getTrihedron()); + } + + //NRI SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + //NRI Sel->ClearInteractiveObjects(); + break; + } + + case 6025 : // ERASE ONLY + case 8022 : // ERASE - POPUP VIEWER + { + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + // VTK + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + Handle(SALOME_InteractiveObject) anIObject; + for(;It.More();It.Next()) { + anIObject = It.Value(); + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + if(myRenderInter->isInViewer(anIObject)) { + myRenderInter->Erase(anIObject); + } else { + SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if ( obj->FindAttribute(anAttr, "AttributeIOR")) { + // this SObject may be GEOM module root SObject + SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); + bool useSubItems = false; + while (anIter->More() && !useSubItems) { + SALOMEDS::SObject_var subobj = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttr; + if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { + anAttr = aTmpAttr; + obj = subobj; + useSubItems = true; + } else anIter->Next(); + } + + while(useSubItems?anIter->More():!anAttr->_is_nil()) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); + TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); + if (obj->FindAttribute(anAttr, "AttributeName")) { + // searchin for already displayed objects with the same shape + vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* theAllActors = theRenderer->GetActors(); + theAllActors->InitTraversal(); + vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); + Handle(SALOME_InteractiveObject) anIObj; + // don't create new study object if it already exists + bool isDisplayed = false; + while(!(actor==NULL)) { + SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor); + if (Gactor!=NULL) { + if (Gactor->hasIO()) { + if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) { + isDisplayed = true; + anIObj = Gactor->getIO(); + if (!anIObj.IsNull()) myRenderInter->Erase(anIObj); + } + } + } + actor=(vtkActor*)(theAllActors->GetNextActor()); + } + } + if (useSubItems) { + anIter->Next(); + anAttr=SALOMEDS::GenericAttribute::_nil(); + while (anIter->More() && anAttr->_is_nil()) { + SALOMEDS::SObject_var subobject = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttribute; + if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { + anAttr = aTmpAttribute; + obj = subobject; + } else anIter->Next(); + } + } else anAttr = SALOMEDS::GenericAttribute::_nil(); + } + } + } + } + } +// SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); +// for(;It.More();It.Next()) { +// Handle(SALOME_InteractiveObject) IOS = It.Value(); + // myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);; + } + else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + // OCC + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + Handle(SALOME_InteractiveObject) anIObject; + for(;It.More();It.Next()) { + anIObject = It.Value(); + if ( v3d->isInViewer( anIObject, true ) ) { + Standard_Boolean found; + Handle(GEOM_AISShape) aSh = ConvertIOinGEOMAISShape( anIObject, found, true ); + if ( found ) { + ic->Erase(aSh); + ic->AddOrRemoveCurrentObject(aSh, true); + } + } else { + SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if ( obj->FindAttribute(anAttr, "AttributeIOR")) { + // this SObject may be GEOM module root SObject + SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); + bool useSubItems = false; + while (anIter->More() && !useSubItems) { + SALOMEDS::SObject_var subobj = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttr; + if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { + anAttr = aTmpAttr; + obj = subobj; + useSubItems = true; + } else anIter->Next(); + } + + while(useSubItems?anIter->More():!anAttr->_is_nil()) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); + TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); + if (obj->FindAttribute(anAttr, "AttributeName")) { + // searchin for already displayed objects with the same shape + AIS_ListOfInteractive aDisplayed; + ic->DisplayedObjects(aDisplayed); + AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); + Handle(AIS_Shape) anAISShape; + for(;anIObjects.More();anIObjects.Next()) { + anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); + if (!anAISShape.IsNull()) { + if (anAISShape->Shape().IsSame(Shape)) break; + anAISShape.Nullify(); + } + } + if (!anAISShape.IsNull()) { + if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape); + } + } + if (useSubItems) { + anIter->Next(); + anAttr=SALOMEDS::GenericAttribute::_nil(); + while (anIter->More() && anAttr->_is_nil()) { + SALOMEDS::SObject_var subobject = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttribute; + if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { + anAttr = aTmpAttribute; + obj = subobject; + } else anIter->Next(); + } + } else anAttr = SALOMEDS::GenericAttribute::_nil(); + } + } + } + } + } + } + Sel->ClearIObjects(); + break; + } + + + case 6060: // BOUNDING BOX + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_BndBoxDlg *aDlg = new GeometryGUI_BndBoxDlg(parent, "", Sel ) ; + break ; + } + + case 6061: // MIN DISTANCE + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_DistanceDlg *aDlg = new GeometryGUI_DistanceDlg(parent, "", Sel ) ; + break ; + } + + case 8021: // WIREFRAME-SHADING + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + // VTK + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + + QApplication::setOverrideCursor( Qt::waitCursor ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + myRenderInter->SwitchRepresentation(IOS, false); + } + myRenderInter->Render(); + QApplication::restoreOverrideCursor(); + } + else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean found; + Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape( IObject, found, true ); + if (!Shape.IsNull()) { + AIS_DisplayMode mode = ( AIS_DisplayMode )Shape->DisplayMode(); + if ( mode == -1 ) + mode = ( AIS_DisplayMode )ic->DisplayMode(); + + QApplication::setOverrideCursor( Qt::waitCursor ); + ic->SetDisplayMode(Shape, mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame, false); + } + QApplication::restoreOverrideCursor(); + } + ic->UpdateCurrentViewer(); + } + QApplication::restoreOverrideCursor(); + break; + } + + case 8031: // COLOR - POPUP VIEWER + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + // VTK + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + + Handle(SALOME_InteractiveObject) FirstIOS = Sel->firstIObject(); + if(!FirstIOS.IsNull()) { + + QColor initcolor = myRenderInter->GetColor(FirstIOS); + + QColor c = QColorDialog::getColor( initcolor, + QAD_Application::getDesktop() ); + + if ( c.isValid() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + myRenderInter->SetColor(IOS,c); + } + } + QApplication::restoreOverrideCursor(); + } + } + else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); + Standard_Boolean found; + Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IO, found, true); + if ( found ) { + Quantity_Color CSFColor; + Shape->Color( CSFColor ); + + QColor c = QColorDialog::getColor( QColor(CSFColor.Red() * 255.0, + CSFColor.Green()* 255.0, + CSFColor.Blue() * 255.0 ), + QAD_Application::getDesktop() ); + + if ( c.isValid() ) { + CSFColor = Quantity_Color ( c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB ); + QApplication::setOverrideCursor( Qt::waitCursor ); + + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean found; + Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true); + if ( found ) { + Shape->SetColor ( CSFColor ); + Shape->SetShadingColor ( CSFColor ); + } + } + } + } + } + QApplication::restoreOverrideCursor(); + break; + } + + case 8032: // TRANSPARENCY - POPUP VIEWER + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + GeometryGUI_TransparencyDlg *aDlg = new GeometryGUI_TransparencyDlg( parent, "", Sel, ic ) ; + break ; + } + + case 8033: // ISOS - POPUP VIEWER + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + break; + else { + ic->InitCurrent(); + if ( ic->MoreCurrent() ) { + Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); + QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); + QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); + + if ( !IsoU.isEmpty() ) + ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt()); + else + IsoU = "1"; + if ( !IsoV.isEmpty() ) + ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt()); + else + IsoV = "1"; + + GeometryGUI_NbIsosDlg * NbIsosDlg = + new GeometryGUI_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE ); + + NbIsosDlg->SpinBoxU->setValue(IsoU.toInt()); + NbIsosDlg->SpinBoxV->setValue(IsoV.toInt()); + + if ( NbIsosDlg->exec() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + for ( ; ic->MoreCurrent (); ic->NextCurrent () ) { + Handle (AIS_Drawer) CurDrawer; + + CurDrawer = ic->Current()->Attributes(); + CurDrawer->UIsoAspect()->SetNumber( NbIsosDlg->SpinBoxU->text().toInt() ); + CurDrawer->VIsoAspect()->SetNumber( NbIsosDlg->SpinBoxV->text().toInt() ); + + ic->SetLocalAttributes(CurObject, CurDrawer); + ic->Redisplay(CurObject); + } + } + } + } + QApplication::restoreOverrideCursor(); + break; + } + + case 9022 : // ERASE - OBJBROSER POPUP + { + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + // VTK + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + Handle(SALOME_InteractiveObject) anIObject; + for(;It.More();It.Next()) { + anIObject = It.Value(); + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + +// Handle(SALOME_InteractiveObject) IObject; + if(myRenderInter->isInViewer(anIObject)) { + myRenderInter->Erase(anIObject); + } else { + SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if ( obj->FindAttribute(anAttr, "AttributeIOR")) { + // this SObject may be GEOM module root SObject + SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); + bool useSubItems = false; + while (anIter->More() && !useSubItems) { + SALOMEDS::SObject_var subobj = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttr; + if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { + anAttr = aTmpAttr; + obj = subobj; + useSubItems = true; + } else anIter->Next(); + } + + while(useSubItems?anIter->More():!anAttr->_is_nil()) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); + TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); + if (obj->FindAttribute(anAttr, "AttributeName")) { + // searchin for already displayed objects with the same shape + vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* theAllActors = theRenderer->GetActors(); + theAllActors->InitTraversal(); + vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); + Handle(SALOME_InteractiveObject) anIObj; + // don't create new study object if it already exists + bool isDisplayed = false; + while(!(actor==NULL)) { + SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor); + if (Gactor!=NULL) { + if (Gactor->hasIO()) { + if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) { + isDisplayed = true; + anIObj = Gactor->getIO(); + if (!anIObj.IsNull()) myRenderInter->Erase(anIObj); + } + } + } + actor=(vtkActor*)(theAllActors->GetNextActor()); + } + } + if (useSubItems) { + anIter->Next(); + anAttr=SALOMEDS::GenericAttribute::_nil(); + while (anIter->More() && anAttr->_is_nil()) { + SALOMEDS::SObject_var subobject = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttribute; + if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { + anAttr = aTmpAttribute; + obj = subobject; + } else anIter->Next(); + } + } else anAttr = SALOMEDS::GenericAttribute::_nil(); + } + } + } + } +// SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); +// for(;It.More();It.Next()) { +// Handle(SALOME_InteractiveObject) IOS = It.Value(); +// myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);; + } +// SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); +// for(;It.More();It.Next()) { +// Handle(SALOME_InteractiveObject) IOS = It.Value(); +// myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);; +// } + } + else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + // OCC + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + Handle(SALOME_InteractiveObject) anIObject; + for(;It.More();It.Next()) { + anIObject = It.Value(); + if ( v3d->isInViewer( anIObject, true ) ) { + Standard_Boolean found; + Handle(GEOM_AISShape) aSh = ConvertIOinGEOMAISShape( anIObject, found, true ); + if ( found ) { + ic->Erase(aSh); + ic->AddOrRemoveCurrentObject(aSh, true); + } + } else { + SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if ( obj->FindAttribute(anAttr, "AttributeIOR")) { + // this SObject may be GEOM module root SObject + SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); + bool useSubItems = false; + while (anIter->More() && !useSubItems) { + SALOMEDS::SObject_var subobj = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttr; + if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { + anAttr = aTmpAttr; + obj = subobj; + useSubItems = true; + } else anIter->Next(); + } + + while(useSubItems?anIter->More():!anAttr->_is_nil()) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); + TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); + if (obj->FindAttribute(anAttr, "AttributeName")) { + // searchin for already displayed objects with the same shape + AIS_ListOfInteractive aDisplayed; + ic->DisplayedObjects(aDisplayed); + AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); + Handle(AIS_Shape) anAISShape; + for(;anIObjects.More();anIObjects.Next()) { + anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); + if (!anAISShape.IsNull()) { + if (anAISShape->Shape().IsSame(Shape)) break; + anAISShape.Nullify(); + } + } + if (!anAISShape.IsNull()) { + if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape); + } + } + if (useSubItems) { + anIter->Next(); + anAttr=SALOMEDS::GenericAttribute::_nil(); + while (anIter->More() && anAttr->_is_nil()) { + SALOMEDS::SObject_var subobject = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttribute; + if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { + anAttr = aTmpAttribute; + obj = subobject; + } else anIter->Next(); + } + } else anAttr = SALOMEDS::GenericAttribute::_nil(); + } + } + } + } + } +// QAD_Viewer3d* v3d = myActiveStudy->getActiveStudyFrame()->getViewerOCC(); +// Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); +// myContext->EraseSelected(); + } + + Sel->ClearIObjects(); + break; + } + + case 9023 : // DISPLAY ONLY - OBJBROSER POPUP + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) + OnVTKDisplayOnly(); + else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) + OnDisplayOnly(); + break; + } + + case 9024 : // OPEN - OBJBROSER POPUP + { + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + Handle(SALOME_InteractiveObject) anIObject; + for(;It.More();It.Next()) { + anIObject = It.Value(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); + SALOMEDS::AttributePersistentRef_var aPersist; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + // this SObject may be GEOM module root SObject + SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); + SALOMEDS::GenericAttribute_var anAttr; + bool useSubItems = false; + while (anIter->More() && !useSubItems) { + SALOMEDS::SObject_var subobj = anIter->Value(); + if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) { + useSubItems = true; + obj = subobj; + } + else anIter->Next(); + } + obj->FindAttribute(anAttr, "AttributePersistentRef"); + + while(useSubItems?anIter->More():!anAttr->_is_nil()) { + if (!obj->FindAttribute(anAttr, "AttributeIOR") && + obj->FindAttribute(anAttr, "AttributePersistentRef")) { + // load + Engines::Component_var comp = myDesktop->getEngine("FactoryServer","GEOM"); + if (!CORBA::is_nil(comp)) { + SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp); + + + SALOMEDS::StudyBuilder_var aStudyBuilder = myActiveStudy->getStudyDocument()->NewBuilder(); + aStudyBuilder->LoadWith(myActiveStudy->getStudyDocument()->FindComponent("GEOM"),driver); + + } else { + MESSAGE("Component is null"); + } + } + if (useSubItems) { + anIter->Next(); + obj = anIter->Value(); + } else anAttr = SALOMEDS::GenericAttribute::_nil(); + } + } + } + break; + } + + case 10000 : // SKETCH Segment + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + break; + OnSketchSegment(); + break; + } + case 10001 : // SKETCH Arc + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + break; + OnSketchArc(); + break; + } + case 10002 : // SKETCH Set Angle + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + break; + OnSketchSetAngle(); + break; + } + case 10003 : // SKETCH Set X + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + break; + OnSketchSetx(); + break; + } + case 10004 : // SKETCH Set Y + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + break; + OnSketchSety(); + break; + } + case 10006 : // SKETCH Delete + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + break; + OnSketchDelete(); + break; + } + case 10007 : // SKETCH End + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + break; + OnSketchEnd(); + break; + } + case 10008 : // SKETCH Close + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + break; + OnSketchClose(); + break; + } + case 10010 : // SKETCH OptionsOnofflengthdimension + { + OnSketchOptionsOnofflengthdimension(); + break; + } + case 10011 : // SKETCH OptionsOnoffangledimension + { + OnSketchOptionsOnoffangledimension(); + break; + } + case 10012 : // SKETCH OptionsOnoffradiusdimension + { + OnSketchOptionsOnoffradiusdimension(); + break; + } + case 10013 : // SKETCH OptionsOnoffxdimension + { + OnSketchOptionsOnoffxdimension(); + break; + } + case 10014 : // SKETCH OptionsOnoffydimension + { + OnSketchOptionsOnoffydimension(); + break; + } + + default: + { + parent->putInfo( tr("GEOM_PRP_COMMAND").arg(theCommandID ) ); + break; + } + } + + return true ; +} + + +//===================================================================================== +// function : OnKeyPress() +// purpose : [static] +//===================================================================================== +bool GeometryGUI::OnKeyPress(QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + return false; + return true ; +} + + +//================================================================================== +// function : 0nMousePress() +// purpose : [static] manage mouse events +//================================================================================== +bool GeometryGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) +{ + MESSAGE ( "GeometryGUI::OnMousePress") + + if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + return false; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort(); + + /* Get the clicked or selected point */ + gp_Pnt thePoint; + + if ( myState == CURRENT_SKETCH) { + mySketcher.ValidateEdge(); + if (mySketcher.GetmyEdgesNumber() == 1 ) { + QMenuBar* Mb = myDesktop->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(313,&pp); + pp->setItemEnabled( 313, true); // SKETCH CONTRAINTS + } + } else if( myState == POINT_METHOD ) { + + EraseSimulationShape() ; + GeometryGUI_PointDlg *DialogPt = (GeometryGUI_PointDlg*)(myActiveDialogBox) ; + + if ( DialogPt->UseLocalContext() ) { + ic->InitSelected(); + if ( pe->state() == Qt::ShiftButton ) + v3d->getAISSelector()->shiftSelect(); /* Append selection */ + else + v3d->getAISSelector()->select(); /* New selection */ + + if ( ic->MoreSelected() ) { + thePoint = BRep_Tool::Pnt( TopoDS::Vertex(ic->SelectedShape()) ); + } + else + thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() ); + } + else + thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() ); + + if( DialogPt != 0 ) { + DialogPt->PointIntoCoordinates(thePoint, true) ; /* display point */ + } + else { + // MESSAGE ("On Mouse Press : myActiveDialogBox is null" << endl) ; + myDesktop->putInfo(tr("GEOM_PRP_ABORT")); + } + } + + return false ; +} + + +//======================================================================= +// function : OnMouseMove() +// purpose : [static] manage mouse events +//======================================================================= +bool GeometryGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + return false; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort(); + + if ( myState == CURRENT_SKETCH) + mySketcher.MakeCurrentEdge(pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView()); + + return true; +} + + +//===================================================================================== +// function : SetSettings() +// purpose : [static] +//===================================================================================== +bool GeometryGUI::SetSettings( QAD_Desktop* parent ) +{ + //DCQ parent->menuBar()->setItemEnabled( 504, false); // CORRECTING + //DCQ parent->menuBar()->setItemEnabled( 6062, false); // RADIUS + //VSR parent->menuBar()->setItemEnabled( 701, false); // AUTOMATIC COPY + parent->menuBar()->setItemEnabled( 313, false); // SKETCH CONTRAINTS + parent->menuBar()->setItemEnabled( 3131, false); // SKETCH SET PLAN + + /* Shading Color */ + QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed"); + QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen"); + QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue"); + if(!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) + myShadingColor = Quantity_Color (SCr.toInt()/255., SCg.toInt()/255., SCb.toInt()/255., Quantity_TOC_RGB); + + /* Wireframe or Shading */ + int DisplayMode = 0; + if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); + DisplayMode = ic->DisplayMode(); + } else if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + DisplayMode = myRenderInter->GetDisplayMode(); + } + + if ( DisplayMode == 1 ) + parent->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") ); + else + parent->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") ); + + /* Copy */ +// QString Copy = QAD_CONFIG->getSetting("Geometry:SettingsCopy"); +// if ( !Copy.isEmpty() ) { +// mySettings_Copy = Copy.toInt(); +// QMenuData* pp; +// parent->menuBar()->findItem(701,&pp); +// pp->setItemChecked(701, mySettings_Copy); +// } + QMenuData* pp; + if ( parent->menuBar()->findItem(701,&pp) ) + pp->removeItem(701); + + /* Add in Study */ + QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy"); + if ( !AddInStudy.isEmpty() ) + mySettings_AddInStudy = AddInStudy.toInt(); + else + mySettings_AddInStudy = 1; + parent->menuBar()->findItem(702,&pp); + pp->setItemChecked(702, mySettings_AddInStudy); + + /* step value */ + QString S = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ); + if( S.isEmpty() ) + QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", "100" ); + + /* isos */ + QAD_Study* ActiveStudy = parent->getActiveStudy(); + int count = ActiveStudy->getStudyFramesCount(); + + bool ViewOCC = false; + for ( int i = 0; i < count; i++ ) { + if ( ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); + QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); + if ( !IsoU.isEmpty() ) + ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt()); + if ( !IsoV.isEmpty() ) + ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt()); + + ViewOCC = true; + } + } + + QMenuBar* Mb = myDesktop->getMainMenuBar(); + + Mb->setItemEnabled( 312, ViewOCC); //Sketch + Mb->setItemEnabled( 309, ViewOCC); //SuppressFace + Mb->setItemEnabled( 314, ViewOCC); //SuppressHole + + Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings + Mb->setItemEnabled( 704, ViewOCC);// Isos Settings + + return true; +} + + +//===================================================================================== +// function : DefinePopup() +// purpose : [static] +//===================================================================================== +void GeometryGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject) +{ + SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + theObject = ""; + + if(Sel->IObjectCount() == 1) { + Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); + if(IO->hasEntry()) { + SALOMEDS::SObject_var sobj = myActiveStudy->getStudyDocument()->FindObjectID(IO->getEntry()); + if(!sobj->_is_nil()) { + SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent(); + if(strcmp(scomp->GetID(), IO->getEntry()) == 0) { + // component is selected + theObject = "Component"; + } + } + } + } + + if((theParent.compare("Viewer")==0)) { + if(myState == CURRENT_SKETCH) + theContext = "Sketch"; + else { + if (Sel->IObjectCount() > 0) + theContext = ""; + else + theContext = "NothingSelected"; + } + } + else + theContext = ""; +} + +//===================================================================================== +// function : CustomPopup() +// purpose : [static] +//===================================================================================== +bool GeometryGUI::CustomPopup( QAD_Desktop* parent, + QPopupMenu* popup, + const QString& theContext, + const QString& theParent, + const QString& theObject ) +{ + /* Deactivate any non modal dialog box to get the neutral point */ + EmitSignalDeactivateDialog() ; + + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + int nbSel = Sel->IObjectCount(); + + if ( (nbSel == 0) && ( theContext.compare("Sketch")!=0 ) ) + return false; + + + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) + { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()-> + getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + if ( theParent.compare("Viewer")==0 ) + { + if ( theContext.compare("Sketch")==0 ) + { + SketchStatus myCS = mySketcher.GetCurrentStatus(); + popup->setCheckable(TRUE); + if (myCS==SEGMENT) + { + popup->setItemChecked(10000,true); + popup->setItemChecked(10001,false); + } + else if (myCS==ARC_CHORD) + { + popup->setItemChecked(10000,false); + popup->setItemChecked(10001,true); + } + + return true; + } + else + if (theObject.compare("Component") == 0) + { + popup->removeItem(QAD_DisplayOnly_Popup_ID); + return true; + } + else + { + QFont f = QApplication::font(); + f.setBold( TRUE ); + if (nbSel==1) + { + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + popup->removeItem(QAD_TopLabel_Popup_ID); + popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 ); + if ( IObject->hasEntry() ) + popup->setItemEnabled( 801, false ); + else + popup->setItemEnabled( 801, true ); + + if (IObject->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) + { + Standard_Boolean found; + Handle(GEOM_AISShape) Result = ConvertIOinGEOMAISShape(IObject, found, true); + + if ( found ) + { + if ( Result->DisplayMode() == 1 ) + popup->changeItem(8021, tr("GEOM_MEN_WIREFRAME") ); + else + popup->changeItem(8021, tr("GEOM_MEN_SHADING") ); + } + } + + if ( !(v3d->isInViewer( IObject ) && v3d->isVisible( IObject )) ) + popup->removeItem(QAD_Erase_Popup_ID); + else + popup->removeItem(QAD_Display_Popup_ID); + + } + else + { + popup->removeItem(QAD_DisplayOnly_Popup_ID); + popup->removeItem(QAD_TopLabel_Popup_ID); + popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ), + QAD_TopLabel_Popup_ID, 0 ); + popup->setItemEnabled( 801, false ); + } + } + return true; + } + else + if ( theParent.compare("ObjectBrowser")==0 ) + { + popup->removeItem(QAD_TopLabel_Popup_ID); + int id = popup->idAt(0); // separator + if (id < 0) popup->removeItem(id); + + // checking for GEOM label in the selected list + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + Handle(SALOME_InteractiveObject) anIObject; + + bool useSubItems = false; + bool needOpen = false; + bool needDisplay = false; + bool needErase = false; + SALOMEDS::GenericAttribute_var aTmpAttr; + for(;It.More();It.Next()) + { + anIObject = It.Value(); + if (!anIObject->hasEntry()) + continue; + + if (v3d->isInViewer(anIObject) && v3d->isVisible(anIObject)) + needErase = true; + else + needDisplay = true; + SALOMEDS::SObject_var obj = + myActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() ); + if (!obj->_is_nil()) + { + GEOM::GEOM_Shape_var aShape; + if (obj->FindAttribute(aTmpAttr, "AttributeIOR")) { + char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value(); + if (str && strlen(str)) + aShape = myComponentGeom-> GetIORFromString(str); + } + else + if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef")) + needOpen = true; + if (aShape->_is_nil()) + { + SALOMEDS::ChildIterator_var anIter = myActiveStudy-> + getStudyDocument()->NewChildIterator(obj); + while (anIter->More()) + { + SALOMEDS::SObject_var subobj = anIter->Value(); + if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) + { + useSubItems = true; + needErase = true; + needDisplay = true; + } + else + if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef")) + { + needOpen = true; + useSubItems = true; + } + anIter->Next(); + } + } + } + } + // remove useless popup items + if (nbSel != 1) popup->removeItem(901); // rename + if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only + if (!needOpen) + { + int index = popup->indexOf(9024); + popup->removeItem(9024); // open + popup->removeItemAt(index); // separator under Open + + if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID); + if (!needErase) popup->removeItem(QAD_Erase_Popup_ID); + if (!needDisplay && !needErase) + { + int id = popup->idAt(popup->count()-1); // last item + popup->removeItem(id); // separator + } + } + else + { + popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only + popup->removeItem(QAD_Display_Popup_ID); + popup->removeItem(QAD_Erase_Popup_ID); + if (nbSel!=1) + { + int id = popup->idAt(popup->count()-1); // last item + popup->removeItem(id); // separator + } + } + return true; + } + // MESSAGE ( " CUSTOM POPUP VIEWER OCC done. ") + } + else + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) + { + // MESSAGE ( " CUSTOM POPUP VIEWER VTK ") + if ( ( theParent.compare("Viewer")==0 ) ) + { + + popup->setItemEnabled( 8033, false ); + if (theObject.compare("Component") == 0) + { + popup->removeItem(QAD_DisplayOnly_Popup_ID); + return true; + } + + //int id = popup->idAt(0); + QFont f = QApplication::font(); + f.setBold( TRUE ); + + if (nbSel==1) + { + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + popup->removeItem(QAD_TopLabel_Popup_ID); + popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 ); + if ( IObject->hasEntry() ) + { + popup->setItemEnabled( 801, false ); + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !SO->_is_nil() ) + { + if (SO->FindAttribute(anAttr, "AttributeIOR") ) + { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + Standard_Boolean found; + GEOM_Actor* Result = ConvertIORinGEOMActor(anIOR->Value(), found, true); + if ( found ) + { + if ( Result->getDisplayMode() == 1 ) + popup->changeItem(8021, "Wireframe" ); + else + popup->changeItem(8021, "Shading" ); + + if ( !Result->GetVisibility() ) + popup->removeItem(QAD_Erase_Popup_ID); + else + popup->removeItem(QAD_Display_Popup_ID); + } + else + popup->removeItem(QAD_Erase_Popup_ID); + } + } + } + else + popup->setItemEnabled( 801, true ); + } + else + { + popup->removeItem(QAD_DisplayOnly_Popup_ID); + popup->removeItem(QAD_TopLabel_Popup_ID); + popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ), QAD_TopLabel_Popup_ID, 0 ); + popup->setItemEnabled( 801, false ); + } + return true; + } + else + if ( theParent.compare("ObjectBrowser")==0 ) + { + popup->removeItem(QAD_TopLabel_Popup_ID); + int id = popup->idAt(0); // separator + if (id < 0) popup->removeItem(id); + + // checking for GEOM label in the selected list + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + Handle(SALOME_InteractiveObject) anIObject; + + bool useSubItems = false; + bool needOpen = false; + bool needDisplay = false; + bool needErase = false; + SALOMEDS::GenericAttribute_var aTmpAttr; + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy-> + getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + for(;It.More();It.Next()) + { + anIObject = It.Value(); + if ( !anIObject->hasEntry() ) + continue; + + if (myRenderInter->isInViewer(anIObject) && myRenderInter->isVisible(anIObject)) + needErase = true; + else + needDisplay = true; + + SALOMEDS::SObject_var obj = myActiveStudy->getStudyDocument() + ->FindObjectID( anIObject->getEntry() ); + if (!obj->_is_nil()) { + GEOM::GEOM_Shape_var aShape; + if (obj->FindAttribute(aTmpAttr, "AttributeIOR")){ + char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value(); + if (str && strlen(str)) + aShape = myComponentGeom->GetIORFromString(str); + } + else + if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef")) + needOpen = true; + if (aShape->_is_nil()) + { + SALOMEDS::ChildIterator_var anIter = + myActiveStudy->getStudyDocument()->NewChildIterator(obj); + while (anIter->More()) + { + SALOMEDS::SObject_var subobj = anIter->Value(); + if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) + { + useSubItems = true; + needDisplay = true; + needErase = true; + } + else + if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef")) + { + needOpen = true; + useSubItems = true; + } + anIter->Next(); + } + } + } + } + // remove useless popup items + if (nbSel != 1) popup->removeItem(901); // rename + if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only + if (!needOpen) + { + int index = popup->indexOf(9024); + popup->removeItem(9024); // open + popup->removeItemAt(index); // separator under Open + + if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID); + if (!needErase) popup->removeItem(QAD_Erase_Popup_ID); + if (!needDisplay && !needErase) + { + int id = popup->idAt(popup->count()-1); // last item + popup->removeItem(id); // separator + } + } + else + { + popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only + popup->removeItem(QAD_Display_Popup_ID); + popup->removeItem(QAD_Erase_Popup_ID); + if (nbSel!=1) + { + int id = popup->idAt(popup->count()-1); // last item + popup->removeItem(id); // separator + } + } + return true; + // MESSAGE ( " CUSTOM POPUP VIEWER VTK done.") + } + } else + { // other viewer types not supported. + while (1) + { + int id = popup->idAt(0); + if (id <= QAD_TopLabel_Popup_ID && id != -1) + popup->removeItemAt(0); + else + break; + } + popup->removeItem(QAD_DisplayOnly_Popup_ID); + popup->removeItem(QAD_Display_Popup_ID); + popup->removeItem(QAD_Erase_Popup_ID); + int id = popup->idAt(popup->count()-1); // last item + if (id < 0 && id != -1) popup->removeItem(id); // separator + return false; + } + return false; +} + + +//======================================================================= +// function : activeStudyChanged() +// purpose : static +//======================================================================= +void GeometryGUI::activeStudyChanged(QAD_Desktop* parent) +{ + if(GeomGUI != 0) { + if(myState == CURRENT_SKETCH) { + mySketcher.Clear(); + ResetState(); + } + + QMenuBar* Mb = myDesktop->getMainMenuBar(); + bool ViewOCC = false; + if(myDesktop->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) + ViewOCC = true; + + Mb->setItemEnabled(312, ViewOCC); //Sketch + Mb->setItemEnabled(309, ViewOCC); //SuppressFace + Mb->setItemEnabled(314, ViewOCC); //SuppressHole + + Mb->setItemEnabled(703, ViewOCC);// ShadingColor Settings + Mb->setItemEnabled(704, ViewOCC);// Isos Settings + + EraseSimulationShape(); + EmitSignalCloseAllDialogs(); + GeomGUI = 0; + } + return ; +} + + +//======================================================================= +// function : BuildPresentation() +// purpose : static +//======================================================================= +void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) +{ + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + + OCCViewer_Viewer3d* v3d; + Handle(AIS_InteractiveContext) ic; + vtkRenderer* Renderer; + + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + ic = v3d->getAISContext(); + } else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + Renderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + } else + return; + + if (theIO.IsNull()) + MESSAGE("BuildPresentation(): null SALOME_InteractiveObject passed") + + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + // VTK + + SALOMEDS::SObject_var fatherSF = + aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry()); + + SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() ); + + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + + if(myRenderInter->isInViewer(theIO)) { + myRenderInter->Display(theIO, false); + } + else { + // Create new actor + if ( !obj->_is_nil() ) { + if ( obj->FindAttribute(anAttr, "AttributeIOR")) { + // this SObject may be GEOM module root SObject + + bool useSubItems = false; + SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); + if (myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) { + while (anIter->More() && !useSubItems) { + SALOMEDS::SObject_var subobj = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttr; + if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { + if (!myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) { + anAttr = aTmpAttr; + obj = subobj; + useSubItems = true; + } else anIter->Next(); + } else anIter->Next(); + } + } + + while(useSubItems?anIter->More():!anAttr->_is_nil()) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); + TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); + + if (obj->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + + vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* theAllActors = theRenderer->GetActors(); + theAllActors->InitTraversal(); + vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); + Handle(SALOME_InteractiveObject) anIObj; + // don't create new study object if it already exists + bool isDisplayed = false; + while(!(actor==NULL)) { + SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor); + if (Gactor!=NULL) { + if (Gactor->hasIO()) { + if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) { + isDisplayed = true; + anIObj = Gactor->getIO(); + if (!anIObj.IsNull()) myRenderInter->Display(anIObj, false); + } + } + } + actor=(vtkActor*)(theAllActors->GetNextActor()); + } + if (!isDisplayed) { + // open transaction + QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); + op->start(); + + SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); + aStudyBuilder->Addreference(newObj1, obj); + // commit transaction + op->finish(); + + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + int themode = myRenderInter->GetDisplayMode(); + + vtkActorCollection* theActors = + GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True); + theActors->InitTraversal(); + vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); + while(!(anActor==NULL)) { + GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor ); + Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), myFatherior,"GEOM"); + IO->setEntry(obj->GetID()); + GActor->setIO( IO ); + GActor->setName( theIO->getName() ); + + theRenderer->AddActor(GActor); + // renWin->Render(); + anActor = (vtkActor*)theActors->GetNextActor(); + } + } + } + // next item iteration + if (useSubItems) { + anIter->Next(); + anAttr = SALOMEDS::GenericAttribute::_nil(); + while (anIter->More() && anAttr->_is_nil()) { + SALOMEDS::SObject_var subobject = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttribute; + if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { + anAttr = aTmpAttribute; + obj = subobject; + } else anIter->Next(); + } + } else anAttr = SALOMEDS::GenericAttribute::_nil(); + } + } + } + } + // No viewer update should be done here! + //myRenderInter->Render(); + //myActiveStudy->updateObjBrowser( true ); + } else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + SALOMEDS::SObject_var fatherSF = + aStudy->FindObjectID( myActiveStudy->getActiveStudyFrame()->entry()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + + if ( v3d->isInViewer( theIO, true ) ) { + Standard_Boolean found; + Handle(GEOM_AISShape) aSh = ConvertIOinGEOMAISShape( theIO, found, true ); + if ( found ) { + ic->Display(aSh, false); + ic->AddOrRemoveCurrentObject(aSh, false); + } + + } else { + SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() ); + if ( !obj->_is_nil() ) { + MESSAGE("BuildPresentation(): SObject not null") + if ( obj->FindAttribute(anAttr, "AttributeIOR")) { + MESSAGE("BuildPresentation(): SObject has IOR") + // this SObject may be GEOM module root SObject + + bool useSubItems = false; + SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); + if (myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) { + while (anIter->More() && !useSubItems) { + SALOMEDS::SObject_var subobj = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttr; + if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { + if (!myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) { + anAttr = aTmpAttr; + obj = subobj; + useSubItems = true; + } else anIter->Next(); + } else anIter->Next(); + } + } + + while(useSubItems?anIter->More():!anAttr->_is_nil()) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); + TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); + if (Shape.IsNull()) + MESSAGE("BuildPresentation(): TopoDS_Shape is null!") + if (obj->FindAttribute(anAttr, "AttributeName")) { + MESSAGE("BuildPresentation(): SObject has Name") + aName = SALOMEDS::AttributeName::_narrow(anAttr); + // searchin for already displayed objects with the same shape + AIS_ListOfInteractive aDisplayed; + ic->DisplayedObjects(aDisplayed); + AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); + Handle(AIS_Shape) anAISShape; + for(;anIObjects.More();anIObjects.Next()) { + anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); + if (!anAISShape.IsNull()) { + if (anAISShape->Shape().IsSame(Shape)) break; + anAISShape.Nullify(); + } + } + if (!anAISShape.IsNull()) { + if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape, false); + } else { + if (!useSubItems) { + // open transaction + QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); + op->start(); + if (fatherSF->_is_nil()) + MESSAGE("BuildPresentation(): fatherSF is nil!") + SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); + aStudyBuilder->Addreference(newObj1, obj); + // commit transaction + op->finish(); + } + Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value()); + aSh->SetShadingColor( myShadingColor ); + Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), + myFatherior, + "GEOM"); + IO->setEntry(obj->GetID()); + aSh->setIO( IO ); + aSh->setName( aName->Value() ); + ic->Display (aSh, false); + if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, false); + } + } + // next item iteration + if (useSubItems) { + anIter->Next(); + anAttr=SALOMEDS::GenericAttribute::_nil(); + while (anIter->More() && anAttr->_is_nil()) { + SALOMEDS::SObject_var subobject = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttribute; + if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { + anAttr = aTmpAttribute; + obj = subobject; + } else anIter->Next(); + } + } else + anAttr = SALOMEDS::GenericAttribute::_nil(); + } + } + } + } + // No viewer update should be done here! + //myActiveStudy->updateObjBrowser( true ); + //ic->UpdateCurrentViewer(); + } +} + + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + { + return GeometryGUI::GetOrCreateGeometryGUI(parent)->OnGUIEvent(theCommandID, parent); + } + + bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) + { + return GeometryGUI::GetOrCreateGeometryGUI(parent)->OnKeyPress(pe, parent, studyFrame); + } + + bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) + { + return GeometryGUI::GetOrCreateGeometryGUI(parent)->OnMousePress(pe, parent, studyFrame); + } + + bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) + { + return GeometryGUI::GetOrCreateGeometryGUI(parent)->OnMouseMove(pe, parent, studyFrame); + } + + bool SetSettings (QAD_Desktop* parent) + { + return GeometryGUI::GetOrCreateGeometryGUI(parent)->SetSettings(parent); + } + + bool customPopup (QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, + const QString & theParent, const QString & theObject) + { + return GeometryGUI::GetOrCreateGeometryGUI(parent)->CustomPopup(parent, popup, theContext, + theParent, theObject); + } + + void definePopup (QString & theContext, QString & parent, QString & theObject) + { + GeometryGUI::GetGeometryGUI()->DefinePopup(theContext, parent, theObject); + } + + bool activeStudyChanged (QAD_Desktop* parent) + { + GeometryGUI::GetOrCreateGeometryGUI(parent)->activeStudyChanged(parent); + } + + void buildPresentation (const Handle(SALOME_InteractiveObject)& theIO) + { + GeometryGUI::GetGeometryGUI()->BuildPresentation(theIO); + } + + void supportedViewType(int* buffer, int bufferSize) + { + if(!buffer || !bufferSize) return; + buffer[0] = (int)VIEW_OCC; + if (--bufferSize) buffer[1] = (int)VIEW_VTK; + } +} diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index ce3eacd0f..a5c016716 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -38,6 +38,9 @@ #include "GEOM_Actor.h" #include "GEOM_Sketcher.h" +#include "GEOM_Client.hxx" +#include + // Open CASCADE Includes #include #include @@ -51,6 +54,7 @@ #include CORBA_SERVER_HEADER(SALOMEDS) #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + //================================================================================= // //================================================================================= @@ -69,10 +73,10 @@ class GeometryGUI : public QObject Q_OBJECT /* for QT compatibility */ private : - + GEOM::GEOM_Gen_var myComponentGeom; + GEOM_Client myShapeReader; QAD_Desktop* myDesktop; QAD_Study* myActiveStudy; - GEOM::GEOM_Gen_var myComponentGeom; QDialog* myActiveDialogBox; /* Unique active dialog box */ Handle(AIS_Shape) mySimulationShape; /* AIS shape used only during topo/geom simulations */ vtkActorCollection* mySimulationActor; /* GEOM Actor used only during topo/geom simulations */ @@ -82,6 +86,13 @@ private : Quantity_Color myShadingColor; + AIS_ListOfInteractive myListDisplayedObject; + + bool mySettings_AddInStudy; + bool mySettings_Copy; + Standard_CString myFatherior; + + public : GeometryGUI(); @@ -90,43 +101,26 @@ public : static GeometryGUI* GetOrCreateGeometryGUI( QAD_Desktop* desktop ); static GeometryGUI* GetGeometryGUI() ; - QAD_Study* GetActiveStudy() ; + QAD_Study* GetActiveStudy(); QAD_Desktop* GetDesktop() ; + GEOM_Client& GetShapeReader(); - QDialog* GetActiveDialogBox() ; /* Returns the active DialogBox */ - void SetActiveDialogBox(QDialog* aDlg) ; /* Sets 'myActiveDialogBox' a pointer to the active Dialog Box */ + QDialog* GetActiveDialogBox(); /* Returns the active DialogBox */ + void SetActiveDialogBox(QDialog* aDlg); /* Sets 'myActiveDialogBox' a pointer to the active Dialog Box */ - void SetState(int aState) ; - void ResetState() ; /* Sets myState = -1 a private field to indicate wich method is active */ - bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ; + void SetState(int aState); + void ResetState(); /* Sets myState = -1 a private field to indicate wich method is active */ - bool SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR); - - void OnEditCopy (); - void OnEditDelete (); - void OnVTKDisplayOnly (); - - void OnDisplayOnly (); - void OnDisplayAll ( bool onlyPreviousDisplayedObject = false ); - void SetDisplayedObjectList(); - bool AddInStudy( bool selection = false, const Handle(SALOME_InteractiveObject)& anIO = 0 ); - bool Display( GEOM::GEOM_Shape_ptr aShape, Standard_CString name = ""); - - /* Import and export topology methods */ - bool Import(); - bool Export(); - + bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ; + bool SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR); static int GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int ShapeType) ; static bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P) ; static void GetBipointDxDyDz( gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz) ; - static bool GetShapeTypeString( const TopoDS_Shape& aShape, Standard_CString& aTypeString ) ; static bool LinearEdgeExtremities( const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2) ; - static gp_Pnt ConvertClickToPoint( Standard_Real x, Standard_Real y, Handle(V3d_View) aView ) ; - /* User dialog 1 parameter returned */ static double Parameter( Standard_Boolean& res, const char* aValue1 = 0, @@ -137,91 +131,27 @@ public : const int decimals = 6 ) ; /* Managed by IAPP */ - Standard_EXPORT static bool OnGUIEvent ( int theCommandID, QAD_Desktop* parent) ; - Standard_EXPORT static bool OnMousePress ( QMouseEvent* pe, QAD_Desktop* parent, + Standard_EXPORT bool OnGUIEvent ( int theCommandID, QAD_Desktop* parent) ; + Standard_EXPORT bool OnMousePress ( QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame ); - Standard_EXPORT static bool OnMouseMove ( QMouseEvent* pe, QAD_Desktop* parent, + Standard_EXPORT bool OnMouseMove ( QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame ); - Standard_EXPORT static bool OnKeyPress ( QKeyEvent* pe, QAD_Desktop* parent, + Standard_EXPORT bool OnKeyPress ( QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame ); - Standard_EXPORT static void activeStudyChanged ( QAD_Desktop* parent ); - Standard_EXPORT static bool SetSettings ( QAD_Desktop* parent ); - Standard_EXPORT static void DefinePopup( QString & theContext, + Standard_EXPORT void activeStudyChanged ( QAD_Desktop* parent ); + Standard_EXPORT bool SetSettings ( QAD_Desktop* parent ); + Standard_EXPORT void DefinePopup( QString & theContext, QString & theParent, QString & theObject ); - Standard_EXPORT static bool CustomPopup ( QAD_Desktop* parent, + Standard_EXPORT bool CustomPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, const QString& theParent, const QString& theObject ); - Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&); + Standard_EXPORT void BuildPresentation(const Handle(SALOME_InteractiveObject)&); - void Archimede( const Handle(SALOME_InteractiveObject)& IO, const double aWeight, - const double aWaterDensity, const double aMeshingDeflection ); - - void MakePointAndDisplay( const double x, const double y, const double z ) ; - void MakeVectorAndDisplay( const gp_Pnt P1, const gp_Pnt P2 ); - void MakeBoxAndDisplay( const gp_Pnt P1, const gp_Pnt P2 ) ; - void MakePlaneAndDisplay( const gp_Pnt P1, const Standard_Real dx, - const Standard_Real dy, const Standard_Real dz, const Standard_Real TrimSize ) ; - void MakeSphereAndDisplay( const gp_Pnt aCenterPoint, const double aRadius) ; - void MakeCircleAndDisplay( const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius) ; - void MakeEllipseAndDisplay( const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Major_Radius, const Standard_Real Minor_Radius) ; - void MakeArcAndDisplay( gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint ) ; - void MakeLineAndDisplay( const gp_Pnt InitPoint, const gp_Pnt LastPoint) ; - void MakeCylinderAndDisplay( const gp_Pnt BasePoint, const gp_Dir aDir, - const double Radius, const double aHeight ) ; - void MakeConeAndDisplay( const gp_Pnt BasePoint, const gp_Dir aDir, - const double Radius1, const double Radius2, const double aHeight ) ; - void MakeTorusAndDisplay( const gp_Pnt BasePoint, const gp_Dir aDir, - const double Radius1, const double Radius2 ) ; - void MakeBooleanAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2, - const short operation ) ; - void MakeRevolutionAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, - const gp_Dir dir, Standard_Real revolAngle ) ; - void MakePrismAndDisplay( GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2 ) ; - void MakePipeAndDisplay( GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase ) ; - void MakeFillingAndDisplay( GEOM::GEOM_Shape_ptr SectionShape, const short mindeg, const short maxdeg, - const double tol3d, const double tol2d, const short nbiter ) ; - void MakeRotationAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir, - const Standard_Real angle ) ; - void MakeTranslationAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Vec V) ; - - void MakeMultiTranslation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const double Step, const short NbTimes ) ; - void MakeMultiTranslation2DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir1, const double Step1, const short NbTimes1, - const gp_Dir Dir2, const double Step2, const short NbTimes2 ) ; - void MakeMultiRotation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes ) ; - void MakeMultiRotation2DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const double Ang, - const short NbTimes1, const double Step, const short NbTimes2 ) ; - void MakeCDGAndDisplay( GEOM::GEOM_Shape_ptr Shape ); - void MakeScaleAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, - const Standard_Real factor) ; - void MakeMirrorAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2 ) ; - void MakeSewingAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, - const Standard_Real precision ) ; - void MakeCompoundAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) ; - void MakeShellAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) ; - void MakeSolidAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) ; - void MakeLinearEdgeAndDisplay( const gp_Pnt P1, const gp_Pnt P2 ) ; - void MakeOrientationChangeAndDisplay( GEOM::GEOM_Shape_ptr Shape ) ; - - void MakePartitionAndDisplay (const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, - const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR, - const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR, - const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR, - const GEOM::shape_type limit ) ; - - void MakeWireAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) ; - void MakeWorkingPlane( const gp_Pnt P, const gp_Dir D) ; - void MakeFaceAndDisplay( GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar ) ; - - /* Simulation management */ - bool CreateArrowForLinearEdge( const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone ) ; - void DisplaySimulationShape(const TopoDS_Shape& S) ; - void EraseSimulationShape() ; /* Selection and objects management */ - TopoDS_Shape GetShapeFromIOR( QString IOR ); bool GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds) ; int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ; @@ -270,28 +200,99 @@ public : Standard_Integer& aLocalContextId, bool& myUseLocalContext ) ; + + /* Import and export topology methods */ + bool Import(); + bool Export(); + + void OnEditCopy(); + void OnEditDelete(); + + void OnVTKDisplayOnly(); + void OnDisplayOnly(); + void OnDisplayAll(bool onlyPreviousDisplayedObject = false); + void SetDisplayedObjectList(); + bool Display(GEOM::GEOM_Shape_ptr aShape, Standard_CString name = ""); + + /* Simulation management */ + bool CreateArrowForLinearEdge(const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone); + void DisplaySimulationShape(const TopoDS_Shape& S); + void EraseSimulationShape(); + + + void MakePointAndDisplay(const double x, const double y, const double z); + void MakeLineAndDisplay(const gp_Pnt InitPoint, const gp_Pnt LastPoint); + void MakeCircleAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius); + void MakeEllipseAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Major_Radius, + const Standard_Real Minor_Radius); + void MakeArcAndDisplay(gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint); + void MakeVectorAndDisplay(const gp_Pnt P1, const gp_Pnt P2); + void MakePlaneAndDisplay(const gp_Pnt P1, const Standard_Real dx, const Standard_Real dy, + const Standard_Real dz, const Standard_Real TrimSize); + void MakeWorkingPlane(const gp_Pnt P, const gp_Dir D); + + + void MakePrismAndDisplay(GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2); + void MakeRevolutionAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, + const gp_Dir dir, Standard_Real revolAngle); + void MakeFillingAndDisplay(GEOM::GEOM_Shape_ptr SectionShape, const short mindeg, const short maxdeg, + const double tol3d, const double tol2d, const short nbiter); + void MakePipeAndDisplay(GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase); + + + void MakeLinearEdgeAndDisplay(const gp_Pnt P1, const gp_Pnt P2); + void MakeWireAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); + void MakeFaceAndDisplay(GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar); + void MakeShellAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); + void MakeSolidAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); + void MakeCompoundAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); + + /* Remove faces in a shape */ bool OnSuppressFaces( const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const Standard_Integer& aLocalContextId, bool& myUseLocalContext ) ; - /* Remove an hole in a topology (ListOfIdEndFace may be an empty list ) */ bool OnSuppressHole( const char* ShapeTopoIOR, const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace, const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace ) ; - + const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace ) ; /* Remove one or more holes in a face or a shell */ bool OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR, const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires ) ; - /* Create a face corresponding to a hole on a shape */ bool OnFillingHole( const TopoDS_Shape& MainShape, const char* ShapeTopoIOR, const Standard_Integer& aLocalContextId, bool& myUseLocalContext ) ; - + + + void MakeTranslationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Vec V); + void MakeRotationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, + const gp_Dir dir, const Standard_Real angle); + void MakeMirrorAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2); + void MakeScaleAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, + const Standard_Real factor); + void MakeMultiTranslation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, + const gp_Dir Dir, const double Step, const short NbTimes); + void MakeMultiTranslation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape, + const gp_Dir Dir1, const double Step1, const short NbTimes1, + const gp_Dir Dir2, const double Step2, const short NbTimes2); + void MakeMultiRotation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, + const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes); + void MakeMultiRotation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape, + const gp_Dir Dir, const gp_Pnt Loc, const double Ang, + const short NbTimes1, const double Step, const short NbTimes2); + + + void MakePartitionAndDisplay(const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, + const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR, + const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR, + const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR, + const GEOM::shape_type limit ) ; + void Archimede(const Handle(SALOME_InteractiveObject)& IO, const double aWeight, + const double aWaterDensity, const double aMeshingDeflection); /* Method for Fillet */ bool OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, const int SubShapeType, const char* ShapeTopoIOR) ; bool OnFilletGetSelected(const TopoDS_Shape& ShapeTopo, @@ -300,7 +301,6 @@ public : const int SubShapeType, Standard_Integer& aLocalContextId, bool& myUseLocalContext ); - /* Methods for Chamfer */ bool OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, const int SubShapeType, const char* ShapeTopoIOR) ; bool OnChamferGetSelected(const TopoDS_Shape& ShapeTopo, @@ -309,9 +309,13 @@ public : Standard_Integer& aLocalContextId, bool& myUseLocalContext ) ; - /* Non modal dialog boxes magement */ - void EmitSignalDeactivateDialog() ; - void EmitSignalCloseAllDialogs() ; + + void MakeSewingAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, + const Standard_Real precision); + void MakeOrientationChangeAndDisplay(GEOM::GEOM_Shape_ptr Shape); + + + void MakeCDGAndDisplay( GEOM::GEOM_Shape_ptr Shape ); /* Sketcher management */ void OnSketchSegment(); @@ -334,6 +338,10 @@ public : void OnSettingsPerpendicular(); void OnSettingsTangent(); + /* Non modal dialog boxes magement */ + void EmitSignalDeactivateDialog() ; + void EmitSignalCloseAllDialogs() ; + signals: void SignalDeactivateActiveDialog() ; void SignalCloseAllDialogs() ; diff --git a/src/GEOMGUI/GeometryGUI_1Sel1Spin.cxx b/src/GEOMGUI/GeometryGUI_1Sel1Spin.cxx index 56ee26b90..06dc53e52 100644 --- a/src/GEOMGUI/GeometryGUI_1Sel1Spin.cxx +++ b/src/GEOMGUI/GeometryGUI_1Sel1Spin.cxx @@ -36,15 +36,12 @@ * Constructs a GeometryGUI_1Sel1Spin which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ -GeometryGUI_1Sel1Spin::GeometryGUI_1Sel1Spin( QWidget* parent, const char* name, WFlags fl ) - : GeometryGUI_1Sel1Spin_QTD( parent, name, fl ) +GeometryGUI_1Sel1Spin::GeometryGUI_1Sel1Spin(QWidget* parent, const char* name, WFlags fl) + :GeometryGUI_1Sel1Spin_QTD(parent, name, fl) { - - SpinBox1->close( TRUE ); - - SpinBox_DX = new GeometryGUI_SpinBox( GroupBox1, "SpinBox_DX" ) ; - Layout2->addWidget( SpinBox_DX, 0, 1 ); - + SpinBox1->close(TRUE); + SpinBox_DX = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DX"); + Layout2->addWidget(SpinBox_DX, 0, 1); } diff --git a/src/GEOMGUI/GeometryGUI_1Sel4Spin.cxx b/src/GEOMGUI/GeometryGUI_1Sel4Spin.cxx index 11d895791..0ca01867a 100644 --- a/src/GEOMGUI/GeometryGUI_1Sel4Spin.cxx +++ b/src/GEOMGUI/GeometryGUI_1Sel4Spin.cxx @@ -36,27 +36,25 @@ * Constructs a GeometryGUI_1Sel4Spin which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ -GeometryGUI_1Sel4Spin::GeometryGUI_1Sel4Spin( QWidget* parent, const char* name, WFlags fl ) - : GeometryGUI_1Sel4Spin_QTD( parent, name, fl ) +GeometryGUI_1Sel4Spin::GeometryGUI_1Sel4Spin(QWidget* parent, const char* name, WFlags fl) + :GeometryGUI_1Sel4Spin_QTD(parent, name, fl) { + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + SpinBox3->close(TRUE); + SpinBox4->close(TRUE); - SpinBox1->close( TRUE ); - SpinBox2->close( TRUE ); - SpinBox3->close( TRUE ); - SpinBox4->close( TRUE ); + SpinBox_DX = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DX"); + Layout3->addWidget(SpinBox_DX, 0, 2); - SpinBox_DX = new GeometryGUI_SpinBox( GroupBox1, "SpinBox_DX" ) ; - Layout3->addWidget( SpinBox_DX, 0, 2 ); + SpinBox_DY = new GeometryGUI_SpinBox( GroupBox1, "SpinBox_DY"); + Layout3->addWidget(SpinBox_DY, 0, 4); - SpinBox_DY = new GeometryGUI_SpinBox( GroupBox1, "SpinBox_DY" ) ; - Layout3->addWidget( SpinBox_DY, 0, 4 ); - - SpinBox_DZ = new GeometryGUI_SpinBox( GroupBox1, "SpinBox_DZ" ) ; - Layout3->addWidget( SpinBox_DZ, 0, 6 ); - - SpinBox_S = new GeometryGUI_SpinBox( GroupBox1, "SpinBox_S" ) ; - Layout4->addWidget( SpinBox_S, 0, 1 ); + SpinBox_DZ = new GeometryGUI_SpinBox( GroupBox1, "SpinBox_DZ"); + Layout3->addWidget(SpinBox_DZ, 0, 6); + SpinBox_S = new GeometryGUI_SpinBox( GroupBox1, "SpinBox_S"); + Layout4->addWidget(SpinBox_S, 0, 1); } diff --git a/src/GEOMGUI/GeometryGUI_1Spin.cxx b/src/GEOMGUI/GeometryGUI_1Spin.cxx new file mode 100644 index 000000000..7653374de --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_1Spin.cxx @@ -0,0 +1,56 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// 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 +// +// +// +// File : GeometryGUI_1Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "GeometryGUI_1Spin.h" + +#include +#include +#include + +/* + * Constructs a GeometryGUI_1Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +GeometryGUI_1Spin::GeometryGUI_1Spin(QWidget* parent, const char* name, WFlags fl) + :GeometryGUI_1Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + + SpinBox_DX = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DX"); + Layout1->addWidget(SpinBox_DX, 0, 1); + +} + + +/* + * Destroys the object and frees any allocated resources + */ +GeometryGUI_1Spin::~GeometryGUI_1Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/GEOMGUI/GeometryGUI_1Spin.h b/src/GEOMGUI/GeometryGUI_1Spin.h new file mode 100644 index 000000000..d36bc9c76 --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_1Spin.h @@ -0,0 +1,47 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// 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 +// +// +// +// File : GeometryGUI_1Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef GEOMETRYGUI_1SPIN_H +#define GEOMETRYGUI_1SPIN_H + +#include "GeometryGUI_1Spin_QTD.h" +#include "GeometryGUI_SpinBox.h" + +class GeometryGUI_1Spin : public GeometryGUI_1Spin_QTD +{ + Q_OBJECT + +public: + GeometryGUI_1Spin(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~GeometryGUI_1Spin(); + + GeometryGUI_SpinBox* SpinBox_DX; + +}; + +#endif // GEOMETRYGUI_1SPIN_H diff --git a/src/GEOMGUI/GeometryGUI_1Spin_QTD.cxx b/src/GEOMGUI/GeometryGUI_1Spin_QTD.cxx new file mode 100644 index 000000000..7b2c994d1 --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_1Spin_QTD.cxx @@ -0,0 +1,68 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'GeometryGUI_1Spin_QTD.ui' +** +** Created: jeu sep 25 12:22:29 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "GeometryGUI_1Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a GeometryGUI_1Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +GeometryGUI_1Spin_QTD::GeometryGUI_1Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "GeometryGUI_1Spin_QTD" ); + resize( 124, 55 ); + setCaption( trUtf8( "GeometryGUI_1Spin_QTD" ) ); + GeometryGUI_1Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "GeometryGUI_1Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 1 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox1, 0, 1 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + GeometryGUI_1Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +GeometryGUI_1Spin_QTD::~GeometryGUI_1Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/GEOMGUI/GeometryGUI_1Spin_QTD.h b/src/GEOMGUI/GeometryGUI_1Spin_QTD.h new file mode 100644 index 000000000..e0acda271 --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_1Spin_QTD.h @@ -0,0 +1,40 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'GeometryGUI_1Spin_QTD.ui' +** +** Created: jeu sep 25 12:22:29 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef GEOMETRYGUI_1SPIN_QTD_H +#define GEOMETRYGUI_1SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QSpinBox; + +class GeometryGUI_1Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + GeometryGUI_1Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~GeometryGUI_1Spin_QTD(); + + QGroupBox* GroupBox1; + QSpinBox* SpinBox1; + QLabel* TextLabel1; + + +protected: + QGridLayout* GeometryGUI_1Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; +}; + +#endif // GEOMETRYGUI_1SPIN_QTD_H diff --git a/src/GEOMGUI/GeometryGUI_2Sel1Spin.cxx b/src/GEOMGUI/GeometryGUI_2Sel1Spin.cxx index 54ba70102..3eb5fd957 100644 --- a/src/GEOMGUI/GeometryGUI_2Sel1Spin.cxx +++ b/src/GEOMGUI/GeometryGUI_2Sel1Spin.cxx @@ -36,15 +36,12 @@ * Constructs a GeometryGUI_2Sel1Spin which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ -GeometryGUI_2Sel1Spin::GeometryGUI_2Sel1Spin( QWidget* parent, const char* name, WFlags fl ) - : GeometryGUI_2Sel1Spin_QTD( parent, name, fl ) +GeometryGUI_2Sel1Spin::GeometryGUI_2Sel1Spin(QWidget* parent, const char* name, WFlags fl) + :GeometryGUI_2Sel1Spin_QTD(parent, name, fl) { - - SpinBox1->close( TRUE ); - - SpinBox_DX = new GeometryGUI_SpinBox( GroupBox1, "SpinBox_DX" ) ; - Layout2->addWidget( SpinBox_DX, 0, 1 ); - + SpinBox1->close(TRUE); + SpinBox_DX = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DX"); + Layout2->addWidget(SpinBox_DX, 0, 1); } diff --git a/src/GEOMGUI/GeometryGUI_2Sel2Spin.cxx b/src/GEOMGUI/GeometryGUI_2Sel2Spin.cxx new file mode 100644 index 000000000..27a1c95a6 --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_2Sel2Spin.cxx @@ -0,0 +1,57 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// 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 +// +// +// +// File : GeometryGUI_2Sel2Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "GeometryGUI_2Sel2Spin.h" + +#include +#include +#include + +/* + * Constructs a GeometryGUI_2Sel1Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +GeometryGUI_2Sel2Spin::GeometryGUI_2Sel2Spin(QWidget* parent, const char* name, WFlags fl) + :GeometryGUI_2Sel2Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + SpinBox_DX = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DX"); + Layout2->addWidget(SpinBox_DX, 0, 1); + SpinBox_DY = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DY"); + Layout2->addWidget(SpinBox_DY, 1, 1); +} + + +/* + * Destroys the object and frees any allocated resources + */ +GeometryGUI_2Sel2Spin::~GeometryGUI_2Sel2Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/GEOMGUI/GeometryGUI_2Sel2Spin.h b/src/GEOMGUI/GeometryGUI_2Sel2Spin.h new file mode 100644 index 000000000..ab8da718e --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_2Sel2Spin.h @@ -0,0 +1,48 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// 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 +// +// +// +// File : GeometryGUI_2Sel2Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef GEOMETRYGUI_2SEL2SPIN_H +#define GEOMETRYGUI_2SEL2SPIN_H + +#include "GeometryGUI_2Sel2Spin_QTD.h" +#include "GeometryGUI_SpinBox.h" + +class GeometryGUI_2Sel2Spin : public GeometryGUI_2Sel2Spin_QTD +{ + Q_OBJECT + +public: + GeometryGUI_2Sel2Spin(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~GeometryGUI_2Sel2Spin(); + + GeometryGUI_SpinBox* SpinBox_DX; + GeometryGUI_SpinBox* SpinBox_DY; + +}; + +#endif // GEOMETRYGUI_2SEL2SPIN_H diff --git a/src/GEOMGUI/GeometryGUI_2Sel2Spin_QTD.cxx b/src/GEOMGUI/GeometryGUI_2Sel2Spin_QTD.cxx new file mode 100644 index 000000000..21b947185 --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_2Sel2Spin_QTD.cxx @@ -0,0 +1,116 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'GeometryGUI_2Sel2Spin_QTD.ui' +** +** Created: jeu sep 25 12:10:29 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "GeometryGUI_2Sel2Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a GeometryGUI_2Sel2Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +GeometryGUI_2Sel2Spin_QTD::GeometryGUI_2Sel2Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "GeometryGUI_2Sel2Spin_QTD" ); + resize( 129, 145 ); + setCaption( trUtf8( "GeometryGUI_2Sel2Spin_QTD" ) ); + GeometryGUI_2Sel2Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "GeometryGUI_2Sel2Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox2, 1, 1 ); + + TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + TextLabel4->setText( trUtf8( "TL4" ) ); + + Layout2->addWidget( TextLabel4, 1, 0 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout2->addWidget( TextLabel3, 0, 0 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox1, 0, 1 ); + + Layout1->addMultiCellLayout( Layout2, 2, 2, 0, 2 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + QSpacerItem* spacer = new QSpacerItem( 0, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 2 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + GeometryGUI_2Sel2Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +GeometryGUI_2Sel2Spin_QTD::~GeometryGUI_2Sel2Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/GEOMGUI/GeometryGUI_2Sel2Spin_QTD.h b/src/GEOMGUI/GeometryGUI_2Sel2Spin_QTD.h new file mode 100644 index 000000000..5a620ada9 --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_2Sel2Spin_QTD.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'GeometryGUI_2Sel2Spin_QTD.ui' +** +** Created: jeu sep 25 12:10:29 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef GEOMETRYGUI_2SEL2SPIN_QTD_H +#define GEOMETRYGUI_2SEL2SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QSpinBox; + +class GeometryGUI_2Sel2Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + GeometryGUI_2Sel2Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~GeometryGUI_2Sel2Spin_QTD(); + + QGroupBox* GroupBox1; + QLineEdit* LineEdit1; + QSpinBox* SpinBox2; + QLabel* TextLabel4; + QLabel* TextLabel3; + QSpinBox* SpinBox1; + QPushButton* PushButton2; + QLabel* TextLabel2; + QLabel* TextLabel1; + QPushButton* PushButton1; + QLineEdit* LineEdit2; + + +protected: + QGridLayout* GeometryGUI_2Sel2Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; + QGridLayout* Layout2; +}; + +#endif // GEOMETRYGUI_2SEL2SPIN_QTD_H diff --git a/src/GEOMGUI/GeometryGUI_2Sel3Spin.cxx b/src/GEOMGUI/GeometryGUI_2Sel3Spin.cxx new file mode 100644 index 000000000..6a5cfa9d7 --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_2Sel3Spin.cxx @@ -0,0 +1,60 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// 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 +// +// +// +// File : GeometryGUI_2Sel3Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "GeometryGUI_2Sel3Spin.h" + +#include +#include +#include + +/* + * Constructs a GeometryGUI_2Sel1Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +GeometryGUI_2Sel3Spin::GeometryGUI_2Sel3Spin(QWidget* parent, const char* name, WFlags fl) + :GeometryGUI_2Sel3Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + SpinBox3->close(TRUE); + SpinBox_DX = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DX"); + Layout2->addWidget(SpinBox_DX, 0, 1); + SpinBox_DY = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DY"); + Layout2->addWidget(SpinBox_DY, 1, 1); + SpinBox_DZ = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DZ"); + Layout2->addWidget(SpinBox_DZ, 2, 1); +} + + +/* + * Destroys the object and frees any allocated resources + */ +GeometryGUI_2Sel3Spin::~GeometryGUI_2Sel3Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/GEOMGUI/GeometryGUI_2Sel3Spin.h b/src/GEOMGUI/GeometryGUI_2Sel3Spin.h new file mode 100644 index 000000000..a104b4f6b --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_2Sel3Spin.h @@ -0,0 +1,49 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// 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 +// +// +// +// File : GeometryGUI_2Sel3Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef GEOMETRYGUI_2SEL3SPIN_H +#define GEOMETRYGUI_2SEL3SPIN_H + +#include "GeometryGUI_2Sel3Spin_QTD.h" +#include "GeometryGUI_SpinBox.h" + +class GeometryGUI_2Sel3Spin : public GeometryGUI_2Sel3Spin_QTD +{ + Q_OBJECT + +public: + GeometryGUI_2Sel3Spin(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~GeometryGUI_2Sel3Spin(); + + GeometryGUI_SpinBox* SpinBox_DX; + GeometryGUI_SpinBox* SpinBox_DY; + GeometryGUI_SpinBox* SpinBox_DZ; + +}; + +#endif // GEOMETRYGUI_2SEL3SPIN_H diff --git a/src/GEOMGUI/GeometryGUI_2Sel3Spin_QTD.cxx b/src/GEOMGUI/GeometryGUI_2Sel3Spin_QTD.cxx new file mode 100644 index 000000000..d8778a631 --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_2Sel3Spin_QTD.cxx @@ -0,0 +1,127 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'GeometryGUI_2Sel3Spin_QTD.ui' +** +** Created: jeu sep 25 16:18:43 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "GeometryGUI_2Sel3Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a GeometryGUI_2Sel3Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +GeometryGUI_2Sel3Spin_QTD::GeometryGUI_2Sel3Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "GeometryGUI_2Sel3Spin_QTD" ); + resize( 129, 173 ); + setCaption( trUtf8( "GeometryGUI_2Sel3Spin_QTD" ) ); + GeometryGUI_2Sel3Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "GeometryGUI_2Sel3Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout2->addWidget( TextLabel3, 0, 0 ); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox2, 1, 1 ); + + TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + TextLabel4->setText( trUtf8( "TL4" ) ); + + Layout2->addWidget( TextLabel4, 1, 0 ); + + TextLabel5 = new QLabel( GroupBox1, "TextLabel5" ); + TextLabel5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel5->sizePolicy().hasHeightForWidth() ) ); + TextLabel5->setText( trUtf8( "TL4" ) ); + + Layout2->addWidget( TextLabel5, 2, 0 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox1, 0, 1 ); + + SpinBox3 = new QSpinBox( GroupBox1, "SpinBox3" ); + SpinBox3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox3->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox3, 2, 1 ); + + Layout1->addMultiCellLayout( Layout2, 2, 2, 0, 2 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 2 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + GeometryGUI_2Sel3Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +GeometryGUI_2Sel3Spin_QTD::~GeometryGUI_2Sel3Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/GEOMGUI/GeometryGUI_2Sel3Spin_QTD.h b/src/GEOMGUI/GeometryGUI_2Sel3Spin_QTD.h new file mode 100644 index 000000000..3821a7bfe --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_2Sel3Spin_QTD.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'GeometryGUI_2Sel3Spin_QTD.ui' +** +** Created: jeu sep 25 16:18:43 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef GEOMETRYGUI_2SEL3SPIN_QTD_H +#define GEOMETRYGUI_2SEL3SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QSpinBox; + +class GeometryGUI_2Sel3Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + GeometryGUI_2Sel3Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~GeometryGUI_2Sel3Spin_QTD(); + + QGroupBox* GroupBox1; + QLineEdit* LineEdit1; + QLabel* TextLabel1; + QLabel* TextLabel2; + QLabel* TextLabel3; + QSpinBox* SpinBox2; + QLabel* TextLabel4; + QLabel* TextLabel5; + QSpinBox* SpinBox1; + QSpinBox* SpinBox3; + QPushButton* PushButton1; + QLineEdit* LineEdit2; + QPushButton* PushButton2; + + +protected: + QGridLayout* GeometryGUI_2Sel3Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; + QGridLayout* Layout2; +}; + +#endif // GEOMETRYGUI_2SEL3SPIN_QTD_H diff --git a/src/GEOMGUI/GeometryGUI_2Spin.cxx b/src/GEOMGUI/GeometryGUI_2Spin.cxx new file mode 100644 index 000000000..5ec679f6b --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_2Spin.cxx @@ -0,0 +1,60 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// 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 +// +// +// +// File : GeometryGUI_2Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "GeometryGUI_2Spin.h" + +#include +#include +#include + +/* + * Constructs a GeometryGUI_2Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +GeometryGUI_2Spin::GeometryGUI_2Spin(QWidget* parent, const char* name, WFlags fl) + :GeometryGUI_2Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + + SpinBox_DX = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DX"); + Layout1->addWidget(SpinBox_DX, 0, 1); + + SpinBox_DY = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DY"); + Layout1->addWidget(SpinBox_DY, 1, 1); + +} + + +/* + * Destroys the object and frees any allocated resources + */ +GeometryGUI_2Spin::~GeometryGUI_2Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/GEOMGUI/GeometryGUI_2Spin.h b/src/GEOMGUI/GeometryGUI_2Spin.h new file mode 100644 index 000000000..c01348aeb --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_2Spin.h @@ -0,0 +1,48 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// 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 +// +// +// +// File : GeometryGUI_2Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef GEOMETRYGUI_2SPIN_H +#define GEOMETRYGUI_2SPIN_H + +#include "GeometryGUI_2Spin_QTD.h" +#include "GeometryGUI_SpinBox.h" + +class GeometryGUI_2Spin : public GeometryGUI_2Spin_QTD +{ + Q_OBJECT + +public: + GeometryGUI_2Spin(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~GeometryGUI_2Spin(); + + GeometryGUI_SpinBox* SpinBox_DX; + GeometryGUI_SpinBox* SpinBox_DY; + +}; + +#endif // GEOMETRYGUI_2SPIN_H diff --git a/src/GEOMGUI/GeometryGUI_2Spin_QTD.cxx b/src/GEOMGUI/GeometryGUI_2Spin_QTD.cxx new file mode 100644 index 000000000..95c966afe --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_2Spin_QTD.cxx @@ -0,0 +1,79 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'GeometryGUI_2Spin_QTD.ui' +** +** Created: jeu sep 25 12:10:30 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "GeometryGUI_2Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a GeometryGUI_2Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +GeometryGUI_2Spin_QTD::GeometryGUI_2Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "GeometryGUI_2Spin_QTD" ); + resize( 124, 83 ); + setCaption( trUtf8( "GeometryGUI_2Spin_QTD" ) ); + GeometryGUI_2Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "GeometryGUI_2Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox2, 1, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 1 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox1, 0, 1 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + GeometryGUI_2Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +GeometryGUI_2Spin_QTD::~GeometryGUI_2Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/GEOMGUI/GeometryGUI_2Spin_QTD.h b/src/GEOMGUI/GeometryGUI_2Spin_QTD.h new file mode 100644 index 000000000..9ade2f2fa --- /dev/null +++ b/src/GEOMGUI/GeometryGUI_2Spin_QTD.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'GeometryGUI_2Spin_QTD.ui' +** +** Created: jeu sep 25 12:10:30 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef GEOMETRYGUI_2SPIN_QTD_H +#define GEOMETRYGUI_2SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QSpinBox; + +class GeometryGUI_2Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + GeometryGUI_2Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~GeometryGUI_2Spin_QTD(); + + QGroupBox* GroupBox1; + QSpinBox* SpinBox2; + QSpinBox* SpinBox1; + QLabel* TextLabel1; + QLabel* TextLabel2; + + +protected: + QGridLayout* GeometryGUI_2Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; +}; + +#endif // GEOMETRYGUI_2SPIN_QTD_H diff --git a/src/GEOMGUI/GeometryGUI_3Spin.cxx b/src/GEOMGUI/GeometryGUI_3Spin.cxx index 16fbbb980..ba44a7f2a 100644 --- a/src/GEOMGUI/GeometryGUI_3Spin.cxx +++ b/src/GEOMGUI/GeometryGUI_3Spin.cxx @@ -36,23 +36,21 @@ * Constructs a GeometryGUI_3Spin which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ -GeometryGUI_3Spin::GeometryGUI_3Spin( QWidget* parent, const char* name, WFlags fl ) - : GeometryGUI_3Spin_QTD( parent, name, fl ) +GeometryGUI_3Spin::GeometryGUI_3Spin(QWidget* parent, const char* name, WFlags fl) + :GeometryGUI_3Spin_QTD(parent, name, fl) { + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + SpinBox3->close(TRUE); - SpinBox1->close( TRUE ); - SpinBox2->close( TRUE ); - SpinBox3->close( TRUE ); + SpinBox_DX = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DX"); + Layout1->addWidget(SpinBox_DX, 0, 1); - SpinBox_DX = new GeometryGUI_SpinBox( GroupBox1, "SpinBox_DX" ) ; - Layout1->addWidget( SpinBox_DX, 0, 1 ); - - SpinBox_DY = new GeometryGUI_SpinBox( GroupBox1, "SpinBox_DY" ) ; - Layout1->addWidget( SpinBox_DY, 1, 1 ); - - SpinBox_DZ = new GeometryGUI_SpinBox( GroupBox1, "SpinBox_DZ" ) ; - Layout1->addWidget( SpinBox_DZ, 2, 1 ); + SpinBox_DY = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DY"); + Layout1->addWidget(SpinBox_DY, 1, 1); + SpinBox_DZ = new GeometryGUI_SpinBox(GroupBox1, "SpinBox_DZ"); + Layout1->addWidget(SpinBox_DZ, 2, 1); } diff --git a/src/GEOMGUI/GeometryGUI_BoxDlg.cxx b/src/GEOMGUI/GeometryGUI_BoxDlg.cxx index ec3bccf9a..56e6110e7 100644 --- a/src/GEOMGUI/GeometryGUI_BoxDlg.cxx +++ b/src/GEOMGUI/GeometryGUI_BoxDlg.cxx @@ -29,7 +29,6 @@ using namespace std; #include "GeometryGUI_BoxDlg.h" -#include #include #include "GeometryGUI.h" @@ -43,7 +42,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GeometryGUI_BoxDlg::GeometryGUI_BoxDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) +GeometryGUI_BoxDlg::GeometryGUI_BoxDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, SALOME_Selection* Sel, bool modal, WFlags fl) :GeometryGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_DLG_BOX_2P"))); @@ -76,7 +75,8 @@ GeometryGUI_BoxDlg::GeometryGUI_BoxDlg(QWidget* parent, const char* name, SALOME /***************************************************************/ /* Initialisations */ - Init(Sel); + myPrimitiveGUI = thePrimitiveGUI; + Init(); } @@ -94,7 +94,7 @@ GeometryGUI_BoxDlg::~GeometryGUI_BoxDlg() // function : Init() // purpose : //================================================================================= -void GeometryGUI_BoxDlg::Init(SALOME_Selection* Sel) +void GeometryGUI_BoxDlg::Init() { /* init variables */ myConstructorId = 0; @@ -144,7 +144,7 @@ void GeometryGUI_BoxDlg::Init(SALOME_Selection* Sel) GroupPoints->show(); this->show(); - return ; + return; } @@ -167,13 +167,14 @@ void GeometryGUI_BoxDlg::ConstructorsClicked(int constructorId) GroupDimensions->hide(); resize(0, 0); GroupPoints->show(); + myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit2->setText(""); /* filter for next selection */ mySelection->AddFilter(myVertexFilter); - connect (mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } case 1: @@ -228,7 +229,7 @@ void GeometryGUI_BoxDlg::ClickOnApply() case 0 : { if(myOkPoint1 && myOkPoint2) - myGeomGUI->MakeBoxAndDisplay(myPoint1, myPoint2); + myPrimitiveGUI->MakeBoxAndDisplay(myPoint1, myPoint2); break; } case 1 : @@ -239,7 +240,7 @@ void GeometryGUI_BoxDlg::ClickOnApply() double vz = GroupDimensions->SpinBox_DZ->GetValue(); myPoint1.SetCoord(0.0, 0.0, 0.0); myPoint2.SetCoord(vx, vy, vz); - myGeomGUI->MakeBoxAndDisplay(myPoint1, myPoint2); + myPrimitiveGUI->MakeBoxAndDisplay(myPoint1, myPoint2); break; } } diff --git a/src/GEOMGUI/GeometryGUI_BoxDlg.h b/src/GEOMGUI/GeometryGUI_BoxDlg.h index e22552931..2da1afbe9 100644 --- a/src/GEOMGUI/GeometryGUI_BoxDlg.h +++ b/src/GEOMGUI/GeometryGUI_BoxDlg.h @@ -33,6 +33,8 @@ #include "GeometryGUI_2Sel_QTD.h" #include "GeometryGUI_3Spin.h" +#include "PrimitiveGUI.h" + #include //================================================================================= @@ -44,14 +46,16 @@ class GeometryGUI_BoxDlg : public GeometryGUI_Skeleton Q_OBJECT public: - GeometryGUI_BoxDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + GeometryGUI_BoxDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~GeometryGUI_BoxDlg(); private : - void Init(SALOME_Selection* Sel); + void Init(); void enterEvent(QEvent* e); bool TestBoxDimensions(gp_Pnt P1, gp_Pnt P2); + PrimitiveGUI* myPrimitiveGUI; + double step; int myConstructorId; Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* filter for selection */ diff --git a/src/GEOMGUI/GeometryGUI_CommonDlg.cxx b/src/GEOMGUI/GeometryGUI_CommonDlg.cxx index 17552ed53..580d1d1e1 100644 --- a/src/GEOMGUI/GeometryGUI_CommonDlg.cxx +++ b/src/GEOMGUI/GeometryGUI_CommonDlg.cxx @@ -30,24 +30,7 @@ using namespace std; #include "GeometryGUI_CommonDlg.h" #include "GeometryGUI.h" -#include "QAD_Application.h" #include "QAD_Desktop.h" -#include "utilities.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include //================================================================================= // class : GeometryGUI_CommonDlg() @@ -56,111 +39,33 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GeometryGUI_CommonDlg::GeometryGUI_CommonDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +GeometryGUI_CommonDlg::GeometryGUI_CommonDlg(QWidget* parent, const char* name, BooleanGUI* theBooleanGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + :GeometryGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_COMMON"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_COMMON"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - if ( !name ) - setName( "GeometryGUI_CommonDlg" ); - resize( 322, 220 ); - setCaption( tr( "GEOM_COMMON_TITLE" ) ); - setSizeGripEnabled( TRUE ); + setCaption(tr("GEOM_COMMON_TITLE")); - GeometryGUI_CommonDlgLayout = new QGridLayout( this ); - GeometryGUI_CommonDlgLayout->setSpacing( 6 ); - GeometryGUI_CommonDlgLayout->setMargin( 11 ); + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_COMMON")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "GEOM_COMMON" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - GeometryGUI_CommonDlgLayout->addWidget( GroupConstructors, 0, 0 ); + GroupCommon = new GeometryGUI_2Sel_QTD(this, "GroupCommon"); + GroupCommon->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupCommon->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); + GroupCommon->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); + GroupCommon->PushButton1->setPixmap(image1); + GroupCommon->PushButton2->setPixmap(image1); - /***************************************************************/ - GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); - GroupConstructor1->setTitle( tr( "GEOM_ARGUMENTS" ) ); - GroupConstructor1->setColumnLayout(0, Qt::Vertical ); - GroupConstructor1->layout()->setSpacing( 0 ); - GroupConstructor1->layout()->setMargin( 0 ); - GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); - GroupConstructor1Layout->setAlignment( Qt::AlignTop ); - GroupConstructor1Layout->setSpacing( 6 ); - GroupConstructor1Layout->setMargin( 11 ); - LineEditC1A2Shape = new QLineEdit( GroupConstructor1, "LineEditC1A2Shape" ); - LineEditC1A2Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Shape->sizePolicy().hasHeightForWidth() ) ); - GroupConstructor1Layout->addWidget( LineEditC1A2Shape, 1, 2 ); - LineEditC1A1Shape = new QLineEdit( GroupConstructor1, "LineEditC1A1Shape" ); - LineEditC1A1Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Shape->sizePolicy().hasHeightForWidth() ) ); - GroupConstructor1Layout->addWidget( LineEditC1A1Shape, 0, 2 ); - SelectButtonC1A1Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A1Shape" ); - SelectButtonC1A1Shape->setText( tr( "" ) ); - SelectButtonC1A1Shape->setPixmap( image1 ); - GroupConstructor1Layout->addWidget( SelectButtonC1A1Shape, 0, 1 ); - SelectButtonC1A2Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A2Shape" ); - SelectButtonC1A2Shape->setText( tr( "" ) ); - SelectButtonC1A2Shape->setPixmap( image1 ); - GroupConstructor1Layout->addWidget( SelectButtonC1A2Shape, 1, 1 ); - TextLabelC1A2Shape = new QLabel( GroupConstructor1, "TextLabelC1A2Shape" ); - TextLabelC1A2Shape->setText( tr( "GEOM_OBJECT_I" ).arg("2") ); - TextLabelC1A2Shape->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A2Shape->setFrameShape( QLabel::NoFrame ); - TextLabelC1A2Shape->setFrameShadow( QLabel::Plain ); - GroupConstructor1Layout->addWidget( TextLabelC1A2Shape, 1, 0 ); - TextLabelC1A1Shape = new QLabel( GroupConstructor1, "TextLabelC1A1Shape" ); - TextLabelC1A1Shape->setText( tr( "GEOM_OBJECT_I" ).arg("1") ); - TextLabelC1A1Shape->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1Shape->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1Shape->setFrameShadow( QLabel::Plain ); - GroupConstructor1Layout->addWidget( TextLabelC1A1Shape, 0, 0 ); - GeometryGUI_CommonDlgLayout->addWidget( GroupConstructor1, 1, 0 ); + Layout1->addWidget(GroupCommon, 1, 0); + /***************************************************************/ - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "GEOM_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_1 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_1, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "GEOM_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - GeometryGUI_CommonDlgLayout->addWidget( GroupButtons, 2, 0 ); - - /* Initialisation */ - Init( Sel ) ; + /* Initialisation */ + myBooleanGUI = theBooleanGUI; + Init(); } @@ -171,7 +76,6 @@ GeometryGUI_CommonDlg::GeometryGUI_CommonDlg( QWidget* parent, const char* name, GeometryGUI_CommonDlg::~GeometryGUI_CommonDlg() { /* no need to delete child widgets, Qt does it all for us */ - this->destroy(TRUE, TRUE) ; } @@ -180,181 +84,108 @@ GeometryGUI_CommonDlg::~GeometryGUI_CommonDlg() // function : Init() // purpose : //================================================================================= -void GeometryGUI_CommonDlg::Init( SALOME_Selection* Sel ) -{ - mySelection = Sel ; - myShape1.Nullify() ; - myShape2.Nullify() ; - myConstructorId = 0 ; - - myGeomGUI = GeometryGUI::GetGeometryGUI() ; - - GroupConstructor1->show(); - myConstructorId = 0 ; - myEditCurrentArgument = LineEditC1A1Shape ; - Constructor1->setChecked( TRUE ); - myOkShape1 = myOkShape2 = false ; - - myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; - - Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); - myGeom = GEOM::GEOM_Gen::_narrow(comp); - - // TODO previous selection into argument - - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - connect( SelectButtonC1A1Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A2Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - - connect( LineEditC1A1Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - connect( LineEditC1A2Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - /* to close dialog if study change */ - connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - myGeomGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* Displays Dialog */ - - return ; -} - - - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void GeometryGUI_CommonDlg::ConstructorsClicked(int constructorId) +void GeometryGUI_CommonDlg::Init() { - GeometryGUI::GetGeometryGUI()->EraseSimulationShape() ; + /* init variables */ + myEditCurrentArgument = GroupCommon->LineEdit1; - switch (constructorId) - { - case 0: - { - GroupConstructor1->show(); - myConstructorId = constructorId ; - myEditCurrentArgument = LineEditC1A1Shape ; - LineEditC1A2Shape->setText(tr("")) ; - Constructor1->setChecked( TRUE ); - myOkShape1 = myOkShape2 = false ; - break; - } - } - return ; + myShape1.Nullify(); + myShape2.Nullify(); + myOkShape1 = myOkShape2 = false; + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupCommon->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupCommon->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupCommon->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupCommon->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupCommon->show(); + this->show(); + + return; } + //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void GeometryGUI_CommonDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - + this->ClickOnApply(); + ClickOnCancel(); return ; } + //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void GeometryGUI_CommonDlg::ClickOnApply() { - switch(myConstructorId) - { - case 0 : - { - if(myOkShape1 && myOkShape2) { - myGeomGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 1 ) ; - } - break ; - } - } + myGeomGUI->GetDesktop()->putInfo(tr("")); - // accept(); - return ; + if(myOkShape1 && myOkShape2) + myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 1); + + return; } -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void GeometryGUI_CommonDlg::ClickOnCancel() -{ - myGeomGUI->EraseSimulationShape() ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->ResetState() ; - reject() ; - return ; -} - - - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection has changed //================================================================================= void GeometryGUI_CommonDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText("") ; - QString aString = ""; /* name of future selection */ + myEditCurrentArgument->setText(""); + QString aString = ""; - int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - if ( nbSel != 1 ) { - switch (myConstructorId) - { - case 0: - { - if ( myEditCurrentArgument == LineEditC1A1Shape ) { - myOkShape1 = false ; - } - else if ( myEditCurrentArgument == LineEditC1A2Shape ) { - myOkShape2 = false ; - } - break ; - } - } - return ; + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupCommon->LineEdit1) + myOkShape1 = false; + else if( myEditCurrentArgument == GroupCommon->LineEdit2) + myOkShape2 = false; + return; } - /* nbSel == 1 */ + /* nbSel == 1 */ TopoDS_Shape S; - Standard_Boolean testResult ; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) - return ; + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if ( myEditCurrentArgument == LineEditC1A1Shape ) { - myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) - return ; - myShape1 = S ; - LineEditC1A1Shape->setText(aString) ; - myOkShape1 = true ; - } - else if ( myEditCurrentArgument == LineEditC1A2Shape ) { - myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) - return ; - myShape2 = S ; - LineEditC1A2Shape->setText(aString) ; - myOkShape2 = true ; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + if(myEditCurrentArgument == GroupCommon->LineEdit1) { + myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape1 = S; + GroupCommon->LineEdit1->setText(aString); + myOkShape1 = true; } - return ; + else if(myEditCurrentArgument == GroupCommon->LineEdit2) { + myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape2 = S; + GroupCommon->LineEdit2->setText(aString); + myOkShape2 = true; + } + return; } + //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -362,23 +193,18 @@ void GeometryGUI_CommonDlg::SelectionIntoArgument() void GeometryGUI_CommonDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if( send == SelectButtonC1A1Shape ) { - LineEditC1A1Shape->setFocus() ; - myEditCurrentArgument = LineEditC1A1Shape ; - } - else if(send == SelectButtonC1A2Shape) { - LineEditC1A2Shape->setFocus() ; - myEditCurrentArgument = LineEditC1A2Shape; - } - SelectionIntoArgument() ; - break; - } - } - return ; + + if(send == GroupCommon->PushButton1) { + GroupCommon->LineEdit1->setFocus(); + myEditCurrentArgument = GroupCommon->LineEdit1; + } + else if(send == GroupCommon->PushButton2) { + GroupCommon->LineEdit2->setFocus(); + myEditCurrentArgument = GroupCommon->LineEdit2; + } + SelectionIntoArgument(); + + return; } @@ -389,79 +215,39 @@ void GeometryGUI_CommonDlg::SetEditCurrentArgument() //================================================================================= void GeometryGUI_CommonDlg::LineEditReturnPressed() { - QLineEdit* send = (QLineEdit*)sender(); - if( send == LineEditC1A1Shape ) - myEditCurrentArgument = LineEditC1A1Shape ; - else if ( send == LineEditC1A2Shape ) - myEditCurrentArgument = LineEditC1A2Shape ; + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupCommon->LineEdit1) + myEditCurrentArgument = GroupCommon->LineEdit1; + else if(send == GroupCommon->LineEdit2) + myEditCurrentArgument = GroupCommon->LineEdit2; else - return ; - - /* User name of object input management */ - /* If successfull the selection is changed and signal emitted... */ - /* so SelectionIntoArgument() is automatically called. */ - const QString objectUserName = myEditCurrentArgument->text() ; - QWidget* thisWidget = (QWidget*)this ; - if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) { - myEditCurrentArgument->setText( objectUserName ) ; - } - return ; + return; + + GeometryGUI_Skeleton::LineEditReturnPressed(); + return; } - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void GeometryGUI_CommonDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupConstructor1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->EraseSimulationShape() ; - } - return ; -} - - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void GeometryGUI_CommonDlg::closeEvent( QCloseEvent* e ) -{ - this->ClickOnCancel() ; /* same than click on cancel button */ -} - - -//================================================================================= -// function : enterEvent() -// purpose : when mouse enter onto the QWidget -//================================================================================= -void GeometryGUI_CommonDlg::enterEvent( QEvent * ) -{ - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; -} - - - //================================================================================= // function : ActivateThisDialog() // purpose : //================================================================================= void GeometryGUI_CommonDlg::ActivateThisDialog() { - /* Emit a signal to deactivate any active dialog */ - myGeomGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupConstructor1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - return ; + GeometryGUI_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void GeometryGUI_CommonDlg::enterEvent(QEvent * e) +{ + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; } diff --git a/src/GEOMGUI/GeometryGUI_CommonDlg.h b/src/GEOMGUI/GeometryGUI_CommonDlg.h index 9e8844482..6596eeab9 100644 --- a/src/GEOMGUI/GeometryGUI_CommonDlg.h +++ b/src/GEOMGUI/GeometryGUI_CommonDlg.h @@ -29,91 +29,48 @@ #ifndef DIALOGBOX_COMMON_H #define DIALOGBOX_COMMON_H -#include "SALOME_Selection.h" -#include "GEOM_ShapeTypeFilter.hxx" +#include "GeometryGUI_Skeleton.h" +#include "GeometryGUI_2Sel_QTD.h" + +#include "BooleanGUI.h" #include -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QFrame; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; -class GeometryGUI; - - //================================================================================= // class : GeometryGUI_CommonDlg // purpose : //================================================================================= -class GeometryGUI_CommonDlg : public QDialog +class GeometryGUI_CommonDlg : public GeometryGUI_Skeleton { Q_OBJECT public: - GeometryGUI_CommonDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + GeometryGUI_CommonDlg(QWidget* parent = 0, const char* name = 0, BooleanGUI* theBooleanGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~GeometryGUI_CommonDlg(); private: + void Init(); + void enterEvent(QEvent * e); - void Init( SALOME_Selection* Sel ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + BooleanGUI* myBooleanGUI; - GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ - GeometryGUI* myGeomGUI ; /* Current GeomGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - TopoDS_Shape myShape1 ; /* topology used */ - TopoDS_Shape myShape2 ; /* topology used */ - GEOM::GEOM_Shape_var myGeomShape1 ; /* is myShape1 */ - GEOM::GEOM_Shape_var myGeomShape2 ; /* is myShape2 */ - bool myOkShape1 ; - bool myOkShape2 ; /* to check when arguments are defined */ - int myConstructorId ; /* Current constructor id = radio button id */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + TopoDS_Shape myShape1; /* topology used */ + TopoDS_Shape myShape2; /* topology used */ + GEOM::GEOM_Shape_var myGeomShape1; /* is myShape1 */ + GEOM::GEOM_Shape_var myGeomShape2; /* is myShape2 */ + bool myOkShape1; + bool myOkShape2; /* to check when arguments are defined */ - - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - - QGroupBox* GroupConstructor1; - QLineEdit* LineEditC1A1Shape; - QLineEdit* LineEditC1A2Shape; - QPushButton* SelectButtonC1A1Shape; - QPushButton* SelectButtonC1A2Shape; - QLabel* TextLabelC1A2Shape; - QLabel* TextLabelC1A1Shape; - - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; + GeometryGUI_2Sel_QTD* GroupCommon; private slots: - - void ConstructorsClicked(int constructorId); void ClickOnOk(); - void ClickOnCancel(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + void ActivateThisDialog(); -protected: - QGridLayout* GeometryGUI_CommonDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupConstructor1Layout; }; #endif // DIALOGBOX_COMMON_H diff --git a/src/GEOMGUI/GeometryGUI_ConeDlg.cxx b/src/GEOMGUI/GeometryGUI_ConeDlg.cxx index 030079183..d634c7d46 100644 --- a/src/GEOMGUI/GeometryGUI_ConeDlg.cxx +++ b/src/GEOMGUI/GeometryGUI_ConeDlg.cxx @@ -29,27 +29,13 @@ using namespace std; #include "GeometryGUI_ConeDlg.h" -#include "GeometryGUI.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_Config.h" -#include "utilities.h" - +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - +#include "GeometryGUI.h" +#include "QAD_Desktop.h" +#include "QAD_Config.h" //================================================================================= // class : GeometryGUI_ConeDlg() @@ -58,189 +44,44 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GeometryGUI_ConeDlg::GeometryGUI_ConeDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +GeometryGUI_ConeDlg::GeometryGUI_ConeDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + :GeometryGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CONE_PV"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); - QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CONE_DXYZ"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CONE_PV"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CONE_DXYZ"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - if ( !name ) - setName( "GeometryGUI_ConeDlg" ); - resize( 303, 309 ); - setCaption( tr( "GEOM_CONE_TITLE" ) ); - setSizeGripEnabled( TRUE ); - GeometryGUI_ConeDlgLayout = new QGridLayout( this ); - GeometryGUI_ConeDlgLayout->setSpacing( 6 ); - GeometryGUI_ConeDlgLayout->setMargin( 11 ); + setCaption(tr("GEOM_CONE_TITLE")); - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "GEOM_CONE" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" ); - Constructor2->setText( tr( "" ) ); - Constructor2->setMinimumSize( QSize( 50, 0 ) ); - Constructor2->setPixmap( image2 ); - Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - GroupConstructorsLayout->addWidget( Constructor2, 0, 2 ); - QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer_2, 0, 3 ); - GeometryGUI_ConeDlgLayout->addWidget( GroupConstructors, 0, 0 ); + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_CONE")); + RadioButton1->setPixmap(image0); + RadioButton2->setPixmap(image1); + RadioButton3->close(TRUE); - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "GEOM_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "GEOM_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - GeometryGUI_ConeDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupPoints = new GeometryGUI_2Sel3Spin(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_BASE_POINT")); + GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS_I").arg("1")); + GroupPoints->TextLabel4->setText(tr("GEOM_RADIUS_I").arg("2")); + GroupPoints->TextLabel5->setText(tr("GEOM_HEIGHT")); + GroupPoints->PushButton1->setPixmap(image2); + GroupPoints->PushButton2->setPixmap(image2); - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "GEOM_BASE_POINT" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); - SelectButtonC1A2->setText( tr( "" ) ); - SelectButtonC1A2->setPixmap( image1 ); - GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); - LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); - LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); - TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" ); - TextLabelC1A2->setText( tr( "GEOM_VECTOR" ) ); - TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A2->setFrameShape( QLabel::NoFrame ); - TextLabelC1A2->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); - TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" ); - TextLabelC1A3->setText( tr( "GEOM_RADIUS_I" ).arg("1") ); - TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A3->setFrameShape( QLabel::NoFrame ); - TextLabelC1A3->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 ); + GroupDimensions = new GeometryGUI_3Spin(this, "GroupDimensions"); + GroupDimensions->GroupBox1->setTitle(tr("GEOM_BOX_OBJ")); + GroupDimensions->TextLabel1->setText(tr("GEOM_RADIUS_I").arg("1")); + GroupDimensions->TextLabel2->setText(tr("GEOM_RADIUS_I").arg("2")); + GroupDimensions->TextLabel3->setText(tr("GEOM_HEIGHT")); - SpinBox_C1A3 = new GeometryGUI_SpinBox(GroupC1, "GeomSpinBox_C1A3" ) ; - SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( SpinBox_C1A3 , 2, 2 ); + Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupDimensions, 1, 0); + /***************************************************************/ - TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" ); - TextLabelC1A4->setText( tr( "GEOM_RADIUS_I" ).arg("2") ); - TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A4->setFrameShape( QLabel::NoFrame ); - TextLabelC1A4->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 ); - - SpinBox_C1A4 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A4" ) ; - SpinBox_C1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A4->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( SpinBox_C1A4 , 3, 2 ) ; - - TextLabelC1A5 = new QLabel( GroupC1, "TextLabelC1A5" ); - TextLabelC1A5->setText( tr( "GEOM_HEIGHT" ) ); - TextLabelC1A5->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A5->setFrameShape( QLabel::NoFrame ); - TextLabelC1A5->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A5, 4, 0 ); - - SpinBox_C1A5 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A5" ) ; - SpinBox_C1A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A5->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( SpinBox_C1A5 , 4, 2 ) ; - - GeometryGUI_ConeDlgLayout->addWidget( GroupC1, 1, 0 ); - /***************************************************************/ - - GroupC2 = new QGroupBox( this, "GroupC2" ); - GroupC2->setTitle( tr( "GEOM_BOX_OBJ" ) ); - GroupC2->setColumnLayout(0, Qt::Vertical ); - GroupC2->layout()->setSpacing( 0 ); - GroupC2->layout()->setMargin( 0 ); - GroupC2Layout = new QGridLayout( GroupC2->layout() ); - GroupC2Layout->setAlignment( Qt::AlignTop ); - GroupC2Layout->setSpacing( 6 ); - GroupC2Layout->setMargin( 11 ); - TextLabel_Height = new QLabel(GroupC2 , "TextLabel_Height" ); - TextLabel_Height->setText( tr( "GEOM_HEIGHT" ) ); - GroupC2Layout->addWidget( TextLabel_Height, 2, 0 ); - TextLabel_Radius1 = new QLabel( GroupC2, "TextLabel_Radius1" ); - TextLabel_Radius1->setText( tr( "GEOM_RADIUS_I" ).arg("1") ); - GroupC2Layout->addWidget( TextLabel_Radius1, 0, 0 ); - TextLabel_Radius2 = new QLabel( GroupC2, "TextLabel_Radius2" ); - TextLabel_Radius2->setText( tr( "GEOM_RADIUS_I" ).arg("2") ); - GroupC2Layout->addWidget( TextLabel_Radius2, 1, 0 ); - - SpinBox_Radius1 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius1" ) ; - GroupC2Layout->addWidget( SpinBox_Radius1 , 0, 1 ) ; - - SpinBox_Radius2 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius2" ) ; - GroupC2Layout->addWidget( SpinBox_Radius2 , 1, 1 ) ; - - SpinBox_Height = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Height" ) ; - GroupC2Layout->addWidget( SpinBox_Height , 2, 1 ) ; - - QSpacerItem* spacer1 = new QSpacerItem( 20, 60, QSizePolicy::Minimum, QSizePolicy::Fixed ); - GroupC2Layout->addItem( spacer1 ); - - GeometryGUI_ConeDlgLayout->addWidget(GroupC2 , 1, 0 ); - - /***************************************************************/ - - /* Initialisations */ - Init(Sel) ; + /* Initialisations */ + myPrimitiveGUI = thePrimitiveGUI; + Init(); } @@ -258,223 +99,161 @@ GeometryGUI_ConeDlg::~GeometryGUI_ConeDlg() // function : Init() // purpose : //================================================================================= -void GeometryGUI_ConeDlg::Init( SALOME_Selection* Sel ) +void GeometryGUI_ConeDlg::Init() { + /* init variables */ + myConstructorId = 0; + myEditCurrentArgument = GroupPoints->LineEdit1; + + myRadius1 = 100.0; + myRadius2 = 0.0; + myHeight = 300.0; + + myOkRadius1 = myOkRadius2 = myOkHeight = true; + myOkPoint1 = myOkDir = false; + + myEdgeFilter = new GEOM_EdgeFilter(StdSelect_Line, myGeom); + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + mySelection->AddFilter(myVertexFilter); /* Get setting of step value from file configuration */ - double step ; - QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ; - step = St.toDouble() ; + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); - /* min, max, step and decimals for spin boxes */ - SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* radius 1 */ - SpinBox_C1A3->SetValue( 100.0 ) ; - SpinBox_C1A4->RangeStepAndValidator( 0.000, 999.999, step, 3 ) ; /* radius 2 */ - SpinBox_C1A4->SetValue( 0.0 ) ; - SpinBox_C1A5->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* algebric height */ - SpinBox_C1A5->SetValue( 300.0 ) ; + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - SpinBox_Radius1->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* radius 1 */ - SpinBox_Radius1->SetValue( 100.0 ) ; - SpinBox_Radius2->RangeStepAndValidator( 0.000, 999.999, step, 3 ) ; /* radius 2 */ - SpinBox_Radius2->SetValue( 0.0 ) ; - SpinBox_Height->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* algebric height */ - SpinBox_Height->SetValue( 300.0 ) ; - - GroupC1->show(); - GroupC2->hide(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - myGeomGUI = GeometryGUI::GetGeometryGUI() ; - myRadius1 = 100.0 ; - myRadius2 = 0.0 ; - myHeight = 300.0 ; - - myOkRadius1 = true ; - myOkRadius2 = true ; - myOkHeight = true ; - myOkPoint1 = false ; - myOkDir = false ; - - mySimulationTopoDs.Nullify() ; - myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; - - // TODO : previous selection into argument ? - - /* Filter definitions */ - Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); - myGeom = GEOM::GEOM_Gen::_narrow(comp); - myEdgeFilter = new GEOM_EdgeFilter( StdSelect_Line, myGeom ); - myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom ); - /* first filter used */ - mySelection->AddFilter(myVertexFilter) ; + GroupPoints->SpinBox_DX->SetValue(myRadius1); + GroupPoints->SpinBox_DY->SetValue(myRadius2); + GroupPoints->SpinBox_DZ->SetValue(myHeight); + GroupDimensions->SpinBox_DX->SetValue(myRadius1); + GroupDimensions->SpinBox_DY->SetValue(myRadius2); + GroupDimensions->SpinBox_DZ->SetValue(myHeight); /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); - connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_C1A4, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_C1A5, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_Radius1, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_Radius2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_Height, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - /* to close dialog if study change */ - connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - /* Move widget on the botton right corner of main widget */ - int x, y ; - myGeomGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + /* displays Dialog */ + GroupDimensions->hide(); + GroupPoints->show(); + this->show(); return ; } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= void GeometryGUI_ConeDlg::ConstructorsClicked(int constructorId) { - mySelection->ClearFilters() ; - myGeomGUI->EraseSimulationShape() ; + myConstructorId = constructorId; + mySelection->ClearFilters(); + myGeomGUI->EraseSimulationShape(); + disconnect(mySelection, 0, this, 0); + myOkHeight = myOkRadius1 = myOkRadius2 = true; + myRadius1 = 100.0; + myRadius2 = 0.0; + myHeight = 300.0; switch(myConstructorId) { case 0 : - { - GroupC1->hide(); - GroupC2->show(); - myConstructorId = constructorId ; - myOkHeight = myOkRadius1 = myOkRadius2 = myOkPoint1 = myOkDir = true ; + { + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + myOkPoint1 = myOkDir = false; + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(tr("")); + GroupPoints->LineEdit2->setText(tr("")); - SpinBox_Radius1->SetValue( 100.0 ) ; /* radius 1 */ - SpinBox_Radius2->SetValue( 0.0 ) ; /* radius 2 */ - SpinBox_Height->SetValue( 300.0 ) ; /* height */ + GroupPoints->SpinBox_DX->SetValue(myRadius1); + GroupPoints->SpinBox_DY->SetValue(myRadius2); + GroupPoints->SpinBox_DZ->SetValue(myHeight); - disconnect( mySelection, 0, this, 0 ); - - myRadius1 = 100.0 ; - myRadius2 = 0.0 ; - myHeight = 300.0 ; - - myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ; - myDir.SetCoord( 0.0, 0.0, 1.0 ) ; - - if( myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight ) { - gp_Dir aDir = myDir ; - /* allows user to reverse direction of construction with a negative height */ - if( this->myHeight < -Precision::Confusion() ) { - aDir.Reverse() ; - } - MakeConeSimulationAndDisplay() ; - } - break ; + /* filter for next selection */ + mySelection->AddFilter(myVertexFilter); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + break; } case 1 : { - GroupC2->hide(); - GroupC1->show(); - myConstructorId = constructorId ; - myEditCurrentArgument = LineEditC1A1 ; - myOkHeight = myOkRadius1 = myOkRadius2 = true ; - myOkPoint1 = myOkDir = false ; + GroupPoints->hide(); + resize( 0, 0 ); + GroupDimensions->show(); + myOkPoint1 = myOkDir = true; - SpinBox_C1A3->SetValue( 100.0 ) ; /* radius 1 */ - SpinBox_C1A4->SetValue( 0.0 ) ; /* radius 2 */ - SpinBox_C1A5->SetValue( 300.0 ) ; /* height */ + GroupDimensions->SpinBox_DX->SetValue(myRadius1); + GroupDimensions->SpinBox_DY->SetValue(myRadius2); + GroupDimensions->SpinBox_DZ->SetValue(myHeight); - myRadius1 = 100.0 ; - myRadius2 = 0.0 ; - myHeight = 300.0 ; - disconnect( mySelection, 0, this, 0 ); - break ; + myPoint1.SetCoord(0.0, 0.0, 0.0); + myDir.SetCoord(0.0, 0.0, 1.0); + + MakeConeSimulationAndDisplay(); + break; } } return ; } + //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void GeometryGUI_ConeDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - - return ; + this->ClickOnApply(); + ClickOnCancel(); + return; } + //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void GeometryGUI_ConeDlg::ClickOnApply() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); - switch(myConstructorId) - { - case 0 : - { - if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) { - gp_Dir aDir = myDir ; - /* allows user to reverse direction of construction with a negative height */ - if( this->myHeight < -Precision::Confusion() ) { - aDir.Reverse() ; - } - myGeomGUI->MakeConeAndDisplay( myPoint1, aDir, myRadius1, myRadius2, fabs(myHeight) ) ; - } - break ; - } - case 1 : - { - if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) { - gp_Dir aDir = myDir ; - /* allows user to reverse direction of construction with a negative height */ - if( this->myHeight < -Precision::Confusion() ) { - aDir.Reverse() ; - } - myGeomGUI->MakeConeAndDisplay( myPoint1, aDir, myRadius1, myRadius2, fabs(myHeight) ) ; - } - break ; - } - } - // accept(); - return ; -} - - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void GeometryGUI_ConeDlg::ClickOnCancel() -{ - mySelection->ClearFilters() ; - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->ResetState() ; - reject() ; + if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) { + gp_Dir aDir = myDir; + /* allows user to reverse direction of construction with a negative height */ + if(this->myHeight < -Precision::Confusion()) + aDir.Reverse(); + myPrimitiveGUI->MakeConeAndDisplay(myPoint1, aDir, myRadius1, myRadius2, fabs(myHeight)); + } return ; } @@ -485,227 +264,85 @@ void GeometryGUI_ConeDlg::ClickOnCancel() //================================================================================= void GeometryGUI_ConeDlg::SelectionIntoArgument() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - - /* Future name of selection */ - QString aString = ""; - - int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - if ( nbSel != 1 ) { - if ( myEditCurrentArgument == LineEditC1A1 ) { - LineEditC1A1->setText("") ; - myOkPoint1 = false ; - } - else if ( myEditCurrentArgument == LineEditC1A2 ) { - LineEditC1A2->setText("") ; - myOkDir = false ; - } - return ; + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkPoint1 = false; + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myOkDir = false; + return; } - /* nbSel == 1 ! */ + /* nbSel == 1 */ TopoDS_Shape S; - if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) - return ; - - /* gp_Pnt : not used */ - if ( myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) { - LineEditC1A1->setText(aString) ; - myOkPoint1 = true ; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + /* gp_Pnt : not used */ + if (myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + GroupPoints->LineEdit1->setText(aString); + myOkPoint1 = true; } - else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, notUsed, myDir)*/ ) { + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { BRepAdaptor_Curve curv(TopoDS::Edge(S)); myDir = curv.Line().Direction(); - LineEditC1A2->setText(aString) ; - myOkDir = true ; + GroupPoints->LineEdit2->setText(aString); + myOkDir = true; } - if( myConstructorId == 0 && myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) { - MakeConeSimulationAndDisplay() ; - } - return ; + if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) + MakeConeSimulationAndDisplay(); + return; } + //================================================================================= // function : SetEditCurrentArgument() // purpose : //================================================================================= void GeometryGUI_ConeDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters() ; - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; - mySelection->AddFilter(myVertexFilter) ; - } - else if(send == SelectButtonC1A2) { - LineEditC1A2->setFocus() ; - myEditCurrentArgument = LineEditC1A2; - mySelection->AddFilter(myEdgeFilter) ; - } - SelectionIntoArgument() ; - break; - } - case 1: - { - break ; - } - } + if(myConstructorId != 0) + return; - return ; + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + mySelection->AddFilter(myVertexFilter); + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + mySelection->AddFilter(myEdgeFilter); + } + this->SelectionIntoArgument(); + + return; } + //================================================================================= // function : LineEditReturnPressed() // purpose : //================================================================================= void GeometryGUI_ConeDlg::LineEditReturnPressed() { - QLineEdit* send = (QLineEdit*)sender(); - if( send == LineEditC1A1 ) - myEditCurrentArgument = LineEditC1A1 ; - else if ( send == LineEditC1A2 ) - myEditCurrentArgument = LineEditC1A2 ; + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupPoints->LineEdit1) + myEditCurrentArgument = GroupPoints->LineEdit1; + else if (send == GroupPoints->LineEdit2) + myEditCurrentArgument = GroupPoints->LineEdit2; else - return ; - - /* User name of object input management */ - /* If successfull the selection is changed and signal emitted... */ - /* so SelectionIntoArgument() is automatically called. */ - QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ; - const QString objectUserName = LE->text() ; - QWidget* thisWidget = (QWidget*)this ; - if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) { - LE->setText( objectUserName ) ; - } - return ; -} + return; -//================================================================================= -// function : ValueChangedInSpinBox() -// purpose : -//================================================================================= -void GeometryGUI_ConeDlg::ValueChangedInSpinBox( double newValue ) -{ - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - - QObject* send = (QObject*)sender(); - - if( send == SpinBox_C1A3 || send == SpinBox_Radius1 ) { /* radius1 */ - myRadius1 = newValue ; - myOkRadius1 = true ; - } else if( send == SpinBox_C1A4 || send == SpinBox_Radius2 ) { /* radius2 */ - myRadius2 = newValue ; - myOkRadius2 = true ; - } - else if( send == SpinBox_C1A5 || send == SpinBox_Height ) { /* algebric height */ - myHeight = newValue ; - myOkHeight = true ; - } - - if ( myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight ) { - MakeConeSimulationAndDisplay() ; - } - - return ; -} - - -//================================================================================= -// function : TextChangedInLineEdit() -// purpose : -//================================================================================= -// void GeometryGUI_ConeDlg::TextChangedInLineEdit(const QString& newText) -// { - -// myGeomGUI->EraseSimulationShape() ; -// mySimulationTopoDs.Nullify() ; -// QLineEdit* send = (QLineEdit*)sender(); -// QString newT = strdup(newText) ; -// int i ; - -// if(send == LineEditC1A3) { /* radius1 */ -// if( myVa->validate(newT, i) == myVa->Acceptable ) { -// myRadius1 = newText.toFloat() ; -// myOkRadius1 = true ; -// } -// else { -// myOkRadius1 = false ; -// } -// } else if(send == LineEditC1A4) { /* radius2 */ -// if( myVb->validate(newT, i) == myVb->Acceptable ) { -// myRadius2 = newText.toFloat() ; -// myOkRadius2 = true ; -// } -// else { -// myOkRadius2 = false ; -// } -// } else if(send == LineEditC1A5) { /* algebric height */ - -// if( myVc->validate(newT, i) == myVc->Acceptable ) { -// myHeight = newText.toFloat() ; -// if( fabs(myHeight) > Precision::Confusion() ) -// myOkHeight = true ; -// else -// myOkHeight = false ; -// } -// }else if(send == LineEdit_Radius1) { /* radius1 */ -// if( myVa->validate(newT, i) == myVa->Acceptable ) { -// myRadius1 = newText.toFloat() ; -// myOkRadius1 = true ; -// } -// else { -// myOkRadius1 = false ; -// } -// } else if(send == LineEdit_Radius2) { /* radius2 */ -// if( myVb->validate(newT, i) == myVb->Acceptable ) { -// myRadius2 = newText.toFloat() ; -// myOkRadius2 = true ; -// } -// else { -// myOkRadius2 = false ; -// } -// } else if(send == LineEdit_Height) { /* algebric height */ - -// if( myVc->validate(newT, i) == myVc->Acceptable ) { -// myHeight = newText.toFloat() ; -// if( fabs(myHeight) > Precision::Confusion() ) -// myOkHeight = true ; -// else -// myOkHeight = false ; -// } -// } -// if (myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) { -// MakeConeSimulationAndDisplay() ; -// } - -// return ; -// } - - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void GeometryGUI_ConeDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupC2->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->EraseSimulationShape() ; - mySelection->ClearFilters() ; - } - return ; + GeometryGUI_Skeleton::LineEditReturnPressed(); + return; } @@ -715,16 +352,11 @@ void GeometryGUI_ConeDlg::DeactivateActiveDialog() //================================================================================= void GeometryGUI_ConeDlg::ActivateThisDialog() { - /* Emit a signal to deactivate the active dialog */ - myGeomGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupC2->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - if( !mySimulationTopoDs.IsNull() ) - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; - return ; + GeometryGUI_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; } @@ -734,22 +366,39 @@ void GeometryGUI_ConeDlg::ActivateThisDialog() //================================================================================= void GeometryGUI_ConeDlg::enterEvent(QEvent* e) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; - return ; + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; } //================================================================================= -// function : closeEvent() +// function : ValueChangedInSpinBox() // purpose : //================================================================================= -void GeometryGUI_ConeDlg::closeEvent( QCloseEvent* e ) +void GeometryGUI_ConeDlg::ValueChangedInSpinBox(double newValue) { - /* same than click on cancel button */ - this->ClickOnCancel() ; - return ; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + QObject* send = (QObject*)sender(); + + if(send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DX) { + myRadius1 = newValue; + myOkRadius1 = true; + } + else if(send == GroupPoints->SpinBox_DY || send == GroupDimensions->SpinBox_DY) { + myRadius2 = newValue; + myOkRadius2 = true; + } + else if(send == GroupPoints->SpinBox_DZ || send == GroupDimensions->SpinBox_DZ) { + myHeight = newValue; + myOkHeight = true; + } + + if (myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) + MakeConeSimulationAndDisplay(); + return; } @@ -759,30 +408,27 @@ void GeometryGUI_ConeDlg::closeEvent( QCloseEvent* e ) //================================================================================= void GeometryGUI_ConeDlg::MakeConeSimulationAndDisplay() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - gp_Dir aDir = myDir ; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + gp_Dir aDir = myDir; try { /* allows user to reverse direction of construction with a negative height */ - if( this->myHeight < -Precision::Confusion() ) { - aDir.Reverse() ; - } - - gp_Ax2 anAxis(this->myPoint1, aDir) ; + if(this->myHeight < -Precision::Confusion()) + aDir.Reverse(); - if( fabs(myRadius1 - myRadius2) <= Precision::Confusion() ) { - mySimulationTopoDs = BRepPrimAPI_MakeCylinder( anAxis, (myRadius1+myRadius2)/2.0, fabs(myHeight) ).Shape() ; - } + gp_Ax2 anAxis(this->myPoint1, aDir); + + if(fabs(myRadius1 - myRadius2) <= Precision::Confusion()) + mySimulationTopoDs = BRepPrimAPI_MakeCylinder(anAxis, (myRadius1+myRadius2)/2.0, fabs(myHeight)).Shape(); else { - if( fabs(myHeight) > Precision::Confusion() ) - mySimulationTopoDs = BRepPrimAPI_MakeCone( anAxis, myRadius1, myRadius2, fabs(myHeight) ).Shape() ; + if(fabs(myHeight) > Precision::Confusion()) + mySimulationTopoDs = BRepPrimAPI_MakeCone(anAxis, myRadius1, myRadius2, fabs(myHeight)).Shape(); } - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); } catch(Standard_Failure) { - MESSAGE( "Exception catched in MakeConeSimulationAndDisplay" ) ; + MESSAGE("Exception catched in MakeConeSimulationAndDisplay"); } - return ; + return; } - diff --git a/src/GEOMGUI/GeometryGUI_ConeDlg.h b/src/GEOMGUI/GeometryGUI_ConeDlg.h index 7811f1b58..6330ea97c 100644 --- a/src/GEOMGUI/GeometryGUI_ConeDlg.h +++ b/src/GEOMGUI/GeometryGUI_ConeDlg.h @@ -29,124 +29,66 @@ #ifndef DIALOGBOX_CONE_H #define DIALOGBOX_CONE_H -#include "SALOME_Selection.h" -#include "GEOM_ShapeTypeFilter.hxx" +#include "GeometryGUI_Skeleton.h" +#include "GeometryGUI_2Sel3Spin.h" +#include "GeometryGUI_3Spin.h" + +#include "PrimitiveGUI.h" + #include "GEOM_EdgeFilter.hxx" -#include "GeometryGUI_SpinBox.h" -#include -#include -#include - -#include -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QGroupBox; -class QLabel; -class QSpinBox; -class QLineEdit; -class QPushButton; -class QRadioButton; -class GeometryGUI; +#include +#include //================================================================================= // class : GeometryGUI_ConeDlg // purpose : //================================================================================= -class GeometryGUI_ConeDlg : public QDialog +class GeometryGUI_ConeDlg : public GeometryGUI_Skeleton { Q_OBJECT public: - GeometryGUI_ConeDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + GeometryGUI_ConeDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~GeometryGUI_ConeDlg(); private: + void Init(); + void enterEvent(QEvent* e); + void MakeConeSimulationAndDisplay(); - void Init( SALOME_Selection* Sel ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void MakeConeSimulationAndDisplay() ; + PrimitiveGUI* myPrimitiveGUI; - GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ - GeometryGUI* myGeomGUI ; /* Current GeomGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - TopoDS_Shape mySimulationTopoDs ; + double step; + int myConstructorId; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; + Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ - gp_Pnt myPoint1 ; /* Topology used */ - gp_Dir myDir ; - bool myOkPoint1 ; - bool myOkDir ; /* to check when argument is defined */ + gp_Pnt myPoint1; /* topology used */ + gp_Dir myDir; + bool myOkPoint1; /* to check when arguments is defined */ + bool myOkDir; - Standard_Real myRadius1 ; - Standard_Real myRadius2 ; - Standard_Real myHeight ; - bool myOkRadius1 ; - bool myOkRadius2 ; - bool myOkHeight ; - QDoubleValidator *myVa ; /* Double validator for numeric input myRadius1 */ - QDoubleValidator *myVb ; /* Double validator for numeric input myRadius2 */ - QDoubleValidator *myVc ; /* Double validator for numeric input myHeight */ + Standard_Real myRadius1; + Standard_Real myRadius2; + Standard_Real myHeight; + bool myOkRadius1; + bool myOkRadius2; + bool myOkHeight; - int myConstructorId ; /* Current constructor id = radio button id */ - QWidget* myEditCurrentArgument; /* Current LineEdit or spin box */ - Handle(GEOM_ShapeTypeFilter) myVertexFilter ; /* Filter selection */ - Handle(GEOM_EdgeFilter) myEdgeFilter ; /* Filter selection */ - - - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - QRadioButton* Constructor2; - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; - QGroupBox* GroupC1; - QGroupBox* GroupC2; - QPushButton* SelectButtonC1A1; - QLineEdit* LineEditC1A1; - QLabel* TextLabelC1A1; - QPushButton* SelectButtonC1A2; - QLineEdit* LineEditC1A2; - QLabel* TextLabelC1A2; - QLabel* TextLabelC1A3; - GeometryGUI_SpinBox* SpinBox_C1A3 ; - QLabel* TextLabelC1A4; - GeometryGUI_SpinBox* SpinBox_C1A4 ; - QLabel* TextLabelC1A5; - GeometryGUI_SpinBox* SpinBox_C1A5 ; - - QLabel* TextLabel_Radius1 ; - QLabel* TextLabel_Radius2 ; - QLabel* TextLabel_Height ; - GeometryGUI_SpinBox* SpinBox_Radius1 ; - GeometryGUI_SpinBox* SpinBox_Radius2 ; - GeometryGUI_SpinBox* SpinBox_Height ; + GeometryGUI_2Sel3Spin* GroupPoints; + GeometryGUI_3Spin* GroupDimensions; private slots: - - void ConstructorsClicked(int constructorId); void ClickOnOk(); - void ClickOnCancel(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void ValueChangedInSpinBox( double newValue ) ; - -protected: - QGridLayout* GeometryGUI_ConeDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupC1Layout; - QGridLayout* GroupC2Layout; + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked(int constructorId); + void ValueChangedInSpinBox(double newValue); + }; #endif // DIALOGBOX_CONE_H diff --git a/src/GEOMGUI/GeometryGUI_CutDlg.cxx b/src/GEOMGUI/GeometryGUI_CutDlg.cxx index 948eed897..02e74bedc 100644 --- a/src/GEOMGUI/GeometryGUI_CutDlg.cxx +++ b/src/GEOMGUI/GeometryGUI_CutDlg.cxx @@ -30,25 +30,7 @@ using namespace std; #include "GeometryGUI_CutDlg.h" #include "GeometryGUI.h" -#include "QAD_Application.h" #include "QAD_Desktop.h" -#include "utilities.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - //================================================================================= // class : GeometryGUI_CutDlg() @@ -57,111 +39,33 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GeometryGUI_CutDlg::GeometryGUI_CutDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +GeometryGUI_CutDlg::GeometryGUI_CutDlg(QWidget* parent, const char* name, BooleanGUI* theBooleanGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + :GeometryGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CUT"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CUT"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - if ( !name ) - setName( "GeometryGUI_CutDlg" ); - resize( 322, 220 ); - setCaption( tr( "GEOM_CUT_TITLE" ) ); - setSizeGripEnabled( TRUE ); + setCaption(tr("GEOM_CUT_TITLE")); - GeometryGUI_CutDlgLayout = new QGridLayout( this ); - GeometryGUI_CutDlgLayout->setSpacing( 6 ); - GeometryGUI_CutDlgLayout->setMargin( 11 ); + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_CUT")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "GEOM_CUT" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - GeometryGUI_CutDlgLayout->addWidget( GroupConstructors, 0, 0 ); + GroupCut = new GeometryGUI_2Sel_QTD(this, "GroupCut"); + GroupCut->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupCut->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); + GroupCut->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); + GroupCut->PushButton1->setPixmap(image1); + GroupCut->PushButton2->setPixmap(image1); - /***************************************************************/ - GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); - GroupConstructor1->setTitle( tr( "GEOM_ARGUMENTS" ) ); - GroupConstructor1->setColumnLayout(0, Qt::Vertical ); - GroupConstructor1->layout()->setSpacing( 0 ); - GroupConstructor1->layout()->setMargin( 0 ); - GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); - GroupConstructor1Layout->setAlignment( Qt::AlignTop ); - GroupConstructor1Layout->setSpacing( 6 ); - GroupConstructor1Layout->setMargin( 11 ); - LineEditC1A2Shape = new QLineEdit( GroupConstructor1, "LineEditC1A2Shape" ); - LineEditC1A2Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Shape->sizePolicy().hasHeightForWidth() ) ); - GroupConstructor1Layout->addWidget( LineEditC1A2Shape, 1, 2 ); - LineEditC1A1Shape = new QLineEdit( GroupConstructor1, "LineEditC1A1Shape" ); - LineEditC1A1Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Shape->sizePolicy().hasHeightForWidth() ) ); - GroupConstructor1Layout->addWidget( LineEditC1A1Shape, 0, 2 ); - SelectButtonC1A1Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A1Shape" ); - SelectButtonC1A1Shape->setText( tr( "" ) ); - SelectButtonC1A1Shape->setPixmap( image1 ); - GroupConstructor1Layout->addWidget( SelectButtonC1A1Shape, 0, 1 ); - SelectButtonC1A2Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A2Shape" ); - SelectButtonC1A2Shape->setText( tr( "" ) ); - SelectButtonC1A2Shape->setPixmap( image1 ); - GroupConstructor1Layout->addWidget( SelectButtonC1A2Shape, 1, 1 ); - TextLabelC1A2Shape = new QLabel( GroupConstructor1, "TextLabelC1A2Shape" ); - TextLabelC1A2Shape->setText( tr( "GEOM_TOOL_OBJECT" ) ); - TextLabelC1A2Shape->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A2Shape->setFrameShape( QLabel::NoFrame ); - TextLabelC1A2Shape->setFrameShadow( QLabel::Plain ); - GroupConstructor1Layout->addWidget( TextLabelC1A2Shape, 1, 0 ); - TextLabelC1A1Shape = new QLabel( GroupConstructor1, "TextLabelC1A1Shape" ); - TextLabelC1A1Shape->setText( tr( "GEOM_MAIN_OBJECT" ) ); - TextLabelC1A1Shape->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1Shape->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1Shape->setFrameShadow( QLabel::Plain ); - GroupConstructor1Layout->addWidget( TextLabelC1A1Shape, 0, 0 ); - GeometryGUI_CutDlgLayout->addWidget( GroupConstructor1, 1, 0 ); + Layout1->addWidget(GroupCut, 1, 0); + /***************************************************************/ - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "GEOM_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_1 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_1, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "GEOM_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - GeometryGUI_CutDlgLayout->addWidget( GroupButtons, 2, 0 ); - - /* Initialisation */ - Init( Sel ) ; + /* Initialisation */ + myBooleanGUI = theBooleanGUI; + Init(); } @@ -172,190 +76,112 @@ GeometryGUI_CutDlg::GeometryGUI_CutDlg( QWidget* parent, const char* name, SALOM GeometryGUI_CutDlg::~GeometryGUI_CutDlg() { /* no need to delete child widgets, Qt does it all for us */ - this->destroy(TRUE, TRUE) ; } - //================================================================================= // function : Init() // purpose : //================================================================================= -void GeometryGUI_CutDlg::Init( SALOME_Selection* Sel ) +void GeometryGUI_CutDlg::Init() { - mySelection = Sel ; - myShape1.Nullify() ; - myShape2.Nullify() ; - myConstructorId = 0 ; - - myGeomGUI = GeometryGUI::GetGeometryGUI() ; + /* init variables */ + myEditCurrentArgument = GroupCut->LineEdit1; - GroupConstructor1->show(); - myConstructorId = 0 ; - myEditCurrentArgument = LineEditC1A1Shape ; - Constructor1->setChecked( TRUE ); - myOkShape1 = myOkShape2 = false ; + myShape1.Nullify(); + myShape2.Nullify(); + myOkShape1 = myOkShape2 = false; - myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); - myGeom = GEOM::GEOM_Gen::_narrow(comp); - - // TODO previous selection into argument ? + connect(GroupCut->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupCut->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - connect( SelectButtonC1A1Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A2Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect(GroupCut->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupCut->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect( LineEditC1A1Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - connect( LineEditC1A2Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - /* to close dialog if study change */ - connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - myGeomGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* Displays Dialog */ + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return ; + /* displays Dialog */ + GroupCut->show(); + this->show(); + + return; } - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void GeometryGUI_CutDlg::ConstructorsClicked(int constructorId) -{ - GeometryGUI::GetGeometryGUI()->EraseSimulationShape() ; - - switch (constructorId) - { - case 0: - { - GroupConstructor1->show(); - myConstructorId = constructorId ; - myEditCurrentArgument = LineEditC1A1Shape ; - LineEditC1A2Shape->setText(tr("")) ; - Constructor1->setChecked( TRUE ); - myOkShape1 = myOkShape2 = false ; - break; - } - } - return ; -} - //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void GeometryGUI_CutDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - + this->ClickOnApply(); + ClickOnCancel(); return ; } + //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void GeometryGUI_CutDlg::ClickOnApply() { - myGeomGUI->GetDesktop()->putInfo( tr("") ) ; - switch(myConstructorId) - { - case 0 : - { - if(myOkShape1 && myOkShape2) { - myGeomGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 2 ) ; - } - break ; - } - } + myGeomGUI->GetDesktop()->putInfo(tr("")); - // accept(); - return ; + if(myOkShape1 && myOkShape2) + myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 2); + + return; } -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void GeometryGUI_CutDlg::ClickOnCancel() -{ - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->ResetState() ; - reject() ; - return ; -} - - - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection has changed //================================================================================= void GeometryGUI_CutDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText("") ; - QString aString = ""; /* name of selection */ + myEditCurrentArgument->setText(""); + QString aString = ""; - int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - if ( nbSel != 1 ) { - switch (myConstructorId) - { - case 0: - { - if ( myEditCurrentArgument == LineEditC1A1Shape ) { - myOkShape1 = false ; - } - else if ( myEditCurrentArgument == LineEditC1A2Shape ) { - myOkShape2 = false ; - } - break ; - } - } - return ; + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupCut->LineEdit1) + myOkShape1 = false; + else if( myEditCurrentArgument == GroupCut->LineEdit2) + myOkShape2 = false; + return; } - /* nbSel == 1 */ + /* nbSel == 1 */ TopoDS_Shape S; - Standard_Boolean testResult ; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) - return ; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; - if ( myEditCurrentArgument == LineEditC1A1Shape ) { - myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) - return ; - myShape1 = S ; - LineEditC1A1Shape->setText(aString) ; - myOkShape1 = true ; - } - else if ( myEditCurrentArgument == LineEditC1A2Shape ) { - myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) - return ; - myShape2 = S ; - LineEditC1A2Shape->setText(aString) ; - myOkShape2 = true ; + if(myEditCurrentArgument == GroupCut->LineEdit1) { + myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape1 = S; + GroupCut->LineEdit1->setText(aString); + myOkShape1 = true; } - - return ; + else if(myEditCurrentArgument == GroupCut->LineEdit2) { + myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape2 = S; + GroupCut->LineEdit2->setText(aString); + myOkShape2 = true; + } + return; } @@ -366,26 +192,19 @@ void GeometryGUI_CutDlg::SelectionIntoArgument() void GeometryGUI_CutDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if( send == SelectButtonC1A1Shape ) { - LineEditC1A1Shape->setFocus() ; - myEditCurrentArgument = LineEditC1A1Shape ; - } - else if(send == SelectButtonC1A2Shape) { - LineEditC1A2Shape->setFocus() ; - myEditCurrentArgument = LineEditC1A2Shape; - } - SelectionIntoArgument() ; - break; - } - } - return ; -} + if(send == GroupCut->PushButton1) { + GroupCut->LineEdit1->setFocus(); + myEditCurrentArgument = GroupCut->LineEdit1; + } + else if(send == GroupCut->PushButton2) { + GroupCut->LineEdit2->setFocus(); + myEditCurrentArgument = GroupCut->LineEdit2; + } + SelectionIntoArgument(); + + return; +} //================================================================================= @@ -394,79 +213,39 @@ void GeometryGUI_CutDlg::SetEditCurrentArgument() //================================================================================= void GeometryGUI_CutDlg::LineEditReturnPressed() { - QLineEdit* send = (QLineEdit*)sender(); - if( send == LineEditC1A1Shape ) - myEditCurrentArgument = LineEditC1A1Shape ; - else if ( send == LineEditC1A2Shape ) - myEditCurrentArgument = LineEditC1A2Shape ; + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupCut->LineEdit1) + myEditCurrentArgument = GroupCut->LineEdit1; + else if(send == GroupCut->LineEdit2) + myEditCurrentArgument = GroupCut->LineEdit2; else - return ; - - /* User name of object input management */ - /* If successfull the selection is changed and signal emitted... */ - /* so SelectionIntoArgument() is automatically called. */ - const QString objectUserName = myEditCurrentArgument->text() ; - QWidget* thisWidget = (QWidget*)this ; - if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) { - myEditCurrentArgument->setText( objectUserName ) ; - } - return ; + return; + + GeometryGUI_Skeleton::LineEditReturnPressed(); + return; } - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void GeometryGUI_CutDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - - GroupConstructors->setEnabled(false) ; - GroupConstructor1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - } - return ; -} - - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void GeometryGUI_CutDlg::closeEvent( QCloseEvent* e ) -{ - this->ClickOnCancel() ; /* same than click on cancel button */ -} - - -//================================================================================= -// function : enterEvent() -// purpose : when mouse enter onto the QWidget -//================================================================================= -void GeometryGUI_CutDlg::enterEvent( QEvent * ) -{ - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; -} - - - //================================================================================= // function : ActivateThisDialog() // purpose : //================================================================================= void GeometryGUI_CutDlg::ActivateThisDialog() { - /* Emit a signal to deactivate any active dialog */ - myGeomGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupConstructor1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - return ; + GeometryGUI_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void GeometryGUI_CutDlg::enterEvent(QEvent * e) +{ + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; } diff --git a/src/GEOMGUI/GeometryGUI_CutDlg.h b/src/GEOMGUI/GeometryGUI_CutDlg.h index 1e7c6ed2e..be8456c62 100644 --- a/src/GEOMGUI/GeometryGUI_CutDlg.h +++ b/src/GEOMGUI/GeometryGUI_CutDlg.h @@ -29,90 +29,48 @@ #ifndef DIALOGBOX_CUT_H #define DIALOGBOX_CUT_H -#include "SALOME_Selection.h" -#include "GEOM_ShapeTypeFilter.hxx" +#include "GeometryGUI_Skeleton.h" +#include "GeometryGUI_2Sel_QTD.h" + +#include "BooleanGUI.h" #include -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QFrame; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; -class GeometryGUI; - - //================================================================================= // class : GeometryGUI_CutDlg // purpose : //================================================================================= -class GeometryGUI_CutDlg : public QDialog +class GeometryGUI_CutDlg : public GeometryGUI_Skeleton { Q_OBJECT public: - GeometryGUI_CutDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + GeometryGUI_CutDlg( QWidget* parent = 0, const char* name = 0, BooleanGUI* theBooleanGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); ~GeometryGUI_CutDlg(); private: + void Init(); + void enterEvent(QEvent* e); - void Init( SALOME_Selection* Sel ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + BooleanGUI* myBooleanGUI; - GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ - GeometryGUI* myGeomGUI ; /* Current GeomGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - TopoDS_Shape myShape1 ; /* topology used to fuse */ - TopoDS_Shape myShape2 ; /* topology used to fuse */ - GEOM::GEOM_Shape_var myGeomShape1 ; /* is myShape1 */ - GEOM::GEOM_Shape_var myGeomShape2 ; /* is myShape2 */ - bool myOkShape1 ; - bool myOkShape2 ; /* to check when arguments are defined */ - int myConstructorId ; /* Current constructor id = radio button id */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + TopoDS_Shape myShape1; /* topology used to fuse */ + TopoDS_Shape myShape2; /* topology used to fuse */ + GEOM::GEOM_Shape_var myGeomShape1; /* is myShape1 */ + GEOM::GEOM_Shape_var myGeomShape2; /* is myShape2 */ + bool myOkShape1; /* to check when arguments are defined */ + bool myOkShape2; - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - - QGroupBox* GroupConstructor1; - QLineEdit* LineEditC1A1Shape; - QLineEdit* LineEditC1A2Shape; - QPushButton* SelectButtonC1A1Shape; - QPushButton* SelectButtonC1A2Shape; - QLabel* TextLabelC1A2Shape; - QLabel* TextLabelC1A1Shape; - - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; + GeometryGUI_2Sel_QTD* GroupCut; private slots: - - void ConstructorsClicked(int constructorId); void ClickOnOk(); - void ClickOnCancel(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + void ActivateThisDialog(); -protected: - QGridLayout* GeometryGUI_CutDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupConstructor1Layout; }; #endif // DIALOGBOX_CUT_H diff --git a/src/GEOMGUI/GeometryGUI_CylinderDlg.cxx b/src/GEOMGUI/GeometryGUI_CylinderDlg.cxx index d96817330..110775224 100644 --- a/src/GEOMGUI/GeometryGUI_CylinderDlg.cxx +++ b/src/GEOMGUI/GeometryGUI_CylinderDlg.cxx @@ -29,26 +29,12 @@ using namespace std; #include "GeometryGUI_CylinderDlg.h" -#include "GeometryGUI.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_Config.h" -#include "utilities.h" - +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "GeometryGUI.h" +#include "QAD_Desktop.h" +#include "QAD_Config.h" //================================================================================= // class : GeometryGUI_CylinderDlg() @@ -57,171 +43,42 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GeometryGUI_CylinderDlg::GeometryGUI_CylinderDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +GeometryGUI_CylinderDlg::GeometryGUI_CylinderDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + :GeometryGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CYLINDER_PV"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); - QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CYLINDER_DXYZ"))); - - if ( !name ) - setName( "GeometryGUI_CylinderDlg" ); - resize( 303, 281 ); - setCaption( tr( "GEOM_CYLINDER_TITLE" ) ); - setSizeGripEnabled( TRUE ); - GeometryGUI_CylinderDlgLayout = new QGridLayout( this ); - GeometryGUI_CylinderDlgLayout->setSpacing( 6 ); - GeometryGUI_CylinderDlgLayout->setMargin( 11 ); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CYLINDER_PV"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CYLINDER_DXYZ"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "GEOM_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "GEOM_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - GeometryGUI_CylinderDlgLayout->addWidget( GroupButtons, 2, 0 ); + setCaption(tr("GEOM_CYLINDER_TITLE")); - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "GEOM_CYLINDER" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer_2, 0, 1 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" ); - Constructor2->setText( tr( "" ) ); - Constructor2->setMinimumSize( QSize( 50, 0 ) ); - Constructor2->setPixmap( image2 ); - Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - GroupConstructorsLayout->addWidget( Constructor2, 0, 2 ); - QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer_3, 0, 3 ); - GeometryGUI_CylinderDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "GEOM_BASE_POINT" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); - SelectButtonC1A2->setText( tr( "" ) ); - SelectButtonC1A2->setMinimumSize( QSize( 0, 0 ) ); - SelectButtonC1A2->setPixmap( image1 ); - GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); - LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); - LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); - TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" ); - TextLabelC1A2->setText( tr( "GEOM_VECTOR" ) ); - TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A2->setFrameShape( QLabel::NoFrame ); - TextLabelC1A2->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); - TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" ); - TextLabelC1A3->setText( tr( "GEOM_RADIUS" ) ); - TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A3->setFrameShape( QLabel::NoFrame ); - TextLabelC1A3->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 ); - - SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ; - GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 ) ; - - TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" ); - TextLabelC1A4->setText( tr( "GEOM_HEIGHT" ) ); - TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A4->setFrameShape( QLabel::NoFrame ); - TextLabelC1A4->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 ); + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_CYLINDER")); + RadioButton1->setPixmap(image0); + RadioButton2->setPixmap(image1); + RadioButton3->close(TRUE); - SpinBox_C1A4 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A4" ) ; - GroupC1Layout->addWidget( SpinBox_C1A4, 3, 2 ); - - GeometryGUI_CylinderDlgLayout->addWidget( GroupC1, 1, 0 ); + GroupPoints = new GeometryGUI_2Sel2Spin(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_BASE_POINT")); + GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS")); + GroupPoints->TextLabel4->setText(tr("GEOM_HEIGHT")); + GroupPoints->PushButton1->setPixmap(image2); + GroupPoints->PushButton2->setPixmap(image2); - /***************************************************************/ - GroupC2 = new QGroupBox( this, "GroupC2" ); - GroupC2->setTitle( tr( "GEOM_BOX_OBJ" ) ); - GroupC2->setColumnLayout(0, Qt::Vertical ); - GroupC2->layout()->setSpacing( 0 ); - GroupC2->layout()->setMargin( 0 ); - GroupC2Layout = new QGridLayout( GroupC2->layout() ); - GroupC2Layout->setAlignment( Qt::AlignTop ); - GroupC2Layout->setSpacing( 6 ); - GroupC2Layout->setMargin( 11 ); - TextLabel_Height = new QLabel(GroupC2 , "TextLabel_Height" ); - TextLabel_Height->setText( tr( "GEOM_HEIGHT" ) ); - GroupC2Layout->addWidget( TextLabel_Height, 1, 0 ); - TextLabel_Radius = new QLabel( GroupC2, "TextLabel_Radius" ); - TextLabel_Radius->setText( tr( "GEOM_RADIUS" ) ); - GroupC2Layout->addWidget( TextLabel_Radius, 0, 0 ); + GroupDimensions = new GeometryGUI_2Spin(this, "GroupDimensions"); + GroupDimensions->GroupBox1->setTitle(tr("GEOM_BOX_OBJ")); + GroupDimensions->TextLabel1->setText(tr("GEOM_HEIGHT")); + GroupDimensions->TextLabel2->setText(tr("GEOM_RADIUS")); - SpinBox_Height = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Height" ) ; - SpinBox_Height->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_Height->sizePolicy().hasHeightForWidth() ) ); - GroupC2Layout->addWidget( SpinBox_Height, 1, 1 ) ; + Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupDimensions, 1, 0); + /***************************************************************/ - SpinBox_Radius = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius" ) ; - SpinBox_Radius->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_Radius->sizePolicy().hasHeightForWidth() ) ); - GroupC2Layout->addWidget( SpinBox_Radius, 0, 1 ) ; - - QSpacerItem* spacer1 = new QSpacerItem( 20, 62, QSizePolicy::Minimum, QSizePolicy::Fixed ); - GroupC2Layout->addItem( spacer1 ); - - GeometryGUI_CylinderDlgLayout->addWidget(GroupC2 , 1, 0 ); - /***************************************************************/ - - Init(Sel) ; /* Initialisations */ + /* Initialisations */ + myPrimitiveGUI = thePrimitiveGUI; + Init(); } @@ -239,215 +96,154 @@ GeometryGUI_CylinderDlg::~GeometryGUI_CylinderDlg() // function : Init() // purpose : //================================================================================= -void GeometryGUI_CylinderDlg::Init( SALOME_Selection* Sel ) +void GeometryGUI_CylinderDlg::Init() { + /* init variables */ + myConstructorId = 0; + myEditCurrentArgument = GroupPoints->LineEdit1; + + myRadius = 100.0; + myHeight = 300.0; + myOkRadius = myOkHeight = true; + myOkPoint1 = myOkDir = false; + + myEdgeFilter = new GEOM_EdgeFilter(StdSelect_Line, myGeom); + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + mySelection->AddFilter(myVertexFilter); /* Get setting of step value from file configuration */ - double step ; - QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ); - step = St.toDouble() ; + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); /* min, max, step and decimals for spin boxes & initial values */ /* First constructor : radius */ - SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); /* First constructor : algebric height */ - SpinBox_C1A4->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; + GroupPoints->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); /* Second constructor : radius */ - SpinBox_Radius->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; + GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); /* Second constructor : algebric height */ - SpinBox_Height->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; + GroupDimensions->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - GroupC1->show(); - GroupC2->hide(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - myGeomGUI = GeometryGUI::GetGeometryGUI() ; - - SpinBox_C1A3->SetValue( 100.0 ) ; - SpinBox_C1A4->SetValue( 300.0 ) ; - SpinBox_Radius->SetValue( 100.0 ) ; - SpinBox_Height->SetValue( 300.0 ) ; - myRadius = 100.0 ; - myHeight = 300.0 ; - - myOkRadius = true ; - myOkHeight = true ; - myOkPoint1 = false ; - myOkDir = false ; - - mySimulationTopoDs.Nullify() ; - myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; - - // TODO : previous selection into argument ? - - /* Filter definitions */ - Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); - myGeom = GEOM::GEOM_Gen::_narrow(comp); - myEdgeFilter = new GEOM_EdgeFilter( StdSelect_Line, myGeom ); - myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom ); - - /* first filter used */ - mySelection->AddFilter(myVertexFilter) ; + GroupPoints->SpinBox_DX->SetValue(myRadius); + GroupPoints->SpinBox_DY->SetValue(myHeight); + GroupDimensions->SpinBox_DX->SetValue(myRadius); + GroupDimensions->SpinBox_DY->SetValue(myHeight); /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); - connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_C1A4, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_Radius, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_Height, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - /* to close dialog if study change */ - connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - /* Move widget on the botton right corner of main widget */ - int x, y ; - myGeomGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ + /* displays Dialog */ + GroupDimensions->hide(); + GroupPoints->show(); + this->show(); return ; } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= void GeometryGUI_CylinderDlg::ConstructorsClicked(int constructorId) { - mySelection->ClearFilters() ; - myGeomGUI->EraseSimulationShape() ; + myConstructorId = constructorId; + mySelection->ClearFilters(); + myGeomGUI->EraseSimulationShape(); + disconnect(mySelection, 0, this, 0); + myOkHeight = myOkRadius = true; + myRadius = 100.0; + myHeight = 300.0; switch(myConstructorId) { case 0 : - { - GroupC1->hide(); - GroupC2->show(); - myConstructorId = constructorId ; - myOkHeight = myOkRadius = myOkPoint1 = myOkDir = true ; + { + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + myOkPoint1 = myOkDir = false; + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(tr("")); + GroupPoints->LineEdit2->setText(tr("")); - SpinBox_Radius->SetValue( 100.0 ) ; - SpinBox_Height->SetValue( 300.0 ) ; - myRadius = 100.0 ; - myHeight = 300.0 ; + GroupPoints->SpinBox_DX->SetValue(myRadius); + GroupPoints->SpinBox_DY->SetValue(myHeight); - disconnect( mySelection, 0, this, 0 ); - - myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ; - myDir.SetCoord( 0.0, 0.0, 1.0 ) ; - - if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) { - gp_Dir aDir = myDir ; - /* allows user to reverse direction of construction with a negative height */ - if( this->myHeight < -Precision::Confusion() ) { - aDir.Reverse() ; - } - MakeCylinderSimulationAndDisplay() ; - } - break ; + /* filter for next selection */ + mySelection->AddFilter(myVertexFilter); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + break; } case 1 : { - GroupC2->hide(); - GroupC1->show(); - myConstructorId = constructorId ; - myEditCurrentArgument = LineEditC1A1 ; - myOkHeight = myOkRadius = true ; - myOkPoint1 = myOkDir = false ; - LineEditC1A1->setText( tr("") ); - - SpinBox_C1A3->SetValue( 100.0 ) ; - SpinBox_C1A4->SetValue( 300.0 ) ; - myRadius = 100.0 ; - myHeight = 300.0 ; - disconnect( mySelection, 0, this, 0 ); - break ; + GroupPoints->hide(); + resize( 0, 0 ); + GroupDimensions->show(); + myOkPoint1 = myOkDir = true; + + GroupDimensions->SpinBox_DX->SetValue(myRadius); + GroupDimensions->SpinBox_DY->SetValue(myHeight); + myPoint1.SetCoord(0.0, 0.0, 0.0); + myDir.SetCoord(0.0, 0.0, 1.0); + + MakeCylinderSimulationAndDisplay(); + break; } } return ; } + //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void GeometryGUI_CylinderDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - - return ; + this->ClickOnApply(); + ClickOnCancel(); + return; } + //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void GeometryGUI_CylinderDlg::ClickOnApply() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - myGeomGUI->GetDesktop()->putInfo( tr("") ) ; - switch(myConstructorId) - { - case 0 : - { - if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) { - gp_Dir aDir = myDir ; - /* allows user to reverse direction of construction with a negative height */ - if( this->myHeight < -Precision::Confusion() ) { - aDir.Reverse() ; - } - myGeomGUI->MakeCylinderAndDisplay( myPoint1, aDir, myRadius, fabs(myHeight) ) ; - } - break ; - } - case 1 : - { - if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) { - gp_Dir aDir = myDir ; - /* allows user to reverse direction of construction with a negative height */ - if( this->myHeight < -Precision::Confusion() ) { - aDir.Reverse() ; - } - myGeomGUI->MakeCylinderAndDisplay( myPoint1, aDir, myRadius, fabs(myHeight) ) ; - } - break ; - } - } - // accept(); - return ; -} + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void GeometryGUI_CylinderDlg::ClickOnCancel() -{ - mySelection->ClearFilters() ; - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->ResetState() ; - reject() ; - return ; + if(myOkPoint1 && myOkDir && myOkRadius && myOkHeight) { + gp_Dir aDir = myDir; + /* allows user to reverse direction of construction with a negative height */ + if(this->myHeight < -Precision::Confusion()) + aDir.Reverse(); + myPrimitiveGUI->MakeCylinderAndDisplay(myPoint1, aDir, myRadius, fabs(myHeight)); + } + return; } @@ -457,169 +253,85 @@ void GeometryGUI_CylinderDlg::ClickOnCancel() //================================================================================= void GeometryGUI_CylinderDlg::SelectionIntoArgument() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - - QString aString = ""; /* name of future selection */ + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ - int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - if ( nbSel != 1 ) { - if ( myEditCurrentArgument == LineEditC1A1 ) { - LineEditC1A1->setText("") ; - myOkPoint1 = false ; - } - else if ( myEditCurrentArgument == LineEditC1A2 ) { - LineEditC1A2->setText("") ; - myOkDir = false ; - } - return ; + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkPoint1 = false; + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myOkDir = false; + return; } /* nbSel == 1 */ - TopoDS_Shape S; - if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) - return ; + TopoDS_Shape S; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; /* gp_Pnt : not used */ - if ( myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) { - LineEditC1A1->setText(aString) ; - myOkPoint1 = true ; + if (myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + GroupPoints->LineEdit1->setText(aString); + myOkPoint1 = true; } - else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, notUsed, myDir)*/ ) { + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { BRepAdaptor_Curve curv(TopoDS::Edge(S)); myDir = curv.Line().Direction(); - - LineEditC1A2->setText(aString) ; - myOkDir = true ; + GroupPoints->LineEdit2->setText(aString); + myOkDir = true; } - if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) { - MakeCylinderSimulationAndDisplay() ; - } - return ; + if(myOkPoint1 && myOkDir && myOkRadius && myOkHeight) + MakeCylinderSimulationAndDisplay(); + return; } + //================================================================================= // function : SetEditCurrentArgument() // purpose : //================================================================================= void GeometryGUI_CylinderDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters() ; - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; - mySelection->AddFilter(myVertexFilter) ; - } - else if(send == SelectButtonC1A2) { - LineEditC1A2->setFocus() ; - myEditCurrentArgument = LineEditC1A2; - mySelection->AddFilter(myEdgeFilter) ; - } - SelectionIntoArgument() ; - break; - } - case 1: - { - break ; - } - } + if(myConstructorId != 0) + return; - return ; + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + mySelection->AddFilter(myVertexFilter); + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + mySelection->AddFilter(myEdgeFilter); + } + this->SelectionIntoArgument(); + + return; } + //================================================================================= // function : LineEditReturnPressed() // purpose : //================================================================================= void GeometryGUI_CylinderDlg::LineEditReturnPressed() { - QLineEdit* send = (QLineEdit*)sender(); - if( send == LineEditC1A1 ) - myEditCurrentArgument = LineEditC1A1 ; - else if ( send == LineEditC1A2 ) - myEditCurrentArgument = LineEditC1A2 ; + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupPoints->LineEdit1) + myEditCurrentArgument = GroupPoints->LineEdit1; + else if (send == GroupPoints->LineEdit2) + myEditCurrentArgument = GroupPoints->LineEdit2; else - return ; - - /* User name of object input management */ - /* If successfull the selection is changed and signal emitted... */ - /* so SelectionIntoArgument() is automatically called. */ - QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ; - const QString objectUserName = LE->text() ; - QWidget* thisWidget = (QWidget*)this ; - if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) { - LE->setText( objectUserName ) ; - } - return ; -} + return; - -//================================================================================= -// function : ValueChangedInSpinBox -// purpose : -//================================================================================= -void GeometryGUI_CylinderDlg::ValueChangedInSpinBox( double newValue ) -{ - - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - QObject* send = (QObject*)sender(); - - if(send == SpinBox_C1A3 ) { /* radius */ - - myRadius = newValue ; - myOkRadius = true ; - if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) { - MakeCylinderSimulationAndDisplay() ; - } - } else if (send == SpinBox_C1A4 ) { /* algebric height */ - - myHeight = newValue ; - myOkHeight = true ; - if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) { - MakeCylinderSimulationAndDisplay() ; - } - } - else if (send == SpinBox_Height) { /* algebric height */ - - myOkHeight = true ; - myHeight = newValue ; - if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) { - MakeCylinderSimulationAndDisplay() ; - } - } - else if (send == SpinBox_Radius) { /* radius */ - myRadius = newValue ; - myOkRadius = true ; - if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) { - MakeCylinderSimulationAndDisplay() ; - } - } - return ; -} - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void GeometryGUI_CylinderDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupC2->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->EraseSimulationShape() ; - mySelection->ClearFilters() ; - } - return ; + GeometryGUI_Skeleton::LineEditReturnPressed(); + return; } @@ -629,16 +341,11 @@ void GeometryGUI_CylinderDlg::DeactivateActiveDialog() //================================================================================= void GeometryGUI_CylinderDlg::ActivateThisDialog() { - /* Emit a signal to deactivate the active dialog */ - myGeomGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupC2->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - if( !mySimulationTopoDs.IsNull() ) - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; - return ; + GeometryGUI_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; } @@ -648,22 +355,36 @@ void GeometryGUI_CylinderDlg::ActivateThisDialog() //================================================================================= void GeometryGUI_CylinderDlg::enterEvent(QEvent* e) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; - return ; + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; } //================================================================================= -// function : closeEvent() +// function : ValueChangedInSpinBox // purpose : //================================================================================= -void GeometryGUI_CylinderDlg::closeEvent( QCloseEvent* e ) -{ - /* same than click on cancel button */ - this->ClickOnCancel() ; - return ; +void GeometryGUI_CylinderDlg::ValueChangedInSpinBox( double newValue ) +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + QObject* send = (QObject*)sender(); + + /* radius */ + if(send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DX) { + myRadius = newValue; + myOkRadius = true; + } /* algebric height */ + else if(send == GroupPoints->SpinBox_DY || send == GroupDimensions->SpinBox_DY) { + myHeight = newValue; + myOkHeight = true; + } + + if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight) + MakeCylinderSimulationAndDisplay(); + return; } @@ -673,23 +394,22 @@ void GeometryGUI_CylinderDlg::closeEvent( QCloseEvent* e ) //================================================================================= void GeometryGUI_CylinderDlg::MakeCylinderSimulationAndDisplay() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - gp_Dir aDir = this->myDir ; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + gp_Dir aDir = this->myDir; try { /* allows user to reverse direction of construction with a negative height */ - if( this->myHeight < -Precision::Confusion() ) { - aDir.Reverse() ; - } - gp_Ax2 anAxis(this->myPoint1, aDir) ; + if(this->myHeight < -Precision::Confusion()) + aDir.Reverse(); - mySimulationTopoDs = BRepPrimAPI_MakeCylinder( anAxis, this->myRadius, fabs(myHeight) ).Shape() ; - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + gp_Ax2 anAxis(this->myPoint1, aDir); + + mySimulationTopoDs = BRepPrimAPI_MakeCylinder(anAxis, this->myRadius, fabs(myHeight)).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); } catch(Standard_Failure) { - MESSAGE( "Exception catched in MakeCylinderSimulationAndDisplay" ) ; + MESSAGE("Exception catched in MakeCylinderSimulationAndDisplay"); } - return ; + return; } - diff --git a/src/GEOMGUI/GeometryGUI_CylinderDlg.h b/src/GEOMGUI/GeometryGUI_CylinderDlg.h index fafab604e..5a32e71cf 100644 --- a/src/GEOMGUI/GeometryGUI_CylinderDlg.h +++ b/src/GEOMGUI/GeometryGUI_CylinderDlg.h @@ -29,118 +29,64 @@ #ifndef DIALOGBOX_CYLINDER_H #define DIALOGBOX_CYLINDER_H -#include "SALOME_Selection.h" +#include "GeometryGUI_Skeleton.h" +#include "GeometryGUI_2Sel2Spin.h" +#include "GeometryGUI_2Spin.h" + +#include "PrimitiveGUI.h" -#include "GEOM_ShapeTypeFilter.hxx" #include "GEOM_EdgeFilter.hxx" -#include "GeometryGUI_SpinBox.h" - -#include -#include - -#include -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QSpinBox; -class QRadioButton; -class GeometryGUI; +#include +#include //================================================================================= // class : GeometryGUI_CylinderDlg // purpose : //================================================================================= -class GeometryGUI_CylinderDlg : public QDialog +class GeometryGUI_CylinderDlg : public GeometryGUI_Skeleton { Q_OBJECT public: - GeometryGUI_CylinderDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + GeometryGUI_CylinderDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~GeometryGUI_CylinderDlg(); private: + void Init(); + void enterEvent(QEvent* e); + void MakeCylinderSimulationAndDisplay(); - void Init( SALOME_Selection* Sel ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void MakeCylinderSimulationAndDisplay() ; + PrimitiveGUI* myPrimitiveGUI; - GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ - GeometryGUI* myGeomGUI ; /* Current GeomGUI object */ - TopoDS_Shape mySimulationTopoDs ; - SALOME_Selection* mySelection ; /* User shape selection */ - - gp_Pnt myPoint1 ; /* topology used */ - gp_Dir myDir ; + double step; + int myConstructorId; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; + Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ - Standard_Real myRadius ; - Standard_Real myHeight ; - bool myOkRadius ; - bool myOkHeight ; - QDoubleValidator *myVa ; /* Double validator for numeric input */ - QDoubleValidator *myVb ; /* Double validator for numeric input */ + gp_Pnt myPoint1; /* topology used */ + gp_Dir myDir; + bool myOkPoint1; /* to check when arguments is defined */ + bool myOkDir; - bool myOkPoint1 ; - bool myOkDir ; /* to check when arguments is defined */ - int myConstructorId ; /* Current constructor id = radio button id */ - QWidget* myEditCurrentArgument; /* Current LineEdit or spin box */ - Handle(GEOM_ShapeTypeFilter) myVertexFilter ; /* Filter selection */ - Handle(GEOM_EdgeFilter) myEdgeFilter ; /* Filter selection */ + Standard_Real myRadius; + Standard_Real myHeight; + bool myOkRadius; + bool myOkHeight; - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - QRadioButton* Constructor2; - QGroupBox* GroupC1; - QGroupBox* GroupC2; - QPushButton* SelectButtonC1A1; - QLineEdit* LineEditC1A1; - QLabel* TextLabelC1A1; - QPushButton* SelectButtonC1A2; - QLineEdit* LineEditC1A2; - QLabel* TextLabelC1A2; - - QLabel* TextLabelC1A3; - GeometryGUI_SpinBox* SpinBox_C1A3 ; - QLabel* TextLabelC1A4 ; - GeometryGUI_SpinBox* SpinBox_C1A4 ; - - QLabel* TextLabel_Radius ; - GeometryGUI_SpinBox* SpinBox_Radius ; - QLabel* TextLabel_Height ; - GeometryGUI_SpinBox* SpinBox_Height ; + GeometryGUI_2Sel2Spin* GroupPoints; + GeometryGUI_2Spin* GroupDimensions; private slots: - - void ConstructorsClicked(int constructorId); void ClickOnOk(); - void ClickOnCancel(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void ValueChangedInSpinBox( double newValue ) ; - -protected: - QGridLayout* GeometryGUI_CylinderDlgLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupC1Layout; - QGridLayout* GroupC2Layout; + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked(int constructorId); + void ValueChangedInSpinBox(double newValue); + }; #endif // DIALOGBOX_CYLINDER_H diff --git a/src/GEOMGUI/GeometryGUI_FuseDlg.cxx b/src/GEOMGUI/GeometryGUI_FuseDlg.cxx index 371d927c6..d8b274079 100644 --- a/src/GEOMGUI/GeometryGUI_FuseDlg.cxx +++ b/src/GEOMGUI/GeometryGUI_FuseDlg.cxx @@ -39,7 +39,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GeometryGUI_FuseDlg::GeometryGUI_FuseDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) +GeometryGUI_FuseDlg::GeometryGUI_FuseDlg(QWidget* parent, const char* name, BooleanGUI* theBooleanGUI, SALOME_Selection* Sel, bool modal, WFlags fl) :GeometryGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_FUSE"))); @@ -64,7 +64,8 @@ GeometryGUI_FuseDlg::GeometryGUI_FuseDlg(QWidget* parent, const char* name, SALO /***************************************************************/ /* Initialisation */ - Init(Sel); + myBooleanGUI = theBooleanGUI; + Init(); } @@ -82,7 +83,7 @@ GeometryGUI_FuseDlg::~GeometryGUI_FuseDlg() // function : Init() // purpose : //================================================================================= -void GeometryGUI_FuseDlg::Init(SALOME_Selection* Sel) +void GeometryGUI_FuseDlg::Init() { /* init variables */ myEditCurrentArgument = GroupFuse->LineEdit1; @@ -101,7 +102,7 @@ void GeometryGUI_FuseDlg::Init(SALOME_Selection* Sel) connect(GroupFuse->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupFuse->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT( SelectionIntoArgument())); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); /* displays Dialog */ GroupFuse->show(); @@ -132,7 +133,7 @@ void GeometryGUI_FuseDlg::ClickOnApply() myGeomGUI->GetDesktop()->putInfo(tr("")); if(myOkShape1 && myOkShape2) - myGeomGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 3); + myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 3); return; } @@ -243,7 +244,7 @@ void GeometryGUI_FuseDlg::ActivateThisDialog() //================================================================================= void GeometryGUI_FuseDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) + if(GroupConstructors->isEnabled()) return; this->ActivateThisDialog(); return; diff --git a/src/GEOMGUI/GeometryGUI_FuseDlg.h b/src/GEOMGUI/GeometryGUI_FuseDlg.h index ca47a5e75..5e0835c9d 100644 --- a/src/GEOMGUI/GeometryGUI_FuseDlg.h +++ b/src/GEOMGUI/GeometryGUI_FuseDlg.h @@ -32,6 +32,8 @@ #include "GeometryGUI_Skeleton.h" #include "GeometryGUI_2Sel_QTD.h" +#include "BooleanGUI.h" + #include //================================================================================= @@ -43,13 +45,15 @@ class GeometryGUI_FuseDlg : public GeometryGUI_Skeleton Q_OBJECT public: - GeometryGUI_FuseDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + GeometryGUI_FuseDlg(QWidget* parent = 0, const char* name = 0, BooleanGUI* theBooleanGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~GeometryGUI_FuseDlg(); private: - void Init(SALOME_Selection* Sel); + void Init(); void enterEvent(QEvent* e); + BooleanGUI* myBooleanGUI; + TopoDS_Shape myShape1; /* topology used to fuse */ TopoDS_Shape myShape2; /* topology used to fuse */ GEOM::GEOM_Shape_var myGeomShape1; /* is myShape1 */ @@ -57,15 +61,15 @@ private: bool myOkShape1; /* to check when arguments are defined */ bool myOkShape2; - GeometryGUI_2Sel_QTD* GroupFuse ; + GeometryGUI_2Sel_QTD* GroupFuse; private slots: void ClickOnOk(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void ActivateThisDialog() ; + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + void ActivateThisDialog(); }; diff --git a/src/GEOMGUI/GeometryGUI_SectionDlg.cxx b/src/GEOMGUI/GeometryGUI_SectionDlg.cxx index 4fea1aa15..363a8c934 100644 --- a/src/GEOMGUI/GeometryGUI_SectionDlg.cxx +++ b/src/GEOMGUI/GeometryGUI_SectionDlg.cxx @@ -30,25 +30,7 @@ using namespace std; #include "GeometryGUI_SectionDlg.h" #include "GeometryGUI.h" - -#include "QAD_Application.h" #include "QAD_Desktop.h" -#include "utilities.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - //================================================================================= // class : GeometryGUI_SectionDlg() @@ -57,109 +39,33 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GeometryGUI_SectionDlg::GeometryGUI_SectionDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +GeometryGUI_SectionDlg::GeometryGUI_SectionDlg(QWidget* parent, const char* name, BooleanGUI* theBooleanGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + :GeometryGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_SECTION"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_SECTION"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - if ( !name ) - setName( "GeometryGUI_SectionDlg" ); - resize( 303, 224 ); - setCaption( tr( "GEOM_SECTION_TITLE" ) ); - setSizeGripEnabled( TRUE ); - GeometryGUI_SectionDlgLayout = new QGridLayout( this ); - GeometryGUI_SectionDlgLayout->setSpacing( 6 ); - GeometryGUI_SectionDlgLayout->setMargin( 11 ); + setCaption(tr("GEOM_SECTION_TITLE")); - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "GEOM_SECTION" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - GeometryGUI_SectionDlgLayout->addWidget( GroupConstructors, 0, 0 ); + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_SECTION")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); - /***************************************************************/ - GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); - GroupConstructor1->setTitle( tr( "GEOM_ARGUMENTS" ) ); - GroupConstructor1->setColumnLayout(0, Qt::Vertical ); - GroupConstructor1->layout()->setSpacing( 0 ); - GroupConstructor1->layout()->setMargin( 0 ); - GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); - GroupConstructor1Layout->setAlignment( Qt::AlignTop ); - GroupConstructor1Layout->setSpacing( 6 ); - GroupConstructor1Layout->setMargin( 11 ); - LineEditC1A2Shape = new QLineEdit( GroupConstructor1, "LineEditC1A2Shape" ); - LineEditC1A2Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Shape->sizePolicy().hasHeightForWidth() ) ); - GroupConstructor1Layout->addWidget( LineEditC1A2Shape, 1, 2 ); - LineEditC1A1Shape = new QLineEdit( GroupConstructor1, "LineEditC1A1Shape" ); - LineEditC1A1Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Shape->sizePolicy().hasHeightForWidth() ) ); - GroupConstructor1Layout->addWidget( LineEditC1A1Shape, 0, 2 ); - SelectButtonC1A1Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A1Shape" ); - SelectButtonC1A1Shape->setText( tr( "" ) ); - SelectButtonC1A1Shape->setPixmap( image1 ); - GroupConstructor1Layout->addWidget( SelectButtonC1A1Shape, 0, 1 ); - SelectButtonC1A2Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A2Shape" ); - SelectButtonC1A2Shape->setText( tr( "" ) ); - SelectButtonC1A2Shape->setPixmap( image1 ); - GroupConstructor1Layout->addWidget( SelectButtonC1A2Shape, 1, 1 ); - TextLabelC1A2Shape = new QLabel( GroupConstructor1, "TextLabelC1A2Shape" ); - TextLabelC1A2Shape->setText( tr( "GEOM_OBJECT_I" ).arg("2") ); - TextLabelC1A2Shape->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A2Shape->setFrameShape( QLabel::NoFrame ); - TextLabelC1A2Shape->setFrameShadow( QLabel::Plain ); - GroupConstructor1Layout->addWidget( TextLabelC1A2Shape, 1, 0 ); - TextLabelC1A1Shape = new QLabel( GroupConstructor1, "TextLabelC1A1Shape" ); - TextLabelC1A1Shape->setText( tr( "GEOM_OBJECT_I" ).arg("1") ); - TextLabelC1A1Shape->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1Shape->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1Shape->setFrameShadow( QLabel::Plain ); - GroupConstructor1Layout->addWidget( TextLabelC1A1Shape, 0, 0 ); - GeometryGUI_SectionDlgLayout->addWidget( GroupConstructor1, 1, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "GEOM_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "GEOM_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - GeometryGUI_SectionDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupSection = new GeometryGUI_2Sel_QTD(this, "GroupSection"); + GroupSection->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupSection->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); + GroupSection->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); + GroupSection->PushButton1->setPixmap(image1); + GroupSection->PushButton2->setPixmap(image1); - /* Initialisation */ - Init( Sel ) ; + Layout1->addWidget(GroupSection, 1, 0); + /***************************************************************/ + + /* Initialisation */ + myBooleanGUI = theBooleanGUI; + Init(); } @@ -170,7 +76,6 @@ GeometryGUI_SectionDlg::GeometryGUI_SectionDlg( QWidget* parent, const char* na GeometryGUI_SectionDlg::~GeometryGUI_SectionDlg() { /* no need to delete child widgets, Qt does it all for us */ - this->destroy(TRUE, TRUE) ; } @@ -179,184 +84,108 @@ GeometryGUI_SectionDlg::~GeometryGUI_SectionDlg() // function : Init() // purpose : //================================================================================= -void GeometryGUI_SectionDlg::Init( SALOME_Selection* Sel ) +void GeometryGUI_SectionDlg::Init() { - mySelection = Sel ; - myShape1.Nullify() ; - myShape2.Nullify() ; - myConstructorId = 0 ; - - myGeomGUI = GeometryGUI::GetGeometryGUI() ; + /* init variables */ + myEditCurrentArgument = GroupSection->LineEdit1; - GroupConstructor1->show(); - myConstructorId = 0 ; - myEditCurrentArgument = LineEditC1A1Shape ; - Constructor1->setChecked( TRUE ); - myOkShape1 = myOkShape2 = false ; + myShape1.Nullify(); + myShape2.Nullify(); + myOkShape1 = myOkShape2 = false; - myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); - myGeom = GEOM::GEOM_Gen::_narrow(comp); - - // TODO previous selection into argument ? + connect(GroupSection->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupSection->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect(GroupSection->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupSection->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect( GroupConstructors, SIGNAL(clicked(int) ),this, SLOT( ConstructorsClicked(int) ) ); - connect( SelectButtonC1A1Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A2Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - connect( LineEditC1A1Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - connect( LineEditC1A2Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + /* displays Dialog */ + GroupSection->show(); + this->show(); - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - /* to close dialog if study change */ - connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - myGeomGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* Displays Dialog */ - - return ; + return; } - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void GeometryGUI_SectionDlg::ConstructorsClicked(int constructorId) -{ - GeometryGUI::GetGeometryGUI()->EraseSimulationShape() ; - - switch (constructorId) - { - case 0: - { - GroupConstructor1->show(); - myConstructorId = constructorId ; - myEditCurrentArgument = LineEditC1A1Shape ; - LineEditC1A2Shape->setText(tr("")) ; - Constructor1->setChecked( TRUE ); - myOkShape1 = myOkShape2 = false ; - break; - } - } - return ; -} - //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void GeometryGUI_SectionDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - + this->ClickOnApply(); + ClickOnCancel(); return ; } + //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void GeometryGUI_SectionDlg::ClickOnApply() { - myGeomGUI->GetDesktop()->putInfo( tr("") ) ; - switch(myConstructorId) - { - case 0 : - { - if(myOkShape1 && myOkShape2) { - myGeomGUI->MakeBooleanAndDisplay(myGeomShape1, myGeomShape2, 4 ) ; - } - break ; - } - } - // accept(); - return ; + myGeomGUI->GetDesktop()->putInfo(tr("")); + + if(myOkShape1 && myOkShape2) + myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 4); + + return; } -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void GeometryGUI_SectionDlg::ClickOnCancel() -{ - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->ResetState() ; - reject() ; - return ; -} - - - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection has changed //================================================================================= void GeometryGUI_SectionDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText("") ; - QString aString = ""; /* future the name of selection */ + myEditCurrentArgument->setText(""); + QString aString = ""; - int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - if ( nbSel != 1 ) { - switch (myConstructorId) - { - case 0: - { - if ( myEditCurrentArgument == LineEditC1A1Shape ) { - myOkShape1 = false ; - } - else if ( myEditCurrentArgument == LineEditC1A2Shape ) { - myOkShape2 = false ; - } - break ; - } - } - return ; + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupSection->LineEdit1) + myOkShape1 = false; + else if( myEditCurrentArgument == GroupSection->LineEdit2) + myOkShape2 = false; + return; } - /* nbSel == 1 */ + /* nbSel == 1 */ TopoDS_Shape S; - Standard_Boolean testResult ; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) - return ; - - if ( myEditCurrentArgument == LineEditC1A1Shape ) { - myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) - return ; - myShape1 = S ; - LineEditC1A1Shape->setText(aString) ; - myOkShape1 = true ; - } - else if ( myEditCurrentArgument == LineEditC1A2Shape ) { - myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) - return ; - myShape2 = S ; - LineEditC1A2Shape->setText(aString) ; - myOkShape2 = true ; + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + if(myEditCurrentArgument == GroupSection->LineEdit1) { + myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape1 = S; + GroupSection->LineEdit1->setText(aString); + myOkShape1 = true; } - - return ; + else if(myEditCurrentArgument == GroupSection->LineEdit2) { + myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape2 = S; + GroupSection->LineEdit2->setText(aString); + myOkShape2 = true; + } + return; } - //================================================================================= // function : SetEditCurrentArgument() // purpose : @@ -365,25 +194,18 @@ void GeometryGUI_SectionDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if( send == SelectButtonC1A1Shape ) { - LineEditC1A1Shape->setFocus() ; - myEditCurrentArgument = LineEditC1A1Shape ; - } - else if(send == SelectButtonC1A2Shape) { - LineEditC1A2Shape->setFocus() ; - myEditCurrentArgument = LineEditC1A2Shape; - } - SelectionIntoArgument() ; - break; - } - } - return ; -} + if(send == GroupSection->PushButton1) { + GroupSection->LineEdit1->setFocus(); + myEditCurrentArgument = GroupSection->LineEdit1; + } + else if(send == GroupSection->PushButton2) { + GroupSection->LineEdit2->setFocus(); + myEditCurrentArgument = GroupSection->LineEdit2; + } + SelectionIntoArgument(); + return; +} //================================================================================= @@ -392,80 +214,39 @@ void GeometryGUI_SectionDlg::SetEditCurrentArgument() //================================================================================= void GeometryGUI_SectionDlg::LineEditReturnPressed() { - QLineEdit* send = (QLineEdit*)sender(); - if( send == LineEditC1A1Shape ) - myEditCurrentArgument = LineEditC1A1Shape ; - else if ( send == LineEditC1A2Shape ) - myEditCurrentArgument = LineEditC1A2Shape ; + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupSection->LineEdit1) + myEditCurrentArgument = GroupSection->LineEdit1; + else if(send == GroupSection->LineEdit2) + myEditCurrentArgument = GroupSection->LineEdit2; else - return ; - - /* User name of object input management */ - /* If successfull the selection is changed and signal emitted... */ - /* so SelectionIntoArgument() is automatically called. */ - const QString objectUserName = myEditCurrentArgument->text() ; - QWidget* thisWidget = (QWidget*)this ; - if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) { - myEditCurrentArgument->setText( objectUserName ) ; - } - return ; + return; + + GeometryGUI_Skeleton::LineEditReturnPressed(); + return; } - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void GeometryGUI_SectionDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - - GroupConstructors->setEnabled(false) ; - GroupConstructor1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->EraseSimulationShape() ; - } - return ; -} - - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void GeometryGUI_SectionDlg::closeEvent( QCloseEvent* e ) -{ - this->ClickOnCancel() ; /* same than click on cancel button */ -} - - -//================================================================================= -// function : enterEvent() -// purpose : when mouse enter onto the QWidget -//================================================================================= -void GeometryGUI_SectionDlg::enterEvent( QEvent * ) -{ - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; -} - - - //================================================================================= // function : ActivateThisDialog() // purpose : //================================================================================= void GeometryGUI_SectionDlg::ActivateThisDialog() { - /* Emit a signal to deactivate any active dialog */ - myGeomGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupConstructor1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - return ; + GeometryGUI_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void GeometryGUI_SectionDlg::enterEvent(QEvent * e) +{ + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; } diff --git a/src/GEOMGUI/GeometryGUI_SectionDlg.h b/src/GEOMGUI/GeometryGUI_SectionDlg.h index 5ac5b2a8f..fa7a2dc77 100644 --- a/src/GEOMGUI/GeometryGUI_SectionDlg.h +++ b/src/GEOMGUI/GeometryGUI_SectionDlg.h @@ -29,88 +29,48 @@ #ifndef DIALOGBOX_SECTION_H #define DIALOGBOX_SECTION_H -#include "SALOME_Selection.h" -#include "GEOM_ShapeTypeFilter.hxx" +#include "GeometryGUI_Skeleton.h" +#include "GeometryGUI_2Sel_QTD.h" + +#include "BooleanGUI.h" #include -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; -class GeometryGUI; - - //================================================================================= // class : GeometryGUI_SectionDlg // purpose : //================================================================================= -class GeometryGUI_SectionDlg : public QDialog{ +class GeometryGUI_SectionDlg : public GeometryGUI_Skeleton +{ Q_OBJECT public: - GeometryGUI_SectionDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + GeometryGUI_SectionDlg(QWidget* parent = 0, const char* name = 0, BooleanGUI* theBooleanGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~GeometryGUI_SectionDlg(); private: + void Init(); + void enterEvent(QEvent* e); - void Init( SALOME_Selection* Sel ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + BooleanGUI* myBooleanGUI; - GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ - GeometryGUI* myGeomGUI ; /* Current GeomGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - TopoDS_Shape myShape1 ; /* topology used to fuse */ - TopoDS_Shape myShape2 ; /* topology used to fuse */ - GEOM::GEOM_Shape_var myGeomShape1 ; /* is myShape1 */ - GEOM::GEOM_Shape_var myGeomShape2 ; /* is myShape2 */ - bool myOkShape1 ; - bool myOkShape2 ; /* to check when arguments are defined */ - int myConstructorId ; /* Current constructor id = radio button id */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + TopoDS_Shape myShape1; /* topology used to fuse */ + TopoDS_Shape myShape2; /* topology used to fuse */ + GEOM::GEOM_Shape_var myGeomShape1; /* is myShape1 */ + GEOM::GEOM_Shape_var myGeomShape2; /* is myShape2 */ + bool myOkShape1; /* to check when arguments are defined */ + bool myOkShape2; - - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - QGroupBox* GroupConstructor1; - QLineEdit* LineEditC1A2Shape; - QLineEdit* LineEditC1A1Shape; - QPushButton* SelectButtonC1A1Shape; - QPushButton* SelectButtonC1A2Shape; - QLabel* TextLabelC1A2Shape; - QLabel* TextLabelC1A1Shape; - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; + GeometryGUI_2Sel_QTD* GroupSection; private slots: - - void ConstructorsClicked(int constructorId); void ClickOnOk(); - void ClickOnCancel(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + void ActivateThisDialog(); - -protected: - QGridLayout* GeometryGUI_SectionDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupConstructor1Layout; - QGridLayout* GroupButtonsLayout; }; #endif // DIALOGBOX_SECTION_H diff --git a/src/GEOMGUI/GeometryGUI_Skeleton.cxx b/src/GEOMGUI/GeometryGUI_Skeleton.cxx index e91e5a259..cc39c3596 100644 --- a/src/GEOMGUI/GeometryGUI_Skeleton.cxx +++ b/src/GEOMGUI/GeometryGUI_Skeleton.cxx @@ -39,7 +39,7 @@ // TRUE to construct a modal dialog. //================================================================================= GeometryGUI_Skeleton::GeometryGUI_Skeleton(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) - :GeometryGUI_Skeleton_QTD(parent, name, modal, fl) + :GeometryGUI_Skeleton_QTD(parent, name, modal, fl) { if (!name) setName("GeometryGUI_Skeleton"); @@ -51,7 +51,7 @@ GeometryGUI_Skeleton::GeometryGUI_Skeleton(QWidget* parent, const char* name, SA GroupMedium->close(TRUE); resize(0, 0); - Init(Sel) ; + Init(Sel); } @@ -87,13 +87,13 @@ void GeometryGUI_Skeleton::Init(SALOME_Selection* Sel) connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); /* Move widget on the botton right corner of main widget */ -// int x, y ; -// myGeomGUI->DefineDlgPosition( this, x, y ) ; +// int x, y; +// myGeomGUI->DefineDlgPosition( this, x, y ); /* displays Dialog */ RadioButton1->setChecked(TRUE); - return ; + return; } @@ -140,7 +140,7 @@ void GeometryGUI_Skeleton::LineEditReturnPressed() //================================================================================= void GeometryGUI_Skeleton::DeactivateActiveDialog() { - Layout1->setEnabled(false); + this->setEnabled(false); mySelection->ClearFilters(); disconnect(mySelection, 0, this, 0); myGeomGUI->EraseSimulationShape(); @@ -156,8 +156,8 @@ void GeometryGUI_Skeleton::DeactivateActiveDialog() void GeometryGUI_Skeleton::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - myGeomGUI->EmitSignalDeactivateDialog(); - Layout1->setEnabled(true); + myGeomGUI->EmitSignalDeactivateDialog(); + this->setEnabled(true); myGeomGUI->SetActiveDialogBox((QDialog*)this); return; } diff --git a/src/GEOMGUI/GeometryGUI_SphereDlg.cxx b/src/GEOMGUI/GeometryGUI_SphereDlg.cxx index a78e1f7fc..992e481b6 100644 --- a/src/GEOMGUI/GeometryGUI_SphereDlg.cxx +++ b/src/GEOMGUI/GeometryGUI_SphereDlg.cxx @@ -28,30 +28,12 @@ using namespace std; #include "GeometryGUI_SphereDlg.h" -#include "GeometryGUI_SpinBox.h" + +#include #include "GeometryGUI.h" - -#include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_Config.h" -#include "utilities.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - //================================================================================= // class : GeometryGUI_SphereDlg() @@ -60,138 +42,38 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GeometryGUI_SphereDlg::GeometryGUI_SphereDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +GeometryGUI_SphereDlg::GeometryGUI_SphereDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + :GeometryGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_SPHERE_P"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); - QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_SPHERE_DXYZ"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_SPHERE_P"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_SPHERE_DXYZ"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - if ( !name ) - setName( "GeometryGUI_SphereDlg" ); - resize( 303, 219 ); - setCaption( tr( "GEOM_SPHERE_TITLE" ) ); - setSizeGripEnabled( TRUE ); - GeometryGUI_SphereDlgLayout = new QGridLayout( this ); - GeometryGUI_SphereDlgLayout->setSpacing( 6 ); - GeometryGUI_SphereDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "GEOM_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "GEOM_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - GeometryGUI_SphereDlgLayout->addWidget( GroupButtons, 2, 0 ); + setCaption(tr("GEOM_SPHERE_TITLE")); - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "GEOM_SPHERE" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer_2, 0, 3 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer_3, 0, 1 ); - Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" ); - Constructor2->setText( tr( "" ) ); - GroupConstructors->insert( Constructor2, 1 ); - Constructor2->setMinimumSize( QSize( 50, 0 ) ); - Constructor2->setPixmap( image2 ); - GroupConstructorsLayout->addWidget( Constructor2, 0, 2 ); - GeometryGUI_SphereDlgLayout->addWidget( GroupConstructors, 0, 0 ); - GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); - GroupConstructor1->setTitle( tr( "GEOM_SPHERE_CR" ) ); - GroupConstructor1->setColumnLayout(0, Qt::Vertical ); - GroupConstructor1->layout()->setSpacing( 0 ); - GroupConstructor1->layout()->setMargin( 0 ); - GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); - GroupConstructor1Layout->setAlignment( Qt::AlignTop ); - GroupConstructor1Layout->setSpacing( 6 ); - GroupConstructor1Layout->setMargin( 11 ); - LineEditC1A1 = new QLineEdit( GroupConstructor1, "LineEditC1A1" ); - LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) ); - GroupConstructor1Layout->addWidget( LineEditC1A1, 0, 2 ); - SelectButtonC1A1 = new QPushButton( GroupConstructor1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - GroupConstructor1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - TextLabelC1A1 = new QLabel( GroupConstructor1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "GEOM_CENTER" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupConstructor1Layout->addWidget( TextLabelC1A1, 0, 0 ); - TextLabelC1A2 = new QLabel( GroupConstructor1, "TextLabelC1A2" ); - TextLabelC1A2->setText( tr( "GEOM_RADIUS" ) ); - TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A2->setFrameShape( QLabel::NoFrame ); - TextLabelC1A2->setFrameShadow( QLabel::Plain ); - GroupConstructor1Layout->addWidget( TextLabelC1A2, 1, 0 ); + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_SPHERE")); + RadioButton1->setPixmap(image0); + RadioButton2->setPixmap(image1); + RadioButton3->close(TRUE); - SpinBox_C1A2 = new GeometryGUI_SpinBox( GroupConstructor1, "GeomSpinBox_C1A2" ) ; - GroupConstructor1Layout->addWidget( SpinBox_C1A2, 1, 2 ); + GroupPoints = new GeometryGUI_1Sel1Spin(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_SPHERE_CR")); + GroupPoints->TextLabel1->setText(tr("GEOM_CENTER")); + GroupPoints->TextLabel2->setText(tr("GEOM_RADIUS")); + GroupPoints->PushButton1->setPixmap(image2); - GeometryGUI_SphereDlgLayout->addWidget( GroupConstructor1, 1, 0 ); + GroupDimensions = new GeometryGUI_1Spin(this, "GroupDimensions"); + GroupDimensions->GroupBox1->setTitle(tr("GEOM_SPHERE_RO")); + GroupDimensions->TextLabel1->setText(tr("GEOM_RADIUS")); - /***************************************************************/ - GroupConstructor2 = new QGroupBox( this, "GroupConstructor2" ); - GroupConstructor2->setTitle( tr( "GEOM_SPHERE_RO" ) ); - GroupConstructor2->setColumnLayout(0, Qt::Vertical ); - GroupConstructor2->layout()->setSpacing( 0 ); - GroupConstructor2->layout()->setMargin( 0 ); - GroupConstructor2Layout = new QGridLayout( GroupConstructor2->layout() ); - GroupConstructor2Layout->setAlignment( Qt::AlignTop ); - GroupConstructor2Layout->setSpacing( 6 ); - GroupConstructor2Layout->setMargin( 11 ); + Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupDimensions, 1, 0); + /***************************************************************/ - SpinBox_C2A1 = new GeometryGUI_SpinBox( GroupConstructor2, "GeomSpinBox_C2A1" ) ; - GroupConstructor2Layout->addWidget( SpinBox_C2A1, 0, 1 ); - - TextLabelC2A1 = new QLabel( GroupConstructor2, "TextLabelC2A1" ); - TextLabelC2A1->setText( tr( "GEOM_RADIUS" ) ); - TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC2A1->setFrameShape( QLabel::NoFrame ); - TextLabelC2A1->setFrameShadow( QLabel::Plain ); - GroupConstructor2Layout->addWidget( TextLabelC2A1, 0, 0 ); - QSpacerItem* spacer_5 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); - GroupConstructor2Layout->addItem( spacer_5, 1, 1 ); - GeometryGUI_SphereDlgLayout->addWidget( GroupConstructor2, 1, 0 ); - - Init(Sel) ; /* Initialisations */ + /* Initialisations */ + myPrimitiveGUI = thePrimitiveGUI; + Init(); } @@ -209,146 +91,101 @@ GeometryGUI_SphereDlg::~GeometryGUI_SphereDlg() // function : Init() // purpose : //================================================================================= -void GeometryGUI_SphereDlg::Init( SALOME_Selection* Sel ) +void GeometryGUI_SphereDlg::Init() { + /* init variables */ + myConstructorId = 0; + myEditCurrentArgument = GroupPoints->LineEdit1; + + myPoint1.SetCoord(0.0, 0.0, 0.0); + myRadius = 100.0; + myOkPoint1 = myOkRadius = false; + + /* Vertices Filter for all arguments */ + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + mySelection->AddFilter(myVertexFilter); /* Get setting of step value from file configuration */ - double step ; - QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ; - step = St.toDouble() ; + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); /* min, max, step and decimals for spin boxes */ - SpinBox_C1A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; - SpinBox_C1A2->SetValue( 100.0 ) ; - SpinBox_C2A1->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; - SpinBox_C2A1->SetValue( 100.0 ) ; + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_DX->SetValue(myRadius); + GroupDimensions->SpinBox_DX->SetValue(myRadius); - GroupConstructor1->show(); - GroupConstructor2->hide(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - myGeomGUI = GeometryGUI::GetGeometryGUI() ; - myPoint1.SetCoord( 0.0, 0.0, 0.0 ); - - myRadius = 100.0 ; - myOkRadius = true ; - myOkPoint1 = false ; - - mySimulationTopoDs.Nullify() ; - myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; - - /* Filters definition */ - Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); - myGeom = GEOM::GEOM_Gen::_narrow(comp); - myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom ); - mySelection->AddFilter(myVertexFilter) ; /* first filter used */ - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - connect( SpinBox_C1A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_C2A1, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + /* displays Dialog */ + GroupDimensions->hide(); + GroupPoints->show(); + this->show(); - connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - /* to close dialog if study change */ - connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - myGeomGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ - - return ; + return; } - //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= void GeometryGUI_SphereDlg::ConstructorsClicked(int constructorId) { - myGeomGUI->EraseSimulationShape() ; + myConstructorId = constructorId; + mySelection->ClearFilters(); + myGeomGUI->EraseSimulationShape(); + disconnect(mySelection, 0, this, 0); + myRadius = 100.0; + myOkRadius = true; switch (constructorId) { case 0: { - GroupConstructor1->show(); - GroupConstructor2->hide(); - myConstructorId = constructorId ; - myEditCurrentArgument = SpinBox_C1A2 ; - LineEditC1A1->setText(tr("")) ; - SpinBox_C1A2->SetValue( 100.0 ) ; - myRadius = 100.0 ; - myOkRadius = true ; - myOkPoint1 = false ; + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(""); + + GroupPoints->SpinBox_DX->SetValue(myRadius); + myOkPoint1 = false; + /* filter for next selections */ - mySelection->ClearFilters() ; - mySelection->AddFilter( myVertexFilter ); - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + mySelection->AddFilter(myVertexFilter); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } case 1: { - GroupConstructor1->hide(); - GroupConstructor2->show(); - myConstructorId = constructorId ; - myEditCurrentArgument = SpinBox_C2A1 ;; - SpinBox_C2A1->SetValue( 100.0 ) ; - myRadius = 100.0 ; - myOkRadius = true ; - myPoint1.SetCoord( 0.0, 0.0, 0.0 ); /* at origin */ - myOkPoint1 = false ; + GroupPoints->hide(); + resize( 0, 0 ); + GroupDimensions->show(); + + GroupDimensions->SpinBox_DX->SetValue(myRadius); + myPoint1.SetCoord(0.0, 0.0, 0.0); /* at origin */ + myOkPoint1 = true; + mySimulationTopoDs = BRepPrimAPI_MakeSphere(myPoint1, myRadius).Shape(); - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; - /* no filters here */ - mySelection->ClearFilters() ; + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); break; } } return ; } -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void GeometryGUI_SphereDlg::ClickOnApply() -{ - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - myGeomGUI->GetDesktop()->putInfo( tr("") ) ; - switch(myConstructorId) - { - case 0 : - { - if( myOkPoint1 && myOkRadius ) { - myGeomGUI->MakeSphereAndDisplay( myPoint1, myRadius ) ; - } - break ; - } - case 1 : - { - if( myOkRadius ) - myGeomGUI->MakeSphereAndDisplay( myPoint1, myRadius ) ; - break ; - } - } - return ; -} - //================================================================================= // function : ClickOnOk() @@ -356,24 +193,26 @@ void GeometryGUI_SphereDlg::ClickOnApply() //================================================================================= void GeometryGUI_SphereDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - - return ; + this->ClickOnApply(); + ClickOnCancel(); + return; } + //================================================================================= -// function : ClickOnCancel() +// function : ClickOnApply() // purpose : //================================================================================= -void GeometryGUI_SphereDlg::ClickOnCancel() +void GeometryGUI_SphereDlg::ClickOnApply() { - mySelection->ClearFilters() ; - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->ResetState() ; - reject() ; + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkPoint1 && myOkRadius) + myPrimitiveGUI->MakeSphereAndDisplay(myPoint1, myRadius); return ; } @@ -384,35 +223,33 @@ void GeometryGUI_SphereDlg::ClickOnCancel() //================================================================================= void GeometryGUI_SphereDlg::SelectionIntoArgument() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - - /* Future name of selection */ - QString aString = ""; + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ - int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - if ( nbSel != 1 ) { - if ( myEditCurrentArgument == LineEditC1A1 ) { - LineEditC1A1->setText("") ; - myOkPoint1 = false ; + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) { + GroupPoints->LineEdit1->setText(""); + myOkPoint1 = false; } - return ; + return; } /* nbSel == 1 ! */ TopoDS_Shape S; - if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) - return ; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; /* Constructor 1 treatment */ - if ( myConstructorId == 0 && myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) { - LineEditC1A1->setText(aString) ; - myOkPoint1 = true ; + if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + GroupPoints->LineEdit1->setText(aString); + myOkPoint1 = true; } - if( ( myOkPoint1 || myConstructorId == 1 ) && myOkRadius ) { + if(myOkPoint1 && myOkRadius) { mySimulationTopoDs = BRepPrimAPI_MakeSphere(myPoint1, myRadius).Shape(); - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); } return ; } @@ -424,114 +261,50 @@ void GeometryGUI_SphereDlg::SelectionIntoArgument() //================================================================================= void GeometryGUI_SphereDlg::LineEditReturnPressed() { - QLineEdit* send = (QLineEdit*)sender(); - if( send == LineEditC1A1 ) - myEditCurrentArgument = LineEditC1A1 ; + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupPoints->LineEdit1) + myEditCurrentArgument = GroupPoints->LineEdit1; else - return ; - - /* User name of object input management */ - /* If successfull the selection is changed and signal emitted... */ - /* so SelectionIntoArgument() is automatically called. */ - QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ; - const QString objectUserName = LE->text() ; - QWidget* thisWidget = (QWidget*)this ; - if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) { - LE->setText( objectUserName ) ; - } - return ; + return; + + GeometryGUI_Skeleton::LineEditReturnPressed(); + return; } -//================================================================================= -// function : ValueChangedInSpinBox() -// purpose : -//================================================================================= -void GeometryGUI_SphereDlg::ValueChangedInSpinBox( double newValue ) -{ - myRadius = newValue ; - myOkRadius = true ; - - if ( ( myOkPoint1 || myConstructorId == 1 ) && myOkRadius ) { - mySimulationTopoDs = BRepPrimAPI_MakeSphere(myPoint1, myRadius).Shape(); - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; - } - else { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - } - - return ; -} - - - //================================================================================= // function : SetEditCurrentArgument() // purpose : //================================================================================= void GeometryGUI_SphereDlg::SetEditCurrentArgument() { + if(myConstructorId != 0) + return; + QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; - mySelection->AddFilter(myVertexFilter) ; - SelectionIntoArgument() ; - } - break; - } - case 1: - { - /* no selection button here */ - break; - } - } - return ; -} - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void GeometryGUI_SphereDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - - GroupConstructors->setEnabled(false) ; - GroupConstructor1->setEnabled(false) ; - GroupConstructor2->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->EraseSimulationShape() ; - mySelection->ClearFilters() ; + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + mySelection->AddFilter(myVertexFilter); + this->SelectionIntoArgument(); } - return ; + + return; } + //================================================================================= // function : ActivateThisDialog() // purpose : //================================================================================= void GeometryGUI_SphereDlg::ActivateThisDialog() { - /* Emit a signal to deactivate other active dialog */ - myGeomGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupConstructor1->setEnabled(true) ; - GroupConstructor2->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - if( !mySimulationTopoDs.IsNull() ) - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; - - return ; + GeometryGUI_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; } @@ -541,20 +314,27 @@ void GeometryGUI_SphereDlg::ActivateThisDialog() //================================================================================= void GeometryGUI_SphereDlg::enterEvent(QEvent* e) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; } //================================================================================= -// function : closeEvent() +// function : ValueChangedInSpinBox() // purpose : //================================================================================= -void GeometryGUI_SphereDlg::closeEvent( QCloseEvent* e ) +void GeometryGUI_SphereDlg::ValueChangedInSpinBox(double newValue) { - this->ClickOnCancel() ; /* same than click on cancel button */ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + myRadius = newValue; + myOkRadius = true; + + if (myOkPoint1 && myOkRadius) { + mySimulationTopoDs = BRepPrimAPI_MakeSphere(myPoint1, myRadius).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + return; } - - - diff --git a/src/GEOMGUI/GeometryGUI_SphereDlg.h b/src/GEOMGUI/GeometryGUI_SphereDlg.h index cd5027971..65de969b5 100644 --- a/src/GEOMGUI/GeometryGUI_SphereDlg.h +++ b/src/GEOMGUI/GeometryGUI_SphereDlg.h @@ -29,103 +29,54 @@ #ifndef DIALOGBOX_SPHERE_H #define DIALOGBOX_SPHERE_H -#include "SALOME_Selection.h" -#include "GEOM_ShapeTypeFilter.hxx" +#include "GeometryGUI_Skeleton.h" +#include "GeometryGUI_1Sel1Spin.h" +#include "GeometryGUI_1Spin.h" + +#include "PrimitiveGUI.h" #include -#include -#include - -#include -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QGroupBox; -class QLabel; -class QLineEdit; -class QSpinBox; -class QPushButton; -class GeometryGUI_SpinBox; -class QRadioButton; -class GeometryGUI; - //================================================================================= // class : GeometryGUI_SphereDlg // purpose : //================================================================================= -class GeometryGUI_SphereDlg : public QDialog +class GeometryGUI_SphereDlg : public GeometryGUI_Skeleton { Q_OBJECT public: - GeometryGUI_SphereDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + GeometryGUI_SphereDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~GeometryGUI_SphereDlg(); private : - - GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */ - GeometryGUI* myGeomGUI ; /* Current GeomGUI object */ - TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */ - SALOME_Selection* mySelection ; /* User shape selection */ - gp_Pnt myPoint1 ; /* Points containing the vector */ + void Init(); + void enterEvent(QEvent* e); - Standard_Real myRadius ; - bool myOkRadius ; - QDoubleValidator *myVa ; /* Double validator for numeric input myRadius in LineEditC1A2 */ - QDoubleValidator *myVb ; /* Double validator for numeric input myRadius in LineEditC2A1 */ + PrimitiveGUI* myPrimitiveGUI; - bool myOkPoint1 ; /* Are true when myPoint is defined */ - QWidget* myEditCurrentArgument; /* Current LineEdit or SpinBox */ - int myConstructorId ; /* Current constructor id = radio button id */ - Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filter selection */ + double step; + int myConstructorId; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* filter for selection */ - void closeEvent( QCloseEvent* e ) ; - void enterEvent( QEvent* e); - void Init( SALOME_Selection* Sel ) ; + gp_Pnt myPoint1; /* Points containing the vector */ + Standard_Real myRadius; + bool myOkRadius; /* Are true when myPoint is defined */ + bool myOkPoint1; - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - QRadioButton* Constructor2; - QGroupBox* GroupConstructor1; - QLineEdit* LineEditC1A1; - QPushButton* SelectButtonC1A1; - QLabel* TextLabelC1A1; - QLabel* TextLabelC1A2; - // QLineEdit* LineEditC1A2; - QGroupBox* GroupConstructor2; - // QLineEdit* LineEditC2A1; - GeometryGUI_SpinBox* SpinBox_C1A2 ; - GeometryGUI_SpinBox* SpinBox_C2A1 ; - QLabel* TextLabelC2A1; + GeometryGUI_1Sel1Spin* GroupPoints; + GeometryGUI_1Spin* GroupDimensions; private slots: - - void ConstructorsClicked(int constructorId); void ClickOnOk(); - void ClickOnCancel(); void ClickOnApply(); - void LineEditReturnPressed() ; - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void ValueChangedInSpinBox( double newValue ) ; + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked(int constructorId); + void ValueChangedInSpinBox(double newValue); -protected: - QGridLayout* GeometryGUI_SphereDlgLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupConstructor1Layout; - QGridLayout* GroupConstructor2Layout; }; #endif // DIALOGBOX_SPHERE_H diff --git a/src/GEOMGUI/GeometryGUI_TorusDlg.cxx b/src/GEOMGUI/GeometryGUI_TorusDlg.cxx index ce3c12e83..2f521918f 100644 --- a/src/GEOMGUI/GeometryGUI_TorusDlg.cxx +++ b/src/GEOMGUI/GeometryGUI_TorusDlg.cxx @@ -29,29 +29,12 @@ using namespace std; #include "GeometryGUI_TorusDlg.h" -#include "GeometryGUI.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_Config.h" -#include "utilities.h" - +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - +#include "GeometryGUI.h" +#include "QAD_Desktop.h" +#include "QAD_Config.h" //================================================================================= // class : GeometryGUI_TorusDlg() @@ -60,173 +43,42 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GeometryGUI_TorusDlg::GeometryGUI_TorusDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +GeometryGUI_TorusDlg::GeometryGUI_TorusDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + :GeometryGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_TORUS_PV"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); - QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_TORUS_DXYZ"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_TORUS_PV"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_TORUS_DXYZ"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - if ( !name ) - setName( "GeometryGUI_TorusDlg" ); - resize( 303, 219 ); - setCaption( tr( "GEOM_TORUS_TITLE" ) ); - setSizeGripEnabled( TRUE ); - GeometryGUI_TorusDlgLayout = new QGridLayout( this ); - GeometryGUI_TorusDlgLayout->setSpacing( 6 ); - GeometryGUI_TorusDlgLayout->setMargin( 11 ); + setCaption(tr("GEOM_TORUS_TITLE")); - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "GEOM_TORUS" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" ); - Constructor2->setText( tr( "" ) ); - Constructor2->setMinimumSize( QSize( 50, 0 ) ); - Constructor2->setPixmap( image2 ); - Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - GroupConstructorsLayout->addWidget( Constructor2, 0, 2 ); - QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer_2, 0, 2 ); - GeometryGUI_TorusDlgLayout->addWidget( GroupConstructors, 0, 0 ); + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_TORUS")); + RadioButton1->setPixmap(image0); + RadioButton2->setPixmap(image1); + RadioButton3->close(TRUE); - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "GEOM_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "GEOM_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - GeometryGUI_TorusDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupPoints = new GeometryGUI_2Sel2Spin(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_BASE_POINT")); + GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS_I").arg("1")); + GroupPoints->TextLabel4->setText(tr("GEOM_RADIUS_I").arg("2")); + GroupPoints->PushButton1->setPixmap(image2); + GroupPoints->PushButton2->setPixmap(image2); - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + GroupDimensions = new GeometryGUI_2Spin(this, "GroupDimensions"); + GroupDimensions->GroupBox1->setTitle(tr("GEOM_BOX_OBJ")); + GroupDimensions->TextLabel1->setText(tr("GEOM_RADIUS_I").arg("1")); + GroupDimensions->TextLabel2->setText(tr("GEOM_RADIUS_I").arg("2")); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "GEOM_BASE_POINT" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); - SelectButtonC1A2->setText( tr( "" ) ); - SelectButtonC1A2->setPixmap( image1 ); - GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); - LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); - LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); - TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" ); - TextLabelC1A2->setText( tr( "GEOM_VECTOR" ) ); - TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A2->setFrameShape( QLabel::NoFrame ); - TextLabelC1A2->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); - TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" ); - TextLabelC1A3->setText( tr( "GEOM_RADIUS_I" ).arg("1") ); - TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A3->setFrameShape( QLabel::NoFrame ); - TextLabelC1A3->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 ); + Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupDimensions, 1, 0); + /***************************************************************/ - SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ; - SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 ); - - TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" ); - TextLabelC1A4->setText( tr( "GEOM_RADIUS_I" ).arg("2") ); - TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A4->setFrameShape( QLabel::NoFrame ); - TextLabelC1A4->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 ); - - SpinBox_C1A4 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A4" ) ; - SpinBox_C1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A4->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( SpinBox_C1A4, 3, 2 ); - - GeometryGUI_TorusDlgLayout->addWidget( GroupC1, 1, 0 ); - /***************************************************************/ - - GroupC2 = new QGroupBox( this, "GroupC2" ); - GroupC2->setTitle( tr( "GEOM_BOX_OBJ" ) ); - GroupC2->setColumnLayout(0, Qt::Vertical ); - GroupC2->layout()->setSpacing( 0 ); - GroupC2->layout()->setMargin( 0 ); - GroupC2Layout = new QGridLayout( GroupC2->layout() ); - GroupC2Layout->setAlignment( Qt::AlignTop ); - GroupC2Layout->setSpacing( 6 ); - GroupC2Layout->setMargin( 11 ); - TextLabel_Radius1 = new QLabel( GroupC2, "TextLabel_Radius1" ); - TextLabel_Radius1->setText( tr( "GEOM_RADIUS_I" ).arg("1") ); - GroupC2Layout->addWidget( TextLabel_Radius1, 0, 0 ); - TextLabel_Radius2 = new QLabel( GroupC2, "TextLabel_Radius2" ); - TextLabel_Radius2->setText( tr( "GEOM_RADIUS_I" ).arg("2") ); - GroupC2Layout->addWidget( TextLabel_Radius2, 1, 0 ); - - SpinBox_Radius1 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius1" ) ; - GroupC2Layout->addWidget( SpinBox_Radius1, 0, 1 ); - - SpinBox_Radius2 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius2" ) ; - GroupC2Layout->addWidget( SpinBox_Radius2, 1, 1 ); - - QSpacerItem* spacer1 = new QSpacerItem( 20, 62, QSizePolicy::Minimum, QSizePolicy::Fixed ); - GroupC2Layout->addItem( spacer1 ); - GeometryGUI_TorusDlgLayout->addWidget(GroupC2 , 1, 0 ); - - /***************************************************************/ - - /* Initialisations */ - Init(Sel) ; + /* Initialisations */ + myPrimitiveGUI = thePrimitiveGUI; + Init(); } @@ -244,79 +96,59 @@ GeometryGUI_TorusDlg::~GeometryGUI_TorusDlg() // function : Init() // purpose : //================================================================================= -void GeometryGUI_TorusDlg::Init( SALOME_Selection* Sel ) +void GeometryGUI_TorusDlg::Init() { + /* init variables */ + myConstructorId = 0; + myEditCurrentArgument = GroupPoints->LineEdit1; + + myRadius1 = 300.0; + myRadius2 = 100.0; + myOkRadius1 = myOkRadius2 = true; + myOkPoint1 = myOkDir = false; + + myEdgeFilter = new GEOM_EdgeFilter(StdSelect_Line, myGeom); + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + mySelection->AddFilter(myVertexFilter); /* Get setting of step value from file configuration */ - double step ; - QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ; - step = St.toDouble() ; + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); - /* min, max, step and decimals for spin boxes */ - SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; - SpinBox_C1A4->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; - SpinBox_Radius1->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; - SpinBox_Radius2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, step, 3); - GroupC1->show(); - GroupC2->hide(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - myGeomGUI = GeometryGUI::GetGeometryGUI() ; - - SpinBox_C1A3->SetValue( 300.0 ) ; - SpinBox_C1A4->SetValue( 100.0 ) ; - SpinBox_Radius1->SetValue( 300.0 ) ; - SpinBox_Radius2->SetValue( 100.0 ) ; - myRadius1 = 300.0 ; - myRadius2 = 100.0 ; - - myOkRadius1 = true ; - myOkRadius2 = true ; - myOkPoint1 = false ; - myOkDir = false ; - - mySimulationTopoDs.Nullify() ; - myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; - - // TODO : previous selection into argument ? - - /* Filter definitions */ - Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); - myGeom = GEOM::GEOM_Gen::_narrow(comp); - myEdgeFilter = new GEOM_EdgeFilter( StdSelect_Line, myGeom ); - myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom ); - /* first filter used */ - mySelection->AddFilter(myVertexFilter) ; + GroupPoints->SpinBox_DX->SetValue(myRadius1); + GroupPoints->SpinBox_DY->SetValue(myRadius2); + GroupDimensions->SpinBox_DX->SetValue(myRadius1); + GroupDimensions->SpinBox_DY->SetValue(myRadius2); /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); - connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_C1A4, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_Radius1, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_Radius2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + /* displays Dialog */ + GroupDimensions->hide(); + GroupPoints->show(); + this->show(); - connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - /* to close dialog if study change */ - connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - myGeomGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ return ; } @@ -328,51 +160,48 @@ void GeometryGUI_TorusDlg::Init( SALOME_Selection* Sel ) //================================================================================= void GeometryGUI_TorusDlg::ConstructorsClicked(int constructorId) { - mySelection->ClearFilters() ; - myGeomGUI->EraseSimulationShape() ; + myConstructorId = constructorId; + mySelection->ClearFilters(); + myGeomGUI->EraseSimulationShape(); + disconnect(mySelection, 0, this, 0); + myOkRadius1 = myOkRadius2 = true; + myRadius1 = 300.0; + myRadius2 = 100.0; switch(myConstructorId) { case 0 : - { - GroupC1->hide(); - GroupC2->show(); - myConstructorId = constructorId ; - myOkRadius1 = myOkPoint1 = myOkRadius2 = myOkDir = true ; + { + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + myOkPoint1 = myOkDir = false; - SpinBox_C1A3->SetValue( 300.0 ) ; /* radius 1 */ - SpinBox_C1A4->SetValue( 100.0 ) ; /* radius 2 */ - myRadius1 = 300.0 ; - myRadius2 = 100.0 ; + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(tr("")); + GroupPoints->LineEdit2->setText(tr("")); - disconnect( mySelection, 0, this, 0 ); + GroupPoints->SpinBox_DX->SetValue(myRadius1); + GroupPoints->SpinBox_DY->SetValue(myRadius2); - myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ; - myDir.SetCoord( 0.0, 0.0, 1.0 ) ; - - if( myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) { - gp_Dir aDir = myDir ; - - MakeTorusSimulationAndDisplay() ; - } + /* filter for next selection */ + mySelection->AddFilter(myVertexFilter); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break ; } case 1 : - { - GroupC2->hide(); - GroupC1->show(); - myConstructorId = constructorId ; - myEditCurrentArgument = LineEditC1A1 ; - myOkRadius1 = myOkRadius2 = true ; - myOkPoint1 = myOkDir = false ; + { + GroupPoints->hide(); + resize( 0, 0 ); + GroupDimensions->show(); + myOkPoint1 = myOkDir = true; - SpinBox_Radius1->SetValue( 300.0 ) ; - SpinBox_Radius2->SetValue( 100.0 ) ; - myRadius1 = 300.0 ; - myRadius2 = 100.0 ; + GroupDimensions->SpinBox_DX->SetValue(myRadius1); + GroupDimensions->SpinBox_DY->SetValue(myRadius2); + myPoint1.SetCoord(0.0, 0.0, 0.0); + myDir.SetCoord(0.0, 0.0, 1.0); - LineEditC1A1->setText( tr("") ); - disconnect( mySelection, 0, this, 0 ); + MakeTorusSimulationAndDisplay(); break ; } } @@ -380,60 +209,32 @@ void GeometryGUI_TorusDlg::ConstructorsClicked(int constructorId) } +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void GeometryGUI_TorusDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + + //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void GeometryGUI_TorusDlg::ClickOnApply() { - myGeomGUI->GetDesktop()->putInfo( tr("") ) ; - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - switch(myConstructorId) - { - case 0 : - { - if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) { - myGeomGUI->MakeTorusAndDisplay( myPoint1, myDir, myRadius1, myRadius2 ) ; - } - break ; - } - case 1 : - { - if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) { - myGeomGUI->MakeTorusAndDisplay( myPoint1, myDir, myRadius1, myRadius2 ) ; - } - break ; - } - } - // accept(); - return ; -} + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void GeometryGUI_TorusDlg::ClickOnOk() -{ - this->ClickOnApply() ; - this->ClickOnCancel() ; - - return ; -} - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void GeometryGUI_TorusDlg::ClickOnCancel() -{ - mySelection->ClearFilters() ; - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->ResetState() ; - reject() ; + if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) + myPrimitiveGUI->MakeTorusAndDisplay(myPoint1, myDir, myRadius1, myRadius2); return ; } @@ -444,45 +245,39 @@ void GeometryGUI_TorusDlg::ClickOnCancel() //================================================================================= void GeometryGUI_TorusDlg::SelectionIntoArgument() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ - QString aString = ""; /* Name of future selection */ - - int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - if ( nbSel != 1 ) { - if ( myEditCurrentArgument == LineEditC1A1 ) { - LineEditC1A1->setText("") ; - myOkPoint1 = false ; - } - else if ( myEditCurrentArgument == LineEditC1A2 ) { - LineEditC1A2->setText("") ; - myOkDir = false ; - } - return ; + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if (nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkPoint1 = false; + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myOkDir = false; + return; } /* nbSel == 1 */ TopoDS_Shape S; - if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) - return ; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; /* gp_Pnt : not used */ - if ( myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) { - LineEditC1A1->setText(aString) ; - myOkPoint1 = true ; + if (myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + GroupPoints->LineEdit1->setText(aString); + myOkPoint1 = true; } - else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, notUsed, myDir) */) { + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { BRepAdaptor_Curve curv(TopoDS::Edge(S)); myDir = curv.Line().Direction(); - LineEditC1A2->setText(aString) ; - myOkDir = true ; + GroupPoints->LineEdit2->setText(aString); + myOkDir = true; } - if( myConstructorId == 0 && myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) { - MakeTorusSimulationAndDisplay() ; - } - return ; + if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2) + MakeTorusSimulationAndDisplay(); + return; } @@ -492,32 +287,24 @@ void GeometryGUI_TorusDlg::SelectionIntoArgument() //================================================================================= void GeometryGUI_TorusDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters() ; - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; - mySelection->AddFilter(myVertexFilter) ; - } - else if(send == SelectButtonC1A2) { - LineEditC1A2->setFocus() ; - myEditCurrentArgument = LineEditC1A2; - mySelection->AddFilter(myEdgeFilter) ; - } - SelectionIntoArgument() ; - break; - } - case 1: - { - break ; - } - } + if(myConstructorId != 0) + return; - return ; + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + mySelection->AddFilter(myVertexFilter); + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + mySelection->AddFilter(myEdgeFilter); + } + this->SelectionIntoArgument(); + + return; } @@ -528,79 +315,15 @@ void GeometryGUI_TorusDlg::SetEditCurrentArgument() void GeometryGUI_TorusDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if( send == LineEditC1A1 ) - myEditCurrentArgument = LineEditC1A1 ; - else if ( send == LineEditC1A2) - myEditCurrentArgument = LineEditC1A2; + if(send == GroupPoints->LineEdit1) + myEditCurrentArgument = GroupPoints->LineEdit1; + else if (send == GroupPoints->LineEdit2) + myEditCurrentArgument = GroupPoints->LineEdit2; else - return ; - - /* User name of object input management */ - /* If successfull the selection is changed and signal emitted... */ - /* so SelectionIntoArgument() is automatically called. */ - QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ; - const QString objectUserName = LE->text() ; - QWidget* thisWidget = (QWidget*)this ; - if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) { - LE->setText( objectUserName ) ; - } - - return ; -} + return; - -//================================================================================= -// function : ValueChangedInSpinBox -// purpose : -//================================================================================= -void GeometryGUI_TorusDlg::ValueChangedInSpinBox( double newValue ) -{ - QObject* send = (QObject*)sender(); - - if(send == SpinBox_C1A3 ) { - myRadius1 = newValue ; - myOkRadius1 = true ; - } - else if(send == SpinBox_C1A4 ) { - myRadius2 = newValue ; - myOkRadius2 = true ; - } - else if(send == SpinBox_Radius1 ) { - myRadius1 = newValue ; - myOkRadius1 = true ; - } - else if(send == SpinBox_Radius2 ) { - myRadius2 = newValue ; - myOkRadius2 = true ; - } - - if (myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) { - MakeTorusSimulationAndDisplay() ; - } - else { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - } - return ; -} - - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void GeometryGUI_TorusDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupC2->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->EraseSimulationShape() ; - mySelection->ClearFilters() ; - } - return ; + GeometryGUI_Skeleton::LineEditReturnPressed(); + return; } @@ -610,16 +333,11 @@ void GeometryGUI_TorusDlg::DeactivateActiveDialog() //================================================================================= void GeometryGUI_TorusDlg::ActivateThisDialog() { - /* Emit a signal to deactivate the active dialog */ - myGeomGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupC2->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - if( !mySimulationTopoDs.IsNull() ) - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; - return ; + GeometryGUI_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; } @@ -629,22 +347,35 @@ void GeometryGUI_TorusDlg::ActivateThisDialog() //================================================================================= void GeometryGUI_TorusDlg::enterEvent(QEvent* e) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; - return ; + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; } //================================================================================= -// function : closeEvent() +// function : ValueChangedInSpinBox // purpose : //================================================================================= -void GeometryGUI_TorusDlg::closeEvent( QCloseEvent* e ) +void GeometryGUI_TorusDlg::ValueChangedInSpinBox(double newValue) { - /* same than click on cancel button */ - this->ClickOnCancel() ; - return ; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + QObject* send = (QObject*)sender(); + + if(send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DX) { + myRadius1 = newValue; + myOkRadius1 = true; + } + else if(send == GroupPoints->SpinBox_DY || send == GroupDimensions->SpinBox_DY) { + myRadius2 = newValue; + myOkRadius2 = true; + } + + if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2) + MakeTorusSimulationAndDisplay(); + return; } @@ -654,17 +385,16 @@ void GeometryGUI_TorusDlg::closeEvent( QCloseEvent* e ) //================================================================================= void GeometryGUI_TorusDlg::MakeTorusSimulationAndDisplay() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + try { - gp_Ax2 anAxis(this->myPoint1, this->myDir) ; - mySimulationTopoDs = BRepPrimAPI_MakeTorus( anAxis, this->myRadius1, this->myRadius2 ).Shape() ; - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + gp_Ax2 anAxis(this->myPoint1, this->myDir); + mySimulationTopoDs = BRepPrimAPI_MakeTorus(anAxis, this->myRadius1, this->myRadius2).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); } catch(Standard_Failure) { - MESSAGE( "Exception catched in MakeTorusSimulationAndDisplay" ) ; + MESSAGE("Exception catched in MakeTorusSimulationAndDisplay"); } - return ; + return; } - diff --git a/src/GEOMGUI/GeometryGUI_TorusDlg.h b/src/GEOMGUI/GeometryGUI_TorusDlg.h index bae34d8ee..64d9400c4 100644 --- a/src/GEOMGUI/GeometryGUI_TorusDlg.h +++ b/src/GEOMGUI/GeometryGUI_TorusDlg.h @@ -29,120 +29,64 @@ #ifndef DIALOGBOX_TORUS_H #define DIALOGBOX_TORUS_H -#include "SALOME_Selection.h" -#include "GEOM_ShapeTypeFilter.hxx" -#include "GEOM_EdgeFilter.hxx" -#include "GeometryGUI_SpinBox.h" +#include "GeometryGUI_Skeleton.h" +#include "GeometryGUI_2Sel2Spin.h" +#include "GeometryGUI_2Spin.h" + +#include "PrimitiveGUI.h" + +#include "GEOM_EdgeFilter.hxx" -#include -#include #include #include -#include -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; -class QSpinBox ; -class GeometryGUI; - - //================================================================================= // class : GeometryGUI_TorusDlg // purpose : //================================================================================= -class GeometryGUI_TorusDlg : public QDialog +class GeometryGUI_TorusDlg : public GeometryGUI_Skeleton { Q_OBJECT public: - GeometryGUI_TorusDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + GeometryGUI_TorusDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~GeometryGUI_TorusDlg(); private: + void Init(); + void enterEvent(QEvent* e); + void MakeTorusSimulationAndDisplay(); - void Init( SALOME_Selection* Sel ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void MakeTorusSimulationAndDisplay() ; + PrimitiveGUI* myPrimitiveGUI; - GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ - GeometryGUI* myGeomGUI ; /* Current GeomGUI object */ - TopoDS_Shape mySimulationTopoDs ; - SALOME_Selection* mySelection ; /* User shape selection */ + double step; + int myConstructorId; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; + Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ - gp_Pnt myPoint1 ; /* Topology used */ - gp_Dir myDir ; - bool myOkPoint1 ; - bool myOkDir ; /* to check when arguments is defined */ + gp_Pnt myPoint1; /* topology used */ + gp_Dir myDir; + bool myOkPoint1; /* to check when arguments is defined */ + bool myOkDir; - Standard_Real myRadius1 ; - Standard_Real myRadius2 ; - bool myOkRadius1 ; - bool myOkRadius2 ; - QDoubleValidator *myVa ; /* Double validator for numeric input myRadius1 */ - QDoubleValidator *myVb ; /* Double validator for numeric input myRadius2 */ + Standard_Real myRadius1; + Standard_Real myRadius2; + bool myOkRadius1; + bool myOkRadius2; - int myConstructorId ; /* Current constructor id = radio button id */ - QWidget* myEditCurrentArgument; /* Current LineEdit or spin box */ - Handle(GEOM_ShapeTypeFilter) myVertexFilter ; /* Filter selection */ - Handle(GEOM_EdgeFilter) myEdgeFilter ; /* Filter selection */ - - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - QRadioButton* Constructor2; - QGroupBox* GroupC1; - QGroupBox* GroupC2; - QPushButton* SelectButtonC1A1; - QPushButton* SelectButtonC1A2; - QLineEdit* LineEditC1A1; - QLineEdit* LineEditC1A2; - - GeometryGUI_SpinBox* SpinBox_C1A3 ; - GeometryGUI_SpinBox* SpinBox_C1A4 ; - - QLabel* TextLabelC1A1; - QLabel* TextLabelC1A2; - QLabel* TextLabelC1A3; - QLabel* TextLabelC1A4; - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; - - QLabel* TextLabel_Radius1 ; - QLabel* TextLabel_Radius2 ; - GeometryGUI_SpinBox* SpinBox_Radius1 ; - GeometryGUI_SpinBox* SpinBox_Radius2 ; + GeometryGUI_2Sel2Spin* GroupPoints; + GeometryGUI_2Spin* GroupDimensions; private slots: - - void ConstructorsClicked(int constructorId); void ClickOnOk(); - void ClickOnCancel(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void ValueChangedInSpinBox( double newValue ) ; + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked(int constructorId); + void ValueChangedInSpinBox(double newValue); -protected: - QGridLayout* GeometryGUI_TorusDlgLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupC1Layout; - QGridLayout* GroupC2Layout; }; #endif // DIALOGBOX_TORUS_H diff --git a/src/GEOMGUI/Makefile.in b/src/GEOMGUI/Makefile.in index 4e737026d..59c4f2a18 100644 --- a/src/GEOMGUI/Makefile.in +++ b/src/GEOMGUI/Makefile.in @@ -47,6 +47,8 @@ PO_FILES = \ # Libraries targets LIB = libGEOMGUI.la LIB_SRC = GeometryGUI.cxx \ + BooleanGUI.cxx \ + PrimitiveGUI.cxx \ GeometryGUI_SpinBox.cxx \ GeometryGUI_Skeleton_QTD.cxx \ GeometryGUI_Skeleton.cxx \ @@ -58,6 +60,14 @@ LIB_SRC = GeometryGUI.cxx \ GeometryGUI_1Sel4Spin.cxx \ GeometryGUI_2Sel1Spin_QTD.cxx \ GeometryGUI_2Sel1Spin.cxx \ + GeometryGUI_2Sel2Spin_QTD.cxx \ + GeometryGUI_2Sel2Spin.cxx \ + GeometryGUI_2Sel3Spin_QTD.cxx \ + GeometryGUI_2Sel3Spin.cxx \ + GeometryGUI_1Spin_QTD.cxx \ + GeometryGUI_1Spin.cxx \ + GeometryGUI_2Spin_QTD.cxx \ + GeometryGUI_2Spin.cxx \ GeometryGUI_3Spin_QTD.cxx \ GeometryGUI_3Spin.cxx \ GeometryGUI_TransparencyDlg.cxx \ @@ -117,6 +127,8 @@ LIB_SRC = GeometryGUI.cxx \ LIB_MOC = \ GeometryGUI.h \ + BooleanGUI.h \ + PrimitiveGUI.h \ GeometryGUI_SpinBox.h \ GeometryGUI_Skeleton_QTD.h \ GeometryGUI_Skeleton.h \ @@ -128,6 +140,14 @@ LIB_MOC = \ GeometryGUI_1Sel4Spin.h \ GeometryGUI_2Sel1Spin_QTD.h \ GeometryGUI_2Sel1Spin.h \ + GeometryGUI_2Sel2Spin_QTD.h \ + GeometryGUI_2Sel2Spin.h \ + GeometryGUI_2Sel3Spin_QTD.h \ + GeometryGUI_2Sel3Spin.h \ + GeometryGUI_1Spin_QTD.h \ + GeometryGUI_1Spin.h \ + GeometryGUI_2Spin_QTD.h \ + GeometryGUI_2Spin.h \ GeometryGUI_3Spin_QTD.h \ GeometryGUI_3Spin.h \ GeometryGUI_TransparencyDlg.h \ diff --git a/src/GEOMGUI/PrimitiveGUI.cxx b/src/GEOMGUI/PrimitiveGUI.cxx new file mode 100644 index 000000000..ac53ff02a --- /dev/null +++ b/src/GEOMGUI/PrimitiveGUI.cxx @@ -0,0 +1,239 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// 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 +// +// +// +// File : PrimitiveGUI.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "PrimitiveGUI.h" + +#include "QAD_Application.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + +#include "GeometryGUI_BoxDlg.h" // Method BOX +#include "GeometryGUI_CylinderDlg.h" // Method CYLINDER +#include "GeometryGUI_SphereDlg.h" // Method SPHERE +#include "GeometryGUI_TorusDlg.h" // Method TORUS +#include "GeometryGUI_ConeDlg.h" // Method CONE + +//======================================================================= +// function : PrimitiveGUI() +// purpose : Constructor +//======================================================================= +PrimitiveGUI::PrimitiveGUI() : + QObject() +{ + myGeomGUI = GeometryGUI::GetGeometryGUI(); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); +} + + +//======================================================================= +// function : ~PrimitiveGUI() +// purpose : Destructor +//======================================================================= +PrimitiveGUI::~PrimitiveGUI() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool PrimitiveGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + switch (theCommandID) + { + case 3021: // BOX + { + GeometryGUI_BoxDlg *aDlg = new GeometryGUI_BoxDlg(parent, "", this, Sel); + break; + } + case 3022: // CYLINDER + { + GeometryGUI_CylinderDlg *aDlg = new GeometryGUI_CylinderDlg(parent, "", this, Sel); + break; + } + case 3023: // SPHERE + { + GeometryGUI_SphereDlg *aDlg = new GeometryGUI_SphereDlg(parent, "", this, Sel); + break; + } + case 3024: // TORUS + { + GeometryGUI_TorusDlg *aDlg = new GeometryGUI_TorusDlg(parent, "", this, Sel); + break; + } + case 3025: // CONE + { + GeometryGUI_ConeDlg *aDlg = new GeometryGUI_ConeDlg(parent, "", this, 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) +{ + 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(myGeomGUI->Display(box, "")) + myGeomGUI->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()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_CYLINDER")); + if(myGeomGUI->Display(result, "")) + myGeomGUI->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 (myGeomGUI->Display(result, "")) + myGeomGUI->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()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_TORUS")); + if(myGeomGUI->Display(result, "")) + myGeomGUI->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()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_CONE")); + if(myGeomGUI->Display(result, "")) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} diff --git a/src/GEOMGUI/PrimitiveGUI.h b/src/GEOMGUI/PrimitiveGUI.h new file mode 100644 index 000000000..6f1867921 --- /dev/null +++ b/src/GEOMGUI/PrimitiveGUI.h @@ -0,0 +1,65 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// 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 +// +// +// +// File : PrimitiveGUI.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef PRIMITIVEGUI_H +#define PRIMITIVEGUI_H + +#include "GeometryGUI.h" + +#include + +//================================================================================= +// class : PrimitiveGUI +// purpose : +//================================================================================= +class PrimitiveGUI : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + PrimitiveGUI(); + ~PrimitiveGUI(); + + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + + void MakeBoxAndDisplay(const gp_Pnt P1, const gp_Pnt P2); + void MakeCylinderAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, + const double Radius, const double aHeight); + void MakeSphereAndDisplay(const gp_Pnt aCenterPoint, const double aRadius); + void MakeTorusAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, + const double Radius1, const double Radius2); + void MakeConeAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, + const double Radius1, const double Radius2, const double aHeight); + +private: + GeometryGUI* myGeomGUI; + GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + +}; + +#endif