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