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