X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FBlocksGUI%2FBlocksGUI_TrsfDlg.cxx;h=cf6c2afefcfa92c6416b09471937c59299fb6e4e;hb=a86e82800026fb6762a41d2821d93db89188f8f7;hp=a431b4129c40f4a6c82fef43e14f97ccec247fe0;hpb=e180c20f73ffa96c2d039106f2a2a868c8bc0df1;p=modules%2Fgeom.git diff --git a/src/BlocksGUI/BlocksGUI_TrsfDlg.cxx b/src/BlocksGUI/BlocksGUI_TrsfDlg.cxx index a431b4129..cf6c2afef 100644 --- a/src/BlocksGUI/BlocksGUI_TrsfDlg.cxx +++ b/src/BlocksGUI/BlocksGUI_TrsfDlg.cxx @@ -1,6 +1,7 @@ -// GEOM GEOMGUI : GUI for Geometry component +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 CEA +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -16,110 +17,81 @@ // 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.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// GEOM GEOMGUI : GUI for Geometry component +// File : BlocksGUI_TrsfDlg.cxx +// Author : Julia DOROVSKIKH, Open CASCADE S.A.S. (julia.dorovskikh@opencascade.com) // -// -// File : BlocksGUI_TrsfDlg.cxx -// Author : Julia DOROVSKIKH -// Module : GEOM -// $Header$ - #include "BlocksGUI_TrsfDlg.h" -#include "DlgRef_SpinBox.h" - -#include "SUIT_Session.h" -#include "SalomeApp_Application.h" -#include "LightApp_SelectionMgr.h" -#include "OCCViewer_ViewModel.h" - +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// OCCT Includes #include -#include - //================================================================================= // class : BlocksGUI_TrsfDlg() // purpose : Constructs a BlocksGUI_TrsfDlg which is a child of 'parent'. //================================================================================= -BlocksGUI_TrsfDlg::BlocksGUI_TrsfDlg (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal) - : GEOMBase_Skeleton(theGeometryGUI, parent, "TrsfDlg", modal, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +BlocksGUI_TrsfDlg::BlocksGUI_TrsfDlg (GeometryGUI* theGeometryGUI, QWidget* parent) + : GEOMBase_Skeleton(theGeometryGUI, parent), + myInitial(true) { SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_BLOCK_MULTITRSF_SIMPLE"))); QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_BLOCK_MULTITRSF_DOUBLE"))); QPixmap imageS (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); - setCaption(tr("GEOM_BLOCK_MULTITRSF_TITLE")); + setWindowTitle(tr("GEOM_BLOCK_MULTITRSF_TITLE")); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_BLOCK_MULTITRSF")); + mainFrame()->GroupConstructors->setTitle(tr("GEOM_BLOCK_MULTITRSF")); - RadioButton1->setPixmap(image1); - RadioButton2->setPixmap(image2); - RadioButton3->close(TRUE); + mainFrame()->RadioButton1->setIcon(image1); + mainFrame()->RadioButton2->setIcon(image2); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton3->close(); // Create first group - myGrp1 = new QGroupBox(1, Qt::Horizontal, tr("GEOM_BLOCK_MULTITRSF_SIMPLE"), this); - - QGroupBox* aSelGrp1 = new QGroupBox(3, Qt::Horizontal, myGrp1); - aSelGrp1->setFrameStyle(QFrame::NoFrame); - aSelGrp1->setInsideMargin(0); + myGrp1 = new QGroupBox(tr("GEOM_BLOCK_MULTITRSF_SIMPLE"), centralWidget()); - createSelWg(tr("GEOM_MAIN_OBJECT"), imageS, aSelGrp1, MainObj1); - createSelWg(tr("FACE_1"), imageS, aSelGrp1, Face1); - createSelWg(tr("FACE_2"), imageS, aSelGrp1, Face2); - - QGroupBox* aSpinGrp1 = new QGroupBox(1, Qt::Vertical, myGrp1); - aSpinGrp1->setFrameStyle(QFrame::NoFrame); - aSpinGrp1->setInsideMargin(0); - - new QLabel(tr("GEOM_NB_TIMES"), aSpinGrp1); - mySpinBox[SpinBox1] = new DlgRef_SpinBox(aSpinGrp1); + createSelWg(tr("GEOM_MAIN_OBJECT"), imageS, myGrp1, MainObj1); + createSelWg(tr("FACE_1"), imageS, myGrp1, Face1); + createSelWg(tr("FACE_2"), imageS, myGrp1, Face2); + createSpinWg(tr("GEOM_NB_TIMES"), myGrp1, SpinBox1); // Create second group - myGrp2 = new QGroupBox(1, Qt::Horizontal, tr("GEOM_BLOCK_MULTITRSF_DOUBLE"), this); - - // U trsf - QGroupBox* aSelGrp2U = new QGroupBox(3, Qt::Horizontal, myGrp2); - aSelGrp2U->setFrameStyle(QFrame::NoFrame); - aSelGrp2U->setInsideMargin(0); - - createSelWg(tr("GEOM_MAIN_OBJECT"), imageS, aSelGrp2U, MainObj2); - createSelWg(tr("FACE_1U"), imageS, aSelGrp2U, Face1U); - createSelWg(tr("FACE_2U"), imageS, aSelGrp2U, Face2U); - - QGroupBox* aSpinGrp2U = new QGroupBox(1, Qt::Vertical, myGrp2); - aSpinGrp2U->setFrameStyle(QFrame::NoFrame); - aSpinGrp2U->setInsideMargin(0); - - new QLabel(tr("GEOM_NB_TIMES_U"), aSpinGrp2U); - mySpinBox[SpinBox2U] = new DlgRef_SpinBox(aSpinGrp2U); + myGrp2 = new QGroupBox(tr("GEOM_BLOCK_MULTITRSF_DOUBLE"), centralWidget()); - // V trsf - QGroupBox* aSelGrp2V = new QGroupBox(3, Qt::Horizontal, myGrp2); - aSelGrp2V->setFrameStyle(QFrame::NoFrame); - aSelGrp2V->setInsideMargin(0); - - createSelWg(tr("FACE_1V"), imageS, aSelGrp2V, Face1V); - createSelWg(tr("FACE_2V"), imageS, aSelGrp2V, Face2V); - - QGroupBox* aSpinGrp2V = new QGroupBox(1, Qt::Vertical, myGrp2); - aSpinGrp2V->setFrameStyle(QFrame::NoFrame); - aSpinGrp2V->setInsideMargin(0); - - new QLabel(tr("GEOM_NB_TIMES_V"), aSpinGrp2V); - mySpinBox[SpinBox2V] = new DlgRef_SpinBox(aSpinGrp2V); - - (new QLabel(myGrp2))->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + createSelWg(tr("GEOM_MAIN_OBJECT"), imageS, myGrp2, MainObj2); + createSelWg(tr("FACE_1U"), imageS, myGrp2, Face1U); + createSelWg(tr("FACE_2U"), imageS, myGrp2, Face2U); + createSpinWg(tr("GEOM_NB_TIMES_U"), myGrp2, SpinBox2U); + createSelWg(tr("FACE_1V"), imageS, myGrp2, Face1V); + createSelWg(tr("FACE_2V"), imageS, myGrp2, Face2V); + createSpinWg(tr("GEOM_NB_TIMES_V"), myGrp2, SpinBox2V); // Add groups to layout - Layout1->addWidget( myGrp1, 2, 0 ); - Layout1->addWidget( myGrp2, 2, 0 ); + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); layout->setSpacing(6); + layout->addWidget(myGrp1); + layout->addWidget(myGrp2); /***************************************************************/ - setHelpFileName("multi_transformation.htm"); + setHelpFileName("multi_transformation_operation_page.html"); Init(); } @@ -140,27 +112,26 @@ BlocksGUI_TrsfDlg::~BlocksGUI_TrsfDlg() void BlocksGUI_TrsfDlg::Init() { // Set range of spinboxes - double SpecificStep = 1.0; - QMap::iterator anIter; + int SpecificStep = 1; + QMap::iterator anIter; for (anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter) { - anIter.data()->RangeStepAndValidator(1.0, 999.999, SpecificStep, 3); + //anIter.data()->RangeStepAndValidator(1, 999, SpecificStep); + initSpinBox(anIter.value(), 1, 999, SpecificStep); } // signals and slots connections - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int))); QMap::iterator anIterBtn; for (anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn) - connect(anIterBtn.data(), SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(anIterBtn.value(), SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - QMap::iterator anIterSpin; + QMap::iterator anIterSpin; for (anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin) - connect(anIterSpin.data(), SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + connect(anIterSpin.value(), SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int))); // init controls and fields initName(tr("GEOM_BLOCK_MULTITRSF")); @@ -180,41 +151,41 @@ void BlocksGUI_TrsfDlg::ConstructorsClicked (int constructorId) myConstructorId = constructorId; + // init fields + myShape = GEOM::GEOM_Object::_nil(); + myFaces[Face1] = myFaces[Face2] = -1; + myFaces[Face1U] = myFaces[Face2U] = -1; + myFaces[Face1V] = myFaces[Face2V] = -1; + + // clear line edits + QMap::iterator anIterLE; + for (anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE) + anIterLE.value()->setText(""); + switch (constructorId) { case 0: myGrp2->hide(); myGrp1->show(); - mySpinBox[SpinBox1]->SetValue(2.0); - myEditCurrentArgument = mySelName[MainObj1]; - myFaces[Face1] = -1; - myFaces[Face2] = -1; + mySpinBox[SpinBox1]->setValue(2); + mySelBtn[MainObj1]->click(); break; case 1: myGrp1->hide(); myGrp2->show(); - mySpinBox[SpinBox2U]->SetValue(2.0); - mySpinBox[SpinBox2V]->SetValue(2.0); - myEditCurrentArgument = mySelName[MainObj2]; - myFaces[Face1U] = -1; - myFaces[Face2U] = -1; - myFaces[Face1V] = -1; - myFaces[Face2V] = -1; + mySpinBox[SpinBox2U]->setValue(2); + mySpinBox[SpinBox2V]->setValue(2); + mySelBtn[MainObj2]->click(); break; default: break; } - // clear line edits - QMap::iterator anIterLE; - for (anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE) - anIterLE.data()->setText(""); - - // init fields - myShape = GEOM::GEOM_Object::_nil(); + qApp->processEvents(); + updateGeometry(); + resize(minimumSizeHint()); - activateSelection(); -// enableWidgets(); -// displayPreview(); + // on dialog initialization we init the first field with a selected object (if any) + SelectionIntoArgument(); } //================================================================================= @@ -242,7 +213,7 @@ bool BlocksGUI_TrsfDlg::ClickOnApply() //================================================================================= // function : SelectionIntoArgument() -// purpose : Called when selection has changed +// purpose : Called when selection is changed or on dialog initialization or activation //================================================================================= void BlocksGUI_TrsfDlg::SelectionIntoArgument() { @@ -253,55 +224,97 @@ void BlocksGUI_TrsfDlg::SelectionIntoArgument() int aCurrFocus = -1; QMap::iterator anIter; for (anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter) { - if (myEditCurrentArgument == anIter.data()) { + if (myEditCurrentArgument == anIter.value()) { aCurrFocus = anIter.key(); break; } } - // If selection of main object is activated - if (aCurrFocus == MainObj1 || aCurrFocus == MainObj2) { - if (IObjectCount() == 1) { + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + QString aName; + GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_nil(); + + if (aCurrFocus == MainObj1 || aCurrFocus == MainObj2) + { + // If selection of main object is activated + if (aSelList.Extent() == 1) { Standard_Boolean aResult = Standard_False; - GEOM::GEOM_Object_var anObj = - GEOMBase::ConvertIOinGEOMObject(firstIObject(), aResult); - - if (aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) { - myShape = anObj; - mySelName[aCurrFocus]->setText(GEOMBase::GetName(anObj)); - enableWidgets(); - return; + anObj = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult); + + if (aResult && !anObj->_is_nil() && GEOMBase::IsShape(anObj)) { + aName = GEOMBase::GetName(anObj); } } - - myShape = GEOM::GEOM_Object::_nil(); + myEditCurrentArgument->setText(aName); + myShape = anObj; enableWidgets(); } - // If face selection is activated else if (aCurrFocus == Face1 || aCurrFocus == Face2 || aCurrFocus == Face1U || aCurrFocus == Face2U || aCurrFocus == Face1V || aCurrFocus == Face2V) { - if (IObjectCount() == 1) { + // If face selection is activated + int anIndex = -1; + if (aSelList.Extent() == 1) { Standard_Boolean aResult = Standard_False; - GEOM::GEOM_Object_var anObj = - GEOMBase::ConvertIOinGEOMObject(firstIObject(), aResult); - - if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) { + anObj = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult); + if (aResult && !anObj->_is_nil() && GEOMBase::IsShape(anObj)) { + aName = GEOMBase::GetName(anObj); TColStd_IndexedMapOfInteger anIndexes; - ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), 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)); - myFaces[aCurrFocus] = anIndex; - displayPreview(); - return; + anIndex = anIndexes(1); + aName += QString(":face_%1").arg(anIndex); } } } + myEditCurrentArgument->setText(aName); + myFaces[aCurrFocus] = anIndex; + displayPreview(); + } + + switch (aCurrFocus) { + // 1D + case MainObj1: + if (!myShape->_is_nil() && myFaces[Face1] == -1) + mySelBtn[Face1]->click(); + break; + case Face1: + if (myFaces[Face1] != -1 && myFaces[Face2] == -1) + mySelBtn[Face2]->click(); + break; + case Face2: + if (myFaces[Face2] != -1 && myShape->_is_nil()) + mySelBtn[MainObj1]->click(); + break; + + // 2D + case MainObj2: + if (!myShape->_is_nil() && myFaces[Face1U] == -1) + mySelBtn[Face1U]->click(); + break; + case Face1U: + if (myFaces[Face1U] != -1 && myFaces[Face2U] == -1) + mySelBtn[Face2U]->click(); + break; + case Face2U: + if (myFaces[Face2U] != -1 && myFaces[Face1V] == -1) + mySelBtn[Face1V]->click(); + break; + case Face1V: + if (myFaces[Face1V] != -1 && myFaces[Face2V] == -1) + mySelBtn[Face2V]->click(); + break; + case Face2V: + if (myFaces[Face2V] != -1 && myShape->_is_nil()) + mySelBtn[MainObj1]->click(); + break; - myFaces[aCurrFocus] = -1; + default: + break; } } @@ -313,15 +326,58 @@ void BlocksGUI_TrsfDlg::SetEditCurrentArgument() { QPushButton* aSender = (QPushButton*)sender(); + // clear selection + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + if (myInitial) + myInitial = false; + else + myGeomGUI->getApp()->selectionMgr()->clearSelected(); + + // disable all + switch (myConstructorId) { + case 0: + mySelBtn[MainObj1]->setDown(false); + mySelBtn[Face1]->setDown(false); + mySelBtn[Face2]->setDown(false); + + mySelName[MainObj1]->setEnabled(false); + mySelName[Face1]->setEnabled(false); + mySelName[Face2]->setEnabled(false); + break; + case 1: + mySelBtn[MainObj2]->setDown(false); + mySelBtn[Face1U]->setDown(false); + mySelBtn[Face2U]->setDown(false); + mySelBtn[Face1V]->setDown(false); + mySelBtn[Face2V]->setDown(false); + + mySelName[MainObj2]->setEnabled(false); + mySelName[Face1U]->setEnabled(false); + mySelName[Face2U]->setEnabled(false); + mySelName[Face1V]->setEnabled(false); + mySelName[Face2V]->setEnabled(false); + break; + default: + break; + } + + // set line edit as current argument QMap::iterator anIter; for (anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter) { - if (anIter.data() == aSender) { - mySelName[anIter.key()]->setFocus(); + if (anIter.value() == aSender) { myEditCurrentArgument = mySelName[anIter.key()]; break; } } + // enable line edit + myEditCurrentArgument->setEnabled(true); + myEditCurrentArgument->setFocus(); + + // enable push button + // after setFocus(), because it will be setDown(false) when loses focus + aSender->setDown(true); + activateSelection(); } @@ -332,10 +388,9 @@ void BlocksGUI_TrsfDlg::SetEditCurrentArgument() void BlocksGUI_TrsfDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - activateSelection(); + + // ?? displayPreview(); } @@ -343,17 +398,17 @@ void BlocksGUI_TrsfDlg::ActivateThisDialog() // function : enterEvent() // purpose : //================================================================================= -void BlocksGUI_TrsfDlg::enterEvent (QEvent* e) +void BlocksGUI_TrsfDlg::enterEvent (QEvent*) { - if (!GroupConstructors->isEnabled()) - this->ActivateThisDialog(); + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); } //================================================================================= // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void BlocksGUI_TrsfDlg::ValueChangedInSpinBox (double newValue) +void BlocksGUI_TrsfDlg::ValueChangedInSpinBox(int) { displayPreview(); } @@ -367,11 +422,47 @@ void BlocksGUI_TrsfDlg::createSelWg (const QString& theLbl, QWidget* theParent, const int theId) { - new QLabel(theLbl, theParent); + QLabel* lab = new QLabel(theLbl, theParent); mySelBtn[theId] = new QPushButton(theParent); - mySelBtn[theId]->setPixmap(thePix); + mySelBtn[theId]->setIcon(thePix); + mySelBtn[theId]->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); mySelName[theId] = new QLineEdit(theParent); mySelName[theId]->setReadOnly(true); + QGridLayout* l = 0; + if (!theParent->layout()) { + l = new QGridLayout(theParent); + l->setMargin(9); l->setSpacing(6); + } + else { + l = qobject_cast(theParent->layout()); + } + int row = l->rowCount(); + l->addWidget(lab, row, 0); + l->addWidget(mySelBtn[theId], row, 1); + l->addWidget(mySelName[theId], row, 2); +} + +//================================================================================= +// function : createSpinWg() +// purpose : +//================================================================================= +void BlocksGUI_TrsfDlg::createSpinWg (const QString& theLbl, + QWidget* theParent, + const int theId) +{ + QLabel* lab = new QLabel(theLbl, theParent); + mySpinBox[theId] = new SalomeApp_IntSpinBox(theParent); + QGridLayout* l = 0; + if (!theParent->layout()) { + l = new QGridLayout(theParent); + l->setMargin(9); l->setSpacing(6); + } + else { + l = qobject_cast(theParent->layout()); + } + int row = l->rowCount(); + l->addWidget(lab, row, 0); + l->addWidget(mySpinBox[theId], row, 2); } //================================================================================= @@ -380,26 +471,22 @@ void BlocksGUI_TrsfDlg::createSelWg (const QString& theLbl, //================================================================================= void BlocksGUI_TrsfDlg::activateSelection() { + globalSelection(GEOM_ALLSHAPES); if (!myShape->_is_nil() && - (myEditCurrentArgument == mySelName[ Face1 ] || - myEditCurrentArgument == mySelName[ Face2 ] || - myEditCurrentArgument == mySelName[ Face1U ] || - myEditCurrentArgument == mySelName[ Face2U ] || - myEditCurrentArgument == mySelName[ Face1V ] || - myEditCurrentArgument == mySelName[ Face2V ])) { - + (myEditCurrentArgument == mySelName[Face1 ] || + myEditCurrentArgument == mySelName[Face2 ] || + myEditCurrentArgument == mySelName[Face1U] || + myEditCurrentArgument == mySelName[Face2U] || + myEditCurrentArgument == mySelName[Face1V] || + myEditCurrentArgument == mySelName[Face2V])) + { // Local selection is available only in the OCC Viewer - if (SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() - == OCCViewer_Viewer::Type()) { + if (getDesktop()->activeWindow()->getViewManager()->getType() == OCCViewer_Viewer::Type()) { localSelection(myShape, TopAbs_FACE); - } else { - return; } - } else { - globalSelection( GEOM_ALLSHAPES ); } - - SelectionIntoArgument(); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); } //================================================================================= @@ -413,26 +500,27 @@ void BlocksGUI_TrsfDlg::enableWidgets() bool toEnable = !myShape->_is_nil(); if (anId == 0) { - 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(""); myFaces[Face1] = -1; myFaces[Face2] = -1; } - } else if (anId == 1) { - mySelName[Face1U]->setEnabled(toEnable); - mySelName[Face2U]->setEnabled(toEnable); - mySelName[Face1V]->setEnabled(toEnable); - mySelName[Face2V]->setEnabled(toEnable); - mySelBtn[Face1U]->setEnabled(toEnable); - mySelBtn[Face2U]->setEnabled(toEnable); - mySelBtn[Face1V]->setEnabled(toEnable); - mySelBtn[Face2V]->setEnabled(toEnable); + } + else if (anId == 1) { + //mySelName[Face1U]->setEnabled(toEnable); + //mySelName[Face2U]->setEnabled(toEnable); + //mySelName[Face1V]->setEnabled(toEnable); + //mySelName[Face2V]->setEnabled(toEnable); + //mySelBtn[Face1U]->setEnabled(toEnable); + //mySelBtn[Face2U]->setEnabled(toEnable); + //mySelBtn[Face1V]->setEnabled(toEnable); + //mySelBtn[Face2V]->setEnabled(toEnable); if (!toEnable) { mySelName[Face1U]->setText(""); @@ -457,20 +545,26 @@ GEOM::GEOM_IOperations_ptr BlocksGUI_TrsfDlg::createOperation() } //================================================================================= -// function : ClickOnApply() +// function : isValid // purpose : Verify validity of input data //================================================================================= -bool BlocksGUI_TrsfDlg::isValid (QString&) +bool BlocksGUI_TrsfDlg::isValid (QString& msg) { + bool ok = false, okSP = true; switch (getConstructorId()) { - case 0: - return !myShape->_is_nil() && myFaces[Face1] > 0; - case 1: - return !myShape->_is_nil() && myFaces[Face1U] > 0 && myFaces[Face1V] > 0; - default: - return false; + case 0: + ok = !myShape->_is_nil() && myFaces[Face1] > 0; + okSP = mySpinBox[SpinBox1]->isValid( msg, !IsPreview() ); + break; + case 1: + ok = !myShape->_is_nil() && myFaces[Face1U] > 0 && myFaces[Face1V] > 0; + okSP = mySpinBox[SpinBox2U]->isValid( msg, !IsPreview() ) && okSP; + okSP = mySpinBox[SpinBox2V]->isValid( msg, !IsPreview() ) && okSP; + break; + default: + break; } - return false; + return ok && okSP; } //================================================================================= @@ -483,26 +577,29 @@ bool BlocksGUI_TrsfDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; + GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation()); + switch (getConstructorId()) { - case 0: - anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->MakeMultiTransformation1D - (myShape, - myFaces[Face1], - myFaces[Face2], - (int)mySpinBox[SpinBox1]->GetValue()); - res = true; - break; - case 1: - anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->MakeMultiTransformation2D - (myShape, - myFaces[Face1U], - myFaces[Face2U], - (int)mySpinBox[SpinBox2U]->GetValue(), - myFaces[Face1V], - myFaces[Face2V], - (int)mySpinBox[SpinBox2V]->GetValue()); - res = true; - break; + case 0: + anObj = anOper->MakeMultiTransformation1D(myShape, + myFaces[Face1], myFaces[Face2], + mySpinBox[SpinBox1]->value()); + if (!anObj->_is_nil() && !IsPreview()) + myNoteBook->setParameters(anObj, 1, mySpinBox[SpinBox1]); + res = true; + break; + case 1: + anObj = anOper->MakeMultiTransformation2D (myShape, + myFaces[Face1U], myFaces[Face2U], + mySpinBox[SpinBox2U]->value(), + myFaces[Face1V], myFaces[Face2V], + mySpinBox[SpinBox2V]->value()); + if (!anObj->_is_nil() && !IsPreview()) + myNoteBook->setParameters(anObj, 2, mySpinBox[SpinBox2U], mySpinBox[SpinBox2V]); + res = true; + break; + default: + break; } if (!anObj->_is_nil())