X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FEntityGUI%2FEntityGUI_SketcherDlg.cxx;h=b8a39f79a7911096113a8f4d2ab98f3e0dcd9ffd;hb=7e21a68ba07185cd1dddcf9e1522a28111c2cee4;hp=d91c2454401fbd51aaf2addb82b3349636bd2b2d;hpb=a596550f89dfafcf288f8d62a2ca2a1be40ca512;p=modules%2Fgeom.git diff --git a/src/EntityGUI/EntityGUI_SketcherDlg.cxx b/src/EntityGUI/EntityGUI_SketcherDlg.cxx index d91c24544..b8a39f79a 100644 --- a/src/EntityGUI/EntityGUI_SketcherDlg.cxx +++ b/src/EntityGUI/EntityGUI_SketcherDlg.cxx @@ -1,207 +1,257 @@ -// GEOM GEOMGUI : GUI for Geometry component +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // -// 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 +// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File : EntityGUI_SketcherDlg.cxx -// Author : Damien COQUERET -// Module : GEOM -// $Header: -using namespace std; +// GEOM GEOMGUI : GUI for Geometry component +// File : EntityGUI_SketcherDlg.cxx +// Author : Damien COQUERET, Open CASCADE S.A.S. +// #include "EntityGUI_SketcherDlg.h" -#include "Sketcher_Profile.hxx" -#include "utilities.h" +#include "EntityGUI_Widgets.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 + +#include //================================================================================= // class : EntityGUI_SketcherDlg() -// purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the +// purpose : Constructs a EntityGUI_SketcherDlg 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. //================================================================================= -EntityGUI_SketcherDlg::EntityGUI_SketcherDlg(QWidget* parent, const char* name, EntityGUI* theEntityGUI, SALOME_Selection* Sel, bool modal, WFlags fl) - :EntityGUI_Skeleton_QTD(parent, name, modal, fl) +EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent, + bool modal, Qt::WindowFlags fl, + const double lineWidth ) + : QDialog( parent, fl ), + myIsAllAdded( false ), + myIsApply( false ), + GEOMBase_Helper( dynamic_cast( parent ) ), + myGeometryGUI( GUI ), + myLineWidth( lineWidth ) { - if (!name) - setName("EntityGUI_SketcherDlg"); + setModal( modal ); + setAttribute( Qt::WA_DeleteOnClose ); - buttonCancel->setText(tr("GEOM_BUT_CANCEL")); - buttonEnd->setText(tr("GEOM_BUT_END_SKETCH")); - buttonClose->setText(tr("GEOM_BUT_CLOSE_SKETCH")); - GroupVal->close(TRUE); - GroupDest2->close(TRUE); - GroupDest3->close(TRUE); - resize(0, 0); + myGeometryGUI->SetActiveDialogBox(this); - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + MainWidget = new EntityGUI_Skeleton( this ); + QVBoxLayout* topLayout = new QVBoxLayout( this ); + topLayout->setMargin( 9 ); topLayout->setSpacing( 6 ); - setCaption(tr("GEOM_SKETCHER_TITLE")); + MainWidget->buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) ); + MainWidget->buttonEnd->setText( tr( "GEOM_BUT_END_SKETCH" ) ); + MainWidget->buttonClose->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) ); + MainWidget->buttonHelp->setText( tr( "GEOM_BUT_HELP" ) ); - GroupConstructors->setTitle(tr("GEOM_SKETCHER_EL")); - RadioButton1->setText(tr("GEOM_SKETCHER_SEGMENT")); - RadioButton2->setText(tr("GEOM_SKETCHER_ARC")); - GroupDest->setTitle(tr("GEOM_SKETCHER_DEST")); - GroupDest1->setTitle(tr("GEOM_SKETCHER_TYPE")); - RB_Dest1->setText(tr("GEOM_SKETCHER_POINT")); - RB_Dest2->setText(tr("GEOM_SKETCHER_DIR")); + QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) ); + QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) ); - /***************************************************************/ - GroupPt = new EntityGUI_Point_QTD(GroupDest, "GroupPt"); - GroupPt->GroupPoint->setTitle(tr("GEOM_SKETCHER_POINT")); - GroupPt->RB_Point1->setText(tr("GEOM_SKETCHER_ABS")); - GroupPt->RB_Point2->setText(tr("GEOM_SKETCHER_REL")); - GroupPt->RB_Point3->setText(tr("GEOM_SKETCHER_SEL")); - - GroupD1 = new EntityGUI_Dir1_QTD(GroupDest, "GroupD1"); - GroupD1->GroupDir1->setTitle(tr("GEOM_SKETCHER_DIR")); - GroupD1->RB_Dir11->setText(tr("GEOM_SKETCHER_ANGLE")); - GroupD1->RB_Dir12->setText(tr("GEOM_SKETCHER_PER")); - GroupD1->RB_Dir13->setText(tr("GEOM_SKETCHER_TAN")); - GroupD1->RB_Dir14->setText(tr("GEOM_SKETCHER_VXVY")); - - GroupD2 = new EntityGUI_Dir2_QTD(GroupDest, "GroupD2"); - GroupD2->GroupDir2->setTitle(tr("GEOM_SKETCHER_DIR")); - GroupD2->RB_Dir21->setText(tr("GEOM_SKETCHER_LENGTH")); - GroupD2->RB_Dir22->setText(tr("GEOM_SKETCHER_X")); - GroupD2->RB_Dir23->setText(tr("GEOM_SKETCHER_Y")); - - Group1Sel = new EntityGUI_1Sel_QTD(this, "Group1Sel"); - Group1Sel->TextLabel1->setText(tr("GEOM_SKETCHER_POINT2")); - Group1Sel->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES")); - Group1Sel->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO")); - Group1Sel->buttonApply->setText(tr("GEOM_SKETCHER_APPLY")); - Group1Sel->PushButton1->setPixmap(image0); - - Group1Spin = new EntityGUI_1Spin(this, "Group1Spin"); - Group1Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES")); - Group1Spin->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO")); - Group1Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY")); - - Group2Spin = new EntityGUI_2Spin(this, "Group2Spin"); - Group2Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES")); - Group2Spin->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO")); - Group2Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY")); - - Group3Spin = new EntityGUI_3Spin(this, "Group3Spin"); - Group3Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES")); - Group3Spin->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO")); - Group3Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY")); - - Group4Spin = new EntityGUI_4Spin(this, "Group4Spin"); - Group4Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES")); - Group4Spin->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO")); - Group4Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY")); - - Layout5->addMultiCellWidget(GroupPt, 1, 1, 0, 1); - Layout5->addWidget(GroupD1, 1, 0); - Layout5->addWidget(GroupD2, 1, 1); - - Layout1->addWidget(Group1Sel, 2, 0); - Layout1->addWidget(Group1Spin, 2, 0); - Layout1->addWidget(Group2Spin, 2, 0); - Layout1->addWidget(Group3Spin, 2, 0); - Layout1->addWidget(Group4Spin, 2, 0); - /***************************************************************/ + setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) ); - mySelection = Sel; - mySimulationTopoDs1.Nullify(); - mySimulationTopoDs2.Nullify(); - myEntityGUI = theEntityGUI; + MainWidget->GroupConstructors->setTitle( tr( "GEOM_SKETCHER_EL" ) ); + MainWidget->RadioButton1->setText( tr( "GEOM_SKETCHER_SEGMENT" ) ); + MainWidget->RadioButton2->setText( tr( "GEOM_SKETCHER_ARC" ) ); + MainWidget->GroupDest->setTitle( tr( "GEOM_SKETCHER_DEST" ) ); + MainWidget->GroupDest1->setTitle( tr( "GEOM_SKETCHER_TYPE" ) ); + MainWidget->RB_Dest1->setText( tr( "GEOM_SKETCHER_POINT" ) ); + MainWidget->RB_Dest2->setText( tr( "GEOM_SKETCHER_DIR" ) ); - /* Get setting of step value from file configuration */ - QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + /***************************************************************/ - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeomGUI->SetActiveDialogBox((QDialog*)this); - myGeom = myGeomGUI->myComponentGeom; + GroupBox1 = new QGroupBox(tr("GEOM_CS"), this); + QGridLayout* OwnLayout = new QGridLayout(GroupBox1); + OwnLayout->setSpacing(6); + OwnLayout->setMargin(11); + + ComboBox1 = new QComboBox(GroupBox1); + OwnLayout->addWidget(ComboBox1); + + topLayout->addWidget(GroupBox1); + topLayout->addWidget( MainWidget ); + + GroupPt = new EntityGUI_Point( MainWidget->DestCnt ); + + GroupPt->GroupPoint->setTitle( tr( "GEOM_SKETCHER_POINT" ) ); + GroupPt->RB_Point1->setText( tr( "GEOM_SKETCHER_ABS" ) ); + GroupPt->RB_Point2->setText( tr( "GEOM_SKETCHER_REL" ) ); + GroupPt->RB_Point3->setText( tr( "GEOM_SKETCHER_SEL" ) ); + + GroupD1 = new EntityGUI_Dir1( MainWidget->DestCnt ); + + GroupD1->GroupDir1->setTitle( tr( "GEOM_SKETCHER_DIR" ) ); + GroupD1->RB_Dir11->setText( tr( "GEOM_SKETCHER_ANGLE" ) ); + GroupD1->RB_Dir12->setText( tr( "GEOM_SKETCHER_PER" ) ); + GroupD1->RB_Dir13->setText( tr( "GEOM_SKETCHER_TAN" ) ); + GroupD1->RB_Dir14->setText( tr( "GEOM_SKETCHER_VXVY" ) ); + + GroupD2 = new EntityGUI_Dir2( MainWidget->DestCnt ); + + GroupD2->GroupDir2->setTitle( tr( "GEOM_SKETCHER_DIR" ) ); + GroupD2->RB_Dir21->setText( tr( "GEOM_SKETCHER_LENGTH" ) ); + GroupD2->RB_Dir22->setText( tr( "GEOM_SKETCHER_X" ) ); + GroupD2->RB_Dir23->setText( tr( "GEOM_SKETCHER_Y" ) ); + + Group1Sel = new EntityGUI_1Sel( MainWidget->SkeletonCnt ); + + Group1Sel->TextLabel1->setText( tr( "GEOM_SKETCHER_POINT2" ) ); + Group1Sel->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) ); + Group1Sel->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) ); + Group1Sel->PushButton1->setIcon( image0 ); + Group1Sel->buttonUndo->setIcon( image1 ); + Group1Sel->buttonRedo->setIcon( image2 ); + Group1Sel->LineEdit1->setReadOnly( true ); + + Group1Spin = new EntityGUI_1Spin( MainWidget->SkeletonCnt ); + Group1Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) ); + Group1Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) ); + Group1Spin->buttonUndo->setIcon( image1 ); + Group1Spin->buttonRedo->setIcon( image2 ); + + Group2Spin = new EntityGUI_2Spin( MainWidget->SkeletonCnt ); + Group2Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) ); + Group2Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) ); + Group2Spin->buttonUndo->setIcon( image1 ); + Group2Spin->buttonRedo->setIcon( image2 ); + + Group3Spin = new EntityGUI_3Spin( MainWidget->SkeletonCnt ); + Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) ); + Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) ); + Group3Spin->buttonUndo->setIcon( image1 ); + Group3Spin->buttonRedo->setIcon( image2 ); + + Group4Spin = new EntityGUI_4Spin( MainWidget->SkeletonCnt ); + Group4Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) ); + Group4Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) ); + Group4Spin->buttonUndo->setIcon( image1 ); + Group4Spin->buttonRedo->setIcon( image2 ); + + QGridLayout* DestCntLayout = new QGridLayout( MainWidget->DestCnt ); + DestCntLayout->setMargin( 0 ); DestCntLayout->setSpacing( 6 ); + DestCntLayout->addWidget( GroupPt, 0, 0, 1, 2 ); + DestCntLayout->addWidget( GroupD1, 1, 0 ); + DestCntLayout->addWidget( GroupD2, 1, 1 ); + + QVBoxLayout* SkeletonCntlayout = new QVBoxLayout( MainWidget->SkeletonCnt ); + SkeletonCntlayout->setMargin( 0 ); SkeletonCntlayout->setSpacing( 6 ); + SkeletonCntlayout->addWidget( Group1Sel, 0, 0 ); + SkeletonCntlayout->addWidget( Group1Spin, 0, 0 ); + SkeletonCntlayout->addWidget( Group2Spin, 0, 0 ); + SkeletonCntlayout->addWidget( Group3Spin, 0, 0 ); + SkeletonCntlayout->addWidget( Group4Spin, 0, 0 ); + /***************************************************************/ - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - mySelection->AddFilter(myVertexFilter); + QButtonGroup* ButtonGroup = new QButtonGroup( this ); + ButtonGroup->addButton( MainWidget->RB_Dest1, 1 ); + ButtonGroup->addButton( MainWidget->RB_Dest2, 0 ); /* signals and slots connections */ - connect(buttonEnd, SIGNAL(clicked()), this, SLOT(ClickOnEnd())); - connect(buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnClose())); - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - - connect(Group1Sel->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(Group1Sel->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo())); - connect(Group1Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(Group1Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo())); - connect(Group2Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(Group2Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo())); - connect(Group3Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(Group3Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo())); - connect(Group4Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(Group4Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo())); - - connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(TypeClicked(int))); - connect(GroupDest1, SIGNAL(clicked(int)), this, SLOT(DestClicked(int))); - connect(GroupPt->GroupPoint, SIGNAL(clicked(int)), this, SLOT(PointClicked(int))); - connect(GroupD1->GroupDir1, SIGNAL(clicked(int)), this, SLOT(Dir1Clicked(int))); - connect(GroupD2->GroupDir2, SIGNAL(clicked(int)), this, SLOT(Dir2Clicked(int))); - - connect(Group1Sel->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(Group1Sel->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(Group1Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(Group2Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(Group2Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(Group3Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(Group3Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(Group3Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(Group4Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(Group4Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(Group4Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(Group4Spin->SpinBox_DS, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group1Spin->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DZ, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DZ, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DS, SLOT(SetStep(double))); - - 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; -// myGeomBase->DefineDlgPosition( this, x, y ); - - myEntityGUI = theEntityGUI; - this->Init(); - this->show(); + connect( MainWidget->buttonEnd, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) ); + connect( MainWidget->buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnEnd() ) ); + connect( MainWidget->buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ); + connect( MainWidget->buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) ); + + connect( Group1Sel->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect( Group1Sel->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) ); + connect( Group1Sel->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ); + connect( Group1Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect( Group1Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) ); + connect( Group1Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ); + connect( Group2Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect( Group2Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) ); + connect( Group2Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ); + connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) ); + connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ; + connect( Group4Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + connect( Group4Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) ); + connect( Group4Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ); + + connect( MainWidget->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) ); + connect( ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( DestClicked( int ) ) ); + connect( GroupPt->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( PointClicked( int ) ) ); + connect( GroupD1->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir1Clicked( int ) ) ); + connect( GroupD2->ButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( Dir2Clicked( int ) )); + + connect( Group1Sel->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( Group1Sel->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + + connect( Group1Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); + + connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) ); + + connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); + + connect( myGeometryGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); + connect( myGeometryGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); + + // install event filter on spin-boxes to provide Apply action on Return pressed + Group1Spin->SpinBox_DX->installEventFilter(this); + Group2Spin->SpinBox_DX->installEventFilter(this); + Group2Spin->SpinBox_DY->installEventFilter(this); + Group3Spin->SpinBox_DX->installEventFilter(this); + Group3Spin->SpinBox_DY->installEventFilter(this); + Group3Spin->SpinBox_DZ->installEventFilter(this); + Group4Spin->SpinBox_DX->installEventFilter(this); + Group4Spin->SpinBox_DY->installEventFilter(this); + Group4Spin->SpinBox_DZ->installEventFilter(this); + Group4Spin->SpinBox_DS->installEventFilter(this); + + Init(); } @@ -211,8 +261,44 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg(QWidget* parent, const char* name, //================================================================================= EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg() { - // no need to delete child widgets, Qt does it all for us - this->destroy(TRUE, TRUE); + myGeometryGUI->SetActiveDialogBox( 0 ); +} + + +//================================================================================= +// function : eventFilter() +// purpose : event filter for spin-boxes to provide Apply action on Return pressed +//================================================================================= +bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event) +{ + if (event->type() == QEvent::KeyPress) { + QKeyEvent* ke = (QKeyEvent*)event; + if (ke->key() == Qt::Key_Return) { + if (object == Group1Spin->SpinBox_DX) { + Group1Spin->buttonApply->animateClick(); + return true; + } else if (object == Group2Spin->SpinBox_DX || + object == Group2Spin->SpinBox_DY) { + Group2Spin->buttonApply->animateClick(); + return true; + } else if (object == Group3Spin->SpinBox_DX || + object == Group3Spin->SpinBox_DY || + object == Group3Spin->SpinBox_DZ) { + Group3Spin->buttonApply->animateClick(); + return true; + } else if (object == Group4Spin->SpinBox_DX || + object == Group4Spin->SpinBox_DY || + object == Group4Spin->SpinBox_DZ || + object == Group4Spin->SpinBox_DS) { + Group4Spin->buttonApply->animateClick(); + return true; + } + } + } + + // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x + + return QDialog::eventFilter(object, event); } @@ -224,75 +310,66 @@ void EntityGUI_SketcherDlg::Init() { /* init variables */ myEditCurrentArgument = Group1Sel->LineEdit1; + myCommand.append( "Sketcher" ); + myUndoCommand.append( "Sketcher" ); - /* min, max, step and decimals for spin boxes */ - Group1Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group2Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group2Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group3Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group3Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group4Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, 0.1, 3); - Group4Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, 0.1, 3); - Group4Spin->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group4Spin->SpinBox_DS->RangeStepAndValidator(-999.999, 999.999, 5., 3); - - Group1Spin->SpinBox_DX->SetValue(0.0); - Group2Spin->SpinBox_DX->SetValue(0.0); - Group2Spin->SpinBox_DY->SetValue(0.0); - Group3Spin->SpinBox_DX->SetValue(0.0); - Group3Spin->SpinBox_DY->SetValue(0.0); - Group3Spin->SpinBox_DZ->SetValue(0.0); - Group4Spin->SpinBox_DX->SetValue(0.0); - Group4Spin->SpinBox_DY->SetValue(0.0); - Group4Spin->SpinBox_DZ->SetValue(0.0); - Group4Spin->SpinBox_DS->SetValue(0.0); - - /* displays Dialog */ - Group1Sel->buttonUndo->setEnabled(false); - Group1Spin->buttonUndo->setEnabled(false); - Group2Spin->buttonUndo->setEnabled(false); - Group3Spin->buttonUndo->setEnabled(false); - Group4Spin->buttonUndo->setEnabled(false); - - RadioButton1->setChecked(true); + mySketchState = FIRST_POINT; + globalSelection( GEOM_POINT ); - myLastOp = 0; myLastX1 = 0.0; myLastY1 = 0.0; myLastX2 = 0.0; myLastY2 = 0.0; - mySketchState = FIRST_POINT; - this->TypeClicked(0); + myHelpFileName = "create_sketcher_page.html"; + + /* Get setting of step value from file configuration */ + double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 ); - return; + /* min, max, step and decimals for spin boxes */ + initSpinBox( Group1Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox( Group4Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" ); + // san: Note specific step values below! + initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" ); + initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" ); + initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" ); + + /* displays Dialog */ + MainWidget->GroupConstructors->setEnabled( false ); + MainWidget->GroupDest1->setEnabled( false ); + setEnabledUndo( false ); + setEnabledRedo( false ); + + MainWidget->RadioButton1->setChecked( true ); + + TypeClicked( 0 ); + + FindLocalCS(); + resize(100,100); + + + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); } //================================================================================= // function : InitClick() -// purpose : +// purpose : //================================================================================= void EntityGUI_SketcherDlg::InitClick() { - disconnect(mySelection, 0, this, 0); - - Group2Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group2Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group3Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group3Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); + disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 ); Group1Sel->hide(); Group1Spin->hide(); Group2Spin->hide(); Group3Spin->hide(); Group4Spin->hide(); - - resize(0, 0); - - return; } @@ -300,22 +377,21 @@ void EntityGUI_SketcherDlg::InitClick() // function : TypeClicked() // purpose : Radio button management //================================================================================= -void EntityGUI_SketcherDlg::TypeClicked(int constructorId) +void EntityGUI_SketcherDlg::TypeClicked( int constructorId ) { myConstructorId = constructorId; - if(myConstructorId == 0) { // SEGMENT - GroupD2->setEnabled(true); - RB_Dest1->setEnabled(true); - RB_Dest1->setChecked(true); - this->DestClicked(1); + if ( myConstructorId == 0 ) { // SEGMENT + GroupD2->setEnabled( true ); + MainWidget->RB_Dest1->setEnabled( true ); + MainWidget->RB_Dest1->setChecked( true ); + DestClicked( 1 ); } - else if(myConstructorId == 1) { // ARC - GroupD2->setEnabled(false); - RB_Dest1->setEnabled(false); - RB_Dest2->setChecked(true); - this->DestClicked(0); + else if ( myConstructorId == 1 ) { // ARC + GroupD2->setEnabled( false ); + MainWidget->RB_Dest1->setEnabled( false ); + MainWidget->RB_Dest2->setChecked( true ); + DestClicked( 0 ); } - return; } @@ -323,24 +399,25 @@ void EntityGUI_SketcherDlg::TypeClicked(int constructorId) // function : DestClicked() // purpose : Radio button management //================================================================================= -void EntityGUI_SketcherDlg::DestClicked(int constructorId) +void EntityGUI_SketcherDlg::DestClicked( int constructorId ) { GroupPt->hide(); GroupD1->hide(); GroupD2->hide(); - if(constructorId == 1) { // Point - GroupPt->RB_Point1->setChecked(true); + if ( constructorId == 1 ) { + // Point + GroupPt->RB_Point1->setChecked( true ); GroupPt->show(); - this->PointClicked(1); // XY + PointClicked( 1 ); // XY } - else if(constructorId == 0) { // Direction - GroupD1->RB_Dir11->setChecked(true); + else if ( constructorId == 0 ) { + // Direction + GroupD1->RB_Dir11->setChecked( true ); GroupD1->show(); GroupD2->show(); - this->Dir1Clicked(2); // Angle + Dir1Clicked( 2 ); // Angle } - return; } @@ -348,46 +425,54 @@ void EntityGUI_SketcherDlg::DestClicked(int constructorId) // function : PointClicked() // purpose : Radio button management //================================================================================= -void EntityGUI_SketcherDlg::PointClicked(int constructorId) +void EntityGUI_SketcherDlg::PointClicked( int constructorId ) { - this->InitClick(); + InitClick(); - if(myConstructorId == 0) { // SEGMENT - if(constructorId == 1) { // XY + // Get setting of step value from file configuration + double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 ); + + if ( myConstructorId == 0 ) { // SEGMENT + if ( constructorId == 1 ) { // XY mySketchType = PT_ABS; - Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2")); - Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2")); + initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" ); + Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) ); + Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) ); myX = 0.0; - Group2Spin->SpinBox_DX->SetValue(myX); + Group2Spin->SpinBox_DX->setValue( myX ); myY = 0.0; - Group2Spin->SpinBox_DY->SetValue(myY); + Group2Spin->SpinBox_DY->setValue( myY ); Group2Spin->show(); Group2Spin->buttonApply->setFocus(); - this->MakeSimulationAndDisplay(); + + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); } - else if(constructorId == 0) { // DXDY + else if ( constructorId == 0 ) { // DXDY mySketchType = PT_RELATIVE; - Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_DX2")); - Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_DY2")); + initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" ); + Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) ); + Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) ); myDX = 0.0; - Group2Spin->SpinBox_DX->SetValue(myDX); + Group2Spin->SpinBox_DX->setValue( myDX ); myDY = 0.0; - Group2Spin->SpinBox_DY->SetValue(myDY); + Group2Spin->SpinBox_DY->setValue( myDY ); Group2Spin->show(); Group2Spin->buttonApply->setFocus(); - this->MakeSimulationAndDisplay(); + + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); } - else if(constructorId == 2) { // Selection + else if ( constructorId == 2 ) { // Selection mySketchType = PT_SEL; myEditCurrentArgument = Group1Sel->LineEdit1; - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect( myGeometryGUI->getApp()->selectionMgr(), + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); Group1Sel->show(); Group1Sel->buttonApply->setFocus(); - this->SelectionIntoArgument(); + SelectionIntoArgument(); } } - - return; } @@ -395,12 +480,11 @@ void EntityGUI_SketcherDlg::PointClicked(int constructorId) // function : Dir1Clicked() // purpose : Radio button management //================================================================================= -void EntityGUI_SketcherDlg::Dir1Clicked(int constructorId) +void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId ) { myConstructorDirId = constructorId; - GroupD2->RB_Dir21->setChecked(true); - this->Dir2Clicked(2); - return; + GroupD2->RB_Dir21->setChecked( true ); + Dir2Clicked( 2 ); } @@ -408,176 +492,185 @@ void EntityGUI_SketcherDlg::Dir1Clicked(int constructorId) // function : Dir2Clicked() // purpose : Radio button management //================================================================================= -void EntityGUI_SketcherDlg::Dir2Clicked(int constructorId) +void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId ) { - this->InitClick(); + InitClick(); myAngle = 0.0; - if(myConstructorId == 0) { // SEGMENT + // Get setting of step value from file configuration + double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 ); + + if ( myConstructorId == 0 ) { // SEGMENT myX = 0.0; myY = 0.0; myLength = 100.0; - if(myConstructorDirId == 2) { // Angle - Group2Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, 5., 3); - Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2")); - Group2Spin->SpinBox_DX->SetValue(myAngle); + if ( myConstructorDirId == 2 ) { // Angle + initSpinBox( Group2Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "length_precision" ); + Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) ); + Group2Spin->SpinBox_DX->setValue( myAngle ); Group2Spin->buttonApply->setFocus(); Group2Spin->show(); - if(constructorId == 2) { // Length - mySketchType = DIR_ANGLE_LENGTH; - Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_LENGTH2")); - Group2Spin->SpinBox_DY->SetValue(myLength); + if ( constructorId == 2 ) { // Length + mySketchType = DIR_ANGLE_LENGTH; + initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" ); + Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_LENGTH2" ) ); + Group2Spin->SpinBox_DY->setValue( myLength ); } - else if(constructorId == 0) { // X - mySketchType = DIR_ANGLE_X; - Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_X3")); - Group2Spin->SpinBox_DY->SetValue(myX); + else if ( constructorId == 0 ) { // X + mySketchType = DIR_ANGLE_X; + initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" ); + Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_X3" ) ); + Group2Spin->SpinBox_DY->setValue( myX ); } - else if(constructorId == 1) { // Y - mySketchType = DIR_ANGLE_Y; - Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y3")); - Group2Spin->SpinBox_DY->SetValue(myY); + else if ( constructorId == 1 ) { // Y + mySketchType = DIR_ANGLE_Y; + initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "angle_precision" ); + Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y3" ) ); + Group2Spin->SpinBox_DY->setValue( myY ); } } - else if(myConstructorDirId == 0) { // Perpendicular + else if ( myConstructorDirId == 0 ) { // Perpendicular Group1Spin->show(); Group1Spin->buttonApply->setFocus(); - if(constructorId == 2) { // Length - mySketchType = DIR_PER_LENGTH; - Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2")); - Group1Spin->SpinBox_DX->SetValue(myLength); + if ( constructorId == 2 ) { // Length + mySketchType = DIR_PER_LENGTH; + Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) ); + Group1Spin->SpinBox_DX->setValue( myLength ); } - else if(constructorId == 0) { // X - mySketchType = DIR_PER_X; - Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3")); - Group1Spin->SpinBox_DX->SetValue(myX); + else if ( constructorId == 0 ) { // X + mySketchType = DIR_PER_X; + Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) ); + Group1Spin->SpinBox_DX->setValue( myX ); } - else if(constructorId == 1) { // Y - mySketchType = DIR_PER_Y; - Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3")); - Group1Spin->SpinBox_DX->SetValue(myY); + else if ( constructorId == 1 ) { // Y + mySketchType = DIR_PER_Y; + Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) ); + Group1Spin->SpinBox_DX->setValue( myY ); } } - else if(myConstructorDirId == 1) { // Tangent + else if ( myConstructorDirId == 1 ) { // Tangent Group1Spin->show(); Group1Spin->buttonApply->setFocus(); - if(constructorId == 2) { // Length - mySketchType = DIR_TAN_LENGTH; - Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2")); - Group1Spin->SpinBox_DX->SetValue(myLength); + if ( constructorId == 2 ) { // Length + mySketchType = DIR_TAN_LENGTH; + Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_LENGTH2" ) ); + Group1Spin->SpinBox_DX->setValue( myLength ); } - else if(constructorId == 0) { // X - mySketchType = DIR_TAN_X; - Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3")); - Group1Spin->SpinBox_DX->SetValue(myX); + else if ( constructorId == 0 ) { // X + mySketchType = DIR_TAN_X; + Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X3" ) ); + Group1Spin->SpinBox_DX->setValue( myX ); } - else if(constructorId == 1) { // Y - mySketchType = DIR_TAN_Y; - Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3")); - Group1Spin->SpinBox_DX->SetValue(myY); + else if ( constructorId == 1 ) { // Y + mySketchType = DIR_TAN_Y; + Group1Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_Y3" ) ); + Group1Spin->SpinBox_DX->setValue( myY ); } } - else if(myConstructorDirId == 3) { // DXDY - Group3Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, 0.1, 3); - Group3Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, 0.1, 3); - Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2")); - Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2")); + else if ( myConstructorDirId == 3 ) { // DXDY + initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" ); + initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" ); + initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" ); + Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) ); + Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) ); myDX = 0.0; - Group3Spin->SpinBox_DX->SetValue(myDX); + Group3Spin->SpinBox_DX->setValue( myDX ); myDY = 0.0; - Group3Spin->SpinBox_DY->SetValue(myDY); + Group3Spin->SpinBox_DY->setValue( myDY ); Group3Spin->show(); Group3Spin->buttonApply->setFocus(); - if(constructorId == 2) { // Length - mySketchType = DIR_DXDY_LENGTH; - Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_LENGTH2")); - Group3Spin->SpinBox_DZ->SetValue(myLength); + if ( constructorId == 2 ) { // Length + mySketchType = DIR_DXDY_LENGTH; + Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_LENGTH2" ) ); + Group3Spin->SpinBox_DZ->setValue( myLength ); } - else if(constructorId == 0) { // X - mySketchType = DIR_DXDY_X; - Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_X3")); - Group3Spin->SpinBox_DZ->SetValue(myX); + else if ( constructorId == 0 ) { // X + mySketchType = DIR_DXDY_X; + Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_X3" ) ); + Group3Spin->SpinBox_DZ->setValue( myX ); } - else if(constructorId == 1) { // Y - mySketchType = DIR_DXDY_Y; - Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Y3")); - Group3Spin->SpinBox_DZ->SetValue(myY); + else if ( constructorId == 1 ) { // Y + mySketchType = DIR_DXDY_Y; + Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Y3" ) ); + Group3Spin->SpinBox_DZ->setValue( myY ); } } } - else if(myConstructorId == 1) { // ARC - if(myConstructorDirId == 2) { // Angle - if(constructorId == 2) { // Length - mySketchType = DIR_ANGLE_LENGTH; - Group3Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, 5., 3); - Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, 5., 3); - Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2")); - Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_RADIUS2")); - Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_ANGLE2")); - Group3Spin->SpinBox_DX->SetValue(myAngle); - myRadius = 100.0; - Group3Spin->SpinBox_DY->SetValue(myRadius); - myLength = 30.0; - Group3Spin->SpinBox_DZ->SetValue(myLength); - Group3Spin->show(); - Group3Spin->buttonApply->setFocus(); + else if ( myConstructorId == 1 ) { // ARC + if ( myConstructorDirId == 2 ) { // Angle + if ( constructorId == 2 ) { // Length + mySketchType = DIR_ANGLE_LENGTH; + initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 5., "angle_precision" ); + initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, 5., "angle_precision" ); + Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_ANGLE2" ) ); + Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) ); + Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" )); + Group3Spin->SpinBox_DX->setValue( myAngle ); + myRadius = 100.0; + Group3Spin->SpinBox_DY->setValue( myRadius ); + myLength = 30.0; + Group3Spin->SpinBox_DZ->setValue( myLength ); + Group3Spin->show(); + Group3Spin->buttonApply->setFocus(); } } - else if(myConstructorDirId == 0) { // Perpendicular - if(constructorId == 2) { // Length - mySketchType = DIR_PER_LENGTH; - Group2Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, 5., 3); - Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2")); - Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2")); - myRadius = 100.0; - Group2Spin->SpinBox_DX->SetValue(myRadius); - myLength = 30.0; - Group2Spin->SpinBox_DY->SetValue(myLength); - Group2Spin->show(); - Group2Spin->buttonApply->setFocus(); + else if ( myConstructorDirId == 0 ) { // Perpendicular + if ( constructorId == 2 ) { // Length + mySketchType = DIR_PER_LENGTH; + initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" ); + Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) ); + Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) ); + myRadius = 100.0; + Group2Spin->SpinBox_DX->setValue( myRadius ); + myLength = 30.0; + Group2Spin->SpinBox_DY->setValue( myLength ); + Group2Spin->show(); + Group2Spin->buttonApply->setFocus(); } } - else if(myConstructorDirId == 1) { // Tangent - if(constructorId == 2) { // Length - mySketchType = DIR_TAN_LENGTH; - Group2Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, 5., 3); - Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2")); - Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2")); - myRadius = 100.0; - Group2Spin->SpinBox_DX->SetValue(myRadius); - myLength = 30.0; - Group2Spin->SpinBox_DY->SetValue(myLength); - Group2Spin->show(); - Group2Spin->buttonApply->setFocus(); + else if ( myConstructorDirId == 1 ) { // Tangent + if ( constructorId == 2 ) { // Length + mySketchType = DIR_TAN_LENGTH; + initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" ); + Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) ); + Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) ); + myRadius = 100.0; + Group2Spin->SpinBox_DX->setValue( myRadius ); + myLength = 30.0; + Group2Spin->SpinBox_DY->setValue( myLength ); + Group2Spin->show(); + Group2Spin->buttonApply->setFocus(); } } - else if(myConstructorDirId == 3) { // DXDY - if(constructorId == 2) { // Length - mySketchType = DIR_DXDY_LENGTH; - Group4Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2")); - Group4Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2")); - Group4Spin->TextLabel3->setText(tr("GEOM_SKETCHER_RADIUS2")); - Group4Spin->TextLabel4->setText(tr("GEOM_SKETCHER_ANGLE2")); - myDX = 0.0; - Group4Spin->SpinBox_DX->SetValue(myDX); - myDY = 0.0; - Group4Spin->SpinBox_DY->SetValue(myDY); - myRadius = 100.0; - Group4Spin->SpinBox_DZ->SetValue(myRadius); - myLength = 30.0; - Group4Spin->SpinBox_DS->SetValue(myLength); - Group4Spin->show(); - Group4Spin->buttonApply->setFocus(); + else if ( myConstructorDirId == 3 ) { // DXDY + if ( constructorId == 2 ) { // Length + mySketchType = DIR_DXDY_LENGTH; + Group4Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) ); + Group4Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) ); + Group4Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_RADIUS2" ) ); + Group4Spin->TextLabel4->setText( tr( "GEOM_SKETCHER_ANGLE2" ) ); + myDX = 0.0; + Group4Spin->SpinBox_DX->setValue( myDX ); + myDY = 0.0; + Group4Spin->SpinBox_DY->setValue( myDY ); + myRadius = 100.0; + Group4Spin->SpinBox_DZ->setValue( myRadius ); + myLength = 30.0; + Group4Spin->SpinBox_DS->setValue( myLength ); + Group4Spin->show(); + Group4Spin->buttonApply->setFocus(); } } } - this->MakeSimulationAndDisplay(); - return; + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); } @@ -587,88 +680,128 @@ void EntityGUI_SketcherDlg::Dir2Clicked(int constructorId) //================================================================================= void EntityGUI_SketcherDlg::ClickOnCancel() { - QAD_Application::getDesktop()->putInfo(tr("")); - myEntityGUI->EraseSimulationShape(); - mySimulationTopoDs1.Nullify(); - mySimulationTopoDs2.Nullify(); - - mySelection->ClearFilters(); - disconnect(mySelection, 0, this, 0); - - reject(); - return; + close(); } //================================================================================= // function : ClickOnEnd() -// purpose : +// purpose : connected to buttonEnd AND buttonClose //================================================================================= void EntityGUI_SketcherDlg::ClickOnEnd() { - if(mySketchState != FIRST_POINT && mySketchState != SECOND_POINT) - myEntityGUI->OnSketchEnd(myCommand.ascii()); + if ( sender() == MainWidget->buttonClose ) { + // Verify validity of commands + if ( myCommand.count() <= 2 ) { + SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), + tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) ); + return; + } - this->ClickOnCancel(); - return; -} + QString Parameters; + QString Command = myCommand.join( "" ) + GetNewCommand( Parameters ); + Sketcher_Profile aProfile( Command.toAscii() ); + Command = myCommand.join( "" ); + aProfile = Sketcher_Profile( Command.toAscii() ); + TopoDS_Shape myShape; + if ( aProfile.IsDone() ) + myShape = aProfile.GetShape(); -//================================================================================= -// function : ClickOnClose() -// purpose : -//================================================================================= -void EntityGUI_SketcherDlg::ClickOnClose() -{ - if(mySketchState != FIRST_POINT && mySketchState != SECOND_POINT) { - myCommand = myCommand + ":WW"; - myEntityGUI->OnSketchEnd(myCommand.ascii()); + if ( myShape.ShapeType() != TopAbs_VERTEX ) + myCommand.append( ":WW" ); + } + else { + // PAL16008 (Sketcher Validation should be equal to Apply&Close) + if ( Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() || + Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() || + Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() || + Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() || + Group1Sel ->buttonApply->isEnabled() && Group1Sel->isVisible() ) { + ClickOnApply(); + } + myIsAllAdded = true; } - this->ClickOnCancel(); - return; -} + if ( myCommand.size() > 2 ) + if ( !onAccept() ) + return; + close(); +} //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= -void EntityGUI_SketcherDlg::ClickOnApply() +bool EntityGUI_SketcherDlg::ClickOnApply() { - if(mySketchState == FIRST_POINT) { - mySketchState = SECOND_POINT; - myLastX2 = myLastX1; - myLastY2 = myLastY1; - } - else { - if(mySketchState != SECOND_POINT) { - Group1Sel->buttonUndo->setEnabled(true); - Group1Spin->buttonUndo->setEnabled(true); - Group2Spin->buttonUndo->setEnabled(true); - Group3Spin->buttonUndo->setEnabled(true); - Group4Spin->buttonUndo->setEnabled(true); - } + if ( sender() && sender()->inherits( "QPushButton" ) ) + ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948) - QString myNewCommand = this->GetNewCommand(); - QString myCommandTemp = myCommand + myNewCommand; + QString aParameters; + myCommand.append( GetNewCommand( aParameters ) ); + mySketchState = NEXT_POINT; - Sketcher_Profile aProfile (myCommandTemp.ascii()); + myUndoCommand.clear(); + myUndoCommand.append( "Sketcher" ); - if(aProfile.IsDone()) { - myLastCommand = myCommand; - myCommand = myCommandTemp; - myLastX2 = myLastX1; - myLastY2 = myLastY1; - mySketchState = NEXT_POINT; - } + myParameters.append( aParameters ); + myUndoParameters.clear(); + + MainWidget->GroupConstructors->setEnabled( true ); + MainWidget->GroupDest1->setEnabled( true ); + setEnabledUndo( true ); + setEnabledRedo( false ); + + myIsApply = true; + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); + myIsApply = false; + + // Set focus to SpinBox_DX + if ( sender() == Group1Spin->buttonApply ) { + (Group1Spin->SpinBox_DX)->setFocus(); + (Group1Spin->SpinBox_DX)->selectAll(); + } + else if ( sender() == Group2Spin->buttonApply ) { + (Group2Spin->SpinBox_DX)->setFocus(); + (Group2Spin->SpinBox_DX)->selectAll(); + } + else if ( sender() == Group3Spin->buttonApply ) { + (Group3Spin->SpinBox_DX)->setFocus(); + (Group3Spin->SpinBox_DX)->selectAll(); + } + else if ( sender() == Group4Spin->buttonApply ) { + (Group4Spin->SpinBox_DX)->setFocus(); + (Group4Spin->SpinBox_DX)->selectAll(); } - myLastOp = myConstructorId; - this->MakeSimulationAndDisplay(); - return; + return true; } +//================================================================================= +// function : ClickOnHelp() +// purpose : +//================================================================================= +void EntityGUI_SketcherDlg::ClickOnHelp() +{ + LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() ); + if ( app ) + app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), myHelpFileName ); + else { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + + SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ), + QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ). + arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ), + QObject::tr( "BUT_OK" ) ); + } +} //================================================================================= // function : ClickOnUndo() @@ -676,58 +809,117 @@ void EntityGUI_SketcherDlg::ClickOnApply() //================================================================================= void EntityGUI_SketcherDlg::ClickOnUndo() { - Group1Sel->buttonUndo->setEnabled(false); - Group1Spin->buttonUndo->setEnabled(false); - Group2Spin->buttonUndo->setEnabled(false); - Group3Spin->buttonUndo->setEnabled(false); - Group4Spin->buttonUndo->setEnabled(false); - - myCommand = myLastCommand; - this->MakeSimulationAndDisplay(); - return; -} + myUndoCommand.append( myCommand.last() ); + myCommand.pop_back(); + + myUndoParameters.append( myParameters.last() ); + myParameters.pop_back(); + + if ( myCommand.count() == 1 ) { + mySketchState = FIRST_POINT; + + MainWidget->RadioButton1->setChecked( true ); + TypeClicked( 0 ); + + MainWidget->GroupConstructors->setEnabled( false ); + MainWidget->GroupDest1->setEnabled( false ); + setEnabledUndo( false ); + } + setEnabledRedo( true ); + + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); +} //================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed +// function : ClickOnRedo() +// purpose : //================================================================================= -void EntityGUI_SketcherDlg::SelectionIntoArgument() +void EntityGUI_SketcherDlg::ClickOnRedo() { - myEntityGUI->EraseSimulationShape(1); //Juste Shape2!! + myCommand.append( myUndoCommand.last() ); + myUndoCommand.pop_back(); - Group1Sel->buttonApply->setEnabled(false); - Group1Sel->buttonApply->setFocus(); + myParameters.append( myUndoParameters.last() ); + myUndoParameters.pop_back(); - myEditCurrentArgument->setText(""); - QString aString = ""; + mySketchState = NEXT_POINT; - myX = 0.0; - myY = 0.0; + MainWidget->GroupConstructors->setEnabled( true ); + MainWidget->GroupDest1->setEnabled( true ); + setEnabledUndo( true ); - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) - return; + if ( myUndoCommand.count() == 1 ) + setEnabledRedo( false ); - /* nbSel == 1 */ - TopoDS_Shape S; - gp_Pnt myPoint1; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); +} - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; +//================================================================================= +// function : setEnabledUndo() +// purpose : +//================================================================================= +void EntityGUI_SketcherDlg::setEnabledUndo( bool value ) +{ + Group1Sel->buttonUndo->setEnabled( value ); + Group1Spin->buttonUndo->setEnabled( value ); + Group2Spin->buttonUndo->setEnabled( value ); + Group3Spin->buttonUndo->setEnabled( value ); + Group4Spin->buttonUndo->setEnabled( value ); +} - if(myEditCurrentArgument == Group1Sel->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - myX = myPoint1.X(); - myY = myPoint1.Y(); - Group1Sel->LineEdit1->setText(aString); +//================================================================================= +// function : setEnabledRedo() +// purpose : +//================================================================================= +void EntityGUI_SketcherDlg::setEnabledRedo( bool value ) +{ + Group1Sel->buttonRedo->setEnabled( value ); + Group1Spin->buttonRedo->setEnabled( value ); + Group2Spin->buttonRedo->setEnabled( value ); + Group3Spin->buttonRedo->setEnabled( value ); + Group4Spin->buttonRedo->setEnabled( value ); +} - Group1Sel->buttonApply->setEnabled(true); - Group1Sel->buttonApply->setFocus(); - this->MakeSimulationAndDisplay(); +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed +//================================================================================= +void EntityGUI_SketcherDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText( "" ); + myX = myLastX1; + myY = myLastY1; + + LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + int nbSel = aSelList.Extent(); + if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) { + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes); + if (!CORBA::is_nil(aSelectedObject) && aRes) { + TopoDS_Shape aShape; + if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) { + gp_Trsf aTrans; + gp_Ax3 aWPlane = GetActiveLocalCS(); + + aTrans.SetTransformation(aWPlane); + BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False); + aShape = aTransformation.Shape(); + + gp_Pnt aPnt; + if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) { + myX = aPnt.X(); + myY = aPnt.Y(); + Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) ); + } + } + } } - return; + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); } @@ -737,16 +929,11 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument() //================================================================================= void EntityGUI_SketcherDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); - - mySelection->ClearFilters(); - if(send == Group1Sel->PushButton1) { - //Group1Sel->LineEdit1->setFocus(); + if ( sender() == Group1Sel->PushButton1 ) { myEditCurrentArgument = Group1Sel->LineEdit1; + myEditCurrentArgument->setFocus(); } - mySelection->AddFilter(myVertexFilter); - this->SelectionIntoArgument(); - return; + SelectionIntoArgument(); } @@ -756,15 +943,22 @@ void EntityGUI_SketcherDlg::SetEditCurrentArgument() //================================================================================= void EntityGUI_SketcherDlg::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(myGeomBase->SelectionByNameInDialogs(thisWidget, objectUserName, mySelection)) - myEditCurrentArgument->setText(objectUserName); - - return; + if ( sender() == Group1Sel->LineEdit1 ) { + myEditCurrentArgument = Group1Sel->LineEdit1; + + /* 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; + + LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + if (GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, aSelList)) + myEditCurrentArgument->setText( objectUserName ); + } } @@ -774,12 +968,12 @@ void EntityGUI_SketcherDlg::LineEditReturnPressed() //================================================================================= void EntityGUI_SketcherDlg::DeactivateActiveDialog() { - this->setEnabled(false); - mySelection->ClearFilters(); - disconnect(mySelection, 0, this, 0); - myEntityGUI->EraseSimulationShape(); - myGeomGUI->SetActiveDialogBox(0); - return; + //myGeometryGUI->SetState( -1 ); + + setEnabled( false ); + globalSelection(); + disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 ); + myGeometryGUI->SetActiveDialogBox( 0 ); } @@ -789,15 +983,20 @@ void EntityGUI_SketcherDlg::DeactivateActiveDialog() //================================================================================= void EntityGUI_SketcherDlg::ActivateThisDialog() { - /* Emit a signal to deactivate the active dialog */ - myGeomGUI->EmitSignalDeactivateDialog(); - this->setEnabled(true); - myGeomGUI->SetActiveDialogBox((QDialog*)this); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - mySelection->AddFilter(myVertexFilter); - myEntityGUI->DisplaySimulationShape(mySimulationTopoDs1, mySimulationTopoDs2); - - return; + myGeometryGUI->EmitSignalDeactivateDialog(); + setEnabled( true ); + myGeometryGUI->SetActiveDialogBox( this ); + + connect( myGeometryGUI->getApp()->selectionMgr(), + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + //myGeometryGUI->SetState( 0 ); + globalSelection( GEOM_POINT ); + + myEditCurrentArgument = Group1Sel->LineEdit1; + myEditCurrentArgument->setFocus(); + + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); } @@ -805,12 +1004,10 @@ void EntityGUI_SketcherDlg::ActivateThisDialog() // function : enterEvent [REDEFINED] // purpose : //================================================================================= -void EntityGUI_SketcherDlg::enterEvent(QEvent* e) +void EntityGUI_SketcherDlg::enterEvent( QEvent* ) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !MainWidget->GroupConstructors->isEnabled() ) + ActivateThisDialog(); } @@ -818,11 +1015,12 @@ void EntityGUI_SketcherDlg::enterEvent(QEvent* e) // function : closeEvent() // purpose : //================================================================================= -void EntityGUI_SketcherDlg::closeEvent(QCloseEvent* e) +void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e ) { - /* same than click on cancel button */ - this->ClickOnCancel(); - return; + //myGeometryGUI->SetState( -1 ); + disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 ); + myGeometryGUI->getApp()->updateActions(); + QDialog::closeEvent( e ); } @@ -830,339 +1028,709 @@ void EntityGUI_SketcherDlg::closeEvent(QCloseEvent* e) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void EntityGUI_SketcherDlg::ValueChangedInSpinBox(double newValue) +void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue ) { QObject* send = (QObject*)sender(); Standard_Real vx, vy, vz, vs; vx = vy = vz = vs = 0.0; - if(send == Group1Spin->SpinBox_DX) { - vx = newValue; - Group1Spin->buttonApply->setFocus(); + QString vxStr, vyStr, vzStr, vsStr; + + QString newValueStr; + if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = (SalomeApp_DoubleSpinBox*)send ) + newValueStr = aDoubleSpinBox->text(); + + if ( send == Group1Spin->SpinBox_DX ) { + vx = newValue; vxStr = newValueStr; } - else if(send == Group2Spin->SpinBox_DX) { - vx = newValue; - vy = Group2Spin->SpinBox_DY->GetValue(); - Group2Spin->buttonApply->setFocus(); + else if ( send == Group2Spin->SpinBox_DX ) { + vx = newValue; vxStr = newValueStr; + vy = Group2Spin->SpinBox_DY->value(); vyStr = Group2Spin->SpinBox_DY->text(); } - else if(send == Group2Spin->SpinBox_DY) { - vx = Group2Spin->SpinBox_DX->GetValue(); - vy = newValue; - Group2Spin->buttonApply->setFocus(); + else if ( send == Group2Spin->SpinBox_DY ) { + vx = Group2Spin->SpinBox_DX->value(); vxStr = Group2Spin->SpinBox_DX->text(); + vy = newValue; vyStr = newValueStr; } - else if(send == Group3Spin->SpinBox_DX) { - vx = newValue; - vy = Group3Spin->SpinBox_DY->GetValue(); - vz = Group3Spin->SpinBox_DZ->GetValue(); - Group3Spin->buttonApply->setFocus(); + else if ( send == Group3Spin->SpinBox_DX ) { + vx = newValue; vxStr = newValueStr; + vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text(); + vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text(); } - else if(send == Group3Spin->SpinBox_DY) { - vx = Group3Spin->SpinBox_DX->GetValue(); - vy = newValue; - vz = Group3Spin->SpinBox_DZ->GetValue(); - Group3Spin->buttonApply->setFocus(); + else if ( send == Group3Spin->SpinBox_DY ) { + vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text(); + vy = newValue; vyStr = newValueStr; + vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text(); } - else if(send == Group3Spin->SpinBox_DZ) { - vx = Group3Spin->SpinBox_DX->GetValue(); - vy = Group3Spin->SpinBox_DY->GetValue(); - vz = newValue; - Group3Spin->buttonApply->setFocus(); + else if ( send == Group3Spin->SpinBox_DZ ) { + vx = Group3Spin->SpinBox_DX->value(); vxStr = Group3Spin->SpinBox_DX->text(); + vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text(); + vz = newValue; vzStr = newValueStr; } - else if(send == Group4Spin->SpinBox_DX) { - vx = newValue; - vy = Group4Spin->SpinBox_DY->GetValue(); - vz = Group4Spin->SpinBox_DZ->GetValue(); - vs = Group4Spin->SpinBox_DS->GetValue(); - Group4Spin->buttonApply->setFocus(); + else if ( send == Group4Spin->SpinBox_DX ) { + vx = newValue; vxStr = newValueStr; + vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text(); + vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text(); + vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text(); } - else if(send == Group4Spin->SpinBox_DY) { - vx = Group4Spin->SpinBox_DX->GetValue(); - vy = newValue; - vz = Group4Spin->SpinBox_DZ->GetValue(); - vs = Group4Spin->SpinBox_DS->GetValue(); - Group4Spin->buttonApply->setFocus(); + else if ( send == Group4Spin->SpinBox_DY ) { + vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text(); + vy = newValue; vyStr = newValueStr; + vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text(); + vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text(); } - else if(send == Group4Spin->SpinBox_DZ) { - vx = Group4Spin->SpinBox_DX->GetValue(); - vy = Group4Spin->SpinBox_DY->GetValue(); - vz = newValue; - vs = Group4Spin->SpinBox_DS->GetValue(); - Group4Spin->buttonApply->setFocus(); + else if ( send == Group4Spin->SpinBox_DZ ) { + vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text(); + vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text(); + vz = newValue; vzStr = newValueStr; + vs = Group4Spin->SpinBox_DS->value(); vsStr = Group4Spin->SpinBox_DS->text(); } - else if(send == Group4Spin->SpinBox_DS) { - vx = Group4Spin->SpinBox_DX->GetValue(); - vy = Group4Spin->SpinBox_DY->GetValue(); - vz = Group4Spin->SpinBox_DZ->GetValue(); - vs = newValue; - Group4Spin->buttonApply->setFocus(); + else if ( send == Group4Spin->SpinBox_DS ) { + vx = Group4Spin->SpinBox_DX->value(); vxStr = Group4Spin->SpinBox_DX->text(); + vy = Group4Spin->SpinBox_DY->value(); vyStr = Group4Spin->SpinBox_DY->text(); + vz = Group4Spin->SpinBox_DZ->value(); vzStr = Group4Spin->SpinBox_DZ->text(); + vs = newValue; vsStr = newValueStr; } + // Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x - if(myConstructorId == 0) { // SEGMENT - if(mySketchType == PT_ABS) { + if ( myConstructorId == 0 ) { // SEGMENT + if ( mySketchType == PT_ABS ) { myX = vx; myY = vy; + myXStr = vxStr; + myYStr = vyStr; } - else if(mySketchType == PT_RELATIVE) { + else if ( mySketchType == PT_RELATIVE ) { myDX = vx; myDY = vy; + myDXStr = vxStr; + myDYStr = vyStr; } - else if(mySketchType == DIR_ANGLE_LENGTH) { + else if ( mySketchType == DIR_ANGLE_LENGTH ) { myAngle = vx; myLength = vy; + myAngleStr = vxStr; + myLengthStr = vyStr; } - else if(mySketchType == DIR_ANGLE_X) { + else if ( mySketchType == DIR_ANGLE_X ) { myAngle = vx; myX = vy; + myAngleStr = vxStr; + myXStr = vyStr; } - else if(mySketchType == DIR_ANGLE_Y) { + else if ( mySketchType == DIR_ANGLE_Y ) { myAngle = vx; myY = vy; + myAngleStr = vxStr; + myYStr = vyStr; } - else if(mySketchType == DIR_PER_LENGTH) { + else if ( mySketchType == DIR_PER_LENGTH ) { myLength = vx; + myLengthStr = vxStr; } - else if(mySketchType == DIR_PER_X) { + else if ( mySketchType == DIR_PER_X ) { myX = vx; + myXStr = vxStr; } - else if(mySketchType == DIR_PER_Y) { + else if ( mySketchType == DIR_PER_Y ) { myY = vx; + myYStr = vxStr; } - else if(mySketchType == DIR_TAN_LENGTH) { + else if ( mySketchType == DIR_TAN_LENGTH ) { myLength = vx; + myLengthStr = vxStr; } - else if(mySketchType == DIR_TAN_X) { + else if ( mySketchType == DIR_TAN_X ) { myX = vx; + myXStr = vxStr; } - else if(mySketchType == DIR_TAN_Y) { + else if ( mySketchType == DIR_TAN_Y ) { myY = vx; + myYStr = vxStr; } - else if(mySketchType == DIR_DXDY_LENGTH) { + else if ( mySketchType == DIR_DXDY_LENGTH ) { myDX = vx; myDY = vy; myLength = vz; + myDXStr = vxStr; + myDYStr = vyStr; + myLengthStr = vzStr; } - else if(mySketchType == DIR_DXDY_X) { + else if ( mySketchType == DIR_DXDY_X ) { myDX = vx; myDY = vy; myX = vz; + myDXStr = vxStr; + myDYStr = vyStr; + myXStr = vzStr; } - else if(mySketchType == DIR_DXDY_Y) { + else if ( mySketchType == DIR_DXDY_Y ) { myDX = vx; myDY = vy; myY = vz; + myDXStr = vxStr; + myDYStr = vyStr; + myYStr = vzStr; } } - else if(myConstructorId == 1) { // ARC - if(mySketchType == DIR_ANGLE_LENGTH) { + else if ( myConstructorId == 1 ) { // ARC + if ( mySketchType == DIR_ANGLE_LENGTH ) { myAngle = vx; myRadius = vy; myLength = vz; + myAngleStr = vxStr; + myRadiusStr = vyStr; + myLengthStr = vzStr; } - else if(mySketchType == DIR_PER_LENGTH) { + else if ( mySketchType == DIR_PER_LENGTH ) { myRadius = vx; myLength = vy; + myRadiusStr = vxStr; + myLengthStr = vyStr; } - else if(mySketchType == DIR_TAN_LENGTH) { + else if ( mySketchType == DIR_TAN_LENGTH ) { myRadius = vx; myLength = vy; + myRadiusStr = vxStr; + myLengthStr = vyStr; } - else if(mySketchType == DIR_DXDY_LENGTH) { + else if ( mySketchType == DIR_DXDY_LENGTH ) { myDX = vx; myDY = vy; myRadius = vz; myLength = vs; + myDXStr = vxStr; + myDYStr = vyStr; + myRadiusStr = vzStr; + myLengthStr = vsStr; } } - this->MakeSimulationAndDisplay(); - return; + GEOMBase_Helper::displayPreview( false, true, true, myLineWidth ); } //================================================================================= // function : GetNewCommand() -// purpose : +// purpose : Build the new command with context //================================================================================= -QString EntityGUI_SketcherDlg::GetNewCommand() +QString EntityGUI_SketcherDlg::GetNewCommand( QString& theParameters ) { - QString myNewCommand = ""; - if(mySketchState == FIRST_POINT) + theParameters.clear(); + QString myNewCommand = ":"; + if ( mySketchState == FIRST_POINT ) { + if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) { + myNewCommand = myNewCommand + "F " + QString::number( myX ) + " " + QString::number( myY ); + theParameters = myXStr + ":" + myYStr; + } + if ( mySketchType == PT_RELATIVE) { + myNewCommand = myNewCommand + "F " + QString::number( myDX ) + " " + QString::number( myDY ); + theParameters = myDXStr + ":" + myDYStr; + } return myNewCommand; + } - myNewCommand = ":"; - if(myConstructorId == 0) { // SEGMENT - if(mySketchType == PT_ABS || mySketchType == PT_SEL) - myNewCommand = myNewCommand + "TT " + QString::number(myX) + " " + QString::number(myY); - if(mySketchType == PT_RELATIVE) - myNewCommand = myNewCommand + "T " + QString::number(myDX) + " " + QString::number(myDY); - if(mySketchType == DIR_ANGLE_LENGTH) { - myNewCommand = myNewCommand + "R " + QString::number(myAngle); - myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength); - } - if(mySketchType == DIR_ANGLE_X) { - myNewCommand = myNewCommand + "R " + QString::number(myAngle); - myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX); - } - if(mySketchType == DIR_ANGLE_Y) { - myNewCommand = myNewCommand + "R " + QString::number(myAngle); - myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY); - } - if(mySketchType == DIR_PER_LENGTH) { - myNewCommand = myNewCommand + "R " + QString::number(90.0); - myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength); - } - if(mySketchType == DIR_PER_X) { - myNewCommand = myNewCommand + "R " + QString::number(90.0); - myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX); - } - if(mySketchType == DIR_PER_Y) { - myNewCommand = myNewCommand + "R " + QString::number(90.0); - myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY); - } - if(mySketchType == DIR_TAN_LENGTH) - myNewCommand = myNewCommand + "L " + QString::number(myLength); - if(mySketchType == DIR_TAN_X) - myNewCommand = myNewCommand + "IX " + QString::number(myX); - if(mySketchType == DIR_TAN_Y) + if ( myConstructorId == 0 ) { // SEGMENT + if ( mySketchType == PT_ABS || mySketchType == PT_SEL ) { + myNewCommand = myNewCommand + "TT " + QString::number( myX ) + " " + QString::number( myY ); + theParameters = myXStr + ":" + myYStr; + } + if ( mySketchType == PT_RELATIVE) { + myNewCommand = myNewCommand + "T " + QString::number( myDX ) + " " + QString::number( myDY ); + theParameters = myDXStr + ":" + myDYStr; + } + if ( mySketchType == DIR_ANGLE_LENGTH ) { + myNewCommand = myNewCommand + "R " + QString::number( myAngle ); + myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength ); + theParameters = myAngleStr + ":" + myLengthStr; + } + if ( mySketchType == DIR_ANGLE_X ) { + myNewCommand = myNewCommand + "R " + QString::number( myAngle ); + myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX ); + theParameters = myAngleStr + ":" + myXStr; + } + if ( mySketchType == DIR_ANGLE_Y ) { + myNewCommand = myNewCommand + "R " + QString::number( myAngle ); + myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY ); + theParameters = myAngleStr + ":" + myYStr; + } + if ( mySketchType == DIR_PER_LENGTH ) { + myNewCommand = myNewCommand + "R " + QString::number( 90.0 ); + myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength ); + theParameters = QString::number( 90.0 ) + ":" + myLengthStr; + } + if ( mySketchType == DIR_PER_X ) { + myNewCommand = myNewCommand + "R " + QString::number( 90.0 ); + myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX ); + theParameters = QString::number( 90.0 ) + ":" + myXStr; + } + if ( mySketchType == DIR_PER_Y ) { + myNewCommand = myNewCommand + "R " + QString::number( 90.0 ); + myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY ); + theParameters = QString::number( 90.0 ) + ":" + myYStr; + } + if ( mySketchType == DIR_TAN_LENGTH ) { + myNewCommand = myNewCommand + "L " + QString::number( myLength ); + theParameters = myLengthStr; + } + if ( mySketchType == DIR_TAN_X ) { + myNewCommand = myNewCommand + "IX " + QString::number( myX ); + theParameters = myXStr; + } + if ( mySketchType == DIR_TAN_Y) { myNewCommand = myNewCommand + "IY " + QString::number(myY); - if(mySketchType == DIR_DXDY_LENGTH) { - myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY); - myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength); + theParameters = myYStr; + } + if ( mySketchType == DIR_DXDY_LENGTH ) { + myNewCommand = myNewCommand + "D " + QString::number( myDX ) + " " + QString::number( myDY ); + myNewCommand = myNewCommand + ":" + "L " + QString::number( myLength ); + theParameters = myDXStr + ":" + myDYStr + ":" + myLengthStr; } - if(mySketchType == DIR_DXDY_X) { - myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY); - myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX); + if ( mySketchType == DIR_DXDY_X ) { + myNewCommand = myNewCommand + "D " + QString::number( myDX ) + " " + QString::number( myDY ); + myNewCommand = myNewCommand + ":" + "IX " + QString::number( myX ); + theParameters = myDXStr + ":" + myDYStr + ":" + myXStr; } - if(mySketchType == DIR_DXDY_Y) { - myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY); - myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY); + if ( mySketchType == DIR_DXDY_Y ) { + myNewCommand = myNewCommand + "D " + QString::number( myDX ) + " " + QString::number( myDY ); + myNewCommand = myNewCommand + ":" + "IY " + QString::number( myY ); + theParameters = myDXStr + ":" + myDYStr + ":" + myYStr; } } - else if(myConstructorId == 1) { // ARC - if(mySketchType == DIR_ANGLE_LENGTH) { - myNewCommand = myNewCommand + "R " + QString::number(myAngle); - myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength); + else if ( myConstructorId == 1 ) { // ARC + if ( mySketchType == DIR_ANGLE_LENGTH ) { + myNewCommand = myNewCommand + "R " + QString::number( myAngle ); + myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius ) + " " + QString::number( myLength ); + theParameters = myAngleStr + ":" + myRadiusStr + ":" + myLengthStr; } - if(mySketchType == DIR_PER_LENGTH) { - myNewCommand = myNewCommand + "R " + QString::number(90.0); - myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength); + if ( mySketchType == DIR_PER_LENGTH ) { + myNewCommand = myNewCommand + "R " + QString::number( 90.0 ); + myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius ) + " " + QString::number( myLength ); + theParameters = QString::number( 90.0 ) + ":" + myRadiusStr + ":" + myLengthStr; } - if(mySketchType == DIR_TAN_LENGTH) { - myNewCommand = myNewCommand + "C " + QString::number(myRadius) + " " + QString::number(myLength); + if ( mySketchType == DIR_TAN_LENGTH ) { + myNewCommand = myNewCommand + "C " + QString::number( myRadius ) + " " + QString::number( myLength ); + theParameters = myRadiusStr + ":" + myLengthStr; } - if(mySketchType == DIR_DXDY_LENGTH) { - myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY); - myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength); + if ( mySketchType == DIR_DXDY_LENGTH ) { + myNewCommand = myNewCommand + "D " + QString::number( myDX ) + " " + QString::number( myDY ); + myNewCommand = myNewCommand + ":" + "C " + QString::number( myRadius ) + " " + QString::number( myLength ); + theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr; } } return myNewCommand; } +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation() +{ + return getGeomEngine()->GetICurvesOperations( getStudyId() ); +} //================================================================================= -// function : MakeSimulationAndDisplay() +// function : isValid // purpose : //================================================================================= -void EntityGUI_SketcherDlg::MakeSimulationAndDisplay() +bool EntityGUI_SketcherDlg::isValid( QString& msg ) { - myEntityGUI->EraseSimulationShape(); - mySimulationTopoDs1.Nullify(); - mySimulationTopoDs2.Nullify(); - - try { - if(mySketchState == FIRST_POINT) { - myCommand = "Sketch "; - myCommand = myCommand + ":" + "F " + QString::number(myX) + " " + QString::number(myY); + bool ok = true; + bool toCorrect = !IsPreview() || myIsApply; - myLastX1 = myX; - myLastY1 = myY; + if( Group1Spin->isVisible() ) { + ok = Group1Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok; + } + else if( Group2Spin->isVisible() ) { + ok = Group2Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok; + ok = Group2Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok; + } + else if( Group3Spin->isVisible() ) { + ok = Group3Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok; + ok = Group3Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok; + ok = Group3Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok; + } + else if( Group4Spin->isVisible() ) { + ok = Group4Spin->SpinBox_DX->isValid( msg, toCorrect ) && ok; + ok = Group4Spin->SpinBox_DY->isValid( msg, toCorrect ) && ok; + ok = Group4Spin->SpinBox_DZ->isValid( msg, toCorrect ) && ok; + ok = Group4Spin->SpinBox_DS->isValid( msg, toCorrect ) && ok; + } - } + if( myIsApply && !ok ) + showError( msg ); - Sketcher_Profile aProfile1 (myCommand.ascii()); + return ok; +} - if(aProfile1.IsDone()) { - myShape = aProfile1.GetShape(); - mySimulationTopoDs1 = myShape; - } +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool EntityGUI_SketcherDlg::execute( ObjectList& objects ) +{ + QString aParameters; - if(mySketchState != FIRST_POINT) { - if(mySketchState == SECOND_POINT) { - gp_Pnt pt = BRep_Tool::Pnt(TopoDS::Vertex(myShape)); - myLastX1 = pt.X(); - myLastY1 = pt.Y(); + if ( mySketchState == FIRST_POINT ) { + myLastX2 = myX; + myLastY2 = myY; + } + else { + //Test if the current point is the same as the last one + TopoDS_Shape myShape1, myShape2; + + //Last Shape + QString Command1 = myCommand.join( "" ); + Sketcher_Profile aProfile1( Command1.toAscii() ); + if ( aProfile1.IsDone() ) + myShape1 = aProfile1.GetShape(); + + //Current Shape + QString Command2 = Command1 + GetNewCommand( aParameters ); + Sketcher_Profile aProfile2( Command2.toAscii() ); + if ( aProfile2.IsDone() ) + myShape2 = aProfile2.GetShape(); + + if ( myShape2.IsNull() ) { + //the current point is the same as the last one + myLastX2 = myLastX1; + myLastY2 = myLastY1; + } + else { + TopoDS_Vertex V1, V2; + gp_Pnt pt; + if ( myShape1.ShapeType() == TopAbs_VERTEX ) { + //the last shape is the first point + pt = BRep_Tool::Pnt( TopoDS::Vertex( myShape1 ) ); + myLastX1 = pt.X(); + myLastY1 = pt.Y(); } else { - TopoDS_Vertex V1, V2; - TopExp::Vertices(TopoDS::Wire(myShape), V1, V2); - gp_Pnt pt = BRep_Tool::Pnt(V2); - myLastX1 = pt.X(); - myLastY1 = pt.Y(); - if(myLastOp == 1) { // ARC - myLastDir = aProfile1.GetLastDir(); - myLastX2 = myLastX1 - myLastDir.X(); - myLastY2 = myLastY1 - myLastDir.Y(); - } - } - QString myNewCommand = "Sketch "; - myNewCommand = myNewCommand + ":" + "F " + QString::number(myLastX1) + " " + QString::number(myLastY1); - if(mySketchState != SECOND_POINT && !((myLastX1 - myLastX2) == 0 && (myLastY1 - myLastY2) == 0)) - myNewCommand = myNewCommand + ":" + "D " + QString::number(myLastX1 - myLastX2) + " " + QString::number(myLastY1 - myLastY2); - myNewCommand = myNewCommand + this->GetNewCommand(); - Sketcher_Profile aProfile2 (myNewCommand.ascii()); - if(aProfile2.IsDone()) - mySimulationTopoDs2 = aProfile2.GetShape(); - - if ( mySimulationTopoDs2.IsNull() ) { - if ( Group1Sel->isVisible() ) { - Group1Sel->buttonApply->setEnabled(false); - Group1Sel->buttonApply->setFocus(); - } - if ( Group1Spin->isVisible() ) { - Group1Spin->buttonApply->setEnabled(false); - Group1Spin->buttonApply->setFocus(); - } - if ( Group2Spin->isVisible() ) { - Group2Spin->buttonApply->setEnabled(false); - Group2Spin->buttonApply->setFocus(); - } - if ( Group3Spin->isVisible() ) { - Group3Spin->buttonApply->setEnabled(false); - Group3Spin->buttonApply->setFocus(); - } - if ( Group4Spin->isVisible() ) { - Group4Spin->buttonApply->setEnabled(false); - Group4Spin->buttonApply->setFocus(); - } - } else { - if ( Group1Sel->isVisible() ) { - Group1Sel->buttonApply->setEnabled(true); - Group1Sel->buttonApply->setFocus(); - } - if ( Group1Spin->isVisible() ) { - Group1Spin->buttonApply->setEnabled(true); - Group1Spin->buttonApply->setFocus(); - } - if ( Group2Spin->isVisible() ) { - Group2Spin->buttonApply->setEnabled(true); - Group2Spin->buttonApply->setFocus(); - } - if ( Group3Spin->isVisible() ) { - Group3Spin->buttonApply->setEnabled(true); - Group3Spin->buttonApply->setFocus(); - } - if ( Group4Spin->isVisible() ) { - Group4Spin->buttonApply->setEnabled(true); - Group4Spin->buttonApply->setFocus(); - } + TopExp::Vertices( TopoDS::Wire( myShape1 ), V1, V2 ); + pt = BRep_Tool::Pnt( V2 ); + myLastX1 = pt.X(); + myLastY1 = pt.Y(); } + TopExp::Vertices( TopoDS::Wire( myShape2 ), V1, V2 ); + pt = BRep_Tool::Pnt( V2 ); + myLastX2 = pt.X(); + myLastY2 = pt.Y(); + } + } + + QString cmd; + if ( ( mySketchState != FIRST_POINT && + myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) { + cmd = myCommand.join( "" ); + + if ( Group1Sel->isVisible() ) { + Group1Sel->buttonApply->setEnabled( false ); + //Group1Sel->buttonApply->setFocus(); + } + if ( Group1Spin->isVisible() ) { + Group1Spin->buttonApply->setEnabled( false ); + //Group1Spin->buttonApply->setFocus(); + } + if ( Group2Spin->isVisible() ) { + Group2Spin->buttonApply->setEnabled( false ); + //Group2Spin->buttonApply->setFocus(); + } + if ( Group3Spin->isVisible() ) { + Group3Spin->buttonApply->setEnabled( false ); + //Group3Spin->buttonApply->setFocus(); + } + if ( Group4Spin->isVisible() ) { + Group4Spin->buttonApply->setEnabled( false ); + //Group4Spin->buttonApply->setFocus(); + } + } + else { + cmd = myCommand.join( "" ) + GetNewCommand( aParameters ); + + if ( Group1Sel->isVisible() ) { + Group1Sel->buttonApply->setEnabled( true ); + //Group1Sel->buttonApply->setFocus(); + } + if ( Group1Spin->isVisible() ) { + Group1Spin->buttonApply->setEnabled( true ); + //Group1Spin->buttonApply->setFocus(); + } + if ( Group2Spin->isVisible() ) { + Group2Spin->buttonApply->setEnabled( true ); + //Group2Spin->buttonApply->setFocus(); + } + if ( Group3Spin->isVisible() ) { + Group3Spin->buttonApply->setEnabled( true ); + //Group3Spin->buttonApply->setFocus(); + } + if ( Group4Spin->isVisible() ) { + Group4Spin->buttonApply->setEnabled( true ); + //Group4Spin->buttonApply->setFocus(); + } + } + + gp_Ax3 myWPlane = GetActiveLocalCS(); + GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble; + WPlane->length( 9 ); + WPlane[0] = myWPlane.Location().X(); + WPlane[1] = myWPlane.Location().Y(); + WPlane[2] = myWPlane.Location().Z(); + + WPlane[3] = myWPlane.Direction().X(); + WPlane[4] = myWPlane.Direction().Y(); + WPlane[5] = myWPlane.Direction().Z(); + + WPlane[6] = myWPlane.XDirection().X(); + WPlane[7] = myWPlane.XDirection().Y(); + WPlane[8] = myWPlane.XDirection().Z(); + + GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation()); + GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane ); + + if ( !anObj->_is_nil() ) + { + if( !IsPreview() ) { + QStringList aCurrentParameters = myParameters; + aCurrentParameters << aParameters; + anObj->SetParameters(aCurrentParameters.join(":").toLatin1().constData()); } - myEntityGUI->DisplaySimulationShape(mySimulationTopoDs1, mySimulationTopoDs2); + objects.push_back( anObj._retn() ); } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeSimulationAndDisplay"); + + return true; +} + +//================================================================ +// Function : displayPreview +// Purpose : Method for displaying preview of resulting shape +// Redefined from GEOMBase_Helper. +//================================================================ +void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object, + const bool append, + const bool activate, + const bool update, + const double lineWidth, + const int displayMode, + const int color ) +{ + // Set color for preview shape + getDisplayer()->SetColor( Quantity_NOC_RED ); + + // set width of displayed shape + getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth ); + + // Disable activation of selection + getDisplayer()->SetToActivate( activate ); + + // Make a reference to GEOM_Object + CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object ); + getDisplayer()->SetName( objStr.in() ); + + // Create wire from applayed object + TopoDS_Shape anApplyedWire, aLastSegment; + if ( !createShapes( object, anApplyedWire, aLastSegment ) ) + return; + + // Build prs + SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire ); + if ( aPrs != 0 && !aPrs->IsNull() ) + GEOMBase_Helper::displayPreview( aPrs, append, update ); + + getDisplayer()->SetColor( Quantity_NOC_VIOLET ); + aPrs = getDisplayer()->BuildPrs( aLastSegment ); + if ( aPrs != 0 && !aPrs->IsNull() ) + GEOMBase_Helper::displayPreview( aPrs, append, update ); + + getDisplayer()->UnsetName(); + + // Enable activation of displayed objects + getDisplayer()->SetToActivate( true ); +} + +//================================================================ +// Function : createShapes +// Purpose : Create applyed wire, and last segment from entry object +//================================================================ +bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject, + TopoDS_Shape& theApplyedWire, + TopoDS_Shape& theLastSegment ) +{ + TopoDS_Shape aShape; + if ( !GEOMBase::GetShape( theObject, aShape ) || + aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) + return false; + + if ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() || + Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() || + Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() || + Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() || + Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) { + theApplyedWire = aShape; + return true; + } + + BRepBuilderAPI_MakeWire aBuilder; + TopExp_Explorer anExp( aShape, TopAbs_EDGE ); + while ( 1 ) { + TopoDS_Shape anEdge = anExp.Current(); + anExp.Next(); + if ( anExp.More() ) // i.e. non-last edge + aBuilder.Add( TopoDS::Edge( anEdge ) ); + else { + theLastSegment = anEdge; + break; + } + } + + if ( aBuilder.IsDone() ) + theApplyedWire = aBuilder.Shape(); + + return true; +} + +//================================================================================= +// function : keyPressEvent() +// purpose : +//================================================================================= +void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) return; + + if ( e->key() == Qt::Key_F1 ) { + e->accept(); + ClickOnHelp(); } - return; +} + +//================================================================================= +// function : initSpinBox() +// purpose : +//================================================================================= +void EntityGUI_SketcherDlg::initSpinBox( SalomeApp_DoubleSpinBox* spinBox, + double min, double max, + double step, const char* quantity ) +{ + // The same stuff as in GEOMBase_Skeleton::initSpinBox()! + // TODO: Think how to keep the single piece of code... + + // Obtain precision from preferences + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + int aPrecision = resMgr->integerValue( "Geometry", quantity, 6 ); + + spinBox->setPrecision( aPrecision ); + spinBox->setDecimals( aPrecision ); // it's necessary to set decimals before the range setting, + // by default Qt rounds boundaries to 2 decimals at setRange + spinBox->setRange( min, max ); + spinBox->setSingleStep( step ); + + // Add a hint for the user saying how to tune precision + QString userPropName = QObject::tr( QString( "PREF_%1" ).arg( quantity ).toLatin1().constData() ); + spinBox->setProperty( "validity_tune_hint", + QVariant( QObject::tr( "PRECISION_HINT" ).arg( userPropName ) ) ); +} + +//================================================================================= +// function : SetDoubleSpinBoxStep() +// purpose : Double spin box management +//================================================================================= +void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step ) +{ + Group1Spin->SpinBox_DX->setSingleStep(step); + Group2Spin->SpinBox_DX->setSingleStep(step); + Group2Spin->SpinBox_DY->setSingleStep(step); + Group3Spin->SpinBox_DX->setSingleStep(step); + Group3Spin->SpinBox_DY->setSingleStep(step); + Group3Spin->SpinBox_DZ->setSingleStep(step); + Group4Spin->SpinBox_DZ->setSingleStep(step); + + // san: Do NOT override the step when a speicifc step value is used + // in some input fields! + //Group4Spin->SpinBox_DX->setSingleStep(step); + //Group4Spin->SpinBox_DY->setSingleStep(step); + //Group4Spin->SpinBox_DS->setSingleStep(step); +} + +//================================================================================= +// function : FindLocalCS() +// purpose : Find All Coordinates systems in study +//================================================================================= +void EntityGUI_SketcherDlg::FindLocalCS() +{ + ComboBox1->clear(); + myLCSList.clear(); + SalomeApp_Application* app = + dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) + return; + + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + if ( !appStudy ) + return; + + _PTR(Study) aStudy = appStudy->studyDS(); + + //add Global CS + ComboBox1->addItem(tr("GEOM_GCS")); + gp_Pnt aOrigin = gp_Pnt(0, 0, 0); + gp_Dir aDirZ = gp_Dir(0, 0, 1); + gp_Dir aDirX = gp_Dir(1, 0, 0); + gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX); + myLCSList.push_back(globalCS); + + // get GEOM component + CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() ); + _PTR(SObject) obj = aStudy->FindObjectIOR( geomIOR.in() ); + if (!obj) + return; + _PTR(SComponent) fc = obj->GetFatherComponent(); + QString geomComp = fc->GetID().c_str(); + _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() ); + if ( !comp ) + return; + + // browse through all GEOM data tree + _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) ); + for ( it->InitEx( true ); it->More(); it->Next() ) { + _PTR(SObject) child( it->Value() ); + CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child ); + GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj ); + if( CORBA::is_nil( geomObj ) ) + continue; + if (geomObj->GetType() == GEOM_MARKER) { + ComboBox1->addItem(geomObj->GetName()); + TopoDS_Shape aShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), geomObj); + + gp_Ax3 aLCS; + aLCS.Transform(aShape.Location().Transformation()); + if (aShape.ShapeType() == TopAbs_FACE) { + Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape)); + if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) { + Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS); + gp_Pln aPln = aGPlane->Pln(); + aLCS = aPln.Position(); + } + } + myLCSList.push_back(aLCS); + } + } +} + +//================================================================================= +// function : GetActiveLocalCS() +// purpose : Find All Coordinates systems in study +//================================================================================= +gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS() +{ + int ind = ComboBox1->currentIndex(); + if (ind == -1) + return myGeometryGUI->GetWorkingPlane(); + + gp_Ax3 aLCS = myLCSList.at(ind); + + myGeometryGUI->SetWorkingPlane( aLCS ); + myGeometryGUI->ActiveWorkingPlane(); + return aLCS; }