Salome HOME
Implement 'make dist' and 'make distcheck' steps support
[modules/geom.git] / src / GEOMGUI / GeometryGUI.cxx
index 3f462d90d08a8fcecfb42519b9a97aff5dc9c094..3fdf39984e943c75f0c03d766eb7df365ad70293 100644 (file)
@@ -1,35 +1,35 @@
-//  GEOM GEOMGUI : GUI for Geometry component
+// 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
+// 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 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+// File   : GeometryGUI.cxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
 //
-//
-//  File   : GeometryGUI.cxx
-//  Author : Lucien PIGNOLONI
-//  Module : GEOM
-//  $Header$
 
 #include "GeometryGUI.h"
 #include "GEOMGUI_OCCSelector.h"
 #include "GEOMGUI_Selection.h"
 #include "GEOM_Displayer.h"
+#include "GEOM_AISShape.hxx"
+
+#include "GEOM_Actor.h"
 
 #include <SUIT_Desktop.h>
 #include <SUIT_MessageBox.h>
 #include <OCCViewer_ViewModel.h>
 #include <OCCViewer_ViewManager.h>
 
+#include <SOCC_ViewModel.h>
+#include <SOCC_ViewWindow.h>
+
 #include <SVTK_ViewWindow.h>
 #include <SVTK_RenderWindowInteractor.h>
 #include <SVTK_InteractorStyle.h>
 #include <SVTK_ViewModel.h>
 
 #include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
+
 #include <LightApp_SelectionMgr.h>
 #include <LightApp_VTKSelector.h>
-#include <SalomeApp_Study.h>
+#include <LightApp_DataObject.h>
 #include <LightApp_Preferences.h>
+
 #include <SALOME_LifeCycleCORBA.hxx>
 #include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
+
+#include <SALOMEDSClient_ClientFactory.hxx>
+#include <SALOMEDSClient_IParameters.hxx>
 
 // External includes
 #include <QAction>
 #include <QString>
 #include <QPainter>
 
+#include <AIS_Drawer.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_IsoAspect.hxx>
 #include <Aspect_TypeOfMarker.hxx>
 #include <OSD_SharedLibrary.hxx>
+#include <NCollection_DataMap.hxx>
 
 #include <utilities.h>
 
@@ -349,17 +363,17 @@ void GeometryGUI::OnGUIEvent( int id )
       id == 2175 ||  // POPUP VIEWER - SELECT ONLY - SHELL
       id == 2176 ||  // POPUP VIEWER - SELECT ONLY - SOLID
       id == 2177 ||  // POPUP VIEWER - SELECT ONLY - COMPOUND
-      id == 2178 ||  // POPUP VIEWER - SELECT ONLY - SELECT ALL      
+      id == 2178 ||  // POPUP VIEWER - SELECT ONLY - SELECT ALL
       id == 31   ||  // MENU EDIT - COPY
       id == 33   ||  // MENU EDIT - DELETE
       id == 411  ||  // MENU SETTINGS - ADD IN STUDY
       id == 412  ||  // MENU SETTINGS - SHADING COLOR
-      id == 413  ||  // MENU SETTINGS - ISOS
-      id == 414  ||  // MENU SETTINGS - STEP VALUE FOR SPIN BOXES
       id == 5103 ||  // MENU TOOLS - CHECK GEOMETRY
       id == 8032 ||  // POPUP VIEWER - COLOR
       id == 8033 ||  // POPUP VIEWER - TRANSPARENCY
       id == 8034 ||  // POPUP VIEWER - ISOS
+      id == 8035 ||  // POPUP VIEWER - AUTO COLOR
+      id == 8036 ||  // POPUP VIEWER - DISABLE AUTO COLOR
       id == 804  ||  // POPUP VIEWER - ADD IN STUDY
       id == 901  ||  // OBJECT BROWSER - RENAME
       id == 9024 ) { // OBJECT BROWSER - OPEN
@@ -404,7 +418,9 @@ void GeometryGUI::OnGUIEvent( int id )
           id == 4022 ||  // MENU PRIMITIVE - CYLINDER
           id == 4023 ||  // MENU PRIMITIVE - SPHERE
           id == 4024 ||  // MENU PRIMITIVE - TORUS
-          id == 4025 ) { // MENU PRIMITIVE - CONE
+          id == 4025 ||  // MENU PRIMITIVE - CONE
+          id == 4026 ||  // MENU PRIMITIVE - FACE
+          id == 4027 ) { // MENU PRIMITIVE - DISK
 #ifndef WNT
        library = getLibrary( "libPrimitiveGUI.so" );
 #else
@@ -469,7 +485,8 @@ void GeometryGUI::OnGUIEvent( int id )
           id == 504 ||   // MENU OPERATION - ARCHIMEDE
           id == 505 ||   // MENU OPERATION - FILLET
           id == 506 ||   // MENU OPERATION - CHAMFER
-          id == 507 ) {  // MENU OPERATION - CLIPPING RANGE
+          id == 507 ||   // MENU OPERATION - CLIPPING RANGE
+          id == 508 ) {  // MENU OPERATION - GET SHAPES ON SHAPE
 #ifndef WNT
        library = getLibrary( "libOperationGUI.so" );
 #else
@@ -483,10 +500,11 @@ void GeometryGUI::OnGUIEvent( int id )
            id == 606 ||   // MENU REPAIR - CLOSE CONTOUR
            id == 607 ||   // MENU REPAIR - REMOVE INTERNAL WIRES
            id == 608 ||   // MENU REPAIR - ADD POINT ON EDGE
-           id == 609 ||   // MENU REPAIR - FREE BOUNDARIES
-           id == 610 ||   // MENU REPAIR - FREE FACES
+           id == 609 ||   // MENU MEASURE - FREE BOUNDARIES
+           id == 610 ||   // MENU MEASURE - FREE FACES
            id == 611 ||   // MENU REPAIR - CHANGE ORIENTATION
-          id == 602 ) {  // MENU REPAIR - GLUE FACES
+          id == 602 ||   // MENU REPAIR - GLUE FACES
+          id == 612 ) {  // MENU REPAIR - REMOVE EXTRA EDGES
 #ifndef WNT
        library = getLibrary( "libRepairGUI.so" );
 #else
@@ -496,8 +514,10 @@ void GeometryGUI::OnGUIEvent( int id )
   else if( id == 701   ||  // MENU MEASURE - PROPERTIES
           id == 702   ||  // MENU MEASURE - CDG
           id == 703   ||  // MENU MEASURE - INERTIA
+          id == 704   ||  // MENU MEASURE - NORMALE
           id == 7041  ||  // MENU MEASURE - BOUNDING BOX
           id == 7042  ||  // MENU MEASURE - MIN DISTANCE
+          id == 7043  ||  // MENU MEASURE - ANGLE
           id == 705   ||  // MENU MEASURE - TOLERANCE
           id == 706   ||  // MENU MEASURE - WHATIS
           id == 707   ||  // MENU MEASURE - CHECK
@@ -738,7 +758,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   createGeomAction( 111, "IMPORT", "", (CTRL + Key_I) );
   createGeomAction( 121, "EXPORT", "", (CTRL + Key_E) );
 
-  createGeomAction( 33, "DELETE" );
+  createGeomAction( 33, "DELETE", "", Qt::Key_Delete );
 
   createGeomAction( 4011, "POINT" );
   createGeomAction( 4012, "LINE" );
@@ -756,6 +776,8 @@ void GeometryGUI::initialize( CAM_Application* app )
   createGeomAction( 4023, "SPHERE" );
   createGeomAction( 4024, "TORUS" );
   createGeomAction( 4025, "CONE" );
+  createGeomAction( 4026, "FACE" );
+  createGeomAction( 4027, "DISK" );
 
   createGeomAction( 4031, "EXTRUSION" );
   createGeomAction( 4032, "REVOLUTION" );
@@ -797,6 +819,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   createGeomAction( 505, "FILLET" );
   createGeomAction( 506, "CHAMFER" );
   //createGeomAction( 507, "CLIPPING" );
+  createGeomAction( 508, "GET_SHAPES_ON_SHAPES" );
 
   createGeomAction( 9998, "MUL_TRANSFORM" );
   createGeomAction( 9995, "EXPLODE_BLOCKS" );
@@ -813,24 +836,26 @@ void GeometryGUI::initialize( CAM_Application* app )
   createGeomAction( 609, "CHECK_FREE_BNDS" );
   createGeomAction( 610, "CHECK_FREE_FACES" );
   createGeomAction( 611, "CHANGE_ORIENTATION" );
+  createGeomAction( 612, "REMOVE_EXTRA_EDGES" );
 
   createGeomAction( 708, "POINT_COORDS" );
   createGeomAction( 701, "BASIC_PROPS" );
   createGeomAction( 702, "MASS_CENTER" );
   createGeomAction( 703, "INERTIA" );
+  createGeomAction( 704, "NORMALE" );
   createGeomAction( 7041, "BND_BOX" );
   createGeomAction( 7042, "MIN_DIST" );
+  createGeomAction( 7043, "MEASURE_ANGLE" );
 
   createGeomAction( 705, "TOLERANCE" );
   createGeomAction( 706, "WHAT_IS" );
   createGeomAction( 707, "CHECK" );
   createGeomAction( 7072, "CHECK_COMPOUND" );
 
+#ifdef _DEBUG_ // PAL16821
   createGeomAction( 5103, "CHECK_GEOMETRY" );
-
+#endif
   createGeomAction( 412, "SHADING_COLOR" );
-  createGeomAction( 413, "ISOS" );
-  createGeomAction( 414, "STEP_VALUE" );
 
   createGeomAction( 211, "SHADING" );
   createGeomAction( 212, "DISPLAY_ALL" );
@@ -847,12 +872,14 @@ void GeometryGUI::initialize( CAM_Application* app )
   createGeomAction( 213, "DISPLAY_ONLY" );
   createGeomAction( 215, "ERASE" );
 
-  createGeomAction( 901, "POP_RENAME" );
+  createGeomAction( 901, "POP_RENAME", "", Qt::Key_F2 );
   createGeomAction( 80311, "POP_WIREFRAME", "", 0, true );
   createGeomAction( 80312, "POP_SHADING", "", 0, true );
   createGeomAction( 8032, "POP_COLOR" );
   createGeomAction( 8033, "POP_TRANSPARENCY" );
   createGeomAction( 8034, "POP_ISOS" );
+  createGeomAction( 8035, "POP_AUTO_COLOR" );
+  createGeomAction( 8036, "POP_DISABLE_AUTO_COLOR" );
   createGeomAction( 8001, "POP_CREATE_GROUP" );
 
   // make wireframe-shading items to be exclusive (only one at a time is selected)
@@ -891,6 +918,8 @@ void GeometryGUI::initialize( CAM_Application* app )
   createMenu( 4023, primId, -1 );
   createMenu( 4024, primId, -1 );
   createMenu( 4025, primId, -1 );
+  createMenu( 4026, primId, -1 );
+  createMenu( 4027, primId, -1 );
 
   int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
   createMenu( 4031, genId, -1 );
@@ -942,6 +971,7 @@ void GeometryGUI::initialize( CAM_Application* app )
 
   createMenu( 503, operId, -1 );
   createMenu( 504, operId, -1 );
+  createMenu( 508, operId, -1 );
   createMenu( separator(), operId, -1 );
   createMenu( 505, transId, -1 );
   createMenu( 506, transId, -1 );
@@ -961,9 +991,10 @@ void GeometryGUI::initialize( CAM_Application* app )
   createMenu( 601, repairId, -1 );
   createMenu( 602, repairId, -1 );
   createMenu( 608, repairId, -1 );
-  createMenu( 609, repairId, -1 );
-  createMenu( 610, repairId, -1 );
+  //createMenu( 609, repairId, -1 );
+  //createMenu( 610, repairId, -1 );
   createMenu( 611, repairId, -1 );
+  createMenu( 612, repairId, -1 );
 
   int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
   createMenu( 708, measurId, -1 );
@@ -971,11 +1002,18 @@ void GeometryGUI::initialize( CAM_Application* app )
   createMenu( separator(), measurId, -1 );
   createMenu( 702, measurId, -1 );
   createMenu( 703, measurId, -1 );
+  createMenu( 704, measurId, -1 );
+  // NPAL16572: move "Check free boundaries" and "Check free faces" from "Repair" to "Measure"
+  createMenu( separator(), measurId, -1 );
+  createMenu( 609, measurId, -1 );
+  createMenu( 610, measurId, -1 );
+  // NPAL16572 END
   createMenu( separator(), measurId, -1 );
 
   int dimId = createMenu( tr( "MEN_DIMENSIONS" ), measurId, -1 );
   createMenu( 7041, dimId, -1 );
   createMenu( 7042, dimId, -1 );
+  createMenu( 7043, dimId, -1 );
   createMenu( separator(), measurId, -1 );
 
   createMenu( 705, measurId, -1 );
@@ -984,16 +1022,15 @@ void GeometryGUI::initialize( CAM_Application* app )
   createMenu( 707, measurId, -1 );
   createMenu( 7072, measurId, -1 );
 
+#ifdef _DEBUG_ // PAL16821
   int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 );
   createMenu( separator(), toolsId, -1 );
   createMenu( 5103, toolsId, -1 );
-
+#endif
   //int prefId = createMenu( tr( "MEN_PREFERENCES" ), -1, -1, 50 );
   //createMenu( separator(), prefId, -1 );
   //int geomId = createMenu( tr( "MEN_PREFERENCES_GEOM" ), prefId, -1 );
   //createMenu( 412, geomId, -1 );
-  //createMenu( 413, geomId, -1 );
-  //createMenu( 414, geomId, -1 );
   //createMenu( separator(), prefId, -1 );
 
   int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 );
@@ -1037,6 +1074,8 @@ void GeometryGUI::initialize( CAM_Application* app )
   createTool( 4023, primTbId );
   createTool( 4024, primTbId );
   createTool( 4025, primTbId );
+  createTool( 4026, primTbId );
+  createTool( 4027, primTbId );
 
   int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
   createTool( 5011, boolTbId );
@@ -1066,9 +1105,17 @@ void GeometryGUI::initialize( CAM_Application* app )
   QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
   QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
 
+  QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
+  QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
+
+  QString autoColorPrefix =
+    "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
+
   QtxPopupMgr* mgr = popupMgr();
   mgr->insert( action(  901 ), -1, -1 );  // rename
   mgr->setRule( action( 901 ), QString("$type in {'Shape' 'Group'} and selcount=1"), QtxPopupMgr::VisibleRule );
+  mgr->insert( action(   33 ), -1, -1 );  // delete
+  mgr->setRule( action(  33 ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
   mgr->insert( action(  8001 ), -1, -1 ); // create group
   mgr->setRule( action( 8001 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
   mgr->insert( action(  801 ), -1, -1 );  // edit group
@@ -1083,11 +1130,16 @@ void GeometryGUI::initialize( CAM_Application* app )
   mgr->setRule( action( 80312 ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
   mgr->insert( separator(), -1, -1 );     // -----------
   mgr->insert( action(  8032 ), -1, -1 ); // color
-  mgr->setRule( action( 8032 ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
+  mgr->setRule( action( 8032 ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
   mgr->insert( action(  8033 ), -1, -1 ); // transparency
   mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
   mgr->insert( action(  8034 ), -1, -1 ); // isos
-  mgr->setRule( action( 8034 ), QString("client='OCCViewer' and selcount>0 and isVisible"), QtxPopupMgr::VisibleRule );
+  mgr->setRule( action( 8034 ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
+  mgr->insert( separator(), -1, -1 );     // -----------
+  mgr->insert( action(  8035 ), -1, -1 ); // auto color
+  mgr->setRule( action( 8035 ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
+  mgr->insert( action(  8036 ), -1, -1 ); // disable auto color
+  mgr->setRule( action( 8036 ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
   mgr->insert( separator(), -1, -1 );     // -----------
 
 
@@ -1106,7 +1158,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   mgr->setRule( action( 214 ), clientOCCorVTK, QtxPopupMgr::VisibleRule );
 
   QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)";
-  
+
   int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1);                //select only menu
   mgr->insert( action(2171), selectolnyId, -1);                                  //Vertex
   mgr->setRule(action(2171), selectOnly, QtxPopupMgr::VisibleRule);
@@ -1133,7 +1185,6 @@ void GeometryGUI::initialize( CAM_Application* app )
   mgr->insert( action(2178), selectolnyId, -1);                                  //Clear selection filter
   mgr->setRule(action(2178), selectOnly, QtxPopupMgr::VisibleRule);
   mgr->setRule(action(2178), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
-  
   mgr->insert( action(  213 ), -1, -1 ); // display only
   mgr->setRule( action( 213 ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
   mgr->insert( separator(), -1, -1 );
@@ -1164,14 +1215,17 @@ bool GeometryGUI::activateModule( SUIT_Study* study )
   // Reset actions accelerator keys
   //action(111)->setAccel(QKeySequence(CTRL + Key_I)); // Import
   //action(121)->setAccel(QKeySequence(CTRL + Key_E)); // Export
-  action(111)->setEnabled(true); // Import
-  action(121)->setEnabled(true); // Export
+  action(111)->setEnabled( true ); // Import: CTRL + Key_I
+  action(121)->setEnabled( true ); // Export: CTRL + Key_E
+  action( 33)->setEnabled( true ); // Delete: Key_Delete
+  action(901)->setEnabled( true ); // Rename: Key_F2
 
   GUIMap::Iterator it;
   for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it )
     it.value()->activate( application()->desktop() );
 
   LightApp_SelectionMgr* sm = getApp()->selectionMgr();
+
   SUIT_ViewManager* vm;
   ViewManagerList OCCViewManagers, VTKViewManagers;
 
@@ -1185,13 +1239,18 @@ bool GeometryGUI::activateModule( SUIT_Study* study )
   while ( itVTK.hasNext() && (vm = itVTK.next()) )
     myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast<SVTK_Viewer*>( vm->getViewModel() ), sm ) );
 
+  //NPAL 19674
+  SALOME_ListIO selected;
+  sm->selectedObjects( selected );
+  sm->clearSelected();
+  
   // disable OCC selectors
   getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() );
   QListIterator<GEOMGUI_OCCSelector*> itOCCSel( myOCCSelectors );
   while ( itOCCSel.hasNext() )
     if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() )
       sr->setEnabled(true);
-  
+
   // disable VTK selectors
   getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() );
   QListIterator<LightApp_VTKSelector*> itVTKSel( myVTKSelectors );
@@ -1199,6 +1258,8 @@ bool GeometryGUI::activateModule( SUIT_Study* study )
     if ( LightApp_VTKSelector* sr = itVTKSel.next() )
       sr->setEnabled(true);
 
+  sm->setSelectedObjects( selected, true );   //NPAL 19674
+
   return true;
 }
 
@@ -1224,12 +1285,16 @@ bool GeometryGUI::deactivateModule( SUIT_Study* study )
   // Unset actions accelerator keys
   //action(111)->setAccel(QKeySequence()); // Import
   //action(121)->setAccel(QKeySequence()); // Export
-  action(111)->setEnabled(false); // Import
-  action(121)->setEnabled(false); // Export
+  action(111)->setEnabled( false ); // Import: CTRL + Key_I
+  action(121)->setEnabled( false ); // Export: CTRL + Key_E
+  action( 33)->setEnabled( false ); // Delete: Key_Delete
+  action(901)->setEnabled( false ); // Rename: Key_F2
 
+  qDeleteAll(myOCCSelectors);
   myOCCSelectors.clear();
   getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() );
 
+  qDeleteAll(myVTKSelectors);
   myVTKSelectors.clear();
   getApp()->selectionMgr()->setEnabled( true, SVTK_Viewer::Type() );
 
@@ -1255,7 +1320,7 @@ void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
     return;
 
   const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
-//  const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
+  //const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
 
   // disable non-OCC viewframe menu commands
 //  action( 404 )->setEnabled( ViewOCC ); // SKETCHER
@@ -1265,7 +1330,6 @@ void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
   action( 607 )->setEnabled( ViewOCC ); // RemoveInternalWires
   action( 608 )->setEnabled( ViewOCC ); // AddPointOnEdge
 //  action( 609 )->setEnabled( ViewOCC ); // Free boundaries
-  action( 413 )->setEnabled( ViewOCC ); // Isos Settings
 
   action( 800 )->setEnabled( ViewOCC ); // Create Group
   action( 801 )->setEnabled( ViewOCC ); // Edit Group
@@ -1350,19 +1414,14 @@ void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
 
 QString GeometryGUI::engineIOR() const
 {
-  QString anIOR = QString::null;
   if ( !CORBA::is_nil( GetGeomGen() ) )
-  {
-    CORBA::String_var objStr = getApp()->orb()->object_to_string( GetGeomGen() );
-    anIOR = QString( objStr.in() );
-//    free( objStr ); ASV : 26.07.06 : commented out because it raises exception and blocks application
-  }
-  return anIOR;
+    return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
+  return "";
 }
 
-LightApp_Selection* GeometryGUI::createSelection( const QString& client, LightApp_SelectionMgr* mgr ) const
+LightApp_Selection* GeometryGUI::createSelection() const
 {
-  return new GEOMGUI_Selection( client, mgr );
+  return new GEOMGUI_Selection();
 }
 
 void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
@@ -1385,10 +1444,11 @@ void GeometryGUI::createPreferences()
   int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) );
 
   int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId );
-  setPreferenceProperty( genGroup, "columns", 1 );
+  setPreferenceProperty( genGroup, "columns", 2 );
 
   int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup,
-                           LightApp_Preferences::Selector, "Geometry", "display_mode" );
+                               LightApp_Preferences::Selector, 
+                               "Geometry", "display_mode" );
 
   addPreference( tr( "PREF_SHADING_COLOR" ), genGroup,
                 LightApp_Preferences::Color, "Geometry", "shading_color" );
@@ -1412,6 +1472,7 @@ void GeometryGUI::createPreferences()
                            LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
 
   int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId );
+  setPreferenceProperty( VertexGroup, "columns", 2 );
 
   int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), VertexGroup,
                                     LightApp_Preferences::Selector, "Geometry", "type_of_marker" );
@@ -1432,7 +1493,7 @@ void GeometryGUI::createPreferences()
   setPreferenceProperty( dispmode, "indexes", anIndexesList );
 
   // Set property for step value for spinboxes
-  setPreferenceProperty( step, "min", 0.001 );
+  setPreferenceProperty( step, "min", 1 );
   setPreferenceProperty( step, "max", 10000 );
   setPreferenceProperty( step, "precision", 3 );
 
@@ -1505,3 +1566,440 @@ int GeometryGUI::getLocalSelectionMode() const
 {
   return myLocalSelectionMode;
 }
+
+const char gSeparator = '_'; // character used to separate parameter names
+const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
+
+/*!
+ * \brief Store visual parameters
+ *
+ * This method is called just before the study document is saved.
+ * Store visual parameters in AttributeParameter attribue(s)
+ */
+void GeometryGUI::storeVisualParameters (int savePoint)
+{
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
+  if (!appStudy || !appStudy->studyDS())
+    return;
+  _PTR(Study) studyDS = appStudy->studyDS();
+
+  // componentName is used for encoding of entries when storing them in IParameters
+  std::string componentName = myComponentGeom->ComponentDataType();
+  //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
+  //if (!aSComponent) return;
+
+  // IParameters
+  _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
+                                                             componentName.c_str(),
+                                                             savePoint);
+  _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
+
+  // viewers counters are used for storing view_numbers in IParameters
+  int vtkViewers(0), occViewers(0);
+
+  QList<SUIT_ViewManager*> lst;
+  QList<SUIT_ViewManager*>::Iterator it;
+
+  // main cycle to store parameters of displayed objects
+  lst.clear();
+  vtkViewers = occViewers = 0;
+  getApp()->viewManagers(lst);
+  for (it = lst.begin(); it != lst.end(); it++)
+  {
+    SUIT_ViewManager* vman = *it;
+    QString vType = vman->getType();
+
+    // saving VTK actors properties
+    if (vType == SVTK_Viewer::Type())
+    {
+      QVector<SUIT_ViewWindow*> views = vman->getViews();
+      for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
+      {
+       if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
+        {
+         vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
+         allActors->InitTraversal();
+         while (vtkActor* actor = allActors->GetNextActor())
+          {
+           if (actor->GetVisibility()) // store only visible actors
+            {
+              GEOM_Actor* aGeomActor = 0;
+              if (actor->IsA("GEOM_Actor"))
+                aGeomActor = GEOM_Actor::SafeDownCast(actor);
+             if (aGeomActor && aGeomActor->hasIO())
+              {
+                Handle(SALOME_InteractiveObject) io = aGeomActor->getIO();
+                if (io->hasEntry())
+                {
+                  // entry is "encoded" = it does NOT contain component adress, since it is a
+                  // subject to change on next component loading
+                  std::string entry = ip->encodeEntry(io->getEntry(), componentName);
+
+                  std::string param, occParam = vType.toLatin1().data();
+                  occParam += gSeparator;
+                  occParam += QString::number(vtkViewers).toLatin1().data();
+                  occParam += gSeparator;
+
+                  param = occParam + "Visibility";
+                  ip->setParameter(entry, param, "On");
+
+                  param = occParam + "DisplayMode";
+                  ip->setParameter(entry, param, QString::number
+                                   (aGeomActor->getDisplayMode()).toLatin1().data());
+
+                  vtkFloatingPointType r, g, b;
+                  aGeomActor->GetColor(r, g, b);
+                  QString colorStr = QString::number(r);
+                  colorStr += gDigitsSep; colorStr += QString::number(g);
+                  colorStr += gDigitsSep; colorStr += QString::number(b);
+                  param = occParam + "Color";
+                  ip->setParameter(entry, param, colorStr.toLatin1().data());
+
+                  param = occParam + "Opacity";
+                  ip->setParameter(entry, param, QString::number(aGeomActor->GetOpacity()).toLatin1().data());
+
+                  int nbUIso(0), nbVIso(0);
+                  aGeomActor->GetNbIsos(nbUIso,nbVIso);
+                  QString isosStr = QString::number(nbUIso);
+                  isosStr += gDigitsSep;
+                  isosStr += QString::number(nbVIso);
+                  param = occParam + "Isos";
+                  ip->setParameter(entry, param, isosStr.toLatin1().data());
+                } // if (io->hasEntry())
+             } // GEOM_Actor && hasIO
+           } // isVisible
+         } // while.. actors traversal
+       } // if (vtkView)
+      } // for (views)
+      vtkViewers++;
+    } // if (SVTK view model)
+    else if (vType == SOCC_Viewer::Type()) // processing OCC viewers
+    {
+      QVector<SUIT_ViewWindow*> views = vman->getViews();
+      for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
+      {
+       SOCC_ViewWindow* occView = dynamic_cast<SOCC_ViewWindow*>(views[i]);
+       if (occView)
+        {
+          //Handle(AIS_InteractiveContext) ic =
+          //  ((OCCViewer_Viewer*)(occView->getViewManager()->getViewModel()))->getAISContext();
+          OCCViewer_Viewer* viewModel = (OCCViewer_Viewer*)(vman->getViewModel());
+          //OCCViewer_Viewer* viewModel = ((OCCViewer_ViewManager*)vman)->getOCCViewer();
+          Handle(AIS_InteractiveContext) ic = viewModel->getAISContext();
+
+          AIS_ListOfInteractive aList;
+          ic->DisplayedObjects(aList);
+
+          AIS_ListIteratorOfListOfInteractive ite (aList);
+          for (; ite.More(); ite.Next())
+          {
+            if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape)))
+            {
+              Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
+              if (aSh->hasIO())
+              {
+                Handle(SALOME_InteractiveObject) io =
+                  Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
+                if (io->hasEntry())
+                {
+                  // entry is "encoded": it does NOT contain component adress,
+                  // since it is a subject to change on next component loading
+                  std::string entry = ip->encodeEntry(io->getEntry(), componentName);
+
+                  std::string param, occParam = vType.toLatin1().data();
+                  occParam += gSeparator;
+                  occParam += QString::number(occViewers).toLatin1().data();
+                  occParam += gSeparator;
+
+                  // Visibility
+                  param = occParam + "Visibility";
+                  ip->setParameter(entry, param, "On");
+
+                  // DisplayMode
+                  param = occParam + "DisplayMode";
+                  int dm = aSh->DisplayMode();
+                  ip->setParameter(entry, param, QString::number(dm).toLatin1().data());
+
+                  // Color
+                  // is a property of GEOM_Object, it is stored by GEOM engine
+
+                  // Transparency
+                  param = occParam + "Transparency";
+                  ip->setParameter(entry, param, QString::number(aSh->Transparency()).toLatin1().data());
+
+                  // Isos
+                  Handle(AIS_Drawer) aDrawer = aSh->Attributes();
+                  int nbUIso = aDrawer->UIsoAspect()->Number();
+                  int nbVIso = aDrawer->VIsoAspect()->Number();
+                  QString isosStr = QString::number(nbUIso);
+                  isosStr += gDigitsSep;
+                  isosStr += QString::number(nbVIso);
+                  param = occParam + "Isos";
+                  ip->setParameter(entry, param, isosStr.toLatin1().data());
+                } // if (io->hasEntry())
+              } // if (io)
+           } // if (GEOM_AISShape)
+         } // for (AIS_ListOfInteractive)
+       } // if ( occView )
+      } // for ( views )
+      occViewers++;
+    } // if (SOCC view model)
+    else
+    {
+      // unknown viewer type
+    }
+  } // for (viewManagers)
+}
+
+/*!
+ * \brief Restore visual parameters
+ *
+ * This method is called after the study document is opened.
+ * Restore visual parameters from AttributeParameter attribue(s)
+ */
+void GeometryGUI::restoreVisualParameters (int savePoint)
+{
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
+  if (!appStudy || !appStudy->studyDS())
+    return;
+  _PTR(Study) studyDS = appStudy->studyDS();
+
+  // componentName is used for encoding of entries when storing them in IParameters
+  std::string componentName = myComponentGeom->ComponentDataType();
+  //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
+  //if (!aSComponent) return;
+
+  // IParameters
+  _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
+                                                             componentName.c_str(),
+                                                             savePoint);
+  _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
+
+  std::vector<std::string> entries = ip->getEntries();
+
+  for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
+  {
+    // entry is a normal entry - it should be "decoded" (setting base adress of component)
+    QString entry (ip->decodeEntry(*entIt).c_str());
+
+    // Check that the entry corresponds to a real object in the Study
+    // as the object may be deleted or modified after the visual state is saved.
+    _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
+    if (!so) continue; //Skip the not existent entry
+
+    std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
+    std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
+
+    std::vector<std::string>::iterator namesIt = paramNames.begin();
+    std::vector<std::string>::iterator valuesIt = paramValues.begin();
+
+    // actors are stored in a map after displaying of them for
+    // quicker access in the future: map < viewID to actor >
+    NCollection_DataMap<int, GEOM_Actor*          > vtkActors;
+    NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
+
+    for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
+    {
+      // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
+      // '_' is used as separator and should not be used in viewer type or parameter names.
+      QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
+      if (lst.size() != 3)
+        continue;
+
+      QString viewerTypStr = lst[0];
+      QString viewIndexStr = lst[1];
+      QString paramNameStr = lst[2];
+
+      bool ok;
+      int viewIndex = viewIndexStr.toUInt(&ok);
+      if (!ok) // bad conversion of view index to integer
+       continue;
+
+      // viewers
+      if (viewerTypStr == SVTK_Viewer::Type())
+      {
+        GEOM_Actor* vActor = 0;
+        if (vtkActors.IsBound(viewIndex))
+          vActor = vtkActors.Find(viewIndex);
+
+        if (paramNameStr == "Visibility")
+        {
+          if (!vActor && displayer())
+          {
+            QList<SUIT_ViewManager*> lst;
+            getApp()->viewManagers(viewerTypStr, lst);
+
+            // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
+            if (viewIndex >= 0 && viewIndex < lst.count()) {
+              SUIT_ViewManager* vman = lst.at(viewIndex);
+              SUIT_ViewModel* vmodel = vman->getViewModel();
+              // SVTK view model can be casted to SALOME_View
+              displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
+
+              // store displayed actor in a temporary map for quicker
+              // access later when restoring other parameters
+              SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
+              vtkRenderer* Renderer = vtkView->getRenderer();
+              vtkActorCollection* theActors = Renderer->GetActors();
+              theActors->InitTraversal();
+              bool isFound = false;
+              vtkActor *ac = theActors->GetNextActor();
+              for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
+                if (ac->IsA("GEOM_Actor")) {
+                  GEOM_Actor* aGeomAc = GEOM_Actor::SafeDownCast(ac);
+                  if (aGeomAc->hasIO()) {
+                    Handle(SALOME_InteractiveObject) io =
+                      Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
+                    if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
+                      isFound = true;
+                      vtkActors.Bind(viewIndex, aGeomAc);
+                    }
+                  }
+                }
+              }
+            }
+          }
+        } // if (paramNameStr == "Visibility")
+       else
+        {
+          // the rest properties "work" with GEOM_Actor
+         if (vActor)
+          {
+            QString val ((*valuesIt).c_str());
+
+            if (paramNameStr == "DisplayMode") {
+              vActor->setDisplayMode(val.toInt());
+            }
+            else if (paramNameStr == "Color") {
+              QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
+              if (colors.count() == 3)
+                vActor->SetColor(colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat());
+            }
+            else if (paramNameStr == "Opacity") {
+              vActor->SetOpacity(val.toFloat());
+            }
+            else if (paramNameStr == "Isos") {
+              QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
+              if (isos.count() == 2) {
+                int aIsos[2] = {isos[0].toInt(), isos[1].toInt()};
+                vActor->SetNbIsos(aIsos);
+              }
+            }
+          }
+       } // other parameters than Visibility
+      }
+      else if (viewerTypStr == SOCC_Viewer::Type())
+      {
+        //Handle(AIS_InteractiveObject) occActor;
+        Handle(GEOM_AISShape) occActor;
+        if (occActors.IsBound(viewIndex))
+          occActor = occActors.Find(viewIndex);
+
+        // ViewModel and InteractiveContext
+        SOCC_Viewer* occVModel = 0;
+        Handle(AIS_InteractiveContext) ic;
+
+        QList<SUIT_ViewManager*> lst;
+        getApp()->viewManagers(viewerTypStr, lst);
+
+        // SOCC ViewManager always has 1 ViewWindow, so view index is index of view manager
+        if (viewIndex >= 0 && viewIndex < lst.count()) {
+          SUIT_ViewManager* vman = lst.at(viewIndex);
+          SUIT_ViewModel* vmodel = vman->getViewModel();
+          occVModel = dynamic_cast<SOCC_Viewer*>(vmodel);
+          if (occVModel)
+            ic = occVModel->getAISContext();
+        }
+
+        if (ic.IsNull())
+          continue;
+
+        if (paramNameStr == "Visibility")
+        {
+         if (occActor.IsNull() && displayer())
+          {
+            displayer()->Display(entry, true, occVModel);
+
+            // store displayed actor in a temporary map for quicker
+            // access later when restoring other parameters
+            AIS_ListOfInteractive aList;
+            ic->DisplayedObjects(aList);
+            bool isFound = false;
+            AIS_ListIteratorOfListOfInteractive ite (aList);
+            for (; ite.More() && !isFound; ite.Next()) {
+              if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
+                Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
+                if (aSh->hasIO()) {
+                  Handle(SALOME_InteractiveObject) io =
+                    Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
+                  if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
+                    isFound = true;
+                    occActors.Bind(viewIndex, aSh);
+                  }
+                }
+              }
+            }
+          }
+        } // if (paramNameStr == "Visibility")
+       else
+        {
+          // the rest properties "work" with GEOM_AISShape
+         if (!occActor.IsNull())
+          {
+            QString val ((*valuesIt).c_str());
+
+            if (paramNameStr == "DisplayMode") {
+              ic->SetDisplayMode(occActor, AIS_DisplayMode(val.toInt()), false);
+              //ic->Redisplay(occActor, Standard_False, Standard_True);
+            }
+            // Color is restored by the GEOM engine
+            else if (paramNameStr == "Transparency") {
+              ic->SetTransparency(occActor, val.toFloat(), false);
+              ic->Redisplay(occActor, Standard_False, Standard_True);
+            }
+            else if (paramNameStr == "Isos") {
+              QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
+              if (isos.count() == 2) {
+                Handle(AIS_Drawer) aDrawer = occActor->Attributes();
+                int nbUIso = isos[0].toInt();
+                int nbVIso = isos[1].toInt();
+                Handle(Prs3d_IsoAspect) uIsoAspect = aDrawer->UIsoAspect();
+                Handle(Prs3d_IsoAspect) vIsoAspect = aDrawer->VIsoAspect();
+                uIsoAspect->SetNumber(nbUIso);
+                vIsoAspect->SetNumber(nbVIso);
+                aDrawer->SetUIsoAspect(uIsoAspect);
+                aDrawer->SetVIsoAspect(vIsoAspect);
+                ic->SetLocalAttributes(occActor, aDrawer);
+                ic->Redisplay(occActor);
+              }
+            }
+          }
+       } // other parameters than Visibility
+      }
+      else
+      {
+        // unknown viewer type
+      }
+    } // for names/parameters iterator
+  } // for entries iterator
+
+  // update all VTK and OCC views
+  QList<SUIT_ViewManager*> lst;
+  getApp()->viewManagers(lst);
+  for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
+    SUIT_ViewModel* vmodel = (*it)->getViewModel();
+    if (!vmodel)
+      continue;
+    if (vmodel->getType() == SVTK_Viewer::Type()) {
+      SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
+      vtkView->getRenderer()->ResetCameraClippingRange();
+      vtkView->Repaint();
+    }
+    else if (vmodel->getType() == SOCC_Viewer::Type()) {
+      //SOCC_ViewWindow* occView = (SOCC_ViewWindow*) (*it)->getActiveView();
+      SALOME_View* occVMod = dynamic_cast<SALOME_View*>(vmodel);
+      if (occVMod)
+        occVMod->Repaint();
+    }
+  }
+}