// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : OperationGUI_ChamferDlg.cxx
#include <LightApp_SelectionMgr.h>
#include <OCCViewer_ViewModel.h>
+// OCCT Includes
#include <TColStd_MapOfInteger.hxx>
#include <GEOMImpl_Types.hxx>
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
-OperationGUI_ChamferDlg::OperationGUI_ChamferDlg( GeometryGUI* theGeometryGUI, QWidget* parent )
- : GEOMBase_Skeleton( theGeometryGUI, parent, false )
+OperationGUI_ChamferDlg::OperationGUI_ChamferDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, false),
+ myInitial(true)
{
- QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CHAMFER_ALL" ) ) );
- QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CHAMFER_EDGE_FROM_FACE" ) ) );
- QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CHAMFER_FACE" ) ) );
- QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CHAMFER_EDGE" ) ) );
- QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_CHAMFER_ALL")));
+ QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_CHAMFER_EDGE_FROM_FACE")));
+ QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_CHAMFER_FACE")));
+ QPixmap image4 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_CHAMFER_EDGE")));
+
+ QPixmap iconSelect (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
- setWindowTitle( tr( "GEOM_CHAMFER_TITLE" ) );
+ setWindowTitle(tr("GEOM_CHAMFER_TITLE"));
- mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CHAMFER" ) );
+ /***************************************************************/
+ mainFrame()->GroupConstructors->setTitle(tr("GEOM_CHAMFER"));
- mainFrame()->RadioButton1->setIcon( image1 );
- mainFrame()->RadioButton2->setIcon( image2 );
- mainFrame()->RadioButton3->setIcon( image3 );
+ mainFrame()->RadioButton1->setIcon(image1);
+ mainFrame()->RadioButton2->setIcon(image2);
+ mainFrame()->RadioButton3->setIcon(image3);
mainFrame()->RadioButton4->show();
- mainFrame()->RadioButton4->setIcon( image4 );
+ mainFrame()->RadioButton4->setIcon(image4);
// Create first group
- myGrp1 = new QGroupBox( tr( "GEOM_CHAMFER_ALL" ), centralWidget() );
+ myGrp1 = new QGroupBox(tr("GEOM_CHAMFER_ALL"), centralWidget());
- QGridLayout* aLayout = new QGridLayout( myGrp1 );
- aLayout->setMargin( 9 ); aLayout->setSpacing( 6 );
+ QGridLayout* aLayout = new QGridLayout(myGrp1);
+ aLayout->setMargin(9); aLayout->setSpacing(6);
- createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, myGrp1, aLayout, MainObj1 );
+ createSelWg(tr("GEOM_MAIN_OBJECT"), iconSelect, myGrp1, aLayout, MainObj1);
int row = aLayout->rowCount();
- aLayout->addWidget( new QLabel( tr( "D" ), myGrp1 ), row, 0 );
- aLayout->addWidget( ( mySpinBox[ SpinBox1 ] = new QDoubleSpinBox( myGrp1 ) ), row++, 2 );
- aLayout->setRowStretch( row, 10 );
+ aLayout->addWidget(new QLabel(tr("D"), myGrp1), row, 0);
+ aLayout->addWidget((mySpinBox[ SpinBox1 ] = new QDoubleSpinBox(myGrp1)), row++, 2);
+ aLayout->setRowStretch(row, 10);
// Create second group
- myGrp2 = new QGroupBox( tr( "GEOM_CHAMFER_EDGES" ), centralWidget() );
+ myGrp2 = new QGroupBox(tr("GEOM_CHAMFER_EDGES"), centralWidget());
- aLayout = new QGridLayout( myGrp2 );
- aLayout->setMargin( 9 ); aLayout->setSpacing( 6 );
+ aLayout = new QGridLayout(myGrp2);
+ aLayout->setMargin(9); aLayout->setSpacing(6);
- createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, myGrp2, aLayout, MainObj2 );
- createSelWg( tr( "FACE_1" ), iconSelect, myGrp2, aLayout, Face1 );
- createSelWg( tr( "FACE_2" ), iconSelect, myGrp2, aLayout, Face2 );
+ createSelWg(tr("GEOM_MAIN_OBJECT"), iconSelect, myGrp2, aLayout, MainObj2);
+ createSelWg(tr("FACE_1"), iconSelect, myGrp2, aLayout, Face1);
+ createSelWg(tr("FACE_2"), iconSelect, myGrp2, aLayout, Face2);
- createRadioWg( tr( "GEOM_D1" ), tr( "GEOM_D2" ), myGrp2, aLayout, RadioButton21, SpinBox21, SpinBox22 );
- createRadioWg( tr( "GEOM_D" ), tr( "GEOM_ANGLE" ), myGrp2, aLayout, RadioButton22, SpinBox23, SpinBox24 );
+ createRadioWg(tr("GEOM_D1"), tr("GEOM_D2"), myGrp2, aLayout, RadioButton21, SpinBox21, SpinBox22);
+ createRadioWg(tr("GEOM_D"), tr("GEOM_ANGLE"), myGrp2, aLayout, RadioButton22, SpinBox23, SpinBox24);
- aLayout->setRowStretch( aLayout->rowCount(), 10 );
+ aLayout->setRowStretch(aLayout->rowCount(), 10);
// Create third group
- myGrp3 = new QGroupBox( tr( "GEOM_CHAMFER_FACES" ), centralWidget() );
+ myGrp3 = new QGroupBox(tr("GEOM_CHAMFER_FACES"), centralWidget());
- aLayout = new QGridLayout( myGrp3 );
- aLayout->setMargin( 9 ); aLayout->setSpacing( 6 );
+ aLayout = new QGridLayout(myGrp3);
+ aLayout->setMargin(9); aLayout->setSpacing(6);
- createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, myGrp3, aLayout, MainObj3 );
- createSelWg( tr( "SELECTED_FACES" ), iconSelect, myGrp3, aLayout, Faces );
+ createSelWg(tr("GEOM_MAIN_OBJECT"), iconSelect, myGrp3, aLayout, MainObj3);
+ createSelWg(tr("SELECTED_FACES"), iconSelect, myGrp3, aLayout, Faces);
- createRadioWg( tr( "GEOM_D1" ), tr( "GEOM_D2" ), myGrp3, aLayout, RadioButton31, SpinBox31, SpinBox32 );
- createRadioWg( tr( "GEOM_D" ), tr( "GEOM_ANGLE" ), myGrp3, aLayout, RadioButton32, SpinBox33, SpinBox34 );
+ createRadioWg(tr("GEOM_D1"), tr("GEOM_D2"), myGrp3, aLayout, RadioButton31, SpinBox31, SpinBox32);
+ createRadioWg(tr("GEOM_D"), tr("GEOM_ANGLE"), myGrp3, aLayout, RadioButton32, SpinBox33, SpinBox34);
- aLayout->setRowStretch( aLayout->rowCount(), 10 );
+ aLayout->setRowStretch(aLayout->rowCount(), 10);
// Create fourth group
- myGrp4 = new QGroupBox( tr( "GEOM_CHAMFER_EDGE" ), centralWidget() );
+ myGrp4 = new QGroupBox(tr("GEOM_CHAMFER_EDGE"), centralWidget());
- aLayout = new QGridLayout( myGrp4 );
- aLayout->setMargin( 9 ); aLayout->setSpacing( 6 );
+ aLayout = new QGridLayout(myGrp4);
+ aLayout->setMargin(9); aLayout->setSpacing(6);
- createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, myGrp4, aLayout, MainObj4 );
- createSelWg( tr( "SELECTED_EDGE" ), iconSelect, myGrp4, aLayout, Edges );
+ createSelWg(tr("GEOM_MAIN_OBJECT"), iconSelect, myGrp4, aLayout, MainObj4);
+ createSelWg(tr("SELECTED_EDGE"), iconSelect, myGrp4, aLayout, Edges);
- createRadioWg( tr( "GEOM_D1" ), tr( "GEOM_D2" ), myGrp4, aLayout, RadioButton41, SpinBox41, SpinBox42 );
- createRadioWg( tr( "GEOM_D" ), tr( "GEOM_ANGLE" ), myGrp4, aLayout, RadioButton42, SpinBox43, SpinBox44 );
+ createRadioWg(tr("GEOM_D1"), tr("GEOM_D2"), myGrp4, aLayout, RadioButton41, SpinBox41, SpinBox42);
+ createRadioWg(tr("GEOM_D"), tr("GEOM_ANGLE"), myGrp4, aLayout, RadioButton42, SpinBox43, SpinBox44);
- aLayout->setRowStretch( aLayout->rowCount(), 10 );
+ aLayout->setRowStretch(aLayout->rowCount(), 10);
// Add groups to layout
- QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
- layout->setMargin( 0 ); layout->setSpacing( 6 );
- layout->addWidget( myGrp1 );
- layout->addWidget( myGrp2 );
- layout->addWidget( myGrp3 );
- layout->addWidget( myGrp4 );
+ QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+ layout->setMargin(0); layout->setSpacing(6);
+ layout->addWidget(myGrp1);
+ layout->addWidget(myGrp2);
+ layout->addWidget(myGrp3);
+ layout->addWidget(myGrp4);
+ /***************************************************************/
// Set range of spinboxes
-
double SpecificStep = 10.0;
QMap< int, QDoubleSpinBox* >::iterator anIter;
- for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter ) {
- if ( anIter.key() == SpinBox44 || anIter.key() == SpinBox34 || anIter.key() == SpinBox24 )
- initSpinBox( anIter.value(), 0.001, 89.999, 5, 0 );
+ for (anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter) {
+ if (anIter.key() == SpinBox44 || anIter.key() == SpinBox34 || anIter.key() == SpinBox24)
+ initSpinBox(anIter.value(), 0.001, 89.999, 5, 0);
else
- initSpinBox( anIter.value(), 0.001, COORD_MAX, SpecificStep, 3 );
+ initSpinBox(anIter.value(), 0.001, COORD_MAX, SpecificStep, 3);
}
- setHelpFileName( "chamfer_operation_page.html" );
+ setHelpFileName("chamfer_operation_page.html");
- /* Initialisations */
+ // Initialisation
Init();
myRadioButton[ RadioButton21 ]->click();
}
-
//=================================================================================
// function : ~OperationGUI_ChamferDlg()
// purpose : Destroys the object and frees any allocated resources
{
}
-
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void OperationGUI_ChamferDlg::Init()
{
- myConstructorId = -1;
- reset();
+ // Set Initial values of spinboxes
+ QMap< int, QDoubleSpinBox* >::iterator anIter;
+ for (anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter)
+ anIter.value()->setValue(5);
+
+ // Clear line edits
+ QMap< int, QLineEdit* >::iterator anIterLE;
+ for (anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE)
+ anIterLE.value()->setText("");
+
+ myShape = GEOM::GEOM_Object::_nil();
+
+ myFaces.Clear();
+ myEdges.Clear();
+ myFace[ Face1 ] = -1;
+ myFace[ Face2 ] = -1;
- /* signals and slots connections */
+ // signals and slots connections
// main buttons
- connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
- connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+ connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk() ));
+ connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
// group box
- connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
+ connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
// push buttons
QMap< int, QPushButton* >::iterator anIterBtn;
- for ( anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn )
- connect( anIterBtn.value(), SIGNAL( clicked() ),
- this, SLOT( SetEditCurrentArgument() ) );
+ for (anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn)
+ connect(anIterBtn.value(), SIGNAL(clicked()),
+ this, SLOT(SetEditCurrentArgument()));
// line edits
QMap< int, QLineEdit* >::iterator anIterLE2;
- for ( anIterLE2 = mySelName.begin(); anIterLE2 != mySelName.end(); ++anIterLE2 )
- connect( anIterLE2.value(), SIGNAL( returnPressed() ),
- this, SLOT( LineEditReturnPressed() ) );
+ for (anIterLE2 = mySelName.begin(); anIterLE2 != mySelName.end(); ++anIterLE2)
+ connect(anIterLE2.value(), SIGNAL(returnPressed()),
+ this, SLOT(LineEditReturnPressed()));
// spin boxes
QMap< int, QDoubleSpinBox* >::iterator anIterSpin;
- for ( anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin )
- connect( anIterSpin.value(), SIGNAL( valueChanged( double ) ),
- this, SLOT( ValueChangedInSpinBox( double ) ) );
+ for (anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin)
+ connect(anIterSpin.value(), SIGNAL(valueChanged(double)),
+ this, SLOT(ValueChangedInSpinBox(double)));
// radio buttons
QMap< int, QRadioButton* >::iterator anIterRadio;
- for ( anIterRadio = myRadioButton.begin(); anIterRadio != myRadioButton.end(); ++anIterRadio )
- connect( anIterRadio.value(), SIGNAL( clicked() ),
- this, SLOT( RadioButtonPressed() ) );
+ for (anIterRadio = myRadioButton.begin(); anIterRadio != myRadioButton.end(); ++anIterRadio)
+ connect(anIterRadio.value(), SIGNAL(clicked()),
+ this, SLOT(RadioButtonPressed()));
- // selection
- connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ initName(tr("GEOM_CHAMFER"));
- initName( tr( "GEOM_CHAMFER" ) );
-
- ConstructorsClicked( 0 );
+ myConstructorId = -1;
+ ConstructorsClicked(0);
}
-
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
-void OperationGUI_ChamferDlg::ConstructorsClicked( int constructorId )
+void OperationGUI_ChamferDlg::ConstructorsClicked (int constructorId)
{
// Activate next widget
- if ( myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
- != OCCViewer_Viewer::Type() ) {
- mainFrame()->RadioButton1->setChecked( true );
+ if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
+ != OCCViewer_Viewer::Type()) {
+ mainFrame()->RadioButton1->setChecked(true);
return;
}
- if ( myConstructorId == constructorId )
+ if (myConstructorId == constructorId)
return;
+ //disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+
// Get values from previous widget
double D1 = 5, D2 = 5, D = 5, Angle = 5;
- if ( myConstructorId == 0 )
+ if (myConstructorId == 0)
D1 = D2 = mySpinBox[ SpinBox1 ]->value();
- else if ( myConstructorId == 1 ) {
+ else if (myConstructorId == 1) {
D1 = mySpinBox[ SpinBox21 ]->value();
D2 = mySpinBox[ SpinBox22 ]->value();
D = mySpinBox[ SpinBox23 ]->value();
Angle = mySpinBox[ SpinBox24 ]->value();
}
- else if ( myConstructorId == 2 ) {
+ else if (myConstructorId == 2) {
D1 = mySpinBox[ SpinBox31 ]->value();
D2 = mySpinBox[ SpinBox32 ]->value();
D = mySpinBox[ SpinBox33 ]->value();
Angle = mySpinBox[ SpinBox34 ]->value();
}
- else if ( myConstructorId == 3 ) {
+ else if (myConstructorId == 3) {
D1 = mySpinBox[ SpinBox41 ]->value();
D2 = mySpinBox[ SpinBox42 ]->value();
D = mySpinBox[ SpinBox43 ]->value();
myConstructorId = constructorId;
- switch ( constructorId ) {
+ switch (constructorId) {
case 0:
myGrp2->hide();
myGrp3->hide();
myGrp4->hide();
myGrp1->show();
- mySpinBox[ SpinBox1 ]->setValue( D1 );
+ mySpinBox[ SpinBox1 ]->setValue(D1);
break;
case 1:
myGrp1->hide();
myGrp3->hide();
myGrp4->hide();
myGrp2->show();
- mySpinBox[ SpinBox21 ]->setValue( D1 );
- mySpinBox[ SpinBox22 ]->setValue( D2 );
- mySpinBox[ SpinBox23 ]->setValue( D );
- mySpinBox[ SpinBox24 ]->setValue( Angle );
+ mySpinBox[ SpinBox21 ]->setValue(D1);
+ mySpinBox[ SpinBox22 ]->setValue(D2);
+ mySpinBox[ SpinBox23 ]->setValue(D);
+ mySpinBox[ SpinBox24 ]->setValue(Angle);
break;
case 2:
myGrp1->hide();
myGrp2->hide();
myGrp4->hide();
myGrp3->show();
- mySpinBox[ SpinBox31 ]->setValue( D1 );
- mySpinBox[ SpinBox32 ]->setValue( D2 );
- mySpinBox[ SpinBox32 ]->setValue( D2 );
- mySpinBox[ SpinBox33 ]->setValue( D );
- mySpinBox[ SpinBox34 ]->setValue( Angle );
+ mySpinBox[ SpinBox31 ]->setValue(D1);
+ mySpinBox[ SpinBox32 ]->setValue(D2);
+ mySpinBox[ SpinBox32 ]->setValue(D2);
+ mySpinBox[ SpinBox33 ]->setValue(D);
+ mySpinBox[ SpinBox34 ]->setValue(Angle);
break;
case 3:
myGrp1->hide();
myGrp2->hide();
myGrp3->hide();
myGrp4->show();
- mySpinBox[ SpinBox41 ]->setValue( D1 );
- mySpinBox[ SpinBox42 ]->setValue( D2 );
- mySpinBox[ SpinBox43 ]->setValue( D );
- mySpinBox[ SpinBox44 ]->setValue( Angle );
+ mySpinBox[ SpinBox41 ]->setValue(D1);
+ mySpinBox[ SpinBox42 ]->setValue(D2);
+ mySpinBox[ SpinBox43 ]->setValue(D);
+ mySpinBox[ SpinBox44 ]->setValue(Angle);
break;
default:
break;
}
-
- if ( constructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ];
- else if ( constructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ];
- else if ( constructorId == 2 ) myEditCurrentArgument = mySelName[ MainObj3 ];
- else myEditCurrentArgument = mySelName[ MainObj4 ];
- activateSelection();
+ if (constructorId == 0) mySelBtn[ MainObj1 ]->click();
+ else if (constructorId == 1) mySelBtn[ MainObj2 ]->click();
+ else if (constructorId == 2) mySelBtn[ MainObj3 ]->click();
+ else mySelBtn[ MainObj4 ]->click();
+
enableWidgets();
-
- if ( !myShape->_is_nil() )
- {
- myEditCurrentArgument->setText( GEOMBase::GetName( myShape ) );
- GEOMBase_Skeleton::LineEditReturnPressed();
+
+ if (myInitial) {
+ myInitial = false;
+ SelectionIntoArgument();
+ }
+ else {
+ if (!myShape->_is_nil()) {
+ myEditCurrentArgument->setText(GEOMBase::GetName(myShape));
+ GEOMBase_Skeleton::LineEditReturnPressed();
+ switch (getConstructorId()) {
+ case 1:
+ if (myFace[ Face1 ] == -1)
+ mySelBtn[ Face1 ]->click();
+ break;
+ case 2:
+ if (myFaces.Extent() == 0)
+ mySelBtn[ Faces ]->click();
+ break;
+ case 3:
+ if (myEdges.Extent() == 0)
+ mySelBtn[ Edges ]->click();
+ break;
+ default:
+ break;
+ }
+ }
+ else {
+ myEditCurrentArgument->setText("");
+ }
+
+ displayPreview();
}
- else
- myEditCurrentArgument->setText( "" );
qApp->processEvents();
updateGeometry();
- resize( minimumSize() );
-
- displayPreview();
+ resize(minimumSize());
}
-
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void OperationGUI_ChamferDlg::ClickOnOk()
{
- if ( ClickOnApply() )
+ if (ClickOnApply())
ClickOnCancel();
}
//=================================================================================
bool OperationGUI_ChamferDlg::ClickOnApply()
{
- if ( !onAccept() )
+ if (!onAccept())
return false;
initName();
+ // activate selection and connect selection manager
+ ConstructorsClicked(getConstructorId());
return true;
}
//=================================================================================
// function : SelectionIntoArgument()
-// purpose : Called when selection has changed
+// purpose : Called when selection is changed or on dialog initialization or activation
//=================================================================================
void OperationGUI_ChamferDlg::SelectionIntoArgument()
{
// Get index of current selection focus
int aCurrFocus = -1;
QMap< int, QLineEdit* >::iterator anIter;
- for ( anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter ) {
- if ( myEditCurrentArgument == anIter.value() ) {
+ for (anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter) {
+ if (myEditCurrentArgument == anIter.value()) {
aCurrFocus = anIter.key();
break;
}
// If selection of main object is activated
if (aCurrFocus == MainObj1 || aCurrFocus == MainObj2 || aCurrFocus == MainObj3 || aCurrFocus == MainObj4)
{
+ myShape = GEOM::GEOM_Object::_nil();
if (aSelList.Extent() == 1) {
Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj =
GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
- if ( aResult && !anObj->_is_nil() ) {
+ if (aResult && !anObj->_is_nil()) {
myShape = anObj;
- mySelName[ aCurrFocus ]->setText( GEOMBase::GetName( anObj ) );
+ myEditCurrentArgument->setText(GEOMBase::GetName(anObj));
displayPreview();
- enableWidgets();
- return;
}
}
- myShape = GEOM::GEOM_Object::_nil();
enableWidgets();
}
// If face selection of second tab is activated
else if (aCurrFocus == Face1 || aCurrFocus == Face2)
{
+ myFace[ aCurrFocus ] = -1;
if (aSelList.Extent() == 1) {
Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj =
GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
- if ( aResult && !anObj->_is_nil() ) {
+ if (aResult && !anObj->_is_nil()) {
TColStd_IndexedMapOfInteger anIndexes;
- aSelMgr->GetIndexes(aSelList.First(), anIndexes);
+ aSelMgr->GetIndexes(aSelList.First(), anIndexes);
if (anIndexes.Extent() == 1) {
int anIndex = anIndexes(1);
- QString aFaceName = QString( GEOMBase::GetName( anObj ) ) + ":%1";
- myEditCurrentArgument->setText( aFaceName.arg( anIndex ) );
+ QString aFaceName = QString(GEOMBase::GetName(anObj)) + ":%1";
+ myEditCurrentArgument->setText(aFaceName.arg(anIndex));
myFace[ aCurrFocus ] = anIndex;
displayPreview();
- return;
}
}
}
-
- myFace[ aCurrFocus ] = -1;
}
// If face selection of third or fourth tab is activated
else if (aCurrFocus == Faces || aCurrFocus == Edges) {
+ if (aCurrFocus == Faces) myFaces.Clear();
+ else myEdges.Clear();
if (aSelList.Extent() == 1) {
Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj =
GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
- if ( aResult && !anObj->_is_nil() ) {
- TColStd_IndexedMapOfInteger anIndexes;
- aSelMgr->GetIndexes(aSelList.First(), anIndexes);
-
- if (anIndexes.Extent() > 0) {
- QString aName;
- if (anIndexes.Extent() == 1) {
- int anIndex = anIndexes(1);
-
- aName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex );
- }
- else {
- aName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() );
- }
-
- myEditCurrentArgument->setText( aName );
- int aConstructorId = getConstructorId();
- if ( aConstructorId == 2)
- myFaces = anIndexes;
- else if ( aConstructorId == 3 )
- myEdges = anIndexes;
-
- displayPreview();
- return;
- }
+ if (aResult && !anObj->_is_nil()) {
+ TColStd_IndexedMapOfInteger anIndexes;
+ aSelMgr->GetIndexes(aSelList.First(), anIndexes);
+
+ if (anIndexes.Extent() > 0) {
+ QString aName;
+ if (anIndexes.Extent() == 1) {
+ int anIndex = anIndexes(1);
+
+ aName = QString(GEOMBase::GetName(anObj)) + QString(":%1").arg(anIndex);
+ }
+ else {
+ aName = tr("GEOM_MEN_POPUP_NAME").arg(anIndexes.Extent());
+ }
+
+ myEditCurrentArgument->setText(aName);
+ int aConstructorId = getConstructorId();
+ if (aConstructorId == 2)
+ myFaces = anIndexes;
+ else if (aConstructorId == 3)
+ myEdges = anIndexes;
+
+ displayPreview();
+ }
}
}
- myFaces.Clear();
- myEdges.Clear();
}
-}
-
-
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void OperationGUI_ChamferDlg::LineEditReturnPressed()
-{
- QLineEdit* aSender = ( QLineEdit* )sender();
- QMap< int, QLineEdit* >::iterator anIterLE;
- for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
- if ( anIterLE.value() == aSender )
- myEditCurrentArgument = anIterLE.value();
-
- GEOMBase_Skeleton::LineEditReturnPressed();
-}
-
-
-//=================================================================================
-// function : RadioButtonPressed()
-// purpose :
-//=================================================================================
-void OperationGUI_ChamferDlg::RadioButtonPressed()
-{
- const QObject* s = sender();
- bool flag = s == myRadioButton[ RadioButton21 ] ||
- s == myRadioButton[ RadioButton31 ] ||
- s == myRadioButton[ RadioButton41 ];
-
- myRadioButton[ RadioButton21 ]->blockSignals( true );
- myRadioButton[ RadioButton22 ]->blockSignals( true );
- myRadioButton[ RadioButton31 ]->blockSignals( true );
- myRadioButton[ RadioButton32 ]->blockSignals( true );
- myRadioButton[ RadioButton41 ]->blockSignals( true );
- myRadioButton[ RadioButton42 ]->blockSignals( true );
-
- myRadioButton[ RadioButton21 ]->setChecked( flag );
- myRadioButton[ RadioButton31 ]->setChecked( flag );
- myRadioButton[ RadioButton41 ]->setChecked( flag );
- myRadioButton[ RadioButton22 ]->setChecked( !flag );
- myRadioButton[ RadioButton32 ]->setChecked( !flag );
- myRadioButton[ RadioButton42 ]->setChecked( !flag );
- mySpinBox[ SpinBox21 ]->setEnabled( flag );
- mySpinBox[ SpinBox22 ]->setEnabled( flag );
- mySpinBox[ SpinBox31 ]->setEnabled( flag );
- mySpinBox[ SpinBox32 ]->setEnabled( flag );
- mySpinBox[ SpinBox41 ]->setEnabled( flag );
- mySpinBox[ SpinBox42 ]->setEnabled( flag );
- mySpinBox[ SpinBox23 ]->setEnabled( !flag );
- mySpinBox[ SpinBox24 ]->setEnabled( !flag );
- mySpinBox[ SpinBox33 ]->setEnabled( !flag );
- mySpinBox[ SpinBox34 ]->setEnabled( !flag );
- mySpinBox[ SpinBox43 ]->setEnabled( !flag );
- mySpinBox[ SpinBox44 ]->setEnabled( !flag );
-
- myRadioButton[ RadioButton21 ]->blockSignals( false );
- myRadioButton[ RadioButton22 ]->blockSignals( false );
- myRadioButton[ RadioButton31 ]->blockSignals( false );
- myRadioButton[ RadioButton32 ]->blockSignals( false );
- myRadioButton[ RadioButton41 ]->blockSignals( false );
- myRadioButton[ RadioButton42 ]->blockSignals( false );
+ // clear selection
+ if (aCurrFocus != Faces && aCurrFocus != Edges) {
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myGeomGUI->getApp()->selectionMgr()->clearSelected();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+ }
- displayPreview();
+ switch (getConstructorId()) {
+ case 1:
+ if (aCurrFocus == MainObj2) {
+ if (!myShape->_is_nil() && myFace[ Face1 ] == -1)
+ mySelBtn[ Face1 ]->click();
+ }
+ else if (aCurrFocus == Face1) {
+ if (myFace[ Face1 ] != -1 && myFace[ Face2 ] == -1)
+ mySelBtn[ Face2 ]->click();
+ }
+ else if (aCurrFocus == Face2) {
+ if (myFace[ Face2 ] != -1 && myShape->_is_nil())
+ mySelBtn[ MainObj2 ]->click();
+ }
+ break;
+ case 2:
+ if (aCurrFocus == MainObj3) {
+ if (!myShape->_is_nil() && myFaces.Extent() == 0)
+ mySelBtn[ Faces ]->click();
+ }
+ break;
+ case 3:
+ if (aCurrFocus == MainObj4) {
+ if (!myShape->_is_nil() && myEdges.Extent() == 0)
+ mySelBtn[ Edges ]->click();
+ }
+ break;
+ default:
+ break;
+ }
}
-
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void OperationGUI_ChamferDlg::SetEditCurrentArgument()
{
- QPushButton* aSender = ( QPushButton* )sender();
+ QPushButton* send = (QPushButton*)sender();
QMap< int, QPushButton* >::iterator anIter;
- for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter ) {
- if ( anIter.value() == aSender ) {
+ for (anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter) {
+ if (anIter.value() == send) {
mySelName[ anIter.key() ]->setFocus();
myEditCurrentArgument = mySelName[ anIter.key() ];
}
+ else {
+ anIter.value()->setDown(false);
+ mySelName[ anIter.key() ]->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();
+
+ // seems we need it only to avoid preview disappearing, caused by selection mode change
+ displayPreview();
}
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void OperationGUI_ChamferDlg::LineEditReturnPressed()
+{
+ QLineEdit* send = (QLineEdit*)sender();
+
+ QMap< int, QLineEdit* >::iterator anIterLE;
+ for (anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE)
+ if (anIterLE.value() == send)
+ myEditCurrentArgument = anIterLE.value();
+
+ GEOMBase_Skeleton::LineEditReturnPressed();
+}
//=================================================================================
// function : ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
- connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
-
- activateSelection();
- displayPreview();
+ // reinit, because some selected objects could be removed
+ Init();
}
-
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
-void OperationGUI_ChamferDlg::enterEvent( QEvent* )
+void OperationGUI_ChamferDlg::enterEvent (QEvent*)
{
- if ( !mainFrame()->GroupConstructors->isEnabled() )
+ if (!mainFrame()->GroupConstructors->isEnabled())
this->ActivateThisDialog();
}
-
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
-void OperationGUI_ChamferDlg::ValueChangedInSpinBox( double )
+void OperationGUI_ChamferDlg::ValueChangedInSpinBox (double)
{
displayPreview();
}
-
//=================================================================================
// function : createSelWg()
// purpose :
//=================================================================================
-void OperationGUI_ChamferDlg::createSelWg( const QString& theLbl,
+void OperationGUI_ChamferDlg::createSelWg (const QString& theLbl,
QPixmap& thePix,
QWidget* theParent,
- QGridLayout* theLayout,
- const int theId )
+ QGridLayout* theLayout,
+ const int theId)
{
- QLabel* lab = new QLabel( theLbl, theParent );
- mySelBtn[ theId ] = new QPushButton( theParent );
- mySelBtn[ theId ]->setIcon( thePix );
- mySelName[ theId ] = new QLineEdit( theParent );
- mySelName[ theId ]->setReadOnly( true );
+ QLabel* lab = new QLabel(theLbl, theParent);
+ mySelBtn[ theId ] = new QPushButton(theParent);
+ mySelBtn[ theId ]->setIcon(thePix);
+ mySelName[ theId ] = new QLineEdit(theParent);
+ mySelName[ theId ]->setReadOnly(true);
int row = theLayout->rowCount();
- theLayout->addWidget( lab, row, 0 );
- theLayout->addWidget( mySelBtn[ theId ], row, 1 );
- theLayout->addWidget( mySelName[ theId ], row, 2, 1, 4 ); // take into account createRadioWg()
+ theLayout->addWidget(lab, row, 0);
+ theLayout->addWidget(mySelBtn[ theId ], row, 1);
+ theLayout->addWidget(mySelName[ theId ], row, 2, 1, 4); // take into account createRadioWg()
}
//=================================================================================
// function : createRadioWg()
// purpose :
//=================================================================================
-void OperationGUI_ChamferDlg::createRadioWg( const QString& theLbl1,
- const QString& theLbl2,
- QWidget* theParent,
- QGridLayout* theLayout,
- const int theRbId,
- const int theSpin1Id,
- const int theSpin2Id )
+void OperationGUI_ChamferDlg::createRadioWg(const QString& theLbl1,
+ const QString& theLbl2,
+ QWidget* theParent,
+ QGridLayout* theLayout,
+ const int theRbId,
+ const int theSpin1Id,
+ const int theSpin2Id)
{
- myRadioButton[ theRbId ] = new QRadioButton( theParent );
- QLabel* lab1 = new QLabel( theLbl1, theParent );
- QLabel* lab2 = new QLabel( theLbl2, theParent );
- mySpinBox[ theSpin1Id ] = new QDoubleSpinBox( theParent );
- mySpinBox[ theSpin2Id ] = new QDoubleSpinBox( theParent );
+ myRadioButton[ theRbId ] = new QRadioButton(theParent);
+ QLabel* lab1 = new QLabel(theLbl1, theParent);
+ QLabel* lab2 = new QLabel(theLbl2, theParent);
+ mySpinBox[ theSpin1Id ] = new QDoubleSpinBox(theParent);
+ mySpinBox[ theSpin2Id ] = new QDoubleSpinBox(theParent);
int row = theLayout->rowCount();
- theLayout->addWidget( myRadioButton[ theRbId ], row, 0 );
- theLayout->addWidget( lab1, row, 2 );
- theLayout->addWidget( mySpinBox[ theSpin1Id ], row, 3 );
- theLayout->addWidget( lab2, row, 4 );
- theLayout->addWidget( mySpinBox[ theSpin2Id ], row, 5 );
-}
-
-//=================================================================================
-// function : reset()
-// purpose :
-//=================================================================================
-void OperationGUI_ChamferDlg::reset()
-{
- // Set Initial values of spinboxes
- QMap< int, QDoubleSpinBox* >::iterator anIter;
- for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter )
- anIter.value()->setValue( 5 );
-
- // clear line edits
- QMap< int, QLineEdit* >::iterator anIterLE;
- for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
- anIterLE.value()->setText( "" );
-
- // constructor id
- int aConstructorId = getConstructorId();
-
- if ( aConstructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ];
- else if ( aConstructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ];
- else if ( aConstructorId == 2 ) myEditCurrentArgument = mySelName[ MainObj3 ];
- else myEditCurrentArgument = mySelName[ MainObj4 ];
-
- myShape = GEOM::GEOM_Object::_nil();
-
- myFaces.Clear();
- myEdges.Clear();
- myFace[ Face1 ] = -1;
- myFace[ Face2 ] = -1;
-
- erasePreview( true );
-
- activateSelection();
-
- enableWidgets();
+ theLayout->addWidget(myRadioButton[ theRbId ], row, 0);
+ theLayout->addWidget(lab1, row, 2);
+ theLayout->addWidget(mySpinBox[ theSpin1Id ], row, 3);
+ theLayout->addWidget(lab2, row, 4);
+ theLayout->addWidget(mySpinBox[ theSpin2Id ], row, 5);
}
//=================================================================================
//=================================================================================
void OperationGUI_ChamferDlg::activateSelection()
{
- if ( !myShape->_is_nil() &&
- ( myEditCurrentArgument == mySelName[ Face1 ] ||
- myEditCurrentArgument == mySelName[ Face2 ] ||
- myEditCurrentArgument == mySelName[ Faces ] ) ) {
- localSelection( myShape, TopAbs_FACE );
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+
+ if (!myShape->_is_nil() &&
+ (myEditCurrentArgument == mySelName[ Face1 ] ||
+ myEditCurrentArgument == mySelName[ Face2 ] ||
+ myEditCurrentArgument == mySelName[ Faces ])) {
+ localSelection(myShape, TopAbs_FACE);
}
- else if ( !myShape->_is_nil() && myEditCurrentArgument == mySelName[ Edges ] ) {
- localSelection( myShape, TopAbs_EDGE );
+ else if (!myShape->_is_nil() && myEditCurrentArgument == mySelName[ Edges ]) {
+ localSelection(myShape, TopAbs_EDGE);
}
else {
TColStd_MapOfInteger aMap;
- aMap.Add( GEOM_SHELL );
- aMap.Add( GEOM_SOLID );
- aMap.Add( GEOM_COMPOUND );
- globalSelection( aMap );
+ aMap.Add(GEOM_SHELL);
+ aMap.Add(GEOM_SOLID);
+ aMap.Add(GEOM_COMPOUND);
+ globalSelection(aMap);
}
- SelectionIntoArgument();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
}
//=================================================================================
int anId = getConstructorId();
bool toEnable = !myShape->_is_nil();
-
- if ( anId == 1 )
+
+ if (anId == 1)
{
- mySelName[ Face1 ]->setEnabled( toEnable );
- mySelName[ Face2 ]->setEnabled( toEnable );
- mySelBtn[ Face1 ]->setEnabled( toEnable );
- mySelBtn[ Face2 ]->setEnabled( toEnable );
+ //mySelName[ Face1 ]->setEnabled(toEnable);
+ //mySelName[ Face2 ]->setEnabled(toEnable);
+ mySelBtn[ Face1 ]->setEnabled(toEnable);
+ mySelBtn[ Face2 ]->setEnabled(toEnable);
- if ( !toEnable )
+ if (!toEnable)
{
- mySelName[ Face1 ]->setText( "" );
- mySelName[ Face2 ]->setText( "" );
+ mySelName[ Face1 ]->setText("");
+ mySelName[ Face2 ]->setText("");
myFace[ Face1 ] = -1;
myFace[ Face2 ] = -1;
}
}
- else if ( anId == 2 )
+ else if (anId == 2)
{
- mySelName[ Faces ]->setEnabled( toEnable );
- if ( !toEnable ) {
- mySelName[ Faces ]->setText( "" );
- myFaces = -1;
+ //mySelName[ Faces ]->setEnabled(toEnable);
+ mySelBtn[ Faces ]->setEnabled(toEnable);
+ if (!toEnable) {
+ mySelName[ Faces ]->setText("");
+ myFaces.Clear();
}
}
- else if ( anId == 3 ) {
- mySelName[ Edges ]->setEnabled( toEnable );
-
- if ( !toEnable ) {
- mySelName[ Edges ]->setText( "" );
- myEdges = -1;
+ else if (anId == 3) {
+ //mySelName[ Edges ]->setEnabled(toEnable);
+ mySelBtn[ Edges ]->setEnabled(toEnable);
+
+ if (!toEnable) {
+ mySelName[ Edges ]->setText("");
+ myEdges.Clear();
}
}
}
//=================================================================================
GEOM::GEOM_IOperations_ptr OperationGUI_ChamferDlg::createOperation()
{
- return getGeomEngine()->GetILocalOperations( getStudyId() );
+ return getGeomEngine()->GetILocalOperations(getStudyId());
}
//=================================================================================
-// function : ClickOnApply()
+// function : isValid()
// purpose : Verify validity of input data
//=================================================================================
-bool OperationGUI_ChamferDlg::isValid( QString& )
+bool OperationGUI_ChamferDlg::isValid (QString&)
{
- switch ( getConstructorId() )
+ switch (getConstructorId())
{
case 0: return !myShape->_is_nil();
case 1: return !myShape->_is_nil() && myFace[ Face1 ] > 0 && myFace[ Face2 ] > 0;
// function : execute
// purpose :
//=================================================================================
-bool OperationGUI_ChamferDlg::execute( ObjectList& objects )
+bool OperationGUI_ChamferDlg::execute (ObjectList& objects)
{
GEOM::GEOM_Object_var anObj;
- bool flag = ( myRadioButton[ RadioButton21 ]->isChecked() &&
- myRadioButton[ RadioButton31 ]->isChecked() &&
- myRadioButton[ RadioButton41 ]->isChecked() );
+ bool flag = (myRadioButton[ RadioButton21 ]->isChecked() &&
+ myRadioButton[ RadioButton31 ]->isChecked() &&
+ myRadioButton[ RadioButton41 ]->isChecked());
int anId = getConstructorId();
- if ( anId == 0 ) {
- anObj = GEOM::GEOM_ILocalOperations::_narrow(
- getOperation() )->MakeChamferAll( myShape,
- mySpinBox[ SpinBox1 ]->value() );
+ if (anId == 0) {
+ anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
+ MakeChamferAll(myShape, mySpinBox[ SpinBox1 ]->value());
}
- else if ( anId == 1 ) {
- if ( flag ) {
- anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
- MakeChamferEdge( myShape,
- mySpinBox[ SpinBox21 ]->value(),
- mySpinBox[ SpinBox22 ]->value(),
- myFace[ Face1 ],
- myFace[ Face2 ] );
+ else if (anId == 1) {
+ if (flag) {
+ anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
+ MakeChamferEdge(myShape,
+ mySpinBox[ SpinBox21 ]->value(),
+ mySpinBox[ SpinBox22 ]->value(),
+ myFace[ Face1 ],
+ myFace[ Face2 ]);
}
else {
- anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
- MakeChamferEdgeAD( myShape,
- mySpinBox[ SpinBox23 ]->value(),
- mySpinBox[ SpinBox24 ]->value() * PI180,
- myFace[ Face1 ],
- myFace[ Face2 ]);
+ anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
+ MakeChamferEdgeAD(myShape,
+ mySpinBox[ SpinBox23 ]->value(),
+ mySpinBox[ SpinBox24 ]->value() * PI180,
+ myFace[ Face1 ],
+ myFace[ Face2 ]);
}
}
- else if ( anId == 2 )
+ else if (anId == 2)
{
GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
- anArray->length( myFaces.Extent() );
-
- for ( int i = 1, n = myFaces.Extent(); i <= n; i++ )
- anArray[ i - 1 ] = myFaces( i );
-
- if ( flag )
- anObj = GEOM::GEOM_ILocalOperations::_narrow(
- getOperation() )->MakeChamferFaces( myShape,
- mySpinBox[ SpinBox31 ]->value(),
- mySpinBox[ SpinBox32 ]->value(),
- anArray );
+ anArray->length(myFaces.Extent());
+
+ for (int i = 1, n = myFaces.Extent(); i <= n; i++)
+ anArray[ i - 1 ] = myFaces(i);
+
+ if (flag)
+ anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
+ MakeChamferFaces(myShape,
+ mySpinBox[ SpinBox31 ]->value(),
+ mySpinBox[ SpinBox32 ]->value(),
+ anArray);
else
- anObj = GEOM::GEOM_ILocalOperations::_narrow(
- getOperation() )->MakeChamferFacesAD( myShape,
- mySpinBox[ SpinBox33 ]->value(),
- mySpinBox[ SpinBox34 ]->value() * PI180,
- anArray );
+ anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
+ MakeChamferFacesAD(myShape,
+ mySpinBox[ SpinBox33 ]->value(),
+ mySpinBox[ SpinBox34 ]->value() * PI180,
+ anArray);
}
- else if ( anId == 3 ) {
+ else if (anId == 3) {
GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
- anArray->length( myEdges.Extent() );
- for ( int i = 1, n = myEdges.Extent(); i <= n; i++ )
- anArray[ i - 1 ] = myEdges( i );
- if ( flag ) {
- anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
- MakeChamferEdges( myShape, mySpinBox[ SpinBox41 ]->value(),
- mySpinBox[ SpinBox42 ]->value(), anArray );
+ anArray->length(myEdges.Extent());
+ for (int i = 1, n = myEdges.Extent(); i <= n; i++)
+ anArray[ i - 1 ] = myEdges(i);
+ if (flag) {
+ anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
+ MakeChamferEdges(myShape,
+ mySpinBox[ SpinBox41 ]->value(),
+ mySpinBox[ SpinBox42 ]->value(),
+ anArray);
}
else {
- anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
- MakeChamferEdgesAD( myShape, mySpinBox[ SpinBox43 ]->value(),
- mySpinBox[ SpinBox44 ]->value() * PI180, anArray );
+ anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
+ MakeChamferEdgesAD(myShape,
+ mySpinBox[ SpinBox43 ]->value(),
+ mySpinBox[ SpinBox44 ]->value() * PI180,
+ anArray);
}
}
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
return true;
}
+
+//=================================================================================
+// function : RadioButtonPressed()
+// purpose :
+//=================================================================================
+void OperationGUI_ChamferDlg::RadioButtonPressed()
+{
+ const QObject* s = sender();
+ bool flag = s == myRadioButton[ RadioButton21 ] ||
+ s == myRadioButton[ RadioButton31 ] ||
+ s == myRadioButton[ RadioButton41 ];
+
+ myRadioButton[ RadioButton21 ]->blockSignals(true);
+ myRadioButton[ RadioButton22 ]->blockSignals(true);
+ myRadioButton[ RadioButton31 ]->blockSignals(true);
+ myRadioButton[ RadioButton32 ]->blockSignals(true);
+ myRadioButton[ RadioButton41 ]->blockSignals(true);
+ myRadioButton[ RadioButton42 ]->blockSignals(true);
+
+ myRadioButton[ RadioButton21 ]->setChecked(flag);
+ myRadioButton[ RadioButton31 ]->setChecked(flag);
+ myRadioButton[ RadioButton41 ]->setChecked(flag);
+ myRadioButton[ RadioButton22 ]->setChecked(!flag);
+ myRadioButton[ RadioButton32 ]->setChecked(!flag);
+ myRadioButton[ RadioButton42 ]->setChecked(!flag);
+ mySpinBox[ SpinBox21 ]->setEnabled(flag);
+ mySpinBox[ SpinBox22 ]->setEnabled(flag);
+ mySpinBox[ SpinBox31 ]->setEnabled(flag);
+ mySpinBox[ SpinBox32 ]->setEnabled(flag);
+ mySpinBox[ SpinBox41 ]->setEnabled(flag);
+ mySpinBox[ SpinBox42 ]->setEnabled(flag);
+ mySpinBox[ SpinBox23 ]->setEnabled(!flag);
+ mySpinBox[ SpinBox24 ]->setEnabled(!flag);
+ mySpinBox[ SpinBox33 ]->setEnabled(!flag);
+ mySpinBox[ SpinBox34 ]->setEnabled(!flag);
+ mySpinBox[ SpinBox43 ]->setEnabled(!flag);
+ mySpinBox[ SpinBox44 ]->setEnabled(!flag);
+
+ myRadioButton[ RadioButton21 ]->blockSignals(false);
+ myRadioButton[ RadioButton22 ]->blockSignals(false);
+ myRadioButton[ RadioButton31 ]->blockSignals(false);
+ myRadioButton[ RadioButton32 ]->blockSignals(false);
+ myRadioButton[ RadioButton41 ]->blockSignals(false);
+ myRadioButton[ RadioButton42 ]->blockSignals(false);
+
+ displayPreview();
+}
private:
void Init();
void enterEvent( QEvent* );
- void reset();
void createSelWg( const QString&, QPixmap&, QWidget*,
QGridLayout*, const int );
void createRadioWg( const QString&, const QString&, QWidget*,
QMap< int, int > myFace; // indexes of faces from second tab ( Face1,2 )
TColStd_IndexedMapOfInteger myFaces; // indexes of faces from first tab ( Faces )
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* myGrp2;
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : OperationGUI_FilletDlg.cxx
#include <LightApp_SelectionMgr.h>
#include <OCCViewer_ViewModel.h>
+// OCCT Includes
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
//=================================================================================
// 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'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
-OperationGUI_FilletDlg::OperationGUI_FilletDlg( GeometryGUI* theGeometryGUI, QWidget* parent )
- : GEOMBase_Skeleton( theGeometryGUI, parent, false )
+OperationGUI_FilletDlg::OperationGUI_FilletDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, false),
+ myInitial(true)
{
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
- QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_ALL" ) ) );
- QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_EDGE" ) ) );
- QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_FACE" ) ) );
+ QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_ALL")));
+ QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_EDGE")));
+ 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()->RadioButton1->setIcon( image0 );
- mainFrame()->RadioButton2->setIcon( image1 );
- mainFrame()->RadioButton3->setIcon( image2 );
-
- Group1 = new DlgRef_1Sel1Spin( centralWidget() );
- Group1->GroupBox1->setTitle( tr( "GEOM_FILLET_ALL" ) );
- Group1->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) );
- Group1->TextLabel2->setText( tr( "GEOM_RADIUS" ) );
- Group1->PushButton1->setIcon( iconSelect );
- Group1->LineEdit1->setReadOnly( true );
-
- Group2 = new DlgRef_2Sel3Spin2Rb( centralWidget() );
- Group2->GroupBox1->setTitle( tr( "GEOM_FILLET_EDGES" ) );
- Group2->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) );
- Group2->TextLabel2->setText( tr( "SELECTED_EDGES" ) );
- Group2->TextLabel3->setText( tr( "GEOM_RADIUS" ) );
- Group2->TextLabel4->setText( tr( "GEOM_R1" ) );
- Group2->TextLabel5->setText( tr( "GEOM_R2" ) );
- Group2->PushButton1->setIcon( iconSelect );
- Group2->PushButton2->setIcon( iconSelect );
- Group2->LineEdit1->setReadOnly( true );
- Group2->LineEdit2->setReadOnly( true );
-
- Group3 = new DlgRef_2Sel3Spin2Rb( centralWidget() );
- Group3->GroupBox1->setTitle( tr( "GEOM_FILLET_FACES" ) );
- Group3->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) );
- Group3->TextLabel2->setText( tr( "SELECTED_FACES" ) );
- Group3->TextLabel3->setText( tr( "GEOM_RADIUS" ) );
- Group3->TextLabel4->setText( tr( "GEOM_R1" ) );
- Group3->TextLabel5->setText( tr( "GEOM_R2" ) );
- Group3->PushButton1->setIcon( iconSelect );
- Group3->PushButton2->setIcon( iconSelect );
- Group3->LineEdit1->setReadOnly( true );
- Group3->LineEdit2->setReadOnly( true );
-
- QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
- layout->setMargin( 0 ); layout->setSpacing( 6 );
- layout->addWidget( Group1 );
- layout->addWidget( Group2 );
- layout->addWidget( Group3 );
+ mainFrame()->GroupConstructors->setTitle(tr("GEOM_FILLET"));
+ mainFrame()->RadioButton1->setIcon(image0);
+ mainFrame()->RadioButton2->setIcon(image1);
+ mainFrame()->RadioButton3->setIcon(image2);
+
+ Group1 = new DlgRef_1Sel1Spin(centralWidget());
+ Group1->GroupBox1->setTitle(tr("GEOM_FILLET_ALL"));
+ Group1->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
+ Group1->TextLabel2->setText(tr("GEOM_RADIUS"));
+ Group1->PushButton1->setIcon(iconSelect);
+ Group1->LineEdit1->setReadOnly(true);
+
+ Group2 = new DlgRef_2Sel3Spin2Rb(centralWidget());
+ Group2->GroupBox1->setTitle(tr("GEOM_FILLET_EDGES"));
+ Group2->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
+ Group2->TextLabel2->setText(tr("SELECTED_EDGES"));
+ Group2->TextLabel3->setText(tr("GEOM_RADIUS"));
+ Group2->TextLabel4->setText(tr("GEOM_R1"));
+ Group2->TextLabel5->setText(tr("GEOM_R2"));
+ Group2->PushButton1->setIcon(iconSelect);
+ Group2->PushButton2->setIcon(iconSelect);
+ Group2->LineEdit1->setReadOnly(true);
+ Group2->LineEdit2->setReadOnly(true);
+
+ Group3 = new DlgRef_2Sel3Spin2Rb(centralWidget());
+ Group3->GroupBox1->setTitle(tr("GEOM_FILLET_FACES"));
+ Group3->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
+ Group3->TextLabel2->setText(tr("SELECTED_FACES"));
+ Group3->TextLabel3->setText(tr("GEOM_RADIUS"));
+ Group3->TextLabel4->setText(tr("GEOM_R1"));
+ Group3->TextLabel5->setText(tr("GEOM_R2"));
+ Group3->PushButton1->setIcon(iconSelect);
+ Group3->PushButton2->setIcon(iconSelect);
+ Group3->LineEdit1->setReadOnly(true);
+ Group3->LineEdit2->setReadOnly(true);
+
+ QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+ layout->setMargin(0); layout->setSpacing(6);
+ layout->addWidget(Group1);
+ layout->addWidget(Group2);
+ layout->addWidget(Group3);
/***************************************************************/
+ // Set range of spinboxes
double SpecificStep = 10.0;
- 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_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( 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_DZ, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
-
- setHelpFileName( "fillet_operation_page.html" );
-
- /* Initialisations */
+ 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_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(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_DZ, 0.001, COORD_MAX, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
+
+ setHelpFileName("fillet_operation_page.html");
+
+ // Initialisation
Init();
}
-
//=================================================================================
// function : ~OperationGUI_FilletDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
OperationGUI_FilletDlg::~OperationGUI_FilletDlg()
-{
+{
}
-
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void OperationGUI_FilletDlg::Init()
{
- myConstructorId = -1;
- 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);
+
+ // 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
- connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
- connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+ connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk() ));
+ connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
// group box
- connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
+ connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
// push buttons
- connect( Group1->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( Group2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( Group3->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( Group2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( Group3->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(Group3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(Group2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(Group3->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
// line edits
- connect( Group1->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
- connect( Group2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
- connect( Group3->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
-
- // spin boxes
- 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_DY, 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_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
- connect( Group3->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+ connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
+ connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
+ connect(Group3->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
+
+ // spin boxes
+ 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_DY, 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_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+ connect(Group3->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
// radio buttons
- connect( Group2->RadioButton1, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) );
- connect( Group2->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) );
- connect( Group3->RadioButton1, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) );
- connect( Group3->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) );
-
- // selection
- connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ connect(Group2->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
+ connect(Group2->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
+ connect(Group3->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
+ connect(Group3->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
- initName( tr( "GEOM_FILLET" ) );
+ initName(tr("GEOM_FILLET"));
- ConstructorsClicked( 0 );
+ myConstructorId = -1;
+ ConstructorsClicked(0);
}
-
//=================================================================================
// function : ConstructorsClicked()
// 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()
- != OCCViewer_Viewer::Type() ) {
- mainFrame()->RadioButton1->setChecked( true );
+ if (myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
+ != OCCViewer_Viewer::Type()) {
+ mainFrame()->RadioButton1->setChecked(true);
return;
}
- if ( myConstructorId == constructorId )
+ if (myConstructorId == constructorId)
return;
// Get radius from previous widget
double R = 5, R1 = 5, R2 = 5;
- if ( myConstructorId == 0 ) {
+ if (myConstructorId == 0) {
R = Group1->SpinBox_DX->value();
}
- else if ( myConstructorId == 1 ) {
+ else if (myConstructorId == 1) {
R = Group2->SpinBox_DX->value();
R1 = Group2->SpinBox_DY->value();
R2 = Group2->SpinBox_DZ->value();
myConstructorId = constructorId;
- switch ( constructorId ) {
+ switch (constructorId) {
case 0:
Group2->hide();
Group3->hide();
Group1->show();
- Group1->SpinBox_DX->setValue( R );
+ Group1->SpinBox_DX->setValue(R);
break;
case 1:
Group1->hide();
Group3->hide();
Group2->show();
- Group2->SpinBox_DX->setValue( R );
- Group2->SpinBox_DY->setValue( R1 );
- Group2->SpinBox_DZ->setValue( R2 );
+ Group2->SpinBox_DX->setValue(R);
+ Group2->SpinBox_DY->setValue(R1);
+ Group2->SpinBox_DZ->setValue(R2);
break;
case 2:
Group1->hide();
Group2->hide();
Group3->show();
- Group3->SpinBox_DX->setValue( R );
- Group3->SpinBox_DY->setValue( R1 );
- Group3->SpinBox_DZ->setValue( R2 );
+ Group3->SpinBox_DX->setValue(R);
+ Group3->SpinBox_DY->setValue(R1);
+ Group3->SpinBox_DZ->setValue(R2);
break;
default:
break;
}
- if ( constructorId == 0 ) myEditCurrentArgument = Group1->LineEdit1;
- else if ( constructorId == 1 ) myEditCurrentArgument = Group2->LineEdit1;
- else myEditCurrentArgument = Group3->LineEdit1;
+ if (constructorId == 0) Group1->PushButton1->click();
+ else if (constructorId == 1) Group2->PushButton1->click();
+ else Group3->PushButton1->click();
- activateSelection();
enableWidgets();
- if ( !myShape->_is_nil() ) {
- myEditCurrentArgument->setText( GEOMBase::GetName( myShape ) );
- GEOMBase_Skeleton::LineEditReturnPressed();
+ if (myInitial) {
+ myInitial = false;
+ 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();
updateGeometry();
- resize( minimumSize() );
-
- displayPreview();
+ resize(minimumSize());
}
-
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void OperationGUI_FilletDlg::ClickOnOk()
{
- if ( ClickOnApply() )
+ if (ClickOnApply())
ClickOnCancel();
}
-
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool OperationGUI_FilletDlg::ClickOnApply()
{
- if ( !onAccept() )
+ if (!onAccept())
return false;
initName();
+ // activate selection and connect selection manager
+ ConstructorsClicked(getConstructorId());
return true;
}
//=================================================================================
// function : SelectionIntoArgument()
-// purpose : Called when selection has changed
+// purpose : Called when selection is changed or on dialog initialization or activation
//=================================================================================
void OperationGUI_FilletDlg::SelectionIntoArgument()
{
erasePreview();
- myEditCurrentArgument->setText( "" );
+ myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
myEditCurrentArgument == Group2->LineEdit1 ||
myEditCurrentArgument == Group3->LineEdit1)
{
+ myShape = GEOM::GEOM_Object::_nil();
if (aSelList.Extent() == 1) {
Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj =
myShape = anObj;
myEditCurrentArgument->setText(GEOMBase::GetName(anObj));
displayPreview();
- enableWidgets();
- return;
}
}
- myShape = GEOM::GEOM_Object::_nil();
enableWidgets();
}
// If face or edge selection is activated
else if (myEditCurrentArgument == Group2->LineEdit2 ||
myEditCurrentArgument == Group3->LineEdit2)
{
+ if (myEditCurrentArgument == Group2->LineEdit2) myEdges.Clear();
+ else myFaces.Clear();
if (aSelList.Extent() == 1) {
Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj =
if (anIndexes.Extent() == 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;
else
myFaces = anIndexes;
displayPreview();
- return;
}
}
}
- myFaces.Clear();
}
-}
-//=================================================================================
-// 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;
+ // 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()));
+ }
- GEOMBase_Skeleton::LineEditReturnPressed();
+ 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 : SetEditCurrentArgument()
// purpose :
{
QPushButton* send = (QPushButton*)sender();
- if ( send == Group1->PushButton1 ) {
- Group1->LineEdit1->setFocus();
+ if (send == Group1->PushButton1) {
myEditCurrentArgument = Group1->LineEdit1;
}
- else if ( send == Group2->PushButton1 ) {
- Group2->LineEdit1->setFocus();
+ else if (send == Group2->PushButton1) {
myEditCurrentArgument = Group2->LineEdit1;
+ Group2->PushButton2->setDown(false);
+ Group2->LineEdit2->setEnabled(false);
}
- else if ( send == Group2->PushButton2 ) {
- Group2->LineEdit2->setFocus();
+ else if (send == Group2->PushButton2) {
myEditCurrentArgument = Group2->LineEdit2;
+ Group2->PushButton1->setDown(false);
+ Group2->LineEdit1->setEnabled(false);
}
- else if ( send == Group3->PushButton1 ) {
- Group3->LineEdit1->setFocus();
+ else if (send == Group3->PushButton1) {
myEditCurrentArgument = Group3->LineEdit1;
+ Group3->PushButton2->setDown(false);
+ Group3->LineEdit2->setEnabled(false);
}
- else if ( send == Group3->PushButton2 ) {
- Group3->LineEdit1->setFocus();
+ else if (send == Group3->PushButton2) {
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();
+
+ // 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()
{
GEOMBase_Skeleton::ActivateThisDialog();
- connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
-
- activateSelection();
- displayPreview();
+ // reinit, because some selected objects could be removed
+ Init();
}
-
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
-void OperationGUI_FilletDlg::enterEvent( QEvent* )
+void OperationGUI_FilletDlg::enterEvent (QEvent*)
{
- if ( !mainFrame()->GroupConstructors->isEnabled() )
+ if (!mainFrame()->GroupConstructors->isEnabled())
this->ActivateThisDialog();
}
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
-void OperationGUI_FilletDlg::ValueChangedInSpinBox( double )
+void OperationGUI_FilletDlg::ValueChangedInSpinBox (double)
{
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
// purpose : Activate selection in accordance with myEditCurrentArgument
//=================================================================================
void OperationGUI_FilletDlg::activateSelection()
{
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- if ( !myShape->_is_nil() && myEditCurrentArgument == Group2->LineEdit2 )
- localSelection( myShape, TopAbs_EDGE );
- else if ( !myShape->_is_nil() && myEditCurrentArgument == Group3->LineEdit2 )
- localSelection( myShape, TopAbs_FACE );
+ if (!myShape->_is_nil() && myEditCurrentArgument == Group2->LineEdit2)
+ localSelection(myShape, TopAbs_EDGE);
+ else if (!myShape->_is_nil() && myEditCurrentArgument == Group3->LineEdit2)
+ localSelection(myShape, TopAbs_FACE);
else {
TColStd_MapOfInteger aMap;
- aMap.Add( GEOM_SHELL );
- aMap.Add( GEOM_SOLID );
- aMap.Add( GEOM_COMPOUND );
- globalSelection( aMap );
+ aMap.Add(GEOM_SHELL);
+ aMap.Add(GEOM_SOLID);
+ aMap.Add(GEOM_COMPOUND);
+ globalSelection(aMap);
}
- SelectionIntoArgument();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
}
//=================================================================================
bool toEnable = !myShape->_is_nil();
- if ( anId == 1 ) {
- Group2->LineEdit2->setEnabled( toEnable );
- Group2->PushButton2->setEnabled( toEnable );
-
- if ( !toEnable ) {
- Group2->LineEdit2->setText( "" );
+ if (anId == 1) {
+ //Group2->LineEdit2->setEnabled(toEnable);
+ Group2->PushButton2->setEnabled(toEnable);
+
+ if (!toEnable) {
+ Group2->LineEdit2->setText("");
myEdges.Clear();
}
}
- else if ( anId == 2 ) {
- Group3->LineEdit2->setEnabled( toEnable );
- Group3->PushButton2->setEnabled( toEnable );
+ else if (anId == 2) {
+ //Group3->LineEdit2->setEnabled(toEnable);
+ Group3->PushButton2->setEnabled(toEnable);
- if ( !toEnable ) {
- Group3->LineEdit2->setText( "" );
+ if (!toEnable) {
+ Group3->LineEdit2->setText("");
myFaces.Clear();
}
}
//=================================================================================
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
//=================================================================================
-bool OperationGUI_FilletDlg::isValid( QString& )
+bool OperationGUI_FilletDlg::isValid (QString&)
{
- switch ( getConstructorId() )
+ switch (getConstructorId())
{
case 0: return !myShape->_is_nil();
case 1: return !myShape->_is_nil() && myEdges.Extent() > 0;
// function : execute
// purpose :
//=================================================================================
-bool OperationGUI_FilletDlg::execute( ObjectList& objects )
+bool OperationGUI_FilletDlg::execute (ObjectList& objects)
{
GEOM::GEOM_Object_var anObj;
int anId = getConstructorId();
- if ( anId == 0 )
- anObj = GEOM::GEOM_ILocalOperations::_narrow(
- getOperation() )->MakeFilletAll( myShape, getRadius() );
- else if ( anId == 1 ) {
+ if (anId == 0)
+ anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
+ MakeFilletAll(myShape, getRadius());
+ else if (anId == 1) {
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++ )
- aList[ i - 1 ] = myEdges( i );
+ for (int i = 1, n = myEdges.Extent(); i <= n; i++)
+ aList[ i - 1 ] = myEdges(i);
- if ( Group2->RadioButton1->isChecked() )
- anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
- MakeFilletEdges( myShape, getRadius(), aList );
+ if (Group2->RadioButton1->isChecked())
+ anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
+ MakeFilletEdges(myShape, getRadius(), aList);
else
- anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
- MakeFilletEdgesR1R2( myShape,
- Group2->SpinBox_DY->value(),
- Group2->SpinBox_DZ->value(),
- aList );
+ anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
+ MakeFilletEdgesR1R2(myShape,
+ Group2->SpinBox_DY->value(),
+ Group2->SpinBox_DZ->value(),
+ aList);
}
- else if ( anId == 2 ) {
+ else if (anId == 2) {
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++ )
- aList[ i - 1 ] = myFaces( i );
+ for (int i = 1, n = myFaces.Extent(); i <= n; i++)
+ aList[ i - 1 ] = myFaces(i);
- if ( Group3->RadioButton1->isChecked() ) {
- anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
- MakeFilletFaces( myShape, getRadius(), aList );
+ if (Group3->RadioButton1->isChecked()) {
+ anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
+ MakeFilletFaces(myShape, getRadius(), aList);
}
else {
- anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
- MakeFilletFacesR1R2( myShape,
- Group3->SpinBox_DY->value(),
- Group3->SpinBox_DZ->value(), aList );
+ anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())->
+ MakeFilletFacesR1R2(myShape,
+ Group3->SpinBox_DY->value(),
+ Group3->SpinBox_DZ->value(), aList);
}
}
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
return true;
}
//=================================================================================
// function : getRadius
-// purpose : Get radius
+// purpose : Get radius
//=================================================================================
double OperationGUI_FilletDlg::getRadius() const
{
int anId = getConstructorId();
- if ( anId == 0 ) return Group1->SpinBox_DX->value();
- else if ( anId == 1 ) return Group2->SpinBox_DX->value();
- else return Group3->SpinBox_DX->value();
+ if (anId == 0) return Group1->SpinBox_DX->value();
+ else if (anId == 1) return Group2->SpinBox_DX->value();
+ else return Group3->SpinBox_DX->value();
}
//=================================================================================
// function : RadiobuttonClicked
// purpose :
//=================================================================================
-
void OperationGUI_FilletDlg::RadioButtonClicked()
{
const QObject* s = sender();
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->RadioButton2->blockSignals( false );
- Group3->RadioButton1->blockSignals( false );
- Group3->RadioButton2->blockSignals( false );
-
- displayPreview();
+
+ 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->RadioButton2->blockSignals(false);
+ Group3->RadioButton1->blockSignals(false);
+ Group3->RadioButton2->blockSignals(false);
+
+ displayPreview();
}
private:
void Init();
void enterEvent( QEvent* );
- void reset();
void activateSelection();
void enableWidgets();
double getRadius() const;
GEOM::GEOM_Object_var myShape;
TColStd_IndexedMapOfInteger myEdges;
TColStd_IndexedMapOfInteger myFaces;
+
+ // to initialize the first selection field with a selected object on the dialog creation
+ bool myInitial;
DlgRef_1Sel1Spin* Group1;
DlgRef_2Sel3Spin2Rb* Group2;
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "OperationGUI_GetShapesOnShapeDlg.h"
+#include <DlgRef.h>
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
+
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
-#include <DlgRef.h>
-#include <GeometryGUI.h>
-#include <GEOMBase.h>
-
//==============================================================================
// class : OperationGUI_GetShapesOnShapeDlg()
// purpose : Constructs a OperationGUI_GetShapesOnShapeDlg which is a child of
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
-OperationGUI_GetShapesOnShapeDlg::OperationGUI_GetShapesOnShapeDlg( GeometryGUI* theGeometryGUI,
- QWidget* parent )
- : GEOMBase_Skeleton( theGeometryGUI, parent, false )
+OperationGUI_GetShapesOnShapeDlg::OperationGUI_GetShapesOnShapeDlg (GeometryGUI* theGeometryGUI,
+ QWidget* parent)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, false)
{
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
- QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_SHAPES_ON_SHAPE" ) ) );
- QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
+ QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_SHAPES_ON_SHAPE")));
+ 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()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
+ mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton2->close();
- mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
+ mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close();
- GroupPoints = new DlgRef_2Sel2List( centralWidget() );
+ GroupPoints = new DlgRef_2Sel2List(centralWidget());
//GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION"));
- GroupPoints->GroupBox1->setTitle( "Input data" );
- GroupPoints->TextLabel1->setText( tr( "GEOM_SHAPES_ON_SHAPE_ESHAPE" ) );
- GroupPoints->TextLabel2->setText( tr( "GEOM_SHAPES_ON_SHAPE_CSHAPE" ) );
- GroupPoints->TextLabel3->setText( tr( "GEOM_RECONSTRUCTION_LIMIT" ) );
- GroupPoints->TextLabel4->setText( tr( "GEOM_SHAPES_ON_SHAPE_STATE" ) );
- GroupPoints->PushButton1->setIcon( image2 );
- GroupPoints->PushButton2->setIcon( image2 );
- GroupPoints->LineEdit1->setReadOnly( true );
- GroupPoints->LineEdit2->setReadOnly( true );
-
- QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
- layout->setMargin( 0 ); layout->setSpacing( 6 );
- layout->addWidget( GroupPoints );
-
- setHelpFileName( "shapesonshape_page.html" );
-
+ GroupPoints->GroupBox1->setTitle("Input data");
+ GroupPoints->TextLabel1->setText(tr("GEOM_SHAPES_ON_SHAPE_ESHAPE"));
+ GroupPoints->TextLabel2->setText(tr("GEOM_SHAPES_ON_SHAPE_CSHAPE"));
+ GroupPoints->TextLabel3->setText(tr("GEOM_RECONSTRUCTION_LIMIT"));
+ GroupPoints->TextLabel4->setText(tr("GEOM_SHAPES_ON_SHAPE_STATE"));
+ GroupPoints->PushButton1->setIcon(image2);
+ GroupPoints->PushButton2->setIcon(image2);
+ GroupPoints->LineEdit1->setReadOnly(true);
+ GroupPoints->LineEdit2->setReadOnly(true);
+
+ QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+ layout->setMargin(0); layout->setSpacing(6);
+ layout->addWidget(GroupPoints);
+ /***************************************************************/
+
+ setHelpFileName("shapesonshape_page.html");
+
Init();
}
//=================================================================================
void OperationGUI_GetShapesOnShapeDlg::Init()
{
- /* type for sub shape selection */
- GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_SOLID" ) );
+ // type for sub shape selection
+ GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_SOLID"));
// 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_FACE" ) );
+ //GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_SHELL"));
+ GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_FACE"));
// 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_EDGE" ) );
- GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_VERTEX" ) );
+ //GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_WIRE"));
+ GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_EDGE"));
+ GroupPoints->ComboBox1->addItem(tr("GEOM_RECONSTRUCTION_LIMIT_VERTEX"));
- /* type for state selection */
- GroupPoints->ComboBox2->addItem( tr( "GEOM_STATE_IN" ) );
- GroupPoints->ComboBox2->addItem( tr( "GEOM_STATE_OUT" ) );
- GroupPoints->ComboBox2->addItem( tr( "GEOM_STATE_ON" ) );
- GroupPoints->ComboBox2->addItem( tr( "GEOM_STATE_ONIN" ) );
- GroupPoints->ComboBox2->addItem( tr( "GEOM_STATE_ONOUT" ) );
+ // type for state selection
+ GroupPoints->ComboBox2->addItem(tr("GEOM_STATE_IN"));
+ GroupPoints->ComboBox2->addItem(tr("GEOM_STATE_OUT"));
+ GroupPoints->ComboBox2->addItem(tr("GEOM_STATE_ON"));
+ GroupPoints->ComboBox2->addItem(tr("GEOM_STATE_ONIN"));
+ GroupPoints->ComboBox2->addItem(tr("GEOM_STATE_ONOUT"));
GroupPoints->LineEdit1->clear();
GroupPoints->LineEdit2->clear();
+ myObject1 = myObject2 = GEOM::GEOM_Object::_nil();
- /* signals and slots connections */
- connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
- connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+ // signals and slots connections
+ connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+ connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
- connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
- connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
-
- connect( GroupPoints->ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ComboTextChanged() ) );
- connect( GroupPoints->ComboBox2, SIGNAL( activated( int ) ), this, SLOT( ComboTextChanged() ) );
+ connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
+ connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged()));
+ 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->ComboBox1->show();
- GroupPoints->ComboBox1->setCurrentIndex( 0 );
+ GroupPoints->ComboBox1->setCurrentIndex(0);
GroupPoints->ComboBox2->show();
- GroupPoints->ComboBox2->setCurrentIndex( 0 );
+ GroupPoints->ComboBox2->setCurrentIndex(0);
- myEditCurrentArgument = GroupPoints->LineEdit1;
- myEditCurrentArgument->setFocus();
+ globalSelection(GEOM_ALLSHAPES);
+
+ GroupPoints->PushButton1->click();
+ SelectionIntoArgument();
}
//=================================================================================
//=================================================================================
void OperationGUI_GetShapesOnShapeDlg::ClickOnOk()
{
- if ( ClickOnApply() )
+ if (ClickOnApply())
ClickOnCancel();
}
//=================================================================================
bool OperationGUI_GetShapesOnShapeDlg::ClickOnApply()
{
- if ( !onAccept() )
- return false;
+ if (!onAccept())
+ return false;
initName();
+ // activate first line edit
+ GroupPoints->PushButton1->click();
return true;
}
//=================================================================================
// function : SelectionIntoArgument()
-// purpose : Called when selection has changed
+// purpose : Called when selection is changed or on dialog initialization or activation
//=================================================================================
void OperationGUI_GetShapesOnShapeDlg::SelectionIntoArgument()
{
- myEditCurrentArgument->setText( "" );
- QString aString = "";
+ myEditCurrentArgument->setText("");
+
+ 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();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
- int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
+ QString aName = "";
+ int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName, true);
if (nbSel > 0) {
Standard_Boolean aRes = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
if (!CORBA::is_nil(aSelectedObject) && aRes && GEOMBase::IsShape(aSelectedObject)) {
- {
- myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
- if (myEditCurrentArgument == GroupPoints->LineEdit1) myObject1 = aSelectedObject;
- else if (myEditCurrentArgument == GroupPoints->LineEdit2) myObject2 = aSelectedObject;
+ 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()));
+
+ 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 );
}
//=================================================================================
{
QPushButton* send = (QPushButton*)sender();
- if ( send == GroupPoints->PushButton1 ) myEditCurrentArgument = GroupPoints->LineEdit1;
- else if ( send == GroupPoints->PushButton2 ) myEditCurrentArgument = GroupPoints->LineEdit2;
+ if (send == GroupPoints->PushButton1) {
+ 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();
- SelectionIntoArgument();
+ // after setFocus(), because it will be setDown(false) when loses focus
+ send->setDown(true);
}
//=================================================================================
void OperationGUI_GetShapesOnShapeDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
- if ( send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2 )
+ if (send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2)
{
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
void OperationGUI_GetShapesOnShapeDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
- globalSelection( GEOM_ALLSHAPES );
- connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+
+ // reinit, because some selected objects could be removed
+ Init();
}
//=================================================================================
// function : enterEvent()
// 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();
}
//=================================================================================
GEOM::GEOM_IOperations_ptr OperationGUI_GetShapesOnShapeDlg::createOperation()
{
- return getGeomEngine()->GetIShapesOperations( getStudyId() );
+ return getGeomEngine()->GetIShapesOperations(getStudyId());
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
-bool OperationGUI_GetShapesOnShapeDlg::isValid( QString& msg )
+bool OperationGUI_GetShapesOnShapeDlg::isValid(QString&)
{
//Handle(SALOME_InteractiveObject) IO = firstIObject();
//Standard_Boolean testResult;
- //GEOM::GEOM_Object_var anObject = GEOMBase::ConvertIOinGEOMObject( IO, testResult );
- //if ( !testResult || anObject->_is_nil() )
+ //GEOM::GEOM_Object_var anObject = GEOMBase::ConvertIOinGEOMObject(IO, testResult);
+ //if (!testResult || anObject->_is_nil())
// return false;
- return !CORBA::is_nil( myObject1 ) && !CORBA::is_nil( myObject2 );
+ return !CORBA::is_nil(myObject1) && !CORBA::is_nil(myObject2);
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
-bool OperationGUI_GetShapesOnShapeDlg::execute( ObjectList& objects )
+bool OperationGUI_GetShapesOnShapeDlg::execute (ObjectList& objects)
{
int aLimit = GroupPoints->ComboBox1->currentIndex();
- switch ( aLimit )
+ switch (aLimit)
{
case 0: aLimit = GEOM::SOLID ; break;
case 1: aLimit = GEOM::FACE ; break;
}
GEOM::shape_state aState;
- switch ( GroupPoints->ComboBox2->currentIndex() )
+ switch (GroupPoints->ComboBox2->currentIndex())
{
case 0: aState = GEOM::ST_IN; break;
case 1: aState = GEOM::ST_OUT; break;
default: break;
}
- GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::
- _narrow( getOperation() )->GetShapesOnShapeAsCompound( myObject2, myObject1,
- (CORBA::Short) aLimit,
- aState );
+ GEOM::GEOM_Object_var anObj =
+ GEOM::GEOM_IShapesOperations::_narrow(getOperation())->
+ GetShapesOnShapeAsCompound(myObject2, myObject1,
+ (CORBA::Short) aLimit,
+ aState);
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
return objects.size();
}
//=======================================================================
//function : ComboTextChanged
-//purpose :
+//purpose :
//=======================================================================
void OperationGUI_GetShapesOnShapeDlg::ComboTextChanged()
{
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : TransformationGUI_MirrorDlg.cxx
#include <GeometryGUI.h>
#include <GEOMBase.h>
-#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
+// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
//=================================================================================
// 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'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
-TransformationGUI_MirrorDlg::TransformationGUI_MirrorDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
- bool modal, Qt::WindowFlags fl )
- : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
+TransformationGUI_MirrorDlg::TransformationGUI_MirrorDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
+ bool modal, Qt::WindowFlags fl)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
+ myInitial(true)
{
- QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_MIRROR_POINT" ) ) );
- QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_MIRROR_AXE" ) ) );
- QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_MIRROR_PLANE" ) ) );
- QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
+ SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
+ QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MIRROR_POINT")));
+ QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MIRROR_AXE")));
+ 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()->RadioButton1->setIcon( image0 );
- mainFrame()->RadioButton2->setIcon( image1 );
- mainFrame()->RadioButton3->setIcon( image2 );
-
- GroupPoints = new DlgRef_2Sel1Spin2Check( centralWidget() );
+ mainFrame()->GroupConstructors->setTitle(tr("GEOM_MIRROR"));
+ mainFrame()->RadioButton1->setIcon(image0);
+ mainFrame()->RadioButton2->setIcon(image1);
+ mainFrame()->RadioButton3->setIcon(image2);
+
+ GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget());
GroupPoints->SpinBox_DX->hide();
GroupPoints->TextLabel3->hide();
GroupPoints->CheckButton2->hide();
- GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
- GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
- GroupPoints->TextLabel2->setText( tr( "GEOM_POINT_MIRROR" ) );
- GroupPoints->TextLabel2->setFixedWidth( 74 );
- GroupPoints->PushButton1->setIcon( image3 );
- GroupPoints->PushButton2->setIcon( image3 );
- GroupPoints->CheckButton1->setText( tr( "GEOM_CREATE_COPY" ) );
-
- QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
- layout->setMargin( 0 ); layout->setSpacing( 6 );
- layout->addWidget( GroupPoints );
+ GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
+ GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS"));
+ GroupPoints->TextLabel2->setText(tr("GEOM_POINT_MIRROR"));
+ GroupPoints->TextLabel2->setFixedWidth(74);
+ GroupPoints->PushButton1->setIcon(image3);
+ GroupPoints->PushButton2->setIcon(image3);
+ GroupPoints->CheckButton1->setText(tr("GEOM_CREATE_COPY"));
+
+ QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+ layout->setMargin(0); layout->setSpacing(6);
+ 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();
}
-
//=================================================================================
// function : ~TransformationGUI_MirrorDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
TransformationGUI_MirrorDlg::~TransformationGUI_MirrorDlg()
-{
- /* no need to delete child widgets, Qt does it all for us */
+{
+ // no need to delete child widgets, Qt does it all for us
}
-
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void TransformationGUI_MirrorDlg::Init()
-{
- /* init variables */
- myEditCurrentArgument = GroupPoints->LineEdit1;
- GroupPoints->LineEdit1->setReadOnly( true );
- GroupPoints->LineEdit2->setReadOnly( true );
-
+{
+ // init variables
+ GroupPoints->LineEdit1->setReadOnly(true);
+ GroupPoints->LineEdit2->setReadOnly(true);
+
+ GroupPoints->LineEdit1->setText("");
+ GroupPoints->LineEdit2->setText("");
+
myArgument = GEOM::GEOM_Object::_nil();
-
- // Activate Create a Copy mode
- GroupPoints->CheckButton1->setChecked( true );
- CreateCopyModeChanged( true );
mainFrame()->GroupBoxPublish->show();
- /* signals and slots connections */
- connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
- connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+ // 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(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->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
- connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
-
- connect( GroupPoints->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( CreateCopyModeChanged( bool ) ) );
-
- connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
+ connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- initName( tr( "GEOM_MIRROR" ) );
+ connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
- ConstructorsClicked( 0 );
-}
+ initName(tr("GEOM_MIRROR"));
+ ConstructorsClicked(0);
+}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
-void TransformationGUI_MirrorDlg::ConstructorsClicked( int constructorId )
+void TransformationGUI_MirrorDlg::ConstructorsClicked (int constructorId)
{
- disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
-
- globalSelection();
- myEditCurrentArgument = GroupPoints->LineEdit1;
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+
GroupPoints->LineEdit2->clear();
myArgument = GEOM::GEOM_Object::_nil();
-
- switch ( constructorId ) {
- case 0: /* mirror an object by point */
- GroupPoints->TextLabel2->setText( tr( "GEOM_POINT_MIRROR" ) );
+
+ switch (constructorId) {
+ case 0: // mirror an object by point
+ GroupPoints->TextLabel2->setText(tr("GEOM_POINT_MIRROR"));
break;
- case 1: /* mirror an object by axe */
- GroupPoints->TextLabel2->setText( tr( "GEOM_AXE_MIRROR" ) );
+ case 1: // mirror an object by axe
+ GroupPoints->TextLabel2->setText(tr("GEOM_AXE_MIRROR"));
break;
- case 2: /* mirror an object by plane */
- GroupPoints->TextLabel2->setText( tr( "GEOM_PLANE_MIRROR" ) );
+ case 2: // mirror an object by plane
+ GroupPoints->TextLabel2->setText(tr("GEOM_PLANE_MIRROR"));
break;
}
- connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
-}
-
+ GroupPoints->PushButton1->click();
+ if (myInitial) {
+ myInitial = false;
+ SelectionIntoArgument();
+ }
+ else {
+ displayPreview();
+ }
+}
//=================================================================================
// function : ClickOnOk()
//=================================================================================
void TransformationGUI_MirrorDlg::ClickOnOk()
{
- if ( ClickOnApply() )
+ if (ClickOnApply())
ClickOnCancel();
}
-
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool TransformationGUI_MirrorDlg::ClickOnApply()
{
- if ( !onAccept( GroupPoints->CheckButton1->isChecked() ) )
+ if (!onAccept(GroupPoints->CheckButton1->isChecked()))
return false;
-
+
initName();
- ConstructorsClicked( getConstructorId() );
+ // activate selection and connect selection manager
+ ConstructorsClicked(getConstructorId());
return true;
}
-
//=================================================================================
// function : SelectionIntoArgument()
-// purpose : Called when selection has changed
+// purpose : Called when selection is changed or on dialog initialization or activation
//=================================================================================
void TransformationGUI_MirrorDlg::SelectionIntoArgument()
{
- myEditCurrentArgument->setText( "" );
- QString aName;
+ erasePreview();
+ 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();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
+ QString aName;
+
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
- if ( aNbSel < 1 ) {
- myObjects.length(0);
+ if (aNbSel < 1)
return;
- }
+
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
if (!myObjects.length())
return;
- if (aNbSel != 1)
- aName = tr("%1_objects").arg(aNbSel);
+ else
+ myEditCurrentArgument->setText(aName);
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
- if (aSelList.Extent() != 1) {
- myArgument = GEOM::GEOM_Object::_nil();
+ if (aSelList.Extent() != 1)
return;
- }
+
+ // nbSel == 1
Standard_Boolean testResult = Standard_False;
- GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
- myArgument = aSelectedObject;
+ myArgument = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if (!testResult || CORBA::is_nil(myArgument))
return;
- aName = GEOMBase::GetName(aSelectedObject);
-
- if (testResult && !aSelectedObject->_is_nil()) {
+ aName = GEOMBase::GetName(myArgument);
+
+ if (testResult && !myArgument->_is_nil()) {
TopoDS_Shape aShape;
- if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
- TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
- if ( getConstructorId() == 1 )
- aNeedType = TopAbs_EDGE;
- else if ( getConstructorId() == 2 )
- aNeedType = TopAbs_FACE;
-
- TColStd_IndexedMapOfInteger aMap;
- aSelMgr->GetIndexes(aSelList.First(), aMap);
- if ( aMap.Extent() == 1 ) {
- int anIndex = aMap( 1 );
- if ( aNeedType == TopAbs_VERTEX )
- aName += QString( ":vertex_%1" ).arg( anIndex );
- else
- aName += QString( ":edge_%1" ).arg( anIndex );
-
- //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 =
- getGeomEngine()->GetIShapesOperations( getStudyId() );
- myArgument = aShapesOp->GetSubShape( aSelectedObject, anIndex );
- }
- else {
- myArgument = aFindedObject; // get Object from study
- }
- }
- else {
- if ( aShape.ShapeType() != aNeedType ) {
- myArgument = GEOM::GEOM_Object::_nil();
- aName = "";
- }
- }
+ if (GEOMBase::GetShape(myArgument, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
+ TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
+ if (getConstructorId() == 1)
+ aNeedType = TopAbs_EDGE;
+ else if (getConstructorId() == 2)
+ aNeedType = TopAbs_FACE;
+
+ TColStd_IndexedMapOfInteger aMap;
+ aSelMgr->GetIndexes(aSelList.First(), aMap);
+ if (aMap.Extent() == 1) {
+ int anIndex = aMap(1);
+ if (aNeedType == TopAbs_VERTEX)
+ aName += QString(":vertex_%1").arg(anIndex);
+ else
+ aName += QString(":edge_%1").arg(anIndex);
+
+ //Find SubShape Object in Father
+ GEOM::GEOM_Object_var aFindedObject = findObjectInFather(myArgument, aName);
+
+ if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
+ GEOM::GEOM_IShapesOperations_var aShapesOp =
+ getGeomEngine()->GetIShapesOperations(getStudyId());
+ myArgument = aShapesOp->GetSubShape(myArgument, anIndex);
+ }
+ else {
+ myArgument = aFindedObject; // get Object from study
+ }
+ }
+ else {
+ if (aShape.ShapeType() != aNeedType) {
+ myArgument = GEOM::GEOM_Object::_nil();
+ aName = "";
+ }
+ }
}
}
+ myEditCurrentArgument->setText(aName);
+
+ if (!myArgument->_is_nil() && !myObjects.length())
+ GroupPoints->PushButton1->click();
}
- myEditCurrentArgument->setText( aName );
-
- displayPreview();
-}
+ // clear selection
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myGeomGUI->getApp()->selectionMgr()->clearSelected();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void TransformationGUI_MirrorDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if ( send == GroupPoints->LineEdit1 ||
- send == GroupPoints->LineEdit2 ) {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
+ displayPreview();
}
-
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
void TransformationGUI_MirrorDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
+
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection();
-
- if ( send == GroupPoints->PushButton1 ) {
+
+ if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1;
+
+ GroupPoints->PushButton2->setDown(false);
+ GroupPoints->LineEdit2->setEnabled(false);
}
- else if ( send == GroupPoints->PushButton2 ) {
+ else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2;
- switch ( getConstructorId() ) {
+
+ switch (getConstructorId()) {
case 0:
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+ localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
break;
case 1:
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
+ localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
break;
case 2:
- globalSelection( GEOM_PLANE );
+ globalSelection(GEOM_PLANE);
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();
- 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()
void TransformationGUI_MirrorDlg::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()
// 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();
}
-
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr TransformationGUI_MirrorDlg::createOperation()
{
- return getGeomEngine()->GetITransformOperations( getStudyId() );
+ return getGeomEngine()->GetITransformOperations(getStudyId());
}
-
//=================================================================================
// function : isValid
// 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
// purpose :
//=================================================================================
-bool TransformationGUI_MirrorDlg::execute( ObjectList& objects )
+bool TransformationGUI_MirrorDlg::execute (ObjectList& objects)
{
bool res = false;
bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
-
+
GEOM::GEOM_Object_var anObj;
-
- switch ( getConstructorId() ) {
+
+ switch (getConstructorId()) {
case 0:
{
- if ( toCreateCopy ) {
- for ( int i = 0; i < myObjects.length(); i++ ) {
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
- MirrorPointCopy( myObjects[i], myArgument );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
- }
+ if (toCreateCopy) {
+ for (int i = 0; i < myObjects.length(); i++) {
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ MirrorPointCopy(myObjects[i], myArgument);
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+ }
}
else {
- for ( int i = 0; i < myObjects.length(); i++ ) {
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
- MirrorPoint( myObjects[i], myArgument );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
- }
+ for (int i = 0; i < myObjects.length(); i++) {
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ MirrorPoint(myObjects[i], myArgument);
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+ }
}
res = true;
break;
}
case 1:
{
- if ( toCreateCopy ) {
- for ( int i = 0; i < myObjects.length(); i++ ) {
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
- MirrorAxisCopy( myObjects[i], myArgument );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
- }
+ if (toCreateCopy) {
+ for (int i = 0; i < myObjects.length(); i++) {
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ MirrorAxisCopy(myObjects[i], myArgument);
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+ }
}
else {
- for ( int i = 0; i < myObjects.length(); i++ ) {
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
- MirrorAxis( myObjects[i], myArgument );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
- }
+ for (int i = 0; i < myObjects.length(); i++) {
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ MirrorAxis(myObjects[i], myArgument);
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+ }
}
res = true;
break;
}
case 2:
{
- if ( toCreateCopy ) {
- for ( int i = 0; i < myObjects.length(); i++ ) {
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPlaneCopy( myObjects[i], myArgument );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
- }
+ if (toCreateCopy) {
+ for (int i = 0; i < myObjects.length(); i++) {
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ MirrorPlaneCopy(myObjects[i], myArgument);
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+ }
}
else {
- for ( int i = 0; i < myObjects.length(); i++ ) {
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPlane( myObjects[i], myArgument );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
- }
+ for (int i = 0; i < myObjects.length(); i++) {
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ MirrorPlane(myObjects[i], myArgument);
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+ }
}
res = true;
break;
}
}
-
+
return res;
}
// function : restoreSubShapes
// purpose :
//=================================================================================
-void TransformationGUI_MirrorDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy,
- SALOMEDS::SObject_ptr theSObject )
+void TransformationGUI_MirrorDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
+ SALOMEDS::SObject_ptr theSObject)
{
- if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) {
+ if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored
- getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(),
- /*theFindMethod=*/GEOM::FSM_Transformed,
- /*theInheritFirstArg=*/true );
+ getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
+ /*theFindMethod=*/GEOM::FSM_Transformed,
+ /*theInheritFirstArg=*/true);
}
}
// function : CreateCopyModeChanged()
// purpose :
//=================================================================================
-void TransformationGUI_MirrorDlg::CreateCopyModeChanged( bool isCreateCopy )
+void TransformationGUI_MirrorDlg::CreateCopyModeChanged (bool isCreateCopy)
{
- mainFrame()->GroupBoxName->setEnabled( isCreateCopy );
+ mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
}
//=================================================================================
void TransformationGUI_MirrorDlg::addSubshapesToStudy()
{
bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
- if ( toCreateCopy ) {
+ if (toCreateCopy) {
QMap<QString, GEOM::GEOM_Object_var> objMap;
- switch ( getConstructorId() ) {
+ switch (getConstructorId()) {
case 0:
objMap[GroupPoints->LineEdit2->text()] = myArgument;
break;
case 2:
return;
}
- addSubshapesToFather( objMap );
+ addSubshapesToFather(objMap);
}
}
private:
GEOM::GEOM_Object_var myArgument;
GEOM::ListOfGO myObjects;
+
+ // to initialize the first selection field with a selected object on the dialog creation
+ bool myInitial;
DlgRef_2Sel1Spin2Check* GroupPoints;
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : TransformationGUI_MultiRotationDlg.cxx
#include <GeometryGUI.h>
#include <GEOMBase.h>
-#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
+// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
//=================================================================================
// 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'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg
-( GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl )
- : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
+(GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
+ myInitial(true)
{
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
- QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_MULTIROTATION_SIMPLE" ) ) );
- QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_MULTIROTATION_DOUBLE" ) ) );
- QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
+ QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTIROTATION_SIMPLE")));
+ QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTIROTATION_DOUBLE")));
+ 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()->RadioButton1->setIcon( image0 );
- mainFrame()->RadioButton2->setIcon( image1 );
- mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
+ mainFrame()->GroupConstructors->setTitle(tr("GEOM_MULTIROTATION"));
+ mainFrame()->RadioButton1->setIcon(image0);
+ mainFrame()->RadioButton2->setIcon(image1);
+ mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close();
- GroupPoints = new DlgRef_2Sel1Spin( centralWidget() );
- GroupPoints->GroupBox1->setTitle( tr( "GEOM_MULTIROTATION_SIMPLE" ) );
- GroupPoints->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) );
- GroupPoints->TextLabel2->setText( tr( "GEOM_VECTOR" ) );
- GroupPoints->TextLabel3->setText( tr( "GEOM_NB_TIMES" ) );
- GroupPoints->PushButton1->setIcon( image2 );
- GroupPoints->PushButton2->setIcon( image2 );
- GroupPoints->LineEdit1->setReadOnly( true );
- GroupPoints->LineEdit2->setReadOnly( true );
-
- GroupDimensions = new DlgRef_2Sel4Spin1Check( centralWidget() );
- GroupDimensions->GroupBox1->setTitle( tr( "GEOM_MULTIROTATION_DOUBLE" ) );
- GroupDimensions->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) );
- GroupDimensions->TextLabel2->setText( tr( "GEOM_VECTOR" ) );
- GroupDimensions->TextLabel3->setText( tr( "GEOM_ANGLE" ) );
- GroupDimensions->TextLabel4->setText( tr( "GEOM_NB_TIMES" ) );
- GroupDimensions->TextLabel5->setText( tr( "GEOM_STEP" ) );
- GroupDimensions->TextLabel6->setText( tr( "GEOM_NB_TIMES" ) );
- GroupDimensions->CheckButton1->setText( tr( "GEOM_REVERSE" ) );
- GroupDimensions->PushButton1->setIcon( image2 );
- GroupDimensions->PushButton2->setIcon( image2 );
- GroupDimensions->LineEdit1->setReadOnly( true );
- GroupDimensions->LineEdit2->setReadOnly( true );
-
- QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
- layout->setMargin( 0 ); layout->setSpacing( 6 );
- layout->addWidget( GroupPoints );
- layout->addWidget( GroupDimensions );
+ GroupPoints = new DlgRef_2Sel1Spin(centralWidget());
+ GroupPoints->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_SIMPLE"));
+ GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
+ GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR"));
+ GroupPoints->TextLabel3->setText(tr("GEOM_NB_TIMES"));
+ GroupPoints->PushButton1->setIcon(image2);
+ GroupPoints->PushButton2->setIcon(image2);
+ GroupPoints->LineEdit1->setReadOnly(true);
+ GroupPoints->LineEdit2->setReadOnly(true);
+
+ GroupDimensions = new DlgRef_2Sel4Spin1Check(centralWidget());
+ GroupDimensions->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_DOUBLE"));
+ GroupDimensions->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
+ GroupDimensions->TextLabel2->setText(tr("GEOM_VECTOR"));
+ GroupDimensions->TextLabel3->setText(tr("GEOM_ANGLE"));
+ GroupDimensions->TextLabel4->setText(tr("GEOM_NB_TIMES"));
+ GroupDimensions->TextLabel5->setText(tr("GEOM_STEP"));
+ GroupDimensions->TextLabel6->setText(tr("GEOM_NB_TIMES"));
+ GroupDimensions->CheckButton1->setText(tr("GEOM_REVERSE"));
+ GroupDimensions->PushButton1->setIcon(image2);
+ GroupDimensions->PushButton2->setIcon(image2);
+ GroupDimensions->LineEdit1->setReadOnly(true);
+ GroupDimensions->LineEdit2->setReadOnly(true);
+
+ QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+ layout->setMargin(0); layout->setSpacing(6);
+ layout->addWidget(GroupPoints);
+ layout->addWidget(GroupDimensions);
/***************************************************************/
- setHelpFileName( "multi_rotation_operation_page.html" );
+ setHelpFileName("multi_rotation_operation_page.html");
Init();
}
-
//=================================================================================
// function : ~TransformationGUI_MultiRotationDlg()
// purpose : Destroys the object and frees any allocated resources
// no need to delete child widgets, Qt does it all for us
}
-
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
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();
- double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
+ double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
double SpecificStep1 = 5;
double SpecificStep2 = 1;
- /* min, max, step and decimals for spin boxes & initial values */
- initSpinBox( GroupPoints->SpinBox_DX, 1.0, MAX_NUMBER, SpecificStep2, 10 );
- GroupPoints->SpinBox_DX->setValue( myNbTimes1 );
-
- 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_DX2, COORD_MIN, COORD_MAX, step, 10 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( GroupDimensions->SpinBox_DY2, 1.0, MAX_NUMBER, SpecificStep2, 10 );
- GroupDimensions->SpinBox_DX1->setValue( myAng );
- GroupDimensions->SpinBox_DY1->setValue( myNbTimes1 );
- GroupDimensions->SpinBox_DX2->setValue( myStep );
- GroupDimensions->SpinBox_DY2->setValue( myNbTimes2 );
-
- /* 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( GroupDimensions->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( GroupDimensions->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
-
- 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( 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() ) );
-
- connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
-
- initName( tr( "GEOM_MULTIROTATION" ) );
-
- ConstructorsClicked( 0 );
-}
+ // min, max, step and decimals for spin boxes & initial values
+ initSpinBox(GroupPoints->SpinBox_DX, 1.0, MAX_NUMBER, SpecificStep2, 10);
+ GroupPoints->SpinBox_DX->setValue(myNbTimes1);
+
+ 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_DX2, COORD_MIN, COORD_MAX, step, 10); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox(GroupDimensions->SpinBox_DY2, 1.0, MAX_NUMBER, SpecificStep2, 10);
+ GroupDimensions->SpinBox_DX1->setValue(myAng);
+ GroupDimensions->SpinBox_DY1->setValue(myNbTimes1);
+ GroupDimensions->SpinBox_DX2->setValue(myStep);
+ GroupDimensions->SpinBox_DY2->setValue(myNbTimes2);
+
+ // init variables
+ myAng = 45.0;
+ myStep = 50.0;
+ myNbTimes1 = myNbTimes2 = 2;
+
+ GroupPoints->LineEdit1->setText("");
+ GroupPoints->LineEdit2->setText("");
+
+ GroupDimensions->LineEdit1->setText("");
+ GroupDimensions->LineEdit2->setText("");
+
+ myBase = myVector = 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(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+
+ 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(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()
// purpose : Double spin box management
//=================================================================================
-void TransformationGUI_MultiRotationDlg::SetDoubleSpinBoxStep( double step )
+void TransformationGUI_MultiRotationDlg::SetDoubleSpinBoxStep (double step)
{
GroupPoints->SpinBox_DX->setSingleStep(step);
GroupDimensions->SpinBox_DX1->setSingleStep(step);
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
-void TransformationGUI_MultiRotationDlg::ConstructorsClicked( int constructorId )
+void TransformationGUI_MultiRotationDlg::ConstructorsClicked (int constructorId)
{
- disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
-
- myAng = 45.0;
- myStep = 50.0;
- myNbTimes1 = myNbTimes2 = 2;
-
- globalSelection( GEOM_ALLSHAPES );
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- switch ( constructorId ) {
- case 0: /* Rotate simple */
+ switch (constructorId) {
+ case 0: // Rotate simple
{
GroupDimensions->hide();
GroupPoints->show();
- myEditCurrentArgument = GroupPoints->LineEdit1;
- GroupPoints->LineEdit1->setText( "" );
- GroupPoints->LineEdit2->setText( "" );
-
- GroupPoints->SpinBox_DX->setValue( myNbTimes1 );
-
- break;
+ GroupPoints->LineEdit1->setText("");
+ GroupPoints->LineEdit2->setText("");
+ myBase = myVector = GEOM::GEOM_Object::_nil();
+
+ GroupPoints->SpinBox_DX->setValue(myNbTimes1);
+
+ GroupPoints->PushButton1->click();
}
- case 1: /* Rotate double */
+ break;
+ case 1: // Rotate double
{
GroupPoints->hide();
GroupDimensions->show();
-
- myEditCurrentArgument = GroupDimensions->LineEdit1;
- GroupDimensions->LineEdit1->setText( "" );
- GroupDimensions->LineEdit2->setText( "" );
-
- GroupDimensions->SpinBox_DX1->setValue( myAng );
- GroupDimensions->SpinBox_DY1->setValue( myNbTimes1 );
- GroupDimensions->SpinBox_DX2->setValue( myStep );
- GroupDimensions->SpinBox_DY2->setValue( myNbTimes2 );
-
- break;
- }
+
+ GroupDimensions->LineEdit1->setText("");
+ GroupDimensions->LineEdit2->setText("");
+ myBase = myVector = GEOM::GEOM_Object::_nil();
+
+ GroupDimensions->SpinBox_DX1->setValue(myAng);
+ GroupDimensions->SpinBox_DY1->setValue(myNbTimes1);
+ GroupDimensions->SpinBox_DX2->setValue(myStep);
+ GroupDimensions->SpinBox_DY2->setValue(myNbTimes2);
+
+ GroupDimensions->PushButton1->click();
+ }
+ break;
}
qApp->processEvents();
updateGeometry();
- resize( minimumSize() );
+ resize(minimumSize());
- myEditCurrentArgument->setFocus();
- myBase = myVector = GEOM::GEOM_Object::_nil();
- connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
- this, SLOT( SelectionIntoArgument() ) );
+ if (myInitial) {
+ myInitial = false;
+ SelectionIntoArgument();
+ }
+ else {
+ displayPreview();
+ }
}
-
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void TransformationGUI_MultiRotationDlg::ClickOnOk()
{
- if ( ClickOnApply() )
+ if (ClickOnApply())
ClickOnCancel();
}
-
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool TransformationGUI_MultiRotationDlg::ClickOnApply()
{
- if ( !onAccept() )
+ if (!onAccept())
return false;
-
+
initName();
- ConstructorsClicked( getConstructorId() );
+ // activate selection and connect selection manager
+ ConstructorsClicked(getConstructorId());
return true;
}
-
//=================================================================================
// 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()
{
- 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();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
- 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();
+ if (aSelList.Extent() != 1)
return;
- }
// nbSel == 1
Standard_Boolean testResult = Standard_False;;
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;
- QString aName = GEOMBase::GetName( aSelectedObject );
+ QString aName = GEOMBase::GetName(aSelectedObject);
- if ( myEditCurrentArgument == GroupPoints->LineEdit1 ||
- myEditCurrentArgument == GroupDimensions->LineEdit1 )
+ if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit1)
myBase = aSelectedObject;
- else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
- myEditCurrentArgument == GroupDimensions->LineEdit2 ) {
- if ( testResult && !aSelectedObject->_is_nil() ) {
- TopoDS_Shape aShape;
-
- if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
- TColStd_IndexedMapOfInteger aMap;
- aSelMgr->GetIndexes( aSelList.First(), aMap );
- if ( aMap.Extent() == 1 ) {
- int anIndex = aMap( 1 );
- aName += QString( ":edge_%1" ).arg( anIndex );
-
- //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 =
- getGeomEngine()->GetIShapesOperations( getStudyId() );
- myVector = aShapesOp->GetSubShape(aSelectedObject, anIndex);
- }
- else {
- myVector = aFindedObject; // get existing object
- }
- }
- else {
- if ( aShape.ShapeType() != TopAbs_EDGE ) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
- myVector = aSelectedObject;
- }
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit2) {
+ TopoDS_Shape aShape;
+
+ if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
+ TColStd_IndexedMapOfInteger aMap;
+ aSelMgr->GetIndexes(aSelList.First(), aMap);
+ if (aMap.Extent() == 1) {
+ int anIndex = aMap(1);
+ aName += QString(":edge_%1").arg(anIndex);
+
+ //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 =
+ getGeomEngine()->GetIShapesOperations(getStudyId());
+ myVector = aShapesOp->GetSubShape(aSelectedObject, anIndex);
+ }
+ else {
+ myVector = aFindedObject; // get existing object
+ }
+ }
+ else {
+ if (aShape.ShapeType() != TopAbs_EDGE) {
+ aSelectedObject = GEOM::GEOM_Object::_nil();
+ aName = "";
+ }
+ 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();
}
-
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
void TransformationGUI_MultiRotationDlg::SetEditCurrentArgument()
{
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;
+
+ GroupPoints->PushButton2->setDown(false);
+ GroupPoints->LineEdit2->setEnabled(false);
}
- else if ( send == GroupPoints->PushButton2 ) {
+ else if (send == GroupPoints->PushButton2) {
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;
+
+ GroupDimensions->PushButton2->setDown(false);
+ GroupDimensions->LineEdit2->setEnabled(false);
}
- else if ( send == GroupDimensions->PushButton2 ) {
+ else if (send == GroupDimensions->PushButton2) {
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();
- 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()
void TransformationGUI_MultiRotationDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
- if ( send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 ||
- send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2 ) {
- myEditCurrentArgument = send;
+ if (send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 ||
+ send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2) {
+ myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
void TransformationGUI_MultiRotationDlg::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()
// purpose :
//=================================================================================
-void TransformationGUI_MultiRotationDlg::enterEvent( QEvent* )
+void TransformationGUI_MultiRotationDlg::enterEvent (QEvent*)
{
- if ( !mainFrame()->GroupConstructors->isEnabled() )
+ if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog();
}
-
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
-void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox( double newValue )
+void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox (double newValue)
{
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;
- else if ( send == GroupDimensions->SpinBox_DX1 )
+ else if (send == GroupDimensions->SpinBox_DX1)
myAng = newValue;
- else if ( send == GroupDimensions->SpinBox_DX2 )
+ else if (send == GroupDimensions->SpinBox_DX2)
myStep = newValue;
- else if ( send == GroupDimensions->SpinBox_DY2 )
+ else if (send == GroupDimensions->SpinBox_DY2)
myNbTimes2 = (int)newValue;
-
+
displayPreview();
}
-
//=================================================================================
// function : ReverseAngle()
// purpose : 'state' not used here
int aConstructorId = getConstructorId();
- if ( aConstructorId == 0 )
- GroupPoints->SpinBox_DX->setValue( myAng );
- else if ( aConstructorId == 1 )
- GroupDimensions->SpinBox_DX1->setValue( myAng );
+ if (aConstructorId == 0)
+ GroupPoints->SpinBox_DX->setValue(myAng);
+ else if (aConstructorId == 1)
+ GroupDimensions->SpinBox_DX1->setValue(myAng);
displayPreview();
}
-
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr TransformationGUI_MultiRotationDlg::createOperation()
{
- return myGeomGUI->GetGeomGen()->GetITransformOperations( getStudyId() );
+ return getGeomEngine()->GetITransformOperations(getStudyId());
}
-
//=================================================================================
// function : isValid
// 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
// purpose :
//=================================================================================
-bool TransformationGUI_MultiRotationDlg::execute( ObjectList& objects )
+bool TransformationGUI_MultiRotationDlg::execute (ObjectList& objects)
{
bool res = false;
-
+
GEOM::GEOM_Object_var anObj;
- switch ( getConstructorId() ) {
- case 0 :
- if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVector ) ) {
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
- MultiRotate1D( myBase, myVector, myNbTimes1 );
+ switch (getConstructorId()) {
+ case 0:
+ if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVector)) {
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ MultiRotate1D(myBase, myVector, myNbTimes1);
res = true;
}
break;
- case 1 :
- if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVector ) ) {
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
- MultiRotate2D( myBase, myVector, myAng, myNbTimes1, myStep, myNbTimes2 );
+ case 1:
+ if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVector)) {
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ MultiRotate2D(myBase, myVector, myAng, myNbTimes1, myStep, myNbTimes2);
res = true;
}
break;
}
-
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
-
+
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+
return res;
}
void TransformationGUI_MultiRotationDlg::addSubshapesToStudy()
{
QMap<QString, GEOM::GEOM_Object_var> objMap;
-
- switch ( getConstructorId() ) {
+
+ switch (getConstructorId()) {
case 0:
objMap[GroupPoints->LineEdit2->text()] = myVector;
break;
objMap[GroupDimensions->LineEdit2->text()] = myVector;
break;
}
- addSubshapesToFather( objMap );
+ addSubshapesToFather(objMap);
}
int myNbTimes2;
Standard_Real myAng;
Standard_Real myStep;
+
+ // to initialize the first selection field with a selected object on the dialog creation
+ bool myInitial;
DlgRef_2Sel1Spin* GroupPoints;
DlgRef_2Sel4Spin1Check* GroupDimensions;
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : TransformationGUI_MultiTranslationDlg.cxx
#include <GeometryGUI.h>
#include <GEOMBase.h>
-#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
+// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
//=================================================================================
// 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'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg
-( GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl )
- : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
+(GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
+ myInitial(true)
{
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
- QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_MULTITRANSLATION_SIMPLE" ) ) );
- QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_MULTITRANSLATION_DOUBLE" ) ) );
- QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
+ QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_SIMPLE")));
+ QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_DOUBLE")));
+ 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()->RadioButton1->setIcon( image0 );
- mainFrame()->RadioButton2->setIcon( image1 );
- mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
+ mainFrame()->GroupConstructors->setTitle(tr("GEOM_MULTITRANSLATION"));
+ mainFrame()->RadioButton1->setIcon(image0);
+ mainFrame()->RadioButton2->setIcon(image1);
+ mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close();
- GroupPoints = new DlgRef_2Sel2Spin1Check( centralWidget() );
- GroupPoints->GroupBox1->setTitle( tr( "GEOM_MULTITRANSLATION_SIMPLE" ) );
- GroupPoints->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) );
- GroupPoints->TextLabel2->setText( tr( "GEOM_VECTOR_U" ) );
- GroupPoints->TextLabel3->setText( tr( "GEOM_STEP_U" ) );
- GroupPoints->TextLabel4->setText( tr( "GEOM_NB_TIMES_U" ) );
- GroupPoints->CheckButton1->setText( tr( "GEOM_REVERSE_U" ) );
- GroupPoints->PushButton1->setIcon( image2 );
- GroupPoints->PushButton2->setIcon( image2 );
- GroupPoints->LineEdit1->setReadOnly( true );
- GroupPoints->LineEdit2->setReadOnly( true );
-
- GroupDimensions = new DlgRef_3Sel4Spin2Check( centralWidget() );
- GroupDimensions->GroupBox1->setTitle( tr( "GEOM_MULTITRANSLATION_DOUBLE" ) );
- GroupDimensions->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) );
- GroupDimensions->TextLabel2->setText( tr( "GEOM_VECTOR_U" ) );
- GroupDimensions->TextLabel3->setText( tr( "GEOM_VECTOR_V" ) );
- GroupDimensions->TextLabel4->setText( tr( "GEOM_STEP_U" ) );
- GroupDimensions->TextLabel5->setText( tr( "GEOM_NB_TIMES_U" ) );
- GroupDimensions->TextLabel6->setText( tr( "GEOM_STEP_V" ) );
- GroupDimensions->TextLabel7->setText( tr( "GEOM_NB_TIMES_V" ) );
- GroupDimensions->CheckButton1->setText( tr( "GEOM_REVERSE_U" ) );
- GroupDimensions->CheckButton2->setText( tr( "GEOM_REVERSE_V" ) );
- GroupDimensions->PushButton1->setIcon( image2 );
- GroupDimensions->PushButton2->setIcon( image2 );
- GroupDimensions->PushButton3->setIcon( image2 );
- GroupDimensions->LineEdit1->setReadOnly( true );
- GroupDimensions->LineEdit2->setReadOnly( true );
- GroupDimensions->LineEdit3->setReadOnly( true );
-
- QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
- layout->setMargin( 0 ); layout->setSpacing( 6 );
- layout->addWidget( GroupPoints );
- layout->addWidget( GroupDimensions );
+ GroupPoints = new DlgRef_2Sel2Spin1Check(centralWidget());
+ GroupPoints->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_SIMPLE"));
+ GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
+ GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR_U"));
+ GroupPoints->TextLabel3->setText(tr("GEOM_STEP_U"));
+ GroupPoints->TextLabel4->setText(tr("GEOM_NB_TIMES_U"));
+ GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE_U"));
+ GroupPoints->PushButton1->setIcon(image2);
+ GroupPoints->PushButton2->setIcon(image2);
+ GroupPoints->LineEdit1->setReadOnly(true);
+ GroupPoints->LineEdit2->setReadOnly(true);
+
+ GroupDimensions = new DlgRef_3Sel4Spin2Check(centralWidget());
+ GroupDimensions->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_DOUBLE"));
+ GroupDimensions->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
+ GroupDimensions->TextLabel2->setText(tr("GEOM_VECTOR_U"));
+ GroupDimensions->TextLabel3->setText(tr("GEOM_VECTOR_V"));
+ GroupDimensions->TextLabel4->setText(tr("GEOM_STEP_U"));
+ GroupDimensions->TextLabel5->setText(tr("GEOM_NB_TIMES_U"));
+ GroupDimensions->TextLabel6->setText(tr("GEOM_STEP_V"));
+ GroupDimensions->TextLabel7->setText(tr("GEOM_NB_TIMES_V"));
+ GroupDimensions->CheckButton1->setText(tr("GEOM_REVERSE_U"));
+ GroupDimensions->CheckButton2->setText(tr("GEOM_REVERSE_V"));
+ GroupDimensions->PushButton1->setIcon(image2);
+ GroupDimensions->PushButton2->setIcon(image2);
+ GroupDimensions->PushButton3->setIcon(image2);
+ GroupDimensions->LineEdit1->setReadOnly(true);
+ GroupDimensions->LineEdit2->setReadOnly(true);
+ GroupDimensions->LineEdit3->setReadOnly(true);
+
+ QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+ layout->setMargin(0); layout->setSpacing(6);
+ layout->addWidget(GroupPoints);
+ layout->addWidget(GroupDimensions);
/***************************************************************/
- setHelpFileName( "multi_translation_operation_page.html" );
+ setHelpFileName("multi_translation_operation_page.html");
Init();
}
-
//=================================================================================
// function : ~TransformationGUI_MultiTranslationDlg()
// purpose : Destroys the object and frees any allocated resources
// no need to delete child widgets, Qt does it all for us
}
-
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
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();
- double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
-
+ double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
+
double SpecificStep = 1;
- /* 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_DY, 1.0, MAX_NUMBER, SpecificStep, 10 );
- GroupPoints->SpinBox_DX->setValue( myStepU );
- GroupPoints->SpinBox_DY->setValue( myNbTimesU );
-
- 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_DX2, COORD_MIN, COORD_MAX, step, 10 ); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox( GroupDimensions->SpinBox_DY2, 1.0, MAX_NUMBER, SpecificStep, 10 );
- GroupDimensions->SpinBox_DX1->setValue( myStepU );
- GroupDimensions->SpinBox_DY1->setValue( myNbTimesU );
- GroupDimensions->SpinBox_DX2->setValue( myStepV );
- GroupDimensions->SpinBox_DY2->setValue( myNbTimesV );
-
- /* 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( GroupDimensions->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( GroupDimensions->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( GroupDimensions->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
-
- 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() ) );
-
- connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
-
- initName( tr( "GEOM_MULTITRANSLATION" ) );
-
- ConstructorsClicked( 0 );
-}
+ // 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_DY, 1.0, MAX_NUMBER, SpecificStep, 10);
+ GroupPoints->SpinBox_DX->setValue(myStepU);
+ GroupPoints->SpinBox_DY->setValue(myNbTimesU);
+
+ 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_DX2, COORD_MIN, COORD_MAX, step, 10); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox(GroupDimensions->SpinBox_DY2, 1.0, MAX_NUMBER, SpecificStep, 10);
+ GroupDimensions->SpinBox_DX1->setValue(myStepU);
+ GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
+ GroupDimensions->SpinBox_DX2->setValue(myStepV);
+ GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
+
+ // init variables
+ myStepU = myStepV = 50.0;
+ myNbTimesU = myNbTimesV = 2;
+
+ GroupPoints->LineEdit1->setText("");
+ GroupPoints->LineEdit2->setText("");
+
+ GroupDimensions->LineEdit1->setText("");
+ GroupDimensions->LineEdit2->setText("");
+ GroupDimensions->LineEdit3->setText("");
+
+ myBase = myVectorU = myVectorV = 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(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(GroupDimensions->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+
+ 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()
// purpose : Double spin box management
//=================================================================================
-void TransformationGUI_MultiTranslationDlg::SetDoubleSpinBoxStep( double step )
+void TransformationGUI_MultiTranslationDlg::SetDoubleSpinBoxStep (double step)
{
GroupPoints->SpinBox_DX->setSingleStep(step);
GroupPoints->SpinBox_DY->setSingleStep(step);
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
-void TransformationGUI_MultiTranslationDlg::ConstructorsClicked( int constructorId )
+void TransformationGUI_MultiTranslationDlg::ConstructorsClicked (int constructorId)
{
- disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
-
- myStepU = myStepV = 50.0;
- myNbTimesU = myNbTimesV = 2;
-
- globalSelection( GEOM_ALLSHAPES );
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- switch ( constructorId ) {
- case 0: /* Translate simple */
+ switch (constructorId) {
+ case 0: // Translate simple
{
GroupDimensions->hide();
GroupPoints->show();
-
- myEditCurrentArgument = GroupPoints->LineEdit1;
- GroupPoints->LineEdit1->setText( "" );
- GroupPoints->LineEdit2->setText( "" );
-
- GroupPoints->SpinBox_DX->setValue( myStepU );
- GroupPoints->SpinBox_DY->setValue( myNbTimesU );
-
+
+ GroupPoints->LineEdit1->setText("");
+ GroupPoints->LineEdit2->setText("");
+ myBase = myVectorU = GEOM::GEOM_Object::_nil();
+
+ GroupPoints->SpinBox_DX->setValue(myStepU);
+ GroupPoints->SpinBox_DY->setValue(myNbTimesU);
+
+ GroupPoints->PushButton1->click();
break;
}
- case 1: /* Translate double */
+ case 1: // Translate double
{
GroupPoints->hide();
GroupDimensions->show();
-
- myEditCurrentArgument = GroupDimensions->LineEdit1;
- GroupDimensions->LineEdit1->setText( "" );
- GroupDimensions->LineEdit2->setText( "" );
- GroupDimensions->LineEdit3->setText( "" );
-
- GroupDimensions->SpinBox_DX1->setValue( myStepU );
- GroupDimensions->SpinBox_DY1->setValue( myNbTimesU );
- GroupDimensions->SpinBox_DX2->setValue( myStepV );
- GroupDimensions->SpinBox_DY2->setValue( myNbTimesV );
-
- myVectorV = GEOM::GEOM_Object::_nil();
+
+ GroupDimensions->LineEdit1->setText("");
+ GroupDimensions->LineEdit2->setText("");
+ GroupDimensions->LineEdit3->setText("");
+ myBase = myVectorU = myVectorV = GEOM::GEOM_Object::_nil();
+
+ GroupDimensions->SpinBox_DX1->setValue(myStepU);
+ GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
+ GroupDimensions->SpinBox_DX2->setValue(myStepV);
+ GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
+
+ GroupDimensions->PushButton1->click();
break;
}
}
-
+
qApp->processEvents();
updateGeometry();
- resize( minimumSize() );
+ resize(minimumSize());
- myEditCurrentArgument->setFocus();
- myBase = myVectorU = GEOM::GEOM_Object::_nil();
- connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ if (myInitial) {
+ myInitial = false;
+ SelectionIntoArgument();
+ }
+ else {
+ displayPreview();
+ }
}
-
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void TransformationGUI_MultiTranslationDlg::ClickOnOk()
{
- if ( ClickOnApply() )
+ if (ClickOnApply())
ClickOnCancel();
}
-
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool TransformationGUI_MultiTranslationDlg::ClickOnApply()
{
- if ( !onAccept() )
+ if (!onAccept())
return false;
-
+
initName();
- ConstructorsClicked( getConstructorId() );
+ // activate selection and connect selection manager
+ ConstructorsClicked(getConstructorId());
return true;
}
-
//=================================================================================
// 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()
{
- 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();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
- 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();
+ if (aSelList.Extent() != 1)
return;
- }
// nbSel == 1
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;
- QString aName = GEOMBase::GetName( aSelectedObject );
+ QString aName = GEOMBase::GetName(aSelectedObject);
- if ( myEditCurrentArgument == GroupPoints->LineEdit1 ||
- myEditCurrentArgument == GroupDimensions->LineEdit1 )
+ if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit1)
myBase = aSelectedObject;
- else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
- myEditCurrentArgument == GroupDimensions->LineEdit2 ||
- myEditCurrentArgument == GroupDimensions->LineEdit3 ) {
- if ( testResult && !aSelectedObject->_is_nil() ) {
- TopoDS_Shape aShape;
-
- if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
- TColStd_IndexedMapOfInteger aMap;
- aSelMgr->GetIndexes( aSelList.First(), aMap );
- if ( aMap.Extent() == 1 ) {
- int anIndex = aMap( 1 );
- aName += QString( ":edge_%1" ).arg( anIndex );
-
- //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 =
- getGeomEngine()->GetIShapesOperations( getStudyId() );
- if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
- myVectorV = aShapesOp->GetSubShape( aSelectedObject, anIndex );
- else
- myVectorU = aShapesOp->GetSubShape(aSelectedObject, anIndex);
- }
- else {
- if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
- myVectorV = aFindedObject;
- else
- myVectorU = aFindedObject;
- }
- }
- else {
- if ( aShape.ShapeType() != TopAbs_EDGE ) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
- if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
- myVectorV = aSelectedObject;
- else
- myVectorU = aSelectedObject;
- }
+ else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit2 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit3) {
+ TopoDS_Shape aShape;
+
+ if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
+ TColStd_IndexedMapOfInteger aMap;
+ aSelMgr->GetIndexes(aSelList.First(), aMap);
+ if (aMap.Extent() == 1) {
+ int anIndex = aMap(1);
+ aName += QString(":edge_%1").arg(anIndex);
+
+ //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 =
+ getGeomEngine()->GetIShapesOperations(getStudyId());
+ if (myEditCurrentArgument == GroupDimensions->LineEdit3)
+ myVectorV = aShapesOp->GetSubShape(aSelectedObject, anIndex);
+ else
+ myVectorU = aShapesOp->GetSubShape(aSelectedObject, anIndex);
+ }
+ else {
+ if (myEditCurrentArgument == GroupDimensions->LineEdit3)
+ myVectorV = aFindedObject;
+ else
+ myVectorU = aFindedObject;
+ }
+ }
+ else {
+ if (aShape.ShapeType() != TopAbs_EDGE) {
+ aSelectedObject = GEOM::GEOM_Object::_nil();
+ aName = "";
+ }
+ if (myEditCurrentArgument == GroupDimensions->LineEdit3)
+ myVectorV = aSelectedObject;
+ else
+ myVectorU = aSelectedObject;
}
}
}
+ myEditCurrentArgument->setText(aName);
- myEditCurrentArgument->setText( aName );
-
- displayPreview();
-}
+ if (myEditCurrentArgument == GroupPoints->LineEdit1) {
+ if (!myBase->_is_nil() && myVectorU->_is_nil())
+ 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()
void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument()
{
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;
+
+ GroupPoints->PushButton2->setDown(false);
+ GroupPoints->LineEdit2->setEnabled(false);
}
- else if ( send == GroupPoints->PushButton2 ) {
+ else if (send == GroupPoints->PushButton2) {
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;
+
+ GroupDimensions->PushButton2->setDown(false);
+ GroupDimensions->PushButton3->setDown(false);
+ GroupDimensions->LineEdit2->setEnabled(false);
+ GroupDimensions->LineEdit3->setEnabled(false);
}
- else if ( send == GroupDimensions->PushButton2 ) {
+ else if (send == GroupDimensions->PushButton2) {
myEditCurrentArgument = GroupDimensions->LineEdit2;
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
+
+ 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 ) {
+ else if (send == GroupDimensions->PushButton3) {
myEditCurrentArgument = GroupDimensions->LineEdit3;
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
+
+ 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();
- 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()
void TransformationGUI_MultiTranslationDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
- if ( send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 ||
- send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2 ||
- send == GroupDimensions->LineEdit3 ) {
- myEditCurrentArgument = send;
+ if (send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 ||
+ send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2 ||
+ send == GroupDimensions->LineEdit3) {
+ myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
void TransformationGUI_MultiTranslationDlg::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()
// purpose :
//=================================================================================
-void TransformationGUI_MultiTranslationDlg::enterEvent( QEvent* )
+void TransformationGUI_MultiTranslationDlg::enterEvent (QEvent*)
{
- if ( !mainFrame()->GroupConstructors->isEnabled() )
+ if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog();
}
-
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
-void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox( double newValue )
+void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (double newValue)
{
QObject* send = (QObject*)sender();
- switch ( getConstructorId() ) {
+ switch (getConstructorId()) {
case 0:
- if ( send == GroupPoints->SpinBox_DX )
+ if (send == GroupPoints->SpinBox_DX)
myStepU = newValue;
- else if ( send == GroupPoints->SpinBox_DY )
+ else if (send == GroupPoints->SpinBox_DY)
myNbTimesU = (int)newValue;
break;
- case 1 :
- if ( send == GroupDimensions->SpinBox_DX1 )
+ case 1:
+ if (send == GroupDimensions->SpinBox_DX1)
myStepU = newValue;
- else if ( send == GroupDimensions->SpinBox_DY1)
+ else if (send == GroupDimensions->SpinBox_DY1)
myNbTimesU = (int)newValue;
- else if ( send == GroupDimensions->SpinBox_DX2 )
+ else if (send == GroupDimensions->SpinBox_DX2)
myStepV = newValue;
- else if ( send == GroupDimensions->SpinBox_DY2 )
+ else if (send == GroupDimensions->SpinBox_DY2)
myNbTimesV = (int)newValue;
break;
}
-
+
displayPreview();
}
-
//=================================================================================
// function : ReverseStepU()
// purpose : 'state' not used here
void TransformationGUI_MultiTranslationDlg::ReverseStepU()
{
myStepU = -myStepU;
-
+
int aConstructorId = getConstructorId();
- if ( aConstructorId == 0 )
- GroupPoints->SpinBox_DX->setValue( myStepU );
- else if ( aConstructorId == 1 )
- GroupDimensions->SpinBox_DX1->setValue( myStepU );
-
+ if (aConstructorId == 0)
+ GroupPoints->SpinBox_DX->setValue(myStepU);
+ else if (aConstructorId == 1)
+ GroupDimensions->SpinBox_DX1->setValue(myStepU);
+
displayPreview();
}
-
//=================================================================================
// function : ReverseStepV
// purpose : 'state' not used here
void TransformationGUI_MultiTranslationDlg::ReverseStepV()
{
myStepV = -myStepV;
-
- GroupDimensions->SpinBox_DX2->setValue( myStepV );
-
+
+ GroupDimensions->SpinBox_DX2->setValue(myStepV);
+
displayPreview();
}
-
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr TransformationGUI_MultiTranslationDlg::createOperation()
{
- return myGeomGUI->GetGeomGen()->GetITransformOperations( getStudyId() );
+ return getGeomEngine()->GetITransformOperations(getStudyId());
}
-
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
-bool TransformationGUI_MultiTranslationDlg::isValid( QString& /*msg*/ )
+bool TransformationGUI_MultiTranslationDlg::isValid (QString& /*msg*/)
{
int aConstructorId = getConstructorId();
-
- if ( aConstructorId == 0 )
- return !( myBase->_is_nil() || myVectorU->_is_nil() );
- else if ( aConstructorId == 1 )
- return !( myBase->_is_nil() || myVectorU->_is_nil() || myVectorV->_is_nil() );
- return 0;
+
+ if (aConstructorId == 0)
+ return !(myBase->_is_nil() || myVectorU->_is_nil());
+ else if (aConstructorId == 1)
+ return !(myBase->_is_nil() || myVectorU->_is_nil() || myVectorV->_is_nil());
+ return 0;
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
-bool TransformationGUI_MultiTranslationDlg::execute( ObjectList& objects )
+bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects)
{
bool res = false;
-
+
GEOM::GEOM_Object_var anObj;
- switch ( getConstructorId() ) {
- case 0 :
- if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVectorU ) ) {
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MultiTranslate1D( myBase, myVectorU, myStepU, myNbTimesU );
+ switch (getConstructorId()) {
+ case 0:
+ if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU)) {
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ MultiTranslate1D(myBase, myVectorU, myStepU, myNbTimesU);
res = true;
}
break;
- case 1 :
- if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVectorU ) &&
- !CORBA::is_nil( myVectorV ) ) {
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MultiTranslate2D( myBase, myVectorU, myStepU, myNbTimesU,
- myVectorV, myStepV, myNbTimesV );
+ case 1:
+ if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU) &&
+ !CORBA::is_nil(myVectorV)) {
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ MultiTranslate2D(myBase, myVectorU, myStepU, myNbTimesU,
+ myVectorV, myStepV, myNbTimesV);
res = true;
}
break;
}
-
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
-
+
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+
return res;
}
-
//=================================================================================
// function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection
void TransformationGUI_MultiTranslationDlg::addSubshapesToStudy()
{
QMap<QString, GEOM::GEOM_Object_var> objMap;
-
- switch ( getConstructorId() ) {
+
+ switch (getConstructorId()) {
case 0:
objMap[GroupPoints->LineEdit2->text()] = myVectorU;
break;
objMap[GroupDimensions->LineEdit3->text()] = myVectorV;
break;
}
- addSubshapesToFather( objMap );
+ addSubshapesToFather(objMap);
}
int myNbTimesV;
Standard_Real myStepU;
Standard_Real myStepV;
+
+ // to initialize the first selection field with a selected object on the dialog creation
+ bool myInitial;
DlgRef_2Sel2Spin1Check* GroupPoints;
DlgRef_3Sel4Spin2Check* GroupDimensions;
QPushButton* send = (QPushButton*)sender();
if ( send == GroupPoints->PushButton1 ) {
+ GroupPoints->PushButton1->setDown(true);
myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : TransformationGUI_PositionDlg.cxx
#include <GeometryGUI.h>
#include <GEOMBase.h>
-#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
+// OCCT Includes
#include <TColStd_MapOfInteger.hxx>
#include <GEOMImpl_Types.hxx>
//=================================================================================
// 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'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
TransformationGUI_PositionDlg::TransformationGUI_PositionDlg
-( GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl )
- : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
+(GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
+ myInitial(true)
{
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
- QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_POSITION" ) ) );
- QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_POSITION2" ) ) );
- QPixmap imageselect( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT") ) );
+ QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POSITION")));
+ QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POSITION2")));
+ 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()->RadioButton1->setIcon( image0 );
- mainFrame()->RadioButton2->setIcon( image1 );
- mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
+ mainFrame()->GroupConstructors->setTitle(tr("GEOM_POSITION"));
+ mainFrame()->RadioButton1->setIcon(image0);
+ mainFrame()->RadioButton2->setIcon(image1);
+ mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close();
-
- Group1 = new DlgRef_3Sel3Spin1Check( centralWidget() );
+
+ Group1 = new DlgRef_3Sel3Spin1Check(centralWidget());
Group1->SpinBox1->hide();
Group1->SpinBox2->hide();
Group1->SpinBox3->hide();
Group1->TextLabel4->hide();
Group1->TextLabel5->hide();
Group1->TextLabel6->hide();
- Group1->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
- Group1->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
- Group1->TextLabel2->setText( tr( "GEOM_START_LCS" ) );
- Group1->TextLabel3->setText( tr( "GEOM_END_LCS" ) );
- Group1->PushButton1->setIcon( imageselect );
- Group1->PushButton2->setIcon( imageselect );
- Group1->PushButton3->setIcon( imageselect );
- Group1->CheckBox1->setText( tr( "GEOM_CREATE_COPY" ) );
-
- QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
- layout->setMargin( 0 ); layout->setSpacing( 6 );
- layout->addWidget( Group1 );
-
+ Group1->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
+ Group1->TextLabel1->setText(tr("GEOM_OBJECTS"));
+ Group1->TextLabel2->setText(tr("GEOM_START_LCS"));
+ Group1->TextLabel3->setText(tr("GEOM_END_LCS"));
+ Group1->PushButton1->setIcon(imageselect);
+ Group1->PushButton2->setIcon(imageselect);
+ Group1->PushButton3->setIcon(imageselect);
+ Group1->CheckBox1->setText(tr("GEOM_CREATE_COPY"));
+
+ QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+ layout->setMargin(0); layout->setSpacing(6);
+ 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();
}
-
//=================================================================================
// function : ~TransformationGUI_PositionDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
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()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::Init()
-{
- /* init variables */
- Group1->LineEdit1->setReadOnly( true );
- Group1->LineEdit2->setReadOnly( true );
- Group1->LineEdit3->setReadOnly( true );
-
- myStartLCS = GEOM::GEOM_Object::_nil();
- myEndLCS = GEOM::GEOM_Object::_nil();
-
- // Activate Create a Copy mode
- Group1->CheckBox1->setChecked( true );
- CreateCopyModeChanged( true );
+{
+ // init variables
+ Group1->LineEdit1->setReadOnly(true);
+ Group1->LineEdit2->setReadOnly(true);
+ Group1->LineEdit3->setReadOnly(true);
- mainFrame()->GroupBoxPublish->show();
+ Group1->LineEdit1->setText("");
+ Group1->LineEdit2->setText("");
+ Group1->LineEdit3->setText("");
- /* signals and slots connections */
- connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
- connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+ myStartLCS = myEndLCS = GEOM::GEOM_Object::_nil();
- connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
+ mainFrame()->GroupBoxPublish->show();
- connect( Group1->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( Group1->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( Group1->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ // signals and slots connections
+ connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+ connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
- connect( Group1->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
- connect( Group1->LineEdit2, 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() ) );
+ connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
- initName( tr( "GEOM_POSITION" ) );
+ connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(Group1->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(Group1->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- ConstructorsClicked( 0 );
-}
+ connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
+ connect(Group1->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
+ connect(Group1->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
+
+ connect(Group1->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
+ initName(tr("GEOM_POSITION"));
+ ConstructorsClicked(0);
+}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
-void TransformationGUI_PositionDlg::ConstructorsClicked( int constructorId )
+void TransformationGUI_PositionDlg::ConstructorsClicked (int constructorId)
{
- disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
-
- globalSelection();
- myEditCurrentArgument = Group1->LineEdit1;
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+
Group1->LineEdit2->clear();
Group1->LineEdit3->clear();
myStartLCS = GEOM::GEOM_Object::_nil();
myEndLCS = GEOM::GEOM_Object::_nil();
-
- switch ( constructorId ) {
+
+ switch (constructorId) {
case 0:
- Group1->LineEdit2->hide();
- Group1->TextLabel2->hide();
- Group1->PushButton2->hide();
+ {
+ Group1->LineEdit2->hide();
+ Group1->TextLabel2->hide();
+ Group1->PushButton2->hide();
+
+ Group1->PushButton1->click();
+ }
break;
case 1:
- Group1->LineEdit2->show();
- Group1->TextLabel2->show();
- Group1->PushButton2->show();
+ {
+ Group1->LineEdit2->show();
+ Group1->TextLabel2->show();
+ Group1->PushButton2->show();
+
+ Group1->PushButton1->click();
+ }
break;
}
-
+
qApp->processEvents();
updateGeometry();
- resize( minimumSize() );
+ resize(minimumSize());
- connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT(SelectionIntoArgument() ) );
- SelectionIntoArgument();
+ if (myInitial) {
+ myInitial = false;
+ SelectionIntoArgument();
+ }
+ else {
+ displayPreview();
+ }
}
-
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::ClickOnOk()
{
- if ( ClickOnApply() )
+ if (ClickOnApply())
ClickOnCancel();
}
-
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool TransformationGUI_PositionDlg::ClickOnApply()
{
- if ( !onAccept( Group1->CheckBox1->isChecked() ) )
+ if (!onAccept(Group1->CheckBox1->isChecked()))
return false;
-
+
initName();
- ConstructorsClicked( getConstructorId() );
+ // activate selection and connect selection manager
+ ConstructorsClicked(getConstructorId());
return true;
}
-
//=================================================================================
// function : SelectionIntoArgument()
-// purpose : Called when selection has changed
+// purpose : Called when selection is changed or on dialog initialization or activation
//=================================================================================
void TransformationGUI_PositionDlg::SelectionIntoArgument()
{
- myEditCurrentArgument->setText( "" );
- QString aName;
+ erasePreview();
+ 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();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
+ QString aName;
+
if (myEditCurrentArgument == Group1->LineEdit1) {
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
- if (aNbSel < 1) {
- myObjects.length(0);
- displayPreview();
+ if (aNbSel < 1)
return;
- }
+
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
- if ( !myObjects.length() ) {
- displayPreview();
+ if (!myObjects.length())
return;
- }
+ else
+ myEditCurrentArgument->setText(aName);
}
else if (myEditCurrentArgument == Group1->LineEdit2) {
- myStartLCS = GEOM::GEOM_Object::_nil();
- if (aSelList.Extent() != 1) {
- displayPreview();
+ if (aSelList.Extent() != 1)
return;
- }
+ // nbSel == 1
Standard_Boolean testResult = Standard_False;
myStartLCS = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
- if ( !testResult || CORBA::is_nil( myStartLCS ) ) {
- displayPreview();
+ if (!testResult || CORBA::is_nil(myStartLCS))
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();
- if ( aSelList.Extent() != 1 ) {
- displayPreview();
+ if (aSelList.Extent() != 1)
return;
- }
-
+
Standard_Boolean testResult = Standard_False;
myEndLCS = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
- if ( !testResult || CORBA::is_nil( myEndLCS ) ) {
- displayPreview();
+ if (!testResult || CORBA::is_nil(myEndLCS))
return;
- }
- aName = GEOMBase::GetName( myEndLCS );
- }
- myEditCurrentArgument->setText( aName );
- displayPreview();
-}
+ aName = GEOMBase::GetName(myEndLCS);
+ myEditCurrentArgument->setText(aName);
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void TransformationGUI_PositionDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if ( send == Group1->LineEdit1 || send == Group1->LineEdit2 ||
- send == Group1->LineEdit3 ) {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
+ if (!myEndLCS->_is_nil() && !myObjects.length())
+ Group1->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()
void TransformationGUI_PositionDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
-
- if ( send == Group1->PushButton1 ) {
+
+ 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 ) {
+ else if (send == Group1->PushButton2) {
myEditCurrentArgument = Group1->LineEdit2;
+
TColStd_MapOfInteger aMap;
- aMap.Add( GEOM_PLANE );
- aMap.Add( GEOM_MARKER );
- globalSelection( 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 ) {
+ else if (send == Group1->PushButton3) {
myEditCurrentArgument = Group1->LineEdit3;
+
TColStd_MapOfInteger aMap;
- aMap.Add( GEOM_PLANE );
- aMap.Add( GEOM_MARKER );
- globalSelection( 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();
- 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_PositionDlg::LineEditReturnPressed()
+{
+ QLineEdit* send = (QLineEdit*)sender();
+ if (send == Group1->LineEdit1 ||
+ send == Group1->LineEdit2 ||
+ send == Group1->LineEdit3) {
+ myEditCurrentArgument = send;
+ GEOMBase_Skeleton::LineEditReturnPressed();
+ }
+}
//=================================================================================
// function : ActivateThisDialog()
void TransformationGUI_PositionDlg::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()
// 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();
}
-
//=================================================================================
// function : createOperation
// 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
// purpose :
//=================================================================================
-bool TransformationGUI_PositionDlg::isValid( QString& /*msg*/ )
+bool TransformationGUI_PositionDlg::isValid (QString& /*msg*/)
{
bool res;
- if ( getConstructorId() == 0 )
- res = !( myObjects.length() == 0 || myEndLCS->_is_nil() );
+ if (getConstructorId() == 0)
+ res = !(myObjects.length() == 0 || myEndLCS->_is_nil());
else
- res = !( myObjects.length() == 0 || myStartLCS->_is_nil() || myEndLCS->_is_nil() );
+ res = !(myObjects.length() == 0 || myStartLCS->_is_nil() || myEndLCS->_is_nil());
return res;
}
-
//=================================================================================
// function : execute
// purpose :
//=================================================================================
-bool TransformationGUI_PositionDlg::execute( ObjectList& objects )
+bool TransformationGUI_PositionDlg::execute (ObjectList& objects)
{
bool res = false;
bool toCreateCopy = IsPreview() || Group1->CheckBox1->isChecked();
GEOM::GEOM_Object_var anObj;
-
- switch ( getConstructorId() ) {
+
+ switch (getConstructorId()) {
case 0:
{
- for ( int i = 0; i < myObjects.length(); i++ ) {
- if ( toCreateCopy )
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
- PositionShapeCopy( myObjects[i], myObjects[i], myEndLCS );
- else
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
- PositionShape( myObjects[i], myObjects[i], myEndLCS );
-
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
+ for (int i = 0; i < myObjects.length(); i++) {
+ if (toCreateCopy)
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ PositionShapeCopy(myObjects[i], myObjects[i], myEndLCS);
+ else
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ PositionShape(myObjects[i], myObjects[i], myEndLCS);
+
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
}
res = true;
break;
}
case 1:
{
- for ( int i = 0; i < myObjects.length(); i++ ) {
- if ( toCreateCopy )
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
- PositionShapeCopy( myObjects[i], myStartLCS, myEndLCS );
- else
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
- PositionShape( myObjects[i], myStartLCS, myEndLCS );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
+ for (int i = 0; i < myObjects.length(); i++) {
+ if (toCreateCopy)
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ PositionShapeCopy(myObjects[i], myStartLCS, myEndLCS);
+ else
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ PositionShape(myObjects[i], myStartLCS, myEndLCS);
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
}
res = true;
break;
}
}
-
+
return res;
}
// function : restoreSubShapes
// purpose :
//=================================================================================
-void TransformationGUI_PositionDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy,
- SALOMEDS::SObject_ptr theSObject )
+void TransformationGUI_PositionDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
+ SALOMEDS::SObject_ptr theSObject)
{
- if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) {
+ if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored
- getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(),
- /*theFindMethod=*/GEOM::FSM_Transformed,
- /*theInheritFirstArg=*/true );
+ getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
+ /*theFindMethod=*/GEOM::FSM_Transformed,
+ /*theInheritFirstArg=*/true);
}
}
// function : CreateCopyModeChanged()
// purpose :
//=================================================================================
-void TransformationGUI_PositionDlg::CreateCopyModeChanged( bool isCreateCopy )
+void TransformationGUI_PositionDlg::CreateCopyModeChanged (bool isCreateCopy)
{
- mainFrame()->GroupBoxName->setEnabled( isCreateCopy );
+ mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
}
GEOM::GEOM_Object_var myStartLCS;
GEOM::GEOM_Object_var myEndLCS;
GEOM::ListOfGO myObjects;
+
+ // to initialize the first selection field with a selected object on the dialog creation
+ bool myInitial;
DlgRef_3Sel3Spin1Check* Group1;
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : TransformationGUI_RotationDlg.cxx
#include <GeometryGUI.h>
#include <GEOMBase.h>
-#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
+// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
//=================================================================================
// 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'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
TransformationGUI_RotationDlg::TransformationGUI_RotationDlg
-( GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl )
- : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
+(GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
+ myInitial(true)
{
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
- QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ROTATION" ) ) );
- QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
- QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ROTATION_THREE_POINTS" ) ) );
+ QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_ROTATION")));
+ QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
+ 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()->RadioButton1->setIcon( image0 );
- mainFrame()->RadioButton2->setIcon( image2 );
- mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
+ mainFrame()->GroupConstructors->setTitle(tr("GEOM_ROTATION"));
+ mainFrame()->RadioButton1->setIcon(image0);
+ mainFrame()->RadioButton2->setIcon(image2);
+ mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close();
- GroupPoints = new DlgRef_4Sel1Spin2Check( centralWidget() );
- GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
- GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
- GroupPoints->TextLabel2->setText( tr( "GEOM_AXIS" ) );
- GroupPoints->TextLabel3->setText( tr( "GEOM_ANGLE" ) );
- GroupPoints->TextLabel4->setText( tr( "GEOM_POINT_I" ).arg( 1 ) );
- GroupPoints->TextLabel5->setText( tr( "GEOM_POINT_I" ).arg( 2 ) );
-
- GroupPoints->LineEdit1->setReadOnly( true );
- GroupPoints->LineEdit2->setReadOnly( true );
- GroupPoints->LineEdit4->setReadOnly( true );
- GroupPoints->LineEdit5->setReadOnly( true );
- GroupPoints->PushButton1->setIcon( image1 );
- GroupPoints->PushButton2->setIcon( image1 );
- GroupPoints->PushButton4->setIcon( image1 );
- GroupPoints->PushButton5->setIcon( image1 );
- GroupPoints->CheckButton1->setText( tr( "GEOM_CREATE_COPY" ) );
- GroupPoints->CheckButton2->setText( tr( "GEOM_REVERSE" ) );
-
- QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
- layout->setMargin( 0 ); layout->setSpacing( 6 );
- layout->addWidget( GroupPoints );
-
+ GroupPoints = new DlgRef_4Sel1Spin2Check(centralWidget());
+ GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
+ GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS"));
+ GroupPoints->TextLabel2->setText(tr("GEOM_AXIS"));
+ GroupPoints->TextLabel3->setText(tr("GEOM_ANGLE"));
+ GroupPoints->TextLabel4->setText(tr("GEOM_POINT_I").arg(1));
+ GroupPoints->TextLabel5->setText(tr("GEOM_POINT_I").arg(2));
+
+ GroupPoints->LineEdit1->setReadOnly(true);
+ GroupPoints->LineEdit2->setReadOnly(true);
+ GroupPoints->LineEdit4->setReadOnly(true);
+ GroupPoints->LineEdit5->setReadOnly(true);
+ GroupPoints->PushButton1->setIcon(image1);
+ GroupPoints->PushButton2->setIcon(image1);
+ GroupPoints->PushButton4->setIcon(image1);
+ GroupPoints->PushButton5->setIcon(image1);
+ GroupPoints->CheckButton1->setText(tr("GEOM_CREATE_COPY"));
+ GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE"));
+
+ QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+ layout->setMargin(0); layout->setSpacing(6);
+ layout->addWidget(GroupPoints);
/***************************************************************/
- double anAngle = 0;
- double SpecificStep = 5;
- /* 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
- GroupPoints->CheckButton1->setChecked( 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 ) ) );
+ setHelpFileName("rotation_operation_page.html");
- 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" );
+ // Activate Create a Copy mode
+ GroupPoints->CheckButton1->setChecked(true);
+ CreateCopyModeChanged(true);
Init();
}
-
//=================================================================================
// function : ~TransformationGUI_RotationDlg()
// purpose : Destroys the object and frees any allocated resources
// no need to delete child widgets, Qt does it all for us
}
-
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void TransformationGUI_RotationDlg::Init()
{
- /* init variables */
- myEditCurrentArgument = GroupPoints->LineEdit1;
- GroupPoints->LineEdit2->clear();
-
+ double anAngle = 0;
+ double SpecificStep = 5;
+
+ // 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();
-
- initName( tr( "GEOM_ROTATION" ) );
- ConstructorsClicked( 0 );
+
+ 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()));
+
+ initName(tr("GEOM_ROTATION"));
+
+ ConstructorsClicked(0);
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
-void TransformationGUI_RotationDlg::ConstructorsClicked( int constructorId )
+void TransformationGUI_RotationDlg::ConstructorsClicked (int constructorId)
{
- disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
-
- myEditCurrentArgument = GroupPoints->LineEdit1;
- globalSelection();
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- switch ( constructorId ) {
- case 0: /* rotation an object angle and axis */
- GroupPoints->ShowRows( 2, 3, false );
- GroupPoints->TextLabel2->setText( tr( "GEOM_AXIS" ) );
- GroupPoints->LineEdit2->clear();
- GroupPoints->ShowRows( 4, 4, true );
- myAxis = GEOM::GEOM_Object::_nil();
+ switch (constructorId) {
+ case 0: // rotation an object angle and axis
+ {
+ GroupPoints->ShowRows(2, 3, false);
+ GroupPoints->TextLabel2->setText(tr("GEOM_AXIS"));
+ GroupPoints->LineEdit2->clear();
+ GroupPoints->ShowRows(4, 4, true);
+
+ myAxis = GEOM::GEOM_Object::_nil();
+
+ GroupPoints->PushButton1->click();
+ }
break;
- case 1: /* rotation an object by 3 points */
- GroupPoints->ShowRows( 4, 4, false );
- GroupPoints->ShowRows( 2, 3, true );
- GroupPoints->TextLabel2->setText( tr( "GEOM_CENTRAL_POINT" ) );
- GroupPoints->TextLabel4->setText( tr( "GEOM_POINT_I" ).arg( 1 ) );
- GroupPoints->TextLabel5->setText( tr( "GEOM_POINT_I" ).arg( 2 ) );
- GroupPoints->LineEdit2->clear();
- GroupPoints->LineEdit4->clear();
- GroupPoints->LineEdit5->clear();
- myCentPoint = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
+ case 1: // rotation an object by 3 points
+ {
+ GroupPoints->ShowRows(4, 4, false);
+ GroupPoints->ShowRows(2, 3, true);
+ GroupPoints->TextLabel2->setText(tr("GEOM_CENTRAL_POINT"));
+ GroupPoints->TextLabel4->setText(tr("GEOM_POINT_I").arg(1));
+ GroupPoints->TextLabel5->setText(tr("GEOM_POINT_I").arg(2));
+
+ GroupPoints->LineEdit2->clear();
+ GroupPoints->LineEdit4->clear();
+ GroupPoints->LineEdit5->clear();
+
+ myCentPoint = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
+
+ GroupPoints->PushButton1->click();
+ }
break;
- }
-
+ }
+
qApp->processEvents();
updateGeometry();
- resize( minimumSize() );
+ resize(minimumSize());
- myEditCurrentArgument->setFocus();
- connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ if (myInitial) {
+ myInitial = false;
+ SelectionIntoArgument();
+ }
+ else {
+ displayPreview();
+ }
}
//=================================================================================
//=================================================================================
void TransformationGUI_RotationDlg::ClickOnOk()
{
- if ( ClickOnApply() )
+ if (ClickOnApply())
ClickOnCancel();
}
-
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool TransformationGUI_RotationDlg::ClickOnApply()
{
- if ( !onAccept( GroupPoints->CheckButton1->isChecked() ) )
+ if (!onAccept(GroupPoints->CheckButton1->isChecked()))
return false;
-
+
initName();
- ConstructorsClicked( getConstructorId() );
+ // activate selection and connect selection manager
+ ConstructorsClicked(getConstructorId());
return true;
}
-
//=================================================================================
// 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()
{
- myEditCurrentArgument->setText( "" );
- QString aName;
-
+ erasePreview();
+ 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();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
+ QString aName;
+
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
- if (aNbSel < 1) {
- myObjects.length(0);
+ if (aNbSel < 1)
return;
- }
+
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
if (!myObjects.length())
return;
+ else
+ myEditCurrentArgument->setText(aName);
}
else {
- 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();
+ if (aSelList.Extent() != 1)
return;
- }
+ // nbSel == 1
Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
- if ( !testResult || CORBA::is_nil( aSelectedObject ) )
+
+ if (!testResult || CORBA::is_nil(aSelectedObject))
return;
-
- aName = GEOMBase::GetName( aSelectedObject );
+
+ aName = GEOMBase::GetName(aSelectedObject);
+
+ // Get Selected object if selected subshape
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;
- if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0 )
- aNeedType = TopAbs_EDGE;
-
+ if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0)
+ aNeedType = TopAbs_EDGE;
+
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap);
- if ( aMap.Extent() == 1 ) {
- int anIndex = aMap( 1 );
- if ( aNeedType == TopAbs_EDGE )
- aName += QString( ":edge_%1" ).arg( anIndex );
- else
- aName += QString( ":vertex_%1" ).arg( anIndex );
-
- //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 =
- getGeomEngine()->GetIShapesOperations( getStudyId() );
- aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
- }
- else {
- aSelectedObject = aFindedObject; // get Object from study
- }
+ if (aMap.Extent() == 1)
+ {
+ int anIndex = aMap(1);
+ if (aNeedType == TopAbs_EDGE)
+ aName += QString(":edge_%1").arg(anIndex);
+ else
+ aName += QString(":vertex_%1").arg(anIndex);
+
+ //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 =
+ getGeomEngine()->GetIShapesOperations(getStudyId());
+ aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
+ }
+ else {
+ aSelectedObject = aFindedObject; // get Object from study
+ }
}
- else {
- if ( aShape.ShapeType() != aNeedType ) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
+ else // Global Selection
+ {
+ if (aShape.ShapeType() != aNeedType) {
+ aSelectedObject = GEOM::GEOM_Object::_nil();
+ aName = "";
+ }
}
}
-
- if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0 )
+
+ myEditCurrentArgument->setText(aName);
+
+ if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0) {
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;
- else if ( myEditCurrentArgument == GroupPoints->LineEdit4 )
+ if (!myCentPoint->_is_nil() && myPoint1->_is_nil())
+ GroupPoints->PushButton4->click();
+ }
+ else if (myEditCurrentArgument == GroupPoints->LineEdit4) {
myPoint1 = aSelectedObject;
- else if ( myEditCurrentArgument == GroupPoints->LineEdit5 )
+ if (!myPoint1->_is_nil() && myPoint2->_is_nil())
+ GroupPoints->PushButton5->click();
+ }
+ else if (myEditCurrentArgument == GroupPoints->LineEdit5) {
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();
}
-
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
void TransformationGUI_RotationDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
+
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection();
-
- if ( send == GroupPoints->PushButton1 ) {
+
+ if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1;
+
+ GroupPoints->PushButton2->setDown(false);
+ GroupPoints->LineEdit2->setEnabled(false);
}
- else if ( send == GroupPoints->PushButton2 ) {
+ else if (send == GroupPoints->PushButton2) {
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
- 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;
- 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;
- 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();
- 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_RotationDlg::LineEditReturnPressed()
-{
+{
QLineEdit* send = (QLineEdit*)sender();
- if ( send == GroupPoints->LineEdit1 ||
- send == GroupPoints->LineEdit2 ) {
+ if (send == GroupPoints->LineEdit1 ||
+ send == GroupPoints->LineEdit2) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
void TransformationGUI_RotationDlg::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()
// purpose :
//=================================================================================
-void TransformationGUI_RotationDlg::enterEvent( QEvent* )
+void TransformationGUI_RotationDlg::enterEvent (QEvent*)
{
- if ( !mainFrame()->GroupConstructors->isEnabled() )
+ if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog();
}
-
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
displayPreview();
}
-
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr TransformationGUI_RotationDlg::createOperation()
{
- return getGeomEngine()->GetITransformOperations( getStudyId() );
+ return getGeomEngine()->GetITransformOperations(getStudyId());
}
-
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
-bool TransformationGUI_RotationDlg::isValid( QString& /*msg*/ )
+bool TransformationGUI_RotationDlg::isValid (QString& /*msg*/)
{
- switch ( getConstructorId() ) {
- case 0:
- return !( myObjects.length() == 0 || myAxis->_is_nil() );
+ if (myObjects.length() < 1) return false;
+
+ switch (getConstructorId()) {
+ case 0:
+ return !(myAxis->_is_nil());
break;
- case 1:
- return !( myObjects.length() == 0 || myCentPoint->_is_nil() || myPoint1->_is_nil() || myPoint2->_is_nil() );
+ case 1:
+ return !(myCentPoint->_is_nil() || myPoint1->_is_nil() || myPoint2->_is_nil());
+ break;
+ default:
break;
- default:
- return false;
}
+ return false;
}
-
//=================================================================================
// function : execute
// purpose :
//=================================================================================
-bool TransformationGUI_RotationDlg::execute( ObjectList& objects )
+bool TransformationGUI_RotationDlg::execute (ObjectList& objects)
{
bool res = false;
bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
GEOM::GEOM_Object_var anObj;
-
- switch ( getConstructorId() ) {
- case 0 :
+
+ switch (getConstructorId()) {
+ case 0:
{
- if ( toCreateCopy ) {
- for ( int i = 0; i < myObjects.length(); i++ ) {
- myCurrObject = myObjects[i];
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->RotateCopy( myObjects[i], myAxis, GetAngle() * PI180 );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
- }
+ if (toCreateCopy) {
+ for (int i = 0; i < myObjects.length(); i++) {
+ myCurrObject = myObjects[i];
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ RotateCopy(myObjects[i], myAxis, GetAngle() * PI180);
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+ }
}
else {
- for ( int i = 0; i < myObjects.length(); i++ ) {
- myCurrObject = myObjects[i];
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->Rotate( myObjects[i], myAxis, GetAngle() * PI180 );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
- }
+ for (int i = 0; i < myObjects.length(); i++) {
+ myCurrObject = myObjects[i];
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ Rotate(myObjects[i], myAxis, GetAngle() * PI180);
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+ }
}
res = true;
break;
}
- case 1 :
+ case 1:
{
- if ( toCreateCopy ) {
- for ( int i = 0; i < myObjects.length(); i++ ) {
- myCurrObject = myObjects[i];
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->RotateThreePointsCopy( myObjects[i], myCentPoint, myPoint1, myPoint2 );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
- }
+ if (toCreateCopy) {
+ for (int i = 0; i < myObjects.length(); i++) {
+ myCurrObject = myObjects[i];
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ RotateThreePointsCopy(myObjects[i], myCentPoint, myPoint1, myPoint2);
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+ }
}
else {
- for ( int i = 0; i < myObjects.length(); i++ ) {
- myCurrObject = myObjects[i];
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->RotateThreePoints( myObjects[i], myCentPoint, myPoint1, myPoint2 );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
- }
+ for (int i = 0; i < myObjects.length(); i++) {
+ myCurrObject = myObjects[i];
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ RotateThreePoints(myObjects[i], myCentPoint, myPoint1, myPoint2);
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+ }
}
res = true;
break;
}
}
-
+
return res;
}
// function : restoreSubShapes
// purpose :
//=================================================================================
-void TransformationGUI_RotationDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy,
- SALOMEDS::SObject_ptr theSObject )
+void TransformationGUI_RotationDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
+ 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
// because the rotation operation place its arguments in the data structure in another order,
// and we need to point the first argument directly
GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
anArgs->length(1);
anArgs[0] = myCurrObject;
- getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, anArgs,
- /*theFindMethod=*/GEOM::FSM_Transformed,
- /*theInheritFirstArg=*/true );
+ getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
+ /*theFindMethod=*/GEOM::FSM_Transformed,
+ /*theInheritFirstArg=*/true);
}
}
// function : CreateCopyModeChanged()
// purpose :
//=================================================================================
-void TransformationGUI_RotationDlg::CreateCopyModeChanged( bool isCreateCopy )
+void TransformationGUI_RotationDlg::CreateCopyModeChanged (bool isCreateCopy)
{
- mainFrame()->GroupBoxName->setEnabled( isCreateCopy );
+ mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
}
//=================================================================================
void TransformationGUI_RotationDlg::onReverse()
{
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
//=================================================================================
void TransformationGUI_RotationDlg::addSubshapesToStudy()
{
bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
- if ( toCreateCopy ) {
+ if (toCreateCopy) {
QMap<QString, GEOM::GEOM_Object_var> objMap;
- switch ( getConstructorId() ) {
+ switch (getConstructorId()) {
case 0:
objMap[GroupPoints->LineEdit2->text()] = myAxis;
break;
objMap[GroupPoints->LineEdit5->text()] = myPoint2;
break;
}
- addSubshapesToFather( objMap );
+ addSubshapesToFather(objMap);
}
}
GEOM::ListOfGO myObjects;
GEOM::GEOM_Object_var myCurrObject;
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;
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : TransformationGUI_ScaleDlg.cxx
#include <GEOMBase.h>
#include <QtxDoubleSpinBox.h>
-#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
+// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
//=================================================================================
// 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'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
-TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
- bool modal, Qt::WindowFlags fl )
- : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
+TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
+ bool modal, Qt::WindowFlags fl)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
+ myInitial(true)
{
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
- QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_SCALE" ) ) );
- QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_SCALE_ALONG_AXES" ) ) );
- QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
+ QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_SCALE")));
+ QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_SCALE_ALONG_AXES")));
+ QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
- setWindowTitle( tr( "GEOM_SCALE_TITLE" ) );
+ setWindowTitle(tr("GEOM_SCALE_TITLE"));
// Constructors
- mainFrame()->GroupConstructors->setTitle( tr( "GEOM_SCALE" ) );
- mainFrame()->RadioButton1->setIcon( image1 );
- mainFrame()->RadioButton2->setIcon( image2 );
- mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
+ mainFrame()->GroupConstructors->setTitle(tr("GEOM_SCALE"));
+ mainFrame()->RadioButton1->setIcon(image1);
+ mainFrame()->RadioButton2->setIcon(image2);
+ mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close();
// Own widgets
- GroupBox1 = new QGroupBox( tr( "GEOM_ARGUMENTS" ), this );
- QGridLayout* OwnLayout = new QGridLayout( GroupBox1 );
- OwnLayout->setSpacing( 6 );
- OwnLayout->setMargin( 11 );
-
- TextLabel1 = new QLabel( tr( "GEOM_OBJECTS" ), GroupBox1 );
- PushButton1 = new QPushButton( GroupBox1 );
- PushButton1->setIcon( image3 );
- PushButton1->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
- LineEdit1 = new QLineEdit( GroupBox1 );
- LineEdit1->setReadOnly( true );
- LineEdit1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
- TextLabel2 = new QLabel( tr( "GEOM_CENTRAL_POINT" ), GroupBox1 );
- PushButton2 = new QPushButton( GroupBox1 );
- PushButton2->setIcon( image3 );
- PushButton2->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
- LineEdit2 = new QLineEdit( GroupBox1 );
- LineEdit2->setReadOnly( true );
- LineEdit2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
- TextLabel3 = new QLabel( tr( "GEOM_SCALE_FACTOR" ), GroupBox1 );
- SpinBox_FX = new QtxDoubleSpinBox( GroupBox1 );
-
- TextLabel4 = new QLabel( tr( "GEOM_SCALE_FACTOR_Y" ), GroupBox1 );
- SpinBox_FY = new QtxDoubleSpinBox( GroupBox1 );
-
- TextLabel5 = new QLabel( tr( "GEOM_SCALE_FACTOR_Z" ), GroupBox1 );
- SpinBox_FZ = new QtxDoubleSpinBox( GroupBox1 );
-
- CheckBoxCopy = new QCheckBox( tr( "GEOM_CREATE_COPY" ), GroupBox1 );
- CheckBoxCopy->setChecked( true );
+ GroupBox1 = new QGroupBox(tr("GEOM_ARGUMENTS"), this);
+ QGridLayout* OwnLayout = new QGridLayout(GroupBox1);
+ OwnLayout->setSpacing(6);
+ OwnLayout->setMargin(11);
+
+ TextLabel1 = new QLabel(tr("GEOM_OBJECTS"), GroupBox1);
+ PushButton1 = new QPushButton(GroupBox1);
+ PushButton1->setIcon(image3);
+ PushButton1->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
+ LineEdit1 = new QLineEdit(GroupBox1);
+ LineEdit1->setReadOnly(true);
+ LineEdit1->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
+
+ TextLabel2 = new QLabel(tr("GEOM_CENTRAL_POINT"), GroupBox1);
+ PushButton2 = new QPushButton(GroupBox1);
+ PushButton2->setIcon(image3);
+ PushButton2->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
+ LineEdit2 = new QLineEdit(GroupBox1);
+ LineEdit2->setReadOnly(true);
+ LineEdit2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
+
+ TextLabel3 = new QLabel(tr("GEOM_SCALE_FACTOR"), GroupBox1);
+ SpinBox_FX = new QtxDoubleSpinBox(GroupBox1);
+
+ TextLabel4 = new QLabel(tr("GEOM_SCALE_FACTOR_Y"), GroupBox1);
+ SpinBox_FY = new QtxDoubleSpinBox(GroupBox1);
+
+ TextLabel5 = new QLabel(tr("GEOM_SCALE_FACTOR_Z"), GroupBox1);
+ SpinBox_FZ = new QtxDoubleSpinBox(GroupBox1);
+
+ CheckBoxCopy = new QCheckBox(tr("GEOM_CREATE_COPY"), GroupBox1);
+ CheckBoxCopy->setChecked(true);
// Layouting
- OwnLayout->addWidget( TextLabel1, 0, 0 );
- OwnLayout->addWidget( PushButton1, 0, 1 );
- OwnLayout->addWidget( LineEdit1, 0, 2, 1, 2 );
- OwnLayout->addWidget( TextLabel2, 1, 0 );
- OwnLayout->addWidget( PushButton2, 1, 1 );
- OwnLayout->addWidget( LineEdit2, 1, 2, 1, 2 );
- OwnLayout->addWidget( TextLabel3, 2, 0 );
- OwnLayout->addWidget( SpinBox_FX, 2, 2 );
- OwnLayout->addWidget( TextLabel4, 3, 0 );
- OwnLayout->addWidget( SpinBox_FY, 3, 2 );
- OwnLayout->addWidget( TextLabel5, 4, 0 );
- OwnLayout->addWidget( SpinBox_FZ, 4, 2 );
- OwnLayout->addWidget( CheckBoxCopy, 5, 0, 1, 4 );
-
- QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
- layout->setMargin( 0 ); layout->setSpacing( 6 );
- layout->addWidget( GroupBox1 );
-
- // Min, max, step and decimals for spin boxes & initial values
- 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 );
+ OwnLayout->addWidget(TextLabel1, 0, 0);
+ OwnLayout->addWidget(PushButton1, 0, 1);
+ OwnLayout->addWidget(LineEdit1, 0, 2, 1, 2);
+ OwnLayout->addWidget(TextLabel2, 1, 0);
+ OwnLayout->addWidget(PushButton2, 1, 1);
+ OwnLayout->addWidget(LineEdit2, 1, 2, 1, 2);
+ OwnLayout->addWidget(TextLabel3, 2, 0);
+ OwnLayout->addWidget(SpinBox_FX, 2, 2);
+ OwnLayout->addWidget(TextLabel4, 3, 0);
+ OwnLayout->addWidget(SpinBox_FY, 3, 2);
+ OwnLayout->addWidget(TextLabel5, 4, 0);
+ OwnLayout->addWidget(SpinBox_FZ, 4, 2);
+ OwnLayout->addWidget(CheckBoxCopy, 5, 0, 1, 4);
+
+ QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+ layout->setMargin(0); layout->setSpacing(6);
+ layout->addWidget(GroupBox1);
+
+ setHelpFileName("scale_operation_page.html");
// Modification of an existing object by offset is not allowed
CheckBoxCopy->hide();
-
+
// Activate Create a Copy mode
- CreateCopyModeChanged( true );
+ CreateCopyModeChanged(true);
// Allowed inheritance of children and visual properties by the scaling result
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();
}
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
TransformationGUI_ScaleDlg::~TransformationGUI_ScaleDlg()
-{
+{
}
//=================================================================================
//=================================================================================
void TransformationGUI_ScaleDlg::Init()
{
- myEditCurrentArgument = LineEdit1;
- LineEdit2->clear();
-
+ // Min, max, step and decimals for spin boxes & initial values
+ 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);
+
+ // init variables
+ LineEdit1->setText("");
+ LineEdit2->setText("");
+
myPoint = GEOM::GEOM_Object::_nil();
-
- initName( tr( "GEOM_SCALE" ) );
- 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(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()
// 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 )
- {
- case 0: /* translation an object by dx, dy, dz */
- TextLabel3->setText( tr( "GEOM_SCALE_FACTOR" ) );
+ switch (constructorId) {
+ case 0: // translation an object by dx, dy, dz
+ TextLabel3->setText(tr("GEOM_SCALE_FACTOR"));
TextLabel4->hide();
TextLabel5->hide();
SpinBox_FY->hide();
SpinBox_FZ->hide();
+
+ PushButton1->click();
break;
- case 1: /* translation an object by 2 points */
- TextLabel3->setText( tr( "GEOM_SCALE_FACTOR_X" ) );
+ case 1: // translation an object by 2 points
+ TextLabel3->setText(tr("GEOM_SCALE_FACTOR_X"));
TextLabel4->show();
TextLabel5->show();
SpinBox_FY->show();
SpinBox_FZ->show();
+
+ PushButton1->click();
break;
default:
break;
qApp->processEvents();
updateGeometry();
- resize( minimumSize() );
+ resize(minimumSize());
- displayPreview();
+ if (myInitial) {
+ myInitial = false;
+ SelectionIntoArgument();
+ }
+ else {
+ displayPreview();
+ }
}
//=================================================================================
//=================================================================================
void TransformationGUI_ScaleDlg::ClickOnOk()
{
- if ( ClickOnApply() )
+ if (ClickOnApply())
ClickOnCancel();
}
//=================================================================================
bool TransformationGUI_ScaleDlg::ClickOnApply()
{
- if ( !onAccept( CheckBoxCopy->isChecked() ) )
+ if (!onAccept(CheckBoxCopy->isChecked()))
return false;
- initName( tr( "GEOM_SCALE" ) );
+ initName(tr("GEOM_SCALE"));
+ // activate selection and connect selection manager
+ ConstructorsClicked(getConstructorId());
return true;
}
//=================================================================================
// 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()
{
erasePreview();
- myEditCurrentArgument->setText( "" );
- QString aName;
+ myEditCurrentArgument->setText("");
+
+ if (myEditCurrentArgument == LineEdit1)
+ myObjects.length(0);
+ else if (myEditCurrentArgument == LineEdit2)
+ myPoint = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
+ QString aName;
+
if (myEditCurrentArgument == LineEdit1)
{
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
if (aNbSel < 1)
- {
- myObjects.length(0);
return;
- }
+
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
if (!myObjects.length())
return;
+ else
+ myEditCurrentArgument->setText(aName);
}
else if (myEditCurrentArgument == LineEdit2)
{
aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1)
{
- int anIndex = aMap( 1 );
- aName += QString( ":vertex_%1" ).arg( anIndex );
+ int anIndex = aMap(1);
+ aName += QString(":vertex_%1").arg(anIndex);
//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 =
- getGeomEngine()->GetIShapesOperations( getStudyId() );
- aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
- aSelMgr->clearSelected();
+ getGeomEngine()->GetIShapesOperations(getStudyId());
+ aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
}
else
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();
aName = "";
}
}
myPoint = aSelectedObject;
+ myEditCurrentArgument->setText(aName);
+
+ if (!myPoint->_is_nil() && !myObjects.length())
+ PushButton1->click();
}
- myEditCurrentArgument->setText(aName);
- displayPreview();
-}
+ // clear selection
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myGeomGUI->getApp()->selectionMgr()->clearSelected();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void TransformationGUI_ScaleDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if ( send == LineEdit1 || send == LineEdit2 )
- {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
+ displayPreview();
}
//=================================================================================
void TransformationGUI_ScaleDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
+
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection();
-
- if ( send == PushButton1 ) {
+
+ if (send == PushButton1) {
myEditCurrentArgument = LineEdit1;
+
+ PushButton2->setDown(false);
+ LineEdit2->setEnabled(false);
}
- else if ( send == PushButton2 ) {
+ 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();
- 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_ScaleDlg::LineEditReturnPressed()
+{
+ QLineEdit* send = (QLineEdit*)sender();
+ if (send == LineEdit1 || send == LineEdit2)
+ {
+ myEditCurrentArgument = send;
+ GEOMBase_Skeleton::LineEditReturnPressed();
+ }
}
//=================================================================================
void TransformationGUI_ScaleDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
- connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
- this, SLOT( SelectionIntoArgument() ) );
- globalSelection();
- myEditCurrentArgument->setFocus();
- if ( myEditCurrentArgument == LineEdit2 ) {
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
- }
+
+ // reinit, because some selected objects could be removed
+ Init();
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
-void TransformationGUI_ScaleDlg::enterEvent( QEvent* )
+void TransformationGUI_ScaleDlg::enterEvent (QEvent*)
{
- if ( !mainFrame()->GroupConstructors->isEnabled() )
+ if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog();
}
// function : SetDoubleSpinBoxStep()
// purpose : Double spin box management
//=================================================================================
-void TransformationGUI_ScaleDlg::SetDoubleSpinBoxStep( double step )
+void TransformationGUI_ScaleDlg::SetDoubleSpinBoxStep(double step)
{
- SpinBox_FX->setSingleStep( step );
- SpinBox_FY->setSingleStep( step );
- SpinBox_FZ->setSingleStep( step );
+ SpinBox_FX->setSingleStep(step);
+ SpinBox_FY->setSingleStep(step);
+ SpinBox_FZ->setSingleStep(step);
}
//=================================================================================
//=================================================================================
GEOM::GEOM_IOperations_ptr TransformationGUI_ScaleDlg::createOperation()
{
- return myGeomGUI->GetGeomGen()->GetITransformOperations( getStudyId() );
+ return getGeomEngine()->GetITransformOperations(getStudyId());
}
//=================================================================================
// function : isValid
// 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()
- if ( getConstructorId() == 0 )
+ if (getConstructorId() == 0)
return true;
- if ( fabs( SpinBox_FY->value() ) > 0.00001 &&
- fabs( SpinBox_FZ->value() ) > 0.00001 )
+ if (fabs(SpinBox_FY->value()) > 0.00001 &&
+ fabs(SpinBox_FZ->value()) > 0.00001)
return true;
}
return false;
// function : execute
// purpose :
//=================================================================================
-bool TransformationGUI_ScaleDlg::execute( ObjectList& objects )
+bool TransformationGUI_ScaleDlg::execute (ObjectList& objects)
{
bool toCreateCopy = IsPreview() || CheckBoxCopy->isChecked();
GEOM::GEOM_Object_var anObj;
- switch ( getConstructorId() )
+ switch (getConstructorId())
{
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() )->
- ScaleShapeCopy( myObjects[i], myPoint, SpinBox_FX->value() );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ ScaleShapeCopy(myObjects[i], myPoint, SpinBox_FX->value());
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
}
}
else
{
- for ( int i = 0; i < myObjects.length(); i++ )
+ for (int i = 0; i < myObjects.length(); i++)
{
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
- ScaleShape( myObjects[i], myPoint, SpinBox_FX->value() );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ ScaleShape(myObjects[i], myPoint, SpinBox_FX->value());
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
}
}
}
break;
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() )->
- ScaleShapeAlongAxesCopy( myObjects[i], myPoint, SpinBox_FX->value(),
- SpinBox_FY->value(), SpinBox_FZ->value() );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ ScaleShapeAlongAxesCopy(myObjects[i], myPoint, SpinBox_FX->value(),
+ SpinBox_FY->value(), SpinBox_FZ->value());
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
}
}
else
{
- for ( int i = 0; i < myObjects.length(); i++ )
+ for (int i = 0; i < myObjects.length(); i++)
{
- anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
- ScaleShapeAlongAxes( myObjects[i], myPoint, SpinBox_FX->value(),
- SpinBox_FY->value(), SpinBox_FZ->value() );
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
+ anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
+ ScaleShapeAlongAxes(myObjects[i], myPoint, SpinBox_FX->value(),
+ SpinBox_FY->value(), SpinBox_FZ->value());
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
}
}
}
// function : restoreSubShapes
// purpose :
//=================================================================================
-void TransformationGUI_ScaleDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy,
- SALOMEDS::SObject_ptr theSObject )
+void TransformationGUI_ScaleDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
+ SALOMEDS::SObject_ptr theSObject)
{
- if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) {
+ if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored
- getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(),
- /*theFindMethod=*/GEOM::FSM_Transformed,
- /*theInheritFirstArg=*/true );
+ getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
+ /*theFindMethod=*/GEOM::FSM_Transformed,
+ /*theInheritFirstArg=*/true);
}
}
// function : CreateCopyModeChanged()
// purpose :
//=================================================================================
-void TransformationGUI_ScaleDlg::CreateCopyModeChanged( bool isCreateCopy )
+void TransformationGUI_ScaleDlg::CreateCopyModeChanged (bool isCreateCopy)
{
- mainFrame()->GroupBoxName->setEnabled( isCreateCopy );
+ mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
}
//=================================================================================
void TransformationGUI_ScaleDlg::addSubshapesToStudy()
{
bool toCreateCopy = IsPreview() || CheckBoxCopy->isChecked();
- if ( toCreateCopy )
+ if (toCreateCopy)
{
- if ( !myPoint->_is_nil() )
+ if (!myPoint->_is_nil())
{
QMap<QString, GEOM::GEOM_Object_var> objMap;
objMap[LineEdit2->text()] = myPoint;
- addSubshapesToFather( objMap );
+ addSubshapesToFather(objMap);
}
}
}
private:
GEOM::ListOfGO myObjects;
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;
QLabel* TextLabel1;
GroupPoints->CheckBox1->hide();
GroupPoints->PushButton1->click();
- break;
}
+ break;
case 1: // translation an object by 2 points
{
GroupPoints->ShowRows(3, 5, false);
myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
GroupPoints->PushButton1->click();
- break;
}
+ break;
case 2: // translation an object by vector
{
GroupPoints->ShowRows(0, 1, true);
ActivateDistanceChanged(GroupPoints->CheckBox1->isChecked());
GroupPoints->PushButton1->click();
- break;
}
+ break;
}
qApp->processEvents();