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