Salome HOME
Bugs 16640, 19050: Improve selection mechanism in GEOM dialog boxes.
[modules/geom.git] / src / BlocksGUI / BlocksGUI_TrsfDlg.cxx
index e639d1132792370296bfe9b57d93c5973cee9973..1977fccf38f5ee3926d832c1048b99310fd636f8 100644 (file)
 #include <LightApp_SelectionMgr.h>
 #include <OCCViewer_ViewModel.h>
 
+// OCCT Includes
 #include <TColStd_IndexedMapOfInteger.hxx>
 
 //=================================================================================
 // class    : BlocksGUI_TrsfDlg()
 // purpose  : Constructs a BlocksGUI_TrsfDlg which is a child of 'parent'.
 //=================================================================================
-BlocksGUI_TrsfDlg::BlocksGUI_TrsfDlg( GeometryGUI* theGeometryGUI, QWidget* parent )
-  : GEOMBase_Skeleton( theGeometryGUI, parent )
+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" ) ) );
+  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")));
 
-  setWindowTitle( tr( "GEOM_BLOCK_MULTITRSF_TITLE" ) );
+  setWindowTitle(tr("GEOM_BLOCK_MULTITRSF_TITLE"));
 
   /***************************************************************/
-  mainFrame()->GroupConstructors->setTitle( tr( "GEOM_BLOCK_MULTITRSF" ) );
+  mainFrame()->GroupConstructors->setTitle(tr("GEOM_BLOCK_MULTITRSF"));
 
-  mainFrame()->RadioButton1->setIcon( image1 );
-  mainFrame()->RadioButton2->setIcon( image2 );
-  mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
+  mainFrame()->RadioButton1->setIcon(image1);
+  mainFrame()->RadioButton2->setIcon(image2);
+  mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
   mainFrame()->RadioButton3->close();
 
   // Create first group
-  myGrp1 = new QGroupBox( tr( "GEOM_BLOCK_MULTITRSF_SIMPLE" ), centralWidget() );
+  myGrp1 = new QGroupBox(tr("GEOM_BLOCK_MULTITRSF_SIMPLE"), centralWidget());
 
-  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 );
+  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( tr( "GEOM_BLOCK_MULTITRSF_DOUBLE" ), centralWidget() );
+  myGrp2 = new QGroupBox(tr("GEOM_BLOCK_MULTITRSF_DOUBLE"), centralWidget());
 
-  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 );
+  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
-  QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
-  layout->setMargin( 0 ); layout->setSpacing( 6 );
-  layout->addWidget( myGrp1 );
-  layout->addWidget( myGrp2 );
+  QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+  layout->setMargin(0); layout->setSpacing(6);
+  layout->addWidget(myGrp1);
+  layout->addWidget(myGrp2);
   /***************************************************************/
 
-  setHelpFileName( "multi_transformation_operation_page.html" );
+  setHelpFileName("multi_transformation_operation_page.html");
 
   Init();
 }
@@ -110,86 +112,78 @@ void BlocksGUI_TrsfDlg::Init()
   // Set range of spinboxes
   double SpecificStep = 1.0;
   QMap<int, QDoubleSpinBox*>::iterator anIter;
-  for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter ) {
+  for (anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter) {
     //anIter.data()->RangeStepAndValidator(1.0, 999.999, SpecificStep, 3);
-    initSpinBox( anIter.value(), 1.0, MAX_NUMBER, SpecificStep, 3 );
+    initSpinBox(anIter.value(), 1.0, MAX_NUMBER, SpecificStep, 3);
   }
 
   // signals and slots connections
-  connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
-  connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+  connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+  connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
 
-  connect( this, SIGNAL( constructorsClicked( int ) ), 
-          this, SLOT( ConstructorsClicked( int ) ) );
+  connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
 
   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()));
 
   QMap<int, QDoubleSpinBox*>::iterator anIterSpin;
-  for ( anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin )
-    connect( anIterSpin.value(), SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-
-  connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 
-          SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ) ;
+  for (anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin)
+    connect(anIterSpin.value(), SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
 
   // init controls and fields
-  initName( tr( "GEOM_BLOCK_MULTITRSF" ) );
+  initName(tr("GEOM_BLOCK_MULTITRSF"));
 
   myConstructorId = -1;
-  ConstructorsClicked( 0 );
+  ConstructorsClicked(0);
 }
 
 //=================================================================================
 // function : ConstructorsClicked()
 // purpose  : Radio button management
 //=================================================================================
-void BlocksGUI_TrsfDlg::ConstructorsClicked( int constructorId )
+void BlocksGUI_TrsfDlg::ConstructorsClicked (int constructorId)
 {
-  if ( myConstructorId == constructorId )
+  if (myConstructorId == constructorId)
     return;
 
   myConstructorId = constructorId;
 
-  switch ( 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<int, QLineEdit*>::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.0);
+    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.0);
+    mySpinBox[SpinBox2V]->setValue(2.0);
+    mySelBtn[MainObj2]->click();
     break;
   default:
     break;
   }
 
-  // clear line edits
-  QMap<int, QLineEdit*>::iterator anIterLE;
-  for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
-    anIterLE.value()->setText( "" );
-
-  // init fields
-  myShape = GEOM::GEOM_Object::_nil();
-
   qApp->processEvents();
   updateGeometry();
-  resize( minimumSize() );
+  resize(minimumSize());
 
-  activateSelection();
-//  enableWidgets();
-//  displayPreview();
+  // on dialog initialization we init the first field with a selected object (if any)
+  SelectionIntoArgument();
 }
 
 //=================================================================================
@@ -198,7 +192,7 @@ void BlocksGUI_TrsfDlg::ConstructorsClicked( int constructorId )
 //=================================================================================
 void BlocksGUI_TrsfDlg::ClickOnOk()
 {
-  if ( ClickOnApply() )
+  if (ClickOnApply())
     ClickOnCancel();
 }
 
@@ -208,7 +202,7 @@ void BlocksGUI_TrsfDlg::ClickOnOk()
 //=================================================================================
 bool BlocksGUI_TrsfDlg::ClickOnApply()
 {
-  if ( !onAccept() )
+  if (!onAccept())
     return false;
 
   initName();
@@ -217,18 +211,18 @@ 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()
 {
   erasePreview();
-  myEditCurrentArgument->setText( "" );
+  myEditCurrentArgument->setText("");
 
   // 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;
     }
@@ -238,49 +232,87 @@ void BlocksGUI_TrsfDlg::SelectionIntoArgument()
   SALOME_ListIO aSelList;
   aSelMgr->selectedObjects(aSelList);
 
-  // If selection of main object is activated
-  if ( aCurrFocus == MainObj1 || aCurrFocus == MainObj2 ) {
+  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(aSelList.First(), 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 ) {
+  else if (aCurrFocus == Face1  || aCurrFocus == Face2  ||
+           aCurrFocus == Face1U || aCurrFocus == Face2U ||
+           aCurrFocus == Face1V || aCurrFocus == Face2V) {
+    // If face selection is activated
+    int anIndex = -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() && GEOMBase::IsShape( anObj ) ) {
+      anObj = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
+      if (aResult && !anObj->_is_nil() && GEOMBase::IsShape(anObj)) {
+        aName = GEOMBase::GetName(anObj);
         TColStd_IndexedMapOfInteger anIndexes;
-       myGeomGUI->getApp()->selectionMgr()->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;
+        aSelMgr->GetIndexes(aSelList.First(), anIndexes);
+
+        if (anIndexes.Extent() == 1) {
+          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;
   }
 }
 
@@ -292,15 +324,57 @@ 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;
+  }
+
+  // enable push button
+  aSender->setDown(true);
+
+  // set line edit as current argument
   QMap<int, QPushButton*>::iterator anIter;
-  for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter ) {
-    if ( anIter.value() == aSender ) {
-      mySelName[anIter.key()]->setFocus();
+  for (anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter) {
+    if (anIter.value() == aSender) {
       myEditCurrentArgument = mySelName[anIter.key()];
       break;
     }
   }
 
+  // enable line edit
+  myEditCurrentArgument->setEnabled(true);
+  myEditCurrentArgument->setFocus();
+
   activateSelection();
 }
 
@@ -311,10 +385,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();
 }
 
@@ -322,17 +395,17 @@ void BlocksGUI_TrsfDlg::ActivateThisDialog()
 // function : enterEvent()
 // purpose  :
 //=================================================================================
-void BlocksGUI_TrsfDlg::enterEvent( QEvent* )
+void BlocksGUI_TrsfDlg::enterEvent (QEvent*)
 {
-  if ( !mainFrame()->GroupConstructors->isEnabled() )
-    this->ActivateThisDialog();
+  if (!mainFrame()->GroupConstructors->isEnabled())
+    ActivateThisDialog();
 }
 
 //=================================================================================
 // function : ValueChangedInSpinBox()
 // purpose  :
 //=================================================================================
-void BlocksGUI_TrsfDlg::ValueChangedInSpinBox( double )
+void BlocksGUI_TrsfDlg::ValueChangedInSpinBox(double)
 {
   displayPreview();
 }
@@ -341,52 +414,52 @@ void BlocksGUI_TrsfDlg::ValueChangedInSpinBox( double )
 // function : createSelWg()
 // purpose  :
 //=================================================================================
-void BlocksGUI_TrsfDlg::createSelWgconst QString& theLbl,
+void BlocksGUI_TrsfDlg::createSelWg (const QString& theLbl,
                                      QPixmap&       thePix,
                                      QWidget*       theParent,
-                                     const int      theId )
+                                     const int      theId)
 {
-  QLabel* lab = new QLabel( theLbl, theParent );
-  mySelBtn[theId] = new QPushButton( theParent );
-  mySelBtn[theId]->setIcon( thePix );
-  mySelBtn[theId]->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
-  mySelName[theId] = new QLineEdit( theParent );
-  mySelName[theId]->setReadOnly( true );
+  QLabel* lab = new QLabel(theLbl, theParent);
+  mySelBtn[theId] = new QPushButton(theParent);
+  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 );
+  if (!theParent->layout()) {
+    l = new QGridLayout(theParent);
+    l->setMargin(9); l->setSpacing(6);
   }
   else {
-    l = qobject_cast<QGridLayout*>( theParent->layout() );
+    l = qobject_cast<QGridLayout*>(theParent->layout());
   }
   int row = l->rowCount();
-  l->addWidget( lab,              row, 0 );
-  l->addWidget( mySelBtn[theId],  row, 1 );
-  l->addWidget( mySelName[theId], row, 2 );
+  l->addWidget(lab,              row, 0);
+  l->addWidget(mySelBtn[theId],  row, 1);
+  l->addWidget(mySelName[theId], row, 2);
 }
 
 //=================================================================================
 // function : createSpinWg()
 // purpose  :
 //=================================================================================
-void BlocksGUI_TrsfDlg::createSpinWgconst QString& theLbl,
-                                     QWidget*       theParent,
-                                     const int      theId )
+void BlocksGUI_TrsfDlg::createSpinWg (const QString& theLbl,
+                                      QWidget*       theParent,
+                                      const int      theId)
 {
-  QLabel* lab = new QLabel( theLbl, theParent );
-  mySpinBox[theId] = new QDoubleSpinBox( theParent );
+  QLabel* lab = new QLabel(theLbl, theParent);
+  mySpinBox[theId] = new QDoubleSpinBox(theParent);
   QGridLayout* l = 0;
-  if ( !theParent->layout() ) {
-    l = new QGridLayout( theParent );
-    l->setMargin( 9 ); l->setSpacing( 6 );
+  if (!theParent->layout()) {
+    l = new QGridLayout(theParent);
+    l->setMargin(9); l->setSpacing(6);
   }
   else {
-    l = qobject_cast<QGridLayout*>( theParent->layout() );
+    l = qobject_cast<QGridLayout*>(theParent->layout());
   }
   int row = l->rowCount();
-  l->addWidget( lab,              row, 0 );
-  l->addWidget( mySpinBox[theId], row, 2 );
+  l->addWidget(lab,              row, 0);
+  l->addWidget(mySpinBox[theId], row, 2);
 }
 
 //=================================================================================
@@ -395,28 +468,22 @@ void BlocksGUI_TrsfDlg::createSpinWg( const QString& theLbl,
 //=================================================================================
 void BlocksGUI_TrsfDlg::activateSelection()
 {
-  if ( !myShape->_is_nil() &&
-       ( myEditCurrentArgument == mySelName[ Face1  ] ||
-        myEditCurrentArgument == mySelName[ Face2  ] ||
-        myEditCurrentArgument == mySelName[ Face1U ] ||
-        myEditCurrentArgument == mySelName[ Face2U ] ||
-        myEditCurrentArgument == mySelName[ Face1V ] ||
-        myEditCurrentArgument == mySelName[ Face2V ] ) ) {
-
+  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]))
+  {
     // Local selection is available only in the OCC Viewer
-    if ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() 
-        == OCCViewer_Viewer::Type() ) {
-      localSelection( myShape, TopAbs_FACE );
-    } 
-    else {
-      return;
+    if (getDesktop()->activeWindow()->getViewManager()->getType() == OCCViewer_Viewer::Type()) {
+      localSelection(myShape, TopAbs_FACE);
     }
-  } 
-  else {
-    globalSelection( GEOM_ALLSHAPES );
   }
-
-  SelectionIntoArgument();
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+          this, SLOT(SelectionIntoArgument()));
 }
 
 //=================================================================================
@@ -429,34 +496,34 @@ 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 );
+  if (anId == 0) {
+    //mySelName[Face1]->setEnabled(toEnable);
+    //mySelName[Face2]->setEnabled(toEnable);
+    //mySelBtn[Face1]->setEnabled(toEnable);
+    //mySelBtn[Face2]->setEnabled(toEnable);
 
-    if ( !toEnable)  {
-      mySelName[Face1]->setText( "" );
-      mySelName[Face2]->setText( "" );
+    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 );
-
-    if ( !toEnable ) {
-      mySelName[Face1U]->setText( "" );
-      mySelName[Face2U]->setText( "" );
-      mySelName[Face1V]->setText( "" );
-      mySelName[Face2V]->setText( "" );
+  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("");
+      mySelName[Face2U]->setText("");
+      mySelName[Face1V]->setText("");
+      mySelName[Face2V]->setText("");
       myFaces[Face1U] = -1;
       myFaces[Face2U] = -1;
       myFaces[Face1V] = -1;
@@ -471,17 +538,17 @@ void BlocksGUI_TrsfDlg::enableWidgets()
 //=================================================================================
 GEOM::GEOM_IOperations_ptr BlocksGUI_TrsfDlg::createOperation()
 {
-  return getGeomEngine()->GetIBlocksOperations( getStudyId() );
+  return getGeomEngine()->GetIBlocksOperations(getStudyId());
 }
 
 //=================================================================================
-// function : ClickOnApply()
+// function : isValid
 // purpose  : Verify validity of input data
 //=================================================================================
-bool BlocksGUI_TrsfDlg::isValid( QString& )
+bool BlocksGUI_TrsfDlg::isValid (QString&)
 {
   bool ok = false;
-  switch ( getConstructorId() ) {
+  switch (getConstructorId()) {
   case 0:
     ok = !myShape->_is_nil() && myFaces[Face1] > 0;
     break;
@@ -498,36 +565,35 @@ bool BlocksGUI_TrsfDlg::isValid( QString& )
 // function : execute
 // purpose  :
 //=================================================================================
-bool BlocksGUI_TrsfDlg::execute( ObjectList& objects )
+bool BlocksGUI_TrsfDlg::execute (ObjectList& objects)
 {
   bool res = false;
 
   GEOM::GEOM_Object_var anObj;
 
-  switch ( getConstructorId() ) {
+  switch (getConstructorId()) {
   case 0:
-    anObj = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->MakeMultiTransformation1D
-      ( myShape,
-       myFaces[Face1],
-       myFaces[Face2],
-       (int)mySpinBox[SpinBox1]->value() );
+    anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->
+      MakeMultiTransformation1D(myShape,
+                                myFaces[Face1], myFaces[Face2],
+                                (int)mySpinBox[SpinBox1]->value());
     res = true;
     break;
   case 1:
-    anObj = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->MakeMultiTransformation2D
-      ( myShape,
-       myFaces[Face1U],
-       myFaces[Face2U],
-       (int)mySpinBox[SpinBox2U]->value(),
-       myFaces[Face1V],
-       myFaces[Face2V],
-       (int)mySpinBox[SpinBox2V]->value() );
+    anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->
+      MakeMultiTransformation2D (myShape,
+                                 myFaces[Face1U], myFaces[Face2U],
+                                 (int)mySpinBox[SpinBox2U]->value(),
+                                 myFaces[Face1V], myFaces[Face2V],
+                                 (int)mySpinBox[SpinBox2V]->value());
     res = true;
     break;
+  default:
+    break;
   }
 
-  if ( !anObj->_is_nil() )
-    objects.push_back( anObj._retn() );
+  if (!anObj->_is_nil())
+    objects.push_back(anObj._retn());
 
   return res;
 }