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