X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FBasicGUI%2FBasicGUI_WorkingPlaneDlg.cxx;h=55bba2858e9d04ca402521ce79e24fea082a592b;hb=b568e7744737ad193de8a49b27a5769a4777d7fd;hp=35eba3f63964ac6c51288b762705973fe815ed3e;hpb=162d5c03bd54dc72d9e98318a867372f088e1bcb;p=modules%2Fgeom.git diff --git a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx index 35eba3f63..55bba2858 100644 --- a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx @@ -1,39 +1,38 @@ -// GEOM GEOMGUI : GUI for Geometry component +// 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 +// 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 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. +// 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 +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// File : BasicGUI_WorkingPlaneDlg.cxx +// Author : Lucien PIGNOLONI, Open CASCADE S.A.S. // -// -// File : BasicGUI_WorkingPlaneDlg.cxx -// Author : Lucien PIGNOLONI -// Module : GEOM #include "BasicGUI_WorkingPlaneDlg.h" -#include "GeometryGUI.h" -#include "GEOMBase.h" +#include +#include +#include -#include "SUIT_ResourceMgr.h" -#include "SUIT_Session.h" -#include "SalomeApp_Application.h" -#include "LightApp_SelectionMgr.h" +#include +#include +#include +#include // OCCT Includes #include @@ -43,13 +42,14 @@ #include #include #include +#include +#include +#include // QT Includes #include -#include "GEOMImpl_Types.hxx" - -using namespace std; +#include //================================================================================= // class : BasicGUI_WorkingPlaneDlg() @@ -58,74 +58,65 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BasicGUI_WorkingPlaneDlg::BasicGUI_WorkingPlaneDlg(GeometryGUI* theGeometryGUI, QWidget* parent, - const char* name, bool modal, Qt::WindowFlags fl) - :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, Qt::WindowTitleHint | Qt::WindowSystemMenuHint) +BasicGUI_WorkingPlaneDlg::BasicGUI_WorkingPlaneDlg( GeometryGUI* theGeometryGUI, QWidget* parent, + bool modal, Qt::WindowFlags fl ) + : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) { - QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT"))); - QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_WPLANE_FACE"))); - QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_WPLANE_VECTOR"))); - QPixmap image3(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_WPLANE_ORIGIN"))); + QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_FACE" ) ) ); + QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_VECTOR" ) ) ); + QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_ORIGIN" ) ) ); - setWindowTitle(tr("GEOM_WPLANE_TITLE")); + setWindowTitle( tr( "GEOM_WPLANE_TITLE" ) ); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_WPLANE")); - RadioButton1->setIcon(image1); - RadioButton2->setIcon(image2); - RadioButton3->setIcon(image3); - - Group1 = new Ui::DlgRef_1Sel_QTD(); - QWidget* aGroup1Widget = new QWidget(this); - Group1->setupUi(aGroup1Widget); - aGroup1Widget->setObjectName("Group1"); - - Group1->GroupBox1->setTitle(tr("GEOM_WPLANE_FACE")); - Group1->TextLabel1->setText(tr("GEOM_SELECTION")); - Group1->PushButton1->setIcon(image0); + mainFrame()->GroupConstructors->setTitle( tr( "GEOM_WPLANE" ) ); + mainFrame()->RadioButton1->setIcon( image1 ); + mainFrame()->RadioButton2->setIcon( image2 ); + mainFrame()->RadioButton3->setIcon( image3 ); + + Group1 = new DlgRef_1Sel( centralWidget() ); + + Group1->GroupBox1->setTitle( tr( "GEOM_WPLANE_FACE" ) ); + Group1->TextLabel1->setText( tr( "GEOM_SELECTION" ) ); + Group1->PushButton1->setIcon( image0 ); Group1->LineEdit1->setReadOnly( true ); - Group2 = new Ui::DlgRef_2Sel_QTD(); - QWidget* aGroup2Widget = new QWidget(this); - Group2->setupUi(aGroup2Widget); - aGroup2Widget->setObjectName("Group2"); + Group2 = new DlgRef_2Sel( centralWidget() ); - Group2->GroupBox1->setTitle(tr("GEOM_WPLANE_VECTOR")); - Group2->TextLabel1->setText(tr("GEOM_WPLANE_VX")); - Group2->TextLabel2->setText(tr("GEOM_WPLANE_VZ")); - Group2->PushButton1->setIcon(image0); - Group2->PushButton2->setIcon(image0); + Group2->GroupBox1->setTitle( tr( "GEOM_WPLANE_VECTOR" ) ); + Group2->TextLabel1->setText( tr( "GEOM_WPLANE_VX" ) ); + Group2->TextLabel2->setText( tr( "GEOM_WPLANE_VZ" ) ); + Group2->PushButton1->setIcon( image0 ); + Group2->PushButton2->setIcon( image0 ); Group2->LineEdit1->setReadOnly( true ); Group2->LineEdit2->setReadOnly( true ); - Group3 = new Ui::DlgRef_3Check_QTD(); - QWidget* aGroup3Widget = new QWidget(this); - Group3->setupUi(aGroup3Widget); - aGroup3Widget->setObjectName("Group3"); + Group3 = new DlgRef_3Check( centralWidget() ); - Group3->GroupBox1->setTitle(tr("GEOM_WPLANE_ORIGIN")); - Group3->RadioButton1->setText(tr("GEOM_WPLANE_OXY")); - Group3->RadioButton2->setText(tr("GEOM_WPLANE_OYZ")); - Group3->RadioButton3->setText(tr("GEOM_WPLANE_OZX")); + Group3->GroupBox1->setTitle( tr( "GEOM_WPLANE_ORIGIN" ) ); + Group3->RadioButton1->setText( tr( "GEOM_WPLANE_OXY" ) ); + Group3->RadioButton2->setText( tr( "GEOM_WPLANE_OYZ" ) ); + Group3->RadioButton3->setText( tr( "GEOM_WPLANE_OZX" ) ); - gridLayout1->addWidget(aGroup1Widget, 1, 0); - gridLayout1->addWidget(aGroup2Widget, 1, 0); - gridLayout1->addWidget(aGroup3Widget, 1, 0); /***************************************************************/ - QFrame* aReverseGroupBox = new QFrame(this); - aReverseGroupBox->setObjectName("aReverseGroupBox"); - aReverseGroupBox->setContentsMargins(10, 10, 10, 10); + QGroupBox* aReverseGroupBox = new QGroupBox( centralWidget() ); QHBoxLayout* aReverseGroupBoxLayout = new QHBoxLayout( aReverseGroupBox ); - - myReverseCB = new QCheckBox(aReverseGroupBox); - myReverseCB->setObjectName("myReverseCB"); - myReverseCB->setText(tr("GEOM_REVERSE_PLANE")); - aReverseGroupBoxLayout->addWidget(myReverseCB); - - gridLayout1->addWidget(aReverseGroupBox, 2, 0); - + aReverseGroupBoxLayout->setMargin( 9 ); + aReverseGroupBoxLayout->setSpacing( 6 ); - setHelpFileName("working_plane.htm"); + myReverseCB = new QCheckBox( aReverseGroupBox ); + myReverseCB->setText( tr( "GEOM_REVERSE_PLANE" ) ); + aReverseGroupBoxLayout->addWidget( myReverseCB ); + + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); + layout->setMargin( 0 ); layout->setSpacing( 6 ); + layout->addWidget( Group1 ); + layout->addWidget( Group2 ); + layout->addWidget( Group3 ); + layout->addWidget( aReverseGroupBox ); + + setHelpFileName( "create_wplane_page.html" ); Init(); } @@ -150,7 +141,7 @@ void BasicGUI_WorkingPlaneDlg::Init() // myGeomGUI->SetState( 0 ); - myFace = GEOM::GEOM_Object::_nil(); + myFace = GEOM::GEOM_Object::_nil(); myVectX = GEOM::GEOM_Object::_nil(); myVectZ = GEOM::GEOM_Object::_nil(); @@ -160,96 +151,99 @@ void BasicGUI_WorkingPlaneDlg::Init() globalSelection( GEOM_PLANE ); /* 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())); - connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); + connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); + + connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); - connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect( Group1->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( Group1->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( Group2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( Group2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( Group2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( Group2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(Group2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(Group2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect( Group3->GroupBox1, SIGNAL( clicked( int ) ), this, SLOT( GroupClicked( int ) ) ); - connect(Group3->GroupBox1, SIGNAL(clicked(int)), this, SLOT(GroupClicked(int))); + connect( myReverseCB, SIGNAL( clicked() ), this, SLOT( onReverse() ) ); - connect(myReverseCB, SIGNAL(clicked()), this, SLOT(onReverse())); + connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + initName( tr( "GEOM_WPLANE" ) ); - initName( tr( "GEOM_WPLANE" ).toStdString().c_str() ); - ConstructorsClicked(0); + setConstructorId( 2 ); // simplest constructor + ConstructorsClicked( 2 ); } //================================================================================= // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void BasicGUI_WorkingPlaneDlg::ConstructorsClicked(int constructorId) +void BasicGUI_WorkingPlaneDlg::ConstructorsClicked( int constructorId ) { LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - disconnect(aSelMgr, 0, this, 0); + disconnect( aSelMgr, 0, this, 0 ); - switch (constructorId) + switch ( constructorId ) { + case 0: { - case 0: - { - //globalSelection( GEOM_PLANE ); - TColStd_MapOfInteger aMap; - aMap.Add( GEOM_PLANE ); - aMap.Add( GEOM_MARKER ); - globalSelection( aMap ); - - ::qobject_cast( Group2->gridLayout->parent() )->hide(); - ::qobject_cast( Group3->gridLayout->parent() )->hide(); - resize(0, 0); - ::qobject_cast( Group1->gridLayout->parent() )->show(); - - myEditCurrentArgument = Group1->LineEdit1; - Group1->LineEdit1->setText(""); - myFace = GEOM::GEOM_Object::_nil(); - - connect(aSelMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - break; - } - case 1: - { - globalSelection( GEOM_LINE ); - - ::qobject_cast( Group1->gridLayout->parent() )->hide(); - ::qobject_cast( Group3->gridLayout->parent() )->hide(); - resize(0, 0); - ::qobject_cast( Group2->gridLayout->parent() )->show(); - - myEditCurrentArgument = Group2->LineEdit1; - Group2->LineEdit1->setText(""); - Group2->LineEdit2->setText(""); - myVectX = GEOM::GEOM_Object::_nil(); - myVectZ = GEOM::GEOM_Object::_nil(); + //globalSelection( GEOM_PLANE ); + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_PLANE ); + aMap.Add( GEOM_MARKER ); + globalSelection( aMap ); + + Group2->hide(); + Group3->hide(); + Group1->show(); + + myEditCurrentArgument = Group1->LineEdit1; + Group1->LineEdit1->setText( "" ); + myFace = GEOM::GEOM_Object::_nil(); - connect(aSelMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - break; - } - case 2: - { - ::qobject_cast( Group1->gridLayout->parent() )->hide(); - ::qobject_cast( Group2->gridLayout->parent() )->hide(); - resize(0, 0); - ::qobject_cast( Group3->gridLayout->parent() )->show(); - - Group3->RadioButton1->setChecked(true); - aOriginType = 1; - break; - } + connect( aSelMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + break; } - + case 1: + { + //globalSelection( GEOM_LINE ); + GEOM::GEOM_Object_var anObj; + localSelection( anObj, TopAbs_EDGE ); + + Group1->hide(); + Group3->hide(); + Group2->show(); + + myEditCurrentArgument = Group2->LineEdit1; + Group2->LineEdit1->setText( "" ); + Group2->LineEdit2->setText( "" ); + myVectX = GEOM::GEOM_Object::_nil(); + myVectZ = GEOM::GEOM_Object::_nil(); + + connect( aSelMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + break; + } + case 2: + { + Group1->hide(); + Group2->hide(); + Group3->show(); + + Group3->RadioButton1->setChecked( true ); + aOriginType = 1; + break; + } + } + + qApp->processEvents(); + updateGeometry(); + resize( minimumSize() ); + updateWPlane(); } @@ -257,7 +251,7 @@ void BasicGUI_WorkingPlaneDlg::ConstructorsClicked(int constructorId) // function : GroupClicked() // purpose : Radio button management //================================================================================= -void BasicGUI_WorkingPlaneDlg::GroupClicked(int groupId) +void BasicGUI_WorkingPlaneDlg::GroupClicked( int groupId ) { aOriginType = groupId; updateWPlane(); @@ -279,14 +273,14 @@ void BasicGUI_WorkingPlaneDlg::ClickOnOk() //================================================================================= bool BasicGUI_WorkingPlaneDlg::ClickOnApply() { - buttonApply->setFocus(); - myGeomGUI->application()->putInfo(tr("")); - - if (updateWPlane(false)){ - myGeomGUI->SetWorkingPlane(myWPlane); + buttonApply()->setFocus(); + myGeomGUI->application()->putInfo( "" ); + + if ( updateWPlane( false ) ) { + myGeomGUI->SetWorkingPlane( myWPlane ); myGeomGUI->ActiveWorkingPlane(); } - + return true; } @@ -296,16 +290,17 @@ bool BasicGUI_WorkingPlaneDlg::ClickOnApply() //================================================================================= void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText(""); + myEditCurrentArgument->setText( "" ); + QString aName; const int id = getConstructorId(); if ( IObjectCount() != 1 ) { - if(id == 0) + if ( id == 0 ) myFace = GEOM::GEOM_Object::_nil(); - else if(id == 1) { - if (myEditCurrentArgument == Group2->LineEdit1) + else if ( id == 1 ) { + if ( myEditCurrentArgument == Group2->LineEdit1 ) myVectX = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == Group2->LineEdit2) + else if ( myEditCurrentArgument == Group2->LineEdit2 ) myVectZ = GEOM::GEOM_Object::_nil(); } return; @@ -313,20 +308,47 @@ void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument() // nbSel == 1 Standard_Boolean aRes = Standard_False; - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), aRes); + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes ); - if(!aRes || CORBA::is_nil( aSelectedObject )) + if ( !aRes || CORBA::is_nil( aSelectedObject ) ) return; - if(myEditCurrentArgument == Group1->LineEdit1) + aName = GEOMBase::GetName(aSelectedObject); + + if ( myEditCurrentArgument == Group1->LineEdit1 ) myFace = aSelectedObject; - else if(myEditCurrentArgument == Group2->LineEdit1) - myVectX = aSelectedObject; - else if(myEditCurrentArgument == Group2->LineEdit2) - myVectZ = aSelectedObject; + else if ( myEditCurrentArgument == Group2->LineEdit1 || + myEditCurrentArgument == Group2->LineEdit2 ) { + if ( aRes && !aSelectedObject->_is_nil() ) { + TopoDS_Shape aShape; + if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes( firstIObject(), aMap ); + if ( aMap.Extent() == 1 ) { + int anIndex = aMap( 1 ); + aName = aName + ":edge_" + QString::number( anIndex ); + + GEOM::GEOM_IShapesOperations_var aShapesOp = + getGeomEngine()->GetIShapesOperations( getStudyId() ); + if ( myEditCurrentArgument == Group2->LineEdit1 ) + myVectX = aShapesOp->GetSubShape( aSelectedObject, anIndex ); + else + myVectZ = aShapesOp->GetSubShape( aSelectedObject, anIndex ); + } + else { + if ( myEditCurrentArgument == Group2->LineEdit1 ) + myVectX = aSelectedObject; + else + myVectZ = aSelectedObject; + } + aSelMgr->clearSelected(); + } + } + } + + myEditCurrentArgument->setText( aName ); - myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); - updateWPlane(); } @@ -339,17 +361,19 @@ void BasicGUI_WorkingPlaneDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if(send == Group1->PushButton1) { + if ( send == Group1->PushButton1 ) { myEditCurrentArgument = Group1->LineEdit1; globalSelection( GEOM_PLANE ); } - else if(send == Group2->PushButton1) { + else if ( send == Group2->PushButton1 ) { myEditCurrentArgument = Group2->LineEdit1; - globalSelection( GEOM_LINE ); + GEOM::GEOM_Object_var anObj; + localSelection( anObj, TopAbs_EDGE ); } - else if(send == Group2->PushButton2) { + else if ( send == Group2->PushButton2 ) { myEditCurrentArgument = Group2->LineEdit2; - globalSelection( GEOM_LINE ); + GEOM::GEOM_Object_var anObj; + localSelection( anObj, TopAbs_EDGE ); } myEditCurrentArgument->setFocus(); @@ -364,7 +388,7 @@ void BasicGUI_WorkingPlaneDlg::SetEditCurrentArgument() void BasicGUI_WorkingPlaneDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == Group1->LineEdit1 || send == Group2->LineEdit1 || send == Group2->LineEdit2) { + if ( send == Group1->LineEdit1 || send == Group2->LineEdit1 || send == Group2->LineEdit2 ) { myEditCurrentArgument = send; GEOMBase_Skeleton::LineEditReturnPressed(); } @@ -388,8 +412,8 @@ void BasicGUI_WorkingPlaneDlg::onReverse() void BasicGUI_WorkingPlaneDlg::ActivateThisDialog( ) { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication( ) ) )->selectionMgr(), + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); ConstructorsClicked( getConstructorId() ); } @@ -405,35 +429,16 @@ void BasicGUI_WorkingPlaneDlg::DeactivateActiveDialog() GEOMBase_Skeleton::DeactivateActiveDialog(); } -//======================================================================= -// function : ClickOnCancel() -// purpose : -//======================================================================= -void BasicGUI_WorkingPlaneDlg::ClickOnCancel() -{ - GEOMBase_Skeleton::ClickOnCancel(); -} - //================================================================================= // function : enterEvent() // purpose : //================================================================================= -void BasicGUI_WorkingPlaneDlg::enterEvent(QEvent* e) +void BasicGUI_WorkingPlaneDlg::enterEvent( QEvent* ) { - if ( !GroupConstructors->isEnabled() ) + if ( !mainFrame()->GroupConstructors->isEnabled() ) ActivateThisDialog(); } -//================================================================================= -// function : closeEvent -// purpose : -//================================================================================= -void BasicGUI_WorkingPlaneDlg::closeEvent( QCloseEvent* e ) -{ - GEOMBase_Skeleton::closeEvent( e ); -} - - //================================================================================= // function : updateWPlane // purpose : @@ -441,40 +446,41 @@ void BasicGUI_WorkingPlaneDlg::closeEvent( QCloseEvent* e ) bool BasicGUI_WorkingPlaneDlg::updateWPlane( const bool showPreview ) { erasePreview(); - + const int id = getConstructorId(); - if (id == 0) { // by planar face selection - if (CORBA::is_nil(myFace)) { - if(!showPreview) + if ( id == 0 ) { // by planar face selection + if ( CORBA::is_nil( myFace ) ) { + if ( !showPreview ) showError( "Face has to be selected" ); return false; } // PAL12781: set center of WPL to face's center of mass // like it is done for LCS creation - CORBA::Double Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz; + CORBA::Double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz; Ox = Oy = Oz = Zx = Zy = Xy = Xz = 0.; Zz = Xx = 1.; GEOM::GEOM_IMeasureOperations_ptr aMeasureOp = - myGeomGUI->GetGeomGen()->GetIMeasureOperations(getStudyId()); - aMeasureOp->GetPosition(myFace, Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz); - - if (aMeasureOp->IsDone()) { - gp_Pnt aPnt (Ox,Oy,Oz); - gp_Dir aDirN (Zx,Zy,Zz); - gp_Dir aDirX (Xx,Xy,Xz); - myWPlane = gp_Ax3(aPnt, aDirN, aDirX); - } else { - if(!showPreview) + myGeomGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() ); + aMeasureOp->GetPosition( myFace, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz); + + if ( aMeasureOp->IsDone() ) { + gp_Pnt aPnt ( Ox, Oy, Oz ); + gp_Dir aDirN ( Zx, Zy, Zz ); + gp_Dir aDirX ( Xx, Xy, Xz ); + myWPlane = gp_Ax3( aPnt, aDirN, aDirX ); + } + else { + if ( !showPreview ) showError( "Wrong shape selected (has to be a planar face)" ); return false; } - - } else if (id == 1) { // by two vectors (Ox & Oz) + } + else if ( id == 1 ) { // by two vectors (Ox & Oz) if ( CORBA::is_nil( myVectX ) || CORBA::is_nil( myVectZ ) ) { - if(!showPreview) + if ( !showPreview ) showError( "Two vectors have to be selected" ); return false; } @@ -483,79 +489,80 @@ bool BasicGUI_WorkingPlaneDlg::updateWPlane( const bool showPreview ) TopoDS_Vertex VX1, VX2, VZ1, VZ2; gp_Vec aVX, aVZ; - if (!GEOMBase::GetShape( myVectX, aVectX, TopAbs_EDGE ) || - !GEOMBase::GetShape( myVectZ, aVectZ, TopAbs_EDGE )) { - if(!showPreview) + if ( !GEOMBase::GetShape( myVectX, aVectX, TopAbs_EDGE ) || + !GEOMBase::GetShape( myVectZ, aVectZ, TopAbs_EDGE ) ) { + if ( !showPreview ) showError( "Wrong shape selected (two vectors(edges) have to be selected)" ); return false; } - TopExp::Vertices(aVectX, VX1, VX2, Standard_True); - TopExp::Vertices(aVectZ, VZ1, VZ2, Standard_True); + TopExp::Vertices( aVectX, VX1, VX2, Standard_True ); + TopExp::Vertices( aVectZ, VZ1, VZ2, Standard_True ); - if (VX1.IsNull() || VX2.IsNull()) { - if(!showPreview) + if ( VX1.IsNull() || VX2.IsNull() ) { + if ( !showPreview ) showError( "Bad OX vector" ); return false; } - if (VZ1.IsNull() || VZ2.IsNull()) { - if(!showPreview) + if ( VZ1.IsNull() || VZ2.IsNull() ) { + if ( !showPreview ) showError( "Bad OZ vector" ); return false; } - aVX = gp_Vec(BRep_Tool::Pnt(VX1), BRep_Tool::Pnt(VX2)); - aVZ = gp_Vec(BRep_Tool::Pnt(VZ1), BRep_Tool::Pnt(VZ2)); + aVX = gp_Vec( BRep_Tool::Pnt( VX1 ), BRep_Tool::Pnt( VX2 ) ); + aVZ = gp_Vec( BRep_Tool::Pnt( VZ1 ), BRep_Tool::Pnt( VZ2 ) ); - if (aVX.Magnitude() < Precision::Confusion()) { - if(!showPreview) + if ( aVX.Magnitude() < Precision::Confusion() ) { + if ( !showPreview ) showError( "Bad OX vector" ); return false; } - if (aVZ.Magnitude() < Precision::Confusion()) { - if(!showPreview) + if ( aVZ.Magnitude() < Precision::Confusion() ) { + if ( !showPreview ) showError( "Bad OZ vector" ); return false; } - gp_Dir aDirX = gp_Dir(aVX.X(), aVX.Y(), aVX.Z()); - gp_Dir aDirZ = gp_Dir(aVZ.X(), aVZ.Y(), aVZ.Z()); + gp_Dir aDirX = gp_Dir( aVX.X(), aVX.Y(), aVX.Z() ); + gp_Dir aDirZ = gp_Dir( aVZ.X(), aVZ.Y(), aVZ.Z() ); - if (aDirX.IsParallel(aDirZ, Precision::Angular())) { - if(!showPreview) + if ( aDirX.IsParallel( aDirZ, Precision::Angular() ) ) { + if ( !showPreview ) showError( "Parallel vectors selected" ); return false; } - myWPlane = gp_Ax3(BRep_Tool::Pnt(VX1), aDirZ, aDirX); + myWPlane = gp_Ax3( BRep_Tool::Pnt( VX1 ), aDirZ, aDirX ); - } else if (id == 2) { // by selection from standard (OXY or OYZ, or OZX) + } + else if ( id == 2 ) { // by selection from standard (OXY or OYZ, or OZX) gp_Ax2 anAx2; - if (aOriginType == 1) anAx2 = gp::XOY(); - else if (aOriginType == 2) anAx2 = gp::YOZ(); - else if (aOriginType == 0) anAx2 = gp::ZOX(); + if ( aOriginType == 1 ) anAx2 = gp::XOY(); + else if ( aOriginType == 2 ) anAx2 = gp::YOZ(); + else if ( aOriginType == 0 ) anAx2 = gp::ZOX(); - myWPlane = gp_Ax3(anAx2); + myWPlane = gp_Ax3( anAx2 ); - } else { + } + else { return false; } - - if (myReverseCB->isChecked()) - { - myWPlane.YReverse(); - myWPlane.ZReverse(); - } - - if (showPreview) - { - GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() ); - GEOM::GEOM_Object_var anObj = aBasicOp->MakeMarker( myWPlane.Location().X(), myWPlane.Location().Y(), myWPlane.Location().Z(), - myWPlane.XDirection().X(), myWPlane.XDirection().Y(), myWPlane.XDirection().Z(), - myWPlane.YDirection().X(), myWPlane.YDirection().Y(), myWPlane.YDirection().Z() ); - displayPreview(anObj); - } + + if ( myReverseCB->isChecked() ) { + myWPlane.YReverse(); + myWPlane.ZReverse(); + } + + if ( showPreview ) { + GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() ); + GEOM::GEOM_Object_var anObj = aBasicOp->MakeMarker + ( myWPlane.Location().X(), myWPlane.Location().Y(), myWPlane.Location().Z(), + myWPlane.XDirection().X(), myWPlane.XDirection().Y(), myWPlane.XDirection().Z(), + myWPlane.YDirection().X(), myWPlane.YDirection().Y(), myWPlane.YDirection().Z() ); + displayPreview( anObj ); + } return true; }