Salome HOME
Merge from BR_Dev_For_4_0 branch (from tag mergeto_BR_QT4_Dev_17Jan08)
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI_1.cxx
index 4991063474fc397ee6659df010f9a7223dd4ad32..2be9e4c79c3337620eb53591fdb0b2c26a5f1e00 100644 (file)
-//  GEOM GEOMGUI : GUI for Geometry component
+// GEOM GEOMGUI : GUI for Geometry component
 //
-//  Copyright (C) 2004  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.salome-platform.org or email : webmaster.salome@opencascade.org 
+// Copyright (C) 2004  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.
 //
-//  File   : GEOMToolsGUI_1.cxx
-//  Author : Sergey ANIKIN
-//  Module : GEOM
-//  $Header$
+// 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   : GEOMToolsGUI_1.cxx
+// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
+//
+
+#include <PyConsole_Console.h>
 
 #include "GEOMToolsGUI.h"
-#include "GeometryGUI.h"
-#include "GEOM_Actor.h"
-#include "GEOMBase.h"
-
-#include "QAD_Desktop.h"
-#include "QAD_Config.h"
-#include "QAD_FileDlg.h"
-#include "QAD_PyEditor.h"
-#include "QAD_RightFrame.h"
-#include "QAD_MessageBox.h"
-#include "SALOMEGUI_NameDlg.h"
-
-#include "OCCViewer_Viewer3d.h"
-#include "OCCViewer_ViewFrame.h"
-#include "VTKViewer_ViewFrame.h"
-#include "VTKViewer_RenderWindowInteractor.h"
-
-#include "SALOME_ListIO.hxx"
-#include "SALOME_ListIteratorOfListIO.hxx"
+#include "GEOMToolsGUI_TransparencyDlg.h"
+#include "GEOMToolsGUI_NbIsosDlg.h"
 
-#include <AIS_Drawer.hxx>
-#include <AIS_ListOfInteractive.hxx>
-#include <AIS_ListIteratorOfListOfInteractive.hxx>
-#include <Prs3d_IsoAspect.hxx>
+#include <GeometryGUI.h>
+#include <GEOM_Displayer.h>
 
-#include <vtkBMPReader.h>
-#include <vtkTexture.h>
-#include <vtkTextureMapToPlane.h>
-#include <vtkTransformTextureCoords.h>
-#include <vtkDataSetMapper.h>
-#include <vtkRenderer.h>
+#include <GEOMBase.h>
+#include <GEOM_Actor.h>
+
+#include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
+
+#include <SOCC_Prs.h>
 
-#include <qfileinfo.h>
-#include <qcolordialog.h>
-#include <qspinbox.h>
-#include <qapplication.h>
+#include <SVTK_Prs.h>
+#include <SVTK_ViewModel.h>
+#include <SVTK_ViewWindow.h>
+#include <SVTK_View.h>
 
-#include "GEOMToolsGUI_NbIsosDlg.h"        // Method ISOS adjustement
-#include "GEOMToolsGUI_TransparencyDlg.h"  // Method TRANSPARENCY adjustement
+#include <OCCViewer_ViewModel.h>
+
+#include <SUIT_ViewManager.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SUIT_OverrideCursor.h>
+#include <SUIT_MessageBox.h>
+
+#include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
+#include <SalomeApp_Module.h>
+
+#include <LightApp_SelectionMgr.h>
+#include <LightApp_NameDlg.h>
+
+#include <GEOMImpl_Types.hxx>
 
 #include "utilities.h"
 
-using namespace std;
+// OCCT Includes
+#include <AIS_Drawer.hxx>
+#include <Prs3d_IsoAspect.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+
+// QT Includes
+#include <QColorDialog>
+#include <QList>
+
+// VTK includes
+#include <vtkRenderer.h>
 
 void GEOMToolsGUI::OnSettingsColor()
 {
-  
-  QString aSCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed");
-  QString aSCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen");
-  QString aSCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue");
-  QColor anInitColor;
-  if(!aSCr.isEmpty() && !aSCg.isEmpty() && !aSCb.isEmpty()) {    
-    anInitColor = QColor (aSCr.toInt(), aSCg.toInt(), aSCb.toInt());
-  } 
-  else {
-    Quantity_Color aDefColor = Quantity_Color();
-    anInitColor = 
-      QColor ((int)( aDefColor.Red() * 255.0 ), (int)( aDefColor.Green() * 255.0 ), (int)( aDefColor.Blue() * 255.0 ) );
-  }
-  
-  QColor aDialogColor = QColorDialog::getColor(anInitColor, QAD_Application::getDesktop());
-  if(aDialogColor.isValid()) {
-    QApplication::setOverrideCursor(Qt::waitCursor);
-    
-    if( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC &&
-       QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
-      MESSAGE("Settings Color is not supported for current Viewer");
-    
-    QAD_CONFIG->addSetting("Geometry:SettingsShadingColorRed", aDialogColor.red());
-    QAD_CONFIG->addSetting("Geometry:SettingsShadingColorGreen", aDialogColor.green());
-    QAD_CONFIG->addSetting("Geometry:SettingsShadingColorBlue", aDialogColor.blue());  
-    QApplication::restoreOverrideCursor();
-  }
-}
+  SUIT_Session* sess = SUIT_Session::session();
+  SUIT_ResourceMgr* resMgr = sess->resourceMgr();
+  SUIT_Desktop* desk = sess->activeApplication()->desktop();
 
-void GEOMToolsGUI::OnSettingsIsos()
-{
-  if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
-    return;
-  
-  OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
-  Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
-  
-  QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
-  QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
-  
-  if(!IsoU.isEmpty())
-    ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
-  else
-    IsoU = "1";
-  if (!IsoV.isEmpty())
-    ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
-  else
-    IsoV = "1";
-  
-  GEOMBase_NbIsosDlg* NbIsosDlg = new GEOMBase_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE);    
-  int UIso = IsoU.toInt();
-  int VIso = IsoV.toInt();
-  
-  NbIsosDlg->SpinBoxU->setValue(UIso);
-  NbIsosDlg->SpinBoxV->setValue(VIso);
-  
-  if(NbIsosDlg->exec()) {
-    UIso = NbIsosDlg->SpinBoxU->text().toInt();
-    VIso = NbIsosDlg->SpinBoxV->text().toInt();
-    
-    ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso);
-    ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso);
-    QAD_CONFIG->addSetting("Geometry:SettingsIsoU", NbIsosDlg->SpinBoxU->text()); /* text format */
-    QAD_CONFIG->addSetting("Geometry:SettingsIsoV", NbIsosDlg->SpinBoxV->text()); /* text format */
-  }
-}
+  QColor anInitColor = resMgr->colorValue( "Geometry", "SettingsShadingColor", QColor( "yellow" ) );
 
-void GEOMToolsGUI::OnSettingsStep()
-{
-  QString step = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
-  if(step.isEmpty())
-    step = "100.0";
-  
-  Standard_Boolean res = false;
-  double dd = GEOMBase::Parameter(res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3);
-  if(res) {
-    QAD_CONFIG->addSetting("Geometry:SettingsGeomStep", QString("%1").arg(dd));
-    
-    /* Emit signal to GeometryGUI_SpinBoxes */
-    GeometryGUI::GetGeomGUI()->EmitSignalDefaultStepValueChanged(dd);
+  QColor aDialogColor = QColorDialog::getColor(anInitColor, desk );
+  if( aDialogColor.isValid() )
+  {
+    QString type = desk->activeWindow()->getViewManager()->getType();
+    if( type != OCCViewer_Viewer::Type() && type != SVTK_Viewer::Type() )
+      MESSAGE("Settings Color is not supported for current Viewer");
+
+    resMgr->setValue( "Geometry", "SettingsShadingColor", aDialogColor );
   }
-  else
-    QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
 }
 
 void GEOMToolsGUI::OnRename()
 {
-  SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
-  SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
-  
-  bool aLocked = aStudy->GetProperties()->IsLocked();
-  if ( aLocked ) {
-    QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
-                           QObject::tr("WRN_WARNING"), 
-                           QObject::tr("WRN_STUDY_LOCKED"),
-                           QObject::tr("BUT_OK") );
-    return;
-  }
-  
-  SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-  for(; It.More(); It.Next()) {
-    Handle(SALOME_InteractiveObject) IObject = It.Value();
-    
-    SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
-    SALOMEDS::GenericAttribute_var anAttr;
-    SALOMEDS::AttributeName_var aName;
-    if(!obj->_is_nil()) {
-      if(obj->FindAttribute(anAttr, "AttributeName")) {
-       aName = SALOMEDS::AttributeName::_narrow(anAttr);
-       
-       QString nm = QString(aName->Value());
-       nm = SALOMEGUI_NameDlg::getName(QAD_Application::getDesktop(), nm);
-       if(!nm.isEmpty()) {
-         QApplication::setOverrideCursor(Qt::waitCursor);
-         QAD_Application::getDesktop()->getActiveStudy()->renameIObject(IObject, nm);
-         QApplication::restoreOverrideCursor();
+  SALOME_ListIO selected;
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if ( app ) {
+    LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+    SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+    if ( aSelMgr && appStudy ) {
+      aSelMgr->selectedObjects( selected );
+      if ( !selected.IsEmpty() ) {
+       _PTR(Study) aStudy = appStudy->studyDS();
+
+       bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
+       if ( aLocked ) {
+         SUIT_MessageBox::warning ( app->desktop(),
+                                    QObject::tr("WRN_WARNING"),
+                                    QObject::tr("WRN_STUDY_LOCKED"),
+                                    QObject::tr("BUT_OK") );
+         return;
        }
+
+       for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+         Handle(SALOME_InteractiveObject) IObject = It.Value();
+
+         _PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) );
+         _PTR(GenericAttribute) anAttr;
+         if ( obj ) {
+           if( obj->FindAttribute(anAttr, "AttributeName") ) {
+             _PTR(AttributeName) aName (anAttr);
+
+             QString newName = LightApp_NameDlg::getName( app->desktop(), aName->Value().c_str() );
+             if ( !newName.isEmpty() ) {
+               aName->SetValue( newName.toLatin1().constData() ); // rename the SObject
+               IObject->setName( newName.toLatin1() );// rename the InteractiveObject
+               // Rename the corresponding GEOM_Object
+               GEOM::GEOM_Object_var anObj =  GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
+               if (!CORBA::is_nil( anObj ))
+                 anObj->SetName( newName.toLatin1() );
+               (dynamic_cast<SalomeApp_Module*>(app->activeModule()))->updateObjBrowser( false );
+             }
+           } // if ( name attribute )
+         } // if ( obj )
+       } // iterator
       }
     }
   }
+  
+  app->updateActions(); //SRN: To update a Save button in the toolbar
 }
 
 void GEOMToolsGUI::OnCheckGeometry()
 {
-  QAD_PyEditor* PyEditor = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getPyEditor();
-  PyEditor->setText("from GEOM_usinggeom import *\n");
-  PyEditor->handleReturn();
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  PyConsole_Console* pyConsole = app->pythonConsole();
+
+  if(pyConsole)
+    pyConsole->exec("from GEOM_usinggeom import *");
 }
 
-void GEOMToolsGUI::OnLoadScript()
+void GEOMToolsGUI::OnAutoColor()
 {
-  SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
-  bool aLocked = aStudy->GetProperties()->IsLocked();
-  if ( aLocked ) {
-    QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
-                           QObject::tr("WRN_WARNING"), 
-                           QObject::tr("WRN_STUDY_LOCKED"),
-                           QObject::tr("BUT_OK") );
+  QList<SALOME_Prs> aListOfGroups;
+
+  SALOME_ListIO selected;
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if( !app )
     return;
-  }
-  
-  QStringList filtersList;
-  filtersList.append(tr("GEOM_MEN_LOAD_SCRIPT"));
-  filtersList.append(tr("GEOM_MEN_ALL_FILES"));
-  
-  QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), "", filtersList, tr("GEOM_MEN_IMPORT"), true);
-  if(!aFile.isEmpty()) {
-    QFileInfo file = aFile;
-    QApplication::setOverrideCursor(Qt::waitCursor);
-    QAD_PyEditor* PyEditor = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getPyEditor();
-    
-    QStringList aTextList = QStringList::split(".", file.fileName());
-    
-    PyEditor->setText("import geompy; geompy.addPath('" + file.dirPath() + "'); from " + aTextList.first() + " import *\n" );
-    PyEditor->handleReturn();
-  }
-  QApplication::restoreOverrideCursor();
-}
 
-void GEOMToolsGUI::OnColor()
-{
-  SALOME_Selection* Sel = SALOME_Selection::Selection(
-    QAD_Application::getDesktop()->getActiveStudy()->getSelection() );
+  LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+  if( !aSelMgr || !appStudy )
+    return;
+
+  aSelMgr->selectedObjects( selected );
+  if( selected.IsEmpty() )
+    return;
+
+  Handle(SALOME_InteractiveObject) anIObject = selected.First();
+
+  _PTR(Study) aStudy = appStudy->studyDS();
+  _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
+  GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
+  if( CORBA::is_nil( aMainObject ) )
+    return;
+
+  aMainObject->SetAutoColor( true );
+
+  QList<SALOMEDS::Color> aReservedColors;
+
+  GEOM_Displayer aDisp (appStudy);
+
+  SALOME_View* vf = aDisp.GetActiveView();
 
-  if ( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
+  SUIT_ViewWindow* window = app->desktop()->activeWindow();
+  bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
+  bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
+
+  for( _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); it->More(); it->Next() )
   {
-    VTKViewer_RenderWindowInteractor* myRenderInter =
-      ( (VTKViewer_ViewFrame*)QAD_Application::getDesktop()->
-         getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
-    
-    SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
-    Handle(SALOME_InteractiveObject) FirstIOS =  Sel->firstIObject();
-    if ( !FirstIOS.IsNull() )
+    _PTR(SObject) aChildSObject( it->Value() );
+    GEOM::GEOM_Object_var aChildObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
+    if( CORBA::is_nil( aChildObject ) )
+      continue;
+
+    if( aChildObject->GetType() != GEOM_GROUP )
+      continue;
+
+    SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors );
+    aChildObject->SetColor( aColor );
+    aReservedColors.append( aColor );
+
+    QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) );
+
+    SALOME_Prs* aPrs = vf->CreatePrs( aChildSObject->GetID().c_str() );
+
+    if ( isVTK )
     {
-      QColor initcolor = myRenderInter->GetColor(FirstIOS);
-      QColor c = QColorDialog::getColor( initcolor, QAD_Application::getDesktop() );
-      
-      if ( c.isValid() )
-      {
-        QApplication::setOverrideCursor( Qt::waitCursor );
-        for ( ;It.More();It.Next() )
-        {
-          Handle(SALOME_InteractiveObject) IOS = It.Value();
-          myRenderInter->SetColor(IOS,c);
-        }
-      }
-      QApplication::restoreOverrideCursor();
+      SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
+      if ( !vtkVW )
+       return;
+      SVTK_View* aView = vtkVW->getView();
+      SUIT_OverrideCursor();
+      for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
+       aView->SetColor( It.Value(), c );
     }
-  }
-  else if( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
-  {
-    Handle(AIS_InteractiveObject) anIO = GEOMBase::GetAIS( Sel->firstIObject() );
-    if ( !anIO.IsNull() )
+    else if ( isOCC )
     {
-      Quantity_Color aColor;
-      anIO->Color( aColor );
-      
-      QColor qColor =  QColorDialog::getColor( QColor( (int)( aColor.Red() * 255.0 ),
-                                                       (int)( aColor.Green() * 255.0 ),
-                                                       (int)( aColor.Blue() * 255.0 ) ),
-                                               QAD_Application::getDesktop());
-      
-      if ( qColor.isValid() )
-      {
-        aColor = Quantity_Color( qColor.red() / 255.,
-                                 qColor.green() / 255.,
-                                 qColor.blue() / 255.,
-                                 Quantity_TOC_RGB );
-        
-        QApplication::setOverrideCursor( Qt::waitCursor );
-        
-        SALOME_ListIteratorOfListIO anIter ( Sel->StoredIObjects() );
-        for( ;anIter.More();anIter.Next() )
-        {
-          Handle(SALOME_InteractiveObject) IObject = anIter.Value();
-          Handle(AIS_InteractiveObject) anIO = GEOMBase::GetAIS( IObject, true );
-          if ( !anIO.IsNull() )
-          {
-            anIO->SetColor( aColor );
-
-            if ( anIO->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
-              Handle(GEOM_AISShape)::DownCast( anIO )->SetShadingColor( aColor );
-
-            anIO->Redisplay( Standard_True );
-          }
-        }
-      }
+      OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
+      Handle(AIS_InteractiveContext) ic = vm->getAISContext();
+
+      SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
+      if( !anOCCPrs )
+       continue;
+
+      AIS_ListOfInteractive aList;
+      anOCCPrs->GetObjects( aList );
+      if( !aList.Extent() )
+       continue;
+
+      Handle(AIS_InteractiveObject) io = aList.First();
+      if( io.IsNull() )
+       continue;
+
+      Quantity_Color aQuanColor( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
+
+      // Set color for a point
+      Handle(AIS_Drawer) aCurDrawer = io->Attributes();
+      Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
+      Quantity_Color aCurColor;
+      Standard_Real aCurScale;
+      Aspect_TypeOfMarker aCurTypeOfMarker;
+      aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
+      aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aQuanColor, aCurScale) );
+      ic->SetLocalAttributes( io, aCurDrawer );
+
+      io->SetColor( aQuanColor );
+      if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
+       Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aQuanColor );
+
+      io->Redisplay( Standard_True );
+    }
+  }
+
+  app->updateActions(); //SRN: To update a Save button in the toolbar
+}
+
+void GEOMToolsGUI::OnDisableAutoColor()
+{
+  SALOME_ListIO selected;
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if( !app )
+    return;
+
+  LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+  if( !aSelMgr || !appStudy )
+    return;
+
+  aSelMgr->selectedObjects( selected );
+  if( selected.IsEmpty() )
+    return;
+
+  Handle(SALOME_InteractiveObject) anIObject = selected.First();
+
+  _PTR(Study) aStudy = appStudy->studyDS();
+  _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
+  GEOM::GEOM_Object_var aMainObject =  GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
+  if( CORBA::is_nil( aMainObject ) )
+    return;
+
+  aMainObject->SetAutoColor( false );
+
+}
+
+void GEOMToolsGUI::OnColor()
+{
+  SALOME_ListIO selected;
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+  if ( app && appStudy ) {
+    LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+    if ( aSelMgr ) {
+      aSelMgr->selectedObjects( selected );
+      if ( !selected.IsEmpty() ) {
+       SUIT_ViewWindow* window = app->desktop()->activeWindow();
+       bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
+       bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
+       if ( isVTK ) {
+         SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
+         if ( !vtkVW )
+           return;
+         SVTK_View* aView = vtkVW->getView();
+         QColor initcolor = aView->GetColor( selected.First()  );
+         QColor c = QColorDialog::getColor( initcolor, app->desktop() );
+         if ( c.isValid() ) {
+           SUIT_OverrideCursor();
+           for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+             aView->SetColor( It.Value(), c );
+           }
+         }
+       } // if ( isVTK )
+       else if ( isOCC ) {
+         Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
+         if ( !io.IsNull() ) {
+           Quantity_Color aColor;
+           io->Color( aColor );
+           QColor initcolor( (int)( aColor.Red() * 255.0 ), (int)( aColor.Green() * 255.0 ), (int)( aColor.Blue() * 255.0 ) );
+           QColor c =  QColorDialog::getColor( initcolor, app->desktop() );
+           if ( c.isValid() ) {
+             SUIT_OverrideCursor();
+             aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
+             for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+               io = GEOMBase::GetAIS( It.Value(), true );
+               if ( !io.IsNull() ) {
+                 // Set color for a point
+                 OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
+                 Handle (AIS_InteractiveContext) ic = vm->getAISContext();
+                 Handle(AIS_Drawer) aCurDrawer = io->Attributes();
+                 Handle(Prs3d_PointAspect) aCurPointAspect =  aCurDrawer->PointAspect();
+                 Quantity_Color aCurColor;
+                 Standard_Real aCurScale;
+                 Aspect_TypeOfMarker aCurTypeOfMarker;
+                 aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
+                 aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aColor, aCurScale) );
+                 ic->SetLocalAttributes(io, aCurDrawer);
+                 
+                 io->SetColor( aColor );
+                 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
+                   Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aColor );
+
+                 io->Redisplay( Standard_True );
+
+                 // store color to GEOM_Object
+                 _PTR(Study) aStudy = appStudy->studyDS();
+                 _PTR(SObject) aSObject( aStudy->FindObjectID( It.Value()->getEntry() ) );
+                 GEOM::GEOM_Object_var anObject =
+                   GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
+
+                 SALOMEDS::Color aSColor;
+                 aSColor.R = (double)c.red() / 255.0;
+                 aSColor.G = (double)c.green() / 255.0;
+                 aSColor.B = (double)c.blue() / 255.0;
+                 anObject->SetColor( aSColor );
+                 anObject->SetAutoColor( false );
+               }
+             }
+           } // if c.isValid()
+         } // first IO is not null
+       } // if ( isOCC )
+      } // if ( selection not empty )
     }
   }
   
-  QApplication::restoreOverrideCursor();
+  app->updateActions(); //SRN: To update a Save button in the toolbar
 }
 
 void GEOMToolsGUI::OnTransparency()
 {
-  Handle(AIS_InteractiveContext) ic;
-  SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
-  if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
-    OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
-    ic = v3d->getAISContext();
-  }
-  new GEOMBase_TransparencyDlg(QAD_Application::getDesktop(), "", Sel, ic);
+  GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
+  dlg.exec();
 }
 
 void GEOMToolsGUI::OnNbIsos()
 {
-  if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
-    return;
-  
-  OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
-  Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+  SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
   
-  ic->InitCurrent();
-  if(ic->MoreCurrent()) {
-    Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
-    Handle(AIS_Drawer)    CurDrawer = CurObject->Attributes();
+  bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
+  bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
+
+  if(isOCC){ // if is OCCViewer
+
+    OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
+    Handle (AIS_InteractiveContext) ic = vm->getAISContext();
+
+    ic->InitCurrent();
+    if ( ic->MoreCurrent() ) {
+      Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
+      Handle(AIS_Drawer)    CurDrawer = CurObject->Attributes();
+      
+      int UIso = CurDrawer->UIsoAspect()->Number();
+      int VIso = CurDrawer->VIsoAspect()->Number();
+      
+      GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
+       new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
+      
+      NbIsosDlg->setU( UIso );
+      NbIsosDlg->setV( VIso );
+      
+      if ( NbIsosDlg->exec() ) {
+       SUIT_OverrideCursor();
+       for(; ic->MoreCurrent(); ic->NextCurrent()) {
+         CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
+         Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
+         
+         int nbUIso = NbIsosDlg->getU();
+         int nbVIso = NbIsosDlg->getV();
+         
+         CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbUIso) );
+         CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbVIso) );
+         
+         ic->SetLocalAttributes(CurObject, CurDrawer);
+         ic->Redisplay(CurObject);
+       }
+      }
+    }
+  }
+  else if(isVTK){ // if is VTKViewer
+    //
+    // Warning. It's works incorrect. must be recheked.
+    //
+    SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+    if ( !app )
+      return;
+    LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+    if ( !aSelMgr )
+      return;
+    SALOME_ListIO selected;
+    aSelMgr->selectedObjects( selected );
+    if ( selected.IsEmpty() )
+      return;
+    
+    Handle(SALOME_InteractiveObject) FirstIOS =  selected.First();
+    if ( FirstIOS.IsNull() )
+      return;
+    
+    SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
+    if ( !vtkVW )
+      return;
     
-    int UIso = CurDrawer->UIsoAspect()->Number();
-    int VIso = CurDrawer->VIsoAspect()->Number();
+    SVTK_View* aView = vtkVW->getView();
+    vtkActorCollection* aCollection = aView->getRenderer()->GetActors();
     
-    GEOMBase_NbIsosDlg * NbIsosDlg =
-      new GEOMBase_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE);
+    int UIso = 0;
+    int VIso = 0;
+    if(aCollection){
+      aCollection->InitTraversal();
+    }
     
-    NbIsosDlg->SpinBoxU->setValue( UIso );
-    NbIsosDlg->SpinBoxV->setValue( VIso );
+    vtkActor *anAct = aCollection->GetNextActor();
+    if(GEOM_Actor *anActor = dynamic_cast<GEOM_Actor*>(anAct)){
+      anActor->GetNbIsos(UIso,VIso);
+    }
     
-    if(NbIsosDlg->exec()) {
-      QApplication::setOverrideCursor(Qt::waitCursor);
-      for(; ic->MoreCurrent(); ic->NextCurrent()) {
-        CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
-       Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
-       
-       int nbUIso = NbIsosDlg->SpinBoxU->text().toInt();
-       int nbVIso = NbIsosDlg->SpinBoxV->text().toInt();
-       
-       CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbUIso) );
-       CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbVIso) );
-       
-       ic->SetLocalAttributes(CurObject, CurDrawer);
-       ic->Redisplay(CurObject);
+    GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
+      new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
+
+    NbIsosDlg->setU( UIso );
+    NbIsosDlg->setV( VIso );
+
+    if ( NbIsosDlg->exec() ) {
+      SUIT_OverrideCursor();
+      
+      while(anAct = aCollection->GetNextActor()) {
+       if(GEOM_Actor *anActor = dynamic_cast<GEOM_Actor*>(anAct)){
+         // There are no casting to needed actor.
+         UIso = NbIsosDlg->getU();
+         VIso = NbIsosDlg->getV();
+         int aIsos[2]={UIso,VIso};
+         anActor->SetNbIsos(aIsos);
+       }
       }
     }
-  }
-  QApplication::restoreOverrideCursor();
+  } // end vtkviewer
 }
 
 void GEOMToolsGUI::OnOpen()
 {
+/*
   SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
-  SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
+  _PTR(Study) aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
 
   SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
   Handle(SALOME_InteractiveObject) anIObject;
   for(;It.More();It.Next()) {
     anIObject = It.Value();
-    SALOMEDS::SObject_var obj = aStudy->FindObjectID(anIObject->getEntry());
-    SALOMEDS::AttributePersistentRef_var aPersist;
-    SALOMEDS::AttributeIOR_var anIOR;
-    if(!obj->_is_nil()) {
+    _PTR(SObject) obj ( aStudy->FindObjectID(anIObject->getEntry()) );
+    _PTR(AttributePersistentRef) aPersist;
+    _PTR(AttributeIOR) anIOR;
+    if(obj) {
       // this SObject may be GEOM module root SObject
-      SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(obj);
-      SALOMEDS::GenericAttribute_var anAttr;
+      _PTR(ChildIterator) anIter ( aStudy->NewChildIterator() );
+      _PTR(GenericAttribute) anAttr;
       bool useSubItems = false;
       while (anIter->More() && !useSubItems) {
-       SALOMEDS::SObject_var subobj = anIter->Value();
+       _PTR(SObject) subobj ( anIter->Value() );
        if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) {
          useSubItems = true;
-         obj = subobj;
+         obj =  subobj;
        }
-       else 
+       else
          anIter->Next();
       }
       obj->FindAttribute(anAttr, "AttributePersistentRef");
-             
-      while(useSubItems?anIter->More():!anAttr->_is_nil()) { 
+
+      while(useSubItems?anIter->More():!anAttr->_is_nil()) {
        if(!obj->FindAttribute(anAttr, "AttributeIOR") &&
           obj->FindAttribute(anAttr, "AttributePersistentRef")) {
-         SALOMEDS::SComponent_var FComp = obj->GetFatherComponent();
-         if (!CORBA::is_nil(FComp)) {
+         _PTR(SComponent) FComp ( obj->GetFatherComponent() );
+         if (FComp) {
            if (FComp->FindAttribute(anAttr, "AttributeName")) {
-             SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
-             QString compName = QAD_Application::getDesktop()->getComponentName(aName->Value());
+             _PTR(AttributeName) aName ( anAttr );
+             QString compName = QAD_Application::getDesktop()->getComponentName(aName->Value().c_str());
              //                    parent->loadComponentData(parent->getComponentName(aName->Value()));
              Engines::Component_var comp ;
              if ( compName.compare("SUPERV") == 0 ) {
@@ -409,13 +533,13 @@ void GEOMToolsGUI::OnOpen()
              if (!CORBA::is_nil(comp)) {
                SALOMEDS::Driver_var   driver = SALOMEDS::Driver::_narrow(comp);
                if (!CORBA::is_nil(driver)) {
-                 SALOMEDS::StudyBuilder_var  B = aStudy->NewBuilder();
+                 SALOMEDS::StudyBuilder_var  B = dynamic_cast<SALOMEDS_Study*>(aStudy.get())->GetStudy()->NewBuilder();
                  if (!CORBA::is_nil(B)) {
                    B->LoadWith(FComp,driver);
                  } else {
                    return;
                  }
-               } 
+               }
                else {
                  MESSAGE("loadComponentData(): Driver is null");
                  return;
@@ -433,7 +557,7 @@ void GEOMToolsGUI::OnOpen()
                //                SALOMEDS::SComponent_var SC = aStudy->FindComponent("GEOM");
                //                if (!CORBA::is_nil(SC))
                //                  aStudyBuilder->LoadWith(SC,driver);
-           } 
+           }
          }
          else {
            MESSAGE("Component is null");
@@ -441,11 +565,23 @@ void GEOMToolsGUI::OnOpen()
        }
        if(useSubItems) {
          anIter->Next();
-         obj = anIter->Value();
-       } 
-       else 
-         anAttr = SALOMEDS::GenericAttribute::_nil();
+         obj.reset( anIter->Value() );
+       }
+       else
+         anAttr = NULL;
       }
     }
   }
+*/
+}
+
+void GEOMToolsGUI::OnSelectOnly(int mode)
+{
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if ( app ) {
+    SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+    GEOM_Displayer aDisp (appStudy);
+    aDisp.GlobalSelection(mode);
+    getGeometryGUI()->setLocalSelectionMode(mode);
+  }
 }