Bugs 16640, 19050: Improve selection mechanism in GEOM dialog boxes.

This commit is contained in:
jfa 2008-09-29 10:04:56 +00:00
parent 0c6f0114a9
commit 54666ebd00
19 changed files with 2732 additions and 2322 deletions

File diff suppressed because it is too large Load Diff

View File

@ -81,7 +81,6 @@ private slots:
private: private:
void Init(); void Init();
void enterEvent( QEvent* ); void enterEvent( QEvent* );
void reset();
void createSelWg( const QString&, QPixmap&, QWidget*, void createSelWg( const QString&, QPixmap&, QWidget*,
QGridLayout*, const int ); QGridLayout*, const int );
void createRadioWg( const QString&, const QString&, QWidget*, void createRadioWg( const QString&, const QString&, QWidget*,
@ -96,6 +95,9 @@ private:
QMap< int, int > myFace; // indexes of faces from second tab ( Face1,2 ) QMap< int, int > myFace; // indexes of faces from second tab ( Face1,2 )
TColStd_IndexedMapOfInteger myFaces; // indexes of faces from first tab ( Faces ) TColStd_IndexedMapOfInteger myFaces; // indexes of faces from first tab ( Faces )
TColStd_IndexedMapOfInteger myEdges; // indexes of edges from fourth tab (Edges) TColStd_IndexedMapOfInteger myEdges; // indexes of edges from fourth tab (Edges)
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
QGroupBox* myGrp1; QGroupBox* myGrp1;
QGroupBox* myGrp2; QGroupBox* myGrp2;

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : OperationGUI_FilletDlg.cxx // File : OperationGUI_FilletDlg.cxx
@ -38,6 +38,7 @@
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <OCCViewer_ViewModel.h> #include <OCCViewer_ViewModel.h>
// OCCT Includes
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
@ -45,166 +46,182 @@
//================================================================================= //=================================================================================
// class : OperationGUI_FilletDlg() // class : OperationGUI_FilletDlg()
// purpose : Constructs a OperationGUI_FilletDlg which is a child of 'parent', with the // purpose : Constructs a OperationGUI_FilletDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
OperationGUI_FilletDlg::OperationGUI_FilletDlg( GeometryGUI* theGeometryGUI, QWidget* parent ) OperationGUI_FilletDlg::OperationGUI_FilletDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
: GEOMBase_Skeleton( theGeometryGUI, parent, false ) : GEOMBase_Skeleton(theGeometryGUI, parent, false),
myInitial(true)
{ {
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_ALL" ) ) ); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_ALL")));
QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_EDGE" ) ) ); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_EDGE")));
QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_FACE" ) ) ); QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_FACE")));
QPixmap iconSelect( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap iconSelect (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_FILLET_TITLE" ) ); setWindowTitle(tr("GEOM_FILLET_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_FILLET" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_FILLET"));
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setIcon( image1 ); mainFrame()->RadioButton2->setIcon(image1);
mainFrame()->RadioButton3->setIcon( image2 ); mainFrame()->RadioButton3->setIcon(image2);
Group1 = new DlgRef_1Sel1Spin( centralWidget() ); Group1 = new DlgRef_1Sel1Spin(centralWidget());
Group1->GroupBox1->setTitle( tr( "GEOM_FILLET_ALL" ) ); Group1->GroupBox1->setTitle(tr("GEOM_FILLET_ALL"));
Group1->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) ); Group1->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
Group1->TextLabel2->setText( tr( "GEOM_RADIUS" ) ); Group1->TextLabel2->setText(tr("GEOM_RADIUS"));
Group1->PushButton1->setIcon( iconSelect ); Group1->PushButton1->setIcon(iconSelect);
Group1->LineEdit1->setReadOnly( true ); Group1->LineEdit1->setReadOnly(true);
Group2 = new DlgRef_2Sel3Spin2Rb( centralWidget() ); Group2 = new DlgRef_2Sel3Spin2Rb(centralWidget());
Group2->GroupBox1->setTitle( tr( "GEOM_FILLET_EDGES" ) ); Group2->GroupBox1->setTitle(tr("GEOM_FILLET_EDGES"));
Group2->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) ); Group2->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
Group2->TextLabel2->setText( tr( "SELECTED_EDGES" ) ); Group2->TextLabel2->setText(tr("SELECTED_EDGES"));
Group2->TextLabel3->setText( tr( "GEOM_RADIUS" ) ); Group2->TextLabel3->setText(tr("GEOM_RADIUS"));
Group2->TextLabel4->setText( tr( "GEOM_R1" ) ); Group2->TextLabel4->setText(tr("GEOM_R1"));
Group2->TextLabel5->setText( tr( "GEOM_R2" ) ); Group2->TextLabel5->setText(tr("GEOM_R2"));
Group2->PushButton1->setIcon( iconSelect ); Group2->PushButton1->setIcon(iconSelect);
Group2->PushButton2->setIcon( iconSelect ); Group2->PushButton2->setIcon(iconSelect);
Group2->LineEdit1->setReadOnly( true ); Group2->LineEdit1->setReadOnly(true);
Group2->LineEdit2->setReadOnly( true ); Group2->LineEdit2->setReadOnly(true);
Group3 = new DlgRef_2Sel3Spin2Rb( centralWidget() ); Group3 = new DlgRef_2Sel3Spin2Rb(centralWidget());
Group3->GroupBox1->setTitle( tr( "GEOM_FILLET_FACES" ) ); Group3->GroupBox1->setTitle(tr("GEOM_FILLET_FACES"));
Group3->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) ); Group3->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
Group3->TextLabel2->setText( tr( "SELECTED_FACES" ) ); Group3->TextLabel2->setText(tr("SELECTED_FACES"));
Group3->TextLabel3->setText( tr( "GEOM_RADIUS" ) ); Group3->TextLabel3->setText(tr("GEOM_RADIUS"));
Group3->TextLabel4->setText( tr( "GEOM_R1" ) ); Group3->TextLabel4->setText(tr("GEOM_R1"));
Group3->TextLabel5->setText( tr( "GEOM_R2" ) ); Group3->TextLabel5->setText(tr("GEOM_R2"));
Group3->PushButton1->setIcon( iconSelect ); Group3->PushButton1->setIcon(iconSelect);
Group3->PushButton2->setIcon( iconSelect ); Group3->PushButton2->setIcon(iconSelect);
Group3->LineEdit1->setReadOnly( true ); Group3->LineEdit1->setReadOnly(true);
Group3->LineEdit2->setReadOnly( true ); Group3->LineEdit2->setReadOnly(true);
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget( Group1 ); layout->addWidget(Group1);
layout->addWidget( Group2 ); layout->addWidget(Group2);
layout->addWidget( Group3 ); layout->addWidget(Group3);
/***************************************************************/ /***************************************************************/
// Set range of spinboxes
double SpecificStep = 10.0; double SpecificStep = 10.0;
initSpinBox( Group1->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(Group1->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( Group2->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(Group2->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( Group2->SpinBox_DY, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(Group2->SpinBox_DY, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( Group2->SpinBox_DZ, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(Group2->SpinBox_DZ, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( Group3->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(Group3->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( Group3->SpinBox_DY, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(Group3->SpinBox_DY, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( Group3->SpinBox_DZ, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(Group3->SpinBox_DZ, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
setHelpFileName( "fillet_operation_page.html" );
/* Initialisations */ setHelpFileName("fillet_operation_page.html");
// Initialisation
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~OperationGUI_FilletDlg() // function : ~OperationGUI_FilletDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
//================================================================================= //=================================================================================
OperationGUI_FilletDlg::~OperationGUI_FilletDlg() OperationGUI_FilletDlg::~OperationGUI_FilletDlg()
{ {
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void OperationGUI_FilletDlg::Init() void OperationGUI_FilletDlg::Init()
{ {
myConstructorId = -1; // Set Initial values of spinboxes
reset(); Group1->SpinBox_DX->setValue(5);
Group2->SpinBox_DX->setValue(5);
Group2->SpinBox_DY->setValue(5);
Group2->SpinBox_DZ->setValue(5);
Group3->SpinBox_DX->setValue(5);
Group3->SpinBox_DY->setValue(5);
Group3->SpinBox_DZ->setValue(5);
// Clear line edits
Group1->LineEdit1->setText("");
Group2->LineEdit1->setText("");
Group2->LineEdit2->setText("");
Group3->LineEdit1->setText("");
Group3->LineEdit2->setText("");
myShape = GEOM::GEOM_Object::_nil();
myFaces.Clear();
myEdges.Clear();
// signals and slots connections
// main buttons // main buttons
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk() ));
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
// group box // group box
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
// push buttons // push buttons
connect( Group1->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( Group2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( Group3->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(Group3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( Group2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(Group2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( Group3->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(Group3->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
// line edits // line edits
connect( Group1->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( Group2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( Group3->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(Group3->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
// spin boxes // spin boxes
connect( Group1->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect(Group1->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect( Group2->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect(Group2->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect( Group2->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect(Group2->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect( Group2->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect(Group2->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect( Group3->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect(Group3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect( Group3->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect(Group3->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect( Group3->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect(Group3->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
// radio buttons // radio buttons
connect( Group2->RadioButton1, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); connect(Group2->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
connect( Group2->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); connect(Group2->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
connect( Group3->RadioButton1, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); connect(Group3->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
connect( Group3->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) ); connect(Group3->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
// selection initName(tr("GEOM_FILLET"));
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName( tr( "GEOM_FILLET" ) ); myConstructorId = -1;
ConstructorsClicked(0);
ConstructorsClicked( 0 );
} }
//================================================================================= //=================================================================================
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
//================================================================================= //=================================================================================
void OperationGUI_FilletDlg::ConstructorsClicked( int constructorId ) void OperationGUI_FilletDlg::ConstructorsClicked (int constructorId)
{ {
if ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
!= OCCViewer_Viewer::Type() ) { != OCCViewer_Viewer::Type()) {
mainFrame()->RadioButton1->setChecked( true ); mainFrame()->RadioButton1->setChecked(true);
return; return;
} }
if ( myConstructorId == constructorId ) if (myConstructorId == constructorId)
return; return;
// Get radius from previous widget // Get radius from previous widget
double R = 5, R1 = 5, R2 = 5; double R = 5, R1 = 5, R2 = 5;
if ( myConstructorId == 0 ) { if (myConstructorId == 0) {
R = Group1->SpinBox_DX->value(); R = Group1->SpinBox_DX->value();
} }
else if ( myConstructorId == 1 ) { else if (myConstructorId == 1) {
R = Group2->SpinBox_DX->value(); R = Group2->SpinBox_DX->value();
R1 = Group2->SpinBox_DY->value(); R1 = Group2->SpinBox_DY->value();
R2 = Group2->SpinBox_DZ->value(); R2 = Group2->SpinBox_DZ->value();
@ -217,87 +234,104 @@ void OperationGUI_FilletDlg::ConstructorsClicked( int constructorId )
myConstructorId = constructorId; myConstructorId = constructorId;
switch ( constructorId ) { switch (constructorId) {
case 0: case 0:
Group2->hide(); Group2->hide();
Group3->hide(); Group3->hide();
Group1->show(); Group1->show();
Group1->SpinBox_DX->setValue( R ); Group1->SpinBox_DX->setValue(R);
break; break;
case 1: case 1:
Group1->hide(); Group1->hide();
Group3->hide(); Group3->hide();
Group2->show(); Group2->show();
Group2->SpinBox_DX->setValue( R ); Group2->SpinBox_DX->setValue(R);
Group2->SpinBox_DY->setValue( R1 ); Group2->SpinBox_DY->setValue(R1);
Group2->SpinBox_DZ->setValue( R2 ); Group2->SpinBox_DZ->setValue(R2);
break; break;
case 2: case 2:
Group1->hide(); Group1->hide();
Group2->hide(); Group2->hide();
Group3->show(); Group3->show();
Group3->SpinBox_DX->setValue( R ); Group3->SpinBox_DX->setValue(R);
Group3->SpinBox_DY->setValue( R1 ); Group3->SpinBox_DY->setValue(R1);
Group3->SpinBox_DZ->setValue( R2 ); Group3->SpinBox_DZ->setValue(R2);
break; break;
default: default:
break; break;
} }
if ( constructorId == 0 ) myEditCurrentArgument = Group1->LineEdit1; if (constructorId == 0) Group1->PushButton1->click();
else if ( constructorId == 1 ) myEditCurrentArgument = Group2->LineEdit1; else if (constructorId == 1) Group2->PushButton1->click();
else myEditCurrentArgument = Group3->LineEdit1; else Group3->PushButton1->click();
activateSelection();
enableWidgets(); enableWidgets();
if ( !myShape->_is_nil() ) { if (myInitial) {
myEditCurrentArgument->setText( GEOMBase::GetName( myShape ) ); myInitial = false;
GEOMBase_Skeleton::LineEditReturnPressed(); SelectionIntoArgument();
}
else {
if (!myShape->_is_nil()) {
myEditCurrentArgument->setText(GEOMBase::GetName(myShape));
GEOMBase_Skeleton::LineEditReturnPressed();
switch (getConstructorId()) {
case 1:
if (myEdges.Extent() == 0)
Group2->PushButton2->click();
break;
case 2:
if (myFaces.Extent() == 0)
Group3->PushButton2->click();
break;
default:
break;
}
}
else
myEditCurrentArgument->setText("");
displayPreview();
} }
else
myEditCurrentArgument->setText( "" );
qApp->processEvents(); qApp->processEvents();
updateGeometry(); updateGeometry();
resize( minimumSize() ); resize(minimumSize());
displayPreview();
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
//================================================================================= //=================================================================================
void OperationGUI_FilletDlg::ClickOnOk() void OperationGUI_FilletDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool OperationGUI_FilletDlg::ClickOnApply() bool OperationGUI_FilletDlg::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection has changed // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void OperationGUI_FilletDlg::SelectionIntoArgument() void OperationGUI_FilletDlg::SelectionIntoArgument()
{ {
erasePreview(); erasePreview();
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
@ -308,6 +342,7 @@ void OperationGUI_FilletDlg::SelectionIntoArgument()
myEditCurrentArgument == Group2->LineEdit1 || myEditCurrentArgument == Group2->LineEdit1 ||
myEditCurrentArgument == Group3->LineEdit1) myEditCurrentArgument == Group3->LineEdit1)
{ {
myShape = GEOM::GEOM_Object::_nil();
if (aSelList.Extent() == 1) { if (aSelList.Extent() == 1) {
Standard_Boolean aResult = Standard_False; Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object_var anObj =
@ -317,18 +352,17 @@ void OperationGUI_FilletDlg::SelectionIntoArgument()
myShape = anObj; myShape = anObj;
myEditCurrentArgument->setText(GEOMBase::GetName(anObj)); myEditCurrentArgument->setText(GEOMBase::GetName(anObj));
displayPreview(); displayPreview();
enableWidgets();
return;
} }
} }
myShape = GEOM::GEOM_Object::_nil();
enableWidgets(); enableWidgets();
} }
// If face or edge selection is activated // If face or edge selection is activated
else if (myEditCurrentArgument == Group2->LineEdit2 || else if (myEditCurrentArgument == Group2->LineEdit2 ||
myEditCurrentArgument == Group3->LineEdit2) myEditCurrentArgument == Group3->LineEdit2)
{ {
if (myEditCurrentArgument == Group2->LineEdit2) myEdges.Clear();
else myFaces.Clear();
if (aSelList.Extent() == 1) { if (aSelList.Extent() == 1) {
Standard_Boolean aResult = Standard_False; Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object_var anObj =
@ -343,48 +377,52 @@ void OperationGUI_FilletDlg::SelectionIntoArgument()
if (anIndexes.Extent() == 1) { if (anIndexes.Extent() == 1) {
int anIndex = anIndexes(1); int anIndex = anIndexes(1);
aName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex ); aName = QString(GEOMBase::GetName(anObj)) + QString(":%1").arg(anIndex);
}
else {
aName = tr("GEOM_MEN_POPUP_NAME").arg(anIndexes.Extent());
} }
else
aName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() );
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText(aName);
if ( myConstructorId == 1 ) if (myConstructorId == 1)
myEdges = anIndexes; myEdges = anIndexes;
else else
myFaces = anIndexes; myFaces = anIndexes;
displayPreview(); displayPreview();
return;
} }
} }
} }
myFaces.Clear(); }
// clear selection
if (!(myEditCurrentArgument == Group2->LineEdit2 ||
myEditCurrentArgument == Group3->LineEdit2)) {
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
}
switch (getConstructorId()) {
case 1:
if (myEditCurrentArgument == Group2->LineEdit1) {
if (!myShape->_is_nil() && myEdges.Extent() == 0)
Group2->PushButton2->click();
}
break;
case 2:
if (myEditCurrentArgument == Group3->LineEdit1) {
if (!myShape->_is_nil() && myFaces.Extent() == 0)
Group3->PushButton2->click();
}
break;
default:
break;
} }
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void OperationGUI_FilletDlg::LineEditReturnPressed()
{
QLineEdit* send = ( QLineEdit* )sender();
if ( send == Group1->LineEdit1 )
myEditCurrentArgument = Group1->LineEdit1;
else if ( send == Group2->LineEdit1 )
myEditCurrentArgument = Group2->LineEdit1;
else if ( send == Group3->LineEdit1 )
myEditCurrentArgument = Group3->LineEdit1;
else
return;
GEOMBase_Skeleton::LineEditReturnPressed();
}
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -393,30 +431,61 @@ void OperationGUI_FilletDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
if ( send == Group1->PushButton1 ) { if (send == Group1->PushButton1) {
Group1->LineEdit1->setFocus();
myEditCurrentArgument = Group1->LineEdit1; myEditCurrentArgument = Group1->LineEdit1;
} }
else if ( send == Group2->PushButton1 ) { else if (send == Group2->PushButton1) {
Group2->LineEdit1->setFocus();
myEditCurrentArgument = Group2->LineEdit1; myEditCurrentArgument = Group2->LineEdit1;
Group2->PushButton2->setDown(false);
Group2->LineEdit2->setEnabled(false);
} }
else if ( send == Group2->PushButton2 ) { else if (send == Group2->PushButton2) {
Group2->LineEdit2->setFocus();
myEditCurrentArgument = Group2->LineEdit2; myEditCurrentArgument = Group2->LineEdit2;
Group2->PushButton1->setDown(false);
Group2->LineEdit1->setEnabled(false);
} }
else if ( send == Group3->PushButton1 ) { else if (send == Group3->PushButton1) {
Group3->LineEdit1->setFocus();
myEditCurrentArgument = Group3->LineEdit1; myEditCurrentArgument = Group3->LineEdit1;
Group3->PushButton2->setDown(false);
Group3->LineEdit2->setEnabled(false);
} }
else if ( send == Group3->PushButton2 ) { else if (send == Group3->PushButton2) {
Group3->LineEdit1->setFocus();
myEditCurrentArgument = Group3->LineEdit2; myEditCurrentArgument = Group3->LineEdit2;
Group3->PushButton1->setDown(false);
Group3->LineEdit1->setEnabled(false);
} }
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
activateSelection(); activateSelection();
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void OperationGUI_FilletDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if (send == Group1->LineEdit1)
myEditCurrentArgument = Group1->LineEdit1;
else if (send == Group2->LineEdit1)
myEditCurrentArgument = Group2->LineEdit1;
else if (send == Group3->LineEdit1)
myEditCurrentArgument = Group3->LineEdit1;
else
return;
GEOMBase_Skeleton::LineEditReturnPressed();
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
@ -426,21 +495,17 @@ void OperationGUI_FilletDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(), // reinit, because some selected objects could be removed
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); Init();
activateSelection();
displayPreview();
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void OperationGUI_FilletDlg::enterEvent( QEvent* ) void OperationGUI_FilletDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
this->ActivateThisDialog(); this->ActivateThisDialog();
} }
@ -448,71 +513,33 @@ void OperationGUI_FilletDlg::enterEvent( QEvent* )
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
//================================================================================= //=================================================================================
void OperationGUI_FilletDlg::ValueChangedInSpinBox( double ) void OperationGUI_FilletDlg::ValueChangedInSpinBox (double)
{ {
displayPreview(); displayPreview();
} }
//=================================================================================
// function : reset()
// purpose :
//=================================================================================
void OperationGUI_FilletDlg::reset()
{
// Set Initial values of spinboxes
Group1->SpinBox_DX->setValue( 5 );
Group2->SpinBox_DX->setValue( 5 );
Group2->SpinBox_DY->setValue( 5 );
Group2->SpinBox_DZ->setValue( 5 );
Group3->SpinBox_DX->setValue( 5 );
Group3->SpinBox_DY->setValue( 5 );
Group3->SpinBox_DZ->setValue( 5 );
Group1->LineEdit1->setText( "" );
Group2->LineEdit1->setText( "" );
Group2->LineEdit2->setText( "" );
Group3->LineEdit1->setText( "" );
Group3->LineEdit2->setText( "" );
// constructor id
int aConstructorId = getConstructorId();
if ( aConstructorId == 0 ) myEditCurrentArgument = Group1->LineEdit1;
else if ( aConstructorId == 1 ) myEditCurrentArgument = Group2->LineEdit1;
else myEditCurrentArgument = Group3->LineEdit1;
myShape = GEOM::GEOM_Object::_nil();
myFaces.Clear();
myEdges.Clear();
erasePreview( true );
activateSelection();
enableWidgets();
}
//================================================================================= //=================================================================================
// function : activateSelection // function : activateSelection
// purpose : Activate selection in accordance with myEditCurrentArgument // purpose : Activate selection in accordance with myEditCurrentArgument
//================================================================================= //=================================================================================
void OperationGUI_FilletDlg::activateSelection() void OperationGUI_FilletDlg::activateSelection()
{ {
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if ( !myShape->_is_nil() && myEditCurrentArgument == Group2->LineEdit2 ) if (!myShape->_is_nil() && myEditCurrentArgument == Group2->LineEdit2)
localSelection( myShape, TopAbs_EDGE ); localSelection(myShape, TopAbs_EDGE);
else if ( !myShape->_is_nil() && myEditCurrentArgument == Group3->LineEdit2 ) else if (!myShape->_is_nil() && myEditCurrentArgument == Group3->LineEdit2)
localSelection( myShape, TopAbs_FACE ); localSelection(myShape, TopAbs_FACE);
else { else {
TColStd_MapOfInteger aMap; TColStd_MapOfInteger aMap;
aMap.Add( GEOM_SHELL ); aMap.Add(GEOM_SHELL);
aMap.Add( GEOM_SOLID ); aMap.Add(GEOM_SOLID);
aMap.Add( GEOM_COMPOUND ); aMap.Add(GEOM_COMPOUND);
globalSelection( aMap ); globalSelection(aMap);
} }
SelectionIntoArgument(); connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
} }
//================================================================================= //=================================================================================
@ -525,21 +552,21 @@ void OperationGUI_FilletDlg::enableWidgets()
bool toEnable = !myShape->_is_nil(); bool toEnable = !myShape->_is_nil();
if ( anId == 1 ) { if (anId == 1) {
Group2->LineEdit2->setEnabled( toEnable ); //Group2->LineEdit2->setEnabled(toEnable);
Group2->PushButton2->setEnabled( toEnable ); Group2->PushButton2->setEnabled(toEnable);
if ( !toEnable ) { if (!toEnable) {
Group2->LineEdit2->setText( "" ); Group2->LineEdit2->setText("");
myEdges.Clear(); myEdges.Clear();
} }
} }
else if ( anId == 2 ) { else if (anId == 2) {
Group3->LineEdit2->setEnabled( toEnable ); //Group3->LineEdit2->setEnabled(toEnable);
Group3->PushButton2->setEnabled( toEnable ); Group3->PushButton2->setEnabled(toEnable);
if ( !toEnable ) { if (!toEnable) {
Group3->LineEdit2->setText( "" ); Group3->LineEdit2->setText("");
myFaces.Clear(); myFaces.Clear();
} }
} }
@ -551,16 +578,16 @@ void OperationGUI_FilletDlg::enableWidgets()
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr OperationGUI_FilletDlg::createOperation() GEOM::GEOM_IOperations_ptr OperationGUI_FilletDlg::createOperation()
{ {
return getGeomEngine()->GetILocalOperations( getStudyId() ); return getGeomEngine()->GetILocalOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : isValid()
// purpose : Verify validity of input data // purpose : Verify validity of input data
//================================================================================= //=================================================================================
bool OperationGUI_FilletDlg::isValid( QString& ) bool OperationGUI_FilletDlg::isValid (QString&)
{ {
switch ( getConstructorId() ) switch (getConstructorId())
{ {
case 0: return !myShape->_is_nil(); case 0: return !myShape->_is_nil();
case 1: return !myShape->_is_nil() && myEdges.Extent() > 0; case 1: return !myShape->_is_nil() && myEdges.Extent() > 0;
@ -573,99 +600,98 @@ bool OperationGUI_FilletDlg::isValid( QString& )
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool OperationGUI_FilletDlg::execute( ObjectList& objects ) bool OperationGUI_FilletDlg::execute (ObjectList& objects)
{ {
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
int anId = getConstructorId(); int anId = getConstructorId();
if ( anId == 0 ) if (anId == 0)
anObj = GEOM::GEOM_ILocalOperations::_narrow( anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
getOperation() )->MakeFilletAll( myShape, getRadius() ); MakeFilletAll(myShape, getRadius());
else if ( anId == 1 ) { else if (anId == 1) {
GEOM::ListOfLong_var aList = new GEOM::ListOfLong; GEOM::ListOfLong_var aList = new GEOM::ListOfLong;
aList->length( myEdges.Extent() ); aList->length(myEdges.Extent());
for ( int i = 1, n = myEdges.Extent(); i <= n; i++ ) for (int i = 1, n = myEdges.Extent(); i <= n; i++)
aList[ i - 1 ] = myEdges( i ); aList[ i - 1 ] = myEdges(i);
if ( Group2->RadioButton1->isChecked() ) if (Group2->RadioButton1->isChecked())
anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
MakeFilletEdges( myShape, getRadius(), aList ); MakeFilletEdges(myShape, getRadius(), aList);
else else
anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
MakeFilletEdgesR1R2( myShape, MakeFilletEdgesR1R2(myShape,
Group2->SpinBox_DY->value(), Group2->SpinBox_DY->value(),
Group2->SpinBox_DZ->value(), Group2->SpinBox_DZ->value(),
aList ); aList);
} }
else if ( anId == 2 ) { else if (anId == 2) {
GEOM::ListOfLong_var aList = new GEOM::ListOfLong; GEOM::ListOfLong_var aList = new GEOM::ListOfLong;
aList->length( myFaces.Extent() ); aList->length(myFaces.Extent());
for ( int i = 1, n = myFaces.Extent(); i <= n; i++ ) for (int i = 1, n = myFaces.Extent(); i <= n; i++)
aList[ i - 1 ] = myFaces( i ); aList[ i - 1 ] = myFaces(i);
if ( Group3->RadioButton1->isChecked() ) { if (Group3->RadioButton1->isChecked()) {
anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
MakeFilletFaces( myShape, getRadius(), aList ); MakeFilletFaces(myShape, getRadius(), aList);
} }
else { else {
anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
MakeFilletFacesR1R2( myShape, MakeFilletFacesR1R2(myShape,
Group3->SpinBox_DY->value(), Group3->SpinBox_DY->value(),
Group3->SpinBox_DZ->value(), aList ); Group3->SpinBox_DZ->value(), aList);
} }
} }
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : getRadius // function : getRadius
// purpose : Get radius // purpose : Get radius
//================================================================================= //=================================================================================
double OperationGUI_FilletDlg::getRadius() const double OperationGUI_FilletDlg::getRadius() const
{ {
int anId = getConstructorId(); int anId = getConstructorId();
if ( anId == 0 ) return Group1->SpinBox_DX->value(); if (anId == 0) return Group1->SpinBox_DX->value();
else if ( anId == 1 ) return Group2->SpinBox_DX->value(); else if (anId == 1) return Group2->SpinBox_DX->value();
else return Group3->SpinBox_DX->value(); else return Group3->SpinBox_DX->value();
} }
//================================================================================= //=================================================================================
// function : RadiobuttonClicked // function : RadiobuttonClicked
// purpose : // purpose :
//================================================================================= //=================================================================================
void OperationGUI_FilletDlg::RadioButtonClicked() void OperationGUI_FilletDlg::RadioButtonClicked()
{ {
const QObject* s = sender(); const QObject* s = sender();
bool flag = s == Group2->RadioButton1 || s == Group3->RadioButton1; bool flag = s == Group2->RadioButton1 || s == Group3->RadioButton1;
Group2->RadioButton1->blockSignals( true );
Group2->RadioButton2->blockSignals( true );
Group3->RadioButton1->blockSignals( true );
Group3->RadioButton2->blockSignals( true );
Group2->SpinBox_DX->setEnabled( flag );
Group2->SpinBox_DY->setEnabled( !flag );
Group2->SpinBox_DZ->setEnabled( !flag );
Group2->RadioButton1->setChecked( flag );
Group2->RadioButton2->setChecked( !flag );
Group3->SpinBox_DX->setEnabled( flag );
Group3->SpinBox_DY->setEnabled( !flag );
Group3->SpinBox_DZ->setEnabled( !flag );
Group3->RadioButton1->setChecked( flag );
Group3->RadioButton2->setChecked( !flag );
Group2->RadioButton1->blockSignals( false ); Group2->RadioButton1->blockSignals(true);
Group2->RadioButton2->blockSignals( false ); Group2->RadioButton2->blockSignals(true);
Group3->RadioButton1->blockSignals( false ); Group3->RadioButton1->blockSignals(true);
Group3->RadioButton2->blockSignals( false ); Group3->RadioButton2->blockSignals(true);
displayPreview(); Group2->SpinBox_DX->setEnabled(flag);
Group2->SpinBox_DY->setEnabled(!flag);
Group2->SpinBox_DZ->setEnabled(!flag);
Group2->RadioButton1->setChecked(flag);
Group2->RadioButton2->setChecked(!flag);
Group3->SpinBox_DX->setEnabled(flag);
Group3->SpinBox_DY->setEnabled(!flag);
Group3->SpinBox_DZ->setEnabled(!flag);
Group3->RadioButton1->setChecked(flag);
Group3->RadioButton2->setChecked(!flag);
Group2->RadioButton1->blockSignals(false);
Group2->RadioButton2->blockSignals(false);
Group3->RadioButton1->blockSignals(false);
Group3->RadioButton2->blockSignals(false);
displayPreview();
} }

View File

@ -65,7 +65,6 @@ private slots:
private: private:
void Init(); void Init();
void enterEvent( QEvent* ); void enterEvent( QEvent* );
void reset();
void activateSelection(); void activateSelection();
void enableWidgets(); void enableWidgets();
double getRadius() const; double getRadius() const;
@ -76,6 +75,9 @@ private:
GEOM::GEOM_Object_var myShape; GEOM::GEOM_Object_var myShape;
TColStd_IndexedMapOfInteger myEdges; TColStd_IndexedMapOfInteger myEdges;
TColStd_IndexedMapOfInteger myFaces; TColStd_IndexedMapOfInteger myFaces;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_1Sel1Spin* Group1; DlgRef_1Sel1Spin* Group1;
DlgRef_2Sel3Spin2Rb* Group2; DlgRef_2Sel3Spin2Rb* Group2;

View File

@ -1,21 +1,21 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
@ -25,15 +25,15 @@
#include "OperationGUI_GetShapesOnShapeDlg.h" #include "OperationGUI_GetShapesOnShapeDlg.h"
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
//============================================================================== //==============================================================================
// class : OperationGUI_GetShapesOnShapeDlg() // class : OperationGUI_GetShapesOnShapeDlg()
// purpose : Constructs a OperationGUI_GetShapesOnShapeDlg which is a child of // purpose : Constructs a OperationGUI_GetShapesOnShapeDlg which is a child of
@ -41,41 +41,43 @@
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
OperationGUI_GetShapesOnShapeDlg::OperationGUI_GetShapesOnShapeDlg( GeometryGUI* theGeometryGUI, OperationGUI_GetShapesOnShapeDlg::OperationGUI_GetShapesOnShapeDlg (GeometryGUI* theGeometryGUI,
QWidget* parent ) QWidget* parent)
: GEOMBase_Skeleton( theGeometryGUI, parent, false ) : GEOMBase_Skeleton(theGeometryGUI, parent, false)
{ {
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_SHAPES_ON_SHAPE" ) ) ); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_SHAPES_ON_SHAPE")));
QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_SHAPES_ON_SHAPE_TITLE" ) ); setWindowTitle(tr("GEOM_SHAPES_ON_SHAPE_TITLE"));
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_SHAPES_ON_SHAPE" ) ); /***************************************************************/
mainFrame()->GroupConstructors->setTitle(tr("GEOM_SHAPES_ON_SHAPE"));
mainFrame()->RadioButton1->setIcon(image0); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton2->close(); mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
GroupPoints = new DlgRef_2Sel2List( centralWidget() ); GroupPoints = new DlgRef_2Sel2List(centralWidget());
//GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION")); //GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION"));
GroupPoints->GroupBox1->setTitle( "Input data" ); GroupPoints->GroupBox1->setTitle("Input data");
GroupPoints->TextLabel1->setText( tr( "GEOM_SHAPES_ON_SHAPE_ESHAPE" ) ); GroupPoints->TextLabel1->setText(tr("GEOM_SHAPES_ON_SHAPE_ESHAPE"));
GroupPoints->TextLabel2->setText( tr( "GEOM_SHAPES_ON_SHAPE_CSHAPE" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_SHAPES_ON_SHAPE_CSHAPE"));
GroupPoints->TextLabel3->setText( tr( "GEOM_RECONSTRUCTION_LIMIT" ) ); GroupPoints->TextLabel3->setText(tr("GEOM_RECONSTRUCTION_LIMIT"));
GroupPoints->TextLabel4->setText( tr( "GEOM_SHAPES_ON_SHAPE_STATE" ) ); GroupPoints->TextLabel4->setText(tr("GEOM_SHAPES_ON_SHAPE_STATE"));
GroupPoints->PushButton1->setIcon( image2 ); GroupPoints->PushButton1->setIcon(image2);
GroupPoints->PushButton2->setIcon( image2 ); GroupPoints->PushButton2->setIcon(image2);
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget( GroupPoints ); layout->addWidget(GroupPoints);
/***************************************************************/
setHelpFileName("shapesonshape_page.html");
setHelpFileName( "shapesonshape_page.html" );
Init(); Init();
} }
@ -93,54 +95,55 @@ OperationGUI_GetShapesOnShapeDlg::~OperationGUI_GetShapesOnShapeDlg()
//================================================================================= //=================================================================================
void OperationGUI_GetShapesOnShapeDlg::Init() void OperationGUI_GetShapesOnShapeDlg::Init()
{ {
/* type for sub shape selection */ // type for sub shape selection
GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_SOLID" ) ); GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_SOLID"));
// commented by skl for IPAL19949 - finder isn't allowed such type // commented by skl for IPAL19949 - finder isn't allowed such type
//GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_SHELL" ) ); //GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_SHELL"));
GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_FACE" ) ); GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_FACE"));
// commented by skl for IPAL19949 - finder isn't allowed such type // commented by skl for IPAL19949 - finder isn't allowed such type
//GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_WIRE" ) ); //GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_WIRE"));
GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_EDGE" ) ); GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_EDGE"));
GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_VERTEX" ) ); GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_VERTEX"));
/* type for state selection */ // type for state selection
GroupPoints->ComboBox2->addItem( tr( "GEOM_STATE_IN" ) ); GroupPoints->ComboBox2->addItem(tr("GEOM_STATE_IN"));
GroupPoints->ComboBox2->addItem( tr( "GEOM_STATE_OUT" ) ); GroupPoints->ComboBox2->addItem(tr("GEOM_STATE_OUT"));
GroupPoints->ComboBox2->addItem( tr( "GEOM_STATE_ON" ) ); GroupPoints->ComboBox2->addItem(tr("GEOM_STATE_ON"));
GroupPoints->ComboBox2->addItem( tr( "GEOM_STATE_ONIN" ) ); GroupPoints->ComboBox2->addItem(tr("GEOM_STATE_ONIN"));
GroupPoints->ComboBox2->addItem( tr( "GEOM_STATE_ONOUT" ) ); GroupPoints->ComboBox2->addItem(tr("GEOM_STATE_ONOUT"));
GroupPoints->LineEdit1->clear(); GroupPoints->LineEdit1->clear();
GroupPoints->LineEdit2->clear(); GroupPoints->LineEdit2->clear();
myObject1 = myObject2 = GEOM::GEOM_Object::_nil();
/* signals and slots connections */ // signals and slots connections
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints->ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ComboTextChanged() ) );
connect( GroupPoints->ComboBox2, SIGNAL( activated( int ) ), this, SLOT( ComboTextChanged() ) );
connect( myGeomGUI->getApp()->selectionMgr(), connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged()));
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); connect(GroupPoints->ComboBox2, SIGNAL(activated(int)), this, SLOT(ComboTextChanged()));
globalSelection( GEOM_ALLSHAPES ); connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
initName( mainFrame()->GroupConstructors->title() ); initName(mainFrame()->GroupConstructors->title());
GroupPoints->TextLabel3->show(); GroupPoints->TextLabel3->show();
GroupPoints->ComboBox1->show(); GroupPoints->ComboBox1->show();
GroupPoints->ComboBox1->setCurrentIndex( 0 ); GroupPoints->ComboBox1->setCurrentIndex(0);
GroupPoints->ComboBox2->show(); GroupPoints->ComboBox2->show();
GroupPoints->ComboBox2->setCurrentIndex( 0 ); GroupPoints->ComboBox2->setCurrentIndex(0);
myEditCurrentArgument = GroupPoints->LineEdit1; globalSelection(GEOM_ALLSHAPES);
myEditCurrentArgument->setFocus();
GroupPoints->PushButton1->click();
SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
@ -149,7 +152,7 @@ void OperationGUI_GetShapesOnShapeDlg::Init()
//================================================================================= //=================================================================================
void OperationGUI_GetShapesOnShapeDlg::ClickOnOk() void OperationGUI_GetShapesOnShapeDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
@ -159,41 +162,57 @@ void OperationGUI_GetShapesOnShapeDlg::ClickOnOk()
//================================================================================= //=================================================================================
bool OperationGUI_GetShapesOnShapeDlg::ClickOnApply() bool OperationGUI_GetShapesOnShapeDlg::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
// activate first line edit
GroupPoints->PushButton1->click();
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection has changed // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void OperationGUI_GetShapesOnShapeDlg::SelectionIntoArgument() void OperationGUI_GetShapesOnShapeDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText("");
QString aString = "";
if (myEditCurrentArgument == GroupPoints->LineEdit1) myObject1 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myObject2 = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true); QString aName = "";
int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName, true);
if (nbSel > 0) { if (nbSel > 0) {
Standard_Boolean aRes = Standard_False; Standard_Boolean aRes = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes); GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
if (!CORBA::is_nil(aSelectedObject) && aRes && GEOMBase::IsShape(aSelectedObject)) { if (!CORBA::is_nil(aSelectedObject) && aRes && GEOMBase::IsShape(aSelectedObject)) {
{ myEditCurrentArgument->setText(aName);
myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
if (myEditCurrentArgument == GroupPoints->LineEdit1) myObject1 = aSelectedObject; // clear selection
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myObject2 = aSelectedObject; disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
myObject1 = aSelectedObject;
if (myObject2->_is_nil())
GroupPoints->PushButton2->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myObject2 = aSelectedObject;
if (myObject1->_is_nil())
GroupPoints->PushButton1->click();
} }
} }
} }
myEditCurrentArgument->setText( aString );
} }
//================================================================================= //=================================================================================
@ -204,11 +223,24 @@ void OperationGUI_GetShapesOnShapeDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
if ( send == GroupPoints->PushButton1 ) myEditCurrentArgument = GroupPoints->LineEdit1; if (send == GroupPoints->PushButton1) {
else if ( send == GroupPoints->PushButton2 ) myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
}
else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2;
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
}
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
SelectionIntoArgument(); // after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
} }
//================================================================================= //=================================================================================
@ -218,7 +250,7 @@ void OperationGUI_GetShapesOnShapeDlg::SetEditCurrentArgument()
void OperationGUI_GetShapesOnShapeDlg::LineEditReturnPressed() void OperationGUI_GetShapesOnShapeDlg::LineEditReturnPressed()
{ {
QLineEdit* send = (QLineEdit*)sender(); QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2 ) if (send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2)
{ {
myEditCurrentArgument = send; myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
@ -232,18 +264,18 @@ void OperationGUI_GetShapesOnShapeDlg::LineEditReturnPressed()
void OperationGUI_GetShapesOnShapeDlg::ActivateThisDialog() void OperationGUI_GetShapesOnShapeDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
globalSelection( GEOM_ALLSHAPES );
connect( myGeomGUI->getApp()->selectionMgr(), // reinit, because some selected objects could be removed
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); Init();
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : when mouse enter onto the QWidget // purpose : when mouse enter onto the QWidget
//================================================================================= //=================================================================================
void OperationGUI_GetShapesOnShapeDlg::enterEvent(QEvent * e) void OperationGUI_GetShapesOnShapeDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
@ -253,32 +285,32 @@ void OperationGUI_GetShapesOnShapeDlg::enterEvent(QEvent * e)
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr OperationGUI_GetShapesOnShapeDlg::createOperation() GEOM::GEOM_IOperations_ptr OperationGUI_GetShapesOnShapeDlg::createOperation()
{ {
return getGeomEngine()->GetIShapesOperations( getStudyId() ); return getGeomEngine()->GetIShapesOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool OperationGUI_GetShapesOnShapeDlg::isValid( QString& msg ) bool OperationGUI_GetShapesOnShapeDlg::isValid(QString&)
{ {
//Handle(SALOME_InteractiveObject) IO = firstIObject(); //Handle(SALOME_InteractiveObject) IO = firstIObject();
//Standard_Boolean testResult; //Standard_Boolean testResult;
//GEOM::GEOM_Object_var anObject = GEOMBase::ConvertIOinGEOMObject( IO, testResult ); //GEOM::GEOM_Object_var anObject = GEOMBase::ConvertIOinGEOMObject(IO, testResult);
//if ( !testResult || anObject->_is_nil() ) //if (!testResult || anObject->_is_nil())
// return false; // return false;
return !CORBA::is_nil( myObject1 ) && !CORBA::is_nil( myObject2 ); return !CORBA::is_nil(myObject1) && !CORBA::is_nil(myObject2);
} }
//================================================================================= //=================================================================================
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool OperationGUI_GetShapesOnShapeDlg::execute( ObjectList& objects ) bool OperationGUI_GetShapesOnShapeDlg::execute (ObjectList& objects)
{ {
int aLimit = GroupPoints->ComboBox1->currentIndex(); int aLimit = GroupPoints->ComboBox1->currentIndex();
switch ( aLimit ) switch (aLimit)
{ {
case 0: aLimit = GEOM::SOLID ; break; case 0: aLimit = GEOM::SOLID ; break;
case 1: aLimit = GEOM::FACE ; break; case 1: aLimit = GEOM::FACE ; break;
@ -288,7 +320,7 @@ bool OperationGUI_GetShapesOnShapeDlg::execute( ObjectList& objects )
} }
GEOM::shape_state aState; GEOM::shape_state aState;
switch ( GroupPoints->ComboBox2->currentIndex() ) switch (GroupPoints->ComboBox2->currentIndex())
{ {
case 0: aState = GEOM::ST_IN; break; case 0: aState = GEOM::ST_IN; break;
case 1: aState = GEOM::ST_OUT; break; case 1: aState = GEOM::ST_OUT; break;
@ -298,20 +330,21 @@ bool OperationGUI_GetShapesOnShapeDlg::execute( ObjectList& objects )
default: break; default: break;
} }
GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations:: GEOM::GEOM_Object_var anObj =
_narrow( getOperation() )->GetShapesOnShapeAsCompound( myObject2, myObject1, GEOM::GEOM_IShapesOperations::_narrow(getOperation())->
(CORBA::Short) aLimit, GetShapesOnShapeAsCompound(myObject2, myObject1,
aState ); (CORBA::Short) aLimit,
aState);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
return objects.size(); return objects.size();
} }
//======================================================================= //=======================================================================
//function : ComboTextChanged //function : ComboTextChanged
//purpose : //purpose :
//======================================================================= //=======================================================================
void OperationGUI_GetShapesOnShapeDlg::ComboTextChanged() void OperationGUI_GetShapesOnShapeDlg::ComboTextChanged()
{ {

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : TransformationGUI_MirrorDlg.cxx // File : TransformationGUI_MirrorDlg.cxx
@ -29,11 +29,12 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
@ -45,258 +46,256 @@
//================================================================================= //=================================================================================
// class : TransformationGUI_MirrorDlg() // class : TransformationGUI_MirrorDlg()
// purpose : Constructs a TransformationGUI_MirrorDlg which is a child of 'parent', with the // purpose : Constructs a TransformationGUI_MirrorDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
TransformationGUI_MirrorDlg::TransformationGUI_MirrorDlg( GeometryGUI* theGeometryGUI, QWidget* parent, TransformationGUI_MirrorDlg::TransformationGUI_MirrorDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl ) bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
{ {
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_MIRROR_POINT" ) ) ); SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_MIRROR_AXE" ) ) ); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MIRROR_POINT")));
QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_MIRROR_PLANE" ) ) ); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MIRROR_AXE")));
QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MIRROR_PLANE")));
QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_MIRROR_TITLE" ) ); setWindowTitle(tr("GEOM_MIRROR_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_MIRROR" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_MIRROR"));
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setIcon( image1 ); mainFrame()->RadioButton2->setIcon(image1);
mainFrame()->RadioButton3->setIcon( image2 ); mainFrame()->RadioButton3->setIcon(image2);
GroupPoints = new DlgRef_2Sel1Spin2Check( centralWidget() ); GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget());
GroupPoints->SpinBox_DX->hide(); GroupPoints->SpinBox_DX->hide();
GroupPoints->TextLabel3->hide(); GroupPoints->TextLabel3->hide();
GroupPoints->CheckButton2->hide(); GroupPoints->CheckButton2->hide();
GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) ); GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS"));
GroupPoints->TextLabel2->setText( tr( "GEOM_POINT_MIRROR" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_POINT_MIRROR"));
GroupPoints->TextLabel2->setFixedWidth( 74 ); GroupPoints->TextLabel2->setFixedWidth(74);
GroupPoints->PushButton1->setIcon( image3 ); GroupPoints->PushButton1->setIcon(image3);
GroupPoints->PushButton2->setIcon( image3 ); GroupPoints->PushButton2->setIcon(image3);
GroupPoints->CheckButton1->setText( tr( "GEOM_CREATE_COPY" ) ); GroupPoints->CheckButton1->setText(tr("GEOM_CREATE_COPY"));
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget( GroupPoints ); layout->addWidget(GroupPoints);
/***************************************************************/ /***************************************************************/
setHelpFileName( "mirror_operation_page.html" ); setHelpFileName("mirror_operation_page.html");
// Activate Create a Copy mode
GroupPoints->CheckButton1->setChecked(true);
CreateCopyModeChanged(true);
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~TransformationGUI_MirrorDlg() // function : ~TransformationGUI_MirrorDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
//================================================================================= //=================================================================================
TransformationGUI_MirrorDlg::~TransformationGUI_MirrorDlg() TransformationGUI_MirrorDlg::~TransformationGUI_MirrorDlg()
{ {
/* no need to delete child widgets, Qt does it all for us */ // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_MirrorDlg::Init() void TransformationGUI_MirrorDlg::Init()
{ {
/* init variables */ // init variables
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly( true );
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
myArgument = GEOM::GEOM_Object::_nil(); myArgument = GEOM::GEOM_Object::_nil();
// Activate Create a Copy mode
GroupPoints->CheckButton1->setChecked( true );
CreateCopyModeChanged( true );
mainFrame()->GroupBoxPublish->show(); mainFrame()->GroupBoxPublish->show();
/* signals and slots connections */ // signals and slots connections
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( CreateCopyModeChanged( bool ) ) );
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName( tr( "GEOM_MIRROR" ) ); connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
ConstructorsClicked( 0 ); initName(tr("GEOM_MIRROR"));
ConstructorsClicked(0);
} }
//================================================================================= //=================================================================================
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
//================================================================================= //=================================================================================
void TransformationGUI_MirrorDlg::ConstructorsClicked( int constructorId ) void TransformationGUI_MirrorDlg::ConstructorsClicked (int constructorId)
{ {
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection();
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit2->clear(); GroupPoints->LineEdit2->clear();
myArgument = GEOM::GEOM_Object::_nil(); myArgument = GEOM::GEOM_Object::_nil();
switch ( constructorId ) { switch (constructorId) {
case 0: /* mirror an object by point */ case 0: // mirror an object by point
GroupPoints->TextLabel2->setText( tr( "GEOM_POINT_MIRROR" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_POINT_MIRROR"));
break; break;
case 1: /* mirror an object by axe */ case 1: // mirror an object by axe
GroupPoints->TextLabel2->setText( tr( "GEOM_AXE_MIRROR" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_AXE_MIRROR"));
break; break;
case 2: /* mirror an object by plane */ case 2: // mirror an object by plane
GroupPoints->TextLabel2->setText( tr( "GEOM_PLANE_MIRROR" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_PLANE_MIRROR"));
break; break;
} }
connect( myGeomGUI->getApp()->selectionMgr(), GroupPoints->PushButton1->click();
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
if (myInitial) {
myInitial = false;
SelectionIntoArgument();
}
else {
displayPreview();
}
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_MirrorDlg::ClickOnOk() void TransformationGUI_MirrorDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_MirrorDlg::ClickOnApply() bool TransformationGUI_MirrorDlg::ClickOnApply()
{ {
if ( !onAccept( GroupPoints->CheckButton1->isChecked() ) ) if (!onAccept(GroupPoints->CheckButton1->isChecked()))
return false; return false;
initName(); initName();
ConstructorsClicked( getConstructorId() ); // activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection has changed // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void TransformationGUI_MirrorDlg::SelectionIntoArgument() void TransformationGUI_MirrorDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); erasePreview();
QString aName; myEditCurrentArgument->setText("");
if (myEditCurrentArgument == GroupPoints->LineEdit1)
myObjects.length(0);
else if (myEditCurrentArgument == GroupPoints->LineEdit2)
myArgument = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
QString aName;
if (myEditCurrentArgument == GroupPoints->LineEdit1) { if (myEditCurrentArgument == GroupPoints->LineEdit1) {
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName); int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
if ( aNbSel < 1 ) { if (aNbSel < 1)
myObjects.length(0);
return; return;
}
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects); GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
if (!myObjects.length()) if (!myObjects.length())
return; return;
if (aNbSel != 1) else
aName = tr("%1_objects").arg(aNbSel); myEditCurrentArgument->setText(aName);
} }
else if (myEditCurrentArgument == GroupPoints->LineEdit2) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1)
myArgument = GEOM::GEOM_Object::_nil();
return; return;
}
// nbSel == 1
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); myArgument = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
myArgument = aSelectedObject;
if (!testResult || CORBA::is_nil(myArgument)) if (!testResult || CORBA::is_nil(myArgument))
return; return;
aName = GEOMBase::GetName(aSelectedObject); aName = GEOMBase::GetName(myArgument);
if (testResult && !aSelectedObject->_is_nil()) { if (testResult && !myArgument->_is_nil()) {
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { if (GEOMBase::GetShape(myArgument, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if ( getConstructorId() == 1 ) if (getConstructorId() == 1)
aNeedType = TopAbs_EDGE; aNeedType = TopAbs_EDGE;
else if ( getConstructorId() == 2 ) else if (getConstructorId() == 2)
aNeedType = TopAbs_FACE; aNeedType = TopAbs_FACE;
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap); aSelMgr->GetIndexes(aSelList.First(), aMap);
if ( aMap.Extent() == 1 ) { if (aMap.Extent() == 1) {
int anIndex = aMap( 1 ); int anIndex = aMap(1);
if ( aNeedType == TopAbs_VERTEX ) if (aNeedType == TopAbs_VERTEX)
aName += QString( ":vertex_%1" ).arg( anIndex ); aName += QString(":vertex_%1").arg(anIndex);
else else
aName += QString( ":edge_%1" ).arg( anIndex ); aName += QString(":edge_%1").arg(anIndex);
//Find SubShape Object in Father //Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = findObjectInFather( aSelectedObject, aName ); GEOM::GEOM_Object_var aFindedObject = findObjectInFather(myArgument, aName);
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations( getStudyId() ); getGeomEngine()->GetIShapesOperations(getStudyId());
myArgument = aShapesOp->GetSubShape( aSelectedObject, anIndex ); myArgument = aShapesOp->GetSubShape(myArgument, anIndex);
} }
else { else {
myArgument = aFindedObject; // get Object from study myArgument = aFindedObject; // get Object from study
} }
} }
else { else {
if ( aShape.ShapeType() != aNeedType ) { if (aShape.ShapeType() != aNeedType) {
myArgument = GEOM::GEOM_Object::_nil(); myArgument = GEOM::GEOM_Object::_nil();
aName = ""; aName = "";
} }
} }
} }
} }
myEditCurrentArgument->setText(aName);
if (!myArgument->_is_nil() && !myObjects.length())
GroupPoints->PushButton1->click();
} }
myEditCurrentArgument->setText( aName );
// clear selection
displayPreview(); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void TransformationGUI_MirrorDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -304,30 +303,60 @@ void TransformationGUI_MirrorDlg::LineEditReturnPressed()
void TransformationGUI_MirrorDlg::SetEditCurrentArgument() void TransformationGUI_MirrorDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); globalSelection();
if ( send == GroupPoints->PushButton1 ) { if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
} }
else if ( send == GroupPoints->PushButton2 ) { else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit2;
switch ( getConstructorId() ) {
switch (getConstructorId()) {
case 0: case 0:
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
break; break;
case 1: case 1:
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
break; break;
case 2: case 2:
globalSelection( GEOM_PLANE ); globalSelection(GEOM_PLANE);
break; break;
} }
}
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
SelectionIntoArgument(); // after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
} }
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void TransformationGUI_MirrorDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if (send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
@ -336,118 +365,116 @@ void TransformationGUI_MirrorDlg::SetEditCurrentArgument()
void TransformationGUI_MirrorDlg::ActivateThisDialog() void TransformationGUI_MirrorDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
ConstructorsClicked( getConstructorId() );
}
// reinit, because some selected objects could be removed
Init();
}
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : when mouse enter onto the QWidget // purpose : when mouse enter onto the QWidget
//================================================================================= //=================================================================================
void TransformationGUI_MirrorDlg::enterEvent( QEvent* ) void TransformationGUI_MirrorDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr TransformationGUI_MirrorDlg::createOperation() GEOM::GEOM_IOperations_ptr TransformationGUI_MirrorDlg::createOperation()
{ {
return getGeomEngine()->GetITransformOperations( getStudyId() ); return getGeomEngine()->GetITransformOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_MirrorDlg::isValid( QString& /*msg*/ ) bool TransformationGUI_MirrorDlg::isValid (QString& /*msg*/)
{ {
return !( myObjects.length() == 0 || myArgument->_is_nil() ); return !(myObjects.length() == 0 || myArgument->_is_nil());
} }
//================================================================================= //=================================================================================
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_MirrorDlg::execute( ObjectList& objects ) bool TransformationGUI_MirrorDlg::execute (ObjectList& objects)
{ {
bool res = false; bool res = false;
bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked(); bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
{ {
if ( toCreateCopy ) { if (toCreateCopy) {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
MirrorPointCopy( myObjects[i], myArgument ); MirrorPointCopy(myObjects[i], myArgument);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
} }
else { else {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
MirrorPoint( myObjects[i], myArgument ); MirrorPoint(myObjects[i], myArgument);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
} }
res = true; res = true;
break; break;
} }
case 1: case 1:
{ {
if ( toCreateCopy ) { if (toCreateCopy) {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
MirrorAxisCopy( myObjects[i], myArgument ); MirrorAxisCopy(myObjects[i], myArgument);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
} }
else { else {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
MirrorAxis( myObjects[i], myArgument ); MirrorAxis(myObjects[i], myArgument);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
} }
res = true; res = true;
break; break;
} }
case 2: case 2:
{ {
if ( toCreateCopy ) { if (toCreateCopy) {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPlaneCopy( myObjects[i], myArgument ); anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
if ( !anObj->_is_nil() ) MirrorPlaneCopy(myObjects[i], myArgument);
objects.push_back( anObj._retn() ); if (!anObj->_is_nil())
} objects.push_back(anObj._retn());
}
} }
else { else {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPlane( myObjects[i], myArgument ); anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
if ( !anObj->_is_nil() ) MirrorPlane(myObjects[i], myArgument);
objects.push_back( anObj._retn() ); if (!anObj->_is_nil())
} objects.push_back(anObj._retn());
}
} }
res = true; res = true;
break; break;
} }
} }
return res; return res;
} }
@ -455,14 +482,14 @@ bool TransformationGUI_MirrorDlg::execute( ObjectList& objects )
// function : restoreSubShapes // function : restoreSubShapes
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_MirrorDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy, void TransformationGUI_MirrorDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject ) SALOMEDS::SObject_ptr theSObject)
{ {
if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) { if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored // empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(), getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
/*theFindMethod=*/GEOM::FSM_Transformed, /*theFindMethod=*/GEOM::FSM_Transformed,
/*theInheritFirstArg=*/true ); /*theInheritFirstArg=*/true);
} }
} }
@ -470,9 +497,9 @@ void TransformationGUI_MirrorDlg::restoreSubShapes( SALOMEDS::Study_ptr theStu
// function : CreateCopyModeChanged() // function : CreateCopyModeChanged()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_MirrorDlg::CreateCopyModeChanged( bool isCreateCopy ) void TransformationGUI_MirrorDlg::CreateCopyModeChanged (bool isCreateCopy)
{ {
mainFrame()->GroupBoxName->setEnabled( isCreateCopy ); mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
} }
//================================================================================= //=================================================================================
@ -482,10 +509,10 @@ void TransformationGUI_MirrorDlg::CreateCopyModeChanged( bool isCreateCopy )
void TransformationGUI_MirrorDlg::addSubshapesToStudy() void TransformationGUI_MirrorDlg::addSubshapesToStudy()
{ {
bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked(); bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
if ( toCreateCopy ) { if (toCreateCopy) {
QMap<QString, GEOM::GEOM_Object_var> objMap; QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
objMap[GroupPoints->LineEdit2->text()] = myArgument; objMap[GroupPoints->LineEdit2->text()] = myArgument;
break; break;
@ -495,6 +522,6 @@ void TransformationGUI_MirrorDlg::addSubshapesToStudy()
case 2: case 2:
return; return;
} }
addSubshapesToFather( objMap ); addSubshapesToFather(objMap);
} }
} }

View File

@ -58,6 +58,9 @@ private:
private: private:
GEOM::GEOM_Object_var myArgument; GEOM::GEOM_Object_var myArgument;
GEOM::ListOfGO myObjects; GEOM::ListOfGO myObjects;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_2Sel1Spin2Check* GroupPoints; DlgRef_2Sel1Spin2Check* GroupPoints;

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : TransformationGUI_MultiRotationDlg.cxx // File : TransformationGUI_MultiRotationDlg.cxx
@ -29,11 +29,12 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
@ -45,65 +46,65 @@
//================================================================================= //=================================================================================
// class : TransformationGUI_MultiRotationDlg() // class : TransformationGUI_MultiRotationDlg()
// purpose : Constructs a TransformationGUI_MultiRotationDlg which is a child of 'parent', with the // purpose : Constructs a TransformationGUI_MultiRotationDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg
( GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl ) (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
{ {
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_MULTIROTATION_SIMPLE" ) ) ); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTIROTATION_SIMPLE")));
QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_MULTIROTATION_DOUBLE" ) ) ); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTIROTATION_DOUBLE")));
QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_MULTIROTATION_TITLE" ) ); setWindowTitle(tr("GEOM_MULTIROTATION_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_MULTIROTATION" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_MULTIROTATION"));
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setIcon( image1 ); mainFrame()->RadioButton2->setIcon(image1);
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
GroupPoints = new DlgRef_2Sel1Spin( centralWidget() ); GroupPoints = new DlgRef_2Sel1Spin(centralWidget());
GroupPoints->GroupBox1->setTitle( tr( "GEOM_MULTIROTATION_SIMPLE" ) ); GroupPoints->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_SIMPLE"));
GroupPoints->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) ); GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
GroupPoints->TextLabel2->setText( tr( "GEOM_VECTOR" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR"));
GroupPoints->TextLabel3->setText( tr( "GEOM_NB_TIMES" ) ); GroupPoints->TextLabel3->setText(tr("GEOM_NB_TIMES"));
GroupPoints->PushButton1->setIcon( image2 ); GroupPoints->PushButton1->setIcon(image2);
GroupPoints->PushButton2->setIcon( image2 ); GroupPoints->PushButton2->setIcon(image2);
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
GroupDimensions = new DlgRef_2Sel4Spin1Check( centralWidget() ); GroupDimensions = new DlgRef_2Sel4Spin1Check(centralWidget());
GroupDimensions->GroupBox1->setTitle( tr( "GEOM_MULTIROTATION_DOUBLE" ) ); GroupDimensions->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_DOUBLE"));
GroupDimensions->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) ); GroupDimensions->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
GroupDimensions->TextLabel2->setText( tr( "GEOM_VECTOR" ) ); GroupDimensions->TextLabel2->setText(tr("GEOM_VECTOR"));
GroupDimensions->TextLabel3->setText( tr( "GEOM_ANGLE" ) ); GroupDimensions->TextLabel3->setText(tr("GEOM_ANGLE"));
GroupDimensions->TextLabel4->setText( tr( "GEOM_NB_TIMES" ) ); GroupDimensions->TextLabel4->setText(tr("GEOM_NB_TIMES"));
GroupDimensions->TextLabel5->setText( tr( "GEOM_STEP" ) ); GroupDimensions->TextLabel5->setText(tr("GEOM_STEP"));
GroupDimensions->TextLabel6->setText( tr( "GEOM_NB_TIMES" ) ); GroupDimensions->TextLabel6->setText(tr("GEOM_NB_TIMES"));
GroupDimensions->CheckButton1->setText( tr( "GEOM_REVERSE" ) ); GroupDimensions->CheckButton1->setText(tr("GEOM_REVERSE"));
GroupDimensions->PushButton1->setIcon( image2 ); GroupDimensions->PushButton1->setIcon(image2);
GroupDimensions->PushButton2->setIcon( image2 ); GroupDimensions->PushButton2->setIcon(image2);
GroupDimensions->LineEdit1->setReadOnly( true ); GroupDimensions->LineEdit1->setReadOnly(true);
GroupDimensions->LineEdit2->setReadOnly( true ); GroupDimensions->LineEdit2->setReadOnly(true);
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget( GroupPoints ); layout->addWidget(GroupPoints);
layout->addWidget( GroupDimensions ); layout->addWidget(GroupDimensions);
/***************************************************************/ /***************************************************************/
setHelpFileName( "multi_rotation_operation_page.html" ); setHelpFileName("multi_rotation_operation_page.html");
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~TransformationGUI_MultiRotationDlg() // function : ~TransformationGUI_MultiRotationDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -113,73 +114,80 @@ TransformationGUI_MultiRotationDlg::~TransformationGUI_MultiRotationDlg()
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_MultiRotationDlg::Init() void TransformationGUI_MultiRotationDlg::Init()
{ {
/* Get setting of step value from file configuration */ // Get setting of step value from file configuration
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 ); double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
double SpecificStep1 = 5; double SpecificStep1 = 5;
double SpecificStep2 = 1; double SpecificStep2 = 1;
/* min, max, step and decimals for spin boxes & initial values */ // min, max, step and decimals for spin boxes & initial values
initSpinBox( GroupPoints->SpinBox_DX, 1.0, MAX_NUMBER, SpecificStep2, 10 ); initSpinBox(GroupPoints->SpinBox_DX, 1.0, MAX_NUMBER, SpecificStep2, 10);
GroupPoints->SpinBox_DX->setValue( myNbTimes1 ); GroupPoints->SpinBox_DX->setValue(myNbTimes1);
initSpinBox( GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, SpecificStep1, 10 ); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, SpecificStep1, 10); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( GroupDimensions->SpinBox_DY1, 1.0, MAX_NUMBER, SpecificStep2, 10 ); initSpinBox(GroupDimensions->SpinBox_DY1, 1.0, MAX_NUMBER, SpecificStep2, 10);
initSpinBox( GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step, 10 ); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step, 10); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( GroupDimensions->SpinBox_DY2, 1.0, MAX_NUMBER, SpecificStep2, 10 ); initSpinBox(GroupDimensions->SpinBox_DY2, 1.0, MAX_NUMBER, SpecificStep2, 10);
GroupDimensions->SpinBox_DX1->setValue( myAng ); GroupDimensions->SpinBox_DX1->setValue(myAng);
GroupDimensions->SpinBox_DY1->setValue( myNbTimes1 ); GroupDimensions->SpinBox_DY1->setValue(myNbTimes1);
GroupDimensions->SpinBox_DX2->setValue( myStep ); GroupDimensions->SpinBox_DX2->setValue(myStep);
GroupDimensions->SpinBox_DY2->setValue( myNbTimes2 ); GroupDimensions->SpinBox_DY2->setValue(myNbTimes2);
/* signals and slots connections */ // init variables
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); myAng = 45.0;
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); myStep = 50.0;
myNbTimes1 = myNbTimes2 = 2;
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); GroupDimensions->LineEdit1->setText("");
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); GroupDimensions->LineEdit2->setText("");
connect( GroupDimensions->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupDimensions->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); myBase = myVector = GEOM::GEOM_Object::_nil();
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupDimensions->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupDimensions->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); // signals and slots connections
connect( GroupDimensions->SpinBox_DX1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect( GroupDimensions->SpinBox_DY1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect( GroupDimensions->SpinBox_DX2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupDimensions->SpinBox_DY2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
connect( GroupDimensions->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( ReverseAngle() ) ); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( myGeomGUI->getApp()->selectionMgr(), connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
initName( tr( "GEOM_MULTIROTATION" ) ); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupDimensions->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupDimensions->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
ConstructorsClicked( 0 ); connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupDimensions->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupDimensions->SpinBox_DY1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupDimensions->SpinBox_DY2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
connect(GroupDimensions->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseAngle()));
initName(tr("GEOM_MULTIROTATION"));
ConstructorsClicked(0);
} }
//================================================================================= //=================================================================================
// function : SetDoubleSpinBoxStep() // function : SetDoubleSpinBoxStep()
// purpose : Double spin box management // purpose : Double spin box management
//================================================================================= //=================================================================================
void TransformationGUI_MultiRotationDlg::SetDoubleSpinBoxStep( double step ) void TransformationGUI_MultiRotationDlg::SetDoubleSpinBoxStep (double step)
{ {
GroupPoints->SpinBox_DX->setSingleStep(step); GroupPoints->SpinBox_DX->setSingleStep(step);
GroupDimensions->SpinBox_DX1->setSingleStep(step); GroupDimensions->SpinBox_DX1->setSingleStep(step);
@ -192,160 +200,178 @@ void TransformationGUI_MultiRotationDlg::SetDoubleSpinBoxStep( double step )
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
//================================================================================= //=================================================================================
void TransformationGUI_MultiRotationDlg::ConstructorsClicked( int constructorId ) void TransformationGUI_MultiRotationDlg::ConstructorsClicked (int constructorId)
{ {
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myAng = 45.0; switch (constructorId) {
myStep = 50.0; case 0: // Rotate simple
myNbTimes1 = myNbTimes2 = 2;
globalSelection( GEOM_ALLSHAPES );
switch ( constructorId ) {
case 0: /* Rotate simple */
{ {
GroupDimensions->hide(); GroupDimensions->hide();
GroupPoints->show(); GroupPoints->show();
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit1->setText( "" ); GroupPoints->LineEdit2->setText("");
GroupPoints->LineEdit2->setText( "" ); myBase = myVector = GEOM::GEOM_Object::_nil();
GroupPoints->SpinBox_DX->setValue( myNbTimes1 ); GroupPoints->SpinBox_DX->setValue(myNbTimes1);
break; GroupPoints->PushButton1->click();
} }
case 1: /* Rotate double */ break;
case 1: // Rotate double
{ {
GroupPoints->hide(); GroupPoints->hide();
GroupDimensions->show(); GroupDimensions->show();
myEditCurrentArgument = GroupDimensions->LineEdit1; GroupDimensions->LineEdit1->setText("");
GroupDimensions->LineEdit1->setText( "" ); GroupDimensions->LineEdit2->setText("");
GroupDimensions->LineEdit2->setText( "" ); myBase = myVector = GEOM::GEOM_Object::_nil();
GroupDimensions->SpinBox_DX1->setValue( myAng ); GroupDimensions->SpinBox_DX1->setValue(myAng);
GroupDimensions->SpinBox_DY1->setValue( myNbTimes1 ); GroupDimensions->SpinBox_DY1->setValue(myNbTimes1);
GroupDimensions->SpinBox_DX2->setValue( myStep ); GroupDimensions->SpinBox_DX2->setValue(myStep);
GroupDimensions->SpinBox_DY2->setValue( myNbTimes2 ); GroupDimensions->SpinBox_DY2->setValue(myNbTimes2);
break; GroupDimensions->PushButton1->click();
} }
break;
} }
qApp->processEvents(); qApp->processEvents();
updateGeometry(); updateGeometry();
resize( minimumSize() ); resize(minimumSize());
myEditCurrentArgument->setFocus(); if (myInitial) {
myBase = myVector = GEOM::GEOM_Object::_nil(); myInitial = false;
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), SelectionIntoArgument();
this, SLOT( SelectionIntoArgument() ) ); }
else {
displayPreview();
}
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_MultiRotationDlg::ClickOnOk() void TransformationGUI_MultiRotationDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_MultiRotationDlg::ClickOnApply() bool TransformationGUI_MultiRotationDlg::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
ConstructorsClicked( getConstructorId() ); // activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() void TransformationGUI_MultiRotationDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); erasePreview();
myEditCurrentArgument->setText("");
if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
myEditCurrentArgument == GroupDimensions->LineEdit1)
myBase = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
myEditCurrentArgument == GroupDimensions->LineEdit2)
myVector = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if ( aSelList.Extent() != 1 ) { if (aSelList.Extent() != 1)
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ||
myEditCurrentArgument == GroupDimensions->LineEdit1 )
myBase = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
myEditCurrentArgument == GroupDimensions->LineEdit2 )
myVector = GEOM::GEOM_Object::_nil();
return; return;
}
// nbSel == 1 // nbSel == 1
Standard_Boolean testResult = Standard_False;; Standard_Boolean testResult = Standard_False;;
GEOM::GEOM_Object_var aSelectedObject = GEOM::GEOM_Object_var aSelectedObject =
GEOMBase::ConvertIOinGEOMObject( aSelList.First(), testResult ); GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if ( !testResult || CORBA::is_nil( aSelectedObject) || !GEOMBase::IsShape( aSelectedObject ) ) if (!testResult || CORBA::is_nil(aSelectedObject) || !GEOMBase::IsShape(aSelectedObject))
return; return;
QString aName = GEOMBase::GetName( aSelectedObject ); QString aName = GEOMBase::GetName(aSelectedObject);
if ( myEditCurrentArgument == GroupPoints->LineEdit1 || if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
myEditCurrentArgument == GroupDimensions->LineEdit1 ) myEditCurrentArgument == GroupDimensions->LineEdit1)
myBase = aSelectedObject; myBase = aSelectedObject;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 || else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
myEditCurrentArgument == GroupDimensions->LineEdit2 ) { myEditCurrentArgument == GroupDimensions->LineEdit2) {
if ( testResult && !aSelectedObject->_is_nil() ) { TopoDS_Shape aShape;
TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { TColStd_IndexedMapOfInteger aMap;
TColStd_IndexedMapOfInteger aMap; aSelMgr->GetIndexes(aSelList.First(), aMap);
aSelMgr->GetIndexes( aSelList.First(), aMap ); if (aMap.Extent() == 1) {
if ( aMap.Extent() == 1 ) { int anIndex = aMap(1);
int anIndex = aMap( 1 ); aName += QString(":edge_%1").arg(anIndex);
aName += QString( ":edge_%1" ).arg( anIndex );
//Find SubShape Object in Father
//Find SubShape Object in Father GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
GEOM::GEOM_Object_var aFindedObject = findObjectInFather( aSelectedObject, aName );
if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study GEOM::GEOM_IShapesOperations_var aShapesOp =
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
getGeomEngine()->GetIShapesOperations( getStudyId() ); myVector = aShapesOp->GetSubShape(aSelectedObject, anIndex);
myVector = aShapesOp->GetSubShape(aSelectedObject, anIndex); }
} else {
else { myVector = aFindedObject; // get existing object
myVector = aFindedObject; // get existing object }
} }
} else {
else { if (aShape.ShapeType() != TopAbs_EDGE) {
if ( aShape.ShapeType() != TopAbs_EDGE ) { aSelectedObject = GEOM::GEOM_Object::_nil();
aSelectedObject = GEOM::GEOM_Object::_nil(); aName = "";
aName = ""; }
} myVector = aSelectedObject;
myVector = aSelectedObject;
}
} }
} }
} }
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText(aName);
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
if (!myBase->_is_nil() && myVector->_is_nil())
GroupPoints->PushButton2->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
if (!myVector->_is_nil() && myBase->_is_nil())
GroupPoints->PushButton1->click();
}
else if (myEditCurrentArgument == GroupDimensions->LineEdit1) {
if (!myBase->_is_nil() && myVector->_is_nil())
GroupDimensions->PushButton2->click();
}
else if (myEditCurrentArgument == GroupDimensions->LineEdit2) {
if (!myVector->_is_nil() && myBase->_is_nil())
GroupDimensions->PushButton1->click();
}
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -353,27 +379,50 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument()
void TransformationGUI_MultiRotationDlg::SetEditCurrentArgument() void TransformationGUI_MultiRotationDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
globalSelection( GEOM_ALLSHAPES );
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if ( send == GroupPoints->PushButton1 ) { globalSelection(GEOM_ALLSHAPES);
if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
} }
else if ( send == GroupPoints->PushButton2 ) { else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit2;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
} }
else if ( send == GroupDimensions->PushButton1 ) { else if (send == GroupDimensions->PushButton1) {
myEditCurrentArgument = GroupDimensions->LineEdit1; myEditCurrentArgument = GroupDimensions->LineEdit1;
GroupDimensions->PushButton2->setDown(false);
GroupDimensions->LineEdit2->setEnabled(false);
} }
else if ( send == GroupDimensions->PushButton2 ) { else if (send == GroupDimensions->PushButton2) {
myEditCurrentArgument = GroupDimensions->LineEdit2; myEditCurrentArgument = GroupDimensions->LineEdit2;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
GroupDimensions->PushButton1->setDown(false);
GroupDimensions->LineEdit1->setEnabled(false);
} }
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
SelectionIntoArgument(); // after setFocus(), because it will be setDown(false) when loses focus
} send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
}
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
@ -382,14 +431,13 @@ void TransformationGUI_MultiRotationDlg::SetEditCurrentArgument()
void TransformationGUI_MultiRotationDlg::LineEditReturnPressed() void TransformationGUI_MultiRotationDlg::LineEditReturnPressed()
{ {
QLineEdit* send = (QLineEdit*)sender(); QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 || if (send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 ||
send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2 ) { send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2) {
myEditCurrentArgument = send; myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -397,45 +445,41 @@ void TransformationGUI_MultiRotationDlg::LineEditReturnPressed()
void TransformationGUI_MultiRotationDlg::ActivateThisDialog() void TransformationGUI_MultiRotationDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
ConstructorsClicked( getConstructorId() );
}
// reinit, because some selected objects could be removed
Init();
}
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_MultiRotationDlg::enterEvent( QEvent* ) void TransformationGUI_MultiRotationDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox( double newValue ) void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox (double newValue)
{ {
QObject* send = (QObject*)sender(); QObject* send = (QObject*)sender();
if ( send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DY1 ) if (send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DY1)
myNbTimes1 = (int)newValue; myNbTimes1 = (int)newValue;
else if ( send == GroupDimensions->SpinBox_DX1 ) else if (send == GroupDimensions->SpinBox_DX1)
myAng = newValue; myAng = newValue;
else if ( send == GroupDimensions->SpinBox_DX2 ) else if (send == GroupDimensions->SpinBox_DX2)
myStep = newValue; myStep = newValue;
else if ( send == GroupDimensions->SpinBox_DY2 ) else if (send == GroupDimensions->SpinBox_DY2)
myNbTimes2 = (int)newValue; myNbTimes2 = (int)newValue;
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : ReverseAngle() // function : ReverseAngle()
// purpose : 'state' not used here // purpose : 'state' not used here
@ -446,64 +490,62 @@ void TransformationGUI_MultiRotationDlg::ReverseAngle()
int aConstructorId = getConstructorId(); int aConstructorId = getConstructorId();
if ( aConstructorId == 0 ) if (aConstructorId == 0)
GroupPoints->SpinBox_DX->setValue( myAng ); GroupPoints->SpinBox_DX->setValue(myAng);
else if ( aConstructorId == 1 ) else if (aConstructorId == 1)
GroupDimensions->SpinBox_DX1->setValue( myAng ); GroupDimensions->SpinBox_DX1->setValue(myAng);
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr TransformationGUI_MultiRotationDlg::createOperation() GEOM::GEOM_IOperations_ptr TransformationGUI_MultiRotationDlg::createOperation()
{ {
return myGeomGUI->GetGeomGen()->GetITransformOperations( getStudyId() ); return getGeomEngine()->GetITransformOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_MultiRotationDlg::isValid( QString& /*msg*/ ) bool TransformationGUI_MultiRotationDlg::isValid (QString& /*msg*/)
{ {
return !( myBase->_is_nil() || myVector->_is_nil() ); return !(myBase->_is_nil() || myVector->_is_nil());
} }
//================================================================================= //=================================================================================
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_MultiRotationDlg::execute( ObjectList& objects ) bool TransformationGUI_MultiRotationDlg::execute (ObjectList& objects)
{ {
bool res = false; bool res = false;
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0 : case 0:
if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVector ) ) { if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVector)) {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
MultiRotate1D( myBase, myVector, myNbTimes1 ); MultiRotate1D(myBase, myVector, myNbTimes1);
res = true; res = true;
} }
break; break;
case 1 : case 1:
if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVector ) ) { if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVector)) {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
MultiRotate2D( myBase, myVector, myAng, myNbTimes1, myStep, myNbTimes2 ); MultiRotate2D(myBase, myVector, myAng, myNbTimes1, myStep, myNbTimes2);
res = true; res = true;
} }
break; break;
} }
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
return res; return res;
} }
@ -514,8 +556,8 @@ bool TransformationGUI_MultiRotationDlg::execute( ObjectList& objects )
void TransformationGUI_MultiRotationDlg::addSubshapesToStudy() void TransformationGUI_MultiRotationDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap; QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
objMap[GroupPoints->LineEdit2->text()] = myVector; objMap[GroupPoints->LineEdit2->text()] = myVector;
break; break;
@ -523,5 +565,5 @@ void TransformationGUI_MultiRotationDlg::addSubshapesToStudy()
objMap[GroupDimensions->LineEdit2->text()] = myVector; objMap[GroupDimensions->LineEdit2->text()] = myVector;
break; break;
} }
addSubshapesToFather( objMap ); addSubshapesToFather(objMap);
} }

View File

@ -61,6 +61,9 @@ private:
int myNbTimes2; int myNbTimes2;
Standard_Real myAng; Standard_Real myAng;
Standard_Real myStep; Standard_Real myStep;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_2Sel1Spin* GroupPoints; DlgRef_2Sel1Spin* GroupPoints;
DlgRef_2Sel4Spin1Check* GroupDimensions; DlgRef_2Sel4Spin1Check* GroupDimensions;

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : TransformationGUI_MultiTranslationDlg.cxx // File : TransformationGUI_MultiTranslationDlg.cxx
@ -29,11 +29,12 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
@ -45,71 +46,71 @@
//================================================================================= //=================================================================================
// class : TransformationGUI_MultiTranslationDlg() // class : TransformationGUI_MultiTranslationDlg()
// purpose : Constructs a TransformationGUI_MultiTranslationDlg which is a child of 'parent', with the // purpose : Constructs a TransformationGUI_MultiTranslationDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg
( GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl ) (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
{ {
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_MULTITRANSLATION_SIMPLE" ) ) ); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_SIMPLE")));
QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_MULTITRANSLATION_DOUBLE" ) ) ); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_DOUBLE")));
QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_MULTITRANSLATION_TITLE" ) ); setWindowTitle(tr("GEOM_MULTITRANSLATION_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_MULTITRANSLATION" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_MULTITRANSLATION"));
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setIcon( image1 ); mainFrame()->RadioButton2->setIcon(image1);
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
GroupPoints = new DlgRef_2Sel2Spin1Check( centralWidget() ); GroupPoints = new DlgRef_2Sel2Spin1Check(centralWidget());
GroupPoints->GroupBox1->setTitle( tr( "GEOM_MULTITRANSLATION_SIMPLE" ) ); GroupPoints->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_SIMPLE"));
GroupPoints->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) ); GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
GroupPoints->TextLabel2->setText( tr( "GEOM_VECTOR_U" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR_U"));
GroupPoints->TextLabel3->setText( tr( "GEOM_STEP_U" ) ); GroupPoints->TextLabel3->setText(tr("GEOM_STEP_U"));
GroupPoints->TextLabel4->setText( tr( "GEOM_NB_TIMES_U" ) ); GroupPoints->TextLabel4->setText(tr("GEOM_NB_TIMES_U"));
GroupPoints->CheckButton1->setText( tr( "GEOM_REVERSE_U" ) ); GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE_U"));
GroupPoints->PushButton1->setIcon( image2 ); GroupPoints->PushButton1->setIcon(image2);
GroupPoints->PushButton2->setIcon( image2 ); GroupPoints->PushButton2->setIcon(image2);
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
GroupDimensions = new DlgRef_3Sel4Spin2Check( centralWidget() ); GroupDimensions = new DlgRef_3Sel4Spin2Check(centralWidget());
GroupDimensions->GroupBox1->setTitle( tr( "GEOM_MULTITRANSLATION_DOUBLE" ) ); GroupDimensions->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_DOUBLE"));
GroupDimensions->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) ); GroupDimensions->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
GroupDimensions->TextLabel2->setText( tr( "GEOM_VECTOR_U" ) ); GroupDimensions->TextLabel2->setText(tr("GEOM_VECTOR_U"));
GroupDimensions->TextLabel3->setText( tr( "GEOM_VECTOR_V" ) ); GroupDimensions->TextLabel3->setText(tr("GEOM_VECTOR_V"));
GroupDimensions->TextLabel4->setText( tr( "GEOM_STEP_U" ) ); GroupDimensions->TextLabel4->setText(tr("GEOM_STEP_U"));
GroupDimensions->TextLabel5->setText( tr( "GEOM_NB_TIMES_U" ) ); GroupDimensions->TextLabel5->setText(tr("GEOM_NB_TIMES_U"));
GroupDimensions->TextLabel6->setText( tr( "GEOM_STEP_V" ) ); GroupDimensions->TextLabel6->setText(tr("GEOM_STEP_V"));
GroupDimensions->TextLabel7->setText( tr( "GEOM_NB_TIMES_V" ) ); GroupDimensions->TextLabel7->setText(tr("GEOM_NB_TIMES_V"));
GroupDimensions->CheckButton1->setText( tr( "GEOM_REVERSE_U" ) ); GroupDimensions->CheckButton1->setText(tr("GEOM_REVERSE_U"));
GroupDimensions->CheckButton2->setText( tr( "GEOM_REVERSE_V" ) ); GroupDimensions->CheckButton2->setText(tr("GEOM_REVERSE_V"));
GroupDimensions->PushButton1->setIcon( image2 ); GroupDimensions->PushButton1->setIcon(image2);
GroupDimensions->PushButton2->setIcon( image2 ); GroupDimensions->PushButton2->setIcon(image2);
GroupDimensions->PushButton3->setIcon( image2 ); GroupDimensions->PushButton3->setIcon(image2);
GroupDimensions->LineEdit1->setReadOnly( true ); GroupDimensions->LineEdit1->setReadOnly(true);
GroupDimensions->LineEdit2->setReadOnly( true ); GroupDimensions->LineEdit2->setReadOnly(true);
GroupDimensions->LineEdit3->setReadOnly( true ); GroupDimensions->LineEdit3->setReadOnly(true);
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget( GroupPoints ); layout->addWidget(GroupPoints);
layout->addWidget( GroupDimensions ); layout->addWidget(GroupDimensions);
/***************************************************************/ /***************************************************************/
setHelpFileName( "multi_translation_operation_page.html" ); setHelpFileName("multi_translation_operation_page.html");
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~TransformationGUI_MultiTranslationDlg() // function : ~TransformationGUI_MultiTranslationDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -119,78 +120,86 @@ TransformationGUI_MultiTranslationDlg::~TransformationGUI_MultiTranslationDlg()
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_MultiTranslationDlg::Init() void TransformationGUI_MultiTranslationDlg::Init()
{ {
/* Get setting of step value from file configuration */ // Get setting of step value from file configuration
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 ); double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
double SpecificStep = 1; double SpecificStep = 1;
/* min, max, step and decimals for spin boxes & initial values */ // min, max, step and decimals for spin boxes & initial values
initSpinBox( GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, 10 ); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, 10); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( GroupPoints->SpinBox_DY, 1.0, MAX_NUMBER, SpecificStep, 10 ); initSpinBox(GroupPoints->SpinBox_DY, 1.0, MAX_NUMBER, SpecificStep, 10);
GroupPoints->SpinBox_DX->setValue( myStepU ); GroupPoints->SpinBox_DX->setValue(myStepU);
GroupPoints->SpinBox_DY->setValue( myNbTimesU ); GroupPoints->SpinBox_DY->setValue(myNbTimesU);
initSpinBox( GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, step, 10 ); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, step, 10); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( GroupDimensions->SpinBox_DY1, 1.0, MAX_NUMBER, SpecificStep, 10 ); initSpinBox(GroupDimensions->SpinBox_DY1, 1.0, MAX_NUMBER, SpecificStep, 10);
initSpinBox( GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step, 10 ); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step, 10); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( GroupDimensions->SpinBox_DY2, 1.0, MAX_NUMBER, SpecificStep, 10 ); initSpinBox(GroupDimensions->SpinBox_DY2, 1.0, MAX_NUMBER, SpecificStep, 10);
GroupDimensions->SpinBox_DX1->setValue( myStepU ); GroupDimensions->SpinBox_DX1->setValue(myStepU);
GroupDimensions->SpinBox_DY1->setValue( myNbTimesU ); GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
GroupDimensions->SpinBox_DX2->setValue( myStepV ); GroupDimensions->SpinBox_DX2->setValue(myStepV);
GroupDimensions->SpinBox_DY2->setValue( myNbTimesV ); GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
/* signals and slots connections */ // init variables
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); myStepU = myStepV = 50.0;
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); myNbTimesU = myNbTimesV = 2;
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); GroupDimensions->LineEdit1->setText("");
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); GroupDimensions->LineEdit2->setText("");
connect( GroupDimensions->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); GroupDimensions->LineEdit3->setText("");
connect( GroupDimensions->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupDimensions->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); myBase = myVectorU = myVectorV = GEOM::GEOM_Object::_nil();
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupDimensions->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupDimensions->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupDimensions->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); // signals and slots connections
connect( GroupPoints->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect( GroupDimensions->SpinBox_DX1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect( GroupDimensions->SpinBox_DY1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupDimensions->SpinBox_DX2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupDimensions->SpinBox_DY2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
connect( GroupPoints->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( ReverseStepU() ) ); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupDimensions->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( ReverseStepU() ) ); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupDimensions->CheckButton2, SIGNAL( toggled( bool ) ), this, SLOT( ReverseStepV() ) ); connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( myGeomGUI->getApp()->selectionMgr(), connect(GroupDimensions->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName( tr( "GEOM_MULTITRANSLATION" ) );
ConstructorsClicked( 0 ); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupDimensions->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupDimensions->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupDimensions->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupDimensions->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupDimensions->SpinBox_DY1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupDimensions->SpinBox_DY2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
connect(GroupDimensions->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
connect(GroupDimensions->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(ReverseStepV()));
initName(tr("GEOM_MULTITRANSLATION"));
ConstructorsClicked(0);
} }
//================================================================================= //=================================================================================
// function : SetDoubleSpinBoxStep() // function : SetDoubleSpinBoxStep()
// purpose : Double spin box management // purpose : Double spin box management
//================================================================================= //=================================================================================
void TransformationGUI_MultiTranslationDlg::SetDoubleSpinBoxStep( double step ) void TransformationGUI_MultiTranslationDlg::SetDoubleSpinBoxStep (double step)
{ {
GroupPoints->SpinBox_DX->setSingleStep(step); GroupPoints->SpinBox_DX->setSingleStep(step);
GroupPoints->SpinBox_DY->setSingleStep(step); GroupPoints->SpinBox_DY->setSingleStep(step);
@ -204,174 +213,195 @@ void TransformationGUI_MultiTranslationDlg::SetDoubleSpinBoxStep( double step )
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
//================================================================================= //=================================================================================
void TransformationGUI_MultiTranslationDlg::ConstructorsClicked( int constructorId ) void TransformationGUI_MultiTranslationDlg::ConstructorsClicked (int constructorId)
{ {
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myStepU = myStepV = 50.0;
myNbTimesU = myNbTimesV = 2;
globalSelection( GEOM_ALLSHAPES ); switch (constructorId) {
case 0: // Translate simple
switch ( constructorId ) {
case 0: /* Translate simple */
{ {
GroupDimensions->hide(); GroupDimensions->hide();
GroupPoints->show(); GroupPoints->show();
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit1->setText( "" ); GroupPoints->LineEdit2->setText("");
GroupPoints->LineEdit2->setText( "" ); myBase = myVectorU = GEOM::GEOM_Object::_nil();
GroupPoints->SpinBox_DX->setValue( myStepU ); GroupPoints->SpinBox_DX->setValue(myStepU);
GroupPoints->SpinBox_DY->setValue( myNbTimesU ); GroupPoints->SpinBox_DY->setValue(myNbTimesU);
GroupPoints->PushButton1->click();
break; break;
} }
case 1: /* Translate double */ case 1: // Translate double
{ {
GroupPoints->hide(); GroupPoints->hide();
GroupDimensions->show(); GroupDimensions->show();
myEditCurrentArgument = GroupDimensions->LineEdit1; GroupDimensions->LineEdit1->setText("");
GroupDimensions->LineEdit1->setText( "" ); GroupDimensions->LineEdit2->setText("");
GroupDimensions->LineEdit2->setText( "" ); GroupDimensions->LineEdit3->setText("");
GroupDimensions->LineEdit3->setText( "" ); myBase = myVectorU = myVectorV = GEOM::GEOM_Object::_nil();
GroupDimensions->SpinBox_DX1->setValue( myStepU ); GroupDimensions->SpinBox_DX1->setValue(myStepU);
GroupDimensions->SpinBox_DY1->setValue( myNbTimesU ); GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
GroupDimensions->SpinBox_DX2->setValue( myStepV ); GroupDimensions->SpinBox_DX2->setValue(myStepV);
GroupDimensions->SpinBox_DY2->setValue( myNbTimesV ); GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
myVectorV = GEOM::GEOM_Object::_nil(); GroupDimensions->PushButton1->click();
break; break;
} }
} }
qApp->processEvents(); qApp->processEvents();
updateGeometry(); updateGeometry();
resize( minimumSize() ); resize(minimumSize());
myEditCurrentArgument->setFocus(); if (myInitial) {
myBase = myVectorU = GEOM::GEOM_Object::_nil(); myInitial = false;
connect( myGeomGUI->getApp()->selectionMgr(), SelectionIntoArgument();
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); }
else {
displayPreview();
}
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_MultiTranslationDlg::ClickOnOk() void TransformationGUI_MultiTranslationDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_MultiTranslationDlg::ClickOnApply() bool TransformationGUI_MultiTranslationDlg::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
ConstructorsClicked( getConstructorId() ); // activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument() void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); erasePreview();
myEditCurrentArgument->setText("");
if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
myEditCurrentArgument == GroupDimensions->LineEdit1)
myBase = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
myEditCurrentArgument == GroupDimensions->LineEdit2)
myVectorU = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupDimensions->LineEdit3)
myVectorV = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if ( aSelList.Extent() != 1 ) { if (aSelList.Extent() != 1)
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ||
myEditCurrentArgument == GroupDimensions->LineEdit1 )
myBase = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
myEditCurrentArgument == GroupDimensions->LineEdit2 )
myVectorU = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
myVectorV = GEOM::GEOM_Object::_nil();
return; return;
}
// nbSel == 1 // nbSel == 1
Standard_Boolean testResult = Standard_False;; Standard_Boolean testResult = Standard_False;;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First(), testResult ); GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if ( !testResult || CORBA::is_nil( aSelectedObject ) || !GEOMBase::IsShape( aSelectedObject ) ) if (!testResult || CORBA::is_nil(aSelectedObject) || !GEOMBase::IsShape(aSelectedObject))
return; return;
QString aName = GEOMBase::GetName( aSelectedObject ); QString aName = GEOMBase::GetName(aSelectedObject);
if ( myEditCurrentArgument == GroupPoints->LineEdit1 || if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
myEditCurrentArgument == GroupDimensions->LineEdit1 ) myEditCurrentArgument == GroupDimensions->LineEdit1)
myBase = aSelectedObject; myBase = aSelectedObject;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 || else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
myEditCurrentArgument == GroupDimensions->LineEdit2 || myEditCurrentArgument == GroupDimensions->LineEdit2 ||
myEditCurrentArgument == GroupDimensions->LineEdit3 ) { myEditCurrentArgument == GroupDimensions->LineEdit3) {
if ( testResult && !aSelectedObject->_is_nil() ) { TopoDS_Shape aShape;
TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { TColStd_IndexedMapOfInteger aMap;
TColStd_IndexedMapOfInteger aMap; aSelMgr->GetIndexes(aSelList.First(), aMap);
aSelMgr->GetIndexes( aSelList.First(), aMap ); if (aMap.Extent() == 1) {
if ( aMap.Extent() == 1 ) { int anIndex = aMap(1);
int anIndex = aMap( 1 ); aName += QString(":edge_%1").arg(anIndex);
aName += QString( ":edge_%1" ).arg( anIndex );
//Find SubShape Object in Father
//Find SubShape Object in Father GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
GEOM::GEOM_Object_var aFindedObject = findObjectInFather( aSelectedObject, aName );
if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study GEOM::GEOM_IShapesOperations_var aShapesOp =
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
getGeomEngine()->GetIShapesOperations( getStudyId() ); if (myEditCurrentArgument == GroupDimensions->LineEdit3)
if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) myVectorV = aShapesOp->GetSubShape(aSelectedObject, anIndex);
myVectorV = aShapesOp->GetSubShape( aSelectedObject, anIndex ); else
else myVectorU = aShapesOp->GetSubShape(aSelectedObject, anIndex);
myVectorU = aShapesOp->GetSubShape(aSelectedObject, anIndex); }
} else {
else { if (myEditCurrentArgument == GroupDimensions->LineEdit3)
if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) myVectorV = aFindedObject;
myVectorV = aFindedObject; else
else myVectorU = aFindedObject;
myVectorU = aFindedObject; }
} }
} else {
else { if (aShape.ShapeType() != TopAbs_EDGE) {
if ( aShape.ShapeType() != TopAbs_EDGE ) { aSelectedObject = GEOM::GEOM_Object::_nil();
aSelectedObject = GEOM::GEOM_Object::_nil(); aName = "";
aName = ""; }
} if (myEditCurrentArgument == GroupDimensions->LineEdit3)
if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) myVectorV = aSelectedObject;
myVectorV = aSelectedObject; else
else myVectorU = aSelectedObject;
myVectorU = aSelectedObject;
}
} }
} }
} }
myEditCurrentArgument->setText(aName);
myEditCurrentArgument->setText( aName ); if (myEditCurrentArgument == GroupPoints->LineEdit1) {
if (!myBase->_is_nil() && myVectorU->_is_nil())
displayPreview(); GroupPoints->PushButton2->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
if (!myVectorU->_is_nil() && myBase->_is_nil())
GroupPoints->PushButton1->click();
}
else if (myEditCurrentArgument == GroupDimensions->LineEdit1) {
if (!myBase->_is_nil() && myVectorU->_is_nil())
GroupDimensions->PushButton2->click();
}
else if (myEditCurrentArgument == GroupDimensions->LineEdit2) {
if (!myVectorU->_is_nil() && myVectorV->_is_nil())
GroupDimensions->PushButton3->click();
}
else if (myEditCurrentArgument == GroupDimensions->LineEdit3) {
if (!myVectorV->_is_nil() && myBase->_is_nil())
GroupDimensions->PushButton1->click();
}
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
displayPreview();
} }
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -379,31 +409,64 @@ void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument()
void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument() void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
globalSelection( GEOM_ALLSHAPES );
if ( send == GroupPoints->PushButton1 ) { disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(GEOM_ALLSHAPES);
if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
}
else if ( send == GroupPoints->PushButton2 ) {
myEditCurrentArgument = GroupPoints->LineEdit2;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
}
else if ( send == GroupDimensions->PushButton1 ) {
myEditCurrentArgument = GroupDimensions->LineEdit1;
}
else if ( send == GroupDimensions->PushButton2 ) {
myEditCurrentArgument = GroupDimensions->LineEdit2;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
}
else if ( send == GroupDimensions->PushButton3 ) {
myEditCurrentArgument = GroupDimensions->LineEdit3;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
}
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
}
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
}
else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2;
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
}
else if (send == GroupDimensions->PushButton1) {
myEditCurrentArgument = GroupDimensions->LineEdit1;
GroupDimensions->PushButton2->setDown(false);
GroupDimensions->PushButton3->setDown(false);
GroupDimensions->LineEdit2->setEnabled(false);
GroupDimensions->LineEdit3->setEnabled(false);
}
else if (send == GroupDimensions->PushButton2) {
myEditCurrentArgument = GroupDimensions->LineEdit2;
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
GroupDimensions->PushButton1->setDown(false);
GroupDimensions->PushButton3->setDown(false);
GroupDimensions->LineEdit1->setEnabled(false);
GroupDimensions->LineEdit3->setEnabled(false);
}
else if (send == GroupDimensions->PushButton3) {
myEditCurrentArgument = GroupDimensions->LineEdit3;
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
GroupDimensions->PushButton1->setDown(false);
GroupDimensions->PushButton2->setDown(false);
GroupDimensions->LineEdit1->setEnabled(false);
GroupDimensions->LineEdit2->setEnabled(false);
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
}
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
@ -412,15 +475,14 @@ void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument()
void TransformationGUI_MultiTranslationDlg::LineEditReturnPressed() void TransformationGUI_MultiTranslationDlg::LineEditReturnPressed()
{ {
QLineEdit* send = (QLineEdit*)sender(); QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 || if (send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 ||
send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2 || send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2 ||
send == GroupDimensions->LineEdit3 ) { send == GroupDimensions->LineEdit3) {
myEditCurrentArgument = send; myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -428,55 +490,51 @@ void TransformationGUI_MultiTranslationDlg::LineEditReturnPressed()
void TransformationGUI_MultiTranslationDlg::ActivateThisDialog() void TransformationGUI_MultiTranslationDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
ConstructorsClicked( getConstructorId() ); // reinit, because some selected objects could be removed
Init();
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_MultiTranslationDlg::enterEvent( QEvent* ) void TransformationGUI_MultiTranslationDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox( double newValue ) void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (double newValue)
{ {
QObject* send = (QObject*)sender(); QObject* send = (QObject*)sender();
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
if ( send == GroupPoints->SpinBox_DX ) if (send == GroupPoints->SpinBox_DX)
myStepU = newValue; myStepU = newValue;
else if ( send == GroupPoints->SpinBox_DY ) else if (send == GroupPoints->SpinBox_DY)
myNbTimesU = (int)newValue; myNbTimesU = (int)newValue;
break; break;
case 1 : case 1:
if ( send == GroupDimensions->SpinBox_DX1 ) if (send == GroupDimensions->SpinBox_DX1)
myStepU = newValue; myStepU = newValue;
else if ( send == GroupDimensions->SpinBox_DY1) else if (send == GroupDimensions->SpinBox_DY1)
myNbTimesU = (int)newValue; myNbTimesU = (int)newValue;
else if ( send == GroupDimensions->SpinBox_DX2 ) else if (send == GroupDimensions->SpinBox_DX2)
myStepV = newValue; myStepV = newValue;
else if ( send == GroupDimensions->SpinBox_DY2 ) else if (send == GroupDimensions->SpinBox_DY2)
myNbTimesV = (int)newValue; myNbTimesV = (int)newValue;
break; break;
} }
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : ReverseStepU() // function : ReverseStepU()
// purpose : 'state' not used here // purpose : 'state' not used here
@ -484,18 +542,17 @@ void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox( double newVal
void TransformationGUI_MultiTranslationDlg::ReverseStepU() void TransformationGUI_MultiTranslationDlg::ReverseStepU()
{ {
myStepU = -myStepU; myStepU = -myStepU;
int aConstructorId = getConstructorId(); int aConstructorId = getConstructorId();
if ( aConstructorId == 0 ) if (aConstructorId == 0)
GroupPoints->SpinBox_DX->setValue( myStepU ); GroupPoints->SpinBox_DX->setValue(myStepU);
else if ( aConstructorId == 1 ) else if (aConstructorId == 1)
GroupDimensions->SpinBox_DX1->setValue( myStepU ); GroupDimensions->SpinBox_DX1->setValue(myStepU);
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : ReverseStepV // function : ReverseStepV
// purpose : 'state' not used here // purpose : 'state' not used here
@ -503,72 +560,71 @@ void TransformationGUI_MultiTranslationDlg::ReverseStepU()
void TransformationGUI_MultiTranslationDlg::ReverseStepV() void TransformationGUI_MultiTranslationDlg::ReverseStepV()
{ {
myStepV = -myStepV; myStepV = -myStepV;
GroupDimensions->SpinBox_DX2->setValue( myStepV ); GroupDimensions->SpinBox_DX2->setValue(myStepV);
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr TransformationGUI_MultiTranslationDlg::createOperation() GEOM::GEOM_IOperations_ptr TransformationGUI_MultiTranslationDlg::createOperation()
{ {
return myGeomGUI->GetGeomGen()->GetITransformOperations( getStudyId() ); return getGeomEngine()->GetITransformOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_MultiTranslationDlg::isValid( QString& /*msg*/ ) bool TransformationGUI_MultiTranslationDlg::isValid (QString& /*msg*/)
{ {
int aConstructorId = getConstructorId(); int aConstructorId = getConstructorId();
if ( aConstructorId == 0 ) if (aConstructorId == 0)
return !( myBase->_is_nil() || myVectorU->_is_nil() ); return !(myBase->_is_nil() || myVectorU->_is_nil());
else if ( aConstructorId == 1 ) else if (aConstructorId == 1)
return !( myBase->_is_nil() || myVectorU->_is_nil() || myVectorV->_is_nil() ); return !(myBase->_is_nil() || myVectorU->_is_nil() || myVectorV->_is_nil());
return 0; return 0;
} }
//================================================================================= //=================================================================================
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_MultiTranslationDlg::execute( ObjectList& objects ) bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects)
{ {
bool res = false; bool res = false;
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0 : case 0:
if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVectorU ) ) { if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU)) {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MultiTranslate1D( myBase, myVectorU, myStepU, myNbTimesU ); anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
MultiTranslate1D(myBase, myVectorU, myStepU, myNbTimesU);
res = true; res = true;
} }
break; break;
case 1 : case 1:
if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVectorU ) && if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU) &&
!CORBA::is_nil( myVectorV ) ) { !CORBA::is_nil(myVectorV)) {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MultiTranslate2D( myBase, myVectorU, myStepU, myNbTimesU, anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
myVectorV, myStepV, myNbTimesV ); MultiTranslate2D(myBase, myVectorU, myStepU, myNbTimesU,
myVectorV, myStepV, myNbTimesV);
res = true; res = true;
} }
break; break;
} }
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
return res; return res;
} }
//================================================================================= //=================================================================================
// function : addSubshapeToStudy // function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection // purpose : virtual method to add new SubObjects if local selection
@ -576,8 +632,8 @@ bool TransformationGUI_MultiTranslationDlg::execute( ObjectList& objects )
void TransformationGUI_MultiTranslationDlg::addSubshapesToStudy() void TransformationGUI_MultiTranslationDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap; QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
objMap[GroupPoints->LineEdit2->text()] = myVectorU; objMap[GroupPoints->LineEdit2->text()] = myVectorU;
break; break;
@ -586,5 +642,5 @@ void TransformationGUI_MultiTranslationDlg::addSubshapesToStudy()
objMap[GroupDimensions->LineEdit3->text()] = myVectorV; objMap[GroupDimensions->LineEdit3->text()] = myVectorV;
break; break;
} }
addSubshapesToFather( objMap ); addSubshapesToFather(objMap);
} }

View File

@ -61,6 +61,9 @@ private:
int myNbTimesV; int myNbTimesV;
Standard_Real myStepU; Standard_Real myStepU;
Standard_Real myStepV; Standard_Real myStepV;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_2Sel2Spin1Check* GroupPoints; DlgRef_2Sel2Spin1Check* GroupPoints;
DlgRef_3Sel4Spin2Check* GroupDimensions; DlgRef_3Sel4Spin2Check* GroupDimensions;

View File

@ -209,6 +209,7 @@ void TransformationGUI_OffsetDlg::SetEditCurrentArgument()
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
if ( send == GroupPoints->PushButton1 ) { if ( send == GroupPoints->PushButton1 ) {
GroupPoints->PushButton1->setDown(true);
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
SelectionIntoArgument(); SelectionIntoArgument();

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : TransformationGUI_PositionDlg.cxx // File : TransformationGUI_PositionDlg.cxx
@ -29,247 +29,324 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
//================================================================================= //=================================================================================
// class : TransformationGUI_PositionDlg() // class : TransformationGUI_PositionDlg()
// purpose : Constructs a TransformationGUI_PositionDlg which is a child of 'parent', with the // purpose : Constructs a TransformationGUI_PositionDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
TransformationGUI_PositionDlg::TransformationGUI_PositionDlg TransformationGUI_PositionDlg::TransformationGUI_PositionDlg
( GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl ) (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
{ {
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_POSITION" ) ) ); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POSITION")));
QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_POSITION2" ) ) ); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POSITION2")));
QPixmap imageselect( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT") ) ); QPixmap imageselect (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_POSITION_TITLE" ) ); setWindowTitle(tr("GEOM_POSITION_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_POSITION" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_POSITION"));
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setIcon( image1 ); mainFrame()->RadioButton2->setIcon(image1);
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
Group1 = new DlgRef_3Sel3Spin1Check( centralWidget() ); Group1 = new DlgRef_3Sel3Spin1Check(centralWidget());
Group1->SpinBox1->hide(); Group1->SpinBox1->hide();
Group1->SpinBox2->hide(); Group1->SpinBox2->hide();
Group1->SpinBox3->hide(); Group1->SpinBox3->hide();
Group1->TextLabel4->hide(); Group1->TextLabel4->hide();
Group1->TextLabel5->hide(); Group1->TextLabel5->hide();
Group1->TextLabel6->hide(); Group1->TextLabel6->hide();
Group1->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); Group1->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
Group1->TextLabel1->setText( tr( "GEOM_OBJECTS" ) ); Group1->TextLabel1->setText(tr("GEOM_OBJECTS"));
Group1->TextLabel2->setText( tr( "GEOM_START_LCS" ) ); Group1->TextLabel2->setText(tr("GEOM_START_LCS"));
Group1->TextLabel3->setText( tr( "GEOM_END_LCS" ) ); Group1->TextLabel3->setText(tr("GEOM_END_LCS"));
Group1->PushButton1->setIcon( imageselect ); Group1->PushButton1->setIcon(imageselect);
Group1->PushButton2->setIcon( imageselect ); Group1->PushButton2->setIcon(imageselect);
Group1->PushButton3->setIcon( imageselect ); Group1->PushButton3->setIcon(imageselect);
Group1->CheckBox1->setText( tr( "GEOM_CREATE_COPY" ) ); Group1->CheckBox1->setText(tr("GEOM_CREATE_COPY"));
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget( Group1 ); layout->addWidget(Group1);
/***************************************************************/ /***************************************************************/
setHelpFileName( "modify_location_operation_page.html" ); setHelpFileName("modify_location_operation_page.html");
// Activate Create a Copy mode
Group1->CheckBox1->setChecked(true);
CreateCopyModeChanged(true);
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~TransformationGUI_PositionDlg() // function : ~TransformationGUI_PositionDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
//================================================================================= //=================================================================================
TransformationGUI_PositionDlg::~TransformationGUI_PositionDlg() TransformationGUI_PositionDlg::~TransformationGUI_PositionDlg()
{ {
/* no need to delete child widgets, Qt does it all for us */ // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_PositionDlg::Init() void TransformationGUI_PositionDlg::Init()
{ {
/* init variables */ // init variables
Group1->LineEdit1->setReadOnly( true ); Group1->LineEdit1->setReadOnly(true);
Group1->LineEdit2->setReadOnly( true ); Group1->LineEdit2->setReadOnly(true);
Group1->LineEdit3->setReadOnly( true ); Group1->LineEdit3->setReadOnly(true);
myStartLCS = GEOM::GEOM_Object::_nil(); Group1->LineEdit1->setText("");
myEndLCS = GEOM::GEOM_Object::_nil(); Group1->LineEdit2->setText("");
Group1->LineEdit3->setText("");
// Activate Create a Copy mode
Group1->CheckBox1->setChecked( true ); myStartLCS = myEndLCS = GEOM::GEOM_Object::_nil();
CreateCopyModeChanged( true );
mainFrame()->GroupBoxPublish->show(); mainFrame()->GroupBoxPublish->show();
/* signals and slots connections */ // signals and slots connections
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
connect( Group1->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( Group1->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(Group1->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( Group1->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(Group1->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( Group1->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( Group1->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(Group1->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( Group1->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(Group1->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( Group1->CheckBox1, SIGNAL( toggled( bool ) ), this, SLOT( CreateCopyModeChanged( bool ) ) );
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName( tr( "GEOM_POSITION" ) ); connect(Group1->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
ConstructorsClicked( 0 ); initName(tr("GEOM_POSITION"));
ConstructorsClicked(0);
} }
//================================================================================= //=================================================================================
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
//================================================================================= //=================================================================================
void TransformationGUI_PositionDlg::ConstructorsClicked( int constructorId ) void TransformationGUI_PositionDlg::ConstructorsClicked (int constructorId)
{ {
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection();
myEditCurrentArgument = Group1->LineEdit1;
Group1->LineEdit2->clear(); Group1->LineEdit2->clear();
Group1->LineEdit3->clear(); Group1->LineEdit3->clear();
myStartLCS = GEOM::GEOM_Object::_nil(); myStartLCS = GEOM::GEOM_Object::_nil();
myEndLCS = GEOM::GEOM_Object::_nil(); myEndLCS = GEOM::GEOM_Object::_nil();
switch ( constructorId ) { switch (constructorId) {
case 0: case 0:
Group1->LineEdit2->hide(); {
Group1->TextLabel2->hide(); Group1->LineEdit2->hide();
Group1->PushButton2->hide(); Group1->TextLabel2->hide();
Group1->PushButton2->hide();
Group1->PushButton1->click();
}
break; break;
case 1: case 1:
Group1->LineEdit2->show(); {
Group1->TextLabel2->show(); Group1->LineEdit2->show();
Group1->PushButton2->show(); Group1->TextLabel2->show();
Group1->PushButton2->show();
Group1->PushButton1->click();
}
break; break;
} }
qApp->processEvents(); qApp->processEvents();
updateGeometry(); updateGeometry();
resize( minimumSize() ); resize(minimumSize());
connect( myGeomGUI->getApp()->selectionMgr(), if (myInitial) {
SIGNAL( currentSelectionChanged() ), this, SLOT(SelectionIntoArgument() ) ); myInitial = false;
SelectionIntoArgument(); SelectionIntoArgument();
}
else {
displayPreview();
}
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_PositionDlg::ClickOnOk() void TransformationGUI_PositionDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_PositionDlg::ClickOnApply() bool TransformationGUI_PositionDlg::ClickOnApply()
{ {
if ( !onAccept( Group1->CheckBox1->isChecked() ) ) if (!onAccept(Group1->CheckBox1->isChecked()))
return false; return false;
initName(); initName();
ConstructorsClicked( getConstructorId() ); // activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection has changed // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void TransformationGUI_PositionDlg::SelectionIntoArgument() void TransformationGUI_PositionDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); erasePreview();
QString aName; myEditCurrentArgument->setText("");
if (myEditCurrentArgument == Group1->LineEdit1)
myObjects.length(0);
else if (myEditCurrentArgument == Group1->LineEdit2)
myStartLCS = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == Group1->LineEdit3)
myEndLCS = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
QString aName;
if (myEditCurrentArgument == Group1->LineEdit1) { if (myEditCurrentArgument == Group1->LineEdit1) {
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName); int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
if (aNbSel < 1) { if (aNbSel < 1)
myObjects.length(0);
displayPreview();
return; return;
}
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects); GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
if ( !myObjects.length() ) { if (!myObjects.length())
displayPreview();
return; return;
} else
myEditCurrentArgument->setText(aName);
} }
else if (myEditCurrentArgument == Group1->LineEdit2) { else if (myEditCurrentArgument == Group1->LineEdit2) {
myStartLCS = GEOM::GEOM_Object::_nil(); if (aSelList.Extent() != 1)
if (aSelList.Extent() != 1) {
displayPreview();
return; return;
}
// nbSel == 1
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
myStartLCS = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); myStartLCS = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if ( !testResult || CORBA::is_nil( myStartLCS ) ) { if (!testResult || CORBA::is_nil(myStartLCS))
displayPreview();
return; return;
}
aName = GEOMBase::GetName( myStartLCS ); aName = GEOMBase::GetName(myStartLCS);
myEditCurrentArgument->setText(aName);
if (!myStartLCS->_is_nil() && myEndLCS->_is_nil())
Group1->PushButton3->click();
} }
else if ( myEditCurrentArgument == Group1->LineEdit3 ) { else if (myEditCurrentArgument == Group1->LineEdit3) {
myEndLCS = GEOM::GEOM_Object::_nil(); myEndLCS = GEOM::GEOM_Object::_nil();
if ( aSelList.Extent() != 1 ) { if (aSelList.Extent() != 1)
displayPreview();
return; return;
}
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
myEndLCS = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); myEndLCS = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if ( !testResult || CORBA::is_nil( myEndLCS ) ) { if (!testResult || CORBA::is_nil(myEndLCS))
displayPreview();
return; return;
}
aName = GEOMBase::GetName( myEndLCS ); aName = GEOMBase::GetName(myEndLCS);
myEditCurrentArgument->setText(aName);
if (!myEndLCS->_is_nil() && !myObjects.length())
Group1->PushButton1->click();
} }
myEditCurrentArgument->setText( aName ); // clear selection
displayPreview(); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
displayPreview();
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
if (send == Group1->PushButton1) {
myEditCurrentArgument = Group1->LineEdit1;
globalSelection();
Group1->PushButton2->setDown(false);
Group1->PushButton3->setDown(false);
Group1->LineEdit2->setEnabled(false);
Group1->LineEdit3->setEnabled(false);
}
else if (send == Group1->PushButton2) {
myEditCurrentArgument = Group1->LineEdit2;
TColStd_MapOfInteger aMap;
aMap.Add(GEOM_PLANE);
aMap.Add(GEOM_MARKER);
globalSelection(aMap);
Group1->PushButton1->setDown(false);
Group1->PushButton3->setDown(false);
Group1->LineEdit1->setEnabled(false);
Group1->LineEdit3->setEnabled(false);
}
else if (send == Group1->PushButton3) {
myEditCurrentArgument = Group1->LineEdit3;
TColStd_MapOfInteger aMap;
aMap.Add(GEOM_PLANE);
aMap.Add(GEOM_MARKER);
globalSelection(aMap);
Group1->PushButton1->setDown(false);
Group1->PushButton2->setDown(false);
Group1->LineEdit1->setEnabled(false);
Group1->LineEdit2->setEnabled(false);
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
} }
//================================================================================= //=================================================================================
@ -279,46 +356,14 @@ void TransformationGUI_PositionDlg::SelectionIntoArgument()
void TransformationGUI_PositionDlg::LineEditReturnPressed() void TransformationGUI_PositionDlg::LineEditReturnPressed()
{ {
QLineEdit* send = (QLineEdit*)sender(); QLineEdit* send = (QLineEdit*)sender();
if ( send == Group1->LineEdit1 || send == Group1->LineEdit2 || if (send == Group1->LineEdit1 ||
send == Group1->LineEdit3 ) { send == Group1->LineEdit2 ||
send == Group1->LineEdit3) {
myEditCurrentArgument = send; myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
if ( send == Group1->PushButton1 ) {
myEditCurrentArgument = Group1->LineEdit1;
globalSelection();
}
else if ( send == Group1->PushButton2 ) {
myEditCurrentArgument = Group1->LineEdit2;
TColStd_MapOfInteger aMap;
aMap.Add( GEOM_PLANE );
aMap.Add( GEOM_MARKER );
globalSelection( aMap );
}
else if ( send == Group1->PushButton3 ) {
myEditCurrentArgument = Group1->LineEdit3;
TColStd_MapOfInteger aMap;
aMap.Add( GEOM_PLANE );
aMap.Add( GEOM_MARKER );
globalSelection( aMap );
}
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -326,93 +371,89 @@ void TransformationGUI_PositionDlg::SetEditCurrentArgument()
void TransformationGUI_PositionDlg::ActivateThisDialog() void TransformationGUI_PositionDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
ConstructorsClicked( getConstructorId() );
}
// reinit, because some selected objects could be removed
Init();
}
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : when mouse enter onto the QWidget // purpose : when mouse enter onto the QWidget
//================================================================================= //=================================================================================
void TransformationGUI_PositionDlg::enterEvent( QEvent* ) void TransformationGUI_PositionDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr TransformationGUI_PositionDlg::createOperation() GEOM::GEOM_IOperations_ptr TransformationGUI_PositionDlg::createOperation()
{ {
return getGeomEngine()->GetITransformOperations( getStudyId() ); return getGeomEngine()->GetITransformOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_PositionDlg::isValid( QString& /*msg*/ ) bool TransformationGUI_PositionDlg::isValid (QString& /*msg*/)
{ {
bool res; bool res;
if ( getConstructorId() == 0 ) if (getConstructorId() == 0)
res = !( myObjects.length() == 0 || myEndLCS->_is_nil() ); res = !(myObjects.length() == 0 || myEndLCS->_is_nil());
else else
res = !( myObjects.length() == 0 || myStartLCS->_is_nil() || myEndLCS->_is_nil() ); res = !(myObjects.length() == 0 || myStartLCS->_is_nil() || myEndLCS->_is_nil());
return res; return res;
} }
//================================================================================= //=================================================================================
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_PositionDlg::execute( ObjectList& objects ) bool TransformationGUI_PositionDlg::execute (ObjectList& objects)
{ {
bool res = false; bool res = false;
bool toCreateCopy = IsPreview() || Group1->CheckBox1->isChecked(); bool toCreateCopy = IsPreview() || Group1->CheckBox1->isChecked();
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
{ {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
if ( toCreateCopy ) if (toCreateCopy)
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
PositionShapeCopy( myObjects[i], myObjects[i], myEndLCS ); PositionShapeCopy(myObjects[i], myObjects[i], myEndLCS);
else else
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
PositionShape( myObjects[i], myObjects[i], myEndLCS ); PositionShape(myObjects[i], myObjects[i], myEndLCS);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
res = true; res = true;
break; break;
} }
case 1: case 1:
{ {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
if ( toCreateCopy ) if (toCreateCopy)
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
PositionShapeCopy( myObjects[i], myStartLCS, myEndLCS ); PositionShapeCopy(myObjects[i], myStartLCS, myEndLCS);
else else
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
PositionShape( myObjects[i], myStartLCS, myEndLCS ); PositionShape(myObjects[i], myStartLCS, myEndLCS);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
res = true; res = true;
break; break;
} }
} }
return res; return res;
} }
@ -420,14 +461,14 @@ bool TransformationGUI_PositionDlg::execute( ObjectList& objects )
// function : restoreSubShapes // function : restoreSubShapes
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_PositionDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy, void TransformationGUI_PositionDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject ) SALOMEDS::SObject_ptr theSObject)
{ {
if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) { if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored // empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(), getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
/*theFindMethod=*/GEOM::FSM_Transformed, /*theFindMethod=*/GEOM::FSM_Transformed,
/*theInheritFirstArg=*/true ); /*theInheritFirstArg=*/true);
} }
} }
@ -435,7 +476,7 @@ void TransformationGUI_PositionDlg::restoreSubShapes( SALOMEDS::Study_ptr theS
// function : CreateCopyModeChanged() // function : CreateCopyModeChanged()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_PositionDlg::CreateCopyModeChanged( bool isCreateCopy ) void TransformationGUI_PositionDlg::CreateCopyModeChanged (bool isCreateCopy)
{ {
mainFrame()->GroupBoxName->setEnabled( isCreateCopy ); mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
} }

View File

@ -58,6 +58,9 @@ private:
GEOM::GEOM_Object_var myStartLCS; GEOM::GEOM_Object_var myStartLCS;
GEOM::GEOM_Object_var myEndLCS; GEOM::GEOM_Object_var myEndLCS;
GEOM::ListOfGO myObjects; GEOM::ListOfGO myObjects;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_3Sel3Spin1Check* Group1; DlgRef_3Sel3Spin1Check* Group1;

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : TransformationGUI_RotationDlg.cxx // File : TransformationGUI_RotationDlg.cxx
@ -29,11 +29,12 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
@ -45,92 +46,63 @@
//================================================================================= //=================================================================================
// class : TransformationGUI_RotationDlg() // class : TransformationGUI_RotationDlg()
// purpose : Constructs a TransformationGUI_RotationDlg which is a child of 'parent', with the // purpose : Constructs a TransformationGUI_RotationDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
TransformationGUI_RotationDlg::TransformationGUI_RotationDlg TransformationGUI_RotationDlg::TransformationGUI_RotationDlg
( GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl ) (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
{ {
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ROTATION" ) ) ); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_ROTATION")));
QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ROTATION_THREE_POINTS" ) ) ); QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_ROTATION_THREE_POINTS")));
setWindowTitle( tr( "GEOM_ROTATION_TITLE" ) ); setWindowTitle(tr("GEOM_ROTATION_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_ROTATION" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_ROTATION"));
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setIcon( image2 ); mainFrame()->RadioButton2->setIcon(image2);
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
GroupPoints = new DlgRef_4Sel1Spin2Check( centralWidget() ); GroupPoints = new DlgRef_4Sel1Spin2Check(centralWidget());
GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) ); GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS"));
GroupPoints->TextLabel2->setText( tr( "GEOM_AXIS" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_AXIS"));
GroupPoints->TextLabel3->setText( tr( "GEOM_ANGLE" ) ); GroupPoints->TextLabel3->setText(tr("GEOM_ANGLE"));
GroupPoints->TextLabel4->setText( tr( "GEOM_POINT_I" ).arg( 1 ) ); GroupPoints->TextLabel4->setText(tr("GEOM_POINT_I").arg(1));
GroupPoints->TextLabel5->setText( tr( "GEOM_POINT_I" ).arg( 2 ) ); GroupPoints->TextLabel5->setText(tr("GEOM_POINT_I").arg(2));
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->LineEdit4->setReadOnly( true ); GroupPoints->LineEdit4->setReadOnly(true);
GroupPoints->LineEdit5->setReadOnly( true ); GroupPoints->LineEdit5->setReadOnly(true);
GroupPoints->PushButton1->setIcon( image1 ); GroupPoints->PushButton1->setIcon(image1);
GroupPoints->PushButton2->setIcon( image1 ); GroupPoints->PushButton2->setIcon(image1);
GroupPoints->PushButton4->setIcon( image1 ); GroupPoints->PushButton4->setIcon(image1);
GroupPoints->PushButton5->setIcon( image1 ); GroupPoints->PushButton5->setIcon(image1);
GroupPoints->CheckButton1->setText( tr( "GEOM_CREATE_COPY" ) ); GroupPoints->CheckButton1->setText(tr("GEOM_CREATE_COPY"));
GroupPoints->CheckButton2->setText( tr( "GEOM_REVERSE" ) ); GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE"));
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( GroupPoints );
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints);
/***************************************************************/ /***************************************************************/
double anAngle = 0;
double SpecificStep = 5; setHelpFileName("rotation_operation_page.html");
/* min, max, step and decimals for spin boxes & initial values */
initSpinBox( GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
GroupPoints->SpinBox_DX->setValue( anAngle );
// Activate Create a Copy mode // Activate Create a Copy mode
GroupPoints->CheckButton1->setChecked( true ); GroupPoints->CheckButton1->setChecked(true);
CreateCopyModeChanged( true ); CreateCopyModeChanged(true);
mainFrame()->GroupBoxPublish->show();
/* signals and slots connections */
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->PushButton4, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->PushButton5, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
connect( GroupPoints->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( CreateCopyModeChanged( bool ) ) );
connect( GroupPoints->CheckButton2, SIGNAL( toggled( bool ) ), this, SLOT( onReverse() ) );
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
setHelpFileName( "rotation_operation_page.html" );
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~TransformationGUI_RotationDlg() // function : ~TransformationGUI_RotationDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -140,62 +112,104 @@ TransformationGUI_RotationDlg::~TransformationGUI_RotationDlg()
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_RotationDlg::Init() void TransformationGUI_RotationDlg::Init()
{ {
/* init variables */ double anAngle = 0;
myEditCurrentArgument = GroupPoints->LineEdit1; double SpecificStep = 5;
GroupPoints->LineEdit2->clear();
// min, max, step and decimals for spin boxes & initial values
initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
GroupPoints->SpinBox_DX->setValue(anAngle);
// init variables
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
GroupPoints->LineEdit4->setText("");
GroupPoints->LineEdit5->setText("");
myAxis = myCentPoint = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); myAxis = myCentPoint = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
initName( tr( "GEOM_ROTATION" ) ); mainFrame()->GroupBoxPublish->show();
ConstructorsClicked( 0 );
// signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton4, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton5, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse()));
initName(tr("GEOM_ROTATION"));
ConstructorsClicked(0);
} }
//================================================================================= //=================================================================================
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
//================================================================================= //=================================================================================
void TransformationGUI_RotationDlg::ConstructorsClicked( int constructorId ) void TransformationGUI_RotationDlg::ConstructorsClicked (int constructorId)
{ {
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myEditCurrentArgument = GroupPoints->LineEdit1;
globalSelection();
switch ( constructorId ) { switch (constructorId) {
case 0: /* rotation an object angle and axis */ case 0: // rotation an object angle and axis
GroupPoints->ShowRows( 2, 3, false ); {
GroupPoints->TextLabel2->setText( tr( "GEOM_AXIS" ) ); GroupPoints->ShowRows(2, 3, false);
GroupPoints->LineEdit2->clear(); GroupPoints->TextLabel2->setText(tr("GEOM_AXIS"));
GroupPoints->ShowRows( 4, 4, true ); GroupPoints->LineEdit2->clear();
myAxis = GEOM::GEOM_Object::_nil(); GroupPoints->ShowRows(4, 4, true);
myAxis = GEOM::GEOM_Object::_nil();
GroupPoints->PushButton1->click();
}
break; break;
case 1: /* rotation an object by 3 points */ case 1: // rotation an object by 3 points
GroupPoints->ShowRows( 4, 4, false ); {
GroupPoints->ShowRows( 2, 3, true ); GroupPoints->ShowRows(4, 4, false);
GroupPoints->TextLabel2->setText( tr( "GEOM_CENTRAL_POINT" ) ); GroupPoints->ShowRows(2, 3, true);
GroupPoints->TextLabel4->setText( tr( "GEOM_POINT_I" ).arg( 1 ) ); GroupPoints->TextLabel2->setText(tr("GEOM_CENTRAL_POINT"));
GroupPoints->TextLabel5->setText( tr( "GEOM_POINT_I" ).arg( 2 ) ); GroupPoints->TextLabel4->setText(tr("GEOM_POINT_I").arg(1));
GroupPoints->LineEdit2->clear(); GroupPoints->TextLabel5->setText(tr("GEOM_POINT_I").arg(2));
GroupPoints->LineEdit4->clear();
GroupPoints->LineEdit5->clear(); GroupPoints->LineEdit2->clear();
myCentPoint = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); GroupPoints->LineEdit4->clear();
GroupPoints->LineEdit5->clear();
myCentPoint = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
GroupPoints->PushButton1->click();
}
break; break;
} }
qApp->processEvents(); qApp->processEvents();
updateGeometry(); updateGeometry();
resize( minimumSize() ); resize(minimumSize());
myEditCurrentArgument->setFocus(); if (myInitial) {
connect( myGeomGUI->getApp()->selectionMgr(), myInitial = false;
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); SelectionIntoArgument();
}
else {
displayPreview();
}
} }
//================================================================================= //=================================================================================
@ -204,118 +218,147 @@ void TransformationGUI_RotationDlg::ConstructorsClicked( int constructorId )
//================================================================================= //=================================================================================
void TransformationGUI_RotationDlg::ClickOnOk() void TransformationGUI_RotationDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_RotationDlg::ClickOnApply() bool TransformationGUI_RotationDlg::ClickOnApply()
{ {
if ( !onAccept( GroupPoints->CheckButton1->isChecked() ) ) if (!onAccept(GroupPoints->CheckButton1->isChecked()))
return false; return false;
initName(); initName();
ConstructorsClicked( getConstructorId() ); // activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void TransformationGUI_RotationDlg::SelectionIntoArgument() void TransformationGUI_RotationDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); erasePreview();
QString aName; myEditCurrentArgument->setText("");
if (myEditCurrentArgument == GroupPoints->LineEdit1)
myObjects.length(0);
else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0)
myAxis = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1)
myCentPoint = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit4)
myPoint1 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit5)
myPoint2 = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
QString aName;
if (myEditCurrentArgument == GroupPoints->LineEdit1) { if (myEditCurrentArgument == GroupPoints->LineEdit1) {
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName); int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
if (aNbSel < 1) { if (aNbSel < 1)
myObjects.length(0);
return; return;
}
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects); GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
if (!myObjects.length()) if (!myObjects.length())
return; return;
else
myEditCurrentArgument->setText(aName);
} }
else { else {
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1)
if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0 )
myAxis = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1 )
myCentPoint = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == GroupPoints->LineEdit4 )
myPoint1 = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == GroupPoints->LineEdit5 )
myPoint2 = GEOM::GEOM_Object::_nil();
return; return;
}
// nbSel == 1
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if ( !testResult || CORBA::is_nil( aSelectedObject ) )
if (!testResult || CORBA::is_nil(aSelectedObject))
return; return;
aName = GEOMBase::GetName( aSelectedObject ); aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
{
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0 ) if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0)
aNeedType = TopAbs_EDGE; aNeedType = TopAbs_EDGE;
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap); aSelMgr->GetIndexes(aSelList.First(), aMap);
if ( aMap.Extent() == 1 ) { if (aMap.Extent() == 1)
int anIndex = aMap( 1 ); {
if ( aNeedType == TopAbs_EDGE ) int anIndex = aMap(1);
aName += QString( ":edge_%1" ).arg( anIndex ); if (aNeedType == TopAbs_EDGE)
else aName += QString(":edge_%1").arg(anIndex);
aName += QString( ":vertex_%1" ).arg( anIndex ); else
aName += QString(":vertex_%1").arg(anIndex);
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = findObjectInFather( aSelectedObject, aName ); //Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
getGeomEngine()->GetIShapesOperations( getStudyId() ); GEOM::GEOM_IShapesOperations_var aShapesOp =
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); getGeomEngine()->GetIShapesOperations(getStudyId());
} aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
else { }
aSelectedObject = aFindedObject; // get Object from study else {
} aSelectedObject = aFindedObject; // get Object from study
}
} }
else { else // Global Selection
if ( aShape.ShapeType() != aNeedType ) { {
aSelectedObject = GEOM::GEOM_Object::_nil(); if (aShape.ShapeType() != aNeedType) {
aName = ""; aSelectedObject = GEOM::GEOM_Object::_nil();
} aName = "";
}
} }
} }
if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0 ) myEditCurrentArgument->setText(aName);
if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0) {
myAxis = aSelectedObject; myAxis = aSelectedObject;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1 ) if (!myAxis->_is_nil() && !myObjects.length())
GroupPoints->PushButton1->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) {
myCentPoint = aSelectedObject; myCentPoint = aSelectedObject;
else if ( myEditCurrentArgument == GroupPoints->LineEdit4 ) if (!myCentPoint->_is_nil() && myPoint1->_is_nil())
GroupPoints->PushButton4->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit4) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
else if ( myEditCurrentArgument == GroupPoints->LineEdit5 ) if (!myPoint1->_is_nil() && myPoint2->_is_nil())
GroupPoints->PushButton5->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit5) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if (!myPoint2->_is_nil() && !myObjects.length())
GroupPoints->PushButton1->click();
}
} }
myEditCurrentArgument->setText( aName );
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -323,47 +366,82 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument()
void TransformationGUI_RotationDlg::SetEditCurrentArgument() void TransformationGUI_RotationDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); globalSelection();
if ( send == GroupPoints->PushButton1 ) { if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
} }
else if ( send == GroupPoints->PushButton2 ) { else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit2;
if ( getConstructorId() == 0 )
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); GroupPoints->PushButton1->setDown(false);
GroupPoints->PushButton4->setDown(false);
GroupPoints->PushButton5->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
GroupPoints->LineEdit4->setEnabled(false);
GroupPoints->LineEdit5->setEnabled(false);
if (getConstructorId() == 0)
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
else else
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
} }
else if ( send == GroupPoints->PushButton4 ) { else if (send == GroupPoints->PushButton4) {
myEditCurrentArgument = GroupPoints->LineEdit4; myEditCurrentArgument = GroupPoints->LineEdit4;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
GroupPoints->PushButton1->setDown(false);
GroupPoints->PushButton2->setDown(false);
GroupPoints->PushButton5->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
GroupPoints->LineEdit2->setEnabled(false);
GroupPoints->LineEdit5->setEnabled(false);
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
} }
else if ( send == GroupPoints->PushButton5 ) { else if (send == GroupPoints->PushButton5) {
myEditCurrentArgument = GroupPoints->LineEdit5; myEditCurrentArgument = GroupPoints->LineEdit5;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
GroupPoints->PushButton1->setDown(false);
GroupPoints->PushButton2->setDown(false);
GroupPoints->PushButton4->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
GroupPoints->LineEdit2->setEnabled(false);
GroupPoints->LineEdit4->setEnabled(false);
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
} }
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
SelectionIntoArgument(); // after setFocus(), because it will be setDown(false) when loses focus
} send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
}
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_RotationDlg::LineEditReturnPressed() void TransformationGUI_RotationDlg::LineEditReturnPressed()
{ {
QLineEdit* send = (QLineEdit*)sender(); QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 || if (send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2 ) { send == GroupPoints->LineEdit2) {
myEditCurrentArgument = send; myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -371,24 +449,21 @@ void TransformationGUI_RotationDlg::LineEditReturnPressed()
void TransformationGUI_RotationDlg::ActivateThisDialog() void TransformationGUI_RotationDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ) , this, SLOT( SelectionIntoArgument() ) );
ConstructorsClicked( getConstructorId() ); // reinit, because some selected objects could be removed
Init();
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_RotationDlg::enterEvent( QEvent* ) void TransformationGUI_RotationDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
@ -398,92 +473,96 @@ void TransformationGUI_RotationDlg::ValueChangedInSpinBox()
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr TransformationGUI_RotationDlg::createOperation() GEOM::GEOM_IOperations_ptr TransformationGUI_RotationDlg::createOperation()
{ {
return getGeomEngine()->GetITransformOperations( getStudyId() ); return getGeomEngine()->GetITransformOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_RotationDlg::isValid( QString& /*msg*/ ) bool TransformationGUI_RotationDlg::isValid (QString& /*msg*/)
{ {
switch ( getConstructorId() ) { if (myObjects.length() < 1) return false;
case 0:
return !( myObjects.length() == 0 || myAxis->_is_nil() );
break;
case 1:
return !( myObjects.length() == 0 || myCentPoint->_is_nil() || myPoint1->_is_nil() || myPoint2->_is_nil() );
break;
default:
return false;
}
}
switch (getConstructorId()) {
case 0:
return !(myAxis->_is_nil());
break;
case 1:
return !(myCentPoint->_is_nil() || myPoint1->_is_nil() || myPoint2->_is_nil());
break;
default:
break;
}
return false;
}
//================================================================================= //=================================================================================
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_RotationDlg::execute( ObjectList& objects ) bool TransformationGUI_RotationDlg::execute (ObjectList& objects)
{ {
bool res = false; bool res = false;
bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked(); bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0 : case 0:
{ {
if ( toCreateCopy ) { if (toCreateCopy) {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
myCurrObject = myObjects[i]; myCurrObject = myObjects[i];
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->RotateCopy( myObjects[i], myAxis, GetAngle() * PI180 ); anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
if ( !anObj->_is_nil() ) RotateCopy(myObjects[i], myAxis, GetAngle() * PI180);
objects.push_back( anObj._retn() ); if (!anObj->_is_nil())
} objects.push_back(anObj._retn());
}
} }
else { else {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
myCurrObject = myObjects[i]; myCurrObject = myObjects[i];
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->Rotate( myObjects[i], myAxis, GetAngle() * PI180 ); anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
if ( !anObj->_is_nil() ) Rotate(myObjects[i], myAxis, GetAngle() * PI180);
objects.push_back( anObj._retn() ); if (!anObj->_is_nil())
} objects.push_back(anObj._retn());
}
} }
res = true; res = true;
break; break;
} }
case 1 : case 1:
{ {
if ( toCreateCopy ) { if (toCreateCopy) {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
myCurrObject = myObjects[i]; myCurrObject = myObjects[i];
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->RotateThreePointsCopy( myObjects[i], myCentPoint, myPoint1, myPoint2 ); anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
if ( !anObj->_is_nil() ) RotateThreePointsCopy(myObjects[i], myCentPoint, myPoint1, myPoint2);
objects.push_back( anObj._retn() ); if (!anObj->_is_nil())
} objects.push_back(anObj._retn());
}
} }
else { else {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
myCurrObject = myObjects[i]; myCurrObject = myObjects[i];
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->RotateThreePoints( myObjects[i], myCentPoint, myPoint1, myPoint2 ); anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
if ( !anObj->_is_nil() ) RotateThreePoints(myObjects[i], myCentPoint, myPoint1, myPoint2);
objects.push_back( anObj._retn() ); if (!anObj->_is_nil())
} objects.push_back(anObj._retn());
}
} }
res = true; res = true;
break; break;
} }
} }
return res; return res;
} }
@ -491,19 +570,19 @@ bool TransformationGUI_RotationDlg::execute( ObjectList& objects )
// function : restoreSubShapes // function : restoreSubShapes
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_RotationDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy, void TransformationGUI_RotationDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject ) SALOMEDS::SObject_ptr theSObject)
{ {
if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) { if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
// we pass here the first operation argument (object) through the list of arguments // we pass here the first operation argument (object) through the list of arguments
// because the rotation operation place its arguments in the data structure in another order, // because the rotation operation place its arguments in the data structure in another order,
// and we need to point the first argument directly // and we need to point the first argument directly
GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO; GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
anArgs->length(1); anArgs->length(1);
anArgs[0] = myCurrObject; anArgs[0] = myCurrObject;
getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, anArgs, getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
/*theFindMethod=*/GEOM::FSM_Transformed, /*theFindMethod=*/GEOM::FSM_Transformed,
/*theInheritFirstArg=*/true ); /*theInheritFirstArg=*/true);
} }
} }
@ -520,9 +599,9 @@ double TransformationGUI_RotationDlg::GetAngle() const
// function : CreateCopyModeChanged() // function : CreateCopyModeChanged()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_RotationDlg::CreateCopyModeChanged( bool isCreateCopy ) void TransformationGUI_RotationDlg::CreateCopyModeChanged (bool isCreateCopy)
{ {
mainFrame()->GroupBoxName->setEnabled( isCreateCopy ); mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
} }
//================================================================================= //=================================================================================
@ -532,19 +611,19 @@ void TransformationGUI_RotationDlg::CreateCopyModeChanged( bool isCreateCopy )
void TransformationGUI_RotationDlg::onReverse() void TransformationGUI_RotationDlg::onReverse()
{ {
double anOldValue = GroupPoints->SpinBox_DX->value(); double anOldValue = GroupPoints->SpinBox_DX->value();
GroupPoints->SpinBox_DX->setValue( -anOldValue ); GroupPoints->SpinBox_DX->setValue(-anOldValue);
} }
//================================================================================= //=================================================================================
// function : addSubshapeToStudy // function : addSubshapesToStudy
// purpose : virtual method to add new SubObjects if local selection // purpose : virtual method to add new SubObjects if local selection
//================================================================================= //=================================================================================
void TransformationGUI_RotationDlg::addSubshapesToStudy() void TransformationGUI_RotationDlg::addSubshapesToStudy()
{ {
bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked(); bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
if ( toCreateCopy ) { if (toCreateCopy) {
QMap<QString, GEOM::GEOM_Object_var> objMap; QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
objMap[GroupPoints->LineEdit2->text()] = myAxis; objMap[GroupPoints->LineEdit2->text()] = myAxis;
break; break;
@ -554,6 +633,6 @@ void TransformationGUI_RotationDlg::addSubshapesToStudy()
objMap[GroupPoints->LineEdit5->text()] = myPoint2; objMap[GroupPoints->LineEdit5->text()] = myPoint2;
break; break;
} }
addSubshapesToFather( objMap ); addSubshapesToFather(objMap);
} }
} }

View File

@ -60,6 +60,9 @@ private:
GEOM::ListOfGO myObjects; GEOM::ListOfGO myObjects;
GEOM::GEOM_Object_var myCurrObject; GEOM::GEOM_Object_var myCurrObject;
GEOM::GEOM_Object_var myAxis, myCentPoint, myPoint1, myPoint2; GEOM::GEOM_Object_var myAxis, myCentPoint, myPoint1, myPoint2;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_4Sel1Spin2Check* GroupPoints; DlgRef_4Sel1Spin2Check* GroupPoints;

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : TransformationGUI_ScaleDlg.cxx // File : TransformationGUI_ScaleDlg.cxx
@ -29,11 +29,12 @@
#include <GEOMBase.h> #include <GEOMBase.h>
#include <QtxDoubleSpinBox.h> #include <QtxDoubleSpinBox.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
@ -44,125 +45,94 @@
//================================================================================= //=================================================================================
// class : TransformationGUI_ScaleDlg() // class : TransformationGUI_ScaleDlg()
// purpose : Constructs a TransformationGUI_ScaleDlg which is a child of 'parent', with the // purpose : Constructs a TransformationGUI_ScaleDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg( GeometryGUI* theGeometryGUI, QWidget* parent, TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl ) bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
{ {
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_SCALE" ) ) ); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_SCALE")));
QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_SCALE_ALONG_AXES" ) ) ); QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_SCALE_ALONG_AXES")));
QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_SCALE_TITLE" ) ); setWindowTitle(tr("GEOM_SCALE_TITLE"));
// Constructors // Constructors
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_SCALE" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_SCALE"));
mainFrame()->RadioButton1->setIcon( image1 ); mainFrame()->RadioButton1->setIcon(image1);
mainFrame()->RadioButton2->setIcon( image2 ); mainFrame()->RadioButton2->setIcon(image2);
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
// Own widgets // Own widgets
GroupBox1 = new QGroupBox( tr( "GEOM_ARGUMENTS" ), this ); GroupBox1 = new QGroupBox(tr("GEOM_ARGUMENTS"), this);
QGridLayout* OwnLayout = new QGridLayout( GroupBox1 ); QGridLayout* OwnLayout = new QGridLayout(GroupBox1);
OwnLayout->setSpacing( 6 ); OwnLayout->setSpacing(6);
OwnLayout->setMargin( 11 ); OwnLayout->setMargin(11);
TextLabel1 = new QLabel( tr( "GEOM_OBJECTS" ), GroupBox1 ); TextLabel1 = new QLabel(tr("GEOM_OBJECTS"), GroupBox1);
PushButton1 = new QPushButton( GroupBox1 ); PushButton1 = new QPushButton(GroupBox1);
PushButton1->setIcon( image3 ); PushButton1->setIcon(image3);
PushButton1->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); PushButton1->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
LineEdit1 = new QLineEdit( GroupBox1 ); LineEdit1 = new QLineEdit(GroupBox1);
LineEdit1->setReadOnly( true ); LineEdit1->setReadOnly(true);
LineEdit1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); LineEdit1->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
TextLabel2 = new QLabel( tr( "GEOM_CENTRAL_POINT" ), GroupBox1 ); TextLabel2 = new QLabel(tr("GEOM_CENTRAL_POINT"), GroupBox1);
PushButton2 = new QPushButton( GroupBox1 ); PushButton2 = new QPushButton(GroupBox1);
PushButton2->setIcon( image3 ); PushButton2->setIcon(image3);
PushButton2->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); PushButton2->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
LineEdit2 = new QLineEdit( GroupBox1 ); LineEdit2 = new QLineEdit(GroupBox1);
LineEdit2->setReadOnly( true ); LineEdit2->setReadOnly(true);
LineEdit2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); LineEdit2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
TextLabel3 = new QLabel( tr( "GEOM_SCALE_FACTOR" ), GroupBox1 ); TextLabel3 = new QLabel(tr("GEOM_SCALE_FACTOR"), GroupBox1);
SpinBox_FX = new QtxDoubleSpinBox( GroupBox1 ); SpinBox_FX = new QtxDoubleSpinBox(GroupBox1);
TextLabel4 = new QLabel( tr( "GEOM_SCALE_FACTOR_Y" ), GroupBox1 ); TextLabel4 = new QLabel(tr("GEOM_SCALE_FACTOR_Y"), GroupBox1);
SpinBox_FY = new QtxDoubleSpinBox( GroupBox1 ); SpinBox_FY = new QtxDoubleSpinBox(GroupBox1);
TextLabel5 = new QLabel( tr( "GEOM_SCALE_FACTOR_Z" ), GroupBox1 ); TextLabel5 = new QLabel(tr("GEOM_SCALE_FACTOR_Z"), GroupBox1);
SpinBox_FZ = new QtxDoubleSpinBox( GroupBox1 ); SpinBox_FZ = new QtxDoubleSpinBox(GroupBox1);
CheckBoxCopy = new QCheckBox( tr( "GEOM_CREATE_COPY" ), GroupBox1 ); CheckBoxCopy = new QCheckBox(tr("GEOM_CREATE_COPY"), GroupBox1);
CheckBoxCopy->setChecked( true ); CheckBoxCopy->setChecked(true);
// Layouting // Layouting
OwnLayout->addWidget( TextLabel1, 0, 0 ); OwnLayout->addWidget(TextLabel1, 0, 0);
OwnLayout->addWidget( PushButton1, 0, 1 ); OwnLayout->addWidget(PushButton1, 0, 1);
OwnLayout->addWidget( LineEdit1, 0, 2, 1, 2 ); OwnLayout->addWidget(LineEdit1, 0, 2, 1, 2);
OwnLayout->addWidget( TextLabel2, 1, 0 ); OwnLayout->addWidget(TextLabel2, 1, 0);
OwnLayout->addWidget( PushButton2, 1, 1 ); OwnLayout->addWidget(PushButton2, 1, 1);
OwnLayout->addWidget( LineEdit2, 1, 2, 1, 2 ); OwnLayout->addWidget(LineEdit2, 1, 2, 1, 2);
OwnLayout->addWidget( TextLabel3, 2, 0 ); OwnLayout->addWidget(TextLabel3, 2, 0);
OwnLayout->addWidget( SpinBox_FX, 2, 2 ); OwnLayout->addWidget(SpinBox_FX, 2, 2);
OwnLayout->addWidget( TextLabel4, 3, 0 ); OwnLayout->addWidget(TextLabel4, 3, 0);
OwnLayout->addWidget( SpinBox_FY, 3, 2 ); OwnLayout->addWidget(SpinBox_FY, 3, 2);
OwnLayout->addWidget( TextLabel5, 4, 0 ); OwnLayout->addWidget(TextLabel5, 4, 0);
OwnLayout->addWidget( SpinBox_FZ, 4, 2 ); OwnLayout->addWidget(SpinBox_FZ, 4, 2);
OwnLayout->addWidget( CheckBoxCopy, 5, 0, 1, 4 ); OwnLayout->addWidget(CheckBoxCopy, 5, 0, 1, 4);
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget( GroupBox1 ); layout->addWidget(GroupBox1);
// Min, max, step and decimals for spin boxes & initial values setHelpFileName("scale_operation_page.html");
double aFactor = 2.0;
double SpecificStep = 0.5;
initSpinBox( SpinBox_FX, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY );
initSpinBox( SpinBox_FY, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY );
initSpinBox( SpinBox_FZ, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY );
SpinBox_FX->setValue( aFactor );
SpinBox_FY->setValue( aFactor );
SpinBox_FZ->setValue( aFactor );
// Modification of an existing object by offset is not allowed // Modification of an existing object by offset is not allowed
CheckBoxCopy->hide(); CheckBoxCopy->hide();
// Activate Create a Copy mode // Activate Create a Copy mode
CreateCopyModeChanged( true ); CreateCopyModeChanged(true);
// Allowed inheritance of children and visual properties by the scaling result // Allowed inheritance of children and visual properties by the scaling result
mainFrame()->GroupBoxPublish->show(); mainFrame()->GroupBoxPublish->show();
// Signals and slots connections
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
connect( PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( SpinBox_FX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
connect( SpinBox_FY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
connect( SpinBox_FZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
connect( CheckBoxCopy, SIGNAL( toggled( bool ) ), this, SLOT( CreateCopyModeChanged( bool ) ) );
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
setHelpFileName( "scale_operation_page.html" );
Init(); Init();
} }
@ -171,7 +141,7 @@ TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg( GeometryGUI* theGeometry
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
//================================================================================= //=================================================================================
TransformationGUI_ScaleDlg::~TransformationGUI_ScaleDlg() TransformationGUI_ScaleDlg::~TransformationGUI_ScaleDlg()
{ {
} }
//================================================================================= //=================================================================================
@ -180,39 +150,73 @@ TransformationGUI_ScaleDlg::~TransformationGUI_ScaleDlg()
//================================================================================= //=================================================================================
void TransformationGUI_ScaleDlg::Init() void TransformationGUI_ScaleDlg::Init()
{ {
myEditCurrentArgument = LineEdit1; // Min, max, step and decimals for spin boxes & initial values
LineEdit2->clear(); double aFactor = 2.0;
double SpecificStep = 0.5;
myPoint = GEOM::GEOM_Object::_nil();
initName( tr( "GEOM_SCALE" ) );
ConstructorsClicked( 0 ); initSpinBox(SpinBox_FX, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
initSpinBox(SpinBox_FY, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
initSpinBox(SpinBox_FZ, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
SpinBox_FX->setValue(aFactor);
SpinBox_FY->setValue(aFactor);
SpinBox_FZ->setValue(aFactor);
// init variables
LineEdit1->setText("");
LineEdit2->setText("");
myPoint = GEOM::GEOM_Object::_nil();
// Signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
connect(PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(SpinBox_FX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(SpinBox_FY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(SpinBox_FZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
connect(CheckBoxCopy, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
initName(tr("GEOM_SCALE"));
ConstructorsClicked(0);
} }
//================================================================================= //=================================================================================
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
//================================================================================= //=================================================================================
void TransformationGUI_ScaleDlg::ConstructorsClicked( int constructorId ) void TransformationGUI_ScaleDlg::ConstructorsClicked (int constructorId)
{ {
erasePreview(); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
switch( constructorId ) switch (constructorId) {
{ case 0: // translation an object by dx, dy, dz
case 0: /* translation an object by dx, dy, dz */ TextLabel3->setText(tr("GEOM_SCALE_FACTOR"));
TextLabel3->setText( tr( "GEOM_SCALE_FACTOR" ) );
TextLabel4->hide(); TextLabel4->hide();
TextLabel5->hide(); TextLabel5->hide();
SpinBox_FY->hide(); SpinBox_FY->hide();
SpinBox_FZ->hide(); SpinBox_FZ->hide();
PushButton1->click();
break; break;
case 1: /* translation an object by 2 points */ case 1: // translation an object by 2 points
TextLabel3->setText( tr( "GEOM_SCALE_FACTOR_X" ) ); TextLabel3->setText(tr("GEOM_SCALE_FACTOR_X"));
TextLabel4->show(); TextLabel4->show();
TextLabel5->show(); TextLabel5->show();
SpinBox_FY->show(); SpinBox_FY->show();
SpinBox_FZ->show(); SpinBox_FZ->show();
PushButton1->click();
break; break;
default: default:
break; break;
@ -220,9 +224,15 @@ void TransformationGUI_ScaleDlg::ConstructorsClicked( int constructorId )
qApp->processEvents(); qApp->processEvents();
updateGeometry(); updateGeometry();
resize( minimumSize() ); resize(minimumSize());
displayPreview(); if (myInitial) {
myInitial = false;
SelectionIntoArgument();
}
else {
displayPreview();
}
} }
//================================================================================= //=================================================================================
@ -231,7 +241,7 @@ void TransformationGUI_ScaleDlg::ConstructorsClicked( int constructorId )
//================================================================================= //=================================================================================
void TransformationGUI_ScaleDlg::ClickOnOk() void TransformationGUI_ScaleDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
@ -241,38 +251,46 @@ void TransformationGUI_ScaleDlg::ClickOnOk()
//================================================================================= //=================================================================================
bool TransformationGUI_ScaleDlg::ClickOnApply() bool TransformationGUI_ScaleDlg::ClickOnApply()
{ {
if ( !onAccept( CheckBoxCopy->isChecked() ) ) if (!onAccept(CheckBoxCopy->isChecked()))
return false; return false;
initName( tr( "GEOM_SCALE" ) ); initName(tr("GEOM_SCALE"));
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void TransformationGUI_ScaleDlg::SelectionIntoArgument() void TransformationGUI_ScaleDlg::SelectionIntoArgument()
{ {
erasePreview(); erasePreview();
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText("");
QString aName;
if (myEditCurrentArgument == LineEdit1)
myObjects.length(0);
else if (myEditCurrentArgument == LineEdit2)
myPoint = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
QString aName;
if (myEditCurrentArgument == LineEdit1) if (myEditCurrentArgument == LineEdit1)
{ {
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName); int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
if (aNbSel < 1) if (aNbSel < 1)
{
myObjects.length(0);
return; return;
}
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects); GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
if (!myObjects.length()) if (!myObjects.length())
return; return;
else
myEditCurrentArgument->setText(aName);
} }
else if (myEditCurrentArgument == LineEdit2) else if (myEditCurrentArgument == LineEdit2)
{ {
@ -292,24 +310,23 @@ void TransformationGUI_ScaleDlg::SelectionIntoArgument()
aSelMgr->GetIndexes(aSelList.First(), aMap); aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) if (aMap.Extent() == 1)
{ {
int anIndex = aMap( 1 ); int anIndex = aMap(1);
aName += QString( ":vertex_%1" ).arg( anIndex ); aName += QString(":vertex_%1").arg(anIndex);
//Find SubShape Object in Father //Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = findObjectInFather( aSelectedObject, aName ); GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations( getStudyId() ); getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
aSelMgr->clearSelected();
} }
else else
aSelectedObject = aFindedObject; // get Object from study aSelectedObject = aFindedObject; // get Object from study
} }
else else // Global Selection
{ {
if ( aShape.ShapeType() != TopAbs_VERTEX ) { if (aShape.ShapeType() != TopAbs_VERTEX) {
aSelectedObject = GEOM::GEOM_Object::_nil(); aSelectedObject = GEOM::GEOM_Object::_nil();
aName = ""; aName = "";
} }
@ -319,9 +336,56 @@ void TransformationGUI_ScaleDlg::SelectionIntoArgument()
} }
myPoint = aSelectedObject; myPoint = aSelectedObject;
myEditCurrentArgument->setText(aName);
if (!myPoint->_is_nil() && !myObjects.length())
PushButton1->click();
} }
myEditCurrentArgument->setText(aName); // clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
displayPreview();
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void TransformationGUI_ScaleDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection();
if (send == PushButton1) {
myEditCurrentArgument = LineEdit1;
PushButton2->setDown(false);
LineEdit2->setEnabled(false);
}
else if (send == PushButton2) {
myEditCurrentArgument = LineEdit2;
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
PushButton1->setDown(false);
LineEdit1->setEnabled(false);
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview(); displayPreview();
} }
@ -332,34 +396,13 @@ void TransformationGUI_ScaleDlg::SelectionIntoArgument()
void TransformationGUI_ScaleDlg::LineEditReturnPressed() void TransformationGUI_ScaleDlg::LineEditReturnPressed()
{ {
QLineEdit* send = (QLineEdit*)sender(); QLineEdit* send = (QLineEdit*)sender();
if ( send == LineEdit1 || send == LineEdit2 ) if (send == LineEdit1 || send == LineEdit2)
{ {
myEditCurrentArgument = send; myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void TransformationGUI_ScaleDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
globalSelection();
if ( send == PushButton1 ) {
myEditCurrentArgument = LineEdit1;
}
else if ( send == PushButton2 ) {
myEditCurrentArgument = LineEdit2;
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
}
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -367,22 +410,18 @@ void TransformationGUI_ScaleDlg::SetEditCurrentArgument()
void TransformationGUI_ScaleDlg::ActivateThisDialog() void TransformationGUI_ScaleDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) ); // reinit, because some selected objects could be removed
globalSelection(); Init();
myEditCurrentArgument->setFocus();
if ( myEditCurrentArgument == LineEdit2 ) {
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
}
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_ScaleDlg::enterEvent( QEvent* ) void TransformationGUI_ScaleDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
@ -399,11 +438,11 @@ void TransformationGUI_ScaleDlg::ValueChangedInSpinBox()
// function : SetDoubleSpinBoxStep() // function : SetDoubleSpinBoxStep()
// purpose : Double spin box management // purpose : Double spin box management
//================================================================================= //=================================================================================
void TransformationGUI_ScaleDlg::SetDoubleSpinBoxStep( double step ) void TransformationGUI_ScaleDlg::SetDoubleSpinBoxStep(double step)
{ {
SpinBox_FX->setSingleStep( step ); SpinBox_FX->setSingleStep(step);
SpinBox_FY->setSingleStep( step ); SpinBox_FY->setSingleStep(step);
SpinBox_FZ->setSingleStep( step ); SpinBox_FZ->setSingleStep(step);
} }
//================================================================================= //=================================================================================
@ -412,22 +451,22 @@ void TransformationGUI_ScaleDlg::SetDoubleSpinBoxStep( double step )
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr TransformationGUI_ScaleDlg::createOperation() GEOM::GEOM_IOperations_ptr TransformationGUI_ScaleDlg::createOperation()
{ {
return myGeomGUI->GetGeomGen()->GetITransformOperations( getStudyId() ); return getGeomEngine()->GetITransformOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_ScaleDlg::isValid( QString& /*msg*/) bool TransformationGUI_ScaleDlg::isValid (QString& /*msg*/)
{ {
if ( myObjects.length() > 0 && fabs( SpinBox_FX->value() ) > 0.00001 ) if (myObjects.length() > 0 && fabs(SpinBox_FX->value()) > 0.00001)
{ {
// && !myPoint->_is_nil() // && !myPoint->_is_nil()
if ( getConstructorId() == 0 ) if (getConstructorId() == 0)
return true; return true;
if ( fabs( SpinBox_FY->value() ) > 0.00001 && if (fabs(SpinBox_FY->value()) > 0.00001 &&
fabs( SpinBox_FZ->value() ) > 0.00001 ) fabs(SpinBox_FZ->value()) > 0.00001)
return true; return true;
} }
return false; return false;
@ -437,60 +476,60 @@ bool TransformationGUI_ScaleDlg::isValid( QString& /*msg*/)
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_ScaleDlg::execute( ObjectList& objects ) bool TransformationGUI_ScaleDlg::execute (ObjectList& objects)
{ {
bool toCreateCopy = IsPreview() || CheckBoxCopy->isChecked(); bool toCreateCopy = IsPreview() || CheckBoxCopy->isChecked();
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
switch ( getConstructorId() ) switch (getConstructorId())
{ {
case 0: case 0:
{ {
if ( toCreateCopy ) if (toCreateCopy)
{ {
for ( int i = 0; i < myObjects.length(); i++ ) for (int i = 0; i < myObjects.length(); i++)
{ {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
ScaleShapeCopy( myObjects[i], myPoint, SpinBox_FX->value() ); ScaleShapeCopy(myObjects[i], myPoint, SpinBox_FX->value());
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
} }
else else
{ {
for ( int i = 0; i < myObjects.length(); i++ ) for (int i = 0; i < myObjects.length(); i++)
{ {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
ScaleShape( myObjects[i], myPoint, SpinBox_FX->value() ); ScaleShape(myObjects[i], myPoint, SpinBox_FX->value());
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
} }
} }
break; break;
case 1: case 1:
{ {
if ( toCreateCopy ) if (toCreateCopy)
{ {
for ( int i = 0; i < myObjects.length(); i++ ) for (int i = 0; i < myObjects.length(); i++)
{ {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
ScaleShapeAlongAxesCopy( myObjects[i], myPoint, SpinBox_FX->value(), ScaleShapeAlongAxesCopy(myObjects[i], myPoint, SpinBox_FX->value(),
SpinBox_FY->value(), SpinBox_FZ->value() ); SpinBox_FY->value(), SpinBox_FZ->value());
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
} }
else else
{ {
for ( int i = 0; i < myObjects.length(); i++ ) for (int i = 0; i < myObjects.length(); i++)
{ {
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
ScaleShapeAlongAxes( myObjects[i], myPoint, SpinBox_FX->value(), ScaleShapeAlongAxes(myObjects[i], myPoint, SpinBox_FX->value(),
SpinBox_FY->value(), SpinBox_FZ->value() ); SpinBox_FY->value(), SpinBox_FZ->value());
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
} }
} }
@ -506,14 +545,14 @@ bool TransformationGUI_ScaleDlg::execute( ObjectList& objects )
// function : restoreSubShapes // function : restoreSubShapes
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_ScaleDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy, void TransformationGUI_ScaleDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject ) SALOMEDS::SObject_ptr theSObject)
{ {
if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) { if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored // empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(), getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
/*theFindMethod=*/GEOM::FSM_Transformed, /*theFindMethod=*/GEOM::FSM_Transformed,
/*theInheritFirstArg=*/true ); /*theInheritFirstArg=*/true);
} }
} }
@ -521,9 +560,9 @@ void TransformationGUI_ScaleDlg::restoreSubShapes( SALOMEDS::Study_ptr theStud
// function : CreateCopyModeChanged() // function : CreateCopyModeChanged()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_ScaleDlg::CreateCopyModeChanged( bool isCreateCopy ) void TransformationGUI_ScaleDlg::CreateCopyModeChanged (bool isCreateCopy)
{ {
mainFrame()->GroupBoxName->setEnabled( isCreateCopy ); mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
} }
//================================================================================= //=================================================================================
@ -533,13 +572,13 @@ void TransformationGUI_ScaleDlg::CreateCopyModeChanged( bool isCreateCopy )
void TransformationGUI_ScaleDlg::addSubshapesToStudy() void TransformationGUI_ScaleDlg::addSubshapesToStudy()
{ {
bool toCreateCopy = IsPreview() || CheckBoxCopy->isChecked(); bool toCreateCopy = IsPreview() || CheckBoxCopy->isChecked();
if ( toCreateCopy ) if (toCreateCopy)
{ {
if ( !myPoint->_is_nil() ) if (!myPoint->_is_nil())
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap; QMap<QString, GEOM::GEOM_Object_var> objMap;
objMap[LineEdit2->text()] = myPoint; objMap[LineEdit2->text()] = myPoint;
addSubshapesToFather( objMap ); addSubshapesToFather(objMap);
} }
} }
} }

View File

@ -65,6 +65,9 @@ private:
private: private:
GEOM::ListOfGO myObjects; GEOM::ListOfGO myObjects;
GEOM::GEOM_Object_var myPoint; /* Central Point */ GEOM::GEOM_Object_var myPoint; /* Central Point */
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
QGroupBox* GroupBox1; QGroupBox* GroupBox1;
QLabel* TextLabel1; QLabel* TextLabel1;

View File

@ -196,8 +196,8 @@ void TransformationGUI_TranslationDlg::ConstructorsClicked (int constructorId)
GroupPoints->CheckBox1->hide(); GroupPoints->CheckBox1->hide();
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
break;
} }
break;
case 1: // translation an object by 2 points case 1: // translation an object by 2 points
{ {
GroupPoints->ShowRows(3, 5, false); GroupPoints->ShowRows(3, 5, false);
@ -214,8 +214,8 @@ void TransformationGUI_TranslationDlg::ConstructorsClicked (int constructorId)
myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
break;
} }
break;
case 2: // translation an object by vector case 2: // translation an object by vector
{ {
GroupPoints->ShowRows(0, 1, true); GroupPoints->ShowRows(0, 1, true);
@ -234,8 +234,8 @@ void TransformationGUI_TranslationDlg::ConstructorsClicked (int constructorId)
ActivateDistanceChanged(GroupPoints->CheckBox1->isChecked()); ActivateDistanceChanged(GroupPoints->CheckBox1->isChecked());
GroupPoints->PushButton1->click(); GroupPoints->PushButton1->click();
break;
} }
break;
} }
qApp->processEvents(); qApp->processEvents();