From: yfr Date: Fri, 3 Oct 2003 09:45:03 +0000 (+0000) Subject: DCQ : New GEOM Architecture X-Git-Tag: DCQ_03_12_03~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=66dbb45c38adca7f5815cb27622a608726722d0d;p=modules%2Fgeom.git DCQ : New GEOM Architecture --- diff --git a/src/BasicGUI/BasicGUI.cxx b/src/BasicGUI/BasicGUI.cxx new file mode 100644 index 000000000..697305166 --- /dev/null +++ b/src/BasicGUI/BasicGUI.cxx @@ -0,0 +1,352 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "BasicGUI.h" + +#include "QAD_RightFrame.h" +#include "OCCViewer_Viewer3d.h" +#include "OCCViewer_ViewPort3d.h" + +#include "BasicGUI_PointDlg.h" // Method POINT +#include "BasicGUI_LineDlg.h" // Method LINE +#include "BasicGUI_CircleDlg.h" // Method CIRCLE +#include "BasicGUI_EllipseDlg.h" // Method ELLIPSE +#include "BasicGUI_ArcDlg.h" // Method ARC +#include "BasicGUI_VectorDlg.h" // Method VECTOR +#include "BasicGUI_PlaneDlg.h" // Method PLANE +#include "BasicGUI_WorkingPlaneDlg.h" // Method WORKING PLANE + +//======================================================================= +// function : BasicGUI() +// purpose : Constructor +//======================================================================= +BasicGUI::BasicGUI() : + QObject() +{ + myGeomGUI = GEOMBase_Context::GetGeomGUI(); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); +} + + +//======================================================================= +// function : ~BasicGUI() +// purpose : Destructor +//======================================================================= +BasicGUI::~BasicGUI() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool BasicGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + switch (theCommandID) + { + case 3011: // POINT + { + Handle(AIS_InteractiveContext) ic; + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + ic = v3d->getAISContext(); + } + BasicGUI_PointDlg *aDlg = new BasicGUI_PointDlg(parent, "", this, Sel, ic); + break; + } + case 3012: // LINE + { + BasicGUI_LineDlg *aDlg = new BasicGUI_LineDlg(parent, "", this, Sel); + break; + } + case 3013: // CIRCLE + { + BasicGUI_CircleDlg *aDlg = new BasicGUI_CircleDlg(parent, "", this, Sel); + break; + } + case 3014: // ELLIPSE + { + BasicGUI_EllipseDlg *aDlg = new BasicGUI_EllipseDlg(parent, "", this, Sel); + break; + } + case 3015: // ARC + { + BasicGUI_ArcDlg *aDlg = new BasicGUI_ArcDlg(parent, "", this, Sel); + break ; + } + case 3016: // VECTOR + { + BasicGUI_VectorDlg *aDlg = new BasicGUI_VectorDlg(parent, "", this, Sel); + break; + } + case 3017: // PLANE + { + BasicGUI_PlaneDlg *aDlg = new BasicGUI_PlaneDlg(parent, "", this, Sel); + break; + } + case 3018: // WORKING PLANE + { + BasicGUI_WorkingPlaneDlg *aDlg = new BasicGUI_WorkingPlaneDlg(parent, "", this, Sel); + break; + } + default: + { + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + } + return true; +} + + +//======================================================================= +// function : MakePointAndDisplay +// purpose : +//======================================================================= +void BasicGUI::MakePointAndDisplay(const double x, const double y, const double z) +{ + try { + GEOM::GEOM_Shape_var P = myGeom->MakeVertex(x, y, z); + P->NameType(tr("GEOM_VERTEX")); + if (myGeomGUI->Display(P)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeLineAndDisplay() +// purpose : Create an infinite oriented line (linear edge in fact) +//===================================================================================== +void BasicGUI::MakeLineAndDisplay(const gp_Pnt InitPoint, const gp_Pnt LastPoint) +{ + gp_Pnt P1, P2; + double dx, dy, dz; + myGeomGUI->GetBipointDxDyDz(InitPoint, LastPoint, dx, dy, dz); + Standard_Real length = InitPoint.Distance(LastPoint); + if(length <= Precision::Confusion()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + + Standard_Real coeff = 1E6 / length; + + /* To create a line with length = 1E6 */ + /* Precision::Infinite() is 1E100 in OCC */ + P1.SetX(InitPoint.X() - (coeff * dx)); + P1.SetY(InitPoint.Y() - (coeff * dy)); + P1.SetZ(InitPoint.Z() - (coeff * dz)); + + P2.SetX(LastPoint.X() + (coeff * dx)); + P2.SetY(LastPoint.Y() + (coeff * dy)); + P2.SetZ(LastPoint.Z() + (coeff * dz)); + + try { + GEOM::PointStruct pstruct = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()); + GEOM::PointStruct d = myGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()); + GEOM::DirStruct dstruct = myGeom->MakeDirection(d); + + GEOM::GEOM_Shape_ptr result = myGeom->MakeLine(pstruct, dstruct); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_LINE")); + + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_READY")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeCircleAndDisplay() +// purpose : +//===================================================================================== +void BasicGUI::MakeCircleAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius) +{ + try { + GEOM::PointStruct pstruct = myGeom->MakePointStruct(CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z()); + GEOM::PointStruct d = myGeom->MakePointStruct(dir.X(), dir.Y(), dir.Z()); + GEOM::DirStruct dstruct = myGeom->MakeDirection(d); + + GEOM::GEOM_Shape_var result = myGeom->MakeCircle(pstruct, dstruct, Radius); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_CIRCLE")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeEllipseAndDisplay() +// purpose : +//===================================================================================== +void BasicGUI::MakeEllipseAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir, + const Standard_Real Major_Radius, const Standard_Real Minor_Radius) +{ + try { + GEOM::PointStruct pstruct = myGeom->MakePointStruct(CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z()); + GEOM::PointStruct d = myGeom->MakePointStruct(dir.X(), dir.Y(), dir.Z()); + GEOM::DirStruct dstruct = myGeom->MakeDirection(d) ; + + GEOM::GEOM_Shape_var result = myGeom->MakeEllipse(pstruct, dstruct, Major_Radius, Minor_Radius); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_ELLIPSE")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//======================================================================================= +// function : MakeArcAndDisplay() +// purpose : Make an arc of circle from InitPoint to CirclePoint and passing on EndPoint +//======================================================================================= +void BasicGUI::MakeArcAndDisplay(gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint) +{ + gp_Vec v1(CirclePoint, InitPoint); + gp_Vec v2(CirclePoint, EndPoint); + if(v1.IsParallel(v2, Precision::Angular())) + return; + + try { + GEOM::PointStruct pI = myGeom->MakePointStruct(InitPoint.X(), InitPoint.Y(), InitPoint.Z()); + GEOM::PointStruct pC = myGeom->MakePointStruct(CirclePoint.X(), CirclePoint.Y(), CirclePoint.Z()); + GEOM::PointStruct pE = myGeom->MakePointStruct(EndPoint.X(), EndPoint.Y(), EndPoint.Z()); + GEOM::GEOM_Shape_var result = myGeom->MakeArc(pI, pC, pE); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_ARC")); + if (myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//======================================================================= +// function : MakeVectorAndDisplay() +// purpose : +//======================================================================= +void BasicGUI::MakeVectorAndDisplay(const gp_Pnt P1, const gp_Pnt P2) +{ + try { + GEOM::PointStruct pstruct1 = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()); + GEOM::PointStruct pstruct2 = myGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()); + GEOM::GEOM_Shape_var Vector = myGeom->MakeVector(pstruct1, pstruct2); + Vector->NameType(tr("GEOM_VECTOR")); + if(myGeomGUI->Display(Vector)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//======================================================================= +// function : MakePlaneAndDisplay() +// purpose : Plane point is P1 and dx, dy, dz define a normal vector +//======================================================================= +void BasicGUI::MakePlaneAndDisplay(const gp_Pnt P1, const Standard_Real dx, const Standard_Real dy, + const Standard_Real dz, const Standard_Real TrimSize) +{ + try { + gp_Dir aDirection; + aDirection.SetCoord(dx, dy, dz); + gp_Ax2 Axis(P1, aDirection); + + GEOM::PointStruct pstruct = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()); + GEOM::PointStruct d = myGeom->MakePointStruct(aDirection.X(), aDirection.Y(), aDirection.Z()); + GEOM::DirStruct dstruct = myGeom->MakeDirection(d); + GEOM::GEOM_Shape_ptr plane = myGeom->MakePlane(pstruct, dstruct, TrimSize); + plane->NameType(tr("GEOM_PLANE")); + if(myGeomGUI->Display(plane)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//======================================================================= +// function : MakeWorkingPlane() +// purpose : Change the point of view3d +//======================================================================= +void BasicGUI::MakeWorkingPlane(const gp_Pnt P, const gp_Dir D) +{ + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER")); + return; + } + + OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort(); + Handle(V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView(); + view3d->SetAt(P.X(), P.Y(), P.Z()); + view3d->SetProj(D.X(), D.Y(), D.Z()); + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + return; +} diff --git a/src/BasicGUI/BasicGUI.h b/src/BasicGUI/BasicGUI.h new file mode 100644 index 000000000..2d2ec910e --- /dev/null +++ b/src/BasicGUI/BasicGUI.h @@ -0,0 +1,66 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef BASICGUI_H +#define BASICGUI_H + +#include "GEOMBase_Display.h" +#include "QAD_Config.h" + +//================================================================================= +// class : BasicGUI +// purpose : +//================================================================================= +class BasicGUI : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + BasicGUI(); + ~BasicGUI(); + + 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); + void MakeCircleAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius); + void MakeEllipseAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir, + const Standard_Real Major_Radius, const Standard_Real Minor_Radius); + void MakeArcAndDisplay(gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint); + void MakeVectorAndDisplay(const gp_Pnt P1, const gp_Pnt P2); + void MakePlaneAndDisplay(const gp_Pnt P1, const Standard_Real dx, const Standard_Real dy, + const Standard_Real dz, const Standard_Real TrimSize); + void MakeWorkingPlane(const gp_Pnt P, const gp_Dir D); + +private: + GEOMBase_Context* myGeomGUI; + GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + +}; + +#endif diff --git a/src/BasicGUI/BasicGUI_ArcDlg.cxx b/src/BasicGUI/BasicGUI_ArcDlg.cxx new file mode 100644 index 000000000..db7c5f1db --- /dev/null +++ b/src/BasicGUI/BasicGUI_ArcDlg.cxx @@ -0,0 +1,305 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_ArcDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BasicGUI_ArcDlg.h" + +#include +#include +#include + +//================================================================================= +// class : BasicGUI_ArcDlg() +// purpose : Constructs a BasicGUI_ArcDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BasicGUI_ArcDlg::BasicGUI_ArcDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, 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_ARC"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_ARC_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_ARC")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_3Sel_QTD(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_POINTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_POINT_I").arg("1")); + GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg("2")); + GroupPoints->TextLabel3->setText(tr("GEOM_POINT_I").arg("3")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->PushButton2->setPixmap(image1); + GroupPoints->PushButton3->setPixmap(image1); + + Layout1->addWidget(GroupPoints, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myBasicGUI = theBasicGUI; + Init(); +} + + +//================================================================================= +// function : ~BasicGUI_ArcDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BasicGUI_ArcDlg::~BasicGUI_ArcDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BasicGUI_ArcDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + myOkPoint1 = myOkPoint2 = myOkPoint3 = false; + + /* Vertices Filter for all arguments */ + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + mySelection->AddFilter(myVertexFilter); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupPoints->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BasicGUI_ArcDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BasicGUI_ArcDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkPoint1 && myOkPoint2 && myOkPoint3) + myBasicGUI->MakeArcAndDisplay(myPoint1, myPoint2, myPoint3); + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BasicGUI_ArcDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if (nbSel != 1) { + if (myEditCurrentArgument == GroupPoints->LineEdit1) + myOkPoint1 = false; + else if(myEditCurrentArgument == GroupPoints->LineEdit2) + myOkPoint2 = false; + else if(myEditCurrentArgument == GroupPoints->LineEdit3) + myOkPoint3 = false; + return; + } + + // nbSel == 1 + TopoDS_Shape S; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + myEditCurrentArgument->setText(aString); + myOkPoint1 = true; + } + else if(myEditCurrentArgument == GroupPoints->LineEdit2 && myGeomGUI->VertexToPoint(S, myPoint2)) { + myEditCurrentArgument->setText(aString); + myOkPoint2 = true; + } + else if(myEditCurrentArgument == GroupPoints->LineEdit3 && myGeomGUI->VertexToPoint(S, myPoint3)) { + myEditCurrentArgument->setText(aString); + myOkPoint3 = true; + } + + if(myOkPoint1 && myOkPoint2 && myOkPoint3) + this->MakeArcSimulationAndDisplay(); + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BasicGUI_ArcDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + } + else if(send == GroupPoints->PushButton3) { + GroupPoints->LineEdit3->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit3; + } + mySelection->AddFilter(myVertexFilter); + this->SelectionIntoArgument(); + + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BasicGUI_ArcDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupPoints->LineEdit1) + myEditCurrentArgument = GroupPoints->LineEdit1; + else if(send == GroupPoints->LineEdit2) + myEditCurrentArgument = GroupPoints->LineEdit2; + else if(send == GroupPoints->LineEdit3) + myEditCurrentArgument = GroupPoints->LineEdit3; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BasicGUI_ArcDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BasicGUI_ArcDlg::enterEvent(QEvent* e) +{ + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : MakeArcSimulationAndDisplay() +// purpose : +//================================================================================= +void BasicGUI_ArcDlg::MakeArcSimulationAndDisplay() +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + try { + if(myPoint2.IsEqual(myPoint1, Precision::Confusion()) || + myPoint2.IsEqual(myPoint3, Precision::Confusion())) { + myEditCurrentArgument->setText(""); + return; + } + + gp_Vec v1(myPoint2, myPoint1); + gp_Vec v2(myPoint2, myPoint3); + if(v1.IsParallel(v2, Precision::Angular())) { + myEditCurrentArgument->setText(""); + return; + } + + GC_MakeArcOfCircle Arc(myPoint1, myPoint2, myPoint3); + if(Arc.IsDone()) { + Handle(Geom_TrimmedCurve) curve = Arc.Value(); + mySimulationTopoDs = BRepBuilderAPI_MakeEdge(curve).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + } + catch(Standard_Failure) { + MESSAGE("Exception catched in MakeArcSimulationAndDisplay"); + } + return; +} diff --git a/src/BasicGUI/BasicGUI_ArcDlg.h b/src/BasicGUI/BasicGUI_ArcDlg.h new file mode 100644 index 000000000..85dcaec4f --- /dev/null +++ b/src/BasicGUI/BasicGUI_ArcDlg.h @@ -0,0 +1,76 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_ArcDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_ARC_H +#define DIALOGBOX_ARC_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_3Sel_QTD.h" + +#include "BasicGUI.h" + +//================================================================================= +// class : BasicGUI_ArcDlg +// purpose : +//================================================================================= +class BasicGUI_ArcDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BasicGUI_ArcDlg( QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~BasicGUI_ArcDlg(); + +private : + void Init(); + void enterEvent(QEvent* e); + void MakeArcSimulationAndDisplay(); + + BasicGUI* myBasicGUI; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filter selection */ + + gp_Pnt myPoint1; + gp_Pnt myPoint2; + gp_Pnt myPoint3; + bool myOkPoint1; + bool myOkPoint2; + bool myOkPoint3; + + DlgRef_3Sel_QTD* GroupPoints; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + +}; + +#endif // DIALOGBOX_ARC_H diff --git a/src/BasicGUI/BasicGUI_CircleDlg.cxx b/src/BasicGUI/BasicGUI_CircleDlg.cxx new file mode 100644 index 000000000..fd11b431c --- /dev/null +++ b/src/BasicGUI/BasicGUI_CircleDlg.cxx @@ -0,0 +1,305 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_CircleDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BasicGUI_CircleDlg.h" + +#include +#include + +//================================================================================= +// class : BasicGUI_CircleDlg() +// purpose : Constructs a BasicGUI_CircleDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BasicGUI_CircleDlg::BasicGUI_CircleDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, 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_CIRCLE_PV"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_CIRCLE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_CIRCLE")); + 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_CENTER_POINT")); + GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->PushButton2->setPixmap(image1); + + Layout1->addWidget(GroupPoints, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myBasicGUI = theBasicGUI; + Init(); +} + + +//================================================================================= +// function : ~BasicGUI_CircleDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BasicGUI_CircleDlg::~BasicGUI_CircleDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BasicGUI_CircleDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myRadius = 100.0; + myOkPoint1 = myOkDir = false; + + myEdgeFilter = new GEOM_EdgeFilter(StdSelect_Line, myGeom); + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + mySelection->AddFilter(myVertexFilter); + + /* Get setting of step value from file configuration */ + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); + + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_DX->SetValue(myRadius); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + 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(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + /* displays Dialog */ + GroupPoints->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BasicGUI_CircleDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BasicGUI_CircleDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkPoint1 && myOkDir) + myBasicGUI->MakeCircleAndDisplay(myPoint1, myDir, myRadius); +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BasicGUI_CircleDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if (nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkPoint1 = false; + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myOkDir = false; + return; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + /* gp_Pnt : not used */ + if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + GroupPoints->LineEdit1->setText(aString); + myOkPoint1 = true; + } + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + BRepAdaptor_Curve curv(TopoDS::Edge(S)); + myDir = curv.Line().Direction(); + GroupPoints->LineEdit2->setText(aString); + myOkDir = true; + } + + if(myOkPoint1 && myOkDir) + this->MakeCircleSimulationAndDisplay(); + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BasicGUI_CircleDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + mySelection->AddFilter(myVertexFilter); + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + mySelection->AddFilter(myEdgeFilter); + } + this->SelectionIntoArgument(); + + return; +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BasicGUI_CircleDlg::LineEditReturnPressed() +{ + 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 : ActivateThisDialog() +// purpose : +//================================================================================= +void BasicGUI_CircleDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BasicGUI_CircleDlg::enterEvent(QEvent* e) +{ + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void BasicGUI_CircleDlg::ValueChangedInSpinBox( double newValue ) +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + myRadius = newValue; + + if (myOkPoint1 && myOkDir) + MakeCircleSimulationAndDisplay(); + return; +} + + +//================================================================================= +// function : MakeCircleSimulationAndDisplay() +// purpose : +//================================================================================= +void BasicGUI_CircleDlg::MakeCircleSimulationAndDisplay() +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + try { + gp_Ax2 anAxis(myPoint1, myDir); + gp_Circ circ(anAxis, myRadius); + BRepBuilderAPI_MakeEdge MakeEdge(circ); + mySimulationTopoDs = MakeEdge.Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + catch(Standard_Failure) { + MESSAGE("Exception catched in MakeCircleSimulationAndDisplay"); + } + return; +} diff --git a/src/BasicGUI/BasicGUI_CircleDlg.h b/src/BasicGUI/BasicGUI_CircleDlg.h new file mode 100644 index 000000000..070d0a6ef --- /dev/null +++ b/src/BasicGUI/BasicGUI_CircleDlg.h @@ -0,0 +1,83 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_CircleDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_CIRCLE_H +#define DIALOGBOX_CIRCLE_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel1Spin.h" + +#include "BasicGUI.h" + +#include "GEOM_EdgeFilter.hxx" + +#include + +//================================================================================= +// class : BasicGUI_CircleDlg +// purpose : +//================================================================================= +class BasicGUI_CircleDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BasicGUI_CircleDlg(QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BasicGUI_CircleDlg(); + +private : + void Init(); + void enterEvent(QEvent* e); + void MakeCircleSimulationAndDisplay(); + + BasicGUI* myBasicGUI; + + double step; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; + Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ + + gp_Pnt myPoint1; + gp_Dir myDir; + Standard_Real myRadius; + bool myOkPoint1; + bool myOkDir; + + DlgRef_2Sel1Spin* GroupPoints; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ValueChangedInSpinBox(double newValue); + +}; + +#endif // DIALOGBOX_CIRCLE_H diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.cxx b/src/BasicGUI/BasicGUI_EllipseDlg.cxx new file mode 100644 index 000000000..2e51e4ce8 --- /dev/null +++ b/src/BasicGUI/BasicGUI_EllipseDlg.cxx @@ -0,0 +1,318 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_EllipseDlg.cxx +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BasicGUI_EllipseDlg.h" + +#include "gp_Elips.hxx" + +#include +#include + +//================================================================================= +// class : BasicGUI_EllipseDlg() +// purpose : Constructs a BasicGUI_EllipseDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BasicGUI_EllipseDlg::BasicGUI_EllipseDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, 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_ELLIPSE_PV"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_ELLIPSE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_ELLIPSE")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_2Sel2Spin(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_CENTER")); + GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS_MINOR")); + GroupPoints->TextLabel4->setText(tr("GEOM_RADIUS_MAJOR")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->PushButton2->setPixmap(image1); + + Layout1->addWidget(GroupPoints, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myBasicGUI = theBasicGUI; + Init(); +} + + +//================================================================================= +// function : ~BasicGUI_EllipseDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BasicGUI_EllipseDlg::~BasicGUI_EllipseDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BasicGUI_EllipseDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myMajorRadius = 200.0; + myMinorRadius = 100.0; + myOkPoint = myOkDir = false; + + myEdgeFilter = new GEOM_EdgeFilter(StdSelect_Line, myGeom); + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + mySelection->AddFilter(myVertexFilter); + + /* Get setting of step value from file configuration */ + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); + + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_DX->SetValue(myMajorRadius); + GroupPoints->SpinBox_DY->SetValue(myMinorRadius); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + 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->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + /* displays Dialog */ + GroupPoints->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BasicGUI_EllipseDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BasicGUI_EllipseDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkPoint && myOkDir) + myBasicGUI->MakeEllipseAndDisplay(myPoint, myDir, myMajorRadius, myMinorRadius); +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BasicGUI_EllipseDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if (nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkPoint = false; + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myOkDir = false; + return; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + /* gp_Pnt : not used */ + if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint)) { + GroupPoints->LineEdit1->setText(aString); + myOkPoint = true; + } + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + BRepAdaptor_Curve curv(TopoDS::Edge(S)); + myDir = curv.Line().Direction(); + GroupPoints->LineEdit2->setText(aString); + myOkDir = true; + } + + if(myOkPoint && myOkDir) + this->MakeEllipseSimulationAndDisplay(); + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BasicGUI_EllipseDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + mySelection->AddFilter(myVertexFilter); + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + mySelection->AddFilter(myEdgeFilter); + } + this->SelectionIntoArgument(); + + return; +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BasicGUI_EllipseDlg::LineEditReturnPressed() +{ + 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 : ActivateThisDialog() +// purpose : +//================================================================================= +void BasicGUI_EllipseDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BasicGUI_EllipseDlg::enterEvent(QEvent* e) +{ + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void BasicGUI_EllipseDlg::ValueChangedInSpinBox( double newValue ) +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + QObject* send = (QObject*)sender(); + + if(send == GroupPoints->SpinBox_DX ) + myMajorRadius = newValue; + else if(send == GroupPoints->SpinBox_DY) + myMinorRadius = newValue; + + if (myOkPoint && myOkDir) + MakeEllipseSimulationAndDisplay(); + return; +} + + +//================================================================================= +// function : MakeEllipseSimulationAndDisplay() +// purpose : +//================================================================================= +void BasicGUI_EllipseDlg::MakeEllipseSimulationAndDisplay() +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myMajorRadius < myMinorRadius) + return; + + try { + gp_Ax2 anAxis(myPoint, myDir); + gp_Elips ellipse(anAxis, myMajorRadius, myMinorRadius); + BRepBuilderAPI_MakeEdge MakeEdge(ellipse); + mySimulationTopoDs = MakeEdge.Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + catch(Standard_Failure) { + MESSAGE("Exception catched in MakeEllipseSimulationAndDisplay"); + } + return; +} diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.h b/src/BasicGUI/BasicGUI_EllipseDlg.h new file mode 100644 index 000000000..166685b65 --- /dev/null +++ b/src/BasicGUI/BasicGUI_EllipseDlg.h @@ -0,0 +1,84 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_EllipseDlg.h +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +#ifndef BASICGUI_ELLIPSE_H +#define BASICGUI_ELLIPSE_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel2Spin.h" + +#include "BasicGUI.h" + +#include "GEOM_EdgeFilter.hxx" + +#include + +//================================================================================= +// class : BasicGUI_EllipseDlg +// purpose : +//================================================================================= +class BasicGUI_EllipseDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BasicGUI_EllipseDlg(QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BasicGUI_EllipseDlg(); + +private : + void Init(); + void enterEvent(QEvent* e); + void MakeEllipseSimulationAndDisplay(); + + BasicGUI* myBasicGUI; + + double step; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; + Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ + + gp_Pnt myPoint; /* Central point of ellipse */ + bool myOkPoint; /* true when myPoint is defined */ + gp_Dir myDir; /* to set normal axis of ellipse */ + bool myOkDir; /* true when myPoint is defined */ + + Standard_Real myMajorRadius; + Standard_Real myMinorRadius; + + DlgRef_2Sel2Spin* GroupPoints; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ValueChangedInSpinBox(double newValue); + +}; + +#endif // BASICGUI_ELLIPSE_H diff --git a/src/BasicGUI/BasicGUI_LineDlg.cxx b/src/BasicGUI/BasicGUI_LineDlg.cxx new file mode 100644 index 000000000..b071dca73 --- /dev/null +++ b/src/BasicGUI/BasicGUI_LineDlg.cxx @@ -0,0 +1,281 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_LineDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BasicGUI_LineDlg.h" + +#include +#include +#include + +//================================================================================= +// class : BasicGUI_LineDlg() +// purpose : Constructs a BasicGUI_LineDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BasicGUI_LineDlg::BasicGUI_LineDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, 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_LINE_2P"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_LINE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_LINE")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_2Sel_QTD(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_POINTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_POINT_I").arg("1")); + GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg("2")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->PushButton2->setPixmap(image1); + + Layout1->addWidget(GroupPoints, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myBasicGUI = theBasicGUI; + Init(); +} + + +//================================================================================= +// function : ~BasicGUI_LineDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BasicGUI_LineDlg::~BasicGUI_LineDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BasicGUI_LineDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myPoint1.SetCoord(0.0, 0.0, 0.0); + myPoint2.SetCoord(0.0, 0.0, 0.0); + myOkPoint1 = myOkPoint2 = false; + + /* Vertices Filter for all arguments */ + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + mySelection->AddFilter(myVertexFilter); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + 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(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupPoints->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BasicGUI_LineDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BasicGUI_LineDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkPoint1 && myOkPoint2) + myBasicGUI->MakeLineAndDisplay(myPoint1, myPoint2); + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BasicGUI_LineDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkPoint1 = false; + else if(myEditCurrentArgument == GroupPoints->LineEdit2) + myOkPoint2 = false; + return; + } + + // nbSel == 1 + TopoDS_Shape S; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + myEditCurrentArgument->setText(aString); + myOkPoint1 = true; + } + else if(myEditCurrentArgument == GroupPoints->LineEdit2 && myGeomGUI->VertexToPoint(S, myPoint2)) { + myEditCurrentArgument->setText(aString); + 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); + } + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BasicGUI_LineDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + } + mySelection->AddFilter(myVertexFilter); + this->SelectionIntoArgument(); + + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BasicGUI_LineDlg::LineEditReturnPressed() +{ + 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 : ActivateThisDialog() +// purpose : +//================================================================================= +void BasicGUI_LineDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BasicGUI_LineDlg::enterEvent(QEvent* e) +{ + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : AddArrowToSimulation() +// 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) +{ + 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; + } + return false; +} diff --git a/src/BasicGUI/BasicGUI_LineDlg.h b/src/BasicGUI/BasicGUI_LineDlg.h new file mode 100644 index 000000000..3f09f339f --- /dev/null +++ b/src/BasicGUI/BasicGUI_LineDlg.h @@ -0,0 +1,74 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_LineDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_LINE_H +#define DIALOGBOX_LINE_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel_QTD.h" + +#include "BasicGUI.h" + +//================================================================================= +// class : BasicGUI_LineDlg +// purpose : +//================================================================================= +class BasicGUI_LineDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BasicGUI_LineDlg(QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BasicGUI_LineDlg(); + +private : + void Init(); + void enterEvent(QEvent* e); + bool AddArrowToSimulation(TopoDS_Shape& modifiedShape); + + BasicGUI* myBasicGUI; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filter selection */ + + gp_Pnt myPoint1; /* Points containing the vector */ + gp_Pnt myPoint2; + bool myOkPoint1; /* Are true when myPoint is defined */ + bool myOkPoint2; + + DlgRef_2Sel_QTD* GroupPoints; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + +}; + +#endif // DIALOGBOX_LINE_H diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.cxx b/src/BasicGUI/BasicGUI_PlaneDlg.cxx new file mode 100644 index 000000000..225de7d2b --- /dev/null +++ b/src/BasicGUI/BasicGUI_PlaneDlg.cxx @@ -0,0 +1,566 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_PlaneDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BasicGUI_PlaneDlg.h" + +#include +#include +#include +#include +#include + +//================================================================================= +// class : BasicGUI_PlaneDlg() +// purpose : Constructs a BasicGUI_PlaneDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BasicGUI_PlaneDlg::BasicGUI_PlaneDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, 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_PLANE_PV"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_DXYZ"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_FACE"))); + QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_PLANE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_PLANE")); + RadioButton1->setPixmap(image0); + RadioButton2->setPixmap(image1); + RadioButton3->setPixmap(image2); + + GroupPointDirection = new DlgRef_2Sel1Spin(this, "GroupPointDirection"); + GroupPointDirection->GroupBox1->setTitle(tr("GEOM_PLANE_PV")); + GroupPointDirection->TextLabel1->setText(tr("GEOM_POINT")); + GroupPointDirection->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPointDirection->TextLabel3->setText(tr("GEOM_PLANE_SIZE")); + GroupPointDirection->PushButton1->setPixmap(image3); + GroupPointDirection->PushButton2->setPixmap(image3); + + GroupPointPlusCoordinates = new DlgRef_1Sel4Spin(this, "GroupPointPlusCoordinates" ); + GroupPointPlusCoordinates->GroupBox1->setTitle(tr("GEOM_PLANE_PVC")); + GroupPointPlusCoordinates->TextLabel1->setText(tr("GEOM_POINT")); + GroupPointPlusCoordinates->TextLabel2->setText(tr("GEOM_COOR")); + GroupPointPlusCoordinates->TextLabel3->setText(tr("GEOM_DX")); + GroupPointPlusCoordinates->TextLabel4->setText(tr("GEOM_DY")); + GroupPointPlusCoordinates->TextLabel5->setText(tr("GEOM_DZ")); + GroupPointPlusCoordinates->TextLabel6->setText(tr("GEOM_PLANE_SIZE")); + GroupPointPlusCoordinates->PushButton1->setPixmap(image3); + + GroupFace = new DlgRef_1Sel1Spin(this, "GroupFace"); + GroupFace->GroupBox1->setTitle(tr("GEOM_FACE")); + GroupFace->TextLabel1->setText(tr("GEOM_SELECTION")); + GroupFace->TextLabel2->setText(tr("GEOM_PLANE_SIZE")); + GroupFace->PushButton1->setPixmap(image3); + + Layout1->addWidget(GroupPointDirection, 1, 0); + Layout1->addWidget(GroupPointPlusCoordinates, 1, 0); + Layout1->addWidget(GroupFace, 1, 0); + /***************************************************************/ + + /* Initialisation */ + myBasicGUI = theBasicGUI; + Init(); +} + + +//================================================================================= +// function : ~BasicGUI_PlaneDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BasicGUI_PlaneDlg::Init() +{ + /* init variables */ + myConstructorId = 0; + myEditCurrentArgument = GroupPointDirection->LineEdit1; + + myPoint1.SetCoord(0.0, 0.0, 0.0); + myOkPoint1 = myOkDirection = myOkCoordinates = myOkPlanarFace = false; + + /* Filters definition */ + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); + myFaceFilter = new GEOM_FaceFilter(StdSelect_Plane, myGeom); + /* Filter for the next selection */ + mySelection->AddFilter(myVertexFilter); + + /* Get setting of step value from file configuration */ + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); + this->myTrimSize = 2000.0; + + /* min, max, step and decimals for spin boxes */ + GroupPointDirection->SpinBox_DX->RangeStepAndValidator(+0.001, 10000000.0, step, 5); + GroupPointDirection->SpinBox_DX->SetValue(myTrimSize); + + GroupPointPlusCoordinates->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupPointPlusCoordinates->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupPointPlusCoordinates->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupPointPlusCoordinates->SpinBox_DX->SetValue(1.0); + GroupPointPlusCoordinates->SpinBox_DY->SetValue(1.0); + GroupPointPlusCoordinates->SpinBox_DZ->SetValue(1.0); + GroupPointPlusCoordinates->SpinBox_S->RangeStepAndValidator(+0.001, 10000000.0, step, 5); + GroupPointPlusCoordinates->SpinBox_S->SetValue(myTrimSize) ; + + GroupFace->SpinBox_DX->RangeStepAndValidator(+0.001, 10000000.0, step, 5); + GroupFace->SpinBox_DX->SetValue(myTrimSize); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); + + connect(GroupPointDirection->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPointDirection->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPointPlusCoordinates->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupFace->PushButton1, SIGNAL(clicked()), this, SLOT( SetEditCurrentArgument())); + + connect(GroupPointDirection->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPointDirection->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPointPlusCoordinates->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupFace->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupPointPlusCoordinates->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPointPlusCoordinates->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPointPlusCoordinates->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPointPlusCoordinates->SpinBox_S, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPointDirection->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupFace->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* Displays Dialog */ + GroupPointPlusCoordinates->hide(); + GroupFace->hide(); + GroupPointDirection->show(); + this->show(); + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BasicGUI_PlaneDlg::ConstructorsClicked(int constructorId) +{ + myConstructorId = constructorId; + mySelection->ClearFilters(); + myGeomGUI->EraseSimulationShape(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + myOkPoint1 = myOkDirection = myOkCoordinates = myOkPlanarFace = false; + + switch (constructorId) + { + case 0: /* plane from a point and a direction (vector, edge...) */ + { + GroupPointPlusCoordinates->hide(); + GroupFace->hide(); + resize(0, 0); + GroupPointDirection->show(); + + myEditCurrentArgument = GroupPointDirection->LineEdit1; + GroupPointDirection->LineEdit1->setText(tr("")); + GroupPointDirection->LineEdit2->setText(tr("")); + + /* for the first argument */ + mySelection->AddFilter(myVertexFilter); + break; + } + case 1: /* plane from a point and vector coordinates */ + { + GroupPointDirection->hide(); + GroupFace->hide(); + resize(0, 0); + GroupPointPlusCoordinates->show(); + + myEditCurrentArgument = GroupPointPlusCoordinates->LineEdit1; + GroupPointPlusCoordinates->LineEdit1->setText(tr("")); + GroupPointPlusCoordinates->SpinBox_DX->SetValue(1.0); + GroupPointPlusCoordinates->SpinBox_DY->SetValue(1.0); + GroupPointPlusCoordinates->SpinBox_DZ->SetValue(1.0); + myOkCoordinates = true; + + /* for the first argument */ + mySelection->AddFilter(myVertexFilter); + break; + } + case 2: /* plane from a planar face selection */ + { + GroupPointDirection->hide(); + GroupPointPlusCoordinates->hide(); + resize(0, 0); + GroupFace->show(); + + myEditCurrentArgument = GroupFace->LineEdit1; + GroupFace->LineEdit1->setText(tr("")); + + /* for the first argument */ + mySelection->AddFilter(myFaceFilter); + break; + } + } + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BasicGUI_PlaneDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BasicGUI_PlaneDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + switch(myConstructorId) + { + case 0 : /* args are myPoint1 and myDx, myDy, myDz from a vector(edge) */ + { + if(myOkPoint1 && myOkDirection) + myBasicGUI->MakePlaneAndDisplay(myPoint1, myDx, myDy, myDz, myTrimSize); + break; + } + case 1 : /* args are myPoint1 and myDx, myDy, myDz from a Spin Box */ + { + if(myOkPoint1) + myBasicGUI->MakePlaneAndDisplay(myPoint1, myDx, myDy, myDz, myTrimSize); + break; + } + case 2 : /* arg is a planar face selection */ + { + if(myOkPlanarFace) + myBasicGUI->MakePlaneAndDisplay(myPoint1, myDx, myDy, myDz, myTrimSize); + break; + } + } + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void BasicGUI_PlaneDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + QString aString = ""; + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + switch (myConstructorId) + { + case 0: + { + if(myEditCurrentArgument == GroupPointDirection->LineEdit1) { + GroupPointDirection->LineEdit1->setText(""); + myOkPoint1 = false ; + } + else if(myEditCurrentArgument == GroupPointDirection->LineEdit2) { + GroupPointDirection->LineEdit2->setText(""); + myOkDirection = false ; + } + break; + } + case 1: + { + if(myEditCurrentArgument == GroupPointPlusCoordinates->LineEdit1) { + GroupPointPlusCoordinates->LineEdit1->setText("") ; + myOkPoint1 = false ; + } + break; + } + case 2: + { + if(myEditCurrentArgument == GroupFace->LineEdit1) { + GroupFace->LineEdit1->setText("") ; + if(aString.compare("") == 0) + myOkPlanarFace = false; + else + myOkPlanarFace = true; + } + break; + } + } + return ; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return ; + + /* FIRST CONSTRUCTOR */ + if(myEditCurrentArgument == GroupPointDirection->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + GroupPointDirection->LineEdit1->setText(aString); + myOkPoint1 = true; + } + else if( myEditCurrentArgument == GroupPointDirection->LineEdit2) { + /* We verify if the selection is a linear edge */ + gp_Pnt Pfirst, Plast; + if( myGeomGUI->LinearEdgeExtremities(S, Pfirst, Plast)) { + myGeomGUI->GetBipointDxDyDz(Pfirst, Plast, myDx, myDy, myDz); + GroupPointDirection->LineEdit2->setText(aString); + myOkDirection = true; + this->myTrimSize = GroupPointDirection->SpinBox_DX->GetValue(); + } + } + + /* SECOND CONSTRUCTOR */ + else if(myEditCurrentArgument == GroupPointPlusCoordinates->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + GroupPointPlusCoordinates->LineEdit1->setText(aString); + /* Get arguments */ + myDx = GroupPointPlusCoordinates->SpinBox_DX->GetValue(); + myDy = GroupPointPlusCoordinates->SpinBox_DY->GetValue(); + myDz = GroupPointPlusCoordinates->SpinBox_DZ->GetValue(); + this->myTrimSize = GroupPointPlusCoordinates->SpinBox_S->GetValue(); + myOkPoint1 = true; + myOkCoordinates = true; + } + + /* THIRD CONSTRUCTOR */ + else if(myEditCurrentArgument == GroupFace->LineEdit1) { + if(myOkPlanarFace) { + GroupFace->LineEdit1->setText(aString); + BRepAdaptor_Surface surf(TopoDS::Face(S)); + gp_Pln Plane = surf.Plane(); + + gp_Pnt myPoint1 = Plane.Location(); + gp_Ax1 ax = Plane.Axis(); + myDx = (ax.Direction()).X(); + myDy = (ax.Direction()).Y(); + myDz = (ax.Direction()).Z(); + this->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) ; + } + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BasicGUI_PlaneDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters() ; + + switch (myConstructorId) + { + case 0: + { + if(send == GroupPointDirection->PushButton1) { + GroupPointDirection->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPointDirection->LineEdit1; + mySelection->AddFilter(myVertexFilter); + } + else if(send == GroupPointDirection->PushButton2) { + GroupPointDirection->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPointDirection->LineEdit2; + /* Edge filter here */ + mySelection->AddFilter(myEdgeFilter); + SelectionIntoArgument(); + } + break; + } + case 1: + { + if(send == GroupPointPlusCoordinates->PushButton1) { + GroupPointPlusCoordinates->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPointPlusCoordinates->LineEdit1; + /* Vertex filter here */ + mySelection->AddFilter(myVertexFilter); + SelectionIntoArgument(); + } + break; + } + case 2: + { + if(send == GroupFace->PushButton1) { + GroupFace->LineEdit1->setFocus(); + myEditCurrentArgument = GroupFace->LineEdit1; + /* Face filter here */ + mySelection->AddFilter(myFaceFilter); + SelectionIntoArgument(); + } + break; + } + } + return ; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BasicGUI_PlaneDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupPointDirection->LineEdit1) + myEditCurrentArgument = GroupPointDirection->LineEdit1; + else if (send == GroupPointDirection->LineEdit2) + myEditCurrentArgument = GroupPointDirection->LineEdit2; + else if (send == GroupPointPlusCoordinates->LineEdit1) + myEditCurrentArgument = GroupPointPlusCoordinates->LineEdit1; + else if (send == GroupFace->LineEdit1) + myEditCurrentArgument = GroupFace->LineEdit1; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BasicGUI_PlaneDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BasicGUI_PlaneDlg::enterEvent(QEvent* e) +{ + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void BasicGUI_PlaneDlg::ValueChangedInSpinBox( double newValue ) +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + QObject* send = (QObject*)sender() ; + + 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(); + myDy = newValue; + myDz = GroupPointPlusCoordinates->SpinBox_DZ->GetValue(); + } else if(send == GroupPointPlusCoordinates->SpinBox_DZ) { + myDx = GroupPointPlusCoordinates->SpinBox_DX->GetValue(); + myDy = GroupPointPlusCoordinates->SpinBox_DY->GetValue(); + myDz = newValue; + } 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); + } + + return ; +} + + +//================================================================================= +// 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) +{ + try { + gp_Dir aDirection(dx, dy, dz); + /* We make a trimmed plane */ + gp_Pln gplane(P1, aDirection); + mySimulationTopoDs = BRepBuilderAPI_MakeFace(gplane, -trimsize, +trimsize, -trimsize, +trimsize); + } + catch(Standard_Failure) { + MESSAGE( "Exception catched in MakePlaneSimulation" << endl ); + return; + } + + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return ; +} diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.h b/src/BasicGUI/BasicGUI_PlaneDlg.h new file mode 100644 index 000000000..cd5a08a25 --- /dev/null +++ b/src/BasicGUI/BasicGUI_PlaneDlg.h @@ -0,0 +1,96 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_PlaneDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_PLANE_H +#define DIALOGBOX_PLANE_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel1Spin.h" +#include "DlgRef_1Sel4Spin.h" +#include "DlgRef_1Sel1Spin.h" + +#include "BasicGUI.h" + +#include "GEOM_FaceFilter.hxx" + +//================================================================================= +// class : BasicGUI_PlaneDlg +// purpose : +//================================================================================= +class BasicGUI_PlaneDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BasicGUI_PlaneDlg(QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BasicGUI_PlaneDlg(); + +private : + void Init(); + void enterEvent(QEvent* e); + + BasicGUI* myBasicGUI; + + double step; + int myConstructorId; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filters selection */ + Handle(GEOM_ShapeTypeFilter) myEdgeFilter; + Handle(GEOM_FaceFilter) myFaceFilter; + + gp_Pnt myPoint1; /* Point on the plane */ + + Standard_Real myDx; + Standard_Real myDy; + Standard_Real myDz; + Standard_Real myTrimSize; + + bool myOkPoint1; /* true when argument is defined */ + bool myOkDirection; + bool myOkCoordinates; + bool myOkPlanarFace; + + DlgRef_2Sel1Spin* GroupPointDirection; + DlgRef_1Sel4Spin* GroupPointPlusCoordinates; + DlgRef_1Sel1Spin* GroupFace; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + 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); + +}; + +#endif // DIALOGBOX_PLANE_H diff --git a/src/BasicGUI/BasicGUI_PointDlg.cxx b/src/BasicGUI/BasicGUI_PointDlg.cxx new file mode 100644 index 000000000..659aaeff5 --- /dev/null +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -0,0 +1,498 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_PointDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BasicGUI_PointDlg.h" + +#include +#include +#include +#include + +//================================================================================= +// class : BasicGUI_PointDlg() +// purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BasicGUI_PointDlg::BasicGUI_PointDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, SALOME_Selection* Sel, const Handle (AIS_InteractiveContext)& ic, 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_POINT_EDGE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_POINT"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_POINT_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_POINTS")); + RadioButton1->setPixmap(image0); + RadioButton2->setPixmap(image1); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_1Sel1Spin(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_PARAM_POINT")); + GroupPoints->TextLabel1->setText(tr("GEOM_EDGE")); + GroupPoints->TextLabel2->setText(tr("GEOM_PARAMETER")); + GroupPoints->PushButton1->setPixmap(image2); + + GroupDimensions = new DlgRef_3Spin(this, "GroupDimensions"); + GroupDimensions->GroupBox1->setTitle(tr("GEOM_COORDINATES")); + GroupDimensions->TextLabel1->setText(tr("GEOM_X")); + GroupDimensions->TextLabel2->setText(tr("GEOM_Y")); + GroupDimensions->TextLabel3->setText(tr("GEOM_Z")); + + Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupDimensions, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myBasicGUI = theBasicGUI; + Init(ic); +} + + +//======================================================================= +// function : ~BasicGUI_PointDlg() +// purpose : Destructor +//======================================================================= +BasicGUI_PointDlg::~BasicGUI_PointDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BasicGUI_PointDlg::Init(const Handle(AIS_InteractiveContext)& ic) +{ + /* init variables */ + myConstructorId = 0; + myEditCurrentArgument = GroupPoints->LineEdit1; + + myIC = ic; + myParameter = 0.50; + myPoint.SetCoord(0.0, 0.0, 0.0); + myOkEdge = false; + + myGeomGUI->SetState(POINT_METHOD); + + /* Vertices Filter for all arguments */ + 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"); + step = St.toDouble(); + + /* min, max, step and decimals for spin boxes */ + double specificStep = 0.1; + GroupPoints->SpinBox_DX->RangeStepAndValidator(-999999.99999, 999999.99999, specificStep, 5); + GroupDimensions->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupDimensions->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupPoints->SpinBox_DX->SetValue(myParameter); + GroupDimensions->SpinBox_DX->SetValue(0.0); + GroupDimensions->SpinBox_DY->SetValue(0.0); + GroupDimensions->SpinBox_DZ->SetValue(0.0); + + if (myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + myLocalContextId = myIC->OpenLocalContext(); + myGeomGUI->SetDisplayedObjectList(); + /* sub shapes selection */ + myLocalContextMode = TopAbs_VERTEX; + myIC->ActivateStandardMode(myLocalContextMode); + myUseLocalContext = true; + } else { + myUseLocalContext = false; + } + + TopoDS_Shape S; + bool displayPoint = true; + if(myGeomGUI->GetTopoFromSelection(mySelection, S)) { + /* Filter a possibly previous selection and try to put it into coordinates */ + if(myGeomGUI->VertexToPoint(S, myPoint)) + displayPoint = false; + } + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupDimensions->hide(); + GroupPoints->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) +{ + myConstructorId = constructorId; + mySelection->ClearFilters(); + myGeomGUI->EraseSimulationShape(); + disconnect(mySelection, 0, this, 0); + + switch (constructorId) + { + case 0: + { + if (myUseLocalContext == true && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + myIC->CloseLocalContext(myLocalContextId); + myUseLocalContext = false; + } + + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(""); + myOkEdge = false; + + /* filter for next selections */ + mySelection->AddFilter(myEdgeFilter); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + break; + } + case 1: + { + if(myUseLocalContext == false && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + myLocalContextId = myIC->OpenLocalContext(); + myGeomGUI->SetDisplayedObjectList(); + /* sub shapes selection */ + myLocalContextMode = TopAbs_VERTEX; + myIC->ActivateStandardMode(myLocalContextMode); + myUseLocalContext = true; + } + + GroupPoints->hide(); + resize(0, 0); + GroupDimensions->show(); + + /* Display point simulation */ + PointIntoCoordinates(myPoint, true); + break; + } + } + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BasicGUI_PointDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BasicGUI_PointDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if(mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + /* Close local context */ + if (myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + myIC->CloseLocalContext(myLocalContextId); + myUseLocalContext = false; + } + + switch(myConstructorId) + { + case 0 : + { + if(myOkEdge == true) { + /* this constructor method has no idl interface : we use same than constructor 0 */ + myBasicGUI->MakePointAndDisplay(myPoint.X(), myPoint.Y(), myPoint.Z()); + } + break; + } + case 1 : + { + /* Recup args and call method */ + double x = GroupDimensions->SpinBox_DX->GetValue(); + double y = GroupDimensions->SpinBox_DY->GetValue(); + double z = GroupDimensions->SpinBox_DZ->GetValue(); + + myBasicGUI->MakePointAndDisplay(x,y,z); /* WARNING : no display if a local context is opened */ + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + /* no display if a local context is opened */ + myLocalContextId = myIC->OpenLocalContext(); + myGeomGUI->SetDisplayedObjectList(); + /* sub shapes selection */ + myLocalContextMode = TopAbs_VERTEX; + myIC->ActivateStandardMode(myLocalContextMode); + myUseLocalContext = true; + } + break; + } + } + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed (for constructors not using local context) +//================================================================================= +void BasicGUI_PointDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + myOkEdge = false; + return; + } + + // nbSel == 1 + TopoDS_Shape S; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + if(S.ShapeType() == TopAbs_EDGE) { + if(CalculateVertexOnCurve(TopoDS::Edge(S), myParameter, mySimulationTopoDs)) { + if(myGeomGUI->VertexToPoint(mySimulationTopoDs, myPoint)) { + GroupPoints->LineEdit1->setText(aString); + myOkEdge = true; + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + } + } + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BasicGUI_PointDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupPoints->LineEdit1) + myEditCurrentArgument = GroupPoints->LineEdit1; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BasicGUI_PointDlg::SetEditCurrentArgument() +{ + if(myConstructorId != 0) + return; + + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + mySelection->AddFilter(myEdgeFilter); + this->SelectionIntoArgument(); + } + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : to reactivate this dialog box when mouse enter onto the window +//================================================================================= +void BasicGUI_PointDlg::enterEvent(QEvent* e) +{ + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BasicGUI_PointDlg::ActivateThisDialog( ) +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + +// myGeomGUI->SetState(POINT_METHOD); +// if( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { +// OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); +// myIC = v3d->getAISContext(); +// myLocalContextId = myIC->OpenLocalContext(); +// myGeomGUI->SetDisplayedObjectList(); +// /* sub shapes selection */ +// myLocalContextMode = TopAbs_VERTEX ; +// myIC->ActivateStandardMode(myLocalContextMode); +// myUseLocalContext = true ; +// } + + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +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(); + vz = GroupDimensions->SpinBox_DZ->GetValue(); + } else if(send == GroupDimensions->SpinBox_DY) { + vx = GroupDimensions->SpinBox_DX->GetValue(); + vy = newValue; + vz = GroupDimensions->SpinBox_DZ->GetValue(); + } else if(send == GroupDimensions->SpinBox_DZ) { + vx = GroupDimensions->SpinBox_DX->GetValue(); + vy = GroupDimensions->SpinBox_DY->GetValue(); + vz = newValue; + } else if(send == GroupPoints->SpinBox_DX) { + myParameter = newValue; + } else + return; + + switch(myConstructorId) + { + case 0: // default constructor + { + this->SelectionIntoArgument(); + break; + } + case 1: + { + myPoint.SetCoord(vx, vy, vz); + mySimulationTopoDs = BRepBuilderAPI_MakeVertex (myPoint).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + break; + } + } + return; +} + + +//================================================================================= +// function : CalculateVertexOnCurve() +// purpose : Calculate a Vertex on the curve given by 'anEdge'. +// : The position of resultVertex is given by aParameter. +// : For a linear edge, aParameter=0.0 gives the first vertex of edge +// : aParameter=1.0 gives the last vertex of edge +// : aParameter=0.5 gives the vertex on the middle of edge +// : It is possible to get vertices out of edge using values > 1.0 or < 0.0 +//================================================================================= +bool BasicGUI_PointDlg::CalculateVertexOnCurve(const TopoDS_Edge& anEdge, const Standard_Real aParameter, TopoDS_Shape& resultVertex) +{ + if(anEdge.IsNull() || !BRepAlgoAPI::IsValid(anEdge)) + return false; + + Standard_Real first, last; + Handle(Geom_Curve) curv = BRep_Tool::Curve(anEdge, first, last); + if(!curv->IsCN(0)) + return false; + + Standard_Real param; + if(anEdge.Orientation() == TopAbs_FORWARD) + param = first + (last-first) * aParameter; + else + param = last + (first-last) * aParameter; + + gp_Pnt paramPoint; + curv->D0(param, paramPoint); + resultVertex = BRepBuilderAPI_MakeVertex(paramPoint); + return true; +} + + +//======================================================================= +// funcion : PointIntoCoordinates() +// purpose : Sets user point coordinates into this dialog Spin boxes +// : and displays it or not according to 'bool displayPoint' +//======================================================================= +void BasicGUI_PointDlg::PointIntoCoordinates(gp_Pnt P, bool displayPoint) +{ + GroupDimensions->SpinBox_DX->SetValue(P.X()); + GroupDimensions->SpinBox_DY->SetValue(P.Y()); + GroupDimensions->SpinBox_DZ->SetValue(P.Z()); + this->myPoint.SetCoord(P.X(), P.Y(), P.Z()); + if(displayPoint) { + mySimulationTopoDs = BRepBuilderAPI_MakeVertex(P).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + return; +} diff --git a/src/BasicGUI/BasicGUI_PointDlg.h b/src/BasicGUI/BasicGUI_PointDlg.h new file mode 100644 index 000000000..9be01197b --- /dev/null +++ b/src/BasicGUI/BasicGUI_PointDlg.h @@ -0,0 +1,97 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_PointDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_POINT_H +#define DIALOGBOX_POINT_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel1Spin.h" +#include "DlgRef_3Spin.h" + +#include "BasicGUI.h" + +#include + +//================================================================================= +// class : BasicGUI_PointDlg +// purpose : +//================================================================================= +class BasicGUI_PointDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BasicGUI_PointDlg(QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, const Handle(AIS_InteractiveContext)& ic = 0, bool modal = FALSE, WFlags fl = 0); + + ~BasicGUI_PointDlg(); + +private : + void Init(const Handle(AIS_InteractiveContext)& ic); + void enterEvent(QEvent* e); + + BasicGUI* myBasicGUI; + + double step; + int myConstructorId; + Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* filter for selection */ + + gp_Pnt myPoint; /* Is 'mySimulationTopoDs' */ + bool myOkEdge; /* true when an edge is selected by user */ + double myParameter; /* Parameter used to create a vertex on edge (point on curve) */ + + /* Interactive and local context management see also : bool UseLocalContext() */ + Handle(AIS_InteractiveContext) myIC; /* Interactive context from IAPP */ + Standard_Integer myLocalContextId; /* identify a local context for this method */ + TopAbs_ShapeEnum myLocalContextMode; /* identify a selection mode into local context */ + bool myUseLocalContext; /* true when method as opened a local context */ + + DlgRef_1Sel1Spin* GroupPoints; + DlgRef_3Spin* GroupDimensions; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked(int constructorId); + void ValueChangedInSpinBox(double newValue); + + bool CalculateVertexOnCurve(const TopoDS_Edge& anEdge, + const Standard_Real aParameter, + TopoDS_Shape& resultVertex); + +public: + void PointIntoCoordinates(gp_Pnt P, bool displayPoint); + /* return true if method has opened a local context */ + bool UseLocalContext(){return myUseLocalContext;}; + +}; + +#endif // DIALOGBOX_POINT_H diff --git a/src/BasicGUI/BasicGUI_VectorDlg.cxx b/src/BasicGUI/BasicGUI_VectorDlg.cxx new file mode 100644 index 000000000..b696752de --- /dev/null +++ b/src/BasicGUI/BasicGUI_VectorDlg.cxx @@ -0,0 +1,467 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_VectorDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BasicGUI_VectorDlg.h" + +#include +#include +#include +#include + +//================================================================================= +// class : BasicGUI_VectorDlg() +// purpose : Constructs a BasicGUI_VectorDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BasicGUI_VectorDlg::BasicGUI_VectorDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, 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_VECTOR_2P"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_VECTOR_DXYZ"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_VECTOR_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_VECTOR")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_2Sel_QTD(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_POINTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_POINT_I").arg("1")); + GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg("2")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->PushButton2->setPixmap(image1); + + GroupDimensions = new DlgRef_3Spin1Check(this, "GroupDimensions"); + GroupDimensions->GroupBox1->setTitle(tr("GEOM_COORDINATES")); + GroupDimensions->TextLabel1->setText(tr("GEOM_DX")); + GroupDimensions->TextLabel2->setText(tr("GEOM_DY")); + GroupDimensions->TextLabel3->setText(tr("GEOM_DZ")); + GroupDimensions->CheckBox1->setText(tr("GEOM_REVERSE_VECTOR")); + + Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupDimensions, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myBasicGUI = theBasicGUI; + Init(); +} + + +//================================================================================= +// function : ~BasicGUI_VectorDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BasicGUI_VectorDlg::~BasicGUI_VectorDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BasicGUI_VectorDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myDx = 0.0; + myDy = 0.0; + myDz = 200.0; + myPoint1.SetCoord(0.0, 0.0, 0.0); + myPoint2.SetCoord(0.0, 0.0, 0.0); + myOkPoint1 = myOkPoint2 = false; + + /* Vertices Filter for all arguments */ + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); + mySelection->AddFilter(myVertexFilter); + + /* 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 */ + GroupDimensions->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupDimensions->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); + + GroupDimensions->SpinBox_DX->SetValue(myDx); + GroupDimensions->SpinBox_DY->SetValue(myDy); + GroupDimensions->SpinBox_DZ->SetValue(myDz); + + GroupDimensions->CheckBox1->setChecked(FALSE); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(GroupDimensions->CheckBox1, SIGNAL(stateChanged(int)), this, SLOT(ReverseVector(int))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupDimensions->hide(); + GroupPoints->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BasicGUI_VectorDlg::ConstructorsClicked(int constructorId) +{ + myConstructorId = constructorId; + mySelection->ClearFilters(); + myGeomGUI->EraseSimulationShape(); + disconnect(mySelection, 0, this, 0); + myOkPoint1 = myOkPoint2 = false; + + switch (constructorId) + { + case 0: + { + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(""); + GroupPoints->LineEdit2->setText(""); + + /* filter for next selection */ + mySelection->AddFilter(myVertexFilter); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + break; + } + case 1: + { + GroupPoints->hide(); + resize( 0, 0 ); + GroupDimensions->show(); + + myDx = 0.0; + myDy = 0.0; + myDz = 200.0; + + GroupDimensions->SpinBox_DX->SetValue(myDx); + GroupDimensions->SpinBox_DY->SetValue(myDy); + GroupDimensions->SpinBox_DZ->SetValue(myDz); + + myPoint1.SetCoord(0.0, 0.0, 0.0) ; + myPoint2.SetCoord(myDx, myDy, myDz); + + GroupDimensions->CheckBox1->setChecked(FALSE); + + mySimulationTopoDs = BRepBuilderAPI_MakeEdge(myPoint1, myPoint2).Shape(); + /* Add arrow in simulation */ + bool noNeedToTest = AddArrowToSimulation(mySimulationTopoDs); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + break; + } + } + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BasicGUI_VectorDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BasicGUI_VectorDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + switch(myConstructorId) + { + case 0 : + { + if(myOkPoint1 && myOkPoint2) + myBasicGUI->MakeVectorAndDisplay(myPoint1, myPoint2); + break ; + } + case 1 : + { + /* Recup args and call method */ + myDx = GroupDimensions->SpinBox_DX->GetValue(); + myDy = GroupDimensions->SpinBox_DY->GetValue(); + myDz = GroupDimensions->SpinBox_DZ->GetValue(); + myPoint1.SetCoord(0.0, 0.0, 0.0); + myPoint2.SetCoord(myDx, myDy, myDz); + myBasicGUI->MakeVectorAndDisplay(myPoint1, myPoint2); + break; + } + } + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BasicGUI_VectorDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if (nbSel != 1) { + if (myEditCurrentArgument == GroupPoints->LineEdit1) + myOkPoint1 = false; + else if ( myEditCurrentArgument == GroupPoints->LineEdit2) + myOkPoint2 = false; + return; + } + + // nbSel == 1 + TopoDS_Shape S; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + myEditCurrentArgument->setText(aString); + myOkPoint1 = true; + } + else if(myEditCurrentArgument == GroupPoints->LineEdit2 && myGeomGUI->VertexToPoint(S, myPoint2)) { + myEditCurrentArgument->setText(aString); + myOkPoint2 = true; + } + + if(myOkPoint1 && myOkPoint2 && myPoint1.Distance(myPoint2) > Precision::Confusion()) { + mySimulationTopoDs = BRepBuilderAPI_MakeEdge(myPoint1, myPoint2).Shape(); + /* Add arrow in simulation */ + bool noNeedToTest = this->AddArrowToSimulation(mySimulationTopoDs); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BasicGUI_VectorDlg::SetEditCurrentArgument() +{ + if(myConstructorId != 0) + return; + + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + } + mySelection->AddFilter(myVertexFilter); + this->SelectionIntoArgument(); + + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BasicGUI_VectorDlg::LineEditReturnPressed() +{ + 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 : ActivateThisDialog() +// purpose : +//================================================================================= +void BasicGUI_VectorDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BasicGUI_VectorDlg::enterEvent(QEvent* e) +{ + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void BasicGUI_VectorDlg::ValueChangedInSpinBox( double newValue ) +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + QObject* send = (QObject*)sender(); + + if(send == GroupDimensions->SpinBox_DX ) { + myDx = newValue; + myDy = GroupDimensions->SpinBox_DY->GetValue(); + myDz = GroupDimensions->SpinBox_DZ->GetValue(); + } else if (send == GroupDimensions->SpinBox_DY) { + myDx = GroupDimensions->SpinBox_DX->GetValue(); + myDy = newValue; + myDz = GroupDimensions->SpinBox_DZ->GetValue(); + } else if (send == GroupDimensions->SpinBox_DZ) { + myDx = GroupDimensions->SpinBox_DX->GetValue(); + myDy = GroupDimensions->SpinBox_DY->GetValue(); + myDz = newValue; + } + + myPoint1.SetCoord(0.0, 0.0, 0.0); + myPoint2.SetCoord(myDx, myDy, myDz); + + if(myPoint1.Distance(myPoint2) > Precision::Confusion()) { // mySimulationTopoDs + mySimulationTopoDs = BRepBuilderAPI_MakeEdge(myPoint1, myPoint2).Shape(); + /* Create simulation vector with an arrow */ + this->AddArrowToSimulation(mySimulationTopoDs); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + return; +} + + +//================================================================================= +// function : AddArrowToSimulation() +// 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_VectorDlg::AddArrowToSimulation(TopoDS_Shape& modifiedShape) +{ + 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; + } + return false; +} + + +//================================================================================= +// function : ReverseVector() +// purpose : 'state' not used here +//================================================================================= +void BasicGUI_VectorDlg::ReverseVector(int state) +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + myDx = -myDx; + myDy = -myDy; + myDz = -myDz; + + GroupDimensions->SpinBox_DX->SetValue(myDx); + GroupDimensions->SpinBox_DY->SetValue(myDy); + GroupDimensions->SpinBox_DZ->SetValue(myDz); + + myPoint1.SetCoord(0.0, 0.0, 0.0); + myPoint2.SetCoord(myDx, myDy, myDz); + + /* In the appropriate constructor */ + if(myPoint1.Distance(myPoint2) > Precision::Confusion()) { + mySimulationTopoDs = BRepBuilderAPI_MakeEdge(myPoint1, myPoint2).Shape(); + /* Add arrow in simulation */ + bool noNeedToTest = this->AddArrowToSimulation(mySimulationTopoDs); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + return; +} diff --git a/src/BasicGUI/BasicGUI_VectorDlg.h b/src/BasicGUI/BasicGUI_VectorDlg.h new file mode 100644 index 000000000..6372a26b4 --- /dev/null +++ b/src/BasicGUI/BasicGUI_VectorDlg.h @@ -0,0 +1,86 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_VectorDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_VECTOR_H +#define DIALOGBOX_VECTOR_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel_QTD.h" +#include "DlgRef_3Spin1Check.h" + +#include "BasicGUI.h" + +//================================================================================= +// class : BasicGUI_VectorDlg +// purpose : +//================================================================================= +class BasicGUI_VectorDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BasicGUI_VectorDlg(QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BasicGUI_VectorDlg(); + +private : + void Init(); + void enterEvent(QEvent* e); + bool AddArrowToSimulation(TopoDS_Shape& modifiedShape); + + BasicGUI* myBasicGUI; + + double step; + int myConstructorId; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filter selection */ + Handle(GEOM_ShapeTypeFilter) myEdgeFilter; + + gp_Pnt myPoint1; /* Points containing the vector */ + gp_Pnt myPoint2; + bool myOkPoint1; /* Are true when myPoint is defined */ + bool myOkPoint2; + double myDx; + double myDy; + double myDz; + + DlgRef_2Sel_QTD* GroupPoints; + DlgRef_3Spin1Check* GroupDimensions; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked(int constructorId); + void ValueChangedInSpinBox(double newValue); + void ReverseVector(int state); + +}; + +#endif // DIALOGBOX_VECTOR_H diff --git a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx new file mode 100644 index 000000000..59be8750e --- /dev/null +++ b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx @@ -0,0 +1,232 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_WorkingPlaneDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM + +using namespace std; +#include "BasicGUI_WorkingPlaneDlg.h" + +#include +#include +#include +#include + +//================================================================================= +// class : BasicGUI_WorkingPlaneDlg() +// purpose : Constructs a BasicGUI_WorkingPlaneDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BasicGUI_WorkingPlaneDlg::BasicGUI_WorkingPlaneDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, 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_WPLANE_FACE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_WPLANE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_WPLANE")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupWPlane = new DlgRef_1Sel_QTD(this, "GroupWPlane"); + GroupWPlane->GroupBox1->setTitle(tr("GEOM_WPLANE_FACE")); + GroupWPlane->TextLabel1->setText(tr("GEOM_SELECTION")); + GroupWPlane->PushButton1->setPixmap(image1); + + Layout1->addWidget(GroupWPlane, 1, 0); + /***************************************************************/ + + /* Initialisation */ + myBasicGUI = theBasicGUI; + Init(); +} + + +//================================================================================= +// function : ~BasicGUI_WorkingPlaneDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BasicGUI_WorkingPlaneDlg::~BasicGUI_WorkingPlaneDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BasicGUI_WorkingPlaneDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupWPlane->LineEdit1; + + myOkPlane = false; + + /* Filter definition */ + myFaceFilter = new GEOM_FaceFilter(StdSelect_Plane, myGeom); + mySelection->AddFilter(myFaceFilter); /* filter for next selection */ + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupWPlane->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupWPlane->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupWPlane->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BasicGUI_WorkingPlaneDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BasicGUI_WorkingPlaneDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + mySelection->ClearFilters(); + if(myOkPlane) + myBasicGUI->MakeWorkingPlane(myLoc, myDir); + + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + QString aString = ""; + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupWPlane->LineEdit1) + myOkPlane = false; + return; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + 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; + } + + /* no simulation */ + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BasicGUI_WorkingPlaneDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupWPlane->PushButton1) { + GroupWPlane->LineEdit1->setFocus(); + myEditCurrentArgument = GroupWPlane->LineEdit1; + mySelection->AddFilter(myFaceFilter); + SelectionIntoArgument(); + } + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BasicGUI_WorkingPlaneDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupWPlane->LineEdit1) + myEditCurrentArgument = GroupWPlane->LineEdit1; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BasicGUI_WorkingPlaneDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BasicGUI_WorkingPlaneDlg::enterEvent(QEvent* e) +{ + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} diff --git a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.h b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.h new file mode 100644 index 000000000..6e9b5baf6 --- /dev/null +++ b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.h @@ -0,0 +1,74 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BasicGUI_WorkingPlaneDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM + +#ifndef DIALOGBOX_WORKINGPLANE_H +#define DIALOGBOX_WORKINGPLANE_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel_QTD.h" + +#include "BasicGUI.h" + +#include "GEOM_FaceFilter.hxx" + +//================================================================================= +// class : BasicGUI_WorkingPlaneDlg +// purpose : +//================================================================================= +class BasicGUI_WorkingPlaneDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BasicGUI_WorkingPlaneDlg( QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~BasicGUI_WorkingPlaneDlg(); + +private: + void Init(); + void enterEvent(QEvent* e); + + BasicGUI* myBasicGUI; + + Handle(GEOM_FaceFilter) myFaceFilter; /* filter for selection */ + + gp_Pnt myLoc; + gp_Dir myDir; + bool myOkPlane; /* to check when arguments are defined */ + + DlgRef_1Sel_QTD* GroupWPlane; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + void ActivateThisDialog(); + +}; + +#endif // DIALOGBOX_WORKINGPLANE_H diff --git a/src/BasicGUI/Makefile.in b/src/BasicGUI/Makefile.in new file mode 100644 index 000000000..2810b5000 --- /dev/null +++ b/src/BasicGUI/Makefile.in @@ -0,0 +1,82 @@ +# GEOM BASICGUI : +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Damien COQUERET (OCC) +# Module : GEOM +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= BasicGUI.h \ + BasicGUI_PointDlg.h + +# Libraries targets +LIB = libBasicGUI.la + +LIB_SRC = BasicGUI.cxx \ + BasicGUI_PointDlg.cxx \ + BasicGUI_LineDlg.cxx \ + BasicGUI_CircleDlg.cxx \ + BasicGUI_EllipseDlg.cxx \ + BasicGUI_ArcDlg.cxx \ + BasicGUI_VectorDlg.cxx \ + BasicGUI_PlaneDlg.cxx \ + BasicGUI_WorkingPlaneDlg.cxx + +LIB_MOC = \ + BasicGUI.h \ + BasicGUI_PointDlg.h \ + BasicGUI_LineDlg.h \ + BasicGUI_CircleDlg.h \ + BasicGUI_EllipseDlg.h \ + BasicGUI_ArcDlg.h \ + BasicGUI_VectorDlg.h \ + BasicGUI_PlaneDlg.h \ + BasicGUI_WorkingPlaneDlg.h + +LIB_CLIENT_IDL = SALOME_Exception.idl \ + GEOM_Gen.idl \ + GEOM_Shape.idl \ + SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +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 -lDlgRef -lGEOMBase $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/BooleanGUI/BooleanGUI.cxx b/src/BooleanGUI/BooleanGUI.cxx new file mode 100644 index 000000000..ce5a73b76 --- /dev/null +++ b/src/BooleanGUI/BooleanGUI.cxx @@ -0,0 +1,128 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BooleanGUI.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "BooleanGUI.h" + +#include "QAD_Application.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + +#include "BooleanGUI_FuseDlg.h" // Method FUSE +#include "BooleanGUI_CommonDlg.h" // Method COMMON +#include "BooleanGUI_CutDlg.h" // Method CUT +#include "BooleanGUI_SectionDlg.h" // Method SECTION + +//======================================================================= +// function : BooleanGUI() +// purpose : Constructor +//======================================================================= +BooleanGUI::BooleanGUI() : + QObject() +{ + myGeomGUI = GEOMBase_Context::GetGeomGUI(); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); +} + + +//======================================================================= +// function : ~BooleanGUI() +// purpose : Destructor +//======================================================================= +BooleanGUI::~BooleanGUI() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool BooleanGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + switch (theCommandID) + { + case 4011: // FUSE + { + BooleanGUI_FuseDlg *aDlg = new BooleanGUI_FuseDlg(parent, "", this, Sel); + break; + } + case 4012: // COMMON + { + BooleanGUI_CommonDlg *aDlg = new BooleanGUI_CommonDlg(parent, "", this, Sel); + break; + } + case 4013: // CUT + { + BooleanGUI_CutDlg *aDlg = new BooleanGUI_CutDlg(parent, "", this, Sel); + break; + } + case 4014: // SECTION + { + BooleanGUI_SectionDlg *aDlg = new BooleanGUI_SectionDlg(parent, "", this, Sel); + break; + } + default: + { + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + } + return true; +} + + +//======================================================================= +// function : MakeBooleanAndDisplay() +// purpose : +//======================================================================= +void BooleanGUI::MakeBooleanAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2, const short operation) +{ + try { + GEOM::GEOM_Shape_ptr result = myGeom->MakeBoolean(Shape1, Shape2, operation); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + result->NameType(type); + + if (myGeomGUI->Display(result, "")) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} diff --git a/src/BooleanGUI/BooleanGUI.h b/src/BooleanGUI/BooleanGUI.h new file mode 100644 index 000000000..77b7b5f15 --- /dev/null +++ b/src/BooleanGUI/BooleanGUI.h @@ -0,0 +1,58 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BooleanGUI.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef BOOLEANGUI_H +#define BOOLEANGUI_H + +#include "GEOMBase_Display.h" + +//================================================================================= +// class : BooleanGUI +// purpose : +//================================================================================= +class BooleanGUI : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + BooleanGUI(); + ~BooleanGUI(); + + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + + void MakeBooleanAndDisplay(GEOM::GEOM_Shape_ptr Shape1, + GEOM::GEOM_Shape_ptr Shape2, + const short operation); + +private: + GEOMBase_Context* myGeomGUI; + GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + +}; + +#endif diff --git a/src/BooleanGUI/BooleanGUI_CommonDlg.cxx b/src/BooleanGUI/BooleanGUI_CommonDlg.cxx new file mode 100644 index 000000000..6982ae3b9 --- /dev/null +++ b/src/BooleanGUI/BooleanGUI_CommonDlg.cxx @@ -0,0 +1,250 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BooleanGUI_CommonDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BooleanGUI_CommonDlg.h" + +//================================================================================= +// class : BooleanGUI_CommonDlg() +// purpose : Constructs a BooleanGUI_CommonDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BooleanGUI_CommonDlg::BooleanGUI_CommonDlg(QWidget* parent, const char* name, BooleanGUI* theBooleanGUI, 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_COMMON"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_COMMON_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_COMMON")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupCommon = new DlgRef_2Sel_QTD(this, "GroupCommon"); + GroupCommon->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupCommon->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); + GroupCommon->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); + GroupCommon->PushButton1->setPixmap(image1); + GroupCommon->PushButton2->setPixmap(image1); + + Layout1->addWidget(GroupCommon, 1, 0); + /***************************************************************/ + + /* Initialisation */ + myBooleanGUI = theBooleanGUI; + Init(); +} + + +//================================================================================= +// function : ~BooleanGUI_CommonDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BooleanGUI_CommonDlg::~BooleanGUI_CommonDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BooleanGUI_CommonDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupCommon->LineEdit1; + + myShape1.Nullify(); + myShape2.Nullify(); + myOkShape1 = myOkShape2 = false; + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupCommon->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupCommon->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupCommon->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupCommon->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupCommon->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BooleanGUI_CommonDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BooleanGUI_CommonDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + + if(myOkShape1 && myOkShape2) + myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 1); + + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void BooleanGUI_CommonDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + QString aString = ""; + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupCommon->LineEdit1) + myOkShape1 = false; + else if( myEditCurrentArgument == GroupCommon->LineEdit2) + myOkShape2 = false; + return; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + if(myEditCurrentArgument == GroupCommon->LineEdit1) { + myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape1 = S; + GroupCommon->LineEdit1->setText(aString); + myOkShape1 = true; + } + else if(myEditCurrentArgument == GroupCommon->LineEdit2) { + myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape2 = S; + GroupCommon->LineEdit2->setText(aString); + myOkShape2 = true; + } + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BooleanGUI_CommonDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupCommon->PushButton1) { + GroupCommon->LineEdit1->setFocus(); + myEditCurrentArgument = GroupCommon->LineEdit1; + } + else if(send == GroupCommon->PushButton2) { + GroupCommon->LineEdit2->setFocus(); + myEditCurrentArgument = GroupCommon->LineEdit2; + } + SelectionIntoArgument(); + + return; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BooleanGUI_CommonDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupCommon->LineEdit1) + myEditCurrentArgument = GroupCommon->LineEdit1; + else if(send == GroupCommon->LineEdit2) + myEditCurrentArgument = GroupCommon->LineEdit2; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BooleanGUI_CommonDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void BooleanGUI_CommonDlg::enterEvent(QEvent * e) +{ + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} diff --git a/src/BooleanGUI/BooleanGUI_CommonDlg.h b/src/BooleanGUI/BooleanGUI_CommonDlg.h new file mode 100644 index 000000000..f592e6df0 --- /dev/null +++ b/src/BooleanGUI/BooleanGUI_CommonDlg.h @@ -0,0 +1,76 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BooleanGUI_CommonDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_COMMON_H +#define DIALOGBOX_COMMON_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel_QTD.h" + +#include "BooleanGUI.h" + +#include + +//================================================================================= +// class : BooleanGUI_CommonDlg +// purpose : +//================================================================================= +class BooleanGUI_CommonDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BooleanGUI_CommonDlg(QWidget* parent = 0, const char* name = 0, BooleanGUI* theBooleanGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BooleanGUI_CommonDlg(); + +private: + void Init(); + void enterEvent(QEvent * e); + + BooleanGUI* myBooleanGUI; + + 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 */ + + DlgRef_2Sel_QTD* GroupCommon; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + void ActivateThisDialog(); + +}; + +#endif // DIALOGBOX_COMMON_H diff --git a/src/BooleanGUI/BooleanGUI_CutDlg.cxx b/src/BooleanGUI/BooleanGUI_CutDlg.cxx new file mode 100644 index 000000000..a05ac1e22 --- /dev/null +++ b/src/BooleanGUI/BooleanGUI_CutDlg.cxx @@ -0,0 +1,248 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BooleanGUI_CutDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BooleanGUI_CutDlg.h" + +//================================================================================= +// class : BooleanGUI_CutDlg() +// purpose : Constructs a BooleanGUI_CutDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BooleanGUI_CutDlg::BooleanGUI_CutDlg(QWidget* parent, const char* name, BooleanGUI* theBooleanGUI, 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_CUT"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_CUT_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_CUT")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupCut = new DlgRef_2Sel_QTD(this, "GroupCut"); + GroupCut->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupCut->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); + GroupCut->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); + GroupCut->PushButton1->setPixmap(image1); + GroupCut->PushButton2->setPixmap(image1); + + Layout1->addWidget(GroupCut, 1, 0); + /***************************************************************/ + + /* Initialisation */ + myBooleanGUI = theBooleanGUI; + Init(); +} + + +//================================================================================= +// function : ~BooleanGUI_CutDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BooleanGUI_CutDlg::~BooleanGUI_CutDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BooleanGUI_CutDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupCut->LineEdit1; + + myShape1.Nullify(); + myShape2.Nullify(); + myOkShape1 = myOkShape2 = false; + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupCut->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupCut->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupCut->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupCut->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupCut->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BooleanGUI_CutDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BooleanGUI_CutDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + + if(myOkShape1 && myOkShape2) + myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 2); + + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void BooleanGUI_CutDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + QString aString = ""; + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupCut->LineEdit1) + myOkShape1 = false; + else if( myEditCurrentArgument == GroupCut->LineEdit2) + myOkShape2 = false; + return; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + if(myEditCurrentArgument == GroupCut->LineEdit1) { + myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape1 = S; + GroupCut->LineEdit1->setText(aString); + myOkShape1 = true; + } + else if(myEditCurrentArgument == GroupCut->LineEdit2) { + myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape2 = S; + GroupCut->LineEdit2->setText(aString); + myOkShape2 = true; + } + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BooleanGUI_CutDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupCut->PushButton1) { + GroupCut->LineEdit1->setFocus(); + myEditCurrentArgument = GroupCut->LineEdit1; + } + else if(send == GroupCut->PushButton2) { + GroupCut->LineEdit2->setFocus(); + myEditCurrentArgument = GroupCut->LineEdit2; + } + SelectionIntoArgument(); + + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BooleanGUI_CutDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupCut->LineEdit1) + myEditCurrentArgument = GroupCut->LineEdit1; + else if(send == GroupCut->LineEdit2) + myEditCurrentArgument = GroupCut->LineEdit2; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BooleanGUI_CutDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void BooleanGUI_CutDlg::enterEvent(QEvent * e) +{ + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} diff --git a/src/BooleanGUI/BooleanGUI_CutDlg.h b/src/BooleanGUI/BooleanGUI_CutDlg.h new file mode 100644 index 000000000..46738f7f3 --- /dev/null +++ b/src/BooleanGUI/BooleanGUI_CutDlg.h @@ -0,0 +1,76 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BooleanGUI_CutDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_CUT_H +#define DIALOGBOX_CUT_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel_QTD.h" + +#include "BooleanGUI.h" + +#include + +//================================================================================= +// class : BooleanGUI_CutDlg +// purpose : +//================================================================================= +class BooleanGUI_CutDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BooleanGUI_CutDlg( QWidget* parent = 0, const char* name = 0, BooleanGUI* theBooleanGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~BooleanGUI_CutDlg(); + +private: + void Init(); + void enterEvent(QEvent* e); + + BooleanGUI* myBooleanGUI; + + TopoDS_Shape myShape1; /* topology used to fuse */ + TopoDS_Shape myShape2; /* topology used to fuse */ + GEOM::GEOM_Shape_var myGeomShape1; /* is myShape1 */ + GEOM::GEOM_Shape_var myGeomShape2; /* is myShape2 */ + bool myOkShape1; /* to check when arguments are defined */ + bool myOkShape2; + + DlgRef_2Sel_QTD* GroupCut; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + void ActivateThisDialog(); + +}; + +#endif // DIALOGBOX_CUT_H diff --git a/src/BooleanGUI/BooleanGUI_FuseDlg.cxx b/src/BooleanGUI/BooleanGUI_FuseDlg.cxx new file mode 100644 index 000000000..fbf00b6af --- /dev/null +++ b/src/BooleanGUI/BooleanGUI_FuseDlg.cxx @@ -0,0 +1,248 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BooleanGUI_FuseDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BooleanGUI_FuseDlg.h" + +//================================================================================= +// class : BooleanGUI_FuseDlg() +// purpose : Constructs a BooleanGUI_FuseDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BooleanGUI_FuseDlg::BooleanGUI_FuseDlg(QWidget* parent, const char* name, BooleanGUI* theBooleanGUI, 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_FUSE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_FUSE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_FUSE")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupFuse = new DlgRef_2Sel_QTD(this, "GroupFuse"); + GroupFuse->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupFuse->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); + GroupFuse->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); + GroupFuse->PushButton1->setPixmap(image1); + GroupFuse->PushButton2->setPixmap(image1); + + Layout1->addWidget(GroupFuse, 1, 0); + /***************************************************************/ + + /* Initialisation */ + myBooleanGUI = theBooleanGUI; + Init(); +} + + +//================================================================================= +// function : ~BooleanGUI_FuseDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BooleanGUI_FuseDlg::~BooleanGUI_FuseDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BooleanGUI_FuseDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupFuse->LineEdit1; + + myShape1.Nullify(); + myShape2.Nullify(); + myOkShape1 = myOkShape2 = false; + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupFuse->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupFuse->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupFuse->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupFuse->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupFuse->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BooleanGUI_FuseDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BooleanGUI_FuseDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + + if(myOkShape1 && myOkShape2) + myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 3); + + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void BooleanGUI_FuseDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + QString aString = ""; + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupFuse->LineEdit1) + myOkShape1 = false; + else if( myEditCurrentArgument == GroupFuse->LineEdit2) + myOkShape2 = false; + return; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + if(myEditCurrentArgument == GroupFuse->LineEdit1) { + myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape1 = S; + GroupFuse->LineEdit1->setText(aString); + myOkShape1 = true; + } + else if(myEditCurrentArgument == GroupFuse->LineEdit2) { + myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape2 = S; + GroupFuse->LineEdit2->setText(aString); + myOkShape2 = true; + } + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BooleanGUI_FuseDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupFuse->PushButton1) { + GroupFuse->LineEdit1->setFocus(); + myEditCurrentArgument = GroupFuse->LineEdit1; + } + else if(send == GroupFuse->PushButton2) { + GroupFuse->LineEdit2->setFocus(); + myEditCurrentArgument = GroupFuse->LineEdit2; + } + SelectionIntoArgument(); + + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BooleanGUI_FuseDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupFuse->LineEdit1) + myEditCurrentArgument = GroupFuse->LineEdit1; + else if(send == GroupFuse->LineEdit2) + myEditCurrentArgument = GroupFuse->LineEdit2; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BooleanGUI_FuseDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void BooleanGUI_FuseDlg::enterEvent(QEvent* e) +{ + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} diff --git a/src/BooleanGUI/BooleanGUI_FuseDlg.h b/src/BooleanGUI/BooleanGUI_FuseDlg.h new file mode 100644 index 000000000..799eb0b9d --- /dev/null +++ b/src/BooleanGUI/BooleanGUI_FuseDlg.h @@ -0,0 +1,76 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BooleanGUI_FuseDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_FUSE_H +#define DIALOGBOX_FUSE_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel_QTD.h" + +#include "BooleanGUI.h" + +#include + +//================================================================================= +// class : BooleanGUI_FuseDlg +// purpose : +//================================================================================= +class BooleanGUI_FuseDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BooleanGUI_FuseDlg(QWidget* parent = 0, const char* name = 0, BooleanGUI* theBooleanGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BooleanGUI_FuseDlg(); + +private: + void Init(); + void enterEvent(QEvent* e); + + BooleanGUI* myBooleanGUI; + + TopoDS_Shape myShape1; /* topology used to fuse */ + TopoDS_Shape myShape2; /* topology used to fuse */ + GEOM::GEOM_Shape_var myGeomShape1; /* is myShape1 */ + GEOM::GEOM_Shape_var myGeomShape2; /* is myShape2 */ + bool myOkShape1; /* to check when arguments are defined */ + bool myOkShape2; + + DlgRef_2Sel_QTD* GroupFuse; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + void ActivateThisDialog(); + +}; + +#endif // DIALOGBOX_FUSE_H diff --git a/src/BooleanGUI/BooleanGUI_SectionDlg.cxx b/src/BooleanGUI/BooleanGUI_SectionDlg.cxx new file mode 100644 index 000000000..4350ac6c3 --- /dev/null +++ b/src/BooleanGUI/BooleanGUI_SectionDlg.cxx @@ -0,0 +1,249 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BooleanGUI_SectionDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BooleanGUI_SectionDlg.h" + +//================================================================================= +// class : BooleanGUI_SectionDlg() +// purpose : Constructs a BooleanGUI_SectionDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BooleanGUI_SectionDlg::BooleanGUI_SectionDlg(QWidget* parent, const char* name, BooleanGUI* theBooleanGUI, 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_SECTION"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_SECTION_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_SECTION")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupSection = new DlgRef_2Sel_QTD(this, "GroupSection"); + GroupSection->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupSection->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); + GroupSection->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); + GroupSection->PushButton1->setPixmap(image1); + GroupSection->PushButton2->setPixmap(image1); + + Layout1->addWidget(GroupSection, 1, 0); + /***************************************************************/ + + /* Initialisation */ + myBooleanGUI = theBooleanGUI; + Init(); +} + + +//================================================================================= +// function : ~BooleanGUI_SectionDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BooleanGUI_SectionDlg::~BooleanGUI_SectionDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BooleanGUI_SectionDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupSection->LineEdit1; + + myShape1.Nullify(); + myShape2.Nullify(); + myOkShape1 = myOkShape2 = false; + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupSection->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupSection->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupSection->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupSection->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupSection->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BooleanGUI_SectionDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BooleanGUI_SectionDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + + if(myOkShape1 && myOkShape2) + myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 4); + + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void BooleanGUI_SectionDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + QString aString = ""; + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupSection->LineEdit1) + myOkShape1 = false; + else if( myEditCurrentArgument == GroupSection->LineEdit2) + myOkShape2 = false; + return; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + if(myEditCurrentArgument == GroupSection->LineEdit1) { + myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape1 = S; + GroupSection->LineEdit1->setText(aString); + myOkShape1 = true; + } + else if(myEditCurrentArgument == GroupSection->LineEdit2) { + myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myShape2 = S; + GroupSection->LineEdit2->setText(aString); + myOkShape2 = true; + } + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BooleanGUI_SectionDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupSection->PushButton1) { + GroupSection->LineEdit1->setFocus(); + myEditCurrentArgument = GroupSection->LineEdit1; + } + else if(send == GroupSection->PushButton2) { + GroupSection->LineEdit2->setFocus(); + myEditCurrentArgument = GroupSection->LineEdit2; + } + SelectionIntoArgument(); + + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BooleanGUI_SectionDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupSection->LineEdit1) + myEditCurrentArgument = GroupSection->LineEdit1; + else if(send == GroupSection->LineEdit2) + myEditCurrentArgument = GroupSection->LineEdit2; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BooleanGUI_SectionDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void BooleanGUI_SectionDlg::enterEvent(QEvent * e) +{ + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} diff --git a/src/BooleanGUI/BooleanGUI_SectionDlg.h b/src/BooleanGUI/BooleanGUI_SectionDlg.h new file mode 100644 index 000000000..badf2afdf --- /dev/null +++ b/src/BooleanGUI/BooleanGUI_SectionDlg.h @@ -0,0 +1,76 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BooleanGUI_SectionDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header: + +#ifndef DIALOGBOX_SECTION_H +#define DIALOGBOX_SECTION_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel_QTD.h" + +#include "BooleanGUI.h" + +#include + +//================================================================================= +// class : BooleanGUI_SectionDlg +// purpose : +//================================================================================= +class BooleanGUI_SectionDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BooleanGUI_SectionDlg(QWidget* parent = 0, const char* name = 0, BooleanGUI* theBooleanGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BooleanGUI_SectionDlg(); + +private: + void Init(); + void enterEvent(QEvent* e); + + BooleanGUI* myBooleanGUI; + + TopoDS_Shape myShape1; /* topology used to fuse */ + TopoDS_Shape myShape2; /* topology used to fuse */ + GEOM::GEOM_Shape_var myGeomShape1; /* is myShape1 */ + GEOM::GEOM_Shape_var myGeomShape2; /* is myShape2 */ + bool myOkShape1; /* to check when arguments are defined */ + bool myOkShape2; + + DlgRef_2Sel_QTD* GroupSection; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + void ActivateThisDialog(); + +}; + +#endif // DIALOGBOX_SECTION_H diff --git a/src/BooleanGUI/Makefile.in b/src/BooleanGUI/Makefile.in new file mode 100644 index 000000000..9bb1b3c08 --- /dev/null +++ b/src/BooleanGUI/Makefile.in @@ -0,0 +1,73 @@ +# GEOM BOOLEANGUI : +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Damien COQUERET (OCC) +# Module : GEOM +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= BooleanGUI.h + +# Libraries targets +LIB = libBooleanGUI.la + +LIB_SRC = BooleanGUI.cxx \ + BooleanGUI_FuseDlg.cxx \ + BooleanGUI_CommonDlg.cxx \ + BooleanGUI_CutDlg.cxx \ + BooleanGUI_SectionDlg.cxx + +LIB_MOC = \ + BooleanGUI.h \ + BooleanGUI_FuseDlg.h \ + BooleanGUI_CommonDlg.h \ + BooleanGUI_CutDlg.h \ + BooleanGUI_SectionDlg.h + +LIB_CLIENT_IDL = SALOME_Exception.idl \ + GEOM_Gen.idl \ + GEOM_Shape.idl \ + SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +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 -lDlgRef -lGEOMBase $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/BuildGUI/BuildGUI.cxx b/src/BuildGUI/BuildGUI.cxx new file mode 100644 index 000000000..8d74df5d3 --- /dev/null +++ b/src/BuildGUI/BuildGUI.cxx @@ -0,0 +1,680 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BooleanGUI.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "BuildGUI.h" + +#include "OCCViewer_Viewer3d.h" +#include "VTKViewer_ViewFrame.h" +#include "QAD_RightFrame.h" +#include "GEOM_AssemblyBuilder.h" +#include "SALOMEGUI_ImportOperation.h" + +#include +#include +#include + +#include "BuildGUI_SubShapeDlg.h" // Method SUBSHAPE +#include "BuildGUI_EdgeDlg.h" // Method EDGE +#include "BuildGUI_WireDlg.h" // Method WIRE +#include "BuildGUI_FaceDlg.h" // Method FACE +#include "BuildGUI_ShellDlg.h" // Method SHELL +#include "BuildGUI_SolidDlg.h" // Method SOLID +#include "BuildGUI_CompoundDlg.h" // Method COMPOUND + +//======================================================================= +// function : BuildGUI() +// purpose : Constructor +//======================================================================= +BuildGUI::BuildGUI() : + QObject() +{ + myGeomGUI = GEOMBase_Context::GetGeomGUI(); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); +} + + +//======================================================================= +// function : ~BuildGUI() +// purpose : Destructor +//======================================================================= +BuildGUI::~BuildGUI() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool BuildGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + switch (theCommandID) + { + case 303: // 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); + break ; + } + case 304: // GEOM::EDGE + { + BuildGUI_EdgeDlg *aDlg = new BuildGUI_EdgeDlg(parent, "", this, Sel); + break; + } + case 305: // GEOM::WIRE + { + BuildGUI_WireDlg *aDlg = new BuildGUI_WireDlg(parent, "", this, Sel); + break; + } + case 306: // GEOM::FACE + { + BuildGUI_FaceDlg *aDlg = new BuildGUI_FaceDlg(parent, "", this, Sel); + break; + } + case 315: // GEOM::SHELL + { + BuildGUI_ShellDlg *aDlg = new BuildGUI_ShellDlg(parent, "", this, Sel); + break; + } + case 316: // GEOM::SOLID + { + BuildGUI_SolidDlg *aDlg = new BuildGUI_SolidDlg(parent, "", this, Sel); + break; + } + case 308: // GEOM::COMPOUND + { + BuildGUI_CompoundDlg *aDlg = new BuildGUI_CompoundDlg(parent, "", this, Sel); + break; + } + default: + { + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + } + return true; +} + + +//===================================================================================== +// function : MakeLinearEdgeAndDisplay() +// purpose : +//===================================================================================== +void BuildGUI::MakeLinearEdgeAndDisplay(const gp_Pnt P1, const gp_Pnt P2) +{ + try { + GEOM::PointStruct ps1 = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()); + GEOM::PointStruct ps2 = myGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()); + GEOM::GEOM_Shape_var result = myGeom->MakeEdge(ps1, ps2); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + result->NameType(tr("GEOM_EDGE")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeWireAndDisplay() +// purpose : +//===================================================================================== +void BuildGUI::MakeWireAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR) +{ + try { + GEOM::GEOM_Shape_var result = myGeom->MakeWire(listShapesIOR); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + result->NameType(tr("GEOM_WIRE")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeFaceAndDisplay() +// purpose : +//===================================================================================== +void BuildGUI::MakeFaceAndDisplay(GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar) +{ + try { + GEOM::GEOM_Shape_var result = myGeom->MakeFace(aWire, wantPlanar); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + if (wantPlanar) + result->NameType(tr("GEOM_PLANE")); + else + result->NameType(tr("GEOM_FACE")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeShellAndDisplay() +// purpose : +//===================================================================================== +void BuildGUI::MakeShellAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR) +{ + try { + GEOM::GEOM_Shape_var result = myGeom->MakeShell(listShapesIOR); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + result->NameType(tr("GEOM_SHELL")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeSolidAndDisplay() +// purpose : +//===================================================================================== +void BuildGUI::MakeSolidAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR) +{ + try { + GEOM::GEOM_Shape_var result = myGeom->MakeSolid(listShapesIOR); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + result->NameType(tr("GEOM_SOLID")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeCompoundAndDisplay() +// purpose : +//===================================================================================== +void BuildGUI::MakeCompoundAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR) +{ + try { + GEOM::GEOM_Shape_var result = myGeom->MakeCompound(listShapesIOR); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + result->NameType(tr("GEOM_COMPOUND")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : OnSubShapeGetAll() +// purpose : Explode a shape in all sub shapes with a SubShapeType +//===================================================================================== +bool BuildGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType) +{ + 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; + } + + 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; + + /* We create a sub object for each sub shape as attribute of the main object */ + /* Each sub object contains list (length=1) containing its index in the main shape */ + GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR); + GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes; + GEOM::GEOM_Shape_var aResult; + + try { + listGeomShapes = myGeom->SubShapeAll(aShape, SubShapeType); + if(listGeomShapes->length() < 1) { + myGeomGUI->GetDesktop()->putInfo (tr("GEOM_PRP_ABORT")); + return false; + } + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + + /* open transaction */ + QAD_Operation* op = new SALOMEGUI_ImportOperation(myGeomGUI->GetActiveStudy()); + op->start(); + + TopoDS_Shape mainTopo = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); + TopoDS_Shape mainShape; + bool main = false; + while(!main) { + if(aShape->IsMainShape()) { + mainShape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); + main = true; + } + else + aShape = myGeom->GetIORFromString(aShape->MainName()); + } + + /* Loop on each sub shape created */ + /* int i = 1 ; /* index for the nameType */ + for(int j=0; jlength(); j++) { + /* Get each sub shape extracted CORBA and OCC */ + aResult = listGeomShapes[j] ; + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, aResult); + + if (S.IsNull()) { + myGeomGUI->GetDesktop()->putInfo (tr("GEOM_PRP_ABORT")); + return false; + } + + /* Set the nameType of sub shape */ + char* nameG = (char *)malloc(20); + Standard_CString Type; + if(myGeomGUI->GetShapeTypeString(S, Type)) { + aResult->NameType(Type); + sprintf(nameG, "%s_%d", Type, myGeomGUI->GetIndex(S, mainShape, SubShapeType)); + } + else { + aResult->NameType(tr("GEOM_SHAPE")); + sprintf(nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->GetNbGeom()++); + } + SALOMEDS::SObject_var SO = aStudy->FindObjectIOR(aResult->Name()); + + bool allreadyexist = false; + + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + Handle(GEOM_AISShape) result = new GEOM_AISShape(S, nameG); + Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM"); + + MESSAGE ("SO->_is_nil() " << SO->_is_nil()) + + if(SO->_is_nil()) { + SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(theObj); + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(nameG); + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIOR->SetValue(aResult->Name()); + + 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() ) + + SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); + aStudyBuilder->Addreference(newObj1, newObj); + IO->setEntry(newObj->GetID()); + + aResult->StudyShapeId( newObj->GetID() ); + } else { + allreadyexist = true; + 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() ); + } + } + + result->setIO( IO ); + result->setName( nameG ); + if ( !allreadyexist ) + ic->Display(result); + + } 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"); + + 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()); + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(nameG); + + 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" ); + } + + SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); + aStudyBuilder->Addreference(newObj1, newObj); + IO->setEntry(newObj->GetID()); + } else { + allreadyexist = true; + 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); + theActors->InitTraversal(); + vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); + while(!(anActor==NULL)) { + GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor ); + GActor->setIO( IO ); + GActor->setName( nameG ); + theRenderer->AddActor(GActor); + renWin->Render(); + anActor = (vtkActor*)theActors->GetNextActor(); + } + } + } + } + + /* commit transaction */ + op->finish(); + + myGeomGUI->GetActiveStudy()->updateObjBrowser(); + myGeomGUI->GetDesktop()->putInfo (tr("GEOM_PRP_READY")); + return true ; +} + + +//===================================================================================== +// function : OnSubShapeGetSelected() +// purpose : +//===================================================================================== +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 ) { + return false; + } + + 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 ; + } + + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + if( myUseLocalContext == false ) { + /* local context is from DialogBox */ + MESSAGE("Error : No local context opened for sub shapes method" << endl ) ; + return false ; + } + + GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString( ShapeTopoIOR ); + TopoDS_Shape mainTopo = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); + + TopoDS_Shape mainShape; + bool main = false; + while ( !main ) { + if ( aShape->IsMainShape() ) { + mainShape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); + main = true; + } else + aShape = myGeom->GetIORFromString( aShape->MainName() ); + } + + GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; + ic->InitSelected(); + int nbSelected = ic->NbSelected(); + ListOfID->length(nbSelected); + + TopoDS_Compound compound; + ic->InitSelected(); /* to init again */ + BRep_Builder B; + 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() ); + i++; + ic->NextSelected(); + } + + /* Test if user has selected sub shapes */ + if( ListOfID->length() < 1 ) + return false ; + + GEOM::GEOM_Shape_var aResult ; + try { + aResult = myGeom->SubShape( aShape, SubShapeType, ListOfID ); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + + /* local context from DialogBox */ + ic->CloseLocalContext(aLocalContextId) ; + myUseLocalContext = false ; + + 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()++ ); + } + 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()++ ); + } else { + aResult->NameType( tr("GEOM_SHAPE") ); + sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->GetNbGeom()++ ); + } + result = new GEOM_AISShape( compound, nameG ); + IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM"); + } + + SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() ); + + /* open transaction */ + 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::GenericAttribute_var anAttr; + 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 ); + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIOR->SetValue(aResult->Name()); + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(result->getName()); + + 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" ); + } + + SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); + aStudyBuilder->Addreference(newObj1, newObj); + + IO->setEntry(newObj->GetID()); + aResult->StudyShapeId(newObj->GetID()); + } else { + allreadyexist = true; + 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()); + } + } + + /* commit transaction */ + op->finish(); + + result->setIO( IO ); + result->setName( nameG ); + + if ( !allreadyexist ) + ic->Display(result); + + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true); + + myGeomGUI->GetActiveStudy()->updateObjBrowser(); + myGeomGUI->GetDesktop()->putInfo (tr("GEOM_PRP_READY")); + return true; +} diff --git a/src/BuildGUI/BuildGUI.h b/src/BuildGUI/BuildGUI.h new file mode 100644 index 000000000..444619eaf --- /dev/null +++ b/src/BuildGUI/BuildGUI.h @@ -0,0 +1,66 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef BUILDGUI_H +#define BUILDGUI_H + +#include "GEOMBase_Display.h" + +//================================================================================= +// class : BuildGUI +// purpose : +//================================================================================= +class BuildGUI : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + BuildGUI(); + ~BuildGUI(); + + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + + void MakeLinearEdgeAndDisplay(const gp_Pnt P1, const gp_Pnt P2); + void MakeWireAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); + void MakeFaceAndDisplay(GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar); + void MakeShellAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); + void MakeSolidAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); + void MakeCompoundAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); + + /* Methods for sub shapes explode */ + bool OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType); + 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 */ + +}; + +#endif diff --git a/src/BuildGUI/BuildGUI_CompoundDlg.cxx b/src/BuildGUI/BuildGUI_CompoundDlg.cxx new file mode 100644 index 000000000..82403791c --- /dev/null +++ b/src/BuildGUI/BuildGUI_CompoundDlg.cxx @@ -0,0 +1,370 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI_CompoundDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BuildGUI_CompoundDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : BuildGUI_CompoundDlg() +// purpose : Constructs a BuildGUI_CompoundDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BuildGUI_CompoundDlg::BuildGUI_CompoundDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_BUILD_COMPOUND"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + if ( !name ) + setName( "BuildGUI_CompoundDlg" ); + resize( 303, 175 ); + setCaption( tr( "GEOM_COMPOUND_TITLE" ) ); + setSizeGripEnabled( TRUE ); + BuildGUI_CompoundDlgLayout = new QGridLayout( this ); + BuildGUI_CompoundDlgLayout->setSpacing( 6 ); + BuildGUI_CompoundDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_COMPOUND" ) ); + 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( image1 ); + 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 ); + BuildGUI_CompoundDlgLayout->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 ); + BuildGUI_CompoundDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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_OBJECTS" ) ); + 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( image0 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + BuildGUI_CompoundDlgLayout->addWidget( GroupC1, 1, 0 ); + /***************************************************************/ + myBuildGUI = theBuildGUI; + Init(Sel) ; /* Initialisations */ +} + + +//================================================================================= +// function : ~BuildGUI_CompoundDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BuildGUI_CompoundDlg::~BuildGUI_CompoundDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BuildGUI_CompoundDlg::Init( SALOME_Selection* Sel ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + this->myOkListShapes = false ; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + 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); + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BuildGUI_CompoundDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BuildGUI_CompoundDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BuildGUI_CompoundDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkListShapes) { + myBuildGUI->MakeCompoundAndDisplay( myListShapes ) ; + } + break ; + } + } + // accept(); + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void BuildGUI_CompoundDlg::ClickOnCancel() +{ + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BuildGUI_CompoundDlg::SelectionIntoArgument() +{ + /* All this for first constructor */ + // if(myEditCurrentArgument == LineEditC1A1 ) + + myOkListShapes = false; + myEditCurrentArgument->setText("") ; + QString aString = ""; /* name of selection */ + + int nbSel = mySelection->IObjectCount() ; + if ( nbSel == 0 ) + return; + aString = tr( "%1_objects" ).arg( nbSel ); + + myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes) ; + myEditCurrentArgument->setText(aString) ; + myOkListShapes = true ; + /* no simulation */ + return ; +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BuildGUI_CompoundDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BuildGUI_CompoundDlg::LineEditReturnPressed() +{ + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void BuildGUI_CompoundDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BuildGUI_CompoundDlg::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() ) ); + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BuildGUI_CompoundDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void BuildGUI_CompoundDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} diff --git a/src/BuildGUI/BuildGUI_CompoundDlg.h b/src/BuildGUI/BuildGUI_CompoundDlg.h new file mode 100644 index 000000000..630a95034 --- /dev/null +++ b/src/BuildGUI/BuildGUI_CompoundDlg.h @@ -0,0 +1,104 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_Context*_CompoundDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_COMPOUND_H +#define DIALOGBOX_COMPOUND_H + +#include "BuildGUI.h" + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; + + +//================================================================================= +// class : BuildGUI_CompoundDlg +// purpose : +//================================================================================= +class BuildGUI_CompoundDlg : public QDialog +{ + Q_OBJECT + +public: + BuildGUI_CompoundDlg(QWidget* parent = 0, const char* name = 0, BuildGUI* theBuildGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BuildGUI_CompoundDlg(); + +private: + BuildGUI* myBuildGUI; + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + GEOM::GEOM_Gen::ListOfIOR myListShapes ; + bool myOkListShapes ; /* to check when arguments is defined */ + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void LineEditReturnPressed() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* BuildGUI_CompoundDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_COMPOUND_H diff --git a/src/BuildGUI/BuildGUI_EdgeDlg.cxx b/src/BuildGUI/BuildGUI_EdgeDlg.cxx new file mode 100644 index 000000000..74b8069c8 --- /dev/null +++ b/src/BuildGUI/BuildGUI_EdgeDlg.cxx @@ -0,0 +1,457 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI_EdgeDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BuildGUI_EdgeDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +//================================================================================= +// class : BuildGUI_EdgeDlg() +// purpose : Constructs a BuildGUI_EdgeDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BuildGUI_EdgeDlg::BuildGUI_EdgeDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_BUILD_EDGE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "BuildGUI_EdgeDlg" ); + resize( 303, 225 ); + setCaption( tr( "GEOM_EDGE_TITLE" ) ); + setSizeGripEnabled( TRUE ); + BuildGUI_EdgeDlgLayout = new QGridLayout( this ); + BuildGUI_EdgeDlgLayout->setSpacing( 6 ); + BuildGUI_EdgeDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_EDGE" ) ); + 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 ); + BuildGUI_EdgeDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_POINTS" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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 ); + GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); + GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "GEOM_POINT_I" ).arg("1") ); + 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_POINT_I" ).arg("2") ); + TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); + GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); + BuildGUI_EdgeDlgLayout->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 ); + BuildGUI_EdgeDlgLayout->addWidget( GroupButtons, 2, 0 ); + /***************************************************************/ + myBuildGUI = theBuildGUI; + Init(Sel) ; /* Initialisations */ +} + + +//================================================================================= +// function : ~BuildGUI_EdgeDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BuildGUI_EdgeDlg::~BuildGUI_EdgeDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BuildGUI_EdgeDlg::Init( SALOME_Selection* Sel ) +{ + + GroupC1->show(); + // GroupC2->hide(); + // GroupC3->hide(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + myPoint1.SetCoord( 0.0, 0.0, 0.0 ); + myPoint2.SetCoord( 0.0, 0.0, 0.0 ); + myOkPoint1 = myOkPoint2 = false ; + mySimulationTopoDs.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 */ + + /* 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( 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 ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BuildGUI_EdgeDlg::ConstructorsClicked(int constructorId) +{ + switch (constructorId) + { + case 0: + { + break; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BuildGUI_EdgeDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BuildGUI_EdgeDlg::ClickOnApply() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + switch(myConstructorId) + { + case 0 : + { + if(myOkPoint1 && myOkPoint2) + myBuildGUI->MakeLinearEdgeAndDisplay( myPoint1, myPoint2 ) ; + break ; + } + } + // accept(); + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void BuildGUI_EdgeDlg::ClickOnCancel() +{ + mySelection->ClearFilters() ; + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BuildGUI_EdgeDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + QString aString = ""; /* name of future selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) { + if ( myEditCurrentArgument == LineEditC1A1 ) { + myOkPoint1 = false ; + } + else if ( myEditCurrentArgument == LineEditC1A2 ) { + myOkPoint2 = false ; + } + return ; + } + + // nbSel == 1 ! + TopoDS_Shape S; + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if ( myConstructorId == 0 && myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) { + myEditCurrentArgument->setText(aString) ; + myOkPoint1 = true ; + } + else if ( myConstructorId == 0 && myEditCurrentArgument == LineEditC1A2 && myGeomGUI->VertexToPoint(S, myPoint2) ) { + myEditCurrentArgument->setText(aString) ; + myOkPoint2 = true ; + } + + if( myOkPoint1 && myOkPoint2 && myPoint1.Distance(myPoint2) > Precision::Confusion() ) { + mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape(); + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + } + return ; +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BuildGUI_EdgeDlg::LineEditReturnPressed() +{ + 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 ; +} + + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BuildGUI_EdgeDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters() ; + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + else if(send == SelectButtonC1A2) { + LineEditC1A2->setFocus() ; + myEditCurrentArgument = LineEditC1A2; + } + mySelection->AddFilter(myVertexFilter) ; + SelectionIntoArgument() ; + break; + } + } + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void BuildGUI_EdgeDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + // TODO other constructors + // + GroupButtons->setEnabled(false) ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->EraseSimulationShape() ; + mySelection->ClearFilters() ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BuildGUI_EdgeDlg::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 ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BuildGUI_EdgeDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void BuildGUI_EdgeDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} diff --git a/src/BuildGUI/BuildGUI_EdgeDlg.h b/src/BuildGUI/BuildGUI_EdgeDlg.h new file mode 100644 index 000000000..6949e4572 --- /dev/null +++ b/src/BuildGUI/BuildGUI_EdgeDlg.h @@ -0,0 +1,114 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI_EdgeDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_EDGE_H +#define DIALOGBOX_EDGE_H + +#include "BuildGUI.h" + +#include + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; + + +//================================================================================= +// class : BuildGUI_EdgeDlg +// purpose : +//================================================================================= +class BuildGUI_EdgeDlg : public QDialog +{ + Q_OBJECT + +public: + BuildGUI_EdgeDlg(QWidget* parent = 0, const char* name = 0, BuildGUI* theBuildGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BuildGUI_EdgeDlg(); + +private : + BuildGUI* myBuildGUI; + 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 */ + gp_Pnt myPoint1 ; /* Points containing the vector */ + gp_Pnt myPoint2 ; + + bool myOkPoint1 ; /* true when myPoint is defined */ + bool myOkPoint2 ; + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + int myConstructorId ; /* Current constructor id = radio button id */ + Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filter selection */ + + void closeEvent( QCloseEvent* e ) ; + void enterEvent( QEvent* e); + void Init( SALOME_Selection* Sel ) ; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupC1; + QPushButton* SelectButtonC1A2; + QLineEdit* LineEditC1A1; + QLineEdit* LineEditC1A2; + QPushButton* SelectButtonC1A1; + QLabel* TextLabelC1A1; + QLabel* TextLabelC1A2; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void LineEditReturnPressed() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* BuildGUI_EdgeDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; + QGridLayout* GroupButtonsLayout; +}; + +#endif // DIALOGBOX_EDGE_H diff --git a/src/BuildGUI/BuildGUI_FaceDlg.cxx b/src/BuildGUI/BuildGUI_FaceDlg.cxx new file mode 100644 index 000000000..3aa96d62d --- /dev/null +++ b/src/BuildGUI/BuildGUI_FaceDlg.cxx @@ -0,0 +1,415 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI_FaceDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BuildGUI_FaceDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +//================================================================================= +// class : BuildGUI_FaceDlg() +// purpose : Constructs a BuildGUI_FaceDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BuildGUI_FaceDlg::BuildGUI_FaceDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_BUILD_FACE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "BuildGUI_FaceDlg" ); + resize( 303, 208 ); + setCaption( tr( "GEOM_FACE_TITLE" ) ); + setSizeGripEnabled( TRUE ); + BuildGUI_FaceDlgLayout = new QGridLayout( this ); + BuildGUI_FaceDlgLayout->setSpacing( 6 ); + BuildGUI_FaceDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_FACE" ) ); + 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 ); + BuildGUI_FaceDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_FACE_FFW" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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_WIRE" ) ); + 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 ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + CheckBox1 = new QCheckBox( GroupC1, "CheckBox1" ); + CheckBox1->setText( tr( "GEOM_FACE_OPT" ) ); + CheckBox1->setChecked( TRUE ); + GroupC1Layout->addWidget( CheckBox1, 1, 2); + BuildGUI_FaceDlgLayout->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 ); + BuildGUI_FaceDlgLayout->addWidget( GroupButtons, 2, 0 ); + myBuildGUI = theBuildGUI; + Init(Sel) ; /* Initialisations */ +} + + +//================================================================================= +// function : ~BuildGUI_FaceDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BuildGUI_FaceDlg::~BuildGUI_FaceDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BuildGUI_FaceDlg::Init( SALOME_Selection* Sel ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + CheckBox1->setChecked( TRUE ); + + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + this->myOkShape = false ; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + 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); + myWireFilter = new GEOM_ShapeTypeFilter( TopAbs_WIRE, myGeom ); + mySelection->AddFilter(myWireFilter) ; /* first filter used */ + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + 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 ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BuildGUI_FaceDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BuildGUI_FaceDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BuildGUI_FaceDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + switch(myConstructorId) + { + case 0 : + { + if(myOkShape) { + myBuildGUI->MakeFaceAndDisplay(this->myGeomShape, this->CheckBox1->isChecked() ) ; + } + break ; + } + } + // accept(); + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void BuildGUI_FaceDlg::ClickOnCancel() +{ + mySelection->ClearFilters() ; + myGeomGUI->ResetState() ; + disconnect( mySelection, 0, this, 0 ); + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BuildGUI_FaceDlg::SelectionIntoArgument() +{ + /* All this for first constructor */ + // if(myEditCurrentArgument == LineEditC1A1 ) + + myOkShape = false; + myEditCurrentArgument->setText("") ; + QString aString = ""; /* future the name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) + return ; + + // nbSel == 1 ! + Standard_Boolean testResult ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + if( !myGeomGUI->GetTopoFromSelection(this->mySelection, this->myShape) ) + return ; + + myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; + if( !testResult ) + return ; + + myEditCurrentArgument->setText(aString) ; + this->myOkShape = true ; + + /* no simulation */ + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BuildGUI_FaceDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters() ; + + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + mySelection->AddFilter(myWireFilter) ; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BuildGUI_FaceDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + 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 ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void BuildGUI_FaceDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + disconnect( mySelection, 0, this, 0 ); + mySelection->ClearFilters() ; + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BuildGUI_FaceDlg::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() ) ); + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BuildGUI_FaceDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void BuildGUI_FaceDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} diff --git a/src/BuildGUI/BuildGUI_FaceDlg.h b/src/BuildGUI/BuildGUI_FaceDlg.h new file mode 100644 index 000000000..a014cdce4 --- /dev/null +++ b/src/BuildGUI/BuildGUI_FaceDlg.h @@ -0,0 +1,110 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI_FaceDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_FACE_H +#define DIALOGBOX_FACE_H + +#include "BuildGUI.h" + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QCheckBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; + + +//================================================================================= +// class : BuildGUI_FaceDlg +// purpose : +//================================================================================= +class BuildGUI_FaceDlg : public QDialog +{ + Q_OBJECT + +public: + BuildGUI_FaceDlg( QWidget* parent = 0, const char* name = 0, BuildGUI* theBuildGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~BuildGUI_FaceDlg(); + +private: + BuildGUI* myBuildGUI; + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + + TopoDS_Shape myShape ; /* topology used to fuse */ + GEOM::GEOM_Shape_var myGeomShape ; /* is myShape */ + bool myOkShape ; /* to check when arguments is defined */ + + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + Handle(GEOM_ShapeTypeFilter) myWireFilter; /* Filter selection */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + QCheckBox* CheckBox1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void LineEditReturnPressed() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* BuildGUI_FaceDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; + QGridLayout* GroupButtonsLayout; +}; + +#endif // DIALOGBOX_FACE_H diff --git a/src/BuildGUI/BuildGUI_ShellDlg.cxx b/src/BuildGUI/BuildGUI_ShellDlg.cxx new file mode 100644 index 000000000..18f428d62 --- /dev/null +++ b/src/BuildGUI/BuildGUI_ShellDlg.cxx @@ -0,0 +1,201 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI_ShellDlg.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "BuildGUI_ShellDlg.h" + +#include "BuildGUI.h" +#include "QAD_Desktop.h" + +//================================================================================= +// class : BuildGUI_ShellDlg() +// purpose : Constructs a BuildGUI_ShellDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BuildGUI_ShellDlg::BuildGUI_ShellDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, 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_BUILD_SHELL"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setCaption(tr("GEOM_SHELL_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_SHELL")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupShell = new DlgRef_1Sel_QTD(this, "GroupShell"); + GroupShell->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupShell->TextLabel1->setText(tr("GEOM_OBJECTS")); + GroupShell->PushButton1->setPixmap(image1); + + Layout1->addWidget(GroupShell, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myBuildGUI = theBuildGUI; + Init(); +} + + +//================================================================================= +// function : ~BuildGUI_ShellDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BuildGUI_ShellDlg::~BuildGUI_ShellDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BuildGUI_ShellDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupShell->LineEdit1; + myOkListShapes = false; + + myFaceFilter = new GEOM_FaceFilter(StdSelect_Plane, myGeom); + /* Filter for the next selection */ + mySelection->AddFilter(myFaceFilter) ; + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupShell->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupShell->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BuildGUI_ShellDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BuildGUI_ShellDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + + if(myOkListShapes) + myBuildGUI->MakeShellAndDisplay(myListShapes); + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BuildGUI_ShellDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + QString aString = ""; + + myOkListShapes = false; + int nbSel = mySelection->IObjectCount(); + if(nbSel == 0) + return; + + aString = tr("%1_objects").arg(nbSel); + + myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes); + myEditCurrentArgument->setText(aString); + myOkListShapes = true; + + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BuildGUI_ShellDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters() ; + + if(send == GroupShell->PushButton1) { + GroupShell->LineEdit1->setFocus(); + myEditCurrentArgument = GroupShell->LineEdit1; + mySelection->AddFilter(myFaceFilter); + } + SelectionIntoArgument(); + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BuildGUI_ShellDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BuildGUI_ShellDlg::enterEvent(QEvent* e) +{ + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} diff --git a/src/BuildGUI/BuildGUI_ShellDlg.h b/src/BuildGUI/BuildGUI_ShellDlg.h new file mode 100644 index 000000000..87f3d428e --- /dev/null +++ b/src/BuildGUI/BuildGUI_ShellDlg.h @@ -0,0 +1,73 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI_ShellDlg.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DIALOGBOX_SHELL_H +#define DIALOGBOX_SHELL_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel_QTD.h" + +#include "BuildGUI.h" + +#include "GEOM_FaceFilter.hxx" + +//================================================================================= +// class : BuildGUI_ShellDlg +// purpose : +//================================================================================= +class BuildGUI_ShellDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BuildGUI_ShellDlg(QWidget* parent = 0, const char* name = 0, BuildGUI* theBuildGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BuildGUI_ShellDlg(); + +private: + void Init(); + void enterEvent(QEvent * e); + + BuildGUI* myBuildGUI; + + Handle(GEOM_FaceFilter) myFaceFilter; /* Filters selection */ + GEOM::GEOM_Gen::ListOfIOR myListShapes; + bool myOkListShapes; /* to check when arguments is defined */ + + DlgRef_1Sel_QTD* GroupShell; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void SetEditCurrentArgument(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void ActivateThisDialog(); + +}; + +#endif // DIALOGBOX_SHELL_H diff --git a/src/BuildGUI/BuildGUI_SolidDlg.cxx b/src/BuildGUI/BuildGUI_SolidDlg.cxx new file mode 100644 index 000000000..4c4533787 --- /dev/null +++ b/src/BuildGUI/BuildGUI_SolidDlg.cxx @@ -0,0 +1,201 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI_SolidDlg.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "BuildGUI_SolidDlg.h" + +#include "BuildGUI.h" +#include "QAD_Desktop.h" + +//================================================================================= +// class : BuildGUI_SolidDlg() +// purpose : Constructs a BuildGUI_SolidDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BuildGUI_SolidDlg::BuildGUI_SolidDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, 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_BUILD_SOLID"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setCaption(tr("GEOM_SOLID_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_SOLID")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupSolid = new DlgRef_1Sel_QTD(this, "GroupSolid"); + GroupSolid->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupSolid->TextLabel1->setText(tr("GEOM_OBJECTS")); + GroupSolid->PushButton1->setPixmap(image1); + + Layout1->addWidget(GroupSolid, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myBuildGUI = theBuildGUI; + Init(); +} + + +//================================================================================= +// function : ~BuildGUI_SolidDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BuildGUI_SolidDlg::~BuildGUI_SolidDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BuildGUI_SolidDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupSolid->LineEdit1; + myOkListShapes = false; + + myShellFilter = new GEOM_ShapeTypeFilter(TopAbs_SHELL, myGeom); + /* filter for next selection */ + mySelection->AddFilter(myShellFilter); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupSolid->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupSolid->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BuildGUI_SolidDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BuildGUI_SolidDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + + if(myOkListShapes) + myBuildGUI->MakeSolidAndDisplay(myListShapes); + + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BuildGUI_SolidDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + QString aString = ""; + + myOkListShapes = false; + int nbSel = mySelection->IObjectCount(); + if (nbSel == 0) + return; + + aString = tr("%1_objects").arg(nbSel); + + myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes); + myEditCurrentArgument->setText(aString); + myOkListShapes = true; + + return ; +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BuildGUI_SolidDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + mySelection->ClearFilters() ; + + if(send == GroupSolid->PushButton1) { + GroupSolid->LineEdit1->setFocus(); + myEditCurrentArgument = GroupSolid->LineEdit1; + mySelection->AddFilter(myShellFilter); + } + SelectionIntoArgument(); + + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BuildGUI_SolidDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BuildGUI_SolidDlg::enterEvent(QEvent* e) +{ + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} diff --git a/src/BuildGUI/BuildGUI_SolidDlg.h b/src/BuildGUI/BuildGUI_SolidDlg.h new file mode 100644 index 000000000..15945f0f1 --- /dev/null +++ b/src/BuildGUI/BuildGUI_SolidDlg.h @@ -0,0 +1,71 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI_SolidDlg.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DIALOGBOX_SOLID_H +#define DIALOGBOX_SOLID_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel_QTD.h" + +#include "BuildGUI.h" + +//================================================================================= +// class : BuildGUI_SolidDlg +// purpose : +//================================================================================= +class BuildGUI_SolidDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BuildGUI_SolidDlg(QWidget* parent = 0, const char* name = 0, BuildGUI* theBuildGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BuildGUI_SolidDlg(); + +private: + void Init(); + void enterEvent(QEvent * e); + + BuildGUI* myBuildGUI; + + Handle(GEOM_ShapeTypeFilter) myShellFilter; /* filter for selection */ + GEOM::GEOM_Gen::ListOfIOR myListShapes; + bool myOkListShapes; /* to check when arguments is defined */ + + DlgRef_1Sel_QTD* GroupSolid; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void SetEditCurrentArgument(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void ActivateThisDialog(); + +}; + +#endif // DIALOGBOX_SOLID_H diff --git a/src/BuildGUI/BuildGUI_SubShapeDlg.cxx b/src/BuildGUI/BuildGUI_SubShapeDlg.cxx new file mode 100644 index 000000000..5f8284255 --- /dev/null +++ b/src/BuildGUI/BuildGUI_SubShapeDlg.cxx @@ -0,0 +1,741 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI_SubShapeDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BuildGUI_SubShapeDlg.h" + +#include "QAD_RightFrame.h" +#include "OCCViewer_Viewer3d.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include + +//================================================================================= +// class : BuildGUI_SubShapeDlg() +// purpose : Constructs a BuildGUI_SubShapeDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BuildGUI_SubShapeDlg::BuildGUI_SubShapeDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, SALOME_Selection* Sel, Handle(AIS_InteractiveContext) ic, bool modal, WFlags fl) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_SUBSHAPE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "BuildGUI_SUBSHAPE" ); + resize( 303, 239 ); + setCaption( tr( "GEOM_SUBSHAPE_TITLE" ) ); + setSizeGripEnabled( TRUE ); + BuildGUI_SubShapeDlgLayout = new QGridLayout( this ); + BuildGUI_SubShapeDlgLayout->setSpacing( 6 ); + BuildGUI_SubShapeDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_SUB_SHAPE" ) ); + 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 ); + BuildGUI_SubShapeDlgLayout->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 ); + BuildGUI_SubShapeDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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_MAIN_OBJECT" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + TextLabelComboBox1 = new QLabel( GroupC1, "TextLabelComboBox1" ); + TextLabelComboBox1->setText( tr( "GEOM_SUBSHAPE_TYPE" ) ); + GroupC1Layout->addMultiCellWidget( TextLabelComboBox1, 1, 1, 0, 1 ); + ComboBox1 = new QComboBox( FALSE, GroupC1, "ComboBox1" ); + ComboBox1->setMaxCount( 100 ); + GroupC1Layout->addMultiCellWidget( ComboBox1, 1, 1, 2, 3 ); + CheckBox1 = new QCheckBox( GroupC1, "CheckBox1" ); + CheckBox1->setText( tr( "GEOM_SUBSHAPE_SELECT" ) ); + CheckBox1->setChecked( FALSE ); + GroupC1Layout->addMultiCellWidget( CheckBox1, 2, 2, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 2, 3 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + BuildGUI_SubShapeDlgLayout->addWidget( GroupC1, 1, 0 ); + /***************************************************************/ + myBuildGUI = theBuildGUI; + /* Initialisations */ + Init(Sel, ic) ; +} + + +//================================================================================= +// function : ~BuildGUI_SubShapeDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BuildGUI_SubShapeDlg::~BuildGUI_SubShapeDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BuildGUI_SubShapeDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myShape.Nullify() ; + + myIC = ic ; + myUseLocalContext = false ; + myLocalContextId = -1; + myAbort = false ; + myOkShape = false ; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + + /* type for sub shape selection */ + ComboBox1->insertItem("Compound"); + ComboBox1->insertItem("Compsolid"); + ComboBox1->insertItem("Solid"); + ComboBox1->insertItem("Shell"); + ComboBox1->insertItem("Face"); + ComboBox1->insertItem("Wire"); + ComboBox1->insertItem("Edge"); + ComboBox1->insertItem("Vertex"); + ComboBox1->insertItem("Shape"); + + myWithShape = true; + myShapeType = ComboBox1->currentItem(); + + /* Select sub shapes mode not checked */ + CheckBox1->setChecked( FALSE ); + myOkSelectSubMode = CheckBox1->isChecked(); + + // TODO : previous selection into argument ? + + /* Filter definitions */ + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); + + /* 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) ), this, SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( CheckBox1, SIGNAL (stateChanged(int) ), this, SLOT( AllOrNotAll() ) ) ; + + connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); + connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); + + connect( ComboBox1, SIGNAL( activated(int) ), this, SLOT( ComboTextChanged() ) ); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* display Dialog */ + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BuildGUI_SubShapeDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BuildGUI_SubShapeDlg::ClickOnOk() +{ + this->ClickOnApply() ; + + /* User has aborted or not operation of explode all with many sub shapes */ + if( this->myAbort == false ) + this->ClickOnCancel() ; + else + this->myAbort = false ; + + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BuildGUI_SubShapeDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + bool testResult = false ; + + this->myAbort = false ; /* Not aborted by default */ + + switch(myConstructorId) + { + case 0 : + { + /* Explode all sub shapes */ + if( myOkShape && !myOkSelectSubMode ) { + + /* More than 30 subshapes : ask confirmation */ + unsigned int nb = NumberOfSubShapes( myShape, myShapeType ) ; + if( nb > 30 ) { + const QString caption = tr("GEOM_CONFIRM") ; + const QString text = tr("GEOM_CONFIRM_INFO").arg(nb) ; + const QString button0 = tr("GEOM_BUT_EXPLODE") ; + const QString button1 = tr("GEOM_BUT_CANCEL") ; + + if( QMessageBox::warning( this, caption, text, button0, button1 ) == 0 ) + testResult = myBuildGUI->OnSubShapeGetAll( myShape, myShapeIOR, myShapeType ) ; + else + this->myAbort = true ; /* aborted */ + } + else { + testResult = myBuildGUI->OnSubShapeGetAll( myShape, myShapeIOR, myShapeType ) ; + } + } + /* explode only selected sub shapes */ + else if( myOkShape && myOkSelectSubMode ) { + testResult = myBuildGUI->OnSubShapeGetSelected( myShape, myShapeIOR, myShapeType, myLocalContextId, myUseLocalContext ) ; + } + if( !testResult ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ; + this->myAbort = true; + } + else { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ; + } + /* Reset all arguments and local context to allow user a new selection ...*/ + this->ResetStateOfDialog() ; + break ; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void BuildGUI_SubShapeDlg::ClickOnCancel() +{ + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + myIC = v3d->getAISContext(); + if(myUseLocalContext) { + myIC->CloseLocalContext(myLocalContextId) ; + + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + this->myUseLocalContext = false ; + } + } + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +// : used only by SelectButtonC1A1 (LineEditC1A1) +//================================================================================= +void BuildGUI_SubShapeDlg::SelectionIntoArgument() +{ + + /* Reset all arguments and local context when selection as changed */ + this->ResetStateOfDialog() ; + + QString aString = ""; /* future name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + + if ( nbSel != 1 ) { + LineEditC1A1->setText("") ; + myOkShape = false; + return ; + } + + /* nbSel == 1 */ + TopoDS_Shape S ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if( !IO->hasEntry() ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")) ; + return ; + } + + if ( !S.IsNull() && S.ShapeType() != TopAbs_VERTEX ) + { + if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) + { + Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO ); + myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */ + LineEditC1A1->setText(aString) ; + myShape = S ; + myOkShape = true ; + } + else + { + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) + { + if (obj->FindAttribute(anAttr, "AttributeIOR")) + { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + myShapeIOR = anIOR->Value(); + myOkShape = true ; + myShape = S ; + LineEditC1A1->setText(aString) ; + } + } + } + + int SelectedShapeType = ComboBox1->currentItem(); + int count = ComboBox1->count(); + if ( myWithShape ) count = count - 1; + + int i = 0; + while ( i <= myShape.ShapeType() ) { + ComboBox1->removeItem(0); + i++; + } + + if (myShape.ShapeType()==TopAbs_COMPOUND) + { + if (myWithShape == false) { + ComboBox1->insertItem("Shape"); + myWithShape = true; + } + } + else + { + if (myWithShape == true) { + ComboBox1->removeItem( ComboBox1->count() -1 ); + myWithShape = false; + } + } + + int count1 = ComboBox1->count(); + if ( myWithShape ) count1 = count1 - 1; + + if ( SelectedShapeType > myShape.ShapeType() ) { + if ( SelectedShapeType == 8 ) { + if ( myShape.ShapeType() != TopAbs_COMPOUND ) { + ComboBox1->setCurrentItem(0); + myShapeType = 8 - count1; + } + } else { + ComboBox1->setCurrentItem( count1 - count + SelectedShapeType ); + myShapeType = 8 - count1 + ComboBox1->currentItem(); + } + } else { + ComboBox1->setCurrentItem(0); + myShapeType = 8 - count1; + } + } +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BuildGUI_SubShapeDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + SelectionIntoArgument() ; + } + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BuildGUI_SubShapeDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + 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 ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void BuildGUI_SubShapeDlg::DeactivateActiveDialog() +{ + /* Check if active */ + if ( GroupConstructors->isEnabled() ) { + + this->ResetStateOfDialog() ; + + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + myGeomGUI->ResetState() ; + myGeomGUI->SetActiveDialogBox(0) ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BuildGUI_SubShapeDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate other active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BuildGUI_SubShapeDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void BuildGUI_SubShapeDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +//================================================================================= +// function : AllOrNotAll() +// purpose : Allow user selection of all or only selected sub shapes +// : Called when 'CheckBox1' state change +//================================================================================= +void BuildGUI_SubShapeDlg::AllOrNotAll() +{ + + /* No sub shape selection if main shape not selected */ + if( !this->myOkShape ) { + ResetStateOfDialog() ; + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_FIRST")) ; + return ; + } + + if (myShapeType ==TopAbs_SHAPE && myShape.ShapeType()==TopAbs_COMPOUND) + { + /* Select sub shapes mode not checked */ + myOkSelectSubMode = false ; + CheckBox1->setChecked( FALSE ); + //no meaning to allow user selection for type = shape + //TODO - add another message + //myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_FIRST")) ; + return ; + } + + myOkSelectSubMode = CheckBox1->isChecked() ; + + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + myIC = v3d->getAISContext(); + if( this->myUseLocalContext ) { + myIC->CloseLocalContext(myLocalContextId) ; + this->myUseLocalContext = false ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + } else { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ; + return; + } + + if( myOkShape && myOkSelectSubMode ) { + /* local context is defined into the method */ + myGeomGUI->PrepareSubShapeSelection( this->myShapeType, this->myLocalContextId ) ; + myUseLocalContext = true ; + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_FACE")) ; + } + return ; +} + + +//================================================================================= +// function : ResetStateOfDialog() +// purpose : Completely reset the state of method including local context +//================================================================================= +void BuildGUI_SubShapeDlg::ResetStateOfDialog() +{ + /* To leave current selection if explode all as been aborted by user */ + if( this->myAbort == true ) { + this->myOkShape = false ; + this->myEditCurrentArgument->setText("") ; + } + else { + ; /* nothing to do : keep selection argument */ + } + + int SelectedShapeType = ComboBox1->currentItem(); + int count = ComboBox1->count(); + if ( myWithShape ) count = count - 1; + /* type for sub shape selection */ + ComboBox1->clear(); + ComboBox1->insertItem("Compound"); + ComboBox1->insertItem("Compsolid"); + ComboBox1->insertItem("Solid"); + ComboBox1->insertItem("Shell"); + ComboBox1->insertItem("Face"); + ComboBox1->insertItem("Wire"); + ComboBox1->insertItem("Edge"); + ComboBox1->insertItem("Vertex"); + ComboBox1->insertItem("Shape"); + this->myWithShape=true; + ComboBox1->setCurrentItem( 8 - count + SelectedShapeType ); + + + /* unpress buttons : due to abort box*/ + this->buttonApply->setDown(FALSE) ; + this->buttonOk->setDown(FALSE) ; + + /* Select sub shapes mode not checked */ + this->myOkSelectSubMode = false ; + this->CheckBox1->setChecked( FALSE ); + + /* Close its local contact if opened */ + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + myIC = v3d->getAISContext(); + if( this->myUseLocalContext ) { + myIC->CloseLocalContext(this->myLocalContextId) ; + this->myUseLocalContext = false ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + } + return ; +} + + + +//================================================================================= +// function : ComboTextChanged() +// purpose : +//================================================================================= +void BuildGUI_SubShapeDlg::ComboTextChanged() +{ + if ( myOkShape ) + this->myShapeType = ComboBox1->currentItem() + myShape.ShapeType() + 1; + else + this->myShapeType = ComboBox1->currentItem(); + + /* Select sub shapes mode not checked */ + CheckBox1->setChecked( FALSE ); + myOkSelectSubMode = FALSE ; + + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + myIC = v3d->getAISContext(); + if( this->myUseLocalContext ) { + myIC->CloseLocalContext(myLocalContextId) ; + this->myUseLocalContext = false ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + } + return ; +} + + +//================================================================================= +// function : NumberOfSubShapes() +// purpose : +//================================================================================= +unsigned int BuildGUI_SubShapeDlg::NumberOfSubShapes( const TopoDS_Shape& S, const int shapeType ) +{ + if( S.IsNull() ) + return 0 ; + + unsigned int index = 0 ; + TopExp_Explorer Exp( S, TopAbs_ShapeEnum(shapeType) ); + TopTools_MapOfShape M; + while ( Exp.More() ) { + if ( M.Add(Exp.Current()) ) + index++; + Exp.Next(); + } + M.Clear() ; + return index ; +} + + diff --git a/src/BuildGUI/BuildGUI_SubShapeDlg.h b/src/BuildGUI/BuildGUI_SubShapeDlg.h new file mode 100644 index 000000000..862f1df5e --- /dev/null +++ b/src/BuildGUI/BuildGUI_SubShapeDlg.h @@ -0,0 +1,131 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI_SubShapeDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_SUBSHAPE_H +#define DIALOGBOX_SUBSHAPE_H + +#include "BuildGUI.h" + +#include + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QCheckBox; +class QComboBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; + + +//================================================================================= +// class : BuildGUI_SubShapeDlg +// purpose : +//================================================================================= +class BuildGUI_SubShapeDlg : public QDialog +{ + Q_OBJECT + +public: + BuildGUI_SubShapeDlg(QWidget* parent = 0, const char* name = 0, BuildGUI* theBuildGUI = 0, SALOME_Selection* Sel = 0, Handle(AIS_InteractiveContext) ic = 0, bool modal = FALSE, WFlags fl = 0); + ~BuildGUI_SubShapeDlg(); + +private : + BuildGUI* myBuildGUI; + void Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void ResetStateOfDialog() ; + + unsigned int NumberOfSubShapes( const TopoDS_Shape& S, const int shapeType ) ; + + + /* Interactive and local context management see also : bool myUseLocalContext() */ + Handle (AIS_InteractiveContext) myIC ; /* Interactive context */ + Standard_Integer myLocalContextId ; /* identify a local context used by this method */ + bool myUseLocalContext ; /* true when this method as opened a local context */ + + GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + + TopoDS_Shape myShape ; + char* myShapeIOR ; + bool myOkShape ; + int myShapeType ; /* define a type of topology mode of sub selection */ + + bool myWithShape ; /* check if Shape item exists */ + + bool myOkSelectSubMode ; /* true = sub mode selection activated */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + int myConstructorId ; /* Current constructor id = radio button id */ + bool myAbort ; /* Indicate if sub Shape All has been aborted by user */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + QLabel* TextLabelC1A1; + QLabel* TextLabelComboBox1; + QComboBox* ComboBox1; + + QCheckBox* CheckBox1; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void LineEditReturnPressed() ; + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void AllOrNotAll() ; + void ComboTextChanged() ; + +protected: + QGridLayout* BuildGUI_SubShapeDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_SUBSHAPE_H diff --git a/src/BuildGUI/BuildGUI_WireDlg.cxx b/src/BuildGUI/BuildGUI_WireDlg.cxx new file mode 100644 index 000000000..5c42f52c4 --- /dev/null +++ b/src/BuildGUI/BuildGUI_WireDlg.cxx @@ -0,0 +1,370 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI_WireDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BuildGUI_WireDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : BuildGUI_WireDlg() +// purpose : Constructs a BuildGUI_WireDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +BuildGUI_WireDlg::BuildGUI_WireDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, SALOME_Selection* Sel, bool modal, WFlags fl) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_BUILD_WIRE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "BuildGUI_WireDlg" ); + resize( 303, 185 ); + setCaption( tr( "GEOM_WIRE_TITLE" ) ); + setSizeGripEnabled( TRUE ); + BuildGUI_WireDlgLayout = new QGridLayout( this ); + BuildGUI_WireDlgLayout->setSpacing( 6 ); + BuildGUI_WireDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_WIRE" ) ); + 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 ); + BuildGUI_WireDlgLayout->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 ); + BuildGUI_WireDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_WIRE_CONNECT" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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_OBJECTS" ) ); + 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 ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + BuildGUI_WireDlgLayout->addWidget( GroupC1, 1, 0 ); + myBuildGUI = theBuildGUI; + Init(Sel) ; /* Initialisations */ +} + +//================================================================================= +// function : ~BuildGUI_WireDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BuildGUI_WireDlg::~BuildGUI_WireDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BuildGUI_WireDlg::Init( SALOME_Selection* Sel ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + this->myOkListShapes = false ; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + 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); + + /* 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( 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 ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BuildGUI_WireDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void BuildGUI_WireDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkListShapes) { + myBuildGUI->MakeWireAndDisplay( myListShapes ) ; + } + break ; + } + } + // accept(); + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BuildGUI_WireDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void BuildGUI_WireDlg::ClickOnCancel() +{ + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BuildGUI_WireDlg::SelectionIntoArgument() +{ + /* All this for first constructor */ + // if(myEditCurrentArgument == LineEditC1A1 ) + + myEditCurrentArgument->setText("") ; + myOkListShapes = false; + QString aString = ""; /* Future name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if(nbSel < 1) + return ; + + myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes) ; + myEditCurrentArgument->setText(aString) ; + myOkListShapes = true ; + /* no simulation */ + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BuildGUI_WireDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BuildGUI_WireDlg::LineEditReturnPressed() +{ + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void BuildGUI_WireDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BuildGUI_WireDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BuildGUI_WireDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void BuildGUI_WireDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + diff --git a/src/BuildGUI/BuildGUI_WireDlg.h b/src/BuildGUI/BuildGUI_WireDlg.h new file mode 100644 index 000000000..2f1369f24 --- /dev/null +++ b/src/BuildGUI/BuildGUI_WireDlg.h @@ -0,0 +1,104 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI_WireDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_WIRE_H +#define DIALOGBOX_WIRE_H + +#include "BuildGUI.h" + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; + + +//================================================================================= +// class : BuildGUI_WireDlg +// purpose : +//================================================================================= +class BuildGUI_WireDlg : public QDialog +{ + Q_OBJECT + +public: + BuildGUI_WireDlg( QWidget* parent = 0, const char* name = 0, BuildGUI* theBuildGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~BuildGUI_WireDlg(); + +private: + BuildGUI* myBuildGUI; + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + GEOM::GEOM_Gen::ListOfIOR myListShapes ; + bool myOkListShapes ; /* to check when arguments is defined */ + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void LineEditReturnPressed() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* BuildGUI_WireDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_WIRE_H diff --git a/src/BuildGUI/Makefile.in b/src/BuildGUI/Makefile.in new file mode 100644 index 000000000..13a346ed2 --- /dev/null +++ b/src/BuildGUI/Makefile.in @@ -0,0 +1,79 @@ +# GEOM BUILDGUI : +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Damien COQUERET (OCC) +# Module : GEOM +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= BuildGUI.h + +# Libraries targets +LIB = libBuildGUI.la + +LIB_SRC = BuildGUI.cxx \ + BuildGUI_SubShapeDlg.cxx \ + BuildGUI_EdgeDlg.cxx \ + BuildGUI_WireDlg.cxx \ + BuildGUI_FaceDlg.cxx \ + BuildGUI_ShellDlg.cxx \ + BuildGUI_SolidDlg.cxx \ + BuildGUI_CompoundDlg.cxx + +LIB_MOC = \ + BuildGUI.h \ + BuildGUI_SubShapeDlg.h \ + BuildGUI_EdgeDlg.h \ + BuildGUI_WireDlg.h \ + BuildGUI_FaceDlg.h \ + BuildGUI_ShellDlg.h \ + BuildGUI_SolidDlg.h \ + BuildGUI_CompoundDlg.h + +LIB_CLIENT_IDL = SALOME_Exception.idl \ + GEOM_Gen.idl \ + GEOM_Shape.idl \ + SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +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 -lDlgRef -lGEOMBase $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/DlgRef/DlgRef_1Sel1Spin.cxx b/src/DlgRef/DlgRef_1Sel1Spin.cxx new file mode 100644 index 000000000..86be0f2dd --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel1Spin.cxx @@ -0,0 +1,54 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_1Sel1Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_1Sel1Spin.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_1Sel1Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_1Sel1Spin::DlgRef_1Sel1Spin(QWidget* parent, const char* name, WFlags fl) + :DlgRef_1Sel1Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout2->addWidget(SpinBox_DX, 0, 1); +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1Sel1Spin::~DlgRef_1Sel1Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_1Sel1Spin.h b/src/DlgRef/DlgRef_1Sel1Spin.h new file mode 100644 index 000000000..64c560b7b --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel1Spin.h @@ -0,0 +1,47 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_1Sel1Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_1SEL1SPIN_H +#define DLGREF_1SEL1SPIN_H + +#include "DlgRef_1Sel1Spin_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_1Sel1Spin : public DlgRef_1Sel1Spin_QTD +{ + Q_OBJECT + +public: + DlgRef_1Sel1Spin( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_1Sel1Spin(); + + DlgRef_SpinBox* SpinBox_DX; + +}; + +#endif // DLGREF_1SEL1SPIN_H diff --git a/src/DlgRef/DlgRef_1Sel1Spin_QTD.cxx b/src/DlgRef/DlgRef_1Sel1Spin_QTD.cxx new file mode 100644 index 000000000..34846e0e9 --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel1Spin_QTD.cxx @@ -0,0 +1,89 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_1Sel1Spin_QTD.ui' +** +** Created: mar sep 23 16:05:08 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_1Sel1Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_1Sel1Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_1Sel1Spin_QTD::DlgRef_1Sel1Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_1Sel1Spin_QTD" ); + resize( 129, 87 ); + setCaption( trUtf8( "DlgRef_1Sel1Spin_QTD" ) ); + DlgRef_1Sel1Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_1Sel1Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout2->addWidget( TextLabel2, 0, 0 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox1, 0, 1 ); + + Layout1->addMultiCellLayout( Layout2, 1, 1, 0, 2 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 2, 2 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_1Sel1Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1Sel1Spin_QTD::~DlgRef_1Sel1Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_1Sel1Spin_QTD.h b/src/DlgRef/DlgRef_1Sel1Spin_QTD.h new file mode 100644 index 000000000..dba7a6e5c --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel1Spin_QTD.h @@ -0,0 +1,46 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_1Sel1Spin_QTD.ui' +** +** Created: mar sep 23 16:05:08 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_1SEL1SPIN_QTD_H +#define DLGREF_1SEL1SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QSpinBox; + +class DlgRef_1Sel1Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_1Sel1Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_1Sel1Spin_QTD(); + + QGroupBox* GroupBox1; + QPushButton* PushButton1; + QLabel* TextLabel1; + QLineEdit* LineEdit1; + QLabel* TextLabel2; + QSpinBox* SpinBox1; + + +protected: + QGridLayout* DlgRef_1Sel1Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; + QGridLayout* Layout2; +}; + +#endif // DLGREF_1SEL1SPIN_QTD_H diff --git a/src/DlgRef/DlgRef_1Sel2Spin.cxx b/src/DlgRef/DlgRef_1Sel2Spin.cxx new file mode 100644 index 000000000..f8471b369 --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel2Spin.cxx @@ -0,0 +1,60 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_1Sel2Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_1Sel2Spin.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_1Sel2Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_1Sel2Spin::DlgRef_1Sel2Spin(QWidget* parent, const char* name, WFlags fl) + :DlgRef_1Sel2Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout2->addWidget(SpinBox_DX, 0, 1); + + SpinBox_DY = new DlgRef_SpinBox( GroupBox1, "SpinBox_DY"); + Layout2->addWidget(SpinBox_DY, 1, 1); + +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1Sel2Spin::~DlgRef_1Sel2Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_1Sel2Spin.h b/src/DlgRef/DlgRef_1Sel2Spin.h new file mode 100644 index 000000000..33a11f4f5 --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel2Spin.h @@ -0,0 +1,48 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_1Sel2Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_1SEL2SPIN_H +#define DLGREF_1SEL2SPIN_H + +#include "DlgRef_1Sel2Spin_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_1Sel2Spin : public DlgRef_1Sel2Spin_QTD +{ + Q_OBJECT + +public: + DlgRef_1Sel2Spin(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~DlgRef_1Sel2Spin(); + + DlgRef_SpinBox* SpinBox_DX; + DlgRef_SpinBox* SpinBox_DY; + +}; + +#endif // DLGREF_1SEL2SPIN_H diff --git a/src/DlgRef/DlgRef_1Sel2Spin_QTD.cxx b/src/DlgRef/DlgRef_1Sel2Spin_QTD.cxx new file mode 100644 index 000000000..9e0e82546 --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel2Spin_QTD.cxx @@ -0,0 +1,100 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_1Sel2Spin_QTD.ui' +** +** Created: jeu oct 2 11:08:05 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_1Sel2Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_1Sel2Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_1Sel2Spin_QTD::DlgRef_1Sel2Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_1Sel2Spin_QTD" ); + resize( 129, 115 ); + setCaption( trUtf8( "DlgRef_1Sel2Spin_QTD" ) ); + DlgRef_1Sel2Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_1Sel2Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout2->addWidget( TextLabel3, 1, 0 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox1, 0, 1 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout2->addWidget( TextLabel2, 0, 0 ); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox2, 1, 1 ); + + Layout1->addMultiCellLayout( Layout2, 1, 1, 0, 2 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + QSpacerItem* spacer = new QSpacerItem( 0, 30, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 2, 2 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_1Sel2Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1Sel2Spin_QTD::~DlgRef_1Sel2Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_1Sel2Spin_QTD.h b/src/DlgRef/DlgRef_1Sel2Spin_QTD.h new file mode 100644 index 000000000..82cae8783 --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel2Spin_QTD.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_1Sel2Spin_QTD.ui' +** +** Created: jeu oct 2 11:08:05 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_1SEL2SPIN_QTD_H +#define DLGREF_1SEL2SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QSpinBox; + +class DlgRef_1Sel2Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_1Sel2Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_1Sel2Spin_QTD(); + + QGroupBox* GroupBox1; + QLabel* TextLabel3; + QSpinBox* SpinBox1; + QLabel* TextLabel2; + QSpinBox* SpinBox2; + QLineEdit* LineEdit1; + QPushButton* PushButton1; + QLabel* TextLabel1; + + +protected: + QGridLayout* DlgRef_1Sel2Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; + QGridLayout* Layout2; +}; + +#endif // DLGREF_1SEL2SPIN_QTD_H diff --git a/src/DlgRef/DlgRef_1Sel3Spin.cxx b/src/DlgRef/DlgRef_1Sel3Spin.cxx new file mode 100644 index 000000000..d5170c7da --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel3Spin.cxx @@ -0,0 +1,63 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_1Sel3Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_1Sel3Spin.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_1Sel3Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_1Sel3Spin::DlgRef_1Sel3Spin(QWidget* parent, const char* name, WFlags fl) + :DlgRef_1Sel3Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + SpinBox3->close(TRUE); + + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout2->addWidget(SpinBox_DX, 0, 1); + + SpinBox_DY = new DlgRef_SpinBox( GroupBox1, "SpinBox_DY"); + Layout2->addWidget(SpinBox_DY, 0, 3); + + SpinBox_DZ = new DlgRef_SpinBox( GroupBox1, "SpinBox_DZ"); + Layout2->addWidget(SpinBox_DZ, 0, 5); +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1Sel3Spin::~DlgRef_1Sel3Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_1Sel3Spin.h b/src/DlgRef/DlgRef_1Sel3Spin.h new file mode 100644 index 000000000..1cdad86b6 --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel3Spin.h @@ -0,0 +1,49 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_1Sel3Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_1SEL3SPIN_H +#define DLGREF_1SEL3SPIN_H + +#include "DlgRef_1Sel3Spin_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_1Sel3Spin : public DlgRef_1Sel3Spin_QTD +{ + Q_OBJECT + +public: + DlgRef_1Sel3Spin(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~DlgRef_1Sel3Spin(); + + DlgRef_SpinBox* SpinBox_DX; + DlgRef_SpinBox* SpinBox_DY; + DlgRef_SpinBox* SpinBox_DZ; + +}; + +#endif // DLGREF_1SEL3SPIN_H diff --git a/src/DlgRef/DlgRef_1Sel3Spin_QTD.cxx b/src/DlgRef/DlgRef_1Sel3Spin_QTD.cxx new file mode 100644 index 000000000..3dc087045 --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel3Spin_QTD.cxx @@ -0,0 +1,111 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_1Sel3Spin_QTD.ui' +** +** Created: mer oct 1 16:53:03 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_1Sel3Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_1Sel3Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_1Sel3Spin_QTD::DlgRef_1Sel3Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_1Sel3Spin_QTD" ); + resize( 232, 87 ); + setCaption( trUtf8( "DlgRef_1Sel3Spin_QTD" ) ); + DlgRef_1Sel3Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_1Sel3Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 207, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 2, 2 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + TextLabel4->setText( trUtf8( "TL4" ) ); + + Layout2->addWidget( TextLabel4, 0, 5 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout2->addWidget( TextLabel2, 0, 1 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout2->addWidget( TextLabel3, 0, 3 ); + + SpinBox3 = new QSpinBox( GroupBox1, "SpinBox3" ); + SpinBox3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox3->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox3, 0, 6 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox1, 0, 2 ); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox2, 0, 4 ); + + Layout1->addMultiCellLayout( Layout2, 1, 1, 0, 2 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_1Sel3Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1Sel3Spin_QTD::~DlgRef_1Sel3Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_1Sel3Spin_QTD.h b/src/DlgRef/DlgRef_1Sel3Spin_QTD.h new file mode 100644 index 000000000..90275651f --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel3Spin_QTD.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_1Sel3Spin_QTD.ui' +** +** Created: mer oct 1 16:53:02 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_1SEL3SPIN_QTD_H +#define DLGREF_1SEL3SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QSpinBox; + +class DlgRef_1Sel3Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_1Sel3Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_1Sel3Spin_QTD(); + + QGroupBox* GroupBox1; + QPushButton* PushButton1; + QLabel* TextLabel1; + QLineEdit* LineEdit1; + QLabel* TextLabel4; + QLabel* TextLabel2; + QLabel* TextLabel3; + QSpinBox* SpinBox3; + QSpinBox* SpinBox1; + QSpinBox* SpinBox2; + + +protected: + QGridLayout* DlgRef_1Sel3Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; + QGridLayout* Layout2; +}; + +#endif // DLGREF_1SEL3SPIN_QTD_H diff --git a/src/DlgRef/DlgRef_1Sel4Spin.cxx b/src/DlgRef/DlgRef_1Sel4Spin.cxx new file mode 100644 index 000000000..107e5a426 --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel4Spin.cxx @@ -0,0 +1,67 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_1Sel4Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_1Sel4Spin.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_1Sel4Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_1Sel4Spin::DlgRef_1Sel4Spin(QWidget* parent, const char* name, WFlags fl) + :DlgRef_1Sel4Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + SpinBox3->close(TRUE); + SpinBox4->close(TRUE); + + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout3->addWidget(SpinBox_DX, 0, 2); + + SpinBox_DY = new DlgRef_SpinBox( GroupBox1, "SpinBox_DY"); + Layout3->addWidget(SpinBox_DY, 0, 4); + + SpinBox_DZ = new DlgRef_SpinBox( GroupBox1, "SpinBox_DZ"); + Layout3->addWidget(SpinBox_DZ, 0, 6); + + SpinBox_S = new DlgRef_SpinBox( GroupBox1, "SpinBox_S"); + Layout4->addWidget(SpinBox_S, 0, 1); +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1Sel4Spin::~DlgRef_1Sel4Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_1Sel4Spin.h b/src/DlgRef/DlgRef_1Sel4Spin.h new file mode 100644 index 000000000..db4d2560d --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel4Spin.h @@ -0,0 +1,51 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_1Sel4Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_1SEL4SPIN_H +#define DLGREF_1SEL4SPIN_H + +#include "DlgRef_1Sel4Spin_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_1Sel4Spin : public DlgRef_1Sel4Spin_QTD +{ + Q_OBJECT + +public: + DlgRef_1Sel4Spin( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_1Sel4Spin(); + + DlgRef_SpinBox* SpinBox_DX; + DlgRef_SpinBox* SpinBox_DY; + DlgRef_SpinBox* SpinBox_DZ; + + DlgRef_SpinBox* SpinBox_S; + +}; + +#endif // DLGREF_1SEL4SPIN_H diff --git a/src/DlgRef/DlgRef_1Sel4Spin_QTD.cxx b/src/DlgRef/DlgRef_1Sel4Spin_QTD.cxx new file mode 100644 index 000000000..319249c03 --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel4Spin_QTD.cxx @@ -0,0 +1,132 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_1Sel4Spin_QTD.ui' +** +** Created: mar sep 23 16:05:09 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_1Sel4Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_1Sel4Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_1Sel4Spin_QTD::DlgRef_1Sel4Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_1Sel4Spin_QTD" ); + resize( 284, 119 ); + setCaption( trUtf8( "DlgRef_1Sel4Spin_QTD" ) ); + DlgRef_1Sel4Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_1Sel4Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3"); + + TextLabel5 = new QLabel( GroupBox1, "TextLabel5" ); + TextLabel5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel5->sizePolicy().hasHeightForWidth() ) ); + TextLabel5->setText( trUtf8( "TL5" ) ); + + Layout3->addWidget( TextLabel5, 0, 5 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout3->addWidget( TextLabel3, 0, 1 ); + + TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + TextLabel4->setText( trUtf8( "TL4" ) ); + + Layout3->addWidget( TextLabel4, 0, 3 ); + + SpinBox3 = new QSpinBox( GroupBox1, "SpinBox3" ); + SpinBox3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox3->sizePolicy().hasHeightForWidth() ) ); + + Layout3->addWidget( SpinBox3, 0, 6 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout3->addWidget( SpinBox1, 0, 2 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout3->addWidget( TextLabel2, 0, 0 ); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout3->addWidget( SpinBox2, 0, 4 ); + + Layout1->addLayout( Layout3, 1, 0 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 0 ); + + Layout4 = new QGridLayout( 0, 1, 1, 0, 6, "Layout4"); + + TextLabel6 = new QLabel( GroupBox1, "TextLabel6" ); + TextLabel6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel6->sizePolicy().hasHeightForWidth() ) ); + TextLabel6->setText( trUtf8( "TL6" ) ); + + Layout4->addWidget( TextLabel6, 0, 0 ); + + SpinBox4 = new QSpinBox( GroupBox1, "SpinBox4" ); + + Layout4->addWidget( SpinBox4, 0, 1 ); + + Layout1->addLayout( Layout4, 2, 0 ); + + Layout2 = new QHBoxLayout( 0, 0, 6, "Layout2"); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + Layout2->addWidget( TextLabel1 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + Layout2->addWidget( PushButton1 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + Layout2->addWidget( LineEdit1 ); + + Layout1->addLayout( Layout2, 0, 0 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_1Sel4Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1Sel4Spin_QTD::~DlgRef_1Sel4Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_1Sel4Spin_QTD.h b/src/DlgRef/DlgRef_1Sel4Spin_QTD.h new file mode 100644 index 000000000..db64ea6ae --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel4Spin_QTD.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_1Sel4Spin_QTD.ui' +** +** Created: mar sep 23 16:05:09 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_1SEL4SPIN_QTD_H +#define DLGREF_1SEL4SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QSpinBox; + +class DlgRef_1Sel4Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_1Sel4Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_1Sel4Spin_QTD(); + + QGroupBox* GroupBox1; + QLabel* TextLabel5; + QLabel* TextLabel3; + QLabel* TextLabel4; + QSpinBox* SpinBox3; + QSpinBox* SpinBox1; + QLabel* TextLabel2; + QSpinBox* SpinBox2; + QLabel* TextLabel6; + QSpinBox* SpinBox4; + QLabel* TextLabel1; + QPushButton* PushButton1; + QLineEdit* LineEdit1; + + +protected: + QGridLayout* DlgRef_1Sel4Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; + QGridLayout* Layout3; + QGridLayout* Layout4; + QHBoxLayout* Layout2; +}; + +#endif // DLGREF_1SEL4SPIN_QTD_H diff --git a/src/DlgRef/DlgRef_1Sel5Spin.cxx b/src/DlgRef/DlgRef_1Sel5Spin.cxx new file mode 100644 index 000000000..4d276d01f --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel5Spin.cxx @@ -0,0 +1,71 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_1Sel5Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_1Sel5Spin.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_1Sel5Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_1Sel5Spin::DlgRef_1Sel5Spin(QWidget* parent, const char* name, WFlags fl) + :DlgRef_1Sel5Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + SpinBox3->close(TRUE); + SpinBox4->close(TRUE); + SpinBox5->close(TRUE); + + SpinBox_1 = new DlgRef_SpinBox(GroupBox1, "SpinBox_1"); + Layout2->addWidget(SpinBox_1, 0, 1); + + SpinBox_2 = new DlgRef_SpinBox(GroupBox1, "SpinBox_2"); + Layout2->addWidget(SpinBox_2, 0, 3); + + SpinBox_3 = new DlgRef_SpinBox(GroupBox1, "SpinBox_3"); + Layout2->addWidget(SpinBox_3, 0, 5); + + SpinBox_4 = new DlgRef_SpinBox(GroupBox1, "SpinBox_4"); + Layout2->addWidget(SpinBox_4, 1, 1); + + SpinBox_5 = new DlgRef_SpinBox(GroupBox1, "SpinBox_5"); + Layout2->addWidget(SpinBox_5, 1, 3); +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1Sel5Spin::~DlgRef_1Sel5Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_1Sel5Spin.h b/src/DlgRef/DlgRef_1Sel5Spin.h new file mode 100644 index 000000000..cc145e319 --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel5Spin.h @@ -0,0 +1,51 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_1Sel5Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_1SEL5SPIN_H +#define DLGREF_1SEL5SPIN_H + +#include "DlgRef_1Sel5Spin_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_1Sel5Spin : public DlgRef_1Sel5Spin_QTD +{ + Q_OBJECT + +public: + DlgRef_1Sel5Spin( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_1Sel5Spin(); + + DlgRef_SpinBox* SpinBox_1; + DlgRef_SpinBox* SpinBox_2; + DlgRef_SpinBox* SpinBox_3; + DlgRef_SpinBox* SpinBox_4; + DlgRef_SpinBox* SpinBox_5; + +}; + +#endif // DLGREF_1SEL5SPIN_H diff --git a/src/DlgRef/DlgRef_1Sel5Spin_QTD.cxx b/src/DlgRef/DlgRef_1Sel5Spin_QTD.cxx new file mode 100644 index 000000000..822868fb1 --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel5Spin_QTD.cxx @@ -0,0 +1,133 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_1Sel5Spin_QTD.ui' +** +** Created: jeu oct 2 10:50:22 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_1Sel5Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_1Sel5Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_1Sel5Spin_QTD::DlgRef_1Sel5Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_1Sel5Spin_QTD" ); + resize( 232, 115 ); + setCaption( trUtf8( "DlgRef_1Sel5Spin_QTD" ) ); + DlgRef_1Sel5Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_1Sel5Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + TextLabel6 = new QLabel( GroupBox1, "TextLabel6" ); + TextLabel6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel6->sizePolicy().hasHeightForWidth() ) ); + TextLabel6->setText( trUtf8( "TL6" ) ); + + Layout2->addWidget( TextLabel6, 1, 2 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox1, 0, 1 ); + + SpinBox4 = new QSpinBox( GroupBox1, "SpinBox4" ); + SpinBox4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox4->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox4, 1, 1 ); + + TextLabel5 = new QLabel( GroupBox1, "TextLabel5" ); + TextLabel5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel5->sizePolicy().hasHeightForWidth() ) ); + TextLabel5->setText( trUtf8( "TL5" ) ); + + Layout2->addWidget( TextLabel5, 1, 0 ); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox2, 0, 3 ); + + SpinBox5 = new QSpinBox( GroupBox1, "SpinBox5" ); + SpinBox5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox5->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox5, 1, 3 ); + + SpinBox3 = new QSpinBox( GroupBox1, "SpinBox3" ); + SpinBox3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox3->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox3, 0, 5 ); + + TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + TextLabel4->setText( trUtf8( "TL4" ) ); + + Layout2->addWidget( TextLabel4, 0, 4 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout2->addWidget( TextLabel3, 0, 2 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout2->addWidget( TextLabel2, 0, 0 ); + + Layout1->addMultiCellLayout( Layout2, 1, 1, 0, 2 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 2, 2 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_1Sel5Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1Sel5Spin_QTD::~DlgRef_1Sel5Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_1Sel5Spin_QTD.h b/src/DlgRef/DlgRef_1Sel5Spin_QTD.h new file mode 100644 index 000000000..484275fa6 --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel5Spin_QTD.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_1Sel5Spin_QTD.ui' +** +** Created: jeu oct 2 10:50:22 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_1SEL5SPIN_QTD_H +#define DLGREF_1SEL5SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QSpinBox; + +class DlgRef_1Sel5Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_1Sel5Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_1Sel5Spin_QTD(); + + QGroupBox* GroupBox1; + QLabel* TextLabel1; + QLabel* TextLabel6; + QSpinBox* SpinBox1; + QSpinBox* SpinBox4; + QLabel* TextLabel5; + QSpinBox* SpinBox2; + QSpinBox* SpinBox5; + QSpinBox* SpinBox3; + QLabel* TextLabel4; + QLabel* TextLabel3; + QLabel* TextLabel2; + QLineEdit* LineEdit1; + QPushButton* PushButton1; + + +protected: + QGridLayout* DlgRef_1Sel5Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; + QGridLayout* Layout2; +}; + +#endif // DLGREF_1SEL5SPIN_QTD_H diff --git a/src/DlgRef/DlgRef_1Sel_QTD.cxx b/src/DlgRef/DlgRef_1Sel_QTD.cxx new file mode 100644 index 000000000..90a136249 --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel_QTD.cxx @@ -0,0 +1,74 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_1Sel_QTD.ui' +** +** Created: lun sep 22 17:38:06 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_1Sel_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_1Sel_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_1Sel_QTD::DlgRef_1Sel_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_1Sel_QTD" ); + resize( 129, 57 ); + setCaption( trUtf8( "DlgRef_1Sel_QTD" ) ); + DlgRef_1Sel_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_1Sel_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 0, GroupBox1->sizePolicy().hasHeightForWidth() ) ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 1, 2 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_1Sel_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1Sel_QTD::~DlgRef_1Sel_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_1Sel_QTD.h b/src/DlgRef/DlgRef_1Sel_QTD.h new file mode 100644 index 000000000..133d043cf --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel_QTD.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_1Sel_QTD.ui' +** +** Created: lun sep 22 17:38:05 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_1SEL_QTD_H +#define DLGREF_1SEL_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; + +class DlgRef_1Sel_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_1Sel_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_1Sel_QTD(); + + QGroupBox* GroupBox1; + QPushButton* PushButton1; + QLineEdit* LineEdit1; + QLabel* TextLabel1; + + +protected: + QGridLayout* DlgRef_1Sel_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; +}; + +#endif // DLGREF_1SEL_QTD_H diff --git a/src/DlgRef/DlgRef_1Spin.cxx b/src/DlgRef/DlgRef_1Spin.cxx new file mode 100644 index 000000000..20778cd4b --- /dev/null +++ b/src/DlgRef/DlgRef_1Spin.cxx @@ -0,0 +1,56 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_1Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_1Spin.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_1Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_1Spin::DlgRef_1Spin(QWidget* parent, const char* name, WFlags fl) + :DlgRef_1Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout1->addWidget(SpinBox_DX, 0, 1); + +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1Spin::~DlgRef_1Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_1Spin.h b/src/DlgRef/DlgRef_1Spin.h new file mode 100644 index 000000000..470d62d83 --- /dev/null +++ b/src/DlgRef/DlgRef_1Spin.h @@ -0,0 +1,47 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_1Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_1SPIN_H +#define DLGREF_1SPIN_H + +#include "DlgRef_1Spin_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_1Spin : public DlgRef_1Spin_QTD +{ + Q_OBJECT + +public: + DlgRef_1Spin(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~DlgRef_1Spin(); + + DlgRef_SpinBox* SpinBox_DX; + +}; + +#endif // DLGREF_1SPIN_H diff --git a/src/DlgRef/DlgRef_1Spin_QTD.cxx b/src/DlgRef/DlgRef_1Spin_QTD.cxx new file mode 100644 index 000000000..aa54d9ad8 --- /dev/null +++ b/src/DlgRef/DlgRef_1Spin_QTD.cxx @@ -0,0 +1,68 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_1Spin_QTD.ui' +** +** Created: jeu sep 25 12:22:29 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_1Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_1Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_1Spin_QTD::DlgRef_1Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_1Spin_QTD" ); + resize( 124, 55 ); + setCaption( trUtf8( "DlgRef_1Spin_QTD" ) ); + DlgRef_1Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_1Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 1 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox1, 0, 1 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_1Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1Spin_QTD::~DlgRef_1Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_1Spin_QTD.h b/src/DlgRef/DlgRef_1Spin_QTD.h new file mode 100644 index 000000000..d19f64043 --- /dev/null +++ b/src/DlgRef/DlgRef_1Spin_QTD.h @@ -0,0 +1,40 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_1Spin_QTD.ui' +** +** Created: jeu sep 25 12:22:29 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_1SPIN_QTD_H +#define DLGREF_1SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QSpinBox; + +class DlgRef_1Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_1Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_1Spin_QTD(); + + QGroupBox* GroupBox1; + QSpinBox* SpinBox1; + QLabel* TextLabel1; + + +protected: + QGridLayout* DlgRef_1Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; +}; + +#endif // DLGREF_1SPIN_QTD_H diff --git a/src/DlgRef/DlgRef_2Sel1Spin.cxx b/src/DlgRef/DlgRef_2Sel1Spin.cxx new file mode 100644 index 000000000..cb8499e99 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel1Spin.cxx @@ -0,0 +1,54 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_2Sel1Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_2Sel1Spin.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel1Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_2Sel1Spin::DlgRef_2Sel1Spin(QWidget* parent, const char* name, WFlags fl) + :DlgRef_2Sel1Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout2->addWidget(SpinBox_DX, 0, 1); +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel1Spin::~DlgRef_2Sel1Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_2Sel1Spin.h b/src/DlgRef/DlgRef_2Sel1Spin.h new file mode 100644 index 000000000..5bdc29962 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel1Spin.h @@ -0,0 +1,47 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_2Sel1Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_2SEL1SPIN_H +#define DLGREF_2SEL1SPIN_H + +#include "DlgRef_2Sel1Spin_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_2Sel1Spin : public DlgRef_2Sel1Spin_QTD +{ + Q_OBJECT + +public: + DlgRef_2Sel1Spin( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_2Sel1Spin(); + + DlgRef_SpinBox* SpinBox_DX; + +}; + +#endif // DLGREF_2SEL1SPIN_H diff --git a/src/DlgRef/DlgRef_2Sel1Spin1Check.cxx b/src/DlgRef/DlgRef_2Sel1Spin1Check.cxx new file mode 100644 index 000000000..c4d8c0619 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel1Spin1Check.cxx @@ -0,0 +1,54 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_2Sel1Spin1Check.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_2Sel1Spin1Check.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel1Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_2Sel1Spin1Check::DlgRef_2Sel1Spin1Check(QWidget* parent, const char* name, WFlags fl) + :DlgRef_2Sel1Spin1Check_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout2->addWidget(SpinBox_DX, 0, 1); +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel1Spin1Check::~DlgRef_2Sel1Spin1Check() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_2Sel1Spin1Check.h b/src/DlgRef/DlgRef_2Sel1Spin1Check.h new file mode 100644 index 000000000..f26c0bfbe --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel1Spin1Check.h @@ -0,0 +1,47 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_2Sel1Spin1Check.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_2SEL1SPIN1CHECK_H +#define DLGREF_2SEL1SPIN1CHECK_H + +#include "DlgRef_2Sel1Spin1Check_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_2Sel1Spin1Check : public DlgRef_2Sel1Spin1Check_QTD +{ + Q_OBJECT + +public: + DlgRef_2Sel1Spin1Check(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~DlgRef_2Sel1Spin1Check(); + + DlgRef_SpinBox* SpinBox_DX; + +}; + +#endif // DLGREF_2SEL1SPIN1CHECK_H diff --git a/src/DlgRef/DlgRef_2Sel1Spin1Check_QTD.cxx b/src/DlgRef/DlgRef_2Sel1Spin1Check_QTD.cxx new file mode 100644 index 000000000..7fa002f40 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel1Spin1Check_QTD.cxx @@ -0,0 +1,111 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_2Sel1Spin1Check_QTD.ui' +** +** Created: mer oct 1 16:20:02 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_2Sel1Spin1Check_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel1Spin1Check_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_2Sel1Spin1Check_QTD::DlgRef_2Sel1Spin1Check_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_2Sel1Spin1Check_QTD" ); + resize( 129, 117 ); + setCaption( trUtf8( "DlgRef_2Sel1Spin1Check_QTD" ) ); + DlgRef_2Sel1Spin1Check_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_2Sel1Spin1Check_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 2 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox1, 0, 1 ); + + CheckButton1 = new QRadioButton( GroupBox1, "CheckButton1" ); + CheckButton1->setText( trUtf8( "" ) ); + + Layout2->addWidget( CheckButton1, 0, 2 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout2->addWidget( TextLabel3, 0, 0 ); + + Layout1->addMultiCellLayout( Layout2, 2, 2, 0, 2 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_2Sel1Spin1Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel1Spin1Check_QTD::~DlgRef_2Sel1Spin1Check_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_2Sel1Spin1Check_QTD.h b/src/DlgRef/DlgRef_2Sel1Spin1Check_QTD.h new file mode 100644 index 000000000..cbc33b9c0 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel1Spin1Check_QTD.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_2Sel1Spin1Check_QTD.ui' +** +** Created: mer oct 1 16:20:02 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_2SEL1SPIN1CHECK_QTD_H +#define DLGREF_2SEL1SPIN1CHECK_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QSpinBox; + +class DlgRef_2Sel1Spin1Check_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_2Sel1Spin1Check_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_2Sel1Spin1Check_QTD(); + + QGroupBox* GroupBox1; + QLineEdit* LineEdit1; + QLabel* TextLabel1; + QLabel* TextLabel2; + QLineEdit* LineEdit2; + QPushButton* PushButton1; + QPushButton* PushButton2; + QSpinBox* SpinBox1; + QRadioButton* CheckButton1; + QLabel* TextLabel3; + + +protected: + QGridLayout* DlgRef_2Sel1Spin1Check_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; + QGridLayout* Layout2; +}; + +#endif // DLGREF_2SEL1SPIN1CHECK_QTD_H diff --git a/src/DlgRef/DlgRef_2Sel1Spin_QTD.cxx b/src/DlgRef/DlgRef_2Sel1Spin_QTD.cxx new file mode 100644 index 000000000..9c27921ac --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel1Spin_QTD.cxx @@ -0,0 +1,105 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_2Sel1Spin_QTD.ui' +** +** Created: mar sep 23 16:05:09 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_2Sel1Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel1Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_2Sel1Spin_QTD::DlgRef_2Sel1Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_2Sel1Spin_QTD" ); + resize( 129, 117 ); + setCaption( trUtf8( "DlgRef_2Sel1Spin_QTD" ) ); + DlgRef_2Sel1Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_2Sel1Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox1, 0, 1 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout2->addWidget( TextLabel3, 0, 0 ); + + Layout1->addMultiCellLayout( Layout2, 2, 2, 0, 2 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 2 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_2Sel1Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel1Spin_QTD::~DlgRef_2Sel1Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_2Sel1Spin_QTD.h b/src/DlgRef/DlgRef_2Sel1Spin_QTD.h new file mode 100644 index 000000000..8f1f48985 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel1Spin_QTD.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_2Sel1Spin_QTD.ui' +** +** Created: mar sep 23 16:05:09 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_2SEL1SPIN_QTD_H +#define DLGREF_2SEL1SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QSpinBox; + +class DlgRef_2Sel1Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_2Sel1Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_2Sel1Spin_QTD(); + + QGroupBox* GroupBox1; + QLineEdit* LineEdit1; + QPushButton* PushButton2; + QLabel* TextLabel1; + QLineEdit* LineEdit2; + QPushButton* PushButton1; + QLabel* TextLabel2; + QSpinBox* SpinBox1; + QLabel* TextLabel3; + + +protected: + QGridLayout* DlgRef_2Sel1Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; + QGridLayout* Layout2; +}; + +#endif // DLGREF_2SEL1SPIN_QTD_H diff --git a/src/DlgRef/DlgRef_2Sel2Spin.cxx b/src/DlgRef/DlgRef_2Sel2Spin.cxx new file mode 100644 index 000000000..660206876 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel2Spin.cxx @@ -0,0 +1,57 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_2Sel2Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_2Sel2Spin.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel1Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_2Sel2Spin::DlgRef_2Sel2Spin(QWidget* parent, const char* name, WFlags fl) + :DlgRef_2Sel2Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout2->addWidget(SpinBox_DX, 0, 1); + SpinBox_DY = new DlgRef_SpinBox(GroupBox1, "SpinBox_DY"); + Layout2->addWidget(SpinBox_DY, 1, 1); +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel2Spin::~DlgRef_2Sel2Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_2Sel2Spin.h b/src/DlgRef/DlgRef_2Sel2Spin.h new file mode 100644 index 000000000..4300521ef --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel2Spin.h @@ -0,0 +1,48 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_2Sel2Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_2SEL2SPIN_H +#define DLGREF_2SEL2SPIN_H + +#include "DlgRef_2Sel2Spin_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_2Sel2Spin : public DlgRef_2Sel2Spin_QTD +{ + Q_OBJECT + +public: + DlgRef_2Sel2Spin(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~DlgRef_2Sel2Spin(); + + DlgRef_SpinBox* SpinBox_DX; + DlgRef_SpinBox* SpinBox_DY; + +}; + +#endif // DLGREF_2SEL2SPIN_H diff --git a/src/DlgRef/DlgRef_2Sel2Spin_QTD.cxx b/src/DlgRef/DlgRef_2Sel2Spin_QTD.cxx new file mode 100644 index 000000000..045cf651b --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel2Spin_QTD.cxx @@ -0,0 +1,116 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_2Sel2Spin_QTD.ui' +** +** Created: jeu sep 25 12:10:29 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_2Sel2Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel2Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_2Sel2Spin_QTD::DlgRef_2Sel2Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_2Sel2Spin_QTD" ); + resize( 129, 145 ); + setCaption( trUtf8( "DlgRef_2Sel2Spin_QTD" ) ); + DlgRef_2Sel2Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_2Sel2Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox2, 1, 1 ); + + TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + TextLabel4->setText( trUtf8( "TL4" ) ); + + Layout2->addWidget( TextLabel4, 1, 0 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout2->addWidget( TextLabel3, 0, 0 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox1, 0, 1 ); + + Layout1->addMultiCellLayout( Layout2, 2, 2, 0, 2 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + QSpacerItem* spacer = new QSpacerItem( 0, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 2 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_2Sel2Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel2Spin_QTD::~DlgRef_2Sel2Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_2Sel2Spin_QTD.h b/src/DlgRef/DlgRef_2Sel2Spin_QTD.h new file mode 100644 index 000000000..dd6bd6c83 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel2Spin_QTD.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_2Sel2Spin_QTD.ui' +** +** Created: jeu sep 25 12:10:29 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_2SEL2SPIN_QTD_H +#define DLGREF_2SEL2SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QSpinBox; + +class DlgRef_2Sel2Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_2Sel2Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_2Sel2Spin_QTD(); + + QGroupBox* GroupBox1; + QLineEdit* LineEdit1; + QSpinBox* SpinBox2; + QLabel* TextLabel4; + QLabel* TextLabel3; + QSpinBox* SpinBox1; + QPushButton* PushButton2; + QLabel* TextLabel2; + QLabel* TextLabel1; + QPushButton* PushButton1; + QLineEdit* LineEdit2; + + +protected: + QGridLayout* DlgRef_2Sel2Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; + QGridLayout* Layout2; +}; + +#endif // DLGREF_2SEL2SPIN_QTD_H diff --git a/src/DlgRef/DlgRef_2Sel3Spin.cxx b/src/DlgRef/DlgRef_2Sel3Spin.cxx new file mode 100644 index 000000000..a0a9999f8 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel3Spin.cxx @@ -0,0 +1,60 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_2Sel3Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_2Sel3Spin.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel1Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_2Sel3Spin::DlgRef_2Sel3Spin(QWidget* parent, const char* name, WFlags fl) + :DlgRef_2Sel3Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + SpinBox3->close(TRUE); + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout2->addWidget(SpinBox_DX, 0, 1); + SpinBox_DY = new DlgRef_SpinBox(GroupBox1, "SpinBox_DY"); + Layout2->addWidget(SpinBox_DY, 1, 1); + SpinBox_DZ = new DlgRef_SpinBox(GroupBox1, "SpinBox_DZ"); + Layout2->addWidget(SpinBox_DZ, 2, 1); +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel3Spin::~DlgRef_2Sel3Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_2Sel3Spin.h b/src/DlgRef/DlgRef_2Sel3Spin.h new file mode 100644 index 000000000..367e8b55d --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel3Spin.h @@ -0,0 +1,49 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_2Sel3Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_2SEL3SPIN_H +#define DLGREF_2SEL3SPIN_H + +#include "DlgRef_2Sel3Spin_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_2Sel3Spin : public DlgRef_2Sel3Spin_QTD +{ + Q_OBJECT + +public: + DlgRef_2Sel3Spin(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~DlgRef_2Sel3Spin(); + + DlgRef_SpinBox* SpinBox_DX; + DlgRef_SpinBox* SpinBox_DY; + DlgRef_SpinBox* SpinBox_DZ; + +}; + +#endif // DLGREF_2SEL3SPIN_H diff --git a/src/DlgRef/DlgRef_2Sel3Spin_QTD.cxx b/src/DlgRef/DlgRef_2Sel3Spin_QTD.cxx new file mode 100644 index 000000000..be815e3ec --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel3Spin_QTD.cxx @@ -0,0 +1,127 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_2Sel3Spin_QTD.ui' +** +** Created: jeu sep 25 16:18:43 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_2Sel3Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel3Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_2Sel3Spin_QTD::DlgRef_2Sel3Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_2Sel3Spin_QTD" ); + resize( 129, 173 ); + setCaption( trUtf8( "DlgRef_2Sel3Spin_QTD" ) ); + DlgRef_2Sel3Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_2Sel3Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout2->addWidget( TextLabel3, 0, 0 ); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox2, 1, 1 ); + + TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + TextLabel4->setText( trUtf8( "TL4" ) ); + + Layout2->addWidget( TextLabel4, 1, 0 ); + + TextLabel5 = new QLabel( GroupBox1, "TextLabel5" ); + TextLabel5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel5->sizePolicy().hasHeightForWidth() ) ); + TextLabel5->setText( trUtf8( "TL4" ) ); + + Layout2->addWidget( TextLabel5, 2, 0 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox1, 0, 1 ); + + SpinBox3 = new QSpinBox( GroupBox1, "SpinBox3" ); + SpinBox3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox3->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox3, 2, 1 ); + + Layout1->addMultiCellLayout( Layout2, 2, 2, 0, 2 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 2 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_2Sel3Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel3Spin_QTD::~DlgRef_2Sel3Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_2Sel3Spin_QTD.h b/src/DlgRef/DlgRef_2Sel3Spin_QTD.h new file mode 100644 index 000000000..9dbbd5f5d --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel3Spin_QTD.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_2Sel3Spin_QTD.ui' +** +** Created: jeu sep 25 16:18:43 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_2SEL3SPIN_QTD_H +#define DLGREF_2SEL3SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QSpinBox; + +class DlgRef_2Sel3Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_2Sel3Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_2Sel3Spin_QTD(); + + QGroupBox* GroupBox1; + QLineEdit* LineEdit1; + QLabel* TextLabel1; + QLabel* TextLabel2; + QLabel* TextLabel3; + QSpinBox* SpinBox2; + QLabel* TextLabel4; + QLabel* TextLabel5; + QSpinBox* SpinBox1; + QSpinBox* SpinBox3; + QPushButton* PushButton1; + QLineEdit* LineEdit2; + QPushButton* PushButton2; + + +protected: + QGridLayout* DlgRef_2Sel3Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; + QGridLayout* Layout2; +}; + +#endif // DLGREF_2SEL3SPIN_QTD_H diff --git a/src/DlgRef/DlgRef_2Sel_QTD.cxx b/src/DlgRef/DlgRef_2Sel_QTD.cxx new file mode 100644 index 000000000..8dc9f08e4 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel_QTD.cxx @@ -0,0 +1,90 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_2Sel_QTD.ui' +** +** Created: mar sep 23 16:05:09 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_2Sel_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_2Sel_QTD::DlgRef_2Sel_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_2Sel_QTD" ); + resize( 129, 87 ); + setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)7, 0, 0, sizePolicy().hasHeightForWidth() ) ); + setCaption( trUtf8( "DlgRef_2Sel_QTD" ) ); + DlgRef_2Sel_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_2Sel_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 2, 2 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_2Sel_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel_QTD::~DlgRef_2Sel_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_2Sel_QTD.h b/src/DlgRef/DlgRef_2Sel_QTD.h new file mode 100644 index 000000000..07cb6c569 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel_QTD.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_2Sel_QTD.ui' +** +** Created: mar sep 23 16:05:09 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_2SEL_QTD_H +#define DLGREF_2SEL_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; + +class DlgRef_2Sel_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_2Sel_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_2Sel_QTD(); + + QGroupBox* GroupBox1; + QPushButton* PushButton1; + QLineEdit* LineEdit2; + QPushButton* PushButton2; + QLabel* TextLabel1; + QLabel* TextLabel2; + QLineEdit* LineEdit1; + + +protected: + QGridLayout* DlgRef_2Sel_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; +}; + +#endif // DLGREF_2SEL_QTD_H diff --git a/src/DlgRef/DlgRef_2Spin.cxx b/src/DlgRef/DlgRef_2Spin.cxx new file mode 100644 index 000000000..f66c33baa --- /dev/null +++ b/src/DlgRef/DlgRef_2Spin.cxx @@ -0,0 +1,60 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_2Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_2Spin.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_2Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_2Spin::DlgRef_2Spin(QWidget* parent, const char* name, WFlags fl) + :DlgRef_2Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout1->addWidget(SpinBox_DX, 0, 1); + + SpinBox_DY = new DlgRef_SpinBox(GroupBox1, "SpinBox_DY"); + Layout1->addWidget(SpinBox_DY, 1, 1); + +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Spin::~DlgRef_2Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_2Spin.h b/src/DlgRef/DlgRef_2Spin.h new file mode 100644 index 000000000..306593117 --- /dev/null +++ b/src/DlgRef/DlgRef_2Spin.h @@ -0,0 +1,48 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_2Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_2SPIN_H +#define DLGREF_2SPIN_H + +#include "DlgRef_2Spin_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_2Spin : public DlgRef_2Spin_QTD +{ + Q_OBJECT + +public: + DlgRef_2Spin(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~DlgRef_2Spin(); + + DlgRef_SpinBox* SpinBox_DX; + DlgRef_SpinBox* SpinBox_DY; + +}; + +#endif // DLGREF_2SPIN_H diff --git a/src/DlgRef/DlgRef_2Spin_QTD.cxx b/src/DlgRef/DlgRef_2Spin_QTD.cxx new file mode 100644 index 000000000..bb6948f73 --- /dev/null +++ b/src/DlgRef/DlgRef_2Spin_QTD.cxx @@ -0,0 +1,79 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_2Spin_QTD.ui' +** +** Created: jeu sep 25 12:10:30 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_2Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_2Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_2Spin_QTD::DlgRef_2Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_2Spin_QTD" ); + resize( 124, 83 ); + setCaption( trUtf8( "DlgRef_2Spin_QTD" ) ); + DlgRef_2Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_2Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox2, 1, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 1 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox1, 0, 1 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_2Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Spin_QTD::~DlgRef_2Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_2Spin_QTD.h b/src/DlgRef/DlgRef_2Spin_QTD.h new file mode 100644 index 000000000..bcf59c686 --- /dev/null +++ b/src/DlgRef/DlgRef_2Spin_QTD.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_2Spin_QTD.ui' +** +** Created: jeu sep 25 12:10:30 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_2SPIN_QTD_H +#define DLGREF_2SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QSpinBox; + +class DlgRef_2Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_2Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_2Spin_QTD(); + + QGroupBox* GroupBox1; + QSpinBox* SpinBox2; + QSpinBox* SpinBox1; + QLabel* TextLabel1; + QLabel* TextLabel2; + + +protected: + QGridLayout* DlgRef_2Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; +}; + +#endif // DLGREF_2SPIN_QTD_H diff --git a/src/DlgRef/DlgRef_3Sel_QTD.cxx b/src/DlgRef/DlgRef_3Sel_QTD.cxx new file mode 100644 index 000000000..832f64940 --- /dev/null +++ b/src/DlgRef/DlgRef_3Sel_QTD.cxx @@ -0,0 +1,106 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_3Sel_QTD.ui' +** +** Created: lun sep 29 11:05:21 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_3Sel_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_3Sel_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_3Sel_QTD::DlgRef_3Sel_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_3Sel_QTD" ); + resize( 129, 117 ); + setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)7, 0, 0, sizePolicy().hasHeightForWidth() ) ); + setCaption( trUtf8( "DlgRef_3Sel_QTD" ) ); + DlgRef_3Sel_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_3Sel_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + LineEdit3 = new QLineEdit( GroupBox1, "LineEdit3" ); + + Layout1->addWidget( LineEdit3, 2, 2 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout1->addWidget( TextLabel3, 2, 0 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + QSpacerItem* spacer = new QSpacerItem( 0, 159, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 2 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + PushButton3 = new QPushButton( GroupBox1, "PushButton3" ); + PushButton3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton3->sizePolicy().hasHeightForWidth() ) ); + PushButton3->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton3, 2, 1 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_3Sel_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_3Sel_QTD::~DlgRef_3Sel_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_3Sel_QTD.h b/src/DlgRef/DlgRef_3Sel_QTD.h new file mode 100644 index 000000000..eba5a2c67 --- /dev/null +++ b/src/DlgRef/DlgRef_3Sel_QTD.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_3Sel_QTD.ui' +** +** Created: lun sep 29 11:05:21 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_3SEL_QTD_H +#define DLGREF_3SEL_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; + +class DlgRef_3Sel_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_3Sel_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_3Sel_QTD(); + + QGroupBox* GroupBox1; + QLineEdit* LineEdit3; + QPushButton* PushButton1; + QLineEdit* LineEdit2; + QLabel* TextLabel1; + QLabel* TextLabel3; + QLineEdit* LineEdit1; + QLabel* TextLabel2; + QPushButton* PushButton3; + QPushButton* PushButton2; + + +protected: + QGridLayout* DlgRef_3Sel_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; +}; + +#endif // DLGREF_3SEL_QTD_H diff --git a/src/DlgRef/DlgRef_3Spin.cxx b/src/DlgRef/DlgRef_3Spin.cxx new file mode 100644 index 000000000..07237c2ed --- /dev/null +++ b/src/DlgRef/DlgRef_3Spin.cxx @@ -0,0 +1,63 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_3Spin.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_3Spin.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_3Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_3Spin::DlgRef_3Spin(QWidget* parent, const char* name, WFlags fl) + :DlgRef_3Spin_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + SpinBox3->close(TRUE); + + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout1->addWidget(SpinBox_DX, 0, 1); + + SpinBox_DY = new DlgRef_SpinBox(GroupBox1, "SpinBox_DY"); + Layout1->addWidget(SpinBox_DY, 1, 1); + + SpinBox_DZ = new DlgRef_SpinBox(GroupBox1, "SpinBox_DZ"); + Layout1->addWidget(SpinBox_DZ, 2, 1); +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_3Spin::~DlgRef_3Spin() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_3Spin.h b/src/DlgRef/DlgRef_3Spin.h new file mode 100644 index 000000000..855f00b5d --- /dev/null +++ b/src/DlgRef/DlgRef_3Spin.h @@ -0,0 +1,49 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_3Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_3SPIN_H +#define DLGREF_3SPIN_H + +#include "DlgRef_3Spin_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_3Spin : public DlgRef_3Spin_QTD +{ + Q_OBJECT + +public: + DlgRef_3Spin( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_3Spin(); + + DlgRef_SpinBox* SpinBox_DX; + DlgRef_SpinBox* SpinBox_DY; + DlgRef_SpinBox* SpinBox_DZ; + +}; + +#endif // DLGREF_3SPIN_H diff --git a/src/DlgRef/DlgRef_3Spin1Check.cxx b/src/DlgRef/DlgRef_3Spin1Check.cxx new file mode 100644 index 000000000..7e622ab82 --- /dev/null +++ b/src/DlgRef/DlgRef_3Spin1Check.cxx @@ -0,0 +1,63 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_3Spin1Check.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_3Spin1Check.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_3Spin which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_3Spin1Check::DlgRef_3Spin1Check(QWidget* parent, const char* name, WFlags fl) + :DlgRef_3Spin1Check_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox2->close(TRUE); + SpinBox3->close(TRUE); + + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout1->addWidget(SpinBox_DX, 0, 1); + + SpinBox_DY = new DlgRef_SpinBox(GroupBox1, "SpinBox_DY"); + Layout1->addWidget(SpinBox_DY, 1, 1); + + SpinBox_DZ = new DlgRef_SpinBox(GroupBox1, "SpinBox_DZ"); + Layout1->addWidget(SpinBox_DZ, 2, 1); +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_3Spin1Check::~DlgRef_3Spin1Check() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_3Spin1Check.h b/src/DlgRef/DlgRef_3Spin1Check.h new file mode 100644 index 000000000..c792015c2 --- /dev/null +++ b/src/DlgRef/DlgRef_3Spin1Check.h @@ -0,0 +1,49 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_3Spin.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_3SPIN1CHECK_H +#define DLGREF_3SPIN1CHECK_H + +#include "DlgRef_3Spin1Check_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_3Spin1Check : public DlgRef_3Spin1Check_QTD +{ + Q_OBJECT + +public: + DlgRef_3Spin1Check(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~DlgRef_3Spin1Check(); + + DlgRef_SpinBox* SpinBox_DX; + DlgRef_SpinBox* SpinBox_DY; + DlgRef_SpinBox* SpinBox_DZ; + +}; + +#endif // DLGREF_3SPIN1CHECK_H diff --git a/src/DlgRef/DlgRef_3Spin1Check_QTD.cxx b/src/DlgRef/DlgRef_3Spin1Check_QTD.cxx new file mode 100644 index 000000000..2509bd63b --- /dev/null +++ b/src/DlgRef/DlgRef_3Spin1Check_QTD.cxx @@ -0,0 +1,96 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_3Spin1Check_QTD.ui' +** +** Created: dim sep 28 18:11:19 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_3Spin1Check_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_3Spin1Check_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_3Spin1Check_QTD::DlgRef_3Spin1Check_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_3Spin1Check_QTD" ); + resize( 124, 130 ); + setCaption( trUtf8( "DlgRef_3Spin1Check_QTD" ) ); + DlgRef_3Spin1Check_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_3Spin1Check_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + CheckBox1 = new QRadioButton( GroupBox1, "CheckBox1" ); + CheckBox1->setText( trUtf8( "" ) ); + + Layout1->addMultiCellWidget( CheckBox1, 3, 3, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 4, 1 ); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox2, 1, 1 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout1->addWidget( TextLabel3, 2, 0 ); + + SpinBox3 = new QSpinBox( GroupBox1, "SpinBox3" ); + SpinBox3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox3->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox3, 2, 1 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox1, 0, 1 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_3Spin1Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_3Spin1Check_QTD::~DlgRef_3Spin1Check_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_3Spin1Check_QTD.h b/src/DlgRef/DlgRef_3Spin1Check_QTD.h new file mode 100644 index 000000000..f292ff982 --- /dev/null +++ b/src/DlgRef/DlgRef_3Spin1Check_QTD.h @@ -0,0 +1,46 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_3Spin1Check_QTD.ui' +** +** Created: dim sep 28 18:11:19 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_3SPIN1CHECK_QTD_H +#define DLGREF_3SPIN1CHECK_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QRadioButton; +class QSpinBox; + +class DlgRef_3Spin1Check_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_3Spin1Check_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_3Spin1Check_QTD(); + + QGroupBox* GroupBox1; + QRadioButton* CheckBox1; + QSpinBox* SpinBox2; + QLabel* TextLabel3; + QSpinBox* SpinBox3; + QSpinBox* SpinBox1; + QLabel* TextLabel1; + QLabel* TextLabel2; + + +protected: + QGridLayout* DlgRef_3Spin1Check_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; +}; + +#endif // DLGREF_3SPIN1CHECK_QTD_H diff --git a/src/DlgRef/DlgRef_3Spin_QTD.cxx b/src/DlgRef/DlgRef_3Spin_QTD.cxx new file mode 100644 index 000000000..2066934c5 --- /dev/null +++ b/src/DlgRef/DlgRef_3Spin_QTD.cxx @@ -0,0 +1,90 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_3Spin_QTD.ui' +** +** Created: mar sep 23 16:05:10 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_3Spin_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_3Spin_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_3Spin_QTD::DlgRef_3Spin_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_3Spin_QTD" ); + resize( 124, 111 ); + setCaption( trUtf8( "DlgRef_3Spin_QTD" ) ); + DlgRef_3Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_3Spin_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox2, 1, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 1 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout1->addWidget( TextLabel3, 2, 0 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox1, 0, 1 ); + + SpinBox3 = new QSpinBox( GroupBox1, "SpinBox3" ); + SpinBox3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox3->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox3, 2, 1 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_3Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_3Spin_QTD::~DlgRef_3Spin_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_3Spin_QTD.h b/src/DlgRef/DlgRef_3Spin_QTD.h new file mode 100644 index 000000000..dceddcc97 --- /dev/null +++ b/src/DlgRef/DlgRef_3Spin_QTD.h @@ -0,0 +1,44 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_3Spin_QTD.ui' +** +** Created: mar sep 23 16:05:09 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_3SPIN_QTD_H +#define DLGREF_3SPIN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QSpinBox; + +class DlgRef_3Spin_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_3Spin_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_3Spin_QTD(); + + QGroupBox* GroupBox1; + QSpinBox* SpinBox2; + QLabel* TextLabel3; + QSpinBox* SpinBox1; + QSpinBox* SpinBox3; + QLabel* TextLabel1; + QLabel* TextLabel2; + + +protected: + QGridLayout* DlgRef_3Spin_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; +}; + +#endif // DLGREF_3SPIN_QTD_H diff --git a/src/DlgRef/DlgRef_Skeleton_QTD.cxx b/src/DlgRef/DlgRef_Skeleton_QTD.cxx new file mode 100644 index 000000000..cb1100af3 --- /dev/null +++ b/src/DlgRef/DlgRef_Skeleton_QTD.cxx @@ -0,0 +1,111 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_Skeleton_QTD.ui' +** +** Created: mar sep 23 15:06:58 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_Skeleton_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_Skeleton_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +DlgRef_Skeleton_QTD::DlgRef_Skeleton_QTD( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, fl ) +{ + if ( !name ) + setName( "DlgRef_Skeleton_QTD" ); + resize( 307, 147 ); + setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)7, 0, 0, sizePolicy().hasHeightForWidth() ) ); + setCaption( trUtf8( "DlgRef_Skeleton_QTD" ) ); + setSizeGripEnabled( TRUE ); + DlgRef_Skeleton_QTDLayout = new QGridLayout( this, 1, 1, 11, 6, "DlgRef_Skeleton_QTDLayout"); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); + GroupButtons->setTitle( trUtf8( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 6 ); + GroupButtons->layout()->setMargin( 11 ); + GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + + Layout3 = new QHBoxLayout( 0, 0, 6, "Layout3"); + + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( trUtf8( "&Ok" ) ); + Layout3->addWidget( buttonOk ); + + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( trUtf8( "&Apply" ) ); + Layout3->addWidget( buttonApply ); + QSpacerItem* spacer = new QSpacerItem( 91, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + Layout3->addItem( spacer ); + + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( trUtf8( "&Cancel" ) ); + Layout3->addWidget( buttonCancel ); + GroupButtonsLayout->addLayout( Layout3 ); + + Layout1->addWidget( GroupButtons, 2, 0 ); + + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) ); + GroupConstructors->setTitle( trUtf8( "" ) ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 6 ); + GroupConstructors->layout()->setMargin( 11 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + + Layout2 = new QHBoxLayout( 0, 0, 6, "Layout2"); + + RadioButton1 = new QRadioButton( GroupConstructors, "RadioButton1" ); + RadioButton1->setText( trUtf8( "" ) ); + Layout2->addWidget( RadioButton1 ); + + RadioButton2 = new QRadioButton( GroupConstructors, "RadioButton2" ); + RadioButton2->setText( trUtf8( "" ) ); + Layout2->addWidget( RadioButton2 ); + + RadioButton3 = new QRadioButton( GroupConstructors, "RadioButton3" ); + RadioButton3->setText( trUtf8( "" ) ); + Layout2->addWidget( RadioButton3 ); + + GroupConstructorsLayout->addLayout( Layout2, 0, 0 ); + + Layout1->addWidget( GroupConstructors, 0, 0 ); + + GroupMedium = new QGroupBox( this, "GroupMedium" ); + GroupMedium->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 0, GroupMedium->sizePolicy().hasHeightForWidth() ) ); + GroupMedium->setTitle( trUtf8( "" ) ); + + Layout1->addWidget( GroupMedium, 1, 0 ); + + DlgRef_Skeleton_QTDLayout->addLayout( Layout1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_Skeleton_QTD::~DlgRef_Skeleton_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_Skeleton_QTD.h b/src/DlgRef/DlgRef_Skeleton_QTD.h new file mode 100644 index 000000000..f16363d60 --- /dev/null +++ b/src/DlgRef/DlgRef_Skeleton_QTD.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_Skeleton_QTD.ui' +** +** Created: mar sep 23 15:06:57 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_SKELETON_QTD_H +#define DLGREF_SKELETON_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QPushButton; +class QRadioButton; + +class DlgRef_Skeleton_QTD : public QDialog +{ + Q_OBJECT + +public: + DlgRef_Skeleton_QTD( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~DlgRef_Skeleton_QTD(); + + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonApply; + QPushButton* buttonCancel; + QButtonGroup* GroupConstructors; + QRadioButton* RadioButton1; + QRadioButton* RadioButton2; + QRadioButton* RadioButton3; + QGroupBox* GroupMedium; + + +protected: + QGridLayout* DlgRef_Skeleton_QTDLayout; + QGridLayout* Layout1; + QHBoxLayout* GroupButtonsLayout; + QHBoxLayout* Layout3; + QGridLayout* GroupConstructorsLayout; + QHBoxLayout* Layout2; +}; + +#endif // DLGREF_SKELETON_QTD_H diff --git a/src/DlgRef/DlgRef_SpinBox.cxx b/src/DlgRef/DlgRef_SpinBox.cxx new file mode 100644 index 000000000..ba262d597 --- /dev/null +++ b/src/DlgRef/DlgRef_SpinBox.cxx @@ -0,0 +1,101 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_SpinBox.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "DlgRef_SpinBox.h" +//#include "DlgRef.h" +#include +//#include +//#include "utilities.h" + +//================================================================================= +// class : DlgRef_SpinBox() +// purpose : constructor of specific widget accepting floats in double precision. +//================================================================================= +DlgRef_SpinBox::DlgRef_SpinBox( QWidget* parent, const char* name ) +: QAD_SpinBoxDbl( parent, name) +{ + /* when step value is changed in myGeomGUI */ + //connect( DlgRef::GetDlgRef(), SIGNAL( SignalDefaultStepValueChanged( double )), this, SLOT( SetStep( double ) ) ); +} + + +//================================================================================= +// function : SetStep() [SLOT] +// purpose : +//================================================================================= +void DlgRef_SpinBox::SetStep( double newStep ) +{ + setLineStep( newStep ); +} + +//================================================================================= +// function : ~DlgRef_SpinBox() +// purpose : destructor +//================================================================================= +DlgRef_SpinBox::~DlgRef_SpinBox() +{ +} + +//================================================================================= +// function : SetValue() +// purpose : +//================================================================================= +void DlgRef_SpinBox::SetValue( double v ) +{ + setValue( v ); +} + +//================================================================================= +// function : GetValue() +// purpose : returns a double +//================================================================================= +double DlgRef_SpinBox::GetValue( ) +{ + return value(); +} + +//================================================================================= +// function : GetString() +// purpose : returns a QString +//================================================================================= +QString DlgRef_SpinBox::GetString( ) +{ + return cleanText(); +} + +//================================================================================= +// function : RangeStepAndValidator() +// purpose : +//================================================================================= +void DlgRef_SpinBox::RangeStepAndValidator( double min, double max, double step, unsigned short decimals ) +{ + setRange( min, max ); + setLineStep( step ); + ( ( QDoubleValidator* )validator() )->setRange( min, max, decimals ) ; +} diff --git a/src/DlgRef/DlgRef_SpinBox.h b/src/DlgRef/DlgRef_SpinBox.h new file mode 100644 index 000000000..af50e74f3 --- /dev/null +++ b/src/DlgRef/DlgRef_SpinBox.h @@ -0,0 +1,60 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DlgRef_SpinBox.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef GEOMSPINBOX_H +#define GEOMSPINBOX_H + +#include "QAD_SpinBoxDbl.h" + +class DlgRef ; + +//================================================================================= +// class : DlgRef_SpinBox +// purpose : Derivated from QSpinBox class and modified to accept floats +//================================================================================= +class DlgRef_SpinBox : public QAD_SpinBoxDbl +{ + Q_OBJECT + +public : + DlgRef_SpinBox( QWidget* parent, const char* name = 0 ); + ~DlgRef_SpinBox(); + + void RangeStepAndValidator( double min = -1000000.0, + double max = +1000000.0, + double step = 100.0, + unsigned short decimals = 3 ); + void SetValue( double v ); + double GetValue(); + QString GetString(); + +public slots: + void SetStep( double newStep ); + +}; +#endif // GEOMSPINBOX_H diff --git a/src/DlgRef/Makefile.in b/src/DlgRef/Makefile.in new file mode 100644 index 000000000..cee0a258c --- /dev/null +++ b/src/DlgRef/Makefile.in @@ -0,0 +1,117 @@ +# GEOM DLGREF : +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Damien COQUERET (OCC) +# Module : GEOM +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# Libraries targets +LIB = libDlgRef.la + +LIB_SRC = DlgRef_Skeleton_QTD.cxx \ + DlgRef_1Sel_QTD.cxx \ + DlgRef_2Sel_QTD.cxx \ + DlgRef_3Sel_QTD.cxx \ + DlgRef_1Sel1Spin_QTD.cxx \ + DlgRef_1Sel2Spin_QTD.cxx \ + DlgRef_1Sel3Spin_QTD.cxx \ + DlgRef_1Sel4Spin_QTD.cxx \ + DlgRef_1Sel5Spin_QTD.cxx \ + DlgRef_2Sel1Spin_QTD.cxx \ + DlgRef_2Sel2Spin_QTD.cxx \ + DlgRef_2Sel3Spin_QTD.cxx \ + DlgRef_2Sel1Spin1Check_QTD.cxx \ + DlgRef_1Spin_QTD.cxx \ + DlgRef_2Spin_QTD.cxx \ + DlgRef_3Spin_QTD.cxx \ + DlgRef_3Spin1Check_QTD.cxx \ + DlgRef_SpinBox.cxx \ + DlgRef_1Sel1Spin.cxx \ + DlgRef_1Sel2Spin.cxx \ + DlgRef_1Sel3Spin.cxx \ + DlgRef_1Sel4Spin.cxx \ + DlgRef_1Sel5Spin.cxx \ + DlgRef_2Sel1Spin.cxx \ + DlgRef_2Sel2Spin.cxx \ + DlgRef_2Sel3Spin.cxx \ + DlgRef_2Sel1Spin1Check.cxx \ + DlgRef_1Spin.cxx \ + DlgRef_2Spin.cxx \ + DlgRef_3Spin.cxx \ + DlgRef_3Spin1Check.cxx + +LIB_MOC = \ + DlgRef_Skeleton_QTD.h \ + DlgRef_1Sel_QTD.h \ + DlgRef_2Sel_QTD.h \ + DlgRef_3Sel_QTD.h \ + DlgRef_1Sel1Spin_QTD.h \ + DlgRef_1Sel2Spin_QTD.h \ + DlgRef_1Sel3Spin_QTD.h \ + DlgRef_1Sel4Spin_QTD.h \ + DlgRef_1Sel5Spin_QTD.h \ + DlgRef_2Sel1Spin_QTD.h \ + DlgRef_2Sel2Spin_QTD.h \ + DlgRef_2Sel3Spin_QTD.h \ + DlgRef_2Sel1Spin1Check_QTD.h \ + DlgRef_1Spin_QTD.h \ + DlgRef_2Spin_QTD.h \ + DlgRef_3Spin_QTD.h \ + DlgRef_3Spin1Check_QTD.h \ + DlgRef_SpinBox.h \ + DlgRef_1Sel1Spin.h \ + DlgRef_1Sel2Spin.h \ + DlgRef_1Sel3Spin.h \ + DlgRef_1Sel4Spin.h \ + DlgRef_1Sel5Spin.h \ + DlgRef_2Sel1Spin.h \ + DlgRef_2Sel2Spin.h \ + DlgRef_2Sel3Spin.h \ + DlgRef_2Sel1Spin1Check.h \ + DlgRef_1Spin.h \ + DlgRef_2Spin.h \ + DlgRef_3Spin.h \ + DlgRef_3Spin1Check.h + +# header files +EXPORT_HEADERS= $(LIB_MOC) + +LIB_CLIENT_IDL = + +LIB_SERVER_IDL = + +# additionnal information to compil and link file +CPPFLAGS += $(QT_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS += -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/DlgRef/UIFiles/DlgRef_1Sel1Spin_QTD.ui b/src/DlgRef/UIFiles/DlgRef_1Sel1Spin_QTD.ui new file mode 100644 index 000000000..e3551d166 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_1Sel1Spin_QTD.ui @@ -0,0 +1,165 @@ + +DlgRef_1Sel1Spin_QTD + + + DlgRef_1Sel1Spin_QTD + + + + 0 + 0 + 129 + 87 + + + + DlgRef_1Sel1Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + LineEdit1 + + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + + + Spacer7 + + + Vertical + + + Expanding + + + + 0 + 16 + + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_1Sel2Spin_QTD.ui b/src/DlgRef/UIFiles/DlgRef_1Sel2Spin_QTD.ui new file mode 100644 index 000000000..641264bb6 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_1Sel2Spin_QTD.ui @@ -0,0 +1,194 @@ + +DlgRef_1Sel2Spin_QTD + + + DlgRef_1Sel2Spin_QTD + + + + 0 + 0 + 129 + 115 + + + + DlgRef_1Sel2Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + SpinBox2 + + + + 7 + 0 + 0 + 0 + + + + + + + + LineEdit1 + + + + + Spacer7 + + + Vertical + + + Expanding + + + + 0 + 30 + + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_1Sel3Spin_QTD.ui b/src/DlgRef/UIFiles/DlgRef_1Sel3Spin_QTD.ui new file mode 100644 index 000000000..262deb7a5 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_1Sel3Spin_QTD.ui @@ -0,0 +1,223 @@ + +DlgRef_1Sel3Spin_QTD + + + DlgRef_1Sel3Spin_QTD + + + + 0 + 0 + 232 + 87 + + + + DlgRef_1Sel3Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + Spacer6 + + + Vertical + + + Expanding + + + + 0 + 207 + + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + LineEdit1 + + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel4 + + + + 0 + 0 + 0 + 0 + + + + TL4 + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + SpinBox3 + + + + 7 + 0 + 0 + 0 + + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + SpinBox2 + + + + 7 + 0 + 0 + 0 + + + + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_1Sel4Spin_QTD.ui b/src/DlgRef/UIFiles/DlgRef_1Sel4Spin_QTD.ui new file mode 100644 index 000000000..49a0cd1c2 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_1Sel4Spin_QTD.ui @@ -0,0 +1,292 @@ + +DlgRef_1Sel4Spin_QTD + + + DlgRef_1Sel4Spin_QTD + + + + 0 + 0 + 284 + 119 + + + + DlgRef_1Sel4Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel5 + + + + 0 + 0 + 0 + 0 + + + + TL5 + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + TextLabel4 + + + + 0 + 0 + 0 + 0 + + + + TL4 + + + + + SpinBox3 + + + + 7 + 0 + 0 + 0 + + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + SpinBox2 + + + + 7 + 0 + 0 + 0 + + + + + + + + Spacer6 + + + Vertical + + + Expanding + + + + 0 + 16 + + + + + + Layout4 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel6 + + + + 0 + 0 + 0 + 0 + + + + TL6 + + + + + SpinBox4 + + + + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + LineEdit1 + + + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_1Sel5Spin_QTD.ui b/src/DlgRef/UIFiles/DlgRef_1Sel5Spin_QTD.ui new file mode 100644 index 000000000..daa18adb1 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_1Sel5Spin_QTD.ui @@ -0,0 +1,281 @@ + +DlgRef_1Sel5Spin_QTD + + + DlgRef_1Sel5Spin_QTD + + + + 0 + 0 + 232 + 115 + + + + DlgRef_1Sel5Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel6 + + + + 0 + 0 + 0 + 0 + + + + TL6 + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + SpinBox4 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel5 + + + + 0 + 0 + 0 + 0 + + + + TL5 + + + + + SpinBox2 + + + + 7 + 0 + 0 + 0 + + + + + + SpinBox5 + + + + 7 + 0 + 0 + 0 + + + + + + SpinBox3 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel4 + + + + 0 + 0 + 0 + 0 + + + + TL4 + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + + + LineEdit1 + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + Spacer6 + + + Vertical + + + Expanding + + + + 0 + 20 + + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_1Sel_QTD.ui b/src/DlgRef/UIFiles/DlgRef_1Sel_QTD.ui new file mode 100644 index 000000000..3816fd110 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_1Sel_QTD.ui @@ -0,0 +1,128 @@ + +DlgRef_1Sel_QTD + + + DlgRef_1Sel_QTD + + + + 0 + 0 + 129 + 57 + + + + DlgRef_1Sel_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + 7 + 7 + 0 + 0 + + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + Spacer8 + + + Vertical + + + Expanding + + + + 0 + 16 + + + + + + LineEdit1 + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_1Spin_QTD.ui b/src/DlgRef/UIFiles/DlgRef_1Spin_QTD.ui new file mode 100644 index 000000000..ddeca8757 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_1Spin_QTD.ui @@ -0,0 +1,112 @@ + +DlgRef_1Spin_QTD + + + DlgRef_1Spin_QTD + + + + 0 + 0 + 124 + 55 + + + + DlgRef_1Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + Spacer1 + + + Vertical + + + Expanding + + + + 0 + 16 + + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_2Sel1Spin1Check_QTD.ui b/src/DlgRef/UIFiles/DlgRef_2Sel1Spin1Check_QTD.ui new file mode 100644 index 000000000..a06de5cb4 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_2Sel1Spin1Check_QTD.ui @@ -0,0 +1,210 @@ + +DlgRef_2Sel1Spin1Check_QTD + + + DlgRef_2Sel1Spin1Check_QTD + + + + 0 + 0 + 129 + 117 + + + + DlgRef_2Sel1Spin1Check_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + LineEdit1 + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + LineEdit2 + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 20 + + + + + + PushButton2 + + + + 0 + 0 + 0 + 0 + + + + + + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + CheckButton1 + + + + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_2Sel1Spin_QTD.ui b/src/DlgRef/UIFiles/DlgRef_2Sel1Spin_QTD.ui new file mode 100644 index 000000000..053cae186 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_2Sel1Spin_QTD.ui @@ -0,0 +1,202 @@ + +DlgRef_2Sel1Spin_QTD + + + DlgRef_2Sel1Spin_QTD + + + + 0 + 0 + 129 + 117 + + + + DlgRef_2Sel1Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + LineEdit1 + + + + + PushButton2 + + + + 0 + 0 + 0 + 0 + + + + + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + LineEdit2 + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 16 + + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_2Sel2Spin_QTD.ui b/src/DlgRef/UIFiles/DlgRef_2Sel2Spin_QTD.ui new file mode 100644 index 000000000..b935dc89a --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_2Sel2Spin_QTD.ui @@ -0,0 +1,231 @@ + +DlgRef_2Sel2Spin_QTD + + + DlgRef_2Sel2Spin_QTD + + + + 0 + 0 + 129 + 145 + + + + DlgRef_2Sel2Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + LineEdit1 + + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + SpinBox2 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel4 + + + + 0 + 0 + 0 + 0 + + + + TL4 + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + + + PushButton2 + + + + 0 + 0 + 0 + 0 + + + + + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 20 + + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + LineEdit2 + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_2Sel3Spin_QTD.ui b/src/DlgRef/UIFiles/DlgRef_2Sel3Spin_QTD.ui new file mode 100644 index 000000000..e51bd758a --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_2Sel3Spin_QTD.ui @@ -0,0 +1,260 @@ + +DlgRef_2Sel3Spin_QTD + + + DlgRef_2Sel3Spin_QTD + + + + 0 + 0 + 129 + 173 + + + + DlgRef_2Sel3Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + LineEdit1 + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + SpinBox2 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel4 + + + + 0 + 0 + 0 + 0 + + + + TL4 + + + + + TextLabel5 + + + + 0 + 0 + 0 + 0 + + + + TL4 + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + SpinBox3 + + + + 7 + 0 + 0 + 0 + + + + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 20 + + + + + + LineEdit2 + + + + + PushButton2 + + + + 0 + 0 + 0 + 0 + + + + + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_2Sel_QTD.ui b/src/DlgRef/UIFiles/DlgRef_2Sel_QTD.ui new file mode 100644 index 000000000..46e7f5b7e --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_2Sel_QTD.ui @@ -0,0 +1,165 @@ + +DlgRef_2Sel_QTD + + + DlgRef_2Sel_QTD + + + + 0 + 0 + 129 + 87 + + + + + 5 + 7 + 0 + 0 + + + + DlgRef_2Sel_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + Spacer3 + + + Vertical + + + Expanding + + + + 0 + 16 + + + + + + LineEdit2 + + + + + PushButton2 + + + + 0 + 0 + 0 + 0 + + + + + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + LineEdit1 + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_2Spin_QTD.ui b/src/DlgRef/UIFiles/DlgRef_2Spin_QTD.ui new file mode 100644 index 000000000..3fe8a9fe0 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_2Spin_QTD.ui @@ -0,0 +1,141 @@ + +DlgRef_2Spin_QTD + + + DlgRef_2Spin_QTD + + + + 0 + 0 + 124 + 83 + + + + DlgRef_2Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + SpinBox2 + + + + 7 + 0 + 0 + 0 + + + + + + Spacer1 + + + Vertical + + + Expanding + + + + 0 + 16 + + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_3Sel_QTD.ui b/src/DlgRef/UIFiles/DlgRef_3Sel_QTD.ui new file mode 100644 index 000000000..0fe998827 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_3Sel_QTD.ui @@ -0,0 +1,202 @@ + +DlgRef_3Sel_QTD + + + DlgRef_3Sel_QTD + + + + 0 + 0 + 129 + 117 + + + + + 5 + 7 + 0 + 0 + + + + DlgRef_3Sel_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + LineEdit3 + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + LineEdit2 + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + LineEdit1 + + + + + Spacer3 + + + Vertical + + + Expanding + + + + 0 + 159 + + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + PushButton3 + + + + 0 + 0 + 0 + 0 + + + + + + + + + PushButton2 + + + + 0 + 0 + 0 + 0 + + + + + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_3Spin1Check_QTD.ui b/src/DlgRef/UIFiles/DlgRef_3Spin1Check_QTD.ui new file mode 100644 index 000000000..fd3317f2d --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_3Spin1Check_QTD.ui @@ -0,0 +1,178 @@ + +DlgRef_3Spin1Check_QTD + + + DlgRef_3Spin1Check_QTD + + + + 0 + 0 + 124 + 130 + + + + DlgRef_3Spin1Check_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + CheckBox1 + + + + + + + + Spacer1 + + + Vertical + + + Expanding + + + + 0 + 20 + + + + + + SpinBox2 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + SpinBox3 + + + + 7 + 0 + 0 + 0 + + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_3Spin_QTD.ui b/src/DlgRef/UIFiles/DlgRef_3Spin_QTD.ui new file mode 100644 index 000000000..96f6b4dfb --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_3Spin_QTD.ui @@ -0,0 +1,170 @@ + +DlgRef_3Spin_QTD + + + DlgRef_3Spin_QTD + + + + 0 + 0 + 124 + 111 + + + + DlgRef_3Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + SpinBox2 + + + + 7 + 0 + 0 + 0 + + + + + + Spacer1 + + + Vertical + + + Expanding + + + + 0 + 16 + + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + SpinBox3 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_Skeleton_QTD.ui b/src/DlgRef/UIFiles/DlgRef_Skeleton_QTD.ui new file mode 100644 index 000000000..0c6e57718 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_Skeleton_QTD.ui @@ -0,0 +1,225 @@ + +DlgRef_Skeleton_QTD + + + DlgRef_Skeleton_QTD + + + + 0 + 0 + 307 + 147 + + + + + 5 + 7 + 0 + 0 + + + + DlgRef_Skeleton_QTD + + + true + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + GroupButtons + + + + 7 + 0 + 0 + 0 + + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + buttonOk + + + &Ok + + + + + buttonApply + + + &Apply + + + + + Spacer1 + + + Horizontal + + + Expanding + + + + 91 + 0 + + + + + + buttonCancel + + + &Cancel + + + + + + + + + GroupConstructors + + + + 5 + 0 + 0 + 0 + + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + RadioButton1 + + + + + + + + RadioButton2 + + + + + + + + RadioButton3 + + + + + + + + + + + + GroupMedium + + + + 7 + 7 + 0 + 0 + + + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/ui_to_cxx b/src/DlgRef/UIFiles/ui_to_cxx new file mode 100755 index 000000000..ceceffc57 --- /dev/null +++ b/src/DlgRef/UIFiles/ui_to_cxx @@ -0,0 +1,61 @@ +#!/bin/sh + +#uic -o DlgRef_Skeleton_QTD.h DlgRef_Skeleton_QTD.ui +#uic -o DlgRef_Skeleton_QTD.cxx -impl DlgRef_Skeleton_QTD.h DlgRef_Skeleton_QTD.ui + +#uic -o DlgRef_TopRef1_QTD.h DlgRef_TopRef1_QTD.ui +#uic -o DlgRef_TopRef1_QTD.cxx -impl DlgRef_TopRef1_QTD.h DlgRef_TopRef1_QTD.ui + +#uic -o DlgRef_TopRef2_QTD.h DlgRef_TopRef2_QTD.ui +#uic -o DlgRef_TopRef2_QTD.cxx -impl DlgRef_TopRef2_QTD.h DlgRef_TopRef2_QTD.ui + +#uic -o DlgRef_TopRef3_QTD.h DlgRef_TopRef3_QTD.ui +#uic -o DlgRef_TopRef3_QTD.cxx -impl DlgRef_TopRef3_QTD.h DlgRef_TopRef3_QTD.ui + +#uic -o DlgRef_1Sel_QTD.h DlgRef_1Sel_QTD.ui +#uic -o DlgRef_1Sel_QTD.cxx -impl DlgRef_1Sel_QTD.h DlgRef_1Sel_QTD.ui + +#uic -o DlgRef_1Sel1Spin_QTD.h DlgRef_1Sel1Spin_QTD.ui +#uic -o DlgRef_1Sel1Spin_QTD.cxx -impl DlgRef_1Sel1Spin_QTD.h DlgRef_1Sel1Spin_QTD.ui + +uic -o DlgRef_1Sel2Spin_QTD.h DlgRef_1Sel2Spin_QTD.ui +uic -o DlgRef_1Sel2Spin_QTD.cxx -impl DlgRef_1Sel2Spin_QTD.h DlgRef_1Sel2Spin_QTD.ui + +#uic -o DlgRef_1Sel3Spin_QTD.h DlgRef_1Sel3Spin_QTD.ui +#uic -o DlgRef_1Sel3Spin_QTD.cxx -impl DlgRef_1Sel3Spin_QTD.h DlgRef_1Sel3Spin_QTD.ui + +#uic -o DlgRef_1Sel4Spin_QTD.h DlgRef_1Sel4Spin_QTD.ui +#uic -o DlgRef_1Sel4Spin_QTD.cxx -impl DlgRef_1Sel4Spin_QTD.h DlgRef_1Sel4Spin_QTD.ui + +#uic -o DlgRef_1Sel5Spin_QTD.h DlgRef_1Sel5Spin_QTD.ui +#uic -o DlgRef_1Sel5Spin_QTD.cxx -impl DlgRef_1Sel5Spin_QTD.h DlgRef_1Sel5Spin_QTD.ui + +#uic -o DlgRef_2Sel1Spin_QTD.h DlgRef_2Sel1Spin_QTD.ui +#uic -o DlgRef_2Sel1Spin_QTD.cxx -impl DlgRef_2Sel1Spin_QTD.h DlgRef_2Sel1Spin_QTD.ui + +#uic -o DlgRef_2Sel1Spin1Check_QTD.h DlgRef_2Sel1Spin1Check_QTD.ui +#uic -o DlgRef_2Sel1Spin1Check_QTD.cxx -impl DlgRef_2Sel1Spin1Check_QTD.h DlgRef_2Sel1Spin1Check_QTD.ui + +#uic -o DlgRef_2Sel2Spin_QTD.h DlgRef_2Sel2Spin_QTD.ui +#uic -o DlgRef_2Sel2Spin_QTD.cxx -impl DlgRef_2Sel2Spin_QTD.h DlgRef_2Sel2Spin_QTD.ui + +#uic -o DlgRef_2Sel3Spin_QTD.h DlgRef_2Sel3Spin_QTD.ui +#uic -o DlgRef_2Sel3Spin_QTD.cxx -impl DlgRef_2Sel3Spin_QTD.h DlgRef_2Sel3Spin_QTD.ui + +#uic -o DlgRef_2Sel_QTD.h DlgRef_2Sel_QTD.ui +#uic -o DlgRef_2Sel_QTD.cxx -impl DlgRef_2Sel_QTD.h DlgRef_2Sel_QTD.ui + +#uic -o DlgRef_3Sel_QTD.h DlgRef_3Sel_QTD.ui +#uic -o DlgRef_3Sel_QTD.cxx -impl DlgRef_3Sel_QTD.h DlgRef_3Sel_QTD.ui + +#uic -o DlgRef_1Spin_QTD.h DlgRef_1Spin_QTD.ui +#uic -o DlgRef_1Spin_QTD.cxx -impl DlgRef_1Spin_QTD.h DlgRef_1Spin_QTD.ui + +#uic -o DlgRef_2Spin_QTD.h DlgRef_2Spin_QTD.ui +#uic -o DlgRef_2Spin_QTD.cxx -impl DlgRef_2Spin_QTD.h DlgRef_2Spin_QTD.ui + +#uic -o DlgRef_3Spin_QTD.h DlgRef_3Spin_QTD.ui +#uic -o DlgRef_3Spin_QTD.cxx -impl DlgRef_3Spin_QTD.h DlgRef_3Spin_QTD.ui + +#uic -o DlgRef_3Spin1Check_QTD.h DlgRef_3Spin1Check_QTD.ui +#uic -o DlgRef_3Spin1Check_QTD.cxx -impl DlgRef_3Spin1Check_QTD.h DlgRef_3Spin1Check_QTD.ui diff --git a/src/GEOMBase/GEOMBase_Context.cxx b/src/GEOMBase/GEOMBase_Context.cxx new file mode 100644 index 000000000..004515abd --- /dev/null +++ b/src/GEOMBase/GEOMBase_Context.cxx @@ -0,0 +1,1440 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_Context.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "GEOMBase_Context.h" + +//// SALOME Includes +# include "Utils_ORB_INIT.hxx" +# include "Utils_SINGLETON.hxx" + +#include "QAD_RightFrame.h" +#include "QAD_MessageBox.h" + +#include "GEOM_AssemblyBuilder.h" +#include "VTKViewer_ViewFrame.h" +#include "OCCViewer_ViewPort3d.h" +#include "OCCViewer_Viewer3d.h" + +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOMEGUI_ImportOperation.h" +#include "SALOMEGUI_NameDlg.h" + +// // Open CASCADE Includes +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +// // QT Includes +#include + +#include "GEOMBase_Display.h" +#include "GEOMBase_aParameterDlg.h" + +/* The object itself created in the static method 'GetOrCreateGEOMBase()' */ +static GEOMBase_Context* GeomGUI = 0; + +//======================================================================= +// function : GEOMBase_Context() +// purpose : Constructor +//======================================================================= +GEOMBase_Context::GEOMBase_Context() : + QObject() +{ + mySettings_AddInStudy = false; + mySettings_Copy = false; + myFatherior = ""; +} + + +//======================================================================= +// function : ~GEOMBase_Context() +// purpose : Destructor +//======================================================================= +GEOMBase_Context::~GEOMBase_Context() +{ +} + + +//======================================================================= +// function : GetGEOMBase_Context() static +// purpose : Returns current 'GeomGUI' a static pointer +//======================================================================= +GEOMBase_Context* GEOMBase_Context::GetGeomGUI() +{ + return GeomGUI; +} + + +//======================================================================= +// function : GetOrCreateGEOMBase() +// purpose : Gets or create an object 'GEOMBase' with initialisations +// : Returns 'GeomGUI' as a pointer +//======================================================================= +GEOMBase_Context* GEOMBase_Context::GetOrCreateGeomGUI(QAD_Desktop* desktop) +{ + if(GeomGUI == 0) { + GeomGUI = new GEOMBase_Context; + GeomGUI->myActiveDialogBox = 0; + GeomGUI->mySimulationShape = new AIS_Shape(TopoDS_Shape()); + GeomGUI->myState = -1; + GeomGUI->myDesktop = desktop; + GeomGUI->myActiveStudy = desktop->getActiveStudy(); + GeomGUI->mySimulationActor = vtkActorCollection::New(); + + GeomGUI->myShadingColor = Quantity_Color(Quantity_NOC_GOLDENROD); + + Engines::Component_var comp = desktop->getEngine("FactoryServer", "GEOM"); + GeomGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp); + + /* GetCurrentStudy */ + int studyId = GeomGUI->myActiveStudy->getStudyId(); + GeomGUI->myComponentGeom->GetCurrentStudy(studyId); + + GeomGUI->myNbGeom = GeomGUI->myComponentGeom->NbLabels(); + } + else { + /* study may have changed */ + GeomGUI->myActiveStudy = desktop->getActiveStudy(); + } + + return GeomGUI; +} + + +//===================================================================================== +// function : GetIndex() +// purpose : Get the index of a sub shape in a main shape : index start at 1 +//===================================================================================== +int GEOMBase_Context::GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int /*ShapeType*/) +{ + if(shape.IsNull() || subshape.IsNull()) + return -1; + + int index = 1; + if(subshape.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Iterator it; + TopTools_ListOfShape CL; + CL.Append(shape); + TopTools_ListIteratorOfListOfShape itC; + for(itC.Initialize(CL); itC.More(); itC.Next()) { + for(it.Initialize(itC.Value()); it.More(); it.Next()) { + if(it.Value().ShapeType() == TopAbs_COMPOUND) { + if(it.Value().IsSame(subshape)) + return index; + else + index++; + CL.Append(it.Value()); + } + } + } + } + else { + TopExp_Explorer Exp(shape, subshape.ShapeType()); + TopTools_MapOfShape M; + while(Exp.More()) { + if(M.Add(Exp.Current())) { + if(Exp.Current().IsSame(subshape)) + return index; + index++; + } + Exp.Next(); + } + } + return -1; +} + + +//================================================================================= +// function : VertexToPoint() +// purpose : If S can be converted in a gp_Pnt returns true and the result is P +//================================================================================= +bool GEOMBase_Context::VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P) +{ + if(S.IsNull() || S.ShapeType() != TopAbs_VERTEX) + return false; + P = BRep_Tool::Pnt(TopoDS::Vertex(S)); + return true; +} + + +//================================================================================= +// function : GetBipointDxDyDz() +// purpose : +//================================================================================= +void GEOMBase_Context::GetBipointDxDyDz(gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz) +{ + dx = P2.X() - P1.X(); + dy = P2.Y() - P1.Y(); + dz = P2.Z() - P1.Z(); + return; +} + + +//================================================================================= +// function : LinearEdgeExtremities() +// purpose : If S can be converted in a linear edge and if initial an final points +// : distance is sufficient, returns true else returns false. +// : Resulting points are respectively P1 and P2 +//================================================================================= +bool GEOMBase_Context::LinearEdgeExtremities(const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2) +{ + if(S.IsNull() || S.ShapeType() != TopAbs_EDGE) + return false; + BRepAdaptor_Curve curv(TopoDS::Edge(S)); + if(curv.GetType() != GeomAbs_Line) + return false; + + curv.D0(curv.FirstParameter(), P1); + curv.D0(curv.LastParameter(), P2); + + if(P1.Distance(P2) <= Precision::Confusion()) + return false; + + return true; +} + + +//======================================================================= +// function : GetTopoFromSelection() +// purpose : Define tds from a single selection and retuen true +//======================================================================= +bool GEOMBase_Context::GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds) +{ + if(Sel->IObjectCount() != 1) + return false; + + Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); + /* case SObject */ + if(IO->hasEntry()) { + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID(IO->getEntry()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if(!obj->_is_nil()) { + if(obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + tds = this->GetShapeFromIOR(anIOR->Value()); + if(tds.IsNull()) + return false; + else + return true; + } + } + } + + if(IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject))) { + Standard_CString ior = ""; + Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast(IO); + ior = GIObject->getIOR(); + tds = this->GetShapeFromIOR(ior); + if(tds.IsNull()) + return false; + else + return true; + } + + return false; +} + + + +//===================================================================================== +// function : PrepareSubShapeSelection() +// purpose : (localContextId of the method is opened and defined here) +//===================================================================================== +bool GEOMBase_Context::PrepareSubShapeSelection(const int SubShapeType, Standard_Integer& returnLocalContextId) +{ + //* Test the type of viewer */ + if(myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + return false; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + /* local context opening */ + this->SetDisplayedObjectList(); + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayOnly(); + + returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False); + SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean found; + Handle(GEOM_AISShape) Shape = this->ConvertIOinGEOMAISShape(IObject, found); + if(found && SubShapeType >= Shape->Shape().ShapeType()) { + ic->Load(Shape, (8 - SubShapeType), Standard_True); + ic->HilightWithColor(Shape, Quantity_NOC_RED); + } + } + myDesktop->putInfo(tr("GEOM_PRP_SELECT_SUBSHAPES")); + return true; +} + + +//===================================================================================== +// function : PrepareSubShapeSelectionArgumentShape() +// purpose : ( localContextId of the method is opened and defined here ) +//===================================================================================== +bool GEOMBase_Context::PrepareSubShapeSelectionArgumentShape(const TopoDS_Shape& aShape,const int SubShapeType, Standard_Integer& returnLocalContextId ) +{ + //* Test the type of viewer */ + if(myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + return false; + + if(aShape.IsNull()) + return false ; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + /* local context opening */ + this->SetDisplayedObjectList(); + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayOnly(); + + returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ; + + Handle(GEOM_AISShape) Shape = new GEOM_AISShape(aShape, ""); + ic->Display(Shape, 0, (8 - SubShapeType)); + + // Not Load(...) but Display(...) + // ic->Load(Shape, (8 - SubShapeType), Standard_True); + ic->HilightWithColor(Shape, Quantity_NOC_RED); + + myDesktop->putInfo(tr("GEOM_PRP_SELECT_SUBSHAPES")); + return true; +} + + +//======================================================================= +// function : GetNameOfSelectedIObjects() +// purpose : Define the name geom++ or other name of mono or multi sel. +//======================================================================= +int GEOMBase_Context::GetNameOfSelectedIObjects(SALOME_Selection* Sel, QString& aName) +{ + int nbSel = Sel->IObjectCount(); + if(nbSel == 1) { + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + aName = IObject->getName(); + } + else { + aName = tr("%1_objects").arg(nbSel); + } + return nbSel; +} + + +//======================================================================= +// function : ConvertIOinGEOMAISShape() +// purpose : +//======================================================================= +Handle(GEOM_AISShape) GEOMBase_Context::ConvertIOinGEOMAISShape(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult, bool onlyInActiveView) +{ + Handle(GEOM_AISShape) res; + int nbSf = myActiveStudy->getStudyFramesCount(); + for(int i = 0; i < nbSf; i++) { + QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); + if(sf->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + AIS_ListOfInteractive List; + ic->DisplayedObjects(List); + AIS_ListOfInteractive List1; + ic->ObjectsInCollector(List1); + List.Append(List1); + + AIS_ListIteratorOfListOfInteractive ite(List); + while(ite.More()) { + if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); + if(aSh->hasIO()) { + Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); + if(GIO->isSame(IO)) { + if(onlyInActiveView) { + if(sf == myActiveStudy->getActiveStudyFrame()) { + testResult = true; + return aSh; + } + } + else { + testResult = true; + return aSh; + } + } + } + } + ite.Next(); + } + } + } + testResult = false; + return res; +} + + +//======================================================================= +// function : ConvertIORinGEOMAISShape() +// purpose : +//======================================================================= +Handle(GEOM_AISShape) GEOMBase_Context::ConvertIORinGEOMAISShape(const char * IOR, Standard_Boolean& testResult, bool onlyInActiveView) +{ + Handle(GEOM_AISShape) resultShape; + testResult = false; + int nbSf = myActiveStudy->getStudyFramesCount(); + for(int i = 0; i < nbSf; i++) { + QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); + if(sf->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + AIS_ListOfInteractive List; + ic->DisplayedObjects(List); + AIS_ListOfInteractive List1; + ic->ObjectsInCollector(List1); + List.Append(List1); + + AIS_ListIteratorOfListOfInteractive ite(List); + while(ite.More()) { + if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); + if(aSh->hasIO()) { + Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); + Standard_CString theIOR = GIO->getIOR(); + if(strcmp(IOR, theIOR) == 0) { + if(onlyInActiveView) { + if(sf == myActiveStudy->getActiveStudyFrame()) { + testResult = true; + resultShape = aSh; + return resultShape; + } + } + else { + testResult = true; + resultShape = aSh; + return resultShape; + } + } + } + } + ite.Next(); + } + } + } + return resultShape; +} + + +//======================================================================= +// function : ConvertIORinGEOMActor() +// purpose : +//======================================================================= +GEOM_Actor* GEOMBase_Context::ConvertIORinGEOMActor(const char* IOR, Standard_Boolean& testResult, bool onlyInActiveView) +{ + int nbSf = myActiveStudy->getStudyFramesCount(); + for(int i = 0; i < nbSf; i++) { + QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); + if(sf->getTypeView() == VIEW_VTK) { + vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* theActors = Renderer->GetActors(); + theActors->InitTraversal(); + vtkActor *ac = theActors->GetNextActor(); + while(!(ac==NULL)) { + if( ac->IsA("GEOM_Actor")) { + GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(ac); + if(anActor->hasIO()) { + Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(anActor->getIO()); + Standard_CString theIOR = GIO->getIOR(); + if(strcmp(IOR, theIOR) == 0) { + if(onlyInActiveView) { + if(sf == myActiveStudy->getActiveStudyFrame()) { + testResult = true; + return anActor; + } + } + else { + testResult = true; + return anActor; + } + } + } + } + ac = theActors->GetNextActor(); + } + } + } + testResult = false; + return GEOM_Actor::New(); +} + + +//======================================================================= +// function : ConvertIOinGEOMShape() +// purpose : +//======================================================================= +GEOM::GEOM_Shape_ptr GEOMBase_Context::ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) +{ + GEOM::GEOM_Shape_ptr aShape; + testResult = false; + + /* case SObject */ + if(IO->hasEntry()) { + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID(IO->getEntry()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if(!obj->_is_nil()) { + if(obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + aShape = myComponentGeom->GetIORFromString(anIOR->Value()); + testResult = true; + return aShape; + } + } + } + /* case Graphical Object */ + if(IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject))) { + Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast(IO); + Standard_CString ior = GIObject->getIOR(); + testResult = true; + aShape = myComponentGeom->GetIORFromString(ior); + return aShape; + } + return aShape; +} + + +//======================================================================= +// function : ConvertListOfIOInListOfIOR() +// purpose : +//======================================================================= +void GEOMBase_Context::ConvertListOfIOInListOfIOR(const SALOME_ListIO& aList, GEOM::GEOM_Gen::ListOfIOR& listIOR) +{ + int nbSel = aList.Extent(); + listIOR.length(nbSel); + int j=0; + SALOME_ListIteratorOfListIO It(aList); + for(int i=0; It.More(); It.Next(), i++) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + if(IObject->hasEntry()) { + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if(!obj->_is_nil() && obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + ORB_INIT &init = *SINGLETON_::Instance(); + CORBA::ORB_var& _orb = init.orb(); + CORBA::String_var theValue = anIOR->Value(); + CORBA::Object_var theObj = _orb->string_to_object(theValue); + if(theObj->_is_a("IDL:GEOM/GEOM_Shape:1.0")) { + listIOR[j] = strdup(theValue); + j++; + } + } + } + else if(IObject->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject))) { + Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast(IObject); + Standard_CString ior = GIObject->getIOR(); + listIOR[j] = strdup(ior); + j++; + } + } + listIOR.length(j); +} + + +//================================================================================= +// function : GetShapeTypeString() +// purpose : for a single shape +//================================================================================= +bool GEOMBase_Context::GetShapeTypeString(const TopoDS_Shape& aShape, Standard_CString& aTypeString) +{ + if(aShape.IsNull()) { + aTypeString = "aNullShape"; + return false; + } + switch(aShape.ShapeType()) + { + case TopAbs_COMPOUND: + { + aTypeString = strdup(tr("GEOM_COMPOUND")); + return true; + } + case TopAbs_COMPSOLID: + { + aTypeString = strdup(tr("GEOM_COMPOUNDSOLID")) ; + return true ; + } + case TopAbs_SOLID: + { + aTypeString = strdup(tr("GEOM_SOLID")) ; + return true ; + } + case TopAbs_SHELL: + { + aTypeString = strdup(tr("GEOM_SHELL")) ; + return true ; + } + case TopAbs_FACE: + { + BRepAdaptor_Surface surf(TopoDS::Face(aShape)); + if(surf.GetType() == GeomAbs_Plane) { + aTypeString = strdup(tr("GEOM_PLANE")); + return true; + } + else if(surf.GetType() == GeomAbs_Cylinder) { + aTypeString = strdup(tr("GEOM_SURFCYLINDER")); + return true; + } + else if(surf.GetType() == GeomAbs_Sphere) { + aTypeString = strdup(tr("GEOM_SURFSPHERE")); + return true ; + } + else if(surf.GetType() == GeomAbs_Torus) { + aTypeString = strdup(tr("GEOM_SURFTORUS")); + return true ; + } + else if(surf.GetType() == GeomAbs_Cone) { + aTypeString = strdup(tr("GEOM_SURFCONE")); + return true ; + } + else { + aTypeString = strdup(tr("GEOM_FACE")); + return true; + } + } + case TopAbs_WIRE: + { + aTypeString = strdup(tr("GEOM_WIRE")); + return true; + } + case TopAbs_EDGE: + { + BRepAdaptor_Curve curv(TopoDS::Edge(aShape)); + if(curv.GetType() == GeomAbs_Line) { + if((Abs(curv.FirstParameter()) >= 1E6) || (Abs(curv.LastParameter()) >= 1E6)) + aTypeString = strdup(tr("GEOM_LINE")); + else + aTypeString = strdup(tr("GEOM_EDGE")); + return true; + } + else if(curv.GetType() == GeomAbs_Circle) { + if(curv.IsClosed()) + aTypeString = strdup(tr("GEOM_CIRCLE")); + else + aTypeString = strdup(tr("GEOM_ARC")); + return true; + } + else { + aTypeString = strdup(tr("GEOM_EDGE")); + return true; + } + } + case TopAbs_VERTEX: + { + aTypeString = strdup(tr("GEOM_VERTEX")); + return true; + } + case TopAbs_SHAPE: + { + aTypeString = strdup(tr("GEOM_SHAPE")); + return true; + } + } + return false; +} + + +//================================================================================= +// function : CreateArrowForLinearEdge() +// purpose : Create a cone topology to be used to display an arrow in the middle +// : of an edge showing its orientation. (For simulation and Viewer OCC only) +//================================================================================= +bool GEOMBase_Context::CreateArrowForLinearEdge(const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone) +{ + if(myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC || tds.ShapeType() != TopAbs_EDGE) + return false; + + OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort(); + Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView(); + Standard_Real Width, Height; + view3d->Size(Width, Height); + const Standard_Real aHeight = (Width + Height) / 50.0; + + try { + Standard_Real first, last; + Handle(Geom_Curve) curv = BRep_Tool::Curve(TopoDS::Edge(tds), first, last); + if(!curv->IsCN(1)) + return false; + + const Standard_Real param = (first+last) / 2.0; + gp_Pnt middleParamPoint; + gp_Vec V1; + curv->D1( param, middleParamPoint, V1); + if(V1.Magnitude() < Precision::Confusion()) + return false; + + /* Topology orientation not geom orientation */ + if(tds.Orientation() == TopAbs_REVERSED) + V1 *= -1.0; + + gp_Ax2 anAxis( middleParamPoint, gp_Dir(V1)); + const Standard_Real radius1 = aHeight / 5.0; + if(radius1 > 10.0 * Precision::Confusion() && aHeight > 10.0 * Precision::Confusion()) { + ArrowCone = BRepPrimAPI_MakeCone( anAxis, radius1, 0.0, aHeight ).Shape(); + return true; + } + } + catch(Standard_Failure) { + // OCC failures are hard to catch in GUI. + // This because of the position for #include that is very critic to find + // in SALOME environment : compilation error ! + } + return false; +} + + +//======================================================================= +// function : SelectionByNameInDialogs() +// purpose : Called when user has entered a name of object in a LineEdit. +// : The selection is changed. Dialog box will receive the +// : corresponding signal to manage this event. +//======================================================================= +bool GEOMBase_Context::SelectionByNameInDialogs(QWidget* aWidget, const QString& objectUserName, SALOME_Selection* Sel) +{ + /* Find SObject with name in component GEOM */ + SALOMEDS::Study_var ST = this->myActiveStudy->getStudyDocument(); + SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject; + listSO = ST->FindObjectByName(objectUserName, "GEOM"); + + if(listSO->length() < 1) { + const QString caption = tr("GEOM_WRN_WARNING"); + const QString text = tr("GEOM_NAME_INCORRECT"); + const QString button0 = tr("GEOM_BUT_OK"); + QMessageBox::warning(aWidget, caption, text, button0); + return false; + } + /* More than one object with same name */ + if(listSO->length() > 1) { + const QString caption = tr("GEOM_WRN_WARNING"); + const QString text = tr("GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE"); + const QString button0 = tr("GEOM_BUT_OK") ; + QMessageBox::warning(aWidget, caption, text, button0) ; + return false; + } + + SALOMEDS::SObject_var theObj = listSO[0]; + /* Create a SALOME_InteractiveObject with a SALOME::SObject */ + Standard_CString anEntry = theObj->GetID(); + Handle(SALOME_InteractiveObject) SI = new SALOME_InteractiveObject(anEntry, "GEOM", strdup(objectUserName)); + + /* Add as a selected object */ + /* Clear any previous selection : */ + /* Warning the LineEdit is purged because of signal currentSelectionChanged ! */ + Sel->ClearIObjects(); + Sel->AddIObject(SI); + return true; +} + + +//======================================================================= +// function : SetState() +// purpose : Sets myState = aState a private field indicating which methode is active +//======================================================================= +void GEOMBase_Context::SetState(int aState) +{ + this->myState = aState; + return; +} + + +//======================================================================= +// function : ResetState() +// purpose : Sets myState = -1 a private field indicating which methode is active +//======================================================================= +void GEOMBase_Context::ResetState() +{ + this->myState = -1; + return; +} + + +//======================================================================= +// function : EmitSignalDeactivateDialog() +// purpose : Emit a signal to deactivate the active dialog Box +//======================================================================= +void GEOMBase_Context::EmitSignalDeactivateDialog() +{ + emit this->SignalDeactivateActiveDialog(); + return; +} + + +//======================================================================= +// function : EmitSignalCloseAllDialogs() +// purpose : Emit a signal to deactivate all non modal dialogs box +//======================================================================= +void GEOMBase_Context::EmitSignalCloseAllDialogs() +{ + emit this->SignalCloseAllDialogs(); + return; +} + + +//======================================================================= +// function : EmitSignalDefaultStepValueChanged() +// purpose : +//======================================================================= +void GEOMBase_Context::EmitSignalDefaultStepValueChanged(double newVal) +{ + emit this->SignalDefaultStepValueChanged(newVal); + return; +} + + +//======================================================================= +// function : SetActiveDialogBox() +// purpose : +//======================================================================= +void GEOMBase_Context::SetActiveDialogBox(QDialog* aDlg) +{ + this->myActiveDialogBox = (QDialog*)aDlg; + return; +} + + +//===================================================================================== +// function : GetIndexSubShapeSelected() +// purpose : Define a ListOfID of sub shapes selected in ShapeTopo with SubShapeType +// : Method used by Dialogs +//===================================================================================== +bool GEOMBase_Context::GetIndexSubShapeSelected(const TopoDS_Shape& ShapeTopo, const int SubShapeType, GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID, Standard_Integer& aLocalContextId, bool& myUseLocalContext) +{ + //* Test the type of viewer */ + if(this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + return false; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + ic->InitSelected(); + int nbSelected = ic->NbSelected(); + ListOfID.length(nbSelected); + + //***************** DEFINE INDEX OF EACH SELECTION *********************// + int i = 0; + ic->InitSelected(); /* to restart */ + while(ic->MoreSelected()) { + /* Find index of sub shape into main shape */ + TopExp_Explorer Exp (ShapeTopo, TopAbs_ShapeEnum(SubShapeType)); + int index = 1; + bool found = false; + while( Exp.More()) { + if((Exp.Current()).IsSame(ic->SelectedShape())) { + found = true; + break; + } + index++; + Exp.Next(); + } + if(!found) { + /* Manage local context from DialogBox */ + ic->CloseLocalContext(aLocalContextId); + myUseLocalContext = false; + return false; + } + ListOfID[i] = index; + i++; + ic->NextSelected(); + } + //***************** END *********************// + + /* Manage local context from DialogBox */ + ic->CloseLocalContext(aLocalContextId); + myUseLocalContext = false; + + return true; +} + + +//======================================================================= +// function : DefineDlgPosition() +// purpose : Define x and y the default position for a dialog box +//======================================================================= +bool GEOMBase_Context::DefineDlgPosition(QWidget* aDlg, int& x, int& y) +{ + /* Here the position is on the bottom right corner - 10 */ + QAD_Desktop* PP = QAD_Application::getDesktop(); + x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10); + y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10); + return true; +} + + +//======================================================================= +// function : ConvertClickToPoint() +// purpose : Returns the point clicked in 3D view +//======================================================================= +gp_Pnt GEOMBase_Context::ConvertClickToPoint(Standard_Real x, Standard_Real y, Handle(V3d_View) aView) +{ + V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt; + aView->Eye(XEye, YEye, ZEye); + + aView->At(XAt, YAt, ZAt); + gp_Pnt EyePoint(XEye, YEye, ZEye); + gp_Pnt AtPoint(XAt, YAt, ZAt); + + gp_Vec EyeVector(EyePoint, AtPoint); + gp_Dir EyeDir(EyeVector); + + gp_Pln PlaneOfTheView = gp_Pln(AtPoint,EyeDir); + Standard_Real X, Y, Z; + aView->Convert(x, y, X, Y, Z); + gp_Pnt ConvertedPoint(X, Y, Z); + + gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfTheView, ConvertedPoint); + gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView); + return ResultPoint; +} + + +//================================================================================ +// function : SetDisplayedObjectList() +// purpose : +//================================================================================ +void GEOMBase_Context::SetDisplayedObjectList() +{ + if(myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + return; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + myListDisplayedObject.Clear(); + + Handle (AIS_InteractiveContext) aContext = v3d->getAISContext(); + aContext->DisplayedObjects(myListDisplayedObject); +} + + +//===================================================================================== +// function : DisplaySimulationShape() +// purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape +//===================================================================================== +void GEOMBase_Context::DisplaySimulationShape(const TopoDS_Shape& S) +{ + if( S.IsNull() ) + return ; + + //NRI DEBUG : 14/02/2002 + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + return ; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + try { + /* erase any previous */ + ic->Erase( this->mySimulationShape, Standard_True, Standard_False ); + ic->ClearPrs( this->mySimulationShape ); + this->mySimulationShape = new AIS_Shape( TopoDS_Shape() ) ; + this->mySimulationShape->Set( S ) ; + this->mySimulationShape->SetColor(Quantity_NOC_VIOLET) ; + ic->Deactivate( this->mySimulationShape ); + ic->Display( this->mySimulationShape, Standard_False ); + ic->UpdateCurrentViewer(); + } + catch(Standard_Failure) { + MESSAGE( "Exception catched in GEOMBase_Context::DisplaySimulationShape " ) ; + } + this->mySimulationShape->UnsetColor() ; + return ; +} + + + +//================================================================================== +// function : EraseSimulationShape() +// purpose : Clears the display of 'mySimulationShape' a pure graphical shape +//================================================================================== +void GEOMBase_Context::EraseSimulationShape() +{ + int count = myActiveStudy->getStudyFramesCount(); + for ( int i = 0; i < count; i++ ) { + if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + ic->Erase( this->mySimulationShape, Standard_True, Standard_False ); + ic->ClearPrs( this->mySimulationShape ); + ic->UpdateCurrentViewer(); + + } else if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_VTK ) { // VTK + } + } + // MESSAGE ( " GEOMBase_Context::EraseSimulationShape done. " ) +} + + +//===================================================================================== +// function : Display() +// purpose : Displays a CORBA shape +//===================================================================================== +bool GEOMBase_Context::Display(GEOM::GEOM_Shape_ptr aShape, Standard_CString name) +{ + // MESSAGE ( "GEOMBase_Context::Display init ") + Handle(GEOM_InteractiveObject) IO; + SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + Sel->ClearIObjects(); + + if(aShape->_is_nil()) { + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), + tr ("GEOM_WRN_WARNING"), + tr ("GEOM_PRP_ABORT"), + tr ("GEOM_BUT_OK") ); + return false ; + } + + TopoDS_Shape shape = myShapeReader.GetShape(myComponentGeom, aShape); + + if ( shape.IsNull() ) + return false; + + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributePixMap_var aPixmap; + + SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM"); + int aLocked = false; + if (father->_is_nil()) { + QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); + op->start(); + aLocked = aStudy->GetProperties()->IsLocked(); + if (aLocked) aStudy->GetProperties()->SetLocked(false); + father = aStudyBuilder->NewComponent("GEOM"); + anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + // aName->SetValue( tr("GEOM_MEN_COMPONENT") ); + aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) ); + anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" ); + myActiveStudy->updateObjBrowser(); + if (aLocked) aStudy->GetProperties()->SetLocked(true); + op->finish(); + } +// if (aLocked) return false; + + aStudyBuilder->DefineComponentInstance( father, myComponentGeom ); + father->ComponentIOR( myFatherior ); + + TCollection_AsciiString nameG(""); + Standard_CString Type; + if ( TCollection_AsciiString(name).IsEqual(Standard_CString("")) ) { + if ( TCollection_AsciiString(aShape->NameType()).IsEqual(Standard_CString("")) ) { + Standard_CString type; + GetShapeTypeString(shape,type); + aShape->NameType( type ); + nameG += TCollection_AsciiString( type ) + TCollection_AsciiString("_") + + TCollection_AsciiString( myNbGeom++ ) + TCollection_AsciiString("\0"); + } else + nameG += TCollection_AsciiString( aShape->NameType()) + TCollection_AsciiString("_") + + TCollection_AsciiString( myNbGeom++ ) + TCollection_AsciiString("\0"); + } else + nameG = TCollection_AsciiString(name); + + // VTK + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + int themode = myRenderInter->GetDisplayMode(); + + vtkActorCollection* theActors = + GEOM_AssemblyBuilder::BuildActors(shape,0,themode,Standard_True); + theActors->InitTraversal(); + vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); + + IO = new GEOM_InteractiveObject(aShape->Name(), + myFatherior, + "GEOM"); + while(!(anActor==NULL)) { + GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor ); + GActor->setIO( IO ); + GActor->setName( nameG.ToCString() ); + + theRenderer->AddActor(GActor); + anActor = (vtkActor*)theActors->GetNextActor(); + } + } + // OCC + else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + Handle(GEOM_AISShape) theResult = new GEOM_AISShape( shape, nameG.ToCString() ); + theResult->SetShadingColor( myShadingColor ); + IO = new GEOM_InteractiveObject(aShape->Name(), + myFatherior, + "GEOM"); + theResult->setIO( IO ); + theResult->setName( nameG.ToCString() ); + + /* Precaution : close any local context to permit the display */ + if ( ic->HasOpenedContext() ) { + ic->CloseAllContexts(); + } + +// if(isInfinite) +// theResult->SetInfiniteState() ; + + ic->Display(theResult); + } + + Sel->AddIObject( IO, false ); + myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Repaint(); + if ( mySettings_AddInStudy ) + AddInStudy( false, IO ); + + return true; +} + + +//===================================================================================== +// function : AddInStudy() +// purpose : anIOShape or a selected shape +//===================================================================================== +bool GEOMBase_Context::AddInStudy(bool selection, const Handle(SALOME_InteractiveObject)& anIO) +{ + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + if ( !( !mySettings_AddInStudy || selection ) ) { + Sel->ClearIObjects(); + } + + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributePixMap_var aPixmap; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributeSelectable_var aSelAttr; + + SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM"); + int aLocked = false; + if (father->_is_nil()) { + QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); + op->start(); + aLocked = aStudy->GetProperties()->IsLocked(); + if (aLocked) aStudy->GetProperties()->SetLocked(false); + father = aStudyBuilder->NewComponent("GEOM"); + anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + // aName->SetValue( tr("GEOM_MEN_COMPONENT") ); + aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) ); + anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" ); + if (aLocked) aStudy->GetProperties()->SetLocked(true); + op->finish(); + } +// if (aLocked) return false; + + aStudyBuilder->DefineComponentInstance( father, myComponentGeom ); + father->ComponentIOR( myFatherior ); + + SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry()); + + Handle(GEOM_AISShape) GAISShape; + GEOM_Actor* GActor; + Handle(GEOM_InteractiveObject) GIO; + bool found = false; + + // VTK + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + vtkRenderer *Renderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + + vtkActorCollection* theActors = Renderer->GetActors(); + theActors->InitTraversal(); + vtkActor *ac = theActors->GetNextActor(); + while(!(ac==NULL)) { + if ( ac->IsA("GEOM_Actor") ) { + GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( ac ); + if ( anActor->hasIO() ) { + Handle(SALOME_InteractiveObject) IO = anActor->getIO(); + if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) { + GIO = Handle(GEOM_InteractiveObject)::DownCast( IO ); + if ( anIO->isSame( GIO ) ) { + found = true; + GActor = anActor; + break; + } + } + } + } + ac = theActors->GetNextActor(); + } + + if ( !found ) + return false; + } + // OCC + else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + AIS_ListOfInteractive List; + ic->DisplayedObjects(List); + AIS_ListIteratorOfListOfInteractive ite(List); + while (ite.More()) { + if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); + if ( aSh->hasIO() ) { + Handle(SALOME_InteractiveObject) IO = aSh->getIO(); + if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) { + GIO = Handle(GEOM_InteractiveObject)::DownCast( IO ); + if ( anIO->isSame( GIO ) ) { + found = true; + GAISShape = aSh; + break; + } + } + } + } + ite.Next(); + } + + if ( !found ) + return false; + } + + if ( !mySettings_AddInStudy || selection ) { + QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), anIO->getName() ); + if ( !Name.isEmpty() ) { + // VTK + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + GActor->setName( strdup(Name.latin1()) ); + } + // OCC + else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + GAISShape->setName( strdup(Name.latin1()) ); + } + } else { + return false; + } + } + + // open transaction + QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); + op->start(); + + SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(father); + + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GIO->getIOR() ); + + /* For the shape inserted into the study we set its field 'studyshapeid' */ + /* so the shape will contain its corresponding entry in the study Ocaf doc. */ + aShape->StudyShapeId(newObj->GetID()) ; + + GIO->setEntry(newObj->GetID()); + + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIOR->SetValue(aShape->Name()); + + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + if ( aShape->ShapeType() == GEOM::COMPOUND ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" ); + } else if ( aShape->ShapeType() == GEOM::COMPSOLID ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" ); + } else if ( aShape->ShapeType() == GEOM::SOLID ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" ); + } else if ( aShape->ShapeType() == GEOM::SHELL ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" ); + } else if ( aShape->ShapeType() == GEOM::FACE ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" ); + } else if ( aShape->ShapeType() == GEOM::WIRE ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" ); + } else if ( aShape->ShapeType() == GEOM::EDGE ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" ); + } else if ( aShape->ShapeType() == GEOM::VERTEX ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" ); + } + + // VTK + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + GActor->setIO( GIO ); + aName->SetValue(GActor->getName()); + } + // OCC + else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + GAISShape->setIO( GIO ); + aName->SetValue(GAISShape->getName()); + } + + SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); + aStudyBuilder->Addreference(newObj1,newObj); + + GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR; + listIOR = myComponentGeom->GetReferencedObjects(aShape); + + if (listIOR->length()>0) { + SALOMEDS::SObject_var Arguments = aStudyBuilder->NewObject(newObj); + anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(tr("GEOM_ARGUMENTS")); + anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + + bool ObjectReferenced = false; + for (unsigned int ind = 0; ind < listIOR->length();ind++) { + SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(listIOR[ind]); + + if ( !theObj->_is_nil() ) { + SALOMEDS::SObject_var RefObject = aStudyBuilder->NewObject(Arguments); + aStudyBuilder->Addreference(RefObject, theObj); + ObjectReferenced = true; + } + } + + if ( !ObjectReferenced ) + aStudyBuilder->RemoveObject(Arguments); + } + + op->finish(); + + + if ( !mySettings_AddInStudy || selection ) { + myActiveStudy->updateObjBrowser(); + } else { + myActiveStudy->updateObjBrowser(false); + Sel->AddIObject( GIO ); + } + + // MESSAGE ( " highlihght done" ) + return true; + +} + + +//===================================================================================== +// function : GetShapeFromIOR() +// purpose : exist also as static method ! +//===================================================================================== +TopoDS_Shape GEOMBase_Context::GetShapeFromIOR( QString IOR ) +{ + TopoDS_Shape result; + if( IOR.stripWhiteSpace().isEmpty() ) + return result; + ORB_INIT &init = *SINGLETON_::Instance() ; + CORBA::ORB_var& _orb = init.orb() ; + CORBA::Object_var obj = _orb->string_to_object( (char*)(IOR.latin1()) ); + if ( CORBA::is_nil( obj ) ) + return result; + GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( IOR ); + if (!aShape->_is_nil()) { + result = myShapeReader.GetShape( myComponentGeom, aShape ); + } + return result; +} + + + +//======================================================================= +// function : Parameter() +// purpose : return a parameter (float) from a dialog box +// +// avalue1 : is a float or integer used as a default value displayed +// aTitle1 : is the title for aValue1 +// aTitle : is the main title +// bottom : maximum value to be entered +// top : minimum value to be entered +// decimals : number of decimals +//======================================================================= +double GEOMBase_Context::Parameter(Standard_Boolean& res, const char* aValue1, const char* aTitle1, const char* aTitle, const double bottom, const double top, const int decimals) +{ + GEOMBase_aParameterDlg * Dialog = new GEOMBase_aParameterDlg(aValue1, aTitle1, QAD_Application::getDesktop(), aTitle, TRUE, 0, bottom, top, decimals); + int r = Dialog->exec(); + float X = 0.0; + if(r == QDialog::Accepted) { + res = Standard_True; + X = Dialog->getValue(); + } + else + res = Standard_False; + delete Dialog; + return X; +} + + +//===================================================================================== +// function : SObjectExist() +// purpose : +//===================================================================================== +bool GEOMBase_Context::SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR) { + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(theFatherObject); + SALOMEDS::SObject_var RefSO; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + for(; it->More();it->Next()) { + SALOMEDS::SObject_var SO= it->Value(); + if(SO->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + if(strcmp( anIOR->Value(), IOR ) == 0) + return true; + } + if(SO->ReferencedObject(RefSO)) { + if(RefSO->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + if(strcmp(anIOR->Value(), IOR) == 0) + return true; + } + } + } + return false; +} diff --git a/src/GEOMBase/GEOMBase_Context.h b/src/GEOMBase/GEOMBase_Context.h new file mode 100644 index 000000000..035f6e03f --- /dev/null +++ b/src/GEOMBase/GEOMBase_Context.h @@ -0,0 +1,195 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_Context.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef GEOMBASE_CONTEXT_H +#define GEOMBASE_CONTEXT_H + +// SALOME Includes +#include "QAD_Desktop.h" +#include "QAD_Application.h" + +#include "SALOME_Selection.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + +#include "GEOM_InteractiveObject.hxx" +#include "GEOM_AISShape.hxx" +#include "GEOM_Actor.h" +#include "GEOM_Sketcher.h" +#include "GEOM_Client.hxx" +#include "GEOM_ShapeTypeFilter.hxx" + +// Open CASCADE Includes +#include +#include +#include +#include +#include + +// QT Includes +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + + +//================================================================================= +// +//================================================================================= +enum {POINT_METHOD, CURRENT_SKETCH}; + + +//================================================================================= +// class : GEOMBase_Context +// purpose : +//================================================================================= +class GEOMBase_Context : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + GEOMBase_Context(); + ~GEOMBase_Context(); + +private : + int myNbGeom; /* Unique name for a geom entity */ + int myState; /* Identify a method */ + + QAD_Desktop* myDesktop; + QAD_Study* myActiveStudy; + QDialog* myActiveDialogBox; /* Unique active dialog box */ + + GEOM::GEOM_Gen_var myComponentGeom; + GEOM_Client myShapeReader; + Standard_CString myFatherior; + AIS_ListOfInteractive myListDisplayedObject; + Quantity_Color myShadingColor; + + Sketch mySketcher; + + Handle(AIS_Shape) mySimulationShape; /* AIS shape used only during topo/geom simulations */ + vtkActorCollection* mySimulationActor; /* GEOM Actor used only during topo/geom simulations */ + + bool mySettings_AddInStudy; + bool mySettings_Copy; + +public : + static GEOMBase_Context* GetOrCreateGeomGUI(QAD_Desktop* desktop); + static GEOMBase_Context* GetGeomGUI(); + + static int GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int ShapeType); + static bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P); + static bool GetShapeTypeString(const TopoDS_Shape& aShape, Standard_CString& aTypeString); + static bool LinearEdgeExtremities(const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2); + static gp_Pnt ConvertClickToPoint(Standard_Real x, Standard_Real y, Handle(V3d_View) aView); + /* User dialog 1 parameter returned */ + static double Parameter(Standard_Boolean& res, + const char* aValue1 = 0, const char* aTitle1 = 0, + const char* aTitle = 0, const double bottom = -1E6, + const double top = +1E6, const int decimals = 6); + void GetBipointDxDyDz(gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz); + + int& GetNbGeom(){return myNbGeom;}; + int& GetState(){return myState;}; + QAD_Desktop* GetDesktop(){return myDesktop;}; + QAD_Study* GetActiveStudy(){return myActiveStudy;}; + QDialog* GetActiveDialogBox(){return myActiveDialogBox ;}; /* Returns the active DialogBox */ + + GEOM_Client& GetShapeReader(){return myShapeReader;}; + Standard_CString& GetFatherior(){return myFatherior;}; + AIS_ListOfInteractive& GetListDisplayedObject(){return myListDisplayedObject;}; + Quantity_Color& GetShadingColor(){return myShadingColor;}; + + Handle(AIS_Shape)& GetSimulationShape(){return mySimulationShape;}; + bool& GetSettings_AddInStudy(){return mySettings_AddInStudy;}; + bool& GetSettings_Copy(){return mySettings_Copy;}; + + Sketch& GetSketcher(){return mySketcher;}; + + void SetState(int aState); + void ResetState(); /* Sets myState = -1 a private field to indicate wich method is active */ + bool AddInStudy(bool selection = false, const Handle(SALOME_InteractiveObject)& anIO = 0); + void SetActiveDialogBox(QDialog* aDlg); /* Sets 'myActiveDialogBox' a pointer to the active Dialog Box */ + + bool DefineDlgPosition(QWidget* aDlg, int& x, int& y); + bool SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR); + + /* Selection and objects management */ + TopoDS_Shape GetShapeFromIOR(QString IOR); + bool GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds); + int GetNameOfSelectedIObjects(SALOME_Selection* Sel, QString& aName); + GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject)& IO, + Standard_Boolean& testResult); + Handle(GEOM_AISShape) ConvertIOinGEOMAISShape(const Handle(SALOME_InteractiveObject)& IO, + Standard_Boolean& testResult, + bool onlyInActiveView = false); + Handle(GEOM_AISShape) ConvertIORinGEOMAISShape(const char * IOR, + Standard_Boolean& testResult, + bool onlyInActiveView = false); + GEOM_Actor* ConvertIORinGEOMActor(const char * IOR, Standard_Boolean& testResult, + bool onlyInActiveView = false); + void ConvertListOfIOInListOfIOR(const SALOME_ListIO& aList, + GEOM::GEOM_Gen::ListOfIOR& listIOR); + + /* Method used by dialog boxes called when used has entered a name of object in a LineEdit */ + bool SelectionByNameInDialogs(QWidget* aWidget, const QString& userObjectName, SALOME_Selection *Sel); + + /* Method opening context for any sub shape selection */ + bool PrepareSubShapeSelection(const int SubShapeType, Standard_Integer& returnLocalContextId); + /* Method opening context for sub shape selection on an argument shape */ + bool PrepareSubShapeSelectionArgumentShape(const TopoDS_Shape& aShape, const int SubShapeType, + Standard_Integer& returnLocalContextId); + /* Define a list of indices of sub shapes selected in a local context */ + bool GetIndexSubShapeSelected(const TopoDS_Shape& ShapeTopo, const int SubShapeType, + GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID, + Standard_Integer& aLocalContextId, bool& myUseLocalContext); + + void SetDisplayedObjectList(); + bool Display(GEOM::GEOM_Shape_ptr aShape, Standard_CString name = ""); + + /* Simulation management */ + bool CreateArrowForLinearEdge(const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone); + void DisplaySimulationShape(const TopoDS_Shape& S); + void EraseSimulationShape(); + + /* Non modal dialog boxes magement */ + void EmitSignalDeactivateDialog(); + void EmitSignalCloseAllDialogs(); + void EmitSignalDefaultStepValueChanged(double newVal); + +signals : + void SignalDeactivateActiveDialog(); + void SignalCloseAllDialogs(); + void SignalDefaultStepValueChanged(double newVal); + +}; + +#endif + diff --git a/src/GEOMBase/GEOMBase_Display.cxx b/src/GEOMBase/GEOMBase_Display.cxx new file mode 100644 index 000000000..79d17e78c --- /dev/null +++ b/src/GEOMBase/GEOMBase_Display.cxx @@ -0,0 +1,637 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_Display.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "GEOMBase_Display.h" + +#include "QAD_RightFrame.h" +#include "GEOM_AssemblyBuilder.h" +#include "VTKViewer_ViewFrame.h" +#include "OCCViewer_ViewFrame.h" +#include "OCCViewer_Viewer3d.h" + +#include "SALOMEGUI_ImportOperation.h" +#include "SALOME_ListIteratorOfListIO.hxx" +#include + +//======================================================================= +// function : DisplayGUI() +// purpose : Constructor +//======================================================================= +GEOMBase_Display::GEOMBase_Display() : + QObject() +{ + myGeomGUI = GEOMBase_Context::GetGeomGUI(); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); +} + + +//======================================================================= +// function : ~GEOMBase_Display() +// purpose : Destructor +//======================================================================= +GEOMBase_Display::~GEOMBase_Display() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool GEOMBase_Display::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + switch (theCommandID) + { + case 6021: // SHADING/WIREFRAME - MENU + { + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + QApplication::setOverrideCursor(waitCursor); + + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + int themode = myRenderInter->GetDisplayMode(); + if(themode==0) { + myRenderInter->SetDisplayMode(1); + myGeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME")); + } + else { + myRenderInter->SetDisplayMode(0); + myGeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING")); + } + + QApplication::restoreOverrideCursor(); + } + else if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + QApplication::setOverrideCursor(Qt::waitCursor); + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); + AIS_DisplayMode mode = (AIS_DisplayMode)ic->DisplayMode(); + AIS_DisplayMode newmode = (mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame); + + AIS_ListOfInteractive List; + ic->DisplayedObjects(List); + AIS_ListOfInteractive List1; + ic->ObjectsInCollector(List1); + List.Append(List1); + + AIS_ListIteratorOfListOfInteractive ite(List); + while(ite.More()) { + if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); + ic->SetDisplayMode(aSh,Standard_Integer(newmode),true); + } + ite.Next(); + } + + ic->SetDisplayMode(newmode, Standard_False); + if(newmode == 1) + myGeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME")); + else + myGeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING")); + + QApplication::restoreOverrideCursor(); + } + break; + } + case 6022: // DISPLAY ALL - MENU + { + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) + ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->DisplayAll(); + else if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) + this->OnDisplayAll(); + break; + } + case 6024: // ERASE ALL - MENU + { + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) + ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->EraseAll(); + else if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); + + ic->EraseAll(Standard_True, Standard_False); + ic->Display(v3d->getTrihedron()); + } + break; + } + case 8021: // WIREFRAME/SHADING - POPUP VIEWER + { + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + // VTK + VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + + QApplication::setOverrideCursor(Qt::waitCursor); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + myRenderInter->SwitchRepresentation(IOS, false); + } + myRenderInter->Render(); + QApplication::restoreOverrideCursor(); + } + else if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + QApplication::setOverrideCursor(Qt::waitCursor); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean found; + Handle(GEOM_AISShape) Shape = myGeomGUI->ConvertIOinGEOMAISShape(IObject, found, true); + if(!Shape.IsNull()) { + AIS_DisplayMode mode = (AIS_DisplayMode)Shape->DisplayMode(); + if(mode == -1) + mode = (AIS_DisplayMode)ic->DisplayMode(); + + QApplication::setOverrideCursor(Qt::waitCursor); + ic->SetDisplayMode(Shape, mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame, false); + } + QApplication::restoreOverrideCursor(); + } + ic->UpdateCurrentViewer(); + } + QApplication::restoreOverrideCursor(); + break; + } + case 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)); + break; + } + } + return true; +} + + +//===================================================================================== +// function : OnDisplayAll() +// purpose : +//===================================================================================== +void GEOMBase_Display::OnDisplayAll(bool onlyPreviousDisplayedObject) +{ + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + return; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); + + myContext->Display(v3d->getTrihedron()); + + if(!onlyPreviousDisplayedObject) { + AIS_ListOfInteractive List1; + myContext->ObjectsInCollector(List1); + AIS_ListIteratorOfListOfInteractive ite1(List1); + while(ite1.More()) { + if(ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value()); + if(aSh->hasIO()) { + Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); + if(v3d->isInViewer(GIO, true)) { + myContext->Display(aSh); + } + } + } + ite1.Next(); + } + } + else { + AIS_ListIteratorOfListOfInteractive ite(myGeomGUI->GetListDisplayedObject()); + while(ite.More()) { + if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); + if (aSh->hasIO()) { + Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); + if (v3d->isInViewer(GIO,true)) { + myContext->Display(aSh); + } + } + } + ite.Next(); + } + } + return; +} + + +//===================================================================================== +// function : OnVTKDisplayOnly() +// purpose : +//===================================================================================== +void GEOMBase_Display::OnVTKDisplayOnly() +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + + // Erase all not selected actors + vtkRenderer* aren = ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* theActors = aren->GetActors(); + theActors->InitTraversal(); + vtkActor *ac = theActors->GetNextActor(); + while(!(ac==NULL)) { + if(ac->IsA("SALOME_Actor")) { + SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(ac); + if(!anActor->isHighlighted()) + anActor->VisibilityOff(); + } + ac = theActors->GetNextActor(); + } + + // Display selection + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + 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; + + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); + + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + if(myRenderInter->isInViewer(IObject)) { + myRenderInter->Display(IObject); + } + else { + // Create new actor + if(!obj->_is_nil()) { + if(!obj->FindAttribute(anAttr, "AttributeIOR")) + break; + // If selected object contains displayable subobjects, then do nothing + SALOMEDS::ChildIterator_var anIter = myGeomGUI->GetActiveStudy()->getStudyDocument()->NewChildIterator(obj); + SALOMEDS::GenericAttribute_var aTmpAttr; + + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value()); + if(CORBA::is_nil(aShape)) continue; + TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); + + if(obj->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + // 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(); + + vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + 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); + GActor->setIO(IObject); + GActor->setName(IObject->getName()); + + theRenderer->AddActor(GActor); + vtkRenderWindow *renWin + = ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()->GetRenderWindow(); + renWin->Render(); + anActor = (vtkActor*)theActors->GetNextActor(); + } + } + } + } + } + myGeomGUI->GetActiveStudy()->updateObjBrowser(true); + + QApplication::restoreOverrideCursor(); + return; +} + + +//===================================================================================== +// function : OnDisplayOnly() +// purpose : +//===================================================================================== +void GEOMBase_Display::OnDisplayOnly() +{ + if (myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + return; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + AIS_ListOfInteractive List; + ic->DisplayedObjects(List); + AIS_ListIteratorOfListOfInteractive ite(List); + while(ite.More()) { + if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); + if (!ic->IsSelected( aSh )) { + ic->Erase(aSh, Standard_True, Standard_True); + } + } + ite.Next(); + } + + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + SALOME_ListIteratorOfListIO It1(Sel->StoredIObjects()); + for(;It1.More();It1.Next()) { + Handle(SALOME_InteractiveObject) IObject = It1.Value(); + + SALOMEDS::SObject_var fatherSF = + aStudy->FindObjectID(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->entry()); + if(v3d->isInViewer(IObject, true)) { + AIS_ListOfInteractive List1; + ic->ObjectsInCollector(List1); + AIS_ListIteratorOfListOfInteractive ite1(List1); + while(ite1.More()) { + if(ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value()); + if (aSh->hasIO()) { + Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); + if (IObject->isSame(GIO)) { + ic->Display(aSh); + ic->AddOrRemoveCurrentObject(aSh, true); + break; + } + } + } + ite1.Next(); + } + } + else { + if (IObject->hasEntry()) { + SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + if (!obj->_is_nil()) { + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + // this SObject may be GEOM module root SObject + + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value()); + if(CORBA::is_nil(aShape)) continue; + TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); + + if(obj->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + // 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()); + 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); + ic->AddOrRemoveCurrentObject(aSh, true); + } + } + } + } + } +} + + +//===================================================================================== +// function : OnErase() +// purpose : +//===================================================================================== +void GEOMBase_Display::OnErase() +{ + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + // VTK + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + Handle(SALOME_InteractiveObject) anIObject; + for(;It.More();It.Next()) { + anIObject = It.Value(); + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + if(myRenderInter->isInViewer(anIObject)) { + myRenderInter->Erase(anIObject); + } + else { + SALOMEDS::SObject_var obj = aStudy->FindObjectID(anIObject->getEntry()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if(!obj->_is_nil()) { + if(obj->FindAttribute(anAttr, "AttributeIOR")) { + // this SObject may be GEOM module root SObject + SALOMEDS::ChildIterator_var anIter = myGeomGUI->GetActiveStudy()->getStudyDocument()->NewChildIterator(obj); + bool useSubItems = false; + while(anIter->More() && !useSubItems) { + SALOMEDS::SObject_var subobj = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttr; + if(subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { + anAttr = aTmpAttr; + obj = subobj; + useSubItems = true; + } + else + anIter->Next(); + } + + while(useSubItems?anIter->More():!anAttr->_is_nil()) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value()); + TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); + if(obj->FindAttribute(anAttr, "AttributeName")) { + // searchin for already displayed objects with the same shape + 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->Erase(anIObj); + } + } + } + actor=(vtkActor*)(theAllActors->GetNextActor()); + } + } + if(useSubItems) { + anIter->Next(); + anAttr=SALOMEDS::GenericAttribute::_nil(); + while(anIter->More() && anAttr->_is_nil()) { + SALOMEDS::SObject_var subobject = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttribute; + if(subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { + anAttr = aTmpAttribute; + obj = subobject; + } + else + anIter->Next(); + } + } + else + anAttr = SALOMEDS::GenericAttribute::_nil(); + } + } + } + } + } + } + else if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + // OCC + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + Handle(SALOME_InteractiveObject) anIObject; + for(;It.More();It.Next()) { + anIObject = It.Value(); + if(v3d->isInViewer(anIObject, true)) { + Standard_Boolean found; + Handle(GEOM_AISShape) aSh = myGeomGUI->ConvertIOinGEOMAISShape(anIObject, found, true); + if(found) { + ic->Erase(aSh); + ic->AddOrRemoveCurrentObject(aSh, true); + } + } + else { + SALOMEDS::SObject_var obj = aStudy->FindObjectID(anIObject->getEntry()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if(!obj->_is_nil()) { + if(obj->FindAttribute(anAttr, "AttributeIOR")) { + // this SObject may be GEOM module root SObject + SALOMEDS::ChildIterator_var anIter = myGeomGUI->GetActiveStudy()->getStudyDocument()->NewChildIterator(obj); + bool useSubItems = false; + while(anIter->More() && !useSubItems) { + SALOMEDS::SObject_var subobj = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttr; + if(subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { + anAttr = aTmpAttr; + obj = subobj; + useSubItems = true; + } + else + anIter->Next(); + } + + while(useSubItems?anIter->More():!anAttr->_is_nil()) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value()); + TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); + if(obj->FindAttribute(anAttr, "AttributeName")) { + // searchin for already displayed objects with the same shape + AIS_ListOfInteractive aDisplayed; + ic->DisplayedObjects(aDisplayed); + AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); + Handle(AIS_Shape) anAISShape; + for(;anIObjects.More();anIObjects.Next()) { + anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); + if(!anAISShape.IsNull()) { + if(anAISShape->Shape().IsSame(Shape)) + break; + anAISShape.Nullify(); + } + } + if(!anAISShape.IsNull()) { + if(ic->IsDisplayed(anAISShape)) + ic->Erase(anAISShape); + } + } + if(useSubItems) { + anIter->Next(); + anAttr=SALOMEDS::GenericAttribute::_nil(); + while(anIter->More() && anAttr->_is_nil()) { + SALOMEDS::SObject_var subobject = anIter->Value(); + SALOMEDS::GenericAttribute_var aTmpAttribute; + if(subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { + anAttr = aTmpAttribute; + obj = subobject; + } + else + anIter->Next(); + } + } + else + anAttr = SALOMEDS::GenericAttribute::_nil(); + } + } + } + } + } + } + Sel->ClearIObjects(); +} diff --git a/src/GEOMBase/GEOMBase_Display.h b/src/GEOMBase/GEOMBase_Display.h new file mode 100644 index 000000000..928fedf70 --- /dev/null +++ b/src/GEOMBase/GEOMBase_Display.h @@ -0,0 +1,59 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_Display.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef GEOMBASE_DISPLAY_H +#define GEOMBASE_DISPLAY_H + +#include "GEOMBase_Context.h" + +//================================================================================= +// class : GEOMBase_Display +// purpose : +//================================================================================= +class GEOMBase_Display : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + GEOMBase_Display(); + ~GEOMBase_Display(); + + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + + void OnDisplayAll(bool onlyPreviousDisplayedObject = false); + void OnVTKDisplayOnly(); + void OnDisplayOnly(); + void OnErase(); + +private: + GEOMBase_Context* myGeomGUI; + GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + +}; + +#endif diff --git a/src/GEOMBase/GEOMBase_NbIsosDlg.cxx b/src/GEOMBase/GEOMBase_NbIsosDlg.cxx new file mode 100644 index 000000000..1827bc487 --- /dev/null +++ b/src/GEOMBase/GEOMBase_NbIsosDlg.cxx @@ -0,0 +1,135 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_NbIsosDlg.cxx +// Author : +// Module : GEOM +// $Header: + +using namespace std; +#include "GEOMBase_NbIsosDlg.h" +#include "GEOMBase_Context.h" +#include "QAD_Tools.h" + +#include +#include +#include +#include +#include + +//================================================================================= +// class : GEOMBase_NbIsosDlg() +// purpose : Constructs a GEOMBase_NbIsosDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +GEOMBase_NbIsosDlg::GEOMBase_NbIsosDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "GEOMBase_NbIsosDlg" ); + setCaption( name ); + setSizeGripEnabled( TRUE ); + QGridLayout* MyDialogLayout = new QGridLayout( this ); + MyDialogLayout->setSpacing( 6 ); + MyDialogLayout->setMargin( 11 ); + + /***************************************************************/ + QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + TextLabel1 = new QLabel( GroupC1, "TextLabel1" ); + TextLabel1->setText( tr( "GEOM_MEN_ISOU") ); + GroupC1Layout->addWidget( TextLabel1, 0, 0 ); + + SpinBoxU = new QSpinBox( GroupC1, "SpinBoxU" ); + SpinBoxU->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + SpinBoxU->setMinValue( 1 ); + SpinBoxU->setValue( 1 ); + GroupC1Layout->addWidget( SpinBoxU, 0, 1 ); + + TextLabel2 = new QLabel( GroupC1, "TextLabel2" ); + TextLabel2->setText( tr( "GEOM_MEN_ISOV") ) ; + GroupC1Layout->addWidget( TextLabel2, 0, 2 ); + + SpinBoxV = new QSpinBox( GroupC1, "SpinBoxV"); + SpinBoxV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + SpinBoxV->setValue( 1 ); + SpinBoxV->setMinValue( 1 ); + GroupC1Layout->addWidget( SpinBoxV, 0, 3 ); + + /***************************************************************/ + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "GEOM_BUT_OK" ) ) ; + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + + GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) ) ; + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + /***************************************************************/ + + MyDialogLayout->addWidget( GroupC1, 0, 0 ); + MyDialogLayout->addWidget( GroupButtons, 1, 0 ); + + /* Retrieve GeomGUI */ + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + /* Move widget on the botton right corner of main widget */ + QAD_Tools::centerWidget( this, parent ); +} + + +//================================================================================= +// function : ~GEOMBase_NbIsosDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +GEOMBase_NbIsosDlg::~GEOMBase_NbIsosDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/GEOMBase/GEOMBase_NbIsosDlg.h b/src/GEOMBase/GEOMBase_NbIsosDlg.h new file mode 100644 index 000000000..392662718 --- /dev/null +++ b/src/GEOMBase/GEOMBase_NbIsosDlg.h @@ -0,0 +1,61 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_NbIsosDlg.h +// Author : +// Module : GEOM +// $Header: + +#ifndef GEOMBASE_NBISOSDLG_H +#define GEOMBASE_NBISOSDLG_H + +#include + +class QLabel; +class QSpinBox; +class QPushButton; +class GEOMBase_Context; + +//================================================================================= +// class : GEOMBase_NbIsosDlg +// purpose : +//================================================================================= +class GEOMBase_NbIsosDlg : public QDialog +{ + Q_OBJECT + +public: + GEOMBase_NbIsosDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~GEOMBase_NbIsosDlg(); + + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + + QPushButton* buttonOk; + QPushButton* buttonCancel; + QLabel* TextLabel1 ; + QLabel* TextLabel2 ; + QSpinBox* SpinBoxU ; + QSpinBox* SpinBoxV ; +}; + +#endif // GEOMETRYGUI_NBISOSDLG_H diff --git a/src/GEOMBase/GEOMBase_Skeleton.cxx b/src/GEOMBase/GEOMBase_Skeleton.cxx new file mode 100644 index 000000000..4ae077053 --- /dev/null +++ b/src/GEOMBase/GEOMBase_Skeleton.cxx @@ -0,0 +1,172 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_Skeleton.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "GEOMBase_Skeleton.h" + +//================================================================================= +// class : GEOMBase_Skeleton() +// purpose : Constructs a GEOMBase_Skeleton which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +GEOMBase_Skeleton::GEOMBase_Skeleton(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) + :DlgRef_Skeleton_QTD(parent, name, modal, fl) +{ + if (!name) + setName("GEOMBase_Skeleton"); + + buttonCancel->setText(tr("GEOM_BUT_CLOSE")); + buttonOk->setText(tr("GEOM_BUT_OK")); + buttonApply->setText(tr("GEOM_BUT_APPLY")); + + GroupMedium->close(TRUE); + resize(0, 0); + + Init(Sel); +} + + +//================================================================================= +// function : ~GEOMBase_Skeleton() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +GEOMBase_Skeleton::~GEOMBase_Skeleton() +{ + // no need to delete child widgets, Qt does it all for us + this->destroy(TRUE, TRUE); +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void GEOMBase_Skeleton::Init(SALOME_Selection* Sel) +{ + /* init variables */ + mySelection = Sel; + mySimulationTopoDs.Nullify(); + + myGeomGUI = GEOMBase_Context::GetGeomGUI(); + myGeomGUI->SetActiveDialogBox((QDialog*)this); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); + + /* signals and slots connections */ + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); + connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + 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 ); + + /* displays Dialog */ + RadioButton1->setChecked(TRUE); + + return; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void GEOMBase_Skeleton::ClickOnCancel() +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + mySelection->ClearFilters(); + disconnect(mySelection, 0, this, 0); + + myGeomGUI->ResetState(); + reject(); + + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void GEOMBase_Skeleton::LineEditReturnPressed() +{ + /* 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; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void GEOMBase_Skeleton::DeactivateActiveDialog() +{ + this->setEnabled(false); + mySelection->ClearFilters(); + disconnect(mySelection, 0, this, 0); + myGeomGUI->EraseSimulationShape(); + myGeomGUI->SetActiveDialogBox(0); + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void GEOMBase_Skeleton::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog(); + this->setEnabled(true); + myGeomGUI->SetActiveDialogBox((QDialog*)this); + return; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void GEOMBase_Skeleton::closeEvent(QCloseEvent* e) +{ + /* same than click on cancel button */ + this->ClickOnCancel(); + return; +} diff --git a/src/GEOMBase/GEOMBase_Skeleton.h b/src/GEOMBase/GEOMBase_Skeleton.h new file mode 100644 index 000000000..bb2ed8a35 --- /dev/null +++ b/src/GEOMBase/GEOMBase_Skeleton.h @@ -0,0 +1,71 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_Skeleton.h +// Author : Damine COQUERET +// Module : GEOM +// $Header: + +#ifndef GEOMBASE_SKELETON_H +#define GEOMBASE_SKELETON_H + +#include "DlgRef_Skeleton_QTD.h" + +#include "GEOMBase_Context.h" + +#include +#include +#include +#include +#include +#include + +class GEOMBase_Skeleton : public DlgRef_Skeleton_QTD +{ + Q_OBJECT + +public: + GEOMBase_Skeleton(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~GEOMBase_Skeleton(); + +private : + void Init(SALOME_Selection* Sel); + +protected: + void closeEvent(QCloseEvent* e); + + TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + SALOME_Selection* mySelection; /* User shape selection */ + GEOM::GEOM_Gen_var myGeom; /* Current GeomI object */ + GEOMBase_Context* myGeomGUI; /* Current GeomGUI object */ + +protected slots: + void ClickOnCancel(); + void LineEditReturnPressed(); + void DeactivateActiveDialog(); + void ActivateThisDialog(); + +}; + +#endif // GEOMBASE_SKELETON_H diff --git a/src/GEOMBase/GEOMBase_Sketcher.cxx b/src/GEOMBase/GEOMBase_Sketcher.cxx new file mode 100644 index 000000000..d30ecba6a --- /dev/null +++ b/src/GEOMBase/GEOMBase_Sketcher.cxx @@ -0,0 +1,547 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_Sketcher.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "GEOMBase_Sketcher.h" + +#include "QAD_RightFrame.h" +#include "OCCViewer_Viewer3d.h" + +#include +#include +#include +#include +#include + +//======================================================================= +// function : GEOMBase_Sketcher() +// purpose : Constructor +//======================================================================= +GEOMBase_Sketcher::GEOMBase_Sketcher() : + QObject() +{ + myGeomGUI = GEOMBase_Context::GetGeomGUI(); + Engines::Component_var comp = myGeomGUI->GetDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); + mySketcher = myGeomGUI->GetSketcher(); +} + + +//======================================================================= +// function : ~GEOMBase_Sketcher() +// purpose : Destructor +//======================================================================= +GEOMBase_Sketcher::~GEOMBase_Sketcher() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool GEOMBase_Sketcher::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + return false; + + myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + QMenuBar* Mb = myGeomGUI->GetDesktop()->getMainMenuBar(); + QMenuData* pp; + + switch (theCommandID) + { + case 312: // SKETCHER + { + ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTop(); // DCQ : 28/02/2002 + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + + mySketcher = Sketch(v3d->getViewer3d()); + myGeomGUI->SetState(CURRENT_SKETCH); + + QMenuItem* item = Mb->findItem(10010, &pp); + mySketcher.SetParameterVisibility(LENGTH_PARAMETER, pp->isItemChecked(10010)); + item = Mb->findItem(10011, &pp); + mySketcher.SetParameterVisibility(ANGLE_PARAMETER, pp->isItemChecked(10011)); + item = Mb->findItem(10012, &pp); + mySketcher.SetParameterVisibility(RADIUS_PARAMETER, pp->isItemChecked(10012)); + item = Mb->findItem(10013, &pp); + mySketcher.SetParameterVisibility(XVALUE_PARAMETER, pp->isItemChecked(10013)); + item = Mb->findItem(10014, &pp); + mySketcher.SetParameterVisibility(YVALUE_PARAMETER, pp->isItemChecked(10014)); + + mySketcher.SetTransitionStatus(NOCONSTRAINT); + item = Mb->findItem(3133, &pp); + pp->setItemChecked(3133, false); + item = Mb->findItem(3134, &pp); + pp->setItemChecked(3134, false); + break; + } + case 3133: // sketcher + { + QMenuItem* item = Mb->findItem(3133, &pp); + pp->setItemChecked(3133, !pp->isItemChecked(3133)); + if (pp->isItemChecked(3133) == true) + mySketcher.SetTransitionStatus(TANGENT); + else + mySketcher.SetTransitionStatus(NOCONSTRAINT); + + pp->setItemChecked(3134, false); + break; + } + case 3134: // sketcher + { + QMenuItem* item = Mb->findItem(3134, &pp); + pp->setItemChecked(3134,!pp->isItemChecked(3134)); + if (pp->isItemChecked(3134) == true) + mySketcher.SetTransitionStatus(PERPENDICULAR); + else + mySketcher.SetTransitionStatus(NOCONSTRAINT); + + pp->setItemChecked(3133, false); + break; + } + case 10000 : // SKETCH Segment + { + mySketcher.ChangeMode(SEGMENT); + break; + } + case 10001 : // SKETCH Arc + { + mySketcher.ChangeMode(ARC_CHORD); + break; + } + case 10002 : // SKETCH Set Angle + { + OnSketchSetAngle(); + break; + } + case 10003 : // SKETCH Set X + { + OnSketchSetx(); + break; + } + case 10004 : // SKETCH Set Y + { + OnSketchSety(); + break; + } + case 10006 : // SKETCH Delete + { + OnSketchDelete(); + break; + } + case 10007 : // SKETCH End + { + OnSketchEnd(); + break; + } + case 10008 : // SKETCH Close + { + OnSketchClose(); + break; + } + case 10010 : // SKETCH OptionsOnofflengthdimension + { + OnSketchOptionsOnofflengthdimension(); + break; + } + case 10011 : // SKETCH OptionsOnoffangledimension + { + OnSketchOptionsOnoffangledimension(); + break; + } + case 10012 : // SKETCH OptionsOnoffradiusdimension + { + OnSketchOptionsOnoffradiusdimension(); + break; + } + case 10013 : // SKETCH OptionsOnoffxdimension + { + OnSketchOptionsOnoffxdimension(); + break; + } + case 10014 : // SKETCH OptionsOnoffydimension + { + OnSketchOptionsOnoffydimension(); + break; + } + default: + { + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + } + return true; +} + + +//======================================================================= +// function : OnSketchSetAngle() +// purpose : +//======================================================================= +void GEOMBase_Sketcher::OnSketchSetAngle() +{ + Standard_Real anAngle = mySketcher.GetSegmentAngle()/PI180; + Sketch::fitInResol(anAngle); + Standard_Boolean res = false; + QString Value = QString("%1").arg(anAngle); + anAngle = myGeomGUI->Parameter(res, Value, tr("GEOM_MEN_ANGLE"), tr("GEOM_MEN_ENTER_ANGLE"), + -180.0, +180.0, 6) * PI180; + + if(res) { + mySketcher.SetSegmentAngle(anAngle); + QMenuBar* Mb = myGeomGUI->GetDesktop()->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(3133, &pp); + pp->setItemChecked(3133, false); + item = Mb->findItem(3134, &pp); + pp->setItemChecked(3134, false); + } + return; +} + + +//======================================================================= +// function : OnSketchSetx() +// purpose : +//======================================================================= +void GEOMBase_Sketcher::OnSketchSetx() +{ + Standard_Boolean res = false; + double X = myGeomGUI->Parameter(res, "0.", tr("GEOM_MEN_X"), tr("GEOM_MEN_SKETCHER_X"), + 2.0 * Precision::Confusion(), 1E6, 6); + if(res) + mySketcher.SetXDimension(X); + QMenuBar* Mb = myGeomGUI->GetDesktop()->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(3133, &pp); + pp->setItemChecked(3133, false); + item = Mb->findItem(3134, &pp); + pp->setItemChecked(3134, false); + return; +} + + +//======================================================================= +// function : OnSketchSety() +// purpose : +//======================================================================= +void GEOMBase_Sketcher::OnSketchSety() +{ + Standard_Boolean res = false; + double Y = myGeomGUI->Parameter(res, "0.", tr("GEOM_MEN_Y"), tr("GEOM_MEN_SKETCHER_Y"), + 2.0 * Precision::Confusion(), 1E6, 6); + if(res) + mySketcher.SetYDimension(Y); + QMenuBar* Mb = myGeomGUI->GetDesktop()->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(3133, &pp); + pp->setItemChecked(3133, false); + item = Mb->findItem(3134, &pp); + pp->setItemChecked(3134, false); + return; +} + + +//======================================================================= +// function : OnSketchDelete() +// purpose : +//======================================================================= +void GEOMBase_Sketcher::OnSketchDelete() +{ + if(mySketcher.GetmyEdgesNumber() == 1) { + QMenuBar* Mb = myGeomGUI->GetDesktop()->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(313, &pp); + pp->setItemEnabled(313, false); // SKETCH CONTRAINTS + mySketcher.SetTransitionStatus(NOCONSTRAINT); + } + + if(mySketcher.Delete()) + myGeomGUI->ResetState(); + return; +} + + +//======================================================================= +// function : OnSketchClose() +// purpose : +//======================================================================= +void GEOMBase_Sketcher::OnSketchClose() +{ + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle(AIS_InteractiveContext) myContext = v3d->getAISContext(); + + TopoDS_Wire W = mySketcher.Close(); + if(!W.IsNull()) { + GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR; + listShapes->length(0); + unsigned int i = 0; + + BRepTools_WireExplorer Ex(W); + while(Ex.More()) { + TopoDS_Edge E = Ex.Current(); + gp_Pnt pt1, pt2; + + pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E)); + pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E)); + + gp_Pnt CenterPoint; + Handle(Geom_Curve) Curve; + Handle(Geom_Circle) Circle; + gp_Circ Circ; + Standard_Real First,Last; + + Curve = BRep_Tool::Curve(E,First,Last); + if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) { + Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ + Circ = Circle->Circ(); // gp_Circ + + Curve->D0((First + Last) / 2., CenterPoint); + + GEOM::PointStruct pI = myGeom->MakePointStruct(pt1.X(), pt1.Y(), pt1.Z()); + GEOM::PointStruct pC = myGeom->MakePointStruct(CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z()); + GEOM::PointStruct pE = myGeom->MakePointStruct(pt2.X(), pt2.Y(), pt2.Z()); + + GEOM::GEOM_Shape_var arc; + + try { + arc = myGeom->MakeArc(pI, pC, pE); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + + listShapes->length(i+1); + listShapes[i] = strdup(arc->Name()); + i++; + } + else { + GEOM::PointStruct pI = myGeom->MakePointStruct(pt1.X(), pt1.Y(), pt1.Z()); + GEOM::PointStruct pE = myGeom->MakePointStruct(pt2.X(), pt2.Y(), pt2.Z()); + GEOM::GEOM_Shape_var segment; + + try { + segment = myGeom->MakeEdge(pI,pE); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + + listShapes->length(i+1); + listShapes[i] = strdup(segment->Name()); + i++; + } + Ex.Next(); + } + GEOM::GEOM_Shape_var Wire = myGeom->MakeWire(listShapes); + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, Wire); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + Wire->NameType(type); + + if(myGeomGUI->Display(Wire)) + QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + myGeomGUI->ResetState(); + QMenuBar* Mb = myGeomGUI->GetDesktop()->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(313, &pp); + pp->setItemEnabled(313, false); // SKETCH CONTRAINTS + mySketcher.SetTransitionStatus(NOCONSTRAINT); + return; +} + + +//======================================================================= +// function : OnSketchEnd() +// purpose : +//======================================================================= +void GEOMBase_Sketcher::OnSketchEnd() +{ + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); + + TopoDS_Wire W = mySketcher.End(); + if(!W.IsNull()) { + GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR; + listShapes->length(0); + unsigned int i = 0; + + BRepTools_WireExplorer Ex(W); + while(Ex.More()) { + TopoDS_Edge E = TopoDS::Edge(Ex.Current()); + + gp_Pnt pt1, pt2; + pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E)); + pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E)); + + gp_Pnt CenterPoint; + Handle(Geom_Curve) Curve; + Handle(Geom_Circle) Circle; + gp_Circ Circ; + Standard_Real First,Last; + + Curve = BRep_Tool::Curve(E,First,Last); + if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) { + Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ + Circ = Circle->Circ(); // gp_Circ + + Curve->D0((First + Last) / 2., CenterPoint); + + GEOM::PointStruct pI = myGeom->MakePointStruct(pt1.X(), pt1.Y(), pt1.Z()); + GEOM::PointStruct pC = myGeom->MakePointStruct(CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z()); + GEOM::PointStruct pE = myGeom->MakePointStruct(pt2.X(), pt2.Y(), pt2.Z()); + + GEOM::GEOM_Shape_var arc; + + try { + arc = myGeom->MakeArc(pI, pC, pE); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + + listShapes->length(i+1); + listShapes[i] = strdup(arc->Name()); + i++; + } else { + GEOM::PointStruct pI = myGeom->MakePointStruct(pt1.X(), pt1.Y(), pt1.Z()); + GEOM::PointStruct pE = myGeom->MakePointStruct(pt2.X(), pt2.Y(), pt2.Z()); + GEOM::GEOM_Shape_var segment; + + try { + segment = myGeom->MakeEdge(pI,pE); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + + listShapes->length(i+1); + listShapes[i] = strdup(segment->Name()); + i++; + } + Ex.Next(); + } + + GEOM::GEOM_Shape_var Wire = myGeom->MakeWire(listShapes); + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, Wire); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + Wire->NameType(type); + + if(myGeomGUI->Display(Wire)) + QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + myGeomGUI->ResetState(); + QMenuBar* Mb = myGeomGUI->GetDesktop()->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(313, &pp); + pp->setItemEnabled(313, false); // SKETCH CONTRAINTS + mySketcher.SetTransitionStatus(NOCONSTRAINT); + return; +} + + +//======================================================================= +// function : OnSketchOptionsOnoffangledimension() +// purpose : +//======================================================================= +void GEOMBase_Sketcher::OnSketchOptionsOnoffangledimension() +{ + QMenuBar* Mb = myGeomGUI->GetDesktop()->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(10011, &pp); + pp->setItemChecked(10011, !pp->isItemChecked(10011)); + mySketcher.SetParameterVisibility(ANGLE_PARAMETER, pp->isItemChecked(10011)); + return; +} + + +//======================================================================= +// function : OnSketchOptionsOnofflengthdimension() +// purpose : +//======================================================================= +void GEOMBase_Sketcher::OnSketchOptionsOnofflengthdimension() +{ + QMenuBar* Mb = myGeomGUI->GetDesktop()->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(10010, &pp); + pp->setItemChecked(10010, !pp->isItemChecked(10010)); + mySketcher.SetParameterVisibility(LENGTH_PARAMETER, pp->isItemChecked(10010)); + return; +} + + +//======================================================================= +// function : OnSketchOptionsOnoffradiusdimension() +// purpose : +//======================================================================= +void GEOMBase_Sketcher::OnSketchOptionsOnoffradiusdimension() +{ + QMenuBar* Mb = myGeomGUI->GetDesktop()->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(10012, &pp); + pp->setItemChecked(10012, !pp->isItemChecked(10012)); + mySketcher.SetParameterVisibility(RADIUS_PARAMETER, pp->isItemChecked(10012)); + return; +} + + +//======================================================================= +// function : OnSketchOptionsOnoffxdimension() +// purpose : +//======================================================================= +void GEOMBase_Sketcher::OnSketchOptionsOnoffxdimension() +{ + QMenuBar* Mb = myGeomGUI->GetDesktop()->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(10013, &pp); + pp->setItemChecked(10013, !pp->isItemChecked(10013)); + mySketcher.SetParameterVisibility(XVALUE_PARAMETER, pp->isItemChecked(10013)); + return; +} + + +//======================================================================= +// function : OnSketchOptionsOnoffydimension() +// purpose : +//======================================================================= +void GEOMBase_Sketcher::OnSketchOptionsOnoffydimension() +{ + QMenuBar* Mb = myGeomGUI->GetDesktop()->getMainMenuBar(); + QMenuData* pp; + QMenuItem* item = Mb->findItem(10014, &pp); + pp->setItemChecked(10014, !pp->isItemChecked(10014)); + mySketcher.SetParameterVisibility(YVALUE_PARAMETER, pp->isItemChecked(10014)); + return; +} diff --git a/src/GEOMBase/GEOMBase_Sketcher.h b/src/GEOMBase/GEOMBase_Sketcher.h new file mode 100644 index 000000000..5e794839f --- /dev/null +++ b/src/GEOMBase/GEOMBase_Sketcher.h @@ -0,0 +1,70 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_Sketcher.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef GEOMBASE_SKETCHER_H +#define GEOMBASE_SKETCHER_H + +#include "GEOMBase_Context.h" + +//================================================================================= +// class : GEOMBase_Sketcher +// purpose : +//================================================================================= +class GEOMBase_Sketcher : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + GEOMBase_Sketcher(); + ~GEOMBase_Sketcher(); + + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + + /* Sketcher management */ + void OnSketchSetAngle(); + void OnSketchSetx(); + void OnSketchSety(); + + void OnSketchDelete(); + void OnSketchClose(); + void OnSketchEnd(); + + void OnSketchOptionsOnoffangledimension(); + void OnSketchOptionsOnofflengthdimension(); + void OnSketchOptionsOnoffradiusdimension(); + void OnSketchOptionsOnoffxdimension(); + void OnSketchOptionsOnoffydimension(); + +private: + GEOMBase_Context* myGeomGUI; + GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + Sketch mySketcher; + +}; + +#endif diff --git a/src/GEOMBase/GEOMBase_Tools.cxx b/src/GEOMBase/GEOMBase_Tools.cxx new file mode 100644 index 000000000..57c95c919 --- /dev/null +++ b/src/GEOMBase/GEOMBase_Tools.cxx @@ -0,0 +1,1121 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_Tools.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "GEOMBase_Tools.h" + +#include "QAD_Config.h" +#include "QAD_FileDlg.h" +#include "QAD_Tools.h" +#include "QAD_MessageBox.h" +#include "QAD_RightFrame.h" + +#include "OCCViewer_Viewer3d.h" +#include "VTKViewer_ViewFrame.h" +#include "GEOM_AssemblyBuilder.h" + +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOMEGUI_NameDlg.h" +#include "SALOMEGUI_ImportOperation.h" + +#include +#include +#include + +#include +#include + +#include "GEOMBase_NbIsosDlg.h" // Method ISOS adjustement +#include "GEOMBase_TransparencyDlg.h" // Method TRANSPARENCY adjustement + +//======================================================================= +// function : GEOMBase_Tools() +// purpose : Constructor +//======================================================================= +GEOMBase_Tools::GEOMBase_Tools() : + QObject() +{ + myGeomGUI = GEOMBase_Context::GetGeomGUI(); + Engines::Component_var comp = myGeomGUI->GetDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); +} + + +//======================================================================= +// function : ~GEOMBase_Tools() +// purpose : Destructor +//======================================================================= +GEOMBase_Tools::~GEOMBase_Tools() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool GEOMBase_Tools::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + QMenuBar* Mb = myGeomGUI->GetDesktop()->getMainMenuBar(); + QMenuData* pp; + + 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) + { + case 31: // COPY + { + this->OnEditCopy(); + break; + } + case 33: // DELETE + { + this->OnEditDelete(); + break; + } + case 111: // IMPORT BREP + { + myGeomGUI->SetState(111); + this->Import(); + myGeomGUI->ResetState(); + break; + } + case 112: // IMPORT IGES + { + myGeomGUI->SetState(112); + this->Import(); + myGeomGUI->ResetState(); + break; + } + case 113: // IMPORT STEP + { + myGeomGUI->SetState(113); + this->Import(); + myGeomGUI->ResetState(); + break; + } + case 121: // EXPORT BREP + { + myGeomGUI->SetState(121); + this->Export(); + myGeomGUI->ResetState(); + break; + } + case 122: // EXPORT IGES + { + myGeomGUI->SetState(122); + this->Export(); + myGeomGUI->ResetState(); + break; + } + case 123: // EXPORT STEP + { + myGeomGUI->SetState(123); + this->Export(); + myGeomGUI->ResetState(); + break; + } + case 701: // SETTINGS - COPY + { + QMenuItem* item = parent->menuBar()->findItem(701, &pp); + bool check = !pp->isItemChecked(701); + pp->setItemChecked(701, check); + myGeomGUI->GetSettings_Copy() = check; + QAD_CONFIG->addSetting("Geometry:SettingsCopy", myGeomGUI->GetSettings_Copy()); + break; + } + case 702: // SETTINGS - ADD IN STUDY + { + QMenuItem* item = parent->menuBar()->findItem(702, &pp); + bool check = !pp->isItemChecked(702); + pp->setItemChecked(702,check); + myGeomGUI->GetSettings_AddInStudy() = check; + QAD_CONFIG->addSetting("Geometry:SettingsAddInStudy", myGeomGUI->GetSettings_AddInStudy()); + break; + } + case 703: // SETTINGS - SHADING COLOR + { + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + break; + + QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed"); + QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen"); + QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue"); + QColor color; + if(!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) { + color = QColor (SCr.toInt(), SCg.toInt(), SCb.toInt()); + } else { + Quantity_Color Default = Quantity_Color(); + color = QColor ((int)Default.Red() * 255.0, + (int)Default.Green()* 255.0, + (int)Default.Blue() * 255.0); + } + + QColor c = QColorDialog::getColor(color, myGeomGUI->GetDesktop()); + if(c.isValid()) { + 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); + AIS_ListOfInteractive List1; + ic->ObjectsInCollector(List1); + List.Append(List1); + + AIS_ListIteratorOfListOfInteractive ite(List); + while(ite.More()) { + if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); + aSh->SetShadingColor(myGeomGUI->GetShadingColor()); + ic->Redisplay(aSh, Standard_True, Standard_True); + } + ite.Next(); + } + + ic->UpdateCurrentViewer(); + + QAD_CONFIG->addSetting("Geometry:SettingsShadingColorRed", c.red()); + QAD_CONFIG->addSetting("Geometry:SettingsShadingColorGreen", c.green()); + QAD_CONFIG->addSetting("Geometry:SettingsShadingColorBlue", c.blue()); + } + break; + } + case 704: // SETTINGS - ISOS + { + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + break; + + QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); + QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); + if(!IsoU.isEmpty()) + ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt()); + else + IsoU = "1"; + if (!IsoV.isEmpty()) + ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt()); + else + IsoV = "1"; + + GEOMBase_NbIsosDlg* NbIsosDlg = new GEOMBase_NbIsosDlg(myGeomGUI->GetDesktop(), + tr("GEOM_MEN_ISOS"), TRUE); + int UIso = IsoU.toInt(); + int VIso = IsoV.toInt(); + + NbIsosDlg->SpinBoxU->setValue(UIso); + NbIsosDlg->SpinBoxV->setValue(VIso); + + if(NbIsosDlg->exec()) { + UIso = NbIsosDlg->SpinBoxU->text().toInt(); + VIso = NbIsosDlg->SpinBoxV->text().toInt(); + + ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso); + ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso); + QAD_CONFIG->addSetting("Geometry:SettingsIsoU", NbIsosDlg->SpinBoxU->text()); /* text format */ + QAD_CONFIG->addSetting("Geometry:SettingsIsoV", NbIsosDlg->SpinBoxV->text()); /* text format */ + } + + AIS_ListOfInteractive List; + ic->DisplayedObjects(List); + AIS_ListOfInteractive List1; + ic->ObjectsInCollector(List1); + List.Append(List1); + + AIS_ListIteratorOfListOfInteractive ite(List); + ic->InitCurrent(); + if(ic->NbCurrents()) + while(ite.More()) { + if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); + Handle (AIS_Drawer) CurDrawer; + CurDrawer = aSh->Attributes(); + CurDrawer->UIsoAspect()->SetNumber(UIso); + CurDrawer->VIsoAspect()->SetNumber(VIso); + ic->SetLocalAttributes(aSh, CurDrawer); + ic->Redisplay(aSh); + } + ite.Next(); + } + ic->UpdateCurrentViewer(); + break; + } + case 705: // SETTINGS : STEP VALUE FOR SPIN BOXES + { + QString step = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + if(step.isEmpty()) + step = "100.0"; + + Standard_Boolean res = false; + double dd = myGeomGUI->Parameter(res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3); + if(res) { + QAD_CONFIG->addSetting("Geometry:SettingsGeomStep", QString("%1").arg(dd)); + + /* Emit signal to GeometryGUI_SpinBoxes */ + myGeomGUI->EmitSignalDefaultStepValueChanged(dd); + } + else + parent->putInfo(tr("GEOM_PRP_ABORT")); + break; + } + case 801: // ADD IN STUDY - POPUP VIEWER + { + const SALOME_ListIO& ListSelected = Sel->StoredIObjects(); + SALOME_ListIteratorOfListIO It(ListSelected); + for(; It.More(); It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + myGeomGUI->AddInStudy(true, IObject); + } + /* Is set on the dialog box */ + QApplication::restoreOverrideCursor(); + break; + } + case 901: // RENAME + { + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + for(; It.More(); It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + + SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if(!obj->_is_nil()) { + if(obj->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + + QString nm = QString(aName->Value()); + nm = SALOMEGUI_NameDlg::getName(myGeomGUI->GetDesktop(), nm); + if(!nm.isEmpty()) { + QApplication::setOverrideCursor(Qt::waitCursor); + myGeomGUI->GetActiveStudy()->renameIObject(IObject, nm); + QApplication::restoreOverrideCursor(); + } + } + } + } + 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 5001: // CHECK GEOMETRY + { + QAD_PyEditor* PyEditor = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getPyEditor(); + PyEditor->setText("from GEOM_usinggeom import *\n"); + PyEditor->setText(">>> "); + PyEditor->handleReturn(); + break; + } + case 8031: // COLOR - POPUP VIEWER + { + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + // VTK + VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + Handle(SALOME_InteractiveObject) FirstIOS = Sel->firstIObject(); + if(!FirstIOS.IsNull()) { + QColor initcolor = myRenderInter->GetColor(FirstIOS); + QColor c = QColorDialog::getColor( initcolor, myGeomGUI->GetDesktop()); + + if(c.isValid()) { + QApplication::setOverrideCursor(Qt::waitCursor); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + myRenderInter->SetColor(IOS,c); + } + } + QApplication::restoreOverrideCursor(); + } + } + else if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); + Standard_Boolean found; + Handle(GEOM_AISShape) Shape = myGeomGUI->ConvertIOinGEOMAISShape(IO, found, true); + if(found) { + Quantity_Color CSFColor; + Shape->Color(CSFColor); + + QColor c = QColorDialog::getColor(QColor(CSFColor.Red() * 255.0, + CSFColor.Green()* 255.0, + CSFColor.Blue() * 255.0), + myGeomGUI->GetDesktop()); + + if(c.isValid()) { + CSFColor = Quantity_Color (c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB); + QApplication::setOverrideCursor( Qt::waitCursor ); + + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean found; + Handle(GEOM_AISShape) Shape = myGeomGUI->ConvertIOinGEOMAISShape(IObject, found, true); + if(found) { + Shape->SetColor(CSFColor); + Shape->SetShadingColor(CSFColor); + } + } + } + } + } + QApplication::restoreOverrideCursor(); + break; + } + case 8032: // TRANSPARENCY - POPUP VIEWER + { + GEOMBase_TransparencyDlg *aDlg = new GEOMBase_TransparencyDlg(parent, "", Sel, ic); + break; + } + case 8033: // ISOS - POPUP VIEWER + { + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + break; + + ic->InitCurrent(); + if(ic->MoreCurrent()) { + Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); + QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); + QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); + + if(!IsoU.isEmpty()) + ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt()); + else + IsoU = "1"; + if (!IsoV.isEmpty()) + ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt()); + else + IsoV = "1"; + + GEOMBase_NbIsosDlg * NbIsosDlg = + new GEOMBase_NbIsosDlg(myGeomGUI->GetDesktop(), tr("GEOM_MEN_ISOS"), TRUE); + + NbIsosDlg->SpinBoxU->setValue(IsoU.toInt()); + NbIsosDlg->SpinBoxV->setValue(IsoV.toInt()); + + if(NbIsosDlg->exec()) { + QApplication::setOverrideCursor(Qt::waitCursor); + for(; ic->MoreCurrent(); ic->NextCurrent()) { + Handle(AIS_Drawer) CurDrawer; + + CurDrawer = ic->Current()->Attributes(); + CurDrawer->UIsoAspect()->SetNumber(NbIsosDlg->SpinBoxU->text().toInt()); + CurDrawer->VIsoAspect()->SetNumber(NbIsosDlg->SpinBoxV->text().toInt()); + + ic->SetLocalAttributes(CurObject, CurDrawer); + ic->Redisplay(CurObject); + } + } + } + QApplication::restoreOverrideCursor(); + break; + } + case 9024 : // OPEN - OBJBROSER POPUP + { + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + Handle(SALOME_InteractiveObject) anIObject; + for(;It.More();It.Next()) { + anIObject = It.Value(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID(anIObject->getEntry()); + SALOMEDS::AttributePersistentRef_var aPersist; + SALOMEDS::AttributeIOR_var anIOR; + if(!obj->_is_nil()) { + // this SObject may be GEOM module root SObject + SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(obj); + SALOMEDS::GenericAttribute_var anAttr; + bool useSubItems = false; + while (anIter->More() && !useSubItems) { + SALOMEDS::SObject_var subobj = anIter->Value(); + if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) { + useSubItems = true; + obj = subobj; + } + else + anIter->Next(); + } + obj->FindAttribute(anAttr, "AttributePersistentRef"); + + while(useSubItems?anIter->More():!anAttr->_is_nil()) { + if(!obj->FindAttribute(anAttr, "AttributeIOR") && + obj->FindAttribute(anAttr, "AttributePersistentRef")) { + // load + Engines::Component_var comp = myGeomGUI->GetDesktop()->getEngine("FactoryServer","GEOM"); + if (!CORBA::is_nil(comp)) { + SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp); + aStudyBuilder->LoadWith(aStudy->FindComponent("GEOM"),driver); + } + else { + MESSAGE("Component is null"); + } + } + if(useSubItems) { + anIter->Next(); + obj = anIter->Value(); + } + else + anAttr = SALOMEDS::GenericAttribute::_nil(); + } + } + } + break; + } + default: + { + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + } + return true; +} + + +//=============================================================================== +// function : OnEditDelete() +// purpose : +//=============================================================================== +void GEOMBase_Tools::OnEditDelete() +{ + if ( QAD_MessageBox::warn2 + ( myGeomGUI->GetDesktop(), + tr ("GEOM_WRN_WARNING"), + tr ("GEOM_REALLY_DELETE"), + tr ("GEOM_BUT_YES"), tr ("GEOM_BUT_NO"), 1, 0, 0) != 1 ) + return; + + int nbSf = myGeomGUI->GetActiveStudy()->getStudyFramesCount(); + + Standard_Boolean found; + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + + SALOME_Selection* Sel = SALOME_Selection::Selection( myGeomGUI->GetActiveStudy()->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + if ( IObject->hasEntry() ) { + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() ); + + /* Erase child graphical objects */ + SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO); + for (; it->More();it->Next()) { + SALOMEDS::SObject_var CSO= it->Value(); + if (CSO->FindAttribute(anAttr, "AttributeIOR") ) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + /* Delete child(s) shape in Client : */ + const TCollection_AsciiString ASCior(anIOR->Value()) ; + myGeomGUI->GetShapeReader().RemoveShapeFromBuffer( ASCior ) ; + + for ( int i = 0; i < nbSf; i++ ) { + QAD_StudyFrame* sf = myGeomGUI->GetActiveStudy()->getStudyFrame(i); + if ( sf->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); + Handle(GEOM_AISShape) Result = myGeomGUI->ConvertIORinGEOMAISShape( anIOR->Value(), found ); + if ( found ) + myContext->Erase( Result, true, false ); + } else if ( sf->getTypeView() == VIEW_VTK ) { + //vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor(); + GEOM_Actor* ac = myGeomGUI->ConvertIORinGEOMActor( anIOR->Value(), found ); + if ( found ) { + //Renderer->RemoveActor(ac); + if ( ac->hasIO() ) + myRenderInter->Remove( ac->getIO() ); + } + } + } + } + } + + /* Erase main graphical object */ + for ( int i = 0; i < nbSf; i++ ) { + QAD_StudyFrame* sf = myGeomGUI->GetActiveStudy()->getStudyFrame(i); + if ( sf->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); + Handle(GEOM_AISShape) Result = myGeomGUI->ConvertIOinGEOMAISShape( IObject, found ); + if ( found ) + myContext->Erase( Result, true, false ); + } else if ( sf->getTypeView() == VIEW_VTK ) { + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor(); + myRenderInter->Remove( IObject ); + } + } + + /* Delete main shape in Client : */ + if (SO->FindAttribute(anAttr, "AttributeIOR") ) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + const TCollection_AsciiString ASCIor(anIOR->Value()) ; + myGeomGUI->GetShapeReader().RemoveShapeFromBuffer( ASCIor ) ; + } + + /* Erase objects in Study */ + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); + if ( !obj->_is_nil() ) { + QAD_Operation* op = new SALOMEGUI_ImportOperation( myGeomGUI->GetActiveStudy() ); + op->start(); + aStudyBuilder->RemoveObject(obj); + op->finish(); + } + + } /* IObject->hasEntry() */ + } /* more/next */ + + /* Clear any previous selection */ + Sel->ClearIObjects() ; + myGeomGUI->GetActiveStudy()->updateObjBrowser(); +} + + +//============================================================================== +// function : OnEditCopy() +// purpose : +//============================================================================== +void GEOMBase_Tools::OnEditCopy() +{ + SALOME_Selection* Sel = SALOME_Selection::Selection( myGeomGUI->GetActiveStudy()->getSelection() ); + GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR; + + const SALOME_ListIO& List = Sel->StoredIObjects(); + + myGeomGUI->ConvertListOfIOInListOfIOR( List, listIOR); + + Sel->ClearIObjects(); + + for (unsigned int ind = 0; ind < listIOR->length();ind++) { + GEOM::GEOM_Shape_var aShapeInit = myGeom->GetIORFromString(listIOR[ind]); + try { + GEOM::GEOM_Shape_var result = myGeom->MakeCopy(aShapeInit) ; + result->NameType( aShapeInit->NameType() ); + myGeomGUI->Display(result); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + } + + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_READY")); +} + + +//===================================================================================== +// function : Import +// purpose : BRep, Iges, Step +//===================================================================================== +bool GEOMBase_Tools::Import() +{ + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + + GEOM::GEOM_Shape_var aShape; + QString file; + QStringList filtersList ; + + switch (myGeomGUI->GetState()) + { + case 111 : // Import BREP + { + filtersList.append( tr("GEOM_MEN_IMPORT_BREP") ); + filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ; + + file = QAD_FileDlg::getFileName(myGeomGUI->GetDesktop(), + "", + filtersList, + tr("GEOM_MEN_IMPORT"), + true); + if ( !file.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + aShape = myGeom->ImportBREP( file.latin1() ); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + } + break; + } + case 112 : // Import IGES + { + filtersList.append( tr("GEOM_MEN_IMPORT_IGES") ) ; + filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ; + + file = QAD_FileDlg::getFileName(myGeomGUI->GetDesktop(), + "", + filtersList, + tr("GEOM_MEN_IMPORT"), + true); + if ( !file.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + aShape = myGeom->ImportIGES( file.latin1() ); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + } + break; + } + case 113 : // Import STEP + { + filtersList.append( tr("GEOM_MEN_IMPORT_STEP") ) ; + filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ; + + file = QAD_FileDlg::getFileName(myGeomGUI->GetDesktop(), + "", + filtersList, + tr("GEOM_MEN_IMPORT"), + true); + if ( !file.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + aShape = myGeom->ImportSTEP( file.latin1() ); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + } + break; + } + } + + if ( !file.isEmpty() ) { + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_LOADING").arg(QAD_Tools::getFileNameFromPath( file )) ); + + SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM"); + SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->entry()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributePixMap_var aPixmap; + int aLocked = false; + if (father->_is_nil()) { + QAD_Operation* op = new SALOMEGUI_ImportOperation( myGeomGUI->GetActiveStudy() ); + op->start(); + aLocked = aStudy->GetProperties()->IsLocked(); + if (aLocked) aStudy->GetProperties()->SetLocked(false); + father = aStudyBuilder->NewComponent("GEOM"); + anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + // aName->SetValue( tr("GEOM_MEN_COMPONENT") ); + aName->SetValue( myGeomGUI->GetDesktop()->getComponentUserName( "GEOM" ) ); + anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" ); + if (aLocked) aStudy->GetProperties()->SetLocked(true); + op->finish(); + } +// if (aLocked) return false; + aStudyBuilder->DefineComponentInstance( father, myGeom ); + father->ComponentIOR(myGeomGUI->GetFatherior()); + + QString nameShape = QAD_Tools::getFileNameFromPath(file,false) + QString("_%1").arg(myGeomGUI->GetNbGeom()++); + + if(myGeomGUI->Display(aShape, strdup(nameShape.latin1()))) { + myGeomGUI->GetActiveStudy()->setMessage( tr("GEOM_INF_LOADED").arg(QAD_Tools::getFileNameFromPath( file )) ); + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_READY")); + } + } + QApplication::restoreOverrideCursor(); + return true; +} + + +//===================================================================================== +// function : Export +// purpose : BRep, Iges, Step +//===================================================================================== +bool GEOMBase_Tools::Export() +{ + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + + GEOM::GEOM_Shape_var aShape; + + static QString filters[] = { tr("GEOM_MEN_IMPORT_BREP"), + tr("GEOM_MEN_IMPORT_IGES"), + tr("GEOM_MEN_IMPORT_STEP") }; + + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + + switch (myGeomGUI->GetState()) + { + case 121 : + { + for(;It.More();It.Next()) { + QApplication::restoreOverrideCursor(); + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean found; + GEOM::GEOM_Shape_var aShape = myGeomGUI->ConvertIOinGEOMShape(IObject, found); + // Handle(GEOM_AISShape) Shape = myGeomGUI->ConvertIOinGEOMAISShape(IObject, found, true); + if ( found ) { + QString file = QAD_FileDlg::getFileName(myGeomGUI->GetDesktop(), + QString( IObject->getName() ) + ".brep", + tr("GEOM_MEN_IMPORT_BREP"), + tr("GEOM_MEN_EXPORT"), + false); + if ( !file.isEmpty() && !aShape->_is_nil() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + // Standard_Boolean result = BRepTools::Write(Shape->Shape(), strdup(file.latin1()) ); + try { + myGeom->ExportBREP(strdup( file.latin1()), aShape); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + } + } + } + break; + } + case 122 : + { + for(;It.More();It.Next()) { + QApplication::restoreOverrideCursor(); + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean found; + GEOM::GEOM_Shape_var aShape = myGeomGUI->ConvertIOinGEOMShape(IObject, found); + // Handle(GEOM_AISShape) Shape = myGeomGUI->ConvertIOinGEOMAISShape(IObject, found, true); + if ( found ) { + QString file = QAD_FileDlg::getFileName(myGeomGUI->GetDesktop(), + QString( IObject->getName() ) + ".igs", + tr("GEOM_MEN_IMPORT_IGES"), + tr("GEOM_MEN_EXPORT"), + false); + if ( !file.isEmpty() && !aShape->_is_nil() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + myGeom->ExportIGES(strdup( file.latin1()), aShape); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } +// //VRV: OCC 4.0 migration +// IGESControl_Controller::Init(); +// IGESControl_Writer ICW (Interface_Static::CVal("XSTEP.iges.unit"), +// Interface_Static::IVal("XSTEP.iges.writebrep.mode")); +// //VRV: OCC 4.0 migration + +// ICW.AddShape (Shape->Shape()); +// ICW.ComputeModel(); +// Standard_Boolean result = ICW.Write( strdup(file.latin1()) ); + } + } + } + break; + } + + case 123 : + { +// bool test = false ; +// IFSelect_ReturnStatus status ; +// //VRV: OCC 4.0 migration +// STEPControl_Writer aWriter; +// //VRV: OCC 4.0 migration + QString file; + + for( ; It.More(); It.Next() ) { +// GEOM::GEOM_Shape_var aShape = myGeomGUI->ConvertIOinGEOMShape(IObject, found); + QApplication::restoreOverrideCursor(); + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean found; + GEOM::GEOM_Shape_var aShape = myGeomGUI->ConvertIOinGEOMShape(IObject, found); + // Handle(GEOM_AISShape) Shape = myGeomGUI->ConvertIOinGEOMAISShape(IObject, found, true); + if ( found ) { + file = QAD_FileDlg::getFileName(myGeomGUI->GetDesktop(), + QString( IObject->getName() ) + ".stp", + tr("GEOM_MEN_IMPORT_STEP"), + tr("GEOM_MEN_EXPORT"), + false); + if ( !file.isEmpty() && !aShape->_is_nil() ) { + + QApplication::setOverrideCursor( Qt::waitCursor ) ; + try { + myGeom->ExportSTEP(strdup( file.latin1()), aShape); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } +// //VRV: OCC 4.0 migration +// status = aWriter.Transfer( Shape->Shape(), STEPControl_ManifoldSolidBrep ) ; +// //VRV: OCC 4.0 migration +// test = true ; +// if ( status != IFSelect_RetDone ) { +// QApplication::restoreOverrideCursor() ; +// return false ; +// } + } + } + } +// if(test) { +// status = aWriter.Write( strdup(file.latin1()) ) ; +// QApplication::restoreOverrideCursor() ; +// return status ; +// } + break; + } + + } + QApplication::restoreOverrideCursor() ; +} diff --git a/src/GEOMBase/GEOMBase_Tools.h b/src/GEOMBase/GEOMBase_Tools.h new file mode 100644 index 000000000..85d6faa12 --- /dev/null +++ b/src/GEOMBase/GEOMBase_Tools.h @@ -0,0 +1,61 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_Tools.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef GEOMBASE_TOOLS_H +#define GEOMBASE_TOOLS_H + +#include "GEOMBase_Context.h" + +//================================================================================= +// class : GEOMBase_Tools +// purpose : +//================================================================================= +class GEOMBase_Tools : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + GEOMBase_Tools(); + ~GEOMBase_Tools(); + + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + + /* Import and export topology methods */ + bool Import(); + bool Export(); + + void OnEditCopy(); + void OnEditDelete(); + +private: + GEOMBase_Context* myGeomGUI; + GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + +}; + +#endif diff --git a/src/GEOMBase/GEOMBase_TransparencyDlg.cxx b/src/GEOMBase/GEOMBase_TransparencyDlg.cxx new file mode 100644 index 000000000..9930c20e7 --- /dev/null +++ b/src/GEOMBase/GEOMBase_TransparencyDlg.cxx @@ -0,0 +1,249 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_TransparencyDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM + +using namespace std; +#include "GEOMBase_TransparencyDlg.h" +#include "GEOMBase_Context.h" + +#include "QAD_RightFrame.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "VTKViewer_ViewFrame.h" +#include "VTKViewer_RenderWindowInteractor.h" + +//================================================================================= +// class : GEOMBase_TransparencyDlg() +// purpose : Constructs a GEOMBase_SUBSHAPE which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// +// : WARNING : this dialog is modal ! +// +//================================================================================= +GEOMBase_TransparencyDlg::GEOMBase_TransparencyDlg( QWidget* parent, + const char* name, + SALOME_Selection* Sel, + const Handle(AIS_InteractiveContext)& ic, + bool modal, + WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "GEOMBase_TransparencyDlg" ); + resize( 152, 107 ); + setCaption( tr( "GEOM_TRANSPARENCY_TITLE" ) ); + setSizeGripEnabled( TRUE ); + GEOMBase_TransparencyDlgLayout = new QGridLayout( this ); + GEOMBase_TransparencyDlgLayout->setSpacing( 6 ); + GEOMBase_TransparencyDlgLayout->setMargin( 11 ); + + /*************************************************************************/ + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "GEOM_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0 ); + GroupButtonsLayout->addWidget( buttonOk, 0, 1 ); + GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2 ); + + /*************************************************************************/ + QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + TextLabelOpaque = new QLabel( GroupC1, "TextLabelOpaque" ); + TextLabelOpaque->setText( tr( "GEOM_TRANSPARENCY_OPAQUE" ) ); + TextLabelOpaque->setAlignment( int( QLabel::AlignLeft ) ); + GroupC1Layout->addWidget( TextLabelOpaque, 0, 0 ); + GroupC1Layout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + TextLabelTransparent = new QLabel( GroupC1, "TextLabelTransparent" ); + TextLabelTransparent->setText( tr( "GEOM_TRANSPARENCY_TRANSPARENT" ) ); + TextLabelTransparent->setAlignment( int( QLabel::AlignRight ) ); + GroupC1Layout->addWidget( TextLabelTransparent, 0, 2 ); + + Slider1 = new QSlider( 0, 10, 1, 5, Horizontal, GroupC1, "Slider1" ); + Slider1->setMinimumSize( 300, 0 ); + Slider1->setTickmarks( QSlider::Left ); + GroupC1Layout->addMultiCellWidget( Slider1, 1, 1, 0, 2 ); + /*************************************************************************/ + + GEOMBase_TransparencyDlgLayout->addWidget( GroupC1, 0, 0 ); + GEOMBase_TransparencyDlgLayout->addWidget( GroupButtons, 1, 0 ); + + /* Initialisations */ + this->myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + this->myIc = ic ; + this->mySel = Sel ; + + /* First call valueChanged() method for initialisation */ + /* The default value of transparency will change with the selection */ + this->myFirstInit = true ; +// Slider1->setMaxValue( 10 ); +// Slider1->setValue( 5 ) ; + this->ValueHasChanged( Slider1->value() ) ; + + // signals and slots connections : after ValueHasChanged() + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( Slider1, SIGNAL( valueChanged(int) ), this, SLOT( ValueHasChanged(int) ) ); + + /* 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 this Dialog */ +} + + + + +//================================================================================= +// function : ~GEOMBase_TransparencyDlg() +// purpose : +//================================================================================= +GEOMBase_TransparencyDlg::~GEOMBase_TransparencyDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//======================================================================= +// function : ClickOnOk() +// purpose : +//======================================================================= +void GEOMBase_TransparencyDlg::ClickOnOk() +{ + accept() ; + return ; +} + + +//======================================================================= +// function : ClickOnClose() +// purpose : +//======================================================================= +void GEOMBase_TransparencyDlg::ClickOnClose() +{ + accept() ; + return ; +} + + +//================================================================================= +// function : ValueHasChanged() +// purpose : Called when value of slider change +// : or the first time as initilisation +//================================================================================= +void GEOMBase_TransparencyDlg::ValueHasChanged( int newValue ) +{ + + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + // VTK + // vtkQGLRenderWindowInteractor* myRenderInter= myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor(); + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + SALOME_ListIteratorOfListIO It( this->mySel->StoredIObjects() ); + + Handle(SALOME_InteractiveObject) FirstIOS = mySel->firstIObject(); + if( !FirstIOS.IsNull() ) { + + /* The first time as initialisation */ + if( this->myFirstInit ) { + this->myFirstInit = false ; + float transp = ( myRenderInter->GetTransparency(FirstIOS))*10.0 ; + this->Slider1->setValue( int(transp) ) ; + } + } + + QApplication::setOverrideCursor( Qt::waitCursor ); + for( ;It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + myRenderInter->SetTransparency( IOS, newValue/10.0 ); + } + QApplication::restoreOverrideCursor(); + } + + else if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + // OCC + SALOME_ListIteratorOfListIO It( this->mySel->StoredIObjects() ); + Handle(SALOME_InteractiveObject) FirstIOS = mySel->firstIObject() ; + if( !FirstIOS.IsNull() ) { + + /* The first time as initialisation */ + if( this->myFirstInit ) { + this->myFirstInit = false ; + Standard_Boolean found; + Handle(GEOM_AISShape) Shape = myGeomGUI->ConvertIOinGEOMAISShape(FirstIOS, found); + if( !found ) { + return ; + } + float transp = ( int( Shape->Transparency() * 10.0 + 0.001) ); + this->Slider1->setValue(int(transp) ) ; + return ; + } + } + + QApplication::setOverrideCursor( Qt::waitCursor ); + for( ;It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean found; + Handle(GEOM_AISShape) Shape = myGeomGUI->ConvertIOinGEOMAISShape(IObject, found); + if( !found ) { + QApplication::restoreOverrideCursor(); + return ; + } + this->myIc->SetTransparency( Shape, newValue / 10.0, false ); + myIc->Redisplay( Shape, Standard_False, Standard_True ); + } + myIc->UpdateCurrentViewer(); + } + QApplication::restoreOverrideCursor(); + return ; +} diff --git a/src/GEOMBase/GEOMBase_TransparencyDlg.h b/src/GEOMBase/GEOMBase_TransparencyDlg.h new file mode 100644 index 000000000..eec9b47e1 --- /dev/null +++ b/src/GEOMBase/GEOMBase_TransparencyDlg.h @@ -0,0 +1,96 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_TransparencyDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_TRANSPARENCYDLG_H +#define DIALOGBOX_TRANSPARENCYDLG_H + +#include +#include + +#include "SALOME_Selection.h" +#include "SALOME_InteractiveObject.hxx" +#include "GEOM_InteractiveObject.hxx" +#include "GEOM_AISShape.hxx" + + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QFrame; +class QLabel; +class QPushButton; +class QSlider; +class GEOMBase_Context; + + + +//================================================================================= +// class : GEOMBase_TransparencyDlg +// purpose : +// : WARNING : that is a MODAL dialog. +//================================================================================= +class GEOMBase_TransparencyDlg : public QDialog +{ + Q_OBJECT + +public: + GEOMBase_TransparencyDlg( QWidget* parent = 0, + const char* name = 0, + SALOME_Selection* Sel = 0, + const Handle(AIS_InteractiveContext)& ic = 0, + bool modal = TRUE, + WFlags fl = 0 ); + + ~GEOMBase_TransparencyDlg(); + +private : + + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + bool myFirstInit ; /* Inform for the first init */ + SALOME_Selection* mySel; /* User selection */ + Handle(AIS_InteractiveContext) myIc ; /* Interactive context */ + + QPushButton* buttonOk; + QLabel* TextLabelOpaque; + QLabel* TextLabelTransparent; + QSlider* Slider1; + +public slots: + + void ClickOnOk(); + void ClickOnClose(); + void ValueHasChanged( int newValue ) ; + +protected: + QGridLayout* GEOMBase_TransparencyDlgLayout; + QHBoxLayout* Layout1; + QHBoxLayout* Layout2; +}; + +#endif // DIALOGBOX_TRANSPARENCYDLG_H + diff --git a/src/GEOMBase/GEOMBase_aParameterDlg.cxx b/src/GEOMBase/GEOMBase_aParameterDlg.cxx new file mode 100644 index 000000000..e8e0c7fc3 --- /dev/null +++ b/src/GEOMBase/GEOMBase_aParameterDlg.cxx @@ -0,0 +1,166 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_aParameterDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "GEOMBase_aParameterDlg.h" +#include "GEOMBase_Context.h" +#include "QAD_SpinBoxDbl.h" +#include "QAD_Tools.h" + +#include + +#include +#include +#include +#include +#include +#include + +//====================================================================================== +// function : GEOMBase_aParameterDlg() +// purpose : Constructs a GEOMBase_aParametertDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f' +// +// avalue1 : is a float or integer used as default value in edit line +// aTitle1 : is the prompt for aValue1 +// aTitle : is the title for the user in dialog box +// +// bottom : the minimal value to be entered +// top : the maximum value to be entered +// decimals : number of decimals to be entered +// +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +// +//====================================================================================== +GEOMBase_aParameterDlg::GEOMBase_aParameterDlg( const char *aValue1, + const char *aTitle1, + QWidget* parent, + const char* name, + bool modal, + WFlags fl, + const double bottom, + const double top, + const int decimals ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "MyParameterDialog" ); + resize( 288, 81 ); + setCaption( name ); /* appears on the title bar */ + setSizeGripEnabled( TRUE ); + + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setSpacing( 6 ); + topLayout->setMargin( 11 ); + + QGroupBox* mainGrp = new QGroupBox( this, "mainGrp" ); + mainGrp->setColumnLayout(0, Qt::Vertical ); + mainGrp->layout()->setSpacing( 0 ); + mainGrp->layout()->setMargin( 0 ); + QGridLayout* mainGrpLayout = new QGridLayout( mainGrp->layout() ); + mainGrpLayout->setAlignment( Qt::AlignTop ); + mainGrpLayout ->setSpacing( 6 ); + mainGrpLayout->setMargin( 11 ); + topLayout->addWidget( mainGrp, 0, 0 ); + + /* aTitle1 : text prompt on left of edit line */ + QLabel* TextLabel1 = new QLabel( mainGrp, "TextLabel1" ); + TextLabel1->setText( tr( aTitle1 ) ); + mainGrpLayout->addWidget( TextLabel1, 0, 0 ); + + mySpinBox = new QAD_SpinBoxDbl( mainGrp, "mySpinBox" ); + mySpinBox->setPrecision( 12); + mySpinBox->setRange( bottom, top ); + (( QDoubleValidator* )(mySpinBox->validator()))->setRange(bottom, top, decimals); + mySpinBox->setValue(QString(aValue1).toDouble()); + mainGrpLayout->addWidget( mySpinBox, 0, 1 ); + + QGroupBox* btnGrp = new QGroupBox( this, "btnGrp" ); + btnGrp->setColumnLayout(0, Qt::Vertical ); + btnGrp->layout()->setSpacing( 0 ); + btnGrp->layout()->setMargin( 0 ); + QGridLayout* btnGrpLayout = new QGridLayout( btnGrp->layout() ); + btnGrpLayout->setAlignment( Qt::AlignTop ); + btnGrpLayout->setSpacing( 6 ); + btnGrpLayout->setMargin( 11 ); + topLayout->addWidget( btnGrp, 1, 0 ); + + /* Ok button */ + myButtonOk = new QPushButton( btnGrp, "buttonOk" ); + myButtonOk->setText( tr("GEOM_BUT_OK") ); + myButtonOk->setAutoDefault( TRUE ); + myButtonOk->setDefault( TRUE ); + btnGrpLayout->addWidget( myButtonOk, 0, 0 ); + + btnGrpLayout->addItem( new QSpacerItem(5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1 ); + + /* Cancel button */ + myButtonCancel = new QPushButton( btnGrp, "buttonCancel" ); + myButtonCancel->setText( tr("GEOM_BUT_CANCEL") ); + myButtonCancel->setAutoDefault( TRUE ); + btnGrpLayout->addWidget( myButtonCancel, 0, 2 ); + + /* signals and slots connections */ + connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + /* Retrieve GeomGUI */ + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + + /* Move widget on the botton right corner of main widget */ + QAD_Tools::centerWidget(this, parent); +} + + +//====================================================================================== +// function : ~GEOMBase_aParameterDlg() destructor +// purpose : Destroys the object and frees any allocated resources +//====================================================================================== +GEOMBase_aParameterDlg::~GEOMBase_aParameterDlg() +{ // no need to delete child widgets, Qt does it all for us +} + +//====================================================================================== +// function : GEOMBase_aParameterDlg::setValue +// purpose : sets value +//====================================================================================== +void GEOMBase_aParameterDlg::setValue( double val ) +{ + mySpinBox->setValue( val ); +} + +//====================================================================================== +// function : GEOMBase_aParameterDlg::getValue +// purpose : gets value +//====================================================================================== +double GEOMBase_aParameterDlg::getValue() +{ + return mySpinBox->value(); +} + diff --git a/src/GEOMBase/GEOMBase_aParameterDlg.h b/src/GEOMBase/GEOMBase_aParameterDlg.h new file mode 100644 index 000000000..d8d962a59 --- /dev/null +++ b/src/GEOMBase/GEOMBase_aParameterDlg.h @@ -0,0 +1,72 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_aParameterDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef GEOMBase_aParameterDLG_H +#define GEOMBase_aParameterDLG_H + +#include + +class QPushButton; +class QAD_SpinBoxDbl; + +class GEOMBase_Context; + +//================================================================================= +// class : GEOMBase_aParameterDlg +// purpose : +//================================================================================= +class GEOMBase_aParameterDlg : public QDialog +{ + Q_OBJECT + +public: + GEOMBase_aParameterDlg( const char* aValue1 = "25", + const char* aTitle1 = "Value :", + QWidget* parent = 0, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0, + const double bottom = -1E6, + const double top = +1E6, + const int decimals = 6 ) ; + + ~GEOMBase_aParameterDlg(); + + void setValue( double val ); + double getValue(); + +private: + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + + QPushButton* myButtonOk; + QPushButton* myButtonCancel; + QAD_SpinBoxDbl* mySpinBox; + +}; + +#endif // GEOMBase_aParameterDlg.h diff --git a/src/GEOMBase/GEOM_icons.po b/src/GEOMBase/GEOM_icons.po new file mode 100644 index 000000000..3195286cc --- /dev/null +++ b/src/GEOMBase/GEOM_icons.po @@ -0,0 +1,349 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. translating +# from French to English, "Foo::Bar" would be translated to "Pub", +# not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2001-06-14 09:11:49 PM CEST\n" +"PO-Revision-Date: 2003-09-22 16:39+0200\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +#Select +msgid "ICON_SELECT" +msgstr "select1.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_Geometry" +msgstr "geometry.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_COMPOUND" +msgstr "tree_compound.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_COMPSOLID" +msgstr "tree_compsolid.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_EDGE" +msgstr "tree_edge.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_FACE" +msgstr "tree_face.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_SHAPE" +msgstr "tree_shape.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_SHELL" +msgstr "tree_shell.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_SOLID" +msgstr "tree_solid.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_VERTEX" +msgstr "tree_vertex.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_WIRE" +msgstr "tree_wire.png" + +#BoxDlg +msgid "ICON_DLG_BOX_2P" +msgstr "box2points.png" + +#BoxDlg +msgid "ICON_DLG_BOX_DXYZ" +msgstr "boxdxyz.png" + +#CylinderDlg +msgid "ICON_DLG_CYLINDER_PV" +msgstr "cylinderpointvector.png" + +#CylinderDlg +msgid "ICON_DLG_CYLINDER_DXYZ" +msgstr "cylinderdxyz.png" + +#SphereDlg +msgid "ICON_DLG_SPHERE_P" +msgstr "spherepoint.png" + +#SphereDlg +msgid "ICON_DLG_SPHERE_DXYZ" +msgstr "spheredxyz.png" + +#torusDlg +msgid "ICON_DLG_TORUS_PV" +msgstr "toruspointvector.png" + +#ConeDlg +msgid "ICON_DLG_CONE_PV" +msgstr "conepointvector.png" + +#torusDlg +msgid "ICON_DLG_TORUS_DXYZ" +msgstr "torusdxyz.png" + +#ConeDlg +msgid "ICON_DLG_CONE_DXYZ" +msgstr "conedxyz.png" + +#LineDlg +msgid "ICON_DLG_LINE_2P" +msgstr "line2points.png" + +#LineDlg +msgid "ICON_DLG_LINE_EDGE" +msgstr "lineedge.png" + +#LineDlg +msgid "ICON_DLG_LINE_PV" +msgstr "linepointvector.png" + +#CircleDlg +msgid "ICON_DLG_CIRCLE_PV" +msgstr "circlepointvector.png" + +#VectorDlg +msgid "ICON_DLG_VECTOR_2P" +msgstr "vector2points.png" + +#vectorDlg +msgid "ICON_DLG_VECTOR_DXYZ" +msgstr "vectordxyz.png" + +#PlaneDlg +msgid "ICON_DLG_PLANE_DXYZ" +msgstr "planedxyz.png" + +#PlaneDlg +msgid "ICON_DLG_PLANE_FACE" +msgstr "planeface.png" + +#PlaneDlg +msgid "ICON_DLG_PLANE_PV" +msgstr "planepointvector.png" + +#WorkingPlaneDlg +msgid "ICON_DLG_WPLANE_FACE" +msgstr "planeworkingface.png" + +#PointDlg +msgid "ICON_DLG_POINT" +msgstr "point2.png" + +#PoinDlg +msgid "ICON_DLG_POINT_EDGE" +msgstr "pointonedge.png" + +#ArcDlg +msgid "ICON_DLG_ARC" +msgstr "arc.png" + +#ArchimedeDlg +msgid "ICON_DLG_ARCHIMEDE" +msgstr "archimede.png" + +#PartitionDlg +msgid "ICON_DLG_PARTITION" +msgstr "partition.png" + +#PartitionDlg +msgid "ICON_DLG_PARTITION_KEEP_FACES" +msgstr "partitionkeep.png" + +#CenterMassDlg +msgid "ICON_DLG_CENTERMASS" +msgstr "centergravity.png" + +#BoundingBoxDlg +msgid "ICON_DLG_BOUNDING_BOX" +msgstr "bounding.png" + +#CommonDlg +msgid "ICON_DLG_COMMON" +msgstr "common.png" + +#CompoundDlg +msgid "ICON_DLG_BUILD_COMPOUND" +msgstr "build_compound.png" + +#CutDlg +msgid "ICON_DLG_CUT" +msgstr "cut.png" + +#EdgeDlg +msgid "ICON_DLG_BUILD_EDGE" +msgstr "build_edge.png" + +#FaceDlg +msgid "ICON_DLG_BUILD_FACE" +msgstr "build_face.png" + +#ShellDlg +msgid "ICON_DLG_BUILD_SHELL" +msgstr "build_shell.png" + +#SolidDlg +msgid "ICON_DLG_BUILD_SOLID" +msgstr "build_solid.png" + +#WireDlg +msgid "ICON_DLG_BUILD_WIRE" +msgstr "build_wire.png" + +#FillingDlg +msgid "ICON_DLG_FILLING" +msgstr "filling.png" + +#FuseDlg +msgid "ICON_DLG_FUSE" +msgstr "fuse.png" + +#InertiaDlg +msgid "ICON_DLG_INERTIA" +msgstr "axisinertia.png" + +#ToleranceDlg +msgid "ICON_DLG_TOLERANCE" +msgstr "tolerance.png" + +#BasicPropertiesDlg +msgid "ICON_DLG_BASICPROPERTIES" +msgstr "basicproperties.png" + +#WhatisDlg +msgid "ICON_DLG_WHATIS" +msgstr "whatis.png" + +#MinDistDlg +msgid "ICON_DLG_MINDIST" +msgstr "mindist.png" + +#MirrorDlg +msgid "ICON_DLG_MIRROR" +msgstr "mirrorPlane.png" + +#TranslationDlg +msgid "ICON_DLG_TRANSLATION" +msgstr "translation.png" + +#RotationDlg +msgid "ICON_DLG_ROTATION" +msgstr "rotate.png" + +#ScaleDlg +msgid "ICON_DLG_SCALE" +msgstr "scale.png" + +#OrientationDlg +msgid "ICON_DLG_ORIENTATION" +msgstr "orientation.png" + +#SewingDlg +msgid "ICON_DLG_SEWING" +msgstr "sewing.png" + +#PipeDlg +msgid "ICON_DLG_PIPE" +msgstr "pipe.png" + +#PrismDlg +msgid "ICON_DLG_PRISM" +msgstr "prism.png" + +#RevolutionDlg +msgid "ICON_DLG_REVOL" +msgstr "revol.png" + +#SectionDlg +msgid "ICON_DLG_SECTION" +msgstr "section.png" + +#SubShapeDlg +msgid "ICON_DLG_SUBSHAPE" +msgstr "subshape.png" + +#FilletDlg +msgid "ICON_DLG_FILLET" +msgstr "fillet.png" + +#ChamferDlg +msgid "ICON_DLG_CHAMFER" +msgstr "chamfer.png" + +#FilletDlg +msgid "ICON_DLG_FILLET_ALL" +msgstr "filletall.png" + +#ChamferDlg +msgid "ICON_DLG_CHAMFER_ALL" +msgstr "chamferall.png" + +#FilletDlg +msgid "ICON_DLG_FILLET_EDGE" +msgstr "filletedge.png" + +#ChamferDlg +msgid "ICON_DLG_CHAMFER_EDGE" +msgstr "chamferedge.png" + +#FilletDlg +msgid "ICON_DLG_FILLET_FACE" +msgstr "filletface.png" + +#ChamferDlg +msgid "ICON_DLG_CHAMFER_FACE" +msgstr "chamferface.png" + +#ChamferDlg +msgid "ICON_DLG_CHECKSHAPE" +msgstr "check.png" + +#SupressFaceDlg +msgid "ICON_DLG_SUPRESS_FACE" +msgstr "supressface.png" + +#SupressHoleDlg +msgid "ICON_DLG_SUPRESS_HOLE" +msgstr "supresshole.png" + +#SupressHoleDlg +msgid "ICON_DLG_SUPRESS_HOLE_FACE_SHELL" +msgstr "supressHolesOnFaceShell.png" + +#MultiTranslationDlg +msgid "ICON_DLG_MULTITRANSLATION_SIMPLE" +msgstr "multitranslationsimple.png" + +#MultiTranslationDlg +msgid "ICON_DLG_MULTITRANSLATION" +msgstr "multitranslation.png" + +#MultiTranslationDlg +msgid "ICON_DLG_MULTITRANSLATION_DOUBLE" +msgstr "multitranslationdouble.png" + +#MultiRotationDlg +msgid "ICON_DLG_MULTIROTATION_SIMPLE" +msgstr "multirotationsimple.png" + +#MultiRotationDlg +msgid "ICON_DLG_MULTIROTATION" +msgstr "multirotation.png" + +#MultiRotationDlg +msgid "ICON_DLG_MULTIROTATION_DOUBLE" +msgstr "multirotationdouble.png" + +#EllipseDlg +msgid "ICON_DLG_ELLIPSE_PV" +msgstr "ellipsepointvector.png" + + diff --git a/src/GEOMBase/GEOM_msg_en.po b/src/GEOMBase/GEOM_msg_en.po new file mode 100644 index 000000000..3c2b93cc8 --- /dev/null +++ b/src/GEOMBase/GEOM_msg_en.po @@ -0,0 +1,1179 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. translating +# from French to English, "Foo::Bar" would be translated to "Pub", +# not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-03-19 09:35:48 AM CET\n" +"PO-Revision-Date: 2003-09-22 16:38+0200\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +# +#============================================================================== +# + +#Button Apply +msgid "GEOM_BUT_APPLY" +msgstr "&Apply" + +#Button Close +msgid "GEOM_BUT_CLOSE" +msgstr "&Close" + +#Button Cancel +msgid "GEOM_BUT_CANCEL" +msgstr "&Cancel" + +#Button Ok +msgid "GEOM_BUT_OK" +msgstr "&Ok" + +#Button Yes +msgid "GEOM_BUT_YES" +msgstr "&Yes" + +#Button No +msgid "GEOM_BUT_NO" +msgstr "&No" + +#Button Help +msgid "GEOM_BUT_HELP" +msgstr "&Help" + +#Button Explode +msgid "GEOM_BUT_EXPLODE" +msgstr "&Explode" + + +# +#============================================================================== +# + +#: GeometryGUI.cxx:563 +msgid "GEOM_INF_LOADED" +msgstr "File %1 loaded." + +# +#============================================================================== +# + +#: GeometryGUI.cxx:3069 +msgid "GEOM_PRP_COMMAND" +msgstr "No command associated with this id = %1." + +#: GeometryGUI.cxx:4977 +msgid "GEOM_PRP_ABORT" +msgstr "Operation aborted" + +#: GeometryGUI.cxx:5058 +msgid "GEOM_PRP_DONE" +msgstr "Operation done" + +#: GeometryGUI.cxx:3717 +msgid "GEOM_PRP_LOADING" +msgstr "Loading %1 ..." + +#: GeometryGUI.cxx:1412 +msgid "GEOM_PRP_NULLSHAPE" +msgstr "Error, null or inappropriate shape !" + +#: GeometryGUI.cxx:5072 +msgid "GEOM_PRP_READY" +msgstr "Ready" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_SUBSHAPES" +msgstr "Select Sub Shapes" + +msgid "GEOM_CONFIRM" +msgstr "Confirm operation" + +msgid "GEOM_CONFIRM_INFO" +msgstr "Shape contains %1 sub shapes !" + + +msgid "GEOM_PRP_NOT_FOR_VTK_VIEWER" +msgstr "Not allowed in VTK viewer" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SHAPE_IN_STUDY" +msgstr "Main shape must be in the study before" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_EDGE" +msgstr "Select edges and click on Apply" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_FACE" +msgstr "Select faces to suppress and click on Ok/Apply" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_FIRST" +msgstr "Select main shape first" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_MIN_DIST" +msgstr "Min Distance not computed" + +# +#============================================================================== +# + +#: GeometryGUI.cxx:3698 +msgid "GEOM_MEN_ALL_FILES" +msgstr "All Files ( * )" + +#: GeometryGUI.cxx:4389 +msgid "GEOM_MEN_ANGLE" +msgstr "Angle :" + +#: GeometryGUI.cxx:3941 +msgid "GEOM_MEN_COMPONENT" +msgstr "Geometry" + +#: GeometryGUI.cxx:4389 +msgid "GEOM_MEN_ENTER_ANGLE" +msgstr "Enter An Angle In Degrees" + +#: GeometryGUI.cxx:3758 +msgid "GEOM_MEN_EXPORT" +msgstr "Export" + +#: GeometryGUI.cxx:3648 +msgid "GEOM_MEN_IMPORT" +msgstr "Import" + +#: GeometryGUI.cxx:3761 +msgid "GEOM_MEN_IMPORT_BREP" +msgstr "BREP Files ( *.brep )" + +#: GeometryGUI.cxx:3762 +msgid "GEOM_MEN_IMPORT_IGES" +msgstr "IGES Files ( *.iges *.igs )" + +#: GeometryGUI.cxx:3763 +msgid "GEOM_MEN_IMPORT_STEP" +msgstr "STEP Files ( *.step *.stp )" + +#: GeometryGUI.cxx:2931 +msgid "GEOM_MEN_ISOS" +msgstr "Select Number Of Isos" + +#: GeometryGUI.cxx:4278 +msgid "GEOM_MEN_POPUP_NAME" +msgstr "%1 Objects" + +#: GeometryGUI.cxx:4414 +msgid "GEOM_MEN_SKETCHER_X" +msgstr "Enter a length to set X" + +#: GeometryGUI.cxx:4438 +msgid "GEOM_MEN_SKETCHER_Y" +msgstr "Enter a length to set Y" + +#: GeometryGUI.cxx:2898 +msgid "GEOM_MEN_TRANSPARENCY" +msgstr "Transparency" + +#: GeometryGUI.cxx:4413 +msgid "GEOM_MEN_X" +msgstr "X :" + +#: GeometryGUI.cxx:4437 +msgid "GEOM_MEN_Y" +msgstr "Y :" + +#: GeometryGUI_NbIsosDlg.cxx:36 +msgid "GEOM_MEN_ISOU" +msgstr "Isos u :" + +#: GeometryGUI_NbIsosDlg.cxx:53 +msgid "GEOM_MEN_ISOV" +msgstr "Isos v :" + +#: GeometryGUI_TransparencyDlg.cxx:31 +msgid "GEOM_MEN_TRANSPARENCY_LABEL" +msgstr "Transparency :" + +msgid "GEOM_MEN_STEP_LABEL" +msgstr "Step :" + + +msgid "GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE" +msgstr "Identical names : select by mouse !" + +msgid "GEOM_NAME_INCORRECT" +msgstr "Object name not found" + +# +#============================================================================== +# + +#: GeometryGUI.cxx:892 +msgid "GEOM_WRN_RADIUS_NULL" +msgstr "Radius is null" + +#: GeometryGUI.cxx:3854 +msgid "GEOM_WRN_WARNING" +msgstr "Warning" + +#: GeometryGUI.cxx:3854 +msgid "GEOM_REALLY_DELETE" +msgstr "Do you really want to delete object(s) ?" + +# +#============================================================================== +# + +#Object +msgid "GEOM_OBJECT" +msgstr "Object" + +#Main object +msgid "GEOM_MAIN_OBJECT" +msgstr "Main Object" + +#Tool object +msgid "GEOM_TOOL_OBJECT" +msgstr "Tool Object" + +#Base Object +msgid "GEOM_BASE_OBJECT" +msgstr "Base Object" + +#Path Object +msgid "GEOM_PATH_OBJECT" +msgstr "Path Object" + +#Objects +msgid "GEOM_OBJECTS" +msgstr "Objects" + +#Object i +msgid "GEOM_OBJECT_I" +msgstr "Object %1" + +#Object and result +msgid "GEOM_OBJECT_RESULT" +msgstr "Object And Result" + +#Point +msgid "GEOM_POINT" +msgstr "Point" + +#Base point +msgid "GEOM_BASE_POINT" +msgstr "Base Point" + +#Center Point +msgid "GEOM_CENTER_POINT" +msgstr "Center Point" + +#Diagonal Points +msgid "GEOM_DIAGONAL_POINTS" +msgstr "Diagonal Points" + +#Central Point +msgid "GEOM_CENTRAL_POINT" +msgstr "Central Point" + +#Points +msgid "GEOM_POINTS" +msgstr "Points" + +#Point i +msgid "GEOM_POINT_I" +msgstr "Point %1" + +#Arguments +msgid "GEOM_ARGUMENTS" +msgstr "Arguments" + +#Center +msgid "GEOM_CENTER" +msgstr "Center" + +#Radius +msgid "GEOM_RADIUS" +msgstr "Radius :" + +#Radius i +msgid "GEOM_RADIUS_I" +msgstr "Radius %1 :" + +#Height +msgid "GEOM_HEIGHT" +msgstr "Height :" + +#Length +msgid "GEOM_LENGTH" +msgstr "Length is :" + +#Weight +msgid "GEOM_WEIGHT" +msgstr "Weight :" + +#Coordinates +msgid "GEOM_COORDINATES" +msgstr "Coordinates" + +#Coor. +msgid "GEOM_COOR" +msgstr "Coord. :" + +#Reverse +msgid "GEOM_REVERSE" +msgstr "Reverse" + +#Reverse U +msgid "GEOM_REVERSE_U" +msgstr "Reverse U" + +#Reverse V +msgid "GEOM_REVERSE_V" +msgstr "Reverse V" + +#Angle +msgid "GEOM_ANGLE" +msgstr "Angle :" + +#Axis +msgid "GEOM_AXIS" +msgstr "Axis" + +#Matrix +msgid "GEOM_MATRIX" +msgstr "Matrix :" + +#Vector Length +msgid "GEOM_VECTOR_LENGTH" +msgstr "Vector Length :" + +#Reverse Vector +msgid "GEOM_REVERSE_VECTOR" +msgstr "Reverse Vector" + +#Plane Mirror +msgid "GEOM_PLANE_MIRROR" +msgstr "Plane Mirror" + +#Face Selection +msgid "GEOM_FACE_SELECTION" +msgstr "Face Selection" + +#Base +msgid "GEOM_BASE" +msgstr "Base" + +#Water Density +msgid "GEOM_WATER_DENSITY" +msgstr "Water Density :" + +#Meshing Deflection +msgid "GEOM_MESHING_DEFLECTION" +msgstr "Meshing Deflect. :" + +#Dimensions +msgid "GEOM_DIMENSIONS" +msgstr "Dimensions" + +#Precision +msgid "GEOM_PRECISION" +msgstr "Precision :" + +#Selection +msgid "GEOM_SELECTION" +msgstr "Selection" + +#Nb. Times +msgid "GEOM_NB_TIMES" +msgstr "Nb. Times :" + +#Nb. Times U +msgid "GEOM_NB_TIMES_U" +msgstr "Nb. Times U :" + +#Nb. Times V +msgid "GEOM_NB_TIMES_V" +msgstr "Nb. Times V :" + +#Step +msgid "GEOM_STEP" +msgstr "Step :" + +#Step V +msgid "GEOM_STEP_V" +msgstr "Step V :" + +#Step U +msgid "GEOM_STEP_U" +msgstr "Step U :" + +# +#============================================================================== +# + +#Partition +msgid "GEOM_PARTITION" +msgstr "Partition" + +#Tolerance +msgid "GEOM_TOLERANCE" +msgstr "Tolerance" + +#Orientation +msgid "GEOM_ORIENTATION" +msgstr "Orientation" + +#Pipe +msgid "GEOM_PIPE" +msgstr "Pipe" + +#Revolution +msgid "GEOM_REVOLUTION" +msgstr "Revolution" + +#Rotation +msgid "GEOM_ROTATION" +msgstr "Rotation" + +#Archimede +msgid "GEOM_ARCHIMEDE" +msgstr "Archimede" + +#Common +msgid "GEOM_COMMON" +msgstr "Common" + +#Cut +msgid "GEOM_CUT" +msgstr "Cut" + +#Distance +msgid "GEOM_DISTANCE" +msgstr "Distance" + +#Filling +msgid "GEOM_FILLING" +msgstr "Filling" + +#Fuse +msgid "GEOM_FUSE" +msgstr "Fuse" + +#Scale +msgid "GEOM_SCALE" +msgstr "Scale" + +#Section +msgid "GEOM_SECTION" +msgstr "Section" + +#Sewing +msgid "GEOM_SEWING" +msgstr "Sewing" + +#Translation +msgid "GEOM_TRANSLATION" +msgstr "Translation" + +#Working Plane +msgid "GEOM_WPLANE" +msgstr "Working Plane" + +#Mirror +msgid "GEOM_MIRROR" +msgstr "Mirror" + +#Prism +msgid "GEOM_PRISM" +msgstr "Prism" + +#Sub Shapes +msgid "GEOM_SUB_SHAPE" +msgstr "Sub Shapes" + +#Supress Face +msgid "GEOM_SUPRESSFACE" +msgstr "Supress Face" + +#Fillet +msgid "GEOM_FILLET" +msgstr "Fillet" + +#Chamfer +msgid "GEOM_CHAMFER" +msgstr "Chamfer" + +#Check Shape +msgid "GEOM_CHECK_SHAPE" +msgstr "Check Shape" + +#Whatis +msgid "GEOM_WHATIS" +msgstr "Whatis" + +#Bounding Box +msgid "GEOM_BNDBOX" +msgstr "Bounding Box" + +#Center Of Mass +msgid "GEOM_CMASS" +msgstr "Center Of Mass" + +#Basic Properties +msgid "GEOM_PROPERTIES" +msgstr "Basic Properties" + +#Multi-Translation +msgid "GEOM_MULTITRANSLATION" +msgstr "Multi-Translation" + +#Multi-Rotation +msgid "GEOM_MULTIROTATION" +msgstr "Multi-Rotation" + +# +#============================================================================== +# + +#Arc +msgid "GEOM_ARC" +msgstr "Arc" + +#Box +msgid "GEOM_BOX" +msgstr "Box" + +#Circle +msgid "GEOM_CIRCLE" +msgstr "Circle" + +#Ellipse +msgid "GEOM_ELLIPSE" +msgstr "Ellipse" + +msgid "GEOM_ELLIPSE_TITLE" +msgstr "Ellipse Construction" + +#Radius major +msgid "GEOM_RADIUS_MAJOR" +msgstr "Major radius :" + +#Radius minor +msgid "GEOM_RADIUS_MINOR" +msgstr "Minor radius :" + +#Compound +msgid "GEOM_COMPOUND" +msgstr "Compound" + +#CompSolid +msgid "GEOM_COMPOUNDSOLID" +msgstr "CompSolid" + +#Cone +msgid "GEOM_CONE" +msgstr "Cone" + +#Cylinder +msgid "GEOM_CYLINDER" +msgstr "Cylinder" + +#Edge +msgid "GEOM_EDGE" +msgstr "Edge" + +#Face +msgid "GEOM_FACE" +msgstr "Face" + +#Faces +msgid "GEOM_FACES" +msgstr "Faces" + +#Line +msgid "GEOM_LINE" +msgstr "Line" + +#Plane +msgid "GEOM_PLANE" +msgstr "Plane" + +#Shape +msgid "GEOM_SHAPE" +msgstr "Shape" + +#Shell +msgid "GEOM_SHELL" +msgstr "Shell" + +#Solid +msgid "GEOM_SOLID" +msgstr "Solid" + +#Sphere +msgid "GEOM_SPHERE" +msgstr "Sphere" + +#Conical Face +msgid "GEOM_SURFCONE" +msgstr "Conical Face" + +#Cylindrical Face +msgid "GEOM_SURFCYLINDER" +msgstr "Cylindrical Face" + +#Spherical Face +msgid "GEOM_SURFSPHERE" +msgstr "Spherical Face" + +#Toroidal Face +msgid "GEOM_SURFTORUS" +msgstr "Toroidal Face" + +#Torus +msgid "GEOM_TORUS" +msgstr "Torus" + +#Vector +msgid "GEOM_VECTOR" +msgstr "Vector" + +#Vector U +msgid "GEOM_VECTOR_U" +msgstr "Vector U" + +#Vector V +msgid "GEOM_VECTOR_V" +msgstr "Vector V" + +#Vertex +msgid "GEOM_VERTEX" +msgstr "Vertex" + +#Wire +msgid "GEOM_WIRE" +msgstr "Wire" + +#Parameter +msgid "GEOM_PARAMETER" +msgstr "Parameter :" + +# +#============================================================================== +# + +#Min +msgid "GEOM_MIN" +msgstr "Min :" + +#Max +msgid "GEOM_MAX" +msgstr "Max :" + +#X +msgid "GEOM_X" +msgstr "X :" + +#Y +msgid "GEOM_Y" +msgstr "Y :" + +#Z +msgid "GEOM_Z" +msgstr "Z :" + +#DX +msgid "GEOM_DX" +msgstr "Dx :" + +#DY +msgid "GEOM_DY" +msgstr "Dy :" + +#DZ +msgid "GEOM_DZ" +msgstr "Dz :" + +#D1 +msgid "GEOM_D1" +msgstr "D1 :" + +#D2 +msgid "GEOM_D2" +msgstr "D2 :" + +# +#============================================================================== +# + +#: GeometryGUI.cxx +msgid "GEOM_STEP_TITLE" +msgstr "Step value for GUI constructions" + +#: GeometryGUI_ArcDlg.cxx:45 +msgid "GEOM_ARC_TITLE" +msgstr "Arc Construction" + +#: GeometryGUI_ArchimedeDlg.cxx:55 +msgid "GEOM_ARCHIMEDE_TITLE" +msgstr "Archimede Construction" + +#: GeometryGUI_BndBoxDlg.cxx:59 +msgid "GEOM_BNDBOX_TITLE" +msgstr "Bounding Box Informations" + +#: GeometryGUI_BndBoxDlg.cxx:82 +msgid "GEOM_BNDBOX_OBJDIM" +msgstr "Object And Its Dimensions" + +#: GeometryGUI_BoxDlg.cxx:50 +msgid "GEOM_BOX_TITLE" +msgstr "Box Construction" + +#: GeometryGUI_BoxDlg.cxx:50 +msgid "GEOM_BOX_OBJ" +msgstr "Dimensions At Origin" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_TITLE" +msgstr "Chamfer Construction" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_ALL" +msgstr "Chamfer On Whole Shape" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_EDGES" +msgstr "Chamfer On Edges From Shape" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_FACES" +msgstr "Chamfer On Faces From Shape" + +#: GeometryGUI_CircleDlg.cxx:48 +msgid "GEOM_CIRCLE_TITLE" +msgstr "Circle Construction" + +#: GeometryGUI_CenterMassDlg.cxx:77 +msgid "GEOM_CMASS_TITLE" +msgstr "Center Of Mass Construction" + +msgid "GEOM_PLANE_SIZE" +msgstr "Size of plane :" + +#: GeometryGUI_CommonDlg.cxx:47 +msgid "GEOM_COMMON_TITLE" +msgstr "BOOLEAN : Common Of Two Objects" + +#: GeometryGUI_CompoundDlg.cxx:44 +msgid "GEOM_COMPOUND_TITLE" +msgstr "Create A Compound" + +#: GeometryGUI_ConeDlg.cxx:49 +msgid "GEOM_CONE_TITLE" +msgstr "Cone Construction" + +#: GeometryGUI_CutDlg.cxx:48 +msgid "GEOM_CUT_TITLE" +msgstr "BOOLEAN : Cut Of Two Objects" +# +#: GeometryGUI_CylinderDlg.cxx:47 +msgid "GEOM_CYLINDER_TITLE" +msgstr "Cylinder Construction" + +#: GeometryGUI_CheckShape.cxx:60 +msgid "GEOM_CHECK_TITLE" +msgstr "Check Shape Informations" + +#: GeometryGUI_CheckShape.cxx:83 +msgid "GEOM_CHECK_INFOS" +msgstr "Object And Its Topological Informations" + +#: GeometryGUI_DistanceDlg.cxx:57 +msgid "GEOM_MINDIST_TITLE" +msgstr "Minimun Distance Between Two Objects" + +#: GeometryGUI_DistanceDlg.cxx:57 +msgid "GEOM_MINDIST_OBJ" +msgstr "Objects And Results" + +#: GeometryGUI_EdgeDlg.cxx:47 +msgid "GEOM_EDGE_TITLE" +msgstr "Create An Edge" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_TITLE" +msgstr "Fillet Construction" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_ALL" +msgstr "Fillet On Whole Shape" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_EDGES" +msgstr "Fillet On Edges From Shape" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_FACES" +msgstr "Fillet On Faces From Shape" + +#: GeometryGUI_FaceDlg.cxx:49 +msgid "GEOM_FACE_TITLE" +msgstr "Create A Face" + +#: GeometryGUI_FaceDlg.cxx:78 +msgid "GEOM_FACE_FFW" +msgstr "Face from a wire" + +#: GeometryGUI_FaceDlg.cxx:103 +msgid "GEOM_FACE_OPT" +msgstr "Try to create a planar face" + +#: GeometryGUI_FillingDlg.cxx:53 +msgid "GEOM_FILLING_TITLE" +msgstr "Filling Surface With Curves" + +#: GeometryGUI_FillingDlg.cxx:112 +msgid "GEOM_FILLING_ARG" +msgstr "Arguments And Parameters" + +#: GeometryGUI_FillingDlg.cxx:128 +msgid "GEOM_FILLING_MIN_DEG" +msgstr "Min deg" + +#: GeometryGUI_FillingDlg.cxx:142 +msgid "GEOM_FILLING_MAX_DEG" +msgstr "Max deg" + +#: GeometryGUI_FillingDlg.cxx:150 +msgid "GEOM_FILLING_TOL_2D" +msgstr "Tol. 2D :" + +#: GeometryGUI_FillingDlg.cxx:170 +msgid "GEOM_FILLING_COMPOUND" +msgstr "Curves Comp." + +#: GeometryGUI_FillingDlg.cxx:184 +msgid "GEOM_FILLING_TOL_3D" +msgstr "Tol. 3D :" + +#: GeometryGUI_FillingDlg.cxx:192 +msgid "GEOM_FILLING_NB_ITER" +msgstr "Nb. Iter :" + +#: GeometryGUI_FuseDlg.cxx:48 +msgid "GEOM_FUSE_TITLE" +msgstr "BOOLEAN : Fuse Two Objects" + +#: GeometryGUI_InertiaDlg.cxx:42 +msgid "GEOM_INERTIA_TITLE" +msgstr "Calculs Of Inertia" + +#: GeometryGUI_InertiaDlg.cxx:50 +msgid "GEOM_INERTIA_CONSTR" +msgstr "Matrix And Moments Of Inertia" + +#: GeometryGUI_InertiaDlg.cxx:100 +msgid "GEOM_INERTIA_I" +msgstr "%1:1 :" + +#: GeometryGUI_InertiaDlg.cxx:182 +msgid "GEOM_INERTIA_IXYZ" +msgstr "IX & IY & IZ :" + +#: GeometryGUI_LineDlg.cxx:50 +msgid "GEOM_LINE_TITLE" +msgstr "Line Construction" + +#: GeometryGUI_MaxToleranceDlg.cxx:53 +msgid "GEOM_TOLERANCE_TITLE" +msgstr "Maximum Tolerance" + +#: GeometryGUI_MaxToleranceDlg.cxx:84 +msgid "GEOM_TOLERANCE_CONSTR" +msgstr "Object And Its Tolerances" + +#: GeometryGUI_MaxToleranceDlg.cxx:121 +msgid "GEOM_TOLERANCE_FACE" +msgstr "Face :" + +#: GeometryGUI_MaxToleranceDlg.cxx:138 +msgid "GEOM_TOLERANCE_EDGE" +msgstr "Edge :" + +#: GeometryGUI_MaxToleranceDlg.cxx:155 +msgid "GEOM_TOLERANCE_VERTEX" +msgstr "Vertex :" + +#: GeometryGUI_MirrorDlg.cxx:52 +msgid "GEOM_MIRROR_TITLE" +msgstr "Mirror An Object" + +#: GeometryGUI_OrientationDlg.cxx:46 +msgid "GEOM_ORIENTATION_TITLE" +msgstr "Change Orientation" + +#: GeometryGUI_OrientationDlg.cxx:134 +msgid "GEOM_ORIENTATION_OPT" +msgstr "Reverse orientation with normal vectors simulation" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "GEOM_PARTITION_TITLE" +msgstr "Partition Of Object With Tool" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "GEOM_KEEP_OBJECT" +msgstr "Keep Object" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "GEOM_PARTITION_ORIENTATION" +msgstr "Change Orientation" + +#: GeometryGUI_PipeDlg.cxx:47 +msgid "GEOM_PIPE_TITLE" +msgstr "Pipe Construction" + +#: GeometryGUI_PointDlg.cxx:52 +msgid "GEOM_POINT_TITLE" +msgstr "Point Construction" + +#: GeometryGUI_PlaneDlg.cxx:60 +msgid "GEOM_PLANE_TITLE" +msgstr "Plane Construction" + +#: GeometryGUI_PlaneDlg.cxx:172 +msgid "GEOM_PLANE_PVC" +msgstr "Point + Coordinate Vector" + +#: GeometryGUI_PlaneDlg.cxx:133 +msgid "GEOM_PLANE_PV" +msgstr "Point + Vector" + +#: GeometryGUI_PrismDlg.cxx:54 +msgid "GEOM_PRISM_TITLE" +msgstr "Prism Construction" + +#: GeometryGUI_PrismDlg.cxx:83 +msgid "GEOM_PRISM_BSV" +msgstr "Base Shape + Vector" + +#: GeometryGUI_PropertiesDlg.cxx:56 +msgid "GEOM_PROPERTIES_TITLE" +msgstr "Basic Properties Informations" + +#: GeometryGUI_PropertiesDlg.cxx:78 +msgid "GEOM_PROPERTIES_CONSTR" +msgstr "Object And Its Properties" + +#: GeometryGUI_PropertiesDlg.cxx:114 +msgid "GEOM_PROPERTIES_SURFACE" +msgstr "Surface is :" + +#: GeometryGUI_PropertiesDlg.cxx:120 +msgid "GEOM_PROPERTIES_VOLUME" +msgstr "Volume is :" + +#: GeometryGUI_RevolDlg.cxx:49 +msgid "GEOM_REVOLUTION_TITLE" +msgstr "Construction By Revolution" + +#: GeometryGUI_RotationDlg.cxx:51 +msgid "GEOM_ROTATION_TITLE" +msgstr "Rotation Of An Object" + +#: GeometryGUI_ScaleDlg.cxx:52 +msgid "GEOM_SCALE_TITLE" +msgstr "Scale An Object" + +#: GeometryGUI_ScaleDlg.cxx:117 +msgid "GEOM_SCALE_FACTOR" +msgstr "Scale Factor :" + +#: GeometryGUI_SectionDlg.cxx:50 +msgid "GEOM_SECTION_TITLE" +msgstr "BOOLEAN : Section Of Two Objects" + +#: GeometryGUI_SewingDlg.cxx:48 +msgid "GEOM_SEWING_TITLE" +msgstr "Sewing Topologies" + +#: GeometryGUI_ShellDlg.cxx:53 +msgid "GEOM_SHELL_TITLE" +msgstr "Shell Construction" + +#: GeometryGUI_SolidDlg.cxx:74 +msgid "GEOM_SOLID_TITLE" +msgstr "Solid Construction" + +#: GeometryGUI_SphereDlg.cxx:50 +msgid "GEOM_SPHERE_TITLE" +msgstr "Sphere Construction" + +#: GeometryGUI_SphereDlg.cxx:113 +msgid "GEOM_SPHERE_CR" +msgstr "Center + Radius" + +#: GeometryGUI_SphereDlg.cxx:146 +msgid "GEOM_SPHERE_RO" +msgstr "Radius At Origin" + +#: GeometryGUI_SubShapeDlg.cxx:55 +msgid "GEOM_SUBSHAPE_TITLE" +msgstr "Sub Shapes Selection" + +#: GeometryGUI_SubShapeDlg.cxx:131 +msgid "GEOM_SUBSHAPE_TYPE" +msgstr "Sub Shapes Type :" + +#: GeometryGUI_SubShapeDlg.cxx:137 +msgid "GEOM_SUBSHAPE_SELECT" +msgstr "Select Sub Shapes" + +#: GeometryGUI_TorusDlg.cxx:51 +msgid "GEOM_TORUS_TITLE" +msgstr "Torus Construction" + +#: GeometryGUI_SuppressFacesDlg.cxx:103 +msgid "GEOM_SUPRESSFACE_TITLE" +msgstr "Suppress Faces In An Object" + +#: GeometryGUI_SuppressFacesDlg.cxx:164 +msgid "GEOM_SUPRESSFACE_SELECT" +msgstr "Select Faces To Suppress" + +#: GeometryGUI_TranslationDlg.cxx:78 +msgid "GEOM_TRANSLATION_COOR" +msgstr "Translation With Coordinates" + +msgid "GEOM_TRANSPARENCY_TITLE" +msgstr "Transparency" + +msgid "GEOM_TRANSPARENCY_OPAQUE" +msgstr "Opaque" + +msgid "GEOM_TRANSPARENCY_TRANSPARENT" +msgstr "Transparent" + +msgid "GEOM_SUPPRESSHOLE_TITLE" +msgstr "Suppress holes" + +msgid "GEOM_SUPPRESSHOLE_SELECTFACE" +msgstr "Select the face with hole" + +msgid "GEOM_SUPPRESSHOLE_SELECTWIRE" +msgstr "Select wire on face" + +msgid "GEOM_SUPPRESSHOLE_SELECTFACE_END" +msgstr "Select end face (if hole traversing)" + +msgid "GEOM_SUPPRESSHOLE_SELECTWIRE_END" +msgstr "Select end wire (if hole traversing)" + +msgid "GEOM_SUPPRESSHOLE_FACE_SHELL" +msgstr "Face or shell" + +msgid "GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE" +msgstr "Select hole(s) on the face" + +#: GeometryGUI_TranslationDlg.cxx:56 +msgid "GEOM_TRANSLATION_TITLE" +msgstr "Translation Of An Object" + +#: GeometryGUI_VectorDlg.cxx:54 +msgid "GEOM_VECTOR_TITLE" +msgstr "Vector Construction" + +#: GeometryGUI_WhatisDlg.cxx:63 +msgid "GEOM_WHATIS_TITLE" +msgstr "Whatis Informations" + +#: GeometryGUI_WhatisDlg.cxx:86 +msgid "GEOM_WHATIS_OBJECT" +msgstr "Object And Its Topological Informations" + +#: GeometryGUI_WireDlg.cxx:46 +msgid "GEOM_WIRE_TITLE" +msgstr "Create A Wire" + +#: GeometryGUI_WireDlg.cxx:103 +msgid "GEOM_WIRE_CONNECT" +msgstr "Wire creation from wires/edges connected" + +#: GeometryGUI_WorkingPlaneDlg.cxx:50 +msgid "GEOM_WPLANE_TITLE" +msgstr "Working Plane Selection" + +#: GeometryGUI_WorkingPlaneDlg.cxx:107 +msgid "GEOM_WPLANE_FACE" +msgstr "Plane Or Planar Face" + +#: GeometryGUI_multiTranslationDlg.cxx:107 +msgid "GEOM_MULTITRANSLATION_TITLE" +msgstr "Multi-Translation" + +#: GeometryGUI_multiTranslationDlg.cxx:107 +msgid "GEOM_MULTITRANSLATION_SIMPLE" +msgstr "Multi Translation Simple" + +#: GeometryGUI_multiTranslationDlg.cxx:107 +msgid "GEOM_MULTITRANSLATION_DOUBLE" +msgstr "Multi Translation Double" + +#: GeometryGUI_multiRotationDlg.cxx:107 +msgid "GEOM_MULTIROTATION_TITLE" +msgstr "Multi-Rotation" + +#: GeometryGUI_multiRotationDlg.cxx:107 +msgid "GEOM_MULTIROTATION_SIMPLE" +msgstr "Multi Rotation Simple" + +#: GeometryGUI_multiRotationDlg.cxx:107 +msgid "GEOM_MULTIROTATION_DOUBLE" +msgstr "Multi Rotation Double" + +msgid "GEOM_PARAM_POINT" +msgstr "Parametric point" + + +# +#============================================================================== +# + +#: GeometryGUI.cxx:4613 +msgid "GEOM_MEN_WIREFRAME" +msgstr "Wireframe" + +#: GeometryGUI.cxx:4613 +msgid "GEOM_MEN_SHADING" +msgstr "\nShading" + +msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT" +msgstr "Reconstruction Limit" + +msgid "GeometryGUI_PartitionDlg::SUPPRESS_RESULT" +msgstr "Suppress Result" + +msgid "GeometryGUI_PartitionDlg::SUPPRESS_RESULT_INSIDE" +msgstr "Inside" + +msgid "GeometryGUI_PartitionDlg::SUPPRESS_RESULT_OUTSIDE" +msgstr "Outside" + +msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_SHAPE" +msgstr "Shape" +msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_SOLID" +msgstr "Solid" +msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_SHELL" +msgstr "Shell" +msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_FACE" +msgstr "Face" +msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_WIRE" +msgstr "Wire" +msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_EDGE" +msgstr "Edge" +msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_VERTEX" +msgstr "Vertex" diff --git a/src/GEOMBase/GEOM_msg_fr.po b/src/GEOMBase/GEOM_msg_fr.po new file mode 100644 index 000000000..fdeb94661 --- /dev/null +++ b/src/GEOMBase/GEOM_msg_fr.po @@ -0,0 +1,1130 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. translating +# from French to English, "Foo::Bar" would be translated to "Pub", +# not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-03-19 09:35:48 AM CET\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +# +#============================================================================== +# + +#Button Apply +msgid "GEOM_BUT_APPLY" +msgstr "&Appliquer" + +#Button Close +msgid "GEOM_BUT_CLOSE" +msgstr "&Fermer" + +#Button Cancel +msgid "GEOM_BUT_CANCEL" +msgstr "&Annuler" + +#Button Ok +msgid "GEOM_BUT_OK" +msgstr "&Ok" + +#Button Yes +msgid "GEOM_BUT_YES" +msgstr "&Oui" + +#Button Help +msgid "GEOM_BUT_HELP" +msgstr "&Aide" + + +#Button Explode +msgid "GEOM_BUT_EXPLODE" +msgstr "&Exploser" + +# +#============================================================================== +# + +#: GeometryGUI.cxx:563 +msgid "GEOM_INF_LOADED" +msgstr "Le fichier %1 est chargé." + +# +#============================================================================== +# + +#: GeometryGUI.cxx:3069 +msgid "GEOM_PRP_COMMAND" +msgstr "Pas de commande associée à l'id = %1." + +#: GeometryGUI.cxx:4977 +msgid "GEOM_PRP_ABORT" +msgstr "L'opération a echoué" + +#: GeometryGUI.cxx:5058 +msgid "GEOM_PRP_DONE" +msgstr "Opération effectuée" + +#: GeometryGUI.cxx:3717 +msgid "GEOM_PRP_LOADING" +msgstr "Chargement de %1 ..." + +#: GeometryGUI.cxx:1412 +msgid "GEOM_PRP_NULLSHAPE" +msgstr "Erreur, objet inconsistant ou inapproprié !" + +#: GeometryGUI.cxx:5072 +msgid "GEOM_PRP_READY" +msgstr "Prêt..." + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_SUBSHAPES" +msgstr "Selection de sous objets" + +msgid "GEOM_CONFIRM" +msgstr "Confirmer cette operation" + +msgid "GEOM_CONFIRM_INFO" +msgstr "L'objet contient %1 sous objets" + + +msgid "GEOM_PRP_NOT_FOR_VTK_VIEWER" +msgstr "Non permis dans viewer VTK" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SHAPE_IN_STUDY" +msgstr "La shape principale doit etre avant dans l'etude" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_EDGE" +msgstr "Selectionner les edges et clicker sur Apply" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_FACE" +msgstr "Select les faces a supprimer et clicker sur Ok/Apply" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_FIRST" +msgstr "Selectionner la shape principale en premier" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_MIN_DIST" +msgstr "Min Distance non calculer" + +# +#============================================================================== +# + +#: GeometryGUI.cxx:3698 +msgid "GEOM_MEN_ALL_FILES" +msgstr "Tous fichiers ( * )" + +#: GeometryGUI.cxx:4389 +msgid "GEOM_MEN_ANGLE" +msgstr "Angle :" + +#: GeometryGUI.cxx:3941 +msgid "GEOM_MEN_COMPONENT" +msgstr "Géometrie" + +#: GeometryGUI.cxx:4389 +msgid "GEOM_MEN_ENTER_ANGLE" +msgstr "Saisir un angle en degrés" + +#: GeometryGUI.cxx:3758 +msgid "GEOM_MEN_EXPORT" +msgstr "Exporter" + +#: GeometryGUI.cxx:3648 +msgid "GEOM_MEN_IMPORT" +msgstr "Importer" + +#: GeometryGUI.cxx:3761 +msgid "GEOM_MEN_IMPORT_BREP" +msgstr "Fichiers BREP ( *.brep )" + +#: GeometryGUI.cxx:3762 +msgid "GEOM_MEN_IMPORT_IGES" +msgstr "Fichiers IGES ( *.iges *.igs )" + +#: GeometryGUI.cxx:3763 +msgid "GEOM_MEN_IMPORT_STEP" +msgstr "Fichiers STEP ( *.step *.stp )" + +#: GeometryGUI.cxx:2931 +msgid "GEOM_MEN_ISOS" +msgstr "Choisir un nombre d'isos" + +#: GeometryGUI.cxx:4278 +msgid "GEOM_MEN_POPUP_NAME" +msgstr "%1 Objets" + +#: GeometryGUI.cxx:4414 +msgid "GEOM_MEN_SKETCHER_X" +msgstr "Saisir une longueur pour fixer X" + +#: GeometryGUI.cxx:4438 +msgid "GEOM_MEN_SKETCHER_Y" +msgstr "Saisir une longueur pour fixer Y" + +#: GeometryGUI.cxx:2898 +msgid "GEOM_MEN_TRANSPARENCY" +msgstr "Transparence" + +#: GeometryGUI.cxx:4413 +msgid "GEOM_MEN_X" +msgstr "X :" + +#: GeometryGUI.cxx:4437 +msgid "GEOM_MEN_Y" +msgstr "Y :" + +#: GeometryGUI_NbIsosDlg.cxx:36 +msgid "GEOM_MEN_ISOU" +msgstr "Isos u :" + +#: GeometryGUI_NbIsosDlg.cxx:53 +msgid "GEOM_MEN_ISOV" +msgstr "Isos v :" + +#: GeometryGUI_TransparencyDlg.cxx:31 +msgid "GEOM_MEN_TRANSPARENCY_LABEL" +msgstr "Transparence :" + +msgid "GEOM_MEN_STEP_LABEL" +msgstr "Increment" + +msgid "GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE" +msgstr "Noms identiques : selectionner avec la souris !" + +msgid "GEOM_NAME_INCORRECT" +msgstr "Le nom saisi n'existe pas" + + + +# +#============================================================================== +# + +#: GeometryGUI.cxx:892 +msgid "GEOM_WRN_RADIUS_NULL" +msgstr "Le rayon est nul" + +#: GeometryGUI.cxx:3854 +msgid "GEOM_WRN_WARNING" +msgstr "Avertissement" + +# +#============================================================================== +# + +#Object +msgid "GEOM_OBJECT" +msgstr "Objet" + +#Main object +msgid "GEOM_MAIN_OBJECT" +msgstr "Objet Principal" + +#Tool object +msgid "GEOM_TOOL_OBJECT" +msgstr "Objet Outil" + +#Base Object +msgid "GEOM_BASE_OBJECT" +msgstr "Objet De Base" + +#Path Object +msgid "GEOM_PATH_OBJECT" +msgstr "Objet Chemin" + +#Objects +msgid "GEOM_OBJECTS" +msgstr "Objets" + +#Object i +msgid "GEOM_OBJECT_I" +msgstr "Objet %1" + +#Object and result +msgid "GEOM_OBJECT_RESULT" +msgstr "Objet Et Résultat" + +#Point +msgid "GEOM_POINT" +msgstr "Point" + +#Base point +msgid "GEOM_BASE_POINT" +msgstr "Point De Base" + +#Center Point +msgid "GEOM_CENTER_POINT" +msgstr "Point Centre" + +#Diagonal Points +msgid "GEOM__DIAGONAL_POINTS" +msgstr "Points Diagonaux" + +#Central Point +msgid "GEOM_CENTRAL_POINT" +msgstr "Point Central" + +#Points +msgid "GEOM_POINTS" +msgstr "Points" + +#Point i +msgid "GEOM_POINT_I" +msgstr "Point %1" + +#Arguments +msgid "GEOM_ARGUMENTS" +msgstr "Arguments" + +#Center +msgid "GEOM_CENTER" +msgstr "Centre" + +#Radius +msgid "GEOM_RADIUS" +msgstr "Rayon" + +#Radius i +msgid "GEOM_RADIUS_I" +msgstr "Rayon %1" + +#Height +msgid "GEOM_HEIGHT" +msgstr "Hauteur" + +#Length +msgid "GEOM_LENGTH" +msgstr "Longueur :" + +#Weight +msgid "GEOM_WEIGHT" +msgstr "poids" + +#Coordinates +msgid "GEOM_COORDINATES" +msgstr "Coordonnées" + +#Coor. +msgid "GEOM_COOR" +msgstr "Coord. :" + +#Reverse +msgid "GEOM_REVERSE" +msgstr "Renverser" + +#Reverse U +msgid "GEOM_REVERSE_U" +msgstr "Renverser U" + +#Reverse V +msgid "GEOM_REVERSE_V" +msgstr "Reverser V" + +#Angle +msgid "GEOM_ANGLE" +msgstr "Angle :" + +#Axis +msgid "GEOM_AXIS" +msgstr "Axe" + +#Matrix +msgid "GEOM_MATRIX" +msgstr "Matrice :" + +#Vector Length +msgid "GEOM_VECTOR_LENGTH" +msgstr "Longueur Du Vecteur :" + +#Reverse Vector +msgid "GEOM_REVERSE_VECTOR" +msgstr "Renverser Le Vecteur" + +#Plane Mirror +msgid "GEOM_PLANE_MIRROR" +msgstr "Plan Miroir" + +#Face Selection +msgid "GEOM_FACE_SELECTION" +msgstr "Selection de Face" + +#Base +msgid "GEOM_BASE" +msgstr "Base" + +#Water Density +msgid "GEOM_WATER_DENSITY" +msgstr "Densité de l'eau :" + +#Meshing Deflection +msgid "GEOM_MESHING_DEFLECTION" +msgstr "Déflection Du Maillage :" + +#Dimensions +msgid "GEOM_DIMENSIONS" +msgstr "Dimensions" + +#Precision +msgid "GEOM_PRECISION" +msgstr "Précision :" + +#Selection +msgid "GEOM_SELECTION" +msgstr "Sélection" + +#Nb. Times +msgid "GEOM_NB_TIMES" +msgstr "Nb. Fois :" + +#Nb. Times U +msgid "GEOM_NB_TIMES_U" +msgstr "Nb. Fois U :" + +#Nb. Times V +msgid "GEOM_NB_TIMES_V" +msgstr "Nb. Fois V :" + +#Step +msgid "GEOM_STEP" +msgstr "Pas :" + +#Step V +msgid "GEOM_STEP_V" +msgstr "Pas V :" + +#Step U +msgid "GEOM_STEP_U" +msgstr "Pas U :" + +# +#============================================================================== +# + +#Partition +msgid "GEOM_PARTITION" +msgstr "Partition" + +#Tolerance +msgid "GEOM_TOLERANCE" +msgstr "Tolérance" + +#Orientation +msgid "GEOM_ORIENTATION" +msgstr "Orientation" + +#Pipe +msgid "GEOM_PIPE" +msgstr "Pipe" + +#Revolution +msgid "GEOM_REVOLUTION" +msgstr "Révolution" + +#Rotation +msgid "GEOM_ROTATION" +msgstr "Rotation" + +#Archimede +msgid "GEOM_ARCHIMEDE" +msgstr "Archimède" + +#Common +msgid "GEOM_COMMON" +msgstr "Joindre" + +#Cut +msgid "GEOM_CUT" +msgstr "Couper" + +#Distance +msgid "GEOM_DISTANCE" +msgstr "Distance" + +#Filling +msgid "GEOM_FILLING" +msgstr "Surface Par Courbes" + +#Fuse +msgid "GEOM_FUSE" +msgstr "Fusionner" + +#Scale +msgid "GEOM_SCALE" +msgstr "Echelle" + +#Section +msgid "GEOM_SECTION" +msgstr "Section" + +#Sewing +msgid "GEOM_SEWING" +msgstr "Coudre" + +#Translation +msgid "GEOM_TRANSLATION" +msgstr "Translation" + +#Working Plane +msgid "GEOM_WPLANE" +msgstr "Plan de Travail" + +#Mirror +msgid "GEOM_MIRROR" +msgstr "Miroir" + +#Prism +msgid "GEOM_PRISM" +msgstr "Extrusion" + +#Sub Shapes +msgid "GEOM_SUB_SHAPE" +msgstr "Sous Shapes" + +#Supress Face +msgid "GEOM_SUPRESSFACE" +msgstr "Supression de Face" + +#Fillet +msgid "GEOM_FILLET" +msgstr "Conge" + +#Chamfer +msgid "GEOM_CHAMFER" +msgstr "Chanfrein" + +#Check Shape +msgid "GEOM_CHECK_SHAPE" +msgstr "Check Shape" + +#Whatis +msgid "GEOM_WHATIS" +msgstr "Whatis" + +#Bounding Box +msgid "GEOM_BNDBOX" +msgstr "Boite Anglobante" + +#Center Of Mass +msgid "GEOM_CMASS" +msgstr "Centre de Masse" + +#Basic Properties +msgid "GEOM_PROPERTIES" +msgstr "Basiques Proprietes" + +#Multi-Translation +msgid "GEOM_MULTITRANSLATION" +msgstr "Multi-Translation" + +#Multi-Rotation +msgid "GEOM_MULTIROTATION" +msgstr "Multi-Rotation" + +# +#============================================================================== +# + +#Arc +msgid "GEOM_ARC" +msgstr "Arc" + +#Box +msgid "GEOM_BOX" +msgstr "Boite" + +#Circle +msgid "GEOM_CIRCLE" +msgstr "Cercle" + +#Compound +msgid "GEOM_COMPOUND" +msgstr "Compound" + +#CompSolid +msgid "GEOM_COMPOUNDSOLID" +msgstr "CompSolid" + +#Cone +msgid "GEOM_CONE" +msgstr "Cone" + +#Cylinder +msgid "GEOM_CYLINDER" +msgstr "Cylindre" + +#Edge +msgid "GEOM_EDGE" +msgstr "Edge" + +#Face +msgid "GEOM_FACE" +msgstr "Face" + +#Faces +msgid "GEOM_FACES" +msgstr "Faces" + +#Line +msgid "GEOM_LINE" +msgstr "Ligne" + +#Plane +msgid "GEOM_PLANE" +msgstr "Plan" + +#Shape +msgid "GEOM_SHAPE" +msgstr "Shape" + +#Shell +msgid "GEOM_SHELL" +msgstr "Shell" + +#Solid +msgid "GEOM_SOLID" +msgstr "Solide" + +#Sphere +msgid "GEOM_SPHERE" +msgstr "Sphère" + +#Conical Face +msgid "GEOM_SURFCONE" +msgstr "Face Conique" + +#Cylindrical Face +msgid "GEOM_SURFCYLINDER" +msgstr "Face Cylindrique" + +#Spherical Face +msgid "GEOM_SURFSPHERE" +msgstr "Face Sphèrique" + +#Toroidal Face +msgid "GEOM_SURFTORUS" +msgstr "Face Toroique" + +#Torus +msgid "GEOM_TORUS" +msgstr "Tore" + +#Vector +msgid "GEOM_VECTOR" +msgstr "Vecteur" + +#Vector U +msgid "GEOM_VECTOR_U" +msgstr "Vecteur U" + +#Vector V +msgid "GEOM_VECTOR_V" +msgstr "Vecteur V" + +#Vertex +msgid "GEOM_VERTEX" +msgstr "Vertex" + +#Wire +msgid "GEOM_WIRE" +msgstr "Wire" + +#Parameter +msgid "GEOM_PARAMETER" +msgstr "Paramètre :" + + +# +#============================================================================== +# + +#Min +msgid "GEOM_MIN" +msgstr "Min :" + +#Max +msgid "GEOM_MAX" +msgstr "Max :" + +#X +msgid "GEOM_X" +msgstr "X :" + +#Y +msgid "GEOM_Y" +msgstr "Y :" + +#Z +msgid "GEOM_Z" +msgstr "Z :" + +#DX +msgid "GEOM_DX" +msgstr "Dx :" + +#DY +msgid "GEOM_DY" +msgstr "Dy :" + +#DZ +msgid "GEOM_DZ" +msgstr "Dz :" + +#D1 +msgid "GEOM_D1" +msgstr "D1 :" + +#D2 +msgid "GEOM_D2" +msgstr "D2 :" + +# +#============================================================================== +# + +#: GeometryGUI.cxx +msgid "GEOM_STEP_TITLE" +msgstr "Increment par défaut lors des constructions" + +#: GeometryGUI_ArcDlg.cxx:45 +msgid "GEOM_ARC_TITLE" +msgstr "Construction d'un Arc" + +#: GeometryGUI_ArchimedeDlg.cxx:55 +msgid "GEOM_ARCHIMEDE_TITLE" +msgstr "Construction d'Archimède" + +#: GeometryGUI_BndBoxDlg.cxx:59 +msgid "GEOM_BNDBOX_TITLE" +msgstr "Boite Englobante" + +#: GeometryGUI_BndBoxDlg.cxx:82 +msgid "GEOM_BNDBOX_OBJDIM" +msgstr "Objet and ses dimensions" + +#: GeometryGUI_BoxDlg.cxx:50 +msgid "GEOM_BOX_TITLE" +msgstr "Construction d'une Boite" + +#: GeometryGUI_BoxDlg.cxx:50 +msgid "GEOM_BOX_OBJ" +msgstr "Dimensions A l'Origine" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_TITLE" +msgstr "Construction d'un Chanfrein" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_ALL" +msgstr "Chanfrein sur toute la Shape" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_EDGES" +msgstr "Chanfrein sur Edges de la Shape" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_FACES" +msgstr "Chanfrein sur Faces de la Shape" + +#: GeometryGUI_CircleDlg.cxx:48 +msgid "GEOM_CIRCLE_TITLE" +msgstr "Construction d'un Cercle" + +#: GeometryGUI_CenterMassDlg.cxx:77 +msgid "GEOM_CMASS_TITLE" +msgstr "Centre De Gravité" + +msgid "GEOM_PLANE_SIZE" +msgstr "Taille du plan :" + +#: GeometryGUI_CommonDlg.cxx:47 +msgid "GEOM_COMMON_TITLE" +msgstr "BOOLEEN : Jonction De Deux Objets" + +#: GeometryGUI_CompoundDlg.cxx:44 +msgid "GEOM_COMPOUND_TITLE" +msgstr "Création d'un Compound" + +#: GeometryGUI_ConeDlg.cxx:49 +msgid "GEOM_CONE_TITLE" +msgstr "Construction d'un Cone" + +#: GeometryGUI_CutDlg.cxx:48 +msgid "GEOM_CUT_TITLE" +msgstr "BOOLEEN : Couper Deux Objets" +# +#: GeometryGUI_CylinderDlg.cxx:47 +msgid "GEOM_CYLINDER_TITLE" +msgstr "Construction d'un Cylindre" + +#: GeometryGUI_CheckShape.cxx:60 +msgid "GEOM_CHECK_TITLE" +msgstr "Check Shape" + +#: GeometryGUI_CheckShape.cxx:83 +msgid "GEOM_CHECK_INFOS" +msgstr "Objet et ses Informations Topologiques" + +#: GeometryGUI_DistanceDlg.cxx:57 +msgid "GEOM_MINDIST_TITLE" +msgstr "Distance Minimale entre Deux Objets" + +#: GeometryGUI_DistanceDlg.cxx:57 +msgid "GEOM_MINDIST_OBJ" +msgstr "Objets Et Resultats" + +#: GeometryGUI_EdgeDlg.cxx:47 +msgid "GEOM_EDGE_TITLE" +msgstr "Création d'un Edge" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_TITLE" +msgstr "Construction d'un Congé" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_ALL" +msgstr "Congé sur toute la Shape" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_EDGES" +msgstr "Congé sur Edges de la Shape" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_FACES" +msgstr "Congé sur Faces de la Shape" + +#: GeometryGUI_FaceDlg.cxx:49 +msgid "GEOM_FACE_TITLE" +msgstr "Création d'une Face" + +#: GeometryGUI_FaceDlg.cxx:78 +msgid "GEOM_FACE_FFW" +msgstr "Face a partir d'un wire" + +#: GeometryGUI_FaceDlg.cxx:103 +msgid "GEOM_FACE_OPT" +msgstr "Création d'une Face plane" + +#: GeometryGUI_FillingDlg.cxx:53 +msgid "GEOM_FILLING_TITLE" +msgstr "Surface Par Courbes" + +#: GeometryGUI_FillingDlg.cxx:112 +msgid "GEOM_FILLING_ARG" +msgstr "Argument Et Parametres" + +#: GeometryGUI_FillingDlg.cxx:128 +msgid "GEOM_FILLING_MIN_DEG" +msgstr "Min. Deg" + +#: GeometryGUI_FillingDlg.cxx:142 +msgid "GEOM_FILLING_MAX_DEG" +msgstr "Max. Deg" + +#: GeometryGUI_FillingDlg.cxx:150 +msgid "GEOM_FILLING_TOL_2D" +msgstr "Tol. 2D" + +#: GeometryGUI_FillingDlg.cxx:170 +msgid "GEOM_FILLING_COMPOUND" +msgstr "Compound de Courbes" + +#: GeometryGUI_FillingDlg.cxx:184 +msgid "GEOM_FILLING_TOL_3D" +msgstr "Tol. 3D" + +#: GeometryGUI_FillingDlg.cxx:192 +msgid "GEOM_FILLING_NB_ITER" +msgstr "Nb. Iter" + +#: GeometryGUI_FuseDlg.cxx:48 +msgid "GEOM_FUSE_TITLE" +msgstr "BOOLEEN : Fusionner deux Objets" + +#: GeometryGUI_InertiaDlg.cxx:42 +msgid "GEOM_INERTIA_TITLE" +msgstr "Calculs d'Inertie" + +#: GeometryGUI_InertiaDlg.cxx:50 +msgid "GEOM_INERTIA_CONSTR" +msgstr "Matrice Et Moments d'Inertie" + +#: GeometryGUI_InertiaDlg.cxx:100 +msgid "GEOM_INERTIA_I" +msgstr "%1:1" + +#: GeometryGUI_InertiaDlg.cxx:182 +msgid "GEOM_INERTIA_IXYZ" +msgstr "IX & IY & IZ" + +#: GeometryGUI_LineDlg.cxx:50 +msgid "GEOM_LINE_TITLE" +msgstr "Construction d'une Ligne" + +#: GeometryGUI_MaxToleranceDlg.cxx:53 +msgid "GEOM_TOLERANCE_TITLE" +msgstr "Tolerance Maximale" + +#: GeometryGUI_MaxToleranceDlg.cxx:84 +msgid "GEOM_TOLERANCE_CONSTR" +msgstr "Object et ses Tolerances" + +#: GeometryGUI_MaxToleranceDlg.cxx:121 +msgid "GEOM_TOLERANCE_FACE" +msgstr "Face :" + +#: GeometryGUI_MaxToleranceDlg.cxx:138 +msgid "GEOM_TOLERANCE_EDGE" +msgstr "Edge :" + +#: GeometryGUI_MaxToleranceDlg.cxx:155 +msgid "GEOM_TOLERANCE_VERTEX" +msgstr "Vertex :" + +#: GeometryGUI_MirrorDlg.cxx:52 +msgid "GEOM_MIRROR_TITLE" +msgstr "Methode Miroir" + +#: GeometryGUI_OrientationDlg.cxx:46 +msgid "GEOM_ORIENTATION_TITLE" +msgstr "Changer l'Orientation" + +#: GeometryGUI_OrientationDlg.cxx:134 +msgid "GEOM_ORIENTATION_OPT" +msgstr "Renverser l'orientation avec une simulation de vecteur normal" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "GEOM_PARTITION_TITLE" +msgstr "Partition d'Objects Avec Outils" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "GEOM_KEEP_OBJECT" +msgstr "Objet garde" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "GEOM_PARTITION_ORIENTATION" +msgstr "Change l'orientation" + +#: GeometryGUI_PipeDlg.cxx:47 +msgid "GEOM_PIPE_TITLE" +msgstr "Construction d'une Pipe" + +#: GeometryGUI_PointDlg.cxx:52 +msgid "GEOM_POINT_TITLE" +msgstr "Construction d'un Point" + +#: GeometryGUI_PlaneDlg.cxx:60 +msgid "GEOM_PLANE_TITLE" +msgstr "Construction d'un Plan" + +#: GeometryGUI_PlaneDlg.cxx:172 +msgid "GEOM_PLANE_PVC" +msgstr "Point + Vecteur Coordonnes" + +#: GeometryGUI_PlaneDlg.cxx:133 +msgid "GEOM_PLANE_PV" +msgstr "Point + Vecteur" + +#: GeometryGUI_PrismDlg.cxx:54 +msgid "GEOM_PRISM_TITLE" +msgstr "Extruder une Shape de base" + +#: GeometryGUI_PrismDlg.cxx:83 +msgid "GEOM_PRISM_BSV" +msgstr "Shape de base + Vecteur" + +#: GeometryGUI_PropertiesDlg.cxx:56 +msgid "GEOM_PROPERTIES_TITLE" +msgstr "Proprietes Basiques" + +#: GeometryGUI_PropertiesDlg.cxx:78 +msgid "GEOM_PROPERTIES_CONSTR" +msgstr "Objet et ses Proprietes" + +#: GeometryGUI_PropertiesDlg.cxx:114 +msgid "GEOM_PROPERTIES_SURFACE" +msgstr "Surface :" + +#: GeometryGUI_PropertiesDlg.cxx:120 +msgid "GEOM_PROPERTIES_VOLUME" +msgstr "Volume :" + +#: GeometryGUI_RevolDlg.cxx:49 +msgid "GEOM_REVOLUTION_TITLE" +msgstr "Construction Par Revolution" + +#: GeometryGUI_RotationDlg.cxx:51 +msgid "GEOM_ROTATION_TITLE" +msgstr "Rotation d'un Objet" + +#: GeometryGUI_ScaleDlg.cxx:52 +msgid "GEOM_SCALE_TITLE" +msgstr "Echelle d'un Objet" + +#: GeometryGUI_ScaleDlg.cxx:117 +msgid "GEOM_SCALE_FACTOR" +msgstr "Facteur d'echelle" + +#: GeometryGUI_SectionDlg.cxx:50 +msgid "GEOM_SECTION_TITLE" +msgstr "BOOLEEN : Section De Deux Objets" + +#: GeometryGUI_SewingDlg.cxx:48 +msgid "GEOM_SEWING_TITLE" +msgstr "Coudre des Topologies" + +#: GeometryGUI_ShellDlg.cxx:53 +msgid "GEOM_SHELL_TITLE" +msgstr "Construction d'une Shell" + +#: GeometryGUI_ShellDlg.cxx:74 +msgid "GEOM_SHELL_LIST" +msgstr "List de Faces Connectees" + +#: GeometryGUI_SphereDlg.cxx:50 +msgid "GEOM_SPHERE_TITLE" +msgstr "Construction d'une Sphere" + +#: GeometryGUI_SphereDlg.cxx:113 +msgid "GEOM_SPHERE_CR" +msgstr "Centre + rayon" + +#: GeometryGUI_SphereDlg.cxx:146 +msgid "GEOM_SPHERE_RO" +msgstr "Rayon a l'origine" + +#: GeometryGUI_SubShapeDlg.cxx:55 +msgid "GEOM_SUBSHAPE_TITLE" +msgstr "Selection de Sous Shapes" + +#: GeometryGUI_SubShapeDlg.cxx:131 +msgid "GEOM_SUBSHAPE_TYPE" +msgstr "Type de Sous Shapes" + +#: GeometryGUI_SubShapeDlg.cxx:137 +msgid "GEOM_SUBSHAPE_SELECT" +msgstr "Selectionner de Sous Shapes" + +#: GeometryGUI_TorusDlg.cxx:51 +msgid "GEOM_TORUS_TITLE" +msgstr "Constructiond'un Tore" + +#: GeometryGUI_SuppressFacesDlg.cxx:103 +msgid "GEOM_SUPRESSFACE_TITLE" +msgstr "Supprimer des Faces dans un Objet" + +#: GeometryGUI_SuppressFacesDlg.cxx:164 +msgid "GEOM_SUPRESSFACE_SELECT" +msgstr "Selectionner les Faces a Supprimer" + +#: GeometryGUI_TranslationDlg.cxx:78 +msgid "GEOM_TRANSLATION_COOR" +msgstr "Translation Avec Coordonnees" + +msgid "GEOM_TRANSPARENCY_TITLE" +msgstr "Transparence" + +msgid "GEOM_TRANSPARENCY_OPAQUE" +msgstr "Opaque" + +msgid "GEOM_TRANSPARENCY_TRANSPARENT" +msgstr "Transparent" + +msgid "GEOM_SUPPRESSHOLE_TITLE" +msgstr "Suppression de trous" + +msgid "GEOM_SUPPRESSHOLE_SELECTFACE" +msgstr "Selection de la face initiale" + +msgid "GEOM_SUPPRESSHOLE_SELECTWIRE" +msgstr "Selection du contour/trou sur la face" + +msgid "GEOM_SUPPRESSHOLE_SELECTFACE_END" +msgstr "Selection de la face terminale (si trou traversant)" + +msgid "GEOM_SUPPRESSHOLE_SELECTWIRE_END" +msgstr "Selection de contour final (si trou traversant)" + +msgid "GEOM_SUPPRESSHOLE_FACE_SHELL" +msgstr "Face ou shell" + +msgid "GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE" +msgstr "Selection de trou(s) sur la face" + +#: GeometryGUI_TranslationDlg.cxx:56 +msgid "GEOM_TRANSLATION_TITLE" +msgstr "Translation d'un Objet" + +#: GeometryGUI_VectorDlg.cxx:54 +msgid "GEOM_VECTOR_TITLE" +msgstr "Construction d'un Vecteur" + +#: GeometryGUI_WhatisDlg.cxx:63 +msgid "GEOM_WHATIS_TITLE" +msgstr "Whatis" + +#: GeometryGUI_WhatisDlg.cxx:86 +msgid "GEOM_WHATIS_OBJECT" +msgstr "Objet et ses Informations Topologiques" + +#: GeometryGUI_WireDlg.cxx:46 +msgid "GEOM_WIRE_TITLE" +msgstr "Creer un Wire" + +#: GeometryGUI_WireDlg.cxx:103 +msgid "GEOM_WIRE_CONNECT" +msgstr "Creation d'un Wire a partir de wires/edges connectes" + +#: GeometryGUI_WorkingPlaneDlg.cxx:50 +msgid "GEOM_WPALNE_TITLE" +msgstr "plan de travail" + +#: GeometryGUI_WorkingPlaneDlg.cxx:107 +msgid "GEOM_WPALNE_FACE" +msgstr "Plan Ou Face plane" + +#: GeometryGUI_multiTranslationDlg.cxx:107 +msgid "GEOM_MULTITRANSLATION_TITLE" +msgstr "Multi-Translation" + +#: GeometryGUI_multiTranslationDlg.cxx:107 +msgid "GEOM_MULTITRANSLATION_SIMPLE" +msgstr "Multi Translation Simple" + +#: GeometryGUI_multiTranslationDlg.cxx:107 +msgid "GEOM_MULTITRANSLATION_DOUBLE" +msgstr "Multi Translation Double" + +#: GeometryGUI_multiRotationDlg.cxx:107 +msgid "GEOM_MULTIROTATION_TITLE" +msgstr "Multi-Rotation" + +#: GeometryGUI_multiRotationDlg.cxx:107 +msgid "GEOM_MULTIROTATION_SIMPLE" +msgstr "Multi Rotation Simple" + +#: GeometryGUI_multiRotationDlg.cxx:107 +msgid "GEOM_MULTIROTATION_DOUBLE" +msgstr "Multi Rotation Double" + +msgid "GEOM_PARAM_POINT" +msgstr "Point paramétrique" + +# +#============================================================================== +# + +#: GeometryGUI.cxx:4613 +msgid "GEOM_MEN_WIREFRAME" +msgstr "Filaire" + +#: GeometryGUI.cxx:4613 +msgid "GEOM_MEN_SHADING" +msgstr "Ombré" diff --git a/src/GEOMBase/Makefile.in b/src/GEOMBase/Makefile.in new file mode 100644 index 000000000..8d4bba71e --- /dev/null +++ b/src/GEOMBase/Makefile.in @@ -0,0 +1,89 @@ +# GEOM GEOMBASE : +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Damien COQUERET (OCC) +# Module : GEOM +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# Libraries targets +LIB = libGEOMBase.la + +# ressources files +PO_FILES = \ + GEOM_icons.po \ + GEOM_msg_en.po \ + GEOM_msg_fr.po + +# header files +EXPORT_HEADERS= GEOMBase_Context.h \ + GEOMBase_Skeleton.h \ + GEOMBase_Tools.h \ + GEOMBase_Display.h \ + GEOMBase_Sketcher.h + +LIB_SRC = GEOMBase_Context.cxx \ + GEOMBase_Skeleton.cxx \ + GEOMBase_Tools.cxx \ + GEOMBase_Display.cxx \ + GEOMBase_aParameterDlg.cxx \ + GEOMBase_NbIsosDlg.cxx \ + GEOMBase_TransparencyDlg.cxx \ + GEOMBase_Sketcher.cxx + +LIB_MOC = \ + GEOMBase_Context.h \ + GEOMBase_Skeleton.h \ + GEOMBase_Tools.h \ + GEOMBase_Display.h \ + GEOMBase_aParameterDlg.h \ + GEOMBase_NbIsosDlg.h \ + GEOMBase_TransparencyDlg.h \ + GEOMBase_Sketcher.h + +LIB_CLIENT_IDL = SALOME_Exception.idl \ + GEOM_Gen.idl \ + GEOM_Shape.idl \ + SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +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 -lGEOMSketcher -lDlgRef $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index d16a2e41e..1e5d2bc54 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -29,6052 +29,230 @@ using namespace std; #include "GeometryGUI.h" -// SALOME Includes -# include "Utils_ORB_INIT.hxx" -# include "Utils_SINGLETON.hxx" - -#include "QAD.h" -#include "QAD_Tools.h" -#include "QAD_Config.h" -#include "QAD_Settings.h" -#include "QAD_RightFrame.h" -#include "QAD_MessageBox.h" -#include "QAD_Resource.h" -#include "QAD_FileDlg.h" - -#include "OCCViewer_ViewPort.h" -#include "OCCViewer_ViewPort3d.h" -#include "OCCViewer_Viewer3d.h" - -#include "SALOME_NamingService.hxx" -#include "SALOME_ListIteratorOfListIO.hxx" -#include "SALOME_InteractiveObject.hxx" - -#include "SALOMEGUI_ImportOperation.h" -#include "SALOMEGUI_QtCatchCorbaException.hxx" -#include "SALOMEGUI_NameDlg.h" -#include "utilities.h" - // Open CASCADE Includes -#include -#include #include -#include -#include #include #include -#include - -#include -#include -#include #include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -//VRV: OCC 4.0 migration -#include -#include -#include -//#include -//VRV: OCC 4.0 migration - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -// QT Includes -#define INCLUDE_MENUITEM_DEF -// #include -// #include -// #include -// #include -// #include -// #include -// #include -#include -#include -#include -// #include -// #include -// #include -// #include +// SALOME Includes +#include "QAD_RightFrame.h" +#include "QAD_Resource.h" -#include "VTKViewer_RenderWindowInteractor.h" +#include "OCCViewer_ViewPort.h" +#include "OCCViewer_ViewPort3d.h" +#include "OCCViewer_Viewer3d.h" #include "VTKViewer_ViewFrame.h" -#include "GEOM_Actor.h" -//#include "GEOM_Client.hxx" -#include "GEOM_AISShape.hxx" #include "GEOM_AssemblyBuilder.h" -#include "GEOM_InteractiveObject.hxx" - - -#include "GeometryGUI_aParameterDlg.h" - -#include "GeometryGUI_PointDlg.h" // Method POINT - -#include "GeometryGUI_VectorDlg.h" // Method VECTOR -#include "GeometryGUI_PlaneDlg.h" // Method PLANE -#include "GeometryGUI_PrismDlg.h" // Method PRISM -#include "GeometryGUI_LineDlg.h" // Method LINE -#include "GeometryGUI_ScaleDlg.h" // Method SCALE -#include "GeometryGUI_MirrorDlg.h" // Method MIRROR - -#include "GeometryGUI_CircleDlg.h" // Method CIRCLE -#include "GeometryGUI_EllipseDlg.h" // Method ELLIPSE -#include "GeometryGUI_RevolDlg.h" // Method REVOL -#include "GeometryGUI_RotationDlg.h" // Method ROTATION -#include "GeometryGUI_TranslationDlg.h" // Method TRANSLATION -#include "GeometryGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION -#include "GeometryGUI_MultiRotationDlg.h" // Method MULTI ROTATION -#include "GeometryGUI_ArcDlg.h" // Method ARC -#include "GeometryGUI_PipeDlg.h" // Method PIPE -#include "GeometryGUI_FillingDlg.h" // Method FILLING -#include "GeometryGUI_SewingDlg.h" // Method SEWING -#include "GeometryGUI_CompoundDlg.h" // Method GEOM::COMPOUND -#include "GeometryGUI_EdgeDlg.h" // Method GEOM::EDGE -#include "GeometryGUI_OrientationDlg.h" // Method ORIENTATION -#include "GeometryGUI_PartitionDlg.h" // Method PARTITION -#include "GeometryGUI_SubShapeDlg.h" // Method EXPLODE -#include "GeometryGUI_WireDlg.h" // Method GEOM::WIRE -#include "GeometryGUI_WorkingPlaneDlg.h" // Method WORKING PLANE -#include "GeometryGUI_PropertiesDlg.h" // Method PROPERTIES -#include "GeometryGUI_CenterMassDlg.h" // Method CENTER MASS -#include "GeometryGUI_InertiaDlg.h" // Method INERTIA -#include "GeometryGUI_FaceDlg.h" // Method GEOM::FACE -#include "GeometryGUI_ShellDlg.h" // Method GEOM::SHELL -#include "GeometryGUI_SolidDlg.h" // Method GEOM::SOLID -#include "GeometryGUI_FilletDlg.h" // Method FILLET -#include "GeometryGUI_ChamferDlg.h" // Method CHAMFER -#include "GeometryGUI_FillingHoleDlg.h" // Method FILLING HOLE -#include "GeometryGUI_SuppressFacesDlg.h" // Method SUPPRESS FACES -#include "GeometryGUI_CheckShape.h" // Method CHECKSHAPE -#include "GeometryGUI_ArchimedeDlg.h" // Method ARCHIMEDE -#include "GeometryGUI_TransparencyDlg.h" // Method TRANSPARENCY adjustement -#include "GeometryGUI_NbIsosDlg.h" // Method ISOS adjustement -#include "GeometryGUI_BndBoxDlg.h" // Method BNDBOX -#include "GeometryGUI_MaxToleranceDlg.h" // Method MAXTOLERANCE -#include "GeometryGUI_WhatisDlg.h" // Method WHATIS -#include "GeometryGUI_DistanceDlg.h" // Method DISTANCE -#include "GeometryGUI_SuppressHoleDlg.h" // Method SUPPRESS HOLE - -#include "BooleanGUI.h" -#include "PrimitiveGUI.h" - -static Handle(AIS_Shape) theConstructionShape = new AIS_Shape(TopoDS_Shape()); -static Handle(GEOM_AISShape) theSelectedShape = new GEOM_AISShape(TopoDS_Shape(), ""); - -/* The object itself created in the static method 'GetOrCreateGeometryGUI()' */ -static GeometryGUI* GeomGUI = 0; - - -//======================================================================= -// class : CustomItem -// purpose : Set Font to a text. -//======================================================================= -class CustomItem : public QCustomMenuItem -{ -public: - CustomItem( const QString& s, const QFont& f ) - : string( s ), font( f ){}; - ~CustomItem(){} - - void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h ) - { - p->setFont ( font ); - p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string ); - } - - QSize sizeHint() - { - return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string ); - } -private: - QString string; - QFont font; -}; - - - - -//======================================================================= -// function : GeometryGUI() -// purpose : Constructor -//======================================================================= -GeometryGUI::GeometryGUI() : - QObject() -{ - mySettings_AddInStudy = false; - mySettings_Copy = false; - myFatherior = ""; -} - -//======================================================================= -// function : ~GeometryGUI() -// purpose : Destructor -//======================================================================= -GeometryGUI::~GeometryGUI() -{ -} - - -//======================================================================= -// function : GetGeometryGUI() static -// purpose : Returns current 'GeomGUI' a static pointer -//======================================================================= -GeometryGUI* GeometryGUI::GetGeometryGUI( ) -{ - return GeomGUI; -} - - -//===================================================================================== -// function : GetIndex() -// purpose : Get the index of a sub shape in a main shape : index start at 1 -//===================================================================================== -int GeometryGUI::GetIndex(const TopoDS_Shape& subshape, - const TopoDS_Shape& shape, - int /*ShapeType*/) -{ - if( shape.IsNull() || subshape.IsNull() ) - return -1 ; - - int index = 1; - if (subshape.ShapeType() == TopAbs_COMPOUND) - { - TopoDS_Iterator it; - TopTools_ListOfShape CL; - CL.Append( shape ); - TopTools_ListIteratorOfListOfShape itC; - for (itC.Initialize( CL ); itC.More(); itC.Next()) - { - for (it.Initialize( itC.Value() ); it.More(); it.Next()) - { - if ( it.Value().ShapeType() == TopAbs_COMPOUND) - { - if (it.Value().IsSame(subshape)) - return index; - else - index++; - CL.Append( it.Value() ); - } - } - } - } - else - { - TopExp_Explorer Exp ( shape, subshape.ShapeType() ); - TopTools_MapOfShape M; - while ( Exp.More() ) - { - if ( M.Add(Exp.Current()) ) - { - if ( Exp.Current().IsSame(subshape) ) - return index; - index++; - } - Exp.Next(); - } - } - return -1; -} - -//======================================================================= -// function : GetOrCreateGeometryGUI() -// purpose : Gets or create an object 'GeometryGUI' with initialisations -// : Returns 'GeomGUI' as a pointer -//======================================================================= -GeometryGUI* GeometryGUI::GetOrCreateGeometryGUI( QAD_Desktop* desktop ) -{ - if( GeomGUI == 0 ) { - GeomGUI = new GeometryGUI; - GeomGUI->myActiveDialogBox = 0 ; - GeomGUI->mySimulationShape = new AIS_Shape(TopoDS_Shape()); - GeomGUI->myState = -1 ; - GeomGUI->myDesktop = desktop ; - GeomGUI->myActiveStudy = desktop->getActiveStudy(); - GeomGUI->mySimulationActor = vtkActorCollection::New() ; - - GeomGUI->myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD ); - - Engines::Component_var comp = desktop->getEngine("FactoryServer", "GEOM"); - GeomGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp); - - /* GetCurrentStudy */ - int studyId = GeomGUI->myActiveStudy->getStudyId(); - GeomGUI->myComponentGeom->GetCurrentStudy(studyId); - - GeomGUI->myNbGeom = GeomGUI->myComponentGeom->NbLabels(); - } else { - /* study may have changed */ - GeomGUI->myActiveStudy = desktop->getActiveStudy(); - } - - return GeomGUI; -} - - -//================================================================================= -// function : VertexToPoint() -// purpose : If S can be converted in a gp_Pnt returns true and the result is P -//================================================================================= -bool GeometryGUI::VertexToPoint( const TopoDS_Shape& S, gp_Pnt& P ) -{ - if( S.IsNull() || S.ShapeType() != TopAbs_VERTEX ) - return false ; - P = BRep_Tool::Pnt(TopoDS::Vertex( S )); - return true ; -} - - -//================================================================================= -// function : LinearEdgeExtremities() -// purpose : If S can be converted in a linear edge and if initial an final points -// : distance is sufficient, returns true else returns false. -// : Resulting points are respectively P1 and P2 -//================================================================================= -bool GeometryGUI::LinearEdgeExtremities( const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2 ) -{ - if( S.IsNull() || S.ShapeType() != TopAbs_EDGE ) - return false ; - BRepAdaptor_Curve curv(TopoDS::Edge(S)); - if (curv.GetType() != GeomAbs_Line) - return false ; - - curv.D0( curv.FirstParameter(), P1 ); - curv.D0( curv.LastParameter(), P2 ); - - if( P1.Distance(P2) <= Precision::Confusion() ) - return false ; - - return true ; -} - -//================================================================================= -// function : GetBipointDxDyDz() -// purpose : -//================================================================================= -void GeometryGUI::GetBipointDxDyDz( gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz ) -{ - dx = P2.X() - P1.X() ; - dy = P2.Y() - P1.Y() ; - dz = P2.Z() - P1.Z() ; - return ; -} - -//======================================================================= -// function : GetTopoFromSelection() -// purpose : Define tds from a single selection and retuen true -//======================================================================= -bool GeometryGUI::GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds) -{ - if(Sel->IObjectCount() != 1) - return false ; - - Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); - /* case SObject */ - if ( IO->hasEntry() ) { - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if (obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - tds = this->GetShapeFromIOR(anIOR->Value()); - if(tds.IsNull() ) - return false ; - else - return true ; - } - } - } - - if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { - Standard_CString ior = ""; - Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO ); - ior = GIObject->getIOR(); - tds = this->GetShapeFromIOR(ior); - if(tds.IsNull() ) - return false ; - else - return true ; - } - - return false; -} - - - -//===================================================================================== -// function : PrepareSubShapeSelection() -// purpose : ( localContextId of the method is opened and defined here) -//===================================================================================== -bool GeometryGUI::PrepareSubShapeSelection(const int SubShapeType, Standard_Integer& returnLocalContextId) -{ - //* Test the type of viewer */ - if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - return false; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - /* local context opening */ - SetDisplayedObjectList() ; - OnDisplayOnly(); - - returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ; - SALOME_Selection* Sel = SALOME_Selection::Selection( this->myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found); - if ( found && SubShapeType >= Shape->Shape().ShapeType()) { - ic->Load(Shape, (8 - SubShapeType), Standard_True); - ic->HilightWithColor(Shape, Quantity_NOC_RED); - } - } - myDesktop->putInfo (tr("GEOM_PRP_SELECT_SUBSHAPES")); - return true ; -} - - - -//===================================================================================== -// function : PrepareSubShapeSelectionArgumentShape() -// purpose : ( localContextId of the method is opened and defined here ) -//===================================================================================== -bool GeometryGUI::PrepareSubShapeSelectionArgumentShape( const TopoDS_Shape& aShape, - const int SubShapeType, - Standard_Integer& returnLocalContextId ) -{ - //* Test the type of viewer */ - if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - return false; - - if( aShape.IsNull() ) - return false ; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - /* local context opening */ - SetDisplayedObjectList() ; - OnDisplayOnly(); - - returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ; - - Handle(GEOM_AISShape) Shape = new GEOM_AISShape(aShape, "") ; - ic->Display(Shape, 0, (8 - SubShapeType)); - - // Not Load(...) but Display(...) - // ic->Load(Shape, (8 - SubShapeType), Standard_True); - ic->HilightWithColor(Shape, Quantity_NOC_RED); - - myDesktop->putInfo (tr("GEOM_PRP_SELECT_SUBSHAPES")); - return true ; -} - - - -//======================================================================= -// function : GetNameOfSelectedIObjects() -// purpose : Define the name geom++ or other name of mono or multi sel. -//======================================================================= -int GeometryGUI::GetNameOfSelectedIObjects( SALOME_Selection* Sel, - QString& aName ) -{ - int nbSel = Sel->IObjectCount() ; - if ( nbSel == 1 ) { - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - aName = IObject->getName(); - } else { - aName = tr( "%1_objects" ).arg( nbSel ); - } - return nbSel; -} - - -//======================================================================= -// function : ConvertIOinGEOMAISShape() -// purpose : -//======================================================================= -Handle(GEOM_AISShape) GeometryGUI::ConvertIOinGEOMAISShape( const Handle(SALOME_InteractiveObject)& IO, - Standard_Boolean& testResult, - bool onlyInActiveView ) -{ - Handle(GEOM_AISShape) res; - int nbSf = myActiveStudy->getStudyFramesCount(); - for ( int i = 0; i < nbSf; i++ ) { - QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); - if ( sf->getTypeView() == VIEW_OCC ) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListOfInteractive List1; - ic->ObjectsInCollector(List1); - List.Append(List1); - - AIS_ListIteratorOfListOfInteractive ite(List); - while (ite.More()) { - if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - if ( aSh->hasIO() ) { - Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); - if ( GIO->isSame( IO ) ) { - if ( onlyInActiveView ) { - if ( sf == myActiveStudy->getActiveStudyFrame() ) { - testResult = true; - return aSh; - } - } else { - testResult = true; - return aSh; - } - } - } - } - ite.Next(); - } - } - } - testResult = false; - return res; -} - -//======================================================================= -// function : ConvertIORinGEOMAISShape() -// purpose : -//======================================================================= -Handle(GEOM_AISShape) GeometryGUI::ConvertIORinGEOMAISShape( const char * IOR, - Standard_Boolean& testResult, - bool onlyInActiveView ) -{ -Handle(GEOM_AISShape) resultShape; -testResult = false; - int nbSf = myActiveStudy->getStudyFramesCount(); - for ( int i = 0; i < nbSf; i++ ) - { - QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); - if ( sf->getTypeView() == VIEW_OCC ) - { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListOfInteractive List1; - ic->ObjectsInCollector(List1); - List.Append(List1); - - AIS_ListIteratorOfListOfInteractive ite(List); - while (ite.More()) - { - if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) - { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - if ( aSh->hasIO() ) - { - Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); - Standard_CString theIOR = GIO->getIOR(); - if ( strcmp( IOR, theIOR ) == 0 ) - { - if ( onlyInActiveView ) - { - if ( sf == myActiveStudy->getActiveStudyFrame() ) - { - testResult = true; - resultShape = aSh; - return resultShape; - } - } - else - { - testResult = true; - resultShape = aSh; - return resultShape; - } - } - } - } - ite.Next(); - } - } - } -return resultShape; -} -//======================================================================= -// function : ConvertIORinGEOMActor() -// purpose : -//======================================================================= -GEOM_Actor* GeometryGUI::ConvertIORinGEOMActor( const char * IOR, - Standard_Boolean& testResult, - bool onlyInActiveView ) -{ - int nbSf = myActiveStudy->getStudyFramesCount(); - for ( int i = 0; i < nbSf; i++ ) { - QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); - if ( sf->getTypeView() == VIEW_VTK ) { - vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* theActors = Renderer->GetActors(); - theActors->InitTraversal(); - vtkActor *ac = theActors->GetNextActor(); - while(!(ac==NULL)) { - if ( ac->IsA("GEOM_Actor") ) { - GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( ac ); - if ( anActor->hasIO() ) { - Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(anActor->getIO()); - Standard_CString theIOR = GIO->getIOR(); - if ( strcmp( IOR, theIOR ) == 0 ) { - if ( onlyInActiveView ) { - if ( sf == myActiveStudy->getActiveStudyFrame() ) { - testResult = true; - return anActor; - } - } else { - testResult = true; - return anActor; - } - } - } - } - ac = theActors->GetNextActor(); - } - } - } - testResult = false; - return GEOM_Actor::New(); -} - -//======================================================================= -// function : ConvertIOinGEOMShape() -// purpose : -//======================================================================= -GEOM::GEOM_Shape_ptr GeometryGUI::ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO, - Standard_Boolean& testResult ) -{ - GEOM::GEOM_Shape_ptr aShape ; - testResult = false ; - - /* case SObject */ - if ( IO->hasEntry() ) { - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if (obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aShape = myComponentGeom->GetIORFromString(anIOR->Value()) ; - testResult = true ; - return aShape; - } - } - } - /* case Graphical Object */ - if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { - Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO ); - Standard_CString ior = GIObject->getIOR(); - testResult = true ; - aShape = myComponentGeom->GetIORFromString(ior) ; - return aShape; - } - return aShape ; -} - -//======================================================================= -// function : ConvertListOfIOInListOfIOR() -// purpose : -//======================================================================= -void GeometryGUI::ConvertListOfIOInListOfIOR( const SALOME_ListIO& aList, - GEOM::GEOM_Gen::ListOfIOR& listIOR ) -{ - int nbSel = aList.Extent(); - listIOR.length(nbSel) ; - int j=0; - SALOME_ListIteratorOfListIO It( aList ); - for ( int i=0; It.More(); It.Next(), i++ ) - { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - - if ( IObject->hasEntry() ) - { - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() && obj->FindAttribute(anAttr, "AttributeIOR") ) - { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - ORB_INIT &init = *SINGLETON_::Instance() ; - CORBA::ORB_var& _orb = init.orb() ; - CORBA::String_var theValue = anIOR->Value(); - CORBA::Object_var theObj = _orb->string_to_object(theValue); - if (theObj->_is_a("IDL:GEOM/GEOM_Shape:1.0")) - { - listIOR[j] = strdup(theValue) ; - j++; - } - } - } - else if ( IObject->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { - Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IObject ); - Standard_CString ior = GIObject->getIOR(); - listIOR[j] = strdup(ior) ; - j++; - } - } - listIOR.length(j) ; -} - - -//================================================================================= -// function : GetShapeTypeString() -// purpose : for a single shape -//================================================================================= -bool GeometryGUI::GetShapeTypeString( const TopoDS_Shape& aShape, Standard_CString& aTypeString ) -{ - if( aShape.IsNull() ) { - aTypeString = "aNullShape" ; - return false ; - } - switch (aShape.ShapeType() ) - { - case TopAbs_COMPOUND: - { aTypeString = strdup(tr("GEOM_COMPOUND")) ; return true ; } - case TopAbs_COMPSOLID: - { aTypeString = strdup(tr("GEOM_COMPOUNDSOLID")) ; return true ; } - case TopAbs_SOLID: - { aTypeString = strdup(tr("GEOM_SOLID")) ; return true ; } - case TopAbs_SHELL: - { aTypeString = strdup(tr("GEOM_SHELL")) ; return true ; } - case TopAbs_FACE: - { - BRepAdaptor_Surface surf(TopoDS::Face(aShape)); - if ( surf.GetType() == GeomAbs_Plane ) { - aTypeString = strdup(tr("GEOM_PLANE")) ; - return true ; - } else if ( surf.GetType() == GeomAbs_Cylinder ) { - aTypeString = strdup(tr("GEOM_SURFCYLINDER")) ; - return true ; - } else if ( surf.GetType() == GeomAbs_Sphere ) { - aTypeString = strdup(tr("GEOM_SURFSPHERE")) ; - return true ; - } else if ( surf.GetType() == GeomAbs_Torus ) { - aTypeString = strdup(tr("GEOM_SURFTORUS")) ; - return true ; - } else if ( surf.GetType() == GeomAbs_Cone ) { - aTypeString = strdup(tr("GEOM_SURFCONE")) ; - return true ; - } else { - aTypeString = strdup(tr("GEOM_FACE")) ; - return true ; - } - } - case TopAbs_WIRE: - { aTypeString = strdup(tr("GEOM_WIRE")) ; return true ; } - case TopAbs_EDGE: - { - BRepAdaptor_Curve curv(TopoDS::Edge(aShape)); - if ( curv.GetType() == GeomAbs_Line ) { - if ( (Abs(curv.FirstParameter()) >= 1E6 ) || - (Abs(curv.LastParameter()) >= 1E6 )) { - aTypeString = strdup(tr("GEOM_LINE")) ; - } else - aTypeString = strdup(tr("GEOM_EDGE")) ; - return true ; - } else if ( curv.GetType() == GeomAbs_Circle ) { - if ( curv.IsClosed() ) - aTypeString = strdup(tr("GEOM_CIRCLE")) ; - else - aTypeString = strdup(tr("GEOM_ARC")) ; - return true ; - } else { - aTypeString = strdup(tr("GEOM_EDGE")) ; - return true ; - } - } - case TopAbs_VERTEX: - { aTypeString = strdup(tr("GEOM_VERTEX")) ; return true ; } - case TopAbs_SHAPE: - { aTypeString = strdup(tr("GEOM_SHAPE")) ; return true ; } - } - return false ; -} - - -//================================================================================= -// function : CreateArrowForLinearEdge() -// purpose : Create a cone topology to be used to display an arrow in the middle -// : of an edge showing its orientation. (For simulation and Viewer OCC only) -//================================================================================= -bool GeometryGUI::CreateArrowForLinearEdge( const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone ) -{ - if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC || tds.ShapeType() != TopAbs_EDGE ) - return false; - - OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort(); - Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView(); - Standard_Real Width, Height ; - view3d->Size(Width, Height) ; - const Standard_Real aHeight = (Width + Height) / 50.0 ; - - try { - Standard_Real first, last ; - Handle(Geom_Curve) curv = BRep_Tool::Curve(TopoDS::Edge(tds), first, last); - if( !curv->IsCN(1) ) - return false ; - - const Standard_Real param = (first+last) / 2.0 ; - gp_Pnt middleParamPoint ; - gp_Vec V1 ; - curv->D1( param, middleParamPoint, V1) ; - if ( V1.Magnitude() < Precision::Confusion() ) - return false ; - - /* Topology orientation not geom orientation */ - if( tds.Orientation() == TopAbs_REVERSED ) - V1 *= -1.0 ; - - gp_Ax2 anAxis( middleParamPoint, gp_Dir(V1) ) ; - const Standard_Real radius1 = aHeight / 5.0 ; - if( radius1 > 10.0 * Precision::Confusion() && aHeight > 10.0 * Precision::Confusion() ) { - ArrowCone = BRepPrimAPI_MakeCone( anAxis, radius1, 0.0, aHeight ).Shape() ; - return true ; - } - } - catch(Standard_Failure) { - // OCC failures are hard to catch in GUI. - // This because of the position for #include that is very critic to find - // in SALOME environment : compilation error ! - } - return false ; -} - - -//======================================================================= -// function : SelectionByNameInDialogs() -// purpose : Called when user has entered a name of object in a LineEdit. -// : The selection is changed. Dialog box will receive the -// : corresponding signal to manage this event. -//======================================================================= -bool GeometryGUI::SelectionByNameInDialogs( QWidget* aWidget, const QString& objectUserName, SALOME_Selection* Sel ) -{ - - /* Find SObject with name in component GEOM */ - SALOMEDS::Study_var ST = this->myActiveStudy->getStudyDocument() ; - SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ; - listSO = ST->FindObjectByName( objectUserName, "GEOM" ) ; - - if ( listSO->length() < 1 ) { - const QString caption = tr("GEOM_WRN_WARNING") ; - const QString text = tr("GEOM_NAME_INCORRECT") ; - const QString button0 = tr("GEOM_BUT_OK") ; - QMessageBox::warning( aWidget, caption, text, button0 ) ; - return false ; - } - /* More than one object with same name */ - if ( listSO->length() > 1 ) { - const QString caption = tr("GEOM_WRN_WARNING") ; - const QString text = tr("GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE") ; - const QString button0 = tr("GEOM_BUT_OK") ; - QMessageBox::warning( aWidget, caption, text, button0 ) ; - return false ; - } - - SALOMEDS::SObject_var theObj = listSO[0] ; - /* Create a SALOME_InteractiveObject with a SALOME::SObject */ - Standard_CString anEntry = theObj->GetID() ; - Handle(SALOME_InteractiveObject) SI = new SALOME_InteractiveObject( anEntry, "GEOM", strdup(objectUserName) ) ; - - /* Add as a selected object */ - /* Clear any previous selection : */ - /* Warning the LineEdit is purged because of signal currentSelectionChanged ! */ - Sel->ClearIObjects() ; - Sel->AddIObject( SI ) ; - return true ; -} - - -//======================================================================= -// function : MakePointAndDisplay -// purpose : -//======================================================================= -void GeometryGUI::MakePointAndDisplay( const double x, const double y, const double z ) -{ - try { - GEOM::GEOM_Shape_var P = myComponentGeom->MakeVertex( x, y, z ); - P->NameType( tr("GEOM_VERTEX") ); - if ( Display( P, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - - -//======================================================================= -// function : MakeVectorAndDisplay() -// purpose : -//======================================================================= -void GeometryGUI::MakeVectorAndDisplay( const gp_Pnt P1, const gp_Pnt P2 ) -{ - try { - GEOM::PointStruct pstruct1 = myComponentGeom->MakePointStruct( P1.X(), P1.Y(), P1.Z() ) ; - GEOM::PointStruct pstruct2 = myComponentGeom->MakePointStruct( P2.X(), P2.Y(), P2.Z() ) ; - GEOM::GEOM_Shape_var Vector = myComponentGeom->MakeVector( pstruct1, pstruct2 ); - Vector->NameType(tr("GEOM_VECTOR")); - if ( Display( Vector, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -} - - - - - - - -//======================================================================= -// function : MakePlaneAndDisplay() -// purpose : Plane point is P1 and dx, dy, dz define a normal vector -//======================================================================= -void GeometryGUI::MakePlaneAndDisplay( const gp_Pnt P1, const Standard_Real dx, - const Standard_Real dy, const Standard_Real dz, - const Standard_Real TrimSize ) -{ - try { - gp_Dir aDirection; - aDirection.SetCoord(dx, dy, dz) ; - gp_Ax2 Axis( P1, aDirection ); - - GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z() ) ; - GEOM::PointStruct d = myComponentGeom->MakePointStruct(aDirection.X(), aDirection.Y(), aDirection.Z()) ; - GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ; - GEOM::GEOM_Shape_ptr plane = myComponentGeom->MakePlane(pstruct, dstruct, TrimSize) ; - plane->NameType(tr("GEOM_PLANE")); - if ( Display( plane, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -} - - -//======================================================================= -// function : MakeWorkingPlane() -// purpose : Change the point of view3d -//======================================================================= -void GeometryGUI::MakeWorkingPlane( const gp_Pnt P, const gp_Dir D) -{ - if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC) { - myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ; - return ; - } - OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort(); - Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView(); - view3d->SetAt( P.X(), P.Y(), P.Z() ); - view3d->SetProj( D.X(), D.Y(), D.Z() ); - myDesktop->putInfo(tr("GEOM_PRP_DONE")); -} - - -//======================================================================= -// function : MakePrismAndDisplay() -// purpose : P1 and P2 is to define a vector for prism -//======================================================================= -void GeometryGUI::MakePrismAndDisplay( GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2 ) -{ - try { - GEOM::PointStruct PS1 = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z() ) ; - GEOM::PointStruct PS2 = myComponentGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z() ) ; - if( BaseShape->_is_nil() ) { - myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - - GEOM::GEOM_Shape_ptr result = myComponentGeom->MakePrism( BaseShape, PS1, PS2 ) ; - if (result->_is_nil()) { - myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); - Standard_CString type; - GetShapeTypeString(S,type); - result->NameType( type ); - - if ( Display( result, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//===================================================================================== -// function : MakeLineAndDisplay() -// purpose : Create an infinite oriented line (linear edge in fact) -//===================================================================================== -void GeometryGUI::MakeLineAndDisplay( const gp_Pnt InitPoint, const gp_Pnt LastPoint ) -{ - gp_Pnt P1,P2; - double dx, dy, dz ; - GetBipointDxDyDz( InitPoint, LastPoint, dx, dy, dz ) ; - Standard_Real length = InitPoint.Distance(LastPoint) ; - if( length <= Precision::Confusion() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - return ; - } - - Standard_Real coeff = 1E6 / length ; - - /* To create a line with length = 1E6 */ - /* Precision::Infinite() is 1E100 in OCC */ - P1.SetX( InitPoint.X() - (coeff * dx) ) ; - P1.SetY( InitPoint.Y() - (coeff * dy) ) ; - P1.SetZ( InitPoint.Z() - (coeff * dz) ) ; - - P2.SetX( LastPoint.X() + (coeff * dx) ) ; - P2.SetY( LastPoint.Y() + (coeff * dy) ) ; - P2.SetZ( LastPoint.Z() + (coeff * dz) ) ; - - try { - GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()) ; - GEOM::PointStruct d = myComponentGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()) ; - GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ; - - GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeLine(pstruct, dstruct) ; - if(result->_is_nil()) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - return ; - } - result->NameType(tr("GEOM_LINE")); - - if ( Display( result, "") ) - myDesktop->putInfo(tr("GEOM_PRP_READY")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - - - - - - - - - - - -//===================================================================================== -// function : MakePipeAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakePipeAndDisplay( GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase ) -{ - try { - GEOM::GEOM_Shape_ptr result = myComponentGeom->MakePipe(aPath, aBase); - if ( !result->_is_nil() && Display( result, "") ) { - - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); - Standard_CString type; - GetShapeTypeString(S,type); - result->NameType( type ); - - myDesktop->putInfo( tr("GEOM_PRP_DONE") ); - } - else { - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - } - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//===================================================================================== -// function : MakeFillingAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeFillingAndDisplay( GEOM::GEOM_Shape_ptr SectionShape, - const short mindeg, - const short maxdeg, - const double tol3d, - const double tol2d, - const short nbiter ) -{ - try { - GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeFilling( SectionShape, - mindeg, maxdeg, - tol3d, tol2d, nbiter ); - if (result->_is_nil()) { - myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); - Standard_CString type; - GetShapeTypeString(S,type); - result->NameType( type ); - - if ( Display( result, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - return ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -} - - - -//===================================================================================== -// function : MakeMirrorAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeMirrorAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2 ) -{ - try { - GEOM::GEOM_Shape_var result = myComponentGeom->MakeMirrorByPlane( Shape1, Shape2 ); - if (result->_is_nil()) { - myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - result->NameType( Shape1->NameType() ); - if ( Display( result, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//===================================================================================== -// function : MakeSewingAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeSewingAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, - const Standard_Real precision ) -{ - try { - GEOM::GEOM_Shape_var result = myComponentGeom->MakeSewing(listShapesIOR, precision) ; - if( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); - Standard_CString type; - GetShapeTypeString(S,type); - result->NameType( type ); - - if( Display( result, "") ) - myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ; - return ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -} - - -//===================================================================================== -// function : MakeCompoundAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeCompoundAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) -{ - try { - GEOM::GEOM_Shape_var result = myComponentGeom->MakeCompound(listShapesIOR) ; - if( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - result->NameType(tr("GEOM_COMPOUND")); - if( Display( result, "" )) - myDesktop->putInfo(tr("GEOM_PRP_DONE")) ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//===================================================================================== -// function : MakeFaceAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeFaceAndDisplay( GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar ) -{ - try { - GEOM::GEOM_Shape_var result = myComponentGeom->MakeFace( aWire, wantPlanar) ; - if( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - if ( wantPlanar ) - result->NameType(tr("GEOM_PLANE")); - else - result->NameType(tr("GEOM_FACE")); - if( Display( result, "") ) - myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//===================================================================================== -// function : MakeShellAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeShellAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) -{ - try { - GEOM::GEOM_Shape_var result = myComponentGeom->MakeShell(listShapesIOR) ; - if( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - result->NameType(tr("GEOM_SHELL")); - if( Display( result, "" )) - myDesktop->putInfo(tr("GEOM_PRP_DONE")) ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//===================================================================================== -// function : MakeSolidAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeSolidAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) -{ - try { - GEOM::GEOM_Shape_var result = myComponentGeom->MakeSolid(listShapesIOR) ; - if( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - result->NameType(tr("GEOM_SOLID")); - if( Display( result, "" )) - myDesktop->putInfo(tr("GEOM_PRP_DONE")) ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//===================================================================================== -// function : MakeLinearEdgeAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeLinearEdgeAndDisplay( const gp_Pnt P1, const gp_Pnt P2 ) -{ - try { - GEOM::PointStruct ps1 = myComponentGeom->MakePointStruct( P1.X(), P1.Y(), P1.Z() ) ; - GEOM::PointStruct ps2 = myComponentGeom->MakePointStruct( P2.X(), P2.Y(), P2.Z() ) ; - GEOM::GEOM_Shape_var result = myComponentGeom->MakeEdge( ps1, ps2 ) ; - if( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - result->NameType(tr("GEOM_EDGE")); - if( Display( result, "") ) - myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ; - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//===================================================================================== -// function : MakeOrientationChangeAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeOrientationChangeAndDisplay( GEOM::GEOM_Shape_ptr Shape ) -{ - try { - GEOM::GEOM_Shape_var result = myComponentGeom->OrientationChange( Shape ) ; - if( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - result->NameType( Shape->NameType() ); - if ( Display( result, "" )) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - return ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -} - - -//===================================================================================== -// function : MakeScaleAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeScaleAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, const Standard_Real factor ) -{ - try { - GEOM::PointStruct P = myComponentGeom->MakePointStruct(centralPoint.X(), centralPoint.Y(), centralPoint.Z() ) ; - GEOM::GEOM_Shape_var result = myComponentGeom->MakeScaleTransform(Shape, P, factor) ; - // result->NameType(tr("GEOM_SCALE")); - result->NameType( Shape->NameType() ); - if ( Display( result, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - else - myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//======================================================================================= -// function : MakeRevolutionAndDisplay() -// purpose : -//======================================================================================= -void GeometryGUI::MakeRevolutionAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir, const Standard_Real revolAngle ) -{ - try { - GEOM::AxisStruct axis = myComponentGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z() ) ; - GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeRevolution(Shape, axis, revolAngle) ; - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - return ; - } - - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); - Standard_CString type; - GetShapeTypeString(S,type); - result->NameType( type ); - - if ( Display( result ) ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//======================================================================================= -// function : MakeRotationAndDisplay() -// purpose : -//======================================================================================= -void GeometryGUI::MakeRotationAndDisplay( GEOM::GEOM_Shape_ptr Shape, - const gp_Pnt loc, - const gp_Dir dir, - const Standard_Real angle ) -{ - try { - const GEOM::AxisStruct axis = myComponentGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z() ) ; - GEOM::GEOM_Shape_var result = myComponentGeom->MakeRotation(Shape, axis, angle); - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT") ); - return ; - } - result->NameType( Shape->NameType() ); - if ( Display( result ) ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//================================================================================= -// function : MakeTranslationAndDisplay() -// purpose : Translate a shape -//================================================================================= -void GeometryGUI::MakeTranslationAndDisplay( GEOM::GEOM_Shape_ptr Shape, gp_Vec V ) -{ - try { - GEOM::GEOM_Shape_var result = myComponentGeom->MakeTranslation( Shape, V.X(), V.Y(), V.Z() ) ; - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT") ); - return ; - } - result->NameType( Shape->NameType() ); - if ( Display( result ) ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - -//================================================================================= -// function : MakeMultiTranslation1DAndDisplay() -// purpose : Multi-Translate a shape -//================================================================================= -void GeometryGUI::MakeMultiTranslation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const double Step, const short NbTimes ) -{ - try { - GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ; - GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ; - - GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiTranslation1D( Shape, dstruct, Step, NbTimes ); - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT") ); - return ; - } - result->NameType( tr("GEOM_COMPOUND") ); - if ( Display( result ) ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//================================================================================= -// function : MakeMultiTranslation2DAndDisplay() -// purpose : Multi-Translate a shape -//================================================================================= -void GeometryGUI::MakeMultiTranslation2DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir1, const double Step1, const short NbTimes1, const gp_Dir Dir2, const double Step2, const short NbTimes2 ) -{ - try { - GEOM::PointStruct d1 = myComponentGeom->MakePointStruct( Dir1.X(), Dir1.Y(), Dir1.Z() ) ; - GEOM::DirStruct dstruct1 = myComponentGeom->MakeDirection(d1) ; - GEOM::PointStruct d2 = myComponentGeom->MakePointStruct( Dir2.X(), Dir2.Y(), Dir2.Z() ) ; - GEOM::DirStruct dstruct2 = myComponentGeom->MakeDirection(d2) ; - - GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiTranslation2D( Shape, dstruct1, Step1, NbTimes1, dstruct2, Step2, NbTimes2 ); - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT") ); - return ; - } - result->NameType( tr("GEOM_COMPOUND") ); - if ( Display( result ) ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//================================================================================= -// function : MakeMultiRotation1DAndDisplay() -// purpose : Multi-Rotate a shape -//================================================================================= -void GeometryGUI::MakeMultiRotation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes ) -{ - try { - GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ; - GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ; - GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( Loc.X(), Loc.Y(), Loc.Z() ) ; - - GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiRotation1D( Shape, dstruct, pstruct, NbTimes ); - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT") ); - return ; - } - result->NameType( tr("GEOM_COMPOUND") ); - if ( Display( result ) ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//================================================================================= -// function : MakeMultiRotation2DAndDisplay() -// purpose : Multi-Rotate a shape -//================================================================================= -void GeometryGUI::MakeMultiRotation2DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const double Ang, const short NbTimes1, const double Step, const short NbTimes2 ) -{ - try { - GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ; - GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ; - GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( Loc.X(), Loc.Y(), Loc.Z() ) ; - - GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiRotation2D( Shape, dstruct, pstruct, Ang, NbTimes1, Step, NbTimes2 ); - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT") ); - return ; - } - result->NameType( tr("GEOM_COMPOUND") ); - if ( Display( result ) ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - - -//======================================================================================= -// function : MakeArcAndDisplay() -// purpose : Make an arc of circle from InitPoint to CirclePoint and passing on EndPoint -//======================================================================================= -void GeometryGUI::MakeArcAndDisplay( gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint ) -{ - gp_Vec v1( CirclePoint, InitPoint ) ; - gp_Vec v2( CirclePoint, EndPoint ) ; - if( v1.IsParallel(v2, Precision::Angular() ) ) - return ; - - try { - GEOM::PointStruct pI = myComponentGeom->MakePointStruct( InitPoint.X(), InitPoint.Y(), InitPoint.Z() ); - GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CirclePoint.X(), CirclePoint.Y(), CirclePoint.Z() ); - GEOM::PointStruct pE = myComponentGeom->MakePointStruct( EndPoint.X(), EndPoint.Y(), EndPoint.Z() ); - GEOM::GEOM_Shape_var result = myComponentGeom->MakeArc(pI, pC, pE) ; - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - return ; - } - result->NameType(tr("GEOM_ARC")); - if ( Display( result ) ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//===================================================================================== -// function : MakeCircleAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeCircleAndDisplay( const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius ) -{ - try { - GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() ) ; - GEOM::PointStruct d = myComponentGeom->MakePointStruct( dir.X(), dir.Y(), dir.Z() ) ; - GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ; - - GEOM::GEOM_Shape_var result = myComponentGeom->MakeCircle(pstruct, dstruct, Radius) ; - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT") ); - return ; - } - result->NameType(tr("GEOM_CIRCLE")); - if ( Display( result ) ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//===================================================================================== -// function : MakeEllipseAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeEllipseAndDisplay( const gp_Pnt CenterPoint, - const gp_Dir dir, - const Standard_Real Major_Radius, - const Standard_Real Minor_Radius ) -{ - try { - GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() ) ; - GEOM::PointStruct d = myComponentGeom->MakePointStruct( dir.X(), dir.Y(), dir.Z() ) ; - GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ; - - GEOM::GEOM_Shape_var result = myComponentGeom->MakeEllipse(pstruct, dstruct, Major_Radius, Minor_Radius) ; - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT") ); - return ; - } - result->NameType(tr("GEOM_ELLIPSE")); - if ( Display( result ) ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//===================================================================================== -// function : MakeWireAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeWireAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) -{ - try { - GEOM::GEOM_Shape_var result = myComponentGeom->MakeWire(listShapesIOR) ; - if( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - result->NameType(tr("GEOM_WIRE")); - if( Display( result, "") ) - myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - - -//===================================================================================== -// function : MakePartitionAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakePartitionAndDisplay (const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, - const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR, - const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR, - const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR, - const GEOM::shape_type limit) -{ - try { - GEOM::GEOM_Shape_var result = myComponentGeom->Partition(listShapesIOR, - listToolsIOR, - listKeepInsIOR, - listRemoveInsIOR, - (CORBA::Short) limit); - if( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ; - return ; - } - result->NameType(tr("GEOM_PARTITION")); - if( Display( result, "") ) - myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ; - return ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -} - -//======================================================================= -// function : SetState() -// purpose : Sets myState = aState a private field indicating which methode is active -//======================================================================= -void GeometryGUI::SetState(int aState ) -{ this->myState = aState ; return ; } - - -//======================================================================= -// function : ResetState() -// purpose : Sets myState = -1 a private field indicating which methode is active -//======================================================================= -void GeometryGUI::ResetState() -{ this->myState = -1 ; return ; } - - -//======================================================================= -// function : EmitSignalDeactivateDialog() -// purpose : Emit a signal to deactivate the active dialog Box -//======================================================================= -void GeometryGUI::EmitSignalDeactivateDialog() -{ - emit this->SignalDeactivateActiveDialog() ; - return ; -} - -//======================================================================= -// function : EmitSignalCloseAllDialogs() -// purpose : Emit a signal to deactivate all non modal dialogs box -//======================================================================= -void GeometryGUI::EmitSignalCloseAllDialogs() -{ - emit this->SignalCloseAllDialogs() ; - return ; -} - - -//======================================================================= -// function : GetActiveDialogBox() -// purpose : -//======================================================================= -QDialog* GeometryGUI::GetActiveDialogBox() -{ - return this->myActiveDialogBox ; -} - - -//======================================================================= -// function : SetActiveDialogBox() -// purpose : -//======================================================================= -void GeometryGUI::SetActiveDialogBox(QDialog* aDlg) -{ - this->myActiveDialogBox = (QDialog*)aDlg ; - return ; -} - - -//======================================================================= -// function : GetActiveStudy() -// purpose : -//======================================================================= -QAD_Study* GeometryGUI::GetActiveStudy() -{ - return this->myActiveStudy ; -} - - -//======================================================================= -// function : GetActiveDesktop() -// purpose : -//======================================================================= -QAD_Desktop* GeometryGUI::GetDesktop() -{ - return this->myDesktop ; -} - - -//======================================================================= -// function : GetShapeReader() -// purpose : -//======================================================================= -GEOM_Client& GeometryGUI::GetShapeReader() -{ - return this->myShapeReader ; -} - - -//===================================================================================== -// function : OnSubShapeGetAll() -// purpose : Explode a shape in all sub shapes with a SubShapeType -//===================================================================================== -bool GeometryGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType) -{ - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR ); - if ( theObj->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); - return false ; - } - - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - SALOMEDS::AttributePixMap_var aPixmap; - - /* We create a sub object for each sub shape as attribute of the main object */ - /* Each sub object contains list (length=1) containing its index in the main shape */ - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR ); - GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes; - GEOM::GEOM_Shape_var aResult ; - - try { - listGeomShapes = myComponentGeom->SubShapeAll( aShape, SubShapeType ); - if( listGeomShapes->length() < 1 ) { - myDesktop->putInfo (tr("GEOM_PRP_ABORT")); - return false ; - } - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - - /* open transaction */ - QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); - op->start(); - - TopoDS_Shape mainTopo = myShapeReader.GetShape(myComponentGeom, aShape); - TopoDS_Shape mainShape; - bool main = false; - while ( !main ) { - if ( aShape->IsMainShape() ) { - mainShape = myShapeReader.GetShape(myComponentGeom, aShape); - main = true; - } else - aShape = myComponentGeom->GetIORFromString( aShape->MainName() ); - } - - /* Loop on each sub shape created */ - /* int i = 1 ; /* index for the nameType */ - for( int j=0; jlength(); j++) { - - /* Get each sub shape extracted CORBA and OCC */ - aResult = listGeomShapes[j] ; - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, aResult); - - if ( S.IsNull() ) { - myDesktop->putInfo (tr("GEOM_PRP_ABORT")); - return false; - } - -// NRI : Following lines are commented according to bugID SAL695 (see history) -// BRepCheck_Analyzer anAnalyzer(S); -// if(!anAnalyzer.IsValid()) { -// myDesktop->putInfo (tr("GEOM_PRP_ABORT")); -// MESSAGE("#### An exploded shape number "<< j << " is not valid"); -// op->abort(); -// return false; -// } - - /* Set the nameType of sub shape */ - char* nameG = (char *)malloc(20); - Standard_CString Type; - if ( GetShapeTypeString(S, Type) ) { - aResult->NameType( Type ); - sprintf (nameG, "%s_%d", Type, GetIndex( S, mainShape, SubShapeType ) ); - } - else { - aResult->NameType( tr("GEOM_SHAPE") ); - sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ ); - } - SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() ); - - bool allreadyexist = false; - - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - Handle(GEOM_AISShape) result = new GEOM_AISShape( S, nameG ); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), myFatherior, "GEOM"); - - MESSAGE ( "SO->_is_nil() " << SO->_is_nil() ) - - if ( SO->_is_nil() ) { - SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj ); - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(nameG); - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - anIOR->SetValue(aResult->Name()); - - 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() ) - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, newObj); - IO->setEntry(newObj->GetID()); - - aResult->StudyShapeId( newObj->GetID() ); - } else { - allreadyexist = true; - if ( ! SObjectExist(theObj, aResult->Name()) ) { - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj); - aStudyBuilder->Addreference(newObj1, SO); - IO->setEntry(SO->GetID()); - aResult->StudyShapeId( SO->GetID() ); - } - } - - result->setIO( IO ); - result->setName( nameG ); - if ( !allreadyexist ) - ic->Display(result); - - } else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - int themode = myRenderInter->GetDisplayMode(); - vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), myFatherior,"GEOM"); - - 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()); - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(nameG); - - 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" ); - } - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, newObj); - IO->setEntry(newObj->GetID()); - } else { - allreadyexist = true; - if ( ! 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); - theActors->InitTraversal(); - vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); - while(!(anActor==NULL)) { - GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor ); - GActor->setIO( IO ); - GActor->setName( nameG ); - theRenderer->AddActor(GActor); - renWin->Render(); - anActor = (vtkActor*)theActors->GetNextActor(); - } - } - } - } - - /* commit transaction */ - op->finish(); - - myActiveStudy->updateObjBrowser(); - myDesktop->putInfo (tr("GEOM_PRP_READY")); - return true ; -} - - - -//===================================================================================== -// function : GetIndexSubShapeSelected() -// purpose : Define a ListOfID of sub shapes selected in ShapeTopo with SubShapeType -// : Method used by Dialogs -//===================================================================================== -bool GeometryGUI::GetIndexSubShapeSelected( const TopoDS_Shape& ShapeTopo, - const int SubShapeType, - GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID, - Standard_Integer& aLocalContextId, - bool& myUseLocalContext ) -{ - //* Test the type of viewer */ - if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { - return false; - } - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - ic->InitSelected(); - int nbSelected = ic->NbSelected(); - ListOfID.length(nbSelected); - - - //***************** DEFINE INDEX OF EACH SELECTION *********************// - int i = 0 ; - ic->InitSelected(); /* to restart */ - while( ic->MoreSelected() ) { - - /* Find index of sub shape into main shape */ - TopExp_Explorer Exp ( ShapeTopo, TopAbs_ShapeEnum(SubShapeType) ); - int index = 1; - bool found = false ; - while ( Exp.More() ) { - if ( (Exp.Current()).IsSame( ic->SelectedShape()) ) { - found = true ; - break; - } - index++; - Exp.Next(); - } - if( !found ) { - /* Manage local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId) ; - myUseLocalContext = false ; - return false ; - } - ListOfID[i] = index ; - i++; - ic->NextSelected(); - } - //***************** END *********************// - - /* Manage local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId) ; - myUseLocalContext = false ; - - return true ; -} - - -//===================================================================================== -// function : OnSubShapeGetSelected() -// purpose : -//===================================================================================== -bool GeometryGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo, - const char* ShapeTopoIOR, - const int SubShapeType, - Standard_Integer& aLocalContextId, - bool& myUseLocalContext ) -{ - //* Test the type of viewer */ - if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { - return false; - } - - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR ); - if ( theObj->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); - return false ; - } - - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - if( myUseLocalContext == false ) { - /* local context is from DialogBox */ - MESSAGE("Error : No local context opened for sub shapes method" << endl ) ; - return false ; - } - - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR ); - TopoDS_Shape mainTopo = myShapeReader.GetShape(myComponentGeom, aShape); - - TopoDS_Shape mainShape; - bool main = false; - while ( !main ) { - if ( aShape->IsMainShape() ) { - mainShape = myShapeReader.GetShape(myComponentGeom, aShape); - main = true; - } else - aShape = myComponentGeom->GetIORFromString( aShape->MainName() ); - } - - GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; - ic->InitSelected(); - int nbSelected = ic->NbSelected(); - ListOfID->length(nbSelected); - - TopoDS_Compound compound; - ic->InitSelected(); /* to init again */ - BRep_Builder B; - 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 = 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 ; - - GEOM::GEOM_Shape_var aResult ; - try { - aResult = myComponentGeom->SubShape( aShape, SubShapeType, ListOfID ); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - - /* local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId) ; - myUseLocalContext = false ; - - char* nameG = (char *)malloc(20); - Standard_CString Type; - - Handle(GEOM_AISShape) result; - Handle(GEOM_InteractiveObject) IO ; - - // if ( ! SObjectExist(theObj, aResult->Name()) ) { - if ( nbSelected == 1 ) { - TopExp_Explorer Exp ( compound, TopAbs_ShapeEnum(SubShapeType) ); - if ( Exp.More() ) { - if ( GetShapeTypeString(Exp.Current(),Type) ) { - aResult->NameType( Type ); - sprintf (nameG, "%s_%d", Type, GetIndex( Exp.Current(), mainTopo, SubShapeType ) ); - } else { - aResult->NameType( tr("GEOM_SHAPE") ); - sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ ); - } - result = new GEOM_AISShape( Exp.Current(), nameG ); - IO = new GEOM_InteractiveObject(aResult->Name(), myFatherior, "GEOM"); - } - } - else { - if ( GetShapeTypeString(compound,Type) ) { - aResult->NameType( Type ); - sprintf (nameG, "%s_%d", Type, this->myNbGeom++ ); - } else { - aResult->NameType( tr("GEOM_SHAPE") ); - sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ ); - } - result = new GEOM_AISShape( compound, nameG ); - IO = new GEOM_InteractiveObject(aResult->Name(), myFatherior, "GEOM"); - } - - SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() ); - - /* open transaction */ - QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); - op->start(); - - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry()); - SALOMEDS::GenericAttribute_var anAttr; - 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 ); - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - anIOR->SetValue(aResult->Name()); - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(result->getName()); - - 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" ); - } - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, newObj); - - IO->setEntry(newObj->GetID()); - aResult->StudyShapeId(newObj->GetID()); - } else { - allreadyexist = true; - if ( ! SObjectExist(theObj, aResult->Name()) ) { - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj); - aStudyBuilder->Addreference(newObj1, SO); - - IO->setEntry(SO->GetID()); - aResult->StudyShapeId(SO->GetID()); - } - } - - /* commit transaction */ - op->finish(); - - result->setIO( IO ); - result->setName( nameG ); - - if ( !allreadyexist ) - ic->Display(result); - - this->OnDisplayAll(true); - myActiveStudy->updateObjBrowser(); - myDesktop->putInfo (tr("GEOM_PRP_READY")); - - return true ; -} - - -//===================================================================================== -// function : OnSuppressFaces() -// purpose : To suppress faces from a shape -// : The result is one or more shells/faces as main shapes ! -//===================================================================================== -bool GeometryGUI::OnSuppressFaces( const TopoDS_Shape& ShapeTopo, - const char* ShapeTopoIOR, - const Standard_Integer& aLocalContextId, - bool& myUseLocalContext ) -{ - /* Test the type of viewer */ - if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { - return false; - } - - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR ); - if ( theObj->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); - return false ; - } - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - if( myUseLocalContext == false ) { - /* local context is from DialogBox */ - MESSAGE("Error : No local context opened for suppress faces method" << endl ) ; - return false ; - } - - GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; - ic->InitSelected(); - int nbSelected = ic->NbSelected(); - ListOfID->length(nbSelected); - - /* Create a list of indices of faces to be suppressed */ - int i = 0; - const int SubShapeType = 4 ; /* GEOM::FACE type */ - ic->InitSelected(); /* to repositioning at beginning */ - while( ic->MoreSelected() ) { - int index = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType ); - ListOfID[i] = index ; - i++; - ic->NextSelected(); - } - - /* Close local context opened in DialogBox */ - ic->CloseLocalContext(aLocalContextId) ; - myUseLocalContext = false ; - - /* Here is the main shape */ - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR ); - GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes; - - /* Call geom method that return a list of shells/faces as result of suppress */ - try { - listGeomShapes = myComponentGeom->SuppressFaces( aShape, ListOfID ); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - - /* Test list of shells/faces */ - if( listGeomShapes->length() < 1 ) { - return false ; - } - - /* Loop on each object created */ - for( int i=0; ilength(); i++ ) { - - GEOM::GEOM_Shape_var aShellOrFace = listGeomShapes[i] ; - TopoDS_Shape S = myShapeReader.GetShape( this->myComponentGeom, aShellOrFace ); - - if( S.IsNull() ) { - return false ; - } - - char* nameG = (char *)malloc(20); - Standard_CString Type; - if ( GetShapeTypeString(S, Type) ) { - aShellOrFace->NameType( Type ); - sprintf (nameG, "%s_%d", Type, this->myNbGeom++); - } - else { - aShellOrFace->NameType( tr("GEOM_SHAPE") ); - sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ ); - } - - /* Display with name */ - if( !Display( aShellOrFace, nameG) ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - return false ; - } - } - - myDesktop->putInfo (tr("GEOM_PRP_READY")); - return true ; -} - - -//===================================================================================== -// function : OnSuppressHole() -// purpose : To suppress an hole on a shape 'ShapeTopo'. -// : 'ListOfIdEndFace' may be an empty list. -// : This means that hole do not traverse ShapeTopo. -// : Warning : the hole to be suppressed must be defined by one or two single closed wires ! -//===================================================================================== -bool GeometryGUI::OnSuppressHole( const char* ShapeTopoIOR, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace ) -{ - /* Test the type of viewer */ - if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { - return false; - } - - try { - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR ); - GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHole( aShape, ListOfIdFace, ListOfIdWire, ListOfIdEndFace ) ; - - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, aResult); - Standard_CString type; - GetShapeTypeString(S,type); - aResult->NameType( type ); - - if ( Display( aResult, "" ) ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return true ; -} - - -//===================================================================================== -// function : OnSuppressHolesInFaceOrShell() -// purpose : To suppress one or more holes on a face -// : 'ListOfIdWires' contains indices or wires/holes. -//===================================================================================== -bool GeometryGUI::OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires ) -{ - /* Test the type of viewer */ - if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { - return false; - } - - try { - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR ); - GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHolesInFaceOrShell( aShape, ListOfIdWires ) ; - - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, aResult); - Standard_CString type; - GetShapeTypeString(S,type); - aResult->NameType( type ); - - if ( Display( aResult, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return true ; -} - - - - - - -//======================================================================= -// function : DefineDlgPosition() -// purpose : Define x and y the default position for a dialog box -//======================================================================= -bool GeometryGUI::DefineDlgPosition(QWidget* aDlg, int& x, int& y) -{ - /* Here the position is on the bottom right corner - 10 */ - QAD_Desktop* PP = QAD_Application::getDesktop() ; - x = abs ( PP->x() + PP->size().width() - aDlg->size().width() - 10 ) ; - y = abs ( PP->y() + PP->size().height() - aDlg->size().height() - 10 ) ; - return true ; -} - - -//======================================================================= -// function : ConvertClickToPoint() -// purpose : Returns the point clicked in 3D view -//======================================================================= -gp_Pnt GeometryGUI::ConvertClickToPoint( Standard_Real x, - Standard_Real y, - Handle(V3d_View) aView ) -{ - V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt; - aView->Eye(XEye, YEye, ZEye); - - aView->At(XAt, YAt, ZAt); - gp_Pnt EyePoint(XEye, YEye, ZEye); - gp_Pnt AtPoint(XAt, YAt, ZAt); - - gp_Vec EyeVector(EyePoint, AtPoint); - gp_Dir EyeDir(EyeVector); - - gp_Pln PlaneOfTheView = gp_Pln(AtPoint,EyeDir); - Standard_Real X, Y, Z; - aView->Convert(x, y, X, Y, Z); - gp_Pnt ConvertedPoint(X, Y, Z); - - gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfTheView, ConvertedPoint); - gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(), - ConvertedPointOnPlane.Y(), - PlaneOfTheView); - return ResultPoint; -} - - - - - - - -//================================================================================ -// function : SetDisplayedObjectList() -// purpose : -//================================================================================ -void GeometryGUI::SetDisplayedObjectList() -{ - if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - myListDisplayedObject.Clear(); - - Handle (AIS_InteractiveContext) aContext = v3d->getAISContext(); - aContext->DisplayedObjects( myListDisplayedObject ); -} - - - -//===================================================================================== -// function : OnDisplayAll() -// purpose : -//===================================================================================== -void GeometryGUI::OnDisplayAll(bool onlyPreviousDisplayedObject) -{ - if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); - - myContext->Display(v3d->getTrihedron()); - - if ( !onlyPreviousDisplayedObject ) { - AIS_ListOfInteractive List1; - myContext->ObjectsInCollector(List1); - AIS_ListIteratorOfListOfInteractive ite1(List1); - while (ite1.More()) { - if (ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value()); - if ( aSh->hasIO() ) { - Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); - if ( v3d->isInViewer(GIO, true) ) { - myContext->Display(aSh); - } - } - } - ite1.Next(); - } - } else { - AIS_ListIteratorOfListOfInteractive ite(myListDisplayedObject); - while (ite.More()) { - if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - if ( aSh->hasIO() ) { - Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); - if ( v3d->isInViewer(GIO,true) ) { - myContext->Display(aSh); - } - } - } - ite.Next(); - } - } -} - - - - -//===================================================================================== -// function : OnVTKDisplayOnly() -// purpose : -//===================================================================================== -void GeometryGUI::OnVTKDisplayOnly() -{ - - // Erase all not selected actors - - QApplication::setOverrideCursor( Qt::waitCursor ); - - vtkRenderer* aren = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* theActors = aren->GetActors(); - theActors->InitTraversal(); - vtkActor *ac = theActors->GetNextActor(); - while(!(ac==NULL)) { - if ( ac->IsA("SALOME_Actor") ) { - SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); - if(!anActor->isHighlighted()) anActor->VisibilityOff(); - } - ac = theActors->GetNextActor(); - } - - // Display selection - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); - - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - if(myRenderInter->isInViewer(IObject)) { - myRenderInter->Display(IObject); - } - else { - // Create new actor - if ( !obj->_is_nil() ) { - if ( !obj->FindAttribute(anAttr, "AttributeIOR")) - break; - // If selected object contains displayable subobjects, then do nothing - SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); - SALOMEDS::GenericAttribute_var aTmpAttr; - - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); - if (CORBA::is_nil(aShape)) continue; - TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); - - if (obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); - op->start(); - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, obj); - // commit transaction - op->finish(); - - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - 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 ); - GActor->setIO( IObject ); - GActor->setName( IObject->getName() ); - - theRenderer->AddActor(GActor); - vtkRenderWindow *renWin - = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()->GetRenderWindow(); - renWin->Render(); - anActor = (vtkActor*)theActors->GetNextActor(); - } - } - } - } - } - myActiveStudy->updateObjBrowser( true ); - QApplication::restoreOverrideCursor(); -} - - - -//===================================================================================== -// function : OnDisplayOnly() -// purpose : -//===================================================================================== -void GeometryGUI::OnDisplayOnly() -{ - if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListIteratorOfListOfInteractive ite(List); - while (ite.More()) { - if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - if (!ic->IsSelected( aSh )) { - ic->Erase( aSh, Standard_True, Standard_True ); - } - } - ite.Next(); - } - - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - - SALOME_ListIteratorOfListIO It1( Sel->StoredIObjects() ); - for(;It1.More();It1.Next()) { - Handle(SALOME_InteractiveObject) IObject = It1.Value(); - - - SALOMEDS::SObject_var fatherSF = - aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry()); - if ( v3d->isInViewer( IObject, true ) ) { - AIS_ListOfInteractive List1; - ic->ObjectsInCollector(List1); - AIS_ListIteratorOfListOfInteractive ite1(List1); - while (ite1.More()) { - if (ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value()); - if ( aSh->hasIO() ) { - Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); - if ( IObject->isSame( GIO ) ) { - ic->Display(aSh); - ic->AddOrRemoveCurrentObject(aSh, true); - break; - } - } - } - ite1.Next(); - } - } else { - if ( IObject->hasEntry() ) { - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if (obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() ); - if (CORBA::is_nil(aShape)) continue; - TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom, aShape); - - if (obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); - op->start(); - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, obj); - // commit transaction - op->finish(); - } - - Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value()); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), myFatherior,"GEOM"); - - IO->setEntry(obj->GetID()); - aSh->setIO( IO ); - aSh->setName( aName->Value() ); - ic->Display (aSh); - ic->AddOrRemoveCurrentObject(aSh, true); - } - } - } - } - } -} - - -//=============================================================================== -// function : OnEditDelete() -// purpose : -//=============================================================================== -void GeometryGUI::OnEditDelete() -{ - if ( QAD_MessageBox::warn2 - ( QAD_Application::getDesktop(), - tr ("GEOM_WRN_WARNING"), - tr ("GEOM_REALLY_DELETE"), - tr ("GEOM_BUT_YES"), tr ("GEOM_BUT_NO"), 1, 0, 0) != 1 ) - return; - - int nbSf = myActiveStudy->getStudyFramesCount(); - - Standard_Boolean found; - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - if ( IObject->hasEntry() ) { - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() ); - - /* Erase child graphical objects */ - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO); - for (; it->More();it->Next()) { - SALOMEDS::SObject_var CSO= it->Value(); - if (CSO->FindAttribute(anAttr, "AttributeIOR") ) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - /* Delete child(s) shape in Client : */ - const TCollection_AsciiString ASCior(anIOR->Value()) ; - myShapeReader.RemoveShapeFromBuffer( ASCior ) ; - - for ( int i = 0; i < nbSf; i++ ) { - QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); - if ( sf->getTypeView() == VIEW_OCC ) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); - Handle(GEOM_AISShape) Result = ConvertIORinGEOMAISShape( anIOR->Value(), found ); - if ( found ) - myContext->Erase( Result, true, false ); - } else if ( sf->getTypeView() == VIEW_VTK ) { - //vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor(); - GEOM_Actor* ac = ConvertIORinGEOMActor( anIOR->Value(), found ); - if ( found ) { - //Renderer->RemoveActor(ac); - if ( ac->hasIO() ) - myRenderInter->Remove( ac->getIO() ); - } - } - } - } - } - - /* Erase main graphical object */ - for ( int i = 0; i < nbSf; i++ ) { - QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); - if ( sf->getTypeView() == VIEW_OCC ) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); - Handle(GEOM_AISShape) Result = ConvertIOinGEOMAISShape( IObject, found ); - if ( found ) - myContext->Erase( Result, true, false ); - } else if ( sf->getTypeView() == VIEW_VTK ) { - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor(); - myRenderInter->Remove( IObject ); - } - } - - /* Delete main shape in Client : */ - if (SO->FindAttribute(anAttr, "AttributeIOR") ) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - const TCollection_AsciiString ASCIor(anIOR->Value()) ; - myShapeReader.RemoveShapeFromBuffer( ASCIor ) ; - } - - /* Erase objects in Study */ - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); - if ( !obj->_is_nil() ) { - QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); - op->start(); - aStudyBuilder->RemoveObject(obj); - op->finish(); - } - - } /* IObject->hasEntry() */ - } /* more/next */ - - /* Clear any previous selection */ - Sel->ClearIObjects() ; - myActiveStudy->updateObjBrowser(); -} - - -//============================================================================== -// function : OnEditCopy() -// purpose : -//============================================================================== -void GeometryGUI::OnEditCopy() -{ - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR; - - const SALOME_ListIO& List = Sel->StoredIObjects(); - - ConvertListOfIOInListOfIOR( List, listIOR); - - Sel->ClearIObjects(); - - for (unsigned int ind = 0; ind < listIOR->length();ind++) { - GEOM::GEOM_Shape_var aShapeInit = myComponentGeom->GetIORFromString(listIOR[ind]); - try { - GEOM::GEOM_Shape_var result = myComponentGeom->MakeCopy(aShapeInit) ; - result->NameType( aShapeInit->NameType() ); - this->Display(result); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - } - - myDesktop->putInfo(tr("GEOM_PRP_READY")); -} - - -//===================================================================================== -// function : DisplaySimulationShape() -// purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape -//===================================================================================== -void GeometryGUI::DisplaySimulationShape(const TopoDS_Shape& S) -{ - if( S.IsNull() ) - return ; - - //NRI DEBUG : 14/02/2002 - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - return ; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - try { - /* erase any previous */ - ic->Erase( this->mySimulationShape, Standard_True, Standard_False ); - ic->ClearPrs( this->mySimulationShape ); - this->mySimulationShape = new AIS_Shape( TopoDS_Shape() ) ; - this->mySimulationShape->Set( S ) ; - this->mySimulationShape->SetColor(Quantity_NOC_VIOLET) ; - ic->Deactivate( this->mySimulationShape ); - ic->Display( this->mySimulationShape, Standard_False ); - ic->UpdateCurrentViewer(); - } - catch(Standard_Failure) { - MESSAGE( "Exception catched in GeometryGUI::DisplaySimulationShape " ) ; - } - this->mySimulationShape->UnsetColor() ; - return ; -} - - - -//================================================================================== -// function : EraseSimulationShape() -// purpose : Clears the display of 'mySimulationShape' a pure graphical shape -//================================================================================== -void GeometryGUI::EraseSimulationShape() -{ - int count = myActiveStudy->getStudyFramesCount(); - for ( int i = 0; i < count; i++ ) { - if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - ic->Erase( this->mySimulationShape, Standard_True, Standard_False ); - ic->ClearPrs( this->mySimulationShape ); - ic->UpdateCurrentViewer(); - - } else if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_VTK ) { // VTK - } - } - // MESSAGE ( " GeometryGUI::EraseSimulationShape done. " ) -} - - - -//===================================================================================== -// function : Import -// purpose : BRep, Iges, Step -//===================================================================================== -bool GeometryGUI::Import( ) -{ - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - - GEOM::GEOM_Shape_var aShape; - QString file; - QStringList filtersList ; - - switch ( myState ) - { - case 111 : // Import BREP - { - filtersList.append( tr("GEOM_MEN_IMPORT_BREP") ); - filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ; - - file = QAD_FileDlg::getFileName(myDesktop, - "", - filtersList, - tr("GEOM_MEN_IMPORT"), - true); - if ( !file.isEmpty() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - try { - aShape = myComponentGeom->ImportBREP( file.latin1() ); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - } - break; - } - case 112 : // Import IGES - { - filtersList.append( tr("GEOM_MEN_IMPORT_IGES") ) ; - filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ; - - file = QAD_FileDlg::getFileName(myDesktop, - "", - filtersList, - tr("GEOM_MEN_IMPORT"), - true); - if ( !file.isEmpty() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - try { - aShape = myComponentGeom->ImportIGES( file.latin1() ); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - } - break; - } - case 113 : // Import STEP - { - filtersList.append( tr("GEOM_MEN_IMPORT_STEP") ) ; - filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ; - - file = QAD_FileDlg::getFileName(myDesktop, - "", - filtersList, - tr("GEOM_MEN_IMPORT"), - true); - if ( !file.isEmpty() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - try { - aShape = myComponentGeom->ImportSTEP( file.latin1() ); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - } - break; - } - } - - if ( !file.isEmpty() ) { - myDesktop->putInfo( tr("GEOM_PRP_LOADING").arg(QAD_Tools::getFileNameFromPath( file )) ); - - SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM"); - SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID( myActiveStudy->getActiveStudyFrame()->entry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributePixMap_var aPixmap; - int aLocked = false; - if (father->_is_nil()) { - QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); - op->start(); - aLocked = aStudy->GetProperties()->IsLocked(); - if (aLocked) aStudy->GetProperties()->SetLocked(false); - father = aStudyBuilder->NewComponent("GEOM"); - anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - // aName->SetValue( tr("GEOM_MEN_COMPONENT") ); - aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) ); - anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" ); - if (aLocked) aStudy->GetProperties()->SetLocked(true); - op->finish(); - } -// if (aLocked) return false; - aStudyBuilder->DefineComponentInstance( father, myComponentGeom ); - father->ComponentIOR( myFatherior ); - - QString nameShape = QAD_Tools::getFileNameFromPath(file,false) + QString("_%1").arg(this->myNbGeom++); - - if ( Display ( aShape, strdup(nameShape.latin1())) ) { - myActiveStudy->setMessage( tr("GEOM_INF_LOADED").arg(QAD_Tools::getFileNameFromPath( file )) ); - myDesktop->putInfo( tr("GEOM_PRP_READY")); - } - } - QApplication::restoreOverrideCursor(); - return true ; -} - - -//===================================================================================== -// function : Export -// purpose : BRep, Iges, Step -//===================================================================================== -bool GeometryGUI::Export( ) -{ - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - - GEOM::GEOM_Shape_var aShape; - - static QString filters[] = { tr("GEOM_MEN_IMPORT_BREP"), - tr("GEOM_MEN_IMPORT_IGES"), - tr("GEOM_MEN_IMPORT_STEP") }; - - SALOME_Selection* Sel = SALOME_Selection::Selection( this->myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - - switch ( myState ) - { - case 121 : - { - for(;It.More();It.Next()) { - QApplication::restoreOverrideCursor(); - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - GEOM::GEOM_Shape_var aShape = ConvertIOinGEOMShape(IObject, found); - // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true); - if ( found ) { - QString file = QAD_FileDlg::getFileName(myDesktop, - QString( IObject->getName() ) + ".brep", - tr("GEOM_MEN_IMPORT_BREP"), - tr("GEOM_MEN_EXPORT"), - false); - if ( !file.isEmpty() && !aShape->_is_nil() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - // Standard_Boolean result = BRepTools::Write(Shape->Shape(), strdup(file.latin1()) ); - try { - myComponentGeom->ExportBREP(strdup( file.latin1()), aShape); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - } - } - } - break; - } - case 122 : - { - for(;It.More();It.Next()) { - QApplication::restoreOverrideCursor(); - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - GEOM::GEOM_Shape_var aShape = ConvertIOinGEOMShape(IObject, found); - // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true); - if ( found ) { - QString file = QAD_FileDlg::getFileName(myDesktop, - QString( IObject->getName() ) + ".igs", - tr("GEOM_MEN_IMPORT_IGES"), - tr("GEOM_MEN_EXPORT"), - false); - if ( !file.isEmpty() && !aShape->_is_nil() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - try { - myComponentGeom->ExportIGES(strdup( file.latin1()), aShape); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -// //VRV: OCC 4.0 migration -// IGESControl_Controller::Init(); -// IGESControl_Writer ICW (Interface_Static::CVal("XSTEP.iges.unit"), -// Interface_Static::IVal("XSTEP.iges.writebrep.mode")); -// //VRV: OCC 4.0 migration - -// ICW.AddShape (Shape->Shape()); -// ICW.ComputeModel(); -// Standard_Boolean result = ICW.Write( strdup(file.latin1()) ); - } - } - } - break; - } - - case 123 : - { -// bool test = false ; -// IFSelect_ReturnStatus status ; -// //VRV: OCC 4.0 migration -// STEPControl_Writer aWriter; -// //VRV: OCC 4.0 migration - QString file; - - for( ; It.More(); It.Next() ) { -// GEOM::GEOM_Shape_var aShape = ConvertIOinGEOMShape(IObject, found); - QApplication::restoreOverrideCursor(); - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - GEOM::GEOM_Shape_var aShape = ConvertIOinGEOMShape(IObject, found); - // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true); - if ( found ) { - file = QAD_FileDlg::getFileName(myDesktop, - QString( IObject->getName() ) + ".stp", - tr("GEOM_MEN_IMPORT_STEP"), - tr("GEOM_MEN_EXPORT"), - false); - if ( !file.isEmpty() && !aShape->_is_nil() ) { - - QApplication::setOverrideCursor( Qt::waitCursor ) ; - try { - myComponentGeom->ExportSTEP(strdup( file.latin1()), aShape); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -// //VRV: OCC 4.0 migration -// status = aWriter.Transfer( Shape->Shape(), STEPControl_ManifoldSolidBrep ) ; -// //VRV: OCC 4.0 migration -// test = true ; -// if ( status != IFSelect_RetDone ) { -// QApplication::restoreOverrideCursor() ; -// return false ; -// } - } - } - } -// if(test) { -// status = aWriter.Write( strdup(file.latin1()) ) ; -// QApplication::restoreOverrideCursor() ; -// return status ; -// } - break; - } - - } - QApplication::restoreOverrideCursor() ; -} - - -//===================================================================================== -// function : Display() -// purpose : Displays a CORBA shape -//===================================================================================== -bool GeometryGUI::Display( GEOM::GEOM_Shape_ptr aShape, - Standard_CString name) -{ - // MESSAGE ( "GeometryGUI::Display init ") - Handle(GEOM_InteractiveObject) IO; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - Sel->ClearIObjects(); - - if( aShape->_is_nil() ) { - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), - tr ("GEOM_WRN_WARNING"), - tr ("GEOM_PRP_ABORT"), - tr ("GEOM_BUT_OK") ); - return false ; - } - - TopoDS_Shape shape = myShapeReader.GetShape(myComponentGeom, aShape); - - if ( shape.IsNull() ) - return false; - - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributePixMap_var aPixmap; - - SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM"); - int aLocked = false; - if (father->_is_nil()) { - QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); - op->start(); - aLocked = aStudy->GetProperties()->IsLocked(); - if (aLocked) aStudy->GetProperties()->SetLocked(false); - father = aStudyBuilder->NewComponent("GEOM"); - anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - // aName->SetValue( tr("GEOM_MEN_COMPONENT") ); - aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) ); - anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" ); - myActiveStudy->updateObjBrowser(); - if (aLocked) aStudy->GetProperties()->SetLocked(true); - op->finish(); - } -// if (aLocked) return false; - - aStudyBuilder->DefineComponentInstance( father, myComponentGeom ); - father->ComponentIOR( myFatherior ); - - TCollection_AsciiString nameG(""); - Standard_CString Type; - if ( TCollection_AsciiString(name).IsEqual(Standard_CString("")) ) { - if ( TCollection_AsciiString(aShape->NameType()).IsEqual(Standard_CString("")) ) { - Standard_CString type; - GetShapeTypeString(shape,type); - aShape->NameType( type ); - nameG += TCollection_AsciiString( type ) + TCollection_AsciiString("_") + - TCollection_AsciiString( myNbGeom++ ) + TCollection_AsciiString("\0"); - } else - nameG += TCollection_AsciiString( aShape->NameType()) + TCollection_AsciiString("_") + - TCollection_AsciiString( myNbGeom++ ) + TCollection_AsciiString("\0"); - } else - nameG = TCollection_AsciiString(name); - - // VTK - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - int themode = myRenderInter->GetDisplayMode(); - - vtkActorCollection* theActors = - GEOM_AssemblyBuilder::BuildActors(shape,0,themode,Standard_True); - theActors->InitTraversal(); - vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); - - IO = new GEOM_InteractiveObject(aShape->Name(), - myFatherior, - "GEOM"); - while(!(anActor==NULL)) { - GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor ); - GActor->setIO( IO ); - GActor->setName( nameG.ToCString() ); - - theRenderer->AddActor(GActor); - anActor = (vtkActor*)theActors->GetNextActor(); - } - } - // OCC - else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - Handle(GEOM_AISShape) theResult = new GEOM_AISShape( shape, nameG.ToCString() ); - theResult->SetShadingColor( myShadingColor ); - IO = new GEOM_InteractiveObject(aShape->Name(), - myFatherior, - "GEOM"); - theResult->setIO( IO ); - theResult->setName( nameG.ToCString() ); - - /* Precaution : close any local context to permit the display */ - if ( ic->HasOpenedContext() ) { - ic->CloseAllContexts(); - } - -// if(isInfinite) -// theResult->SetInfiniteState() ; - - ic->Display(theResult); - } - - Sel->AddIObject( IO, false ); - myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Repaint(); - if ( mySettings_AddInStudy ) - AddInStudy( false, IO ); - - return true; -} - - -//===================================================================================== -// function : AddInStudy() -// purpose : anIOShape or a selected shape -//===================================================================================== -bool GeometryGUI::AddInStudy( bool selection, - const Handle(SALOME_InteractiveObject)& anIO) -{ - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - if ( !( !mySettings_AddInStudy || selection ) ) { - Sel->ClearIObjects(); - } - - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributePixMap_var aPixmap; - SALOMEDS::AttributeIOR_var anIOR; - SALOMEDS::AttributeSelectable_var aSelAttr; - - SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM"); - int aLocked = false; - if (father->_is_nil()) { - QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); - op->start(); - aLocked = aStudy->GetProperties()->IsLocked(); - if (aLocked) aStudy->GetProperties()->SetLocked(false); - father = aStudyBuilder->NewComponent("GEOM"); - anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - // aName->SetValue( tr("GEOM_MEN_COMPONENT") ); - aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) ); - anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" ); - if (aLocked) aStudy->GetProperties()->SetLocked(true); - op->finish(); - } -// if (aLocked) return false; - - aStudyBuilder->DefineComponentInstance( father, myComponentGeom ); - father->ComponentIOR( myFatherior ); - - SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry()); - - Handle(GEOM_AISShape) GAISShape; - GEOM_Actor* GActor; - Handle(GEOM_InteractiveObject) GIO; - bool found = false; - - // VTK - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - vtkRenderer *Renderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - - vtkActorCollection* theActors = Renderer->GetActors(); - theActors->InitTraversal(); - vtkActor *ac = theActors->GetNextActor(); - while(!(ac==NULL)) { - if ( ac->IsA("GEOM_Actor") ) { - GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( ac ); - if ( anActor->hasIO() ) { - Handle(SALOME_InteractiveObject) IO = anActor->getIO(); - if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) { - GIO = Handle(GEOM_InteractiveObject)::DownCast( IO ); - if ( anIO->isSame( GIO ) ) { - found = true; - GActor = anActor; - break; - } - } - } - } - ac = theActors->GetNextActor(); - } - - if ( !found ) - return false; - } - // OCC - else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListIteratorOfListOfInteractive ite(List); - while (ite.More()) { - if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - if ( aSh->hasIO() ) { - Handle(SALOME_InteractiveObject) IO = aSh->getIO(); - if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) { - GIO = Handle(GEOM_InteractiveObject)::DownCast( IO ); - if ( anIO->isSame( GIO ) ) { - found = true; - GAISShape = aSh; - break; - } - } - } - } - ite.Next(); - } - - if ( !found ) - return false; - } - - if ( !mySettings_AddInStudy || selection ) { - QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), anIO->getName() ); - if ( !Name.isEmpty() ) { - // VTK - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - GActor->setName( strdup(Name.latin1()) ); - } - // OCC - else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - GAISShape->setName( strdup(Name.latin1()) ); - } - } else { - return false; - } - } - - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); - op->start(); - - SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(father); - - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GIO->getIOR() ); - - /* For the shape inserted into the study we set its field 'studyshapeid' */ - /* so the shape will contain its corresponding entry in the study Ocaf doc. */ - aShape->StudyShapeId(newObj->GetID()) ; - - GIO->setEntry(newObj->GetID()); - - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - anIOR->SetValue(aShape->Name()); - - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - if ( aShape->ShapeType() == GEOM::COMPOUND ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" ); - } else if ( aShape->ShapeType() == GEOM::COMPSOLID ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" ); - } else if ( aShape->ShapeType() == GEOM::SOLID ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" ); - } else if ( aShape->ShapeType() == GEOM::SHELL ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" ); - } else if ( aShape->ShapeType() == GEOM::FACE ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" ); - } else if ( aShape->ShapeType() == GEOM::WIRE ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" ); - } else if ( aShape->ShapeType() == GEOM::EDGE ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" ); - } else if ( aShape->ShapeType() == GEOM::VERTEX ) { - aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" ); - } - - // VTK - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - GActor->setIO( GIO ); - aName->SetValue(GActor->getName()); - } - // OCC - else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - GAISShape->setIO( GIO ); - aName->SetValue(GAISShape->getName()); - } - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1,newObj); - - GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR; - listIOR = myComponentGeom->GetReferencedObjects(aShape); - - if (listIOR->length()>0) { - SALOMEDS::SObject_var Arguments = aStudyBuilder->NewObject(newObj); - anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(tr("GEOM_ARGUMENTS")); - anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeSelectable"); - aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); - aSelAttr->SetSelectable(false); - - bool ObjectReferenced = false; - for (unsigned int ind = 0; ind < listIOR->length();ind++) { - SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(listIOR[ind]); - - if ( !theObj->_is_nil() ) { - SALOMEDS::SObject_var RefObject = aStudyBuilder->NewObject(Arguments); - aStudyBuilder->Addreference(RefObject, theObj); - ObjectReferenced = true; - } - } - - if ( !ObjectReferenced ) - aStudyBuilder->RemoveObject(Arguments); - } - - op->finish(); - - - if ( !mySettings_AddInStudy || selection ) { - myActiveStudy->updateObjBrowser(); - } else { - myActiveStudy->updateObjBrowser(false); - Sel->AddIObject( GIO ); - } - - // MESSAGE ( " highlihght done" ) - return true; - -} - - -//===================================================================================== -// function : GetShapeFromIOR() -// purpose : exist also as static method ! -//===================================================================================== -TopoDS_Shape GeometryGUI::GetShapeFromIOR( QString IOR ) -{ - TopoDS_Shape result; - if( IOR.stripWhiteSpace().isEmpty() ) - return result; - ORB_INIT &init = *SINGLETON_::Instance() ; - CORBA::ORB_var& _orb = init.orb() ; - CORBA::Object_var obj = _orb->string_to_object( (char*)(IOR.latin1()) ); - if ( CORBA::is_nil( obj ) ) - return result; - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( IOR ); - if (!aShape->_is_nil()) { - result = myShapeReader.GetShape( myComponentGeom, aShape ); - } - return result; -} - - - -//======================================================================= -// function : Parameter() -// purpose : return a parameter (float) from a dialog box -// -// avalue1 : is a float or integer used as a default value displayed -// aTitle1 : is the title for aValue1 -// aTitle : is the main title -// bottom : maximum value to be entered -// top : minimum value to be entered -// decimals : number of decimals -//======================================================================= -double GeometryGUI::Parameter( Standard_Boolean& res, - const char* aValue1, - const char* aTitle1, - const char* aTitle, - const double bottom, - const double top, - const int decimals ) -{ - GeometryGUI_aParameterDlg * Dialog = - new GeometryGUI_aParameterDlg(aValue1, - aTitle1, - QAD_Application::getDesktop(), - aTitle, - TRUE, - 0, - bottom, - top, - decimals) ; - int r = Dialog->exec() ; - float X = 0.0 ; - if ( r == QDialog::Accepted ) { - res = Standard_True; - X = Dialog->getValue(); - } else - res = Standard_False; - delete Dialog; - return X; -} - - -//======================================================================= -// function : OnSketchSegment() -// purpose : -//======================================================================= -void GeometryGUI::OnSketchSegment() -{ - this->mySketcher.ChangeMode(SEGMENT); -} - - -//======================================================================= -// function : OnSketchArc() -// purpose : -//======================================================================= -void GeometryGUI::OnSketchArc() -{ - this->mySketcher.ChangeMode(ARC_CHORD); -} - -//======================================================================= -// function : OnSketchSetAngle() -// purpose : -//======================================================================= -void GeometryGUI::OnSketchSetAngle() -{ - Standard_Real anAngle = this->mySketcher.GetSegmentAngle()/PI180; - Sketch::fitInResol(anAngle); - Standard_Boolean res = false ; - QString Value = QString("%1").arg( anAngle ); - anAngle = Parameter(res, Value, tr("GEOM_MEN_ANGLE"), tr("GEOM_MEN_ENTER_ANGLE"), -180.0, +180.0, 6 )*PI180 ; - - if( res ) { - this->mySketcher.SetSegmentAngle(anAngle); - QMenuBar* Mb = this->myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(3133,&pp); - pp->setItemChecked(3133,false); - item = Mb->findItem(3134,&pp); - pp->setItemChecked(3134,false); - } - -} - - -//======================================================================= -// function : OnSketchSetx() -// purpose : -//======================================================================= -void GeometryGUI::OnSketchSetx() -{ - Standard_Boolean res = false; - double X = Parameter( res, - "0.", - tr("GEOM_MEN_X"), - tr("GEOM_MEN_SKETCHER_X"), - 2.0 * Precision::Confusion(), - 1E6, - 6 ) ; - if (res) - this->mySketcher.SetXDimension(X); - QMenuBar* Mb = this->myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(3133,&pp); - pp->setItemChecked(3133,false); - item = Mb->findItem(3134,&pp); - pp->setItemChecked(3134,false); -} - -//======================================================================= -// function : OnSketchSety() -// purpose : -//======================================================================= -void GeometryGUI::OnSketchSety() -{ - Standard_Boolean res = false; - double Y = Parameter( res, - "0.", - tr("GEOM_MEN_Y"), - tr("GEOM_MEN_SKETCHER_Y"), - 2.0 * Precision::Confusion(), - 1E6, - 6 ) ; - if (res) - this->mySketcher.SetYDimension(Y); - QMenuBar* Mb = this->myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(3133,&pp); - pp->setItemChecked(3133,false); - item = Mb->findItem(3134,&pp); - pp->setItemChecked(3134,false); -} - - -//======================================================================= -// function : OnSketchDelete() -// purpose : -//======================================================================= -void GeometryGUI::OnSketchDelete() -{ - if (mySketcher.GetmyEdgesNumber() == 1 ) { - QMenuBar* Mb = myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(313,&pp); - pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS - mySketcher.SetTransitionStatus(NOCONSTRAINT); - } - - if (this->mySketcher.Delete()) - ResetState(); -} - - -//======================================================================= -// function : OnSketchClose() -// purpose : -//======================================================================= -void GeometryGUI::OnSketchClose() -{ - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); - - TopoDS_Wire W = this->mySketcher.Close(); - if ( !W.IsNull() ) { - // - GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR; - listShapes->length(0); - unsigned int i = 0; - - BRepTools_WireExplorer Ex(W); - while ( Ex.More() ) { - TopoDS_Edge E = Ex.Current(); - gp_Pnt pt1 , pt2 ; - - pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E)); - pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E)); - - gp_Pnt CenterPoint; - Handle(Geom_Curve) Curve; - Handle(Geom_Circle) Circle; - gp_Circ Circ; - Standard_Real First,Last; - - Curve = BRep_Tool::Curve(E,First,Last); - if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) { - Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ - Circ = Circle->Circ(); // gp_Circ - - Curve->D0( (First + Last) / 2. , CenterPoint ); - - GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() ); - GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() ); - GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() ); - - GEOM::GEOM_Shape_var arc; - - try { - arc = myComponentGeom->MakeArc(pI, pC, pE) ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - - listShapes->length(i+1); - listShapes[i] = strdup(arc->Name()); - i++; - } else { - GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() ); - GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() ); - GEOM::GEOM_Shape_var segment; - - try { - segment = myComponentGeom->MakeEdge(pI,pE) ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - - listShapes->length(i+1); - listShapes[i] = strdup(segment->Name()); - i++; - } - Ex.Next(); - } - GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ; - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, Wire); - Standard_CString type; - GetShapeTypeString(S,type); - Wire->NameType( type ); - - if ( Display(Wire, "" )) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - } - ResetState(); - QMenuBar* Mb = this->myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(313,&pp); - pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS - mySketcher.SetTransitionStatus(NOCONSTRAINT); -} - - - -//======================================================================= -// function : OnSketchEnd() -// purpose : -//======================================================================= -void GeometryGUI::OnSketchEnd() -{ - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); - - TopoDS_Wire W = this->mySketcher.End(); - if (!W.IsNull()) { - // - GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR; - listShapes->length(0); - unsigned int i = 0; - - BRepTools_WireExplorer Ex(W); - while ( Ex.More() ) { - TopoDS_Edge E = TopoDS::Edge( Ex.Current() ); - - gp_Pnt pt1 , pt2 ; - pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E)); - pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E)); - - gp_Pnt CenterPoint; - Handle(Geom_Curve) Curve; - Handle(Geom_Circle) Circle; - gp_Circ Circ; - Standard_Real First,Last; - - Curve = BRep_Tool::Curve(E,First,Last); - if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) { - Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ - Circ = Circle->Circ(); // gp_Circ - - Curve->D0( (First + Last) / 2. , CenterPoint ); - - GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() ); - GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() ); - GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() ); - - GEOM::GEOM_Shape_var arc; - - try { - arc = myComponentGeom->MakeArc(pI, pC, pE) ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - - listShapes->length(i+1); - listShapes[i] = strdup(arc->Name()); - i++; - } else { - GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() ); - GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() ); - GEOM::GEOM_Shape_var segment; - - try { - segment = myComponentGeom->MakeEdge(pI,pE) ; - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - - listShapes->length(i+1); - listShapes[i] = strdup(segment->Name()); - i++; - } - Ex.Next(); - } - - GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ; - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, Wire); - Standard_CString type; - GetShapeTypeString(S,type); - Wire->NameType( type ); - - if ( Display(Wire, "") ) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - } - ResetState(); - QMenuBar* Mb = this->myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(313,&pp); - pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS - mySketcher.SetTransitionStatus(NOCONSTRAINT); -} - -//======================================================================= -// function : OnSettingsNoconstraint() -// purpose : -//======================================================================= -void GeometryGUI::OnSettingsNoconstraint() -{ - this->mySketcher.SetTransitionStatus(NOCONSTRAINT); -} - -//======================================================================= -// function : OnSettingsPerpendicular() -// purpose : -//======================================================================= -void GeometryGUI::OnSettingsPerpendicular() -{ - this->mySketcher.SetTransitionStatus(PERPENDICULAR); -} - -//======================================================================= -// function : OnSettingsTangent() -// purpose : -//======================================================================= -void GeometryGUI::OnSettingsTangent() -{ - this->mySketcher.SetTransitionStatus(TANGENT); -} - -//======================================================================= -// function : OnSketchOptionsOnoffangledimension() -// purpose : -//======================================================================= -void GeometryGUI::OnSketchOptionsOnoffangledimension() -{ - QMenuBar* Mb = this->myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(10011,&pp); - pp->setItemChecked(10011,!pp->isItemChecked(10011)); - this->mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011)); -} - -//======================================================================= -// function : OnSketchOptionsOnofflengthdimension() -// purpose : -//======================================================================= -void GeometryGUI::OnSketchOptionsOnofflengthdimension() -{ - QMenuBar* Mb = this->myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(10010,&pp); - pp->setItemChecked(10010,!pp->isItemChecked(10010)); - this->mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010)); -} - -//======================================================================= -// function : OnSketchOptionsOnoffradiusdimension() -// purpose : -//======================================================================= -void GeometryGUI::OnSketchOptionsOnoffradiusdimension() -{ - QMenuBar* Mb = this->myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(10012,&pp); - pp->setItemChecked(10012,!pp->isItemChecked(10012)); - this->mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012)); -} - - -//======================================================================= -// function : OnSketchOptionsOnoffxdimension() -// purpose : -//======================================================================= -void GeometryGUI::OnSketchOptionsOnoffxdimension() -{ - QMenuBar* Mb = this->myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(10013,&pp); - pp->setItemChecked(10013,!pp->isItemChecked(10013)); - this->mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013)); -} - -//======================================================================= -// function : OnSketchOptionsOnoffydimension() -// purpose : -//======================================================================= -void GeometryGUI::OnSketchOptionsOnoffydimension() -{ - QMenuBar* Mb = this->myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(10014,&pp); - pp->setItemChecked(10014,!pp->isItemChecked(10014)); - this->mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014)); -} - - -//======================================================================= -// function : Archimede() -// purpose : -//======================================================================= -void GeometryGUI::Archimede( const Handle(SALOME_InteractiveObject)& IO, - const double aWeight, - const double aWaterDensity, - const double aMeshingDeflection ) -{ - try { - if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { - Handle(GEOM_InteractiveObject) GIO = - Handle(GEOM_InteractiveObject)::DownCast( IO ); - GEOM::GEOM_Shape_var Shape = myComponentGeom->GetIORFromString( GIO->getIOR() ); - - GEOM::GEOM_Shape_var Result = myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection); - Result->NameType(tr("GEOM_PLANE")); - if ( Display(Result, "") ) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - return; - } - if ( IO->hasEntry() ) { - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if (obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var Shape = myComponentGeom->GetIORFromString( anIOR->Value() ); - GEOM::GEOM_Shape_var Result = myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection); - Result->NameType(tr("GEOM_PLANE")); - if ( Display(Result, "") ) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - } - } - } - - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -} - - -//===================================================================================== -// function : OnFilletGetAll() -// purpose : -//===================================================================================== -bool GeometryGUI::OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, const int SubShapeType, const char* ShapeTopoIOR) -{ - GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; - ListOfID->length(0); - - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR ); - if ( theObj->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); - return false ; - } - - try { - if( Radius <= Precision::Confusion() ) - return false; - - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR ); - GEOM::GEOM_Shape_var result = myComponentGeom->MakeFillet(aShape, Radius, SubShapeType, ListOfID) ; - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - return false; - } - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); - Standard_CString type; - GetShapeTypeString(S,type); - result->NameType( type ); - - if ( Display( result, "" )) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return true; -} - -//===================================================================================== -// function : OnFilletGetSelected() -// purpose : -//===================================================================================== -bool GeometryGUI::OnFilletGetSelected(const TopoDS_Shape& ShapeTopo, - const char* ShapeTopoIOR, - const double Radius, - const int SubShapeType, - Standard_Integer& aLocalContextId, - bool& myUseLocalContext ) -{ - if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { - return false; - } - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - if( myUseLocalContext == false ) { - /* No local context opened for fillet method */ - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - return false ; - } - - GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; - ic->InitSelected(); - int nbSelected = ic->NbSelected(); - int i = 0; - ic->InitSelected(); - - while(ic->MoreSelected()) { - TopoDS_Shape s = ic->SelectedShape(); - if ( s.ShapeType() == TopAbs_FACE ) { - TopExp_Explorer Exp( s, TopAbs_EDGE ); - TopTools_MapOfShape M ; - while ( Exp.More() ) { - if( M.Add(Exp.Current() )) { /* if a new edge : do not add doublons indices */ - ListOfID->length( i + 1 ); - ListOfID[i] = GetIndex( Exp.Current(), ShapeTopo, (int)TopAbs_EDGE ) ; - i++ ; - } - Exp.Next(); - } - } - else { - ListOfID->length( i + 1 ); - ListOfID[i] = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType ); - i++; - } - ic->NextSelected(); - } - - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR ); - GEOM::GEOM_Shape_var aResult ; - try { - aResult = myComponentGeom->MakeFillet( aShape, Radius, 6, ListOfID ); - - /* local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId) ; - myUseLocalContext = false ; - - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, aResult); - Standard_CString type; - GetShapeTypeString(S,type); - aResult->NameType( type ); - - if ( Display( aResult, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - - if ( myUseLocalContext ) { - /* local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId) ; - myUseLocalContext = false ; - } - - this->OnDisplayAll(true); - myActiveStudy->updateObjBrowser(); - myDesktop->putInfo (tr("GEOM_PRP_READY")); - - return true ; -} - -//===================================================================================== -// function : OnChamferGetAll() -// purpose : -//===================================================================================== -bool GeometryGUI::OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, const int SubShapeType, const char* ShapeTopoIOR) -{ - GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; - ListOfID->length(0); - - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR ); - if ( theObj->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); - return false ; - } - - try { - if( D1 <= Precision::Confusion() ) - return false; - if( D2 <= Precision::Confusion() ) - return false; - - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR ); - GEOM::GEOM_Shape_var result = myComponentGeom->MakeChamfer(aShape, D1, D2, SubShapeType, ListOfID) ; - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - return false; - } - - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, result); - Standard_CString type; - GetShapeTypeString(S,type); - result->NameType( type ); - - if ( Display( result, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return true; -} - -//===================================================================================== -// function : OnChamferGetSelected() -// purpose : -//===================================================================================== -bool GeometryGUI::OnChamferGetSelected(const TopoDS_Shape& ShapeTopo, - const char* ShapeTopoIOR, - const double D1, const double D2, const int SubShapeType, - Standard_Integer& aLocalContextId, - bool& myUseLocalContext) -{ - if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { - return false; - } - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - if( myUseLocalContext == false ) { - /* No local context opened for chamfer method */ - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); - return false ; - } - - GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; - ic->InitSelected(); - int nbSelected = ic->NbSelected(); - int i = 0; - ic->InitSelected(); - - while(ic->MoreSelected()) { - TopoDS_Shape s = ic->SelectedShape(); - if ( s.ShapeType() == TopAbs_FACE ) { - TopExp_Explorer Exp( s, TopAbs_EDGE ); - TopTools_MapOfShape M ; - while ( Exp.More() ) { - if( M.Add(Exp.Current() )) { /* if a new edge : do not add doublons indices */ - ListOfID->length( i + 1 ); - ListOfID[i] = GetIndex( Exp.Current(), ShapeTopo, (int)TopAbs_EDGE ) ; - i++ ; - } - Exp.Next(); - } - } - else { - ListOfID->length( i + 1 ); - ListOfID[i] = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType ) ; - i++; - } - ic->NextSelected(); - } - - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR ); - GEOM::GEOM_Shape_var aResult ; - try { - aResult = myComponentGeom->MakeChamfer( aShape, D1, D2, 6, ListOfID ); - - /* local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId) ; - myUseLocalContext = false ; - - TopoDS_Shape S = myShapeReader.GetShape(myComponentGeom, aResult); - Standard_CString type; - GetShapeTypeString(S,type); - aResult->NameType( type ); - - if ( Display( aResult, "") ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - - if ( myUseLocalContext ) { - /* local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId) ; - myUseLocalContext = false ; - } - - this->OnDisplayAll(true); - myActiveStudy->updateObjBrowser(); - myDesktop->putInfo (tr("GEOM_PRP_READY")); - - return true ; -} - -//===================================================================================== -// function : MakeCDGAndDisplay() -// purpose : -//===================================================================================== -void GeometryGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape) -{ - try { - GEOM::GEOM_Shape_var result = myComponentGeom->MakeCDG( Shape ); - if ( result->_is_nil() ) { - myDesktop->putInfo(tr("GEOM_PRP_ABORT") ); - return ; - } - result->NameType( tr("GEOM_POINT") ); - if ( Display( result ) ) - myDesktop->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return ; -} - -bool GeometryGUI::SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR) { - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(theFatherObject); - SALOMEDS::SObject_var RefSO; - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - for (; it->More();it->Next()) { - SALOMEDS::SObject_var SO= it->Value(); - if (SO->FindAttribute(anAttr, "AttributeIOR") ) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - if ( strcmp( anIOR->Value(), IOR ) == 0 ) - return true; - } - if ( SO->ReferencedObject( RefSO ) ) { - if (RefSO->FindAttribute(anAttr, "AttributeIOR") ) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - if ( strcmp( anIOR->Value(), IOR ) == 0 ) - return true; - } - } - } - return false; -} - - -//======================================================================= -// function : OnGUIEvent() [static] -// purpose : manage all events on GUI -//======================================================================= -bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) -{ - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - - OCCViewer_Viewer3d* v3d; - Handle(AIS_InteractiveContext) ic; - vtkRenderer* Renderer; - - QMenuBar* Mb = myDesktop->getMainMenuBar(); - - bool ViewOCC = false; - - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - ic = v3d->getAISContext(); - ViewOCC = true; - Mb->setItemEnabled( 312, ViewOCC);//Sketch - Mb->setItemEnabled( 309, ViewOCC);//SuppressFace - Mb->setItemEnabled( 314, ViewOCC);//SuppressHole - - Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings - Mb->setItemEnabled( 704, ViewOCC);// Isos Settings - - } else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - Renderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - - // OnSuppressFaces, OnSuppressHole, SETTINGS - SHADING COLOR, SETTINGS - ISOS, SETTINGS : STEP VALUE FOR SPIN BOXES, SKETCHER, ISOS - POPUP VIEWER, - Mb->setItemEnabled( 312, ViewOCC);//Sketch - Mb->setItemEnabled( 309, ViewOCC);//SuppressFace - Mb->setItemEnabled( 314, ViewOCC);//SuppressHole - - Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings - Mb->setItemEnabled( 704, ViewOCC);// Isos Settings - } else { - return 0; - } - - if (myState == CURRENT_SKETCH && theCommandID != 10000 && theCommandID != 10001 && theCommandID != 10002 && theCommandID != 10003 && theCommandID != 10004 && theCommandID != 10006 && theCommandID != 10007 && theCommandID != 10008 && theCommandID != 10010 && theCommandID != 10011 && theCommandID != 10012 && theCommandID != 10013 && theCommandID != 10014 && theCommandID != 3133 && theCommandID != 3134) - return false; - - -// QString theCommandID_str = itoa(theCommandID); -// theCommandID_str.truncate(3); -// int theCommandID_Group = theCommandID_str.toInt(); - if (theCommandID == 3021 || theCommandID == 3022 || theCommandID == 3023 || theCommandID == 3024 || theCommandID == 3025) { - PrimitiveGUI* myPrimitiveGUI = new PrimitiveGUI(); - myPrimitiveGUI->OnGUIEvent(theCommandID, parent); - return true ; - } - if (theCommandID == 4011 || theCommandID == 4012 || theCommandID == 4013 || theCommandID == 4014) { - BooleanGUI* myBooleanGUI = new BooleanGUI(); - myBooleanGUI->OnGUIEvent(theCommandID, parent); - return true ; - } - - - switch (theCommandID) - { - case 31: // COPY - OnEditCopy(); - break; - - case 33: // DELETE - OnEditDelete(); - break; - - case 111: - { - SetState(111); - Import(); - ResetState(); - break; - } - case 112: - { - SetState(112); - Import(); - ResetState(); - break; - } - case 113: // IMPORT STEP - { - SetState(113); - Import(); - ResetState(); - break; - } - - case 121: // EXPORT BREP - { - SetState(121); - Export(); - ResetState(); - break; - } - - case 122: // EXPORT IGES - { - SetState(122); - Export(); - ResetState(); - break; - } - - case 123: // EXPORT STEP - { - SetState(123); - Export(); - ResetState(); - break; - } - - case 303: // EXPLODE : use ic - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_SubShapeDlg *aDlg = new GeometryGUI_SubShapeDlg( parent, "", Sel, ic ) ; - break ; - } - - case 304: // GEOM::EDGE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_EdgeDlg *aDlg = new GeometryGUI_EdgeDlg( parent, "", Sel ) ; - break ; - } - - case 305: // GEOM::WIRE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_WireDlg *aDlg = new GeometryGUI_WireDlg( parent, "", Sel ) ; - break ; - } - - case 306: // GEOM::FACE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_FaceDlg *aDlg = new GeometryGUI_FaceDlg ( parent, "", Sel ) ; - break ; - } - - case 315: // GEOM::SHELL - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_ShellDlg *aDlg = new GeometryGUI_ShellDlg ( parent, "", Sel ) ; - break ; - } - - case 316: // GEOM::SOLID - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_SolidDlg *aDlg = new GeometryGUI_SolidDlg ( parent, "", Sel ) ; - break ; - } - - case 308: // GEOM::COMPOUND - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_CompoundDlg *aDlg = new GeometryGUI_CompoundDlg ( parent, "", Sel ) ; - break ; - } - - case 309: // SUPPRESS FACES : use ic - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_SuppressFacesDlg *aDlg = new GeometryGUI_SuppressFacesDlg( parent, "", Sel, ic ) ; - break ; - } - - case 314: // SUPPRESS HOLES : use ic - { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_SuppressHoleDlg *aDlg = new GeometryGUI_SuppressHoleDlg( parent, "", Sel, ic ) ; - } - else { - myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ; - } - break ; - } - case 501: // SEWING - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_SewingDlg *aDlg = new GeometryGUI_SewingDlg ( parent, "", Sel ) ; - break ; - } - - case 502: // ORIENTATION - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_OrientationDlg *aDlg = new GeometryGUI_OrientationDlg( parent, "", Sel ) ; - break ; - } - - case 601: // PROPERTIES (Length, surface, volume) - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_PropertiesDlg *aDlg = new GeometryGUI_PropertiesDlg( parent, "", Sel ) ; - break ; - } - - case 604: // CDG : Center of mass - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_CenterMassDlg *aDlg = new GeometryGUI_CenterMassDlg ( parent, "", Sel ) ; - break ; - } - - case 605: // INERTIA - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_InertiaDlg *aDlg = new GeometryGUI_InertiaDlg( parent, "", Sel ) ; - break ; - } - - case 607: // MAXTOLERANCE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_MaxToleranceDlg *aDlg = new GeometryGUI_MaxToleranceDlg( parent, "", Sel ) ; - break ; - } - - case 608: // WHATIS - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_WhatisDlg *aDlg = new GeometryGUI_WhatisDlg( parent, "", Sel ) ; - break ; - } - - case 609: // CHECKSHAPE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_CheckShape *aDlg = new GeometryGUI_CheckShape( parent, "", Sel ) ; - break ; - } - - case 701: // SETTINGS - COPY - { - QMenuData* pp; - QMenuItem* item = parent->menuBar()->findItem(701,&pp); - bool check = !pp->isItemChecked(701); - pp->setItemChecked(701,check); - mySettings_Copy = check; - QAD_CONFIG->addSetting( "Geometry:SettingsCopy", mySettings_Copy ); - break; - } - - case 702: // SETTINGS - ADD IN STUDY - { - QMenuData* pp; - QMenuItem* item = parent->menuBar()->findItem(702,&pp); - bool check = !pp->isItemChecked(702); - pp->setItemChecked(702,check); - mySettings_AddInStudy = check; - - QAD_CONFIG->addSetting( "Geometry:SettingsAddInStudy", mySettings_AddInStudy ); - break; - } - - case 703: // SETTINGS - SHADING COLOR - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - - QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed"); - QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen"); - QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue"); - QColor color; - if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() ) { - color = QColor (SCr.toInt(), - SCg.toInt(), - SCb.toInt()); - } else { - Quantity_Color Default = Quantity_Color(); - color = QColor ( (int)Default.Red() * 255.0, - (int)Default.Green()* 255.0, - (int)Default.Blue() * 255.0 ); - } - - QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() ); - if ( c.isValid() ) { - myShadingColor = Quantity_Color(c.red() / 255.0, - c.green()/ 255.0, - c.blue() / 255.0, - Quantity_TOC_RGB); - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListOfInteractive List1; - ic->ObjectsInCollector(List1); - List.Append(List1); - - AIS_ListIteratorOfListOfInteractive ite(List); - while (ite.More()) { - if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - aSh->SetShadingColor( myShadingColor ); - ic->Redisplay( aSh, Standard_True, Standard_True); - } - ite.Next(); - } - - ic->UpdateCurrentViewer(); - - QAD_CONFIG->addSetting("Geometry:SettingsShadingColorRed", c.red() ); - QAD_CONFIG->addSetting("Geometry:SettingsShadingColorGreen", c.green() ); - QAD_CONFIG->addSetting("Geometry:SettingsShadingColorBlue", c.blue() ); - } - break; - } - - - case 704: // SETTINGS - ISOS - { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - - QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); - QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); - if ( !IsoU.isEmpty() ) - ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt()); - else - IsoU = "1"; - if ( !IsoV.isEmpty() ) - ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt()); - else - IsoV = "1"; - - GeometryGUI_NbIsosDlg * NbIsosDlg = new GeometryGUI_NbIsosDlg( QAD_Application::getDesktop(), - tr("GEOM_MEN_ISOS"), TRUE ); - int UIso = IsoU.toInt(); - int VIso = IsoV.toInt(); - - NbIsosDlg->SpinBoxU->setValue(UIso) ; - NbIsosDlg->SpinBoxV->setValue(VIso) ; - - if ( NbIsosDlg->exec() ) { - UIso = NbIsosDlg->SpinBoxU->text().toInt() ; - VIso = NbIsosDlg->SpinBoxV->text().toInt() ; - - ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso); - ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso); - QAD_CONFIG->addSetting( "Geometry:SettingsIsoU", NbIsosDlg->SpinBoxU->text() ); /* text format */ - QAD_CONFIG->addSetting( "Geometry:SettingsIsoV", NbIsosDlg->SpinBoxV->text() ); /* text format */ - } - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListOfInteractive List1; - ic->ObjectsInCollector(List1); - List.Append(List1); - - AIS_ListIteratorOfListOfInteractive ite(List); - ic->InitCurrent(); - if ( ic->NbCurrents() ) - while (ite.More()) { - if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - Handle (AIS_Drawer) CurDrawer; - CurDrawer = aSh->Attributes(); - CurDrawer->UIsoAspect()->SetNumber( UIso ); - CurDrawer->VIsoAspect()->SetNumber( VIso ); - ic->SetLocalAttributes(aSh, CurDrawer); - ic->Redisplay(aSh); - } - ite.Next(); - } - ic->UpdateCurrentViewer(); - break; - } - - case 705: // SETTINGS : STEP VALUE FOR SPIN BOXES - { - //NRI if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - //NRI break; - - QString step = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ); - if( step.isEmpty() ) - step = "100.0" ; - - Standard_Boolean res = false ; - double dd = Parameter( res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3 ) ; - if( res ) { - QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", QString("%1").arg(dd) ) ; - - /* Emit signal to GeometryGUI_SpinBoxes */ - SignalDefaultStepValueChanged( dd ) ; - } - else - parent->putInfo(tr("GEOM_PRP_ABORT")); - - break ; - } - - case 801: // ADD IN STUDY - POPUP VIEWER - { - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - const SALOME_ListIO& ListSelected = Sel->StoredIObjects(); - SALOME_ListIteratorOfListIO It( ListSelected ); - for ( ; It.More(); It.Next() ) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - AddInStudy(true, IObject); - } - /* Is set on the dialog box */ - QApplication::restoreOverrideCursor(); - break; - } - - case 901: // RENAME - { - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - for ( ; It.More(); It.Next() ) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - if ( !obj->_is_nil() ) { - if (obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - - QString nm = QString( aName->Value() ); - nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), nm ); - if ( !nm.isEmpty() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - myActiveStudy->renameIObject( IObject, nm ); - QApplication::restoreOverrideCursor(); - } - } - } - } - break; - } - - case 903: // DISPLAY OBJECT BROWSER - { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - // VTK - QApplication::setOverrideCursor( Qt::waitCursor ); - - SALOMEDS::SObject_var fatherSF = - aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry()); - - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); - - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - - if(myRenderInter->isInViewer(IObject)) { - myRenderInter->Display(IObject); - } - else { - // Create new actor - if ( !obj->_is_nil() ) { - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); - - if (obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* theAllActors = theRenderer->GetActors(); - theAllActors->InitTraversal(); - vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); - Handle(SALOME_InteractiveObject) anIObj; - // don't create new study object if it already exists - bool isDisplayed = false; - while(!(actor==NULL)) { - SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor); - if (Gactor!=NULL) { - if (Gactor->hasIO()) { - if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) { - isDisplayed = true; - anIObj = Gactor->getIO(); - if (!anIObj.IsNull()) myRenderInter->Display(anIObj); - } - } - } - actor=(vtkActor*)(theAllActors->GetNextActor()); - } - if (!isDisplayed) { - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); - op->start(); - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, obj); - // commit transaction - op->finish(); - - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - int themode = myRenderInter->GetDisplayMode(); - - vtkActorCollection* theActors = - GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True); - theActors->InitTraversal(); - vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); - while(!(anActor==NULL)) { - GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor ); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), myFatherior,"GEOM"); - IO->setEntry(obj->GetID()); - GActor->setIO( IO ); - GActor->setName( IObject->getName() ); - - theRenderer->AddActor(GActor); - renWin->Render(); - anActor = (vtkActor*)theActors->GetNextActor(); - } - } - } - // next item iteration - if (useSubItems) { - anIter->Next(); - anAttr = SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - } - myActiveStudy->updateObjBrowser( true ); - QApplication::restoreOverrideCursor(); - - } else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - - SALOMEDS::SObject_var fatherSF = - aStudy->FindObjectID( myActiveStudy->getActiveStudyFrame()->entry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - - if ( v3d->isInViewer( IObject, true ) ) { - Standard_Boolean found; - Handle(GEOM_AISShape) aSh = ConvertIOinGEOMAISShape( IObject, found, true ); - if ( found ) { - ic->Display(aSh); - ic->AddOrRemoveCurrentObject(aSh, true); - } - - } else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); - if ( !obj->_is_nil() ) { - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); - if (obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - // searchin for already displayed objects with the same shape - AIS_ListOfInteractive aDisplayed; - ic->DisplayedObjects(aDisplayed); - AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); - Handle(AIS_Shape) anAISShape; - for(;anIObjects.More();anIObjects.Next()) { - anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); - if (!anAISShape.IsNull()) { - if (anAISShape->Shape().IsSame(Shape)) break; - anAISShape.Nullify(); - } - } - if (!anAISShape.IsNull()) { - if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape); - } else { - if (!useSubItems) { - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); - op->start(); - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, obj); - // commit transaction - op->finish(); - } - - Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value()); - aSh->SetShadingColor( myShadingColor ); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), - myFatherior, - "GEOM"); - IO->setEntry(obj->GetID()); - aSh->setIO( IO ); - aSh->setName( aName->Value() ); - ic->Display (aSh); - if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, true); - } - } - // next item iteration - if (useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - } - myActiveStudy->updateObjBrowser( true ); - QApplication::restoreOverrideCursor(); - } - break; - } - - case 3011: // POINT - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_PointDlg *aDlg = new GeometryGUI_PointDlg( parent, "", Sel, ic ) ; - break; - } - - case 3012: // LINE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_LineDlg *aDlg = new GeometryGUI_LineDlg( parent, "", Sel ) ; - break ; - } - - case 3013: // CIRCLE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_CircleDlg *aDlg = new GeometryGUI_CircleDlg( parent, "", Sel ) ; - break ; - } - - case 3014: // ELLIPSE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_EllipseDlg *aDlg = new GeometryGUI_EllipseDlg( parent, "", Sel ) ; - break ; - } - - case 3015: // ARC - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_ArcDlg *aDlg = new GeometryGUI_ArcDlg( parent, "", Sel ) ; - break ; - } - - case 3016: // VECTOR - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_VectorDlg *aDlg = new GeometryGUI_VectorDlg( parent, "", Sel ) ; - break; - } - - case 3017: // PLANE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_PlaneDlg *aDlg = new GeometryGUI_PlaneDlg( parent, "", Sel ) ; - break; - } - - case 3018: // WORKING PLANE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_WorkingPlaneDlg *aDlg = new GeometryGUI_WorkingPlaneDlg( parent, "", Sel ) ; - break; - } - - case 312: // SKETCHER - { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - break; - - EmitSignalDeactivateDialog() ; - - ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTop(); // DCQ : 28/02/2002 - - mySketcher = Sketch( v3d->getViewer3d() ); - SetState(CURRENT_SKETCH); - - QMenuBar* Mb = myDesktop->getMainMenuBar(); - QMenuData* pp; - - QMenuItem* item = Mb->findItem(10010,&pp); - mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010)); - item = Mb->findItem(10011,&pp); - mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011)); - item = Mb->findItem(10012,&pp); - mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012)); - item = Mb->findItem(10013,&pp); - mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013)); - item = Mb->findItem(10014,&pp); - mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014)); - - mySketcher.SetTransitionStatus(NOCONSTRAINT); - item = Mb->findItem(3133,&pp); - pp->setItemChecked(3133,false); - item = Mb->findItem(3134,&pp); - pp->setItemChecked(3134,false); - break; - } - - - - case 3131: - { - break; - } - - case 3133: // sketcher - { - QMenuBar* Mb = myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(3133,&pp); - pp->setItemChecked(3133,!pp->isItemChecked(3133)); - if (pp->isItemChecked(3133) == true) - mySketcher.SetTransitionStatus(TANGENT); - else - mySketcher.SetTransitionStatus(NOCONSTRAINT); - - pp->setItemChecked(3134,false); - break; - } - - case 3134: // sketcher - { - QMenuBar* Mb = myDesktop->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = Mb->findItem(3134,&pp); - pp->setItemChecked(3134,!pp->isItemChecked(3134)); - if (pp->isItemChecked(3134) == true) - mySketcher.SetTransitionStatus(PERPENDICULAR); - else - mySketcher.SetTransitionStatus(NOCONSTRAINT); - - pp->setItemChecked(3133,false); - break; - } - - case 4021: // TRANSLATION - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_TranslationDlg *aDlg = new GeometryGUI_TranslationDlg( parent, "", Sel ) ; - break; - } - - case 4022: // ROTATION - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_RotationDlg *aDlg = new GeometryGUI_RotationDlg( parent, "", Sel ) ; - break; - } - - case 4030: // MULTI TRANSLATION - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_MultiTranslationDlg *aDlg = new GeometryGUI_MultiTranslationDlg( parent, "", Sel ) ; - break; - } - - case 4040: // MULTI ROTATION - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_MultiRotationDlg *aDlg = new GeometryGUI_MultiRotationDlg( parent, "", Sel ) ; - break; - } - - case 4023: // MIRROR - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_MirrorDlg *aDlg = new GeometryGUI_MirrorDlg( parent, "", Sel ) ; - break; - } - - case 4024: // SCALE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_ScaleDlg *aDlg = new GeometryGUI_ScaleDlg( parent, "", Sel ) ; - break; - } - - case 4025: // PARTITION - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_PartitionDlg *aDlg = new GeometryGUI_PartitionDlg( parent, "", Sel ) ; - break; - } - - case 4026: // ARCHIMEDE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_ArchimedeDlg *aDlg = new GeometryGUI_ArchimedeDlg( parent, "", Sel ) ; - break; - } - - case 4027: // FILLET - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_FilletDlg *aDlg = new GeometryGUI_FilletDlg( parent, "", Sel, ic ) ; - break; - } - - case 4028: // CHAMFER - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_ChamferDlg *aDlg = new GeometryGUI_ChamferDlg( parent, "", Sel, ic ) ; - break; - } - - case 4031: // PRISM - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_PrismDlg *aDlg = new GeometryGUI_PrismDlg( parent, "", Sel ) ; - break; - } - - case 4032: // REVOL - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_RevolDlg *aDlg = new GeometryGUI_RevolDlg( parent, "", Sel ) ; - break; - } - - case 4033: // FILLING - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_FillingDlg *aDlg = new GeometryGUI_FillingDlg( parent, "", Sel ) ; - break; - } - - case 4034: // PIPE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_PipeDlg *aDlg = new GeometryGUI_PipeDlg(parent, "", Sel ) ; - break; - } - - case 5001: // CHECK GEOMETRY - { - QAD_PyEditor* PyEditor = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getPyEditor(); - PyEditor->setText("from GEOM_usinggeom import *\n"); - PyEditor->setText(">>> "); - PyEditor->handleReturn(); - break; - } +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOMEGUI_ImportOperation.h" - case 6021: // SHADING - WIREFRAME - { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - VTKViewer_RenderWindowInteractor* myRenderInter= - ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); +#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" - QApplication::setOverrideCursor(waitCursor); - - int themode = myRenderInter->GetDisplayMode(); - if( themode==0 ) { - myRenderInter->SetDisplayMode(1); - GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") ); - } else { - myRenderInter->SetDisplayMode(0); - GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") ); - } +/* The object itself created in the static method 'GetOrCreateGEOMBase()' */ +static GEOMBase_Context* GeomGUI = 0; - QApplication::restoreOverrideCursor(); - - } else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - AIS_DisplayMode mode = ( AIS_DisplayMode )ic->DisplayMode(); - QApplication::setOverrideCursor( Qt::waitCursor ); - AIS_DisplayMode newmode = (mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame); +//======================================================================= +// class : CustomItem +// purpose : Set Font to a text. +//======================================================================= +class CustomItem : public QCustomMenuItem +{ +public: + CustomItem(const QString& s, const QFont& f) + :string(s), font(f){}; + ~CustomItem(){} + + void paint(QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, + bool /*enabled*/, int x, int y, int w, int h) + { + p->setFont(font); + p->drawText(x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string); + } - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListOfInteractive List1; - ic->ObjectsInCollector(List1); - List.Append(List1); - - AIS_ListIteratorOfListOfInteractive ite(List); - while (ite.More()) { - if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - ic->SetDisplayMode(aSh,Standard_Integer(newmode),true); - } - ite.Next(); - } + QSize sizeHint() + { + return QFontMetrics(font).size(AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string); + } - ic->SetDisplayMode( newmode, Standard_False); - if ( newmode == 1 ) - GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") ); - else - GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") ); - - QApplication::restoreOverrideCursor(); - } - break; - } - - case 6022: // DISPLAY ALL - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) - //VTK - ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->DisplayAll(); - else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) - OnDisplayAll(); - break; - } - - case 6023: // DISPLAY ONLY - case 8023: // DISPLAY ONLY - POPUP VIEWER - { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - // VTK - OnVTKDisplayOnly(); - } - else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) - OnDisplayOnly(); - break; - } - - case 6024: // ERASE ALL - { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - //VTK - ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->EraseAll(); - } - else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - ic->EraseAll(Standard_True, Standard_False); - ic->Display(v3d->getTrihedron()); - } +private: + QString string; + QFont font; - //NRI SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - //NRI Sel->ClearInteractiveObjects(); - break; - } +}; - case 6025 : // ERASE ONLY - case 8022 : // ERASE - POPUP VIEWER - { - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - // VTK - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - if(myRenderInter->isInViewer(anIObject)) { - myRenderInter->Erase(anIObject); - } else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); - if (obj->FindAttribute(anAttr, "AttributeName")) { - // searchin for already displayed objects with the same shape - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* theAllActors = theRenderer->GetActors(); - theAllActors->InitTraversal(); - vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); - Handle(SALOME_InteractiveObject) anIObj; - // don't create new study object if it already exists - bool isDisplayed = false; - while(!(actor==NULL)) { - SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor); - if (Gactor!=NULL) { - if (Gactor->hasIO()) { - if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) { - isDisplayed = true; - anIObj = Gactor->getIO(); - if (!anIObj.IsNull()) myRenderInter->Erase(anIObj); - } - } - } - actor=(vtkActor*)(theAllActors->GetNextActor()); - } - } - if (useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - } -// SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); -// for(;It.More();It.Next()) { -// Handle(SALOME_InteractiveObject) IOS = It.Value(); - // myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);; - } - else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - // OCC - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - if ( v3d->isInViewer( anIObject, true ) ) { - Standard_Boolean found; - Handle(GEOM_AISShape) aSh = ConvertIOinGEOMAISShape( anIObject, found, true ); - if ( found ) { - ic->Erase(aSh); - ic->AddOrRemoveCurrentObject(aSh, true); - } - } else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); - if (obj->FindAttribute(anAttr, "AttributeName")) { - // searchin for already displayed objects with the same shape - AIS_ListOfInteractive aDisplayed; - ic->DisplayedObjects(aDisplayed); - AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); - Handle(AIS_Shape) anAISShape; - for(;anIObjects.More();anIObjects.Next()) { - anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); - if (!anAISShape.IsNull()) { - if (anAISShape->Shape().IsSame(Shape)) break; - anAISShape.Nullify(); - } - } - if (!anAISShape.IsNull()) { - if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape); - } - } - if (useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - } - } - Sel->ClearIObjects(); - break; - } - - case 6060: // BOUNDING BOX - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_BndBoxDlg *aDlg = new GeometryGUI_BndBoxDlg(parent, "", Sel ) ; - break ; - } +//======================================================================= +// function : GeometryGUI() +// purpose : Constructor +//======================================================================= +GeometryGUI::GeometryGUI() : + QObject() +{ +} - case 6061: // MIN DISTANCE - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_DistanceDlg *aDlg = new GeometryGUI_DistanceDlg(parent, "", Sel ) ; - break ; - } - case 8021: // WIREFRAME-SHADING - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - // VTK - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - - QApplication::setOverrideCursor( Qt::waitCursor ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IOS = It.Value(); - myRenderInter->SwitchRepresentation(IOS, false); - } - myRenderInter->Render(); - QApplication::restoreOverrideCursor(); - } - else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape( IObject, found, true ); - if (!Shape.IsNull()) { - AIS_DisplayMode mode = ( AIS_DisplayMode )Shape->DisplayMode(); - if ( mode == -1 ) - mode = ( AIS_DisplayMode )ic->DisplayMode(); - - QApplication::setOverrideCursor( Qt::waitCursor ); - ic->SetDisplayMode(Shape, mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame, false); - } - QApplication::restoreOverrideCursor(); - } - ic->UpdateCurrentViewer(); - } - QApplication::restoreOverrideCursor(); - break; - } - - case 8031: // COLOR - POPUP VIEWER - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - // VTK - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - - Handle(SALOME_InteractiveObject) FirstIOS = Sel->firstIObject(); - if(!FirstIOS.IsNull()) { - - QColor initcolor = myRenderInter->GetColor(FirstIOS); - - QColor c = QColorDialog::getColor( initcolor, - QAD_Application::getDesktop() ); - - if ( c.isValid() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IOS = It.Value(); - myRenderInter->SetColor(IOS,c); - } - } - QApplication::restoreOverrideCursor(); - } - } - else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); - Standard_Boolean found; - Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IO, found, true); - if ( found ) { - Quantity_Color CSFColor; - Shape->Color( CSFColor ); - - QColor c = QColorDialog::getColor( QColor(CSFColor.Red() * 255.0, - CSFColor.Green()* 255.0, - CSFColor.Blue() * 255.0 ), - QAD_Application::getDesktop() ); - - if ( c.isValid() ) { - CSFColor = Quantity_Color ( c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB ); - QApplication::setOverrideCursor( Qt::waitCursor ); - - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true); - if ( found ) { - Shape->SetColor ( CSFColor ); - Shape->SetShadingColor ( CSFColor ); - } - } - } - } - } - QApplication::restoreOverrideCursor(); - break; - } - - case 8032: // TRANSPARENCY - POPUP VIEWER - { - EmitSignalDeactivateDialog() ; - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - GeometryGUI_TransparencyDlg *aDlg = new GeometryGUI_TransparencyDlg( parent, "", Sel, ic ) ; - break ; - } - - case 8033: // ISOS - POPUP VIEWER - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - else { - ic->InitCurrent(); - if ( ic->MoreCurrent() ) { - Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); - QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); - QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); - - if ( !IsoU.isEmpty() ) - ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt()); - else - IsoU = "1"; - if ( !IsoV.isEmpty() ) - ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt()); - else - IsoV = "1"; - - GeometryGUI_NbIsosDlg * NbIsosDlg = - new GeometryGUI_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE ); - - NbIsosDlg->SpinBoxU->setValue(IsoU.toInt()); - NbIsosDlg->SpinBoxV->setValue(IsoV.toInt()); - - if ( NbIsosDlg->exec() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - for ( ; ic->MoreCurrent (); ic->NextCurrent () ) { - Handle (AIS_Drawer) CurDrawer; - - CurDrawer = ic->Current()->Attributes(); - CurDrawer->UIsoAspect()->SetNumber( NbIsosDlg->SpinBoxU->text().toInt() ); - CurDrawer->VIsoAspect()->SetNumber( NbIsosDlg->SpinBoxV->text().toInt() ); - - ic->SetLocalAttributes(CurObject, CurDrawer); - ic->Redisplay(CurObject); - } - } - } - } - QApplication::restoreOverrideCursor(); - break; - } +//======================================================================= +// function : ~GeometryGUI() +// purpose : Destructor +//======================================================================= +GeometryGUI::~GeometryGUI() +{ +} - case 9022 : // ERASE - OBJBROSER POPUP - { - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - // VTK - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - -// Handle(SALOME_InteractiveObject) IObject; - if(myRenderInter->isInViewer(anIObject)) { - myRenderInter->Erase(anIObject); - } else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); - if (obj->FindAttribute(anAttr, "AttributeName")) { - // searchin for already displayed objects with the same shape - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* theAllActors = theRenderer->GetActors(); - theAllActors->InitTraversal(); - vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); - Handle(SALOME_InteractiveObject) anIObj; - // don't create new study object if it already exists - bool isDisplayed = false; - while(!(actor==NULL)) { - SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor); - if (Gactor!=NULL) { - if (Gactor->hasIO()) { - if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) { - isDisplayed = true; - anIObj = Gactor->getIO(); - if (!anIObj.IsNull()) myRenderInter->Erase(anIObj); - } - } - } - actor=(vtkActor*)(theAllActors->GetNextActor()); - } - } - if (useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } -// SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); -// for(;It.More();It.Next()) { -// Handle(SALOME_InteractiveObject) IOS = It.Value(); -// myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);; - } -// SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); -// for(;It.More();It.Next()) { -// Handle(SALOME_InteractiveObject) IOS = It.Value(); -// myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);; -// } - } - else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - // OCC - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - if ( v3d->isInViewer( anIObject, true ) ) { - Standard_Boolean found; - Handle(GEOM_AISShape) aSh = ConvertIOinGEOMAISShape( anIObject, found, true ); - if ( found ) { - ic->Erase(aSh); - ic->AddOrRemoveCurrentObject(aSh, true); - } - } else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if ( obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } else anIter->Next(); - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); - if (obj->FindAttribute(anAttr, "AttributeName")) { - // searchin for already displayed objects with the same shape - AIS_ListOfInteractive aDisplayed; - ic->DisplayedObjects(aDisplayed); - AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); - Handle(AIS_Shape) anAISShape; - for(;anIObjects.More();anIObjects.Next()) { - anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); - if (!anAISShape.IsNull()) { - if (anAISShape->Shape().IsSame(Shape)) break; - anAISShape.Nullify(); - } - } - if (!anAISShape.IsNull()) { - if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape); - } - } - if (useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } else anIter->Next(); - } - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - } -// QAD_Viewer3d* v3d = myActiveStudy->getActiveStudyFrame()->getViewerOCC(); -// Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); -// myContext->EraseSelected(); - } - Sel->ClearIObjects(); - break; - } - - case 9023 : // DISPLAY ONLY - OBJBROSER POPUP - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) - OnVTKDisplayOnly(); - else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) - OnDisplayOnly(); - break; - } +// //======================================================================= +// // function : GetGEOMBase_Context() static +// // purpose : Returns current 'GeomGUI' a static pointer +// //======================================================================= +// GEOMBase_Context* GeometryGUI::GetGeomGUI() +// { +// return GeomGUI; +// } - case 9024 : // OPEN - OBJBROSER POPUP - { - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() ); - SALOMEDS::AttributePersistentRef_var aPersist; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); - SALOMEDS::GenericAttribute_var anAttr; - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) { - useSubItems = true; - obj = subobj; - } - else anIter->Next(); - } - obj->FindAttribute(anAttr, "AttributePersistentRef"); - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - if (!obj->FindAttribute(anAttr, "AttributeIOR") && - obj->FindAttribute(anAttr, "AttributePersistentRef")) { - // load - Engines::Component_var comp = myDesktop->getEngine("FactoryServer","GEOM"); - if (!CORBA::is_nil(comp)) { - SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp); +//======================================================================= +// function : GetOrCreateGEOMBase() +// purpose : Gets or create an object 'GEOMBase' with initialisations +// : Returns 'GeomGUI' as a pointer +//======================================================================= +GEOMBase_Context* GeometryGUI::GetOrCreateGeometryGUI(QAD_Desktop* desktop) +{ + GeomGUI = GeomGUI->GetOrCreateGeomGUI(desktop); + return GeomGUI; +} + +//======================================================================= +// function : OnGUIEvent() [static] +// purpose : manage all events on GUI +//======================================================================= +bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + GeometryGUI::GetOrCreateGeometryGUI(parent); - SALOMEDS::StudyBuilder_var aStudyBuilder = myActiveStudy->getStudyDocument()->NewBuilder(); - aStudyBuilder->LoadWith(myActiveStudy->getStudyDocument()->FindComponent("GEOM"),driver); + QMenuBar* Mb = GeomGUI->GetDesktop()->getMainMenuBar(); + bool ViewOCC; - } else { - MESSAGE("Component is null"); - } - } - if (useSubItems) { - anIter->Next(); - obj = anIter->Value(); - } else anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - break; - } - - case 10000 : // SKETCH Segment - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - OnSketchSegment(); - break; - } - case 10001 : // SKETCH Arc - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - OnSketchArc(); - break; - } - case 10002 : // SKETCH Set Angle - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - OnSketchSetAngle(); - break; - } - case 10003 : // SKETCH Set X - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - OnSketchSetx(); - break; - } - case 10004 : // SKETCH Set Y - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - OnSketchSety(); - break; - } - case 10006 : // SKETCH Delete - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - OnSketchDelete(); - break; - } - case 10007 : // SKETCH End - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - OnSketchEnd(); - break; - } - case 10008 : // SKETCH Close - { - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - break; - OnSketchClose(); - break; - } - case 10010 : // SKETCH OptionsOnofflengthdimension - { - OnSketchOptionsOnofflengthdimension(); - break; - } - case 10011 : // SKETCH OptionsOnoffangledimension - { - OnSketchOptionsOnoffangledimension(); - break; - } - case 10012 : // SKETCH OptionsOnoffradiusdimension - { - OnSketchOptionsOnoffradiusdimension(); - break; - } - case 10013 : // SKETCH OptionsOnoffxdimension - { - OnSketchOptionsOnoffxdimension(); - break; - } - case 10014 : // SKETCH OptionsOnoffydimension - { - OnSketchOptionsOnoffydimension(); - break; - } + if(GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) + ViewOCC = true; + else if(GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) + ViewOCC = true; + else + return false; - default: - { - parent->putInfo( tr("GEOM_PRP_COMMAND").arg(theCommandID ) ); - break; - } - } + Mb->setItemEnabled( 312, ViewOCC);//Sketch + Mb->setItemEnabled( 309, ViewOCC);//SuppressFace + Mb->setItemEnabled( 314, ViewOCC);//SuppressHole + + Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings + Mb->setItemEnabled( 704, ViewOCC);// Isos Settings - return true ; + if (GeomGUI->GetState() == CURRENT_SKETCH && theCommandID != 10000 && theCommandID != 10001 && theCommandID != 10002 && theCommandID != 10003 && theCommandID != 10004 && theCommandID != 10006 && theCommandID != 10007 && theCommandID != 10008 && theCommandID != 10010 && theCommandID != 10011 && theCommandID != 10012 && theCommandID != 10013 && theCommandID != 10014 && theCommandID != 3133 && theCommandID != 3134) + return false; + + +// QString theCommandID_str = itoa(theCommandID); +// theCommandID_str.truncate(3); +// int theCommandID_Group = theCommandID_str.toInt(); + if(theCommandID == 31 || theCommandID == 33 || theCommandID == 111 || + theCommandID == 112 || theCommandID == 113 || theCommandID == 121 || + theCommandID == 122 || theCommandID == 123 || theCommandID == 701 || + theCommandID == 702 || theCommandID == 703 || theCommandID == 704 || + theCommandID == 705 || theCommandID == 801 || theCommandID == 901 || + theCommandID == 903 || theCommandID == 5001 || theCommandID == 8031 || + theCommandID == 8032 || theCommandID == 8033 || theCommandID == 9024) { + GEOMBase_Tools* myToolsGUI = new GEOMBase_Tools(); + myToolsGUI->OnGUIEvent(theCommandID, parent); + return true; + } + if(theCommandID == 312 || theCommandID == 3133 || theCommandID == 3134 || + theCommandID == 10000 || theCommandID == 10001 || theCommandID == 10002 || + theCommandID == 10003 || theCommandID == 10004 || theCommandID == 10006 || + theCommandID == 10007 || theCommandID == 10008 || theCommandID == 10010 || + theCommandID == 10011 || theCommandID == 10012 || theCommandID == 10013 || + theCommandID == 10014) { + GEOMBase_Sketcher* mySketcherGUI = new GEOMBase_Sketcher(); + mySketcherGUI->OnGUIEvent(theCommandID, parent); + return true; + } + if(theCommandID == 6021 || theCommandID == 6022 || theCommandID == 6024 || + theCommandID == 8021 || theCommandID == 8022 || theCommandID == 8023 || + theCommandID == 9022 || theCommandID == 9023) { + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnGUIEvent(theCommandID, parent); + return true; + } + if(theCommandID == 3011 || theCommandID == 3012 || + theCommandID == 3013 || theCommandID == 3014 || + theCommandID == 3015 || theCommandID == 3016 || + theCommandID == 3017 || theCommandID == 3018) { + BasicGUI* myBasicGUI = new BasicGUI(); + myBasicGUI->OnGUIEvent(theCommandID, parent); + return true; + } + if(theCommandID == 3021 || theCommandID == 3022 || theCommandID == 3023 || + theCommandID == 3024 || theCommandID == 3025) { + PrimitiveGUI* myPrimitiveGUI = new PrimitiveGUI(); + myPrimitiveGUI->OnGUIEvent(theCommandID, parent); + return true; + } + if(theCommandID == 4031 || theCommandID == 4032 || + theCommandID == 4033 || theCommandID == 4034) { + GenerationGUI* myGenerationGUI = new GenerationGUI(); + myGenerationGUI->OnGUIEvent(theCommandID, parent); + return true; + } + if(theCommandID == 303 || theCommandID == 304 || theCommandID == 305 || + theCommandID == 306 || theCommandID == 308 || theCommandID == 315 || + theCommandID == 316) { + BuildGUI* myBuildGUI = new BuildGUI(); + myBuildGUI->OnGUIEvent(theCommandID, parent); + return true; + } + if(theCommandID == 4011 || theCommandID == 4012 || + theCommandID == 4013 || theCommandID == 4014) { + BooleanGUI* myBooleanGUI = new BooleanGUI(); + myBooleanGUI->OnGUIEvent(theCommandID, parent); + return true; + } + if(theCommandID == 4021 || theCommandID == 4022 || theCommandID == 4023 || + theCommandID == 4024 || theCommandID == 4030 || theCommandID == 4040) { + TransformationGUI* myTransformationGUI = new TransformationGUI(); + myTransformationGUI->OnGUIEvent(theCommandID, parent); + return true; + } + if(theCommandID == 501 || theCommandID == 502) { + OperationGUI* myOperationGUI = new OperationGUI(); + myOperationGUI->OnGUIEvent(theCommandID, parent); + return true; + } + if(theCommandID == 501 || theCommandID == 502 || + theCommandID == 309 || theCommandID == 314) { + RepairGUI* myRepairGUI = new RepairGUI(); + myRepairGUI->OnGUIEvent(theCommandID, parent); + return true; + } + if(theCommandID == 601 || theCommandID == 604 || theCommandID == 605 || + theCommandID == 6060 || theCommandID == 6061 || + theCommandID == 607 || theCommandID == 608 || theCommandID == 609) { + MeasureGUI* myMeasureGUI = new MeasureGUI(); + myMeasureGUI->OnGUIEvent(theCommandID, parent); + return true; + } + return true; } @@ -6084,9 +262,11 @@ bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) //===================================================================================== bool GeometryGUI::OnKeyPress(QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + GeometryGUI::GetOrCreateGeometryGUI(parent); + + if(GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) return false; - return true ; + return true; } @@ -6096,30 +276,30 @@ bool GeometryGUI::OnKeyPress(QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* //================================================================================== bool GeometryGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - MESSAGE ( "GeometryGUI::OnMousePress") + GeometryGUI::GetOrCreateGeometryGUI(parent); - if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + if(GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) return false; - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort(); /* Get the clicked or selected point */ gp_Pnt thePoint; - if ( myState == CURRENT_SKETCH) { - mySketcher.ValidateEdge(); - if (mySketcher.GetmyEdgesNumber() == 1 ) { - QMenuBar* Mb = myDesktop->getMainMenuBar(); + if (GeomGUI->GetState() == CURRENT_SKETCH) { + GeomGUI->GetSketcher().ValidateEdge(); + if (GeomGUI->GetSketcher().GetmyEdgesNumber() == 1 ) { + QMenuBar* Mb = GeomGUI->GetDesktop()->getMainMenuBar(); QMenuData* pp; QMenuItem* item = Mb->findItem(313,&pp); pp->setItemEnabled( 313, true); // SKETCH CONTRAINTS } - } else if( myState == POINT_METHOD ) { + } else if( GeomGUI->GetState() == POINT_METHOD ) { - EraseSimulationShape() ; - GeometryGUI_PointDlg *DialogPt = (GeometryGUI_PointDlg*)(myActiveDialogBox) ; + GeomGUI->EraseSimulationShape() ; + BasicGUI_PointDlg *DialogPt = (BasicGUI_PointDlg*)(GeomGUI->GetActiveDialogBox()) ; if ( DialogPt->UseLocalContext() ) { ic->InitSelected(); @@ -6132,17 +312,17 @@ bool GeometryGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFr thePoint = BRep_Tool::Pnt( TopoDS::Vertex(ic->SelectedShape()) ); } else - thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() ); + thePoint = GeomGUI->ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() ); } else - thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() ); + thePoint = GeomGUI->ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() ); if( DialogPt != 0 ) { DialogPt->PointIntoCoordinates(thePoint, true) ; /* display point */ } else { // MESSAGE ("On Mouse Press : myActiveDialogBox is null" << endl) ; - myDesktop->putInfo(tr("GEOM_PRP_ABORT")); + GeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); } } @@ -6156,15 +336,17 @@ bool GeometryGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFr //======================================================================= bool GeometryGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + GeometryGUI::GetOrCreateGeometryGUI(parent); + + if (GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) return false; - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort(); - if ( myState == CURRENT_SKETCH) - mySketcher.MakeCurrentEdge(pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView()); + if ( GeomGUI->GetState() == CURRENT_SKETCH) + GeomGUI->GetSketcher().MakeCurrentEdge(pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView()); return true; } @@ -6176,6 +358,8 @@ bool GeometryGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFr //===================================================================================== bool GeometryGUI::SetSettings( QAD_Desktop* parent ) { + GeometryGUI::GetOrCreateGeometryGUI(parent); + //DCQ parent->menuBar()->setItemEnabled( 504, false); // CORRECTING //DCQ parent->menuBar()->setItemEnabled( 6062, false); // RADIUS //VSR parent->menuBar()->setItemEnabled( 701, false); // AUTOMATIC COPY @@ -6187,7 +371,7 @@ bool GeometryGUI::SetSettings( QAD_Desktop* parent ) QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen"); QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue"); if(!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - myShadingColor = Quantity_Color (SCr.toInt()/255., SCg.toInt()/255., SCb.toInt()/255., Quantity_TOC_RGB); + GeomGUI->GetShadingColor() = Quantity_Color (SCr.toInt()/255., SCg.toInt()/255., SCb.toInt()/255., Quantity_TOC_RGB); /* Wireframe or Shading */ int DisplayMode = 0; @@ -6208,10 +392,10 @@ bool GeometryGUI::SetSettings( QAD_Desktop* parent ) /* Copy */ // QString Copy = QAD_CONFIG->getSetting("Geometry:SettingsCopy"); // if ( !Copy.isEmpty() ) { -// mySettings_Copy = Copy.toInt(); +// GeomGUI->GetSettings_Copy() = Copy.toInt(); // QMenuData* pp; // parent->menuBar()->findItem(701,&pp); -// pp->setItemChecked(701, mySettings_Copy); +// pp->setItemChecked(701, GeomGUI->GetSettings_Copy()); // } QMenuData* pp; if ( parent->menuBar()->findItem(701,&pp) ) @@ -6220,11 +404,11 @@ bool GeometryGUI::SetSettings( QAD_Desktop* parent ) /* Add in Study */ QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy"); if ( !AddInStudy.isEmpty() ) - mySettings_AddInStudy = AddInStudy.toInt(); + GeomGUI->GetSettings_AddInStudy() = AddInStudy.toInt(); else - mySettings_AddInStudy = 1; + GeomGUI->GetSettings_AddInStudy() = 1; parent->menuBar()->findItem(702,&pp); - pp->setItemChecked(702, mySettings_AddInStudy); + pp->setItemChecked(702, GeomGUI->GetSettings_AddInStudy()); /* step value */ QString S = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ); @@ -6252,7 +436,7 @@ bool GeometryGUI::SetSettings( QAD_Desktop* parent ) } } - QMenuBar* Mb = myDesktop->getMainMenuBar(); + QMenuBar* Mb = GeomGUI->GetDesktop()->getMainMenuBar(); Mb->setItemEnabled( 312, ViewOCC); //Sketch Mb->setItemEnabled( 309, ViewOCC); //SuppressFace @@ -6271,13 +455,15 @@ bool GeometryGUI::SetSettings( QAD_Desktop* parent ) //===================================================================================== void GeometryGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject) { - SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop()); + + SALOME_Selection* Sel = SALOME_Selection::Selection(GeomGUI->GetActiveStudy()->getSelection()); theObject = ""; if(Sel->IObjectCount() == 1) { Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); if(IO->hasEntry()) { - SALOMEDS::SObject_var sobj = myActiveStudy->getStudyDocument()->FindObjectID(IO->getEntry()); + SALOMEDS::SObject_var sobj = GeomGUI->GetActiveStudy()->getStudyDocument()->FindObjectID(IO->getEntry()); if(!sobj->_is_nil()) { SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent(); if(strcmp(scomp->GetID(), IO->getEntry()) == 0) { @@ -6289,7 +475,7 @@ void GeometryGUI::DefinePopup(QString & theContext, QString & theParent, QString } if((theParent.compare("Viewer")==0)) { - if(myState == CURRENT_SKETCH) + if(GeomGUI->GetState() == CURRENT_SKETCH) theContext = "Sketch"; else { if (Sel->IObjectCount() > 0) @@ -6306,32 +492,34 @@ void GeometryGUI::DefinePopup(QString & theContext, QString & theParent, QString // function : CustomPopup() // purpose : [static] //===================================================================================== -bool GeometryGUI::CustomPopup( QAD_Desktop* parent, - QPopupMenu* popup, - const QString& theContext, - const QString& theParent, - const QString& theObject ) +bool GeometryGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, + const QString& theParent,const QString& theObject) { + GeometryGUI::GetOrCreateGeometryGUI(parent); + /* Deactivate any non modal dialog box to get the neutral point */ - EmitSignalDeactivateDialog() ; + GeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + Engines::Component_var comp = GeomGUI->GetDesktop()->getEngine("FactoryServer", "GEOM"); + GEOM::GEOM_Gen_var myComponentGeom = GEOM::GEOM_Gen::_narrow(comp); + + SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->GetActiveStudy()->getSelection() ); int nbSel = Sel->IObjectCount(); if ( (nbSel == 0) && ( theContext.compare("Sketch")!=0 ) ) return false; - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) + if (GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()-> + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->GetActiveStudy()->getActiveStudyFrame()-> getRightFrame()->getViewFrame())->getViewer(); Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); if ( theParent.compare("Viewer")==0 ) { if ( theContext.compare("Sketch")==0 ) { - SketchStatus myCS = mySketcher.GetCurrentStatus(); + SketchStatus myCS = GeomGUI->GetSketcher().GetCurrentStatus(); popup->setCheckable(TRUE); if (myCS==SEGMENT) { @@ -6369,7 +557,7 @@ bool GeometryGUI::CustomPopup( QAD_Desktop* parent, if (IObject->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) { Standard_Boolean found; - Handle(GEOM_AISShape) Result = ConvertIOinGEOMAISShape(IObject, found, true); + Handle(GEOM_AISShape) Result = GeomGUI->ConvertIOinGEOMAISShape(IObject, found, true); if ( found ) { @@ -6424,7 +612,7 @@ bool GeometryGUI::CustomPopup( QAD_Desktop* parent, else needDisplay = true; SALOMEDS::SObject_var obj = - myActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() ); + GeomGUI->GetActiveStudy()->getStudyDocument()->FindObjectID( anIObject->getEntry() ); if (!obj->_is_nil()) { GEOM::GEOM_Shape_var aShape; @@ -6438,7 +626,7 @@ bool GeometryGUI::CustomPopup( QAD_Desktop* parent, needOpen = true; if (aShape->_is_nil()) { - SALOMEDS::ChildIterator_var anIter = myActiveStudy-> + SALOMEDS::ChildIterator_var anIter = GeomGUI->GetActiveStudy()-> getStudyDocument()->NewChildIterator(obj); while (anIter->More()) { @@ -6493,7 +681,7 @@ bool GeometryGUI::CustomPopup( QAD_Desktop* parent, // MESSAGE ( " CUSTOM POPUP VIEWER OCC done. ") } else - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) + if (GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { // MESSAGE ( " CUSTOM POPUP VIEWER VTK ") if ( ( theParent.compare("Viewer")==0 ) ) @@ -6518,7 +706,7 @@ bool GeometryGUI::CustomPopup( QAD_Desktop* parent, if ( IObject->hasEntry() ) { popup->setItemEnabled( 801, false ); - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOMEDS::Study_var aStudy = GeomGUI->GetActiveStudy()->getStudyDocument(); SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() ); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeIOR_var anIOR; @@ -6528,7 +716,7 @@ bool GeometryGUI::CustomPopup( QAD_Desktop* parent, { anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); Standard_Boolean found; - GEOM_Actor* Result = ConvertIORinGEOMActor(anIOR->Value(), found, true); + GEOM_Actor* Result = GeomGUI->ConvertIORinGEOMActor(anIOR->Value(), found, true); if ( found ) { if ( Result->getDisplayMode() == 1 ) @@ -6574,7 +762,7 @@ bool GeometryGUI::CustomPopup( QAD_Desktop* parent, bool needDisplay = false; bool needErase = false; SALOMEDS::GenericAttribute_var aTmpAttr; - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy-> + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->GetActiveStudy()-> getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); for(;It.More();It.Next()) { @@ -6587,7 +775,7 @@ bool GeometryGUI::CustomPopup( QAD_Desktop* parent, else needDisplay = true; - SALOMEDS::SObject_var obj = myActiveStudy->getStudyDocument() + SALOMEDS::SObject_var obj = GeomGUI->GetActiveStudy()->getStudyDocument() ->FindObjectID( anIObject->getEntry() ); if (!obj->_is_nil()) { GEOM::GEOM_Shape_var aShape; @@ -6602,7 +790,7 @@ bool GeometryGUI::CustomPopup( QAD_Desktop* parent, if (aShape->_is_nil()) { SALOMEDS::ChildIterator_var anIter = - myActiveStudy->getStudyDocument()->NewChildIterator(obj); + GeomGUI->GetActiveStudy()->getStudyDocument()->NewChildIterator(obj); while (anIter->More()) { SALOMEDS::SObject_var subobj = anIter->Value(); @@ -6681,15 +869,17 @@ bool GeometryGUI::CustomPopup( QAD_Desktop* parent, //======================================================================= void GeometryGUI::activeStudyChanged(QAD_Desktop* parent) { + GeometryGUI::GetOrCreateGeometryGUI(parent); + if(GeomGUI != 0) { - if(myState == CURRENT_SKETCH) { - mySketcher.Clear(); - ResetState(); + if(GeomGUI->GetState() == CURRENT_SKETCH) { + GeomGUI->GetSketcher().Clear(); + GeomGUI->ResetState(); } - QMenuBar* Mb = myDesktop->getMainMenuBar(); + QMenuBar* Mb = GeomGUI->GetDesktop()->getMainMenuBar(); bool ViewOCC = false; - if(myDesktop->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) + if(GeomGUI->GetDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) ViewOCC = true; Mb->setItemEnabled(312, ViewOCC); //Sketch @@ -6699,8 +889,8 @@ void GeometryGUI::activeStudyChanged(QAD_Desktop* parent) Mb->setItemEnabled(703, ViewOCC);// ShadingColor Settings Mb->setItemEnabled(704, ViewOCC);// Isos Settings - EraseSimulationShape(); - EmitSignalCloseAllDialogs(); + GeomGUI->EraseSimulationShape(); + GeomGUI->EmitSignalCloseAllDialogs(); GeomGUI = 0; } return ; @@ -6713,33 +903,38 @@ void GeometryGUI::activeStudyChanged(QAD_Desktop* parent) //======================================================================= void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) { - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop()); + + Engines::Component_var comp = GeomGUI->GetDesktop()->getEngine("FactoryServer", "GEOM"); + GEOM::GEOM_Gen_var myComponentGeom = GEOM::GEOM_Gen::_narrow(comp); + + SALOMEDS::Study_var aStudy = GeomGUI->GetActiveStudy()->getStudyDocument(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); OCCViewer_Viewer3d* v3d; Handle(AIS_InteractiveContext) ic; vtkRenderer* Renderer; - if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { - v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + if ( GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + v3d = ((OCCViewer_ViewFrame*)GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); ic = v3d->getAISContext(); - } else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - Renderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + } else if ( GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + Renderer = ((VTKViewer_ViewFrame*)GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); } else return; if (theIO.IsNull()) MESSAGE("BuildPresentation(): null SALOME_InteractiveObject passed") - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + if (GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { // VTK SALOMEDS::SObject_var fatherSF = - aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry()); + aStudy->FindObjectID(GeomGUI->GetActiveStudy()->getActiveStudyFrame()->entry()); SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() ); - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; @@ -6755,7 +950,7 @@ void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theI // this SObject may be GEOM module root SObject bool useSubItems = false; - SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); + SALOMEDS::ChildIterator_var anIter = GeomGUI->GetActiveStudy()->getStudyDocument()->NewChildIterator(obj); if (myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) { while (anIter->More() && !useSubItems) { SALOMEDS::SObject_var subobj = anIter->Value(); @@ -6773,12 +968,12 @@ void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theI while(useSubItems?anIter->More():!anAttr->_is_nil()) { anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); + TopoDS_Shape Shape = GeomGUI->GetShapeReader().GetShape(myComponentGeom,aShape); if (obj->FindAttribute(anAttr, "AttributeName")) { aName = SALOMEDS::AttributeName::_narrow(anAttr); - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); vtkActorCollection* theAllActors = theRenderer->GetActors(); theAllActors->InitTraversal(); vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); @@ -6800,7 +995,7 @@ void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theI } if (!isDisplayed) { // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); + QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->GetActiveStudy() ); op->start(); SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); @@ -6817,7 +1012,7 @@ void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theI vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); while(!(anActor==NULL)) { GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor ); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), myFatherior,"GEOM"); + Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), GeomGUI->GetFatherior(),"GEOM"); IO->setEntry(obj->GetID()); GActor->setIO( IO ); GActor->setName( theIO->getName() ); @@ -6847,17 +1042,17 @@ void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theI } // No viewer update should be done here! //myRenderInter->Render(); - //myActiveStudy->updateObjBrowser( true ); - } else if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + //GeomGUI->GetActiveStudy()->updateObjBrowser( true ); + } else if (GeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { SALOMEDS::SObject_var fatherSF = - aStudy->FindObjectID( myActiveStudy->getActiveStudyFrame()->entry()); + aStudy->FindObjectID( GeomGUI->GetActiveStudy()->getActiveStudyFrame()->entry()); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; SALOMEDS::AttributeIOR_var anIOR; if ( v3d->isInViewer( theIO, true ) ) { Standard_Boolean found; - Handle(GEOM_AISShape) aSh = ConvertIOinGEOMAISShape( theIO, found, true ); + Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( theIO, found, true ); if ( found ) { ic->Display(aSh, false); ic->AddOrRemoveCurrentObject(aSh, false); @@ -6872,7 +1067,7 @@ void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theI // this SObject may be GEOM module root SObject bool useSubItems = false; - SALOMEDS::ChildIterator_var anIter = myActiveStudy->getStudyDocument()->NewChildIterator(obj); + SALOMEDS::ChildIterator_var anIter = GeomGUI->GetActiveStudy()->getStudyDocument()->NewChildIterator(obj); if (myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) { while (anIter->More() && !useSubItems) { SALOMEDS::SObject_var subobj = anIter->Value(); @@ -6890,7 +1085,7 @@ void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theI while(useSubItems?anIter->More():!anAttr->_is_nil()) { anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myShapeReader.GetShape(myComponentGeom,aShape); + TopoDS_Shape Shape = GeomGUI->GetShapeReader().GetShape(myComponentGeom,aShape); if (Shape.IsNull()) MESSAGE("BuildPresentation(): TopoDS_Shape is null!") if (obj->FindAttribute(anAttr, "AttributeName")) { @@ -6913,7 +1108,7 @@ void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theI } else { if (!useSubItems) { // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); + QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->GetActiveStudy() ); op->start(); if (fatherSF->_is_nil()) MESSAGE("BuildPresentation(): fatherSF is nil!") @@ -6923,9 +1118,9 @@ void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theI op->finish(); } Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value()); - aSh->SetShadingColor( myShadingColor ); + aSh->SetShadingColor( GeomGUI->GetShadingColor() ); Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), - myFatherior, + GeomGUI->GetFatherior(), "GEOM"); IO->setEntry(obj->GetID()); aSh->setIO( IO ); @@ -6953,7 +1148,7 @@ void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theI } } // No viewer update should be done here! - //myActiveStudy->updateObjBrowser( true ); + //GeomGUI->GetActiveStudy()->updateObjBrowser( true ); //ic->UpdateCurrentViewer(); } } @@ -6966,49 +1161,48 @@ extern "C" { bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - return GeometryGUI::GetOrCreateGeometryGUI(parent)->OnGUIEvent(theCommandID, parent); + return GeometryGUI::OnGUIEvent(theCommandID, parent); } bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - return GeometryGUI::GetOrCreateGeometryGUI(parent)->OnKeyPress(pe, parent, studyFrame); + return GeometryGUI::OnKeyPress(pe, parent, studyFrame); } bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - return GeometryGUI::GetOrCreateGeometryGUI(parent)->OnMousePress(pe, parent, studyFrame); + return GeometryGUI::OnMousePress(pe, parent, studyFrame); } - bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) + bool OnMouseMove(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - return GeometryGUI::GetOrCreateGeometryGUI(parent)->OnMouseMove(pe, parent, studyFrame); + return GeometryGUI::OnMouseMove(pe, parent, studyFrame); } - bool SetSettings (QAD_Desktop* parent) + bool SetSettings(QAD_Desktop* parent) { - return GeometryGUI::GetOrCreateGeometryGUI(parent)->SetSettings(parent); + return GeometryGUI::SetSettings(parent); } - bool customPopup (QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, + bool customPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, const QString & theParent, const QString & theObject) { - return GeometryGUI::GetOrCreateGeometryGUI(parent)->CustomPopup(parent, popup, theContext, - theParent, theObject); + return GeometryGUI::CustomPopup(parent, popup, theContext, theParent, theObject); } - void definePopup (QString & theContext, QString & parent, QString & theObject) + void definePopup(QString & theContext, QString & parent, QString & theObject) { - GeometryGUI::GetGeometryGUI()->DefinePopup(theContext, parent, theObject); + GeometryGUI::DefinePopup(theContext, parent, theObject); } - bool activeStudyChanged (QAD_Desktop* parent) + bool activeStudyChanged(QAD_Desktop* parent) { - GeometryGUI::GetOrCreateGeometryGUI(parent)->activeStudyChanged(parent); + GeometryGUI::activeStudyChanged(parent); } - void buildPresentation (const Handle(SALOME_InteractiveObject)& theIO) + void buildPresentation(const Handle(SALOME_InteractiveObject)& theIO) { - GeometryGUI::GetGeometryGUI()->BuildPresentation(theIO); + GeometryGUI::BuildPresentation(theIO); } void supportedViewType(int* buffer, int bufferSize) diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index a5c016716..9253b1fab 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -26,43 +26,10 @@ // Module : GEOM // $Header$ -#ifndef GeometryGUI_HeaderFile -#define GeometryGUI_HeaderFile - -// SALOME Includes -#include "QAD_Desktop.h" -#include "SALOME_Selection.h" -#include "SALOME_InteractiveObject.hxx" -#include "GEOM_InteractiveObject.hxx" -#include "GEOM_AISShape.hxx" -#include "GEOM_Actor.h" -#include "GEOM_Sketcher.h" - -#include "GEOM_Client.hxx" -#include - -// Open CASCADE Includes -#include -#include -#include -#include -#include - -// IDL Headers -#include -#include CORBA_SERVER_HEADER(GEOM_Gen) -#include CORBA_SERVER_HEADER(SALOMEDS) -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) - - -//================================================================================= -// -//================================================================================= - enum { - POINT_METHOD, - CURRENT_SKETCH - } ; +#ifndef GEOMETRYGUI_H +#define GEOMETRYGUI_H +#include "GEOMBase_Display.h" //================================================================================= // class : GeometryGUI @@ -70,282 +37,27 @@ //================================================================================= class GeometryGUI : public QObject { - Q_OBJECT /* for QT compatibility */ - -private : - GEOM::GEOM_Gen_var myComponentGeom; - GEOM_Client myShapeReader; - QAD_Desktop* myDesktop; - QAD_Study* myActiveStudy; - QDialog* myActiveDialogBox; /* Unique active dialog box */ - Handle(AIS_Shape) mySimulationShape; /* AIS shape used only during topo/geom simulations */ - vtkActorCollection* mySimulationActor; /* GEOM Actor used only during topo/geom simulations */ - int myNbGeom ; /* Unique name for a geom entity */ - int myState ; /* Identify a method */ - Sketch mySketcher; - - Quantity_Color myShadingColor; - - AIS_ListOfInteractive myListDisplayedObject; - - bool mySettings_AddInStudy; - bool mySettings_Copy; - Standard_CString myFatherior; - + Q_OBJECT /* for QT compatibility */ public : + GeometryGUI(); + ~GeometryGUI(); + + static GEOMBase_Context* GetOrCreateGeometryGUI(QAD_Desktop* desktop); +/* static GEOMBase_Context* GetGeomGUI(); */ + + /* Managed by IAPP */ + Standard_EXPORT static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + Standard_EXPORT static bool OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); + Standard_EXPORT static bool OnMouseMove(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); + Standard_EXPORT static bool OnKeyPress(QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); + Standard_EXPORT static bool SetSettings(QAD_Desktop* parent); + Standard_EXPORT static void activeStudyChanged(QAD_Desktop* parent); + Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&); + Standard_EXPORT static void DefinePopup(QString & theContext, QString & theParent, QString & theObject); + Standard_EXPORT static bool CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, + const QString& theParent, const QString& theObject); - GeometryGUI(); - ~GeometryGUI(); - - static GeometryGUI* GetOrCreateGeometryGUI( QAD_Desktop* desktop ); - static GeometryGUI* GetGeometryGUI() ; - - QAD_Study* GetActiveStudy(); - QAD_Desktop* GetDesktop() ; - GEOM_Client& GetShapeReader(); - - QDialog* GetActiveDialogBox(); /* Returns the active DialogBox */ - void SetActiveDialogBox(QDialog* aDlg); /* Sets 'myActiveDialogBox' a pointer to the active Dialog Box */ - - void SetState(int aState); - void ResetState(); /* Sets myState = -1 a private field to indicate wich method is active */ - - bool AddInStudy( bool selection = false, const Handle(SALOME_InteractiveObject)& anIO = 0 ); - bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ; - bool SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR); - - static int GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int ShapeType) ; - static bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P) ; - static void GetBipointDxDyDz( gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz) ; - static bool GetShapeTypeString( const TopoDS_Shape& aShape, Standard_CString& aTypeString ) ; - static bool LinearEdgeExtremities( const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2) ; - static gp_Pnt ConvertClickToPoint( Standard_Real x, Standard_Real y, Handle(V3d_View) aView ) ; - /* User dialog 1 parameter returned */ - static double Parameter( Standard_Boolean& res, - const char* aValue1 = 0, - const char* aTitle1 = 0, - const char* aTitle = 0, - const double bottom = -1E6, - const double top = +1E6, - const int decimals = 6 ) ; - - /* Managed by IAPP */ - Standard_EXPORT bool OnGUIEvent ( int theCommandID, QAD_Desktop* parent) ; - Standard_EXPORT bool OnMousePress ( QMouseEvent* pe, QAD_Desktop* parent, - QAD_StudyFrame* studyFrame ); - Standard_EXPORT bool OnMouseMove ( QMouseEvent* pe, QAD_Desktop* parent, - QAD_StudyFrame* studyFrame ); - Standard_EXPORT bool OnKeyPress ( QKeyEvent* pe, QAD_Desktop* parent, - QAD_StudyFrame* studyFrame ); - Standard_EXPORT void activeStudyChanged ( QAD_Desktop* parent ); - Standard_EXPORT bool SetSettings ( QAD_Desktop* parent ); - Standard_EXPORT void DefinePopup( QString & theContext, - QString & theParent, - QString & theObject ); - Standard_EXPORT bool CustomPopup ( QAD_Desktop* parent, - QPopupMenu* popup, - const QString& theContext, - const QString& theParent, - const QString& theObject ); - Standard_EXPORT void BuildPresentation(const Handle(SALOME_InteractiveObject)&); - - - /* Selection and objects management */ - TopoDS_Shape GetShapeFromIOR( QString IOR ); - bool GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds) ; - int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ; - GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO, - Standard_Boolean& testResult ) ; - - Handle(GEOM_AISShape) ConvertIOinGEOMAISShape( const Handle(SALOME_InteractiveObject)& IO, - Standard_Boolean& testResult, - bool onlyInActiveView = false ) ; - Handle(GEOM_AISShape) ConvertIORinGEOMAISShape( const char * IOR, - Standard_Boolean& testResult, - bool onlyInActiveView = false ) ; - - GEOM_Actor* ConvertIORinGEOMActor( const char * IOR, - Standard_Boolean& testResult, - bool onlyInActiveView = false ) ; - - void ConvertListOfIOInListOfIOR( const SALOME_ListIO& aList, - GEOM::GEOM_Gen::ListOfIOR& listIOR ) ; - - /* Method used by dialog boxes called when used has entered a name of object in a LineEdit */ - bool SelectionByNameInDialogs( QWidget* aWidget, const QString& userObjectName, SALOME_Selection *Sel ) ; - - /* Method opening context for any sub shape selection */ - bool PrepareSubShapeSelection( const int SubShapeType, - Standard_Integer& returnLocalContextId ) ; - - /* Method opening context for sub shape selection on an argument shape */ - bool PrepareSubShapeSelectionArgumentShape( const TopoDS_Shape& aShape, - const int SubShapeType, - Standard_Integer& returnLocalContextId ) ; - - - /* Define a list of indices of sub shapes selected in a local context */ - bool GetIndexSubShapeSelected( const TopoDS_Shape& ShapeTopo, - const int SubShapeType, - GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID, - Standard_Integer& aLocalContextId, - bool& myUseLocalContext ) ; - - /* Methods for sub shapes explode */ - bool OnSubShapeGetAll( const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType) ; - bool OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo, - const char* ShapeTopoIOR, - const int SubShapeType, - Standard_Integer& aLocalContextId, - bool& myUseLocalContext ) ; - - - /* Import and export topology methods */ - bool Import(); - bool Export(); - - void OnEditCopy(); - void OnEditDelete(); - - void OnVTKDisplayOnly(); - void OnDisplayOnly(); - void OnDisplayAll(bool onlyPreviousDisplayedObject = false); - void SetDisplayedObjectList(); - bool Display(GEOM::GEOM_Shape_ptr aShape, Standard_CString name = ""); - - /* Simulation management */ - bool CreateArrowForLinearEdge(const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone); - void DisplaySimulationShape(const TopoDS_Shape& S); - void EraseSimulationShape(); - - - void MakePointAndDisplay(const double x, const double y, const double z); - void MakeLineAndDisplay(const gp_Pnt InitPoint, const gp_Pnt LastPoint); - void MakeCircleAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius); - void MakeEllipseAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Major_Radius, - const Standard_Real Minor_Radius); - void MakeArcAndDisplay(gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint); - void MakeVectorAndDisplay(const gp_Pnt P1, const gp_Pnt P2); - void MakePlaneAndDisplay(const gp_Pnt P1, const Standard_Real dx, const Standard_Real dy, - const Standard_Real dz, const Standard_Real TrimSize); - void MakeWorkingPlane(const gp_Pnt P, const gp_Dir D); - - - void MakePrismAndDisplay(GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2); - void MakeRevolutionAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, - const gp_Dir dir, Standard_Real revolAngle); - void MakeFillingAndDisplay(GEOM::GEOM_Shape_ptr SectionShape, const short mindeg, const short maxdeg, - const double tol3d, const double tol2d, const short nbiter); - void MakePipeAndDisplay(GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase); - - - void MakeLinearEdgeAndDisplay(const gp_Pnt P1, const gp_Pnt P2); - void MakeWireAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); - void MakeFaceAndDisplay(GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar); - void MakeShellAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); - void MakeSolidAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); - void MakeCompoundAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); - - - /* Remove faces in a shape */ - bool OnSuppressFaces( const TopoDS_Shape& ShapeTopo, - const char* ShapeTopoIOR, - const Standard_Integer& aLocalContextId, - bool& myUseLocalContext ) ; - /* Remove an hole in a topology (ListOfIdEndFace may be an empty list ) */ - bool OnSuppressHole( const char* ShapeTopoIOR, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace ) ; - /* Remove one or more holes in a face or a shell */ - bool OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires ) ; - /* Create a face corresponding to a hole on a shape */ - bool OnFillingHole( const TopoDS_Shape& MainShape, - const char* ShapeTopoIOR, - const Standard_Integer& aLocalContextId, - bool& myUseLocalContext ) ; - - - void MakeTranslationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Vec V); - void MakeRotationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, - const gp_Dir dir, const Standard_Real angle); - void MakeMirrorAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2); - void MakeScaleAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, - const Standard_Real factor); - void MakeMultiTranslation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, - const gp_Dir Dir, const double Step, const short NbTimes); - void MakeMultiTranslation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape, - const gp_Dir Dir1, const double Step1, const short NbTimes1, - const gp_Dir Dir2, const double Step2, const short NbTimes2); - void MakeMultiRotation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, - const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes); - void MakeMultiRotation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape, - const gp_Dir Dir, const gp_Pnt Loc, const double Ang, - const short NbTimes1, const double Step, const short NbTimes2); - - - void MakePartitionAndDisplay(const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, - const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR, - const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR, - const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR, - const GEOM::shape_type limit ) ; - void Archimede(const Handle(SALOME_InteractiveObject)& IO, const double aWeight, - const double aWaterDensity, const double aMeshingDeflection); - /* Method for Fillet */ - bool OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, const int SubShapeType, const char* ShapeTopoIOR) ; - bool OnFilletGetSelected(const TopoDS_Shape& ShapeTopo, - const char* ShapeTopoIOR, - const double Radius, - const int SubShapeType, - Standard_Integer& aLocalContextId, - bool& myUseLocalContext ); - /* Methods for Chamfer */ - bool OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, const int SubShapeType, const char* ShapeTopoIOR) ; - bool OnChamferGetSelected(const TopoDS_Shape& ShapeTopo, - const char* ShapeTopoIOR, - const double D1, const double D2, const int SubShapeType, - Standard_Integer& aLocalContextId, - bool& myUseLocalContext ) ; - - - void MakeSewingAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, - const Standard_Real precision); - void MakeOrientationChangeAndDisplay(GEOM::GEOM_Shape_ptr Shape); - - - void MakeCDGAndDisplay( GEOM::GEOM_Shape_ptr Shape ); - - /* Sketcher management */ - void OnSketchSegment(); - void OnSketchArc(); - void OnSketchSetAngle(); - void OnSketchSetx(); - void OnSketchSety(); - - void OnSketchDelete(); - void OnSketchClose(); - void OnSketchEnd(); - - void OnSketchOptionsOnoffangledimension(); - void OnSketchOptionsOnofflengthdimension(); - void OnSketchOptionsOnoffradiusdimension(); - void OnSketchOptionsOnoffxdimension(); - void OnSketchOptionsOnoffydimension(); - - void OnSettingsNoconstraint(); - void OnSettingsPerpendicular(); - void OnSettingsTangent(); - - /* Non modal dialog boxes magement */ - void EmitSignalDeactivateDialog() ; - void EmitSignalCloseAllDialogs() ; - -signals: - void SignalDeactivateActiveDialog() ; - void SignalCloseAllDialogs() ; - void SignalDefaultStepValueChanged( double newVal ) ; }; #endif diff --git a/src/GEOMGUI/Makefile.in b/src/GEOMGUI/Makefile.in index 59c4f2a18..1e74ed3d3 100644 --- a/src/GEOMGUI/Makefile.in +++ b/src/GEOMGUI/Makefile.in @@ -38,171 +38,13 @@ VPATH=.:@srcdir@:@top_srcdir@/idl EXPORT_HEADERS= GeometryGUI_Swig.hxx \ GeometryGUI_Swig.i -# ressources files : -PO_FILES = \ - GEOM_icons.po \ - GEOM_msg_en.po \ - GEOM_msg_fr.po - # Libraries targets LIB = libGEOMGUI.la LIB_SRC = GeometryGUI.cxx \ - BooleanGUI.cxx \ - PrimitiveGUI.cxx \ - GeometryGUI_SpinBox.cxx \ - GeometryGUI_Skeleton_QTD.cxx \ - GeometryGUI_Skeleton.cxx \ - GeometryGUI_1Sel_QTD.cxx \ - GeometryGUI_2Sel_QTD.cxx \ - GeometryGUI_1Sel1Spin_QTD.cxx \ - GeometryGUI_1Sel1Spin.cxx \ - GeometryGUI_1Sel4Spin_QTD.cxx \ - GeometryGUI_1Sel4Spin.cxx \ - GeometryGUI_2Sel1Spin_QTD.cxx \ - GeometryGUI_2Sel1Spin.cxx \ - GeometryGUI_2Sel2Spin_QTD.cxx \ - GeometryGUI_2Sel2Spin.cxx \ - GeometryGUI_2Sel3Spin_QTD.cxx \ - GeometryGUI_2Sel3Spin.cxx \ - GeometryGUI_1Spin_QTD.cxx \ - GeometryGUI_1Spin.cxx \ - GeometryGUI_2Spin_QTD.cxx \ - GeometryGUI_2Spin.cxx \ - GeometryGUI_3Spin_QTD.cxx \ - GeometryGUI_3Spin.cxx \ - GeometryGUI_TransparencyDlg.cxx \ - GeometryGUI_NbIsosDlg.cxx \ - GeometryGUI_BoxDlg.cxx \ - GeometryGUI_ArchimedeDlg.cxx \ - GeometryGUI_PointDlg.cxx \ - GeometryGUI_VectorDlg.cxx \ - GeometryGUI_PlaneDlg.cxx \ - GeometryGUI_PrismDlg.cxx \ - GeometryGUI_FuseDlg.cxx \ - GeometryGUI_SectionDlg.cxx \ - GeometryGUI_CommonDlg.cxx \ - GeometryGUI_CutDlg.cxx \ - GeometryGUI_LineDlg.cxx \ - GeometryGUI_ScaleDlg.cxx \ - GeometryGUI_MirrorDlg.cxx \ - GeometryGUI_SphereDlg.cxx \ - GeometryGUI_CircleDlg.cxx \ - GeometryGUI_RevolDlg.cxx \ - GeometryGUI_RotationDlg.cxx \ - GeometryGUI_TranslationDlg.cxx \ - GeometryGUI_ArcDlg.cxx \ - GeometryGUI_PipeDlg.cxx \ - GeometryGUI_CylinderDlg.cxx \ - GeometryGUI_ConeDlg.cxx \ - GeometryGUI_TorusDlg.cxx \ - GeometryGUI_FillingDlg.cxx \ - GeometryGUI_SewingDlg.cxx \ - GeometryGUI_CompoundDlg.cxx \ - GeometryGUI_EdgeDlg.cxx \ - GeometryGUI_OrientationDlg.cxx \ - GeometryGUI_PartitionDlg.cxx \ - GeometryGUI_SubShapeDlg.cxx \ - GeometryGUI_aParameterDlg.cxx \ - GeometryGUI_WireDlg.cxx \ - GeometryGUI_WorkingPlaneDlg.cxx \ - GeometryGUI_PropertiesDlg.cxx \ - GeometryGUI_InertiaDlg.cxx \ - GeometryGUI_CenterMassDlg.cxx \ - GeometryGUI_FaceDlg.cxx \ - GeometryGUI_ShellDlg.cxx \ - GeometryGUI_SolidDlg.cxx \ - GeometryGUI_BndBoxDlg.cxx \ - GeometryGUI_MaxToleranceDlg.cxx \ - GeometryGUI_WhatisDlg.cxx \ - GeometryGUI_DistanceDlg.cxx \ - GeometryGUI_SuppressFacesDlg.cxx \ - GeometryGUI_CheckShape.cxx \ - GeometryGUI_FilletDlg.cxx \ - GeometryGUI_ChamferDlg.cxx \ - GeometryGUI_MultiTranslationDlg.cxx \ - GeometryGUI_MultiRotationDlg.cxx \ - GeometryGUI_Swig.cxx \ - GeometryGUI_SuppressHoleDlg.cxx \ - GeometryGUI_EllipseDlg.cxx + GeometryGUI_Swig.cxx LIB_MOC = \ GeometryGUI.h \ - BooleanGUI.h \ - PrimitiveGUI.h \ - GeometryGUI_SpinBox.h \ - GeometryGUI_Skeleton_QTD.h \ - GeometryGUI_Skeleton.h \ - GeometryGUI_1Sel_QTD.h \ - GeometryGUI_2Sel_QTD.h \ - GeometryGUI_1Sel1Spin_QTD.h \ - GeometryGUI_1Sel1Spin.h \ - GeometryGUI_1Sel4Spin_QTD.h \ - GeometryGUI_1Sel4Spin.h \ - GeometryGUI_2Sel1Spin_QTD.h \ - GeometryGUI_2Sel1Spin.h \ - GeometryGUI_2Sel2Spin_QTD.h \ - GeometryGUI_2Sel2Spin.h \ - GeometryGUI_2Sel3Spin_QTD.h \ - GeometryGUI_2Sel3Spin.h \ - GeometryGUI_1Spin_QTD.h \ - GeometryGUI_1Spin.h \ - GeometryGUI_2Spin_QTD.h \ - GeometryGUI_2Spin.h \ - GeometryGUI_3Spin_QTD.h \ - GeometryGUI_3Spin.h \ - GeometryGUI_TransparencyDlg.h \ - GeometryGUI_NbIsosDlg.h \ - GeometryGUI_BoxDlg.h \ - GeometryGUI_ArchimedeDlg.h \ - GeometryGUI_PointDlg.h \ - GeometryGUI_VectorDlg.h \ - GeometryGUI_PlaneDlg.h \ - GeometryGUI_PrismDlg.h \ - GeometryGUI_FuseDlg.h \ - GeometryGUI_SectionDlg.h \ - GeometryGUI_CommonDlg.h \ - GeometryGUI_CutDlg.h \ - GeometryGUI_LineDlg.h \ - GeometryGUI_ScaleDlg.h \ - GeometryGUI_MirrorDlg.h \ - GeometryGUI_SphereDlg.h \ - GeometryGUI_CircleDlg.h \ - GeometryGUI_RevolDlg.h \ - GeometryGUI_RotationDlg.h \ - GeometryGUI_TranslationDlg.h \ - GeometryGUI_ArcDlg.h \ - GeometryGUI_PipeDlg.h \ - GeometryGUI_CylinderDlg.h \ - GeometryGUI_ConeDlg.h \ - GeometryGUI_TorusDlg.h \ - GeometryGUI_FillingDlg.h \ - GeometryGUI_SewingDlg.h \ - GeometryGUI_CompoundDlg.h \ - GeometryGUI_EdgeDlg.h \ - GeometryGUI_OrientationDlg.h \ - GeometryGUI_PartitionDlg.h \ - GeometryGUI_SubShapeDlg.h \ - GeometryGUI_aParameterDlg.h \ - GeometryGUI_WireDlg.h \ - GeometryGUI_WorkingPlaneDlg.h \ - GeometryGUI_PropertiesDlg.h \ - GeometryGUI_InertiaDlg.h \ - GeometryGUI_CenterMassDlg.h \ - GeometryGUI_FaceDlg.h \ - GeometryGUI_ShellDlg.h \ - GeometryGUI_SolidDlg.h \ - GeometryGUI_BndBoxDlg.h \ - GeometryGUI_MaxToleranceDlg.h \ - GeometryGUI_WhatisDlg.h \ - GeometryGUI_DistanceDlg.h \ - GeometryGUI_SuppressFacesDlg.h \ - GeometryGUI_CheckShape.h \ - GeometryGUI_FilletDlg.h \ - GeometryGUI_ChamferDlg.h \ - GeometryGUI_MultiTranslationDlg.h \ - GeometryGUI_MultiRotationDlg.h \ - GeometryGUI_SuppressHoleDlg.h \ - GeometryGUI_EllipseDlg.h LIB_CLIENT_IDL = SALOME_Exception.idl \ GEOM_Gen.idl \ @@ -219,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 -lGEOMSketcher $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/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 @CONCLUDE@ diff --git a/src/GenerationGUI/GenerationGUI.cxx b/src/GenerationGUI/GenerationGUI.cxx new file mode 100644 index 000000000..4417336c6 --- /dev/null +++ b/src/GenerationGUI/GenerationGUI.cxx @@ -0,0 +1,220 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GenerationGUI.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "GenerationGUI.h" + +#include "GenerationGUI_PrismDlg.h" // Method PRISM +#include "GenerationGUI_RevolDlg.h" // Method REVOL +#include "GenerationGUI_FillingDlg.h" // Method FILLING +#include "GenerationGUI_PipeDlg.h" // Method PIPE + +//======================================================================= +// function : GenerationGUI() +// purpose : Constructor +//======================================================================= +GenerationGUI::GenerationGUI() : + QObject() +{ + myGeomGUI = GEOMBase_Context::GetGeomGUI(); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); +} + + +//======================================================================= +// function : ~GenerationGUI() +// purpose : Destructor +//======================================================================= +GenerationGUI::~GenerationGUI() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool GenerationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + switch (theCommandID) + { + case 4031: // PRISM + { + GenerationGUI_PrismDlg *aDlg = new GenerationGUI_PrismDlg(parent, "", this, Sel); + break; + } + case 4032: // REVOL + { + GenerationGUI_RevolDlg *aDlg = new GenerationGUI_RevolDlg(parent, "", this, Sel); + break; + } + case 4033: // FILLING + { + GenerationGUI_FillingDlg *aDlg = new GenerationGUI_FillingDlg(parent, "", this, Sel); + break; + } + case 4034: // PIPE + { + GenerationGUI_PipeDlg *aDlg = new GenerationGUI_PipeDlg(parent, "", this, Sel); + break; + } + default: + { + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + } + return true; +} + + +//======================================================================= +// function : MakePrismAndDisplay() +// purpose : P1 and P2 is to define a vector for prism +//======================================================================= +void GenerationGUI::MakePrismAndDisplay(GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2) +{ + try { + if(BaseShape->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + + GEOM::PointStruct PS1 = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()); + GEOM::PointStruct PS2 = myGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()); + GEOM::GEOM_Shape_ptr result = myGeom->MakePrism(BaseShape, PS1, PS2); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + result->NameType(type); + + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//======================================================================================= +// function : MakeRevolutionAndDisplay() +// purpose : +//======================================================================================= +void GenerationGUI::MakeRevolutionAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir, const Standard_Real revolAngle) +{ + try { + GEOM::AxisStruct axis = myGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z()); + GEOM::GEOM_Shape_ptr result = myGeom->MakeRevolution(Shape, axis, revolAngle) ; + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + result->NameType(type); + + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeFillingAndDisplay() +// purpose : +//===================================================================================== +void GenerationGUI::MakeFillingAndDisplay(GEOM::GEOM_Shape_ptr SectionShape, const short mindeg, + const short maxdeg, const double tol3d, + const double tol2d, const short nbiter) +{ + try { + GEOM::GEOM_Shape_ptr result = myGeom->MakeFilling(SectionShape, mindeg, maxdeg, + tol3d, tol2d, nbiter); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + result->NameType(type); + + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + return; + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakePipeAndDisplay() +// purpose : +//===================================================================================== +void GenerationGUI::MakePipeAndDisplay(GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase) +{ + try { + GEOM::GEOM_Shape_ptr result = myGeom->MakePipe(aPath, aBase); + if (!result->_is_nil() && myGeomGUI->Display(result)) { + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + result->NameType(type); + + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + else { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + } + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} diff --git a/src/GenerationGUI/GenerationGUI.h b/src/GenerationGUI/GenerationGUI.h new file mode 100644 index 000000000..7eae509de --- /dev/null +++ b/src/GenerationGUI/GenerationGUI.h @@ -0,0 +1,61 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : BooleanGUI.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef GENERATIONGUI_H +#define GENERATIONGUI_H + +#include "GEOMBase_Display.h" + +//================================================================================= +// class : GenerationGUI +// purpose : +//================================================================================= +class GenerationGUI : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + GenerationGUI(); + ~GenerationGUI(); + + 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, + const gp_Dir dir, Standard_Real revolAngle); + void MakeFillingAndDisplay(GEOM::GEOM_Shape_ptr SectionShape, const short mindeg, const short maxdeg, + const double tol3d, const double tol2d, const short nbiter); + void MakePipeAndDisplay(GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase); + +private: + GEOMBase_Context* myGeomGUI; + GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + +}; + +#endif diff --git a/src/GenerationGUI/GenerationGUI_FillingDlg.cxx b/src/GenerationGUI/GenerationGUI_FillingDlg.cxx new file mode 100644 index 000000000..84d01c4f3 --- /dev/null +++ b/src/GenerationGUI/GenerationGUI_FillingDlg.cxx @@ -0,0 +1,263 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GenerationGUI_FillingDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "GenerationGUI_FillingDlg.h" + +#include "QAD_Config.h" + +//================================================================================= +// class : GenerationGUI_FillingDlg() +// purpose : Constructs a GenerationGUI_FillingDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +GenerationGUI_FillingDlg::GenerationGUI_FillingDlg(QWidget* parent, const char* name, GenerationGUI* theGenerationGUI, 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_FILLING"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_FILLING_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_FILLING")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_1Sel5Spin(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_FILLING_COMPOUND")); + GroupPoints->TextLabel2->setText(tr("GEOM_FILLING_MIN_DEG")); + GroupPoints->TextLabel3->setText(tr("GEOM_FILLING_MAX_DEG")); + GroupPoints->TextLabel4->setText(tr("GEOM_FILLING_TOL_3D")); + GroupPoints->TextLabel5->setText(tr("GEOM_FILLING_TOL_2D")); + GroupPoints->TextLabel6->setText(tr("GEOM_FILLING_NB_ITER")); + GroupPoints->PushButton1->setPixmap(image1); + + Layout1->addWidget(GroupPoints, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myGenerationGUI = theGenerationGUI; + Init(); +} + + +//================================================================================= +// function : ~GenerationGUI_FillingDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +GenerationGUI_FillingDlg::~GenerationGUI_FillingDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void GenerationGUI_FillingDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myMinDeg = 2; + myMaxDeg = 5; + myTol3D = 0.0001; + myTol2D = 0.0001; + myNbIter = 5; + myOkSectionShape = false; + + myCompoundFilter = new GEOM_ShapeTypeFilter(TopAbs_COMPOUND, myGeom); + mySelection->AddFilter(myCompoundFilter); + + /* 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_1->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_2->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_3->RangeStepAndValidator(0.00001, 10000.0, 3, 10); + GroupPoints->SpinBox_4->RangeStepAndValidator(0.00001, 10000.0, 3, 10); + GroupPoints->SpinBox_5->RangeStepAndValidator(0.001, 999.999, step, 3); + + GroupPoints->SpinBox_1->SetValue(myMinDeg); + GroupPoints->SpinBox_2->SetValue(myMaxDeg); + GroupPoints->SpinBox_3->SetValue(myTol3D); + GroupPoints->SpinBox_4->SetValue(myTol2D); + GroupPoints->SpinBox_5->SetValue(myNbIter); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + /* displays Dialog */ + GroupPoints->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void GenerationGUI_FillingDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void GenerationGUI_FillingDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + + myMinDeg = GroupPoints->SpinBox_1->value(); + myMaxDeg = GroupPoints->SpinBox_2->value(); + myTol3D = GroupPoints->SpinBox_3->value(); + myTol2D = GroupPoints->SpinBox_4->value(); + myNbIter = GroupPoints->SpinBox_5->value(); + + if(myOkSectionShape) + myGenerationGUI->MakeFillingAndDisplay(myGeomShape, myMinDeg, myMaxDeg, myTol3D, myTol2D, myNbIter); + + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void GenerationGUI_FillingDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkSectionShape = false; + return; + } + + // nbSel == 1 + TopoDS_Shape S; + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + if(myEditCurrentArgument == GroupPoints->LineEdit1 && S.ShapeType() == TopAbs_COMPOUND) { + myEditCurrentArgument->setText(aString); + myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myOkSectionShape = true; + } + /* no simulation */ + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void GenerationGUI_FillingDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + mySelection->AddFilter(myCompoundFilter); + } + this->SelectionIntoArgument(); + + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void GenerationGUI_FillingDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupPoints->LineEdit1) + myEditCurrentArgument = GroupPoints->LineEdit1; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void GenerationGUI_FillingDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void GenerationGUI_FillingDlg::enterEvent(QEvent* e) +{ + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} diff --git a/src/GenerationGUI/GenerationGUI_FillingDlg.h b/src/GenerationGUI/GenerationGUI_FillingDlg.h new file mode 100644 index 000000000..6bd6c47b4 --- /dev/null +++ b/src/GenerationGUI/GenerationGUI_FillingDlg.h @@ -0,0 +1,79 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GenerationGUI_FillingDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_FILLING_H +#define DIALOGBOX_FILLING_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel5Spin.h" + +#include "GenerationGUI.h" + +//================================================================================= +// class : GenerationGUI_FillingDlg +// purpose : +//================================================================================= +class GenerationGUI_FillingDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + GenerationGUI_FillingDlg(QWidget* parent = 0, const char* name = 0, GenerationGUI* theGenerationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~GenerationGUI_FillingDlg(); + +private: + void Init(); + void enterEvent(QEvent* e); + + GenerationGUI* myGenerationGUI; + + int step; + Handle(GEOM_ShapeTypeFilter) myCompoundFilter; /* Filter selection */ + + GEOM::GEOM_Shape_var myGeomShape; /* is mySectionShape */ + TopoDS_Shape mySectionShape; + Standard_Integer myMinDeg; + Standard_Integer myMaxDeg; + Standard_Real myTol3D; + Standard_Real myTol2D; + Standard_Integer myNbIter; + bool myOkSectionShape; /* to check when arguments is defined */ + + DlgRef_1Sel5Spin* GroupPoints; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + +}; + +#endif // DIALOGBOX_FILLING_H diff --git a/src/GenerationGUI/GenerationGUI_PipeDlg.cxx b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx new file mode 100644 index 000000000..6c067447d --- /dev/null +++ b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx @@ -0,0 +1,276 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GenerationGUI_PipeDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "GenerationGUI_PipeDlg.h" + +#include +// #include +// #include +#include + +//================================================================================= +// class : GenerationGUI_PipeDlg() +// purpose : Constructs a GenerationGUI_PipeDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +GenerationGUI_PipeDlg::GenerationGUI_PipeDlg(QWidget* parent, const char* name, GenerationGUI* theGenerationGUI, 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_PIPE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_PIPE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_PIPE")); + 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_BASE_OBJECT")); + GroupPoints->TextLabel2->setText(tr("GEOM_PATH_OBJECT")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->PushButton2->setPixmap(image1); + + Layout1->addWidget(GroupPoints, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myGenerationGUI = theGenerationGUI; + Init(); +} + + +//================================================================================= +// function : ~GenerationGUI_PipeDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +GenerationGUI_PipeDlg::~GenerationGUI_PipeDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void GenerationGUI_PipeDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myOkShape1 = myOkShape2 = false; + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + 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(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + /* displays Dialog */ + GroupPoints->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void GenerationGUI_PipeDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + + +//================================================================================= +// function : ClickOnAply() +// purpose : +//================================================================================= +void GenerationGUI_PipeDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkShape1 && myOkShape2) + myGenerationGUI->MakePipeAndDisplay(myGeomShape2 ,myGeomShape1); + + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void GenerationGUI_PipeDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + 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; + + if(myEditCurrentArgument == GroupPoints->LineEdit1 && S.ShapeType() != TopAbs_COMPSOLID && S.ShapeType() != TopAbs_COMPOUND && S.ShapeType() != TopAbs_SOLID && S.ShapeType() != TopAbs_SHAPE) { + myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myEditCurrentArgument->setText(aString); + myOkShape1 = true; + myShape1 = S; + } + else if(myEditCurrentArgument == GroupPoints->LineEdit2 && S.ShapeType() != TopAbs_COMPSOLID && S.ShapeType() != TopAbs_COMPOUND && S.ShapeType() != TopAbs_SOLID && S.ShapeType() != TopAbs_SHAPE) { + myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + myEditCurrentArgument->setText(aString); + myOkShape2 = true; + 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); + } + } + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void GenerationGUI_PipeDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + } + this->SelectionIntoArgument(); + + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void GenerationGUI_PipeDlg::LineEditReturnPressed() +{ + 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 : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void GenerationGUI_PipeDlg::enterEvent(QEvent* e) +{ + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void GenerationGUI_PipeDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} diff --git a/src/GenerationGUI/GenerationGUI_PipeDlg.h b/src/GenerationGUI/GenerationGUI_PipeDlg.h new file mode 100644 index 000000000..b54122c4d --- /dev/null +++ b/src/GenerationGUI/GenerationGUI_PipeDlg.h @@ -0,0 +1,74 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GenerationGUI_PipeDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_PIPE_H +#define DIALOGBOX_PIPE_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel_QTD.h" + +#include "GenerationGUI.h" + +//================================================================================= +// class : GenerationGUI_PipeDlg +// purpose : +//================================================================================= +class GenerationGUI_PipeDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + GenerationGUI_PipeDlg(QWidget* parent = 0, const char* name = 0, GenerationGUI* theGenerationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~GenerationGUI_PipeDlg(); + +private: + void Init(); + void enterEvent(QEvent* e); + + GenerationGUI* myGenerationGUI; + + 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 */ + + DlgRef_2Sel_QTD* GroupPoints; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + +}; + +#endif // DIALOGBOX_PIPE_H diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx new file mode 100644 index 000000000..c00a82344 --- /dev/null +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx @@ -0,0 +1,351 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GenerationGUI_PrismDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "GenerationGUI_PrismDlg.h" + +#include +#include "QAD_Config.h" + +//================================================================================= +// class : GenerationGUI_PrismDlg() +// purpose : Constructs a GenerationGUI_PrismDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +GenerationGUI_PrismDlg::GenerationGUI_PrismDlg(QWidget* parent, const char* name, GenerationGUI* theGenerationGUI, 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_PRISM"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_PRISM_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_PRISM")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_2Sel1Spin1Check(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_PRISM_BSV")); + GroupPoints->TextLabel1->setText(tr("GEOM_BASE")); + GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPoints->TextLabel3->setText(tr("GEOM_HEIGHT")); + GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->PushButton2->setPixmap(image1); + + Layout1->addWidget(GroupPoints, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myGenerationGUI = theGenerationGUI; + Init(); +} + + +//================================================================================= +// function : ~GenerationGUI_PrismDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +GenerationGUI_PrismDlg::~GenerationGUI_PrismDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void GenerationGUI_PrismDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myHeight = 100.000; + myDx = myDy = myDz = 0.0; + 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"); + step = St.toDouble(); + + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_DX->SetValue(myHeight); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + 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))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + /* displays Dialog */ + GroupPoints->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void GenerationGUI_PrismDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void GenerationGUI_PrismDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + gp_Pnt P1, P2; + + try { + gp_Vec Vec(myDx, myDy, myDz); + Vec.Normalize(); + Vec *= myHeight; + P1.SetCoord(0.0, 0.0, 0.0); + P2.SetCoord(Vec.X(), Vec.Y(), Vec.Z()); + + if(myOkBase && myOkLine) + myGenerationGUI->MakePrismAndDisplay(myGeomShape, P1, P2); + } + catch(Standard_Failure) { + MESSAGE("Exception intercepted in GenerationGUI_PrismDlg" << endl); + return; + } + + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void GenerationGUI_PrismDlg::SelectionIntoArgument() +{ + 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) + myOkLine = false; + return; + } + + // nbSel == 1 + TopoDS_Shape S; + Standard_Boolean testResult; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + gp_Pnt aPoint1, aPoint2 ; + + if(myEditCurrentArgument == GroupPoints->LineEdit1) { + myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult); + if(!testResult) + return; + if(S.ShapeType() <= 2) + return; + myEditCurrentArgument->setText(aString); + myOkBase = true; + myBaseTopo = S; + } + else if(myEditCurrentArgument == GroupPoints->LineEdit2 && myGeomGUI->LinearEdgeExtremities(S, aPoint1, aPoint2)) { + myGeomGUI->GetBipointDxDyDz(aPoint1, aPoint2, myDx, myDy, myDz); + myEditCurrentArgument->setText(aString); + myOkLine = true; + } + + if(myOkBase && myOkLine) + MakePrismSimulationAndDisplay(myBaseTopo); + + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void GenerationGUI_PrismDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + 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_PrismDlg::LineEditReturnPressed() +{ + 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 : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void GenerationGUI_PrismDlg::enterEvent(QEvent * e) +{ + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void GenerationGUI_PrismDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +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); + } + return; +} + + +//================================================================================= +// function : ReverseVector() +// purpose : 'state' not used here +//================================================================================= +void GenerationGUI_PrismDlg::ReverseVector(int state) +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + myDx = -myDx; + myDy = -myDy; + myDz = -myDz; + if(myOkBase && myOkLine) + MakePrismSimulationAndDisplay(myBaseTopo); + return; +} + + +//================================================================================= +// function : MakePrismSimulationAndDisplay() +// purpose : +//================================================================================= +void GenerationGUI_PrismDlg::MakePrismSimulationAndDisplay(const TopoDS_Shape& S) +{ + try { + gp_Vec Vec(myDx, myDy, myDz ); + Vec.Normalize(); + Vec *= myHeight; + mySimulationTopoDs = BRepPrimAPI_MakePrism(S, Vec, Standard_False).Shape(); + } + catch(Standard_Failure) { + 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 new file mode 100644 index 000000000..be7df17f8 --- /dev/null +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.h @@ -0,0 +1,82 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GenerationGUI_PrismDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_PRISM_H +#define DIALOGBOX_PRISM_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel1Spin1Check.h" + +#include "GenerationGUI.h" + +//================================================================================= +// class : GenerationGUI_PrismDlg +// purpose : +//================================================================================= +class GenerationGUI_PrismDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + GenerationGUI_PrismDlg(QWidget* parent = 0, const char* name = 0, GenerationGUI* theGenerationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~GenerationGUI_PrismDlg(); + +private : + void Init(); + void enterEvent(QEvent* e); + void MakePrismSimulationAndDisplay(const TopoDS_Shape& S); + + GenerationGUI* myGenerationGUI; + + double step; + Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filters selection */ + + Standard_Real myDx; + Standard_Real myDy; + Standard_Real myDz; + Standard_Real myHeight; /* Height used for prism (extrusion) */ + TopoDS_Shape myBaseTopo; /* topology used as base of prism */ + GEOM::GEOM_Shape_var myGeomShape; /* that is myBaseTopo */ + bool myOkBase; + bool myOkLine; /* to check when arguments myDx, myDy, myDz are defined */ + + DlgRef_2Sel1Spin1Check* GroupPoints; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ReverseVector(int state); + void ValueChangedInSpinBox(double newValue); + +}; + +#endif // DIALOGBOX_PRISM_H diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx new file mode 100644 index 000000000..b06a844fa --- /dev/null +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx @@ -0,0 +1,556 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GenerationGUI_RevolDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "GenerationGUI_RevolDlg.h" + +#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 +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// 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 ) +{ + 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 */ +} + + +//================================================================================= +// function : ~GenerationGUI_RevolDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +GenerationGUI_RevolDlg::~GenerationGUI_RevolDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void GenerationGUI_RevolDlg::Init( SALOME_Selection* Sel ) +{ + + /* 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 ; + + 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_EdgeFilter( StdSelect_Line, myGeom ); + + /* 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 ; +} + +//================================================================================= +// function : ReverseAngle() +// purpose : 'state' not used here +//================================================================================= +void GenerationGUI_RevolDlg::ReverseAngle(int state) +{ + myAngle = -myAngle ; + SpinBox_C1A3->SetValue( myAngle ) ; + + if(myOkBase && myOkAxis) { + MakeRevolutionSimulationAndDisplay(myBase) ; + } else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void GenerationGUI_RevolDlg::ConstructorsClicked(int constructorId) +{ + /* only a constructor now */ + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void GenerationGUI_RevolDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->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 ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void GenerationGUI_RevolDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + 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 ; + } + + /* 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 ; + + /* 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) */) { + BRepAdaptor_Curve curv(TopoDS::Edge(S)); + myDir = curv.Line().Direction(); + myLoc = curv.Line().Location(); + LineEditC1A2->setText(aString) ; + myOkAxis = true ; + } + + if( myOkBase && myOkAxis ) { + MakeRevolutionSimulationAndDisplay( myBase) ; + } + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +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 ; +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void GenerationGUI_RevolDlg::LineEditReturnPressed() +{ + 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 ; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void GenerationGUI_RevolDlg::ValueChangedInSpinBox( double newValue ) +{ + myAngle = newValue ; + if ( myOkBase && myOkAxis ) { + MakeRevolutionSimulationAndDisplay(myBase) ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void GenerationGUI_RevolDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->EraseSimulationShape() ; + mySelection->ClearFilters() ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void GenerationGUI_RevolDlg::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 ; +} + + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void GenerationGUI_RevolDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void GenerationGUI_RevolDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; /* same than click on cancel button */ +} + + +//================================================================================= +// function : MakeRevolutionSimulationAndDisplay() +// purpose : +//================================================================================= +void GenerationGUI_RevolDlg::MakeRevolutionSimulationAndDisplay( const TopoDS_Shape& S) +{ + 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 ; + + try { + gp_Ax1 AX( this->myLoc, this->myDir); + mySimulationTopoDs = BRepPrimAPI_MakeRevol(S, AX, this->myAngle*PI180 ); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ; + } + catch(Standard_Failure) { + MESSAGE( "Exception catched in MakeRevolutionSimulationAndDisplay" ) ; + } + return ; +} diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.h b/src/GenerationGUI/GenerationGUI_RevolDlg.h new file mode 100644 index 000000000..f51e56b28 --- /dev/null +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.h @@ -0,0 +1,131 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GenerationGUI_RevolDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_REVOLUTION_H +#define DIALOGBOX_REVOLUTION_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 +{ + Q_OBJECT + +public: + GenerationGUI_RevolDlg(QWidget* parent = 0, const char* name = 0, GenerationGUI* theGenerationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~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 ; + + 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 */ + + void closeEvent( QCloseEvent* e ) ; + void enterEvent( QEvent* e); + void Init( SALOME_Selection* Sel ) ; + void MakeRevolutionSimulationAndDisplay( const TopoDS_Shape& S) ; + + 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; + +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 ) ; + +protected: + QGridLayout* GenerationGUI_RevolDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_REVOLUTION_H diff --git a/src/GenerationGUI/Makefile.in b/src/GenerationGUI/Makefile.in new file mode 100644 index 000000000..8ba5726fb --- /dev/null +++ b/src/GenerationGUI/Makefile.in @@ -0,0 +1,73 @@ +# GEOM GENERATIONGUI : +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Damien COQUERET (OCC) +# Module : GEOM +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= GenerationGUI.h + +# Libraries targets +LIB = libGenerationGUI.la + +LIB_SRC = GenerationGUI.cxx \ + GenerationGUI_PrismDlg.cxx \ + GenerationGUI_RevolDlg.cxx \ + GenerationGUI_FillingDlg.cxx \ + GenerationGUI_PipeDlg.cxx + +LIB_MOC = \ + GenerationGUI.h \ + GenerationGUI_PrismDlg.h \ + GenerationGUI_RevolDlg.h \ + GenerationGUI_FillingDlg.h \ + GenerationGUI_PipeDlg.h + +LIB_CLIENT_IDL = SALOME_Exception.idl \ + GEOM_Gen.idl \ + GEOM_Shape.idl \ + SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +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 -lDlgRef -lGEOMBase $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/Makefile.in b/src/Makefile.in index dfd82101c..817441df7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -32,6 +32,6 @@ VPATH=.:@srcdir@ @COMMENCE@ -SUBDIRS = OBJECT SKETCHER ARCHIMEDE PARTITION GEOMDS GEOM GEOMClient GEOMFiltersSelection GEOMGUI GEOM_SWIG +SUBDIRS = OBJECT SKETCHER ARCHIMEDE PARTITION GEOMDS GEOM GEOMClient GEOMFiltersSelection DlgRef GEOMBase BasicGUI PrimitiveGUI GenerationGUI BuildGUI BooleanGUI TransformationGUI OperationGUI RepairGUI MeasureGUI GEOMGUI GEOM_SWIG @MODULE@ diff --git a/src/MeasureGUI/Makefile.in b/src/MeasureGUI/Makefile.in new file mode 100644 index 000000000..92a0683fc --- /dev/null +++ b/src/MeasureGUI/Makefile.in @@ -0,0 +1,81 @@ +# GEOM MEASUREGUI : +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Damien COQUERET (OCC) +# Module : GEOM +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= MeasureGUI.h + +# Libraries targets +LIB = libMeasureGUI.la + +LIB_SRC = MeasureGUI.cxx \ + MeasureGUI_PropertiesDlg.cxx \ + MeasureGUI_CenterMassDlg.cxx \ + MeasureGUI_InertiaDlg.cxx \ + MeasureGUI_BndBoxDlg.cxx \ + MeasureGUI_DistanceDlg.cxx \ + MeasureGUI_MaxToleranceDlg.cxx \ + MeasureGUI_WhatisDlg.cxx \ + MeasureGUI_CheckShape.cxx + +LIB_MOC = \ + MeasureGUI.h \ + MeasureGUI_PropertiesDlg.h \ + MeasureGUI_CenterMassDlg.h \ + MeasureGUI_InertiaDlg.h \ + MeasureGUI_BndBoxDlg.h \ + MeasureGUI_DistanceDlg.h \ + MeasureGUI_MaxToleranceDlg.h \ + MeasureGUI_WhatisDlg.h \ + MeasureGUI_CheckShape.h + +LIB_CLIENT_IDL = SALOME_Exception.idl \ + GEOM_Gen.idl \ + GEOM_Shape.idl \ + SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +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 -lDlgRef -lGEOMBase $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/MeasureGUI/MeasureGUI.cxx b/src/MeasureGUI/MeasureGUI.cxx new file mode 100644 index 000000000..13dd421f4 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI.cxx @@ -0,0 +1,144 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "MeasureGUI.h" + +#include "MeasureGUI_PropertiesDlg.h" // Method PROPERTIES +#include "MeasureGUI_CenterMassDlg.h" // Method CENTER MASS +#include "MeasureGUI_InertiaDlg.h" // Method INERTIA +#include "MeasureGUI_BndBoxDlg.h" // Method BNDBOX +#include "MeasureGUI_DistanceDlg.h" // Method DISTANCE +#include "MeasureGUI_MaxToleranceDlg.h" // Method MAXTOLERANCE +#include "MeasureGUI_WhatisDlg.h" // Method WHATIS +#include "MeasureGUI_CheckShape.h" // Method CHECKSHAPE + +//======================================================================= +// function : MeasureGUI() +// purpose : Constructor +//======================================================================= +MeasureGUI::MeasureGUI() : + QObject() +{ + myGeomGUI = GEOMBase_Context::GetGeomGUI(); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); +} + + +//======================================================================= +// function : ~MeasureGUI() +// purpose : Destructor +//======================================================================= +MeasureGUI::~MeasureGUI() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool MeasureGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + switch (theCommandID) + { + case 601: // PROPERTIES (Length, surface, volume) + { + MeasureGUI_PropertiesDlg *aDlg = new MeasureGUI_PropertiesDlg(parent, "", Sel); + break; + } + case 604: // CDG : Center of mass + { + MeasureGUI_CenterMassDlg *aDlg = new MeasureGUI_CenterMassDlg(parent, "", this, Sel); + break; + } + case 605: // INERTIA + { + MeasureGUI_InertiaDlg *aDlg = new MeasureGUI_InertiaDlg(parent, "", Sel); + break; + } + case 6060: // BOUNDING BOX + { + MeasureGUI_BndBoxDlg *aDlg = new MeasureGUI_BndBoxDlg(parent, "", Sel); + break; + } + case 6061: // MIN DISTANCE + { + MeasureGUI_DistanceDlg *aDlg = new MeasureGUI_DistanceDlg(parent, "", Sel); + break; + } + case 607: // MAXTOLERANCE + { + MeasureGUI_MaxToleranceDlg *aDlg = new MeasureGUI_MaxToleranceDlg(parent, "", Sel); + break; + } + case 608: // WHATIS + { + MeasureGUI_WhatisDlg *aDlg = new MeasureGUI_WhatisDlg(parent, "", Sel); + break; + } + case 609: // CHECKSHAPE + { + MeasureGUI_CheckShape *aDlg = new MeasureGUI_CheckShape(parent, "", Sel); + break; + } + default: + { + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + } + return true; +} + + +//===================================================================================== +// function : MakeCDGAndDisplay() +// purpose : +//===================================================================================== +void MeasureGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape) +{ + try { + GEOM::GEOM_Shape_var result = myGeom->MakeCDG(Shape); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_POINT")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} diff --git a/src/MeasureGUI/MeasureGUI.h b/src/MeasureGUI/MeasureGUI.h new file mode 100644 index 000000000..793dc9ce1 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI.h @@ -0,0 +1,56 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef MEASUREGUI_H +#define MEASUREGUI_H + +#include "GEOMBase_Context.h" + +//================================================================================= +// class : MeasureGUI +// purpose : +//================================================================================= +class MeasureGUI : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + MeasureGUI(); + ~MeasureGUI(); + + 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 */ + +}; + +#endif diff --git a/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx b/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx new file mode 100644 index 000000000..c86045907 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx @@ -0,0 +1,482 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_BndBoxDlg.cxx +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +using namespace std; +#include "MeasureGUI_BndBoxDlg.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : MeasureGUI_BndBoxDlg() +// purpose : Constructs a MeasureGUI_BndBoxDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +MeasureGUI_BndBoxDlg::MeasureGUI_BndBoxDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_BOUNDING_BOX"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "MeasureGUI_BndBoxDlg" ); + resize( 303, 275 ); + setCaption( tr( "GEOM_BNDBOX_TITLE" ) ); + setSizeGripEnabled( TRUE ); + MeasureGUI_BndBoxDlgLayout = new QGridLayout( this ); + MeasureGUI_BndBoxDlgLayout->setSpacing( 6 ); + MeasureGUI_BndBoxDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_BNDBOX" ) ); + 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)3, (QSizePolicy::SizeType)0, + Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 60, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + MeasureGUI_BndBoxDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); + GroupConstructor1->setTitle( tr( "GEOM_BNDBOX_OBJDIM" ) ); + GroupConstructor1->setColumnLayout(0, Qt::Vertical ); + GroupConstructor1->layout()->setSpacing( 0 ); + GroupConstructor1->layout()->setMargin( 0 ); + GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); + GroupConstructor1Layout->setAlignment( Qt::AlignTop ); + GroupConstructor1Layout->setSpacing( 6 ); + GroupConstructor1Layout->setMargin( 11 ); + LineEditC1A1 = new QLineEdit( GroupConstructor1, "LineEditC1A1" ); + LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) ); +// GroupConstructor1Layout->addWidget( LineEditC1A1, 0, 2 ); + SelectButtonC1A1 = new QPushButton( GroupConstructor1, "SelectButtonC1A1" ); + SelectButtonC1A1->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); +// GroupConstructor1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + + TextLabelC1A1 = new QLabel( GroupConstructor1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "GEOM_OBJECT" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); +// GroupConstructor1Layout->addWidget( TextLabelC1A1, 0, 0 ); + + QHBoxLayout* bl = new QHBoxLayout; + bl->setMargin(0); bl->setSpacing(6); + bl->addWidget(TextLabelC1A1); bl->addWidget(SelectButtonC1A1); bl->addWidget(LineEditC1A1); + GroupConstructor1Layout->addMultiCellLayout(bl, 0, 0, 0, 2); + + TextLabel_Min = new QLabel( GroupConstructor1, "TextLabel_Min" ); + TextLabel_Min->setText( tr( "GEOM_MIN" ) ); + TextLabel_Min->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Min->setFrameShape( QLabel::NoFrame ); + TextLabel_Min->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_Min, 1, 1 ); + + TextLabel_Max = new QLabel( GroupConstructor1, "TextLabel_Max" ); + TextLabel_Max->setText( tr( "GEOM_MAX" ) ); + TextLabel_Max->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Max->setFrameShape( QLabel::NoFrame ); + TextLabel_Max->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_Max, 1, 2 ); + + TextLabel_X = new QLabel( GroupConstructor1, "TextLabel_X" ); + TextLabel_X->setText( tr( "GEOM_X" ) ); + TextLabel_X->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_X->setFrameShape( QLabel::NoFrame ); + TextLabel_X->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_X, 2, 0 ); + LineEdit_MinX = new QLineEdit( GroupConstructor1, "LineEdit_MinX" ); + LineEdit_MinX->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, + LineEdit_MinX->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_MinX->setEnabled( FALSE ); + LineEdit_MinX->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_MinX, 2, 1 ); + LineEdit_MaxX = new QLineEdit( GroupConstructor1, "LineEdit_MaxX" ); + LineEdit_MaxX->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, + LineEdit_MaxX->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_MaxX->setEnabled( FALSE ); + LineEdit_MaxX->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_MaxX, 2, 2 ); + + TextLabel_Y = new QLabel( GroupConstructor1, "TextLabel_Y" ); + TextLabel_Y->setText( tr( "GEOM_Y" ) ); + TextLabel_Y->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Y->setFrameShape( QLabel::NoFrame ); + TextLabel_Y->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_Y, 3, 0 ); + LineEdit_MinY = new QLineEdit( GroupConstructor1, "LineEdit_MinY" ); + LineEdit_MinY->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, + LineEdit_MinY->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_MinY->setEnabled( FALSE ); + LineEdit_MinY->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_MinY, 3, 1 ); + LineEdit_MaxY = new QLineEdit( GroupConstructor1, "LineEdit_MaxY" ); + LineEdit_MaxY->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, + LineEdit_MaxY->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_MaxY->setEnabled( FALSE ); + LineEdit_MaxY->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_MaxY, 3, 2 ); + + TextLabel_Z = new QLabel( GroupConstructor1, "TextLabel_Z" ); + TextLabel_Z->setText( tr( "GEOM_Z" ) ); + TextLabel_Z->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Z->setFrameShape( QLabel::NoFrame ); + TextLabel_Z->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_Z, 4, 0 ); + LineEdit_MinZ = new QLineEdit( GroupConstructor1, "LineEdit_MinZ" ); + LineEdit_MinZ->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, + LineEdit_MinZ->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_MinZ->setEnabled( FALSE ); + LineEdit_MinZ->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_MinZ, 4, 1 ); + LineEdit_MaxZ = new QLineEdit( GroupConstructor1, "LineEdit_MaxZ" ); + LineEdit_MaxZ->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, + LineEdit_MaxZ->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_MaxZ->setEnabled( FALSE ); + LineEdit_MaxZ->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_MaxZ, 4, 2 ); + + MeasureGUI_BndBoxDlgLayout->addWidget( GroupConstructor1, 1, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 1 ); + + QSpacerItem* spacer_8 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_8, 0, 0 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + + MeasureGUI_BndBoxDlgLayout->addWidget( GroupButtons, 2, 0 ); + /***************************************************************/ + + Init(Sel) ; /* Initialisations */ +} + + +//================================================================================= +// function : ~MeasureGUI_BndBoxDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +MeasureGUI_BndBoxDlg::~MeasureGUI_BndBoxDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void MeasureGUI_BndBoxDlg::Init( SALOME_Selection* Sel ) +{ + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + 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); + + /* signals and slots connections */ + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + 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() ) ) ; + + mySimulationTopoDs.Nullify() ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void MeasureGUI_BndBoxDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void MeasureGUI_BndBoxDlg::ClickOnCancel() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void MeasureGUI_BndBoxDlg::SelectionIntoArgument() +{ + LineEdit_MinX->setText("") ; + LineEdit_MinY->setText("") ; + LineEdit_MinZ->setText("") ; + LineEdit_MaxX->setText("") ; + LineEdit_MaxY->setText("") ; + LineEdit_MaxZ->setText("") ; + myEditCurrentArgument->setText("") ; + mySimulationTopoDs.Nullify() ; + + QString aString = ""; /* future the name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) { + return ; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if( S.IsNull() ) { + myEditCurrentArgument->setText( "" ); + return ; + } + + LineEditC1A1->setText(aString) ; + this->CalculateAndDisplayBndBox(S) ; + + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void MeasureGUI_BndBoxDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void MeasureGUI_BndBoxDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + 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 ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void MeasureGUI_BndBoxDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupConstructor1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void MeasureGUI_BndBoxDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupConstructor1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void MeasureGUI_BndBoxDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void MeasureGUI_BndBoxDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +//================================================================================= +// function : CalculateAndDisplayBndBox() +// purpose : +//================================================================================= +void MeasureGUI_BndBoxDlg::CalculateAndDisplayBndBox(const TopoDS_Shape& S) +{ + LineEdit_MinX->setText("") ; + LineEdit_MinY->setText("") ; + LineEdit_MinZ->setText("") ; + LineEdit_MaxX->setText("") ; + LineEdit_MaxY->setText("") ; + LineEdit_MaxZ->setText("") ; + if( S.IsNull() ) + return ; + + Standard_Real axmin,aymin,azmin,axmax,aymax,azmax; + Bnd_Box B; + try { + BRepBndLib::Add(S,B); + B.Get(axmin,aymin,azmin,axmax,aymax,azmax); + LineEdit_MinX->setText( tr("%1").arg( axmin, 12, 'f', 6 ) ) ; + LineEdit_MinY->setText( tr("%1").arg( aymin, 12, 'f', 6 ) ) ; + LineEdit_MinZ->setText( tr("%1").arg( azmin, 12, 'f', 6 ) ) ; + LineEdit_MaxX->setText( tr("%1").arg( axmax, 12, 'f', 6 ) ) ; + LineEdit_MaxY->setText( tr("%1").arg( aymax, 12, 'f', 6 ) ) ; + LineEdit_MaxZ->setText( tr("%1").arg( azmax, 12, 'f', 6 ) ) ; + + mySimulationTopoDs = BRepPrimAPI_MakeBox( gp_Pnt(axmin,aymin,azmin), + gp_Pnt(axmax,aymax,azmax) ).Shape(); + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + } + catch(Standard_Failure) { + MESSAGE("Catch intercepted in CalculateAndDisplayBndBox()" << endl ) ; + } + return ; +} diff --git a/src/MeasureGUI/MeasureGUI_BndBoxDlg.h b/src/MeasureGUI/MeasureGUI_BndBoxDlg.h new file mode 100644 index 000000000..6649fe99b --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_BndBoxDlg.h @@ -0,0 +1,117 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_BndBoxDlg.h +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_BNDBOX_H +#define DIALOGBOX_BNDBOX_H + +#include "MeasureGUI.h" + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; + +//================================================================================= +// class : DialogBox_PROPERTIES +// purpose : +//================================================================================= +class MeasureGUI_BndBoxDlg : public QDialog +{ + Q_OBJECT + +public: + MeasureGUI_BndBoxDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~MeasureGUI_BndBoxDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void CalculateAndDisplayBndBox(const TopoDS_Shape& S) ; + + GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + TopoDS_Shape mySimulationTopoDs ; /* Shape used for simulation display */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupConstructor1; + QLineEdit* LineEditC1A1; + QPushButton* SelectButtonC1A1; + QLabel* TextLabelC1A1; + + QLabel* TextLabel_Min; + QLabel* TextLabel_Max; + + QLabel* TextLabel_X; + QLabel* TextLabel_Y; + QLabel* TextLabel_Z; + + QLineEdit* LineEdit_MinX; + QLineEdit* LineEdit_MinY; + QLineEdit* LineEdit_MinZ; + + QLineEdit* LineEdit_MaxX; + QLineEdit* LineEdit_MaxY; + QLineEdit* LineEdit_MaxZ; + + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnCancel(); + void SetEditCurrentArgument() ; + void LineEditReturnPressed() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* MeasureGUI_BndBoxDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupConstructor1Layout; + QGridLayout* GroupButtonsLayout; +}; + +#endif // DIALOGBOX_BNDBOX_H diff --git a/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx b/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx new file mode 100644 index 000000000..f61f4b3b6 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx @@ -0,0 +1,526 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_CenterMassDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "MeasureGUI_CenterMassDlg.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : MeasureGUI_CenterMassDlg() +// purpose : Constructs a MeasureGUI_CenterMassDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +MeasureGUI_CenterMassDlg::MeasureGUI_CenterMassDlg( QWidget* parent, const char* name, MeasureGUI* theMeasureGUI, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CENTERMASS"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "MeasureGUI_CenterMassDlg" ); + resize( 398, 219 ); + setCaption( tr( "GEOM_CMASS_TITLE" ) ); + setSizeGripEnabled( TRUE ); + MeasureGUI_CenterMassDlgLayout = new QGridLayout( this ); + MeasureGUI_CenterMassDlgLayout->setSpacing( 6 ); + MeasureGUI_CenterMassDlgLayout->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 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "GEOM_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + MeasureGUI_CenterMassDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_CMASS" ) ); + 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_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_2, 0, 1 ); + MeasureGUI_CenterMassDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_OBJECT_RESULT" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEdit_X = new QLineEdit( GroupC1, "LineEdit_X" ); + LineEdit_X->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_X->sizePolicy().hasHeightForWidth() ) ); + LineEdit_X->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_X->setEnabled( FALSE ); + LineEdit_X->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_X, 1, 2 ); + TextLabel_Z = new QLabel( GroupC1, "TextLabel_Z" ); + TextLabel_Z->setText( tr( "GEOM_Z" ) ); + TextLabel_Z->setMinimumSize( QSize( 15, 0 ) ); + TextLabel_Z->setFrameShape( QLabel::NoFrame ); + TextLabel_Z->setFrameShadow( QLabel::Plain ); + TextLabel_Z->setMaximumSize( QSize( 15, 32767 ) ); + GroupC1Layout->addWidget( TextLabel_Z, 1, 5 ); + LineEdit_Z = new QLineEdit( GroupC1, "LineEdit_Z" ); + LineEdit_Z->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_Z->sizePolicy().hasHeightForWidth() ) ); + LineEdit_Z->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_Z->setEnabled( FALSE ); + LineEdit_Z->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_Z, 1, 6 ); + 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 ); + LineEdit_Y = new QLineEdit( GroupC1, "LineEdit_Y" ); + LineEdit_Y->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_Y->sizePolicy().hasHeightForWidth() ) ); + LineEdit_Y->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_Y->setEnabled( FALSE ); + LineEdit_Y->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_Y, 1, 4 ); + TextLabel_Y = new QLabel( GroupC1, "TextLabel_Y" ); + TextLabel_Y->setText( tr( "GEOM_Y" ) ); + TextLabel_Y->setMinimumSize( QSize( 15, 0 ) ); + TextLabel_Y->setFrameShape( QLabel::NoFrame ); + TextLabel_Y->setFrameShadow( QLabel::Plain ); + TextLabel_Y->setMaximumSize( QSize( 15, 32767 ) ); + GroupC1Layout->addWidget( TextLabel_Y, 1, 3 ); + TextLabel_X = new QLabel( GroupC1, "TextLabel_X" ); + TextLabel_X->setText( tr( "GEOM_X" ) ); + TextLabel_X->setMinimumSize( QSize( 15, 0 ) ); + TextLabel_X->setFrameShape( QLabel::NoFrame ); + TextLabel_X->setFrameShadow( QLabel::Plain ); + TextLabel_X->setMaximumSize( QSize( 15, 32767 ) ); + GroupC1Layout->addWidget( TextLabel_X, 1, 1 ); + TextLabel_Center = new QLabel( GroupC1, "TextLabel_Center" ); + TextLabel_Center->setText( tr( "GEOM_CENTER" ) ); + TextLabel_Center->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Center->setFrameShape( QLabel::NoFrame ); + TextLabel_Center->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabel_Center, 1, 0 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + LineEditC1A1->setMinimumSize( QSize( 260, 0 ) ); + GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 2, 6 ); + MeasureGUI_CenterMassDlgLayout->addWidget( GroupC1, 1, 0 ); + /***************************************************************/ + myMeasureGUI = theMeasureGUI; + Init(Sel) ; /* Initialisations */ + +} + + +//================================================================================= +// function : ~MeasureGUI_CenterMassDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +MeasureGUI_CenterMassDlg::~MeasureGUI_CenterMassDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void MeasureGUI_CenterMassDlg::Init( SALOME_Selection* Sel ) +{ + LineEdit_X->setMaxLength( 9 ); + LineEdit_Y->setMaxLength( 9 ); + LineEdit_Z->setMaxLength( 9 ); + QDoubleValidator *Va = new QDoubleValidator( -999999, +999999, 3, LineEdit_X ) ; + QDoubleValidator *Vb = new QDoubleValidator( -999999, +999999, 3, LineEdit_Y ) ; + QDoubleValidator *Vc = new QDoubleValidator( -999999, +999999, 3, LineEdit_Z ) ; + LineEdit_X->setValidator( Va ) ; + LineEdit_Y->setValidator( Vb ) ; + LineEdit_Z->setValidator( Vc ) ; + + myConstructorId = 0 ; + + LineEdit_X->setText("") ; + LineEdit_Y->setText("") ; + LineEdit_Z->setText("") ; + + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySimulationTopoDs.Nullify() ; + myShape.Nullify() ; + myOkCenterMass = false ; + + // TODO : previous selection into argument ? + + /* Filter definitions */ + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); + + /* 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( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void MeasureGUI_CenterMassDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void MeasureGUI_CenterMassDlg::ClickOnCancel() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void MeasureGUI_CenterMassDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void MeasureGUI_CenterMassDlg::ClickOnApply() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + if( myOkCenterMass) { + myMeasureGUI->MakeCDGAndDisplay( myGeomShape ) ; + } + return ; +} + + + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void MeasureGUI_CenterMassDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape() ; + myEditCurrentArgument->setText("") ; + myOkCenterMass = false ; + Standard_Boolean testResult ; + + LineEdit_X->setText("") ; + LineEdit_Y->setText("") ; + LineEdit_Z->setText("") ; + + QString aString = ""; /* future the name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) { + return ; + } + + /* nbSel == 1 */ + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + if( !myGeomGUI->GetTopoFromSelection(mySelection, this->myShape) ) + return ; + + myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; + if( !testResult ) + return ; + myEditCurrentArgument->setText(aString) ; + if( this->CalculateAndDisplayCenterMass() ) { + myOkCenterMass = true ; + } + + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void MeasureGUI_CenterMassDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void MeasureGUI_CenterMassDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + 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 ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void MeasureGUI_CenterMassDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + myGeomGUI->EraseSimulationShape() ; + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void MeasureGUI_CenterMassDlg::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 ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void MeasureGUI_CenterMassDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void MeasureGUI_CenterMassDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +//================================================================================= +// function : CalculateAndDisplayCenterMass() +// purpose : +//================================================================================= +bool MeasureGUI_CenterMassDlg::CalculateAndDisplayCenterMass() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + try { + + QString resString; + GProp_GProps System; + + if ( this->myShape.ShapeType() == TopAbs_VERTEX) { + myGeomGUI->VertexToPoint( this->myShape, this->myCenterMass ); + } + else if ( this->myShape.ShapeType() == TopAbs_EDGE || this->myShape.ShapeType() == TopAbs_WIRE ) { + BRepGProp::LinearProperties(this->myShape, System); + this->myCenterMass = System.CentreOfMass() ; + } + else if ( this->myShape.ShapeType() == TopAbs_FACE || this->myShape.ShapeType() == TopAbs_SHELL ) { + BRepGProp::SurfaceProperties(this->myShape, System); + this->myCenterMass = System.CentreOfMass() ; + } + else { + BRepGProp::VolumeProperties(this->myShape, System); + this->myCenterMass = System.CentreOfMass() ; + } + + BRepBuilderAPI_MakeVertex V(this->myCenterMass) ; + mySimulationTopoDs = V.Shape() ; + + resString = tr("%1").arg( myCenterMass.X(), 12, 'f', 6 ) ; + LineEdit_X->setText(resString) ; + + resString = tr("%1").arg( myCenterMass.Y(), 12, 'f', 6 ) ; + LineEdit_Y->setText(resString) ; + + resString = tr("%1").arg( myCenterMass.Z(), 12, 'f', 6 ) ; + LineEdit_Z->setText(resString) ; + + + if( !mySimulationTopoDs.IsNull() ) { + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + return true ; + } + } + catch(Standard_Failure) { + MESSAGE("Catch intercepted in CalculateAndDisplayCenterMass()" << endl ) ; + } + return false ; +} + + diff --git a/src/MeasureGUI/MeasureGUI_CenterMassDlg.h b/src/MeasureGUI/MeasureGUI_CenterMassDlg.h new file mode 100644 index 000000000..75d553a58 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_CenterMassDlg.h @@ -0,0 +1,119 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_CenterMassDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM + +#ifndef DIALOGBOX_CMASS_H +#define DIALOGBOX_CMASS_H + +#include "MeasureGUI.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 : MeasureGUI_CenterMassDlg +// purpose : +//================================================================================= +class MeasureGUI_CenterMassDlg : public QDialog +{ + Q_OBJECT + +public: + MeasureGUI_CenterMassDlg( QWidget* parent = 0, const char* name = 0, MeasureGUI* theMeasureGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~MeasureGUI_CenterMassDlg(); + +private: + MeasureGUI* myMeasureGUI; + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + bool CalculateAndDisplayCenterMass() ; + + GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */ + + GEOM::GEOM_Shape_var myGeomShape ; /* is myBase */ + TopoDS_Shape myShape ; /* Shape argument */ + gp_Pnt myCenterMass ; + bool myOkCenterMass ; /* true after center of mass simulation calculation */ + + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupC1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEdit_X; + QLabel* TextLabel_Z; + QLineEdit* LineEdit_Z; + QLabel* TextLabelC1A1; + QLineEdit* LineEdit_Y; + QLabel* TextLabel_Y; + QLabel* TextLabel_X; + QLabel* TextLabel_Center; + QLineEdit* LineEditC1A1; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnCancel(); + void ClickOnOk() ; + void ClickOnApply(); + void SetEditCurrentArgument() ; + void LineEditReturnPressed() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* MeasureGUI_CenterMassDlgLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_CMASS_H diff --git a/src/MeasureGUI/MeasureGUI_CheckShape.cxx b/src/MeasureGUI/MeasureGUI_CheckShape.cxx new file mode 100644 index 000000000..d11fbb04f --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_CheckShape.cxx @@ -0,0 +1,397 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_CheckShape.cxx +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +using namespace std; +#include "MeasureGUI_CheckShape.h" + +// Open Cascade Include +#include + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : MeasureGUI_CheckShape() +// purpose : Constructs a MeasureGUI_CheckShape which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +MeasureGUI_CheckShape::MeasureGUI_CheckShape( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CHECKSHAPE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "DialogBox_CHECKSHAPE" ); + resize( 303, 275 ); + setCaption( tr( "GEOM_CHECK_TITLE" ) ); + setSizeGripEnabled( TRUE ); + MeasureGUI_CheckShapeLayout = new QGridLayout( this ); + MeasureGUI_CheckShapeLayout->setSpacing( 6 ); + MeasureGUI_CheckShapeLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_CHECK_SHAPE" ) ); + 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)3, (QSizePolicy::SizeType)0, + Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 60, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + MeasureGUI_CheckShapeLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); + GroupConstructor1->setTitle( tr( "GEOM_CHECK_INFOS") ); + GroupConstructor1->setColumnLayout(0, Qt::Vertical ); + GroupConstructor1->layout()->setSpacing( 0 ); + GroupConstructor1->layout()->setMargin( 0 ); + GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); + GroupConstructor1Layout->setAlignment( Qt::AlignTop ); + GroupConstructor1Layout->setSpacing( 6 ); + GroupConstructor1Layout->setMargin( 11 ); + LineEditC1A1 = new QLineEdit( GroupConstructor1, "LineEditC1A1" ); + LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) ); + GroupConstructor1Layout->addWidget( LineEditC1A1, 0, 2 ); + SelectButtonC1A1 = new QPushButton( GroupConstructor1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + GroupConstructor1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + TextLabelC1A1 = new QLabel( GroupConstructor1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "GEOM_OBJECTS" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabelC1A1, 0, 0 ); + + Text = new QTextView(GroupConstructor1); + Text->setTextFormat( Qt::PlainText ); + GroupConstructor1Layout->addMultiCellWidget( Text, 1, 1, 0, 2 ); + + MeasureGUI_CheckShapeLayout->addWidget( GroupConstructor1, 1, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 1 ); + // buttonApply = new QPushButton( GroupButtons, "buttonApply" ); +// buttonApply->setText( tr( "GEOM_BUT_APPLY" ) ); +// buttonApply->setAutoDefault( TRUE ); +// GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_8 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_8, 0, 0 ); + 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 ); + MeasureGUI_CheckShapeLayout->addWidget( GroupButtons, 2, 0 ); + /***************************************************************/ + + Init(Sel) ; /* Initialisations */ +} + + +//================================================================================= +// function : ~MeasureGUI_CheckShape() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +MeasureGUI_CheckShape::~MeasureGUI_CheckShape() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void MeasureGUI_CheckShape::Init( SALOME_Selection* Sel ) +{ + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + 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); + + /* signals and slots connections */ + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + + connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + SelectedName = ""; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void MeasureGUI_CheckShape::ConstructorsClicked(int constructorId) +{ + return ; +} + + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void MeasureGUI_CheckShape::ClickOnCancel() +{ + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void MeasureGUI_CheckShape::SelectionIntoArgument() +{ + Text->setText("") ; + myEditCurrentArgument->setText("") ; + + SelectedName = ""; /* future the name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, SelectedName) ; + if ( nbSel != 1 ) { + return ; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if( S.IsNull() ) { + myEditCurrentArgument->setText( "" ); + return ; + } + + LineEditC1A1->setText(SelectedName) ; + this->Check(S) ; + + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void MeasureGUI_CheckShape::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void MeasureGUI_CheckShape::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + 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 ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void MeasureGUI_CheckShape::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupConstructor1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void MeasureGUI_CheckShape::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupConstructor1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void MeasureGUI_CheckShape::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void MeasureGUI_CheckShape::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +//================================================================================= +// function : Check() +// purpose : +//================================================================================= +void MeasureGUI_CheckShape::Check(const TopoDS_Shape S) +{ + + if( S.IsNull() ) + return ; + + try { + BRepCheck_Analyzer ana(S,false); + if (ana.IsValid()) + Text->setText( "This Shape seems to be valid." ); + else + Text->setText( "This Shape is not valid." ); + } + catch(Standard_Failure) { + MESSAGE("Catch intercepted in Check()" << endl ) ; + } + return ; +} diff --git a/src/MeasureGUI/MeasureGUI_CheckShape.h b/src/MeasureGUI/MeasureGUI_CheckShape.h new file mode 100644 index 000000000..d68cf4969 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_CheckShape.h @@ -0,0 +1,106 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_CheckShape.h +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_CHECKSHAPE_H +#define DIALOGBOX_CHECKSHAPE_H + +#include "MeasureGUI.h" + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QTextView; + +//================================================================================= +// class : MeasureGUI_CheckShape +// purpose : +//================================================================================= +class MeasureGUI_CheckShape : public QDialog +{ + Q_OBJECT + +public: + MeasureGUI_CheckShape( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~MeasureGUI_CheckShape(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void Check(const TopoDS_Shape S) ; + + GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupConstructor1; + QLineEdit* LineEditC1A1; + QPushButton* SelectButtonC1A1; + QLabel* TextLabelC1A1; + + QTextView* Text; + QString SelectedName; + + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnCancel(); + void SetEditCurrentArgument() ; + void LineEditReturnPressed() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* MeasureGUI_CheckShapeLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupConstructor1Layout; + QGridLayout* GroupButtonsLayout; +}; + +#endif // DIALOGBOX_CHECKSHAPE_H diff --git a/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx b/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx new file mode 100644 index 000000000..0ad1bafee --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx @@ -0,0 +1,585 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_DistanceDlg.cxx +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +using namespace std; +#include "MeasureGUI_DistanceDlg.h" + +#include "QAD_RightFrame.h" + +#include "OCCViewer_Viewer3d.h" +#include "OCCViewer_ViewFrame.h" + +// Open CASCADE Includes +#include +#include +#include + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : MeasureGUI_DistanceDlg() +// purpose : Constructs a MeasureGUI_DistanceDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +MeasureGUI_DistanceDlg::MeasureGUI_DistanceDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_MINDIST"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "MeasureGUI_DistanceDlg" ); + resize( 322, 220 ); + setCaption( tr( "GEOM_MINDIST_TITLE" ) ); + setSizeGripEnabled( TRUE ); + + MeasureGUI_DistanceDlgLayout = new QGridLayout( this ); + MeasureGUI_DistanceDlgLayout->setSpacing( 6 ); + MeasureGUI_DistanceDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_DISTANCE" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + MeasureGUI_DistanceDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); + GroupConstructor1->setTitle( tr( "GEOM_MINDIST_OBJ" ) ); + GroupConstructor1->setColumnLayout(0, Qt::Vertical ); + GroupConstructor1->layout()->setSpacing( 0 ); + GroupConstructor1->layout()->setMargin( 0 ); + GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); + GroupConstructor1Layout->setAlignment( Qt::AlignTop ); + GroupConstructor1Layout->setSpacing( 6 ); + GroupConstructor1Layout->setMargin( 11 ); + LineEditC1A2Shape = new QLineEdit( GroupConstructor1, "LineEditC1A2Shape" ); + LineEditC1A2Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Shape->sizePolicy().hasHeightForWidth() ) ); + GroupConstructor1Layout->addWidget( LineEditC1A2Shape, 1, 2 ); + LineEditC1A1Shape = new QLineEdit( GroupConstructor1, "LineEditC1A1Shape" ); + LineEditC1A1Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Shape->sizePolicy().hasHeightForWidth() ) ); + GroupConstructor1Layout->addWidget( LineEditC1A1Shape, 0, 2 ); + SelectButtonC1A1Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A1Shape" ); + SelectButtonC1A1Shape->setText( tr( "" ) ); + SelectButtonC1A1Shape->setPixmap( image1 ); + GroupConstructor1Layout->addWidget( SelectButtonC1A1Shape, 0, 1 ); + SelectButtonC1A2Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A2Shape" ); + SelectButtonC1A2Shape->setText( tr( "" ) ); + SelectButtonC1A2Shape->setPixmap( image1 ); + GroupConstructor1Layout->addWidget( SelectButtonC1A2Shape, 1, 1 ); + TextLabelC1A2Shape = new QLabel( GroupConstructor1, "TextLabelC1A2Shape" ); + TextLabelC1A2Shape->setText( tr( "GEOM_OBJECT_I" ).arg("2") ); + TextLabelC1A2Shape->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A2Shape->setFrameShape( QLabel::NoFrame ); + TextLabelC1A2Shape->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabelC1A2Shape, 1, 0 ); + TextLabelC1A1Shape = new QLabel( GroupConstructor1, "TextLabelC1A1Shape" ); + TextLabelC1A1Shape->setText( tr( "GEOM_OBJECT_I" ).arg("1") ); + TextLabelC1A1Shape->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1Shape->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1Shape->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabelC1A1Shape, 0, 0 ); + MeasureGUI_DistanceDlgLayout->addWidget( GroupConstructor1, 1, 0 ); + + TextLabel_Length = new QLabel( GroupConstructor1, "TextLabel_Length" ); + TextLabel_Length->setText( tr( "GEOM_LENGTH" ) ); + TextLabel_Length->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Length->setFrameShape( QLabel::NoFrame ); + TextLabel_Length->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_Length, 2, 0 ); + LineEdit_Length = new QLineEdit( GroupConstructor1, "LineEdit_Length" ); + LineEdit_Length->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_Length->sizePolicy().hasHeightForWidth() ) ); + // LineEdit_Length->setEnabled( FALSE ); + LineEdit_Length->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_Length, 2, 2 ); + + /***************************************************************/ + 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 ); + MeasureGUI_DistanceDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /* Initialisation */ + Init( Sel ) ; +} + + +//================================================================================= +// function : ~MeasureGUI_DistanceDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +MeasureGUI_DistanceDlg::~MeasureGUI_DistanceDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ + this->destroy(TRUE, TRUE) ; +} + + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void MeasureGUI_DistanceDlg::Init( SALOME_Selection* Sel ) +{ + mySelection = Sel ; + myShape1.Nullify() ; + myShape2.Nullify() ; + myConstructorId = 0 ; + + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + + GroupConstructor1->show(); + myConstructorId = 0 ; + myEditCurrentArgument = LineEditC1A1Shape ; + Constructor1->setChecked( TRUE ); + myOkShape1 = myOkShape2 = false ; + + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); + + // TODO previous selection into argument ? + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect( SelectButtonC1A1Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC1A2Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( LineEditC1A1Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC1A2Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* Displays Dialog */ + + return ; +} + + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void MeasureGUI_DistanceDlg::ConstructorsClicked(int constructorId) +{ + EraseDistance(); + myGeomGUI->EraseSimulationShape() ; + + switch (constructorId) + { + case 0: + { + GroupConstructor1->show(); + myConstructorId = constructorId ; + myEditCurrentArgument = LineEditC1A1Shape ; + LineEditC1A2Shape->setText(tr("")) ; + Constructor1->setChecked( TRUE ); + myOkShape1 = myOkShape2 = false ; + break; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void MeasureGUI_DistanceDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void MeasureGUI_DistanceDlg::ClickOnApply() +{ + EraseDistance() ; + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + switch(myConstructorId) + { + case 0 : + { + if(myOkShape1 && myOkShape2) { + this->MakeDistanceSimulationAndDisplay(myShape1 ,myShape2) ; + } + break ; + } + } + + // accept(); + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void MeasureGUI_DistanceDlg::ClickOnCancel() +{ + EraseDistance() ; + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void MeasureGUI_DistanceDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + LineEdit_Length->setText("") ; + myEditCurrentArgument->setText("") ; /* by default */ + QString aString = ""; /* the name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) { + switch (myConstructorId) + { + case 0: + { + if ( myEditCurrentArgument == LineEditC1A1Shape ) { + myOkShape1 = false ; + } + else if ( myEditCurrentArgument == LineEditC1A2Shape ) { + myOkShape2 = false ; + } + break ; + } + } + return ; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + Standard_Boolean testResult ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if ( myEditCurrentArgument == LineEditC1A1Shape ) { + myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; + if( !testResult ) + return ; + myShape1 = S ; + LineEditC1A1Shape->setText(aString) ; + myOkShape1 = true ; + } + else if ( myEditCurrentArgument == LineEditC1A2Shape ) { + myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; + if( !testResult ) + return ; + myShape2 = S ; + LineEditC1A2Shape->setText(aString) ; + myOkShape2 = true ; + } + + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void MeasureGUI_DistanceDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if( send == SelectButtonC1A1Shape ) { + LineEditC1A1Shape->setFocus() ; + myEditCurrentArgument = LineEditC1A1Shape ; + } + else if(send == SelectButtonC1A2Shape) { + LineEditC1A2Shape->setFocus() ; + myEditCurrentArgument = LineEditC1A2Shape; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void MeasureGUI_DistanceDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1Shape ) + myEditCurrentArgument = LineEditC1A1Shape ; + else if ( send == LineEditC1A2Shape ) + myEditCurrentArgument = LineEditC1A2Shape ; + 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 ; +} + + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void MeasureGUI_DistanceDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + + GroupConstructors->setEnabled(false) ; + GroupConstructor1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + disconnect( mySelection, 0, this, 0 ); + } + return ; +} + + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void MeasureGUI_DistanceDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; /* same than click on cancel button */ +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void MeasureGUI_DistanceDlg::enterEvent( QEvent * ) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void MeasureGUI_DistanceDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate any active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupConstructor1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + if( !mySimulationTopoDs.IsNull() ) + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + + return ; +} + + + +//================================================================================= +// function : MakeDistanceSimulationAndDisplay() +// purpose : +//================================================================================= +void MeasureGUI_DistanceDlg::MakeDistanceSimulationAndDisplay(const TopoDS_Shape& S1, const TopoDS_Shape& S2) +{ + LineEdit_Length->setText("") ; + EraseDistance() ; + myGeomGUI->EraseSimulationShape() ; + + BRepExtrema_DistShapeShape dst( S1, S2 ); + if (dst.IsDone()) { + int i; + for (i=1; i<= dst.NbSolution(); i++) { + gp_Pnt P1,P2; + P1 = (dst.PointOnShape1(i)); + P2 = (dst.PointOnShape2(i)); + + Standard_Real Dist = P1.Distance(P2); + if (Dist<=1.e-9) { + BRepBuilderAPI_MakeVertex MakeVertex(P1); + mySimulationTopoDs = MakeVertex.Vertex(); + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + + LineEdit_Length->setText("0.0") ; + } else { + BRepBuilderAPI_MakeEdge MakeEdge(P1, P2); + mySimulationTopoDs = MakeEdge.Edge(); + + TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(P1); + TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(P2); + + QString S; + S.sprintf("%.1f",Dist); + Handle(AIS_LengthDimension) Distance = new AIS_LengthDimension (V1,V2, new Geom_Plane (0.,0.,1.,0.), + Dist, TCollection_ExtendedString(strdup(S))); + + LineEdit_Length->setText(S) ; + + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) + return ; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + ic->Display( Distance ); + ic->UpdateCurrentViewer(); + } + } + } else + myGeomGUI->GetDesktop()->putInfo( tr( "GEOM_PRP_MIN_DIST" ) ); +} + + +//================================================================================= +// function : EraseDistance() +// purpose : +//================================================================================= +void MeasureGUI_DistanceDlg::EraseDistance() +{ + int count = myGeomGUI->GetActiveStudy()->getStudyFramesCount(); + for ( int i = 0; i < count; i++ ) + if (myGeomGUI->GetActiveStudy()->getStudyFrame(i)->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + AIS_ListOfInteractive L; + ic->DisplayedObjects(AIS_KOI_Relation,-1,L); + AIS_ListIteratorOfListOfInteractive ite(L); + while (ite.More()) { + ic->Remove( ite.Value() ); + ic->UpdateCurrentViewer(); + ite.Next(); + } + } +} diff --git a/src/MeasureGUI/MeasureGUI_DistanceDlg.h b/src/MeasureGUI/MeasureGUI_DistanceDlg.h new file mode 100644 index 000000000..633a4919c --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_DistanceDlg.h @@ -0,0 +1,123 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_DistanceDlg.h +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_DISTANCE_H +#define DIALOGBOX_DISTANCE_H + +#include "MeasureGUI.h" + +#include +#include + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QFrame; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; + + +//================================================================================= +// class : MeasureGUI_DistanceDlg +// purpose : +//================================================================================= +class MeasureGUI_DistanceDlg : public QDialog +{ + Q_OBJECT + +public: + MeasureGUI_DistanceDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~MeasureGUI_DistanceDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void MakeDistanceSimulationAndDisplay( const TopoDS_Shape& S1, const TopoDS_Shape& S2 ) ; + void EraseDistance() ; + + GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + TopoDS_Shape myShape1 ; + TopoDS_Shape myShape2 ; + GEOM::GEOM_Shape_var myGeomShape1 ; + GEOM::GEOM_Shape_var myGeomShape2 ; + bool myOkShape1 ; + bool myOkShape2 ; /* to check when arguments are defined */ + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + + QGroupBox* GroupConstructor1; + QLineEdit* LineEditC1A1Shape; + QLineEdit* LineEditC1A2Shape; + QPushButton* SelectButtonC1A1Shape; + QPushButton* SelectButtonC1A2Shape; + QLabel* TextLabelC1A2Shape; + QLabel* TextLabelC1A1Shape; + + QLabel* TextLabel_Length; + QLineEdit* LineEdit_Length; + + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void LineEditReturnPressed() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* MeasureGUI_DistanceDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupConstructor1Layout; +}; + +#endif // DIALOGBOX_DISTANCE_H diff --git a/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx b/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx new file mode 100644 index 000000000..8978e941e --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx @@ -0,0 +1,564 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_InertiaDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM + +using namespace std; +#include "MeasureGUI_InertiaDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : MeasureGUI_InertiaDlg() +// purpose : Constructs a MeasureGUI_InertiaDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +MeasureGUI_InertiaDlg::MeasureGUI_InertiaDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_INERTIA"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "MeasureGUI_InertiaDlg" ); + resize( 356, 303 ); + setCaption( tr( "GEOM_INERTIA_TITLE" ) ); + setSizeGripEnabled( TRUE ); + MeasureGUI_InertiaDlgLayout = new QGridLayout( this ); + MeasureGUI_InertiaDlgLayout->setSpacing( 6 ); + MeasureGUI_InertiaDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_INERTIA_CONSTR" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + MeasureGUI_InertiaDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_OBJECT_RESULT" ) ); + 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 ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) ); + LineEditC1A1->setMinimumSize( QSize( 220, 0 ) ); + GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 2, 4 ); + TextLabel_Matrix = new QLabel( GroupC1, "TextLabel_Matrix" ); + TextLabel_Matrix->setText( tr( "GEOM_MATRIX" ) ); + TextLabel_Matrix->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Matrix->setFrameShape( QLabel::NoFrame ); + TextLabel_Matrix->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabel_Matrix, 1, 0 ); + TextLabelMatrix_11 = new QLabel( GroupC1, "TextLabelMatrix_11" ); + TextLabelMatrix_11->setText( tr( "GEOM_INERTIA_I" ).arg("1") ); + TextLabelMatrix_11->setMinimumSize( QSize( 0, 0 ) ); + TextLabelMatrix_11->setFrameShape( QLabel::NoFrame ); + TextLabelMatrix_11->setFrameShadow( QLabel::Plain ); + TextLabelMatrix_11->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + GroupC1Layout->addWidget( TextLabelMatrix_11, 1, 1 ); + TextLabelMatrix_21 = new QLabel( GroupC1, "TextLabelMatrix_21" ); + TextLabelMatrix_21->setText( tr( "GEOM_INERTIA_I" ).arg("2") ); + TextLabelMatrix_21->setMinimumSize( QSize( 0, 0 ) ); + TextLabelMatrix_21->setFrameShape( QLabel::NoFrame ); + TextLabelMatrix_21->setFrameShadow( QLabel::Plain ); + TextLabelMatrix_21->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + GroupC1Layout->addWidget( TextLabelMatrix_21, 2, 1 ); + TextLabelMatrix_31 = new QLabel( GroupC1, "TextLabelMatrix_31" ); + TextLabelMatrix_31->setText( tr( "GEOM_INERTIA_I" ).arg("3") ); + TextLabelMatrix_31->setMinimumSize( QSize( 0, 0 ) ); + TextLabelMatrix_31->setFrameShape( QLabel::NoFrame ); + TextLabelMatrix_31->setFrameShadow( QLabel::Plain ); + TextLabelMatrix_31->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + GroupC1Layout->addWidget( TextLabelMatrix_31, 3, 1 ); + LineEdit_L1C1 = new QLineEdit( GroupC1, "LineEdit_L1C1" ); + LineEdit_L1C1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L1C1->sizePolicy().hasHeightForWidth() ) ); + LineEdit_L1C1->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_L1C1->setEnabled( FALSE ); + LineEdit_L1C1->setReadOnly( TRUE ); + LineEdit_L1C1->setText( tr( "" ) ); + GroupC1Layout->addWidget( LineEdit_L1C1, 1, 2 ); + LineEdit_L1C2 = new QLineEdit( GroupC1, "LineEdit_L1C2" ); + LineEdit_L1C2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L1C2->sizePolicy().hasHeightForWidth() ) ); + LineEdit_L1C2->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_L1C2->setEnabled( FALSE ); + LineEdit_L1C2->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_L1C2, 1, 3 ); + LineEdit_L1C3 = new QLineEdit( GroupC1, "LineEdit_L1C3" ); + LineEdit_L1C3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L1C3->sizePolicy().hasHeightForWidth() ) ); + LineEdit_L1C3->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_L1C3->setEnabled( FALSE ); + LineEdit_L1C3->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_L1C3, 1, 4 ); + LineEdit_L2C1 = new QLineEdit( GroupC1, "LineEdit_L2C1" ); + LineEdit_L2C1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L2C1->sizePolicy().hasHeightForWidth() ) ); + LineEdit_L2C1->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_L2C1->setEnabled( FALSE ); + LineEdit_L2C1->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_L2C1, 2, 2 ); + LineEdit_L2C2 = new QLineEdit( GroupC1, "LineEdit_L2C2" ); + LineEdit_L2C2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L2C2->sizePolicy().hasHeightForWidth() ) ); + LineEdit_L2C2->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_L2C2->setEnabled( FALSE ); + LineEdit_L2C2->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_L2C2, 2, 3 ); + LineEdit_L2C3 = new QLineEdit( GroupC1, "LineEdit_L2C3" ); + LineEdit_L2C3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L2C3->sizePolicy().hasHeightForWidth() ) ); + LineEdit_L2C3->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_L2C3->setEnabled( FALSE ); + LineEdit_L2C3->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_L2C3, 2, 4 ); + LineEdit_L3C1 = new QLineEdit( GroupC1, "LineEdit_L3C1" ); + LineEdit_L3C1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L3C1->sizePolicy().hasHeightForWidth() ) ); + LineEdit_L3C1->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_L3C1->setEnabled( FALSE ); + LineEdit_L3C1->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_L3C1, 3, 2 ); + LineEdit_L3C2 = new QLineEdit( GroupC1, "LineEdit_L3C2" ); + LineEdit_L3C2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L3C2->sizePolicy().hasHeightForWidth() ) ); + LineEdit_L3C2->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_L3C2->setEnabled( FALSE ); + LineEdit_L3C2->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_L3C2, 3, 3 ); + LineEdit_L3C3 = new QLineEdit( GroupC1, "LineEdit_L3C3" ); + LineEdit_L3C3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L3C3->sizePolicy().hasHeightForWidth() ) ); + LineEdit_L3C3->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_L3C3->setEnabled( FALSE ); + LineEdit_L3C3->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_L3C3, 3, 4 ); + LineEdit_IX = new QLineEdit( GroupC1, "LineEdit_IX" ); + LineEdit_IX->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_IX->sizePolicy().hasHeightForWidth() ) ); + LineEdit_IX->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_IX->setEnabled( FALSE ); + LineEdit_IX->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_IX, 4, 2 ); + LineEdit_IY = new QLineEdit( GroupC1, "LineEdit_IY" ); + LineEdit_IY->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_IY->sizePolicy().hasHeightForWidth() ) ); + LineEdit_IY->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_IY->setEnabled( FALSE ); + LineEdit_IY->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_IY, 4, 3 ); + LineEdit_IZ = new QLineEdit( GroupC1, "LineEdit_IZ" ); + LineEdit_IZ->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_IZ->sizePolicy().hasHeightForWidth() ) ); + LineEdit_IZ->setMinimumSize( QSize( 70, 0 ) ); + //LineEdit_IZ->setEnabled( FALSE ); + LineEdit_IZ->setReadOnly( TRUE ); + GroupC1Layout->addWidget( LineEdit_IZ, 4, 4 ); + TextLabel_IXIYIZ = new QLabel( GroupC1, "TextLabel_IXIYIZ" ); + TextLabel_IXIYIZ->setText( tr( "GEOM_INERTIA_IXYZ" ) ); + TextLabel_IXIYIZ->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_IXIYIZ->setFrameShape( QLabel::NoFrame ); + TextLabel_IXIYIZ->setFrameShadow( QLabel::Plain ); + TextLabel_IXIYIZ->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + GroupC1Layout->addMultiCellWidget( TextLabel_IXIYIZ, 4, 4, 0, 1 ); + MeasureGUI_InertiaDlgLayout->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, 1 ); + + QSpacerItem* spacer_8 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_8, 0, 0 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + + MeasureGUI_InertiaDlgLayout->addWidget( GroupButtons, 2, 0 ); + /***************************************************************/ + + Init(Sel) ; /* Initialisations */ +} + + +//================================================================================= +// function : ~MeasureGUI_InertiaDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +MeasureGUI_InertiaDlg::~MeasureGUI_InertiaDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void MeasureGUI_InertiaDlg::Init( SALOME_Selection* Sel ) +{ + + LineEdit_L1C1->setMaxLength( 10 ); + LineEdit_L1C2->setMaxLength( 10 ); + LineEdit_L1C3->setMaxLength( 10 ); + LineEdit_L2C1->setMaxLength( 10 ); + LineEdit_L2C2->setMaxLength( 10 ); + LineEdit_L2C3->setMaxLength( 10 ); + LineEdit_L3C1->setMaxLength( 10 ); + LineEdit_L3C2->setMaxLength( 10 ); + LineEdit_L3C3->setMaxLength( 10 ); + + LineEdit_IX->setMaxLength( 10 ); + LineEdit_IY->setMaxLength( 10 ); + LineEdit_IZ->setMaxLength( 10 ); + + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + 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); + + /* signals and slots connections */ + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( GroupConstructors, SIGNAL(clicked(int) ), this, SLOT( ConstructorsClicked(int) ) ); + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + + /* to close dialog if study change */ + connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void MeasureGUI_InertiaDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void MeasureGUI_InertiaDlg::ClickOnCancel() +{ + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void MeasureGUI_InertiaDlg::SelectionIntoArgument() +{ + LineEdit_L1C1->setText("") ; + LineEdit_L1C2->setText("") ; + LineEdit_L1C3->setText("") ; + LineEdit_L2C1->setText("") ; + LineEdit_L2C2->setText("") ; + LineEdit_L2C3->setText("") ; + LineEdit_L3C1->setText("") ; + LineEdit_L3C2->setText("") ; + LineEdit_L3C3->setText("") ; + + LineEdit_IX->setText("") ; + LineEdit_IY->setText("") ; + LineEdit_IZ->setText("") ; + + myEditCurrentArgument->setText("") ; + QString aString = ""; /* future the name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) { + return ; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) || S.IsNull() ) + return ; + + LineEditC1A1->setText(aString) ; + this->CalculateAndDisplayInertia(S) ; + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void MeasureGUI_InertiaDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void MeasureGUI_InertiaDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + 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 MeasureGUI_InertiaDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void MeasureGUI_InertiaDlg::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() ) ); + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void MeasureGUI_InertiaDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void MeasureGUI_InertiaDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +//================================================================================= +// function : CalculateAndDisplayInertia() +// purpose : +//================================================================================= +void MeasureGUI_InertiaDlg::CalculateAndDisplayInertia(const TopoDS_Shape& S) +{ + LineEdit_L1C1->setText("") ; + LineEdit_L1C2->setText("") ; + LineEdit_L1C3->setText("") ; + LineEdit_L2C1->setText("") ; + LineEdit_L2C2->setText("") ; + LineEdit_L2C3->setText("") ; + LineEdit_L3C1->setText("") ; + LineEdit_L3C2->setText("") ; + LineEdit_L3C3->setText("") ; + + LineEdit_IX->setText("") ; + LineEdit_IY->setText("") ; + LineEdit_IZ->setText("") ; + + + if( S.IsNull() ) + return ; + + try { + + QString resString; + GProp_GProps System; + + if ( S.ShapeType() == TopAbs_VERTEX || S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE ) { + BRepGProp::LinearProperties(S, System); + } + else if ( S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL ) { + BRepGProp::SurfaceProperties(S, System); + } + else { + BRepGProp::VolumeProperties(S, System); + } + + gp_Mat I = System.MatrixOfInertia() ; + GProp_PrincipalProps Pr = System.PrincipalProperties(); + Standard_Real Ix,Iy,Iz; + Pr.Moments(Ix,Iy,Iz); + + /* matrix 3x3 */ + resString = tr("%1").arg( I(1,1), 12, 'f', 6 ) ; + LineEdit_L1C1->setText(resString) ; + resString = tr("%1").arg( I(1,2), 12, 'f', 6 ) ; + LineEdit_L1C2->setText(resString) ; + resString = tr("%1").arg( I(1,3), 12, 'f', 6 ) ; + LineEdit_L1C3->setText(resString) ; + + resString = tr("%1").arg( I(2,1), 12, 'f', 6 ) ; + LineEdit_L2C1->setText(resString) ; + resString = tr("%1").arg( I(2,2), 12, 'f', 6 ) ; + LineEdit_L2C2->setText(resString) ; + resString = tr("%1").arg( I(2,3), 12, 'f', 6 ) ; + LineEdit_L2C3->setText(resString) ; + + resString = tr("%1").arg( I(3,1), 12, 'f', 6 ) ; + LineEdit_L3C1->setText(resString) ; + resString = tr("%1").arg( I(3,2), 12, 'f', 6 ) ; + LineEdit_L3C2->setText(resString) ; + resString = tr("%1").arg( I(3,3), 12, 'f', 6 ) ; + LineEdit_L3C3->setText(resString) ; + + /* moments */ + resString = tr("%1").arg( Ix, 12, 'f', 6 ) ; + LineEdit_IX->setText(resString) ; + resString = tr("%1").arg( Ix, 12, 'f', 6 ) ; + LineEdit_IY->setText(resString) ; + resString = tr("%1").arg( Iz, 12, 'f', 6 ) ; + LineEdit_IZ->setText(resString) ; + + } + catch(Standard_Failure) { + MESSAGE("Catch intercepted in CalculateAndDisplayInertia()" << endl ) ; + } + return ; +} + + diff --git a/src/MeasureGUI/MeasureGUI_InertiaDlg.h b/src/MeasureGUI/MeasureGUI_InertiaDlg.h new file mode 100644 index 000000000..882c6c84b --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_InertiaDlg.h @@ -0,0 +1,122 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_InertiaDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_INERTIA_H +#define DIALOGBOX_INERTIA_H + +#include "MeasureGUI.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 : MeasureGUI_InertiaDlg +// purpose : +//================================================================================= +class MeasureGUI_InertiaDlg : public QDialog +{ + Q_OBJECT + +public: + MeasureGUI_InertiaDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~MeasureGUI_InertiaDlg(); + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void CalculateAndDisplayInertia(const TopoDS_Shape& S) ; + + GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; + + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + QLabel* TextLabel_Matrix; + QLabel* TextLabelMatrix_11; + QLabel* TextLabelMatrix_21; + QLabel* TextLabelMatrix_31; + QLineEdit* LineEdit_L1C1; + QLineEdit* LineEdit_L1C2; + QLineEdit* LineEdit_L1C3; + QLineEdit* LineEdit_L2C1; + QLineEdit* LineEdit_L2C2; + QLineEdit* LineEdit_L2C3; + QLineEdit* LineEdit_L3C1; + QLineEdit* LineEdit_L3C2; + QLineEdit* LineEdit_L3C3; + QLineEdit* LineEdit_IX; + QLineEdit* LineEdit_IY; + QLineEdit* LineEdit_IZ; + QLabel* TextLabel_IXIYIZ; + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnCancel(); + void SetEditCurrentArgument() ; + void LineEditReturnPressed() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* MeasureGUI_InertiaDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; + QGridLayout* GroupButtonsLayout; +}; + +#endif // DIALOGBOX_INERTIA_H diff --git a/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx new file mode 100644 index 000000000..40fcc7da0 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx @@ -0,0 +1,542 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_MaxToleranceDlg.cxx +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +using namespace std; +#include "MeasureGUI_MaxToleranceDlg.h" + +// Open CASCADE Includes +#include +#include + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +//================================================================================= +// class : MeasureGUI_MaxToleranceDlg() +// purpose : Constructs a MeasureGUI_MaxToleranceDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +MeasureGUI_MaxToleranceDlg::MeasureGUI_MaxToleranceDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_TOLERANCE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "MeasureGUI_MaxToleranceDlg" ); + resize( 303, 275 ); + setCaption( tr( "GEOM_TOLERANCE_TITLE" ) ); + setSizeGripEnabled( TRUE ); + MeasureGUI_MaxToleranceDlgLayout = new QGridLayout( this ); + MeasureGUI_MaxToleranceDlgLayout->setSpacing( 6 ); + MeasureGUI_MaxToleranceDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_TOLERANCE" ) ); + 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)3, (QSizePolicy::SizeType)0, + Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 60, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + MeasureGUI_MaxToleranceDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); + GroupConstructor1->setTitle( tr( "GEOM_TOLERANCE_CONSTR" ) ); + GroupConstructor1->setColumnLayout(0, Qt::Vertical ); + GroupConstructor1->layout()->setSpacing( 0 ); + GroupConstructor1->layout()->setMargin( 0 ); + GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); + GroupConstructor1Layout->setAlignment( Qt::AlignTop ); + GroupConstructor1Layout->setSpacing( 6 ); + GroupConstructor1Layout->setMargin( 11 ); + + LineEditC1A1 = new QLineEdit( GroupConstructor1, "LineEditC1A1" ); + LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) ); +// GroupConstructor1Layout->addWidget( LineEditC1A1, 0, 2 ); + SelectButtonC1A1 = new QPushButton( GroupConstructor1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); +// GroupConstructor1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + TextLabelC1A1 = new QLabel( GroupConstructor1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "GEOM_OBJECT" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); +// GroupConstructor1Layout->addWidget( TextLabelC1A1, 0, 0 ); + + QHBoxLayout* bl = new QHBoxLayout; + bl->setMargin(0); bl->setSpacing(6); + bl->addWidget(TextLabelC1A1); bl->addWidget(SelectButtonC1A1); bl->addWidget(LineEditC1A1); + GroupConstructor1Layout->addMultiCellLayout(bl, 0, 0, 0, 2); + + TextLabel_Min = new QLabel( GroupConstructor1, "TextLabel_Min" ); + TextLabel_Min->setText( tr( "GEOM_MIN" ) ); + TextLabel_Min->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Min->setFrameShape( QLabel::NoFrame ); + TextLabel_Min->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_Min, 1, 1 ); + + TextLabel_Max = new QLabel( GroupConstructor1, "TextLabel_Max" ); + TextLabel_Max->setText( tr( "GEOM_MAX" ) ); + TextLabel_Max->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Max->setFrameShape( QLabel::NoFrame ); + TextLabel_Max->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_Max, 1, 2 ); + + TextLabel_Face = new QLabel( GroupConstructor1, "TextLabel_Face" ); + TextLabel_Face->setText( tr( "GEOM_TOLERANCE_FACE" ) ); + TextLabel_Face->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Face->setFrameShape( QLabel::NoFrame ); + TextLabel_Face->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_Face, 2, 0 ); + LineEdit_MinFace = new QLineEdit( GroupConstructor1, "LineEdit_MinFace" ); + LineEdit_MinFace->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, + LineEdit_MinFace->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_MinFace->setEnabled( FALSE ); + LineEdit_MinFace->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_MinFace, 2, 1 ); + LineEdit_MaxFace = new QLineEdit( GroupConstructor1, "LineEdit_MaxFace" ); + LineEdit_MaxFace->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, + LineEdit_MaxFace->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_MaxFace->setEnabled( FALSE ); + LineEdit_MaxFace->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_MaxFace, 2, 2 ); + + TextLabel_Edge = new QLabel( GroupConstructor1, "TextLabel_Edge" ); + TextLabel_Edge->setText( tr( "GEOM_TOLERANCE_EDGE" ) ); + TextLabel_Edge->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Edge->setFrameShape( QLabel::NoFrame ); + TextLabel_Edge->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_Edge, 3, 0 ); + LineEdit_MinEdge = new QLineEdit( GroupConstructor1, "LineEdit_MinEdge" ); + LineEdit_MinEdge->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, + LineEdit_MinEdge->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_MinEdge->setEnabled( FALSE ); + LineEdit_MinEdge->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_MinEdge, 3, 1 ); + LineEdit_MaxEdge = new QLineEdit( GroupConstructor1, "LineEdit_MaxEdge" ); + LineEdit_MaxEdge->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, + LineEdit_MaxEdge->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_MaxEdge->setEnabled( FALSE ); + LineEdit_MaxEdge->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_MaxEdge, 3, 2 ); + + TextLabel_Vertex = new QLabel( GroupConstructor1, "TextLabel_Vertex" ); + TextLabel_Vertex->setText( tr( "GEOM_TOLERANCE_VERTEX" ) ); + TextLabel_Vertex->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Vertex->setFrameShape( QLabel::NoFrame ); + TextLabel_Vertex->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_Vertex, 4, 0 ); + LineEdit_MinVertex = new QLineEdit( GroupConstructor1, "LineEdit_MinVertex" ); + LineEdit_MinVertex->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, + LineEdit_MinVertex->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_MinVertex->setEnabled( FALSE ); + LineEdit_MinVertex->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_MinVertex, 4, 1 ); + LineEdit_MaxVertex = new QLineEdit( GroupConstructor1, "LineEdit_MaxVertex" ); + LineEdit_MaxVertex->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, + LineEdit_MaxVertex->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_MaxVertex->setEnabled( FALSE ); + LineEdit_MaxVertex->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_MaxVertex, 4, 2 ); + + MeasureGUI_MaxToleranceDlgLayout->addWidget( GroupConstructor1, 1, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 1 ); + // buttonApply = new QPushButton( GroupButtons, "buttonApply" ); +// buttonApply->setText( tr( "GEOM_BUT_APPLY" ) ); +// buttonApply->setAutoDefault( TRUE ); +// GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_8 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_8, 0, 0 ); + 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 ); + MeasureGUI_MaxToleranceDlgLayout->addWidget( GroupButtons, 2, 0 ); + /***************************************************************/ + + Init(Sel) ; /* Initialisations */ +} + + +//================================================================================= +// function : ~MeasureGUI_MaxToleranceDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +MeasureGUI_MaxToleranceDlg::~MeasureGUI_MaxToleranceDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void MeasureGUI_MaxToleranceDlg::Init( SALOME_Selection* Sel ) +{ + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + 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); + + /* signals and slots connections */ + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + + connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void MeasureGUI_MaxToleranceDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void MeasureGUI_MaxToleranceDlg::ClickOnCancel() +{ + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void MeasureGUI_MaxToleranceDlg::SelectionIntoArgument() +{ + LineEdit_MinFace->setText("") ; + LineEdit_MinEdge->setText("") ; + LineEdit_MinVertex->setText("") ; + LineEdit_MaxFace->setText("") ; + LineEdit_MaxEdge->setText("") ; + LineEdit_MaxVertex->setText("") ; + myEditCurrentArgument->setText("") ; + + QString aString = ""; /* future the name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) { + return ; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if( S.IsNull() ) { + myEditCurrentArgument->setText( "" ); + return ; + } + + LineEditC1A1->setText(aString) ; + this->CalculateMaxTolerance(S) ; + + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void MeasureGUI_MaxToleranceDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void MeasureGUI_MaxToleranceDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + 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 ; +} + + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void MeasureGUI_MaxToleranceDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupConstructor1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void MeasureGUI_MaxToleranceDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupConstructor1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void MeasureGUI_MaxToleranceDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void MeasureGUI_MaxToleranceDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +//================================================================================= +// function : CalculateMaxTolerance() +// purpose : +//================================================================================= +void MeasureGUI_MaxToleranceDlg::CalculateMaxTolerance(const TopoDS_Shape& S) +{ + LineEdit_MinFace->setText("") ; + LineEdit_MinEdge->setText("") ; + LineEdit_MinVertex->setText("") ; + LineEdit_MaxFace->setText("") ; + LineEdit_MaxEdge->setText("") ; + LineEdit_MaxVertex->setText("") ; + if( S.IsNull() ) + return ; + + Standard_Real T,TMF,TME,TMV,TmF,TmE,TmV; + Standard_Integer nbF,nbE,nbV; + TMF=TME=TMV=-RealLast(); + TmF=TmE=TmV=RealLast(); + nbF=nbE=nbV=0; + + bool m_isFace = false; + bool m_isEdge = false; + bool m_isVertex = false; + try + { + for( TopExp_Explorer ExF(S,TopAbs_FACE); ExF.More(); ExF.Next() ) + { + m_isFace = true; + TopoDS_Face Face=TopoDS::Face(ExF.Current()); + T=BRep_Tool::Tolerance(Face); + if(T>TMF) TMF=T; + if(TTME) TME=T; + if(TTMV) TMV=T; + if(TsetText( tr("%1").arg( TmF, 5, 'e', 8 ) ) ; + LineEdit_MaxFace->setText( tr("%1").arg( TMF, 5, 'e', 8 ) ) ; + } + else + { + LineEdit_MinFace->setText( "" ) ; + LineEdit_MaxFace->setText( "" ) ; + } + if (m_isEdge) + { + LineEdit_MinEdge->setText( tr("%1").arg( TmE, 5, 'e', 8 ) ) ; + LineEdit_MaxEdge->setText( tr("%1").arg( TME, 5, 'e', 8 ) ) ; + } + else + { + LineEdit_MinEdge->setText( "" ) ; + LineEdit_MaxEdge->setText( "" ) ; + } + if (m_isVertex) + { + LineEdit_MinVertex->setText( tr("%1").arg( TmV, 5, 'e', 8 ) ) ; + LineEdit_MaxVertex->setText( tr("%1").arg( TMV, 5, 'e', 8 ) ) ; + } + else + { + LineEdit_MinVertex->setText( "" ) ; + LineEdit_MaxVertex->setText( "" ) ; + } + } + catch(Standard_Failure) + { + MESSAGE("Catch intercepted in CalculateMaxTolerance()" << endl ) ; + } + return ; +} diff --git a/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.h b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.h new file mode 100644 index 000000000..fddd69202 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.h @@ -0,0 +1,117 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_MaxToleranceDlg.h +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_MAXTOLERANCE_H +#define DIALOGBOX_MAXTOLERANCE_H + +#include "MeasureGUI.h" + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; + +//================================================================================= +// class : DialogBox_PROPERTIES +// purpose : +//================================================================================= +class MeasureGUI_MaxToleranceDlg : public QDialog +{ + Q_OBJECT + +public: + MeasureGUI_MaxToleranceDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~MeasureGUI_MaxToleranceDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void CalculateMaxTolerance(const TopoDS_Shape& S) ; + + GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupConstructor1; + QLineEdit* LineEditC1A1; + QPushButton* SelectButtonC1A1; + QLabel* TextLabelC1A1; + + QLabel* TextLabel_Min; + QLabel* TextLabel_Max; + + QLabel* TextLabel_Face; + QLabel* TextLabel_Edge; + QLabel* TextLabel_Vertex; + + QLineEdit* LineEdit_MinFace; + QLineEdit* LineEdit_MinEdge; + QLineEdit* LineEdit_MinVertex; + + QLineEdit* LineEdit_MaxFace; + QLineEdit* LineEdit_MaxEdge; + QLineEdit* LineEdit_MaxVertex; + + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnCancel(); + void SetEditCurrentArgument() ; + void LineEditReturnPressed() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* MeasureGUI_MaxToleranceDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupConstructor1Layout; + QGridLayout* GroupButtonsLayout; +}; + +#endif // DIALOGBOX_MAXTOLERANCE_H diff --git a/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx b/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx new file mode 100644 index 000000000..bac538107 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx @@ -0,0 +1,462 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_PropertiesDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "MeasureGUI_PropertiesDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +//================================================================================= +// class : MeasureGUI_PropertiesDlg() +// purpose : Constructs a MeasureGUI_PropertiesDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_BASICPROPERTIES"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "MeasureGUI_PropertiesDlg" ); + resize( 303, 275 ); + setCaption( tr( "GEOM_PROPERTIES_TITLE" ) ); + setSizeGripEnabled( TRUE ); + MeasureGUI_PropertiesDlgLayout = new QGridLayout( this ); + MeasureGUI_PropertiesDlgLayout->setSpacing( 6 ); + MeasureGUI_PropertiesDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_PROPERTIES" ) ); + 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)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 60, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + MeasureGUI_PropertiesDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); + GroupConstructor1->setTitle( tr( "GEOM_PROPERTIES_CONSTR" ) ); + GroupConstructor1->setColumnLayout(0, Qt::Vertical ); + GroupConstructor1->layout()->setSpacing( 0 ); + GroupConstructor1->layout()->setMargin( 0 ); + GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); + GroupConstructor1Layout->setAlignment( Qt::AlignTop ); + GroupConstructor1Layout->setSpacing( 6 ); + GroupConstructor1Layout->setMargin( 11 ); + LineEditC1A1 = new QLineEdit( GroupConstructor1, "LineEditC1A1" ); + LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) ); + GroupConstructor1Layout->addWidget( LineEditC1A1, 0, 2 ); + SelectButtonC1A1 = new QPushButton( GroupConstructor1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + GroupConstructor1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + TextLabelC1A1 = new QLabel( GroupConstructor1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "GEOM_OBJECT" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabelC1A1, 0, 0 ); + TextLabel_Length = new QLabel( GroupConstructor1, "TextLabel_Length" ); + TextLabel_Length->setText( tr( "GEOM_LENGTH" ) ); + TextLabel_Length->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Length->setFrameShape( QLabel::NoFrame ); + TextLabel_Length->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_Length, 1, 0 ); + LineEdit_Length = new QLineEdit( GroupConstructor1, "LineEdit_Length" ); + LineEdit_Length->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_Length->sizePolicy().hasHeightForWidth() ) ); + // LineEdit_Length->setEnabled( FALSE ); + LineEdit_Length->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_Length, 1, 2 ); + LineEdit_Surface = new QLineEdit( GroupConstructor1, "LineEdit_Surface" ); + LineEdit_Surface->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_Surface->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_Surface->setEnabled( FALSE ); + LineEdit_Surface->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_Surface, 2, 2 ); + TextLabel_Surface = new QLabel( GroupConstructor1, "TextLabel_Surface" ); + TextLabel_Surface->setText( tr( "GEOM_PROPERTIES_SURFACE" ) ); + TextLabel_Surface->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Surface->setFrameShape( QLabel::NoFrame ); + TextLabel_Surface->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_Surface, 2, 0 ); + TextLabel_Volume = new QLabel( GroupConstructor1, "TextLabel_Volume" ); + TextLabel_Volume->setText( tr( "GEOM_PROPERTIES_VOLUME" ) ); + TextLabel_Volume->setMinimumSize( QSize( 50, 0 ) ); + TextLabel_Volume->setFrameShape( QLabel::NoFrame ); + TextLabel_Volume->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabel_Volume, 3, 0 ); + LineEdit_Volume = new QLineEdit( GroupConstructor1, "LineEdit_Volume" ); + LineEdit_Volume->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_Volume->sizePolicy().hasHeightForWidth() ) ); + //LineEdit_Volume->setEnabled( FALSE ); + LineEdit_Volume->setReadOnly( TRUE ); + GroupConstructor1Layout->addWidget( LineEdit_Volume, 3, 2 ); + MeasureGUI_PropertiesDlgLayout->addWidget( GroupConstructor1, 1, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 1 ); + + QSpacerItem* spacer_8 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_8, 0, 0 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + + MeasureGUI_PropertiesDlgLayout->addWidget( GroupButtons, 2, 0 ); + /***************************************************************/ + + Init(Sel) ; /* Initialisations */ +} + + +//================================================================================= +// function : ~MeasureGUI_PropertiesDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +MeasureGUI_PropertiesDlg::~MeasureGUI_PropertiesDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void MeasureGUI_PropertiesDlg::Init( SALOME_Selection* Sel ) +{ + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + 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); + + /* signals and slots connections */ + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + + connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void MeasureGUI_PropertiesDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void MeasureGUI_PropertiesDlg::ClickOnCancel() +{ + myGeomGUI->EraseSimulationShape() ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->EraseSimulationShape() ; + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void MeasureGUI_PropertiesDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + LineEdit_Length->setText("") ; + LineEdit_Surface->setText("") ; + LineEdit_Volume->setText("") ; + myEditCurrentArgument->setText("") ; + + QString aString = ""; /* future the name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) { + return ; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if( S.IsNull() || S.ShapeType() == TopAbs_VERTEX ) { + myEditCurrentArgument->setText( "" ); + return ; + } + + LineEditC1A1->setText(aString) ; + + /* Try to display of a cone simulation shape to show direction of a linear edge only in OCC viewer */ + if( myGeomGUI->CreateArrowForLinearEdge( S, mySimulationTopoDs ) ) { + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + } + this->CalculateAndDisplayProperties(S) ; + + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void MeasureGUI_PropertiesDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void MeasureGUI_PropertiesDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + 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 ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void MeasureGUI_PropertiesDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupConstructor1->setEnabled(false) ; + myGeomGUI->EraseSimulationShape() ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void MeasureGUI_PropertiesDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupConstructor1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + if( !mySimulationTopoDs.IsNull() ) + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void MeasureGUI_PropertiesDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void MeasureGUI_PropertiesDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +//================================================================================= +// function : CalculateAndDisplayProperties() +// purpose : +//================================================================================= +void MeasureGUI_PropertiesDlg::CalculateAndDisplayProperties(const TopoDS_Shape& S) +{ + LineEdit_Length->setText("") ; + LineEdit_Surface->setText("") ; + LineEdit_Volume->setText("") ; + if( S.IsNull() ) + return ; + + Standard_Real result; + GProp_GProps LProps; + GProp_GProps SProps; + QString resString; + + try + { + BRepGProp::LinearProperties(S,LProps); + result = LProps.Mass(); + if (!IsEqual( result, 0.0)) + { + resString = tr("%1").arg( result, 12, 'f', 6 ) ; + LineEdit_Length->setText(resString) ; + } + + BRepGProp::SurfaceProperties(S, SProps); + result = SProps.Mass(); + if (!IsEqual( result, 0.0)) + { + resString = tr("%1").arg( result, 12, 'f', 6 ) ; + LineEdit_Surface->setText(resString) ; + } + + result = 0.0; + if (S.ShapeType() < TopAbs_SHELL) + { + for( TopExp_Explorer Exp(S,TopAbs_SOLID); Exp.More(); Exp.Next() ) + { + GProp_GProps VProps; + BRepGProp::VolumeProperties(Exp.Current(), VProps); + result += VProps.Mass(); + } + } + if (!IsEqual( result, 0.0 )) + { + resString = tr("%1").arg( result, 12, 'f', 6 ) ; + LineEdit_Volume->setText(resString) ; + } + } + catch(Standard_Failure) + { + MESSAGE("Catch intercepted in CalculateAndDisplayProperties()" << endl ) ; + } + return ; +} diff --git a/src/MeasureGUI/MeasureGUI_PropertiesDlg.h b/src/MeasureGUI/MeasureGUI_PropertiesDlg.h new file mode 100644 index 000000000..569ee8fe5 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_PropertiesDlg.h @@ -0,0 +1,115 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_PropertiesDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM + +#ifndef DIALOGBOX_PROPERTIES_H +#define DIALOGBOX_PROPERTIES_H + +#include "MeasureGUI.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 MeasureGUI; + +//================================================================================= +// class : MeasureGUI_PropertiesDlg +// purpose : +//================================================================================= +class MeasureGUI_PropertiesDlg : public QDialog +{ + Q_OBJECT + +public: + MeasureGUI_PropertiesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~MeasureGUI_PropertiesDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void CalculateAndDisplayProperties(const TopoDS_Shape& S) ; + + GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + TopoDS_Shape mySimulationTopoDs ; /* Shape used for simulation display */ + + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupConstructor1; + QLineEdit* LineEditC1A1; + QPushButton* SelectButtonC1A1; + QLabel* TextLabelC1A1; + + QLabel* TextLabel_Length; + QLabel* TextLabel_Surface; + QLabel* TextLabel_Volume; + + QLineEdit* LineEdit_Length; + QLineEdit* LineEdit_Surface; + QLineEdit* LineEdit_Volume; + + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnCancel(); + void SetEditCurrentArgument() ; + void LineEditReturnPressed() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* MeasureGUI_PropertiesDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupConstructor1Layout; + QGridLayout* GroupButtonsLayout; +}; + +#endif // DIALOGBOX_PROPERTIES_H diff --git a/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx b/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx new file mode 100644 index 000000000..88e892f12 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx @@ -0,0 +1,444 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_WhatisDlg.cxx +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +using namespace std; +#include "MeasureGUI_WhatisDlg.h" + +// Open CASCADE Includes +//#include +#include +#include +#include +#include + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +//================================================================================= +// class : MeasureGUI_WhatisDlg() +// purpose : Constructs a MeasureGUI_WhatisDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +MeasureGUI_WhatisDlg::MeasureGUI_WhatisDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_WHATIS"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "MeasureGUI_WhatisDlg" ); + resize( 303, 275 ); + setCaption( tr( "GEOM_WHATIS_TITLE" ) ); + setSizeGripEnabled( TRUE ); + MeasureGUI_WhatisDlgLayout = new QGridLayout( this ); + MeasureGUI_WhatisDlgLayout->setSpacing( 6 ); + MeasureGUI_WhatisDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_WHATIS" ) ); + 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)3, (QSizePolicy::SizeType)0, + Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 60, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + MeasureGUI_WhatisDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); + GroupConstructor1->setTitle( tr( "GEOM_WHATIS_OBJECT" ) ); + GroupConstructor1->setColumnLayout(0, Qt::Vertical ); + GroupConstructor1->layout()->setSpacing( 0 ); + GroupConstructor1->layout()->setMargin( 0 ); + GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); + GroupConstructor1Layout->setAlignment( Qt::AlignTop ); + GroupConstructor1Layout->setSpacing( 6 ); + GroupConstructor1Layout->setMargin( 11 ); + LineEditC1A1 = new QLineEdit( GroupConstructor1, "LineEditC1A1" ); + LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) ); + GroupConstructor1Layout->addWidget( LineEditC1A1, 0, 2 ); + SelectButtonC1A1 = new QPushButton( GroupConstructor1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + GroupConstructor1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + TextLabelC1A1 = new QLabel( GroupConstructor1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "GEOM_OBJECT" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabelC1A1, 0, 0 ); + + Text = new QTextView(GroupConstructor1); + Text->setTextFormat( Qt::PlainText ); + GroupConstructor1Layout->addMultiCellWidget( Text, 1, 1, 0, 2 ); + + MeasureGUI_WhatisDlgLayout->addWidget( GroupConstructor1, 1, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 1 ); + + QSpacerItem* spacer_8 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_8, 0, 0 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + + MeasureGUI_WhatisDlgLayout->addWidget( GroupButtons, 2, 0 ); + /***************************************************************/ + + Init(Sel) ; /* Initialisations */ +} + + +//================================================================================= +// function : ~MeasureGUI_WhatisDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +MeasureGUI_WhatisDlg::~MeasureGUI_WhatisDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void MeasureGUI_WhatisDlg::Init( SALOME_Selection* Sel ) +{ + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + 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); + + /* signals and slots connections */ + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + + connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + SelectedName = ""; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void MeasureGUI_WhatisDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void MeasureGUI_WhatisDlg::ClickOnCancel() +{ + myGeomGUI->EraseSimulationShape() ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void MeasureGUI_WhatisDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + Text->setText("") ; + myEditCurrentArgument->setText("") ; + + SelectedName = ""; /* future the name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, SelectedName) ; + if ( nbSel != 1 ) { + return ; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if( S.IsNull() ) { + myEditCurrentArgument->setText( "" ); + return ; + } + + /* Try to display of a cone simulation shape to show direction of a linear edge only in OCC viewer */ + if( myGeomGUI->CreateArrowForLinearEdge( S, mySimulationTopoDs ) ) { + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + } + LineEditC1A1->setText(SelectedName) ; + this->CalculateWhatis(S) ; + + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void MeasureGUI_WhatisDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void MeasureGUI_WhatisDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + 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 ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void MeasureGUI_WhatisDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupConstructor1->setEnabled(false) ; + myGeomGUI->EraseSimulationShape() ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void MeasureGUI_WhatisDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupConstructor1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + if( !mySimulationTopoDs.IsNull() ) + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void MeasureGUI_WhatisDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void MeasureGUI_WhatisDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +//================================================================================= +// function : CalculateWhatis() +// purpose : +//================================================================================= +void MeasureGUI_WhatisDlg::CalculateWhatis(const TopoDS_Shape& S) +{ + + if( S.IsNull() ) + return ; + + TCollection_AsciiString Astr; + Astr = Astr + " Number of shapes in " + strdup(SelectedName.latin1()) + ": \n"; + + try { + // BRepTools_ShapeSet BS; + // BS.Add(S); + // BS.DumpExtent(Astr); + + int iType, nbTypes [TopAbs_SHAPE]; + for (iType = 0; iType < TopAbs_SHAPE; ++iType) + nbTypes[ iType ] = 0; + nbTypes[ S.ShapeType() ]++; + + TopTools_MapOfShape aMapOfShape; + aMapOfShape.Add( S ); + TopTools_ListOfShape aListOfShape; + aListOfShape.Append( S ); + + TopTools_ListIteratorOfListOfShape itL(aListOfShape); + for (; itL.More(); itL.Next()) + { + TopoDS_Iterator it(itL.Value()); + for (; it.More(); it.Next()) + { + TopoDS_Shape s = it.Value(); + if (aMapOfShape.Add( s )) + { + aListOfShape.Append( s ); + nbTypes[ s.ShapeType() ] ++; + } + } + } + + Astr = Astr + " VERTEX : " + TCollection_AsciiString(nbTypes[ TopAbs_VERTEX ]) + "\n"; + Astr = Astr + " EDGE : " + TCollection_AsciiString(nbTypes[ TopAbs_EDGE ]) + "\n"; + Astr = Astr + " WIRE : " + TCollection_AsciiString(nbTypes[ TopAbs_WIRE ]) + "\n"; + Astr = Astr + " FACE : " + TCollection_AsciiString(nbTypes[ TopAbs_FACE ]) + "\n"; + Astr = Astr + " SHELL : " + TCollection_AsciiString(nbTypes[ TopAbs_SHELL ]) + "\n"; + Astr = Astr + " SOLID : " + TCollection_AsciiString(nbTypes[ TopAbs_SOLID ]) + "\n"; + Astr = Astr + " COMPSOLID : " + TCollection_AsciiString(nbTypes[ TopAbs_COMPSOLID ]) + "\n"; + Astr = Astr + " COMPOUND : " + TCollection_AsciiString(nbTypes[ TopAbs_COMPOUND ]) + "\n"; + Astr = Astr + " SHAPE : " + TCollection_AsciiString(aMapOfShape.Extent()) + "\n"; + + Text->setText( Astr.ToCString() ); + } + catch(Standard_Failure) { + MESSAGE("Catch intercepted in CalculateWhatis()" << endl ) ; + } + return ; +} diff --git a/src/MeasureGUI/MeasureGUI_WhatisDlg.h b/src/MeasureGUI/MeasureGUI_WhatisDlg.h new file mode 100644 index 000000000..a4a5c76e5 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_WhatisDlg.h @@ -0,0 +1,110 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MeasureGUI_WhatisDlg.h +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_WHATIS_H +#define DIALOGBOX_WHATIS_H + +#include "MeasureGUI.h" + +#include + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QTextView; +class MeasureGUI; + +//================================================================================= +// class : DialogBox_PROPERTIES +// purpose : +//================================================================================= +class MeasureGUI_WhatisDlg : public QDialog +{ + Q_OBJECT + +public: + MeasureGUI_WhatisDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~MeasureGUI_WhatisDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void CalculateWhatis(const TopoDS_Shape& S) ; + + GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + TopoDS_Shape mySimulationTopoDs ; /* Shape used for simulation display */ + + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupConstructor1; + QLineEdit* LineEditC1A1; + QPushButton* SelectButtonC1A1; + QLabel* TextLabelC1A1; + + QTextView* Text; + QString SelectedName; + + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnCancel(); + void SetEditCurrentArgument() ; + void LineEditReturnPressed() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* MeasureGUI_WhatisDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupConstructor1Layout; + QGridLayout* GroupButtonsLayout; +}; + +#endif // DIALOGBOX_WHATIS_H diff --git a/src/OperationGUI/Makefile.in b/src/OperationGUI/Makefile.in new file mode 100644 index 000000000..78ae410b3 --- /dev/null +++ b/src/OperationGUI/Makefile.in @@ -0,0 +1,73 @@ +# GEOM OPERATIONGUI : +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Damien COQUERET (OCC) +# Module : GEOM +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= OperationGUI.h + +# Libraries targets +LIB = libOperationGUI.la + +LIB_SRC = OperationGUI.cxx \ + OperationGUI_ArchimedeDlg.cxx \ + OperationGUI_PartitionDlg.cxx \ + OperationGUI_FilletDlg.cxx \ + OperationGUI_ChamferDlg.cxx + +LIB_MOC = \ + OperationGUI.h \ + OperationGUI_ArchimedeDlg.h \ + OperationGUI_PartitionDlg.h \ + OperationGUI_FilletDlg.h \ + OperationGUI_ChamferDlg.h + +LIB_CLIENT_IDL = SALOME_Exception.idl \ + GEOM_Gen.idl \ + GEOM_Shape.idl \ + SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +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 -lDlgRef -lGEOMBase $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/OperationGUI/OperationGUI.cxx b/src/OperationGUI/OperationGUI.cxx new file mode 100644 index 000000000..27c9f54d5 --- /dev/null +++ b/src/OperationGUI/OperationGUI.cxx @@ -0,0 +1,439 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : OperationGUI.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "OperationGUI.h" + +#include "QAD_RightFrame.h" +#include "OCCViewer_Viewer3d.h" +#include "OCCViewer_ViewFrame.h" + +#include + +#include "OperationGUI_PartitionDlg.h" // Method PARTITION +#include "OperationGUI_ArchimedeDlg.h" // Method ARCHIMEDE +#include "OperationGUI_FilletDlg.h" // Method FILLET +#include "OperationGUI_ChamferDlg.h" // Method CHAMFER + +//======================================================================= +// function : OperationGUI() +// purpose : Constructor +//======================================================================= +OperationGUI::OperationGUI() : + QObject() +{ + myGeomGUI = GEOMBase_Context::GetGeomGUI(); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); +} + + +//======================================================================= +// function : ~OperationGUI() +// purpose : Destructor +//======================================================================= +OperationGUI::~OperationGUI() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool OperationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + switch (theCommandID) + { + case 4025: // PARTITION + { + OperationGUI_PartitionDlg *aDlg = new OperationGUI_PartitionDlg(parent, "", this, Sel); + break; + } + case 4026: // ARCHIMEDE + { + OperationGUI_ArchimedeDlg *aDlg = new OperationGUI_ArchimedeDlg(parent, "", this, Sel); + break; + } + case 4027: // FILLET + { + Handle(AIS_InteractiveContext) ic; + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + ic = v3d->getAISContext(); + } + OperationGUI_FilletDlg *aDlg = new OperationGUI_FilletDlg(parent, "", this, Sel, ic); + break; + } + case 4028: // CHAMFER + { + Handle(AIS_InteractiveContext) ic; + if(myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + ic = v3d->getAISContext(); + } + OperationGUI_ChamferDlg *aDlg = new OperationGUI_ChamferDlg(parent, "", this, Sel, ic); + break; + } + default: + { + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + } + return true; +} + + +//===================================================================================== +// function : MakePartitionAndDisplay() +// purpose : +//===================================================================================== +void OperationGUI::MakePartitionAndDisplay(const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, + const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR, + const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR, + const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR, + const GEOM::shape_type limit) +{ + try { + GEOM::GEOM_Shape_var result = myGeom->Partition(listShapesIOR, listToolsIOR, + listKeepInsIOR, listRemoveInsIOR, + (CORBA::Short) limit); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + result->NameType(tr("GEOM_PARTITION")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + return; + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } +} + + +//======================================================================= +// function : Archimede() +// purpose : +//======================================================================= +void OperationGUI::Archimede(const Handle(SALOME_InteractiveObject)& IO, const double aWeight, + const double aWaterDensity, const double aMeshingDeflection) +{ + try { + if(IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject))) { + Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(IO); + GEOM::GEOM_Shape_var Shape = myGeom->GetIORFromString(GIO->getIOR()); + + GEOM::GEOM_Shape_var Result = myGeom->Archimede(Shape, aWeight, aWaterDensity, aMeshingDeflection); + Result->NameType(tr("GEOM_PLANE")); + if(myGeomGUI->Display(Result)) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + return; + } + if(IO->hasEntry()) { + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if(!obj->_is_nil()) { + if(obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var Shape = myGeom->GetIORFromString(anIOR->Value()); + GEOM::GEOM_Shape_var Result = myGeom->Archimede(Shape, aWeight, aWaterDensity, aMeshingDeflection); + Result->NameType(tr("GEOM_PLANE")); + if (myGeomGUI->Display(Result)) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + } + } + } + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } +} + + +//===================================================================================== +// function : OnFilletGetAll() +// purpose : +//===================================================================================== +bool OperationGUI::OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, + const int SubShapeType, const char* ShapeTopoIOR) +{ + GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; + ListOfID->length(0); + + 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; + } + + try { + if(Radius <= Precision::Confusion()) + return false; + + GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR); + GEOM::GEOM_Shape_var result = myGeom->MakeFillet(aShape, Radius, SubShapeType, ListOfID); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return false; + } + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + result->NameType(type); + + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return true; +} + + +//===================================================================================== +// function : OnFilletGetSelected() +// purpose : +//===================================================================================== +bool OperationGUI::OnFilletGetSelected(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, + const double Radius, const int SubShapeType, + Standard_Integer& aLocalContextId, bool& myUseLocalContext) +{ + if (myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + return false; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); + + if(myUseLocalContext == false) { + /* No local context opened for fillet method */ + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return false; + } + + GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; + ic->InitSelected(); + int nbSelected = ic->NbSelected(); + int i = 0; + ic->InitSelected(); + + while(ic->MoreSelected()) { + TopoDS_Shape s = ic->SelectedShape(); + if(s.ShapeType() == TopAbs_FACE) { + TopExp_Explorer Exp(s, TopAbs_EDGE); + TopTools_MapOfShape M; + while(Exp.More()) { + if(M.Add(Exp.Current())) { /* if a new edge : do not add doublons indices */ + ListOfID->length(i + 1); + ListOfID[i] = myGeomGUI->GetIndex(Exp.Current(), ShapeTopo, (int)TopAbs_EDGE); + i++; + } + Exp.Next(); + } + } + else { + ListOfID->length(i + 1); + ListOfID[i] = myGeomGUI->GetIndex(ic->SelectedShape(), ShapeTopo, SubShapeType); + i++; + } + ic->NextSelected(); + } + + GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR); + GEOM::GEOM_Shape_var aResult; + try { + aResult = myGeom->MakeFillet(aShape, Radius, 6, ListOfID); + + /* local context from DialogBox */ + ic->CloseLocalContext(aLocalContextId); + myUseLocalContext = false; + + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, aResult); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + aResult->NameType(type); + + if(myGeomGUI->Display(aResult)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + + if(myUseLocalContext) { + /* local context from DialogBox */ + ic->CloseLocalContext(aLocalContextId); + myUseLocalContext = false; + } + + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + myGeomGUI->GetActiveStudy()->updateObjBrowser(); + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_READY")); + + return true; +} + + +//===================================================================================== +// function : OnChamferGetAll() +// purpose : +//===================================================================================== +bool OperationGUI::OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, const int SubShapeType, const char* ShapeTopoIOR) +{ + GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; + ListOfID->length(0); + + 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; + } + + try { + if(D1 <= Precision::Confusion()) + return false; + if(D2 <= Precision::Confusion()) + return false; + + GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR); + GEOM::GEOM_Shape_var result = myGeom->MakeChamfer(aShape, D1, D2, SubShapeType, ListOfID); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return false; + } + + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + result->NameType(type); + + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return true; +} + + +//===================================================================================== +// function : OnChamferGetSelected() +// purpose : +//===================================================================================== +bool OperationGUI::OnChamferGetSelected(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, + const double D1, const double D2, const int SubShapeType, + Standard_Integer& aLocalContextId, bool& myUseLocalContext) +{ + if (myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + return false; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + if(myUseLocalContext == false) { + /* No local context opened for chamfer method */ + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return false; + } + + GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; + ic->InitSelected(); + int nbSelected = ic->NbSelected(); + int i = 0; + ic->InitSelected(); + + while(ic->MoreSelected()) { + TopoDS_Shape s = ic->SelectedShape(); + if (s.ShapeType() == TopAbs_FACE) { + TopExp_Explorer Exp(s, TopAbs_EDGE); + TopTools_MapOfShape M; + while(Exp.More()) { + if(M.Add(Exp.Current())) { /* if a new edge : do not add doublons indices */ + ListOfID->length(i + 1); + ListOfID[i] = myGeomGUI->GetIndex(Exp.Current(), ShapeTopo, (int)TopAbs_EDGE); + i++; + } + Exp.Next(); + } + } + else { + ListOfID->length(i + 1); + ListOfID[i] = myGeomGUI->GetIndex(ic->SelectedShape(), ShapeTopo, SubShapeType); + i++; + } + ic->NextSelected(); + } + + GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR); + GEOM::GEOM_Shape_var aResult; + try { + aResult = myGeom->MakeChamfer(aShape, D1, D2, 6, ListOfID); + + /* local context from DialogBox */ + ic->CloseLocalContext(aLocalContextId); + myUseLocalContext = false; + + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, aResult); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + aResult->NameType(type); + + if(myGeomGUI->Display(aResult)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + + if (myUseLocalContext) { + /* local context from DialogBox */ + ic->CloseLocalContext(aLocalContextId); + myUseLocalContext = false; + } + + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + myGeomGUI->GetActiveStudy()->updateObjBrowser(); + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_READY")); + + return true; +} diff --git a/src/OperationGUI/OperationGUI.h b/src/OperationGUI/OperationGUI.h new file mode 100644 index 000000000..28bee151e --- /dev/null +++ b/src/OperationGUI/OperationGUI.h @@ -0,0 +1,78 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : OperationGUI.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef OPERATIONGUI_H +#define OPERATIONGUI_H + +#include "GEOMBase_Display.h" + +//================================================================================= +// class : OperationGUI +// purpose : +//================================================================================= +class OperationGUI : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + OperationGUI(); + ~OperationGUI(); + + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + + void MakePartitionAndDisplay(const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, + const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR, + const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR, + const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR, + const GEOM::shape_type limit ) ; + void Archimede(const Handle(SALOME_InteractiveObject)& IO, const double aWeight, + const double aWaterDensity, const double aMeshingDeflection); + + /* Method for Fillet */ + bool OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, + const int SubShapeType, const char* ShapeTopoIOR); + bool OnFilletGetSelected(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, + const double Radius, const int SubShapeType, + Standard_Integer& aLocalContextId, bool& myUseLocalContext); + + /* Methods for Chamfer */ + bool OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, + const int SubShapeType, const char* ShapeTopoIOR); + bool OnChamferGetSelected(const TopoDS_Shape& ShapeTopo, + const char* ShapeTopoIOR, + const double D1, const double D2, const int SubShapeType, + Standard_Integer& aLocalContextId, + bool& myUseLocalContext); + +private: + GEOMBase_Context* myGeomGUI; + GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + +}; + +#endif diff --git a/src/OperationGUI/OperationGUI_ArchimedeDlg.cxx b/src/OperationGUI/OperationGUI_ArchimedeDlg.cxx new file mode 100644 index 000000000..97fe98870 --- /dev/null +++ b/src/OperationGUI/OperationGUI_ArchimedeDlg.cxx @@ -0,0 +1,466 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : OperationGUI_ArchimedeDlg.cxx +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +using namespace std; +#include "OperationGUI_ArchimedeDlg.h" + +#include "QAD_Tools.h" + +#include "SALOME_InteractiveObject.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : OperationGUI_ArchimedeDlg() +// purpose : Constructs a OperationGUI_ArchimedeDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +OperationGUI_ArchimedeDlg::OperationGUI_ArchimedeDlg( QWidget* parent, const char* name, OperationGUI* theOperationGUI, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_ARCHIMEDE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "OperationGUI_ArchimedeDlg" ); + resize( 303, 219 ); + setCaption( tr( "GEOM_ARCHIMEDE_TITLE" ) ); + setSizeGripEnabled( TRUE ); + OperationGUI_ArchimedeDlgLayout = new QGridLayout( this ); + OperationGUI_ArchimedeDlgLayout->setSpacing( 6 ); + OperationGUI_ArchimedeDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_ARCHIMEDE" ) ); + 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)3, (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 ); + OperationGUI_ArchimedeDlgLayout->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_1 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_1, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "GEOM_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + OperationGUI_ArchimedeDlgLayout->addWidget( GroupButtons, 2, 0 ); + + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) ); + GroupC1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (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 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); + LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) ); + LineEditC1A2->setMinimumSize( QSize( 40, 0 ) ); + LineEditC1A2->setMaximumSize( QSize( 32767, 32767 ) ); + GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); + + LineEditC1A3 = new QLineEdit( GroupC1, "LineEditC1A3" ); + LineEditC1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A3->sizePolicy().hasHeightForWidth() ) ); + LineEditC1A3->setMinimumSize( QSize( 40, 0 ) ); + LineEditC1A3->setMaximumSize( QSize( 32767, 32767 ) ); + GroupC1Layout->addWidget( LineEditC1A3, 2, 2 ); + + LineEditC1A4 = new QLineEdit( GroupC1, "LineEditC1A4" ); + LineEditC1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A4->sizePolicy().hasHeightForWidth() ) ); + LineEditC1A4->setMinimumSize( QSize( 40, 0 ) ); + LineEditC1A4->setMaximumSize( QSize( 32767, 32767 ) ); + GroupC1Layout->addWidget( LineEditC1A4, 3, 2 ); + + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "GEOM_OBJECTS" ) ); + 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_WEIGHT" ) ); + TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A2->setFrameShape( QLabel::NoFrame ); + TextLabelC1A2->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); + + TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" ); + TextLabelC1A3->setText( tr( "GEOM_WATER_DENSITY" ) ); + TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A3->setFrameShape( QLabel::NoFrame ); + TextLabelC1A3->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 ); + + TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" ); + TextLabelC1A4->setText( tr( "GEOM_MESHING_DEFLECTION" ) ); + TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A4->setFrameShape( QLabel::NoFrame ); + TextLabelC1A4->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 ); + + OperationGUI_ArchimedeDlgLayout->addWidget( GroupC1, 1, 0 ); + /***************************************************************/ + myOperationGUI = theOperationGUI; + Init(Sel) ; /* Initialisations */ + +/* Move widget on the botton right corner of main widget */ + QAD_Tools::alignWidget(this, parent, AlignBottom | AlignRight); + /* Display Dialog */ + this->show() ; +} + + +//================================================================================= +// function : ~OperationGUI_ArchimedeDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +OperationGUI_ArchimedeDlg::~OperationGUI_ArchimedeDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void OperationGUI_ArchimedeDlg::Init( SALOME_Selection* Sel ) +{ + LineEditC1A2->setMaxLength( 10 ); + LineEditC1A3->setMaxLength( 10 ); + LineEditC1A4->setMaxLength( 10 ); + this->myVa = new QDoubleValidator( 0, +999999.999, 3, LineEditC1A2 ) ; + this->myVb = new QDoubleValidator( 0, +999999.999, 3, LineEditC1A3 ) ; + this->myVc = new QDoubleValidator( 0, +999999.999, 3, LineEditC1A4 ) ; + LineEditC1A2->setValidator( myVa ) ; + LineEditC1A3->setValidator( myVb ) ; + LineEditC1A4->setValidator( myVc ) ; + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + + this->myWeight = 100.0 ; + LineEditC1A2->setText("100.0") ; + this->myWaterDensity = 1.0 ; + LineEditC1A3->setText("1.0") ; + this->myMeshingDeflection = 0.01 ; + LineEditC1A4->setText("0.01") ; + + myOkWeight = myOkWaterDensity = myOkMeshingDeflection = true ; + myOkIO = false ; + + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* Filter definitions */ + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); + + /* 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( LineEditC1A2, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ; + connect( LineEditC1A3, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ; + connect( LineEditC1A4, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ; + + connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + return ; +} + + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void OperationGUI_ArchimedeDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void OperationGUI_ArchimedeDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void OperationGUI_ArchimedeDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkIO && myOkWeight && myOkWaterDensity && myOkMeshingDeflection ) { + myOperationGUI->Archimede( myIO, myWeight, myWaterDensity, myMeshingDeflection ); + } + } + break ; + } + // accept(); + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void OperationGUI_ArchimedeDlg::ClickOnCancel() +{ + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void OperationGUI_ArchimedeDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + QString aString = ""; + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) { + myEditCurrentArgument->setText("") ; + myOkIO = false ; + } + else { + myEditCurrentArgument->setText(aString) ; + myIO = mySelection->firstIObject(); + myOkIO = true ; + } + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void OperationGUI_ArchimedeDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + +//================================================================================= +// function : TextChangedInLineEdit() +// purpose : +//================================================================================= +void OperationGUI_ArchimedeDlg::TextChangedInLineEdit(const QString& newText) +{ + QLineEdit* send = (QLineEdit*)sender(); + QString newT = strdup(newText) ; + int i ; + + if(send == LineEditC1A2) { + if( myVa->validate(newT, i) == myVa->Acceptable ) { + this->myWeight = newText.toFloat() ; + myOkWeight = true ; + } + else { + myOkWeight = false ; + } + } + else if(send == LineEditC1A3) { + if( myVb->validate(newT, i) == myVb->Acceptable ) { + this->myWaterDensity = newText.toFloat() ; + myOkWaterDensity = true ; + } + else { + myOkWaterDensity = false ; + } + } + else if(send == LineEditC1A4) { + if( myVc->validate(newT, i) == myVc->Acceptable ) { + this->myMeshingDeflection = newText.toFloat() ; + myOkMeshingDeflection = true ; + } + else { + myOkMeshingDeflection = false ; + } + } + + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void OperationGUI_ArchimedeDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void OperationGUI_ArchimedeDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void OperationGUI_ArchimedeDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void OperationGUI_ArchimedeDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + diff --git a/src/OperationGUI/OperationGUI_ArchimedeDlg.h b/src/OperationGUI/OperationGUI_ArchimedeDlg.h new file mode 100644 index 000000000..6ed596c9a --- /dev/null +++ b/src/OperationGUI/OperationGUI_ArchimedeDlg.h @@ -0,0 +1,125 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : OperationGUI_ArchimedeDlg.h +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_ARCHIMEDE_H +#define DIALOGBOX_ARCHIMEDE_H + +#include "OperationGUI.h" + +#include +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; + + +//================================================================================= +// class : OperationGUI_ArchimedeDlg +// purpose : +//================================================================================= +class OperationGUI_ArchimedeDlg : public QDialog +{ + Q_OBJECT + +public: + OperationGUI_ArchimedeDlg( QWidget* parent = 0, const char* name = 0, OperationGUI* theOperationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~OperationGUI_ArchimedeDlg(); + +private: + OperationGUI* myOperationGUI; + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + + Handle(SALOME_InteractiveObject) myIO ; + + Standard_Real myWeight ; + Standard_Real myWaterDensity ; + Standard_Real myMeshingDeflection ; + + bool myOkIO ; + bool myOkWeight ; + bool myOkWaterDensity ; + bool myOkMeshingDeflection ; + + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + QDoubleValidator *myVa ; /* Double validator for numeric input */ + QDoubleValidator *myVb ; /* Double validator for numeric input */ + QDoubleValidator *myVc ; /* Double validator for numeric input */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QGroupBox* GroupC1; + QLineEdit* LineEditC1A1; + QLineEdit* LineEditC1A2; + QLineEdit* LineEditC1A3; + QLineEdit* LineEditC1A4; + QPushButton* SelectButtonC1A1; + QLabel* TextLabelC1A1; + QLabel* TextLabelC1A2; + QLabel* TextLabelC1A3; + QLabel* TextLabelC1A4; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void TextChangedInLineEdit(const QString&) ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* OperationGUI_ArchimedeDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_ARCHIMEDE_H diff --git a/src/OperationGUI/OperationGUI_ChamferDlg.cxx b/src/OperationGUI/OperationGUI_ChamferDlg.cxx new file mode 100644 index 000000000..eed5428f9 --- /dev/null +++ b/src/OperationGUI/OperationGUI_ChamferDlg.cxx @@ -0,0 +1,935 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : OperationGUI_ChamferDlg.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header$ + +using namespace std; +#include "OperationGUI_ChamferDlg.h" + +#include "QAD_Config.h" +#include "QAD_RightFrame.h" +#include "OCCViewer_Viewer3d.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +//================================================================================= +// class : OperationGUI_ChamferDlg() +// purpose : Constructs a OperationGUI_ChamferDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +OperationGUI_ChamferDlg::OperationGUI_ChamferDlg( QWidget* parent, + const char* name, + OperationGUI* theOperationGUI, + SALOME_Selection* Sel, + Handle (AIS_InteractiveContext) ic, + bool modal, + WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + /***************************************************************/ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CHAMFER_ALL"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CHAMFER_EDGE"))); + QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_CHAMFER_FACE"))); + + if ( !name ) + setName( "OperationGUI_ChamferDlg" ); + resize( 365, 220 ); + setCaption( tr( "GEOM_CHAMFER_TITLE" ) ); + setSizeGripEnabled( TRUE ); + OperationGUI_ChamferDlgLayout = new QGridLayout( this ); + OperationGUI_ChamferDlgLayout->setSpacing( 6 ); + OperationGUI_ChamferDlgLayout->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 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "GEOM_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + OperationGUI_ChamferDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_CHAMFER" ) ); + 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 ); + Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" ); + Constructor2->setText( tr( "" ) ); + Constructor2->setPixmap( image2 ); + Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) ); + Constructor2->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor2, 0, 2 ); + QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_2, 0, 3 ); + QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_3, 0, 1 ); + Constructor3 = new QRadioButton( GroupConstructors, "Constructor3" ); + Constructor3->setText( tr( "" ) ); + Constructor3->setPixmap( image3 ); + Constructor3->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor3, 0, 4 ); + QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_4, 0, 5 ); + OperationGUI_ChamferDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_CHAMFER_ALL" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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_MAIN_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_D1" ) ); + TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A2->setFrameShape( QLabel::NoFrame ); + TextLabelC1A2->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); + + TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" ); + TextLabelC1A3->setText( tr( "GEOM_D2" ) ); + TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A3->setFrameShape( QLabel::NoFrame ); + TextLabelC1A3->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 ); + + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + +// LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); +// LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) ); +// GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); + +// LineEditC1A3 = new QLineEdit( GroupC1, "LineEditC1A3" ); +// LineEditC1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A3->sizePolicy().hasHeightForWidth() ) ); +// GroupC1Layout->addWidget( LineEditC1A3, 2, 2 ); + + SpinBox_C1A2 = new DlgRef_SpinBox( GroupC1, "GeomSpinBox_C1A2" ) ; + SpinBox_C1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A2->sizePolicy().hasHeightForWidth() ) ); + GroupC1Layout->addWidget( SpinBox_C1A2, 1, 2 ); + + SpinBox_C1A3 = new DlgRef_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ; + SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) ); + GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 ); + + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + OperationGUI_ChamferDlgLayout->addWidget( GroupC1, 1, 0 ); + + /***************************************************************/ + GroupC2 = new QGroupBox( this, "GroupC2" ); + GroupC2->setTitle( tr( "GEOM_CHAMFER_EDGES" ) ); + GroupC2->setMinimumSize( QSize( 0, 0 ) ); + GroupC2->setFrameShape( QGroupBox::Box ); + GroupC2->setFrameShadow( QGroupBox::Sunken ); + GroupC2->setColumnLayout(0, Qt::Vertical ); + GroupC2->layout()->setSpacing( 0 ); + GroupC2->layout()->setMargin( 0 ); + GroupC2Layout = new QGridLayout( GroupC2->layout() ); + GroupC2Layout->setAlignment( Qt::AlignTop ); + GroupC2Layout->setSpacing( 6 ); + GroupC2Layout->setMargin( 11 ); + + TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" ); + TextLabelC2A1->setText( tr( "GEOM_MAIN_OBJECT" ) ); + TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A1->setFrameShape( QLabel::NoFrame ); + TextLabelC2A1->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 ); + + TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" ); + TextLabelC2A2->setText( tr( "GEOM_D1" ) ); + TextLabelC2A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A2->setFrameShape( QLabel::NoFrame ); + TextLabelC2A2->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 ); + + TextLabelC2A3 = new QLabel( GroupC2, "TextLabelC2A3" ); + TextLabelC2A3->setText( tr( "GEOM_D2" ) ); + TextLabelC2A3->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A3->setFrameShape( QLabel::NoFrame ); + TextLabelC2A3->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A3, 2, 0 ); + + LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" ); + GroupC2Layout->addWidget( LineEditC2A1, 0, 2 ); + + // LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" ); +// LineEditC2A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC2A2->sizePolicy().hasHeightForWidth() ) ); +// GroupC2Layout->addWidget( LineEditC2A2, 1, 2 ); + +// LineEditC2A3 = new QLineEdit( GroupC2, "LineEditC2A3" ); +// LineEditC2A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC2A3->sizePolicy().hasHeightForWidth() ) ); +// GroupC2Layout->addWidget( LineEditC2A3, 2, 2 ); + + SpinBox_C2A2 = new DlgRef_SpinBox( GroupC2, "GeomSpinBox_C2A2" ) ; + SpinBox_C2A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A2->sizePolicy().hasHeightForWidth() ) ); + GroupC2Layout->addWidget( SpinBox_C2A2, 1, 2 ); + + SpinBox_C2A3 = new DlgRef_SpinBox( GroupC2, "GeomSpinBox_C2A3" ) ; + SpinBox_C2A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A3->sizePolicy().hasHeightForWidth() ) ); + GroupC2Layout->addWidget( SpinBox_C2A3, 2, 2 ); + + SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" ); + SelectButtonC2A1->setText( tr( "" ) ); + SelectButtonC2A1->setPixmap( image1 ); + SelectButtonC2A1->setToggleButton( FALSE ); + SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) ); + GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 ); + OperationGUI_ChamferDlgLayout->addWidget( GroupC2, 1, 0 ); + + /***************************************************************/ + GroupC3 = new QGroupBox( this, "GroupC3" ); + GroupC3->setTitle( tr( "GEOM_CHAMFER_FACES" ) ); + GroupC3->setMinimumSize( QSize( 0, 0 ) ); + GroupC3->setFrameShape( QGroupBox::Box ); + GroupC3->setFrameShadow( QGroupBox::Sunken ); + GroupC3->setColumnLayout(0, Qt::Vertical ); + GroupC3->layout()->setSpacing( 0 ); + GroupC3->layout()->setMargin( 0 ); + GroupC3Layout = new QGridLayout( GroupC3->layout() ); + GroupC3Layout->setAlignment( Qt::AlignTop ); + GroupC3Layout->setSpacing( 6 ); + GroupC3Layout->setMargin( 11 ); + + TextLabelC3A1 = new QLabel( GroupC3, "TextLabelC3A1" ); + TextLabelC3A1->setText( tr( "GEOM_MAIN_OBJECT" ) ); + TextLabelC3A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC3A1->setFrameShape( QLabel::NoFrame ); + TextLabelC3A1->setFrameShadow( QLabel::Plain ); + GroupC3Layout->addWidget( TextLabelC3A1, 0, 0 ); + + TextLabelC3A2 = new QLabel( GroupC3, "TextLabelC3A2" ); + TextLabelC3A2->setText( tr( "GEOM_D1" ) ); + TextLabelC3A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC3A2->setFrameShape( QLabel::NoFrame ); + TextLabelC3A2->setFrameShadow( QLabel::Plain ); + GroupC3Layout->addWidget( TextLabelC3A2, 1, 0 ); + + TextLabelC3A3 = new QLabel( GroupC3, "TextLabelC3A3" ); + TextLabelC3A3->setText( tr( "GEOM_D2" ) ); + TextLabelC3A3->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC3A3->setFrameShape( QLabel::NoFrame ); + TextLabelC3A3->setFrameShadow( QLabel::Plain ); + GroupC3Layout->addWidget( TextLabelC3A3, 2, 0 ); + + LineEditC3A1 = new QLineEdit( GroupC3, "LineEditC3A1" ); + GroupC3Layout->addWidget( LineEditC3A1, 0, 2 ); + + // LineEditC3A2 = new QLineEdit( GroupC3, "LineEditC3A2" ); +// LineEditC3A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC3A2->sizePolicy().hasHeightForWidth() ) ); +// GroupC3Layout->addWidget( LineEditC3A2, 1, 2 ); + +// LineEditC3A3 = new QLineEdit( GroupC3, "LineEditC3A3" ); +// LineEditC3A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC3A3->sizePolicy().hasHeightForWidth() ) ); +// GroupC3Layout->addWidget( LineEditC3A3, 2, 2 ); + + SpinBox_C3A2 = new DlgRef_SpinBox( GroupC3, "GeomSpinBox_C3A2" ) ; + SpinBox_C3A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C3A2->sizePolicy().hasHeightForWidth() ) ); + GroupC3Layout->addWidget( SpinBox_C3A2, 1, 2 ); + + SpinBox_C3A3 = new DlgRef_SpinBox( GroupC3, "GeomSpinBox_C3A3" ) ; + SpinBox_C3A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C3A3->sizePolicy().hasHeightForWidth() ) ); + GroupC3Layout->addWidget( SpinBox_C3A3, 2, 2 ); + + SelectButtonC3A1 = new QPushButton( GroupC3, "SelectButtonC3A1" ); + SelectButtonC3A1->setText( tr( "" ) ); + SelectButtonC3A1->setPixmap( image1 ); + SelectButtonC3A1->setToggleButton( FALSE ); + SelectButtonC3A1->setMaximumSize( QSize( 28, 32767 ) ); + GroupC3Layout->addWidget( SelectButtonC3A1, 0, 1 ); + OperationGUI_ChamferDlgLayout->addWidget( GroupC3, 1, 0 ); + myOperationGUI = theOperationGUI; + /* Initialisation */ + Init( Sel, ic ) ; +} + + +//================================================================================= +// function : ~OperationGUI_ChamferDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +OperationGUI_ChamferDlg::~OperationGUI_ChamferDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ + this->destroy(TRUE, TRUE) ; +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) +{ + + /* 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_C1A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* myD1 */ + SpinBox_C1A2->SetValue( 50 ) ; + SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* myD2 */ + SpinBox_C1A3->SetValue( 50 ) ; + + SpinBox_C2A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; + SpinBox_C2A2->SetValue( 50 ) ; + SpinBox_C2A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; + SpinBox_C2A3->SetValue( 50 ) ; + + SpinBox_C3A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; + SpinBox_C3A2->SetValue( 50 ) ; + SpinBox_C3A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; + SpinBox_C3A3->SetValue( 50 ) ; + + GroupC1->show(); + GroupC2->hide() ; + GroupC3->hide() ; + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + + mySelection = Sel ; + myEditCurrentArgument = LineEditC1A1 ; + myShape.Nullify() ; + myD1 = 50.0 ; + myOkD1 = true ; + myD2 = 50.0 ; + myOkD2 = true ; + myIC = ic ; + myUseLocalContext = false ; + myOkShape = false ; + + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + + mySimulationTopoDs.Nullify() ; + + /* Filters definition */ + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC3A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( SpinBox_C1A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_C2A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_C3A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + + connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_C2A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_C3A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + + connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC3A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* Displays Dialog */ + + return ; +} + + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void OperationGUI_ChamferDlg::ConstructorsClicked(int constructorId) +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + myEditCurrentArgument->setText(tr("")) ; + + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + myIC = v3d->getAISContext(); + if(myUseLocalContext ) { + myIC->CloseLocalContext(this->myLocalContextId); + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + myUseLocalContext = false ; + } + } + + myOkShape = false ; + myD1 = 50.0 ; + myD2 = 50.0 ; + myOkD1 = true ; + myOkD2 = true ; + myConstructorId = constructorId ; + + switch (constructorId) + { + case 0: /* Chamfer All */ + { + GroupC1->show(); + GroupC2->hide() ; + GroupC3->hide() ; + myEditCurrentArgument = LineEditC1A1 ; + SpinBox_C1A2->SetValue( 50 ) ; + SpinBox_C1A3->SetValue( 50 ) ; + LineEditC1A1->setText(tr("")) ; + myShapeType = -1; + break; + } + + case 1: /* Chamfer edges */ + { + myShapeType = 6; + GroupC1->hide(); + GroupC2->show() ; + GroupC3->hide() ; + myEditCurrentArgument = LineEditC2A1 ; + SpinBox_C2A2->SetValue( 50 ) ; + SpinBox_C2A3->SetValue( 50 ) ; + LineEditC2A1->setText(tr("")) ; + break ; + } + + case 2: /* Chamfer Faces */ + { + myShapeType = 4; + GroupC1->hide(); + GroupC2->hide() ; + GroupC3->show() ; + myEditCurrentArgument = LineEditC3A1 ; + SpinBox_C3A2->SetValue( 50 ) ; + SpinBox_C3A3->SetValue( 50 ) ; + LineEditC3A1->setText(tr("")) ; + break ; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::ClickOnApply() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + bool testResult = false ; + myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + + switch(myConstructorId) + { + case 0 : /* Chamfer All */ + { + if(myOkD1 && myOkD2) { + if( myOkShape ) { + testResult = myOperationGUI->OnChamferGetAll( myShape, myD1, myD2, myShapeType, myShapeIOR ) ; + } + } + if( !testResult ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ; + } + else { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ; + } + /* Reset all arguments and local context to allow user a new selection ...*/ + this->ResetStateOfDialog() ; + break ; + } + + case 1 : /* Chamfer Edge */ + { + if(myOkD1 && myOkD2) { + if( myOkShape ) { + testResult = myOperationGUI->OnChamferGetSelected( myShape, myShapeIOR, myD1, myD2, myShapeType, + myLocalContextId, myUseLocalContext ); + } + } + if( !testResult ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ; + } + else { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ; + } + /* Reset all arguments and local context to allow user a new selection ...*/ + this->ResetStateOfDialog() ; + break ; + } + + case 2 : /* Chamfer Face */ + { + if(myOkD1 && myOkD2) { + if( myOkShape ) { + testResult = myOperationGUI->OnChamferGetSelected( myShape, myShapeIOR, myD1, myD2, myShapeType, + myLocalContextId, myUseLocalContext ) ; + } + } + if( !testResult ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ; + } + else { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ; + } + /* Reset all arguments and local context to allow user a new selection ...*/ + this->ResetStateOfDialog() ; + break ; + } + } + + // accept(); + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::ClickOnCancel() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + myIC = v3d->getAISContext(); + if(this->myUseLocalContext ) { + myIC->CloseLocalContext(this->myLocalContextId) ; + this->myUseLocalContext = false ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + } + + reject() ; + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void OperationGUI_ChamferDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + /* Reset all arguments and local context when selection as changed */ + this->ResetStateOfDialog() ; + + /* Future name of argument */ + QString aString = ""; + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel == 1 ) { + + TopoDS_Shape S ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if( !IO->hasEntry() ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")) ; + return ; + } + + if ( !S.IsNull() && S.ShapeType() <= 2 ) { + if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { + Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO ); + myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */ + myEditCurrentArgument->setText(aString) ; + myShape = S ; + myOkShape = true ; + } + + if ( IO->hasEntry() ) { + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + myShapeIOR = anIOR->Value(); + myOkShape = true ; + myShape = S ; + myEditCurrentArgument->setText(aString) ; + } + } + } + + MakePreview(); + + } + } else + return; + + if( myOkShape && myShapeType!=-1 && myConstructorId != 0 ) { + /* local context is defined into the method */ + myGeomGUI->PrepareSubShapeSelection( this->myShapeType, this->myLocalContextId ) ; + myUseLocalContext = true ; + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_EDGE")) ; + } +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + else if ( send == LineEditC2A1 ) + myEditCurrentArgument = LineEditC2A1 ; + else if ( send == LineEditC3A1 ) + myEditCurrentArgument = LineEditC3A1 ; + 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 ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + switch (myConstructorId) + { + case 0: + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + SelectionIntoArgument() ; + } + break; + } + + case 1: + { + if(send ==SelectButtonC2A1 ) { + LineEditC2A1->setFocus() ; + myEditCurrentArgument = LineEditC2A1; + SelectionIntoArgument() ; + } + break; + } + + case 2: + { + if(send ==SelectButtonC3A1 ) { + LineEditC3A1->setFocus() ; + myEditCurrentArgument = LineEditC3A1; + SelectionIntoArgument() ; + } + break; + } + + } + return ; +} + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::ValueChangedInSpinBox( double newValue ) +{ + QObject* send = (QObject*)sender(); + + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + + if( send == SpinBox_C1A2 || send == SpinBox_C2A2 || send == SpinBox_C3A2 ) { /* D1 */ + myD1 = newValue ; + myOkD1 = true ; + MakePreview(); + return ; + } + if( send == SpinBox_C1A3 || send == SpinBox_C2A3 || send == SpinBox_C3A3 ) { /* D2 */ + myD2 = newValue ; + myOkD2 = true ; + MakePreview(); + return ; + } +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + this->ResetStateOfDialog() ; + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupC2->setEnabled(false) ; + GroupC3->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + myGeomGUI->SetActiveDialogBox(0) ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupC2->setEnabled(true) ; + GroupC3->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + + if( !mySimulationTopoDs.IsNull() ) + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::enterEvent( QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +//================================================================================= +// function : ResetStateOfDialog() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::ResetStateOfDialog() +{ + this->myOkShape = false ; + this->myEditCurrentArgument->setText("") ; + + /* Close its local contact if opened */ + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + myIC = v3d->getAISContext(); + if(this->myUseLocalContext) { + myIC->CloseLocalContext(this->myLocalContextId) ; + this->myUseLocalContext = false ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + } + return ; +} + +void OperationGUI_ChamferDlg::MakePreview() +{ + TopoDS_Shape tds ; + try + { + BRepFilletAPI_MakeChamfer MC(myShape); + switch (myConstructorId) + { + case 0: /* Chamfer All */ + { + TopTools_IndexedDataMapOfShapeListOfShape M; + TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,M); + for (int i = 1;i<=M.Extent();i++) + { + TopoDS_Edge E = TopoDS::Edge(M.FindKey(i)); + TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First()); + if (!BRepTools::IsReallyClosed(E, F) && !BRep_Tool::Degenerated(E)) + MC.Add(myD1, myD2,E,F); + } + tds = MC.Shape(); + break; + } +// case 1: /* Chamfer edges */ +// case 2: /* Chamfer Faces */ + } + if (!tds.IsNull()) + { + mySimulationTopoDs = tds; + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + } + + } + catch(Standard_Failure) + { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } +} diff --git a/src/OperationGUI/OperationGUI_ChamferDlg.h b/src/OperationGUI/OperationGUI_ChamferDlg.h new file mode 100644 index 000000000..20c6d5a5b --- /dev/null +++ b/src/OperationGUI/OperationGUI_ChamferDlg.h @@ -0,0 +1,173 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : OperationGUI_ChamferDlg.h +// Author : Damien COQUERET +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_CHAMFER_H +#define DIALOGBOX_CHAMFER_H + +#include "OperationGUI.h" + +#include "DlgRef_SpinBox.h" + +// Qt Includes +#include +#include +#include + +// Open CASCADE Includes +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QFrame; +class QGroupBox; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QToolButton; +class QLabel; +class OperationGUI; + +//================================================================================= +// class : OperationGUI_ChamferDlg +// purpose : +//================================================================================= +class OperationGUI_ChamferDlg : public QDialog +{ + Q_OBJECT + +public: + OperationGUI_ChamferDlg( QWidget* parent = 0, + const char* name = 0, + OperationGUI* theOperationGUI = 0, + SALOME_Selection* Sel = 0, + Handle (AIS_InteractiveContext) ic = 0, + bool modal = FALSE, + WFlags fl = 0 ); + + ~OperationGUI_ChamferDlg(); + +private : + OperationGUI* myOperationGUI; + void Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent( QEvent* e); + void ResetStateOfDialog() ; + + /* Interactive and local context management see also : bool myUseLocalContext() */ + Handle (AIS_InteractiveContext) myIC ; /* Interactive context */ + Standard_Integer myLocalContextId ; /* identify a local context used by this method */ + bool myUseLocalContext ; /* true when this method as opened a local context */ + + QDoubleValidator *myVa ; /* Double validator for numeric input */ + QDoubleValidator *myVb ; /* Double validator for numeric input */ + + GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + + TopoDS_Shape myShape ; + bool myOkShape ; + char* myShapeIOR ; + + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + int myConstructorId ; /* Current constructor id = radio button id */ + int myShapeType ; + + TopoDS_Shape mySimulationTopoDs ; /* Shape used for simulation display */ + void MakePreview(); + + bool myOkD1 ; + double myD1 ; + bool myOkD2 ; + double myD2 ; + + QButtonGroup* GroupConstructors; + + QRadioButton* Constructor1; + QRadioButton* Constructor2; + QRadioButton* Constructor3; + + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + + QGroupBox* GroupC1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + QLabel* TextLabelC1A1; + DlgRef_SpinBox* SpinBox_C1A2 ; + QLabel* TextLabelC1A2; + DlgRef_SpinBox* SpinBox_C1A3 ; + QLabel* TextLabelC1A3; + + QGroupBox* GroupC2; + QPushButton* SelectButtonC2A1; + QLineEdit* LineEditC2A1; + QLabel* TextLabelC2A1; + DlgRef_SpinBox* SpinBox_C2A2 ; + QLabel* TextLabelC2A2; + DlgRef_SpinBox* SpinBox_C2A3; + QLabel* TextLabelC2A3; + + QGroupBox* GroupC3; + QPushButton* SelectButtonC3A1; + QLineEdit* LineEditC3A1; + QLabel* TextLabelC3A1; + DlgRef_SpinBox* SpinBox_C3A2 ; + QLabel* TextLabelC3A2; + DlgRef_SpinBox* SpinBox_C3A3; + QLabel* TextLabelC3A3; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void LineEditReturnPressed() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void ValueChangedInSpinBox( double newValue ) ; + +protected: + + QGridLayout* OperationGUI_ChamferDlgLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; + QGridLayout* GroupC2Layout; + QGridLayout* GroupC3Layout; +}; + +#endif // DIALOGBOX_CHAMFER_H + diff --git a/src/OperationGUI/OperationGUI_FilletDlg.cxx b/src/OperationGUI/OperationGUI_FilletDlg.cxx new file mode 100644 index 000000000..bfb89127d --- /dev/null +++ b/src/OperationGUI/OperationGUI_FilletDlg.cxx @@ -0,0 +1,845 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : OperationGUI_FilletDlg.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header$ + +using namespace std; +#include "OperationGUI_FilletDlg.h" + + +#include "QAD_Config.h" +#include "QAD_RightFrame.h" +#include "OCCViewer_Viewer3d.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + + +//================================================================================= +// class : OperationGUI_FilletDlg() +// purpose : Constructs a OperationGUI_FilletDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +OperationGUI_FilletDlg::OperationGUI_FilletDlg( QWidget* parent, + const char* name, + OperationGUI* theOperationGUI, + SALOME_Selection* Sel, + Handle (AIS_InteractiveContext) ic, + bool modal, + WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + /***************************************************************/ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_FILLET_ALL"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_FILLET_EDGE"))); + QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_FILLET_FACE"))); + + if ( !name ) + setName( "OperationGUI_FilletDlg" ); + resize( 365, 220 ); + setCaption( tr( "GEOM_FILLET_TITLE" ) ); + setSizeGripEnabled( TRUE ); + OperationGUI_FilletDlgLayout = new QGridLayout( this ); + OperationGUI_FilletDlgLayout->setSpacing( 6 ); + OperationGUI_FilletDlgLayout->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 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "GEOM_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + OperationGUI_FilletDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_FILLET" ) ); + 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 ); + Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" ); + Constructor2->setText( tr( "" ) ); + Constructor2->setPixmap( image2 ); + Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) ); + Constructor2->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor2, 0, 2 ); + QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_2, 0, 3 ); + QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_3, 0, 1 ); + Constructor3 = new QRadioButton( GroupConstructors, "Constructor3" ); + Constructor3->setText( tr( "" ) ); + Constructor3->setPixmap( image3 ); + Constructor3->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor3, 0, 4 ); + QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_4, 0, 5 ); + OperationGUI_FilletDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_FILLET_ALL" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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_MAIN_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_RADIUS" ) ); + TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A2->setFrameShape( QLabel::NoFrame ); + TextLabelC1A2->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); + + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + SpinBox_C1A2 = new DlgRef_SpinBox( GroupC1, "GeomSpinBox_C1A2" ) ; + SpinBox_C1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A2->sizePolicy().hasHeightForWidth() ) ); + GroupC1Layout->addWidget( SpinBox_C1A2, 1, 2 ); + + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + OperationGUI_FilletDlgLayout->addWidget( GroupC1, 1, 0 ); + + /***************************************************************/ + GroupC2 = new QGroupBox( this, "GroupC2" ); + GroupC2->setTitle( tr( "GEOM_FILLET_EDGES" ) ); + GroupC2->setMinimumSize( QSize( 0, 0 ) ); + GroupC2->setFrameShape( QGroupBox::Box ); + GroupC2->setFrameShadow( QGroupBox::Sunken ); + GroupC2->setColumnLayout(0, Qt::Vertical ); + GroupC2->layout()->setSpacing( 0 ); + GroupC2->layout()->setMargin( 0 ); + GroupC2Layout = new QGridLayout( GroupC2->layout() ); + GroupC2Layout->setAlignment( Qt::AlignTop ); + GroupC2Layout->setSpacing( 6 ); + GroupC2Layout->setMargin( 11 ); + + TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" ); + TextLabelC2A1->setText( tr( "GEOM_MAIN_OBJECT" ) ); + TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A1->setFrameShape( QLabel::NoFrame ); + TextLabelC2A1->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 ); + + TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" ); + TextLabelC2A2->setText( tr( "GEOM_RADIUS" ) ); + TextLabelC2A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A2->setFrameShape( QLabel::NoFrame ); + TextLabelC2A2->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 ); + + LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" ); + GroupC2Layout->addWidget( LineEditC2A1, 0, 2 ); + + SpinBox_C2A2 = new DlgRef_SpinBox( GroupC2, "GeomSpinBox_C2A2" ) ; + SpinBox_C2A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A2->sizePolicy().hasHeightForWidth() ) ); + GroupC2Layout->addWidget( SpinBox_C2A2, 1, 2 ); + + SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" ); + SelectButtonC2A1->setText( tr( "" ) ); + SelectButtonC2A1->setPixmap( image1 ); + SelectButtonC2A1->setToggleButton( FALSE ); + SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) ); + GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 ); + OperationGUI_FilletDlgLayout->addWidget( GroupC2, 1, 0 ); + + /***************************************************************/ + GroupC3 = new QGroupBox( this, "GroupC3" ); + GroupC3->setTitle( tr( "GEOM_FILLET_FACES" ) ); + GroupC3->setMinimumSize( QSize( 0, 0 ) ); + GroupC3->setFrameShape( QGroupBox::Box ); + GroupC3->setFrameShadow( QGroupBox::Sunken ); + GroupC3->setColumnLayout(0, Qt::Vertical ); + GroupC3->layout()->setSpacing( 0 ); + GroupC3->layout()->setMargin( 0 ); + GroupC3Layout = new QGridLayout( GroupC3->layout() ); + GroupC3Layout->setAlignment( Qt::AlignTop ); + GroupC3Layout->setSpacing( 6 ); + GroupC3Layout->setMargin( 11 ); + + TextLabelC3A1 = new QLabel( GroupC3, "TextLabelC3A1" ); + TextLabelC3A1->setText( tr( "GEOM_MAIN_OBJECT" ) ); + TextLabelC3A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC3A1->setFrameShape( QLabel::NoFrame ); + TextLabelC3A1->setFrameShadow( QLabel::Plain ); + GroupC3Layout->addWidget( TextLabelC3A1, 0, 0 ); + + TextLabelC3A2 = new QLabel( GroupC3, "TextLabelC3A2" ); + TextLabelC3A2->setText( tr( "GEOM_RADIUS" ) ); + TextLabelC3A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC3A2->setFrameShape( QLabel::NoFrame ); + TextLabelC3A2->setFrameShadow( QLabel::Plain ); + GroupC3Layout->addWidget( TextLabelC3A2, 1, 0 ); + + LineEditC3A1 = new QLineEdit( GroupC3, "LineEditC3A1" ); + GroupC3Layout->addWidget( LineEditC3A1, 0, 2 ); + + SpinBox_C3A2 = new DlgRef_SpinBox( GroupC3, "GeomSpinBox_C3A2" ) ; + SpinBox_C3A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C3A2->sizePolicy().hasHeightForWidth() ) ); + GroupC3Layout->addWidget( SpinBox_C3A2, 1, 2 ); + + SelectButtonC3A1 = new QPushButton( GroupC3, "SelectButtonC3A1" ); + SelectButtonC3A1->setText( tr( "" ) ); + SelectButtonC3A1->setPixmap( image1 ); + SelectButtonC3A1->setToggleButton( FALSE ); + SelectButtonC3A1->setMaximumSize( QSize( 28, 32767 ) ); + GroupC3Layout->addWidget( SelectButtonC3A1, 0, 1 ); + OperationGUI_FilletDlgLayout->addWidget( GroupC3, 1, 0 ); + + /* Initialisation */ + myOperationGUI = theOperationGUI; + Init( Sel, ic ) ; +} + + +//================================================================================= +// function : ~OperationGUI_FilletDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +OperationGUI_FilletDlg::~OperationGUI_FilletDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ + this->destroy(TRUE, TRUE) ; +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) +{ + + /* 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_C1A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; + SpinBox_C1A2->SetValue( 50 ) ; + SpinBox_C2A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; + SpinBox_C2A2->SetValue( 50 ) ; + SpinBox_C3A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; + SpinBox_C3A2->SetValue( 50 ) ; + + GroupC1->show(); + GroupC2->hide() ; + GroupC3->hide() ; + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + + mySelection = Sel ; + myEditCurrentArgument = LineEditC1A1 ; + myShape.Nullify() ; + myRadius = 50.0 ; + myOkRadius = true ; + myIC = ic ; + myLocalContextId = -1 ; + myUseLocalContext = false ; + myOkShape = false ; + + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + + mySimulationTopoDs.Nullify() ; + + /* Filters definition */ + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC3A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( SpinBox_C1A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_C2A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_C3A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + + connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC3A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* Displays Dialog */ + + return ; +} + + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void OperationGUI_FilletDlg::ConstructorsClicked(int constructorId) +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + myEditCurrentArgument->setText(tr("")) ; + + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext(); + if(this->myUseLocalContext) { + myIC->CloseLocalContext(this->myLocalContextId) ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + this->myUseLocalContext = false ; + } + } + + myOkShape = false ; + myRadius = 50.0 ; + myOkRadius = true ; + myConstructorId = constructorId ; + + // connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + switch (constructorId) + { + case 0: /* Fillet All */ + { + myShapeType = -1; + GroupC1->show(); + GroupC2->hide() ; + GroupC3->hide() ; + myEditCurrentArgument = LineEditC1A1 ; + SpinBox_C1A2->SetValue( 50 ) ;; + LineEditC1A1->setText(tr("")) ; + break; + } + + case 1: /* Fillet edges */ + { + myShapeType = 6; + GroupC1->hide(); + GroupC2->show() ; + GroupC3->hide() ; + myEditCurrentArgument = LineEditC2A1 ; + SpinBox_C2A2->SetValue( 50 ) ;; + LineEditC2A1->setText(tr("")) ; + break ; + } + + case 2: /* Fillet Faces */ + { + myShapeType = 4; + GroupC1->hide(); + GroupC2->hide() ; + GroupC3->show() ; + myEditCurrentArgument = LineEditC3A1 ; + SpinBox_C3A2->SetValue( 50 ) ;; + LineEditC3A1->setText(tr("")) ; + break ; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::ClickOnApply() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + bool testResult = false ; + myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + switch(myConstructorId) + { + case 0 : /* Fillet All */ + { + if(myOkRadius) { + if( myOkShape ) { + testResult = myOperationGUI->OnFilletGetAll( myShape, myRadius, myShapeType, myShapeIOR ) ; + } + } + if( !testResult ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ; + } else { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ; + } + /* Reset all arguments and local context to allow user a new selection ...*/ + this->ResetStateOfDialog() ; + break ; + } + + case 1 : /* Fillet Edge */ + { + if(myOkRadius) { + if( myOkShape ) { + testResult = myOperationGUI->OnFilletGetSelected( myShape, myShapeIOR, myRadius, myShapeType, myLocalContextId, myUseLocalContext ); + } + } + if( !testResult ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ; + } else { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ; + } + /* Reset all arguments and local context to allow user a new selection ...*/ + this->ResetStateOfDialog() ; + break ; + } + + case 2 : /* Fillet Face */ + { + if(myOkRadius) { + if( myOkShape ) { + testResult = myOperationGUI->OnFilletGetSelected( myShape, myShapeIOR, myRadius, myShapeType, myLocalContextId, myUseLocalContext ) ; + } + } + if( !testResult ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ; + } else { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ; + } + /* Reset all arguments and local context to allow user a new selection ...*/ + this->ResetStateOfDialog() ; + break ; + } + } + + // accept(); + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::ClickOnCancel() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext(); + if(this->myUseLocalContext) { + myIC->CloseLocalContext(this->myLocalContextId) ; + this->myUseLocalContext = false ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + } + reject() ; + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + return ; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + else if ( send == LineEditC2A1 ) + myEditCurrentArgument = LineEditC2A1 ; + else if ( send == LineEditC3A1 ) + myEditCurrentArgument = LineEditC3A1 ; + 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 ; +} + + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void OperationGUI_FilletDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + /* Reset all arguments and local context when selection as changed */ + this->ResetStateOfDialog() ; + + /* Future name of argument */ + QString aString = ""; + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel == 1 ) { + + TopoDS_Shape S ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if( !IO->hasEntry() ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")) ; + return ; + } + + if ( !S.IsNull() && S.ShapeType() <= 2 ) { + if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { + Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO ); + myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */ + myEditCurrentArgument->setText(aString) ; + myShape = S ; + myOkShape = true ; + } + + if ( IO->hasEntry() ) { + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + myShapeIOR = anIOR->Value(); + myOkShape = true ; + myShape = S ; + myEditCurrentArgument->setText(aString) ; + } + } + } + } + + MakePreview(); + + } else + return; + + if( myOkShape && myShapeType!=-1 && myConstructorId != 0 ) { + /* local context is defined into the method */ + myGeomGUI->PrepareSubShapeSelection( this->myShapeType, this->myLocalContextId ) ; + myUseLocalContext = true ; + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_EDGE")) ; + } +} + + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + switch (myConstructorId) + { + case 0: + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + SelectionIntoArgument() ; + } + break; + } + + case 1: + { + if(send ==SelectButtonC2A1 ) { + LineEditC2A1->setFocus() ; + myEditCurrentArgument = LineEditC2A1; + SelectionIntoArgument() ; + } + break; + } + + case 2: + { + if(send ==SelectButtonC3A1 ) { + LineEditC3A1->setFocus() ; + myEditCurrentArgument = LineEditC3A1; + SelectionIntoArgument() ; + } + break; + } + } + return ; +} + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::ValueChangedInSpinBox( double newValue ) +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + myRadius = newValue ; + myOkRadius = true ; + + MakePreview(); +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + this->ResetStateOfDialog() ; + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupC2->setEnabled(false) ; + GroupC3->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + myGeomGUI->SetActiveDialogBox(0) ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupC2->setEnabled(true) ; + GroupC3->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + + if( !mySimulationTopoDs.IsNull() ) + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::enterEvent( QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +//================================================================================= +// function : ResetStateOfDialog() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::ResetStateOfDialog() +{ + this->myOkShape = false ; + this->myEditCurrentArgument->setText("") ; + + /* Close its local contact if opened */ + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext(); + if(this->myUseLocalContext) { + myIC->CloseLocalContext(this->myLocalContextId) ; + this->myUseLocalContext = false ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + } + return ; +} + + +void OperationGUI_FilletDlg::MakePreview() +{ + TopoDS_Shape tds ; + try + { + BRepFilletAPI_MakeFillet fill(myShape); + switch (myConstructorId) + { + case 0: /* Fillet All */ + { + TopExp_Explorer Exp ( myShape, TopAbs_EDGE ); + for (Exp; Exp.More(); Exp.Next()) + { + TopoDS_Edge E =TopoDS::Edge(Exp.Current()); + fill.Add(E); + } + for (int i = 1;i<=fill.NbContours();i++) + fill.SetRadius(myRadius,i); + + tds = fill.Shape(); + break; + } +// case 1: /* Fillet edges */ +// case 2: /* Fillet Faces */ + } + if (!tds.IsNull()) + { + mySimulationTopoDs = tds; + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + } + } + catch(Standard_Failure) + { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } +} diff --git a/src/OperationGUI/OperationGUI_FilletDlg.h b/src/OperationGUI/OperationGUI_FilletDlg.h new file mode 100644 index 000000000..a32bc4370 --- /dev/null +++ b/src/OperationGUI/OperationGUI_FilletDlg.h @@ -0,0 +1,163 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : OperationGUI_FilletDlg.h +// Author : Damien COQUERET +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_FILLET_H +#define DIALOGBOX_FILLET_H + +#include "OperationGUI.h" + +#include "DlgRef_SpinBox.h" + +// Qt Includes +#include +#include +#include + +// Open CASCADE Includes +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QFrame; +class QGroupBox; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QToolButton; +class QLabel; + +//================================================================================= +// class : OperationGUI_FilletDlg +// purpose : +//================================================================================= +class OperationGUI_FilletDlg : public QDialog +{ + Q_OBJECT + +public: + OperationGUI_FilletDlg( QWidget* parent = 0, + const char* name = 0, + OperationGUI* theOperationGUI = 0, + SALOME_Selection* Sel = 0, + Handle (AIS_InteractiveContext) ic = 0, + bool modal = FALSE, + WFlags fl = 0 ); + + ~OperationGUI_FilletDlg(); + +private : + OperationGUI* myOperationGUI; + void Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent( QEvent* e); + void ResetStateOfDialog() ; + + /* Interactive and local context management see also : bool myUseLocalContext() */ + Handle (AIS_InteractiveContext) myIC ; /* Interactive context */ + Standard_Integer myLocalContextId ; /* identify a local context used by this method */ + bool myUseLocalContext ; /* true when this method as opened a local context */ + + QDoubleValidator *myVa ; /* Double validator for numeric input */ + + 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 */ + void MakePreview(); + + TopoDS_Shape myShape ; + bool myOkShape ; + char* myShapeIOR ; + + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + int myConstructorId ; /* Current constructor id = radio button id */ + int myShapeType ; + + bool myOkRadius ; + double myRadius ; + + QButtonGroup* GroupConstructors; + + QRadioButton* Constructor1; + QRadioButton* Constructor2; + QRadioButton* Constructor3; + + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + + QGroupBox* GroupC1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + QLabel* TextLabelC1A1; + DlgRef_SpinBox* SpinBox_C1A2 ; + QLabel* TextLabelC1A2; + + QGroupBox* GroupC2; + QPushButton* SelectButtonC2A1; + QLineEdit* LineEditC2A1; + QLabel* TextLabelC2A1; + DlgRef_SpinBox* SpinBox_C2A2 ; + QLabel* TextLabelC2A2; + + QGroupBox* GroupC3; + QPushButton* SelectButtonC3A1; + QLineEdit* LineEditC3A1; + QLabel* TextLabelC3A1; + DlgRef_SpinBox* SpinBox_C3A2 ; + QLabel* TextLabelC3A2; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void LineEditReturnPressed() ; + void ActivateThisDialog() ; + void ValueChangedInSpinBox( double newValue ) ; + +protected: + + QGridLayout* OperationGUI_FilletDlgLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; + QGridLayout* GroupC2Layout; + QGridLayout* GroupC3Layout; +}; + +#endif // DIALOGBOX_FILLET_H + diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.cxx b/src/OperationGUI/OperationGUI_PartitionDlg.cxx new file mode 100644 index 000000000..7015a67d1 --- /dev/null +++ b/src/OperationGUI/OperationGUI_PartitionDlg.cxx @@ -0,0 +1,526 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : OperationGUI_PartitionDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "OperationGUI_PartitionDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MIN_EDIT_SIZE 150 + +//================================================================================= +// class : OperationGUI_PartitionDlg() +// purpose : Constructs a OperationGUI_PartitionDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( QWidget* parent, const char* name, OperationGUI* theOperationGUI, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_PARTITION"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); +// QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "OperationGUI",tr("ICON_DLG_PARTITION_KEEP_FACES"))); + + if ( !name ) + setName( "OperationGUI_PartitionDlg" ); + setCaption( tr( "GEOM_PARTITION_TITLE" ) ); + setSizeGripEnabled( TRUE ); + QGridLayout* OperationGUI_PartitionDlgLayout = new QGridLayout( this ); + OperationGUI_PartitionDlgLayout->setSpacing( 6 ); + OperationGUI_PartitionDlgLayout->setMargin( 11 ); + + /***************************************************************/ + /* Constructor group */ + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_PARTITION" ) ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + QGridLayout* GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + GroupConstructorsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 0 ); + + OperationGUI_PartitionDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + /* Arguments group */ + /***************************************************************/ + /* Shapes and Tools */ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_PARTITION" ) ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "GEOM_OBJECTS" ) ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + LineEditC1A1->setMinimumSize(MIN_EDIT_SIZE, 0); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" ); + TextLabelC1A2->setText( tr( "GEOM_TOOL_OBJECT" ) ); + GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); + SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); + SelectButtonC1A2->setPixmap( image1 ); + SelectButtonC1A2->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); + LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); + LineEditC1A2->setMinimumSize(MIN_EDIT_SIZE, 0); + GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); + + /* Limit */ + TextLabelComboBox1 = new QLabel( GroupC1, "TextLabelComboBox1" ); + TextLabelComboBox1->setText( tr( "RECONSTRUCTION_LIMIT") ); + GroupC1Layout->addWidget( TextLabelComboBox1, 2, 0 ); + ComboBox1 = new QComboBox( FALSE, GroupC1, "ComboBox1" ); + ComboBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + ComboBox1->setMinimumSize(MIN_EDIT_SIZE, 0); + GroupC1Layout->addWidget( ComboBox1, 2, 2 ); + + OperationGUI_PartitionDlgLayout->addWidget( GroupC1, 1, 0 ); + + /***************************************************************/ + /* Result suppresion */ + /***************************************************************/ + GroupC2 = new QGroupBox( this, "GroupC2" ); + GroupC2->setTitle( tr( "SUPPRESS_RESULT") ); + GroupC2->setColumnLayout(0, Qt::Vertical ); + GroupC2->layout()->setSpacing( 0 ); + GroupC2->layout()->setMargin( 0 ); + QGridLayout* GroupC2Layout = new QGridLayout( GroupC2->layout() ); + GroupC2Layout->setAlignment( Qt::AlignTop ); + GroupC2Layout->setSpacing( 6 ); + GroupC2Layout->setMargin( 11 ); + + TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" ); + TextLabelC2A1->setText( tr( "SUPPRESS_RESULT_INSIDE") ); + GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 ); + SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" ); + SelectButtonC2A1->setPixmap( image1 ); + GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 ); + LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" ); + GroupC2Layout->addWidget( LineEditC2A1, 0, 2 ); + + TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" ); + TextLabelC2A2->setText( tr( "SUPPRESS_RESULT_OUTSIDE") ); + GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 ); + SelectButtonC2A2 = new QPushButton( GroupC2, "SelectButtonC2A2" ); + SelectButtonC2A2->setPixmap( image1 ); + GroupC2Layout->addWidget( SelectButtonC2A2, 1, 1 ); + LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" ); + GroupC2Layout->addWidget( LineEditC2A2, 1, 2 ); + + OperationGUI_PartitionDlgLayout->addWidget( GroupC2, 2, 0 ); + + /***************************************************************/ + /* , , buttons */ + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "GEOM_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "GEOM_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + + GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 ); + + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + + OperationGUI_PartitionDlgLayout->addWidget( GroupButtons, 3, 0 ); + + /***************************************************************/ + myOperationGUI = theOperationGUI; + Init(Sel) ; /* Initialisations */ +} + + +//================================================================================= +// function : ~OperationGUI_PartitionDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +OperationGUI_PartitionDlg::~OperationGUI_PartitionDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void OperationGUI_PartitionDlg::Init( SALOME_Selection* Sel ) +{ + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + myOkListShapes = myOkListTools = myOkKeepShape = myOkRemoveShape = false ; + + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* type for sub shape selection */ +// ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_SHAPE" ) ); + ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_SOLID" ) ); + ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_SHELL" ) ); + ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_FACE" ) ); + ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_WIRE" ) ); + ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_EDGE" ) ); + ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_VERTEX" ) ); + + /* Current item is 'Shape' */ + ComboBox1->setCurrentItem(0); + myLimit = ComboBox1->currentItem(); + + /* Filter definitions */ + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); + + /* 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( ComboBox1, SIGNAL( activated(int) ), this, SLOT( ComboTextChanged() ) ); + + connect( SelectButtonC1A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC1A2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( SelectButtonC2A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC2A2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( LineEditC1A1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC1A2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC2A1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC2A2, 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 */ + + ComboTextChanged(); + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void OperationGUI_PartitionDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void OperationGUI_PartitionDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + if (myOkListShapes || myOkListTools || myOkKeepShape || myOkRemoveShape) + { + GEOM::shape_type limit; + switch (myLimit) { +// case 0: limit = GEOM::SOLID ; break; + case 0: limit = GEOM::SHAPE ; break; + case 1: limit = GEOM::SHELL ; break; + case 2: limit = GEOM::FACE ; break; + case 3: limit = GEOM::WIRE ; break; + case 4: limit = GEOM::EDGE ; break; + case 5: limit = GEOM::VERTEX; break; + default:limit = GEOM::SHAPE; + } + myOperationGUI->MakePartitionAndDisplay (myListShapes, + myListTools, + myListKeepInside, + myListRemoveInside, + limit); + + } + // accept(); + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void OperationGUI_PartitionDlg::ClickOnCancel() +{ + myGeomGUI->EraseSimulationShape() ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : +//================================================================================= +// void OperationGUI_PartitionDlg::ConstructorsClicked(int constructorId) +// { +// } + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void OperationGUI_PartitionDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + QString aString = ""; /* name of selection */ + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + + if ( nbSel < 1 ) { + if ( myEditCurrentArgument == LineEditC1A1 ) { + myOkListShapes = false ; + } + else if ( myEditCurrentArgument == LineEditC1A2 ) { + myOkListTools = false ; + } + else if ( myEditCurrentArgument == LineEditC2A1 ) { + myOkListTools = false ; + } + else if ( myEditCurrentArgument == LineEditC2A2 ) { + myOkListTools = false ; + } + return ; + } + + if ( myEditCurrentArgument == LineEditC1A1 ) { + myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes) ; + myEditCurrentArgument->setText(aString) ; + myOkListShapes = true ; + } + else if ( myEditCurrentArgument == LineEditC1A2 ) { + myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListTools) ; + myEditCurrentArgument->setText(aString) ; + myOkListTools = true ; + } + else if ( myEditCurrentArgument == LineEditC2A1 ) { + myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListRemoveInside) ; + myEditCurrentArgument->setText(aString) ; + myOkKeepShape = true ; + } + else if ( myEditCurrentArgument == LineEditC2A2 ) { + myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListKeepInside) ; + myEditCurrentArgument->setText(aString) ; + myOkRemoveShape = true ; + } + /* no simulation */ + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void OperationGUI_PartitionDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if (send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1 ; + } + else if(send == SelectButtonC1A2) { + LineEditC1A2->setFocus() ; + myEditCurrentArgument = LineEditC1A2 ; + } + else if(send == SelectButtonC2A1) { + LineEditC2A1->setFocus() ; + myEditCurrentArgument = LineEditC2A1 ; + } + else if(send == SelectButtonC2A2) { + LineEditC2A2->setFocus() ; + myEditCurrentArgument = LineEditC2A2 ; + } + SelectionIntoArgument() ; + + return ; +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void OperationGUI_PartitionDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + else if ( send == LineEditC1A2 ) + myEditCurrentArgument = LineEditC1A2 ; + else if ( send == LineEditC2A1 ) + myEditCurrentArgument = LineEditC2A1 ; + else if ( send == LineEditC2A2 ) + myEditCurrentArgument = LineEditC2A2 ; + 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 ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= + +void OperationGUI_PartitionDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupC2->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void OperationGUI_PartitionDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupC2->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void OperationGUI_PartitionDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void OperationGUI_PartitionDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + +//======================================================================= +//function : ComboTextChanged +//purpose : +//======================================================================= + +void OperationGUI_PartitionDlg::ComboTextChanged() +{ + + myLimit = ComboBox1->currentItem(); + GroupC2->setEnabled( ComboBox1->currentItem() < 3 ); + + return ; +} diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.h b/src/OperationGUI/OperationGUI_PartitionDlg.h new file mode 100644 index 000000000..aa1526885 --- /dev/null +++ b/src/OperationGUI/OperationGUI_PartitionDlg.h @@ -0,0 +1,125 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : OperationGUI_PartitionDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_PARTITION_H +#define DIALOGBOX_PARTITION_H + +#include "OperationGUI.h" + +#include + +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QComboBox; + + +//================================================================================= +// class : OperationGUI_PartitionDlg +// purpose : +//================================================================================= +class OperationGUI_PartitionDlg : public QDialog +{ + Q_OBJECT + +public: + OperationGUI_PartitionDlg( QWidget* parent = 0, const char* name = 0, OperationGUI* theOperationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~OperationGUI_PartitionDlg(); + +private: + OperationGUI* myOperationGUI; + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* Mouse enter the QWidget */ + + GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + + GEOM::GEOM_Gen::ListOfIOR myListShapes ; + GEOM::GEOM_Gen::ListOfIOR myListTools ; + GEOM::GEOM_Gen::ListOfIOR myListRemoveInside ; + GEOM::GEOM_Gen::ListOfIOR myListKeepInside ; + + bool myOkListShapes ; /* to check when argument is defined */ + bool myOkListTools ; /* to check when argument is defined */ + bool myOkKeepShape ; /* to check when argument is defined */ + bool myOkRemoveShape ; /* to check when argument is defined */ + int myLimit; + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + /* common buttons */ + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + + /* constructor radiobuttons */ + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + + /* Arguments group */ + QGroupBox* GroupC1; + QLineEdit* LineEditC1A1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A2; + QLabel* TextLabelC1A2; + QPushButton* SelectButtonC1A2; + + /* limit */ + QComboBox* ComboBox1; + QLabel* TextLabelComboBox1; + + /* Keep Inside and Remove Inside feilds */ + QGroupBox* GroupC2; + QLineEdit* LineEditC2A1; + QLabel* TextLabelC2A1; + QPushButton* SelectButtonC2A1; + QLineEdit* LineEditC2A2; + QLabel* TextLabelC2A2; + QPushButton* SelectButtonC2A2; + +private slots: + + //void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void LineEditReturnPressed() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void ComboTextChanged() ; +}; + +#endif // DIALOGBOX_PARTITION_H diff --git a/src/PrimitiveGUI/Makefile.in b/src/PrimitiveGUI/Makefile.in new file mode 100644 index 000000000..925325715 --- /dev/null +++ b/src/PrimitiveGUI/Makefile.in @@ -0,0 +1,75 @@ +# GEOM PRIMITIVEGUI : +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Damien COQUERET (OCC) +# Module : GEOM +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= PrimitiveGUI.h + +# Libraries targets +LIB = libPrimitiveGUI.la + +LIB_SRC = PrimitiveGUI.cxx \ + PrimitiveGUI_BoxDlg.cxx \ + PrimitiveGUI_CylinderDlg.cxx \ + PrimitiveGUI_SphereDlg.cxx \ + PrimitiveGUI_TorusDlg.cxx \ + PrimitiveGUI_ConeDlg.cxx + +LIB_MOC = \ + PrimitiveGUI.h \ + PrimitiveGUI_BoxDlg.h \ + PrimitiveGUI_CylinderDlg.h \ + PrimitiveGUI_SphereDlg.h \ + PrimitiveGUI_TorusDlg.h \ + PrimitiveGUI_ConeDlg.h + +LIB_CLIENT_IDL = SALOME_Exception.idl \ + GEOM_Gen.idl \ + GEOM_Shape.idl \ + SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +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 -lDlgRef -lGEOMBase $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/PrimitiveGUI/PrimitiveGUI.cxx b/src/PrimitiveGUI/PrimitiveGUI.cxx new file mode 100644 index 000000000..dcc8c244b --- /dev/null +++ b/src/PrimitiveGUI/PrimitiveGUI.cxx @@ -0,0 +1,236 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : PrimitiveGUI.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "PrimitiveGUI.h" + +#include "PrimitiveGUI_BoxDlg.h" // Method BOX +#include "PrimitiveGUI_CylinderDlg.h" // Method CYLINDER +#include "PrimitiveGUI_SphereDlg.h" // Method SPHERE +#include "PrimitiveGUI_TorusDlg.h" // Method TORUS +#include "PrimitiveGUI_ConeDlg.h" // Method CONE + +//======================================================================= +// function : PrimitiveGUI() +// purpose : Constructor +//======================================================================= +PrimitiveGUI::PrimitiveGUI() : + QObject() +{ + myGeomGUI = GEOMBase_Context::GetGeomGUI(); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); +} + + +//======================================================================= +// function : ~PrimitiveGUI() +// purpose : Destructor +//======================================================================= +PrimitiveGUI::~PrimitiveGUI() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool PrimitiveGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + switch (theCommandID) + { + case 3021: // BOX + { + PrimitiveGUI_BoxDlg *aDlg = new PrimitiveGUI_BoxDlg(parent, "", this, Sel); + break; + } + case 3022: // CYLINDER + { + PrimitiveGUI_CylinderDlg *aDlg = new PrimitiveGUI_CylinderDlg(parent, "", this, Sel); + break; + } + case 3023: // SPHERE + { + PrimitiveGUI_SphereDlg *aDlg = new PrimitiveGUI_SphereDlg(parent, "", this, Sel); + break; + } + case 3024: // TORUS + { + PrimitiveGUI_TorusDlg *aDlg = new PrimitiveGUI_TorusDlg(parent, "", this, Sel); + break; + } + case 3025: // CONE + { + PrimitiveGUI_ConeDlg *aDlg = new PrimitiveGUI_ConeDlg(parent, "", this, Sel); + break; + } + default: + { + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + } + return true; +} + + +//======================================================================= +// function : MakeBoxAndDisplay() +// purpose : +//======================================================================= +void PrimitiveGUI::MakeBoxAndDisplay(const gp_Pnt P1, const gp_Pnt P2) +{ + try { + GEOM::GEOM_Shape_var box = myGeom->MakeBox(P1.X(), P1.Y(), P1.Z(), P2.X(), P2.Y(), P2.Z()); + box->NameType(tr("GEOM_BOX")); + if(myGeomGUI->Display(box, "")) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } +} + + +//===================================================================================== +// function : MakeCylinderAndDisplay() +// purpose : +//===================================================================================== +void PrimitiveGUI::MakeCylinderAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, + const double Radius, const double aHeight) +{ + try { + if(Radius <= Precision::Confusion() || aHeight <= Precision::Confusion()) + return; + + GEOM::PointStruct pstruct = myGeom->MakePointStruct(BasePoint.X(), BasePoint.Y(), BasePoint.Z()); + GEOM::PointStruct d = myGeom->MakePointStruct(aDir.X(), aDir.Y(), aDir.Z()); + GEOM::DirStruct dstruct = myGeom->MakeDirection(d); + + GEOM::GEOM_Shape_var result = myGeom->MakeCylinder(pstruct, dstruct, Radius, aHeight); + if (result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_CYLINDER")); + if(myGeomGUI->Display(result, "")) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeSphere() +// purpose : +//===================================================================================== +void PrimitiveGUI::MakeSphereAndDisplay(const gp_Pnt aCenterPoint, const double aRadius) +{ + try { + if(aRadius <= Precision::Confusion()) + return; + + GEOM::GEOM_Shape_ptr result = myGeom->MakeSphere(aCenterPoint.X(),aCenterPoint.Y(),aCenterPoint.Z(), aRadius); + result->NameType(tr("GEOM_SPHERE")); + if (myGeomGUI->Display(result, "")) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeTorusAndDisplay() +// purpose : +//===================================================================================== +void PrimitiveGUI::MakeTorusAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, + const double Radius1, const double Radius2) +{ + try { + if(Radius1 <= Precision::Confusion() || Radius2 <= Precision::Confusion()) + return; + + GEOM::PointStruct pstruct = myGeom->MakePointStruct(BasePoint.X(), BasePoint.Y(), BasePoint.Z()); + GEOM::PointStruct d = myGeom ->MakePointStruct(aDir.X(), aDir.Y(), aDir.Z()); + GEOM::DirStruct dstruct = myGeom->MakeDirection(d); + + GEOM::GEOM_Shape_var result = myGeom->MakeTorus(pstruct, dstruct, Radius1, Radius2); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_TORUS")); + if(myGeomGUI->Display(result, "")) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeConeAndDisplay() +// purpose : +//===================================================================================== +void PrimitiveGUI::MakeConeAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, + const double Radius1, const double Radius2, const double aHeight) +{ + try { + if((Radius1 <= Precision::Confusion() && Radius2 <= Precision::Confusion()) || aHeight <= Precision::Confusion()) + return; + + GEOM::PointStruct pstruct = myGeom->MakePointStruct(BasePoint.X(), BasePoint.Y(), BasePoint.Z()); + GEOM::PointStruct d = myGeom->MakePointStruct(aDir.X(), aDir.Y(), aDir.Z()); + GEOM::DirStruct dstruct = myGeom->MakeDirection(d); + + GEOM::GEOM_Shape_var result = myGeom->MakeCone(pstruct, dstruct, Radius1, Radius2, aHeight); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_CONE")); + if(myGeomGUI->Display(result, "")) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} diff --git a/src/PrimitiveGUI/PrimitiveGUI.h b/src/PrimitiveGUI/PrimitiveGUI.h new file mode 100644 index 000000000..fb6de3fdf --- /dev/null +++ b/src/PrimitiveGUI/PrimitiveGUI.h @@ -0,0 +1,64 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : PrimitiveGUI.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef PRIMITIVEGUI_H +#define PRIMITIVEGUI_H + +#include "GEOMBase_Display.h" +#include "QAD_Config.h" + +//================================================================================= +// class : PrimitiveGUI +// purpose : +//================================================================================= +class PrimitiveGUI : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + PrimitiveGUI(); + ~PrimitiveGUI(); + + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + + void MakeBoxAndDisplay(const gp_Pnt P1, const gp_Pnt P2); + void MakeCylinderAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, + const double Radius, const double aHeight); + void MakeSphereAndDisplay(const gp_Pnt aCenterPoint, const double aRadius); + void MakeTorusAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, + const double Radius1, const double Radius2); + void MakeConeAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, + const double Radius1, const double Radius2, const double aHeight); + +private: + GEOMBase_Context* myGeomGUI; + GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + +}; + +#endif diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx new file mode 100644 index 000000000..3b6a64afe --- /dev/null +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx @@ -0,0 +1,400 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : PrimitiveGUI_BoxDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "PrimitiveGUI_BoxDlg.h" + +#include + +//================================================================================= +// class : PrimitiveGUI_BoxDlg() +// purpose : Constructs a PrimitiveGUI_BoxDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +PrimitiveGUI_BoxDlg::PrimitiveGUI_BoxDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, 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_BOX_2P"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_DLG_BOX_DXYZ"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setCaption(tr("GEOM_BOX_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_BOX")); + RadioButton1->setPixmap(image0); + RadioButton2->setPixmap(image1); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_2Sel_QTD(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_DIAGONAL_POINTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_POINT_I").arg("1")); + GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg("2")); + GroupPoints->PushButton1->setPixmap(image2); + GroupPoints->PushButton2->setPixmap(image2); + + GroupDimensions = new DlgRef_3Spin(this, "GroupDimensions"); + GroupDimensions->GroupBox1->setTitle(tr("GEOM_BOX_OBJ")); + GroupDimensions->TextLabel1->setText(tr("GEOM_DX")); + GroupDimensions->TextLabel2->setText(tr("GEOM_DY")); + GroupDimensions->TextLabel3->setText(tr("GEOM_DZ")); + + Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupDimensions, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myPrimitiveGUI = thePrimitiveGUI; + Init(); +} + + +//================================================================================= +// function : ~DialogBox_Box() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +PrimitiveGUI_BoxDlg::~PrimitiveGUI_BoxDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void PrimitiveGUI_BoxDlg::Init() +{ + /* init variables */ + myConstructorId = 0; + myEditCurrentArgument = GroupPoints->LineEdit1; + + myPoint1.SetCoord(0.0, 0.0, 0.0); + myPoint2.SetCoord(0.0, 0.0, 0.0); + myOkPoint1 = myOkPoint2 = false; + + /* Vertices Filter for all arguments */ + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + mySelection->AddFilter(myVertexFilter); + + /* 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 */ + GroupDimensions->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupDimensions->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); + + double initValue = 200.0; + GroupDimensions->SpinBox_DX->SetValue(initValue); + GroupDimensions->SpinBox_DY->SetValue(initValue); + GroupDimensions->SpinBox_DZ->SetValue(initValue); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupDimensions->hide(); + GroupPoints->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void PrimitiveGUI_BoxDlg::ConstructorsClicked(int constructorId) +{ + myConstructorId = constructorId; + mySelection->ClearFilters(); + myGeomGUI->EraseSimulationShape(); + disconnect(mySelection, 0, this, 0); + myOkPoint1 = myOkPoint2 = false; + + switch (constructorId) + { + case 0: + { + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(""); + GroupPoints->LineEdit2->setText(""); + + /* filter for next selection */ + mySelection->AddFilter(myVertexFilter); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + break; + } + case 1: + { + GroupPoints->hide(); + resize( 0, 0 ); + GroupDimensions->show(); + + double initValue = 200.0; + GroupDimensions->SpinBox_DX->SetValue(initValue); + GroupDimensions->SpinBox_DY->SetValue(initValue); + GroupDimensions->SpinBox_DZ->SetValue(initValue); + + myPoint1.SetCoord(0.0, 0.0, 0.0) ; + myPoint2.SetCoord(initValue, initValue, initValue); + + mySimulationTopoDs = BRepPrimAPI_MakeBox(myPoint1, myPoint2).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + break; + } + } + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void PrimitiveGUI_BoxDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void PrimitiveGUI_BoxDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + switch(myConstructorId) + { + case 0 : + { + if(myOkPoint1 && myOkPoint2) + myPrimitiveGUI->MakeBoxAndDisplay(myPoint1, myPoint2); + break; + } + case 1 : + { + /* Recup args and call method */ + double vx = GroupDimensions->SpinBox_DX->GetValue(); + double vy = GroupDimensions->SpinBox_DY->GetValue(); + double vz = GroupDimensions->SpinBox_DZ->GetValue(); + myPoint1.SetCoord(0.0, 0.0, 0.0); + myPoint2.SetCoord(vx, vy, vz); + myPrimitiveGUI->MakeBoxAndDisplay(myPoint1, myPoint2); + break; + } + } + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed +//================================================================================= +void PrimitiveGUI_BoxDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if (nbSel != 1) { + if (myEditCurrentArgument == GroupPoints->LineEdit1) + myOkPoint1 = false; + else if ( myEditCurrentArgument == GroupPoints->LineEdit2) + myOkPoint2 = false; + return; + } + + // nbSel == 1 + TopoDS_Shape S; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + myEditCurrentArgument->setText(aString); + myOkPoint1 = true; + } + else if(myEditCurrentArgument == GroupPoints->LineEdit2 && myGeomGUI->VertexToPoint(S, myPoint2)) { + myEditCurrentArgument->setText(aString); + myOkPoint2 = true; + } + + if(myOkPoint1 && myOkPoint2 && TestBoxDimensions(myPoint1, myPoint2)) { + mySimulationTopoDs = BRepPrimAPI_MakeBox(myPoint1, myPoint2).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void PrimitiveGUI_BoxDlg::SetEditCurrentArgument() +{ + if(myConstructorId != 0) + return; + + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + } + mySelection->AddFilter(myVertexFilter); + this->SelectionIntoArgument(); + + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void PrimitiveGUI_BoxDlg::LineEditReturnPressed() +{ + 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 : ActivateThisDialog() +// purpose : +//================================================================================= +void PrimitiveGUI_BoxDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} + + +//================================================================================= +// function : enterEvent [REDEFINED] +// purpose : +//================================================================================= +void PrimitiveGUI_BoxDlg::enterEvent(QEvent* e) +{ + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void PrimitiveGUI_BoxDlg::ValueChangedInSpinBox(double newValue) +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + QObject* send = (QObject*)sender(); + double vx, vy, vz; + + if(send == GroupDimensions->SpinBox_DX) + vx = newValue; + else if(send == GroupDimensions->SpinBox_DY) + vy = newValue; + else if(send == GroupDimensions->SpinBox_DZ) + vz = newValue; + + myPoint1.SetCoord(0.0, 0.0, 0.0); + myPoint2.SetCoord(vx, vy, vz); + + if(TestBoxDimensions(myPoint1, myPoint2)) { + mySimulationTopoDs = BRepPrimAPI_MakeBox(myPoint1, myPoint2).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + return; +} + + +//================================================================================= +// function : TestBoxDimensions() +// purpose : +//================================================================================= +bool PrimitiveGUI_BoxDlg::TestBoxDimensions(gp_Pnt P1, gp_Pnt P2) +{ + if ((fabs(P1.X() - P2.X()) > Precision::Confusion()) && + (fabs(P1.Y() - P2.Y()) > Precision::Confusion()) && + (fabs(P1.Z() - P2.Z()) > Precision::Confusion())) + return true; + return false; +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h new file mode 100644 index 000000000..655e0a4a3 --- /dev/null +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h @@ -0,0 +1,83 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : PrimitiveGUI_BoxDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_BOX_H +#define DIALOGBOX_BOX_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel_QTD.h" +#include "DlgRef_3Spin.h" + +#include "PrimitiveGUI.h" + +#include + +//================================================================================= +// class : PrimitiveGUI_BoxDlg +// purpose : +//================================================================================= +class PrimitiveGUI_BoxDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + PrimitiveGUI_BoxDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~PrimitiveGUI_BoxDlg(); + +private : + void Init(); + void enterEvent(QEvent* e); + bool TestBoxDimensions(gp_Pnt P1, gp_Pnt P2); + + PrimitiveGUI* myPrimitiveGUI; + + double step; + int myConstructorId; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* filter for selection */ + + gp_Pnt myPoint1; /* Points containing the vector */ + gp_Pnt myPoint2; + bool myOkPoint1; /* true when myPoint is defined */ + bool myOkPoint2; + + DlgRef_2Sel_QTD* GroupPoints; + DlgRef_3Spin* GroupDimensions; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked(int constructorId); + void ValueChangedInSpinBox(double newValue); + +}; + +#endif // DIALOGBOX_BOX_H diff --git a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx new file mode 100644 index 000000000..fb4983dfd --- /dev/null +++ b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx @@ -0,0 +1,430 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : PrimitiveGUI_ConeDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "PrimitiveGUI_ConeDlg.h" + +#include +#include +#include + +//================================================================================= +// class : PrimitiveGUI_ConeDlg() +// purpose : Constructs a PrimitiveGUI_ConeDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +PrimitiveGUI_ConeDlg::PrimitiveGUI_ConeDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, 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_CONE_PV"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CONE_DXYZ"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_CONE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_CONE")); + RadioButton1->setPixmap(image0); + RadioButton2->setPixmap(image1); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_2Sel3Spin(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_BASE_POINT")); + GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS_I").arg("1")); + GroupPoints->TextLabel4->setText(tr("GEOM_RADIUS_I").arg("2")); + GroupPoints->TextLabel5->setText(tr("GEOM_HEIGHT")); + GroupPoints->PushButton1->setPixmap(image2); + GroupPoints->PushButton2->setPixmap(image2); + + GroupDimensions = new DlgRef_3Spin(this, "GroupDimensions"); + GroupDimensions->GroupBox1->setTitle(tr("GEOM_BOX_OBJ")); + GroupDimensions->TextLabel1->setText(tr("GEOM_RADIUS_I").arg("1")); + GroupDimensions->TextLabel2->setText(tr("GEOM_RADIUS_I").arg("2")); + GroupDimensions->TextLabel3->setText(tr("GEOM_HEIGHT")); + + Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupDimensions, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myPrimitiveGUI = thePrimitiveGUI; + Init(); +} + + +//================================================================================= +// function : ~PrimitiveGUI_ConeDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +PrimitiveGUI_ConeDlg::~PrimitiveGUI_ConeDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void PrimitiveGUI_ConeDlg::Init() +{ + /* init variables */ + myConstructorId = 0; + myEditCurrentArgument = GroupPoints->LineEdit1; + + myRadius1 = 100.0; + myRadius2 = 0.0; + myHeight = 300.0; + + myOkRadius1 = myOkRadius2 = myOkHeight = true; + myOkPoint1 = myOkDir = false; + + myEdgeFilter = new GEOM_EdgeFilter(StdSelect_Line, myGeom); + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + mySelection->AddFilter(myVertexFilter); + + /* Get setting of step value from file configuration */ + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); + + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); + + GroupPoints->SpinBox_DX->SetValue(myRadius1); + GroupPoints->SpinBox_DY->SetValue(myRadius2); + GroupPoints->SpinBox_DZ->SetValue(myHeight); + GroupDimensions->SpinBox_DX->SetValue(myRadius1); + GroupDimensions->SpinBox_DY->SetValue(myRadius2); + GroupDimensions->SpinBox_DZ->SetValue(myHeight); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->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->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + /* displays Dialog */ + GroupDimensions->hide(); + GroupPoints->show(); + this->show(); + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void PrimitiveGUI_ConeDlg::ConstructorsClicked(int constructorId) +{ + myConstructorId = constructorId; + mySelection->ClearFilters(); + myGeomGUI->EraseSimulationShape(); + disconnect(mySelection, 0, this, 0); + myOkHeight = myOkRadius1 = myOkRadius2 = true; + myRadius1 = 100.0; + myRadius2 = 0.0; + myHeight = 300.0; + + switch(myConstructorId) + { + case 0 : + { + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + myOkPoint1 = myOkDir = false; + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(tr("")); + GroupPoints->LineEdit2->setText(tr("")); + + GroupPoints->SpinBox_DX->SetValue(myRadius1); + GroupPoints->SpinBox_DY->SetValue(myRadius2); + GroupPoints->SpinBox_DZ->SetValue(myHeight); + + /* filter for next selection */ + mySelection->AddFilter(myVertexFilter); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + break; + } + case 1 : + { + GroupPoints->hide(); + resize( 0, 0 ); + GroupDimensions->show(); + myOkPoint1 = myOkDir = true; + + GroupDimensions->SpinBox_DX->SetValue(myRadius1); + GroupDimensions->SpinBox_DY->SetValue(myRadius2); + GroupDimensions->SpinBox_DZ->SetValue(myHeight); + + myPoint1.SetCoord(0.0, 0.0, 0.0); + myDir.SetCoord(0.0, 0.0, 1.0); + + MakeConeSimulationAndDisplay(); + break; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void PrimitiveGUI_ConeDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void PrimitiveGUI_ConeDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) { + gp_Dir aDir = myDir; + /* allows user to reverse direction of construction with a negative height */ + if(this->myHeight < -Precision::Confusion()) + aDir.Reverse(); + myPrimitiveGUI->MakeConeAndDisplay(myPoint1, aDir, myRadius1, myRadius2, fabs(myHeight)); + } + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void PrimitiveGUI_ConeDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkPoint1 = false; + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myOkDir = false; + return; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + /* gp_Pnt : not used */ + if (myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + GroupPoints->LineEdit1->setText(aString); + myOkPoint1 = true; + } + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + BRepAdaptor_Curve curv(TopoDS::Edge(S)); + myDir = curv.Line().Direction(); + GroupPoints->LineEdit2->setText(aString); + myOkDir = true; + } + + if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) + MakeConeSimulationAndDisplay(); + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void PrimitiveGUI_ConeDlg::SetEditCurrentArgument() +{ + if(myConstructorId != 0) + return; + + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + mySelection->AddFilter(myVertexFilter); + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + mySelection->AddFilter(myEdgeFilter); + } + this->SelectionIntoArgument(); + + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void PrimitiveGUI_ConeDlg::LineEditReturnPressed() +{ + 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 : ActivateThisDialog() +// purpose : +//================================================================================= +void PrimitiveGUI_ConeDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void PrimitiveGUI_ConeDlg::enterEvent(QEvent* e) +{ + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void PrimitiveGUI_ConeDlg::ValueChangedInSpinBox(double newValue) +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + QObject* send = (QObject*)sender(); + + if(send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DX) { + myRadius1 = newValue; + myOkRadius1 = true; + } + else if(send == GroupPoints->SpinBox_DY || send == GroupDimensions->SpinBox_DY) { + myRadius2 = newValue; + myOkRadius2 = true; + } + else if(send == GroupPoints->SpinBox_DZ || send == GroupDimensions->SpinBox_DZ) { + myHeight = newValue; + myOkHeight = true; + } + + if (myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) + MakeConeSimulationAndDisplay(); + return; +} + + +//================================================================================= +// function : MakeConeSimulationAndDisplay() +// purpose : +//================================================================================= +void PrimitiveGUI_ConeDlg::MakeConeSimulationAndDisplay() +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + gp_Dir aDir = myDir; + + try { + /* allows user to reverse direction of construction with a negative height */ + if(this->myHeight < -Precision::Confusion()) + aDir.Reverse(); + + gp_Ax2 anAxis(this->myPoint1, aDir); + + if(fabs(myRadius1 - myRadius2) <= Precision::Confusion()) + mySimulationTopoDs = BRepPrimAPI_MakeCylinder(anAxis, (myRadius1+myRadius2)/2.0, fabs(myHeight)).Shape(); + else { + if(fabs(myHeight) > Precision::Confusion()) + mySimulationTopoDs = BRepPrimAPI_MakeCone(anAxis, myRadius1, myRadius2, fabs(myHeight)).Shape(); + } + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + catch(Standard_Failure) { + MESSAGE("Exception catched in MakeConeSimulationAndDisplay"); + } + return; +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h new file mode 100644 index 000000000..15d101bb6 --- /dev/null +++ b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h @@ -0,0 +1,94 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : PrimitiveGUI_ConeDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_CONE_H +#define DIALOGBOX_CONE_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel3Spin.h" +#include "DlgRef_3Spin.h" + +#include "PrimitiveGUI.h" + +#include "GEOM_EdgeFilter.hxx" + +#include +#include + +//================================================================================= +// class : PrimitiveGUI_ConeDlg +// purpose : +//================================================================================= +class PrimitiveGUI_ConeDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + PrimitiveGUI_ConeDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~PrimitiveGUI_ConeDlg(); + +private: + void Init(); + void enterEvent(QEvent* e); + void MakeConeSimulationAndDisplay(); + + PrimitiveGUI* myPrimitiveGUI; + + double step; + int myConstructorId; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; + Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ + + gp_Pnt myPoint1; /* topology used */ + gp_Dir myDir; + bool myOkPoint1; /* to check when arguments is defined */ + bool myOkDir; + + Standard_Real myRadius1; + Standard_Real myRadius2; + Standard_Real myHeight; + bool myOkRadius1; + bool myOkRadius2; + bool myOkHeight; + + DlgRef_2Sel3Spin* GroupPoints; + DlgRef_3Spin* GroupDimensions; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked(int constructorId); + void ValueChangedInSpinBox(double newValue); + +}; + +#endif // DIALOGBOX_CONE_H diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx new file mode 100644 index 000000000..8ade2054c --- /dev/null +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx @@ -0,0 +1,411 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : PrimitiveGUI_CylinderDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "PrimitiveGUI_CylinderDlg.h" + +#include +#include + +//================================================================================= +// class : PrimitiveGUI_CylinderDlg() +// purpose : Constructs a PrimitiveGUI_CylinderDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +PrimitiveGUI_CylinderDlg::PrimitiveGUI_CylinderDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, 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_CYLINDER_PV"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CYLINDER_DXYZ"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_CYLINDER_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_CYLINDER")); + RadioButton1->setPixmap(image0); + RadioButton2->setPixmap(image1); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_2Sel2Spin(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_BASE_POINT")); + GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS")); + GroupPoints->TextLabel4->setText(tr("GEOM_HEIGHT")); + GroupPoints->PushButton1->setPixmap(image2); + GroupPoints->PushButton2->setPixmap(image2); + + GroupDimensions = new DlgRef_2Spin(this, "GroupDimensions"); + GroupDimensions->GroupBox1->setTitle(tr("GEOM_BOX_OBJ")); + GroupDimensions->TextLabel1->setText(tr("GEOM_HEIGHT")); + GroupDimensions->TextLabel2->setText(tr("GEOM_RADIUS")); + + Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupDimensions, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myPrimitiveGUI = thePrimitiveGUI; + Init(); +} + + +//================================================================================= +// function : ~PrimitiveGUI_CylinderDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +PrimitiveGUI_CylinderDlg::~PrimitiveGUI_CylinderDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void PrimitiveGUI_CylinderDlg::Init() +{ + /* init variables */ + myConstructorId = 0; + myEditCurrentArgument = GroupPoints->LineEdit1; + + myRadius = 100.0; + myHeight = 300.0; + myOkRadius = myOkHeight = true; + myOkPoint1 = myOkDir = false; + + myEdgeFilter = new GEOM_EdgeFilter(StdSelect_Line, myGeom); + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + mySelection->AddFilter(myVertexFilter); + + /* Get setting of step value from file configuration */ + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); + + /* min, max, step and decimals for spin boxes & initial values */ + /* First constructor : radius */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + /* First constructor : algebric height */ + GroupPoints->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); + /* Second constructor : radius */ + GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + /* Second constructor : algebric height */ + GroupDimensions->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); + + GroupPoints->SpinBox_DX->SetValue(myRadius); + GroupPoints->SpinBox_DY->SetValue(myHeight); + GroupDimensions->SpinBox_DX->SetValue(myRadius); + GroupDimensions->SpinBox_DY->SetValue(myHeight); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->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->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + /* displays Dialog */ + GroupDimensions->hide(); + GroupPoints->show(); + this->show(); + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void PrimitiveGUI_CylinderDlg::ConstructorsClicked(int constructorId) +{ + myConstructorId = constructorId; + mySelection->ClearFilters(); + myGeomGUI->EraseSimulationShape(); + disconnect(mySelection, 0, this, 0); + myOkHeight = myOkRadius = true; + myRadius = 100.0; + myHeight = 300.0; + + switch(myConstructorId) + { + case 0 : + { + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + myOkPoint1 = myOkDir = false; + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(tr("")); + GroupPoints->LineEdit2->setText(tr("")); + + GroupPoints->SpinBox_DX->SetValue(myRadius); + GroupPoints->SpinBox_DY->SetValue(myHeight); + + /* filter for next selection */ + mySelection->AddFilter(myVertexFilter); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + break; + } + case 1 : + { + GroupPoints->hide(); + resize( 0, 0 ); + GroupDimensions->show(); + myOkPoint1 = myOkDir = true; + + GroupDimensions->SpinBox_DX->SetValue(myRadius); + GroupDimensions->SpinBox_DY->SetValue(myHeight); + myPoint1.SetCoord(0.0, 0.0, 0.0); + myDir.SetCoord(0.0, 0.0, 1.0); + + MakeCylinderSimulationAndDisplay(); + break; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void PrimitiveGUI_CylinderDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void PrimitiveGUI_CylinderDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkPoint1 && myOkDir && myOkRadius && myOkHeight) { + gp_Dir aDir = myDir; + /* allows user to reverse direction of construction with a negative height */ + if(this->myHeight < -Precision::Confusion()) + aDir.Reverse(); + myPrimitiveGUI->MakeCylinderAndDisplay(myPoint1, aDir, myRadius, fabs(myHeight)); + } + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void PrimitiveGUI_CylinderDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkPoint1 = false; + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myOkDir = false; + return; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + /* gp_Pnt : not used */ + if (myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + GroupPoints->LineEdit1->setText(aString); + myOkPoint1 = true; + } + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + BRepAdaptor_Curve curv(TopoDS::Edge(S)); + myDir = curv.Line().Direction(); + GroupPoints->LineEdit2->setText(aString); + myOkDir = true; + } + + if(myOkPoint1 && myOkDir && myOkRadius && myOkHeight) + MakeCylinderSimulationAndDisplay(); + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void PrimitiveGUI_CylinderDlg::SetEditCurrentArgument() +{ + if(myConstructorId != 0) + return; + + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + mySelection->AddFilter(myVertexFilter); + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + mySelection->AddFilter(myEdgeFilter); + } + this->SelectionIntoArgument(); + + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void PrimitiveGUI_CylinderDlg::LineEditReturnPressed() +{ + 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 : ActivateThisDialog() +// purpose : +//================================================================================= +void PrimitiveGUI_CylinderDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void PrimitiveGUI_CylinderDlg::enterEvent(QEvent* e) +{ + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : ValueChangedInSpinBox +// purpose : +//================================================================================= +void PrimitiveGUI_CylinderDlg::ValueChangedInSpinBox( double newValue ) +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + QObject* send = (QObject*)sender(); + + /* radius */ + if(send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DX) { + myRadius = newValue; + myOkRadius = true; + } /* algebric height */ + else if(send == GroupPoints->SpinBox_DY || send == GroupDimensions->SpinBox_DY) { + myHeight = newValue; + myOkHeight = true; + } + + if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight) + MakeCylinderSimulationAndDisplay(); + return; +} + + +//================================================================================= +// function : MakeCylinderSimulationAndDisplay() +// purpose : +//================================================================================= +void PrimitiveGUI_CylinderDlg::MakeCylinderSimulationAndDisplay() +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + gp_Dir aDir = this->myDir; + + try { + /* allows user to reverse direction of construction with a negative height */ + if(this->myHeight < -Precision::Confusion()) + aDir.Reverse(); + + gp_Ax2 anAxis(this->myPoint1, aDir); + + mySimulationTopoDs = BRepPrimAPI_MakeCylinder(anAxis, this->myRadius, fabs(myHeight)).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + catch(Standard_Failure) { + MESSAGE("Exception catched in MakeCylinderSimulationAndDisplay"); + } + return; +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h new file mode 100644 index 000000000..27a77475e --- /dev/null +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h @@ -0,0 +1,92 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : PrimitiveGUI_CylinderDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_CYLINDER_H +#define DIALOGBOX_CYLINDER_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel2Spin.h" +#include "DlgRef_2Spin.h" + +#include "PrimitiveGUI.h" + +#include "GEOM_EdgeFilter.hxx" + +#include +#include + +//================================================================================= +// class : PrimitiveGUI_CylinderDlg +// purpose : +//================================================================================= +class PrimitiveGUI_CylinderDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + PrimitiveGUI_CylinderDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~PrimitiveGUI_CylinderDlg(); + +private: + void Init(); + void enterEvent(QEvent* e); + void MakeCylinderSimulationAndDisplay(); + + PrimitiveGUI* myPrimitiveGUI; + + double step; + int myConstructorId; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; + Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ + + gp_Pnt myPoint1; /* topology used */ + gp_Dir myDir; + bool myOkPoint1; /* to check when arguments is defined */ + bool myOkDir; + + Standard_Real myRadius; + Standard_Real myHeight; + bool myOkRadius; + bool myOkHeight; + + DlgRef_2Sel2Spin* GroupPoints; + DlgRef_2Spin* GroupDimensions; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked(int constructorId); + void ValueChangedInSpinBox(double newValue); + +}; + +#endif // DIALOGBOX_CYLINDER_H diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx new file mode 100644 index 000000000..af53c1150 --- /dev/null +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx @@ -0,0 +1,335 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : PrimitiveGUI_SphereDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "PrimitiveGUI_SphereDlg.h" + +#include + +//================================================================================= +// class : PrimitiveGUI_SphereDlg() +// purpose : Constructs a PrimitiveGUI_SphereDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +PrimitiveGUI_SphereDlg::PrimitiveGUI_SphereDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, 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_SPHERE_P"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_SPHERE_DXYZ"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_SPHERE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_SPHERE")); + RadioButton1->setPixmap(image0); + RadioButton2->setPixmap(image1); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_1Sel1Spin(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_SPHERE_CR")); + GroupPoints->TextLabel1->setText(tr("GEOM_CENTER")); + GroupPoints->TextLabel2->setText(tr("GEOM_RADIUS")); + GroupPoints->PushButton1->setPixmap(image2); + + GroupDimensions = new DlgRef_1Spin(this, "GroupDimensions"); + GroupDimensions->GroupBox1->setTitle(tr("GEOM_SPHERE_RO")); + GroupDimensions->TextLabel1->setText(tr("GEOM_RADIUS")); + + Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupDimensions, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myPrimitiveGUI = thePrimitiveGUI; + Init(); +} + + +//================================================================================= +// function : ~PrimitiveGUI_SphereDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +PrimitiveGUI_SphereDlg::~PrimitiveGUI_SphereDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void PrimitiveGUI_SphereDlg::Init() +{ + /* init variables */ + myConstructorId = 0; + myEditCurrentArgument = GroupPoints->LineEdit1; + + myPoint1.SetCoord(0.0, 0.0, 0.0); + myRadius = 100.0; + myOkPoint1 = myOkRadius = false; + + /* Vertices Filter for all arguments */ + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + mySelection->AddFilter(myVertexFilter); + + /* Get setting of step value from file configuration */ + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); + + /* min, max, step and decimals for spin boxes */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_DX->SetValue(myRadius); + GroupDimensions->SpinBox_DX->SetValue(myRadius); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + GroupDimensions->hide(); + GroupPoints->show(); + this->show(); + + return; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId) +{ + myConstructorId = constructorId; + mySelection->ClearFilters(); + myGeomGUI->EraseSimulationShape(); + disconnect(mySelection, 0, this, 0); + myRadius = 100.0; + myOkRadius = true; + + switch (constructorId) + { + case 0: + { + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(""); + + GroupPoints->SpinBox_DX->SetValue(myRadius); + myOkPoint1 = false; + + /* filter for next selections */ + mySelection->AddFilter(myVertexFilter); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + break; + } + case 1: + { + GroupPoints->hide(); + resize(0, 0); + GroupDimensions->show(); + + GroupDimensions->SpinBox_DX->SetValue(myRadius); + myPoint1.SetCoord(0.0, 0.0, 0.0); /* at origin */ + myOkPoint1 = true; + + mySimulationTopoDs = BRepPrimAPI_MakeSphere(myPoint1, myRadius).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + break; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void PrimitiveGUI_SphereDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void PrimitiveGUI_SphereDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if(mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkPoint1 && myOkRadius) + myPrimitiveGUI->MakeSphereAndDisplay(myPoint1, myRadius); + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void PrimitiveGUI_SphereDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) { + GroupPoints->LineEdit1->setText(""); + myOkPoint1 = false; + } + return; + } + + /* nbSel == 1 ! */ + TopoDS_Shape S; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + /* Constructor 1 treatment */ + if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + GroupPoints->LineEdit1->setText(aString); + myOkPoint1 = true; + } + + if(myOkPoint1 && myOkRadius) { + mySimulationTopoDs = BRepPrimAPI_MakeSphere(myPoint1, myRadius).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + return ; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void PrimitiveGUI_SphereDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupPoints->LineEdit1) + myEditCurrentArgument = GroupPoints->LineEdit1; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void PrimitiveGUI_SphereDlg::SetEditCurrentArgument() +{ + if(myConstructorId != 0) + return; + + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + mySelection->AddFilter(myVertexFilter); + this->SelectionIntoArgument(); + } + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void PrimitiveGUI_SphereDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void PrimitiveGUI_SphereDlg::enterEvent(QEvent* e) +{ + if(GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void PrimitiveGUI_SphereDlg::ValueChangedInSpinBox(double newValue) +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + myRadius = newValue; + myOkRadius = true; + + if(myOkPoint1 && myOkRadius) { + mySimulationTopoDs = BRepPrimAPI_MakeSphere(myPoint1, myRadius).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + return; +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h new file mode 100644 index 000000000..053a1cbc2 --- /dev/null +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h @@ -0,0 +1,82 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : PrimitiveGUI_SphereDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_SPHERE_H +#define DIALOGBOX_SPHERE_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel1Spin.h" +#include "DlgRef_1Spin.h" + +#include "PrimitiveGUI.h" + +#include + +//================================================================================= +// class : PrimitiveGUI_SphereDlg +// purpose : +//================================================================================= +class PrimitiveGUI_SphereDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + PrimitiveGUI_SphereDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~PrimitiveGUI_SphereDlg(); + +private : + void Init(); + void enterEvent(QEvent* e); + + PrimitiveGUI* myPrimitiveGUI; + + double step; + int myConstructorId; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* filter for selection */ + + gp_Pnt myPoint1; /* Points containing the vector */ + Standard_Real myRadius; + bool myOkRadius; /* Are true when myPoint is defined */ + bool myOkPoint1; + + DlgRef_1Sel1Spin* GroupPoints; + DlgRef_1Spin* GroupDimensions; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked(int constructorId); + void ValueChangedInSpinBox(double newValue); + +}; + +#endif // DIALOGBOX_SPHERE_H diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx new file mode 100644 index 000000000..d8f3db131 --- /dev/null +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx @@ -0,0 +1,396 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : PrimitiveGUI_TorusDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "PrimitiveGUI_TorusDlg.h" + +#include +#include + +//================================================================================= +// class : PrimitiveGUI_TorusDlg() +// purpose : Constructs a PrimitiveGUI_TorusDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +PrimitiveGUI_TorusDlg::PrimitiveGUI_TorusDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, 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_TORUS_PV"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_TORUS_DXYZ"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_TORUS_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_TORUS")); + RadioButton1->setPixmap(image0); + RadioButton2->setPixmap(image1); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_2Sel2Spin(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_BASE_POINT")); + GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS_I").arg("1")); + GroupPoints->TextLabel4->setText(tr("GEOM_RADIUS_I").arg("2")); + GroupPoints->PushButton1->setPixmap(image2); + GroupPoints->PushButton2->setPixmap(image2); + + GroupDimensions = new DlgRef_2Spin(this, "GroupDimensions"); + GroupDimensions->GroupBox1->setTitle(tr("GEOM_BOX_OBJ")); + GroupDimensions->TextLabel1->setText(tr("GEOM_RADIUS_I").arg("1")); + GroupDimensions->TextLabel2->setText(tr("GEOM_RADIUS_I").arg("2")); + + Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupDimensions, 1, 0); + /***************************************************************/ + + /* Initialisations */ + myPrimitiveGUI = thePrimitiveGUI; + Init(); +} + + +//================================================================================= +// function : ~PrimitiveGUI_TorusDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +PrimitiveGUI_TorusDlg::~PrimitiveGUI_TorusDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void PrimitiveGUI_TorusDlg::Init() +{ + /* init variables */ + myConstructorId = 0; + myEditCurrentArgument = GroupPoints->LineEdit1; + + myRadius1 = 300.0; + myRadius2 = 100.0; + myOkRadius1 = myOkRadius2 = true; + myOkPoint1 = myOkDir = false; + + myEdgeFilter = new GEOM_EdgeFilter(StdSelect_Line, myGeom); + myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); + mySelection->AddFilter(myVertexFilter); + + /* Get setting of step value from file configuration */ + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + step = St.toDouble(); + + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupPoints->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, step, 3); + + GroupPoints->SpinBox_DX->SetValue(myRadius1); + GroupPoints->SpinBox_DY->SetValue(myRadius2); + GroupDimensions->SpinBox_DX->SetValue(myRadius1); + GroupDimensions->SpinBox_DY->SetValue(myRadius2); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->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->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + /* displays Dialog */ + GroupDimensions->hide(); + GroupPoints->show(); + this->show(); + + return; +} + + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void PrimitiveGUI_TorusDlg::ConstructorsClicked(int constructorId) +{ + myConstructorId = constructorId; + mySelection->ClearFilters(); + myGeomGUI->EraseSimulationShape(); + disconnect(mySelection, 0, this, 0); + myOkRadius1 = myOkRadius2 = true; + myRadius1 = 300.0; + myRadius2 = 100.0; + + switch(myConstructorId) + { + case 0 : + { + GroupDimensions->hide(); + resize(0, 0); + GroupPoints->show(); + myOkPoint1 = myOkDir = false; + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setText(tr("")); + GroupPoints->LineEdit2->setText(tr("")); + + GroupPoints->SpinBox_DX->SetValue(myRadius1); + GroupPoints->SpinBox_DY->SetValue(myRadius2); + + /* filter for next selection */ + mySelection->AddFilter(myVertexFilter); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + break ; + } + case 1 : + { + GroupPoints->hide(); + resize( 0, 0 ); + GroupDimensions->show(); + myOkPoint1 = myOkDir = true; + + GroupDimensions->SpinBox_DX->SetValue(myRadius1); + GroupDimensions->SpinBox_DY->SetValue(myRadius2); + myPoint1.SetCoord(0.0, 0.0, 0.0); + myDir.SetCoord(0.0, 0.0, 1.0); + + MakeTorusSimulationAndDisplay(); + break ; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void PrimitiveGUI_TorusDlg::ClickOnOk() +{ + this->ClickOnApply(); + ClickOnCancel(); + return; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void PrimitiveGUI_TorusDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo(tr("")); + if (mySimulationTopoDs.IsNull()) + return; + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) + myPrimitiveGUI->MakeTorusAndDisplay(myPoint1, myDir, myRadius1, myRadius2); + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void PrimitiveGUI_TorusDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape(); + myEditCurrentArgument->setText(""); + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkPoint1 = false; + else if(myEditCurrentArgument == GroupPoints->LineEdit2) + myOkDir = false; + return; + } + + /* nbSel == 1 */ + TopoDS_Shape S; + if(!myGeomGUI->GetTopoFromSelection(mySelection, S)) + return; + + /* gp_Pnt : not used */ + if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomGUI->VertexToPoint(S, myPoint1)) { + GroupPoints->LineEdit1->setText(aString); + myOkPoint1 = true; + } + else if(myEditCurrentArgument == GroupPoints->LineEdit2) { + BRepAdaptor_Curve curv(TopoDS::Edge(S)); + myDir = curv.Line().Direction(); + GroupPoints->LineEdit2->setText(aString); + myOkDir = true; + } + + if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2) + MakeTorusSimulationAndDisplay(); + return; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void PrimitiveGUI_TorusDlg::SetEditCurrentArgument() +{ + if(myConstructorId != 0) + return; + + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + mySelection->AddFilter(myVertexFilter); + } + else if(send == GroupPoints->PushButton2) { + GroupPoints->LineEdit2->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit2; + mySelection->AddFilter(myEdgeFilter); + } + this->SelectionIntoArgument(); + + return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void PrimitiveGUI_TorusDlg::LineEditReturnPressed() +{ + 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 : ActivateThisDialog() +// purpose : +//================================================================================= +void PrimitiveGUI_TorusDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + if(!mySimulationTopoDs.IsNull()) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void PrimitiveGUI_TorusDlg::enterEvent(QEvent* e) +{ + if (GroupConstructors->isEnabled()) + return; + this->ActivateThisDialog(); + return; +} + + +//================================================================================= +// function : ValueChangedInSpinBox +// purpose : +//================================================================================= +void PrimitiveGUI_TorusDlg::ValueChangedInSpinBox(double newValue) +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + QObject* send = (QObject*)sender(); + + if(send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DX) { + myRadius1 = newValue; + myOkRadius1 = true; + } + else if(send == GroupPoints->SpinBox_DY || send == GroupDimensions->SpinBox_DY) { + myRadius2 = newValue; + myOkRadius2 = true; + } + + if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2) + MakeTorusSimulationAndDisplay(); + return; +} + + +//================================================================================= +// function : MakeTorusSimulationAndDisplay() +// purpose : +//================================================================================= +void PrimitiveGUI_TorusDlg::MakeTorusSimulationAndDisplay() +{ + myGeomGUI->EraseSimulationShape(); + mySimulationTopoDs.Nullify(); + + try { + gp_Ax2 anAxis(myPoint1, myDir); + mySimulationTopoDs = BRepPrimAPI_MakeTorus(anAxis, myRadius1, myRadius2).Shape(); + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs); + } + catch(Standard_Failure) { + MESSAGE("Exception catched in MakeTorusSimulationAndDisplay"); + } + return; +} diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h new file mode 100644 index 000000000..e95ccba47 --- /dev/null +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h @@ -0,0 +1,92 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : PrimitiveGUI_TorusDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_TORUS_H +#define DIALOGBOX_TORUS_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel2Spin.h" +#include "DlgRef_2Spin.h" + +#include "PrimitiveGUI.h" + +#include "GEOM_EdgeFilter.hxx" + +#include +#include + +//================================================================================= +// class : PrimitiveGUI_TorusDlg +// purpose : +//================================================================================= +class PrimitiveGUI_TorusDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + PrimitiveGUI_TorusDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~PrimitiveGUI_TorusDlg(); + +private: + void Init(); + void enterEvent(QEvent* e); + void MakeTorusSimulationAndDisplay(); + + PrimitiveGUI* myPrimitiveGUI; + + double step; + int myConstructorId; + Handle(GEOM_ShapeTypeFilter) myVertexFilter; + Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ + + gp_Pnt myPoint1; /* topology used */ + gp_Dir myDir; + bool myOkPoint1; /* to check when arguments is defined */ + bool myOkDir; + + Standard_Real myRadius1; + Standard_Real myRadius2; + bool myOkRadius1; + bool myOkRadius2; + + DlgRef_2Sel2Spin* GroupPoints; + DlgRef_2Spin* GroupDimensions; + +private slots: + void ClickOnOk(); + void ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked(int constructorId); + void ValueChangedInSpinBox(double newValue); + +}; + +#endif // DIALOGBOX_TORUS_H diff --git a/src/RepairGUI/Makefile.in b/src/RepairGUI/Makefile.in new file mode 100644 index 000000000..5b846ad34 --- /dev/null +++ b/src/RepairGUI/Makefile.in @@ -0,0 +1,73 @@ +# GEOM REPAIRGUI : +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Damien COQUERET (OCC) +# Module : GEOM +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= RepairGUI.h + +# Libraries targets +LIB = libRepairGUI.la + +LIB_SRC = RepairGUI.cxx \ + RepairGUI_SewingDlg.cxx \ + RepairGUI_OrientationDlg.cxx \ + RepairGUI_SuppressFacesDlg.cxx \ + RepairGUI_SuppressHoleDlg.cxx + +LIB_MOC = \ + RepairGUI.h \ + RepairGUI_SewingDlg.h \ + RepairGUI_OrientationDlg.h \ + RepairGUI_SuppressFacesDlg.h \ + RepairGUI_SuppressHoleDlg.h + +LIB_CLIENT_IDL = SALOME_Exception.idl \ + GEOM_Gen.idl \ + GEOM_Shape.idl \ + SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +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 -lDlgRef -lGEOMBase $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/RepairGUI/RepairGUI.cxx b/src/RepairGUI/RepairGUI.cxx new file mode 100644 index 000000000..12da46f9d --- /dev/null +++ b/src/RepairGUI/RepairGUI.cxx @@ -0,0 +1,333 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : RepairGUI.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "RepairGUI.h" + +#include "QAD_RightFrame.h" +#include "OCCViewer_Viewer3d.h" + +#include "RepairGUI_SewingDlg.h" // Method SEWING +#include "RepairGUI_OrientationDlg.h" // Method ORIENTATION +#include "RepairGUI_SuppressFacesDlg.h" // Method SUPPRESS FACES +#include "RepairGUI_SuppressHoleDlg.h" // Method SUPPRESS HOLE + +//======================================================================= +// function : RepairGUI() +// purpose : Constructor +//======================================================================= +RepairGUI::RepairGUI() : + QObject() +{ + myGeomGUI = GEOMBase_Context::GetGeomGUI(); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); +} + + +//======================================================================= +// function : ~RepairGUI() +// purpose : Destructor +//======================================================================= +RepairGUI::~RepairGUI() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool RepairGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + switch (theCommandID) + { + case 501: // SEWING + { + RepairGUI_SewingDlg *aDlg = new RepairGUI_SewingDlg(parent, "", this, Sel); + break; + } + case 502: // ORIENTATION + { + RepairGUI_OrientationDlg *aDlg = new RepairGUI_OrientationDlg(parent, "", this, Sel); + break; + } + case 309: // 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(); + ic = v3d->getAISContext(); + } + RepairGUI_SuppressFacesDlg *aDlg = new RepairGUI_SuppressFacesDlg(parent, "", this, Sel, ic); + break; + } + case 314: // 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(); + ic = v3d->getAISContext(); + } + RepairGUI_SuppressHoleDlg *aDlg = new RepairGUI_SuppressHoleDlg(parent, "", this, Sel, ic); + break; + } + default: + { + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + } + return true; +} + + +//===================================================================================== +// function : MakeSewingAndDisplay() +// purpose : +//===================================================================================== +void RepairGUI::MakeSewingAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, + const Standard_Real precision) +{ + try { + GEOM::GEOM_Shape_var result = myGeom->MakeSewing(listShapesIOR, precision); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + result->NameType(type); + + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + return; + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeOrientationChangeAndDisplay() +// purpose : +//===================================================================================== +void RepairGUI::MakeOrientationChangeAndDisplay(GEOM::GEOM_Shape_ptr Shape) +{ + try { + GEOM::GEOM_Shape_var result = myGeom->OrientationChange(Shape); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + result->NameType(Shape->NameType()); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + return; + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : OnSuppressHole() +// purpose : To suppress an hole on a shape 'ShapeTopo'. +// : 'ListOfIdEndFace' may be an empty list. +// : This means that hole do not traverse ShapeTopo. +// : Warning : the hole to be suppressed must be defined by one or two single closed wires ! +//===================================================================================== +bool RepairGUI::OnSuppressHole( const char* ShapeTopoIOR, + const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace, + const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire, + const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace ) +{ + /* Test the type of viewer */ + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { + return false; + } + + try { + GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString( ShapeTopoIOR ); + GEOM::GEOM_Shape_var aResult = myGeom->SuppressHole( aShape, ListOfIdFace, ListOfIdWire, ListOfIdEndFace ) ; + + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, aResult); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + aResult->NameType( type ); + + if ( myGeomGUI->Display( aResult) ) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return true ; +} + + +//===================================================================================== +// function : OnSuppressHolesInFaceOrShell() +// purpose : To suppress one or more holes on a face +// : 'ListOfIdWires' contains indices or wires/holes. +//===================================================================================== +bool RepairGUI::OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR, + const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires ) +{ + /* Test the type of viewer */ + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { + return false; + } + + try { + GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString( ShapeTopoIOR ); + GEOM::GEOM_Shape_var aResult = myGeom->SuppressHolesInFaceOrShell( aShape, ListOfIdWires ) ; + + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, aResult); + Standard_CString type; + myGeomGUI->GetShapeTypeString(S,type); + aResult->NameType( type ); + + if ( myGeomGUI->Display( aResult) ) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return true ; +} + + +//===================================================================================== +// function : OnSuppressFaces() +// purpose : To suppress faces from a shape +// : The result is one or more shells/faces as main shapes ! +//===================================================================================== +bool RepairGUI::OnSuppressFaces( const TopoDS_Shape& ShapeTopo, + const char* ShapeTopoIOR, + const Standard_Integer& aLocalContextId, + bool& myUseLocalContext ) +{ + /* Test the type of viewer */ + 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() ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); + return false ; + } + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + if( myUseLocalContext == false ) { + /* local context is from DialogBox */ + MESSAGE("Error : No local context opened for suppress faces method" << endl ) ; + return false ; + } + + GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; + ic->InitSelected(); + int nbSelected = ic->NbSelected(); + ListOfID->length(nbSelected); + + /* Create a list of indices of faces to be suppressed */ + int i = 0; + const int SubShapeType = 4 ; /* GEOM::FACE type */ + ic->InitSelected(); /* to repositioning at beginning */ + while( ic->MoreSelected() ) { + int index = myGeomGUI->GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType ); + ListOfID[i] = index ; + i++; + ic->NextSelected(); + } + + /* Close local context opened in DialogBox */ + ic->CloseLocalContext(aLocalContextId) ; + myUseLocalContext = false ; + + /* Here is the main shape */ + GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString( ShapeTopoIOR ); + GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes; + + /* Call geom method that return a list of shells/faces as result of suppress */ + try { + listGeomShapes = myGeom->SuppressFaces( aShape, ListOfID ); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + + /* Test list of shells/faces */ + if( listGeomShapes->length() < 1 ) { + return false ; + } + + /* Loop on each object created */ + for( int i=0; ilength(); i++ ) { + + GEOM::GEOM_Shape_var aShellOrFace = listGeomShapes[i] ; + TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape( myGeom, aShellOrFace ); + + if( S.IsNull() ) { + return false ; + } + + char* nameG = (char *)malloc(20); + Standard_CString Type; + if ( myGeomGUI->GetShapeTypeString(S, Type) ) { + aShellOrFace->NameType( Type ); + sprintf (nameG, "%s_%d", Type, myGeomGUI->GetNbGeom()++); + } + else { + aShellOrFace->NameType( tr("GEOM_SHAPE") ); + sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->GetNbGeom()++ ); + } + + /* Display with name */ + if( !myGeomGUI->Display( aShellOrFace, nameG) ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return false ; + } + } + + myGeomGUI->GetDesktop()->putInfo (tr("GEOM_PRP_READY")); + return true ; +} diff --git a/src/RepairGUI/RepairGUI.h b/src/RepairGUI/RepairGUI.h new file mode 100644 index 000000000..6823cf0f1 --- /dev/null +++ b/src/RepairGUI/RepairGUI.h @@ -0,0 +1,68 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : RepairGUI.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef REPAIRGUI_H +#define REPAIRGUI_H + +#include "GEOMBase_Display.h" + +//================================================================================= +// class : RepairGUI +// purpose : +//================================================================================= +class RepairGUI : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + RepairGUI(); + ~RepairGUI(); + + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + + void MakeSewingAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, + const Standard_Real precision); + void MakeOrientationChangeAndDisplay(GEOM::GEOM_Shape_ptr Shape); + bool OnSuppressHole(const char* ShapeTopoIOR, + const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace, + const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire, + const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace); + bool OnSuppressHolesInFaceOrShell(const char* ShapeTopoIOR, + const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires); + bool OnSuppressFaces(const TopoDS_Shape& ShapeTopo, + const char* ShapeTopoIOR, + const Standard_Integer& aLocalContextId, + bool& myUseLocalContext); + +private: + GEOMBase_Context* myGeomGUI; + GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + +}; + +#endif diff --git a/src/RepairGUI/RepairGUI_FillingHoleDlg.cxx b/src/RepairGUI/RepairGUI_FillingHoleDlg.cxx new file mode 100644 index 000000000..9e26e9498 --- /dev/null +++ b/src/RepairGUI/RepairGUI_FillingHoleDlg.cxx @@ -0,0 +1,542 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GeometryGUI_FillingHoleDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "GeometryGUI_FillingHoleDlg.h" + +#include "GeometryGUI.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : GeometryGUI_FillingHoleDlg() +// purpose : Constructs a GeometryGUI_FillingHoleDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +GeometryGUI_FillingHoleDlg::GeometryGUI_FillingHoleDlg( QWidget* parent, + const char* name, + SALOME_Selection* Sel, + Handle (AIS_InteractiveContext) ic, + bool modal, + WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_SEWING"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "GeometryGUI_FillingHoleDlg" ); + resize( 303, 203 ); + setCaption( tr( "Filling hole" ) ); + setSizeGripEnabled( TRUE ); + GeometryGUI_FillingHoleDlgLayout = new QGridLayout( this ); + GeometryGUI_FillingHoleDlgLayout->setSpacing( 6 ); + GeometryGUI_FillingHoleDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "" ) ); + 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 ); + GeometryGUI_FillingHoleDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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 ); + Layout2 = new QHBoxLayout; + Layout2->setSpacing( 6 ); + Layout2->setMargin( 0 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "Main object" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + Layout2->addWidget( TextLabelC1A1 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) ); + Layout2->addWidget( SelectButtonC1A1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + LineEditC1A1->setAlignment( int( QLineEdit::AlignLeft ) ); + Layout2->addWidget( LineEditC1A1 ); + GroupC1Layout->addLayout( Layout2, 0, 0 ); + CheckBox1 = new QCheckBox( GroupC1, "CheckBox1" ); + CheckBox1->setText( tr( "Select edges of hole on main object" ) ); + CheckBox1->setChecked( FALSE ); + GroupC1Layout->addWidget( CheckBox1, 1, 0 ); + GeometryGUI_FillingHoleDlgLayout->addWidget( GroupC1, 1, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupButtons->sizePolicy().hasHeightForWidth() ) ); + 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 ); + buttonClose = new QPushButton( GroupButtons, "buttonClose" ); + buttonClose->setText( tr( "&Close" ) ); + buttonClose->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonClose, 0, 3 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "&Ok" ) ); + buttonOk->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "&Apply" ) ); + buttonApply->setAutoDefault( TRUE ); + buttonApply->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_2, 0, 2 ); + GeometryGUI_FillingHoleDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /* Initialisations */ + Init(Sel, ic) ; + +} + + +//================================================================================= +// function : ~GeometryGUI_FillingHoleDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +GeometryGUI_FillingHoleDlg::~GeometryGUI_FillingHoleDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void GeometryGUI_FillingHoleDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myShape.Nullify() ; + + myIC = ic ; + myUseLocalContext = false ; + myOkShape = false ; + myGeomGUI = GeometryGUI::GetGeometryGUI() ; + + /* Select sub shapes mode not checked */ + CheckBox1->setChecked( FALSE ); + myOkSelectSubMode = false ; + + // TODO : previous selection into argument ? + + /* Filter definitions */ + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect( buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnClose() ) ); + connect( GroupConstructors, SIGNAL( clicked(int) ), this, SLOT( ConstructorsClicked(int) )); + + connect( LineEditC1A1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( SelectButtonC1A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() )); + connect( CheckBox1, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserSelection() )); + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() )); + connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnClose() )); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* display Dialog */ + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void GeometryGUI_FillingHoleDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : Same than click on apply but close this dialog. +//================================================================================= +void GeometryGUI_FillingHoleDlg::ClickOnOk() +{ + this->ClickOnApply() ; + accept(); + + return ; +} + + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void GeometryGUI_FillingHoleDlg::ClickOnApply() +{ + bool testResult = false ; + myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + + switch(myConstructorId) + { + case 0 : + { + if( myOkShape && myOkSelectSubMode ) { + testResult = myGeomGUI->OnFillingHole( myShape, myShapeIOR, myLocalContextId, myUseLocalContext ) ; + } + if( !testResult ) { + myGeomGUI->GetDesktop()->putInfo(tr("Operation aborted")) ; + } + else { + myGeomGUI->GetDesktop()->putInfo(tr("Operation done")); + } + /* Reset arguments to allow a new selection */ + this->ResetStateOfDialog() ; + break ; + } + } + return ; +} + + + +//================================================================================= +// function : ClickOnClose() +// purpose : +//================================================================================= +void GeometryGUI_FillingHoleDlg::ClickOnClose() +{ + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + + if(myUseLocalContext) { + myIC->CloseLocalContext(myLocalContextId) ; + this->myUseLocalContext = false ; + myGeomGUI->OnDisplayAll(true) ; + } + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +// : used only by SelectButtonC1A1 (LineEditC1A1) +//================================================================================= +void GeometryGUI_FillingHoleDlg::SelectionIntoArgument() +{ + + /* Reset argument and local context when selection as changed */ + this->ResetStateOfDialog() ; + + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) + return ; + + /* nbSel == 1 */ + TopoDS_Shape S ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + +// if( !IO->hasEntry() ) { +// myGeomGUI->GetDesktop()->putInfo(tr("Main shape must be in the study before")) ; +// return ; +// } + + /* Test the exact type of topology to fill an hole */ + if ( !S.IsNull() && ( S.ShapeType() == TopAbs_SOLID || S.ShapeType() == TopAbs_SHELL || S.ShapeType() == TopAbs_COMPOUND ) ) { + + if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { + Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO ); + myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */ + LineEditC1A1->setText(aString) ; + myShape = S ; + myOkShape = true ; + return; + } + + if ( IO->hasEntry() ) { + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + myShapeIOR = anIOR->Value(); + myOkShape = true ; + myShape = S ; + LineEditC1A1->setText(aString) ; + return; + } + } + } + + } + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void GeometryGUI_FillingHoleDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + SelectionIntoArgument() ; + } + break; + } + } + return ; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void GeometryGUI_FillingHoleDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + 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 ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void GeometryGUI_FillingHoleDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + + this->ResetStateOfDialog() ; + + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + myGeomGUI->ResetState() ; + myGeomGUI->SetActiveDialogBox(0) ; + myGeomGUI->OnDisplayAll(true) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void GeometryGUI_FillingHoleDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate other active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : Mouse enter onto the dialog to activate it +//================================================================================= +void GeometryGUI_FillingHoleDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void GeometryGUI_FillingHoleDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnClose() ; + return ; +} + + +//================================================================================= +// function : ActivateUserSelection() +// purpose : Activate selection of faces when CheckBox1->isChecked()... +//================================================================================= +void GeometryGUI_FillingHoleDlg::ActivateUserSelection() +{ + + if( !this->myOkShape ) { + this->ResetStateOfDialog() ; + myGeomGUI->GetDesktop()->putInfo(tr("Select main shape first")) ; + return ; + } + + this->myOkSelectSubMode = CheckBox1->isChecked() ; + + if( this->myUseLocalContext ) { + myIC->CloseLocalContext(myLocalContextId) ; + this->myUseLocalContext = false ; + myGeomGUI->OnDisplayAll(true) ; + } + + if( myOkShape && myOkSelectSubMode ) { + /* local context is defined into the method : GEOM::EDGE sub selection */ + TopAbs_ShapeEnum aType = TopAbs_EDGE ; + myGeomGUI->PrepareSubShapeSelection( int(aType), this->myLocalContextId ) ; + myUseLocalContext = true ; + myGeomGUI->GetDesktop()->putInfo(tr("Select edges to fill an hole and click on Ok/Apply")) ; + } + return ; +} + + + +//================================================================================= +// function : ResetStateOfDialog() +// purpose : Completely reset the state of method including local context +//================================================================================= +void GeometryGUI_FillingHoleDlg::ResetStateOfDialog() +{ + this->myOkShape = false ; + this->myEditCurrentArgument->setText("") ; + + /* Select sub shapes mode not checked */ + this->myOkSelectSubMode = false ; + this->CheckBox1->setChecked( FALSE ); + + /* Close its local contact if opened */ + if( this->myUseLocalContext ) { + myIC->CloseLocalContext(this->myLocalContextId) ; + this->myUseLocalContext = false ; + myGeomGUI->OnDisplayAll(true) ; + } + return ; +} + + + diff --git a/src/RepairGUI/RepairGUI_FillingHoleDlg.h b/src/RepairGUI/RepairGUI_FillingHoleDlg.h new file mode 100644 index 000000000..8e0b758df --- /dev/null +++ b/src/RepairGUI/RepairGUI_FillingHoleDlg.h @@ -0,0 +1,133 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : GeometryGUI_FillingHoleDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef GEOMETRYGUI_FILLINGHOLE_H +#define GEOMETRYGUI_FILLINGHOLE_H + +#include "SALOME_Selection.h" +#include "GEOM_ShapeTypeFilter.hxx" + +#include +#include + +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QCheckBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class GeometryGUI; + + +//================================================================================= +// class : GeometryGUI_FillingHoleDlg +// purpose : +//================================================================================= +class GeometryGUI_FillingHoleDlg : public QDialog +{ + Q_OBJECT + +public : + GeometryGUI_FillingHoleDlg( QWidget* parent = 0, + const char* name = 0, + SALOME_Selection* Sel = 0, + Handle (AIS_InteractiveContext) ic = 0, + bool modal = FALSE, + WFlags fl = 0 ); + + ~GeometryGUI_FillingHoleDlg(); + +private : + + void Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void ResetStateOfDialog() ; + + /* Interactive and local context management see also : bool myUseLocalContext() */ + Handle (AIS_InteractiveContext) myIC ; /* Interactive context */ + Standard_Integer myLocalContextId ; /* identify a local context used by this method */ + bool myUseLocalContext ; /* true when this method as opened a local context */ + + GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */ + GeometryGUI* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + + TopoDS_Shape myShape ; + char* myShapeIOR ; + bool myOkShape ; + + bool myOkSelectSubMode ; /* true = sub mode selection activated */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + int myConstructorId ; /* Current constructor id = radio button id */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + QCheckBox* CheckBox1; + + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonApply; + QPushButton* buttonClose; + + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnApply() ; + void ClickOnClose(); + + void LineEditReturnPressed() ; + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void ActivateUserSelection() ; + +protected: + + QGridLayout* GeometryGUI_FillingHoleDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; + QHBoxLayout* Layout2; + QGridLayout* GroupButtonsLayout; +}; + +#endif // GEOMETRYGUI_FILLINGHOLE_H diff --git a/src/RepairGUI/RepairGUI_OrientationDlg.cxx b/src/RepairGUI/RepairGUI_OrientationDlg.cxx new file mode 100644 index 000000000..e123c3388 --- /dev/null +++ b/src/RepairGUI/RepairGUI_OrientationDlg.cxx @@ -0,0 +1,605 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : RepairGUI_OrientationDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "RepairGUI_OrientationDlg.h" + + +#include "QAD_Config.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : RepairGUI_OrientationDlg() +// purpose : Constructs a RepairGUI_OrientationDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +RepairGUI_OrientationDlg::RepairGUI_OrientationDlg( QWidget* parent, const char* name, RepairGUI* theRepairGUI, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_ORIENTATION"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + if ( !name ) + setName( "RepairGUI_OrientationDlg" ); + resize( 303, 242 ); + setCaption( tr( "GEOM_ORIENTATION_TITLE" ) ); + setSizeGripEnabled( TRUE ); + RepairGUI_OrientationDlgLayout = new QGridLayout( this ); + RepairGUI_OrientationDlgLayout->setSpacing( 6 ); + RepairGUI_OrientationDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_ORIENTATION" ) ); + 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 ); + RepairGUI_OrientationDlgLayout->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 ); + RepairGUI_OrientationDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + /* Spin box construction */ + SpinBox_C1A2 = new DlgRef_SpinBox( GroupC1, "GeomSpinBox_C1A2" ) ; + GroupC1Layout->addWidget( SpinBox_C1A2, 1, 2 ); + + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + 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_VECTOR_LENGTH" ) ); + TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); + GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); + CheckBoxReverse = new QCheckBox( GroupC1, "CheckBoxReverse" ); + CheckBoxReverse->setText( tr( "GEOM_ORIENTATION_OPT" ) ); + GroupC1Layout->addMultiCellWidget( CheckBoxReverse, 2, 2, 0, 2 ); + RepairGUI_OrientationDlgLayout->addWidget( GroupC1, 1, 0 ); + /***************************************************************/ + myRepairGUI = theRepairGUI; + Init(Sel) ; /* Initialisations */ + +} + +//================================================================================= +// function : ~RepairGUI_OrientationDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +RepairGUI_OrientationDlg::~RepairGUI_OrientationDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void RepairGUI_OrientationDlg::Init( SALOME_Selection* Sel ) +{ + + double step ; + QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ; + step = St.toDouble() ; + + /* min, max, step and decimals for spin boxes */ + SpinBox_C1A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; + SpinBox_C1A2->SetValue( 25.0 ) ; /* = myLength */ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + CheckBoxReverse->setChecked( FALSE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + + myLength = 25.0 ; + myOkShape = false ; + myOkLength = true; + mySimulationTopoDs.Nullify() ; + myShape.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); + + /* 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( CheckBoxReverse, SIGNAL (stateChanged(int) ), this, SLOT( ReverseOrientation(int) ) ) ; + + connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( SpinBox_C1A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + + 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 ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void RepairGUI_OrientationDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void RepairGUI_OrientationDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void RepairGUI_OrientationDlg::ClickOnApply() +{ + /* Leave simulation display in this method ! */ + myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + + switch(myConstructorId) + { + case 0 : + { + if(myOkShape && CheckBoxReverse->isChecked() && myOkLength == true ) { + myRepairGUI->MakeOrientationChangeAndDisplay( myGeomShape ) ; + CheckBoxReverse->setChecked( FALSE ); + } + break ; + } + } + // accept(); + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void RepairGUI_OrientationDlg::ClickOnCancel() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void RepairGUI_OrientationDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + 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 ; +} + + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void RepairGUI_OrientationDlg::SelectionIntoArgument() +{ + myGeomGUI->EraseSimulationShape() ; + this->mySimulationTopoDs.Nullify() ; + + /* Name of future selection */ + QString aString = ""; + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) { + if ( myEditCurrentArgument == LineEditC1A1 ) { + LineEditC1A1->setText("") ; + this->myOkShape = false ; + } + return ; + } + + /* 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 ) + return ; + LineEditC1A1->setText(aString) ; + myShape = S ; + myOkShape = true ; + } + + if( myOkShape && myOkLength ) { + MakeOrientationSimulationAndDisplay( this->myShape, this->myLength ) ; + } + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void RepairGUI_OrientationDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1 ; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void RepairGUI_OrientationDlg::ValueChangedInSpinBox( double newValue ) +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + QObject* send = (QObject*)sender() ; + if( send == SpinBox_C1A2 ) { + this->myLength = newValue ; + myOkLength = true ; + } + + if ( myConstructorId == 0 && myOkShape && myOkLength == true ) { + MakeOrientationSimulationAndDisplay( this->myShape, this->myLength ) ; + } + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void RepairGUI_OrientationDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + GroupC1->setEnabled(false) ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->EraseSimulationShape() ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void RepairGUI_OrientationDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + GroupC1->setEnabled(true) ; + + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + if( !mySimulationTopoDs.IsNull() ) + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void RepairGUI_OrientationDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void RepairGUI_OrientationDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + + +//=========================================================================================== +// function : ReverseOrientation() +// purpose : +//=========================================================================================== +void RepairGUI_OrientationDlg::ReverseOrientation(int state) +{ + if( this->myOkShape && myOkLength == true ) { + MakeOrientationSimulationAndDisplay( this->myShape, this-> myLength ) ; + } + return ; +} + + +//=========================================================================================== +// function : MakeOrientationSimulationAndDisplay() +// purpose : Create 'aCompound1' and 'aCompound2' each contains edges oriented +// : respectively FORWARD and REVERSE for all faces of 'aTopoDS' +// : These edges represent normal vectors on faces of 'aTopoDS' +// : For a unique edge an arrow is displayed to show its orientation. +//=========================================================================================== +void RepairGUI_OrientationDlg::MakeOrientationSimulationAndDisplay(const TopoDS_Shape& aTopoDS, Standard_Real length ) +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + TopoDS_Compound aCompound1, aCompound2 ; + TopoDS_Compound NullComp ; + BRep_Builder aBuilder1, aBuilder2; + aCompound1 = aCompound2 = NullComp ; + aBuilder1.MakeCompound(aCompound1) ; + aBuilder2.MakeCompound(aCompound2) ; + + if( aTopoDS.IsNull() ) + return ; + + /* Case of an edge */ + if( aTopoDS.ShapeType() == TopAbs_EDGE ) { + /* Try to display a cone simulation shape to show direction of edge */ + TopoDS_Shape tmpShape = aTopoDS ; + if( this->CheckBoxReverse->isChecked() ) { + if( aTopoDS.Orientation() == TopAbs_FORWARD) + tmpShape.Orientation(TopAbs_REVERSED) ; + else + tmpShape.Orientation(TopAbs_FORWARD) ; + } + if( myGeomGUI->CreateArrowForLinearEdge( tmpShape, mySimulationTopoDs ) ) { + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + } + return ; + } + + + gp_Pnt P1, P2 ; + gp_Vec V, V1, V2 ; + TopExp_Explorer ex( aTopoDS, TopAbs_FACE ); + int test = 0 ; + while (ex.More()) { + + const TopoDS_Face& F = TopoDS::Face(ex.Current()); + /* find the center of the minmax */ + BRepAdaptor_Surface SF(F); + Standard_Real u, v, x; + + u = SF.FirstUParameter(); + x = SF.LastUParameter(); + if ( Precision::IsInfinite(u) ) { + if( Precision::IsInfinite(x) ) u = 0.0 ; else u = x ; + } + else if ( !Precision::IsInfinite(x) ) + u = (u+x) / 2.0 ; + + v = SF.FirstVParameter(); + x = SF.LastVParameter(); + if ( Precision::IsInfinite(v) ) { + if ( Precision::IsInfinite(x) ) v = 0.0 ; else v = x ; + } + else if ( !Precision::IsInfinite(x) ) + v = (v+x) / 2.0 ; + + SF.D1( u, v, P1, V1, V2 ); + V = V1.Crossed(V2); + x = V.Magnitude(); + if ( x > 1.e-10 ) + V.Multiply( length/x ); + else { + V.SetCoord( length/2.0, 0.0, 0.0 ) ; + MESSAGE ("Null normal in Orientation " << endl ) ; + } + + P2 = P1; + /* test orientation of each face and displays forward (aCompound1) */ + if( F.Orientation() == TopAbs_FORWARD ) + P2.Translate(V); + else + P2.Translate(-V) ; + BRepBuilderAPI_MakeEdge anEdge(P1, P2) ; + aBuilder1.Add( aCompound1, anEdge ) ; + + P2 = P1; + /* test orientation of each face and displays forward (aCompound2) */ + if( F.Orientation() == TopAbs_FORWARD ) + P2.Translate(-V); + else + P2.Translate(V) ; + anEdge = BRepBuilderAPI_MakeEdge(P1, P2) ; + aBuilder2.Add( aCompound2, anEdge ) ; + + ex.Next(); + test++ ; + } + + /* display simulation compounds */ + if( test > 0 && this->CheckBoxReverse->isChecked() ) { + mySimulationTopoDs = aCompound1 ; + } + else if ( test > 0 && !CheckBoxReverse->isChecked() ) { + mySimulationTopoDs = aCompound2 ; + } + if(!mySimulationTopoDs.IsNull() ) + myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ; + + return ; +} diff --git a/src/RepairGUI/RepairGUI_OrientationDlg.h b/src/RepairGUI/RepairGUI_OrientationDlg.h new file mode 100644 index 000000000..40d6fd315 --- /dev/null +++ b/src/RepairGUI/RepairGUI_OrientationDlg.h @@ -0,0 +1,121 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : RepairGUI_OrientationDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_ORIENTATION_H +#define DIALOGBOX_ORIENTATION_H + +#include "RepairGUI.h" + +#include "DlgRef_SpinBox.h" + +#include +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QCheckBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; + + +//================================================================================= +// class : DialogBox_ORIENTATION +// purpose : +//================================================================================= +class RepairGUI_OrientationDlg : public QDialog +{ + Q_OBJECT + +public: + RepairGUI_OrientationDlg( QWidget* parent = 0, const char* name = 0, RepairGUI* theRepairGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~RepairGUI_OrientationDlg(); + +private : + RepairGUI* myRepairGUI; + 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 */ + GEOM::GEOM_Shape_var myGeomShape ; /* is myShape */ + TopoDS_Shape myShape ; /* topology used */ + Standard_Real myLength ; /* to simulate normal vector */ + bool myOkShape ; + bool myOkLength ; + QDoubleValidator *myVa ; /* Double validator for numeric input */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + int myConstructorId ; /* Current constructor id = radio button id */ + + void closeEvent( QCloseEvent* e ) ; + void enterEvent( QEvent* e); + void Init( SALOME_Selection* Sel ) ; + void MakeOrientationSimulationAndDisplay( const TopoDS_Shape& aTopoDS, Standard_Real length ) ; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLineEdit* LineEditC1A1; + DlgRef_SpinBox* SpinBox_C1A2 ; + + QPushButton* SelectButtonC1A1; + QLabel* TextLabelC1A1; + QLabel* TextLabelC1A2; + QCheckBox* CheckBoxReverse; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void LineEditReturnPressed() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void ReverseOrientation(int state) ; + void ValueChangedInSpinBox( double newValue ) ; + +protected: + + QGridLayout* RepairGUI_OrientationDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_ORIENTATION_H diff --git a/src/RepairGUI/RepairGUI_SewingDlg.cxx b/src/RepairGUI/RepairGUI_SewingDlg.cxx new file mode 100644 index 000000000..47e551eb3 --- /dev/null +++ b/src/RepairGUI/RepairGUI_SewingDlg.cxx @@ -0,0 +1,388 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : RepairGUI_SewingDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "RepairGUI_SewingDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +//================================================================================= +// class : RepairGUI_SewingDlg() +// purpose : Constructs a RepairGUI_SewingDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +RepairGUI_SewingDlg::RepairGUI_SewingDlg( QWidget* parent, const char* name, RepairGUI* theRepairGUI, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_SEWING"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "RepairGUI_SewingDlg" ); + resize( 303, 219 ); + setCaption( tr( "GEOM_SEWING_TITLE" ) ); + setSizeGripEnabled( TRUE ); + RepairGUI_SewingDlgLayout = new QGridLayout( this ); + RepairGUI_SewingDlgLayout->setSpacing( 6 ); + RepairGUI_SewingDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_SEWING" ) ); + 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)3, (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 ); + RepairGUI_SewingDlgLayout->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 ); + RepairGUI_SewingDlgLayout->addWidget( GroupButtons, 2, 0 ); + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) ); + GroupC1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (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 ); + 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" ); + LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) ); + LineEditC1A2->setMinimumSize( QSize( 40, 0 ) ); + LineEditC1A2->setMaximumSize( QSize( 32767, 32767 ) ); + GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "GEOM_OBJECTS" ) ); + 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_PRECISION" ) ); + TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A2->setFrameShape( QLabel::NoFrame ); + TextLabelC1A2->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); + RepairGUI_SewingDlgLayout->addWidget( GroupC1, 1, 0 ); + /***************************************************************/ + myRepairGUI = theRepairGUI; + Init(Sel) ; /* Initialisations */ +} + + +//================================================================================= +// function : ~RepairGUI_SewingDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +RepairGUI_SewingDlg::~RepairGUI_SewingDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::Init( SALOME_Selection* Sel ) +{ + LineEditC1A1->setMaxLength( 10 ); + QDoubleValidator *Va = new QDoubleValidator( -0.000001, +10000.0, 3, LineEditC1A1 ) ; + LineEditC1A1->setValidator( Va ) ; + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + this->myOkListShapes = false ; + this->myPrecision = 0.00001 ; + LineEditC1A2->setText("0.00001") ; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + 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); + + /* 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( LineEditC1A2, SIGNAL (returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + return ; +} + + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void RepairGUI_SewingDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkListShapes) { + myRepairGUI->MakeSewingAndDisplay( myListShapes, myPrecision ) ; + } + break ; + } + } + // accept(); + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::ClickOnCancel() +{ + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void RepairGUI_SewingDlg::SelectionIntoArgument() +{ + /* All this for first constructor */ + // if(myEditCurrentArgument == LineEditC1A1 ) + + myOkListShapes = false; + myEditCurrentArgument->setText("") ; + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel < 2 ) { + return ; + } + + myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes) ; + myEditCurrentArgument->setText(aString) ; + myOkListShapes = true ; + /* no simulation */ + return ; +} + + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::LineEditReturnPressed() +{ + this->myPrecision = LineEditC1A2->text().toFloat(); + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + diff --git a/src/RepairGUI/RepairGUI_SewingDlg.h b/src/RepairGUI/RepairGUI_SewingDlg.h new file mode 100644 index 000000000..d9fb934d5 --- /dev/null +++ b/src/RepairGUI/RepairGUI_SewingDlg.h @@ -0,0 +1,107 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : RepairGUI_SewingDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_SEWING_H +#define DIALOGBOX_SEWING_H + +#include "RepairGUI.h" + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; + + +//================================================================================= +// class : RepairGUI_SewingDlg +// purpose : +//================================================================================= +class RepairGUI_SewingDlg : public QDialog +{ + Q_OBJECT + +public: + RepairGUI_SewingDlg( QWidget* parent = 0, const char* name = 0, RepairGUI* theRepairGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~RepairGUI_SewingDlg(); + +private: + RepairGUI* myRepairGUI; + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + GEOM::GEOM_Gen::ListOfIOR myListShapes ; + Standard_Real myPrecision ; + bool myOkListShapes ; /* to check when arguments is defined */ + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QGroupBox* GroupC1; + QLineEdit* LineEditC1A1; + QLineEdit* LineEditC1A2; + QPushButton* SelectButtonC1A1; + QLabel* TextLabelC1A1; + QLabel* TextLabelC1A2; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void LineEditReturnPressed() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* RepairGUI_SewingDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_SEWING_H diff --git a/src/RepairGUI/RepairGUI_SuppressFacesDlg.cxx b/src/RepairGUI/RepairGUI_SuppressFacesDlg.cxx new file mode 100644 index 000000000..ccdfe8744 --- /dev/null +++ b/src/RepairGUI/RepairGUI_SuppressFacesDlg.cxx @@ -0,0 +1,523 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : RepairGUI_SuppressFacesDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "RepairGUI_SuppressFacesDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : RepairGUI_SuppressFacesDlg() +// purpose : Constructs a RepairGUI_SuppressFacesDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +RepairGUI_SuppressFacesDlg::RepairGUI_SuppressFacesDlg( QWidget* parent, + const char* name, + RepairGUI* theRepairGUI, + SALOME_Selection* Sel, + Handle (AIS_InteractiveContext) ic, + bool modal, + WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_SUPRESS_FACE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + + if ( !name ) + setName( "RepairGUI_SuppressFacesDlg" ); + resize( 322, 203 ); + setCaption( tr( "GEOM_SUPRESSFACE_TITLE" ) ); + setSizeGripEnabled( TRUE ); + RepairGUI_SuppressFacesDlgLayout = new QGridLayout( this ); + RepairGUI_SuppressFacesDlgLayout->setSpacing( 6 ); + RepairGUI_SuppressFacesDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_SUPRESSFACE" ) ); + 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 ); + RepairGUI_SuppressFacesDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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 ); + Layout2 = new QHBoxLayout; + Layout2->setSpacing( 6 ); + Layout2->setMargin( 0 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "GEOM_MAIN_OBJECT" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + Layout2->addWidget( TextLabelC1A1 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) ); + Layout2->addWidget( SelectButtonC1A1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + LineEditC1A1->setAlignment( int( QLineEdit::AlignLeft ) ); + Layout2->addWidget( LineEditC1A1 ); + GroupC1Layout->addLayout( Layout2, 0, 0 ); + CheckBox1 = new QCheckBox( GroupC1, "CheckBox1" ); + CheckBox1->setText( tr( "GEOM_SUPRESSFACE_SELECT" ) ); + CheckBox1->setChecked( FALSE ); + GroupC1Layout->addWidget( CheckBox1, 1, 0 ); + RepairGUI_SuppressFacesDlgLayout->addWidget( GroupC1, 1, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupButtons->sizePolicy().hasHeightForWidth() ) ); + 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 ); + // + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "GEOM_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "GEOM_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_2, 0, 2 ); + buttonClose = new QPushButton( GroupButtons, "buttonClose" ); + buttonClose->setText( tr( "GEOM_BUT_CLOSE" ) ); + buttonClose->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonClose, 0, 3 ); + RepairGUI_SuppressFacesDlgLayout->addWidget( GroupButtons, 2, 0 ); + myRepairGUI = theRepairGUI; + /* Initialisations */ + Init(Sel, ic) ; + +} + + +//================================================================================= +// function : ~RepairGUI_SuppressFacesDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +RepairGUI_SuppressFacesDlg::~RepairGUI_SuppressFacesDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void RepairGUI_SuppressFacesDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myShape.Nullify() ; + + myIC = ic ; + myUseLocalContext = false ; + myOkShape = false ; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + + /* Select sub shapes mode not checked */ + CheckBox1->setChecked( FALSE ); + myOkSelectSubMode = false ; + + // TODO : previous selection into argument ? + + /* Filter definitions */ + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect( buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnClose() ) ); + connect( GroupConstructors, SIGNAL( clicked(int) ), this, SLOT( ConstructorsClicked(int) )); + + connect( SelectButtonC1A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() )); + connect( CheckBox1, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserSelection() )); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() )); + connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnClose() )); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* display Dialog */ + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void RepairGUI_SuppressFacesDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : Same than click on apply but close this dialog. +//================================================================================= +void RepairGUI_SuppressFacesDlg::ClickOnOk() +{ + this->ClickOnApply() ; + accept(); + + return ; +} + + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void RepairGUI_SuppressFacesDlg::ClickOnApply() +{ + bool testResult = false ; + switch(myConstructorId) + { + case 0 : + { + if( myOkShape && myOkSelectSubMode ) { + testResult = myRepairGUI->OnSuppressFaces( myShape, myShapeIOR, myLocalContextId, myUseLocalContext ) ; + } + if( !testResult ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ; + } + else { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ; + } + /* Reset arguments to allow a new selection */ + this->ResetStateOfDialog() ; + break ; + } + } + return ; +} + + + +//================================================================================= +// function : ClickOnClose() +// purpose : +//================================================================================= +void RepairGUI_SuppressFacesDlg::ClickOnClose() +{ + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + + if(myUseLocalContext) { + myIC->CloseLocalContext(myLocalContextId) ; + this->myUseLocalContext = false ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +// : used only by SelectButtonC1A1 (LineEditC1A1) +//================================================================================= +void RepairGUI_SuppressFacesDlg::SelectionIntoArgument() +{ + + /* Reset argument and local context when selection as changed */ + this->ResetStateOfDialog() ; + + QString aString = ""; /* name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) + return ; + + /* nbSel == 1 */ + TopoDS_Shape S ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if( !IO->hasEntry() ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")) ; + return ; + } + + /* Test the exact type of topology to suppress faces into */ + if ( !S.IsNull() && ( S.ShapeType() == TopAbs_SOLID || S.ShapeType() == TopAbs_SHELL || S.ShapeType() == TopAbs_COMPOUND ) ) { + + if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { + Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO ); + myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */ + LineEditC1A1->setText(aString) ; + myShape = S ; + myOkShape = true ; + return; + } + + if ( IO->hasEntry() ) { + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + myShapeIOR = anIOR->Value(); + myOkShape = true ; + myShape = S ; + LineEditC1A1->setText(aString) ; + return; + } + } + } + + } + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void RepairGUI_SuppressFacesDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + SelectionIntoArgument() ; + } + break; + } + } + return ; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void RepairGUI_SuppressFacesDlg::LineEditReturnPressed() +{ + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void RepairGUI_SuppressFacesDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + + this->ResetStateOfDialog() ; + + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + myGeomGUI->ResetState() ; + myGeomGUI->SetActiveDialogBox(0) ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void RepairGUI_SuppressFacesDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate other active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : Mouse enter onto the dialog to activate it +//================================================================================= +void RepairGUI_SuppressFacesDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void RepairGUI_SuppressFacesDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnClose() ; + return ; +} + + +//================================================================================= +// function : ActivateUserSelection() +// purpose : Activate selection of faces when CheckBox1->isChecked()... +//================================================================================= +void RepairGUI_SuppressFacesDlg::ActivateUserSelection() +{ + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + if( !this->myOkShape ) { + this->ResetStateOfDialog() ; + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_FIRST")) ; + return ; + } + + this->myOkSelectSubMode = CheckBox1->isChecked() ; + + if( this->myUseLocalContext ) { + myIC->CloseLocalContext(myLocalContextId) ; + this->myUseLocalContext = false ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + + if( myOkShape && myOkSelectSubMode ) { + /* local context is defined into the method : 4 = FACES sub selection */ + myGeomGUI->PrepareSubShapeSelection( int(TopAbs_FACE), this->myLocalContextId ) ; + myUseLocalContext = true ; + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_FACE")) ; + } + } else { + CheckBox1->setChecked( false ); + } + + return ; +} + + + +//================================================================================= +// function : ResetStateOfDialog() +// purpose : Completely reset the state of method including local context +//================================================================================= +void RepairGUI_SuppressFacesDlg::ResetStateOfDialog() +{ + this->myOkShape = false ; + this->myEditCurrentArgument->setText("") ; + + /* Select sub shapes mode not checked */ + this->myOkSelectSubMode = false ; + this->CheckBox1->setChecked( FALSE ); + + /* Close its local contact if opened */ + if( this->myUseLocalContext ) { + myIC->CloseLocalContext(this->myLocalContextId) ; + this->myUseLocalContext = false ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + return ; +} diff --git a/src/RepairGUI/RepairGUI_SuppressFacesDlg.h b/src/RepairGUI/RepairGUI_SuppressFacesDlg.h new file mode 100644 index 000000000..7d9ef3288 --- /dev/null +++ b/src/RepairGUI/RepairGUI_SuppressFacesDlg.h @@ -0,0 +1,129 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : RepairGUI_SuppressFacesDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_SUPPRESSFACES_H +#define DIALOGBOX_SUPPRESSFACES_H + +#include "RepairGUI.h" + +#include +#include + +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QCheckBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; + + +//================================================================================= +// class : RepairGUI_SuppressFacesDlg +// purpose : +//================================================================================= +class RepairGUI_SuppressFacesDlg : public QDialog +{ + Q_OBJECT + +public: + RepairGUI_SuppressFacesDlg( QWidget* parent = 0, + const char* name = 0, + RepairGUI* theRepairGUI = 0, + SALOME_Selection* Sel = 0, + Handle (AIS_InteractiveContext) ic = 0, + bool modal = FALSE, + WFlags fl = 0 ); + + ~RepairGUI_SuppressFacesDlg(); + +private : + RepairGUI* myRepairGUI; + void Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void ResetStateOfDialog() ; + + /* Interactive and local context management see also : bool myUseLocalContext() */ + Handle (AIS_InteractiveContext) myIC ; /* Interactive context */ + Standard_Integer myLocalContextId ; /* identify a local context used by this method */ + bool myUseLocalContext ; /* true when this method as opened a local context */ + + GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + + TopoDS_Shape myShape ; + char* myShapeIOR ; + bool myOkShape ; + + bool myOkSelectSubMode ; /* true = sub mode selection activated */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + int myConstructorId ; /* Current constructor id = radio button id */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonApply; + QPushButton* buttonClose; + + QCheckBox* CheckBox1; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnApply() ; + void ClickOnClose(); + + void LineEditReturnPressed() ; + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void ActivateUserSelection() ; + +protected: + QGridLayout* RepairGUI_SuppressFacesDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; + QHBoxLayout* Layout2; + QGridLayout* GroupButtonsLayout; +}; + +#endif // DIALOGBOX_SUPPRESSFACES_H diff --git a/src/RepairGUI/RepairGUI_SuppressHoleDlg.cxx b/src/RepairGUI/RepairGUI_SuppressHoleDlg.cxx new file mode 100644 index 000000000..ca4e06b78 --- /dev/null +++ b/src/RepairGUI/RepairGUI_SuppressHoleDlg.cxx @@ -0,0 +1,976 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : RepairGUI_SuppressHoleDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "RepairGUI_SuppressHoleDlg.h" + + +#include "TopExp_Explorer.hxx" + + +#include "QAD_RightFrame.h" +#include "OCCViewer_Viewer3d.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : RepairGUI_SuppressHoleDlg() +// purpose : Constructs a RepairGUI_SuppressHoleDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +RepairGUI_SuppressHoleDlg::RepairGUI_SuppressHoleDlg( QWidget* parent, + const char* name, + RepairGUI* theRepairGUI, + SALOME_Selection* Sel, + Handle (AIS_InteractiveContext) ic, + bool modal, + WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_SUPRESS_HOLE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_SUPRESS_HOLE_FACE_SHELL"))); + + if ( !name ) + setName( "RepairGUI_SuppressHoleDlg" ); + resize( 303, 204 ); + setCaption( tr( "GEOM_SUPPRESSHOLE_TITLE" ) ); + setSizeGripEnabled( TRUE ); + RepairGUI_SuppressHoleLayout = new QGridLayout( this ); + RepairGUI_SuppressHoleLayout->setSpacing( 6 ); + RepairGUI_SuppressHoleLayout->setMargin( 11 ); + + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "" ) ); + 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 ); + + Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" ); + Constructor2->setText( tr( "" ) ); + Constructor2->setPixmap( image2 ); + Constructor2->setChecked( TRUE ); + Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) ); + Constructor2->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor2, 0, 2 ); + QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_4, 0, 3 ); + RepairGUI_SuppressHoleLayout->addWidget( GroupConstructors, 0, 0 ); + + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupButtons->sizePolicy().hasHeightForWidth() ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "GEOM_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + buttonOk->setAccel( 276824143 ); + GroupButtonsLayout->addWidget( buttonOk ); + QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_2 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "GEOM_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + buttonApply->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply ); + buttonClose = new QPushButton( GroupButtons, "buttonClose" ); + buttonClose->setText( tr( "GEOM_BUT_CLOSE" ) ); + buttonClose->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonClose ); + RepairGUI_SuppressHoleLayout->addWidget( GroupButtons, 2, 0 ); + + /* First constructor */ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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 ); + + Layout2 = new QHBoxLayout; + Layout2->setSpacing( 6 ); + Layout2->setMargin( 0 ); + + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "GEOM_MAIN_OBJECT" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + Layout2->addWidget( TextLabelC1A1 ); + + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) ); + Layout2->addWidget( SelectButtonC1A1 ); + + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + LineEditC1A1->setAlignment( int( QLineEdit::AlignLeft ) ); + Layout2->addWidget( LineEditC1A1 ); + + GroupC1Layout->addLayout( Layout2, 0, 0 ); + + CheckBox1 = new QCheckBox( GroupC1, "CheckBox1" ); + CheckBox1->setText( tr( "GEOM_SUPPRESSHOLE_SELECTFACE" ) ); + CheckBox1->setChecked( FALSE ); + GroupC1Layout->addWidget( CheckBox1, 1, 0 ); + + CheckBox2 = new QCheckBox( GroupC1, "CheckBox2" ); + CheckBox2->setText( tr( "GEOM_SUPPRESSHOLE_SELECTWIRE" ) ); + CheckBox2->setChecked( FALSE ); + GroupC1Layout->addWidget( CheckBox2, 2, 0 ); + + CheckBox3 = new QCheckBox( GroupC1, "CheckBox3" ); + CheckBox3->setText( tr( "GEOM_SUPPRESSHOLE_SELECTFACE_END" ) ); + CheckBox3->setChecked( FALSE ); + GroupC1Layout->addWidget( CheckBox3, 3, 0 ); + RepairGUI_SuppressHoleLayout->addWidget( GroupC1, 1, 0 ); + + /* Second constructor */ + GroupC2 = new QGroupBox( this, "GroupC2" ); + GroupC2->setTitle( tr( "" ) ); + GroupC2->setMinimumSize( QSize( 0, 0 ) ); + GroupC2->setFrameShape( QGroupBox::Box ); + GroupC2->setFrameShadow( QGroupBox::Sunken ); + GroupC2->setColumnLayout(0, Qt::Vertical ); + GroupC2->layout()->setSpacing( 0 ); + GroupC2->layout()->setMargin( 0 ); + GroupC2Layout = new QGridLayout( GroupC2->layout() ); + GroupC2Layout->setAlignment( Qt::AlignTop ); + GroupC2Layout->setSpacing( 6 ); + GroupC2Layout->setMargin( 11 ); + + Layout3 = new QHBoxLayout; + Layout3->setSpacing( 6 ); + Layout3->setMargin( 0 ); + + TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" ); + TextLabelC2A1->setText( tr( "GEOM_SUPPRESSHOLE_FACE_SHELL" ) ); + TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A1->setFrameShape( QLabel::NoFrame ); + TextLabelC2A1->setFrameShadow( QLabel::Plain ); + Layout3->addWidget( TextLabelC2A1 ); + + SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" ); + SelectButtonC2A1->setText( tr( "" ) ); + SelectButtonC2A1->setPixmap( image1 ); + SelectButtonC2A1->setToggleButton( FALSE ); + SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) ); + Layout3->addWidget( SelectButtonC2A1 ); + + LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" ); + LineEditC2A1->setAlignment( int( QLineEdit::AlignLeft ) ); + Layout3->addWidget( LineEditC2A1 ); + + GroupC2Layout->addLayout( Layout3, 0, 0 ); + QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + GroupC2Layout->addItem( spacer_3, 2, 0 ); + + CheckBoxC2_1 = new QCheckBox( GroupC2, "CheckBoxC2_1" ); + CheckBoxC2_1->setText( tr( "GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE" ) ); + CheckBoxC2_1->setChecked( FALSE ); + + GroupC2Layout->addWidget( CheckBoxC2_1, 1, 0 ); + RepairGUI_SuppressHoleLayout->addWidget( GroupC2, 1, 0 ); + + myRepairGUI = theRepairGUI; + /* Initialisations */ + Init(Sel, ic) ; +} + + +//================================================================================= +// function : ~RepairGUI_SuppressHoleDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +RepairGUI_SuppressHoleDlg::~RepairGUI_SuppressHoleDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void RepairGUI_SuppressHoleDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) +{ + GroupC1->show(); + GroupC2->hide(); + + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myShape.Nullify() ; + + myIC = ic ; + myUseLocalContext = false ; + myOkShape = false ; + myOkSelectFace = false ; + + myListOfIdFace = new GEOM::GEOM_Shape::ListOfSubShapeID; + myListOfIdWire = new GEOM::GEOM_Shape::ListOfSubShapeID; + myListOfIdEndFace = new GEOM::GEOM_Shape::ListOfSubShapeID; + + myListOfIdFace->length(0) ; + myListOfIdWire->length(0) ; + myListOfIdEndFace->length(0) ; + + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + + /* Select sub modes not checked */ + CheckBox1->setChecked( FALSE ); /* sub mode GEOM::FACE */ + CheckBox2->setChecked( FALSE ); /* sub mode GEOM::WIRE */ + CheckBox3->setChecked( FALSE ); /* sub mode END GEOM::FACE */ + + CheckBoxC2_1->setChecked( FALSE ); /* sub mode GEOM::WIRE(S) */ + + // TODO : previous selection into argument ? + + /* Filter definitions */ + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect( buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnClose() ) ); + connect( GroupConstructors, SIGNAL( clicked(int) ), this, SLOT( ConstructorsClicked(int) )); + + connect( SelectButtonC1A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() )); + connect( SelectButtonC2A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() )); + + connect( CheckBox1, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserFaceSelection() )); + connect( CheckBox2, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserWireSelection() )); + connect( CheckBox3, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserEndFaceSelection() )); + + connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + + /* for the second constructor */ + connect( CheckBoxC2_1, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserWiresOnFaceShellSelection() )); + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() )); + connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnClose() )); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myGeomGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* display Dialog */ + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void RepairGUI_SuppressHoleDlg::ConstructorsClicked(int constructorId) +{ + switch (constructorId) + { + case 0: + { + GroupC1->show(); + GroupC2->hide(); + myConstructorId = constructorId ; + myEditCurrentArgument = LineEditC1A1 ; + LineEditC1A1->setText(tr("")) ; + myOkShape = false ; + myOkSelectFace = false ; + this->ResetPartial() ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + break; + } + case 1: + { + GroupC1->hide(); + GroupC2->show(); + myConstructorId = constructorId ; + myEditCurrentArgument = LineEditC2A1 ; + LineEditC2A1->setText(tr("")) ; + myOkShape = false ; + this->ResetPartial() ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + this->ResetPartial() ; + break; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : Same than click on apply but close this dialog. +//================================================================================= +void RepairGUI_SuppressHoleDlg::ClickOnOk() +{ + this->ClickOnApply() ; + accept(); + + return ; +} + + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void RepairGUI_SuppressHoleDlg::ClickOnApply() +{ + myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + bool testResult = false ; + + if( !myOkShape ) + return ; + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if( !myOkSelectFace ) + return ; + + if( CheckBox2->isChecked() ) { + + if( !CheckBox3->isChecked() ) { + + /* Call method to get sub shape selection of GEOM::WIRE */ + bool aTest = myGeomGUI->GetIndexSubShapeSelected(myFace, int(TopAbs_WIRE), myListOfIdWire, myLocalContextId, myUseLocalContext) ; + + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ;/* Display all objects so that next method using ic can memorize them */ + if( !aTest || myListOfIdWire->length() != 1 ) { + CheckBox2->setChecked(FALSE) ; + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ; + } + else { + myListOfIdEndFace->length(0) ; /* no end face */ + QApplication::setOverrideCursor( Qt::waitCursor ); + testResult = myRepairGUI->OnSuppressHole( myShapeIOR, myListOfIdFace, myListOfIdWire, myListOfIdEndFace ) ; + QApplication::restoreOverrideCursor(); + } + } + else { /* CheckBox3->isChecked() */ + + /* Call method to get sub shape selection of END GEOM::FACE */ + bool aTest = myGeomGUI->GetIndexSubShapeSelected(myShape, int(TopAbs_FACE), myListOfIdEndFace, myLocalContextId, myUseLocalContext) ; + + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */ + if( !aTest || myListOfIdEndFace->length() != 1 ) { + CheckBox3->setChecked(FALSE) ; + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ; + } + else { + QApplication::setOverrideCursor( Qt::waitCursor ); + testResult = myRepairGUI->OnSuppressHole( myShapeIOR, myListOfIdFace, myListOfIdWire, myListOfIdEndFace ) ; + QApplication::restoreOverrideCursor(); + } + } + } + break ; + } + + case 1: /* second constructor */ + { + if( CheckBoxC2_1->isChecked() ) { + + /* Call method to get sub shape selection of one or more GEOM::WIRE(s) on a face or a shell */ + bool aTest = myGeomGUI->GetIndexSubShapeSelected(myShape, int(TopAbs_WIRE), myListOfIdWire, myLocalContextId, myUseLocalContext) ; + + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */ + + if( !aTest || myListOfIdWire->length() < 1 ) { + CheckBoxC2_1->setChecked(FALSE) ; + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ; + } + else { + QApplication::setOverrideCursor( Qt::waitCursor ); + testResult = myRepairGUI->OnSuppressHolesInFaceOrShell( myShapeIOR, myListOfIdWire ) ; + QApplication::restoreOverrideCursor(); + } + } + break ; + } + } + + + if( !testResult ) + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ; + else + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_DONE") ) ; + + /* Reset arguments to allow a new selection */ + this->ResetStateOfDialog() ; + return ; +} + + + +//================================================================================= +// function : ClickOnClose() +// purpose : +//================================================================================= +void RepairGUI_SuppressHoleDlg::ClickOnClose() +{ + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext(); + if(myUseLocalContext) { + myIC->CloseLocalContext(myLocalContextId) ; + this->myUseLocalContext = false ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + } + + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +// : used only by SelectButtonC1A1 and SelectButtonC2A1 +//================================================================================= +void RepairGUI_SuppressHoleDlg::SelectionIntoArgument() +{ + + /* Reset argument and local context when selection as changed */ + this->ResetStateOfDialog() ; + + QString aString = ""; /* Name of selection */ + + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) + return ; + + /* nbSel == 1 */ + TopoDS_Shape S ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if ( S.IsNull() || S.ShapeType() == TopAbs_VERTEX || S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE ) { + return ; + } + + /* Test the exact type of topology to suppress faces into. */ + /* For the second constructor a face or shell selection is needed */ + if ( myConstructorId == 0 || ( myConstructorId == 1 && ( S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL ) ) ) { + + if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { + Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO ); + + /* The Geom IOR string of selection */ + myShapeIOR = GIObject->getIOR(); + myEditCurrentArgument->setText(aString) ; + myShape = S ; + myOkShape = true ; + return; + } + + if ( IO->hasEntry() ) { + SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + myShapeIOR = anIOR->Value(); + myOkShape = true ; + myShape = S ; + myEditCurrentArgument->setText(aString) ; + return; + } + } + } + + } + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void RepairGUI_SuppressHoleDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + SelectionIntoArgument() ; + } + break; + } + case 1: + { + if(send == SelectButtonC2A1) { + LineEditC2A1->setFocus() ; + myEditCurrentArgument = LineEditC2A1; + SelectionIntoArgument() ; + } + break; + } + } + return ; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void RepairGUI_SuppressHoleDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + else if ( send == LineEditC2A1) + myEditCurrentArgument = LineEditC2A1; + 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 ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void RepairGUI_SuppressHoleDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + + this->ResetStateOfDialog() ; + + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupC2->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + + myGeomGUI->ResetState() ; + myGeomGUI->SetActiveDialogBox(0) ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void RepairGUI_SuppressHoleDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate other active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupC2->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : Mouse enter onto the dialog to activate it +//================================================================================= +void RepairGUI_SuppressHoleDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void RepairGUI_SuppressHoleDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnClose() ; + return ; +} + + +//================================================================================= +// function : ActivateUserFaceSelection() +// purpose : Called when CheckBox1 state has changed. (Face selection is ckecked) +// : Be careful user must first select a face then a wire ! +//================================================================================= +void RepairGUI_SuppressHoleDlg::ActivateUserFaceSelection() +{ + if( !this->myOkShape ) { + this->ResetStateOfDialog() ; + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_MAIN_OBJECT") ) ; + return ; + } + + /* Test the viewer type VTK */ + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ; + this->ResetStateOfDialog() ; + return; + } + + if( CheckBox1->isChecked() ) { + + /* local context is opened into the method : Prepare GEOM::FACE sub selection */ + myGeomGUI->PrepareSubShapeSelection( int(TopAbs_FACE), this->myLocalContextId ) ; + myUseLocalContext = true ; + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_SUPPRESSHOLE_SELECTFACE") ) ; + } + else { + this->ResetPartial() ; + } + + return ; +} + + +//================================================================================= +// function : ActivateUserWireSelection() +// purpose : Called when CheckBox2 state has changed. (Wire selection is ckecked) +// : Be careful user must first select a face then a wire ! +//================================================================================= +void RepairGUI_SuppressHoleDlg::ActivateUserWireSelection() +{ + + if( !this->myOkShape ) { + this->ResetStateOfDialog() ; + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_MAIN_OBJECT") ) ; + return ; + } + + /* Test the type of viewer VTK */ + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ; + this->ResetStateOfDialog() ; + return; + } + + if( CheckBox1->isChecked() ) { + + /* Get sub shape selection GEOM::FACE : local context is closed */ + bool aTest = myGeomGUI->GetIndexSubShapeSelected(myShape, int(TopAbs_FACE), myListOfIdFace, myLocalContextId, myUseLocalContext) ; + + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */ + if( !aTest || myListOfIdFace->length() != 1 ) { + CheckBox1->setChecked(FALSE) ; + myOkSelectFace = false ; + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ; + } + else { + myOkSelectFace = true ; + } + } + else { + this->ResetPartial() ; + return ; + } + + + if( CheckBox2->isChecked() ) { + + /* Get the face selection */ + this->myFace = FaceFromList(myShape, myListOfIdFace) ; + /* Local context is opened into the method : Prepare GEOM::WIRE sub selection into a face */ + myGeomGUI->PrepareSubShapeSelectionArgumentShape( this->myFace, int(TopAbs_WIRE), this->myLocalContextId ) ; + myUseLocalContext = true ; + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_SUPPRESSHOLE_SELECTWIRE") ) ; + } + else { + this->ResetPartial() ; + } + + return ; +} + + + +//================================================================================= +// function : ActivateUserlEndFaceSelection() +// purpose : Called when CheckBox3 state has changed. ( Optional End Face selection ) +// : Be careful user must first select a face then a wire then this optional end face ! +//================================================================================= +void RepairGUI_SuppressHoleDlg::ActivateUserEndFaceSelection() +{ + + if( !this->myOkShape ) { + this->ResetStateOfDialog() ; + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_MAIN_OBJECT") ) ; + return ; + } + + /* Test the type of viewer VTK */ + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ; + this->ResetStateOfDialog() ; + return; + } + + + if( CheckBox2->isChecked() ) { + /* Call method to get sub shape selection for the GEOM::WIRE into myFace : local context is closed */ + bool aTest = myGeomGUI->GetIndexSubShapeSelected(this->myFace, int(TopAbs_WIRE), myListOfIdWire, myLocalContextId, myUseLocalContext) ; + + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */ + + if( !aTest || myListOfIdWire->length() != 1 ) { + CheckBox2->setChecked(FALSE) ; + CheckBox3->setChecked(FALSE) ; + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ; + return ; + } + } + else { + this->ResetPartial() ; + return ; + } + + + if( CheckBox3->isChecked() ) { + /* Local context is opened into the method : prepare GEOM::FACE(end) into myShape sub selection */ + myGeomGUI->PrepareSubShapeSelectionArgumentShape( this->myShape, int(TopAbs_FACE), this->myLocalContextId ) ; + myUseLocalContext = true ; + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_SUPPRESSHOLE_SELECTFACE_END") ) ; + } + else { + this->ResetPartial() ; + } + + return ; +} + + + +//================================================================================= +// function : ActivateUserWiresOnFaceShellSelection() +// purpose : Called when CheckBoxC2_1 state has changed. +// : Only for second constructor ! +// : Prepare selection for wire(s) on main object that is a face or a shell +//================================================================================= +void RepairGUI_SuppressHoleDlg::ActivateUserWiresOnFaceShellSelection() +{ + + if( !this->myOkShape ) { + this->ResetStateOfDialog() ; + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_MAIN_OBJECT") ) ; + return ; + } + + /* Test the type of viewer VTK */ + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ; + this->ResetStateOfDialog() ; + return; + } + + if( CheckBoxC2_1->isChecked() ) { + /* Local context is opened to prepare GEOM::WIRE(S) selection into 'myShape' that is a (main) face */ + myGeomGUI->PrepareSubShapeSelectionArgumentShape( this->myShape, int(TopAbs_WIRE), this->myLocalContextId ) ; + myUseLocalContext = true ; + myGeomGUI->GetDesktop()->putInfo( tr("GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE") ) ; + } + else { + this->ResetPartial() ; + } + return ; +} + + + +//================================================================================= +// function : FaceFromList() +// purpose : Return the face (selected by user) that is a sub shape of 'aShape' +// : and which unique index is in 'ListOfSub'. +// : This allows opening a local context with this face loaded. +// : See : myGeomGUI->PrepareSubShapeSelectionArgumentShape(...) +//================================================================================= +TopoDS_Shape RepairGUI_SuppressHoleDlg::FaceFromList( const TopoDS_Shape& aShape, + const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfSub ) +{ + TopoDS_Shape tds ; + tds.Nullify() ; + if( ListOfSub.length() != 1 || aShape.IsNull() ) + return tds ; + + int i = ListOfSub[0] ; + TopExp_Explorer exp ; + int j = 1 ; + for( exp.Init(aShape, TopAbs_FACE); exp.More(); exp.Next() ) { + if(j == i) + return exp.Current() ; + j++ ; + } + return tds ; +} + + + + +//================================================================================= +// function : ResetStateOfDialog() +// purpose : Completely reset the state of method including local context +//================================================================================= +void RepairGUI_SuppressHoleDlg::ResetStateOfDialog() +{ + this->myOkShape = false ; + this->myEditCurrentArgument->setText("") ; + + /* Partial reset and more ...*/ + this->ResetPartial() ; + + return ; +} + + +//================================================================================= +// function : ResetPartial() +// purpose : Partially reset to keep only main selection +//================================================================================= +void RepairGUI_SuppressHoleDlg::ResetPartial() +{ + /* Select sub shape modes not checked */ + this->myOkSelectFace = false ; + this->CheckBox1->setChecked( FALSE ); + this->CheckBox2->setChecked( FALSE ); + this->CheckBox3->setChecked( FALSE ); + this->CheckBoxC2_1->setChecked( FALSE ); + + myListOfIdFace->length(0) ; + myListOfIdWire->length(0) ; + myListOfIdEndFace->length(0) ; + + /* Close its local contact if opened */ + if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext(); + if( this->myUseLocalContext ) { + myIC->CloseLocalContext(this->myLocalContextId) ; + this->myUseLocalContext = false ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + } + + return ; +} diff --git a/src/RepairGUI/RepairGUI_SuppressHoleDlg.h b/src/RepairGUI/RepairGUI_SuppressHoleDlg.h new file mode 100644 index 000000000..e37068d19 --- /dev/null +++ b/src/RepairGUI/RepairGUI_SuppressHoleDlg.h @@ -0,0 +1,162 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : RepairGUI_SuppressHoleDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef GEOMETRYGUI_SUPPRESSHOLE_H +#define GEOMETRYGUI_SUPPRESSHOLE_H + +#include "RepairGUI.h" + +#include +#include + +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QCheckBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class RepairGUI; + +//================================================================================= +// class : RepairGUI_SuppressHoleDlg +// purpose : +//================================================================================= +class RepairGUI_SuppressHoleDlg : public QDialog +{ + Q_OBJECT + +public: + RepairGUI_SuppressHoleDlg( QWidget* parent = 0, + const char* name = 0, + RepairGUI* theRepairGUI = 0, + SALOME_Selection* Sel = 0, + Handle (AIS_InteractiveContext) ic = 0, + bool modal = FALSE, + WFlags fl = 0 ); + + ~RepairGUI_SuppressHoleDlg(); + +private : + RepairGUI* myRepairGUI; + void Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* Mouse enter the QWidget (to reactivate it) */ + + void ResetStateOfDialog() ; + void ResetPartial() ; + + /* Return the face selected by user from the main shape and index in a ListOfSub */ + TopoDS_Shape FaceFromList( const TopoDS_Shape& aShape, + const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfSub ) ; + + Handle (AIS_InteractiveContext) myIC ; /* Interactive context */ + Standard_Integer myLocalContextId ; /* identify a local context used by this method */ + bool myUseLocalContext ; /* true when this method as opened a local context */ + + GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */ + GEOMBase_Context* myGeomGUI ; /* Current GeomGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + + TopoDS_Shape myShape ; /* Main shape selected */ + TopoDS_Shape myFace ; /* Face selected */ + + char* myShapeIOR ; + bool myOkShape ; + + bool myOkSelectFace ; /* true = sub mode GEOM::FACE selection done */ + bool myOkSelectWire ; /* true = sub mode GEOM::WIRE selection done (first wire) */ + + GEOM::GEOM_Shape::ListOfSubShapeID_var myListOfIdFace ; /* After selection contains index of face into myShape */ + GEOM::GEOM_Shape::ListOfSubShapeID_var myListOfIdWire ; /* After selection contains index of wire into myFace */ + GEOM::GEOM_Shape::ListOfSubShapeID_var myListOfIdEndFace ; /* After selection contains index of end face into myShape */ + + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + int myConstructorId ; /* Current constructor id = radio button id */ + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonApply; + QPushButton* buttonClose; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + QCheckBox* CheckBox1; + QCheckBox* CheckBox2; + QCheckBox* CheckBox3; + + /* Second constructor */ + QRadioButton* Constructor2; + QGroupBox* GroupC2; + QLabel* TextLabelC2A1; + QPushButton* SelectButtonC2A1; + QLineEdit* LineEditC2A1; + QCheckBox* CheckBoxC2_1; + + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnApply() ; + void ClickOnClose(); + + void LineEditReturnPressed() ; + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void ActivateUserFaceSelection() ; + void ActivateUserWireSelection() ; + void ActivateUserEndFaceSelection() ; + + /* For the second constructor */ + void ActivateUserWiresOnFaceShellSelection() ; + + +protected: + + QGridLayout* RepairGUI_SuppressHoleLayout; + QGridLayout* GroupConstructorsLayout; + QHBoxLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; + QHBoxLayout* Layout2; + + QGridLayout* GroupC2Layout; + QHBoxLayout* Layout3; +}; + +#endif // GEOMETRYGUI_SUPPRESSHOLE_H diff --git a/src/TransformationGUI/Makefile.in b/src/TransformationGUI/Makefile.in new file mode 100644 index 000000000..5a4bf819d --- /dev/null +++ b/src/TransformationGUI/Makefile.in @@ -0,0 +1,77 @@ +# GEOM TRANSFORMATIONGUI : +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Damien COQUERET (OCC) +# Module : GEOM +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= TransformationGUI.h + +# Libraries targets +LIB = libTransformationGUI.la + +LIB_SRC = TransformationGUI.cxx \ + TransformationGUI_TranslationDlg.cxx \ + TransformationGUI_RotationDlg.cxx \ + TransformationGUI_MirrorDlg.cxx \ + TransformationGUI_ScaleDlg.cxx \ + TransformationGUI_MultiTranslationDlg.cxx \ + TransformationGUI_MultiRotationDlg.cxx + +LIB_MOC = \ + TransformationGUI.h \ + TransformationGUI_TranslationDlg.h \ + TransformationGUI_RotationDlg.h \ + TransformationGUI_MirrorDlg.h \ + TransformationGUI_ScaleDlg.h \ + TransformationGUI_MultiTranslationDlg.h \ + TransformationGUI_MultiRotationDlg.h + +LIB_CLIENT_IDL = SALOME_Exception.idl \ + GEOM_Gen.idl \ + GEOM_Shape.idl \ + SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +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 -lDlgRef -lGEOMBase $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/TransformationGUI/TransformationGUI.cxx b/src/TransformationGUI/TransformationGUI.cxx new file mode 100644 index 000000000..6a6407415 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI.cxx @@ -0,0 +1,320 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +using namespace std; +#include "TransformationGUI.h" + +#include "TransformationGUI_TranslationDlg.h" // Method TRANSLATION +#include "TransformationGUI_RotationDlg.h" // Method ROTATION +#include "TransformationGUI_MirrorDlg.h" // Method MIRROR +#include "TransformationGUI_ScaleDlg.h" // Method SCALE +#include "TransformationGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION +#include "TransformationGUI_MultiRotationDlg.h" // Method MULTI ROTATION + +//======================================================================= +// function : TransformationGUI() +// purpose : Constructor +//======================================================================= +TransformationGUI::TransformationGUI() : + QObject() +{ + myGeomGUI = GEOMBase_Context::GetGeomGUI(); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); +} + + +//======================================================================= +// function : ~TransformationGUI() +// purpose : Destructor +//======================================================================= +TransformationGUI::~TransformationGUI() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool TransformationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + myGeomGUI->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection(myGeomGUI->GetActiveStudy()->getSelection()); + + switch (theCommandID) + { + case 4021: // TRANSLATION + { + TransformationGUI_TranslationDlg *aDlg = new TransformationGUI_TranslationDlg(parent, "", this, Sel); + break; + } + case 4022: // ROTATION + { + TransformationGUI_RotationDlg *aDlg = new TransformationGUI_RotationDlg(parent, "", this, Sel); + break; + } + case 4023: // MIRROR + { + TransformationGUI_MirrorDlg *aDlg = new TransformationGUI_MirrorDlg(parent, "", this, Sel); + break; + } + case 4024: // SCALE + { + TransformationGUI_ScaleDlg *aDlg = new TransformationGUI_ScaleDlg(parent, "", this, Sel ); + break; + } + case 4030: // MULTI TRANSLATION + { + TransformationGUI_MultiTranslationDlg *aDlg = new TransformationGUI_MultiTranslationDlg(parent, "", this, Sel); + break; + } + case 4040: // MULTI ROTATION + { + TransformationGUI_MultiRotationDlg *aDlg = new TransformationGUI_MultiRotationDlg(parent, "", this, Sel); + break; + } + default: + { + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + } + return true; +} + + +//================================================================================= +// function : MakeTranslationAndDisplay() +// purpose : Translate a shape +//================================================================================= +void TransformationGUI::MakeTranslationAndDisplay(GEOM::GEOM_Shape_ptr Shape, gp_Vec V) +{ + try { + GEOM::GEOM_Shape_var result = myGeom->MakeTranslation(Shape, V.X(), V.Y(), V.Z()); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(Shape->NameType()); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//======================================================================================= +// function : MakeRotationAndDisplay() +// purpose : +//======================================================================================= +void TransformationGUI::MakeRotationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, + const gp_Dir dir, const Standard_Real angle) +{ + try { + const GEOM::AxisStruct axis = myGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), + dir.X(), dir.Y(), dir.Z()); + GEOM::GEOM_Shape_var result = myGeom->MakeRotation(Shape, axis, angle); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return ; + } + result->NameType(Shape->NameType()); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeMirrorAndDisplay() +// purpose : +//===================================================================================== +void TransformationGUI::MakeMirrorAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2) +{ + try { + GEOM::GEOM_Shape_var result = myGeom->MakeMirrorByPlane(Shape1, Shape2); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + return; + } + result->NameType(Shape1->NameType()); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//===================================================================================== +// function : MakeScaleAndDisplay() +// purpose : +//===================================================================================== +void TransformationGUI::MakeScaleAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, + const Standard_Real factor) +{ + try { + GEOM::PointStruct P = myGeom->MakePointStruct(centralPoint.X(), centralPoint.Y(), centralPoint.Z()); + GEOM::GEOM_Shape_var result = myGeom->MakeScaleTransform(Shape, P, factor); + result->NameType(Shape->NameType()); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + else + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//================================================================================= +// function : MakeMultiTranslation1DAndDisplay() +// purpose : Multi-Translate a shape +//================================================================================= +void TransformationGUI::MakeMultiTranslation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, + const double Step, const short NbTimes) +{ + try { + GEOM::PointStruct d = myGeom->MakePointStruct(Dir.X(), Dir.Y(), Dir.Z()); + GEOM::DirStruct dstruct = myGeom->MakeDirection(d); + + GEOM::GEOM_Shape_var result = myGeom->MakeMultiTranslation1D(Shape, dstruct, Step, NbTimes); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_COMPOUND")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//================================================================================= +// function : MakeMultiTranslation2DAndDisplay() +// purpose : Multi-Translate a shape +//================================================================================= +void TransformationGUI::MakeMultiTranslation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape, + const gp_Dir Dir1,const double Step1, const short NbTimes1, + const gp_Dir Dir2, const double Step2, const short NbTimes2) +{ + try { + GEOM::PointStruct d1 = myGeom->MakePointStruct(Dir1.X(), Dir1.Y(), Dir1.Z()); + GEOM::DirStruct dstruct1 = myGeom->MakeDirection(d1); + GEOM::PointStruct d2 = myGeom->MakePointStruct(Dir2.X(), Dir2.Y(), Dir2.Z()); + GEOM::DirStruct dstruct2 = myGeom->MakeDirection(d2); + + GEOM::GEOM_Shape_var result = myGeom->MakeMultiTranslation2D(Shape, dstruct1, Step1, NbTimes1, + dstruct2, Step2, NbTimes2); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_COMPOUND")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//================================================================================= +// function : MakeMultiRotation1DAndDisplay() +// purpose : Multi-Rotate a shape +//================================================================================= +void TransformationGUI::MakeMultiRotation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, + const gp_Pnt Loc, const short NbTimes) +{ + try { + GEOM::PointStruct d = myGeom->MakePointStruct(Dir.X(), Dir.Y(), Dir.Z()); + GEOM::DirStruct dstruct = myGeom->MakeDirection(d) ; + GEOM::PointStruct pstruct = myGeom->MakePointStruct(Loc.X(), Loc.Y(), Loc.Z()); + + GEOM::GEOM_Shape_var result = myGeom->MakeMultiRotation1D(Shape, dstruct, pstruct, NbTimes); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_COMPOUND")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} + + +//================================================================================= +// function : MakeMultiRotation2DAndDisplay() +// purpose : Multi-Rotate a shape +//================================================================================= +void TransformationGUI::MakeMultiRotation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, + const gp_Pnt Loc, const double Ang, const short NbTimes1, + const double Step, const short NbTimes2) +{ + try { + GEOM::PointStruct d = myGeom->MakePointStruct(Dir.X(), Dir.Y(), Dir.Z()); + GEOM::DirStruct dstruct = myGeom->MakeDirection(d); + GEOM::PointStruct pstruct = myGeom->MakePointStruct(Loc.X(), Loc.Y(), Loc.Z()); + + GEOM::GEOM_Shape_var result = myGeom->MakeMultiRotation2D(Shape, dstruct, pstruct, + Ang, NbTimes1, Step, NbTimes2); + if(result->_is_nil()) { + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")); + return; + } + result->NameType(tr("GEOM_COMPOUND")); + if(myGeomGUI->Display(result)) + myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")); + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + return; +} diff --git a/src/TransformationGUI/TransformationGUI.h b/src/TransformationGUI/TransformationGUI.h new file mode 100644 index 000000000..27686159a --- /dev/null +++ b/src/TransformationGUI/TransformationGUI.h @@ -0,0 +1,71 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef TRANSFORMATIONGUI_H +#define TRANSFORMATIONGUI_H + +#include "GEOMBase_Display.h" + +//================================================================================= +// class : TransformationGUI +// purpose : +//================================================================================= +class TransformationGUI : public QObject +{ + Q_OBJECT /* for QT compatibility */ + +public : + TransformationGUI(); + ~TransformationGUI(); + + 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, + const gp_Dir dir, const Standard_Real angle); + void MakeMirrorAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2); + void MakeScaleAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, + const Standard_Real factor); + void MakeMultiTranslation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, + const gp_Dir Dir, const double Step, const short NbTimes); + void MakeMultiTranslation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape, + const gp_Dir Dir1, const double Step1, const short NbTimes1, + const gp_Dir Dir2, const double Step2, const short NbTimes2); + void MakeMultiRotation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, + const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes); + void MakeMultiRotation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape, + const gp_Dir Dir, const gp_Pnt Loc, const double Ang, + const short NbTimes1, const double Step, const short NbTimes2); + +private: + GEOMBase_Context* myGeomGUI; + GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + +}; + +#endif diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx new file mode 100644 index 000000000..47549a230 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx @@ -0,0 +1,520 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI_MirrorDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "TransformationGUI_MirrorDlg.h" + +#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 +// name 'name' and widget flags set to 'f'. +// 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 ) +{ + + 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 ) ; +} + + +//================================================================================= +// function : ~TransformationGUI_MirrorDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +TransformationGUI_MirrorDlg::~TransformationGUI_MirrorDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void TransformationGUI_MirrorDlg::Init( SALOME_Selection* Sel ) +{ + mySelection = Sel ; + myShape1.Nullify() ; + myShape2.Nullify() ; + mySimulationTopoDs.Nullify() ; + myConstructorId = 0 ; + + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + GroupC1->show(); + + myEditCurrentArgument = LineEditC1A1 ; + Constructor1->setChecked( TRUE ); + myOkShape1 = myOkShape2 = false ; + + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + myGeom = GEOM::GEOM_Gen::_narrow(comp); + /* Filter definition */ + + myFaceFilter = new GEOM_FaceFilter( StdSelect_Plane, myGeom ); + + // TODO previous selection into argument ? + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect( 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 ; +} + + + +//================================================================================= +// 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 ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void TransformationGUI_MirrorDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +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 ; +} + + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void TransformationGUI_MirrorDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + 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 ; + } + + /* 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(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() ) + return ; + else + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + } + catch(Standard_Failure) { + MESSAGE( "Exception catched in MakeMirrorSimulationAndDisplay" ) ; + return ; + } + return ; +} + + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void TransformationGUI_MirrorDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + 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 ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void TransformationGUI_MirrorDlg::LineEditReturnPressed() +{ + 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 ; +} + + + +//================================================================================= +// 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 ; +} + + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void TransformationGUI_MirrorDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; /* same than click on cancel button */ +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void TransformationGUI_MirrorDlg::enterEvent( QEvent * ) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void TransformationGUI_MirrorDlg::ActivateThisDialog() +{ + /* 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 ; +} diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.h b/src/TransformationGUI/TransformationGUI_MirrorDlg.h new file mode 100644 index 000000000..5a6c50df5 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.h @@ -0,0 +1,117 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI_MirrorDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_MIRROR_H +#define DIALOGBOX_MIRROR_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 +{ + 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(); + +private : + 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; + +private slots : + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void LineEditReturnPressed() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* TransformationGUI_MirrorDlgLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_MIRROR_H diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx new file mode 100644 index 000000000..4618535ca --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx @@ -0,0 +1,982 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI_MultiTranslationDlg.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header$ + +using namespace std; +#include "TransformationGUI_MultiRotationDlg.h" + +#include "QAD_Config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : TransformationGUI_MultiRotationDlg() +// purpose : Constructs a TransformationGUI_MultiRotationDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg( 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 ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_MULTIROTATION_SIMPLE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_MULTIROTATION_DOUBLE"))); + + if ( !name ) + setName( "TransformationGUI_MultiTranlationDlg" ); + resize( 303, 251 ); + setCaption( tr( "GEOM_MULTIROTATION_TITLE" ) ); + setSizeGripEnabled( TRUE ); + TransformationGUI_MultiRotationDlgLayout = new QGridLayout( this ); + TransformationGUI_MultiRotationDlgLayout->setSpacing( 6 ); + TransformationGUI_MultiRotationDlgLayout->setMargin( 11 ); + + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_MULTIROTATION" ) ); + 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 ); + Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" ); + Constructor2->setText( tr( "" ) ); + Constructor2->setPixmap( image2 ); + Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) ); + Constructor2->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor2, 0, 2 ); + QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_2, 0, 3 ); + QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_3, 0, 1 ); + + TransformationGUI_MultiRotationDlgLayout->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_MultiRotationDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_MULTIROTATION_SIMPLE" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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_MAIN_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_VECTOR" ) ); + TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A2->setFrameShape( QLabel::NoFrame ); + TextLabelC1A2->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); + + TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" ); + TextLabelC1A3->setText( tr( "GEOM_NB_TIMES" ) ); + TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A3->setFrameShape( QLabel::NoFrame ); + TextLabelC1A3->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 ); + + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); + GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); + + /* a QSpinBox */ + SpinBox_C1A3 = new QSpinBox( GroupC1, "SpinBox_C1A3" ) ; + SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) ); + GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 ); + + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + + SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); + SelectButtonC1A2->setText( tr( "" ) ); + SelectButtonC1A2->setPixmap( image1 ); + SelectButtonC1A2->setToggleButton( FALSE ); + SelectButtonC1A2->setMaximumSize( QSize( 28, 32767 ) ); + GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); + + TransformationGUI_MultiRotationDlgLayout->addWidget( GroupC1, 1, 0 ); + + /***************************************************************/ + + GroupC2 = new QGroupBox( this, "GroupC2" ); + GroupC2->setTitle( tr( "GEOM_MULTIROTATION_DOUBLE" ) ); + GroupC2->setMinimumSize( QSize( 0, 0 ) ); + GroupC2->setFrameShape( QGroupBox::Box ); + GroupC2->setFrameShadow( QGroupBox::Sunken ); + GroupC2->setColumnLayout(0, Qt::Vertical ); + GroupC2->layout()->setSpacing( 0 ); + GroupC2->layout()->setMargin( 0 ); + GroupC2Layout = new QGridLayout( GroupC2->layout() ); + GroupC2Layout->setAlignment( Qt::AlignTop ); + GroupC2Layout->setSpacing( 6 ); + GroupC2Layout->setMargin( 11 ); + + TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" ); + TextLabelC2A1->setText( tr( "GEOM_MAIN_OBJECT" ) ); + TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A1->setFrameShape( QLabel::NoFrame ); + TextLabelC2A1->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 ); + + TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" ); + TextLabelC2A2->setText( tr( "GEOM_VECTOR" ) ); + TextLabelC2A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A2->setFrameShape( QLabel::NoFrame ); + TextLabelC2A2->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 ); + + TextLabelC2A3 = new QLabel( GroupC2, "TextLabelC2A3" ); + TextLabelC2A3->setText( tr( "GEOM_ANGLE" ) ); + TextLabelC2A3->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A3->setFrameShape( QLabel::NoFrame ); + TextLabelC2A3->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A3, 2, 0 ); + + TextLabelC2A4 = new QLabel( GroupC2, "TextLabelC2A4" ); + TextLabelC2A4->setText( tr( "GEOM_NB_TIMES" ) ); + TextLabelC2A4->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A4->setFrameShape( QLabel::NoFrame ); + TextLabelC2A4->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A4, 3, 0 ); + + TextLabelC2A5 = new QLabel( GroupC2, "TextLabelC2A5" ); + TextLabelC2A5->setText( tr( "GEOM_STEP" ) ); + TextLabelC2A5->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A5->setFrameShape( QLabel::NoFrame ); + TextLabelC2A5->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A5, 5, 0 ); + + TextLabelC2A6 = new QLabel( GroupC2, "TextLabelC2A6" ); + TextLabelC2A6->setText( tr( "GEOM_NB_TIMES" ) ); + TextLabelC2A6->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A6->setFrameShape( QLabel::NoFrame ); + TextLabelC2A6->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A6, 6, 0 ); + + LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" ); + GroupC2Layout->addWidget( LineEditC2A1, 0, 2 ); + + LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" ); + GroupC2Layout->addWidget( LineEditC2A2, 1, 2 ); + + /* a TransformationGUI_SpinBox */ + SpinBox_C2A3 = new DlgRef_SpinBox( GroupC2, "GeomSpinBox_C2A3" ) ; + SpinBox_C2A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A3->sizePolicy().hasHeightForWidth() ) ); + GroupC2Layout->addWidget( SpinBox_C2A3, 2, 2 ); + /* a QSpinBox */ + SpinBox_C2A4 = new QSpinBox( GroupC2, "SpinBox_C2A4" ) ; + SpinBox_C2A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A4->sizePolicy().hasHeightForWidth() ) ); + GroupC2Layout->addWidget( SpinBox_C2A4, 3, 2 ); + + /* a TransformationGUI_SpinBox */ + SpinBox_C2A5 = new DlgRef_SpinBox( GroupC2, "GeomSpinBox_C2A5" ) ; + SpinBox_C2A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A5->sizePolicy().hasHeightForWidth() ) ); + GroupC2Layout->addWidget( SpinBox_C2A5, 5, 2 ); + /* a QSpinBox */ + SpinBox_C2A6 = new QSpinBox( GroupC2, "SpinBox_C2A6" ) ; + SpinBox_C2A6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A6->sizePolicy().hasHeightForWidth() ) ); + GroupC2Layout->addWidget( SpinBox_C2A6, 6, 2 ); + + CheckBoxReverse = new QCheckBox( GroupC2, "CheckBoxReverse" ); + CheckBoxReverse->setText( tr( "GEOM_REVERSE" ) ); + GroupC2Layout->addWidget( CheckBoxReverse, 4, 0 ); + + SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" ); + SelectButtonC2A1->setText( tr( "" ) ); + SelectButtonC2A1->setPixmap( image1 ); + SelectButtonC2A1->setToggleButton( FALSE ); + SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) ); + GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 ); + + SelectButtonC2A2 = new QPushButton( GroupC2, "SelectButtonC2A2" ); + SelectButtonC2A2->setText( tr( "" ) ); + SelectButtonC2A2->setPixmap( image1 ); + SelectButtonC2A2->setToggleButton( FALSE ); + SelectButtonC2A2->setMaximumSize( QSize( 28, 32767 ) ); + GroupC2Layout->addWidget( SelectButtonC2A2, 1, 1 ); + + TransformationGUI_MultiRotationDlgLayout->addWidget( GroupC2, 1, 0 ); + + /***************************************************************/ + myTransformationGUI = theTransformationGUI; + Init(Sel) ; /* Initialisations */ +} + +//================================================================================= +// function : ~TransformationGUI_MultiRotationDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +TransformationGUI_MultiRotationDlg::~TransformationGUI_MultiRotationDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::Init( SALOME_Selection* Sel ) +{ + + /* 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 geom spin boxes */ + SpinBox_C2A3->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* angle : constructor 2 */ + SpinBox_C2A3->SetValue( 45.0 ) ; + SpinBox_C2A5->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step : constructor 2 */ + SpinBox_C2A5->SetValue( 50.0 ) ; + + /* min, max, step for QT spin boxes */ + SpinBox_C1A3->setMinValue( 2 ); /* myNbTimes : constructor 1 */ + SpinBox_C1A3->setMaxValue( 10000 ); + SpinBox_C1A3->setWrapping( TRUE ); + SpinBox_C1A3->setValue(2) ; + + SpinBox_C2A4->setMinValue( 2 ); /* myNbTimes1 : constructor 2 */ + SpinBox_C2A4->setMaxValue( 10000 ); + SpinBox_C2A4->setWrapping( TRUE ); + SpinBox_C2A4->setValue(2) ; + + SpinBox_C2A6->setMinValue( 2 ); /* myNbTimes2 : constructor 2 */ + SpinBox_C2A6->setMaxValue( 10000 ); + SpinBox_C2A6->setWrapping( TRUE ); + SpinBox_C2A6->setValue(2) ; + + myAng = 45.0 ; + myStep = 50.0 ; + myNbTimes1 = 2; + myNbTimes2 = 2; + + GroupC1->show(); + GroupC2->hide() ; + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + + myOkBase = myOkDir = 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 ); + + /* 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( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC2A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC2A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + + /* TransformationGUI_SpinBox */ + connect( SpinBox_C2A3, SIGNAL ( valueChanged( double) ), this, SLOT( valueChangedInSpinBox( double) ) ) ; + connect( SpinBox_C2A5, SIGNAL ( valueChanged( double) ), this, SLOT( valueChangedInSpinBox( double) ) ) ; + + /* QSpinBox */ + connect( SpinBox_C1A3, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ; /* Not const ! */ + connect( SpinBox_C2A4, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ; + connect( SpinBox_C2A6, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ; + + 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 ; +} + +//================================================================================= +// function : ReverseAngle() +// purpose : 'state' not used here +//================================================================================= +void TransformationGUI_MultiRotationDlg::ReverseAngle(int state) +{ + myAng = -myAng ; + SpinBox_C2A3->SetValue( myAng ) ; + if( myOkBase && myOkDir ) { + MakeMultiRotationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void TransformationGUI_MultiRotationDlg::ConstructorsClicked(int constructorId) +{ + myEditCurrentArgument->setText(tr("")) ; + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + myAng = 45.0 ; + myStep = 50.0 ; + myNbTimes1 = 2; + myNbTimes2 = 2; + + myOkBase = myOkDir = false ; + myConstructorId = constructorId ; + + switch (constructorId) + { + case 0: /* Rotate simple */ + { + GroupC1->show(); + GroupC2->hide() ; + myEditCurrentArgument = LineEditC1A1 ; + SpinBox_C1A3->setValue( 2 ) ; + LineEditC1A1->setText(tr("")) ; + LineEditC1A2->setText(tr("")) ; + break; + } + + case 1: /* Rotate double */ + { + GroupC1->hide(); + GroupC2->show() ; + myEditCurrentArgument = LineEditC2A1 ; + SpinBox_C2A3->SetValue( 45.0 ) ; + SpinBox_C2A4->setValue( 2 ) ; + SpinBox_C2A5->SetValue( 50.0 ) ; + SpinBox_C2A6->setValue( 2 ) ; + LineEditC2A1->setText(tr("")) ; + LineEditC2A2->setText(tr("")) ; + break ; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::ClickOnApply() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + switch(myConstructorId) + { + case 0 : + { + if(myOkBase && myOkDir) { + myTransformationGUI->MakeMultiRotation1DAndDisplay( myGeomShape, myDir, myLoc, myNbTimes1 ) ; + } + break ; + } + case 1 : + { + if(myOkBase && myOkDir) { + myTransformationGUI->MakeMultiRotation2DAndDisplay( myGeomShape, myDir, myLoc, myAng, myNbTimes1, myStep, myNbTimes2 ) ; + } + break ; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::ClickOnCancel() +{ + mySelection->ClearFilters() ; + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender() ; + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + else if ( send == LineEditC1A2 ) + myEditCurrentArgument = LineEditC1A2 ; + else if ( send == LineEditC2A1 ) + myEditCurrentArgument = LineEditC2A1; + else if ( send == LineEditC2A2 ) + myEditCurrentArgument = LineEditC2A2 ; + 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 ; +} + + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + /* Name of future selection */ + QString aString = ""; + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + + TopoDS_Shape S; + Standard_Boolean testResult ; + + switch (myConstructorId) + { + case 0 : + { + if ( nbSel != 1 ) { + if ( myEditCurrentArgument == LineEditC1A1 ) { + myEditCurrentArgument->setText("") ; + myOkBase = false ; + } + else if ( myEditCurrentArgument == LineEditC1A2 ) { + myEditCurrentArgument->setText("") ; + myOkDir = false ; + } + return ; + } + + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if ( myEditCurrentArgument == LineEditC1A1 ) { + myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; + if( !testResult ) + return ; + myEditCurrentArgument->setText(aString) ; + myBase = S ; + myOkBase = true ; + } + else if ( myEditCurrentArgument == LineEditC1A2 ) { + BRepAdaptor_Curve curv(TopoDS::Edge(S)); + myDir = curv.Line().Direction(); + myLoc = curv.Line().Location(); + myEditCurrentArgument->setText(aString) ; + myOkDir = true ; + } + + if (myOkBase && myOkDir ) { + MakeMultiRotationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + break; + } + case 1 : + { + if ( nbSel != 1 ) { + if ( myEditCurrentArgument == LineEditC2A1 ) { + myEditCurrentArgument->setText("") ; + myOkBase = false ; + } + else if ( myEditCurrentArgument == LineEditC2A2 ) { + myEditCurrentArgument->setText("") ; + myOkDir = false ; + } + return ; + } + + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if ( myEditCurrentArgument == LineEditC2A1 ) { + myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; + if( !testResult ) + return ; + myEditCurrentArgument->setText(aString) ; + myBase = S ; + myOkBase = true ; + } + else if ( myEditCurrentArgument == LineEditC2A2 ) { + BRepAdaptor_Curve curv(TopoDS::Edge(S)); + myDir = curv.Line().Direction(); + myLoc = curv.Line().Location(); + myEditCurrentArgument->setText(aString) ; + myOkDir = true ; + } + + if ( myOkBase && myOkDir ) { + MakeMultiRotationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + break; + } + } + + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0 : + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + mySelection->ClearFilters() ; + } + else if(send == SelectButtonC1A2) { + LineEditC1A2->setFocus() ; + myEditCurrentArgument = LineEditC1A2; + mySelection->AddFilter(myEdgeFilter) ; + } + SelectionIntoArgument() ; + break; + } + case 1 : + { + if(send == SelectButtonC2A1) { + LineEditC2A1->setFocus() ; + myEditCurrentArgument = LineEditC2A1; + mySelection->ClearFilters() ; + } + else if(send == SelectButtonC2A2) { + LineEditC2A2->setFocus() ; + myEditCurrentArgument = LineEditC2A2; + mySelection->AddFilter(myEdgeFilter) ; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : ValueChangedInt() +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::ValueChangedInt( int newIntValue ) +{ + QSpinBox* send = (QSpinBox*)sender(); + + if( send == SpinBox_C1A3 ) { + myNbTimes1 = newIntValue ; + } + else if(send == SpinBox_C2A4 ) { + myNbTimes1 = newIntValue ; + } + else if(send == SpinBox_C2A6 ) { + myNbTimes2 = newIntValue ; + } + + switch (myConstructorId) + { + case 0 : + { + if (myOkBase && myOkDir ) { + MakeMultiRotationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + break; + } + case 1 : + { + if (myOkBase && myOkDir ) { + MakeMultiRotationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + break; + } + } + return ; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : (specifig for TransformationGUI_SpinBox) +//================================================================================= +void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox( double newValue ) +{ + DlgRef_SpinBox* send = (DlgRef_SpinBox*)sender(); + + if( send == SpinBox_C2A3 ) { + myAng = newValue ; + } + else if( send == SpinBox_C2A5 ) { + myStep = newValue ; + } + + switch (myConstructorId) + { + case 0 : + { + if (myOkBase && myOkDir ) { + MakeMultiRotationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + break; + } + case 1 : + { + if (myOkBase && myOkDir ) { + MakeMultiRotationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + break; + } + } + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupC2->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->EraseSimulationShape() ; + mySelection->ClearFilters() ; + myGeomGUI->ResetState() ; + myGeomGUI->SetActiveDialogBox(0) ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupC2->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + if( !mySimulationTopoDs.IsNull() ) + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + return ; +} + + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; /* same than click on cancel button */ + return ; +} + + +//================================================================================= +// function : MakeMultiRotationSimulationAndDisplay() +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::MakeMultiRotationSimulationAndDisplay() +{ + myGeomGUI->EraseSimulationShape() ; + gp_Trsf theTransformation ; + gp_Trsf theTransformation1 ; + gp_Trsf theTransformation2 ; + mySimulationTopoDs.Nullify() ; + + int i ; + int j ; + Standard_Real DX ; + Standard_Real DY ; + Standard_Real DZ ; + GProp_GProps System ; + gp_Pnt myPoint ; + TopoDS_Compound compound; + BRep_Builder B; + + B.MakeCompound( compound ); + + if ( myBase.ShapeType() == TopAbs_VERTEX) { + myGeomGUI->VertexToPoint( myBase, myPoint ); + } + else if ( myBase.ShapeType() == TopAbs_EDGE || myBase.ShapeType() == TopAbs_WIRE ) { + BRepGProp::LinearProperties(myBase, System); + myPoint = System.CentreOfMass() ; + } + else if ( myBase.ShapeType() == TopAbs_FACE || myBase.ShapeType() == TopAbs_SHELL ) { + BRepGProp::SurfaceProperties(myBase, System); + myPoint = System.CentreOfMass() ; + } + else { + BRepGProp::VolumeProperties(myBase, System); + myPoint = System.CentreOfMass() ; + } + + TopoDS_Shape S = BRepBuilderAPI_MakeVertex(myPoint).Shape(); + + try { + switch (myConstructorId) + { + case 0 : + { + gp_Ax1 AX1( myLoc, myDir ) ; + Standard_Real angle = 360/myNbTimes1; + for ( i = 0; i < myNbTimes1; i++ ) { + theTransformation.SetRotation(AX1, i*angle*PI180) ; + BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False) ; + B.Add( compound, myBRepTransformation.Shape() ); + } + mySimulationTopoDs = compound; + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + break; + } + case 1 : + { + gp_Ax1 AX2( myLoc, myDir ) ; + Handle(Geom_Line) Line = new Geom_Line(AX2); + gp_Pnt P2 = GeomAPI_ProjectPointOnCurve( myPoint, Line ) ; + if ( myPoint.IsEqual(P2, Precision::Confusion() ) ) + return; + gp_Vec Vec(P2, myPoint) ; + Vec.Normalize(); + + for ( i = 0; i < myNbTimes2; i++ ) { + for ( j = 0; j < myNbTimes1; j++ ) { + DX = i * myStep * Vec.X() ; + DY = i * myStep * Vec.Y() ; + DZ = i * myStep * Vec.Z() ; + myVec.SetCoord( DX, DY, DZ ) ; + + theTransformation1.SetTranslation(myVec) ; + theTransformation2.SetRotation(AX2, j*myAng*PI180) ; + BRepBuilderAPI_Transform myBRepTransformation1(S, theTransformation1, Standard_False) ; + BRepBuilderAPI_Transform myBRepTransformation2(myBRepTransformation1.Shape(), theTransformation2, Standard_False) ; + B.Add( compound, myBRepTransformation2.Shape() ); + } + } + mySimulationTopoDs = compound ; + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + break; + } + } + } + catch(Standard_Failure) { + MESSAGE( "Exception catched in MakeMultitranslationSimulationAndDisplay" ) ; + return ; + } + return ; +} diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h new file mode 100644 index 000000000..870e6f162 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h @@ -0,0 +1,159 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI_MultiRotationDlg.h +// Author : Damien COQUERET +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_MULTIROTATION_H +#define DIALOGBOX_MULTIROTATION_H + +#include "TransformationGUI.h" + +#include "GEOM_EdgeFilter.hxx" +#include "DlgRef_SpinBox.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 QSpinBox; +class QRadioButton; + +//================================================================================= +// class : TransformationGUI_MultiRotationDlg +// purpose : +//================================================================================= +class TransformationGUI_MultiRotationDlg : public QDialog +{ + Q_OBJECT + +public: + TransformationGUI_MultiRotationDlg( QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~TransformationGUI_MultiRotationDlg(); + +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 */ + + gp_Vec myVec ; + int myNbTimes1 ; + int myNbTimes2 ; + Standard_Real myAng ; + Standard_Real myStep ; + gp_Dir myDir ; + gp_Pnt myLoc ; + + bool myOkBase ; + bool myOkDir ; + bool myOkAng ; + + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + int myConstructorId ; /* Current constructor id = radio button id */ + Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ + + void closeEvent( QCloseEvent* e ) ; + void enterEvent( QEvent* e); + void Init( SALOME_Selection* Sel ) ; + void MakeMultiRotationSimulationAndDisplay() ; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QRadioButton* Constructor2; + + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + + QGroupBox* GroupC1; + QPushButton* SelectButtonC1A1; + QPushButton* SelectButtonC1A2; + QLabel* TextLabelC1A1; + QLabel* TextLabelC1A2; + QLabel* TextLabelC1A3; + QLineEdit* LineEditC1A1; + QLineEdit* LineEditC1A2; + QSpinBox* SpinBox_C1A3; /* int : Nb times */ + + QGroupBox* GroupC2; + QPushButton* SelectButtonC2A1; + QPushButton* SelectButtonC2A2; + QLabel* TextLabelC2A1; + QLabel* TextLabelC2A2; + QLabel* TextLabelC2A3; + QLabel* TextLabelC2A4; + QLabel* TextLabelC2A5; + QLabel* TextLabelC2A6; + + QLineEdit* LineEditC2A1; + QLineEdit* LineEditC2A2; + DlgRef_SpinBox* SpinBox_C2A3 ; /* double : angle */ + QSpinBox* SpinBox_C2A4; /* int : Nb times 1 */ + DlgRef_SpinBox* SpinBox_C2A5 ; /* double : step value */ + QSpinBox* SpinBox_C2A6; /* int : Nb times 2 */ + + QCheckBox* CheckBoxReverse; + +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) ; + void ValueChangedInSpinBox( double newValue ) ; /* for TransformationGUI_SpinBox */ + void ValueChangedInt( int newIntValue ) ; /* for QT spin box ! not const ! */ + +protected: + QGridLayout* TransformationGUI_MultiRotationDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; + QGridLayout* GroupC2Layout; +}; + +#endif // DIALOGBOX_MULTIROTATION_H diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx new file mode 100644 index 000000000..3c0db4b38 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx @@ -0,0 +1,1060 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI_MultiTranslationDlg.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header$ + +using namespace std; +#include "TransformationGUI_MultiTranslationDlg.h" + +#include "QAD_Config.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : TransformationGUI_MultiTranslationDlg() +// purpose : Constructs a TransformationGUI_MultiTranslationDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg( 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 ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_MULTITRANSLATION_SIMPLE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_MULTITRANSLATION_DOUBLE"))); + + if ( !name ) + setName( "TransformationGUI_MultiTranlationDlg" ); + resize( 303, 251 ); + setCaption( tr( "GEOM_MULTITRANSLATION_TITLE" ) ); + setSizeGripEnabled( TRUE ); + TransformationGUI_MultiTranslationDlgLayout = new QGridLayout( this ); + TransformationGUI_MultiTranslationDlgLayout->setSpacing( 6 ); + TransformationGUI_MultiTranslationDlgLayout->setMargin( 11 ); + + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "GEOM_MULTITRANSLATION" ) ); + 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 ); + Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" ); + Constructor2->setText( tr( "" ) ); + Constructor2->setPixmap( image2 ); + Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) ); + Constructor2->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor2, 0, 2 ); + QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_2, 0, 3 ); + QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_3, 0, 1 ); + + TransformationGUI_MultiTranslationDlgLayout->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_MultiTranslationDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "GEOM_MULTITRANSLATION_SIMPLE" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + 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_MAIN_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_VECTOR_U" ) ); + TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A2->setFrameShape( QLabel::NoFrame ); + TextLabelC1A2->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); + + TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" ); + TextLabelC1A3->setText( tr( "GEOM_STEP_U" ) ); + TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A3->setFrameShape( QLabel::NoFrame ); + TextLabelC1A3->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 ); + + TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" ); + TextLabelC1A4->setText( tr( "GEOM_NB_TIMES_U" ) ); + TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A4->setFrameShape( QLabel::NoFrame ); + TextLabelC1A4->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 ); + + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); + GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); + + /* a TransformationGUI_SpinBox */ + SpinBox_C1A3 = new DlgRef_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ; + SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) ); + GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 ); + /* a QSpinBox */ + SpinBox_C1A4 = new QSpinBox( GroupC1, "SpinBox_C1A4" ) ; + SpinBox_C1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A4->sizePolicy().hasHeightForWidth() ) ); + GroupC1Layout->addWidget( SpinBox_C1A4, 3, 2 ); + + CheckBoxReverse0 = new QCheckBox( GroupC1, "CheckBoxReverse0" ); + CheckBoxReverse0->setText( tr( "GEOM_REVERSE_U" ) ); + GroupC1Layout->addWidget( CheckBoxReverse0, 5, 0 ); + + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + + SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); + SelectButtonC1A2->setText( tr( "" ) ); + SelectButtonC1A2->setPixmap( image1 ); + SelectButtonC1A2->setToggleButton( FALSE ); + SelectButtonC1A2->setMaximumSize( QSize( 28, 32767 ) ); + GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); + + TransformationGUI_MultiTranslationDlgLayout->addWidget( GroupC1, 1, 0 ); + + /***************************************************************/ + + GroupC2 = new QGroupBox( this, "GroupC2" ); + GroupC2->setTitle( tr( "GEOM_MULTITRANSLATION_DOUBLE" ) ); + GroupC2->setMinimumSize( QSize( 0, 0 ) ); + GroupC2->setFrameShape( QGroupBox::Box ); + GroupC2->setFrameShadow( QGroupBox::Sunken ); + GroupC2->setColumnLayout(0, Qt::Vertical ); + GroupC2->layout()->setSpacing( 0 ); + GroupC2->layout()->setMargin( 0 ); + GroupC2Layout = new QGridLayout( GroupC2->layout() ); + GroupC2Layout->setAlignment( Qt::AlignTop ); + GroupC2Layout->setSpacing( 6 ); + GroupC2Layout->setMargin( 11 ); + + TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" ); + TextLabelC2A1->setText( tr( "GEOM_MAIN_OBJECT" ) ); + TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A1->setFrameShape( QLabel::NoFrame ); + TextLabelC2A1->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 ); + + TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" ); + TextLabelC2A2->setText( tr( "GEOM_VECTOR_U" ) ); + TextLabelC2A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A2->setFrameShape( QLabel::NoFrame ); + TextLabelC2A2->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 ); + + TextLabelC2A3 = new QLabel( GroupC2, "TextLabelC2A3" ); + TextLabelC2A3->setText( tr( "GEOM_VECTOR_V" ) ); + TextLabelC2A3->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A3->setFrameShape( QLabel::NoFrame ); + TextLabelC2A3->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A3, 2, 0 ); + + TextLabelC2A4 = new QLabel( GroupC2, "TextLabelC2A4" ); + TextLabelC2A4->setText( tr( "GEOM_STEP_U" ) ); + TextLabelC2A4->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A4->setFrameShape( QLabel::NoFrame ); + TextLabelC2A4->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A4, 3, 0 ); + + TextLabelC2A5 = new QLabel( GroupC2, "TextLabelC2A5" ); + TextLabelC2A5->setText( tr( "GEOM_NB_TIMES_U" ) ); + TextLabelC2A5->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A5->setFrameShape( QLabel::NoFrame ); + TextLabelC2A5->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A5, 4, 0 ); + + TextLabelC2A6 = new QLabel( GroupC2, "TextLabelC2A6" ); + TextLabelC2A6->setText( tr( "GEOM_STEP_V" ) ); + TextLabelC2A6->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A6->setFrameShape( QLabel::NoFrame ); + TextLabelC2A6->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A6, 6, 0 ); + + TextLabelC2A7 = new QLabel( GroupC2, "TextLabelC2A7" ); + TextLabelC2A7->setText( tr( "GEOM_NB_TIMES_V" ) ); + TextLabelC2A7->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC2A7->setFrameShape( QLabel::NoFrame ); + TextLabelC2A7->setFrameShadow( QLabel::Plain ); + GroupC2Layout->addWidget( TextLabelC2A7, 7, 0 ); + + LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" ); + GroupC2Layout->addWidget( LineEditC2A1, 0, 2 ); + + LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" ); + GroupC2Layout->addWidget( LineEditC2A2, 1, 2 ); + + LineEditC2A3 = new QLineEdit( GroupC2, "LineEditC2A3" ); + GroupC2Layout->addWidget( LineEditC2A3, 2, 2 ); + + /* a TransformationGUI_SpinBox */ + SpinBox_C2A4 = new DlgRef_SpinBox( GroupC2, "GeomSpinBox_C2A4" ) ; + SpinBox_C2A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A4->sizePolicy().hasHeightForWidth() ) ); + GroupC2Layout->addWidget( SpinBox_C2A4, 3, 2 ); + /* a QSpinBox */ + SpinBox_C2A5 = new QSpinBox( GroupC2, "SpinBox_C2A5" ) ; + SpinBox_C2A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A5->sizePolicy().hasHeightForWidth() ) ); + GroupC2Layout->addWidget( SpinBox_C2A5, 4, 2 ); + + /* a TransformationGUI_SpinBox */ + SpinBox_C2A6 = new DlgRef_SpinBox( GroupC2, "GeomSpinBox_C2A6" ) ; + SpinBox_C2A6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A6->sizePolicy().hasHeightForWidth() ) ); + GroupC2Layout->addWidget( SpinBox_C2A6, 6, 2 ); + /* a QSpinBox */ + SpinBox_C2A7 = new QSpinBox( GroupC2, "SpinBox_C2A7" ) ; + SpinBox_C2A7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A7->sizePolicy().hasHeightForWidth() ) ); + GroupC2Layout->addWidget( SpinBox_C2A7, 7, 2 ); + + + CheckBoxReverse1 = new QCheckBox( GroupC2, "CheckBoxReverse1" ); + CheckBoxReverse1->setText( tr( "GEOM_REVERSE_U" ) ); + GroupC2Layout->addWidget( CheckBoxReverse1, 5, 0 ); + + CheckBoxReverse2 = new QCheckBox( GroupC2, "CheckBoxReverse2" ); + CheckBoxReverse2->setText( tr( "GEOM_REVERSE_V" ) ); + GroupC2Layout->addWidget( CheckBoxReverse2, 8, 0 ); + + SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" ); + SelectButtonC2A1->setText( tr( "" ) ); + SelectButtonC2A1->setPixmap( image1 ); + SelectButtonC2A1->setToggleButton( FALSE ); + SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) ); + GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 ); + + SelectButtonC2A2 = new QPushButton( GroupC2, "SelectButtonC2A2" ); + SelectButtonC2A2->setText( tr( "" ) ); + SelectButtonC2A2->setPixmap( image1 ); + SelectButtonC2A2->setToggleButton( FALSE ); + SelectButtonC2A2->setMaximumSize( QSize( 28, 32767 ) ); + GroupC2Layout->addWidget( SelectButtonC2A2, 1, 1 ); + + SelectButtonC2A3 = new QPushButton( GroupC2, "SelectButtonC2A3" ); + SelectButtonC2A3->setText( tr( "" ) ); + SelectButtonC2A3->setPixmap( image1 ); + SelectButtonC2A3->setToggleButton( FALSE ); + SelectButtonC2A3->setMaximumSize( QSize( 28, 32767 ) ); + GroupC2Layout->addWidget( SelectButtonC2A3, 2, 1 ); + + TransformationGUI_MultiTranslationDlgLayout->addWidget( GroupC2, 1, 0 ); + + /***************************************************************/ + + myTransformationGUI = theTransformationGUI; + Init(Sel) ; /* Initialisations */ +} + +//================================================================================= +// function : ~TransformationGUI_MultiTranslationDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +TransformationGUI_MultiTranslationDlg::~TransformationGUI_MultiTranslationDlg() +{ + // no need to delete child widgets, Qt does it all for us + this->destroy(TRUE, TRUE) ; +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void TransformationGUI_MultiTranslationDlg::Init( SALOME_Selection* Sel ) +{ + + /* 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 geom spin boxes */ + SpinBox_C1A3->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step U : constructor 1 */ + SpinBox_C1A3->SetValue( 50 ) ; + SpinBox_C2A4->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step U : constructor 2 */ + SpinBox_C2A4->SetValue( 50 ) ; + SpinBox_C2A6->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step V : constructor 2 */ + SpinBox_C2A6->SetValue( 50 ) ; + + /* min, max, step for QT spin boxes */ + SpinBox_C1A4->setMinValue( 1 ); /* myNbTimes1 : constructor 1 */ + SpinBox_C1A4->setMaxValue( 10000 ); + SpinBox_C1A4->setWrapping( TRUE ); + SpinBox_C1A4->setValue(2) ; + + SpinBox_C2A5->setMinValue( 1 ); /* myNbTimes1 : constructor 2 */ + SpinBox_C2A5->setMaxValue( 10000 ); + SpinBox_C2A5->setWrapping( TRUE ); + SpinBox_C2A5->setValue(2) ; + + SpinBox_C2A7->setMinValue( 1 ); /* myNbTimes2 : constructor 2 */ + SpinBox_C2A7->setMaxValue( 10000 ); + SpinBox_C2A7->setWrapping( TRUE ); + SpinBox_C2A7->setValue(2) ; + + myStep1 = 50.0 ; + myStep2 = 50.0 ; + myNbTimes1 = 2 ; + myNbTimes2 = 2 ; + + GroupC1->show(); + GroupC2->hide() ; + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myGeomGUI = GEOMBase_Context::GetGeomGUI() ; + + myOkBase = myOkDir1 = myOkDir2 = 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 ); + + /* 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( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC2A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC2A3, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + /* TransformationGUI_SpinBox */ + connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_C2A4, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_C2A6, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + + connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC2A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + connect( LineEditC2A3, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; + + /* QSpinBox */ + connect( SpinBox_C1A4, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ; /* Not const ! */ + connect( SpinBox_C2A5, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ; + connect( SpinBox_C2A7, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ; + + connect( CheckBoxReverse0, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle1(int) ) ) ; + connect( CheckBoxReverse1, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle1(int) ) ) ; + connect( CheckBoxReverse2, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle2(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 ; +} + +//================================================================================= +// function : ReverseAngle1() +// purpose : 'state' not used here +//================================================================================= +void TransformationGUI_MultiTranslationDlg::ReverseAngle1(int state) +{ + myStep1 = -myStep1 ; + SpinBox_C1A3->SetValue( myStep1 ) ; + SpinBox_C2A4->SetValue( myStep1 ) ; + if( myOkBase && myOkDir1 ) { + MakeMultiTranslationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + return ; +} + + +//================================================================================= +// function : ReverseAngle2() +// purpose : 'state' not used here +//================================================================================= +void TransformationGUI_MultiTranslationDlg::ReverseAngle2(int state) +{ + myStep2 = -myStep2 ; + SpinBox_C2A6->SetValue( myStep2 ) ; + if( myOkBase && myOkDir1 && myOkDir2 ) { + MakeMultiTranslationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void TransformationGUI_MultiTranslationDlg::ConstructorsClicked(int constructorId) +{ + myEditCurrentArgument->setText(tr("")) ; + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + myStep1 = 50.0 ; + myStep2 = 50.0 ; + myNbTimes1 = 2; + myNbTimes2 = 2; + + myOkBase = myOkDir1 = myOkDir2 = false ; + myConstructorId = constructorId ; + + switch (constructorId) + { + case 0: /* Translate simple */ + { + GroupC1->show(); + GroupC2->hide() ; + myEditCurrentArgument = LineEditC1A1 ; + SpinBox_C1A3->SetValue(50) ; + SpinBox_C1A4->setValue(2) ; + LineEditC1A1->setText(tr("")) ; + LineEditC1A2->setText(tr("")) ; + break; + } + + case 1: /* Translate double */ + { + GroupC1->hide(); + GroupC2->show() ; + myEditCurrentArgument = LineEditC2A1 ; + SpinBox_C2A4->SetValue(50) ; + SpinBox_C2A5->setValue(2) ; + SpinBox_C2A6->SetValue(50) ; + SpinBox_C2A7->setValue(2) ; + LineEditC2A1->setText(tr("")) ; + LineEditC2A2->setText(tr("")) ; + LineEditC2A3->setText(tr("")) ; + break ; + } + + } + + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void TransformationGUI_MultiTranslationDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void TransformationGUI_MultiTranslationDlg::ClickOnApply() +{ + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + myGeomGUI->GetDesktop()->putInfo( tr("") ) ; + switch(myConstructorId) + { + case 0 : + { + if(myOkBase && myOkDir1 ) { + myTransformationGUI->MakeMultiTranslation1DAndDisplay( myGeomShape, myDir1, myStep1, myNbTimes1 ) ; + } + break ; + } + case 1 : + { + if(myOkBase && myOkDir1 && myOkDir2 ) { + myTransformationGUI->MakeMultiTranslation2DAndDisplay( myGeomShape, myDir1, myStep1, myNbTimes1, myDir2, myStep2, myNbTimes2 ) ; + } + break ; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void TransformationGUI_MultiTranslationDlg::ClickOnCancel() +{ + mySelection->ClearFilters() ; + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void TransformationGUI_MultiTranslationDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender() ; + if( send == LineEditC1A1 ) + myEditCurrentArgument = LineEditC1A1 ; + else if ( send == LineEditC1A2 ) + myEditCurrentArgument = LineEditC1A2 ; + else if ( send == LineEditC2A1 ) + myEditCurrentArgument = LineEditC2A1; + else if ( send == LineEditC2A2 ) + myEditCurrentArgument = LineEditC2A2 ; + else if ( send == LineEditC2A3 ) + myEditCurrentArgument = LineEditC2A3 ; + 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 ; +} + + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + /* Future name of selection */ + QString aString = ""; + int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + + TopoDS_Shape S; + Standard_Boolean testResult ; + + switch (myConstructorId) + { + case 0 : + { + if ( nbSel != 1 ) { + if ( myEditCurrentArgument == LineEditC1A1 ) { + myEditCurrentArgument->setText("") ; + myOkBase = false ; + } + else if ( myEditCurrentArgument == LineEditC1A2 ) { + myEditCurrentArgument->setText("") ; + myOkDir1 = false ; + } + return ; + } + + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if ( myEditCurrentArgument == LineEditC1A1 ) { + myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; + if( !testResult ) + return ; + myEditCurrentArgument->setText(aString) ; + myBase = S ; + myOkBase = true ; + } + else if ( myEditCurrentArgument == LineEditC1A2 ) { + BRepAdaptor_Curve curv(TopoDS::Edge(S)); + myDir1 = curv.Line().Direction(); + myEditCurrentArgument->setText(aString) ; + myOkDir1 = true ; + } + + if (myOkBase && myOkDir1 ) { + MakeMultiTranslationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + break; + } + case 1 : + { + if ( nbSel != 1 ) { + if ( myEditCurrentArgument == LineEditC2A1 ) { + myEditCurrentArgument->setText("") ; + myOkBase = false ; + } + else if ( myEditCurrentArgument == LineEditC2A2 ) { + myEditCurrentArgument->setText("") ; + myOkDir1 = false ; + } + else if ( myEditCurrentArgument == LineEditC2A3 ) { + myEditCurrentArgument->setText("") ; + myOkDir2 = false ; + } + return ; + } + + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) + return ; + + if ( myEditCurrentArgument == LineEditC2A1 ) { + myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ; + if( !testResult ) + return ; + myEditCurrentArgument->setText(aString) ; + myBase = S ; + myOkBase = true ; + } + else if ( myEditCurrentArgument == LineEditC2A2 ) { + BRepAdaptor_Curve curv(TopoDS::Edge(S)); + myDir1 = curv.Line().Direction(); + myEditCurrentArgument->setText(aString) ; + myOkDir1 = true ; + } + else if ( myEditCurrentArgument == LineEditC2A3 ) { + BRepAdaptor_Curve curv(TopoDS::Edge(S)); + myDir2 = curv.Line().Direction(); + myEditCurrentArgument->setText(aString) ; + myOkDir2 = true ; + } + + if (myOkBase && myOkDir1 && myOkDir2 ) { + MakeMultiTranslationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + break; + } + } + + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0 : + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + mySelection->ClearFilters() ; + } + else if(send == SelectButtonC1A2) { + LineEditC1A2->setFocus() ; + myEditCurrentArgument = LineEditC1A2; + mySelection->AddFilter(myEdgeFilter) ; + } + SelectionIntoArgument() ; + break; + } + case 1 : + { + if(send == SelectButtonC2A1) { + LineEditC2A1->setFocus() ; + myEditCurrentArgument = LineEditC2A1; + mySelection->ClearFilters() ; + } + else if(send == SelectButtonC2A2) { + LineEditC2A2->setFocus() ; + myEditCurrentArgument = LineEditC2A2; + mySelection->AddFilter(myEdgeFilter) ; + } + else if(send == SelectButtonC2A3) { + LineEditC2A3->setFocus() ; + myEditCurrentArgument = LineEditC2A3; + mySelection->AddFilter(myEdgeFilter) ; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + +//================================================================================= +// function : ValueChangedInt() +// purpose : (General QT SpinBox) +//================================================================================= +void TransformationGUI_MultiTranslationDlg::ValueChangedInt( int newIntValue ) +{ + QSpinBox* send = (QSpinBox*)sender(); + + /* First constructor */ + if( send == SpinBox_C1A4 ) { + myNbTimes1 = newIntValue ; + } + /* Second constructor */ + else if( send == SpinBox_C2A5 ) { + myNbTimes1 = newIntValue ; + } + else if( send == SpinBox_C2A7 ) { + myNbTimes2 = newIntValue ; + } + + switch (myConstructorId) + { + case 0 : + { + if (myOkBase && myOkDir1 ) { + MakeMultiTranslationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + break; + } + case 1 : + { + if (myOkBase && myOkDir1 && myOkDir2 ) { + MakeMultiTranslationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + break; + } + } + return ; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : (specifig for TransformationGUI_SpinBox) +//================================================================================= +void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox( double newValue ) +{ + DlgRef_SpinBox* send = (DlgRef_SpinBox*)sender(); + + /* First constructor */ + if( send == SpinBox_C1A3 ) { + myStep1 = newValue ; + } + /* Second constructor */ + else if( send == SpinBox_C2A4 ) { + myStep1 = newValue ; + } + else if( send == SpinBox_C2A6 ) { + myStep2 = newValue ; + } + + switch (myConstructorId) + { + case 0 : + { + if (myOkBase && myOkDir1 ) { + MakeMultiTranslationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + break; + } + case 1 : + { + if (myOkBase && myOkDir1 && myOkDir2 ) { + MakeMultiTranslationSimulationAndDisplay() ; + } + else { + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + } + break; + } + } + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void TransformationGUI_MultiTranslationDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupC2->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->EraseSimulationShape() ; + mySelection->ClearFilters() ; + myGeomGUI->ResetState() ; + myGeomGUI->SetActiveDialogBox(0) ; + GEOMBase_Display* myDisplayGUI = new GEOMBase_Display(); + myDisplayGUI->OnDisplayAll(true) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void TransformationGUI_MultiTranslationDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + myGeomGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupC2->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; + if( !mySimulationTopoDs.IsNull() ) + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + return ; +} + + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void TransformationGUI_MultiTranslationDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void TransformationGUI_MultiTranslationDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; /* same than click on cancel button */ + return ; +} + + +//================================================================================= +// function : MakeMultiTranslationSimulationAndDisplay() +// purpose : +//================================================================================= +void TransformationGUI_MultiTranslationDlg::MakeMultiTranslationSimulationAndDisplay() +{ + myGeomGUI->EraseSimulationShape() ; + gp_Trsf theTransformation ; + mySimulationTopoDs.Nullify() ; + + int i ; + int j ; + Standard_Real DX ; + Standard_Real DY ; + Standard_Real DZ ; + GProp_GProps System ; + gp_Pnt myPoint ; + TopoDS_Compound compound; + BRep_Builder B; + + B.MakeCompound( compound ); + TopoDS_Shape S ; + + try { + + BRepGProp::LinearProperties(myBase, System); + myPoint = System.CentreOfMass() ; + S = BRepBuilderAPI_MakeVertex(myPoint).Shape(); + + switch (myConstructorId) + { + case 0 : + { + gp_Vec Vec(myDir1) ; + Vec.Normalize(); + + for ( i = 0; i < myNbTimes1; i++ ) { + DX = i * myStep1 * Vec.X() ; + DY = i * myStep1 * Vec.Y() ; + DZ = i * myStep1 * Vec.Z() ; + myVec.SetCoord( DX, DY, DZ ) ; + + theTransformation.SetTranslation(myVec) ; + BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False) ; + B.Add( compound, myBRepTransformation.Shape() ); + } + mySimulationTopoDs = compound; + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + break; + } + case 1 : + { + gp_Vec Vec1(myDir1) ; + Vec1.Normalize(); + gp_Vec Vec2(myDir2) ; + Vec2.Normalize(); + + for ( i = 0; i < myNbTimes1; i++ ) { + for ( j = 0; j < myNbTimes2; j++ ) { + DX = i * myStep1 * Vec1.X() + j * myStep2 * Vec2.X() ; + DY = i * myStep1 * Vec1.Y() + j * myStep2 * Vec2.Y() ; + DZ = i * myStep1 * Vec1.Z() + j * myStep2 * Vec2.Z() ; + myVec.SetCoord( DX, DY, DZ ) ; + + theTransformation.SetTranslation(myVec) ; + BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False) ; + B.Add( compound, myBRepTransformation.Shape() ); + } + } + mySimulationTopoDs = compound ; + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + break; + } + } + } + catch(Standard_Failure) { + MESSAGE( "Exception catched in MakeMultitranslationSimulationAndDisplay" ) ; + return ; + } + return ; +} diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h new file mode 100644 index 000000000..293247612 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h @@ -0,0 +1,168 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI_MultiTranslationDlg.h +// Author : Damien COQUERET +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_MULTITRANSLATION_H +#define DIALOGBOX_MULTITRANSLATION_H + +#include "TransformationGUI.h" + +#include "GEOM_EdgeFilter.hxx" +#include "DlgRef_SpinBox.h" + +#include +#include + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QCheckBox; +class QGroupBox; +class QLabel; +class QSpinBox; +class QLineEdit; +class QPushButton; +class QSpinBox; +class QRadioButton; + +//================================================================================= +// class : TransformationGUI_MultiTranslationDlg +// purpose : +//================================================================================= +class TransformationGUI_MultiTranslationDlg : public QDialog +{ + Q_OBJECT + +public: + TransformationGUI_MultiTranslationDlg( QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~TransformationGUI_MultiTranslationDlg(); + +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 */ + + gp_Vec myVec ; + int myNbTimes1 ; + int myNbTimes2 ; + Standard_Real myStep1 ; + Standard_Real myStep2 ; + gp_Dir myDir1 ; + gp_Dir myDir2 ; + + bool myOkBase ; + bool myOkDir1 ; + bool myOkDir2 ; + + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + int myConstructorId ; /* Current constructor id = radio button id */ + Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ + + void closeEvent( QCloseEvent* e ) ; + void enterEvent( QEvent* e); + void Init( SALOME_Selection* Sel ) ; + void MakeMultiTranslationSimulationAndDisplay() ; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QRadioButton* Constructor2; + + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + + QGroupBox* GroupC1; + QPushButton* SelectButtonC1A2; + QLineEdit* LineEditC1A1; + QLineEdit* LineEditC1A2; + QPushButton* SelectButtonC1A1; + QLabel* TextLabelC1A1; + QLabel* TextLabelC1A2; + + QLabel* TextLabelC1A3; + QLabel* TextLabelC1A4; + DlgRef_SpinBox* SpinBox_C1A3 ; + QSpinBox* SpinBox_C1A4 ; + + QGroupBox* GroupC2; + QPushButton* SelectButtonC2A2; + QLineEdit* LineEditC2A1; + QLineEdit* LineEditC2A2; + QPushButton* SelectButtonC2A1; + QLineEdit* LineEditC2A3; + QPushButton* SelectButtonC2A3; + QLabel* TextLabelC2A1; + QLabel* TextLabelC2A2; + QLabel* TextLabelC2A3; + + QLabel* TextLabelC2A4; + QLabel* TextLabelC2A5; + QLabel* TextLabelC2A6; + QLabel* TextLabelC2A7; + DlgRef_SpinBox* SpinBox_C2A4 ; + QSpinBox* SpinBox_C2A5; + DlgRef_SpinBox* SpinBox_C2A6 ; + QSpinBox* SpinBox_C2A7 ; + + QCheckBox* CheckBoxReverse0; + QCheckBox* CheckBoxReverse1; + QCheckBox* CheckBoxReverse2; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void LineEditReturnPressed() ; + void ReverseAngle1(int) ; + void ReverseAngle2(int) ; + void ValueChangedInSpinBox( double newValue ) ; /* for TransformationGUI_SpinBox */ + void ValueChangedInt( int newIntValue ) ; /* for QT spin box ! not const ! */ + +protected: + QGridLayout* TransformationGUI_MultiTranslationDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; + QGridLayout* GroupC2Layout; +}; + +#endif // DIALOGBOX_MULTITRANSLATION_H diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx new file mode 100644 index 000000000..c20bebea8 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx @@ -0,0 +1,544 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI_RotationDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +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 + + +//================================================================================= +// class : TransformationGUI_RotationDlg() +// purpose : Constructs a TransformationGUI_RotationDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// 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 ) +{ + 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 */ +} + +//================================================================================= +// 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 +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void TransformationGUI_RotationDlg::Init( SALOME_Selection* Sel ) +{ + + /* 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 ); + + /* 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 ; +} + +//================================================================================= +// 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 ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void TransformationGUI_RotationDlg::ConstructorsClicked(int constructorId) +{ + /* only a constructor now */ + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void TransformationGUI_RotationDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->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 ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +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 ; + } + + /* 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) */) { + BRepAdaptor_Curve curv(TopoDS::Edge(S)); + myDir = curv.Line().Direction(); + myLoc = curv.Line().Location(); + LineEditC1A2->setText(aString) ; + myOkAxis = true ; + } + + if( myOkBase && myOkAxis ) { + MakeRotationSimulationAndDisplay( myBase) ; + } + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +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 ; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void TransformationGUI_RotationDlg::LineEditReturnPressed() +{ + 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 ; +} + + +//================================================================================= +// 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 ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +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 ; +} + + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void TransformationGUI_RotationDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void TransformationGUI_RotationDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; /* same than click on cancel button */ +} + + +//================================================================================= +// function : MakeRotationSimulationAndDisplay() +// purpose : +//================================================================================= +void TransformationGUI_RotationDlg::MakeRotationSimulationAndDisplay( const TopoDS_Shape& S) +{ + myGeomGUI->EraseSimulationShape() ; + + if( S.IsNull() ) + return ; + + 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 ) ; + } + catch(Standard_Failure) { + MESSAGE( "Exception catched in MakeRotationSimulationAndDisplay" ) ; + return ; + } + return ; +} diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.h b/src/TransformationGUI/TransformationGUI_RotationDlg.h new file mode 100644 index 000000000..49d5dca03 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.h @@ -0,0 +1,129 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI_RotationDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_ROTATION_H +#define DIALOGBOX_ROTATION_H + +#include "TransformationGUI.h" + +#include "GEOM_EdgeFilter.hxx" +#include "DlgRef_SpinBox.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 +{ + 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(); + +private : + 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 */ + + void closeEvent( QCloseEvent* e ) ; + void enterEvent( QEvent* e); + void Init( SALOME_Selection* Sel ) ; + void MakeRotationSimulationAndDisplay( const TopoDS_Shape& S) ; + + 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; + +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 ) ; + +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 new file mode 100644 index 000000000..ac09f84c4 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx @@ -0,0 +1,530 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI_ScaleDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "TransformationGUI_ScaleDlg.h" + +#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 +// name 'name' and widget flags set to 'f'. +// 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 ) +{ + 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 ) ; +} + +//================================================================================= +// function : ~TransformationGUI_ScaleDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +TransformationGUI_ScaleDlg::~TransformationGUI_ScaleDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void TransformationGUI_ScaleDlg::Init( SALOME_Selection* Sel ) +{ + + 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 */ + + /* 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 */ + + return ; +} + + +//================================================================================= +// 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 ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void TransformationGUI_ScaleDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// 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 ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void TransformationGUI_ScaleDlg::ClickOnCancel() +{ + mySelection->ClearFilters() ; + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->ResetState() ; + reject() ; + return ; +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void TransformationGUI_ScaleDlg::LineEditReturnPressed() +{ + 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 ; +} + + +//================================================================================= +// function : TextChangedInLineEdit() +// purpose : +//================================================================================= +void TransformationGUI_ScaleDlg::TextChangedInLineEdit(const QString& newText) +{ + QLineEdit* send = (QLineEdit*)sender(); + if(send == LineEditC1A3) { + myGeomGUI->EraseSimulationShape() ; + myFactor = newText.toFloat(); + if( fabs(myFactor) > 0.00001 && myOkBaseTopo && myOkPoint1 ) + MakeScaleSimulationAndDisplay(myBaseTopo) ; + } + return ; +} + + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void TransformationGUI_ScaleDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + myGeomGUI->EraseSimulationShape() ; + mySimulationTopoDs.Nullify() ; + + 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 ; + } + + // 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 ) + return ; + myEditCurrentArgument->setText(aString) ; + myBaseTopo = S ; + myOkBaseTopo = true ; + } + else if ( myEditCurrentArgument == LineEditC1A2 && myGeomGUI->VertexToPoint(S, myPoint1) ) { + myEditCurrentArgument->setText(aString) ; + myOkPoint1 = true ; + } + + if( myOkBaseTopo && myOkPoint1 ) { + MakeScaleSimulationAndDisplay( myBaseTopo ) ; + } + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void TransformationGUI_ScaleDlg::SetEditCurrentArgument() +{ + 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 ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void TransformationGUI_ScaleDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + disconnect( mySelection, 0, this, 0 ); + myGeomGUI->EraseSimulationShape() ; + mySelection->ClearFilters() ; + } + return ; +} + + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +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 ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void TransformationGUI_ScaleDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void TransformationGUI_ScaleDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; /* same than click on cancel button */ +} + + +//================================================================================= +// function : MakeScaleSimulationAndDisplay() +// purpose : +//================================================================================= +void TransformationGUI_ScaleDlg::MakeScaleSimulationAndDisplay( const TopoDS_Shape& S ) +{ + this->mySimulationTopoDs.Nullify() ; + + try { + gp_Trsf theTransformation ; + theTransformation.SetScale( myPoint1, myFactor) ; + BRepBuilderAPI_Transform myBRepTransformation( S, theTransformation, Standard_False) ; + mySimulationTopoDs = myBRepTransformation.Shape() ; + if( mySimulationTopoDs.IsNull() ) + return ; + else + myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ; + } + catch(Standard_Failure) { + MESSAGE( "Exception catched in MakeScaleSimulationAndDisplay" ) ; + return ; + } + return ; +} diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.h b/src/TransformationGUI/TransformationGUI_ScaleDlg.h new file mode 100644 index 000000000..57b779f08 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.h @@ -0,0 +1,117 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI_ScaleDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#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; + + +//================================================================================= +// class : TransformationGUI_ScaleDlg +// purpose : +//================================================================================= +class TransformationGUI_ScaleDlg : public QDialog +{ + 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(); + +private : + TransformationGUI* myTransformationGUI; + void closeEvent( QCloseEvent* e ) ; + void enterEvent( QEvent* e ); + void Init(SALOME_Selection* Sel) ; + void MakeScaleSimulationAndDisplay( const TopoDS_Shape& S ) ; + + 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 */ + + 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; + +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) ; + +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 new file mode 100644 index 000000000..03236f9c4 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx @@ -0,0 +1,561 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI_TranslationDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +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 + + + +//================================================================================= +// class : TransformationGUI_TranslationDlg() +// purpose : Constructs a TransformationGUI_TranslationDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// 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 ) +{ + 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 */ +} + + + +//================================================================================= +// 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 +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void TransformationGUI_TranslationDlg::Init( SALOME_Selection* Sel ) +{ + 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 ); + + /* 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( LineEditC1A1, 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 ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void TransformationGUI_TranslationDlg::ConstructorsClicked(int constructorId) +{ + // myGeomGUI->EraseSimulationShape() ; + switch (constructorId) + { + case 0: + { + break; + } + case 1: + { + break; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void TransformationGUI_TranslationDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->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 ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +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 ; + } + + /* 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 ) + return ; + LineEditC1A1->setText(aString) ; + myBase = S ; + myOkBase = true ; + } + + if( myOkBase ) { + MakeTranslationSimulationAndDisplay() ; + } + return ; +} + + +//================================================================================= +// 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 ; + 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 ; +} + + + +//================================================================================= +// function : ValueChangedInSpinBox() +// 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 ; + } + + this->myVec.SetCoord(Dx, Dy, Dz) ; + if ( myOkBase ) { + MakeTranslationSimulationAndDisplay() ; + } + 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 ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +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 ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void TransformationGUI_TranslationDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void TransformationGUI_TranslationDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +//================================================================================= +// function : MakeTranslationSimulationAndDisplay() +// purpose : +//================================================================================= +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 ; +} diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.h b/src/TransformationGUI/TransformationGUI_TranslationDlg.h new file mode 100644 index 000000000..84c9691a1 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.h @@ -0,0 +1,126 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : TransformationGUI_TranslationDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_TRANSLATION_H +#define DIALOGBOX_TRANSLATION_H + +#include "TransformationGUI.h" + +#include "DlgRef_SpinBox.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 +{ + 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(); + +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; + + DlgRef_SpinBox* SpinBox_DX ; + DlgRef_SpinBox* SpinBox_DY ; + DlgRef_SpinBox* SpinBox_DZ ; + + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void LineEditReturnPressed() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void ValueChangedInSpinBox( double newValue ) ; + +protected: + QGridLayout* TransformationGUI_TranslationDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; + QGridLayout* GroupButtonsLayout; + + QHBoxLayout* Layout1 ; +}; + +#endif // DIALOGBOX_TRANSLATION_H