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