]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_Module.cxx
Salome HOME
7da3b5eaa9fe560f60e6d1b9d52148f682cffe88
[modules/visu.git] / src / VISUGUI / VisuGUI_Module.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU VISUGUI : GUI of VISU component
24 //  File   : VisuGUI_Module.cxx
25 //  Author : Laurent CORNABE
26 //  Module : VISU
27 //  $Header$
28 //
29 #include "VisuGUI_Module.h"
30
31 #include "QtxPopupMgr.h"
32
33 #include "SUIT_Study.h"
34 #include "SUIT_Desktop.h"
35 #include "SUIT_ResourceMgr.h"
36 #include "SUIT_Accel.h"
37 #include "SUIT_Session.h"
38
39 #include "CAM_Module.h"
40
41 #include "SALOME_Event.h"
42 #include "SalomeApp_Application.h"
43 #include "LightApp_SelectionMgr.h"
44 #include "LightApp_VTKSelector.h"
45 #include "LightApp_Preferences.h"
46 #include "LightApp_Displayer.h"
47
48 #include "SALOMEDSClient_ClientFactory.hxx"
49 #include "SALOMEDSClient_IParameters.hxx"
50
51 //#include "VVTK_ViewManager.h"
52 //#include "VVTK_ViewWindow.h"
53 //#include "VVTK_ViewModel.h"
54
55 #include "SVTK_ViewModel.h"
56 #include "SVTK_ViewManager.h"
57 #include "SVTK_ViewWindow.h"
58 #include "SVTK_RenderWindowInteractor.h"
59 #include "VISU_Event.h"
60
61 #include "VTKViewer_Algorithm.h"
62
63 #include "VisuGUI_Prs3dTools.h"
64 #include "VisuGUI_ClippingDlg.h"
65
66 #include "VISU_GaussPoints_i.hh"
67 #include "VISU_GaussPtsAct.h"
68 #include "VisuGUI_GaussPointsDlg.h"
69
70 #include "VISU_Gen_i.hh"
71 #include "VISU_Result_i.hh"
72 #include "VISU_CutLinesBase_i.hh"
73
74 #include "VISU_Actor.h"
75 #include "VISU_ScalarMapAct.h"
76 #include "VisuGUI_Tools.h"
77 #include "VisuGUI_ActionsDef.h"
78
79 #include "VISU_WidgetCtrl.hxx"
80 #include "VISU_PlanesWidget.hxx"
81 #include "VISU_SphereWidget.hxx"
82
83 #include "SalomeApp_Study.h"
84 //#include "VVTK_MainWindow.h"
85 #include "VISU_View_i.hh"
86
87 #ifndef DISABLE_VTKVIEWER
88 #ifndef DISABLE_SALOMEOBJECT
89   #include <SVTK_ViewWindow.h>
90   #include <SVTK_ViewModel.h>
91 #else
92   #include <VTKViewer_ViewWindow.h>
93 #endif
94   #include <VTKViewer_ViewModel.h>
95 #endif
96 #ifndef DISABLE_OCCVIEWER
97   #include <OCCViewer_ViewWindow.h>
98   #include <OCCViewer_ViewPort3d.h>
99 #ifndef DISABLE_SALOMEOBJECT
100   #include <SOCC_ViewModel.h>
101 #else
102   #include <OCCViewer_ViewModel.h>
103 #endif
104 #endif
105 #ifndef DISABLE_GLVIEWER
106   #include <GLViewer_ViewFrame.h>
107   #include <GLViewer_ViewPort.h>
108 #endif
109 #ifndef DISABLE_PLOT2DVIEWER
110   #include <Plot2d_ViewWindow.h>
111   #include <Plot2d_ViewFrame.h>
112 #ifndef DISABLE_SALOMEOBJECT
113   #include <SPlot2d_ViewModel.h>
114 #else
115   #include <Plot2d_ViewModel.h>
116 #endif
117 #endif
118
119 #include <QAction>
120
121 #include <vtkRenderer.h>
122 #include <vtkCamera.h>
123 #include <vtkTimerLog.h>
124 #include <vtkPlane.h>
125
126 #include <sstream>
127
128
129 #ifdef _DEBUG_
130 static int MYDEBUG = 0;
131 #else
132 static int MYDEBUG = 0;
133 #endif
134
135 #define SAVE_VISU_STATE          5090
136
137 #define GAUSS_NEW_VIEWER         5100
138 #define GAUSS_CREATE_PRS         5200
139 #define GAUSS_RENAME             5210
140 #define GAUSS_EDIT_PRS           5300
141 #define GAUSS_COPY_PRS           5310
142 #define GAUSS_ERASE_PRS          5400
143 #define GAUSS_DISPLAY_PRS        5500
144 #define GAUSS_DISPLAY_ONLY_PRS   5600
145
146 #define GAUSS_SAVE_CONFIGURATION       5700
147 #define GAUSS_OVERWRITE_CONFIGURATION  5701
148 #define GAUSS_RESTORE_CONFIGURATION    5702
149 #define GAUSS_RENAME_CONFIGURATION     5703
150
151 using namespace std;
152
153 void
154 CreateCurves( SalomeApp_Module* theModule,
155               VISU::CutLinesBase_i* thePrs,
156               QDialog* theDlg,
157               const bool theCreate = true );
158
159 using namespace VISU;
160
161 namespace VISU
162 {
163   //---------------------------------------------------------------
164   typedef void (SUIT_ViewWindow::* TViewVisibility)();
165   void SetViewVisibility(SalomeApp_Application* app,
166                          TViewVisibility theViewVisibility)
167   {
168     ViewManagerList l;
169     //app->viewManagers( VVTK_Viewer::Type(), l );
170     app->viewManagers( SVTK_Viewer::Type(), l );
171     ViewManagerList::const_iterator anIt = l.begin(), aLast = l.end();
172     for( ; anIt!=aLast; anIt++ )
173       if( SUIT_ViewManager* aViewManager = *anIt )
174       {
175         QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
176         int aSize = aViews.size();
177         for(int anId = 0; anId < aSize; anId++)
178         {
179           if(SUIT_ViewWindow* aView = aViews[anId])
180             (aView->* theViewVisibility)();
181         }
182       }
183   }
184 }
185
186 //---------------------------------------------------------------
187 VisuGUI_Module::VisuGUI_Module() : 
188   VisuGUI(),
189   LightApp_Module("VISU")
190 {
191 }
192
193
194 //---------------------------------------------------------------
195 VisuGUI_Module::~VisuGUI_Module()
196 {
197 }
198
199
200 //---------------------------------------------------------------
201 void VisuGUI_Module::initialize( CAM_Application* theApp )
202 {
203   VisuGUI::initialize( theApp );
204
205   SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
206
207   // "Save VISU State" command is moved from SalomeApp_Applicaiton
208   createAction( SAVE_VISU_STATE, tr( "TOT_DESK_FILE_SAVE_GUI_STATE" ), QIcon(),
209                 tr( "MEN_DESK_FILE_SAVE_GUI_STATE" ), tr( "PRP_DESK_FILE_SAVE_GUI_STATE" ),
210                 0, getApp()->desktop(), false, getApp(), SLOT( onSaveGUIState() ) );
211   int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
212   createMenu( SAVE_VISU_STATE, fileMenu, 9, -1 );
213
214   QPixmap aPixmap;
215   /*  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GAUSS_NEW_VIEWER"));
216   createAction( GAUSS_NEW_VIEWER, 
217                 tr("MEN_GAUSS_NEW_VIEWER"), 
218                 aPixmap,
219                 tr("MEN_GAUSS_NEW_VIEWER"),
220                 tr("MEN_GAUSS_NEW_VIEWER"),
221                 Qt::ALT+Qt::Key_S,
222                 this,
223                 false,
224                 this,
225                 SLOT(onCreateViewManager()));
226   int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 );
227   int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
228   createMenu( action( GAUSS_NEW_VIEWER ), newWinMenu, -1 );
229   */
230   // Add actions to menus
231   createMenu( tr( "MEN_GAUSS" ), -1, -1, 30 );
232   //createMenu( GAUSS_CREATE_PRS, aMenuId, 10 );
233
234   QString aViewerType = SVTK_Viewer::Type();
235   SUIT_Accel* accel = getApp()->accel();
236   accel->setActionKey( SUIT_Accel::PanLeft, Qt::Key_Left, aViewerType );
237   accel->setActionKey( SUIT_Accel::PanRight, Qt::Key_Right, aViewerType );
238   accel->setActionKey( SUIT_Accel::PanUp, Qt::Key_Up, aViewerType );
239   accel->setActionKey( SUIT_Accel::PanDown, Qt::Key_Down, aViewerType );
240   accel->setActionKey( SUIT_Accel::ZoomIn, Qt::Key_PageUp, aViewerType );
241   accel->setActionKey( SUIT_Accel::ZoomOut, Qt::Key_PageDown, aViewerType );
242   accel->setActionKey( SUIT_Accel::RotateLeft, Qt::CTRL+Qt::Key_Left, aViewerType );
243   accel->setActionKey( SUIT_Accel::RotateRight, Qt::CTRL+Qt::Key_Right, aViewerType );
244   accel->setActionKey( SUIT_Accel::RotateUp, Qt::CTRL+Qt::Key_Up, aViewerType );
245   accel->setActionKey( SUIT_Accel::RotateDown, Qt::CTRL+Qt::Key_Down, aViewerType );
246   accel->setActionKey( SVTK::PlusSpeedIncrementEvent, Qt::Key_Plus, aViewerType );
247   accel->setActionKey( SVTK::MinusSpeedIncrementEvent, Qt::Key_Minus, aViewerType );
248   
249   connect( getApp(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
250            this, SLOT( OnViewManagerAdded (SUIT_ViewManager*) ) );
251   
252   // Prepare popup menus
253   QtxPopupMgr* mgr = popupMgr();
254   QString aRule;
255
256   aPixmap = aResourceMgr->loadPixmap( "VISU", tr( "ICON_GAUSS_POINTS" ) );
257   createAction( GAUSS_CREATE_PRS, tr("MEN_GAUSS_CREATE_PRS"), aPixmap,
258                 tr("MEN_GAUSS_CREATE_PRS"), "", 0, this, false,
259                 this, SLOT(OnCreateGaussPoints()));
260   mgr->insert( action( GAUSS_CREATE_PRS ), -1, 0, -1 );
261   mgr->setRule( action( GAUSS_CREATE_PRS ),
262                 "client='ObjectBrowser' and selcount=1 "
263                 "and type in {'VISU::TTIMESTAMP' 'VISU::TFIELD'} "
264                 "and $medEntity in {'EDGE_ENTITY' 'FACE_ENTITY' 'CELL_ENTITY'} "
265                 "and $medSource in {'eImportFile' 'eCopyAndImportFile'}" );
266
267   createMenu( action( GAUSS_CREATE_PRS ), createMenu( tr( "MEN_VISUALISATION" ), -1 ), -1 );
268   createTool( GAUSS_CREATE_PRS, createTool( tr( "TOOL_VISUALISATION" ) ), -1 );
269
270   createAction( GAUSS_RENAME, VisuGUI::tr("MEN_RENAME"), QIcon(),
271                 VisuGUI::tr("MEN_RENAME"), "", 0, this, false,
272                 this, SLOT(OnRename()));
273   mgr->insert( action( GAUSS_RENAME ), -1, 0, -1 );
274   mgr->setRule( action( GAUSS_RENAME ),
275     "selcount=1 and type='VISU::TGAUSSPOINTS'" );
276
277   createAction( GAUSS_EDIT_PRS, VisuGUI::tr("MEN_EDIT_PRS"), QIcon(),
278                 VisuGUI::tr("MEN_EDIT_PRS"), "", 0, this, false,
279                 this, SLOT(OnEditGaussPoints()));
280   mgr->insert( action( GAUSS_EDIT_PRS ), -1, 0, -1 );
281   mgr->setRule( action( GAUSS_EDIT_PRS ),
282     "selcount=1 and type='VISU::TGAUSSPOINTS'" );
283
284   createAction( GAUSS_COPY_PRS, VisuGUI::tr("MEN_COPY_PRS"), QIcon(),
285                 VisuGUI::tr("MEN_COPY_PRS"), "", 0, this, false,
286                 this, SLOT(OnCopyPresentation()));
287   mgr->insert( action( GAUSS_COPY_PRS ), -1, 0, -1 );
288   mgr->setRule( action( GAUSS_COPY_PRS ),
289     "selcount=1 and type='VISU::TGAUSSPOINTS'" );
290
291   action( GAUSS_COPY_PRS )->setEnabled(false);
292
293   QStringList viewers;
294
295 #ifndef DISABLE_OCCVIEWER
296 #ifndef DISABLE_SALOMEOBJECT
297   viewers.append( SOCC_Viewer::Type() );
298 #else
299   viewers.append( OCCViewer_Viewer::Type() );
300 #endif
301 #endif
302 #ifndef DISABLE_VTKVIEWER
303 #ifndef DISABLE_SALOMEOBJECT
304   viewers.append( SVTK_Viewer::Type() );
305   //viewers.append( VVTK_Viewer::Type() );
306 #else
307   viewers.append( VTKViewer_Viewer::Type() );
308 #endif
309 #endif
310 #ifndef DISABLE_PLOT2DVIEWER
311 #ifndef DISABLE_SALOMEOBJECT
312   viewers.append( SPlot2d_Viewer::Type() );
313 #else
314   viewers.append( Plot2d_Viewer::Type() );
315 #endif
316 #endif
317
318   if( !viewers.isEmpty() )
319     {
320       QString strViewers = "{ ", temp = "'%1' ";
321       QStringList::const_iterator anIt = viewers.begin(), aLast = viewers.end();
322       for( ; anIt!=aLast; anIt++ )
323         strViewers+=temp.arg( *anIt );
324       strViewers+="}";
325       mgr->setRule( action(myEraseAll), QString( "client in %1" ).arg( strViewers ) );
326     }
327
328   aRule = "(selcount>0 and type='VISU::TGAUSSPOINTS')";
329
330 /*  createAction( GAUSS_ERASE_PRS, VisuGUI::tr("MEN_HIDE"), QIcon(),
331                 VisuGUI::tr("MEN_HIDE"), "", 0, this, false,
332                 this, SLOT(OnErasePrs()));
333   mgr->insert( action( GAUSS_ERASE_PRS ), -1, -1, -1 ); // erase
334   mgr->setRule( action( GAUSS_ERASE_PRS ),
335     aRule + " and ({true} in $canBeDisplayed) and (isVisible=true)" );
336
337   createAction( GAUSS_DISPLAY_PRS, VisuGUI::tr("MEN_SHOW"), QIcon(),
338                 VisuGUI::tr("MEN_SHOW"), "", 0, this, false,
339                 this, SLOT(OnDisplayPrs()));
340   mgr->insert( action( GAUSS_DISPLAY_PRS ), -1, -1, -1 ); // display
341   mgr->setRule( action( GAUSS_DISPLAY_PRS ),
342     aRule + " and ({true} in $canBeDisplayed) and (isVisible=false)" );
343
344   createAction( GAUSS_DISPLAY_ONLY_PRS, VisuGUI::tr("MEN_DISPLAY_ONLY"), QIcon(),
345                 VisuGUI::tr("MEN_DISPLAY_ONLY"), "", 0, this, false,
346                 this, SLOT(OnDisplayOnlyPrs()));
347   mgr->insert( action( GAUSS_DISPLAY_ONLY_PRS ), -1, -1, -1 ); // display only
348   mgr->setRule( action( GAUSS_DISPLAY_ONLY_PRS ),
349     aRule + " and ({true} in $canBeDisplayed)" );*/
350
351   createAction( GAUSS_RENAME_CONFIGURATION, VisuGUI::tr("MEN_RENAME"), QIcon(),
352                 VisuGUI::tr("MEN_RENAME"), "", 0, this, false,
353                 this, SLOT(OnRename()));
354   mgr->insert( action( GAUSS_RENAME_CONFIGURATION ), -1, -1, -1 );
355   mgr->setRule( action( GAUSS_RENAME_CONFIGURATION ), "selcount=1 and type='VISU::TGAUSSVIEW'" );
356
357   createAction( GAUSS_SAVE_CONFIGURATION, tr("MEN_SAVE_CONFIGURATION"), QIcon(),
358                 tr("MEN_SAVE_CONFIGURATION"), "", 0, this, false,
359                 this, SLOT(OnSaveConfiguration()));
360   mgr->insert( action( GAUSS_SAVE_CONFIGURATION ), -1, -1, -1 );
361   mgr->setRule( action( GAUSS_SAVE_CONFIGURATION ),
362     "selcount>=0 and client='SVTK' and activeView='SVTK'" );
363
364   createAction( GAUSS_OVERWRITE_CONFIGURATION, tr("MEN_OVERWRITE_CONFIGURATION"), QIcon(),
365                 tr("MEN_OVERWRITE_CONFIGURATION"), "", 0, this, false,
366                 this, SLOT(OnOverwriteConfiguration()));
367   mgr->insert( action( GAUSS_OVERWRITE_CONFIGURATION ), -1, -1, -1 );
368   mgr->setRule( action( GAUSS_OVERWRITE_CONFIGURATION ),
369     "selcount>0 and type='VISU::TGAUSSVIEW' and activeView='SVTK'" );
370
371   createAction( GAUSS_RESTORE_CONFIGURATION, tr("MEN_RESTORE_CONFIGURATION"), QIcon(),
372                 tr("MEN_RESTORE_CONFIGURATION"), "", 0, this, false,
373                 this, SLOT(OnRestoreConfiguration()));
374   mgr->insert( action( GAUSS_RESTORE_CONFIGURATION ), -1, -1, -1 );
375   mgr->setRule( action( GAUSS_RESTORE_CONFIGURATION ),
376   "selcount=1 and type='VISU::TGAUSSVIEW'" );
377 }
378
379 // //---------------------------------------------------------------
380 // bool VisuGUI_Module::activateModule( SUIT_Study* theStudy )
381 // {
382 //   VisuGUI::activateModule( theStudy );
383
384 //   //SetViewVisibility(getApp(),&SUIT_ViewWindow::show);
385
386 //   return true;
387 // }
388
389 //---------------------------------------------------------------
390 // bool VisuGUI_Module::deactivateModule( SUIT_Study* theStudy )
391 // {
392 //   return VisuGUI::deactivateModule( theStudy );
393
394 //   //SetViewVisibility(getApp(),&SUIT_ViewWindow::hide);
395
396 //   //return true;
397 // }
398
399
400 //---------------------------------------------------------------
401 // SUIT_ViewManager* VisuGUI_Module::onCreateViewManager()
402 // {
403 //   SalomeApp_Application* anApp = getApp();
404 //   SUIT_ResourceMgr* aResourceMgr = anApp->resourceMgr();
405 //   VVTK_ViewManager* aViewManager = new VVTK_ViewManager( anApp->activeStudy(), anApp->desktop() );
406 //   VVTK_Viewer* aViewer = (VVTK_Viewer*)aViewManager->getViewModel();
407 //   aViewer->setBackgroundColor( aResourceMgr->colorValue( "VTKViewer", "background", aViewer->backgroundColor() ) );
408 //   aViewer->setProjectionMode( aResourceMgr->integerValue( "VTKViewer", "projection_mode", aViewer->projectionMode() ) );
409 //   aViewer->setTrihedronSize( aResourceMgr->integerValue( "VTKViewer", "trihedron_size", aViewer->trihedronSize() ),
410 //                           aResourceMgr->booleanValue( "VTKViewer", "relative_size", aViewer->trihedronRelative() ) );
411 //   aViewer->setIncrementalSpeed( aResourceMgr->integerValue( "VTKViewer", "speed_value", aViewer->incrementalSpeed() ),
412 //                              aResourceMgr->integerValue( "VTKViewer", "speed_mode", aViewer->incrementalSpeedMode() ) );
413 //   aViewer->setInteractionStyle( aResourceMgr->integerValue( "VTKViewer", "navigation_mode", aViewer->interactionStyle() ) );
414 //   aViewer->setSpacemouseButtons( aResourceMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", aViewer->spacemouseBtn(1) ),
415 //                               aResourceMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", aViewer->spacemouseBtn(1) ),
416 //                               aResourceMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", aViewer->spacemouseBtn(1) ) );
417
418 //   new LightApp_VTKSelector( aViewer, anApp->selectionMgr() );
419
420 //   anApp->addViewManager( aViewManager );
421
422 //   return aViewer->getViewManager();
423 // }
424
425
426 //---------------------------------------------------------------
427 void VisuGUI_Module::createPreferences()
428 {
429   VisuGUI::createPreferences();
430
431   createGaussPointsPreferences();
432   createInsideCursorPreferences();
433   createOutsideCursorPreferences();
434   createPickingPreferences();
435   // createSpaceMousePreferences();
436   //createRecorderPreferences();
437 }
438
439
440 //---------------------------------------------------------------
441 void VisuGUI_Module::createGaussPointsPreferences()
442 {
443   int gaussTab = addPreference( tr( "VISU_GAUSS_PREF_TAB_TTL" ) );
444   int primitiveGr = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_GROUP_TTL" ), gaussTab );
445   setPreferenceProperty( primitiveGr, "columns", 2 );
446
447   int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr,
448                                          LightApp_Preferences::Selector, "VISU",
449                                          "point_sprite_primitive_type" );
450
451   QStringList values;
452   values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) );
453   values.append( tr( "VISU_GAUSS_PREF_OPENGLPOINT" ) );
454   values.append( tr( "VISU_GAUSS_PREF_GEOMSPHERE" ) );
455   QList<QVariant> indices;
456   indices.append( 0 );
457   indices.append( 1 );
458   indices.append( 2 );
459   setPreferenceProperty( primitiveTypePref, "strings", values );
460   setPreferenceProperty( primitiveTypePref, "indexes", indices );
461
462   int clampPref = addPreference( tr( "VISU_GAUSS_PREF_CLAMP" ), primitiveGr,
463                                  LightApp_Preferences::IntSpin, "VISU", "point_sprite_clamp" );
464   setPreferenceProperty( clampPref, "min", 1 );
465   setPreferenceProperty( clampPref, "max", 512 );
466
467   addPreference( tr( "VISU_GAUSS_PREF_MAIN_TEXTURE" ), primitiveGr,
468                  LightApp_Preferences::File, "VISU", "point_sprite_main_texture" );
469
470   addPreference( tr( "VISU_GAUSS_PREF_ALPHA_TEXTURE" ), primitiveGr,
471                  LightApp_Preferences::File, "VISU", "point_sprite_alpha_texture" );
472
473   int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr,
474                                           LightApp_Preferences::DblSpin, "VISU",
475                                           "point_sprite_alpha_threshold" );
476   setPreferenceProperty( alphaThresholdPref, "min", 0.0 );
477   setPreferenceProperty( alphaThresholdPref, "max", 1.0 );
478   setPreferenceProperty( alphaThresholdPref, "step", 0.1 );
479
480   int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr,
481                                       LightApp_Preferences::IntSpin, "VISU", "geom_sphere_resolution" );
482   setPreferenceProperty( resolutionPref, "min", 3 );
483   setPreferenceProperty( resolutionPref, "max", 100 );
484
485   int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr,
486                                      LightApp_Preferences::IntSpin, "VISU", "geom_sphere_face_limit" );
487   setPreferenceProperty( faceLimitPref, "min", 10 );
488   setPreferenceProperty( faceLimitPref, "max", 1000000 );
489
490   int sizeGr = addPreference( tr( "VISU_GAUSS_PREF_SIZE_GROUP_TTL" ), gaussTab );
491   setPreferenceProperty( sizeGr, "columns", 2 );
492
493   int minSizePref = addPreference( tr( "VISU_GAUSS_PREF_MIN_SIZE" ), sizeGr,
494                                    LightApp_Preferences::IntSpin, "VISU", "point_sprite_min_size" );
495   setPreferenceProperty( minSizePref, "min", 1 );
496   setPreferenceProperty( minSizePref, "max", 100 );
497
498   int maxSizePref = addPreference( tr( "VISU_GAUSS_PREF_MAX_SIZE" ), sizeGr,
499                                    LightApp_Preferences::IntSpin, "VISU", "point_sprite_max_size" );
500   setPreferenceProperty( maxSizePref, "min", 1 );
501   setPreferenceProperty( maxSizePref, "max", 100 );
502
503   int magnificationPref = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION" ), sizeGr,
504                                          LightApp_Preferences::IntSpin, "VISU",
505                                          "point_sprite_magnification" );
506   setPreferenceProperty( magnificationPref, "min", 10 );
507   setPreferenceProperty( magnificationPref, "max", 1000 );
508
509   int incrementPref = addPreference( tr( "VISU_GAUSS_PREF_INCREMENT" ), sizeGr,
510                                      LightApp_Preferences::DblSpin, "VISU", "point_sprite_increment" );
511   setPreferenceProperty( incrementPref, "min", 0.01 );
512   setPreferenceProperty( incrementPref, "max", 10 );
513   setPreferenceProperty( incrementPref, "step", 0.1 );
514
515   int geomGr = addPreference( tr( "VISU_GAUSS_PREF_GEOM_GROUP_TTL" ), gaussTab );
516   setPreferenceProperty( geomGr, "columns", 2 );
517
518   int sizePref = addPreference( tr( "VISU_GAUSS_PREF_SIZE" ), geomGr,
519                                 LightApp_Preferences::IntSpin, "VISU", "point_sprite_size" );
520   setPreferenceProperty( sizePref, "min", 1 );
521   setPreferenceProperty( sizePref, "max", 100 );
522
523   addPreference( tr( "VISU_GAUSS_PREF_COLOR" ), geomGr,
524                  LightApp_Preferences::Color, "VISU", "point_sprite_color" );
525
526   // ScalarBar Preferences
527   int scalarBarGr = addPreference( tr( "VISU_GAUSS_SCALAR_BAR_PREF_GROUP_TTL" ), gaussTab );
528   setPreferenceProperty( scalarBarGr, "columns", 2 );
529
530   int activeBarPref = addPreference( tr( "VISU_GAUSS_PREF_ACTIVE_BAR" ), scalarBarGr,
531                                      LightApp_Preferences::Selector, "VISU", "scalar_bar_active_local" );
532
533   values.clear();
534   values.append( tr( "VISU_GAUSS_PREF_LOCAL" ) );
535   values.append( tr( "VISU_GAUSS_PREF_GLOBAL" ) );
536   indices.clear();
537   indices.append( 0 );
538   indices.append( 1 );
539   setPreferenceProperty( activeBarPref, "strings", values );
540   setPreferenceProperty( activeBarPref, "indexes", indices );
541
542   addPreference( tr( "VISU_GAUSS_PREF_DISPLAY_GLOBAL" ), scalarBarGr,
543                  LightApp_Preferences::Bool, "VISU", "scalar_bar_display_global" );
544
545   int colorPref = addPreference( tr( "VISU_GAUSS_PREF_SCALAR_BAR_MODE" ), scalarBarGr,
546                                  LightApp_Preferences::Selector, "VISU", "scalar_bar_bicolor" );
547
548   values.clear();
549   values.append( tr( "VISU_GAUSS_PREF_BICOLOR" ) );
550   values.append( tr( "VISU_GAUSS_PREF_RAINBOW" ) );
551   indices.clear();
552   indices.append( 0 );
553   indices.append( 1 );
554   setPreferenceProperty( colorPref, "strings", values );
555   setPreferenceProperty( colorPref, "indexes", indices );
556
557   int spacingPref = addPreference( tr( "VISU_GAUSS_PREF_SPACING" ), scalarBarGr,
558                                      LightApp_Preferences::DblSpin, "VISU", "scalar_bar_spacing" );
559   setPreferenceProperty( spacingPref, "min", 0.01 );
560   setPreferenceProperty( spacingPref, "max", 1.0 );
561   setPreferenceProperty( spacingPref, "step", 0.01 );
562
563   // spacemouse
564   int spacemouseGr = addPreference( tr( "VISU_SPACEMOUSE_PREF" ), gaussTab );
565   setPreferenceProperty( spacemouseGr, "columns", 2 );
566   int spacemousePref3 = addPreference( tr( "VISU_SPACEMOUSE_PREF_3" ), spacemouseGr,
567                                        LightApp_Preferences::Selector, "VISU",
568                                        "spacemouse_func3_btn" ); //decrease_gauss_point_magnification
569   int spacemousePref4 = addPreference( tr( "VISU_SPACEMOUSE_PREF_4" ), spacemouseGr,
570                                        LightApp_Preferences::Selector, "VISU",
571                                        "spacemouse_func4_btn" ); //increase_gauss_point_magnification
572   values.clear();
573   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_1" ) );
574   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_2" ) );
575   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_3" ) );
576   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_4" ) );
577   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_5" ) );
578   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_6" ) );
579   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_7" ) );
580   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_8" ) );
581   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_*" ) );
582   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_10" ) );
583   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_11" ) );
584   indices.clear();
585   indices.append( 1 );
586   indices.append( 2 );
587   indices.append( 3 );
588   indices.append( 4 );
589   indices.append( 5 );
590   indices.append( 6 );
591   indices.append( 7 );
592   indices.append( 8 );
593   indices.append( 9 ); // == button_*
594   indices.append( 10 );
595   indices.append( 11 );
596   setPreferenceProperty( spacemousePref3, "strings", values );
597   setPreferenceProperty( spacemousePref3, "indexes", indices );
598   setPreferenceProperty( spacemousePref4, "strings", values );
599   setPreferenceProperty( spacemousePref4, "indexes", indices );
600 }
601
602
603 //---------------------------------------------------------------
604 void VisuGUI_Module::createInsideCursorPreferences()
605 {
606   int insideCursorTab = addPreference( tr( "VISU_GAUSS_INSIDE_CURSOR_PREF_TAB_TTL" ) );
607
608   int primitiveGr = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_GROUP_TTL" ), insideCursorTab );
609   setPreferenceProperty( primitiveGr, "columns", 2 );
610
611   int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr,
612                                          LightApp_Preferences::Selector, "VISU",
613                                          "inside_point_sprite_primitive_type" );
614
615   QStringList values;
616   values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) );
617   values.append( tr( "VISU_GAUSS_PREF_OPENGLPOINT" ) );
618   values.append( tr( "VISU_GAUSS_PREF_GEOMSPHERE" ) );
619   QList<QVariant> indices;
620   indices.append( 0 );
621   indices.append( 1 );
622   indices.append( 2 );
623   setPreferenceProperty( primitiveTypePref, "strings", values );
624   setPreferenceProperty( primitiveTypePref, "indexes", indices );
625
626   int clampPref = addPreference( tr( "VISU_GAUSS_PREF_CLAMP" ), primitiveGr,
627                                  LightApp_Preferences::IntSpin, "VISU", "inside_point_sprite_clamp" );
628   setPreferenceProperty( clampPref, "min", 1 );
629   setPreferenceProperty( clampPref, "max", 512 );
630
631   addPreference( tr( "VISU_GAUSS_PREF_MAIN_TEXTURE" ), primitiveGr,
632                  LightApp_Preferences::File, "VISU", "inside_point_sprite_main_texture" );
633
634   addPreference( tr( "VISU_GAUSS_PREF_ALPHA_TEXTURE" ), primitiveGr,
635                  LightApp_Preferences::File, "VISU", "inside_point_sprite_alpha_texture" );
636
637   int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr,
638                                           LightApp_Preferences::DblSpin, "VISU",
639                                           "inside_point_sprite_alpha_threshold" );
640   setPreferenceProperty( alphaThresholdPref, "min", 0.0 );
641   setPreferenceProperty( alphaThresholdPref, "max", 1.0 );
642   setPreferenceProperty( alphaThresholdPref, "step", 0.1 );
643
644   int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr,
645                                       LightApp_Preferences::IntSpin, "VISU",
646                                       "inside_geom_sphere_resolution" );
647   setPreferenceProperty( resolutionPref, "min", 3 );
648   setPreferenceProperty( resolutionPref, "max", 100 );
649
650   int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr,
651                                      LightApp_Preferences::IntSpin, "VISU",
652                                      "inside_geom_sphere_face_limit" );
653   setPreferenceProperty( faceLimitPref, "min", 10 );
654   setPreferenceProperty( faceLimitPref, "max", 1000000 );
655
656   int sizeGr = addPreference( tr( "VISU_GAUSS_PREF_SIZE_GROUP_TTL" ), insideCursorTab );
657   setPreferenceProperty( sizeGr, "columns", 4 );
658
659   int minSizePref = addPreference( tr( "VISU_GAUSS_PREF_MIN_SIZE" ), sizeGr,
660                                    LightApp_Preferences::IntSpin, "VISU",
661                                    "inside_point_sprite_min_size" );
662   setPreferenceProperty( minSizePref, "min", 1 );
663   setPreferenceProperty( minSizePref, "max", 100 );
664
665   int maxSizePref = addPreference( tr( "VISU_GAUSS_PREF_MAX_SIZE" ), sizeGr,
666                                    LightApp_Preferences::IntSpin, "VISU",
667                                    "inside_point_sprite_max_size" );
668   setPreferenceProperty( maxSizePref, "min", 1 );
669   setPreferenceProperty( maxSizePref, "max", 100 );
670
671   int magnificationGr = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION_GROUP_TTL" ), insideCursorTab );
672   setPreferenceProperty( magnificationGr, "columns", 4 );
673
674   int magnificationPref = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION" ), magnificationGr,
675                                          LightApp_Preferences::IntSpin, "VISU",
676                                          "inside_point_sprite_magnification" );
677   setPreferenceProperty( magnificationPref, "min", 10 );
678   setPreferenceProperty( magnificationPref, "max", 1000 );
679
680   int incrementPref = addPreference( tr( "VISU_GAUSS_PREF_INCREMENT" ), magnificationGr,
681                                      LightApp_Preferences::DblSpin, "VISU",
682                                      "inside_point_sprite_increment" );
683   setPreferenceProperty( incrementPref, "min", 0.01 );
684   setPreferenceProperty( incrementPref, "max", 10 );
685   setPreferenceProperty( incrementPref, "step", 0.1 );
686 }
687
688
689 //---------------------------------------------------------------
690 void VisuGUI_Module::createOutsideCursorPreferences()
691 {
692   int outsideCursorTab = addPreference( tr( "VISU_GAUSS_OUTSIDE_CURSOR_PREF_TAB_TTL" ) );
693
694   int primitiveGr = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_GROUP_TTL" ), outsideCursorTab );
695   setPreferenceProperty( primitiveGr, "columns", 2 );
696
697   int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr,
698                                          LightApp_Preferences::Selector, "VISU",
699                                          "outside_point_sprite_primitive_type" );
700
701   QStringList values;
702   values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) );
703   values.append( tr( "VISU_GAUSS_PREF_OPENGLPOINT" ) );
704   values.append( tr( "VISU_GAUSS_PREF_GEOMSPHERE" ) );
705   QList<QVariant> indices;
706   indices.append( 0 );
707   indices.append( 1 );
708   indices.append( 2 );
709   setPreferenceProperty( primitiveTypePref, "strings", values );
710   setPreferenceProperty( primitiveTypePref, "indexes", indices );
711
712   int clampPref = addPreference( tr( "VISU_GAUSS_PREF_CLAMP" ), primitiveGr,
713                                  LightApp_Preferences::IntSpin, "VISU", "outside_point_sprite_clamp" );
714   setPreferenceProperty( clampPref, "min", 1 );
715   setPreferenceProperty( clampPref, "max", 512 );
716
717   addPreference( tr( "VISU_GAUSS_PREF_MAIN_TEXTURE" ), primitiveGr,
718                  LightApp_Preferences::File, "VISU", "outside_point_sprite_main_texture" );
719
720   addPreference( tr( "VISU_GAUSS_PREF_ALPHA_TEXTURE" ), primitiveGr,
721                  LightApp_Preferences::File, "VISU", "outside_point_sprite_alpha_texture" );
722
723   int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr,
724                                           LightApp_Preferences::DblSpin, "VISU",
725                                           "outside_point_sprite_alpha_threshold" );
726   setPreferenceProperty( alphaThresholdPref, "min", 0.0 );
727   setPreferenceProperty( alphaThresholdPref, "max", 1.0 );
728   setPreferenceProperty( alphaThresholdPref, "step", 0.1 );
729
730   int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr,
731                                       LightApp_Preferences::IntSpin, "VISU",
732                                       "outside_geom_sphere_resolution" );
733   setPreferenceProperty( resolutionPref, "min", 3 );
734   setPreferenceProperty( resolutionPref, "max", 100 );
735
736   int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr,
737                                      LightApp_Preferences::IntSpin, "VISU",
738                                      "outside_geom_sphere_face_limit" );
739   setPreferenceProperty( faceLimitPref, "min", 10 );
740   setPreferenceProperty( faceLimitPref, "max", 1000000 );
741
742   int sizeGr = addPreference( tr( "VISU_GAUSS_PREF_SIZE_GROUP_TTL" ), outsideCursorTab );
743   setPreferenceProperty( sizeGr, "columns", 2 );
744
745   int sizePref = addPreference( tr( "VISU_GAUSS_PREF_SIZE" ), sizeGr,
746                                 LightApp_Preferences::IntSpin, "VISU", "outside_point_sprite_size" );
747   setPreferenceProperty( sizePref, "min", 1 );
748   setPreferenceProperty( sizePref, "max", 100 );
749
750   int colorGr = addPreference( tr( "VISU_GAUSS_PREF_COLOR_GROUP_TTL" ), outsideCursorTab );
751   setPreferenceProperty( colorGr, "columns", 2 );
752
753   addPreference( tr( "VISU_GAUSS_PREF_UNIFORM_COLOR" ), colorGr,
754                  LightApp_Preferences::Bool, "VISU", "outside_point_sprite_uniform" );
755
756   addPreference( tr( "VISU_GAUSS_PREF_COLOR" ), colorGr,
757                  LightApp_Preferences::Color, "VISU", "outside_point_sprite_color" );
758 }
759
760
761 //---------------------------------------------------------------
762 void VisuGUI_Module::createPickingPreferences()
763 {
764   int pickingTab = addPreference( tr( "VISU_PICKING_PREF_TAB_TTL" ) );
765
766   // Cursor
767   int cursorGr = addPreference( tr( "VISU_PICKING_PREF_CURSOR_GROUP_TTL" ), pickingTab );
768   setPreferenceProperty( cursorGr, "columns", 2 );
769
770   int cursorSizePref = addPreference( tr( "VISU_PICKING_PREF_CURSOR_SIZE" ), cursorGr,
771                                       LightApp_Preferences::DblSpin, "VISU", "picking_cursor_size" );
772   setPreferenceProperty( cursorSizePref, "min", 0 );
773   setPreferenceProperty( cursorSizePref, "max", 1.0 );
774   setPreferenceProperty( cursorSizePref, "step", 0.1 );
775
776   int pyramidHeightPref = addPreference( tr( "VISU_PICKING_PREF_PYRAMID_HEIGHT" ), cursorGr,
777                                          LightApp_Preferences::DblSpin, "VISU", "picking_pyramid_height" );
778   setPreferenceProperty( pyramidHeightPref, "min", 1 );
779   setPreferenceProperty( pyramidHeightPref, "max", 100 );
780
781   /*int selectionColorPref = */
782   addPreference( tr( "VISU_PICKING_PREF_SELECTION_COLOR" ), cursorGr,
783                  LightApp_Preferences::Color, "VISU", "picking_selection_color" );
784
785   // Tolerance
786   int toleranceGr = addPreference( tr( "VISU_PICKING_PREF_TOLERANCE_GROUP_TTL" ), pickingTab );
787   setPreferenceProperty( toleranceGr, "columns", 2 );
788
789   int pointTolerancePref = addPreference( tr( "VISU_PICKING_PREF_POINT_SELECTION_TOLERANCE" ), toleranceGr,
790                                           LightApp_Preferences::DblSpin, "VISU", "picking_point_tolerance" );
791   setPreferenceProperty( pointTolerancePref, "min", 0.001 );
792   setPreferenceProperty( pointTolerancePref, "max", 10 );
793   setPreferenceProperty( pointTolerancePref, "step", 0.01 );
794
795   // Info window
796   int infoWindowGr = addPreference( tr( "VISU_PICKING_PREF_INFO_WINDOW_GROUP_TTL" ), pickingTab );
797   setPreferenceProperty( infoWindowGr, "columns", 2 );
798
799   int infoWindowPref = addPreference( tr( "VISU_PICKING_PREF_INFO_WINDOW" ), infoWindowGr,
800                                       LightApp_Preferences::Bool, "VISU", "picking_info_window" );
801   setPreferenceProperty( infoWindowPref, "columns", 2 );
802
803   int transparencyPref = addPreference( tr( "VISU_PICKING_PREF_TRANSPARENCY" ), infoWindowGr,
804                                         LightApp_Preferences::IntSpin, "VISU", "picking_transparency" );
805   setPreferenceProperty( transparencyPref, "min", 0 );
806   setPreferenceProperty( transparencyPref, "max", 100 );
807   setPreferenceProperty( transparencyPref, "step", 10 );
808
809   int positionPref = addPreference( tr( "VISU_PICKING_PREF_POSITION" ), infoWindowGr,
810                                     LightApp_Preferences::Selector, "VISU", "picking_position" );
811   QStringList values;
812   values.append( tr( "VISU_PICKING_PREF_BELOW_POINT" ) );
813   values.append( tr( "VISU_PICKING_PREF_TOP_LEFT_CORNER" ) );
814   QList<QVariant> indices;
815   indices.append( 0 );
816   indices.append( 1 );
817   setPreferenceProperty( positionPref, "strings", values );
818   setPreferenceProperty( positionPref, "indexes", indices );
819
820   // Camera
821   int cameraGr = addPreference( tr( "VISU_PICKING_PREF_CAMERA_GROUP_TTL" ), pickingTab );
822   setPreferenceProperty( cameraGr, "columns", 2 );
823
824   int cameraPref = addPreference( tr( "VISU_PICKING_PREF_CAMERA_MOVEMENT" ), cameraGr,
825                                   LightApp_Preferences::Bool, "VISU", "picking_camera_movement" );
826   setPreferenceProperty( cameraPref, "columns", 2 );
827
828   int zoomFactorPref = addPreference( tr( "VISU_PICKING_PREF_ZOOM_FACTOR" ), cameraGr,
829                                       LightApp_Preferences::DblSpin, "VISU", "picking_zoom_factor" );
830   setPreferenceProperty( zoomFactorPref, "min", 0.1 );
831   setPreferenceProperty( zoomFactorPref, "max", 10.0 );
832   setPreferenceProperty( zoomFactorPref, "step", 0.1 );
833
834   int stepNumberPref = addPreference( tr( "VISU_PICKING_PREF_STEP_NUMBER" ), cameraGr,
835                                       LightApp_Preferences::IntSpin, "VISU", "picking_step_number" );
836   setPreferenceProperty( stepNumberPref, "min", 1 );
837   setPreferenceProperty( stepNumberPref, "max", 100 );
838
839   // Display parent mesh
840   int parentMeshGr = addPreference( tr( "VISU_PICKING_PREF_PARENT_MESH_TTL" ), pickingTab );
841   setPreferenceProperty( parentMeshGr, "columns", 1 );
842
843   addPreference( tr( "VISU_PICKING_PREF_DISPLAY_PARENT_MESH" ), parentMeshGr,
844                  LightApp_Preferences::Bool, "VISU", "picking_display_parent_mesh" );
845 }
846
847
848 //---------------------------------------------------------------
849 void VisuGUI_Module::createSpaceMousePreferences()
850 {
851   int mouseTab = addPreference( tr( "VISU_MOUSE_PREF_TAB_TLT" ) );
852
853   int mouseGr = addPreference( tr( "VISU_MOUSE_PREF_GROUP_TLT" ), mouseTab );
854   setPreferenceProperty( mouseGr, "columns", 2 );
855   int mousePref = addPreference( tr( "VISU_MOUSE_PREF" ), mouseGr,
856                                  LightApp_Preferences::Selector, "VISU", "mouse_behaviour" );
857   QStringList values;
858   values.append( tr( "VISU_MOUSE_PREF_STANDARD" ) );
859   values.append( tr( "VISU_MOUSE_PREF_KEYBOARD_FREE" ) );
860   QList<QVariant> indices;
861   indices.append( 0 );
862   indices.append( 1 );
863   setPreferenceProperty( mousePref, "strings", values );
864   setPreferenceProperty( mousePref, "indexes", indices );
865
866   int keybrdGr = addPreference( tr( "VISU_KEYBOARD_PREF_GROUP_TTL" ), mouseTab );
867   setPreferenceProperty( keybrdGr, "columns", 2 );
868   int keybrdPref = addPreference( tr( "VISU_KEYBOARD_PREF" ), keybrdGr,
869                                   LightApp_Preferences::IntSpin, "VISU", "speed_increment" );
870   setPreferenceProperty( keybrdPref,  "max",  1000  );
871
872   int spacemouseGr = addPreference( tr( "VISU_SPACEMOUSE_PREF" ), mouseTab );
873   setPreferenceProperty( spacemouseGr, "columns", 2 );
874   int spacemousePref1 = addPreference( tr( "VISU_SPACEMOUSE_PREF_1" ), spacemouseGr,
875                                        LightApp_Preferences::Selector, "VISU",
876                                        "spacemouse_func1_btn" ); //decrease_speed_increment
877   int spacemousePref2 = addPreference( tr( "VISU_SPACEMOUSE_PREF_2" ), spacemouseGr,
878                                        LightApp_Preferences::Selector, "VISU",
879                                        "spacemouse_func2_btn" ); //increase_speed_increment
880   int spacemousePref3 = addPreference( tr( "VISU_SPACEMOUSE_PREF_3" ), spacemouseGr,
881                                        LightApp_Preferences::Selector, "VISU",
882                                        "spacemouse_func3_btn" ); //decrease_gauss_point_magnification
883   int spacemousePref4 = addPreference( tr( "VISU_SPACEMOUSE_PREF_4" ), spacemouseGr,
884                                        LightApp_Preferences::Selector, "VISU",
885                                        "spacemouse_func4_btn" ); //increase_gauss_point_magnification
886   int spacemousePref5 = addPreference( tr( "VISU_SPACEMOUSE_PREF_5" ), spacemouseGr,
887                                        LightApp_Preferences::Selector, "VISU",
888                                        "spacemouse_func5_btn" ); //dominant_combined_switch
889   values.clear();
890   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_1" ) );
891   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_2" ) );
892   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_3" ) );
893   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_4" ) );
894   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_5" ) );
895   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_6" ) );
896   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_7" ) );
897   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_8" ) );
898   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_*" ) );
899   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_10" ) );
900   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_11" ) );
901   indices.clear();
902   indices.append( 1 );
903   indices.append( 2 );
904   indices.append( 3 );
905   indices.append( 4 );
906   indices.append( 5 );
907   indices.append( 6 );
908   indices.append( 7 );
909   indices.append( 8 );
910   indices.append( 9 ); // == button_*
911   indices.append( 10 );
912   indices.append( 11 );
913   setPreferenceProperty( spacemousePref1, "strings", values );
914   setPreferenceProperty( spacemousePref1, "indexes", indices );
915   setPreferenceProperty( spacemousePref2, "strings", values );
916   setPreferenceProperty( spacemousePref2, "indexes", indices );
917   setPreferenceProperty( spacemousePref3, "strings", values );
918   setPreferenceProperty( spacemousePref3, "indexes", indices );
919   setPreferenceProperty( spacemousePref4, "strings", values );
920   setPreferenceProperty( spacemousePref4, "indexes", indices );
921   setPreferenceProperty( spacemousePref5, "strings", values );
922   setPreferenceProperty( spacemousePref5, "indexes", indices );
923 }
924
925
926 //---------------------------------------------------------------
927 void VisuGUI_Module::createRecorderPreferences()
928 {
929   int recorderTab = addPreference( tr( "VISU_RECORDER_PREF_TAB_TTL" ) );
930
931   int recorderGr = addPreference( tr( "VISU_RECORDER_PREF_GROUP_TTL" ), recorderTab );
932   setPreferenceProperty( recorderGr, "columns", 2 );
933
934   int modePref = addPreference( tr( "VISU_RECORDER_PREF_RECORDING_MODE" ), recorderGr,
935                                 LightApp_Preferences::Selector, "VISU", "recorder_mode" );
936   QStringList values;
937   values.append( tr( "VISU_RECORDER_PREF_SKIPPED_FRAMES" ) );
938   values.append( tr( "VISU_RECORDER_PREF_ALL_DISLPAYED_FRAMES" ) );
939   QList<QVariant> indices;
940   indices.append( 0 );
941   indices.append( 1 );
942   setPreferenceProperty( modePref, "strings", values );
943   setPreferenceProperty( modePref, "indexes", indices );
944
945   int fpsPref = addPreference( tr( "VISU_RECORDER_PREF_FPS" ), recorderGr,
946                                LightApp_Preferences::DblSpin, "VISU", "recorder_fps" );
947   setPreferenceProperty( fpsPref, "min", 0.1 );
948   setPreferenceProperty( fpsPref, "max", 100 );
949
950   int qualityPref = addPreference( tr( "VISU_RECORDER_PREF_QUALITY" ), recorderGr,
951                                    LightApp_Preferences::IntSpin, "VISU", "recorder_quality" );
952   setPreferenceProperty( qualityPref, "min", 1 );
953   setPreferenceProperty( qualityPref, "max", 100 );
954
955   addPreference( tr( "VISU_RECORDER_PREF_PROGRESSIVE" ), recorderGr,
956                  LightApp_Preferences::Bool, "VISU", "recorder_progressive" );
957 }
958
959
960 //---------------------------------------------------------------
961 void VisuGUI_Module::OnCreateGaussPoints()
962 {
963   double initialTime = vtkTimerLog::GetCPUTime();
964   //CreatePrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg, 1>(this, VVTK_Viewer::Type());
965   Prs3d_i* aPrs = CreatePrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg, 1>(this, SVTK_Viewer::Type());
966   processPresentationCreated(aPrs);
967   INFOS( "VisuGUI_Module::OnCreateGaussPoints() : Gauss Points created in " <<
968          vtkTimerLog::GetCPUTime() - initialTime << " seconds" );
969 }
970
971 // void VisuGUI_Module::OnViewManagerAdded(SUIT_ViewManager* viewMgr)
972 // {
973 //   QString type = viewMgr->getViewModel()->getType();
974 //   if ( type == VVTK_Viewer::Type() ) 
975 //     connect( viewMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
976 //              this, SLOT( OnViewCreated( SUIT_ViewWindow* ) ) );
977 // }
978
979 void VisuGUI_Module::OnViewCreated(SUIT_ViewWindow* view)
980 {
981   SVTK_ViewWindow* viewWindow = dynamic_cast<SVTK_ViewWindow*>( view );
982   if ( viewWindow ) {
983     setProperty( viewWindow, "speed_increment" );
984     setProperty( viewWindow, "spacemouse_func1_btn" );
985     setProperty( viewWindow, "spacemouse_func2_btn" );
986     setProperty( viewWindow, "spacemouse_func3_btn" );
987     setProperty( viewWindow, "spacemouse_func4_btn" );
988     setProperty( viewWindow, "spacemouse_func5_btn" );
989   }
990 }
991
992 void VisuGUI_Module::setProperty( SVTK_ViewWindow* viewWindow, const QString& pref )
993 {
994   if ( !viewWindow )
995     return;
996
997   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
998   //SVTK_MainWindow* aMainWindow = viewWindow->getMainWindow();
999   int val;
1000   if ( pref == "speed_increment" ) {
1001     val = resMgr->integerValue( "VTKViewer", pref, 10 );
1002     viewWindow->InvokeEvent( SVTK::SetSpeedIncrementEvent, &val );
1003   }
1004   else if ( pref == "spacemouse_func1_btn" ) {
1005     val = resMgr->integerValue( "VTKViewer", pref, 1 );
1006     viewWindow->InvokeEvent( SVTK::SetSMDecreaseSpeedEvent, &val );
1007   }
1008   else if ( pref == "spacemouse_func2_btn" ) {
1009     val = resMgr->integerValue( "VTKViewer", pref, 2 );
1010     viewWindow->InvokeEvent( SVTK::SetSMIncreaseSpeedEvent, &val );
1011   }
1012   else if ( pref == "spacemouse_func3_btn" ) {
1013     val = resMgr->integerValue( "VISU", pref, 10 );
1014     viewWindow->InvokeEvent( VISU::SetSMDecreaseMagnificationEvent, &val );
1015   }
1016   else if ( pref == "spacemouse_func4_btn" ) {
1017     val = resMgr->integerValue( "VISU", pref, 11 );
1018     viewWindow->InvokeEvent( VISU::SetSMIncreaseMagnificationEvent, &val );
1019   }
1020   else if ( pref == "spacemouse_func5_btn" ) {
1021     val = resMgr->integerValue( "VTKViewer", pref, 9 );
1022     viewWindow->InvokeEvent( SVTK::SetSMDominantCombinedSwitchEvent, &val );
1023   }
1024 }
1025
1026 void VisuGUI_Module::setProperty( SVTK_ViewManager* vm, const QString& prop )
1027 {
1028   if ( !vm )
1029     return;
1030
1031   QVector<SUIT_ViewWindow*> windows = vm->getViews();
1032   for ( int n = windows.count(), i = 0; i < n; i++ )
1033     setProperty( dynamic_cast<SVTK_ViewWindow*>( windows[i] ), prop );
1034 }
1035
1036 void VisuGUI_Module::preferencesChanged( const QString& group, const QString& pref )
1037 {
1038   VisuGUI::preferencesChanged(group,pref);
1039
1040 //   if ( group == "VISU" && ( pref == "speed_increment" || pref == "spacemouse_func1_btn" ||
1041 //                          pref == "spacemouse_func2_btn" || pref == "spacemouse_func3_btn" || 
1042 //                          pref == "spacemouse_func4_btn" || pref == "spacemouse_func5_btn" ) ) {
1043
1044 //     // update properties of VVTK view windows
1045 //     SUIT_ViewManager* vm = getApp()->getViewManager( VVTK_Viewer::Type(), false );
1046 //     if ( vm ) 
1047 //       setProperty( dynamic_cast<SVTK_ViewManager*>( vm ), pref );
1048 //   }
1049 }
1050
1051
1052 //---------------------------------------------------------------
1053 SUIT_ViewManager* VisuGUI_Module::getViewManager(const QString& theType, 
1054                const bool theIsCreate)
1055 {
1056   if (SUIT_ViewManager* aViewManager = VisuGUI::getViewManager(theType,theIsCreate))
1057     return aViewManager;
1058
1059 //   if (theIsCreate && theType == VVTK_Viewer::Type())
1060 //     return onCreateViewManager();
1061
1062   return NULL;
1063 }
1064
1065 //---------------------------------------------------------------
1066 void VisuGUI_Module::OnEditGaussPoints()
1067 {
1068   VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
1069   if(aSelectionInfo.empty())
1070       return;
1071
1072   VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
1073   Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
1074
1075   if(VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dToModify(this, aSelectionItem.myObjectInfo.myBase)){
1076     if (SVTK_ViewWindow* aViewWindow = GetViewWindow<SVTK_Viewer>(this)) {
1077       EditPrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg, 1>(this, anIO, aPrs3d, aViewWindow);
1078     }
1079     // Create VVTK_ViewWindow, if it does not exist
1080 //     if (VVTK_ViewWindow* aViewWindow = GetViewWindow<VVTK_Viewer>(this)) {
1081 //       EditPrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg, 1>(this, anIO, aPrs3d, aViewWindow);
1082 //     }
1083   }
1084 }
1085
1086
1087 //---------------------------------------------------------------
1088 namespace
1089 {
1090   /*  void   GetViewParams(VVTK_MainWindow* theViewWindow,
1091                        const char* theSuffix,
1092                        std::ostringstream& theStr)
1093   {
1094     vtkFloatingPointType aColor[3];
1095     vtkRenderer* aRenderer = theViewWindow->getRenderer();
1096     aRenderer->GetBackground(aColor);
1097     Storable::DataToStream(theStr,(std::string("myColor") + theSuffix + ".R").c_str(),aColor[0]);
1098     Storable::DataToStream(theStr,(std::string("myColor") + theSuffix + ".G").c_str(),aColor[1]);
1099     Storable::DataToStream(theStr,(std::string("myColor") + theSuffix + ".B").c_str(),aColor[2]);
1100
1101     double aPosition[3];
1102     vtkCamera* aCamera = aRenderer->GetActiveCamera();
1103     aCamera->GetPosition(aPosition);
1104     Storable::DataToStream(theStr,(std::string("myPosition") + theSuffix + "[0]").c_str(),aPosition[0]);
1105     Storable::DataToStream(theStr,(std::string("myPosition") + theSuffix + "[1]").c_str(),aPosition[1]);
1106     Storable::DataToStream(theStr,(std::string("myPosition") + theSuffix + "[2]").c_str(),aPosition[2]);
1107
1108     double aFocalPnt[3];
1109     aCamera->GetFocalPoint(aFocalPnt);
1110     Storable::DataToStream(theStr,(std::string("myFocalPnt") + theSuffix + "[0]").c_str(),aFocalPnt[0]);
1111     Storable::DataToStream(theStr,(std::string("myFocalPnt") + theSuffix + "[1]").c_str(),aFocalPnt[1]);
1112     Storable::DataToStream(theStr,(std::string("myFocalPnt") + theSuffix + "[2]").c_str(),aFocalPnt[2]);
1113
1114     double aViewUp[3];
1115     aCamera->GetViewUp(aViewUp);
1116     Storable::DataToStream(theStr,(std::string("myViewUp") + theSuffix + "[0]").c_str(),aViewUp[0]);
1117     Storable::DataToStream(theStr,(std::string("myViewUp") + theSuffix + "[1]").c_str(),aViewUp[1]);
1118     Storable::DataToStream(theStr,(std::string("myViewUp") + theSuffix + "[2]").c_str(),aViewUp[2]);
1119
1120     vtkFloatingPointType aParallelScale = aCamera->GetParallelScale();
1121     Storable::DataToStream(theStr,(std::string("myParallelScale") + theSuffix).c_str(),aParallelScale);
1122
1123     double aScaleFactor[3];
1124     theViewWindow->GetScale(aScaleFactor);
1125     Storable::DataToStream(theStr,(std::string("myScaleFactor") + theSuffix + "[0]").c_str(),aScaleFactor[0]);
1126     Storable::DataToStream(theStr,(std::string("myScaleFactor") + theSuffix + "[1]").c_str(),aScaleFactor[1]);
1127     Storable::DataToStream(theStr,(std::string("myScaleFactor") + theSuffix + "[2]").c_str(),aScaleFactor[2]);
1128   }
1129   */
1130   //---------------------------------------------------------------
1131   /*  void SetViewParams(VVTK_MainWindow* theViewWindow,
1132                      const char* theSuffix,
1133                      const Storable::TRestoringMap& theMap)
1134   {
1135     vtkFloatingPointType aColor[3];
1136     aColor[0] = Storable::FindValue(theMap,std::string("myColor") + theSuffix + ".R").toDouble();
1137     aColor[1] = Storable::FindValue(theMap,std::string("myColor") + theSuffix + ".G").toDouble();
1138     aColor[2] = Storable::FindValue(theMap,std::string("myColor") + theSuffix + ".B").toDouble();
1139     vtkRenderer* aRenderer = theViewWindow->getRenderer();
1140     aRenderer->SetBackground(aColor);
1141
1142     double aPosition[3];
1143     aPosition[0] = Storable::FindValue(theMap,std::string("myPosition") + theSuffix + "[0]").toDouble();
1144     aPosition[1] = Storable::FindValue(theMap,std::string("myPosition") + theSuffix + "[1]").toDouble();
1145     aPosition[2] = Storable::FindValue(theMap,std::string("myPosition") + theSuffix + "[2]").toDouble();
1146     vtkCamera* aCamera = aRenderer->GetActiveCamera();
1147     aCamera->SetPosition(aPosition);
1148
1149     double aFocalPnt[3];
1150     aFocalPnt[0] = Storable::FindValue(theMap,std::string("myFocalPnt") + theSuffix + "[0]").toDouble();
1151     aFocalPnt[1] = Storable::FindValue(theMap,std::string("myFocalPnt") + theSuffix + "[1]").toDouble();
1152     aFocalPnt[2] = Storable::FindValue(theMap,std::string("myFocalPnt") + theSuffix + "[2]").toDouble();
1153     aCamera->SetFocalPoint(aFocalPnt);
1154
1155     double aViewUp[3];
1156     aViewUp[0] = Storable::FindValue(theMap,std::string("myViewUp") + theSuffix + "[0]").toDouble();
1157     aViewUp[1] = Storable::FindValue(theMap,std::string("myViewUp") + theSuffix + "[1]").toDouble();
1158     aViewUp[2] = Storable::FindValue(theMap,std::string("myViewUp") + theSuffix + "[2]").toDouble();
1159     aCamera->SetViewUp(aViewUp);
1160
1161     vtkFloatingPointType aParallelScale = Storable::FindValue(theMap,std::string("myParallelScale") + theSuffix).toDouble();
1162     aCamera->SetParallelScale(aParallelScale);
1163
1164     double aScaleFactor[3];
1165     aScaleFactor[0] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[0]").toDouble();
1166     aScaleFactor[1] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[1]").toDouble();
1167     aScaleFactor[2] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[2]").toDouble();
1168     theViewWindow->SetScale(aScaleFactor);
1169   }
1170   */
1171   //---------------------------------------------------------------
1172   /*  void   GetViewParams(VVTK_MainWindow1* theViewWindow,
1173                        std::ostringstream& theStr)
1174   {
1175     GetViewParams(theViewWindow,"1",theStr);
1176
1177     VISU_WidgetCtrl* aWidgetCtrl = theViewWindow->GetWidgetCtrl();
1178     if(aWidgetCtrl->GetEnabled()){
1179       std::string aSegmentationMode;
1180       if(aWidgetCtrl->IsPlanesActive()){
1181         VISU_PlanesWidget *aPlanesWidget = aWidgetCtrl->GetPlanesWidget();
1182         vtkFloatingPointType anOrigin[3];
1183         aPlanesWidget->GetOrigin(anOrigin);
1184         Storable::DataToStream(theStr,"myCursorOrigin[0]",anOrigin[0]);
1185         Storable::DataToStream(theStr,"myCursorOrigin[1]",anOrigin[1]);
1186         Storable::DataToStream(theStr,"myCursorOrigin[2]",anOrigin[2]);
1187
1188         vtkFloatingPointType aNormal[3];
1189         aPlanesWidget->GetNormal(aNormal);
1190         Storable::DataToStream(theStr,"myCursorNormal[0]",aNormal[0]);
1191         Storable::DataToStream(theStr,"myCursorNormal[1]",aNormal[1]);
1192         Storable::DataToStream(theStr,"myCursorNormal[2]",aNormal[2]);
1193
1194         vtkFloatingPointType aDepth = aPlanesWidget->Distance();
1195         Storable::DataToStream(theStr,"myCursorDepth",aDepth);
1196
1197         aSegmentationMode = "Planes";
1198       }else if(aWidgetCtrl->IsSphereActive()){
1199         VISU_SphereWidget *aSphereWidget = aWidgetCtrl->GetSphereWidget();
1200         vtkFloatingPointType aCenter[3];
1201         aSphereWidget->GetCenter(aCenter);
1202         Storable::DataToStream(theStr,"mySphereCursorCenter[0]",aCenter[0]);
1203         Storable::DataToStream(theStr,"mySphereCursorCenter[1]",aCenter[1]);
1204         Storable::DataToStream(theStr,"mySphereCursorCenter[2]",aCenter[2]);
1205
1206         vtkFloatingPointType aRadius = aSphereWidget->GetRadius();
1207         Storable::DataToStream(theStr,"mySphereCursorRaduis",aRadius);
1208
1209         aSegmentationMode = "Sphere";
1210       }
1211
1212       Storable::DataToStream(theStr,"mySegmentationMode",aSegmentationMode.c_str());
1213     }
1214   }
1215   */
1216   //---------------------------------------------------------------
1217   /*void SetViewParams(VVTK_MainWindow1* theViewWindow,
1218                      const Storable::TRestoringMap& theMap)
1219   {
1220     SetViewParams(theViewWindow,"1",theMap);
1221   }
1222
1223   */
1224   //---------------------------------------------------------------
1225   /*void GetViewParams(VVTK_MainWindow2* theViewWindow,
1226                      std::ostringstream& theStr)
1227   {
1228     GetViewParams(theViewWindow,"2",theStr);
1229   }
1230
1231   void SetViewParams(VVTK_MainWindow2* theViewWindow,
1232                      const Storable::TRestoringMap& theMap)
1233   {
1234     SetViewParams(theViewWindow,"2",theMap);
1235   }
1236   */
1237
1238   //---------------------------------------------------------------
1239   /*std::string GetViewParams(VVTK_ViewWindow* theViewWindow)
1240   {
1241     std::ostringstream aStream;
1242
1243     Storable::DataToStream(aStream,"myComment","GAUSSVIEW");
1244
1245     SVTK_Selector* aSelector = theViewWindow->GetSelector();
1246     Selection_Mode aSelectionMode = aSelector->SelectionMode();
1247     Storable::DataToStream(aStream,"mySelectionMode",aSelectionMode);
1248
1249     GetViewParams(theViewWindow->getMainWindow1(),aStream);
1250     GetViewParams(theViewWindow->getMainWindow2(),aStream);
1251
1252     return aStream.str();
1253   }
1254   */
1255   //---------------------------------------------------------------
1256   struct TSelection
1257   {
1258     bool myIsSelected;
1259     bool myHasSubId;
1260     int mySubId;
1261
1262     TSelection():
1263       myIsSelected(false),
1264       myHasSubId(false),
1265       mySubId(-1)
1266     {}
1267   };
1268
1269   typedef std::map<std::string,TSelection> TVisibleEntries;
1270
1271   struct TGetVisibleEntries
1272   {
1273     TVisibleEntries& myVisibleEntries;
1274
1275     TGetVisibleEntries(TVisibleEntries& theVisibleEntries):
1276       myVisibleEntries(theVisibleEntries)
1277     {}
1278
1279     void operator()(VISU_GaussPtsAct* theActor) 
1280     {
1281       if(theActor->GetVisibility()){
1282         const Handle(SALOME_InteractiveObject)& anIO = theActor->getIO();
1283         myVisibleEntries.insert(TVisibleEntries::value_type(anIO->getEntry(),TSelection()));
1284       }
1285     }
1286   };
1287
1288   /*void GetGaussPointsSelection(SVTK_ViewWindow* theViewWindow,
1289                                TVisibleEntries& theVisibleEntries)
1290   {
1291     // First find all visible Gauss Points presentations
1292     vtkRenderer* aRenderer = theViewWindow->getRenderer();
1293     vtkActorCollection* anActors = aRenderer->GetActors();
1294     TGetVisibleEntries aGetVisibleEntries(theVisibleEntries);
1295     SVTK::ForEach<VISU_GaussPtsAct>(anActors,
1296                                     aGetVisibleEntries);
1297
1298     // Next, find the sub-ids for the visible Gauss Points presentations
1299     SVTK_Selector* aSelector = theViewWindow->GetSelector();
1300     const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
1301     SALOME_ListIteratorOfListIO anIter(aListIO);
1302     for(; anIter.More(); anIter.Next()){
1303       Handle(SALOME_InteractiveObject) anIO = anIter.Value();
1304       std::string anEntry = anIO->getEntry();
1305       TVisibleEntries::iterator anEntriesIter = theVisibleEntries.find(anEntry);
1306       if(anEntriesIter != theVisibleEntries.end()){
1307         TSelection& aSelection = anEntriesIter->second;
1308         aSelection.myIsSelected = true;
1309         TColStd_IndexedMapOfInteger anIndexes;
1310         aSelector->GetIndex(anIO,anIndexes);
1311         if(anIndexes.Extent() > 0){
1312           aSelection.myHasSubId = true;
1313           aSelection.mySubId = anIndexes(1);
1314         }
1315       }
1316     }
1317   }
1318   */
1319
1320   //---------------------------------------------------------------
1321   inline void CreateReference(_PTR(Study) theStudyDocument,
1322                               _PTR(StudyBuilder) theStudyBuilder,
1323                               _PTR(SObject) theFatherSObject, 
1324                               const string& theRefEntry,
1325                               const TSelection& theSelection)
1326   {
1327     _PTR(SObject) aNewObj = theStudyBuilder->NewObject(theFatherSObject);
1328     _PTR(SObject) aRefSObj = theStudyDocument->FindObjectID(theRefEntry);
1329     theStudyBuilder->Addreference(aNewObj,aRefSObj);
1330
1331     std::ostringstream aStream;
1332     Storable::DataToStream(aStream,"myIsSelected",theSelection.myIsSelected);
1333     Storable::DataToStream(aStream,"myHasSubId",theSelection.myHasSubId);
1334     Storable::DataToStream(aStream,"mySubId",theSelection.mySubId);
1335
1336     _PTR(GenericAttribute) anAttr;
1337     anAttr = theStudyBuilder->FindOrCreateAttribute(aNewObj,"AttributeString");
1338     _PTR(AttributeString) aComment(anAttr);
1339     aComment->SetValue(aStream.str());
1340   }
1341
1342
1343   //---------------------------------------------------------------
1344   /*void SetGaussPointsSelection(VisuGUI* theModule,
1345                                SVTK_ViewWindow* theViewWindow,
1346                                _PTR(Study) theCStudy,
1347                                _PTR(SObject) theSObject)
1348   {
1349     SVTK_Selector* aSelector = theViewWindow->GetSelector();
1350     aSelector->ClearIObjects();
1351
1352     bool anIsFirst = true;
1353     _PTR(ChildIterator) aChildIter = theCStudy->NewChildIterator(theSObject);
1354     for (; aChildIter->More(); aChildIter->Next()) {
1355       _PTR(SObject) aChildSObject = aChildIter->Value();
1356       _PTR(SObject) aSObject;
1357       if(aChildSObject->ReferencedObject(aSObject)){
1358         CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
1359         PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1360         if(VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in())){
1361           // To set visiblity
1362           VISU::UpdateViewer(theModule, aPrs3d, anIsFirst, false);
1363           anIsFirst = false;
1364
1365           // To update selection
1366           Storable::TRestoringMap aMap = Storable::GetStorableMap(aChildSObject);
1367           if(!aMap.empty()){
1368             bool anIsSelected = aMap["myIsSelected"].toInt();
1369             bool aHasSubId = aMap["myHasSubId"].toInt();
1370             int aSubId = aMap["mySubId"].toInt();
1371
1372             if(anIsSelected){
1373               std::string anEntry = aSObject->GetID();
1374               Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(anEntry.c_str(),"");
1375               aSelector->AddIObject(anIO);
1376               if(aHasSubId)
1377                 aSelector->AddOrRemoveIndex(anIO,aSubId,false);
1378             }
1379           }
1380         }
1381       }
1382     }
1383
1384     aSelector->EndPickCallback(); // To invoke selection changed signal
1385   }
1386   */
1387
1388   //---------------------------------------------------------------
1389   /*void OnStoreConfiguration(SalomeApp_Module* theModule,
1390                             bool theIsNew)
1391   {
1392     _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1393     if (CheckLock(aCStudy,GetDesktop(theModule)))
1394       return;
1395
1396     LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
1397
1398     SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager();
1399         if(aViewManager->getType() == VVTK_Viewer::Type()){
1400       SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
1401       VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
1402
1403       SUIT_Study* aSStudy = aViewManager->study();
1404       SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy);
1405       _PTR(Study) aCStudy = aStudy->studyDS();
1406       _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1407
1408       std::string anEntry;
1409       std::string aValue = GetViewParams(aViewWindow);
1410
1411       if(theIsNew){
1412         _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1413
1414         static int myNbConfigs = 0;
1415         std::string aName = VISU::GenerateName("Config.", ++myNbConfigs).toLatin1().data();
1416
1417         std::string aSComponentEntry = aSComponent->GetID();
1418         anEntry = CreateAttributes(aCStudy,
1419                                    aSComponentEntry.c_str(),
1420                                    "",
1421                                    "",
1422                                    aName.c_str(),
1423                                    "",
1424                                    aValue.c_str());
1425       }else{
1426         SALOME_ListIO aListIO;
1427         aSelectionMgr->selectedObjects(aListIO);
1428         SALOME_ListIteratorOfListIO aListIter( aListIO );
1429         for(; aListIter.More(); aListIter.Next()){
1430           Handle(SALOME_InteractiveObject) anIO = aListIter.Value();
1431           _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1432           _PTR(GenericAttribute) anAttr;
1433           if(aSObject->FindAttribute(anAttr,"AttributeString")){
1434             _PTR(AttributeString) aComment(anAttr);
1435             std::string aCommentValue(aComment->Value());
1436             if(aCommentValue.compare("myComment=GAUSSVIEW") >= 0){
1437               aComment->SetValue(aValue.c_str());
1438               anEntry = aSObject->GetID();
1439
1440               _PTR(ChildIterator) aChildIter = aCStudy->NewChildIterator(aSObject);
1441               for (; aChildIter->More(); aChildIter->Next()) {
1442                 _PTR(SObject) aChildSObject = aChildIter->Value();
1443                 aStudyBuilder->RemoveObject(aChildSObject);
1444               }
1445               break;
1446             }
1447           }
1448         }
1449       }
1450
1451       if(anEntry != ""){
1452         TVisibleEntries aVisibleEntries;
1453         GetGaussPointsSelection(aViewWindow,
1454                                 aVisibleEntries);
1455
1456         _PTR(SObject) aSObject = aCStudy->FindObjectID(anEntry);
1457         _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1458         TVisibleEntries::const_iterator anIter =  aVisibleEntries.begin();
1459         for(; anIter != aVisibleEntries.end(); anIter++){
1460           const std::string& anEntry = anIter->first;
1461           const TSelection& aSelection = anIter->second;
1462
1463           CreateReference(aCStudy,
1464                           aStudyBuilder,
1465                           aSObject,
1466                           anEntry,
1467                           aSelection);
1468         }
1469
1470         //UpdateObjBrowser(theModule,true,aSObject);
1471         UpdateObjBrowser(theModule,true);
1472       }
1473     } 
1474     }*/
1475
1476
1477   //---------------------------------------------------------------
1478 /*  template<class TMainWindow>
1479   void SetMainWindowParams(VisuGUI* theModule,
1480                            _PTR(SObject) theSObject,
1481                            VVTK_ViewWindow* theViewWindow,
1482                            TMainWindow* theMainWindow)
1483   {
1484     _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1485
1486     Storable::TRestoringMap aMap = Storable::GetStorableMap(theSObject);
1487     if(!aMap.empty())
1488       SetViewParams(theMainWindow, aMap);
1489       }*/
1490 }
1491
1492
1493 //---------------------------------------------------------------
1494 // void VisuGUI_Module::OnSaveConfiguration()
1495 // {
1496 //   ::OnStoreConfiguration(this,true);
1497 // }
1498
1499
1500 //---------------------------------------------------------------
1501 // void VisuGUI_Module::OnOverwriteConfiguration()
1502 // {
1503 //   ::OnStoreConfiguration(this,false);
1504 // }
1505
1506
1507 //---------------------------------------------------------------
1508 /*void VisuGUI_Module::OnRestoreConfiguration()
1509 {
1510   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1511
1512   SALOME_ListIO aListIO;
1513   aSelectionMgr->selectedObjects(aListIO);
1514   if(aListIO.Extent() > 1)
1515     return;
1516
1517   if(SUIT_ViewManager* aViewManager = getViewManager(VVTK_Viewer::Type(),true)){
1518     const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1519     _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1520     _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1521     myConfigSObject = aSObject;
1522     Storable::TRestoringMap aMap = Storable::GetStorableMap(aSObject);
1523     if(!aMap.empty()){
1524       SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView();
1525       
1526       Selection_Mode aSelectionMode = Storable::FindValue(aMap,"mySelectionMode").toInt();
1527       SVTK_Selector* aSelector = aViewWindow->GetSelector();
1528       aSelector->SetSelectionMode(aSelectionMode);
1529
1530       SetGaussPointsSelection(this,aViewWindow,aCStudy,aSObject);
1531
1532       std::string aSegmentationMode;
1533       if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
1534         aMainWindow->SetPlanesSegementation(false);
1535         aMainWindow->SetSphereSegementation(false);
1536         VISU_WidgetCtrl* aWidgetCtrl = aMainWindow->GetWidgetCtrl();
1537         aSegmentationMode = Storable::FindValue(aMap,"mySegmentationMode").toLatin1().data();
1538
1539         if(aSegmentationMode == "Planes"){
1540           VISU_PlanesWidget *aPlanesWidget = aWidgetCtrl->GetPlanesWidget();
1541           vtkFloatingPointType anOrigin[3];
1542           anOrigin[0] = Storable::FindValue(aMap,"myCursorOrigin[0]").toDouble();
1543           anOrigin[1] = Storable::FindValue(aMap,"myCursorOrigin[1]").toDouble();
1544           anOrigin[2] = Storable::FindValue(aMap,"myCursorOrigin[2]").toDouble();
1545           aPlanesWidget->SetOrigin(anOrigin);
1546
1547           vtkFloatingPointType aNormal[3];
1548           aNormal[0] = Storable::FindValue(aMap,"myCursorNormal[0]").toDouble();
1549           aNormal[1] = Storable::FindValue(aMap,"myCursorNormal[1]").toDouble();
1550           aNormal[2] = Storable::FindValue(aMap,"myCursorNormal[2]").toDouble();
1551           aPlanesWidget->SetNormal(aNormal);
1552
1553           vtkFloatingPointType aDepth = Storable::FindValue(aMap,"myCursorDepth").toDouble();
1554           aPlanesWidget->SetDistance(aDepth);
1555
1556           aMainWindow->SetPlanesSegementation(true);
1557         }else if(aSegmentationMode == "Sphere"){
1558           VISU_SphereWidget *aSphereWidget = aWidgetCtrl->GetSphereWidget();
1559           vtkFloatingPointType aCenter[3];
1560           aCenter[0] = Storable::FindValue(aMap,"mySphereCursorCenter[0]").toDouble();
1561           aCenter[1] = Storable::FindValue(aMap,"mySphereCursorCenter[1]").toDouble();
1562           aCenter[2] = Storable::FindValue(aMap,"mySphereCursorCenter[2]").toDouble();
1563           aSphereWidget->SetCenter(aCenter);
1564
1565           vtkFloatingPointType aRadius = Storable::FindValue(aMap,"mySphereCursorRaduis").toDouble();
1566           aSphereWidget->SetRadius(aRadius);
1567
1568           aMainWindow->SetSphereSegementation(true);
1569         }
1570       }
1571
1572       if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
1573         SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1574         if(anInteractor->isVisible()){
1575           SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1576         }else
1577           anInteractor->installEventFilter(this);
1578       }
1579
1580       if(aSegmentationMode != ""){
1581         if(VVTK_MainWindow2* aMainWindow = aViewWindow->getMainWindow2()){
1582           SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1583           if(anInteractor->isVisible())
1584             SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1585           else
1586             anInteractor->installEventFilter(this);
1587         }
1588       }
1589
1590       SetGaussPointsSelection(this,aViewWindow,aCStudy,aSObject);
1591     }
1592   }
1593 }*/
1594
1595
1596 //---------------------------------------------------------------
1597 //bool VisuGUI_Module::eventFilter( QObject * theWatched, QEvent * theEvent )
1598 //{
1599 //  bool aRet = VisuGUI::eventFilter(theWatched,theEvent);
1600 //   if(theEvent->type() == QEvent::Show){
1601 //     if(SUIT_ViewManager* aViewManager = getViewManager(VVTK_Viewer::Type(),false)){
1602 //       SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
1603 //       VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
1604 //       if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
1605 //      SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1606 //      if(theWatched == anInteractor){
1607 //        SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1608 //        anInteractor->removeEventFilter(this);
1609 //      }
1610 //       }
1611 //       if(VVTK_MainWindow2* aMainWindow = aViewWindow->getMainWindow2()){
1612 //      SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1613 //      if(theWatched == aMainWindow->GetInteractor()){
1614 //        SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1615 //        anInteractor->removeEventFilter(this);
1616 //      }
1617 //       }
1618 //     }
1619 //   }
1620 //  return aRet;
1621 //}
1622
1623
1624 const char gSeparator = '_'; // character used to separate parameter names
1625 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
1626 /*!
1627  * \brief Virtual public
1628  *
1629  * This method is called just before the study document is saved, so the module has a possibility
1630  * to store visual parameters in AttributeParameter attribue(s)
1631  */
1632 void VisuGUI_Module::storeVisualParameters(int savePoint)
1633 {
1634   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
1635   if( !study || !study->studyDS() )
1636     return;
1637   _PTR(Study) studyDS = study->studyDS();
1638   _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative", moduleName().toLatin1().data(), savePoint);
1639   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1640
1641   // viewers counters are used for storing view_numbers in IParameters
1642   int svtkViewers( 0 ), /*vvtkViewers( 0 ),*/ plotViewers( 0 );
1643
1644   // componentName is used for encoding of entries when storing them in IParameters
1645   _PTR(SComponent) visuEng = ClientFindOrCreateVisuComponent( studyDS );
1646   std::string componentName = visuEng->ComponentDataType();
1647
1648   QList<SUIT_ViewManager*> lst;
1649   QList<SUIT_ViewManager*>::Iterator it;
1650
1651   // saving VVTK viewer parameters.  VVTK (Gauss Viewers) are NOT created by SalomeApp since
1652   // VVTK is declared in VISU, so here we store VVTK view window parameters.
1653   // VisuGUI_Module::restoreVisualParameters() creates VVTK_Views and restores its parameters.
1654   /*  ip->setProperty( "ActiveGaussViewer", "-1" ); 
1655   getApp()->viewManagers( VVTK_Viewer::Type(), lst );
1656   for ( it = lst.begin(); it != lst.end(); it++ ) {
1657     if ( SUIT_ViewWindow* vwin = (*it)->getActiveView() ) {
1658       // using predefined string "GaussViewer" as "entry"..  it's a hardcoded "workaround".
1659       // gauss viewer parameters are retrieved using this "entry" string.
1660       // name of parameter  = caption of gauss ViewWindow
1661       // value of parameter = ViewWindow's visual parameters
1662       ip->setParameter( "GaussViewer",
1663                         vwin->windowTitle().toLatin1().data(),
1664                         vwin->getVisualParameters().toLatin1().data() );
1665
1666       if ( application()->desktop()->activeWindow() == vwin )
1667         ip->setProperty( "ActiveGaussViewer", QString::number( vvtkViewers ).toLatin1().data() );
1668       vvtkViewers++;
1669     }
1670   }
1671   */
1672   // VISU module opens one SVTK viewer in activateModule().  This causes a bug in save-restore visual
1673   // parameters: it no SVTK view was saved, we need NOT any SVTK on restore.  Here we store if any is open..
1674   /*
1675   lst.clear();
1676   getApp()->viewManagers( SVTK_Viewer::Type(), lst );
1677   ip->setProperty( "VtkViewersCount", QString::number( lst.count() ).latin1() );
1678   */
1679
1680   // main cycle to store parameters of displayed objects
1681   lst.clear();
1682   getApp()->viewManagers( lst );
1683   /*vvtkViewers = */svtkViewers = plotViewers = 0;
1684   for ( it = lst.begin(); it != lst.end(); it++ ) {
1685     SUIT_ViewManager* vman = *it;
1686     QString vType = vman->getType();
1687     int* viewsCounter = vType == SVTK_Viewer::Type()    ? &svtkViewers :
1688       //vType == VVTK_Viewer::Type()    ? &vvtkViewers :
1689                         vType == SPlot2d_Viewer::Type() ? &plotViewers : 0;
1690
1691     // saving VTK actors' properties
1692     if ( vType == SVTK_Viewer::Type() /*||  // processing SVTK and VVTK viewers in the same
1693                                         vType == VVTK_Viewer::Type()*/ ) { // way (VVTK_ViewWindow inherits SVTK_ViewWindow)       
1694
1695       QVector<SUIT_ViewWindow*> views = vman->getViews();
1696       for ( int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++ ) {
1697         if ( SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>( views[i] ) ) {
1698           VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
1699           vtkActorCollection* allActors = aCopy.GetActors();
1700           allActors->InitTraversal();
1701           while ( vtkActor* actor = allActors->GetNextActor() ) {
1702             if ( actor->GetVisibility() ) { // store only visible actors
1703               if ( VISU_Actor* vActor = VISU_Actor::SafeDownCast( actor ) ) {
1704                 if ( vActor->hasIO() ) { // actor corresponds to existing obj
1705
1706                   Handle(SALOME_InteractiveObject) io = vActor->getIO();
1707                   // entry is "ecoded" = it does NOT contain component adress, since it is a
1708                   // subject to change on next component loading
1709                   std::string entry = ip->encodeEntry( io->getEntry(), componentName );
1710
1711                   std::string param, vtkParam = vType.toLatin1().data();
1712                   vtkParam += gSeparator;
1713                   vtkParam += QString::number( *viewsCounter ).toLatin1().data();
1714                   vtkParam += gSeparator;
1715
1716                   param = vtkParam + "Visibility";
1717                   ip->setParameter( entry, param, "On" );
1718                   param = vtkParam + "Name";
1719                   ip->setParameter( entry, param, vActor->getName() );
1720                   param = vtkParam + "RepresentationMode";
1721                   ip->setParameter( entry, param, QString::number( vActor->GetRepresentation() ).toLatin1().data() );
1722                   param = vtkParam + "Quadratic2DRepresentation";
1723                   ip->setParameter( entry, param, QString::number( vActor->GetQuadratic2DRepresentation() ).toLatin1().data() );
1724                   param = vtkParam + "Opacity";
1725                   ip->setParameter( entry, param, QString::number( vActor->GetOpacity() ).toLatin1().data() );
1726                   vtkFloatingPointType r, g, b;
1727                   vActor->GetColor(r, g, b);
1728                   QString colorStr  = QString::number( r ); colorStr += gDigitsSep;
1729                           colorStr += QString::number( g ); colorStr += gDigitsSep;
1730                           colorStr += QString::number( b );
1731                   param = vtkParam + "Color";
1732                   ip->setParameter( entry, param, colorStr.toLatin1().data() );
1733                   param = vtkParam + "LineWidth";
1734                   ip->setParameter( entry, param, QString::number( vActor->GetLineWidth() ).toLatin1().data() );
1735                   if ( vActor->IsShrunkable() && vActor->IsShrunk() ) {
1736                     param = vtkParam + "ShrinkMode";
1737                     ip->setParameter( entry, param, "On" );
1738                     param = vtkParam + "ShrinkFactor";
1739                     ip->setParameter( entry, param, QString::number( vActor->GetShrinkFactor() ).toLatin1().data() );
1740                   }
1741                   VISU_ScalarMapAct* scalarMapActor = dynamic_cast<VISU_ScalarMapAct*>( vActor );
1742                   if ( scalarMapActor && scalarMapActor->IsShading() ) {
1743                     param = vtkParam + "Shading";
1744                     ip->setParameter( entry, param, "On" );
1745                   }
1746                   if ( const VISU::Prs3d_i* vPrs = vActor->GetPrs3d() ) {
1747                     param = vtkParam + "ClippingPlane";
1748                     int nPlanes = vPrs->GetNumberOfClippingPlanes();
1749                     if ( !nPlanes )
1750                       ip->setParameter( entry, param, "Off" );
1751                     for ( int p = 0; p < nPlanes; p++ ) {
1752                       vtkPlane* plane = vPrs->GetClippingPlane( p );
1753                       vtkFloatingPointType normal[3], origin[3];
1754                       plane->GetNormal( normal );
1755                       plane->GetOrigin( origin );
1756                       std::string planeValue  = QString::number( normal[0] ).toLatin1().data(); planeValue += gDigitsSep;
1757                                   planeValue += QString::number( normal[1] ).toLatin1().data(); planeValue += gDigitsSep;
1758                                   planeValue += QString::number( normal[2] ).toLatin1().data(); planeValue += gDigitsSep;
1759                                   planeValue += QString::number( origin[0] ).toLatin1().data(); planeValue += gDigitsSep;
1760                                   planeValue += QString::number( origin[1] ).toLatin1().data(); planeValue += gDigitsSep;
1761                                   planeValue += QString::number( origin[2] ).toLatin1().data();
1762                       param = QString( "%1ClippingPlane_%2" ).arg( vtkParam.c_str() ).arg( p+1 ).toLatin1().data();
1763                       ip->setParameter( entry, param, planeValue );
1764                     }
1765                   }
1766
1767                 } // hasIO
1768               } // salome_actor successfull downcast to the VISU_Actor
1769               else if ( VISU_PointMap3dActor* vActor = VISU_PointMap3dActor::SafeDownCast( actor ) ) { //  PointMap3D
1770                 if ( vActor->hasIO() ) { // actor corresponds to existing obj
1771                   Handle(SALOME_InteractiveObject) io = vActor->getIO();
1772                   // entry is "ecoded" = it does NOT contain component adress, since it is a
1773                   // subject to change on next component loading
1774                   std::string entry = ip->encodeEntry( io->getEntry(), componentName );
1775                   std::string param, vtkParam = vType.toLatin1().data();
1776                   vtkParam += gSeparator;
1777                   vtkParam += QString::number( *viewsCounter ).toLatin1().data();
1778                   vtkParam += gSeparator;
1779
1780                   param = vtkParam + "Visibility";
1781                   ip->setParameter( entry, param, "On" );
1782                   param = vtkParam + "Name";
1783                   ip->setParameter( entry, param, vActor->getName() );
1784                   param = vtkParam + "RepresentationMode";
1785                   ip->setParameter( entry, param, QString::number( vActor->GetRepresentation() ).toLatin1().data() );
1786                   param = vtkParam + "Opacity";
1787                   ip->setParameter( entry, param, QString::number( vActor->GetOpacity() ).toLatin1().data() );
1788                   vtkFloatingPointType r, g, b;
1789                   vActor->GetColor(r, g, b);
1790                   QString colorStr  = QString::number( r ); colorStr += gDigitsSep;
1791                   colorStr += QString::number( g ); colorStr += gDigitsSep;
1792                   colorStr += QString::number( b );
1793                   param = vtkParam + "Color";
1794                   ip->setParameter( entry, param, colorStr.toLatin1().data() );
1795                   param = vtkParam + "LineWidth";
1796                   ip->setParameter( entry, param, QString::number( vActor->GetLineWidth() ).toLatin1().data() );
1797                   if ( vActor->IsShrunkable() && vActor->IsShrunk() ) {
1798                     param = vtkParam + "ShrinkMode";
1799                     ip->setParameter( entry, param, "On" );
1800                     param = vtkParam + "ShrinkFactor";
1801                     ip->setParameter( entry, param, QString::number( vActor->GetShrinkFactor() ).toLatin1().data() );
1802                   }
1803                 }
1804                 } // salome actor is downcasted to the VISU_PointMap3dActor
1805             } // isVisible
1806           } // end of ..while.. actors traversal
1807         } // if ( vtkView )
1808       } // for ( views )
1809       (*viewsCounter)++;
1810     } // if ( SVTK view model )
1811     else if ( vType == SPlot2d_Viewer::Type() ) {  // processing Plot2d viewers
1812       QVector<SUIT_ViewWindow*> views = vman->getViews();
1813       for ( int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++ ) {
1814         if ( Plot2d_ViewWindow* plotView = dynamic_cast<Plot2d_ViewWindow*>( views[i] ) ) {
1815           Plot2d_ViewFrame* plotVF = plotView->getViewFrame();
1816           QList<Plot2d_Curve*> curves;
1817           QList<Plot2d_Curve*>::Iterator itCurve;
1818           plotVF->getCurves( curves );
1819           
1820           //Plot2d_Curve* curve;
1821           for ( itCurve = curves.begin(); itCurve != curves.end(); itCurve++ ) {
1822             if ( SPlot2d_Curve* sCurve = dynamic_cast<SPlot2d_Curve*>( *itCurve ) ) {
1823               if ( sCurve->hasIO() ) {
1824
1825                 Handle(SALOME_InteractiveObject) io = sCurve->getIO();
1826                 // entry is "ecoded" = it does NOT contain component adress, since it is a
1827                 // subject to change on next component loading
1828                 std::string entry = ip->encodeEntry( io->getEntry(), componentName );
1829
1830                 std::string param, plotParam = vType.toLatin1().data(); plotParam += gSeparator;
1831                 plotParam += QString::number( *viewsCounter ).toLatin1().data();      plotParam += gSeparator;
1832
1833                 param = plotParam + "Visibility";
1834                 ip->setParameter( entry, param, "On" );
1835               }
1836             }
1837           } // for curves
1838         } // if ( plotView )
1839       } // for ( views )
1840       (*viewsCounter)++;
1841     } // if ( SPlot2d view model )
1842   }
1843 }
1844
1845 const int ViewerType = 0;
1846 const int ViewIndex = 1;
1847 const int ParamName = 2;
1848 // visual parameters are stored in strings as follows:
1849 // ViewerType_ViewNumber_ParamName.  '_' is used as separator and should not be used in
1850 // viewer type or parameter names
1851
1852 // return viewer type substring from parameter name
1853 std::string getParam( const std::string& paramName, const int index )
1854 {
1855   QStringList lst = QString( paramName.c_str() ).split( gSeparator, QString::SkipEmptyParts );
1856   if ( !lst.isEmpty() && index < lst.size() )
1857     return lst[index].toLatin1().data();
1858   return "";
1859 }
1860
1861
1862 /*!
1863  * \brief Virtual public
1864  *
1865  * This method is called after the study document is opened, so the module has a possibility to restore
1866  * visual parameters
1867  */
1868 void VisuGUI_Module::restoreVisualParameters(int savePoint)
1869 {
1870   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
1871   if( !study || !study->studyDS() )
1872     return;
1873   _PTR(Study) studyDS = study->studyDS();
1874   _PTR(AttributeParameter) ap =
1875     studyDS->GetModuleParameters("Interface Applicative", moduleName().toLatin1().data(), savePoint);
1876   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1877
1878   // actors are stored in a map after displaying of them for quicker access in future
1879   QMap<QString, QMap<QString, VISU_Actor*> > vtkActors; // map: entry to map: ViewType_<ID> to actor (SVTK/VVTK)
1880
1881   std::vector<std::string> entries = ip->getEntries();
1882
1883   for ( std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt ) {
1884
1885     std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
1886     std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
1887     std::vector<std::string>::iterator namesIt = paramNames.begin();
1888     std::vector<std::string>::iterator valuesIt = paramValues.begin();
1889     
1890 //     if ( *entIt == "GaussViewer" ) {
1891 //       // parameter names are view window's captions, values - visual parameters.
1892 //       for ( ; namesIt != paramNames.end(); ++namesIt, ++valuesIt ) {
1893 //      SUIT_ViewManager* vman = onCreateViewManager();
1894 //      SUIT_ViewWindow* vwin = vman->getActiveView(); 
1895 //      vwin->setWindowTitle( (*namesIt).c_str() );
1896
1897 //      // wait untill the window is really shown.  This step fixes MANY bugs..
1898 //      while ( !vwin->isVisible() )
1899 //        qApp->processEvents();
1900
1901 //      vwin->setVisualParameters( (*valuesIt).c_str() );
1902 //       }
1903 //       continue; // skip to next entry
1904 //     }
1905     
1906     // entry is a normal entry - it should be "decoded" (setting base adress of component) 
1907     QString entry( ip->decodeEntry( *entIt ).c_str() );
1908
1909     //SRN: Added a check that the entry corresponds to Standard_Real object in the Study
1910     //     as the object may be deleted or modified after the visual state is saved.
1911     _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
1912     if(!so) continue;  //Skip the not existent entry
1913
1914     for ( ; namesIt != paramNames.end(); ++namesIt, ++valuesIt ) {
1915       std::string viewerType = ::getParam( *namesIt, ViewerType );
1916
1917       std::string paramName = ::getParam( *namesIt, ParamName );
1918       bool ok;
1919       std::string viewIndexStr = ::getParam( *namesIt, ViewIndex );
1920       int viewIndex = QString( viewIndexStr.c_str() ).toUInt( &ok );
1921       if ( !ok ) // bad conversion of view index to integer
1922         continue;
1923
1924       //      cout << " -- " << viewerType << ": entry = " << entry.latin1() << ", paramName = " << paramName << endl;
1925
1926       if ( viewerType == SVTK_Viewer::Type().toLatin1().data() /*||
1927                                                                  viewerType == VVTK_Viewer::Type().toLatin1().data()*/ ) {
1928
1929         // used as inner map key for locating the actor.
1930         QString viewerTypeIndex = QString( viewerType.c_str() ) + QString::number( viewIndex );
1931
1932         if ( paramName == "Visibility" && displayer() ) {
1933           // if VVTK, then we must create viewer first, because
1934
1935           QList<SUIT_ViewManager*> lst;
1936           getApp()->viewManagers( viewerType.c_str(), lst );
1937
1938           // SVTK/VVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
1939           if ( viewIndex >= 0 && viewIndex < lst.count() ) {
1940             SUIT_ViewManager* vman = lst.at( viewIndex );
1941             SUIT_ViewModel* vmodel = vman->getViewModel();
1942             // both SVTK and VVTK view models can be casted to SALOME_View
1943             displayer()->Display( entry, true, dynamic_cast<SALOME_View*>( vmodel ) );
1944
1945             // store displayed actor in a temporary map for quicker access later when restoring other parameters
1946             SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
1947             QMap<QString, VISU_Actor*> viewActorMap;
1948             if ( vtkActors.contains( entry ) )
1949               viewActorMap = vtkActors[ entry ];
1950             viewActorMap[ viewerTypeIndex ] = FindActor( GetAppStudy(this), vtkView, entry );
1951             vtkActors[ entry ] = viewActorMap;
1952           }
1953         }
1954         else { // the rest properties "work" with VISU_Actor, so we initialize it at first
1955           VISU_Actor* vActor = 0;
1956           if ( vtkActors.contains( entry ) ) {
1957             QMap<QString, VISU_Actor*> viewActorMap = vtkActors[ entry ];
1958             if ( viewActorMap.contains( viewerTypeIndex ) )
1959               vActor = viewActorMap[ viewerTypeIndex ];
1960           }
1961           if ( !vActor )
1962             continue;
1963
1964           QString val( (*valuesIt).c_str() );
1965
1966           if ( paramName == "Name" )
1967             vActor->setName( val.toLatin1().data() );
1968
1969           else if ( paramName == "RepresentationMode" )
1970             vActor->SetRepresentation( val.toInt() );
1971
1972           else if (paramName == "Quadratic2DRepresentation")
1973             vActor->SetQuadratic2DRepresentation(VISU_Actor::EQuadratic2DRepresentation(val.toInt()));
1974
1975           else if ( paramName == "Opacity" )
1976             vActor->SetOpacity( val.toFloat() );
1977
1978           else if ( paramName == "Color" ) {
1979             QStringList colors = val.split( gDigitsSep, QString::SkipEmptyParts );
1980             if ( colors.count() == 3 )
1981               vActor->SetColor( colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat() );
1982           }
1983
1984           else if ( paramName == "LineWidth" )
1985             vActor->SetLineWidth( val.toFloat() );
1986
1987           else if ( paramName == "ShrinkMode" ) {
1988             vActor->SetShrinkable( true );
1989             vActor->SetShrink();
1990           }
1991
1992           else if ( paramName == "ShrunkFactor" )
1993             vActor->SetShrinkFactor( val.toFloat() );
1994
1995           else if ( paramName == "Shading" ) {
1996             if ( VISU_ScalarMapAct* scalarMapActor = dynamic_cast<VISU_ScalarMapAct*>( vActor ) )
1997               scalarMapActor->SetShading();
1998           }
1999
2000           else if ( paramName.find( "ClippingPlane" ) != std::string::npos ) {
2001             VISU::Prs3d_i* prs = vActor->GetPrs3d();
2002             if ( !prs )
2003               continue;
2004
2005             //prs->RemoveAllClippingPlanes();
2006             for (int i = prs->GetNumberOfClippingPlanes() - 1; i >= 0 ; i--) {
2007               OrientedPlane* aPlane = dynamic_cast<OrientedPlane*>(prs->GetClippingPlane(i));
2008               if (aPlane) 
2009                 prs->RemoveClippingPlane(i);
2010             }
2011             if ( val != "Off" ) {
2012               QStringList vals = val.split( gDigitsSep, QString::SkipEmptyParts );
2013               if ( vals.count() == 6 ) { // format check: 6 float values
2014                 vtkFloatingPointType normal[3], origin[3];
2015                 for (int x = 0; x < 3; x++ ) {
2016                   normal[x] = vals[x].toFloat();
2017                   origin[x] = vals[x+3].toFloat();
2018                 }
2019                 OrientedPlane* plane = OrientedPlane::New();
2020                 plane->SetNormal( normal );
2021                 plane->SetOrigin( origin );
2022                 prs->AddClippingPlane( plane );
2023                 plane->Delete();
2024               }
2025             }
2026           }
2027         } // else ..
2028       } // if SVTK
2029
2030       else if ( viewerType == SPlot2d_Viewer::Type().toLatin1().data() ) {
2031
2032         if ( paramName == "Visibility" && displayer() ) {
2033           QList<SUIT_ViewManager*> lst;
2034           getApp()->viewManagers( viewerType.c_str(), lst );
2035
2036           if ( viewIndex >= 0 && viewIndex < lst.count() ) {
2037             SUIT_ViewManager* vman = lst.at( viewIndex );
2038             SUIT_ViewModel* vmodel = vman->getViewModel();
2039             // SVTK and VVTK view models can be casted to SALOME_View
2040             displayer()->Display( entry, true, dynamic_cast<SALOME_View*>( vmodel ) );
2041           }
2042         }
2043
2044       } // if SPlot2d
2045
2046     } // for names/parameters iterator
2047   } // for entries iterator
2048
2049   // [ update all SVTK/VVTK/Plot2D views
2050   QList<SUIT_ViewManager*> lst;
2051   getApp()->viewManagers( lst );
2052   for ( QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++ ) {
2053     SUIT_ViewModel* vmodel = (*it)->getViewModel();
2054     if ( !vmodel )
2055       continue;
2056     if ( vmodel->getType() == SVTK_Viewer::Type() /*||  // processing SVTK and VVTK viewers
2057                                                     vmodel->getType() == VVTK_Viewer::Type()*/ ) { // in the same way 
2058       SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
2059       vtkView->getRenderer()->ResetCameraClippingRange();
2060       vtkView->Repaint();
2061     }
2062     else if ( vmodel->getType() == SPlot2d_Viewer::Type().toLatin1().data() ) {
2063       Plot2d_ViewWindow* plotView = (Plot2d_ViewWindow*) (*it)->getActiveView();
2064       plotView->getViewFrame()->Repaint();
2065     }
2066   } // ] end of update views
2067
2068   // VISU module opens one SVTK viewer in activateModule().  This causes a bug in save-restore visual
2069   // parameters: it no SVTK view was saved, we need NOT any SVTK on restore.  Here we close one
2070   // default SVTK if needed.
2071   /*
2072   QString openedSvtkViewerStr = ip->getProperty( "VtkViewersCount" ).c_str();
2073   int openedSvtkViewer = openedSvtkViewerStr.toInt( &ok );
2074   if ( ok && openedSvtkViewer == 0 ) {
2075     lst.clear();
2076     getApp()->viewManagers( SVTK_Viewer::Type(), lst );
2077     if ( lst.count() )
2078       lst.at( 0 )->closeAllViews();
2079   }
2080   */
2081
2082   // if active Gauss Viewer is set ( != -1) then raise the gauss view window.
2083 //   bool ok;
2084 //   QString activeGaussViewerStr = ip->getProperty( "ActiveGaussViewer" ).c_str();
2085 //   int activeGaussViewer = activeGaussViewerStr.toInt( &ok );
2086 //   if ( ok && activeGaussViewer != -1 ) {
2087 //     lst.clear();
2088 //     getApp()->viewManagers( VVTK_Viewer::Type(), lst );
2089 //     if ( activeGaussViewer >= 0 && activeGaussViewer < lst.count() ) {
2090 //       SUIT_ViewWindow* activeView = lst.at( activeGaussViewer )->getActiveView();
2091 //       if ( activeView ) {
2092 //      activeView->activateWindow();
2093 //      //activeView->setFocus();
2094 //       }          
2095 //     }
2096 //   }
2097 }
2098