Salome HOME
Merge from OCC_development_generic_2006
[modules/visu.git] / src / VISUGUI / VisuGUI_Module.cxx
1
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
47 #include "VVTK_ViewManager.h"
48 #include "VVTK_ViewWindow.h"
49 #include "VVTK_ViewModel.h"
50
51 #include "SVTK_ViewModel.h"
52 #include "SVTK_ViewManager.h"
53 #include "SVTK_MainWindow.h"
54 #include "SVTK_RenderWindowInteractor.h"
55 #include "VISU_Event.h"
56
57 #include "VisuGUI_Prs3dTools.h"
58
59 #include "VISU_GaussPoints_i.hh"
60 #include "VISU_GaussPtsAct.h"
61 #include "VisuGUI_GaussPointsDlg.h"
62
63 #include "VISU_Gen_i.hh"
64 #include "VISU_Result_i.hh"
65 #include "VISU_CutLines_i.hh"
66
67 #include "VISU_Actor.h"
68 #include "VisuGUI_Tools.h"
69 #include "VisuGUI_ActionsDef.h"
70
71 #include "VISU_WidgetCtrl.hxx"
72 #include "VISU_PlanesWidget.hxx"
73 #include "VISU_SphereWidget.hxx"
74
75 #include "SalomeApp_Study.h"
76 #include "VVTK_MainWindow.h"
77 #include "VISU_View_i.hh"
78
79 #include <qaction.h>
80
81 #include <vtkRenderer.h>
82 #include <vtkCamera.h>
83 #include <vtkTimerLog.h>
84
85 #include <sstream>
86
87 #ifdef _DEBUG_
88 static int MYDEBUG = 0;
89 #else
90 static int MYDEBUG = 0;
91 #endif
92
93 #define GAUSS_NEW_VIEWER         5100
94 #define GAUSS_CREATE_PRS         5200
95 #define GAUSS_RENAME             5210
96 #define GAUSS_EDIT_PRS           5300
97 #define GAUSS_COPY_PRS           5310
98 #define GAUSS_ERASE_PRS          5400
99 #define GAUSS_DISPLAY_PRS        5500
100 #define GAUSS_DISPLAY_ONLY_PRS   5600
101
102 #define GAUSS_SAVE_CONFIGURATION       5700
103 #define GAUSS_OVERWRITE_CONFIGURATION  5701
104 #define GAUSS_RESTORE_CONFIGURATION    5702
105 #define GAUSS_RENAME_CONFIGURATION     5703
106
107 void
108 CreateCurves( SalomeApp_Module* theModule,
109               VISU::CutLines_i* thePrs,
110               QDialog* theDlg,
111               const bool theCreate = true );
112
113 using namespace VISU;
114
115 namespace VISU
116 {
117   //---------------------------------------------------------------
118   class Viewer
119   {
120     VVTK_ViewManager* myViewManager;
121     LightApp_VTKSelector* mySelector;
122   public:
123
124     Viewer(VisuGUI_Module* theModule, TViewerMap& theViewerMap)
125     {
126       SalomeApp_Application* anApp = theModule->getApp();
127       myViewManager = new VVTK_ViewManager( anApp->activeStudy(), anApp->desktop() );
128       VVTK_Viewer* aViewer = (VVTK_Viewer*)myViewManager->getViewModel();
129       mySelector = new LightApp_VTKSelector( aViewer, anApp->selectionMgr() );
130       anApp->addViewManager( myViewManager );
131
132       theViewerMap.insert(TViewerMap::value_type(myViewManager,PViewer(this)));
133       QObject::connect( myViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
134                         theModule, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
135       
136       //aViewer->setBackgroundColor( Qt::darkGreen );
137       myViewManager->createViewWindow();
138     }
139     
140     VVTK_ViewManager* getViewManager() 
141     {
142       return myViewManager;
143     }
144
145     virtual
146     ~Viewer()
147     {
148     }
149   };
150
151
152   //---------------------------------------------------------------
153   typedef void (SUIT_ViewWindow::* TViewVisibility)();
154   void
155   SetViewVisibility(const TViewerMap& theViewerMap, 
156                     TViewVisibility theViewVisibility)
157   {
158     TViewerMap::const_iterator anIter = theViewerMap.begin();
159     for(; anIter != theViewerMap.end(); anIter++){
160       if(SUIT_ViewManager* aViewManager = anIter->first){
161         QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
162         int aSize = aViews.size();
163         for(int anId = 0; anId < aSize; anId++){
164           if(SUIT_ViewWindow* aView = aViews[anId]){
165             (aView->* theViewVisibility)();
166           }
167         }
168       }
169     }
170   }
171
172 }
173
174 //---------------------------------------------------------------
175 VisuGUI_Module
176 ::VisuGUI_Module() : 
177   VisuGUI()
178 {
179 }
180
181
182 //---------------------------------------------------------------
183 VisuGUI_Module
184 ::~VisuGUI_Module()
185 {
186 }
187
188
189 //---------------------------------------------------------------
190 void
191 VisuGUI_Module
192 ::initialize( CAM_Application* theApp )
193 {
194   VisuGUI::initialize( theApp );
195
196   SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
197
198   QPixmap aPixmap;
199   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GAUSS_NEW_VIEWER"));
200   createAction( GAUSS_NEW_VIEWER, 
201                 tr("MEN_GAUSS_NEW_VIEWER"), 
202                 aPixmap,
203                 tr("MEN_GAUSS_NEW_VIEWER"), 
204                 tr("MEN_GAUSS_NEW_VIEWER"),
205                 ALT+Key_S, 
206                 this, 
207                 false,
208                 this, 
209                 SLOT(onCreateViewManager()));
210   int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 );
211   int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
212   createMenu( action( GAUSS_NEW_VIEWER ), newWinMenu, -1 );
213   
214   // Add actions to menus
215   createMenu( tr( "MEN_GAUSS" ), -1, -1, 30 );
216   //createMenu( GAUSS_CREATE_PRS, aMenuId, 10 );
217
218   QString aViewerType = VVTK_Viewer::Type();
219   SUIT_Accel* accel = getApp()->accel();
220   accel->setActionKey( SUIT_Accel::PanLeft, Key_Left, aViewerType );
221   accel->setActionKey( SUIT_Accel::PanRight, Key_Right, aViewerType );
222   accel->setActionKey( SUIT_Accel::PanUp, Key_Up, aViewerType );
223   accel->setActionKey( SUIT_Accel::PanDown, Key_Down, aViewerType );
224   accel->setActionKey( SUIT_Accel::ZoomIn, Key_PageUp, aViewerType );
225   accel->setActionKey( SUIT_Accel::ZoomOut, Key_PageDown, aViewerType );
226   accel->setActionKey( SUIT_Accel::RotateLeft, CTRL+Key_Left, aViewerType );
227   accel->setActionKey( SUIT_Accel::RotateRight, CTRL+Key_Right, aViewerType );
228   accel->setActionKey( SUIT_Accel::RotateUp, CTRL+Key_Up, aViewerType );
229   accel->setActionKey( SUIT_Accel::RotateDown, CTRL+Key_Down, aViewerType );
230   accel->setActionKey( SVTK::PlusSpeedIncrementEvent, Key_Plus, aViewerType );
231   accel->setActionKey( SVTK::MinusSpeedIncrementEvent, Key_Minus, aViewerType );
232
233   connect( getApp(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ), this, SLOT( OnViewManagerAdded (SUIT_ViewManager*) ) );
234
235   // Prepare popup menus
236   QtxPopupMgr* mgr = popupMgr();
237   QString aRule;
238
239   aPixmap = aResourceMgr->loadPixmap( "VISU", tr( "ICON_GAUSS_POINTS" ) );
240   createAction( GAUSS_CREATE_PRS, tr("MEN_GAUSS_CREATE_PRS"), aPixmap,
241                 tr("MEN_GAUSS_CREATE_PRS"), "", 0, this, false,
242                 this, SLOT(OnCreateGaussPoints()));
243   mgr->insert( action( GAUSS_CREATE_PRS ), -1, 0, -1 );
244   mgr->setRule( action( GAUSS_CREATE_PRS ), 
245                 "client='ObjectBrowser' and selcount=1 "
246                 "and type='VISU::TTIMESTAMP' "
247                 "and $medEntity in {'EDGE_ENTITY' 'FACE_ENTITY' 'CELL_ENTITY'} "
248                 "and $medSource in {'eImportFile' 'eCopyAndImportFile'} ",
249                 true );
250
251   createMenu( action( GAUSS_CREATE_PRS ), createMenu( tr( "MEN_VISUALISATION" ), -1 ), -1 );
252   createTool( GAUSS_CREATE_PRS, createTool( tr( "TOOL_VISUALISATION" ) ), -1 );
253
254   createAction( GAUSS_RENAME, VisuGUI::tr("MEN_RENAME"), QIconSet(),
255                 VisuGUI::tr("MEN_RENAME"), "", 0, this, false,
256                 this, SLOT(OnRename()));
257   mgr->insert( action( GAUSS_RENAME ), -1, 0, -1 );
258   mgr->setRule( action( GAUSS_RENAME ), 
259                 "selcount=1 and type='VISU::TGAUSSPOINTS'", 
260                 true );
261
262   createAction( GAUSS_EDIT_PRS, VisuGUI::tr("MEN_EDIT_PRS"), QIconSet(),
263                 VisuGUI::tr("MEN_EDIT_PRS"), "", 0, this, false,
264                 this, SLOT(OnEditGaussPoints()));
265   mgr->insert( action( GAUSS_EDIT_PRS ), -1, 0, -1 );
266   mgr->setRule( action( GAUSS_EDIT_PRS ), 
267                 "selcount=1 and type='VISU::TGAUSSPOINTS'", 
268                 true );
269
270   createAction( GAUSS_COPY_PRS, VisuGUI::tr("MEN_COPY_PRS"), QIconSet(),
271                 VisuGUI::tr("MEN_COPY_PRS"), "", 0, this, false,
272                 this, SLOT(OnCopyPresentation()));
273   mgr->insert( action( GAUSS_COPY_PRS ), -1, 0, -1 );
274   mgr->setRule( action( GAUSS_COPY_PRS ), 
275                 "selcount=1 and type='VISU::TGAUSSPOINTS'", 
276                 true );
277   action( GAUSS_COPY_PRS )->setEnabled(false);
278
279   aRule = "(selcount>0 and type='VISU::TGAUSSPOINTS')";
280
281   createAction( GAUSS_ERASE_PRS, VisuGUI::tr("MEN_ERASE"), QIconSet(),
282                 VisuGUI::tr("MEN_ERASE"), "", 0, this, false,
283                 this, SLOT(OnErasePrs()));
284   mgr->insert( action( GAUSS_ERASE_PRS ), -1, -1, -1 ); // erase
285   mgr->setRule( action( GAUSS_ERASE_PRS ), 
286                 aRule + " and (isVisible=true)", true );
287
288   createAction( GAUSS_DISPLAY_PRS, VisuGUI::tr("MEN_DISPLAY"), QIconSet(),
289                 VisuGUI::tr("MEN_DISPLAY"), "", 0, this, false,
290                 this, SLOT(OnDisplayPrs()));
291   mgr->insert( action( GAUSS_DISPLAY_PRS ), -1, -1, -1 ); // display
292   mgr->setRule( action( GAUSS_DISPLAY_PRS ), 
293                 aRule + " and (isVisible=false)", true );
294
295   createAction( GAUSS_DISPLAY_ONLY_PRS, VisuGUI::tr("MEN_DISPLAY_ONLY"), QIconSet(),
296                 VisuGUI::tr("MEN_DISPLAY_ONLY"), "", 0, this, false,
297                 this, SLOT(OnDisplayOnlyPrs()));
298   mgr->insert( action( GAUSS_DISPLAY_ONLY_PRS ), -1, -1, -1 ); // display only
299   mgr->setRule( action( GAUSS_DISPLAY_ONLY_PRS ), 
300                 aRule, true );
301
302   createAction( GAUSS_RENAME_CONFIGURATION, VisuGUI::tr("MEN_RENAME"), QIconSet(), 
303                 VisuGUI::tr("MEN_RENAME"), "", 0, this, false,
304                 this, SLOT(OnRename()));
305   mgr->insert( action( GAUSS_RENAME_CONFIGURATION ), -1, -1, -1 );
306   mgr->setRule( action( GAUSS_RENAME_CONFIGURATION ), "selcount=1 and type='VISU::TGAUSSVIEW'", true );
307
308   createAction( GAUSS_SAVE_CONFIGURATION, tr("MEN_SAVE_CONFIGURATION"), QIconSet(),
309                 tr("MEN_SAVE_CONFIGURATION"), "", 0, this, false,
310                 this, SLOT(OnSaveConfiguration()));
311   mgr->insert( action( GAUSS_SAVE_CONFIGURATION ), -1, -1, -1 );
312   mgr->setRule( action( GAUSS_SAVE_CONFIGURATION ), "selcount>=0 and client='VVTK' and activeView='VVTK'", true );
313
314   createAction( GAUSS_OVERWRITE_CONFIGURATION, tr("MEN_OVERWRITE_CONFIGURATION"), QIconSet(),
315                 tr("MEN_OVERWRITE_CONFIGURATION"), "", 0, this, false,
316                 this, SLOT(OnOverwriteConfiguration()));
317   mgr->insert( action( GAUSS_OVERWRITE_CONFIGURATION ), -1, -1, -1 );
318   mgr->setRule( action( GAUSS_OVERWRITE_CONFIGURATION ),
319                 "selcount>0 and type='VISU::TGAUSSVIEW' and activeView='VVTK'", true );
320
321   createAction( GAUSS_RESTORE_CONFIGURATION, tr("MEN_RESTORE_CONFIGURATION"), QIconSet(),
322                 tr("MEN_RESTORE_CONFIGURATION"), "", 0, this, false,
323                 this, SLOT(OnRestoreConfiguration()));
324   mgr->insert( action( GAUSS_RESTORE_CONFIGURATION ), -1, -1, -1 );
325   mgr->setRule( action( GAUSS_RESTORE_CONFIGURATION ),
326                 "selcount=1 and type='VISU::TGAUSSVIEW'", true );
327 }
328
329 //---------------------------------------------------------------
330 bool
331 VisuGUI_Module
332 ::activateModule( SUIT_Study* theStudy )
333 {
334   VisuGUI::activateModule( theStudy );
335
336   SetViewVisibility(myViewerMap,&SUIT_ViewWindow::show);
337
338   return true;
339 }
340
341
342 //---------------------------------------------------------------
343 bool
344 VisuGUI_Module
345 ::deactivateModule( SUIT_Study* theStudy )
346 {
347   VisuGUI::deactivateModule( theStudy );
348
349   SetViewVisibility(myViewerMap,&SUIT_ViewWindow::hide);
350
351   return true;
352 }
353
354
355 //---------------------------------------------------------------
356 SUIT_ViewManager*
357 VisuGUI_Module
358 ::onCreateViewManager()
359 {
360   Viewer* aViewer = new Viewer( this, myViewerMap );
361   return aViewer->getViewManager();
362 }
363
364
365 //---------------------------------------------------------------
366 void
367 VisuGUI_Module
368 ::onLastViewClosed(SUIT_ViewManager* theViewManager)
369 {
370   myViewerMap.erase(theViewManager);
371 }
372
373
374 //---------------------------------------------------------------
375 void 
376 VisuGUI_Module
377 ::createPreferences()
378 {
379   VisuGUI::createPreferences();
380
381   createGaussPointsPreferences();
382   createInsideCursorPreferences();
383   createOutsideCursorPreferences();
384   createPickingPreferences();
385   createSpaceMousePreferences();
386   createRecorderPreferences();
387 }
388
389
390 //---------------------------------------------------------------
391 void 
392 VisuGUI_Module
393 ::createGaussPointsPreferences()
394 {
395   int gaussTab = addPreference( tr( "VISU_GAUSS_PREF_TAB_TTL" ) );
396   int primitiveGr = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_GROUP_TTL" ), gaussTab );
397   setPreferenceProperty( primitiveGr, "columns", 1 );
398
399   int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr,
400                                          LightApp_Preferences::Selector, "VISU", "point_sprite_primitive_type" );
401
402   QStringList values;
403   values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) );
404   values.append( tr( "VISU_GAUSS_PREF_OPENGLPOINT" ) );
405   values.append( tr( "VISU_GAUSS_PREF_GEOMSPHERE" ) );
406   QValueList<QVariant> indices;
407   indices.append( 0 );
408   indices.append( 1 );
409   indices.append( 2 );
410   setPreferenceProperty( primitiveTypePref, "strings", values );
411   setPreferenceProperty( primitiveTypePref, "indexes", indices );
412
413   int clampPref = addPreference( tr( "VISU_GAUSS_PREF_CLAMP" ), primitiveGr,
414                                  LightApp_Preferences::IntSpin, "VISU", "point_sprite_clamp" );
415   setPreferenceProperty( clampPref, "min", 1 );
416   setPreferenceProperty( clampPref, "max", 512 );
417
418   addPreference( tr( "VISU_GAUSS_PREF_MAIN_TEXTURE" ), primitiveGr,
419                  LightApp_Preferences::File, "VISU", "point_sprite_main_texture" );
420
421   addPreference( tr( "VISU_GAUSS_PREF_ALPHA_TEXTURE" ), primitiveGr,
422                  LightApp_Preferences::File, "VISU", "point_sprite_alpha_texture" );
423
424   int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr,
425                                           LightApp_Preferences::DblSpin, "VISU", "point_sprite_alpha_threshold" );
426   setPreferenceProperty( alphaThresholdPref, "min", 0.0 );
427   setPreferenceProperty( alphaThresholdPref, "max", 1.0 );
428   setPreferenceProperty( alphaThresholdPref, "step", 0.1 );
429
430   int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr,
431                                       LightApp_Preferences::IntSpin, "VISU", "geom_sphere_resolution" );
432   setPreferenceProperty( resolutionPref, "min", 3 );
433   setPreferenceProperty( resolutionPref, "max", 100 );
434
435   int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr,
436                                      LightApp_Preferences::IntSpin, "VISU", "geom_sphere_face_limit" );
437   setPreferenceProperty( faceLimitPref, "min", 10 );
438   setPreferenceProperty( faceLimitPref, "max", 1000000 );
439
440   int sizeGr = addPreference( tr( "VISU_GAUSS_PREF_SIZE_GROUP_TTL" ), gaussTab );
441   setPreferenceProperty( sizeGr, "columns", 2 );
442
443   int minSizePref = addPreference( tr( "VISU_GAUSS_PREF_MIN_SIZE" ), sizeGr,
444                                    LightApp_Preferences::IntSpin, "VISU", "point_sprite_min_size" );
445   setPreferenceProperty( minSizePref, "min", 1 );
446   setPreferenceProperty( minSizePref, "max", 100 );
447
448   int maxSizePref = addPreference( tr( "VISU_GAUSS_PREF_MAX_SIZE" ), sizeGr,
449                                    LightApp_Preferences::IntSpin, "VISU", "point_sprite_max_size" );
450   setPreferenceProperty( maxSizePref, "min", 1 );
451   setPreferenceProperty( maxSizePref, "max", 100 );
452
453   int magnificationPref = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION" ), sizeGr,
454                                          LightApp_Preferences::IntSpin, "VISU", "point_sprite_magnification" );
455   setPreferenceProperty( magnificationPref, "min", 10 );
456   setPreferenceProperty( magnificationPref, "max", 1000 );
457
458   int incrementPref = addPreference( tr( "VISU_GAUSS_PREF_INCREMENT" ), sizeGr,
459                                      LightApp_Preferences::DblSpin, "VISU", "point_sprite_increment" );
460   setPreferenceProperty( incrementPref, "min", 0.01 );
461   setPreferenceProperty( incrementPref, "max", 10 );
462   setPreferenceProperty( incrementPref, "step", 0.1 );
463
464   int geomGr = addPreference( tr( "VISU_GAUSS_PREF_GEOM_GROUP_TTL" ), gaussTab );
465   setPreferenceProperty( geomGr, "columns", 1 );
466
467   int sizePref = addPreference( tr( "VISU_GAUSS_PREF_SIZE" ), geomGr,
468                                 LightApp_Preferences::IntSpin, "VISU", "point_sprite_size" );
469   setPreferenceProperty( sizePref, "min", 1 );
470   setPreferenceProperty( sizePref, "max", 100 );
471
472   addPreference( tr( "VISU_GAUSS_PREF_COLOR" ), geomGr,
473                  LightApp_Preferences::Color, "VISU", "point_sprite_color" );
474
475   // ScalarBar Preferences
476   int scalarBarGr = addPreference( tr( "VISU_GAUSS_SCALAR_BAR_PREF_GROUP_TTL" ), gaussTab );
477   setPreferenceProperty( scalarBarGr, "columns", 1 );
478
479   int activeBarPref = addPreference( tr( "VISU_GAUSS_PREF_ACTIVE_BAR" ), scalarBarGr,
480                                      LightApp_Preferences::Selector, "VISU", "scalar_bar_active_local" );
481
482   values.clear();
483   values.append( tr( "VISU_GAUSS_PREF_LOCAL" ) );
484   values.append( tr( "VISU_GAUSS_PREF_GLOBAL" ) );
485   indices.clear();
486   indices.append( 0 );
487   indices.append( 1 );
488   setPreferenceProperty( activeBarPref, "strings", values );
489   setPreferenceProperty( activeBarPref, "indexes", indices );
490
491   addPreference( tr( "VISU_GAUSS_PREF_DISPLAY_GLOBAL" ), scalarBarGr,
492                  LightApp_Preferences::Bool, "VISU", "scalar_bar_display_global" );
493
494   int colorPref = addPreference( tr( "VISU_GAUSS_PREF_SCALAR_BAR_MODE" ), scalarBarGr,
495                                  LightApp_Preferences::Selector, "VISU", "scalar_bar_bicolor" );
496
497   values.clear();
498   values.append( tr( "VISU_GAUSS_PREF_BICOLOR" ) );
499   values.append( tr( "VISU_GAUSS_PREF_RAINBOW" ) );
500   indices.clear();
501   indices.append( 0 );
502   indices.append( 1 );
503   setPreferenceProperty( colorPref, "strings", values );
504   setPreferenceProperty( colorPref, "indexes", indices );
505
506   int spacingPref = addPreference( tr( "VISU_GAUSS_PREF_SPACING" ), scalarBarGr,
507                                      LightApp_Preferences::DblSpin, "VISU", "scalar_bar_spacing" );
508   setPreferenceProperty( spacingPref, "min", 0.01 );
509   setPreferenceProperty( spacingPref, "max", 1.0 );
510   setPreferenceProperty( spacingPref, "step", 0.01 );
511 }
512
513
514 //---------------------------------------------------------------
515 void 
516 VisuGUI_Module
517 ::createInsideCursorPreferences()
518 {
519   int insideCursorTab = addPreference( tr( "VISU_GAUSS_INSIDE_CURSOR_PREF_TAB_TTL" ) );
520
521   int primitiveGr = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_GROUP_TTL" ), insideCursorTab );
522   setPreferenceProperty( primitiveGr, "columns", 1 );
523
524   int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr,
525                                 LightApp_Preferences::Selector, "VISU", "inside_point_sprite_primitive_type" );
526
527   QStringList values;
528   values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) );
529   values.append( tr( "VISU_GAUSS_PREF_OPENGLPOINT" ) );
530   values.append( tr( "VISU_GAUSS_PREF_GEOMSPHERE" ) );
531   QValueList<QVariant> indices;
532   indices.append( 0 );
533   indices.append( 1 );
534   indices.append( 2 );
535   setPreferenceProperty( primitiveTypePref, "strings", values );
536   setPreferenceProperty( primitiveTypePref, "indexes", indices );
537
538   int clampPref = addPreference( tr( "VISU_GAUSS_PREF_CLAMP" ), primitiveGr,
539                                  LightApp_Preferences::IntSpin, "VISU", "inside_point_sprite_clamp" );
540   setPreferenceProperty( clampPref, "min", 1 );
541   setPreferenceProperty( clampPref, "max", 512 );
542
543   addPreference( tr( "VISU_GAUSS_PREF_MAIN_TEXTURE" ), primitiveGr,
544                  LightApp_Preferences::File, "VISU", "inside_point_sprite_main_texture" );
545
546   addPreference( tr( "VISU_GAUSS_PREF_ALPHA_TEXTURE" ), primitiveGr,
547                  LightApp_Preferences::File, "VISU", "inside_point_sprite_alpha_texture" );
548
549   int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr,
550                                           LightApp_Preferences::DblSpin, "VISU", "inside_point_sprite_alpha_threshold" );  
551   setPreferenceProperty( alphaThresholdPref, "min", 0.0 );
552   setPreferenceProperty( alphaThresholdPref, "max", 1.0 );
553   setPreferenceProperty( alphaThresholdPref, "step", 0.1 );
554
555   int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr,
556                                       LightApp_Preferences::IntSpin, "VISU", "inside_geom_sphere_resolution" );
557   setPreferenceProperty( resolutionPref, "min", 3 );
558   setPreferenceProperty( resolutionPref, "max", 100 );
559
560   int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr,
561                                      LightApp_Preferences::IntSpin, "VISU", "inside_geom_sphere_face_limit" );
562   setPreferenceProperty( faceLimitPref, "min", 10 );
563   setPreferenceProperty( faceLimitPref, "max", 1000000 );
564
565   int sizeGr = addPreference( tr( "VISU_GAUSS_PREF_SIZE_GROUP_TTL" ), insideCursorTab );
566   setPreferenceProperty( sizeGr, "columns", 2 );
567
568   int minSizePref = addPreference( tr( "VISU_GAUSS_PREF_MIN_SIZE" ), sizeGr,
569                                    LightApp_Preferences::IntSpin, "VISU", "inside_point_sprite_min_size" );
570   setPreferenceProperty( minSizePref, "min", 1 );
571   setPreferenceProperty( minSizePref, "max", 100 );
572
573   int maxSizePref = addPreference( tr( "VISU_GAUSS_PREF_MAX_SIZE" ), sizeGr,
574                                    LightApp_Preferences::IntSpin, "VISU", "inside_point_sprite_max_size" );
575   setPreferenceProperty( maxSizePref, "min", 1 );
576   setPreferenceProperty( maxSizePref, "max", 100 );
577
578   int magnificationGr = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION_GROUP_TTL" ), insideCursorTab );
579   setPreferenceProperty( magnificationGr, "columns", 2 );
580
581   int magnificationPref = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION" ), magnificationGr,
582                                          LightApp_Preferences::IntSpin, "VISU", "inside_point_sprite_magnification" );
583   setPreferenceProperty( magnificationPref, "min", 10 );
584   setPreferenceProperty( magnificationPref, "max", 1000 );
585
586   int incrementPref = addPreference( tr( "VISU_GAUSS_PREF_INCREMENT" ), magnificationGr,
587                                      LightApp_Preferences::DblSpin, "VISU", "inside_point_sprite_increment" );
588   setPreferenceProperty( incrementPref, "min", 0.01 );
589   setPreferenceProperty( incrementPref, "max", 10 );
590   setPreferenceProperty( incrementPref, "step", 0.1 );
591
592 }
593
594
595 //---------------------------------------------------------------
596 void 
597 VisuGUI_Module
598 ::createOutsideCursorPreferences()
599 {
600   int outsideCursorTab = addPreference( tr( "VISU_GAUSS_OUTSIDE_CURSOR_PREF_TAB_TTL" ) );
601
602   int primitiveGr = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_GROUP_TTL" ), outsideCursorTab );
603   setPreferenceProperty( primitiveGr, "columns", 1 );
604
605   int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr,
606                                 LightApp_Preferences::Selector, "VISU", "outside_point_sprite_primitive_type" );
607
608   QStringList values;
609   values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) );
610   values.append( tr( "VISU_GAUSS_PREF_OPENGLPOINT" ) );
611   values.append( tr( "VISU_GAUSS_PREF_GEOMSPHERE" ) );
612   QValueList<QVariant> indices;
613   indices.append( 0 );
614   indices.append( 1 );
615   indices.append( 2 );
616   setPreferenceProperty( primitiveTypePref, "strings", values );
617   setPreferenceProperty( primitiveTypePref, "indexes", indices );
618
619   int clampPref = addPreference( tr( "VISU_GAUSS_PREF_CLAMP" ), primitiveGr,
620                                  LightApp_Preferences::IntSpin, "VISU", "outside_point_sprite_clamp" );
621   setPreferenceProperty( clampPref, "min", 1 );
622   setPreferenceProperty( clampPref, "max", 512 );
623
624   addPreference( tr( "VISU_GAUSS_PREF_MAIN_TEXTURE" ), primitiveGr,
625                  LightApp_Preferences::File, "VISU", "outside_point_sprite_main_texture" );
626
627   addPreference( tr( "VISU_GAUSS_PREF_ALPHA_TEXTURE" ), primitiveGr,
628                  LightApp_Preferences::File, "VISU", "outside_point_sprite_alpha_texture" );
629
630   int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr,
631                                           LightApp_Preferences::DblSpin, "VISU", "outside_point_sprite_alpha_threshold" );  
632   setPreferenceProperty( alphaThresholdPref, "min", 0.0 );
633   setPreferenceProperty( alphaThresholdPref, "max", 1.0 );
634   setPreferenceProperty( alphaThresholdPref, "step", 0.1 );
635
636   int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr,
637                                       LightApp_Preferences::IntSpin, "VISU", "outside_geom_sphere_resolution" );
638   setPreferenceProperty( resolutionPref, "min", 3 );
639   setPreferenceProperty( resolutionPref, "max", 100 );
640
641   int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr,
642                                      LightApp_Preferences::IntSpin, "VISU", "outside_geom_sphere_face_limit" );
643   setPreferenceProperty( faceLimitPref, "min", 10 );
644   setPreferenceProperty( faceLimitPref, "max", 1000000 );
645
646   int sizeGr = addPreference( tr( "VISU_GAUSS_PREF_SIZE_GROUP_TTL" ), outsideCursorTab );
647
648   int sizePref = addPreference( tr( "VISU_GAUSS_PREF_SIZE" ), sizeGr,
649                                 LightApp_Preferences::IntSpin, "VISU", "outside_point_sprite_size" );
650   setPreferenceProperty( sizePref, "min", 1 );
651   setPreferenceProperty( sizePref, "max", 100 );
652
653   int colorGr = addPreference( tr( "VISU_GAUSS_PREF_COLOR_GROUP_TTL" ), outsideCursorTab );
654   setPreferenceProperty( colorGr, "columns", 1 );
655
656   addPreference( tr( "VISU_GAUSS_PREF_UNIFORM_COLOR" ), colorGr,
657                  LightApp_Preferences::Bool, "VISU", "outside_point_sprite_uniform" );
658
659   addPreference( tr( "VISU_GAUSS_PREF_COLOR" ), colorGr,
660                  LightApp_Preferences::Color, "VISU", "outside_point_sprite_color" );
661 }
662
663
664 //---------------------------------------------------------------
665 void 
666 VisuGUI_Module
667 ::createPickingPreferences()
668 {
669   int pickingTab = addPreference( tr( "VISU_PICKING_PREF_TAB_TTL" ) );
670
671   // Cursor
672   int cursorGr = addPreference( tr( "VISU_PICKING_PREF_CURSOR_GROUP_TTL" ), pickingTab );
673   setPreferenceProperty( cursorGr, "columns", 1 );
674
675   int cursorSizePref = addPreference( tr( "VISU_PICKING_PREF_CURSOR_SIZE" ), cursorGr,
676                                          LightApp_Preferences::DblSpin, "VISU", "picking_cursor_size" );
677   setPreferenceProperty( cursorSizePref, "min", 0 );
678   setPreferenceProperty( cursorSizePref, "max", 1.0 );
679   setPreferenceProperty( cursorSizePref, "step", 0.1 );
680
681   int pyramidHeightPref = addPreference( tr( "VISU_PICKING_PREF_PYRAMID_HEIGHT" ), cursorGr,
682                                          LightApp_Preferences::DblSpin, "VISU", "picking_pyramid_height" );
683   setPreferenceProperty( pyramidHeightPref, "min", 1 );
684   setPreferenceProperty( pyramidHeightPref, "max", 100 );
685
686   int selectionColorPref = addPreference( tr( "VISU_PICKING_PREF_SELECTION_COLOR" ), cursorGr,
687                                           LightApp_Preferences::Color, "VISU", "picking_selection_color" );
688
689   // Tolerance
690   int toleranceGr = addPreference( tr( "VISU_PICKING_PREF_TOLERANCE_GROUP_TTL" ), pickingTab );
691
692   int pointTolerancePref = addPreference( tr( "VISU_PICKING_PREF_POINT_SELECTION_TOLERANCE" ), toleranceGr,
693                                          LightApp_Preferences::DblSpin, "VISU", "picking_point_tolerance" );
694   setPreferenceProperty( pointTolerancePref, "min", 0.001 );
695   setPreferenceProperty( pointTolerancePref, "max", 10 );
696   setPreferenceProperty( pointTolerancePref, "step", 0.01 );
697
698   // Info window
699   int infoWindowGr = addPreference( tr( "VISU_PICKING_PREF_INFO_WINDOW_GROUP_TTL" ), pickingTab );
700   setPreferenceProperty( infoWindowGr, "columns", 1 );
701
702   int transparencyPref = addPreference( tr( "VISU_PICKING_PREF_TRANSPARENCY" ), infoWindowGr,
703                                         LightApp_Preferences::IntSpin, "VISU", "picking_transparency" );
704   setPreferenceProperty( transparencyPref, "min", 0 );
705   setPreferenceProperty( transparencyPref, "max", 100 );
706   setPreferenceProperty( transparencyPref, "step", 10 );
707
708   int positionPref = addPreference( tr( "VISU_PICKING_PREF_POSITION" ), infoWindowGr,
709                                     LightApp_Preferences::Selector, "VISU", "picking_position" );
710   QStringList values;
711   values.append( tr( "VISU_PICKING_PREF_BELOW_POINT" ) );
712   values.append( tr( "VISU_PICKING_PREF_TOP_LEFT_CORNER" ) );
713   QValueList<QVariant> indices;
714   indices.append( 0 );
715   indices.append( 1 );
716   setPreferenceProperty( positionPref, "strings", values );
717   setPreferenceProperty( positionPref, "indexes", indices );
718
719   // Camera
720   int cameraGr = addPreference( tr( "VISU_PICKING_PREF_CAMERA_GROUP_TTL" ), pickingTab );
721   setPreferenceProperty( cameraGr, "columns", 1 );
722
723   int zoomFactorPref = addPreference( tr( "VISU_PICKING_PREF_ZOOM_FACTOR" ), cameraGr,
724                                       LightApp_Preferences::DblSpin, "VISU", "picking_zoom_factor" );
725   setPreferenceProperty( zoomFactorPref, "min", 0.1 );
726   setPreferenceProperty( zoomFactorPref, "max", 10.0 );
727   setPreferenceProperty( zoomFactorPref, "step", 0.1 );
728
729   int stepNumberPref = addPreference( tr( "VISU_PICKING_PREF_STEP_NUMBER" ), cameraGr,
730                                       LightApp_Preferences::IntSpin, "VISU", "picking_step_number" );
731   setPreferenceProperty( stepNumberPref, "min", 1 );
732   setPreferenceProperty( stepNumberPref, "max", 100 );
733
734   // Display parent mesh
735   int parentMeshGr = addPreference( tr( "VISU_PICKING_PREF_PARENT_MESH_TTL" ), pickingTab );
736   setPreferenceProperty( parentMeshGr, "columns", 1 );
737
738   addPreference( tr( "VISU_PICKING_PREF_DISPLAY_PARENT_MESH" ), parentMeshGr,
739                  LightApp_Preferences::Bool, "VISU", "picking_display_parent_mesh" );
740 }
741
742
743 //---------------------------------------------------------------
744 void 
745 VisuGUI_Module
746 ::createSpaceMousePreferences()
747 {
748   int mouseTab = addPreference( tr( "VISU_MOUSE_PREF_TAB_TLT" ) );
749
750   int mouseGr = addPreference( tr( "VISU_MOUSE_PREF_GROUP_TLT" ), mouseTab );
751   int mousePref = addPreference( tr( "VISU_MOUSE_PREF" ), mouseGr, LightApp_Preferences::Selector, "VISU", "mouse_behaviour" );
752   QStringList values;
753   values.append( tr( "VISU_MOUSE_PREF_STANDARD" ) );
754   values.append( tr( "VISU_MOUSE_PREF_KEYBOARD_FREE" ) );
755   QValueList<QVariant> indices;
756   indices.append( 0 );
757   indices.append( 1 );
758   setPreferenceProperty( mousePref, "strings", values );
759   setPreferenceProperty( mousePref, "indexes", indices );
760
761   int keybrdGr = addPreference( tr( "VISU_KEYBOARD_PREF_GROUP_TTL" ), mouseTab );
762   int keybrdPref = addPreference( tr( "VISU_KEYBOARD_PREF" ), keybrdGr, LightApp_Preferences::IntSpin, "VISU", "speed_increment" );
763   setPreferenceProperty( keybrdPref,  "max",  1000  );
764
765   int spacemouseGr = addPreference( tr( "VISU_SPACEMOUSE_PREF" ), mouseTab );
766   setPreferenceProperty( spacemouseGr, "columns", 1 );
767   int spacemousePref1 = addPreference( tr( "VISU_SPACEMOUSE_PREF_1" ), spacemouseGr, LightApp_Preferences::Selector, "VISU", "spacemouse_func1_btn" ); //decrease_speed_increment
768   int spacemousePref2 = addPreference( tr( "VISU_SPACEMOUSE_PREF_2" ), spacemouseGr, LightApp_Preferences::Selector, "VISU", "spacemouse_func2_btn" ); //increase_speed_increment
769   int spacemousePref3 = addPreference( tr( "VISU_SPACEMOUSE_PREF_3" ), spacemouseGr, LightApp_Preferences::Selector, "VISU", "spacemouse_func3_btn" ); //decrease_gauss_point_magnification
770   int spacemousePref4 = addPreference( tr( "VISU_SPACEMOUSE_PREF_4" ), spacemouseGr, LightApp_Preferences::Selector, "VISU", "spacemouse_func4_btn" ); //increase_gauss_point_magnification
771   int spacemousePref5 = addPreference( tr( "VISU_SPACEMOUSE_PREF_5" ), spacemouseGr, LightApp_Preferences::Selector, "VISU", "spacemouse_func5_btn" ); //dominant_combined_switch
772   values.clear();
773   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_1" ) );
774   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_2" ) );
775   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_3" ) );
776   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_4" ) );
777   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_5" ) );
778   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_6" ) );
779   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_7" ) );
780   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_8" ) );
781   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_*" ) );
782   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_10" ) );
783   values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_11" ) );
784   indices.clear();
785   indices.append( 1 );
786   indices.append( 2 );
787   indices.append( 3 );
788   indices.append( 4 );
789   indices.append( 5 );
790   indices.append( 6 );
791   indices.append( 7 );
792   indices.append( 8 );
793   indices.append( 9 ); // == button_*
794   indices.append( 10 );
795   indices.append( 11 );
796   setPreferenceProperty( spacemousePref1, "strings", values );
797   setPreferenceProperty( spacemousePref1, "indexes", indices );
798   setPreferenceProperty( spacemousePref2, "strings", values );
799   setPreferenceProperty( spacemousePref2, "indexes", indices );
800   setPreferenceProperty( spacemousePref3, "strings", values );
801   setPreferenceProperty( spacemousePref3, "indexes", indices );
802   setPreferenceProperty( spacemousePref4, "strings", values );
803   setPreferenceProperty( spacemousePref4, "indexes", indices );
804   setPreferenceProperty( spacemousePref5, "strings", values );
805   setPreferenceProperty( spacemousePref5, "indexes", indices );
806 }
807
808
809 //---------------------------------------------------------------
810 void 
811 VisuGUI_Module
812 ::createRecorderPreferences()
813 {
814   int recorderTab = addPreference( tr( "VISU_RECORDER_PREF_TAB_TTL" ) );
815
816   int recorderGr = addPreference( tr( "VISU_RECORDER_PREF_GROUP_TTL" ), recorderTab );
817   setPreferenceProperty( recorderGr, "columns", 1 );
818
819   int modePref = addPreference( tr( "VISU_RECORDER_PREF_RECORDING_MODE" ), recorderGr,
820                                 LightApp_Preferences::Selector, "VISU", "recorder_mode" );
821   QStringList values;
822   values.append( tr( "VISU_RECORDER_PREF_SKIPPED_FRAMES" ) );
823   values.append( tr( "VISU_RECORDER_PREF_ALL_DISLPAYED_FRAMES" ) );
824   QValueList<QVariant> indices;
825   indices.append( 0 );
826   indices.append( 1 );
827   setPreferenceProperty( modePref, "strings", values );
828   setPreferenceProperty( modePref, "indexes", indices );
829
830   int fpsPref = addPreference( tr( "VISU_RECORDER_PREF_FPS" ), recorderGr,
831                                LightApp_Preferences::DblSpin, "VISU", "recorder_fps" );
832   setPreferenceProperty( fpsPref, "min", 0.1 );
833   setPreferenceProperty( fpsPref, "max", 100 );
834
835   int qualityPref = addPreference( tr( "VISU_RECORDER_PREF_QUALITY" ), recorderGr,
836                                    LightApp_Preferences::IntSpin, "VISU", "recorder_quality" );
837   setPreferenceProperty( qualityPref, "min", 1 );
838   setPreferenceProperty( qualityPref, "max", 100 );
839
840   addPreference( tr( "VISU_RECORDER_PREF_PROGRESSIVE" ), recorderGr,
841                  LightApp_Preferences::Bool, "VISU", "recorder_progressive" );
842 }
843
844
845 //---------------------------------------------------------------
846 void
847 VisuGUI_Module
848 ::OnCreateGaussPoints()
849 {
850   double initialTime = vtkTimerLog::GetCPUTime();
851   CreatePrs3d<VISU::GaussPoints_i,VVTK_Viewer,VisuGUI_GaussPointsDlg,1>(this,true);
852   INFOS( "VisuGUI_Module::OnCreateGaussPoints() : Gauss Points created in " <<
853          vtkTimerLog::GetCPUTime() - initialTime << " seconds" );
854 }
855
856 void
857 VisuGUI_Module
858 ::OnViewManagerAdded(SUIT_ViewManager* viewMgr)
859 {
860   QString type = viewMgr->getViewModel()->getType();
861   if ( type == VVTK_Viewer::Type() ) 
862     connect( viewMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), this, SLOT( OnViewCreated( SUIT_ViewWindow* ) ) );
863 }
864
865 void
866 VisuGUI_Module
867 ::OnViewCreated(SUIT_ViewWindow* view)
868 {
869   SVTK_ViewWindow* viewWindow = dynamic_cast<SVTK_ViewWindow*>( view );
870   if ( viewWindow ) {
871     setProperty( viewWindow, "speed_increment" );
872     setProperty( viewWindow, "spacemouse_func1_btn" );
873     setProperty( viewWindow, "spacemouse_func2_btn" );
874     setProperty( viewWindow, "spacemouse_func3_btn" );
875     setProperty( viewWindow, "spacemouse_func4_btn" );
876     setProperty( viewWindow, "spacemouse_func5_btn" );
877   }
878 }
879
880 void
881 VisuGUI_Module
882 ::setProperty( SVTK_ViewWindow* viewWindow, const QString& pref )
883 {
884   if ( !viewWindow )
885     return;
886
887   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
888   SVTK_MainWindow* aMainWindow = viewWindow->getMainWindow();
889   int val;
890   if ( pref == "speed_increment" ) {
891     val = resMgr->integerValue( "VISU", pref, 10 );
892     aMainWindow->InvokeEvent( SVTK::SetSpeedIncrementEvent, &val );
893   }
894   else if ( pref == "spacemouse_func1_btn" ) {
895     val = resMgr->integerValue( "VISU", pref, 1 );
896     aMainWindow->InvokeEvent( SVTK::SetSMDecreaseSpeedEvent, &val );
897   }
898   else if ( pref == "spacemouse_func2_btn" ) {
899     val = resMgr->integerValue( "VISU", pref, 2 );
900     aMainWindow->InvokeEvent( SVTK::SetSMIncreaseSpeedEvent, &val );
901   }
902   else if ( pref == "spacemouse_func3_btn" ) {
903     val = resMgr->integerValue( "VISU", pref, 10 );
904     aMainWindow->InvokeEvent( VISU::SetSMDecreaseMagnificationEvent, &val );
905   }
906   else if ( pref == "spacemouse_func4_btn" ) {
907     val = resMgr->integerValue( "VISU", pref, 11 );
908     aMainWindow->InvokeEvent( VISU::SetSMIncreaseMagnificationEvent, &val );
909   }
910   else if ( pref == "spacemouse_func5_btn" ) {
911     val = resMgr->integerValue( "VISU", pref, 9 );
912     aMainWindow->InvokeEvent( SVTK::SetSMDominantCombinedSwitchEvent, &val );
913   }
914 }
915
916 void
917 VisuGUI_Module
918 ::setProperty( SVTK_ViewManager* vm, const QString& prop )
919 {
920   if ( !vm )
921     return;
922
923   QPtrVector<SUIT_ViewWindow> windows = vm->getViews();
924   for ( int n = windows.count(), i = 0; i < n; i++ )
925     setProperty( dynamic_cast<SVTK_ViewWindow*>( windows[i] ), prop );
926 }
927
928 void
929 VisuGUI_Module
930 ::preferencesChanged( const QString& group, const QString& pref )
931 {
932   VisuGUI::preferencesChanged(group,pref);
933
934   if ( group == "VISU" && ( pref == "speed_increment" || pref == "spacemouse_func1_btn" ||
935                             pref == "spacemouse_func2_btn" || pref == "spacemouse_func3_btn" || 
936                             pref == "spacemouse_func4_btn" || pref == "spacemouse_func5_btn" ) ) {
937
938     // update properties of VVTK view windows
939     SUIT_ViewManager* vm = getApp()->getViewManager( VVTK_Viewer::Type(), false );
940     if ( vm ) 
941       setProperty( dynamic_cast<SVTK_ViewManager*>( vm ), pref );
942   }
943 }
944
945
946 //---------------------------------------------------------------
947 SUIT_ViewManager*
948 VisuGUI_Module
949 ::getViewManager(const QString& theType, 
950                  const bool theIsCreate)
951 {
952   if(SUIT_ViewManager* aViewManager = VisuGUI::getViewManager(theType,theIsCreate))
953     return aViewManager;
954
955   if(theIsCreate && VVTK_Viewer::Type() == theType)
956     return onCreateViewManager();
957
958   return NULL;
959 }
960
961 //---------------------------------------------------------------
962 void
963 VisuGUI_Module
964 ::OnEditGaussPoints()
965 {
966   Handle(SALOME_InteractiveObject) anIO;
967   if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
968     EditPrs3d<VISU::GaussPoints_i,VisuGUI_GaussPointsDlg,1>(this, aPrs3d);
969     if(SVTK_ViewWindow* aViewWindow = GetViewWindow<VVTK_Viewer>(this,true)){
970       aViewWindow->highlight(anIO,1);
971     }
972   }
973 }
974
975
976 //---------------------------------------------------------------
977 void
978 VisuGUI_Module
979 ::OnDisplayPrs()
980 {
981   if(MYDEBUG) MESSAGE("VisuGUI_Module::OnDisplayPrs");
982
983   QApplication::setOverrideCursor(Qt::waitCursor);
984
985   if(LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this)){
986     SALOME_ListIO aSel, aList;
987     aSelectionMgr->selectedObjects(aSel);
988     extractContainers(aSel, aList);
989
990     for(SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next()){
991       Handle(SALOME_InteractiveObject) anIO = it.Value();
992       CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
993
994       // is it a Prs3d object ?
995       if(!CORBA::is_nil(anObject)){
996         if(VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in())){
997           if(MYDEBUG) MESSAGE("VisuGUI_Module::OnDisplayPrs : Prs3d object");
998           if(aPrs3d->GetType() == VISU::TGAUSSPOINTS)
999             VISU::UpdateViewer<VVTK_Viewer>(this,aPrs3d,false,true,true);
1000           else if(SUIT_ViewManager* aViewManager = getApp()->activeViewManager()){
1001             QString aType = aViewManager->getType();
1002             if(aType == SVTK_Viewer::Type())
1003               VISU::UpdateViewer<SVTK_Viewer>(this,aPrs3d,false,true,true);
1004             else if(aType == VVTK_Viewer::Type())
1005               VISU::UpdateViewer<VVTK_Viewer>(this,aPrs3d,false,true,true);
1006           }
1007           continue;
1008         }
1009       }
1010
1011       // is it Curve ?
1012       if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in())){
1013         if(MYDEBUG) MESSAGE("VisuGUI_Module::OnDisplayPrs : Curve object");
1014         PlotCurve( this, aCurve, VISU::eDisplay );
1015         continue;
1016       }
1017
1018       // is it Container ?
1019       if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in())){
1020         if(MYDEBUG) MESSAGE("VisuGUI_Module::DisplayPrs : Container object");
1021         PlotContainer( this, aContainer, VISU::eDisplay );
1022         continue;
1023       }
1024
1025       // is it Table ?
1026       if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in())){
1027         if(MYDEBUG) MESSAGE("VisuGUI_Module::DisplayPrs : Table object");
1028         PlotTable( this, aTable, VISU::eDisplay );
1029         continue;
1030       }
1031     }
1032   }
1033
1034   QApplication::restoreOverrideCursor();
1035 }
1036
1037
1038 //---------------------------------------------------------------
1039 void
1040 VisuGUI_Module
1041 ::OnEraseAll()
1042 {
1043   if(SUIT_ViewManager* aViewManager = getApp()->activeViewManager()){
1044     QString aType = aViewManager->getType();
1045     if(aType == SVTK_Viewer::Type())
1046       VISU::OnEraseAll<SVTK_Viewer>(this);
1047     else if(aType == VVTK_Viewer::Type())
1048       VISU::OnEraseAll<VVTK_Viewer>(this);
1049     else if(aType == SPlot2d_Viewer::Type())
1050       VISU::OnEraseAll<SPlot2d_Viewer>(this);
1051   }
1052 }
1053
1054
1055 //---------------------------------------------------------------
1056 void
1057 VisuGUI_Module
1058 ::OnDisplayOnlyPrs()
1059 {
1060   OnEraseAll();
1061   OnDisplayPrs();
1062 }
1063
1064
1065 //---------------------------------------------------------------
1066 void
1067 VisuGUI_Module
1068 ::OnErasePrs()
1069 {
1070   QApplication::setOverrideCursor(Qt::waitCursor);
1071
1072   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1073   SALOME_ListIO aSel, aList;
1074   aSelectionMgr->selectedObjects(aSel);
1075   extractContainers(aSel, aList);
1076
1077   for(SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next()){
1078     Handle(SALOME_InteractiveObject) anIO = it.Value();
1079     CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this),anIO->getEntry());
1080     if(!CORBA::is_nil(anObject)){
1081       VISU::Base_var aBase = VISU::Base::_narrow(anObject);
1082       if(!CORBA::is_nil(aBase)) 
1083         VISU::ErasePrs(this,aBase,true);
1084     }
1085   }
1086
1087   QApplication::restoreOverrideCursor();
1088 }
1089
1090
1091 //---------------------------------------------------------------
1092 namespace
1093 {
1094   void
1095   GetViewParams(VVTK_MainWindow* theViewWindow,
1096                 const char* theSuffix,
1097                 std::ostringstream& theStr)
1098   {
1099     float aColor[3];
1100     vtkRenderer* aRenderer = theViewWindow->getRenderer();
1101     aRenderer->GetBackground(aColor);
1102     Storable::DataToStream(theStr,std::string("myColor") + theSuffix + ".R",aColor[0]);
1103     Storable::DataToStream(theStr,std::string("myColor") + theSuffix + ".G",aColor[1]);
1104     Storable::DataToStream(theStr,std::string("myColor") + theSuffix + ".B",aColor[2]);
1105       
1106     double aPosition[3];
1107     vtkCamera* aCamera = aRenderer->GetActiveCamera();
1108     aCamera->GetPosition(aPosition);
1109     Storable::DataToStream(theStr,std::string("myPosition") + theSuffix + "[0]",aPosition[0]);
1110     Storable::DataToStream(theStr,std::string("myPosition") + theSuffix + "[1]",aPosition[1]);
1111     Storable::DataToStream(theStr,std::string("myPosition") + theSuffix + "[2]",aPosition[2]);
1112
1113     double aFocalPnt[3];
1114     aCamera->GetFocalPoint(aFocalPnt);
1115     Storable::DataToStream(theStr,std::string("myFocalPnt") + theSuffix + "[0]",aFocalPnt[0]);
1116     Storable::DataToStream(theStr,std::string("myFocalPnt") + theSuffix + "[1]",aFocalPnt[1]);
1117     Storable::DataToStream(theStr,std::string("myFocalPnt") + theSuffix + "[2]",aFocalPnt[2]);
1118       
1119     double aViewUp[3];
1120     aCamera->GetViewUp(aViewUp);
1121     Storable::DataToStream(theStr,std::string("myViewUp") + theSuffix + "[0]",aViewUp[0]);
1122     Storable::DataToStream(theStr,std::string("myViewUp") + theSuffix + "[1]",aViewUp[1]);
1123     Storable::DataToStream(theStr,std::string("myViewUp") + theSuffix + "[2]",aViewUp[2]);
1124       
1125     float aParallelScale = aCamera->GetParallelScale();
1126     Storable::DataToStream(theStr,std::string("myParallelScale") + theSuffix,aParallelScale);
1127       
1128     double aScaleFactor[3];
1129     theViewWindow->GetScale(aScaleFactor);
1130     Storable::DataToStream(theStr,std::string("myScaleFactor") + theSuffix + "[0]",aScaleFactor[0]);
1131     Storable::DataToStream(theStr,std::string("myScaleFactor") + theSuffix + "[1]",aScaleFactor[1]);
1132     Storable::DataToStream(theStr,std::string("myScaleFactor") + theSuffix + "[2]",aScaleFactor[2]);
1133   }
1134
1135   //---------------------------------------------------------------
1136   void
1137   SetViewParams(VVTK_MainWindow* theViewWindow,
1138                 const char* theSuffix,
1139                 const Storable::TRestoringMap& theMap)
1140   {
1141     float aColor[3];
1142     aColor[0] = Storable::FindValue(theMap,std::string("myColor") + theSuffix + ".R").toDouble();
1143     aColor[1] = Storable::FindValue(theMap,std::string("myColor") + theSuffix + ".G").toDouble();
1144     aColor[2] = Storable::FindValue(theMap,std::string("myColor") + theSuffix + ".B").toDouble();
1145     vtkRenderer* aRenderer = theViewWindow->getRenderer();
1146     aRenderer->SetBackground(aColor);
1147       
1148     double aPosition[3];
1149     aPosition[0] = Storable::FindValue(theMap,std::string("myPosition") + theSuffix + "[0]").toDouble();
1150     aPosition[1] = Storable::FindValue(theMap,std::string("myPosition") + theSuffix + "[1]").toDouble();
1151     aPosition[2] = Storable::FindValue(theMap,std::string("myPosition") + theSuffix + "[2]").toDouble();
1152     vtkCamera* aCamera = aRenderer->GetActiveCamera();
1153     aCamera->SetPosition(aPosition);
1154
1155     double aFocalPnt[3];
1156     aFocalPnt[0] = Storable::FindValue(theMap,std::string("myFocalPnt") + theSuffix + "[0]").toDouble();
1157     aFocalPnt[1] = Storable::FindValue(theMap,std::string("myFocalPnt") + theSuffix + "[1]").toDouble();
1158     aFocalPnt[2] = Storable::FindValue(theMap,std::string("myFocalPnt") + theSuffix + "[2]").toDouble();
1159     aCamera->SetFocalPoint(aFocalPnt);
1160       
1161     double aViewUp[3];
1162     aViewUp[0] = Storable::FindValue(theMap,std::string("myViewUp") + theSuffix + "[0]").toDouble();
1163     aViewUp[1] = Storable::FindValue(theMap,std::string("myViewUp") + theSuffix + "[1]").toDouble();
1164     aViewUp[2] = Storable::FindValue(theMap,std::string("myViewUp") + theSuffix + "[2]").toDouble();
1165     aCamera->SetViewUp(aViewUp);
1166
1167     float aParallelScale = Storable::FindValue(theMap,std::string("myParallelScale") + theSuffix).toDouble();
1168     aCamera->SetParallelScale(aParallelScale);
1169       
1170     double aScaleFactor[3];
1171     aScaleFactor[0] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[0]").toDouble();
1172     aScaleFactor[1] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[1]").toDouble();
1173     aScaleFactor[2] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[2]").toDouble();
1174     theViewWindow->SetScale(aScaleFactor);
1175   }
1176
1177   //---------------------------------------------------------------
1178   void
1179   GetViewParams(VVTK_MainWindow1* theViewWindow,
1180                 std::ostringstream& theStr)
1181   {
1182     GetViewParams(theViewWindow,"1",theStr);
1183
1184     VISU_WidgetCtrl* aWidgetCtrl = theViewWindow->GetWidgetCtrl();
1185     if(aWidgetCtrl->GetEnabled()){
1186       std::string aSegmentationMode;
1187       if(aWidgetCtrl->IsPlanesActive()){
1188         VISU_PlanesWidget *aPlanesWidget = aWidgetCtrl->GetPlanesWidget();
1189         float anOrigin[3];
1190         aPlanesWidget->GetOrigin(anOrigin);
1191         Storable::DataToStream(theStr,"myCursorOrigin[0]",anOrigin[0]);
1192         Storable::DataToStream(theStr,"myCursorOrigin[1]",anOrigin[1]);
1193         Storable::DataToStream(theStr,"myCursorOrigin[2]",anOrigin[2]);
1194         
1195         float aNormal[3];
1196         aPlanesWidget->GetNormal(aNormal);
1197         Storable::DataToStream(theStr,"myCursorNormal[0]",aNormal[0]);
1198         Storable::DataToStream(theStr,"myCursorNormal[1]",aNormal[1]);
1199         Storable::DataToStream(theStr,"myCursorNormal[2]",aNormal[2]);
1200         
1201         float aDepth = aPlanesWidget->Distance();
1202         Storable::DataToStream(theStr,"myCursorDepth",aDepth);
1203         
1204         aSegmentationMode = "Planes";
1205       }else if(aWidgetCtrl->IsSphereActive()){
1206         VISU_SphereWidget *aSphereWidget = aWidgetCtrl->GetSphereWidget();
1207         float aCenter[3];
1208         aSphereWidget->GetCenter(aCenter);
1209         Storable::DataToStream(theStr,"mySphereCursorCenter[0]",aCenter[0]);
1210         Storable::DataToStream(theStr,"mySphereCursorCenter[1]",aCenter[1]);
1211         Storable::DataToStream(theStr,"mySphereCursorCenter[2]",aCenter[2]);
1212         
1213         float aRadius = aSphereWidget->GetRadius();
1214         Storable::DataToStream(theStr,"mySphereCursorRaduis",aRadius);
1215         
1216         aSegmentationMode = "Sphere";
1217       }
1218       
1219       Storable::DataToStream(theStr,"mySegmentationMode",aSegmentationMode);
1220     }
1221   }
1222
1223   //---------------------------------------------------------------
1224   void
1225   SetViewParams(VVTK_MainWindow1* theViewWindow,
1226                 const Storable::TRestoringMap& theMap)
1227   {
1228     SetViewParams(theViewWindow,"1",theMap);
1229   }
1230
1231
1232   //---------------------------------------------------------------
1233   void
1234   GetViewParams(VVTK_MainWindow2* theViewWindow,
1235                 std::ostringstream& theStr)
1236   {
1237     GetViewParams(theViewWindow,"2",theStr);
1238   }
1239
1240   void
1241   SetViewParams(VVTK_MainWindow2* theViewWindow,
1242                 const Storable::TRestoringMap& theMap)
1243   {
1244     SetViewParams(theViewWindow,"2",theMap);
1245   }
1246
1247
1248   //---------------------------------------------------------------
1249   std::string
1250   GetViewParams(VVTK_ViewWindow* theViewWindow)
1251   {
1252     std::ostringstream aStream;
1253
1254     Storable::DataToStream(aStream,"myComment","GAUSSVIEW");
1255     
1256     SVTK_Selector* aSelector = theViewWindow->GetSelector();
1257     Selection_Mode aSelectionMode = aSelector->SelectionMode();
1258     Storable::DataToStream(aStream,"mySelectionMode",aSelectionMode);
1259     
1260     GetViewParams(theViewWindow->getMainWindow1(),aStream);
1261     GetViewParams(theViewWindow->getMainWindow2(),aStream);
1262
1263     return aStream.str();
1264   }
1265
1266   //---------------------------------------------------------------
1267   struct TSelection
1268   {
1269     bool myIsSelected;
1270     bool myHasSubId;
1271     int mySubId;
1272     
1273     TSelection():
1274       myIsSelected(false),
1275       myHasSubId(false),
1276       mySubId(-1)
1277     {}
1278   };
1279
1280   typedef std::map<std::string,TSelection> TVisibleEntries;
1281
1282   struct TGetVisibleEntries
1283   {
1284     TVisibleEntries& myVisibleEntries;
1285
1286     TGetVisibleEntries(TVisibleEntries& theVisibleEntries):
1287       myVisibleEntries(theVisibleEntries)
1288     {}
1289
1290     void
1291     operator()(VISU_GaussPtsAct* theActor) 
1292     {
1293       if(theActor->GetVisibility()){
1294         const Handle(SALOME_InteractiveObject)& anIO = theActor->getIO();
1295         myVisibleEntries.insert(TVisibleEntries::value_type(anIO->getEntry(),TSelection()));
1296       }
1297     }
1298   };
1299
1300   void
1301   GetGaussPointsSelection(VVTK_ViewWindow* theViewWindow,
1302                           TVisibleEntries& theVisibleEntries)
1303   {
1304     // First find all visible Gauss Points presentations
1305     vtkRenderer* aRenderer = theViewWindow->getRenderer();
1306     vtkActorCollection* anActors = aRenderer->GetActors();
1307     TGetVisibleEntries aGetVisibleEntries(theVisibleEntries);
1308     SVTK::ForEach<VISU_GaussPtsAct>(anActors,
1309                                     aGetVisibleEntries);
1310     
1311     // Next, find the sub-ids for the visible Gauss Points presentations
1312     SVTK_Selector* aSelector = theViewWindow->GetSelector();
1313     const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
1314     SALOME_ListIteratorOfListIO anIter(aListIO);
1315     for(; anIter.More(); anIter.Next()){
1316       Handle(SALOME_InteractiveObject) anIO = anIter.Value();
1317       std::string anEntry = anIO->getEntry();
1318       TVisibleEntries::iterator anEntriesIter = theVisibleEntries.find(anEntry);
1319       if(anEntriesIter != theVisibleEntries.end()){
1320         TSelection& aSelection = anEntriesIter->second;
1321         aSelection.myIsSelected = true;
1322         TColStd_IndexedMapOfInteger anIndexes;
1323         aSelector->GetIndex(anIO,anIndexes);
1324         if(anIndexes.Extent() > 0){
1325           aSelection.myHasSubId = true;
1326           aSelection.mySubId = anIndexes(1);
1327         }
1328       }
1329     }
1330   }
1331
1332
1333   //---------------------------------------------------------------
1334   inline
1335   void
1336   CreateReference(_PTR(Study) theStudyDocument,
1337                   _PTR(StudyBuilder) theStudyBuilder,
1338                   _PTR(SObject) theFatherSObject, 
1339                   const string& theRefEntry,
1340                   const TSelection& theSelection)
1341   {
1342     _PTR(SObject) aNewObj = theStudyBuilder->NewObject(theFatherSObject);
1343     _PTR(SObject) aRefSObj = theStudyDocument->FindObjectID(theRefEntry);
1344     theStudyBuilder->Addreference(aNewObj,aRefSObj);
1345
1346     std::ostringstream aStream;
1347     Storable::DataToStream(aStream,"myIsSelected",theSelection.myIsSelected);
1348     Storable::DataToStream(aStream,"myHasSubId",theSelection.myHasSubId);
1349     Storable::DataToStream(aStream,"mySubId",theSelection.mySubId);
1350
1351     _PTR(GenericAttribute) anAttr;
1352     anAttr = theStudyBuilder->FindOrCreateAttribute(aNewObj,"AttributeComment");
1353     _PTR(AttributeComment) aComment(anAttr);
1354     aComment->SetValue(aStream.str());
1355   }
1356
1357
1358   //---------------------------------------------------------------
1359   void
1360   SetGaussPointsSelection(VisuGUI* theModule,
1361                           VVTK_ViewWindow* theViewWindow,
1362                           _PTR(Study) theCStudy,
1363                           _PTR(SObject) theSObject)
1364   {
1365     SVTK_Selector* aSelector = theViewWindow->GetSelector();
1366     aSelector->ClearIObjects();
1367
1368     bool anIsFirst = true;
1369     _PTR(ChildIterator) aChildIter = theCStudy->NewChildIterator(theSObject);
1370     for (; aChildIter->More(); aChildIter->Next()) {
1371       _PTR(SObject) aChildSObject = aChildIter->Value();
1372       _PTR(SObject) aSObject;
1373       if(aChildSObject->ReferencedObject(aSObject)){
1374         CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
1375         PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1376         if(VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in())){
1377           // To set visiblity
1378           VISU::UpdateViewer<VVTK_Viewer>(theModule,aPrs3d,anIsFirst,false,false);
1379           anIsFirst = false;
1380           
1381           // To update selection
1382           _PTR(GenericAttribute) anAttr;
1383           if(aChildSObject->FindAttribute(anAttr,"AttributeComment")){
1384             _PTR(AttributeComment) aComment(anAttr);
1385             
1386             QString aStream(aComment->Value().c_str());
1387             Storable::TRestoringMap aMap;
1388             Storable::StrToMap(aStream,aMap);
1389             
1390             bool anIsSelected = Storable::FindValue(aMap,"myIsSelected").toInt();
1391             bool aHasSubId = Storable::FindValue(aMap,"myHasSubId").toInt();
1392             int aSubId = Storable::FindValue(aMap,"mySubId").toInt();
1393             
1394             if(anIsSelected){
1395               std::string anEntry = aSObject->GetID();
1396               Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(anEntry.c_str(),"");
1397               aSelector->AddIObject(anIO);
1398               if(aHasSubId)
1399                 aSelector->AddOrRemoveIndex(anIO,aSubId,false);
1400             }
1401           }
1402         }
1403       }
1404     }
1405
1406     aSelector->EndPickCallback(); // To invoke selection changed signal
1407   }
1408
1409
1410   //---------------------------------------------------------------
1411   void
1412   OnStoreConfiguration(SalomeApp_Module* theModule,
1413                        bool theIsNew)
1414   {
1415     _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1416     if (CheckLock(aCStudy,GetDesktop(theModule)))
1417       return;
1418     
1419     LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
1420     
1421     SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager();
1422     if(aViewManager->getType() == VVTK_Viewer::Type()){
1423       SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
1424       VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
1425       
1426       SUIT_Study* aSStudy = aViewManager->study();
1427       SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy);
1428       _PTR(Study) aCStudy = aStudy->studyDS();
1429       _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1430
1431       std::string anEntry;
1432       std::string aValue = GetViewParams(aViewWindow);
1433
1434       if(theIsNew){
1435         _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1436         
1437         static int myNbConfigs = 0;
1438         std::string aName = VISU::GenerateName("Config.", ++myNbConfigs).latin1();
1439       
1440         std::string aSComponentEntry = aSComponent->GetID();
1441         anEntry = CreateAttributes(aCStudy, 
1442                                    aSComponentEntry.c_str(), 
1443                                    "", 
1444                                    "", 
1445                                    aName.c_str(),
1446                                    "",
1447                                    aValue.c_str());
1448       }else{
1449         SALOME_ListIO aListIO;
1450         aSelectionMgr->selectedObjects(aListIO);
1451         SALOME_ListIteratorOfListIO aListIter( aListIO );
1452         for(; aListIter.More(); aListIter.Next()){
1453           Handle(SALOME_InteractiveObject) anIO = aListIter.Value();
1454           _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1455           _PTR(GenericAttribute) anAttr;
1456           if(aSObject->FindAttribute(anAttr,"AttributeComment")){
1457             _PTR(AttributeComment) aComment(anAttr);
1458             std::string aCommentValue(aComment->Value());
1459             if(aCommentValue.compare("myComment=GAUSSVIEW") >= 0){
1460               aComment->SetValue(aValue.c_str());
1461               anEntry = aSObject->GetID();
1462               
1463               _PTR(ChildIterator) aChildIter = aCStudy->NewChildIterator(aSObject);
1464               for (; aChildIter->More(); aChildIter->Next()) {
1465                 _PTR(SObject) aChildSObject = aChildIter->Value();
1466                 aStudyBuilder->RemoveObject(aChildSObject);
1467               }
1468               break;
1469             }
1470           }
1471         }
1472       }
1473
1474       if(anEntry != ""){
1475         TVisibleEntries aVisibleEntries;
1476         GetGaussPointsSelection(aViewWindow,
1477                                 aVisibleEntries);
1478         
1479         _PTR(SObject) aSObject = aCStudy->FindObjectID(anEntry);
1480         _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1481         TVisibleEntries::const_iterator anIter =  aVisibleEntries.begin();
1482         for(; anIter != aVisibleEntries.end(); anIter++){
1483           const std::string& anEntry = anIter->first;
1484           const TSelection& aSelection = anIter->second;
1485           
1486           CreateReference(aCStudy,
1487                           aStudyBuilder,
1488                           aSObject, 
1489                           anEntry,
1490                           aSelection);
1491         }
1492       
1493         //UpdateObjBrowser(theModule,true,aSObject);
1494         UpdateObjBrowser(theModule,true);
1495       }
1496     }
1497   }
1498
1499
1500   //---------------------------------------------------------------
1501   template<class TMainWindow>
1502   void
1503   SetMainWindowParams(VisuGUI* theModule,
1504                       _PTR(SObject) theSObject,
1505                       VVTK_ViewWindow* theViewWindow,
1506                       TMainWindow* theMainWindow)
1507   {
1508     _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1509
1510     _PTR(GenericAttribute) anAttr;
1511     if(theSObject->FindAttribute(anAttr,"AttributeComment")){
1512       _PTR(AttributeComment) aComment(anAttr);
1513       QString aStream(aComment->Value().c_str());
1514       Storable::TRestoringMap aMap;
1515       Storable::StrToMap(aStream,aMap);
1516       SetViewParams(theMainWindow,aMap);
1517     }
1518   }
1519 }
1520
1521
1522 //---------------------------------------------------------------
1523 void
1524 VisuGUI_Module::
1525 OnSaveConfiguration()
1526 {
1527   ::OnStoreConfiguration(this,true);
1528 }
1529
1530
1531 //---------------------------------------------------------------
1532 void
1533 VisuGUI_Module::
1534 OnOverwriteConfiguration()
1535 {
1536   ::OnStoreConfiguration(this,false);
1537 }
1538
1539
1540 //---------------------------------------------------------------
1541 void
1542 VisuGUI_Module::
1543 OnRestoreConfiguration()
1544 {
1545   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1546
1547   SALOME_ListIO aListIO;
1548   aSelectionMgr->selectedObjects(aListIO);
1549   if(aListIO.Extent() > 1)
1550     return;
1551
1552   if(SUIT_ViewManager* aViewManager = getViewManager(VVTK_Viewer::Type(),true)){
1553     const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1554     _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1555     _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1556     myConfigSObject = aSObject;
1557     _PTR(GenericAttribute) anAttr;
1558     if(aSObject->FindAttribute(anAttr,"AttributeComment")){
1559       _PTR(AttributeComment) aComment(anAttr);
1560       QString aStream(aComment->Value().c_str());
1561       Storable::TRestoringMap aMap;
1562       Storable::StrToMap(aStream,aMap);
1563       SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
1564       VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
1565       
1566       Selection_Mode aSelectionMode = Storable::FindValue(aMap,"mySelectionMode").toInt();
1567       SVTK_Selector* aSelector = aViewWindow->GetSelector();
1568       aSelector->SetSelectionMode(aSelectionMode);
1569       
1570       SetGaussPointsSelection(this,aViewWindow,aCStudy,aSObject);
1571
1572       std::string aSegmentationMode;
1573       if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
1574         aMainWindow->SetPlanesSegementation(false);
1575         aMainWindow->SetSphereSegementation(false);
1576         VISU_WidgetCtrl* aWidgetCtrl = aMainWindow->GetWidgetCtrl();
1577         aSegmentationMode = Storable::FindValue(aMap,"mySegmentationMode").latin1();
1578         
1579         if(aSegmentationMode == "Planes"){
1580           VISU_PlanesWidget *aPlanesWidget = aWidgetCtrl->GetPlanesWidget();
1581           float anOrigin[3];
1582           anOrigin[0] = Storable::FindValue(aMap,"myCursorOrigin[0]").toDouble();
1583           anOrigin[1] = Storable::FindValue(aMap,"myCursorOrigin[1]").toDouble();
1584           anOrigin[2] = Storable::FindValue(aMap,"myCursorOrigin[2]").toDouble();
1585           aPlanesWidget->SetOrigin(anOrigin);
1586           
1587           float aNormal[3];
1588           aNormal[0] = Storable::FindValue(aMap,"myCursorNormal[0]").toDouble();
1589           aNormal[1] = Storable::FindValue(aMap,"myCursorNormal[1]").toDouble();
1590           aNormal[2] = Storable::FindValue(aMap,"myCursorNormal[2]").toDouble();
1591           aPlanesWidget->SetNormal(aNormal);
1592           
1593           float aDepth = Storable::FindValue(aMap,"myCursorDepth").toDouble();
1594           aPlanesWidget->SetDistance(aDepth);
1595           
1596           aMainWindow->SetPlanesSegementation(true);
1597         }else if(aSegmentationMode == "Sphere"){
1598           VISU_SphereWidget *aSphereWidget = aWidgetCtrl->GetSphereWidget();
1599           float aCenter[3];
1600           aCenter[0] = Storable::FindValue(aMap,"mySphereCursorCenter[0]").toDouble();
1601           aCenter[1] = Storable::FindValue(aMap,"mySphereCursorCenter[1]").toDouble();
1602           aCenter[2] = Storable::FindValue(aMap,"mySphereCursorCenter[2]").toDouble();
1603           aSphereWidget->SetCenter(aCenter);
1604           
1605           float aRadius = Storable::FindValue(aMap,"mySphereCursorRaduis").toDouble();
1606           aSphereWidget->SetRadius(aRadius);
1607           
1608           aMainWindow->SetSphereSegementation(true);
1609         }
1610       }
1611
1612       if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
1613         SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1614         if(anInteractor->isVisible()){
1615           SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1616         }else
1617           anInteractor->installEventFilter(this);
1618       }
1619
1620       if(aSegmentationMode != ""){
1621         if(VVTK_MainWindow2* aMainWindow = aViewWindow->getMainWindow2()){
1622           SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1623           if(anInteractor->isVisible())
1624             SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1625           else
1626             anInteractor->installEventFilter(this);
1627         }
1628       }
1629
1630       SetGaussPointsSelection(this,aViewWindow,aCStudy,aSObject);
1631     }
1632   }
1633 }
1634
1635
1636 //---------------------------------------------------------------
1637 bool
1638 VisuGUI_Module::
1639 eventFilter( QObject * theWatched, QEvent * theEvent )
1640 {
1641   bool aRet = VisuGUI::eventFilter(theWatched,theEvent);
1642   if(theEvent->type() == QEvent::Show){
1643     if(SUIT_ViewManager* aViewManager = getViewManager(VVTK_Viewer::Type(),false)){
1644       SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
1645       VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
1646       if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
1647         SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1648         if(theWatched == anInteractor){
1649           SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1650           anInteractor->removeEventFilter(this);
1651         }
1652       }
1653       if(VVTK_MainWindow2* aMainWindow = aViewWindow->getMainWindow2()){
1654         SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1655         if(theWatched == aMainWindow->GetInteractor()){
1656           SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1657           anInteractor->removeEventFilter(this);
1658         }
1659       }
1660     }
1661   }
1662   return aRet;
1663 }