From eb29abbc3342bcad54badcfc0908fe39fd68ee0e Mon Sep 17 00:00:00 2001 From: dcq Date: Tue, 7 Oct 2003 15:51:40 +0000 Subject: [PATCH] DCQ : New Architecture... --- src/BasicGUI/BasicGUI.cxx | 49 +- src/BasicGUI/BasicGUI.h | 4 +- src/BasicGUI/BasicGUI_ArcDlg.cxx | 4 +- src/BasicGUI/BasicGUI_CircleDlg.cxx | 17 +- src/BasicGUI/BasicGUI_CircleDlg.h | 4 +- src/BasicGUI/BasicGUI_EllipseDlg.cxx | 10 +- src/BasicGUI/BasicGUI_EllipseDlg.h | 4 +- src/BasicGUI/BasicGUI_LineDlg.cxx | 47 +- src/BasicGUI/BasicGUI_LineDlg.h | 2 +- src/BasicGUI/BasicGUI_PlaneDlg.cxx | 64 +- src/BasicGUI/BasicGUI_PlaneDlg.h | 4 +- src/BasicGUI/BasicGUI_PointDlg.cxx | 9 +- src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx | 36 +- src/BooleanGUI/BooleanGUI.cxx | 40 +- src/BooleanGUI/BooleanGUI.h | 4 +- src/BuildGUI/BuildGUI.cxx | 315 +++++----- src/BuildGUI/BuildGUI.h | 4 +- src/GEOMBase/GEOMBase_Display.cxx | 47 +- src/GEOMBase/GEOMBase_Tools.cxx | 269 +------- src/GEOMGUI/GeometryGUI.cxx | 285 ++++++--- src/GEOMGUI/GeometryGUI.h | 3 +- src/GEOMGUI/Makefile.in | 2 +- src/GenerationGUI/GenerationGUI.cxx | 37 +- src/GenerationGUI/GenerationGUI.h | 4 +- .../GenerationGUI_FillingDlg.cxx | 4 +- src/GenerationGUI/GenerationGUI_PipeDlg.cxx | 59 +- src/GenerationGUI/GenerationGUI_PipeDlg.h | 1 + src/GenerationGUI/GenerationGUI_PrismDlg.cxx | 44 +- src/GenerationGUI/GenerationGUI_PrismDlg.h | 2 +- src/GenerationGUI/GenerationGUI_RevolDlg.cxx | 564 +++++------------ src/GenerationGUI/GenerationGUI_RevolDlg.h | 96 +-- src/MeasureGUI/MeasureGUI.cxx | 31 +- src/MeasureGUI/MeasureGUI.h | 4 +- src/OperationGUI/OperationGUI.cxx | 45 +- src/OperationGUI/OperationGUI.h | 4 +- src/PrimitiveGUI/PrimitiveGUI.cxx | 39 +- src/PrimitiveGUI/PrimitiveGUI.h | 4 +- src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx | 17 +- src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx | 1 + src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx | 1 + src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx | 1 + src/RepairGUI/RepairGUI.cxx | 45 +- src/RepairGUI/RepairGUI.h | 4 +- src/TransformationGUI/TransformationGUI.cxx | 41 +- src/TransformationGUI/TransformationGUI.h | 5 +- .../TransformationGUI_MirrorDlg.cxx | 535 +++++----------- .../TransformationGUI_MirrorDlg.h | 80 +-- .../TransformationGUI_RotationDlg.cxx | 563 ++++++----------- .../TransformationGUI_RotationDlg.h | 96 +-- .../TransformationGUI_ScaleDlg.cxx | 542 +++++----------- .../TransformationGUI_ScaleDlg.h | 88 +-- .../TransformationGUI_TranslationDlg.cxx | 590 ++++++------------ .../TransformationGUI_TranslationDlg.h | 91 +-- 53 files changed, 1796 insertions(+), 3065 deletions(-) diff --git a/src/BasicGUI/BasicGUI.cxx b/src/BasicGUI/BasicGUI.cxx index 7e919795e..1ad2d92c0 100644 --- a/src/BasicGUI/BasicGUI.cxx +++ b/src/BasicGUI/BasicGUI.cxx @@ -42,6 +42,8 @@ using namespace std; #include "BasicGUI_PlaneDlg.h" // Method PLANE #include "BasicGUI_WorkingPlaneDlg.h" // Method WORKING PLANE +static BasicGUI* myBasicGUI = 0; + //======================================================================= // function : BasicGUI() // purpose : Constructor @@ -64,60 +66,73 @@ BasicGUI::~BasicGUI() } +//======================================================================= +// function : GetOrCreateGUI() +// purpose : Gets or create an object 'GUI' with initialisations +// : Returns 'GUI' as a pointer +//======================================================================= +BasicGUI* BasicGUI::GetOrCreateGUI() +{ + myBasicGUI = new BasicGUI(); + return myBasicGUI; +} + + //======================================================================= // function : OnGUIEvent() // purpose : //======================================================================= bool BasicGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + BasicGUI::GetOrCreateGUI(); + myBasicGUI->myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myBasicGUI->myGeomGUI->GetActiveStudy()->getSelection()); switch (theCommandID) { case 4011: // POINT { Handle(AIS_InteractiveContext) ic; - if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + if(myBasicGUI->myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myBasicGUI->myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); ic = v3d->getAISContext(); } - BasicGUI_PointDlg *aDlg = new BasicGUI_PointDlg(parent, "", this, Sel, ic); + BasicGUI_PointDlg *aDlg = new BasicGUI_PointDlg(parent, "", myBasicGUI, Sel, ic); break; } case 4012: // LINE { - BasicGUI_LineDlg *aDlg = new BasicGUI_LineDlg(parent, "", this, Sel); + BasicGUI_LineDlg *aDlg = new BasicGUI_LineDlg(parent, "", myBasicGUI, Sel); break; } case 4013: // CIRCLE { - BasicGUI_CircleDlg *aDlg = new BasicGUI_CircleDlg(parent, "", this, Sel); + BasicGUI_CircleDlg *aDlg = new BasicGUI_CircleDlg(parent, "", myBasicGUI, Sel); break; } case 4014: // ELLIPSE { - BasicGUI_EllipseDlg *aDlg = new BasicGUI_EllipseDlg(parent, "", this, Sel); + BasicGUI_EllipseDlg *aDlg = new BasicGUI_EllipseDlg(parent, "", myBasicGUI, Sel); break; } case 4015: // ARC { - BasicGUI_ArcDlg *aDlg = new BasicGUI_ArcDlg(parent, "", this, Sel); + BasicGUI_ArcDlg *aDlg = new BasicGUI_ArcDlg(parent, "", myBasicGUI, Sel); break ; } case 4016: // VECTOR { - BasicGUI_VectorDlg *aDlg = new BasicGUI_VectorDlg(parent, "", this, Sel); + BasicGUI_VectorDlg *aDlg = new BasicGUI_VectorDlg(parent, "", myBasicGUI, Sel); break; } case 4017: // PLANE { - BasicGUI_PlaneDlg *aDlg = new BasicGUI_PlaneDlg(parent, "", this, Sel); + BasicGUI_PlaneDlg *aDlg = new BasicGUI_PlaneDlg(parent, "", myBasicGUI, Sel); break; } case 4018: // WORKING PLANE { - BasicGUI_WorkingPlaneDlg *aDlg = new BasicGUI_WorkingPlaneDlg(parent, "", this, Sel); + BasicGUI_WorkingPlaneDlg *aDlg = new BasicGUI_WorkingPlaneDlg(parent, "", myBasicGUI, Sel); break; } default: @@ -350,3 +365,13 @@ void BasicGUI::MakeWorkingPlane(const gp_Pnt P, const gp_Dir D) myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); return; } + + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + {return BasicGUI::OnGUIEvent(theCommandID, parent);} +} diff --git a/src/BasicGUI/BasicGUI.h b/src/BasicGUI/BasicGUI.h index 2d2ec910e..b0b364133 100644 --- a/src/BasicGUI/BasicGUI.h +++ b/src/BasicGUI/BasicGUI.h @@ -44,7 +44,8 @@ public : BasicGUI(); ~BasicGUI(); - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + static BasicGUI* GetOrCreateGUI(); + static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); void MakePointAndDisplay(const double x, const double y, const double z); void MakeLineAndDisplay(const gp_Pnt InitPoint, const gp_Pnt LastPoint); @@ -57,7 +58,6 @@ public : const Standard_Real dz, const Standard_Real TrimSize); void MakeWorkingPlane(const gp_Pnt P, const gp_Dir D); -private: GEOMBase_Context* myGeomGUI; GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ diff --git a/src/BasicGUI/BasicGUI_ArcDlg.cxx b/src/BasicGUI/BasicGUI_ArcDlg.cxx index db7c5f1db..31ad800ca 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.cxx +++ b/src/BasicGUI/BasicGUI_ArcDlg.cxx @@ -155,6 +155,7 @@ void BasicGUI_ArcDlg::ClickOnApply() void BasicGUI_ArcDlg::SelectionIntoArgument() { myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); QString aString = ""; /* name of selection */ @@ -200,6 +201,7 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() void BasicGUI_ArcDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters(); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); @@ -274,7 +276,7 @@ void BasicGUI_ArcDlg::enterEvent(QEvent* e) //================================================================================= void BasicGUI_ArcDlg::MakeArcSimulationAndDisplay() { - myGeomGUI->EraseSimulationShape(); + myGeomGUI->EraseSimulationShape(); mySimulationTopoDs.Nullify(); try { diff --git a/src/BasicGUI/BasicGUI_CircleDlg.cxx b/src/BasicGUI/BasicGUI_CircleDlg.cxx index a26fd00dd..c3a40c60f 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.cxx +++ b/src/BasicGUI/BasicGUI_CircleDlg.cxx @@ -92,7 +92,7 @@ void BasicGUI_CircleDlg::Init() myRadius = 100.0; myOkPoint1 = myOkDir = false; - myEdgeFilter = new GEOM_EdgeFilter(StdSelect_Line, myGeom); + myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); mySelection->AddFilter(myVertexFilter); @@ -152,6 +152,7 @@ void BasicGUI_CircleDlg::ClickOnApply() if(myOkPoint1 && myOkDir) myBasicGUI->MakeCircleAndDisplay(myPoint1, myDir, myRadius); + return; } @@ -162,6 +163,7 @@ void BasicGUI_CircleDlg::ClickOnApply() void BasicGUI_CircleDlg::SelectionIntoArgument() { myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); QString aString = ""; /* name of selection */ @@ -184,7 +186,7 @@ void BasicGUI_CircleDlg::SelectionIntoArgument() GroupPoints->LineEdit1->setText(aString); myOkPoint1 = true; } - else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + else if(myEditCurrentArgument == GroupPoints->LineEdit2) { BRepAdaptor_Curve curv(TopoDS::Edge(S)); myDir = curv.Line().Direction(); GroupPoints->LineEdit2->setText(aString); @@ -204,6 +206,7 @@ void BasicGUI_CircleDlg::SelectionIntoArgument() void BasicGUI_CircleDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters(); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); @@ -259,7 +262,7 @@ void BasicGUI_CircleDlg::ActivateThisDialog() //================================================================================= void BasicGUI_CircleDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) + if(GroupConstructors->isEnabled()) return; this->ActivateThisDialog(); return; @@ -270,14 +273,10 @@ void BasicGUI_CircleDlg::enterEvent(QEvent* e) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void BasicGUI_CircleDlg::ValueChangedInSpinBox( double newValue ) +void BasicGUI_CircleDlg::ValueChangedInSpinBox(double newValue) { - myGeomGUI->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - myRadius = newValue; - - if (myOkPoint1 && myOkDir) + if(myOkPoint1 && myOkDir) MakeCircleSimulationAndDisplay(); return; } diff --git a/src/BasicGUI/BasicGUI_CircleDlg.h b/src/BasicGUI/BasicGUI_CircleDlg.h index 070d0a6ef..ac7188394 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.h +++ b/src/BasicGUI/BasicGUI_CircleDlg.h @@ -34,8 +34,6 @@ #include "BasicGUI.h" -#include "GEOM_EdgeFilter.hxx" - #include //================================================================================= @@ -59,7 +57,7 @@ private : double step; Handle(GEOM_ShapeTypeFilter) myVertexFilter; - Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ + Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filter selection */ gp_Pnt myPoint1; gp_Dir myDir; diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.cxx b/src/BasicGUI/BasicGUI_EllipseDlg.cxx index 88646a656..136947355 100644 --- a/src/BasicGUI/BasicGUI_EllipseDlg.cxx +++ b/src/BasicGUI/BasicGUI_EllipseDlg.cxx @@ -95,7 +95,7 @@ void BasicGUI_EllipseDlg::Init() myMinorRadius = 100.0; myOkPoint = myOkDir = false; - myEdgeFilter = new GEOM_EdgeFilter(StdSelect_Line, myGeom); + myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); mySelection->AddFilter(myVertexFilter); @@ -169,7 +169,8 @@ void BasicGUI_EllipseDlg::ClickOnApply() //================================================================================= void BasicGUI_EllipseDlg::SelectionIntoArgument() { - myGeomGUI->EraseSimulationShape(); + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); QString aString = ""; /* name of selection */ @@ -212,6 +213,7 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument() void BasicGUI_EllipseDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters(); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); @@ -278,10 +280,8 @@ void BasicGUI_EllipseDlg::enterEvent(QEvent* e) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void BasicGUI_EllipseDlg::ValueChangedInSpinBox( double newValue ) +void BasicGUI_EllipseDlg::ValueChangedInSpinBox(double newValue) { - myGeomGUI->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); QObject* send = (QObject*)sender(); if(send == GroupPoints->SpinBox_DX ) diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.h b/src/BasicGUI/BasicGUI_EllipseDlg.h index 166685b65..c68bf1fe1 100644 --- a/src/BasicGUI/BasicGUI_EllipseDlg.h +++ b/src/BasicGUI/BasicGUI_EllipseDlg.h @@ -33,8 +33,6 @@ #include "BasicGUI.h" -#include "GEOM_EdgeFilter.hxx" - #include //================================================================================= @@ -58,7 +56,7 @@ private : double step; Handle(GEOM_ShapeTypeFilter) myVertexFilter; - Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ + Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filter selection */ gp_Pnt myPoint; /* Central point of ellipse */ bool myOkPoint; /* true when myPoint is defined */ diff --git a/src/BasicGUI/BasicGUI_LineDlg.cxx b/src/BasicGUI/BasicGUI_LineDlg.cxx index b071dca73..2b2025389 100644 --- a/src/BasicGUI/BasicGUI_LineDlg.cxx +++ b/src/BasicGUI/BasicGUI_LineDlg.cxx @@ -153,6 +153,7 @@ void BasicGUI_LineDlg::ClickOnApply() void BasicGUI_LineDlg::SelectionIntoArgument() { myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); QString aString = ""; /* name of selection */ @@ -179,12 +180,8 @@ void BasicGUI_LineDlg::SelectionIntoArgument() myOkPoint2 = true; } - if(myOkPoint1 && myOkPoint2 && myPoint1.Distance(myPoint2) > Precision::Confusion() ) { - mySimulationTopoDs = BRepBuilderAPI_MakeEdge(myPoint1, myPoint2).Shape(); - /* Try to add an arrow at simulation shape */ - bool notNeedToTest = this->AddArrowToSimulation(mySimulationTopoDs); - myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); - } + if(myOkPoint1 && myOkPoint2 && myPoint1.Distance(myPoint2) > Precision::Confusion()) + this->MakeLineSimulationAndDisplay(); return; } @@ -196,6 +193,7 @@ void BasicGUI_LineDlg::SelectionIntoArgument() void BasicGUI_LineDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters(); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); @@ -251,7 +249,7 @@ void BasicGUI_LineDlg::ActivateThisDialog() //================================================================================= void BasicGUI_LineDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) + if(GroupConstructors->isEnabled()) return; this->ActivateThisDialog(); return; @@ -259,23 +257,32 @@ void BasicGUI_LineDlg::enterEvent(QEvent* e) //================================================================================= -// function : AddArrowToSimulation() +// function : MakeLineSimulationAndDisplay() // purpose : An arrow (cone topology) is added to 'modifiedShape' // : to simulate a vector or an 'oriented line' display. The result is in 'modifiedShape'. // : If an arrow can't be added returns false and 'modifiedShape' isn't modified ! //================================================================================= -bool BasicGUI_LineDlg::AddArrowToSimulation(TopoDS_Shape& modifiedShape) +void BasicGUI_LineDlg::MakeLineSimulationAndDisplay() { - TopoDS_Shape arrow; - /* Try to add a cone simulation shape to show direction of a linear edge */ - if(myGeomGUI->CreateArrowForLinearEdge(modifiedShape, arrow)) { - TopoDS_Compound Comp; - BRep_Builder B; - B.MakeCompound (Comp); - B.Add(Comp, modifiedShape); - B.Add(Comp, arrow); - modifiedShape = Comp; - return true; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + try { + mySimulationTopoDs = BRepBuilderAPI_MakeEdge(myPoint1, myPoint2).Shape(); + TopoDS_Shape arrow; + if(myGeomGUI->CreateArrowForLinearEdge(mySimulationTopoDs, arrow)) { + TopoDS_Compound Comp; + BRep_Builder B; + B.MakeCompound (Comp); + B.Add(Comp, mySimulationTopoDs); + B.Add(Comp, arrow); + mySimulationTopoDs = Comp; + } + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); } - return false; + catch(Standard_Failure) { + MESSAGE("Exception catched in MakeLineSimulationAndDisplay"); + return; + } + return; } diff --git a/src/BasicGUI/BasicGUI_LineDlg.h b/src/BasicGUI/BasicGUI_LineDlg.h index 3f09f339f..44bfb65fa 100644 --- a/src/BasicGUI/BasicGUI_LineDlg.h +++ b/src/BasicGUI/BasicGUI_LineDlg.h @@ -49,7 +49,7 @@ public: private : void Init(); void enterEvent(QEvent* e); - bool AddArrowToSimulation(TopoDS_Shape& modifiedShape); + void MakeLineSimulationAndDisplay(); BasicGUI* myBasicGUI; Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filter selection */ diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.cxx b/src/BasicGUI/BasicGUI_PlaneDlg.cxx index d026949ff..ddd8a4d9c 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_PlaneDlg.cxx @@ -194,6 +194,7 @@ void BasicGUI_PlaneDlg::ConstructorsClicked(int constructorId) myConstructorId = constructorId; mySelection->ClearFilters(); myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); myOkPoint1 = myOkDirection = myOkCoordinates = myOkPlanarFace = false; @@ -366,7 +367,7 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() myGeomGUI->GetBipointDxDyDz(Pfirst, Plast, myDx, myDy, myDz); GroupPointDirection->LineEdit2->setText(aString); myOkDirection = true; - this->myTrimSize = GroupPointDirection->SpinBox_DX->GetValue(); + myTrimSize = GroupPointDirection->SpinBox_DX->GetValue(); } } @@ -377,7 +378,7 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() myDx = GroupPointPlusCoordinates->SpinBox_DX->GetValue(); myDy = GroupPointPlusCoordinates->SpinBox_DY->GetValue(); myDz = GroupPointPlusCoordinates->SpinBox_DZ->GetValue(); - this->myTrimSize = GroupPointPlusCoordinates->SpinBox_S->GetValue(); + myTrimSize = GroupPointPlusCoordinates->SpinBox_S->GetValue(); myOkPoint1 = true; myOkCoordinates = true; } @@ -394,14 +395,14 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() myDx = (ax.Direction()).X(); myDy = (ax.Direction()).Y(); myDz = (ax.Direction()).Z(); - this->myTrimSize = GroupFace->SpinBox_DX->GetValue(); + myTrimSize = GroupFace->SpinBox_DX->GetValue(); } } /* Call method simulation */ if((myOkPoint1 && myOkDirection) || (myOkPoint1 && myOkCoordinates) || myOkPlanarFace) { if(myDx*myDx + myDy*myDy + myDz*myDz > Precision::Confusion()*Precision::Confusion()) - MakePlaneSimulationAndDisplay(myPoint1, myDx, myDy, myDz, myTrimSize) ; + this->MakePlaneSimulationAndDisplay(); } return; } @@ -414,7 +415,7 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() void BasicGUI_PlaneDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters() ; + mySelection->ClearFilters(); switch (myConstructorId) { @@ -430,7 +431,6 @@ void BasicGUI_PlaneDlg::SetEditCurrentArgument() myEditCurrentArgument = GroupPointDirection->LineEdit2; /* Edge filter here */ mySelection->AddFilter(myEdgeFilter); - SelectionIntoArgument(); } break; } @@ -441,7 +441,6 @@ void BasicGUI_PlaneDlg::SetEditCurrentArgument() myEditCurrentArgument = GroupPointPlusCoordinates->LineEdit1; /* Vertex filter here */ mySelection->AddFilter(myVertexFilter); - SelectionIntoArgument(); } break; } @@ -452,12 +451,12 @@ void BasicGUI_PlaneDlg::SetEditCurrentArgument() myEditCurrentArgument = GroupFace->LineEdit1; /* Face filter here */ mySelection->AddFilter(myFaceFilter); - SelectionIntoArgument(); } break; } } - return ; + this->SelectionIntoArgument(); + return; } @@ -515,35 +514,26 @@ void BasicGUI_PlaneDlg::enterEvent(QEvent* e) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void BasicGUI_PlaneDlg::ValueChangedInSpinBox( double newValue ) +void BasicGUI_PlaneDlg::ValueChangedInSpinBox(double newValue) { - myGeomGUI->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - QObject* send = (QObject*)sender() ; + QObject* send = (QObject*)sender(); - if(send == GroupPointPlusCoordinates->SpinBox_DX) { + if(send == GroupPointPlusCoordinates->SpinBox_DX) myDx = newValue; - myDy = GroupPointPlusCoordinates->SpinBox_DY->GetValue(); - myDz = GroupPointPlusCoordinates->SpinBox_DZ->GetValue(); - } else if(send == GroupPointPlusCoordinates->SpinBox_DY) { - myDx = GroupPointPlusCoordinates->SpinBox_DX->GetValue(); + else if(send == GroupPointPlusCoordinates->SpinBox_DY) myDy = newValue; - myDz = GroupPointPlusCoordinates->SpinBox_DZ->GetValue(); - } else if(send == GroupPointPlusCoordinates->SpinBox_DZ) { - myDx = GroupPointPlusCoordinates->SpinBox_DX->GetValue(); - myDy = GroupPointPlusCoordinates->SpinBox_DY->GetValue(); + else if(send == GroupPointPlusCoordinates->SpinBox_DZ) myDz = newValue; - } else if(send == GroupPointDirection->SpinBox_DX || send == GroupPointPlusCoordinates->SpinBox_S || send == GroupFace->SpinBox_DX) { + else if(send == GroupPointDirection->SpinBox_DX || send == GroupPointPlusCoordinates->SpinBox_S || send == GroupFace->SpinBox_DX) { myTrimSize = newValue; } else return; if((myOkPoint1 && myOkDirection) || (myOkPoint1 && myOkCoordinates) || myOkPlanarFace) { - if (myDx*myDx + myDy*myDy + myDz*myDz > Precision::Confusion() * Precision::Confusion()) - MakePlaneSimulationAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize); + if(myDx*myDx + myDy*myDy + myDz*myDz > Precision::Confusion() * Precision::Confusion()) + this->MakePlaneSimulationAndDisplay(); } - - return ; + return; } @@ -551,23 +541,21 @@ void BasicGUI_PlaneDlg::ValueChangedInSpinBox( double newValue ) // function : MakePlaneSimulationAndDisplay(() // purpose : //================================================================================= -void BasicGUI_PlaneDlg::MakePlaneSimulationAndDisplay(const gp_Pnt& P1, - const Standard_Real dx, - const Standard_Real dy, - const Standard_Real dz, - const Standard_Real trimsize) +void BasicGUI_PlaneDlg::MakePlaneSimulationAndDisplay() { + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + try { - gp_Dir aDirection(dx, dy, dz); + gp_Dir aDirection(myDx, myDy, myDz); /* We make a trimmed plane */ - gp_Pln gplane(P1, aDirection); - mySimulationTopoDs = BRepBuilderAPI_MakeFace(gplane, -trimsize, +trimsize, -trimsize, +trimsize); + gp_Pln gplane(myPoint1, aDirection); + mySimulationTopoDs = BRepBuilderAPI_MakeFace(gplane, -myTrimSize, +myTrimSize, -myTrimSize, +myTrimSize); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); } catch(Standard_Failure) { MESSAGE( "Exception catched in MakePlaneSimulation" << endl ); return; } - - myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); - return ; + return; } diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.h b/src/BasicGUI/BasicGUI_PlaneDlg.h index cd5a08a25..22610cea9 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.h +++ b/src/BasicGUI/BasicGUI_PlaneDlg.h @@ -53,6 +53,7 @@ public: private : void Init(); void enterEvent(QEvent* e); + void MakePlaneSimulationAndDisplay(); BasicGUI* myBasicGUI; @@ -87,9 +88,6 @@ private slots: void SetEditCurrentArgument(); void ConstructorsClicked(int constructorId); void ValueChangedInSpinBox(double newValue); - void MakePlaneSimulationAndDisplay(const gp_Pnt& P, const Standard_Real dx, - const Standard_Real dy, const Standard_Real dz, - const Standard_Real trimSize); }; diff --git a/src/BasicGUI/BasicGUI_PointDlg.cxx b/src/BasicGUI/BasicGUI_PointDlg.cxx index c339d3043..5dce1c54b 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.cxx +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -181,6 +181,7 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) myConstructorId = constructorId; mySelection->ClearFilters(); myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); disconnect(mySelection, 0, this, 0); switch (constructorId) @@ -300,6 +301,7 @@ void BasicGUI_PointDlg::ClickOnApply() void BasicGUI_PointDlg::SelectionIntoArgument() { myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); QString aString = ""; /* name of selection */ @@ -350,9 +352,6 @@ void BasicGUI_PointDlg::LineEditReturnPressed() //================================================================================= void BasicGUI_PointDlg::SetEditCurrentArgument() { - if(myConstructorId != 0) - return; - QPushButton* send = (QPushButton*)sender(); if(send == GroupPoints->PushButton1) { @@ -411,11 +410,9 @@ void BasicGUI_PointDlg::ActivateThisDialog( ) //================================================================================= void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue) { - myGeomGUI->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - DlgRef_SpinBox* send = (DlgRef_SpinBox*)sender(); double vx, vy, vz; + if(send == GroupDimensions->SpinBox_DX) { vx = newValue; vy = GroupDimensions->SpinBox_DY->GetValue(); diff --git a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx index 59be8750e..80bfe990f 100644 --- a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx @@ -128,7 +128,6 @@ void BasicGUI_WorkingPlaneDlg::ClickOnOk() void BasicGUI_WorkingPlaneDlg::ClickOnApply() { myGeomGUI->GetDesktop()->putInfo(tr("")); - mySelection->ClearFilters(); if(myOkPlane) myBasicGUI->MakeWorkingPlane(myLoc, myDir); @@ -147,8 +146,7 @@ void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument() int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); if(nbSel != 1) { - if(myEditCurrentArgument == GroupWPlane->LineEdit1) - myOkPlane = false; + myOkPlane = false; return; } @@ -157,15 +155,13 @@ void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument() if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) return; - if(myEditCurrentArgument == GroupWPlane->LineEdit1) { - BRepAdaptor_Surface surf(TopoDS::Face(S)); - gp_Pln Plane = surf.Plane(); - myLoc = Plane.Location(); - myDir = Plane.Axis().Direction(); - - GroupWPlane->LineEdit1->setText(aString); - myOkPlane = true; - } + BRepAdaptor_Surface surf(TopoDS::Face(S)); + gp_Pln Plane = surf.Plane(); + myLoc = Plane.Location(); + myDir = Plane.Axis().Direction(); + + GroupWPlane->LineEdit1->setText(aString); + myOkPlane = true; /* no simulation */ return; @@ -178,14 +174,8 @@ void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument() //================================================================================= void BasicGUI_WorkingPlaneDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupWPlane->PushButton1) { - GroupWPlane->LineEdit1->setFocus(); - myEditCurrentArgument = GroupWPlane->LineEdit1; - mySelection->AddFilter(myFaceFilter); - SelectionIntoArgument(); - } + GroupWPlane->LineEdit1->setFocus(); + this->SelectionIntoArgument(); return; } @@ -196,12 +186,6 @@ void BasicGUI_WorkingPlaneDlg::SetEditCurrentArgument() //================================================================================= void BasicGUI_WorkingPlaneDlg::LineEditReturnPressed() { - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupWPlane->LineEdit1) - myEditCurrentArgument = GroupWPlane->LineEdit1; - else - return; - GEOMBase_Skeleton::LineEditReturnPressed(); return; } diff --git a/src/BooleanGUI/BooleanGUI.cxx b/src/BooleanGUI/BooleanGUI.cxx index 1af21f9d9..8f7325437 100644 --- a/src/BooleanGUI/BooleanGUI.cxx +++ b/src/BooleanGUI/BooleanGUI.cxx @@ -29,14 +29,13 @@ using namespace std; #include "BooleanGUI.h" -#include "QAD_Application.h" -#include "SALOMEGUI_QtCatchCorbaException.hxx" - #include "BooleanGUI_FuseDlg.h" // Method FUSE #include "BooleanGUI_CommonDlg.h" // Method COMMON #include "BooleanGUI_CutDlg.h" // Method CUT #include "BooleanGUI_SectionDlg.h" // Method SECTION +static BooleanGUI* myBooleanGUI = 0; + //======================================================================= // function : BooleanGUI() // purpose : Constructor @@ -59,35 +58,48 @@ BooleanGUI::~BooleanGUI() } +//======================================================================= +// function : GetOrCreateGUI() +// purpose : Gets or create an object 'GUI' with initialisations +// : Returns 'GUI' as a pointer +//======================================================================= +BooleanGUI* BooleanGUI::GetOrCreateGUI() +{ + myBooleanGUI = new BooleanGUI(); + return myBooleanGUI; +} + + //======================================================================= // function : OnGUIEvent() // purpose : //======================================================================= bool BooleanGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + BooleanGUI::GetOrCreateGUI(); + myBooleanGUI->myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myBooleanGUI->myGeomGUI->GetActiveStudy()->getSelection()); switch (theCommandID) { case 5011: // FUSE { - BooleanGUI_FuseDlg *aDlg = new BooleanGUI_FuseDlg(parent, "", this, Sel); + BooleanGUI_FuseDlg *aDlg = new BooleanGUI_FuseDlg(parent, "", myBooleanGUI, Sel); break; } case 5012: // COMMON { - BooleanGUI_CommonDlg *aDlg = new BooleanGUI_CommonDlg(parent, "", this, Sel); + BooleanGUI_CommonDlg *aDlg = new BooleanGUI_CommonDlg(parent, "", myBooleanGUI, Sel); break; } case 5013: // CUT { - BooleanGUI_CutDlg *aDlg = new BooleanGUI_CutDlg(parent, "", this, Sel); + BooleanGUI_CutDlg *aDlg = new BooleanGUI_CutDlg(parent, "", myBooleanGUI, Sel); break; } case 5014: // SECTION { - BooleanGUI_SectionDlg *aDlg = new BooleanGUI_SectionDlg(parent, "", this, Sel); + BooleanGUI_SectionDlg *aDlg = new BooleanGUI_SectionDlg(parent, "", myBooleanGUI, Sel); break; } default: @@ -126,3 +138,13 @@ void BooleanGUI::MakeBooleanAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_S } return; } + + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + {return BooleanGUI::OnGUIEvent(theCommandID, parent);} +} diff --git a/src/BooleanGUI/BooleanGUI.h b/src/BooleanGUI/BooleanGUI.h index 77b7b5f15..4bc246f7e 100644 --- a/src/BooleanGUI/BooleanGUI.h +++ b/src/BooleanGUI/BooleanGUI.h @@ -43,13 +43,13 @@ public : BooleanGUI(); ~BooleanGUI(); - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + static BooleanGUI* GetOrCreateGUI(); + static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); void MakeBooleanAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2, const short operation); -private: GEOMBase_Context* myGeomGUI; GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ diff --git a/src/BuildGUI/BuildGUI.cxx b/src/BuildGUI/BuildGUI.cxx index 08824e2b6..6e7344d45 100644 --- a/src/BuildGUI/BuildGUI.cxx +++ b/src/BuildGUI/BuildGUI.cxx @@ -47,6 +47,8 @@ using namespace std; #include "BuildGUI_SolidDlg.h" // Method SOLID #include "BuildGUI_CompoundDlg.h" // Method COMPOUND +static BuildGUI* myBuildGUI = 0; + //======================================================================= // function : BuildGUI() // purpose : Constructor @@ -69,52 +71,68 @@ BuildGUI::~BuildGUI() } +//======================================================================= +// function : GetOrCreateGUI() +// purpose : Gets or create an object 'GUI' with initialisations +// : Returns 'GUI' as a pointer +//======================================================================= +BuildGUI* BuildGUI::GetOrCreateGUI() +{ + myBuildGUI = new BuildGUI(); + return myBuildGUI; +} + + //======================================================================= // function : OnGUIEvent() // purpose : //======================================================================= bool BuildGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + BuildGUI::GetOrCreateGUI(); + myBuildGUI->myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myBuildGUI->myGeomGUI->GetActiveStudy()->getSelection()); switch (theCommandID) { case 407: // EXPLODE : use ic { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - BuildGUI_SubShapeDlg *aDlg = new BuildGUI_SubShapeDlg(parent, "", this, Sel, ic); + Handle(AIS_InteractiveContext) ic; + if(myBuildGUI->myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myBuildGUI->myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + ic = v3d->getAISContext(); + } + BuildGUI_SubShapeDlg *aDlg = new BuildGUI_SubShapeDlg(parent, "", myBuildGUI, Sel, ic); break ; } case 4081: // GEOM::EDGE { - BuildGUI_EdgeDlg *aDlg = new BuildGUI_EdgeDlg(parent, "", this, Sel); + BuildGUI_EdgeDlg *aDlg = new BuildGUI_EdgeDlg(parent, "", myBuildGUI, Sel); break; } case 4082: // GEOM::WIRE { - BuildGUI_WireDlg *aDlg = new BuildGUI_WireDlg(parent, "", this, Sel); + BuildGUI_WireDlg *aDlg = new BuildGUI_WireDlg(parent, "", myBuildGUI, Sel); break; } case 4083: // GEOM::FACE { - BuildGUI_FaceDlg *aDlg = new BuildGUI_FaceDlg(parent, "", this, Sel); + BuildGUI_FaceDlg *aDlg = new BuildGUI_FaceDlg(parent, "", myBuildGUI, Sel); break; } case 4084: // GEOM::SHELL { - BuildGUI_ShellDlg *aDlg = new BuildGUI_ShellDlg(parent, "", this, Sel); + BuildGUI_ShellDlg *aDlg = new BuildGUI_ShellDlg(parent, "", myBuildGUI, Sel); break; } case 4085: // GEOM::SOLID { - BuildGUI_SolidDlg *aDlg = new BuildGUI_SolidDlg(parent, "", this, Sel); + BuildGUI_SolidDlg *aDlg = new BuildGUI_SolidDlg(parent, "", myBuildGUI, Sel); break; } case 4086: // GEOM::COMPOUND { - BuildGUI_CompoundDlg *aDlg = new BuildGUI_CompoundDlg(parent, "", this, Sel); + BuildGUI_CompoundDlg *aDlg = new BuildGUI_CompoundDlg(parent, "", myBuildGUI, Sel); break; } default: @@ -370,58 +388,59 @@ bool BuildGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Shape anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap"); aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - MESSAGE( " Type " << S.ShapeType() ) - if ( S.ShapeType() == TopAbs_COMPOUND ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" ); - } else if ( S.ShapeType() == TopAbs_COMPSOLID ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" ); - } else if ( S.ShapeType() == TopAbs_SOLID ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" ); - } else if ( S.ShapeType() == TopAbs_SHELL ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" ); - } else if ( S.ShapeType() == TopAbs_FACE ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" ); - } else if ( S.ShapeType() == TopAbs_WIRE ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" ); - } else if ( S.ShapeType() == TopAbs_EDGE ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" ); - } else if ( S.ShapeType() == TopAbs_VERTEX ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" ); - } - - MESSAGE ( " aPixmap->GetPixMap " << aPixmap->GetPixMap() ) + MESSAGE(" Type " << S.ShapeType()) + if (S.ShapeType() == TopAbs_COMPOUND) + aPixmap->SetPixMap("ICON_OBJBROWSER_COMPOUND"); + else if(S.ShapeType() == TopAbs_COMPSOLID) + aPixmap->SetPixMap("ICON_OBJBROWSER_COMPSOLID"); + else if(S.ShapeType() == TopAbs_SOLID) + aPixmap->SetPixMap("ICON_OBJBROWSER_SOLID"); + else if(S.ShapeType() == TopAbs_SHELL) + aPixmap->SetPixMap("ICON_OBJBROWSER_SHELL"); + else if(S.ShapeType() == TopAbs_FACE) + aPixmap->SetPixMap("ICON_OBJBROWSER_FACE"); + else if(S.ShapeType() == TopAbs_WIRE) + aPixmap->SetPixMap("ICON_OBJBROWSER_WIRE"); + else if(S.ShapeType() == TopAbs_EDGE) + aPixmap->SetPixMap("ICON_OBJBROWSER_EDGE"); + else if(S.ShapeType() == TopAbs_VERTEX) + aPixmap->SetPixMap("ICON_OBJBROWSER_VERTEX"); + + MESSAGE(" aPixmap->GetPixMap " << aPixmap->GetPixMap()) SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); aStudyBuilder->Addreference(newObj1, newObj); IO->setEntry(newObj->GetID()); - aResult->StudyShapeId( newObj->GetID() ); - } else { + aResult->StudyShapeId(newObj->GetID()); + } + else { allreadyexist = true; - if ( !myGeomGUI->SObjectExist(theObj, aResult->Name()) ) { + if(!myGeomGUI->SObjectExist(theObj, aResult->Name())) { SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj); aStudyBuilder->Addreference(newObj1, SO); IO->setEntry(SO->GetID()); - aResult->StudyShapeId( SO->GetID() ); + aResult->StudyShapeId(SO->GetID()); } } - result->setIO( IO ); - result->setName( nameG ); - if ( !allreadyexist ) + result->setIO(IO); + result->setName(nameG); + if(!allreadyexist) ic->Display(result); - } else if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + } + else if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); int themode = myRenderInter->GetDisplayMode(); vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(),"GEOM"); + Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM"); - if ( SO->_is_nil() ) { - SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj ); + if(SO->_is_nil()) { + SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(theObj); anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); anIOR->SetValue(aResult->Name()); @@ -431,45 +450,44 @@ bool BuildGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Shape anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap"); aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - if ( S.ShapeType() == TopAbs_COMPOUND ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" ); - } else if ( S.ShapeType() == TopAbs_COMPSOLID ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" ); - } else if ( S.ShapeType() == TopAbs_SOLID ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" ); - } else if ( S.ShapeType() == TopAbs_SHELL ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" ); - } else if ( S.ShapeType() == TopAbs_FACE ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" ); - } else if ( S.ShapeType() == TopAbs_WIRE ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" ); - } else if ( S.ShapeType() == TopAbs_EDGE ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" ); - } else if ( S.ShapeType() == TopAbs_VERTEX ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" ); - } + if(S.ShapeType() == TopAbs_COMPOUND) + aPixmap->SetPixMap("ICON_OBJBROWSER_COMPOUND"); + else if(S.ShapeType() == TopAbs_COMPSOLID) + aPixmap->SetPixMap("ICON_OBJBROWSER_COMPSOLID"); + else if(S.ShapeType() == TopAbs_SOLID) + aPixmap->SetPixMap("ICON_OBJBROWSER_SOLID"); + else if(S.ShapeType() == TopAbs_SHELL) + aPixmap->SetPixMap("ICON_OBJBROWSER_SHELL"); + else if(S.ShapeType() == TopAbs_FACE) + aPixmap->SetPixMap("ICON_OBJBROWSER_FACE"); + else if(S.ShapeType() == TopAbs_WIRE) + aPixmap->SetPixMap("ICON_OBJBROWSER_WIRE"); + else if(S.ShapeType() == TopAbs_EDGE) + aPixmap->SetPixMap("ICON_OBJBROWSER_EDGE"); + else if(S.ShapeType() == TopAbs_VERTEX) + aPixmap->SetPixMap("ICON_OBJBROWSER_VERTEX"); SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); aStudyBuilder->Addreference(newObj1, newObj); IO->setEntry(newObj->GetID()); - } else { + } + else { allreadyexist = true; - if ( !myGeomGUI->SObjectExist(theObj, aResult->Name()) ) { + if(!myGeomGUI->SObjectExist(theObj, aResult->Name())) { SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj); aStudyBuilder->Addreference(newObj1, SO); IO->setEntry(SO->GetID()); } } - if ( !allreadyexist ) { - vtkActorCollection* theActors = - GEOM_AssemblyBuilder::BuildActors(S,0,themode,Standard_True); + if(!allreadyexist) { + vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(S,0,themode,Standard_True); theActors->InitTraversal(); vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); while(!(anActor==NULL)) { - GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor ); - GActor->setIO( IO ); - GActor->setName( nameG ); + GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor); + GActor->setIO(IO); + GActor->setName(nameG); theRenderer->AddActor(GActor); renWin->Render(); anActor = (vtkActor*)theActors->GetNextActor(); @@ -480,10 +498,10 @@ bool BuildGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Shape /* commit transaction */ op->finish(); - + myGeomGUI->GetActiveStudy()->updateObjBrowser(); myGeomGUI->GetDesktop()->putInfo (tr("GEOM_PRP_READY")); - return true ; + return true; } @@ -491,27 +509,21 @@ bool BuildGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Shape // function : OnSubShapeGetSelected() // purpose : //===================================================================================== -bool BuildGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo, - const char* ShapeTopoIOR, - const int SubShapeType, - Standard_Integer& aLocalContextId, - bool& myUseLocalContext ) +bool BuildGUI::OnSubShapeGetSelected(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType, Standard_Integer& aLocalContextId, bool& myUseLocalContext) { //* Test the type of viewer */ - if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) return false; - } - SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR ); - if ( theObj->_is_nil() ) { + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(ShapeTopoIOR); + if(theObj->_is_nil()) { myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); - return false ; + return false; } - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); if( myUseLocalContext == false ) { /* local context is from DialogBox */ @@ -524,12 +536,13 @@ bool BuildGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo, TopoDS_Shape mainShape; bool main = false; - while ( !main ) { - if ( aShape->IsMainShape() ) { + while(!main) { + if(aShape->IsMainShape()) { mainShape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); main = true; - } else - aShape = myGeom->GetIORFromString( aShape->MainName() ); + } + else + aShape = myGeom->GetIORFromString(aShape->MainName()); } GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; @@ -540,85 +553,85 @@ bool BuildGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo, TopoDS_Compound compound; ic->InitSelected(); /* to init again */ BRep_Builder B; - B.MakeCompound( compound ); + B.MakeCompound(compound); int i = 0; /* We create a unique compound containing all the sub shapes selected by user as attribute of the main shape */ /* the compound is homogenous by selection */ while(ic->MoreSelected()) { - int index = myGeomGUI->GetIndex( ic->SelectedShape(), mainShape, SubShapeType ); - ListOfID[i] = index ; - B.Add( compound, ic->SelectedShape() ); + int index = myGeomGUI->GetIndex(ic->SelectedShape(), mainShape, SubShapeType); + ListOfID[i] = index; + B.Add(compound, ic->SelectedShape()); i++; ic->NextSelected(); } /* Test if user has selected sub shapes */ - if( ListOfID->length() < 1 ) - return false ; + if(ListOfID->length() < 1) + return false; - GEOM::GEOM_Shape_var aResult ; + GEOM::GEOM_Shape_var aResult; try { - aResult = myGeom->SubShape( aShape, SubShapeType, ListOfID ); + aResult = myGeom->SubShape(aShape, SubShapeType, ListOfID); } catch (const SALOME::SALOME_Exception& S_ex) { QtCatchCorbaException(S_ex); } /* local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId) ; + ic->CloseLocalContext(aLocalContextId); myUseLocalContext = false ; - char* nameG = (char *)malloc(20); + char* nameG = (char *)malloc(20); Standard_CString Type; Handle(GEOM_AISShape) result; - Handle(GEOM_InteractiveObject) IO ; - - // if ( !myGeomGUI->SObjectExist(theObj, aResult->Name()) ) { - if ( nbSelected == 1 ) { - TopExp_Explorer Exp ( compound, TopAbs_ShapeEnum(SubShapeType) ); - if ( Exp.More() ) { - if ( myGeomGUI->GetShapeTypeString(Exp.Current(),Type) ) { - aResult->NameType( Type ); - sprintf (nameG, "%s_%d", Type, myGeomGUI->GetIndex( Exp.Current(), mainTopo, SubShapeType ) ); - } else { - aResult->NameType( tr("GEOM_SHAPE") ); - sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->GetNbGeom()++ ); + Handle(GEOM_InteractiveObject) IO; + + if(nbSelected == 1) { + TopExp_Explorer Exp (compound, TopAbs_ShapeEnum(SubShapeType)); + if(Exp.More()) { + if(myGeomGUI->GetShapeTypeString(Exp.Current(),Type)) { + aResult->NameType(Type); + sprintf (nameG, "%s_%d", Type, myGeomGUI->GetIndex( Exp.Current(), mainTopo, SubShapeType)); + } + else { + aResult->NameType(tr("GEOM_SHAPE")); + sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->GetNbGeom()++); } - result = new GEOM_AISShape( Exp.Current(), nameG ); + result = new GEOM_AISShape(Exp.Current(), nameG); IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM"); } } else { - if ( myGeomGUI->GetShapeTypeString(compound,Type) ) { - aResult->NameType( Type ); - sprintf (nameG, "%s_%d", Type, myGeomGUI->GetNbGeom()++ ); + if ( myGeomGUI->GetShapeTypeString(compound,Type)) { + aResult->NameType(Type); + sprintf (nameG, "%s_%d", Type, myGeomGUI->GetNbGeom()++); } else { - aResult->NameType( tr("GEOM_SHAPE") ); - sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->GetNbGeom()++ ); + aResult->NameType(tr("GEOM_SHAPE")); + sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->GetNbGeom()++); } - result = new GEOM_AISShape( compound, nameG ); + result = new GEOM_AISShape(compound, nameG); IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM"); } - SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() ); + SALOMEDS::SObject_var SO = aStudy->FindObjectIOR(aResult->Name()); /* open transaction */ - QAD_Operation* op = new SALOMEGUI_ImportOperation( myGeomGUI->GetActiveStudy() ); + QAD_Operation* op = new SALOMEGUI_ImportOperation(myGeomGUI->GetActiveStudy()); op->start(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->entry()); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->entry()); SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - SALOMEDS::AttributePixMap_var aPixmap; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributePixMap_var aPixmap; bool allreadyexist = false; - if ( SO->_is_nil() ) { - SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj ); + if(SO->_is_nil()) { + SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(theObj); anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); anIOR->SetValue(aResult->Name()); @@ -628,32 +641,32 @@ bool BuildGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo, anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap"); aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - if ( result->Shape().ShapeType() == TopAbs_COMPOUND ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" ); - } else if ( result->Shape().ShapeType() == TopAbs_COMPSOLID ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" ); - } else if ( result->Shape().ShapeType() == TopAbs_SOLID ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" ); - } else if ( result->Shape().ShapeType() == TopAbs_SHELL ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" ); - } else if ( result->Shape().ShapeType() == TopAbs_FACE ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" ); - } else if ( result->Shape().ShapeType() == TopAbs_WIRE ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" ); - } else if ( result->Shape().ShapeType() == TopAbs_EDGE ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" ); - } else if ( result->Shape().ShapeType() == TopAbs_VERTEX ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" ); - } + if(result->Shape().ShapeType() == TopAbs_COMPOUND) + aPixmap->SetPixMap("ICON_OBJBROWSER_COMPOUND"); + else if(result->Shape().ShapeType() == TopAbs_COMPSOLID) + aPixmap->SetPixMap("ICON_OBJBROWSER_COMPSOLID"); + else if(result->Shape().ShapeType() == TopAbs_SOLID) + aPixmap->SetPixMap("ICON_OBJBROWSER_SOLID"); + else if(result->Shape().ShapeType() == TopAbs_SHELL) + aPixmap->SetPixMap("ICON_OBJBROWSER_SHELL"); + else if(result->Shape().ShapeType() == TopAbs_FACE) + aPixmap->SetPixMap("ICON_OBJBROWSER_FACE"); + else if(result->Shape().ShapeType() == TopAbs_WIRE) + aPixmap->SetPixMap("ICON_OBJBROWSER_WIRE"); + else if(result->Shape().ShapeType() == TopAbs_EDGE) + aPixmap->SetPixMap("ICON_OBJBROWSER_EDGE"); + else if(result->Shape().ShapeType() == TopAbs_VERTEX) + aPixmap->SetPixMap("ICON_OBJBROWSER_VERTEX"); SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); aStudyBuilder->Addreference(newObj1, newObj); IO->setEntry(newObj->GetID()); aResult->StudyShapeId(newObj->GetID()); - } else { + } + else { allreadyexist = true; - if ( !myGeomGUI->SObjectExist(theObj, aResult->Name()) ) { + if(!myGeomGUI->SObjectExist(theObj, aResult->Name())) { SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj); aStudyBuilder->Addreference(newObj1, SO); @@ -665,10 +678,10 @@ bool BuildGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo, /* commit transaction */ op->finish(); - result->setIO( IO ); - result->setName( nameG ); + result->setIO(IO); + result->setName(nameG); - if ( !allreadyexist ) + if(!allreadyexist) ic->Display(result); GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); @@ -678,3 +691,13 @@ bool BuildGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo, myGeomGUI->GetDesktop()->putInfo (tr("GEOM_PRP_READY")); return true; } + + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + {return BuildGUI::OnGUIEvent(theCommandID, parent);} +} diff --git a/src/BuildGUI/BuildGUI.h b/src/BuildGUI/BuildGUI.h index 444619eaf..881e1aa7f 100644 --- a/src/BuildGUI/BuildGUI.h +++ b/src/BuildGUI/BuildGUI.h @@ -43,7 +43,8 @@ public : BuildGUI(); ~BuildGUI(); - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + static BuildGUI* GetOrCreateGUI(); + static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); void MakeLinearEdgeAndDisplay(const gp_Pnt P1, const gp_Pnt P2); void MakeWireAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); @@ -57,7 +58,6 @@ public : bool OnSubShapeGetSelected(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType, Standard_Integer& aLocalContextId, bool& myUseLocalContext); -private: GEOMBase_Context* myGeomGUI; GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ diff --git a/src/GEOMBase/GEOMBase_Display.cxx b/src/GEOMBase/GEOMBase_Display.cxx index 653849a7a..81d8948f7 100644 --- a/src/GEOMBase/GEOMBase_Display.cxx +++ b/src/GEOMBase/GEOMBase_Display.cxx @@ -69,7 +69,7 @@ bool GEOMBase_Display::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { switch (theCommandID) { - case 211: // SHADING/WIREFRAME - MENU + case 211: // MENU VIEW - WIREFRAME/SHADING { if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { QApplication::setOverrideCursor(waitCursor); @@ -121,7 +121,7 @@ bool GEOMBase_Display::OnGUIEvent(int theCommandID, QAD_Desktop* parent) } break; } - case 212: // DISPLAY ALL - MENU + case 212: // MENU VIEW - DISPLAY ALL { if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->DisplayAll(); @@ -129,7 +129,15 @@ bool GEOMBase_Display::OnGUIEvent(int theCommandID, QAD_Desktop* parent) this->OnDisplayAll(); break; } - case 214: // ERASE ALL - MENU + case 213: // MENU VIEW - DISPLAY ONLY + { + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) + this->OnVTKDisplayOnly(); + else if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) + this->OnDisplayOnly(); + break; + } + case 214: // MENU VIEW - ERASE ALL { if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->EraseAll(); @@ -142,7 +150,12 @@ bool GEOMBase_Display::OnGUIEvent(int theCommandID, QAD_Desktop* parent) } break; } - case 8021: // WIREFRAME/SHADING - POPUP VIEWER + case 215: // MENU VIEW - ERASE ONLY + { + this->OnErase(); + break; + } + case 8031: // POPUP VIEWER - WIREFRAME/SHADING { if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { // VTK @@ -184,32 +197,6 @@ bool GEOMBase_Display::OnGUIEvent(int theCommandID, QAD_Desktop* parent) QApplication::restoreOverrideCursor(); break; } - case 8022 : // ERASE - POPUP VIEWER - { - this->OnErase(); - break; - } - case 8023: // DISPLAY ONLY - POPUP VIEWER - { - if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) - this->OnVTKDisplayOnly(); - else if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) - this->OnDisplayOnly(); - break; - } - case 9022 : // ERASE - OBJBROSER POPUP - { - this->OnErase(); - break; - } - case 9023 : // DISPLAY ONLY - OBJBROSER POPUP - { - if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) - this->OnVTKDisplayOnly(); - else if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) - this->OnDisplayOnly(); - break; - } default: { parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); diff --git a/src/GEOMBase/GEOMBase_Tools.cxx b/src/GEOMBase/GEOMBase_Tools.cxx index 11bae7c38..e5bfda64b 100644 --- a/src/GEOMBase/GEOMBase_Tools.cxx +++ b/src/GEOMBase/GEOMBase_Tools.cxx @@ -37,7 +37,6 @@ using namespace std; #include "OCCViewer_Viewer3d.h" #include "VTKViewer_ViewFrame.h" -#include "GEOM_AssemblyBuilder.h" #include "SALOME_ListIteratorOfListIO.hxx" #include "SALOMEGUI_NameDlg.h" @@ -85,10 +84,6 @@ bool GEOMBase_Tools::OnGUIEvent(int theCommandID, QAD_Desktop* parent) SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); switch (theCommandID) { @@ -171,23 +166,24 @@ bool GEOMBase_Tools::OnGUIEvent(int theCommandID, QAD_Desktop* parent) if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) break; + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + 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 { + } + else { Quantity_Color Default = Quantity_Color(); - color = QColor ((int)Default.Red() * 255.0, - (int)Default.Green()* 255.0, - (int)Default.Blue() * 255.0); + color = QColor ((int)Default.Red() * 255.0, (int)Default.Green()* 255.0, (int)Default.Blue() * 255.0); } QColor c = QColorDialog::getColor(color, myGeomGUI->GetDesktop()); if(c.isValid()) { - myGeomGUI->GetShadingColor() = Quantity_Color(c.red() / 255.0, c.green() / 255.0, - c.blue() / 255.0, Quantity_TOC_RGB); + myGeomGUI->GetShadingColor() = Quantity_Color(c.red() / 255.0, c.green() / 255.0, c.blue() / 255.0, Quantity_TOC_RGB); AIS_ListOfInteractive List; ic->DisplayedObjects(List); @@ -218,6 +214,9 @@ bool GEOMBase_Tools::OnGUIEvent(int theCommandID, QAD_Desktop* parent) if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) break; + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->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()) @@ -324,239 +323,6 @@ bool GEOMBase_Tools::OnGUIEvent(int theCommandID, QAD_Desktop* parent) } } break; - } - case 903: // DISPLAY OBJECT BROWSER - { - if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - // VTK - QApplication::setOverrideCursor(Qt::waitCursor); - - SALOMEDS::SObject_var fatherSF = - aStudy->FindObjectID(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->entry()); - - 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*)myGeomGUI->GetActiveStudy()->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 = aStudy->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 = myGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom,aShape); - - if (obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->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(myGeomGUI->GetActiveStudy()); - 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(), myGeomGUI->GetFatherior(),"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(); - } - } - } - } - } - myGeomGUI->GetActiveStudy()->updateObjBrowser(true); - QApplication::restoreOverrideCursor(); - - } else if (myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - QApplication::setOverrideCursor( Qt::waitCursor ); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - - SALOMEDS::SObject_var fatherSF = - aStudy->FindObjectID(myGeomGUI->GetActiveStudy()->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 = myGeomGUI->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 = aStudy->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 = myGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom,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(myGeomGUI->GetActiveStudy()); - 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(myGeomGUI->GetShadingColor()); - Handle(GEOM_InteractiveObject) IO = - new GEOM_InteractiveObject(anIOR->Value(), myGeomGUI->GetFatherior(), "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(); - } - } - } - } - } - myGeomGUI->GetActiveStudy()->updateObjBrowser(true); - QApplication::restoreOverrideCursor(); - } - break; } case 5103: // CHECK GEOMETRY { @@ -596,10 +362,7 @@ bool GEOMBase_Tools::OnGUIEvent(int theCommandID, QAD_Desktop* parent) Quantity_Color CSFColor; Shape->Color(CSFColor); - QColor c = QColorDialog::getColor(QColor(CSFColor.Red() * 255.0, - CSFColor.Green()* 255.0, - CSFColor.Blue() * 255.0), - myGeomGUI->GetDesktop()); + QColor c = QColorDialog::getColor(QColor(CSFColor.Red() * 255.0, CSFColor.Green()* 255.0, CSFColor.Blue() * 255.0), myGeomGUI->GetDesktop()); if(c.isValid()) { CSFColor = Quantity_Color (c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB); @@ -623,6 +386,12 @@ bool GEOMBase_Tools::OnGUIEvent(int theCommandID, QAD_Desktop* parent) } case 8033: // TRANSPARENCY - POPUP VIEWER { + OCCViewer_Viewer3d* v3d; + Handle(AIS_InteractiveContext) ic; + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + } GEOMBase_TransparencyDlg *aDlg = new GEOMBase_TransparencyDlg(parent, "", Sel, ic); break; } @@ -631,6 +400,9 @@ bool GEOMBase_Tools::OnGUIEvent(int theCommandID, QAD_Desktop* parent) if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) break; + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + ic->InitCurrent(); if(ic->MoreCurrent()) { Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); @@ -701,6 +473,7 @@ bool GEOMBase_Tools::OnGUIEvent(int theCommandID, QAD_Desktop* parent) Engines::Component_var comp = myGeomGUI->GetDesktop()->getEngine("FactoryServer","GEOM"); if (!CORBA::is_nil(comp)) { SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); aStudyBuilder->LoadWith(aStudy->FindComponent("GEOM"),driver); } else { diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 50aaa8818..c103087d9 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -34,10 +34,13 @@ using namespace std; #include #include #include +#include // SALOME Includes #include "QAD_RightFrame.h" #include "QAD_Resource.h" +#include "QAD_Tools.h" +#include "QAD_Config.h" #include "OCCViewer_ViewPort.h" #include "OCCViewer_ViewPort3d.h" @@ -50,19 +53,11 @@ using namespace std; #include "GEOMBase_Tools.h" #include "GEOMBase_Sketcher.h" -#include "BasicGUI.h" -#include "BasicGUI_PointDlg.h" -#include "PrimitiveGUI.h" -#include "GenerationGUI.h" -#include "BuildGUI.h" -#include "BooleanGUI.h" -#include "TransformationGUI.h" -#include "OperationGUI.h" -#include "RepairGUI.h" -#include "MeasureGUI.h" +// #include "BasicGUI_PointDlg.h" /* The object itself created in the static method 'GetOrCreateGEOMBase()' */ static GEOMBase_Context* GeomGUI = 0; +typedef bool OneDim(int, QAD_Desktop*); //======================================================================= // class : CustomItem @@ -125,6 +120,50 @@ GEOMBase_Context* GeometryGUI::GetOrCreateGeometryGUI(QAD_Desktop* desktop) } +//======================================================================= +// function : OnGUIEvent() [static] +// purpose : manage all events on GUI +//======================================================================= +bool GeometryGUI::LoadLibrary(int theCommandID, QAD_Desktop* parent, QString GUILibrary) +{ + QCString libs; + QFileInfo fileInfo; + QString GUILib, fileString, dir; + + OSD_SharedLibrary myGUILibrary = OSD_SharedLibrary(); + + if(libs = getenv("LD_LIBRARY_PATH")) { + QStringList dirList = QStringList::split(":", libs, false); // skip empty entries + for(int i = dirList.count()-1; i >= 0; i--) { + dir = dirList[i]; + fileString = QAD_Tools::addSlash(dir) + GUILibrary; + fileInfo.setFile(fileString); + if(fileInfo.exists()) { + GUILib = fileInfo.fileName(); + break; + } + } + } + + myGUILibrary.SetName(TCollection_AsciiString((char*)GUILib.latin1()).ToCString()); + bool ok = myGUILibrary.DlOpen(OSD_RTLD_LAZY); + if(!ok) { + return false; + } + + OSD_Function osdF = myGUILibrary.DlSymb("OnGUIEvent"); + OneDim (*f1) = NULL; + if(osdF != NULL) { + f1 = (bool (*) (int, QAD_Desktop*)) osdF; + (*f1)(theCommandID, parent); + } + else + return false; + + return true; +} + + //======================================================================= // function : OnGUIEvent() [static] // purpose : manage all events on GUI @@ -156,94 +195,142 @@ bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) if (GeomGUI->GetState() == CURRENT_SKETCH && theCommandID != 404 && theCommandID != 4041 && theCommandID != 4042 && theCommandID != 4043 && theCommandID != 4044 && theCommandID != 4045 && theCommandID != 4046 && theCommandID != 4047 && theCommandID != 4048 && theCommandID != 4051 && theCommandID != 4052 && theCommandID != 4053 && theCommandID != 4061 && theCommandID != 4062 && theCommandID != 4063 && theCommandID != 4064 && theCommandID != 4065) return false; - +// cout<<"GeometryGUI::OnGUIEvent : theCommandID = "<OnGUIEvent(theCommandID, parent); return true; } - if(theCommandID == 404 || theCommandID == 4041 || theCommandID == 4042 || - theCommandID == 4043 || theCommandID == 4044 || theCommandID == 4045 || - theCommandID == 4046 || theCommandID == 4047 || theCommandID == 4048 || - theCommandID == 4051 || theCommandID == 4052 || theCommandID == 4053 || - theCommandID == 4061 || theCommandID == 4062 || theCommandID == 4063 || - theCommandID == 4064 || theCommandID == 4065) { - GEOMBase_Sketcher* mySketcherGUI = new GEOMBase_Sketcher(); - mySketcherGUI->OnGUIEvent(theCommandID, parent); - return true; - } - if(theCommandID == 211 || theCommandID == 212 || theCommandID == 214 || - theCommandID == 8021 || theCommandID == 8022 || theCommandID == 8023 || - theCommandID == 9022 || theCommandID == 9023) { + if(theCommandID == 211 || // MENU VIEW - WIREFRAME/SHADING + theCommandID == 212 || // MENU VIEW - DISPLAY ALL + theCommandID == 213 || // MENU VIEW - DISPLAY ONLY + theCommandID == 214 || // MENU VIEW - ERASE ALL + theCommandID == 215 || // MENU VIEW - ERASE ONLY + theCommandID == 8031) { // POPUP VIEWER - WIREFRAME/SHADING + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); myDisplayGUI->OnGUIEvent(theCommandID, parent); return true; } - if(theCommandID == 4011 || theCommandID == 4012 || theCommandID == 4013 || - theCommandID == 4014 || theCommandID == 4015 || theCommandID == 4016 || - theCommandID == 4017 || theCommandID == 4018) { - BasicGUI* myBasicGUI = new BasicGUI(); - myBasicGUI->OnGUIEvent(theCommandID, parent); + if(theCommandID == 404 || // SKETCHER + theCommandID == 4041 || // SKETCHER - POPUP VIEWER - SEGMENT + theCommandID == 4042 || // SKETCHER - POPUP VIEWER - ARC + theCommandID == 4043 || // SKETCHER - POPUP VIEWER - SET ANGLE + theCommandID == 4044 || // SKETCHER - POPUP VIEWER - SET X + theCommandID == 4045 || // SKETCHER - POPUP VIEWER - SET Y + theCommandID == 4046 || // SKETCHER - POPUP VIEWER - DELETE + theCommandID == 4047 || // SKETCHER - POPUP VIEWER - END + theCommandID == 4048 || // SKETCHER - POPUP VIEWER - CLOSE + theCommandID == 4051 || // SKETCHER - MENU - SET PLANE + theCommandID == 4052 || // SKETCHER - MENU - TANGENT + theCommandID == 4053 || // SKETCHER - MENU - PERPENDICULAR + theCommandID == 4061 || // SKETCHER - MENU - LENGTH + theCommandID == 4062 || // SKETCHER - MENU - ANGLE + theCommandID == 4063 || // SKETCHER - MENU - RADIUS + theCommandID == 4064 || // SKETCHER - MENU - X + theCommandID == 4065) { // SKETCHER - MENU - Y + GEOMBase_Sketcher* mySketcherGUI = new GEOMBase_Sketcher(); + mySketcherGUI->OnGUIEvent(theCommandID, parent); return true; } - if(theCommandID == 4021 || theCommandID == 4022 || theCommandID == 4023 || - theCommandID == 4024 || theCommandID == 4025) { - PrimitiveGUI* myPrimitiveGUI = new PrimitiveGUI(); - myPrimitiveGUI->OnGUIEvent(theCommandID, parent); - return true; + if(theCommandID == 4011 || // MENU BASIC - POINT + theCommandID == 4012 || // MENU BASIC - LINE + theCommandID == 4013 || // MENU BASIC - CIRCLE + theCommandID == 4014 || // MENU BASIC - ELLIPSE + theCommandID == 4015 || // MENU BASIC - ARC + theCommandID == 4016 || // MENU BASIC - VECTOR + theCommandID == 4017 || // MENU BASIC - PLANE + theCommandID == 4018) { // MENU BASIC - WPLANE + bool testlib = GeometryGUI::LoadLibrary(theCommandID, parent, "libBasicGUI.so"); + return testlib; } - if(theCommandID == 4031 || theCommandID == 4032 || - theCommandID == 4033 || theCommandID == 4034) { - GenerationGUI* myGenerationGUI = new GenerationGUI(); - myGenerationGUI->OnGUIEvent(theCommandID, parent); - return true; + if(theCommandID == 4021 || // MENU PRIMITIVE - BOX + theCommandID == 4022 || // MENU PRIMITIVE - CYLINDER + theCommandID == 4023 || // MENU PRIMITIVE - SPHERE + theCommandID == 4024 || // MENU PRIMITIVE - TORUS + theCommandID == 4025) { // MENU PRIMITIVE - CONE + bool testlib = GeometryGUI::LoadLibrary(theCommandID, parent, "libPrimitiveGUI.so"); + return testlib; } - if(theCommandID == 407 || theCommandID == 4081 || theCommandID == 4082 || - theCommandID == 4083 || theCommandID == 4084 || theCommandID == 4085 || - theCommandID == 4086) { - BuildGUI* myBuildGUI = new BuildGUI(); - myBuildGUI->OnGUIEvent(theCommandID, parent); - return true; + if(theCommandID == 4031 || // MENU GENERATION - PRISM + theCommandID == 4032 || // MENU GENERATION - REVOLUTION + theCommandID == 4033 || // MENU GENERATION - FILLING + theCommandID == 4034) { // MENU GENERATION - PIPE + bool testlib = GeometryGUI::LoadLibrary(theCommandID, parent, "libGenerationGUI.so"); + return testlib; } - if(theCommandID == 5011 || theCommandID == 5012 || - theCommandID == 5013 || theCommandID == 5014) { - BooleanGUI* myBooleanGUI = new BooleanGUI(); - myBooleanGUI->OnGUIEvent(theCommandID, parent); - return true; + if(theCommandID == 407 || // MENU BUILD - EXPLODE + theCommandID == 4081 || // MENU BUILD - EDGE + theCommandID == 4082 || // MENU BUILD - WIRE + theCommandID == 4083 || // MENU BUILD - FACE + theCommandID == 4084 || // MENU BUILD - SHELL + theCommandID == 4085 || // MENU BUILD - SOLID + theCommandID == 4086) { // MENU BUILD - COMPUND + bool testlib = GeometryGUI::LoadLibrary(theCommandID, parent, "libBuildGUI.so"); + return testlib; } - if(theCommandID == 5021 || theCommandID == 5022 || theCommandID == 5023 || - theCommandID == 5024 || theCommandID == 5025 || theCommandID == 5026) { - TransformationGUI* myTransformationGUI = new TransformationGUI(); - myTransformationGUI->OnGUIEvent(theCommandID, parent); - return true; + if(theCommandID == 5011 || // MENU BOOLEAN - FUSE + theCommandID == 5012 || // MENU BOOLEAN - COMMON + theCommandID == 5013 || // MENU BOOLEAN - CUT + theCommandID == 5014) { // MENU BOOLEAN - SECTION + bool testlib = GeometryGUI::LoadLibrary(theCommandID, parent, "libBooleanGUI.so"); + return testlib; } - if(theCommandID == 503 || theCommandID == 504 || - theCommandID == 505 || theCommandID == 506) { - OperationGUI* myOperationGUI = new OperationGUI(); - myOperationGUI->OnGUIEvent(theCommandID, parent); - return true; + if(theCommandID == 5021 || // MENU TRANSFORMATION - TRANSLATION + theCommandID == 5022 || // MENU TRANSFORMATION - ROTATION + theCommandID == 5023 || // MENU TRANSFORMATION - MIRROR + theCommandID == 5024 || // MENU TRANSFORMATION - SCALE + theCommandID == 5025 || // MENU TRANSFORMATION - MULTI-TRANSLATION + theCommandID == 5026) { // MENU TRANSFORMATION - MULTI-ROTATION + bool testlib = GeometryGUI::LoadLibrary(theCommandID, parent, "libTransformationGUI.so"); + return testlib; } - if(theCommandID == 601 || theCommandID == 602 || - theCommandID == 603 || theCommandID == 604) { - RepairGUI* myRepairGUI = new RepairGUI(); - myRepairGUI->OnGUIEvent(theCommandID, parent); - return true; + if(theCommandID == 503 || // MENU OPERATION - PARTITION + theCommandID == 504 || // MENU OPERATION - ARCHIMEDE + theCommandID == 505 || // MENU OPERATION - FILLET + theCommandID == 506) { // MENU OPERATION - CHAMFER + bool testlib = GeometryGUI::LoadLibrary(theCommandID, parent, "libOperationGUI.so"); + return testlib; } - if(theCommandID == 701 || theCommandID == 702 || theCommandID == 703 || - theCommandID == 7041 || theCommandID == 7042 || - theCommandID == 705 || theCommandID == 706 || theCommandID == 707) { - MeasureGUI* myMeasureGUI = new MeasureGUI(); - myMeasureGUI->OnGUIEvent(theCommandID, parent); - return true; + if(theCommandID == 601 || // MENU REPAIR - SEWING + theCommandID == 602 || // MENU REPAIR - ORIENTATION + theCommandID == 603 || // MENU REPAIR - SUPPRESS FACES + theCommandID == 604) { // MENU REPAIR - SUPPRESS HOLE + bool testlib = GeometryGUI::LoadLibrary(theCommandID, parent, "libRepairGUI.so"); + return testlib; + } + if(theCommandID == 701 || // MENU MEASURE - PROPERTIES + theCommandID == 702 || // MENU MEASURE - CDG + theCommandID == 703 || // MENU MEASURE - INERTIA + theCommandID == 7041 || // MENU MEASURE - BOUNDING BOX + theCommandID == 7042 || // MENU MEASURE - MIN DISTANCE + theCommandID == 705 || // MENU MEASURE - TOLERANCE + theCommandID == 706 || // MENU MEASURE - WHATIS + theCommandID == 707) { // MENU MEASURE - CHECK + bool testlib = GeometryGUI::LoadLibrary(theCommandID, parent, "libMeasureGUI.so"); + return testlib; } return true; } @@ -291,28 +378,28 @@ bool GeometryGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFr } } else if(GeomGUI->GetState() == POINT_METHOD) { - GeomGUI->EraseSimulationShape(); - BasicGUI_PointDlg *DialogPt = (BasicGUI_PointDlg*)(GeomGUI->GetActiveDialogBox()); - - if(DialogPt->UseLocalContext()) { - ic->InitSelected(); - if(pe->state() == Qt::ShiftButton) - v3d->getAISSelector()->shiftSelect(); /* Append selection */ - else - v3d->getAISSelector()->select(); /* New selection */ +// GeomGUI->EraseSimulationShape(); +// BasicGUI_PointDlg *DialogPt = (BasicGUI_PointDlg*)(GeomGUI->GetActiveDialogBox()); + +// 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 = GeomGUI->ConvertClickToPoint(pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView()); - } - else - thePoint = GeomGUI->ConvertClickToPoint(pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView()); - - if(DialogPt != 0) - DialogPt->PointIntoCoordinates(thePoint, true); /* display point */ - else - GeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); +// if(ic->MoreSelected()) +// thePoint = BRep_Tool::Pnt( TopoDS::Vertex(ic->SelectedShape())); +// else +// thePoint = GeomGUI->ConvertClickToPoint(pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView()); +// } +// else +// thePoint = GeomGUI->ConvertClickToPoint(pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView()); + +// if(DialogPt != 0) +// DialogPt->PointIntoCoordinates(thePoint, true); /* display point */ +// else +// GeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); } return false; } diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index 9253b1fab..a61a342b4 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -44,7 +44,8 @@ public : ~GeometryGUI(); static GEOMBase_Context* GetOrCreateGeometryGUI(QAD_Desktop* desktop); -/* static GEOMBase_Context* GetGeomGUI(); */ + + static bool LoadLibrary(int theCommandID, QAD_Desktop* parent, QString GUILibrary); /* Managed by IAPP */ Standard_EXPORT static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); diff --git a/src/GEOMGUI/Makefile.in b/src/GEOMGUI/Makefile.in index 1e74ed3d3..c2bf788d8 100644 --- a/src/GEOMGUI/Makefile.in +++ b/src/GEOMGUI/Makefile.in @@ -61,6 +61,6 @@ LIB_SERVER_IDL = CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += -lOCCViewer -lVTKViewer -lSalomeObject -lSalomeGUI -lGEOMClient -lGEOMObject -lGEOMFiltersSelection -lGEOMBase -lBasicGUI -lPrimitiveGUI -lGenerationGUI -lBuildGUI -lBooleanGUI -lTransformationGUI -lOperationGUI -lRepairGUI -lMeasureGUI $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome +LDFLAGS += -lOCCViewer -lVTKViewer -lSalomeObject -lSalomeGUI -lGEOMClient -lGEOMObject -lGEOMFiltersSelection -lGEOMBase $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome @CONCLUDE@ diff --git a/src/GenerationGUI/GenerationGUI.cxx b/src/GenerationGUI/GenerationGUI.cxx index 4417336c6..ed1ce4a18 100644 --- a/src/GenerationGUI/GenerationGUI.cxx +++ b/src/GenerationGUI/GenerationGUI.cxx @@ -34,6 +34,8 @@ using namespace std; #include "GenerationGUI_FillingDlg.h" // Method FILLING #include "GenerationGUI_PipeDlg.h" // Method PIPE +static GenerationGUI* myGenerationGUI = 0; + //======================================================================= // function : GenerationGUI() // purpose : Constructor @@ -56,35 +58,48 @@ GenerationGUI::~GenerationGUI() } +//======================================================================= +// function : GetOrCreateGUI() +// purpose : Gets or create an object 'GUI' with initialisations +// : Returns 'GUI' as a pointer +//======================================================================= +GenerationGUI* GenerationGUI::GetOrCreateGUI() +{ + myGenerationGUI = new GenerationGUI(); + return myGenerationGUI; +} + + //======================================================================= // function : OnGUIEvent() // purpose : //======================================================================= bool GenerationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + GenerationGUI::GetOrCreateGUI(); + myGenerationGUI->myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGenerationGUI->myGeomGUI->GetActiveStudy()->getSelection()); switch (theCommandID) { case 4031: // PRISM { - GenerationGUI_PrismDlg *aDlg = new GenerationGUI_PrismDlg(parent, "", this, Sel); + GenerationGUI_PrismDlg *aDlg = new GenerationGUI_PrismDlg(parent, "", myGenerationGUI, Sel); break; } case 4032: // REVOL { - GenerationGUI_RevolDlg *aDlg = new GenerationGUI_RevolDlg(parent, "", this, Sel); + GenerationGUI_RevolDlg *aDlg = new GenerationGUI_RevolDlg(parent, "", myGenerationGUI, Sel); break; } case 4033: // FILLING { - GenerationGUI_FillingDlg *aDlg = new GenerationGUI_FillingDlg(parent, "", this, Sel); + GenerationGUI_FillingDlg *aDlg = new GenerationGUI_FillingDlg(parent, "", myGenerationGUI, Sel); break; } case 4034: // PIPE { - GenerationGUI_PipeDlg *aDlg = new GenerationGUI_PipeDlg(parent, "", this, Sel); + GenerationGUI_PipeDlg *aDlg = new GenerationGUI_PipeDlg(parent, "", myGenerationGUI, Sel); break; } default: @@ -218,3 +233,13 @@ void GenerationGUI::MakePipeAndDisplay(GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Sh } return; } + + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + {return GenerationGUI::OnGUIEvent(theCommandID, parent);} +} diff --git a/src/GenerationGUI/GenerationGUI.h b/src/GenerationGUI/GenerationGUI.h index 7eae509de..d5d4e9ab6 100644 --- a/src/GenerationGUI/GenerationGUI.h +++ b/src/GenerationGUI/GenerationGUI.h @@ -43,7 +43,8 @@ public : GenerationGUI(); ~GenerationGUI(); - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + static GenerationGUI* GetOrCreateGUI(); + static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); 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, @@ -52,7 +53,6 @@ public : const double tol3d, const double tol2d, const short nbiter); void MakePipeAndDisplay(GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase); -private: GEOMBase_Context* myGeomGUI; GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ diff --git a/src/GenerationGUI/GenerationGUI_FillingDlg.cxx b/src/GenerationGUI/GenerationGUI_FillingDlg.cxx index ef0770396..a7a807fcf 100644 --- a/src/GenerationGUI/GenerationGUI_FillingDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_FillingDlg.cxx @@ -162,7 +162,6 @@ void GenerationGUI_FillingDlg::ClickOnApply() if(myOkSectionShape) myGenerationGUI->MakeFillingAndDisplay(myGeomShape, myMinDeg, myMaxDeg, myTol3D, myTol2D, myNbIter); - return; } @@ -209,13 +208,14 @@ void GenerationGUI_FillingDlg::SelectionIntoArgument() void GenerationGUI_FillingDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters(); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; mySelection->AddFilter(myCompoundFilter); + this->SelectionIntoArgument(); } - this->SelectionIntoArgument(); return; } diff --git a/src/GenerationGUI/GenerationGUI_PipeDlg.cxx b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx index 6c067447d..11b5b6ef7 100644 --- a/src/GenerationGUI/GenerationGUI_PipeDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx @@ -30,8 +30,6 @@ using namespace std; #include "GenerationGUI_PipeDlg.h" #include -// #include -// #include #include //================================================================================= @@ -149,6 +147,8 @@ void GenerationGUI_PipeDlg::ClickOnApply() //================================================================================= void GenerationGUI_PipeDlg::SelectionIntoArgument() { + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); QString aString = ""; /* name of selection */ @@ -185,25 +185,8 @@ void GenerationGUI_PipeDlg::SelectionIntoArgument() myShape2 = S; } - if(myOkShape1 && myOkShape2 && !myShape1.IsNull() && !myShape2.IsNull()) { - //Make preview - TopoDS_Shape tds; - TopoDS_Wire aWire; - - if(myShape2.ShapeType() == TopAbs_WIRE) - aWire = TopoDS::Wire(myShape2); - else if(myShape2.ShapeType() == TopAbs_EDGE) { - TopoDS_Edge aEdge = TopoDS::Edge(myShape2); - aWire = BRepBuilderAPI_MakeWire(aEdge); - } - - tds = BRepOffsetAPI_MakePipe(aWire,myShape1); - if(BRepAlgoAPI::IsValid(tds)) { - //Draw Pipe - mySimulationTopoDs = tds; - myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); - } - } + if(myOkShape1 && myOkShape2) + this->MakePipeSimulationAndDisplay(); return; } @@ -274,3 +257,37 @@ void GenerationGUI_PipeDlg::ActivateThisDialog() myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); return; } + + +//================================================================================= +// function : MakeMirrorSimulationAndDisplay() +// purpose : S1 is a shape and S2 a mirror. +//================================================================================= +void GenerationGUI_PipeDlg::MakePipeSimulationAndDisplay() +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + try { + TopoDS_Wire aWire; + + if(myShape2.ShapeType() == TopAbs_WIRE) + aWire = TopoDS::Wire(myShape2); + else if(myShape2.ShapeType() == TopAbs_EDGE) { + TopoDS_Edge aEdge = TopoDS::Edge(myShape2); + aWire = BRepBuilderAPI_MakeWire(aEdge); + } + + TopoDS_Shape tds = BRepOffsetAPI_MakePipe(aWire,myShape1); + if(BRepAlgoAPI::IsValid(tds)) { + //Draw Pipe + mySimulationTopoDs = tds; + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + } + catch(Standard_Failure) { + MESSAGE("Exception catched in MakeMirrorSimulationAndDisplay"); + return; + } + return; +} diff --git a/src/GenerationGUI/GenerationGUI_PipeDlg.h b/src/GenerationGUI/GenerationGUI_PipeDlg.h index b54122c4d..795c36ed4 100644 --- a/src/GenerationGUI/GenerationGUI_PipeDlg.h +++ b/src/GenerationGUI/GenerationGUI_PipeDlg.h @@ -49,6 +49,7 @@ public: private: void Init(); void enterEvent(QEvent* e); + void MakePipeSimulationAndDisplay(); GenerationGUI* myGenerationGUI; diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx index c00a82344..8a64c4d09 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx @@ -95,7 +95,6 @@ void GenerationGUI_PrismDlg::Init() myOkBase = myOkLine = false; myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); - mySelection->AddFilter(myEdgeFilter); /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); @@ -116,6 +115,7 @@ void GenerationGUI_PrismDlg::Init() connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseVector(int))); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; @@ -179,6 +179,8 @@ void GenerationGUI_PrismDlg::ClickOnApply() //================================================================================= void GenerationGUI_PrismDlg::SelectionIntoArgument() { + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); QString aString = ""; /* name of selection */ @@ -198,7 +200,7 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument() if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) return; - gp_Pnt aPoint1, aPoint2 ; + gp_Pnt aPoint1, aPoint2; if(myEditCurrentArgument == GroupPoints->LineEdit1) { myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); @@ -217,8 +219,7 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument() } if(myOkBase && myOkLine) - MakePrismSimulationAndDisplay(myBaseTopo); - + this->MakePrismSimulationAndDisplay(); return; } @@ -230,6 +231,7 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument() void GenerationGUI_PrismDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters(); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); @@ -298,16 +300,9 @@ void GenerationGUI_PrismDlg::ActivateThisDialog() //================================================================================= void GenerationGUI_PrismDlg::ValueChangedInSpinBox(double newValue) { - myGeomGUI->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - QObject* send = (QObject*)sender(); - - if(send == GroupPoints->SpinBox_DX) { - myHeight = newValue; - - if(myOkBase && myOkLine) - MakePrismSimulationAndDisplay(myBaseTopo); - } + myHeight = newValue; + if(myOkBase && myOkLine) + this->MakePrismSimulationAndDisplay(); return; } @@ -318,14 +313,11 @@ void GenerationGUI_PrismDlg::ValueChangedInSpinBox(double newValue) //================================================================================= void GenerationGUI_PrismDlg::ReverseVector(int state) { - myGeomGUI->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - myDx = -myDx; myDy = -myDy; myDz = -myDz; if(myOkBase && myOkLine) - MakePrismSimulationAndDisplay(myBaseTopo); + this->MakePrismSimulationAndDisplay(); return; } @@ -334,18 +326,24 @@ void GenerationGUI_PrismDlg::ReverseVector(int state) // function : MakePrismSimulationAndDisplay() // purpose : //================================================================================= -void GenerationGUI_PrismDlg::MakePrismSimulationAndDisplay(const TopoDS_Shape& S) +void GenerationGUI_PrismDlg::MakePrismSimulationAndDisplay() { + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + try { - gp_Vec Vec(myDx, myDy, myDz ); + gp_Vec Vec(myDx, myDy, myDz); Vec.Normalize(); Vec *= myHeight; - mySimulationTopoDs = BRepPrimAPI_MakePrism(S, Vec, Standard_False).Shape(); + mySimulationTopoDs = BRepPrimAPI_MakePrism(myBaseTopo, Vec, Standard_False).Shape(); + if(mySimulationTopoDs.IsNull()) + return; + else + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); } catch(Standard_Failure) { - MESSAGE( "Exception catched in MakePrismSimulationAndDisplay" << endl ) ; + MESSAGE("Exception catched in MakePrismSimulationAndDisplay" << endl); return; } - myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); return; } diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.h b/src/GenerationGUI/GenerationGUI_PrismDlg.h index be7df17f8..1eec6575a 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.h +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.h @@ -49,7 +49,7 @@ public: private : void Init(); void enterEvent(QEvent* e); - void MakePrismSimulationAndDisplay(const TopoDS_Shape& S); + void MakePrismSimulationAndDisplay(); GenerationGUI* myGenerationGUI; diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx index b06a844fa..98cfaaf16 100644 --- a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx @@ -30,24 +30,9 @@ using namespace std; #include "GenerationGUI_RevolDlg.h" #include - +#include #include "QAD_Config.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - //================================================================================= // class : GenerationGUI_RevolDlg() // purpose : Constructs a GenerationGUI_RevolDlg which is a child of 'parent', with the @@ -56,125 +41,34 @@ using namespace std; // TRUE to construct a modal dialog. //================================================================================= GenerationGUI_RevolDlg::GenerationGUI_RevolDlg(QWidget* parent, const char* name, GenerationGUI* theGenerationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) + :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_REVOL"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); - - if ( !name ) - setName( "GenerationGUI_RevolDlg" ); - resize( 303, 251 ); - setCaption( tr( "GEOM_REVOLUTION_TITLE" ) ); - setSizeGripEnabled( TRUE ); - GenerationGUI_RevolDlgLayout = new QGridLayout( this ); - GenerationGUI_RevolDlgLayout->setSpacing( 6 ); - GenerationGUI_RevolDlgLayout->setMargin( 11 ); - - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "GEOM_REVOLUTION" ) ); - 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 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - GenerationGUI_RevolDlgLayout->addWidget( GroupConstructors, 0, 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 ); - GenerationGUI_RevolDlgLayout->addWidget( GroupButtons, 2, 0 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) ); - GroupC1->setFrameShape( QGroupBox::Box ); - GroupC1->setFrameShadow( QGroupBox::Sunken ); - 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 ); - - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "GEOM_OBJECT" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - SelectButtonC1A1->setToggleButton( FALSE ); - SelectButtonC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, - SelectButtonC1A1->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 2, 3 ); - - TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" ); - TextLabelC1A2->setText( tr( "GEOM_AXIS" ) ); - TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); - GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); - SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); - SelectButtonC1A2->setText( tr( "" ) ); - SelectButtonC1A2->setPixmap( image1 ); - SelectButtonC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, - SelectButtonC1A2->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); - LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); - GroupC1Layout->addMultiCellWidget( LineEditC1A2, 1, 1, 2, 3 ); - - CheckBoxReverse = new QCheckBox( GroupC1, "CheckBoxReverse" ); - CheckBoxReverse->setText( tr( "GEOM_REVERSE" ) ); - GroupC1Layout->addMultiCellWidget( CheckBoxReverse, 2, 2, 0, 1 ); - TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" ); - TextLabelC1A3->setText( tr( "GEOM_ANGLE" ) ); - TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) ); - GroupC1Layout->addWidget( TextLabelC1A3, 2, 2 ); - SpinBox_C1A3 = new DlgRef_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ; - GroupC1Layout->addWidget( SpinBox_C1A3, 2, 3 ); - - GenerationGUI_RevolDlgLayout->addWidget( GroupC1, 1, 0 ); - /***************************************************************/ - myGenerationGUI = theGenerationGUI; - Init(Sel) ; /* Initialisations */ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_REVOL"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_REVOLUTION_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_REVOLUTION")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_2Sel1Spin1Check(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_OBJECT")); + GroupPoints->TextLabel2->setText(tr("GEOM_AXIS")); + GroupPoints->TextLabel3->setText(tr("GEOM_ANGLE")); + GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->PushButton2->setPixmap(image1); + + Layout1->addWidget(GroupPoints, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myGenerationGUI = theGenerationGUI; + Init(); } @@ -184,7 +78,7 @@ GenerationGUI_RevolDlg::GenerationGUI_RevolDlg(QWidget* parent, const char* name //================================================================================= GenerationGUI_RevolDlg::~GenerationGUI_RevolDlg() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us } @@ -192,146 +86,74 @@ GenerationGUI_RevolDlg::~GenerationGUI_RevolDlg() // function : Init() // purpose : //================================================================================= -void GenerationGUI_RevolDlg::Init( SALOME_Selection* Sel ) +void GenerationGUI_RevolDlg::Init() { + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; - /* Get setting of step value from file configuration */ - double step ; - QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ; - step = St.toDouble() ; - - /* min, max, step and decimals for spin boxes */ - SpinBox_C1A3->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; - SpinBox_C1A3->SetValue( 45.0 ) ; /* = myAngle */ - myAngle = 45.0 ; - - GroupC1->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - myGeomGUI = GEOMBase_Context::GetGeomGUI() ; - - myOkBase = false ; - myOkAxis = false ; + myAngle = 45.0; + myOkBase = myOkAxis = false; - mySimulationTopoDs.Nullify() ; - myBase.Nullify() ; - myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); - // TODO : previous selection into argument + /* Get setting of step value from file configuration */ + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); - /* 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 ); + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupPoints->SpinBox_DX->SetValue(myAngle); /* 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( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( CheckBoxReverse, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle(int) ) ) ; - - connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - connect( LineEditC1A2, 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() ) ) ; - - /* 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 ; -} + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); -//================================================================================= -// function : ReverseAngle() -// purpose : 'state' not used here -//================================================================================= -void GenerationGUI_RevolDlg::ReverseAngle(int state) -{ - myAngle = -myAngle ; - SpinBox_C1A3->SetValue( myAngle ) ; + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + 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->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseVector(int))); - if(myOkBase && myOkAxis) { - MakeRevolutionSimulationAndDisplay(myBase) ; - } else { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - } - return ; -} + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + /* displays Dialog */ + GroupPoints->show(); + this->show(); -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void GenerationGUI_RevolDlg::ConstructorsClicked(int constructorId) -{ - /* only a constructor now */ - return ; + return; } + //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void GenerationGUI_RevolDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - - return ; + this->ClickOnApply(); + ClickOnCancel(); + return; } + //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void GenerationGUI_RevolDlg::ClickOnApply() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - myGeomGUI->GetDesktop()->putInfo( tr("") ) ; - - switch(myConstructorId) - { - case 0 : - { - if(myOkBase && myOkAxis) { - myGenerationGUI->MakeRevolutionAndDisplay( myGeomShape, myLoc, myDir, myAngle*PI180 ) ; - } - break ; - } - } - return ; -} - - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void GenerationGUI_RevolDlg::ClickOnCancel() -{ - mySelection->ClearFilters() ; - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->ResetState() ; - reject() ; - return ; + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkBase && myOkAxis) + myGenerationGUI->MakeRevolutionAndDisplay(myGeomShape, myLoc, myDir, myAngle*PI180); + return; } @@ -341,58 +163,49 @@ void GenerationGUI_RevolDlg::ClickOnCancel() //================================================================================= void GenerationGUI_RevolDlg::SelectionIntoArgument() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + myEditCurrentArgument->setText(""); QString aString = ""; /* name of selection */ - int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - if ( nbSel != 1 ) { - if ( myEditCurrentArgument == LineEditC1A1 ) { - LineEditC1A1->setText("") ; - myOkBase = false ; - } - else if ( myEditCurrentArgument == LineEditC1A2 ) { - LineEditC1A2->setText("") ; - myOkAxis = false ; - } - return ; + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkBase = false; + else if(myEditCurrentArgument == GroupPoints->LineEdit2) + myOkAxis = false; + return; } - - /* nbSel == 1 ! */ - TopoDS_Shape S; - Standard_Boolean testResult ; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - - if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) - return ; - - if ( myEditCurrentArgument == LineEditC1A1 ) { - myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) - return ; + + // nbSel == 1 + TopoDS_Shape S; + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; - /* test if appropriate shape for revol */ - TopAbs_ShapeEnum aType = S.ShapeType() ; - if(aType != TopAbs_VERTEX && aType != TopAbs_EDGE && aType != TopAbs_WIRE && aType != TopAbs_FACE && aType != TopAbs_SHELL && aType != TopAbs_COMPOUND ) - return ; - - LineEditC1A1->setText(aString) ; - myBase = S ; - myOkBase = true ; - } - else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, myLoc, myDir) */) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) { + myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + TopAbs_ShapeEnum aType = S.ShapeType(); + if(aType != TopAbs_VERTEX && aType != TopAbs_EDGE && aType != TopAbs_WIRE && aType != TopAbs_FACE && aType != TopAbs_SHELL && aType != TopAbs_COMPOUND) + return; + myEditCurrentArgument->setText(aString); + myOkBase = true; + myBase = S; + } + else if(myEditCurrentArgument == GroupPoints->LineEdit2) { BRepAdaptor_Curve curv(TopoDS::Edge(S)); myDir = curv.Line().Direction(); myLoc = curv.Line().Location(); - LineEditC1A2->setText(aString) ; - myOkAxis = true ; + myEditCurrentArgument->setText(aString); + myOkAxis = true; } - - if( myOkBase && myOkAxis ) { - MakeRevolutionSimulationAndDisplay( myBase) ; - } - return ; + + if(myOkBase && myOkAxis) + this->MakeRevolutionSimulationAndDisplay(); + return; } @@ -403,128 +216,93 @@ void GenerationGUI_RevolDlg::SelectionIntoArgument() void GenerationGUI_RevolDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; - mySelection->ClearFilters() ; - } - else if(send == SelectButtonC1A2) { - LineEditC1A2->setFocus() ; - myEditCurrentArgument = LineEditC1A2; - mySelection->AddFilter(myEdgeFilter) ; - } - SelectionIntoArgument() ; - break; - } - } - return ; + mySelection->ClearFilters(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + mySelection->AddFilter(myEdgeFilter); + } + this->SelectionIntoArgument(); + + return; } + //================================================================================= // function : LineEditReturnPressed() // purpose : //================================================================================= void GenerationGUI_RevolDlg::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. */ - const QString objectUserName = myEditCurrentArgument->text() ; - QWidget* thisWidget = (QWidget*)this ; - if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) { - myEditCurrentArgument->setText( objectUserName ) ; - } - return ; -} + return; - -//================================================================================= -// function : ValueChangedInSpinBox() -// purpose : -//================================================================================= -void GenerationGUI_RevolDlg::ValueChangedInSpinBox( double newValue ) -{ - myAngle = newValue ; - if ( myOkBase && myOkAxis ) { - MakeRevolutionSimulationAndDisplay(myBase) ; - } - else { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - } - return ; + GEOMBase_Skeleton::LineEditReturnPressed(); + return; } //================================================================================= -// function : DeactivateActiveDialog() +// function : ActivateThisDialog() // purpose : //================================================================================= -void GenerationGUI_RevolDlg::DeactivateActiveDialog() +void GenerationGUI_RevolDlg::ActivateThisDialog() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->EraseSimulationShape() ; - mySelection->ClearFilters() ; - } - return ; + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; } //================================================================================= -// function : ActivateThisDialog() +// function : enterEvent() // purpose : //================================================================================= -void GenerationGUI_RevolDlg::ActivateThisDialog() +void GenerationGUI_RevolDlg::enterEvent(QEvent* e) { - /* Emit a signal to deactivate the active dialog */ - myGeomGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - if( !mySimulationTopoDs.IsNull() ) - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; - return ; + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; } - //================================================================================= -// function : enterEvent() +// function : ValueChangedInSpinBox() // purpose : //================================================================================= -void GenerationGUI_RevolDlg::enterEvent(QEvent* e) -{ - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; +void GenerationGUI_RevolDlg::ValueChangedInSpinBox(double newValue) +{ + myAngle = newValue; + if(myOkBase && myOkAxis) + this->MakeRevolutionSimulationAndDisplay(); + return; } - //================================================================================= -// function : closeEvent() -// purpose : +// function : ReverseAngle() +// purpose : 'state' not used here //================================================================================= -void GenerationGUI_RevolDlg::closeEvent( QCloseEvent* e ) +void GenerationGUI_RevolDlg::ReverseAngle(int state) { - this->ClickOnCancel() ; /* same than click on cancel button */ + myAngle = -myAngle; + GroupPoints->SpinBox_DX->SetValue(myAngle); + if(myOkBase && myOkAxis) + this->MakeRevolutionSimulationAndDisplay(); + return; } @@ -532,25 +310,23 @@ void GenerationGUI_RevolDlg::closeEvent( QCloseEvent* e ) // function : MakeRevolutionSimulationAndDisplay() // purpose : //================================================================================= -void GenerationGUI_RevolDlg::MakeRevolutionSimulationAndDisplay( const TopoDS_Shape& S) +void GenerationGUI_RevolDlg::MakeRevolutionSimulationAndDisplay() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - - if( S.IsNull() ) - return ; - - TopAbs_ShapeEnum aType = S.ShapeType() ; - if(aType != TopAbs_VERTEX && aType != TopAbs_EDGE && aType != TopAbs_WIRE && aType != TopAbs_FACE && aType != TopAbs_SHELL && aType !=TopAbs_COMPOUND ) - return ; - + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + TopAbs_ShapeEnum aType = myBase.ShapeType(); + if(aType != TopAbs_VERTEX && aType != TopAbs_EDGE && aType != TopAbs_WIRE && aType != TopAbs_FACE && aType != TopAbs_SHELL && aType !=TopAbs_COMPOUND) + return; + try { - gp_Ax1 AX( this->myLoc, this->myDir); - mySimulationTopoDs = BRepPrimAPI_MakeRevol(S, AX, this->myAngle*PI180 ); - myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ; + gp_Ax1 AX(myLoc, myDir); + mySimulationTopoDs = BRepPrimAPI_MakeRevol(myBase, AX, myAngle*PI180); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); } catch(Standard_Failure) { - MESSAGE( "Exception catched in MakeRevolutionSimulationAndDisplay" ) ; + MESSAGE("Exception catched in MakeRevolutionSimulationAndDisplay"); + return; } - return ; + return; } diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.h b/src/GenerationGUI/GenerationGUI_RevolDlg.h index f51e56b28..97fd799ba 100644 --- a/src/GenerationGUI/GenerationGUI_RevolDlg.h +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.h @@ -29,35 +29,18 @@ #ifndef DIALOGBOX_REVOLUTION_H #define DIALOGBOX_REVOLUTION_H +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel1Spin1Check.h" + #include "GenerationGUI.h" -#include "DlgRef_SpinBox.h" -#include "GEOM_EdgeFilter.hxx" -#include #include -#include - -#include -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QCheckBox; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; - //================================================================================= // class : GenerationGUI_RevolDlg // purpose : //================================================================================= -class GenerationGUI_RevolDlg : public QDialog +class GenerationGUI_RevolDlg : public GEOMBase_Skeleton { Q_OBJECT @@ -66,66 +49,35 @@ public: ~GenerationGUI_RevolDlg(); private : - GenerationGUI* myGenerationGUI; - GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */ - GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */ - TopoDS_Shape myBase ; - GEOM::GEOM_Shape_var myGeomShape ; /* is myBase */ - - gp_Pnt myLoc ; - gp_Dir myDir ; + void Init(); + void enterEvent(QEvent* e); + void MakeRevolutionSimulationAndDisplay(); - Standard_Real myAngle ; + GenerationGUI* myGenerationGUI; - bool myOkBase ; - bool myOkAxis ; - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ - int myConstructorId ; /* Current constructor id = radio button id */ - Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ + double step; + Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filters selection */ - void closeEvent( QCloseEvent* e ) ; - void enterEvent( QEvent* e); - void Init( SALOME_Selection* Sel ) ; - void MakeRevolutionSimulationAndDisplay( const TopoDS_Shape& S) ; + TopoDS_Shape myBase; + GEOM::GEOM_Shape_var myGeomShape; /* is myBase */ + gp_Pnt myLoc; + gp_Dir myDir; + Standard_Real myAngle; + bool myOkBase; + bool myOkAxis; - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - QGroupBox* GroupButtons; - QPushButton* buttonOk; - QPushButton* buttonCancel; - QPushButton* buttonApply; - QGroupBox* GroupC1; - QPushButton* SelectButtonC1A2; - QLineEdit* LineEditC1A1; - QLineEdit* LineEditC1A2; - QPushButton* SelectButtonC1A1; - QLabel* TextLabelC1A1; - QLabel* TextLabelC1A2; - DlgRef_SpinBox* SpinBox_C1A3 ; /* for angle */ - QLabel* TextLabelC1A3; - QCheckBox* CheckBoxReverse; + DlgRef_2Sel1Spin1Check* GroupPoints; private slots: - - void ConstructorsClicked(int constructorId); void ClickOnOk(); - void ClickOnCancel(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void ReverseAngle(int state) ; - void ValueChangedInSpinBox( double newValue ) ; + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ReverseAngle(int state); + void ValueChangedInSpinBox(double newValue); -protected: - QGridLayout* GenerationGUI_RevolDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupC1Layout; }; #endif // DIALOGBOX_REVOLUTION_H diff --git a/src/MeasureGUI/MeasureGUI.cxx b/src/MeasureGUI/MeasureGUI.cxx index ae489da97..51890210f 100644 --- a/src/MeasureGUI/MeasureGUI.cxx +++ b/src/MeasureGUI/MeasureGUI.cxx @@ -38,6 +38,8 @@ using namespace std; #include "MeasureGUI_WhatisDlg.h" // Method WHATIS #include "MeasureGUI_CheckShape.h" // Method CHECKSHAPE +static MeasureGUI* myMeasureGUI = 0; + //======================================================================= // function : MeasureGUI() // purpose : Constructor @@ -60,14 +62,27 @@ MeasureGUI::~MeasureGUI() } +//======================================================================= +// function : GetOrCreateGUI() +// purpose : Gets or create an object 'GUI' with initialisations +// : Returns 'GUI' as a pointer +//======================================================================= +MeasureGUI* MeasureGUI::GetOrCreateGUI() +{ + myMeasureGUI = new MeasureGUI(); + return myMeasureGUI; +} + + //======================================================================= // function : OnGUIEvent() // purpose : //======================================================================= bool MeasureGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + MeasureGUI::GetOrCreateGUI(); + myMeasureGUI->myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myMeasureGUI->myGeomGUI->GetActiveStudy()->getSelection()); switch (theCommandID) { @@ -78,7 +93,7 @@ bool MeasureGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) } case 702: // CDG : Center of mass { - MeasureGUI_CenterMassDlg *aDlg = new MeasureGUI_CenterMassDlg(parent, "", this, Sel); + MeasureGUI_CenterMassDlg *aDlg = new MeasureGUI_CenterMassDlg(parent, "", myMeasureGUI, Sel); break; } case 703: // INERTIA @@ -142,3 +157,13 @@ void MeasureGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape) } return; } + + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + {return MeasureGUI::OnGUIEvent(theCommandID, parent);} +} diff --git a/src/MeasureGUI/MeasureGUI.h b/src/MeasureGUI/MeasureGUI.h index 793dc9ce1..53ecbbe4e 100644 --- a/src/MeasureGUI/MeasureGUI.h +++ b/src/MeasureGUI/MeasureGUI.h @@ -43,11 +43,11 @@ public : MeasureGUI(); ~MeasureGUI(); - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + static MeasureGUI* GetOrCreateGUI(); + static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); void MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape); -private: GEOMBase_Context* myGeomGUI; GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ diff --git a/src/OperationGUI/OperationGUI.cxx b/src/OperationGUI/OperationGUI.cxx index f373fefc3..c122a99d6 100644 --- a/src/OperationGUI/OperationGUI.cxx +++ b/src/OperationGUI/OperationGUI.cxx @@ -40,6 +40,8 @@ using namespace std; #include "OperationGUI_FilletDlg.h" // Method FILLET #include "OperationGUI_ChamferDlg.h" // Method CHAMFER +static OperationGUI* myOperationGUI = 0; + //======================================================================= // function : OperationGUI() // purpose : Constructor @@ -62,45 +64,58 @@ OperationGUI::~OperationGUI() } +//======================================================================= +// function : GetOrCreateGUI() +// purpose : Gets or create an object 'GUI' with initialisations +// : Returns 'GUI' as a pointer +//======================================================================= +OperationGUI* OperationGUI::GetOrCreateGUI() +{ + myOperationGUI = new OperationGUI(); + return myOperationGUI; +} + + //======================================================================= // function : OnGUIEvent() // purpose : //======================================================================= bool OperationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + OperationGUI::GetOrCreateGUI(); + myOperationGUI->myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myOperationGUI->myGeomGUI->GetActiveStudy()->getSelection()); switch (theCommandID) { case 503: // PARTITION { - OperationGUI_PartitionDlg *aDlg = new OperationGUI_PartitionDlg(parent, "", this, Sel); + OperationGUI_PartitionDlg *aDlg = new OperationGUI_PartitionDlg(parent, "", myOperationGUI, Sel); break; } case 504: // ARCHIMEDE { - OperationGUI_ArchimedeDlg *aDlg = new OperationGUI_ArchimedeDlg(parent, "", this, Sel); + OperationGUI_ArchimedeDlg *aDlg = new OperationGUI_ArchimedeDlg(parent, "", myOperationGUI, Sel); break; } case 505: // FILLET { Handle(AIS_InteractiveContext) ic; - if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + if(myOperationGUI->myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myOperationGUI->myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); ic = v3d->getAISContext(); } - OperationGUI_FilletDlg *aDlg = new OperationGUI_FilletDlg(parent, "", this, Sel, ic); + OperationGUI_FilletDlg *aDlg = new OperationGUI_FilletDlg(parent, "", myOperationGUI, Sel, ic); break; } case 506: // CHAMFER { Handle(AIS_InteractiveContext) ic; - if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + if(myOperationGUI->myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myOperationGUI->myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); ic = v3d->getAISContext(); } - OperationGUI_ChamferDlg *aDlg = new OperationGUI_ChamferDlg(parent, "", this, Sel, ic); + OperationGUI_ChamferDlg *aDlg = new OperationGUI_ChamferDlg(parent, "", myOperationGUI, Sel, ic); break; } default: @@ -437,3 +452,13 @@ bool OperationGUI::OnChamferGetSelected(const TopoDS_Shape& ShapeTopo, const cha return true; } + + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + {return OperationGUI::OnGUIEvent(theCommandID, parent);} +} diff --git a/src/OperationGUI/OperationGUI.h b/src/OperationGUI/OperationGUI.h index 28bee151e..da0dc160f 100644 --- a/src/OperationGUI/OperationGUI.h +++ b/src/OperationGUI/OperationGUI.h @@ -43,7 +43,8 @@ public : OperationGUI(); ~OperationGUI(); - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + static OperationGUI* GetOrCreateGUI(); + static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); void MakePartitionAndDisplay(const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR, @@ -69,7 +70,6 @@ public : Standard_Integer& aLocalContextId, bool& myUseLocalContext); -private: GEOMBase_Context* myGeomGUI; GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ diff --git a/src/PrimitiveGUI/PrimitiveGUI.cxx b/src/PrimitiveGUI/PrimitiveGUI.cxx index 6ce7d7c8b..44f941e11 100644 --- a/src/PrimitiveGUI/PrimitiveGUI.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI.cxx @@ -35,6 +35,8 @@ using namespace std; #include "PrimitiveGUI_TorusDlg.h" // Method TORUS #include "PrimitiveGUI_ConeDlg.h" // Method CONE +static PrimitiveGUI* myPrimitiveGUI = 0; + //======================================================================= // function : PrimitiveGUI() // purpose : Constructor @@ -57,40 +59,53 @@ PrimitiveGUI::~PrimitiveGUI() } +//======================================================================= +// function : GetOrCreateGUI() +// purpose : Gets or create an object 'GUI' with initialisations +// : Returns 'GUI' as a pointer +//======================================================================= +PrimitiveGUI* PrimitiveGUI::GetOrCreateGUI() +{ + myPrimitiveGUI = new PrimitiveGUI(); + return myPrimitiveGUI; +} + + //======================================================================= // function : OnGUIEvent() // purpose : //======================================================================= bool PrimitiveGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + PrimitiveGUI::GetOrCreateGUI(); + myPrimitiveGUI->myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myPrimitiveGUI->myGeomGUI->GetActiveStudy()->getSelection()); switch (theCommandID) { case 4021: // BOX { - PrimitiveGUI_BoxDlg *aDlg = new PrimitiveGUI_BoxDlg(parent, "", this, Sel); + PrimitiveGUI_BoxDlg *aDlg = new PrimitiveGUI_BoxDlg(parent, "", myPrimitiveGUI, Sel); break; } case 4022: // CYLINDER { - PrimitiveGUI_CylinderDlg *aDlg = new PrimitiveGUI_CylinderDlg(parent, "", this, Sel); + PrimitiveGUI_CylinderDlg *aDlg = new PrimitiveGUI_CylinderDlg(parent, "", myPrimitiveGUI, Sel); break; } case 4023: // SPHERE { - PrimitiveGUI_SphereDlg *aDlg = new PrimitiveGUI_SphereDlg(parent, "", this, Sel); + PrimitiveGUI_SphereDlg *aDlg = new PrimitiveGUI_SphereDlg(parent, "", myPrimitiveGUI, Sel); break; } case 4024: // TORUS { - PrimitiveGUI_TorusDlg *aDlg = new PrimitiveGUI_TorusDlg(parent, "", this, Sel); + PrimitiveGUI_TorusDlg *aDlg = new PrimitiveGUI_TorusDlg(parent, "", myPrimitiveGUI, Sel); break; } case 4025: // CONE { - PrimitiveGUI_ConeDlg *aDlg = new PrimitiveGUI_ConeDlg(parent, "", this, Sel); + PrimitiveGUI_ConeDlg *aDlg = new PrimitiveGUI_ConeDlg(parent, "", myPrimitiveGUI, Sel); break; } default: @@ -234,3 +249,13 @@ void PrimitiveGUI::MakeConeAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, } return; } + + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + {return PrimitiveGUI::OnGUIEvent(theCommandID, parent);} +} diff --git a/src/PrimitiveGUI/PrimitiveGUI.h b/src/PrimitiveGUI/PrimitiveGUI.h index fb6de3fdf..55b94bc8c 100644 --- a/src/PrimitiveGUI/PrimitiveGUI.h +++ b/src/PrimitiveGUI/PrimitiveGUI.h @@ -44,7 +44,8 @@ public : PrimitiveGUI(); ~PrimitiveGUI(); - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + static PrimitiveGUI* GetOrCreateGUI(); + static 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, @@ -55,7 +56,6 @@ public : void MakeConeAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, const double Radius1, const double Radius2, const double aHeight); -private: GEOMBase_Context* myGeomGUI; GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx index 0523144b0..447ca237a 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx @@ -180,7 +180,7 @@ void PrimitiveGUI_BoxDlg::ConstructorsClicked(int constructorId) case 1: { GroupPoints->hide(); - resize( 0, 0 ); + resize(0, 0); GroupDimensions->show(); double initValue = 200.0; @@ -372,12 +372,21 @@ void PrimitiveGUI_BoxDlg::ValueChangedInSpinBox(double newValue) QObject* send = (QObject*)sender(); double vx, vy, vz; - if(send == GroupDimensions->SpinBox_DX) + if(send == GroupDimensions->SpinBox_DX) { vx = newValue; - else if(send == GroupDimensions->SpinBox_DY) + vy = GroupDimensions->SpinBox_DY->GetValue(); + vz = GroupDimensions->SpinBox_DZ->GetValue(); + } + else if(send == GroupDimensions->SpinBox_DY) { + vx = GroupDimensions->SpinBox_DX->GetValue(); vy = newValue; - else if(send == GroupDimensions->SpinBox_DZ) + vz = GroupDimensions->SpinBox_DZ->GetValue(); + } + else if(send == GroupDimensions->SpinBox_DZ) { + vx = GroupDimensions->SpinBox_DX->GetValue(); + vy = GroupDimensions->SpinBox_DY->GetValue(); vz = newValue; + } myPoint1.SetCoord(0.0, 0.0, 0.0); myPoint2.SetCoord(vx, vy, vz); diff --git a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx index 4ee474ca4..bd664e701 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx @@ -313,6 +313,7 @@ void PrimitiveGUI_ConeDlg::SetEditCurrentArgument() return; QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters(); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx index 5106024e0..85744d1e8 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx @@ -300,6 +300,7 @@ void PrimitiveGUI_CylinderDlg::SetEditCurrentArgument() return; QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters(); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx index ca3fe0dad..332a61c52 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx @@ -292,6 +292,7 @@ void PrimitiveGUI_TorusDlg::SetEditCurrentArgument() return; QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters(); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); diff --git a/src/RepairGUI/RepairGUI.cxx b/src/RepairGUI/RepairGUI.cxx index a429ea340..9ea698d81 100644 --- a/src/RepairGUI/RepairGUI.cxx +++ b/src/RepairGUI/RepairGUI.cxx @@ -37,6 +37,8 @@ using namespace std; #include "RepairGUI_SuppressFacesDlg.h" // Method SUPPRESS FACES #include "RepairGUI_SuppressHoleDlg.h" // Method SUPPRESS HOLE +static RepairGUI* myRepairGUI = 0; + //======================================================================= // function : RepairGUI() // purpose : Constructor @@ -59,45 +61,58 @@ RepairGUI::~RepairGUI() } +//======================================================================= +// function : GetOrCreateGUI() +// purpose : Gets or create an object 'GUI' with initialisations +// : Returns 'GUI' as a pointer +//======================================================================= +RepairGUI* RepairGUI::GetOrCreateGUI() +{ + myRepairGUI = new RepairGUI(); + return myRepairGUI; +} + + //======================================================================= // function : OnGUIEvent() // purpose : //======================================================================= bool RepairGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + RepairGUI::GetOrCreateGUI(); + myRepairGUI->myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myRepairGUI->myGeomGUI->GetActiveStudy()->getSelection()); switch (theCommandID) { case 601: // SEWING { - RepairGUI_SewingDlg *aDlg = new RepairGUI_SewingDlg(parent, "", this, Sel); + RepairGUI_SewingDlg *aDlg = new RepairGUI_SewingDlg(parent, "", myRepairGUI, Sel); break; } case 602: // ORIENTATION { - RepairGUI_OrientationDlg *aDlg = new RepairGUI_OrientationDlg(parent, "", this, Sel); + RepairGUI_OrientationDlg *aDlg = new RepairGUI_OrientationDlg(parent, "", myRepairGUI, Sel); break; } case 603: // SUPPRESS FACES : use ic { Handle(AIS_InteractiveContext) ic; - if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + if(myRepairGUI->myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myRepairGUI->myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); ic = v3d->getAISContext(); } - RepairGUI_SuppressFacesDlg *aDlg = new RepairGUI_SuppressFacesDlg(parent, "", this, Sel, ic); + RepairGUI_SuppressFacesDlg *aDlg = new RepairGUI_SuppressFacesDlg(parent, "", myRepairGUI, Sel, ic); break; } case 604: // SUPPRESS HOLES : use ic { Handle(AIS_InteractiveContext) ic; - if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + if(myRepairGUI->myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myRepairGUI->myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); ic = v3d->getAISContext(); } - RepairGUI_SuppressHoleDlg *aDlg = new RepairGUI_SuppressHoleDlg(parent, "", this, Sel, ic); + RepairGUI_SuppressHoleDlg *aDlg = new RepairGUI_SuppressHoleDlg(parent, "", myRepairGUI, Sel, ic); break; } default: @@ -331,3 +346,13 @@ bool RepairGUI::OnSuppressFaces( const TopoDS_Shape& ShapeTopo, myGeomGUI->GetDesktop()->putInfo (tr("GEOM_PRP_READY")); return true ; } + + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + {return RepairGUI::OnGUIEvent(theCommandID, parent);} +} diff --git a/src/RepairGUI/RepairGUI.h b/src/RepairGUI/RepairGUI.h index 6823cf0f1..424d33694 100644 --- a/src/RepairGUI/RepairGUI.h +++ b/src/RepairGUI/RepairGUI.h @@ -43,7 +43,8 @@ public : RepairGUI(); ~RepairGUI(); - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + static RepairGUI* GetOrCreateGUI(); + static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); void MakeSewingAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, const Standard_Real precision); @@ -59,7 +60,6 @@ public : const Standard_Integer& aLocalContextId, bool& myUseLocalContext); -private: GEOMBase_Context* myGeomGUI; GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ diff --git a/src/TransformationGUI/TransformationGUI.cxx b/src/TransformationGUI/TransformationGUI.cxx index fb761198a..e9d971a15 100644 --- a/src/TransformationGUI/TransformationGUI.cxx +++ b/src/TransformationGUI/TransformationGUI.cxx @@ -36,6 +36,8 @@ using namespace std; #include "TransformationGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION #include "TransformationGUI_MultiRotationDlg.h" // Method MULTI ROTATION +static TransformationGUI* myTransformationGUI = 0; + //======================================================================= // function : TransformationGUI() // purpose : Constructor @@ -58,45 +60,58 @@ TransformationGUI::~TransformationGUI() } +//======================================================================= +// function : GetOrCreateGUI() +// purpose : Gets or create an object 'GUI' with initialisations +// : Returns 'GUI' as a pointer +//======================================================================= +TransformationGUI* TransformationGUI::GetOrCreateGUI() +{ + myTransformationGUI = new TransformationGUI(); + return myTransformationGUI; +} + + //======================================================================= // function : OnGUIEvent() // purpose : //======================================================================= bool TransformationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + TransformationGUI::GetOrCreateGUI(); + myTransformationGUI->myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myTransformationGUI->myGeomGUI->GetActiveStudy()->getSelection()); switch (theCommandID) { case 5021: // TRANSLATION { - TransformationGUI_TranslationDlg *aDlg = new TransformationGUI_TranslationDlg(parent, "", this, Sel); + TransformationGUI_TranslationDlg *aDlg = new TransformationGUI_TranslationDlg(parent, "", myTransformationGUI, Sel); break; } case 5022: // ROTATION { - TransformationGUI_RotationDlg *aDlg = new TransformationGUI_RotationDlg(parent, "", this, Sel); + TransformationGUI_RotationDlg *aDlg = new TransformationGUI_RotationDlg(parent, "", myTransformationGUI, Sel); break; } case 5023: // MIRROR { - TransformationGUI_MirrorDlg *aDlg = new TransformationGUI_MirrorDlg(parent, "", this, Sel); + TransformationGUI_MirrorDlg *aDlg = new TransformationGUI_MirrorDlg(parent, "", myTransformationGUI, Sel); break; } case 5024: // SCALE { - TransformationGUI_ScaleDlg *aDlg = new TransformationGUI_ScaleDlg(parent, "", this, Sel ); + TransformationGUI_ScaleDlg *aDlg = new TransformationGUI_ScaleDlg(parent, "", myTransformationGUI, Sel ); break; } case 5025: // MULTI TRANSLATION { - TransformationGUI_MultiTranslationDlg *aDlg = new TransformationGUI_MultiTranslationDlg(parent, "", this, Sel); + TransformationGUI_MultiTranslationDlg *aDlg = new TransformationGUI_MultiTranslationDlg(parent, "", myTransformationGUI, Sel); break; } case 5026: // MULTI ROTATION { - TransformationGUI_MultiRotationDlg *aDlg = new TransformationGUI_MultiRotationDlg(parent, "", this, Sel); + TransformationGUI_MultiRotationDlg *aDlg = new TransformationGUI_MultiRotationDlg(parent, "", myTransformationGUI, Sel); break; } default: @@ -318,3 +333,13 @@ void TransformationGUI::MakeMultiRotation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape } return; } + + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + {return TransformationGUI::OnGUIEvent(theCommandID, parent);} +} diff --git a/src/TransformationGUI/TransformationGUI.h b/src/TransformationGUI/TransformationGUI.h index 27686159a..38b44e81e 100644 --- a/src/TransformationGUI/TransformationGUI.h +++ b/src/TransformationGUI/TransformationGUI.h @@ -30,6 +30,7 @@ #define TRANSFORMATIONGUI_H #include "GEOMBase_Display.h" +#include "QAD_Config.h" //================================================================================= // class : TransformationGUI @@ -43,7 +44,8 @@ public : TransformationGUI(); ~TransformationGUI(); - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + static TransformationGUI* GetOrCreateGUI(); + static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); void MakeTranslationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Vec V); void MakeRotationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, @@ -62,7 +64,6 @@ public : const gp_Dir Dir, const gp_Pnt Loc, const double Ang, const short NbTimes1, const double Step, const short NbTimes2); -private: GEOMBase_Context* myGeomGUI; GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx index 47549a230..a7081a016 100644 --- a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx @@ -29,25 +29,10 @@ using namespace std; #include "TransformationGUI_MirrorDlg.h" +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - - //================================================================================= // class : TransformationGUI_MirrorDlg() // purpose : Constructs a TransformationGUI_MirrorDlg which is a child of 'parent', with the @@ -55,112 +40,33 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -TransformationGUI_MirrorDlg::TransformationGUI_MirrorDlg( QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +TransformationGUI_MirrorDlg::TransformationGUI_MirrorDlg(QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_MIRROR"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); - - if ( !name ) - setName( "TransformationGUI_MirrorDlg" ); - resize( 303, 225 ); - setCaption( tr( "GEOM_MIRROR_TITLE" ) ); - setSizeGripEnabled( TRUE ); - TransformationGUI_MirrorDlgLayout = new QGridLayout( this ); - TransformationGUI_MirrorDlgLayout->setSpacing( 6 ); - TransformationGUI_MirrorDlgLayout->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 ); - - TransformationGUI_MirrorDlgLayout->addWidget( GroupButtons, 2, 0 ); - - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "GEOM_MIRROR" ) ); - 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 ); - TransformationGUI_MirrorDlgLayout->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 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "GEOM_OBJECT" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" ); - TextLabelC1A2->setText( tr( "GEOM_PLANE_MIRROR" ) ); - TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A2->setFrameShape( QLabel::NoFrame ); - TextLabelC1A2->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); - SelectButtonC1A2->setText( tr( "" ) ); - SelectButtonC1A2->setPixmap( image1 ); - GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); - GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); - TransformationGUI_MirrorDlgLayout->addWidget( GroupC1, 1, 0 ); - - /* Initialisation */ - myTransformationGUI = theTransformationGUI; - Init( Sel ) ; + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_MIRROR"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_MIRROR_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_MIRROR")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_2Sel_QTD(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_OBJECT")); + GroupPoints->TextLabel2->setText(tr("GEOM_PLANE_MIRROR")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->PushButton2->setPixmap(image1); + + Layout1->addWidget(GroupPoints, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myTransformationGUI = theTransformationGUI; + Init(); } @@ -174,97 +80,49 @@ TransformationGUI_MirrorDlg::~TransformationGUI_MirrorDlg() } - //================================================================================= // function : Init() // purpose : //================================================================================= -void TransformationGUI_MirrorDlg::Init( SALOME_Selection* Sel ) +void TransformationGUI_MirrorDlg::Init() { - mySelection = Sel ; - myShape1.Nullify() ; - myShape2.Nullify() ; - mySimulationTopoDs.Nullify() ; - myConstructorId = 0 ; - - myGeomGUI = GEOMBase_Context::GetGeomGUI() ; - GroupC1->show(); + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; - myEditCurrentArgument = LineEditC1A1 ; - Constructor1->setChecked( TRUE ); - myOkShape1 = myOkShape2 = false ; + myOkShape1 = myOkShape2 = false; - myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + /* Vertices Filter for all arguments */ + myFaceFilter = new GEOM_FaceFilter(StdSelect_Plane, myGeom); - Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); - myGeom = GEOM::GEOM_Gen::_narrow(comp); - /* Filter definition */ - - myFaceFilter = new GEOM_FaceFilter( StdSelect_Plane, myGeom ); + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - // TODO previous selection into argument ? + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - /* 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( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - connect( LineEditC1A2, 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 ; -} + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + /* displays Dialog */ + GroupPoints->show(); + this->show(); -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void TransformationGUI_MirrorDlg::ConstructorsClicked(int constructorId) -{ - GEOMBase_Context::GetGeomGUI()->EraseSimulationShape() ; - - switch (constructorId) - { - case 0: - { - GroupC1->show(); - myConstructorId = constructorId ; - myEditCurrentArgument = LineEditC1A1 ; - LineEditC1A2->setText(tr("")) ; - Constructor1->setChecked( TRUE ); - myOkShape1 = myOkShape2 = false ; - break; - } - } - return ; + return; } + //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void TransformationGUI_MirrorDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - - return ; + this->ClickOnApply(); + ClickOnCancel(); + return; } //================================================================================= @@ -273,136 +131,66 @@ void TransformationGUI_MirrorDlg::ClickOnOk() //================================================================================= void TransformationGUI_MirrorDlg::ClickOnApply() { - myGeomGUI->GetDesktop()->putInfo( tr("") ) ; - switch(myConstructorId) - { - case 0 : - { - if(myOkShape1 && myOkShape2) { - myTransformationGUI->MakeMirrorAndDisplay(myGeomShape1 ,myGeomShape2 ) ; - } - break ; - } - } - // accept(); - return ; -} - - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void TransformationGUI_MirrorDlg::ClickOnCancel() -{ - mySelection->ClearFilters() ; - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->ResetState() ; - reject() ; - return ; + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkShape1 && myOkShape2) + myTransformationGUI->MakeMirrorAndDisplay(myGeomShape1, myGeomShape2); + return; } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection has changed //================================================================================= void TransformationGUI_MirrorDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText("") ; - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + myEditCurrentArgument->setText(""); QString aString = ""; /* name of selection */ - int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - if ( nbSel != 1 ) { - switch (myConstructorId) - { - case 0: - { - if ( myEditCurrentArgument == LineEditC1A1 ) { - myOkShape1 = false ; - } - else if ( myEditCurrentArgument == LineEditC1A2 ) { - myOkShape2 = false ; - } - break ; - } - } - return ; + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkShape1 = false; + else if(myEditCurrentArgument == GroupPoints->LineEdit2) + myOkShape2 = false; + return; } - /* nbSel == 1 */ - TopoDS_Shape S; - Standard_Boolean testResult ; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) - return ; + // nbSel == 1 + TopoDS_Shape S; + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; - if ( myEditCurrentArgument == LineEditC1A1 ) { - myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) - return ; - myShape1 = S ; - LineEditC1A1->setText(aString) ; - myOkShape1 = true ; - } - else if ( myEditCurrentArgument == LineEditC1A2 ) { - myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) - return ; - myShape2 = S ; - LineEditC1A2->setText(aString) ; - myOkShape2 = true ; + if(myEditCurrentArgument == GroupPoints->LineEdit1) { + myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape1 = S; + myEditCurrentArgument->setText(aString); + myOkShape1 = true; } - - if(myOkShape1 && myOkShape2) { - MakeMirrorSimulationAndDisplay( myShape1, myShape2 ) ; - } - - return ; -} - - - -//================================================================================= -// function : MakeMirrorSimulationAndDisplay() -// purpose : S1 is a shape and S2 a mirror. -//================================================================================= -void TransformationGUI_MirrorDlg::MakeMirrorSimulationAndDisplay( const TopoDS_Shape& S1, const TopoDS_Shape& S2 ) -{ - this->mySimulationTopoDs.Nullify() ; - - try { - Handle(Geom_Surface) surf = BRep_Tool::Surface(TopoDS::Face(S2)) ; - Handle(Geom_Plane) myPlane = Handle(Geom_Plane)::DownCast(surf) ; - const gp_Ax3 pos = myPlane->Position() ; - const gp_Pnt loc = pos.Location() ; /* location of the plane */ - const gp_Dir dir = pos.Direction() ; /* Main direction of the plane (Z axis) */ - - /* plane used for mirroring */ - gp_Ax2 pln(loc, dir) ; - gp_Trsf theTransformation ; - theTransformation.SetMirror(pln) ; - BRepBuilderAPI_Transform myBRepTransformation( S1, theTransformation, Standard_False ) ; - - this->mySimulationTopoDs = myBRepTransformation.Shape() ; - if( this->mySimulationTopoDs.IsNull() ) + else if(myEditCurrentArgument == GroupPoints->LineEdit2) { + myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) return ; - else - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; - } - catch(Standard_Failure) { - MESSAGE( "Exception catched in MakeMirrorSimulationAndDisplay" ) ; - return ; + myShape2 = S; + myEditCurrentArgument->setText(aString); + myOkShape2 = true; } - return ; -} + if(myOkShape1 && myOkShape2) + MakeMirrorSimulationAndDisplay(); + return; +} //================================================================================= @@ -412,29 +200,21 @@ void TransformationGUI_MirrorDlg::MakeMirrorSimulationAndDisplay( const TopoDS_S void TransformationGUI_MirrorDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters(); - switch (myConstructorId) - { - case 0: - { - if( send == SelectButtonC1A1 ) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1 ; - mySelection->ClearFilters() ; - SelectionIntoArgument() ; - } - else if(send == SelectButtonC1A2) { - LineEditC1A2->setFocus() ; - myEditCurrentArgument = LineEditC1A2; - mySelection->AddFilter(myFaceFilter) ; - SelectionIntoArgument() ; - } - break; - } - } - return ; -} + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + mySelection->AddFilter(myFaceFilter); + } + this->SelectionIntoArgument(); + return; +} //================================================================================= @@ -443,78 +223,77 @@ void TransformationGUI_MirrorDlg::SetEditCurrentArgument() //================================================================================= void TransformationGUI_MirrorDlg::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. */ - const QString objectUserName = myEditCurrentArgument->text() ; - QWidget* thisWidget = (QWidget*)this ; - if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) { - myEditCurrentArgument->setText( objectUserName ) ; - } - return ; -} - - + return; -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void TransformationGUI_MirrorDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - } - return ; + GEOMBase_Skeleton::LineEditReturnPressed(); + return; } - //================================================================================= -// function : closeEvent() -// purpose : +// function : enterEvent() +// purpose : when mouse enter onto the QWidget //================================================================================= -void TransformationGUI_MirrorDlg::closeEvent( QCloseEvent* e ) +void TransformationGUI_MirrorDlg::enterEvent(QEvent * e) { - this->ClickOnCancel() ; /* same than click on cancel button */ + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; } //================================================================================= -// function : enterEvent() -// purpose : when mouse enter onto the QWidget +// function : ActivateThisDialog() +// purpose : //================================================================================= -void TransformationGUI_MirrorDlg::enterEvent( QEvent * ) +void TransformationGUI_MirrorDlg::ActivateThisDialog() { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; } - //================================================================================= -// function : ActivateThisDialog() -// purpose : +// function : MakeMirrorSimulationAndDisplay() +// purpose : S1 is a shape and S2 a mirror. //================================================================================= -void TransformationGUI_MirrorDlg::ActivateThisDialog() +void TransformationGUI_MirrorDlg::MakeMirrorSimulationAndDisplay() { - /* Emit a signal to deactivate any active dialog */ - myGeomGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - return ; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + try { + Handle(Geom_Surface) surf = BRep_Tool::Surface(TopoDS::Face(myShape2)); + Handle(Geom_Plane) myPlane = Handle(Geom_Plane)::DownCast(surf); + const gp_Ax3 pos = myPlane->Position(); + const gp_Pnt loc = pos.Location(); /* location of the plane */ + const gp_Dir dir = pos.Direction(); /* Main direction of the plane (Z axis) */ + + /* plane used for mirroring */ + gp_Ax2 pln(loc, dir); + gp_Trsf theTransformation; + theTransformation.SetMirror(pln); + BRepBuilderAPI_Transform myBRepTransformation(myShape1, theTransformation, Standard_False); + + this->mySimulationTopoDs = myBRepTransformation.Shape(); + if(mySimulationTopoDs.IsNull()) + return; + else + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + catch(Standard_Failure) { + MESSAGE("Exception catched in MakeMirrorSimulationAndDisplay"); + return; + } + return; } diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.h b/src/TransformationGUI/TransformationGUI_MirrorDlg.h index 5a6c50df5..71c118981 100644 --- a/src/TransformationGUI/TransformationGUI_MirrorDlg.h +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.h @@ -29,89 +29,51 @@ #ifndef DIALOGBOX_MIRROR_H #define DIALOGBOX_MIRROR_H +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel_QTD.h" + #include "TransformationGUI.h" -#include #include "GEOM_FaceFilter.hxx" -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; - - //================================================================================= // class : TransformationGUI_MirrorDlg // purpose : //================================================================================= -class TransformationGUI_MirrorDlg : public QDialog +class TransformationGUI_MirrorDlg : public GEOMBase_Skeleton { Q_OBJECT public: - TransformationGUI_MirrorDlg( QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + TransformationGUI_MirrorDlg(QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~TransformationGUI_MirrorDlg(); private : + void Init(); + void enterEvent(QEvent* e); + void MakeMirrorSimulationAndDisplay(); + TransformationGUI* myTransformationGUI; - void closeEvent( QCloseEvent* e ) ; - void enterEvent( QEvent* e); /* Mouse enter the QWidget */ - void Init( SALOME_Selection* Sel ) ; - void MakeMirrorSimulationAndDisplay( const TopoDS_Shape& S1, const TopoDS_Shape& S2 ) ; - GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ - GEOMBase_Context* 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 */ - TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */ - bool myOkShape1 ; - bool myOkShape2 ; /* to check when arguments are defined */ - int myConstructorId ; /* Current constructor id = radio button id */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ Handle(GEOM_FaceFilter) myFaceFilter; /* To filter selections */ - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - QGroupBox* GroupC1; - QLabel* TextLabelC1A1; - QLabel* TextLabelC1A2; - QPushButton* SelectButtonC1A1; - QPushButton* SelectButtonC1A2; - QLineEdit* LineEditC1A1; - QLineEdit* LineEditC1A2; + 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 */ -private slots : + DlgRef_2Sel_QTD* GroupPoints; - void ConstructorsClicked(int constructorId); +private slots : void ClickOnOk(); - void ClickOnCancel(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); -protected: - QGridLayout* TransformationGUI_MirrorDlgLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupC1Layout; }; #endif // DIALOGBOX_MIRROR_H diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx index c20bebea8..7bd262bc2 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx @@ -30,25 +30,10 @@ using namespace std; #include "TransformationGUI_RotationDlg.h" #include "QAD_Config.h" - +//#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - //================================================================================= // class : TransformationGUI_RotationDlg() // purpose : Constructs a TransformationGUI_RotationDlg which is a child of 'parent', with the @@ -56,276 +41,120 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -TransformationGUI_RotationDlg::TransformationGUI_RotationDlg( QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +TransformationGUI_RotationDlg::TransformationGUI_RotationDlg(QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_ROTATION"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); - - if ( !name ) - setName( "TransformationGUI_RotationDlg" ); - resize( 303, 251 ); - setCaption( tr( "GEOM_ROTATION_TITLE" ) ); - setSizeGripEnabled( TRUE ); - TransformationGUI_RotationDlgLayout = new QGridLayout( this ); - TransformationGUI_RotationDlgLayout->setSpacing( 6 ); - TransformationGUI_RotationDlgLayout->setMargin( 11 ); - - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "GEOM_ROTATION" ) ); - 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 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - TransformationGUI_RotationDlgLayout->addWidget( GroupConstructors, 0, 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 ); - TransformationGUI_RotationDlgLayout->addWidget( GroupButtons, 2, 0 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) ); - GroupC1->setFrameShape( QGroupBox::Box ); - GroupC1->setFrameShadow( QGroupBox::Sunken ); - 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 ); - SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); - SelectButtonC1A2->setText( tr( "" ) ); - SelectButtonC1A2->setPixmap( image1 ); - SelectButtonC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, - SelectButtonC1A2->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); - - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 2, 3 ); - LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); - GroupC1Layout->addMultiCellWidget( LineEditC1A2, 1, 1, 2, 3 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - SelectButtonC1A1->setToggleButton( FALSE ); - SelectButtonC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, - SelectButtonC1A1->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "GEOM_OBJECT" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" ); - TextLabelC1A2->setText( tr( "GEOM_AXIS" ) ); - TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); - GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); - - SpinBox_C1A3 = new DlgRef_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ; - GroupC1Layout->addWidget( SpinBox_C1A3, 2, 3 ); - - TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" ); - TextLabelC1A3->setText( tr( "GEOM_ANGLE" ) ); - TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) ); - GroupC1Layout->addWidget( TextLabelC1A3, 2, 2 ); - CheckBoxReverse = new QCheckBox( GroupC1, "CheckBoxReverse" ); - CheckBoxReverse->setText( tr( "GEOM_REVERSE" ) ); - GroupC1Layout->addMultiCellWidget( CheckBoxReverse, 2, 2, 0, 1 ); - TransformationGUI_RotationDlgLayout->addWidget( GroupC1, 1, 0 ); - myTransformationGUI = theTransformationGUI; - Init(Sel) ; /* Initialisations */ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_ROTATION"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_ROTATION_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_ROTATION")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_2Sel1Spin1Check(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_OBJECT")); + GroupPoints->TextLabel2->setText(tr("GEOM_AXIS")); + GroupPoints->TextLabel3->setText(tr("GEOM_ANGLE")); + GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->PushButton2->setPixmap(image1); + + Layout1->addWidget(GroupPoints, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myTransformationGUI = theTransformationGUI; + Init(); } + //================================================================================= // function : ~TransformationGUI_RotationDlg() // purpose : Destroys the object and frees any allocated resources //================================================================================= TransformationGUI_RotationDlg::~TransformationGUI_RotationDlg() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us } + //================================================================================= // function : Init() // purpose : //================================================================================= -void TransformationGUI_RotationDlg::Init( SALOME_Selection* Sel ) +void TransformationGUI_RotationDlg::Init() { + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myAngle = 45.0; + myOkBase = myOkAxis = false; + + myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); /* Get setting of step value from file configuration */ - double step ; - QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ; - step = St.toDouble() ; - - /* min, max, step and decimals for spin boxes */ - SpinBox_C1A3->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; - SpinBox_C1A3->SetValue( 45.0 ) ; /* = myAngle */ - myAngle = 45.0 ; - - GroupC1->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - myGeomGUI = GEOMBase_Context::GetGeomGUI() ; - myOkBase = myOkAxis = false ; - mySimulationTopoDs.Nullify() ; - myBase.Nullify() ; - myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; - - // TODO : set 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 ); + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); + + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupPoints->SpinBox_DX->SetValue(myAngle); /* 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( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - - connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( CheckBoxReverse, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle(int) ) ) ; - - 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 ; -} + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); -//================================================================================= -// function : ReverseAngle() -// purpose : 'state' not used here -//================================================================================= -void TransformationGUI_RotationDlg::ReverseAngle(int state) -{ - myAngle = -myAngle ; - SpinBox_C1A3->SetValue( myAngle ) ; - if( myOkBase && myOkAxis ) { - MakeRotationSimulationAndDisplay( myBase ) ; - } - else { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - } - return ; -} + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void TransformationGUI_RotationDlg::ConstructorsClicked(int constructorId) -{ - /* only a constructor now */ - return ; + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseVector(int))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + /* displays Dialog */ + GroupPoints->show(); + this->show(); + + return; } + //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void TransformationGUI_RotationDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - return ; + this->ClickOnApply(); + ClickOnCancel(); + return; } + //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void TransformationGUI_RotationDlg::ClickOnApply() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - myGeomGUI->GetDesktop()->putInfo( tr("") ) ; - - switch(myConstructorId) - { - case 0 : - { - if(myOkBase && myOkAxis) { - myTransformationGUI->MakeRotationAndDisplay( myGeomShape, myLoc, myDir, myAngle*PI180) ; - } - break ; - } - } - return ; -} - - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void TransformationGUI_RotationDlg::ClickOnCancel() -{ - mySelection->ClearFilters() ; - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->ResetState() ; - reject() ; - return ; + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkBase && myOkAxis) + myTransformationGUI->MakeRotationAndDisplay(myGeomShape, myLoc, myDir, myAngle*PI180); + return; } @@ -335,52 +164,46 @@ void TransformationGUI_RotationDlg::ClickOnCancel() //================================================================================= void TransformationGUI_RotationDlg::SelectionIntoArgument() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - - QString aString = ""; /* name of future selection */ - - int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - if ( nbSel != 1 ) { - if ( myEditCurrentArgument == LineEditC1A1 ) { - LineEditC1A1->setText("") ; - myOkBase = false ; - } - else if ( myEditCurrentArgument == LineEditC1A2 ) { - LineEditC1A2->setText("") ; - myOkAxis = false ; - } - return ; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkBase = false; + else if(myEditCurrentArgument == GroupPoints->LineEdit2) + myOkAxis = false; + return; } - - /* nbSel == 1 ! */ - TopoDS_Shape S; - Standard_Boolean testResult ; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) - return ; - - if ( myEditCurrentArgument == LineEditC1A1 ) { - myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) - return ; - LineEditC1A1->setText(aString) ; - myBase = S ; - myOkBase = true ; - } - else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, myLoc, myDir) */) { + // nbSel == 1 + TopoDS_Shape S; + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + if(myEditCurrentArgument == GroupPoints->LineEdit1) { + myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myEditCurrentArgument->setText(aString); + myOkBase = true; + myBase = S; + } + else if(myEditCurrentArgument == GroupPoints->LineEdit2) { BRepAdaptor_Curve curv(TopoDS::Edge(S)); myDir = curv.Line().Direction(); myLoc = curv.Line().Location(); - LineEditC1A2->setText(aString) ; - myOkAxis = true ; + myEditCurrentArgument->setText(aString); + myOkAxis = true; } - if( myOkBase && myOkAxis ) { - MakeRotationSimulationAndDisplay( myBase) ; - } - return ; + if(myOkBase && myOkAxis) + this->MakeRotationSimulationAndDisplay(); + return; } @@ -391,25 +214,20 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument() void TransformationGUI_RotationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; - mySelection->ClearFilters() ; - } - else if(send == SelectButtonC1A2) { - LineEditC1A2->setFocus() ; - myEditCurrentArgument = LineEditC1A2; - mySelection->AddFilter(myEdgeFilter) ; - } - SelectionIntoArgument() ; - break; - } - } - return ; + mySelection->ClearFilters(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + mySelection->AddFilter(myEdgeFilter); + } + this->SelectionIntoArgument(); + + return; } @@ -419,59 +237,16 @@ void TransformationGUI_RotationDlg::SetEditCurrentArgument() //================================================================================= void TransformationGUI_RotationDlg::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. */ - const QString objectUserName = myEditCurrentArgument->text() ; - QWidget* thisWidget = (QWidget*)this ; - if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) { - myEditCurrentArgument->setText( objectUserName ) ; - } - return ; -} + return; - -//================================================================================= -// function : ValueChangedInSpinBox() -// purpose : -//================================================================================= -void TransformationGUI_RotationDlg::ValueChangedInSpinBox( double newValue ) -{ - myAngle = newValue ; - if (myOkBase && myOkAxis) { - MakeRotationSimulationAndDisplay(myBase) ; - } - else { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - } - return ; -} - - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void TransformationGUI_RotationDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->EraseSimulationShape() ; - mySelection->ClearFilters() ; - } - return ; + GEOMBase_Skeleton::LineEditReturnPressed(); + return; } @@ -481,39 +256,37 @@ void TransformationGUI_RotationDlg::DeactivateActiveDialog() //================================================================================= void TransformationGUI_RotationDlg::ActivateThisDialog() { - /* Emit a signal to deactivate the active dialog */ - myGeomGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - if( !mySimulationTopoDs.IsNull() ) - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; - return ; + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; } - //================================================================================= // function : enterEvent() // purpose : //================================================================================= void TransformationGUI_RotationDlg::enterEvent(QEvent* e) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; } - //================================================================================= -// function : closeEvent() +// function : ValueChangedInSpinBox() // purpose : //================================================================================= -void TransformationGUI_RotationDlg::closeEvent( QCloseEvent* e ) +void TransformationGUI_RotationDlg::ValueChangedInSpinBox(double newValue) { - this->ClickOnCancel() ; /* same than click on cancel button */ + myAngle = newValue; + if(myOkBase && myOkAxis) + MakeRotationSimulationAndDisplay(); + return; } @@ -521,24 +294,36 @@ void TransformationGUI_RotationDlg::closeEvent( QCloseEvent* e ) // function : MakeRotationSimulationAndDisplay() // purpose : //================================================================================= -void TransformationGUI_RotationDlg::MakeRotationSimulationAndDisplay( const TopoDS_Shape& S) +void TransformationGUI_RotationDlg::MakeRotationSimulationAndDisplay() { - myGeomGUI->EraseSimulationShape() ; - - if( S.IsNull() ) - return ; - + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + try { - gp_Ax1 AX( this->myLoc, this->myDir ) ; - gp_Trsf theTransformation ; - theTransformation.SetRotation(AX, this->myAngle*PI180 ) ; - BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False) ; - this->mySimulationTopoDs = myBRepTransformation.Shape() ; - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + gp_Ax1 AX(myLoc, myDir); + gp_Trsf theTransformation; + theTransformation.SetRotation(AX, myAngle*PI180); + BRepBuilderAPI_Transform myBRepTransformation(myBase, theTransformation, Standard_False); + this->mySimulationTopoDs = myBRepTransformation.Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); } catch(Standard_Failure) { - MESSAGE( "Exception catched in MakeRotationSimulationAndDisplay" ) ; - return ; + MESSAGE("Exception catched in MakeRotationSimulationAndDisplay"); + return; } - return ; + return; +} + + +//================================================================================= +// function : ReverseAngle() +// purpose : 'state' not used here +//================================================================================= +void TransformationGUI_RotationDlg::ReverseAngle(int state) +{ + myAngle = -myAngle; + GroupPoints->SpinBox_DX->SetValue(myAngle); + if(myOkBase && myOkAxis) + MakeRotationSimulationAndDisplay(); + return; } diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.h b/src/TransformationGUI/TransformationGUI_RotationDlg.h index 49d5dca03..9938d4d0c 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.h +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.h @@ -29,101 +29,55 @@ #ifndef DIALOGBOX_ROTATION_H #define DIALOGBOX_ROTATION_H -#include "TransformationGUI.h" +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel1Spin1Check.h" -#include "GEOM_EdgeFilter.hxx" -#include "DlgRef_SpinBox.h" +#include "TransformationGUI.h" -#include -#include #include -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QCheckBox; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; - //================================================================================= // class : TransformationGUI_RotationDlg // purpose : //================================================================================= -class TransformationGUI_RotationDlg : public QDialog +class TransformationGUI_RotationDlg : public GEOMBase_Skeleton { Q_OBJECT public: - TransformationGUI_RotationDlg( QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + TransformationGUI_RotationDlg(QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~TransformationGUI_RotationDlg(); private : + void Init(); + void enterEvent(QEvent* e); + void MakeRotationSimulationAndDisplay(); + TransformationGUI* myTransformationGUI; - GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */ - GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */ - TopoDS_Shape myBase ; - GEOM::GEOM_Shape_var myGeomShape ; /* is myBase */ - gp_Pnt myLoc ; - gp_Dir myDir ; - Standard_Real myAngle ; - - bool myOkBase ; - bool myOkAxis ; - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ - int myConstructorId ; /* Current constructor id = radio button id */ - Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ + double step; + Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filters selection */ - void closeEvent( QCloseEvent* e ) ; - void enterEvent( QEvent* e); - void Init( SALOME_Selection* Sel ) ; - void MakeRotationSimulationAndDisplay( const TopoDS_Shape& S) ; + TopoDS_Shape myBase; + GEOM::GEOM_Shape_var myGeomShape; /* is myBase */ + gp_Pnt myLoc; + gp_Dir myDir; + Standard_Real myAngle; + bool myOkBase; + bool myOkAxis; - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - QGroupBox* GroupButtons; - QPushButton* buttonOk; - QPushButton* buttonCancel; - QPushButton* buttonApply; - QGroupBox* GroupC1; - QPushButton* SelectButtonC1A2; - QLineEdit* LineEditC1A1; - QLineEdit* LineEditC1A2; - QPushButton* SelectButtonC1A1; - QLabel* TextLabelC1A1; - QLabel* TextLabelC1A2; - DlgRef_SpinBox* SpinBox_C1A3 ; /* for angle */ - QLabel* TextLabelC1A3; - QCheckBox* CheckBoxReverse; + DlgRef_2Sel1Spin1Check* GroupPoints; private slots: - - void ConstructorsClicked(int constructorId); void ClickOnOk(); - void ClickOnCancel(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void ReverseAngle(int state) ; - void ValueChangedInSpinBox( double newValue ) ; + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ReverseAngle(int state); + void ValueChangedInSpinBox(double newValue); -protected: - QGridLayout* TransformationGUI_RotationDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupC1Layout; }; #endif // DIALOGBOX_ROTATION_H diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx index ac09f84c4..87f03db61 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx @@ -31,21 +31,6 @@ using namespace std; #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - //================================================================================= // class : TransformationGUI_ScaleDlg() // purpose : Constructs a TransformationGUI_ScaleDlg which is a child of 'parent', with the @@ -53,118 +38,37 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg( QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg(QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_SCALE"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); - - if ( !name ) - setName( "TransformationGUI_ScaleDlg" ); - resize( 303, 253 ); - setCaption( tr( "GEOM_SCALE_TITLE" ) ); - setSizeGripEnabled( TRUE ); - TransformationGUI_ScaleDlgLayout = new QGridLayout( this ); - TransformationGUI_ScaleDlgLayout->setSpacing( 6 ); - TransformationGUI_ScaleDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "GEOM_SCALE" ) ); - 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 ); - TransformationGUI_ScaleDlgLayout->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 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "GEOM_OBJECT" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" ); - TextLabelC1A2->setText( tr( "GEOM_CENTRAL_POINT" ) ); - TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A2->setFrameShape( QLabel::NoFrame ); - TextLabelC1A2->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); - SelectButtonC1A2->setText( tr( "" ) ); - SelectButtonC1A2->setPixmap( image1 ); - GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); - GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); - LineEditC1A3 = new QLineEdit( GroupC1, "LineEditC1A3" ); - GroupC1Layout->addWidget( LineEditC1A3, 2, 2 ); - TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" ); - TextLabelC1A3->setText( tr( "GEOM_SCALE_FACTOR" ) ); - TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) ); - GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 ); - TransformationGUI_ScaleDlgLayout->addWidget( GroupC1, 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 ); - TransformationGUI_ScaleDlgLayout->addWidget( GroupButtons, 2, 0 ); - myTransformationGUI = theTransformationGUI; - /* Initialisation */ - Init( Sel ) ; + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_SCALE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_SCALE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_SCALE")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_2Sel1Spin(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_OBJECT")); + GroupPoints->TextLabel2->setText(tr("GEOM_CENTRAL_POINT")); + GroupPoints->TextLabel3->setText(tr("GEOM_SCALE_FACTOR")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->PushButton2->setPixmap(image1); + + Layout1->addWidget(GroupPoints, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myTransformationGUI = theTransformationGUI; + Init(); } + //================================================================================= // function : ~TransformationGUI_ScaleDlg() // purpose : Destroys the object and frees any allocated resources @@ -179,287 +83,166 @@ TransformationGUI_ScaleDlg::~TransformationGUI_ScaleDlg() // function : Init() // purpose : //================================================================================= -void TransformationGUI_ScaleDlg::Init( SALOME_Selection* Sel ) +void TransformationGUI_ScaleDlg::Init() { + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; - LineEditC1A3->setMaxLength( 10 ); - QDoubleValidator *Va = new QDoubleValidator( -999999, +999999, 3, LineEditC1A3 ) ; - LineEditC1A3->setValidator( Va ) ; - - GroupC1->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - myGeomGUI = GEOMBase_Context::GetGeomGUI() ; - myPoint1.SetCoord( 0.0, 0.0, 0.0 ); - myOkPoint1 = myOkBaseTopo = false ; - myFactor = 2.0 ; - LineEditC1A3->setText("2.0") ; - mySimulationTopoDs.Nullify() ; - myBaseTopo.Nullify() ; - myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; - - // TODO : previous selection into argument ? - - /* 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 */ + myPoint1.SetCoord(0.0, 0.0, 0.0); + myOkPoint1 = myOkBaseTopo = false; + myFactor = 2.0; - /* 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( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - - connect( LineEditC1A3, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ; - 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 */ + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - return ; -} + /* Get setting of step value from file configuration */ + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupPoints->SpinBox_DX->SetValue(myFactor); -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void TransformationGUI_ScaleDlg::ConstructorsClicked(int constructorId) -{ - myGeomGUI->EraseSimulationShape() ; - - switch (constructorId) - { - case 0: - { - GroupC1->show(); - myConstructorId = constructorId ; - myEditCurrentArgument = LineEditC1A1 ; - Constructor1->setChecked( TRUE ); - LineEditC1A1->setText(tr("")) ; - LineEditC1A2->setText(tr("")) ; - myOkPoint1 = myOkBaseTopo = false ; - myFactor = 2.0 ; - /* filter for next selections */ - mySelection->ClearFilters() ; - mySelection->AddFilter( myVertexFilter ); - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - break; - } - } - return ; -} + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void TransformationGUI_ScaleDlg::ClickOnOk() -{ - this->ClickOnApply() ; - this->ClickOnCancel() ; + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - return ; -} + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void TransformationGUI_ScaleDlg::ClickOnApply() -{ - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - myGeomGUI->GetDesktop()->putInfo( tr("") ) ; - - switch(myConstructorId) - { - case 0 : - { - if( myOkBaseTopo && myOkPoint1 ) - myTransformationGUI->MakeScaleAndDisplay(myGeomShape, myPoint1, myFactor ) ; - break ; - } - } - // accept(); - return ; -} + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + /* displays Dialog */ + GroupPoints->show(); + this->show(); -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void TransformationGUI_ScaleDlg::ClickOnCancel() -{ - mySelection->ClearFilters() ; - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->ResetState() ; - reject() ; - return ; + return; } + //================================================================================= -// function : LineEditReturnPressed() +// function : ClickOnOk() // purpose : //================================================================================= -void TransformationGUI_ScaleDlg::LineEditReturnPressed() +void TransformationGUI_ScaleDlg::ClickOnOk() { - QLineEdit* send = (QLineEdit*)sender(); - if( send == LineEditC1A1 ) - myEditCurrentArgument = LineEditC1A1 ; - else if ( send == LineEditC1A2 ) - myEditCurrentArgument = LineEditC1A2 ; - 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 ; + this->ClickOnApply(); + ClickOnCancel(); + return; } //================================================================================= -// function : TextChangedInLineEdit() +// function : ClickOnApply() // purpose : //================================================================================= -void TransformationGUI_ScaleDlg::TextChangedInLineEdit(const QString& newText) +void TransformationGUI_ScaleDlg::ClickOnApply() { - QLineEdit* send = (QLineEdit*)sender(); - if(send == LineEditC1A3) { - myGeomGUI->EraseSimulationShape() ; - myFactor = newText.toFloat(); - if( fabs(myFactor) > 0.00001 && myOkBaseTopo && myOkPoint1 ) - MakeScaleSimulationAndDisplay(myBaseTopo) ; - } - return ; + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkBaseTopo && myOkPoint1) + myTransformationGUI->MakeScaleAndDisplay(myGeomShape, myPoint1, myFactor); + return; } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case //================================================================================= void TransformationGUI_ScaleDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText("") ; - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + myEditCurrentArgument->setText(""); QString aString = ""; /* name of selection */ - - int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - if ( nbSel != 1 ) { - if ( myEditCurrentArgument == LineEditC1A1 ) { - myEditCurrentArgument->setText("") ; - myOkBaseTopo = false ; - } - else if ( myEditCurrentArgument == LineEditC1A2 ) { - myEditCurrentArgument->setText("") ; - myOkPoint1 = false ; - } - return ; + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if (nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkBaseTopo = false; + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myOkPoint1 = false; + return; } - // nbSel == 1 + /* nbSel == 1 */ TopoDS_Shape S; - Standard_Boolean testResult ; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) - return ; - - /* Constructor */ - if ( myEditCurrentArgument == LineEditC1A1 ) { - myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + /* gp_Pnt : not used */ + if(myEditCurrentArgument == GroupPoints->LineEdit1) { + myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) return ; - myEditCurrentArgument->setText(aString) ; - myBaseTopo = S ; - myOkBaseTopo = true ; + GroupPoints->LineEdit1->setText(aString); + myBaseTopo = S; + myOkBaseTopo = true; + } + else if(myEditCurrentArgument == GroupPoints->LineEdit2 && myGeomGUI->VertexToPoint(S, myPoint1)) { + GroupPoints->LineEdit2->setText(aString); + myOkPoint1 = true; } - else if ( myEditCurrentArgument == LineEditC1A2 && myGeomGUI->VertexToPoint(S, myPoint1) ) { - myEditCurrentArgument->setText(aString) ; - myOkPoint1 = true ; - } - - if( myOkBaseTopo && myOkPoint1 ) { - MakeScaleSimulationAndDisplay( myBaseTopo ) ; - } - return ; + + if(myOkPoint1 && myOkBaseTopo) + this->MakeScaleSimulationAndDisplay(); + return; } //================================================================================= -// function : SetEditCurrentArgument() +// function : LineEditReturnPressed() // purpose : //================================================================================= -void TransformationGUI_ScaleDlg::SetEditCurrentArgument() +void TransformationGUI_ScaleDlg::LineEditReturnPressed() { - QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; - mySelection->ClearFilters() ; - SelectionIntoArgument() ; - } - else if(send == SelectButtonC1A2) { - LineEditC1A2->setFocus() ; - myEditCurrentArgument = LineEditC1A2; - mySelection->AddFilter(myVertexFilter) ; - SelectionIntoArgument() ; - } - break; - } - } - return ; + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupPoints->LineEdit1) + myEditCurrentArgument = GroupPoints->LineEdit1; + else if (send == GroupPoints->LineEdit2) + myEditCurrentArgument = GroupPoints->LineEdit2; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); + return; } //================================================================================= -// function : DeactivateActiveDialog() +// function : SetEditCurrentArgument() // purpose : //================================================================================= -void TransformationGUI_ScaleDlg::DeactivateActiveDialog() +void TransformationGUI_ScaleDlg::SetEditCurrentArgument() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->EraseSimulationShape() ; - mySelection->ClearFilters() ; + QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; } - return ; -} + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + mySelection->AddFilter(myVertexFilter); + } + this->SelectionIntoArgument(); + return; +} //================================================================================= @@ -468,17 +251,11 @@ void TransformationGUI_ScaleDlg::DeactivateActiveDialog() //================================================================================= void TransformationGUI_ScaleDlg::ActivateThisDialog() { - /* Emit a signal to deactivate the active dialog */ - myGeomGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - if( !mySimulationTopoDs.IsNull() ) - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; - - return ; + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; } @@ -488,19 +265,23 @@ void TransformationGUI_ScaleDlg::ActivateThisDialog() //================================================================================= void TransformationGUI_ScaleDlg::enterEvent(QEvent* e) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; } //================================================================================= -// function : closeEvent() +// function : ValueChangedInSpinBox() // purpose : //================================================================================= -void TransformationGUI_ScaleDlg::closeEvent( QCloseEvent* e ) +void TransformationGUI_ScaleDlg::ValueChangedInSpinBox(double newValue) { - this->ClickOnCancel() ; /* same than click on cancel button */ + myFactor = newValue; + if(fabs(myFactor) > 0.00001 && myOkPoint1 && myOkBaseTopo) + MakeScaleSimulationAndDisplay(); + return; } @@ -508,23 +289,24 @@ void TransformationGUI_ScaleDlg::closeEvent( QCloseEvent* e ) // function : MakeScaleSimulationAndDisplay() // purpose : //================================================================================= -void TransformationGUI_ScaleDlg::MakeScaleSimulationAndDisplay( const TopoDS_Shape& S ) +void TransformationGUI_ScaleDlg::MakeScaleSimulationAndDisplay() { - this->mySimulationTopoDs.Nullify() ; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); try { - gp_Trsf theTransformation ; - theTransformation.SetScale( myPoint1, myFactor) ; - BRepBuilderAPI_Transform myBRepTransformation( S, theTransformation, Standard_False) ; - mySimulationTopoDs = myBRepTransformation.Shape() ; - if( mySimulationTopoDs.IsNull() ) - return ; + gp_Trsf theTransformation; + theTransformation.SetScale(myPoint1, myFactor); + BRepBuilderAPI_Transform myBRepTransformation(myBaseTopo, theTransformation, Standard_False); + mySimulationTopoDs = myBRepTransformation.Shape(); + if(mySimulationTopoDs.IsNull()) + return; else - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); } catch(Standard_Failure) { - MESSAGE( "Exception catched in MakeScaleSimulationAndDisplay" ) ; - return ; + MESSAGE("Exception catched in MakeScaleSimulationAndDisplay"); + return; } - return ; + return; } diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.h b/src/TransformationGUI/TransformationGUI_ScaleDlg.h index 57b779f08..03cd2cdd4 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.h +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.h @@ -29,89 +29,51 @@ #ifndef DIALOGBOX_SCALE_H #define DIALOGBOX_SCALE_H -#include "TransformationGUI.h" - -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel1Spin.h" +#include "TransformationGUI.h" //================================================================================= // class : TransformationGUI_ScaleDlg // purpose : //================================================================================= -class TransformationGUI_ScaleDlg : public QDialog +class TransformationGUI_ScaleDlg : public GEOMBase_Skeleton { Q_OBJECT public: - TransformationGUI_ScaleDlg( QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + TransformationGUI_ScaleDlg(QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~TransformationGUI_ScaleDlg(); private : - TransformationGUI* myTransformationGUI; - void closeEvent( QCloseEvent* e ) ; - void enterEvent( QEvent* e ); - void Init(SALOME_Selection* Sel) ; - void MakeScaleSimulationAndDisplay( const TopoDS_Shape& S ) ; + void Init(); + void enterEvent(QEvent* e); + void MakeScaleSimulationAndDisplay(); + + TransformationGUI* myTransformationGUI; + + double step; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; - GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ - GEOMBase_Context* 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 */ - TopoDS_Shape myBaseTopo ; - GEOM::GEOM_Shape_var myGeomShape ; /* is myBaseTopo */ - Standard_Real myFactor ; - bool myOkPoint1 ; /* true when myPoint1 is defined */ - bool myOkBaseTopo ; /* true when myBaseTopo is defined */ - int myConstructorId ; /* Current constructor id = radio button id */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ - Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* filter for selection */ + gp_Pnt myPoint1; /* Points containing the vector */ + bool myOkPoint1; /* true when myPoint1 is defined */ + TopoDS_Shape myBaseTopo; + bool myOkBaseTopo; /* true when myBaseTopo is defined */ + GEOM::GEOM_Shape_var myGeomShape; /* is myBaseTopo */ + Standard_Real myFactor; - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - QGroupBox* GroupC1; - QLabel* TextLabelC1A1; - QLabel* TextLabelC1A2; - QPushButton* SelectButtonC1A1; - QPushButton* SelectButtonC1A2; - QLineEdit* LineEditC1A1; - QLineEdit* LineEditC1A2; - QLineEdit* LineEditC1A3; - QLabel* TextLabelC1A3; - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; + DlgRef_2Sel1Spin* GroupPoints; private slots : - - void ConstructorsClicked(int constructorId); void ClickOnOk(); - void ClickOnCancel(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void TextChangedInLineEdit(const QString& newText) ; + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ValueChangedInSpinBox(double newValue); -protected: - QGridLayout* TransformationGUI_ScaleDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupC1Layout; - QGridLayout* GroupButtonsLayout; }; #endif // DIALOGBOX_SCALE_H diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx index 03236f9c4..4d33edfed 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx @@ -29,26 +29,7 @@ using namespace std; #include "TransformationGUI_TranslationDlg.h" - -#include "QAD_Config.h" - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - +#include //================================================================================= // class : TransformationGUI_TranslationDlg() @@ -57,148 +38,44 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -TransformationGUI_TranslationDlg::TransformationGUI_TranslationDlg( QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +TransformationGUI_TranslationDlg::TransformationGUI_TranslationDlg(QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_TRANSLATION"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); - - if ( !name ) - setName( "TransformationGUI_TranslationDlg" ); - resize( 303, 219 ); - setCaption( tr( "GEOM_TRANSLATION_TITLE" ) ); - setSizeGripEnabled( TRUE ); - TransformationGUI_TranslationDlgLayout = new QGridLayout( this ); - TransformationGUI_TranslationDlgLayout->setSpacing( 6 ); - TransformationGUI_TranslationDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "GEOM_TRANSLATION" ) ); - 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 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - TransformationGUI_TranslationDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "GEOM_TRANSLATION" ) ) ; - GroupC1->setMinimumSize( QSize( 0, 0 ) ); - GroupC1->setFrameShape( QGroupBox::Box ); - GroupC1->setFrameShadow( QGroupBox::Sunken ); - GroupC1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)5, GroupC1->sizePolicy().hasHeightForWidth() ) ); - 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 ); - - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "GEOM_OBJECT" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - SelectButtonC1A1->setToggleButton( FALSE ); - SelectButtonC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, SelectButtonC1A1->sizePolicy().hasHeightForWidth() ) ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - - Layout1 = new QHBoxLayout; - Layout1->setSpacing( 6 ); - Layout1->setMargin( 0 ); - - TextLabel_DX = new QLabel( GroupC1, "TextLabel_DX" ); - TextLabel_DX->setText( tr( "GEOM_DX" ) ); - Layout1->addWidget( TextLabel_DX ); - - SpinBox_DX = new DlgRef_SpinBox( GroupC1, "SpinBox_DX" ); - SpinBox_DX->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DX->sizePolicy().hasHeightForWidth() ) ); - Layout1->addWidget( SpinBox_DX ); - - TextLabel_DY = new QLabel( GroupC1, "TextLabel_DY" ); - TextLabel_DY->setText( tr( "GEOM_DY" ) ); - Layout1->addWidget( TextLabel_DY ); - - SpinBox_DY = new DlgRef_SpinBox( GroupC1, "SpinBox_DY" ); - SpinBox_DY->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DY->sizePolicy().hasHeightForWidth() ) ); - Layout1->addWidget( SpinBox_DY ); - - TextLabel_DZ = new QLabel( GroupC1, "TextLabel_DZ" ); - TextLabel_DZ->setText( tr( "GEOM_DZ" ) ); - Layout1->addWidget( TextLabel_DZ ); - - SpinBox_DZ = new DlgRef_SpinBox( GroupC1, "SpinBox_DZ" ); - SpinBox_DZ->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DZ->sizePolicy().hasHeightForWidth() ) ); - Layout1->addWidget( SpinBox_DZ ); - - GroupC1Layout->addMultiCellLayout( Layout1, 1, 1, 0, 2 ); - - TransformationGUI_TranslationDlgLayout->addWidget( GroupC1, 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 ); - TransformationGUI_TranslationDlgLayout->addWidget( GroupButtons, 2, 0 ); - /***************************************************************/ - myTransformationGUI = theTransformationGUI; - Init(Sel) ; /* Initialisations */ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_TRANSLATION"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_TRANSLATION_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_TRANSLATION")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_1Sel3Spin(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_OBJECT")); + GroupPoints->TextLabel2->setText(tr("GEOM_DX")); + GroupPoints->TextLabel3->setText(tr("GEOM_DY")); + GroupPoints->TextLabel4->setText(tr("GEOM_DZ")); + GroupPoints->PushButton1->setPixmap(image1); + + Layout1->addWidget(GroupPoints, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myTransformationGUI = theTransformationGUI; + Init(); } - //================================================================================= // function : ~TransformationGUI_TranslationDlg() // purpose : Destroys the object and frees any allocated resources //================================================================================= TransformationGUI_TranslationDlg::~TransformationGUI_TranslationDlg() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us } @@ -206,142 +83,79 @@ TransformationGUI_TranslationDlg::~TransformationGUI_TranslationDlg() // function : Init() // purpose : //================================================================================= -void TransformationGUI_TranslationDlg::Init( SALOME_Selection* Sel ) +void TransformationGUI_TranslationDlg::Init() { - double step ; - QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ; - step = St.toDouble() ; - - /* min, max, step and decimals for spin boxes */ - SpinBox_DX->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; - SpinBox_DX->SetValue( 100.0 ) ; - SpinBox_DY->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; - SpinBox_DY->SetValue( 100.0 ) ; - SpinBox_DZ->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; - SpinBox_DZ->SetValue( 100.0 ) ; - - GroupC1->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - myGeomGUI = GEOMBase_Context::GetGeomGUI() ; - myOkBase = false ; - - this->myVec.SetCoord( 100.0, 100.0, 100.0 ) ; - mySimulationTopoDs.Nullify() ; - myBase.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_ShapeTypeFilter( TopAbs_EDGE, myGeom ); + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myVec.SetCoord(100.0, 100.0, 100.0); + myOkBase = false; + + /* Get setting of step value from file configuration */ + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); + + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupPoints->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupPoints->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); + + GroupPoints->SpinBox_DX->SetValue(100.0); + GroupPoints->SpinBox_DY->SetValue(100.0); + GroupPoints->SpinBox_DZ->SetValue(100.0); /* 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( SpinBox_DX, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_DY, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_DZ, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, 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() ) ) ; - - /* 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(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))); - return ; -} + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DZ, SLOT(SetStep(double))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + /* displays Dialog */ + GroupPoints->show(); + this->show(); -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void TransformationGUI_TranslationDlg::ConstructorsClicked(int constructorId) -{ - // myGeomGUI->EraseSimulationShape() ; - switch (constructorId) - { - case 0: - { - break; - } - case 1: - { - break; - } - } - return ; + return; } + //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void TransformationGUI_TranslationDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - - return ; + this->ClickOnApply(); + ClickOnCancel(); + return; } + //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void TransformationGUI_TranslationDlg::ClickOnApply() { - myGeomGUI->EraseSimulationShape() ; - myGeomGUI->GetDesktop()->putInfo( tr("") ) ; - mySimulationTopoDs.Nullify() ; - switch(myConstructorId) - { - case 0 : - { - if(myOkBase) { - myTransformationGUI->MakeTranslationAndDisplay( myGeomShape, myVec ) ; - } - break ; - } - case 1 : - { - break ; - } - } - - // accept(); - return ; -} - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void TransformationGUI_TranslationDlg::ClickOnCancel() -{ - mySelection->ClearFilters() ; - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->ResetState() ; - reject() ; - return ; + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkBase) + myTransformationGUI->MakeTranslationAndDisplay(myGeomShape, myVec); + return; } @@ -351,43 +165,38 @@ void TransformationGUI_TranslationDlg::ClickOnCancel() //================================================================================= void TransformationGUI_TranslationDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText("") ; - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - - /* Future name of selection */ - QString aString = ""; - - int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - if ( nbSel != 1 ) { - if ( myEditCurrentArgument == LineEditC1A1 ) { - LineEditC1A1->setText("") ; - myOkBase = false ; - } - return ; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if (nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkBase = false; + return; } - /* nbSel == 1 ! */ - TopoDS_Shape S; - Standard_Boolean testResult ; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - - if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) - return ; - - if ( myConstructorId == 0 && myEditCurrentArgument == LineEditC1A1 ) { - myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) + /* nbSel == 1 */ + TopoDS_Shape S; + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + /* gp_Pnt : not used */ + if(myEditCurrentArgument == GroupPoints->LineEdit1) { + myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) return ; - LineEditC1A1->setText(aString) ; - myBase = S ; - myOkBase = true ; + GroupPoints->LineEdit1->setText(aString); + myBase = S; + myOkBase = true; } - - if( myOkBase ) { - MakeTranslationSimulationAndDisplay() ; - } - return ; + + if(myOkBase) + this->MakeTranslationSimulationAndDisplay(); + return; } @@ -395,105 +204,34 @@ void TransformationGUI_TranslationDlg::SelectionIntoArgument() // function : SetEditCurrentArgument() // purpose : //================================================================================= -void TransformationGUI_TranslationDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1 ; - SelectionIntoArgument() ; - } - break; - } - case 1: - { - break; - } - } - return ; -} - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= void TransformationGUI_TranslationDlg::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. */ - const QString objectUserName = myEditCurrentArgument->text() ; - QWidget* thisWidget = (QWidget*)this ; - if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) { - myEditCurrentArgument->setText( objectUserName ) ; - } - return ; -} + return; + GEOMBase_Skeleton::LineEditReturnPressed(); + return; +} //================================================================================= -// function : ValueChangedInSpinBox() +// function : LineEditReturnPressed() // purpose : //================================================================================= -void TransformationGUI_TranslationDlg::ValueChangedInSpinBox( double newValue ) -{ - - QObject* send = (QObject*)sender() ; - Standard_Real Dx, Dy, Dz ; - - if( send == SpinBox_DX ) { - Dx = newValue ; - Dy = SpinBox_DY->GetValue() ; - Dz = SpinBox_DZ->GetValue() ; - } else if( send == SpinBox_DY ) { - Dx = SpinBox_DX->GetValue() ; - Dy = newValue ; - Dz = SpinBox_DZ->GetValue() ; - } else if( send == SpinBox_DZ ) { - Dx = SpinBox_DX->GetValue() ; - Dy = SpinBox_DY->GetValue() ; - Dz = newValue ; - } +void TransformationGUI_TranslationDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); - this->myVec.SetCoord(Dx, Dy, Dz) ; - if ( myOkBase ) { - MakeTranslationSimulationAndDisplay() ; + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + this->SelectionIntoArgument(); } - else { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - } - return ; -} - - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void TransformationGUI_TranslationDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->EraseSimulationShape() ; - mySelection->ClearFilters() ; - } - return ; + return; } @@ -503,17 +241,11 @@ void TransformationGUI_TranslationDlg::DeactivateActiveDialog() //================================================================================= void TransformationGUI_TranslationDlg::ActivateThisDialog() { - /* Emit a signal to deactivate the active dialog */ - myGeomGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - if( !mySimulationTopoDs.IsNull() ) - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; - - return ; + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; } @@ -523,22 +255,42 @@ void TransformationGUI_TranslationDlg::ActivateThisDialog() //================================================================================= void TransformationGUI_TranslationDlg::enterEvent(QEvent* e) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; } - //================================================================================= -// function : closeEvent() +// function : ValueChangedInSpinBox() // purpose : //================================================================================= -void TransformationGUI_TranslationDlg::closeEvent( QCloseEvent* e ) +void TransformationGUI_TranslationDlg::ValueChangedInSpinBox(double newValue) { - /* same than click on cancel button */ - this->ClickOnCancel() ; - return ; + QObject* send = (QObject*)sender(); + Standard_Real Dx, Dy, Dz; + + if(send == GroupPoints->SpinBox_DX) { + Dx = newValue; + Dy = GroupPoints->SpinBox_DY->GetValue(); + Dz = GroupPoints->SpinBox_DZ->GetValue(); + } + else if(send == GroupPoints->SpinBox_DY) { + Dx = GroupPoints->SpinBox_DX->GetValue(); + Dy = newValue; + Dz = GroupPoints->SpinBox_DZ->GetValue(); + } + else if(send == GroupPoints->SpinBox_DZ) { + Dx = GroupPoints->SpinBox_DX->GetValue(); + Dy = GroupPoints->SpinBox_DY->GetValue(); + Dz = newValue; + } + + myVec.SetCoord(Dx, Dy, Dz); + if(myOkBase) + MakeTranslationSimulationAndDisplay(); + return; } @@ -548,14 +300,22 @@ void TransformationGUI_TranslationDlg::closeEvent( QCloseEvent* e ) //================================================================================= void TransformationGUI_TranslationDlg::MakeTranslationSimulationAndDisplay() { - myGeomGUI->EraseSimulationShape() ; - mySimulationTopoDs.Nullify() ; - - gp_Trsf theTransformation ; - theTransformation.SetTranslation(this->myVec) ; - - BRepBuilderAPI_Transform myBRepTransformation(this->myBase, theTransformation, Standard_False) ; - mySimulationTopoDs = myBRepTransformation.Shape() ; - myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; - return ; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + try { + gp_Trsf theTransformation; + theTransformation.SetTranslation(myVec); + BRepBuilderAPI_Transform myBRepTransformation(myBase, theTransformation, Standard_False); + mySimulationTopoDs = myBRepTransformation.Shape(); + if(mySimulationTopoDs.IsNull()) + return; + else + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + catch(Standard_Failure) { + MESSAGE("Exception catched in MakeTranslationSimulationAndDisplay"); + return; + } + return; } diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.h b/src/TransformationGUI/TransformationGUI_TranslationDlg.h index 84c9691a1..52334bc22 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.h +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.h @@ -29,98 +29,49 @@ #ifndef DIALOGBOX_TRANSLATION_H #define DIALOGBOX_TRANSLATION_H -#include "TransformationGUI.h" +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel3Spin.h" -#include "DlgRef_SpinBox.h" +#include "TransformationGUI.h" #include -#include -#include - -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; - //================================================================================= // class : TransformationGUI_TranslationDlg // purpose : //================================================================================= -class TransformationGUI_TranslationDlg : public QDialog +class TransformationGUI_TranslationDlg : public GEOMBase_Skeleton { Q_OBJECT public: - TransformationGUI_TranslationDlg( QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + TransformationGUI_TranslationDlg(QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~TransformationGUI_TranslationDlg(); private : - TransformationGUI* myTransformationGUI; - GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */ - GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ - TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */ - SALOME_Selection* mySelection ; /* User shape selection */ - TopoDS_Shape myBase ; - GEOM::GEOM_Shape_var myGeomShape ; /* is myBase */ - bool myOkBase ; - gp_Vec myVec ; - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ - int myConstructorId ; /* Current constructor id = radio button id */ - Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filter selection */ - - void closeEvent( QCloseEvent* e ) ; - void enterEvent( QEvent* e); - void Init( SALOME_Selection* Sel ) ; - void MakeTranslationSimulationAndDisplay() ; - - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - QGroupBox* GroupC1; - QLabel* TextLabel_DX; - QLabel* TextLabel_DY; - QLabel* TextLabel_DZ; + void Init(); + void enterEvent(QEvent* e); + void MakeTranslationSimulationAndDisplay(); - DlgRef_SpinBox* SpinBox_DX ; - DlgRef_SpinBox* SpinBox_DY ; - DlgRef_SpinBox* SpinBox_DZ ; + TransformationGUI* myTransformationGUI; + double step; - QLabel* TextLabelC1A1; - QPushButton* SelectButtonC1A1; - QLineEdit* LineEditC1A1; - QGroupBox* GroupButtons; - QPushButton* buttonOk; - QPushButton* buttonCancel; - QPushButton* buttonApply; + TopoDS_Shape myBase; /* is myBase */ + GEOM::GEOM_Shape_var myGeomShape; + bool myOkBase; + gp_Vec myVec; -private slots: + DlgRef_1Sel3Spin* GroupPoints; - void ConstructorsClicked(int constructorId); +private slots : void ClickOnOk(); - void ClickOnCancel(); void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void ValueChangedInSpinBox( double newValue ) ; - -protected: - QGridLayout* TransformationGUI_TranslationDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupC1Layout; - QGridLayout* GroupButtonsLayout; + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ValueChangedInSpinBox(double newValue); - QHBoxLayout* Layout1 ; }; #endif // DIALOGBOX_TRANSLATION_H -- 2.39.2