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