1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // VISU VISUGUI : GUI of VISU component
24 // File : VisuGUI_Module.cxx
25 // Author : Laurent CORNABE
29 #include "VisuGUI_Module.h"
31 #include "QtxPopupMgr.h"
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"
39 #include "CAM_Module.h"
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"
48 #include "SALOMEDSClient_ClientFactory.hxx"
49 #include "SALOMEDSClient_IParameters.hxx"
51 //#include "VVTK_ViewManager.h"
52 //#include "VVTK_ViewWindow.h"
53 //#include "VVTK_ViewModel.h"
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"
61 #include "VTKViewer_Algorithm.h"
63 #include "VisuGUI_Prs3dTools.h"
64 #include "VisuGUI_ClippingDlg.h"
66 #include "VISU_GaussPoints_i.hh"
67 #include "VISU_GaussPtsAct.h"
68 #include "VisuGUI_GaussPointsDlg.h"
70 #include "VISU_Gen_i.hh"
71 #include "VISU_Result_i.hh"
72 #include "VISU_CutLinesBase_i.hh"
74 #include "VISU_Actor.h"
75 #include "VISU_ScalarMapAct.h"
76 #include "VisuGUI_Tools.h"
77 #include "VisuGUI_ActionsDef.h"
79 #include "VISU_WidgetCtrl.hxx"
80 #include "VISU_PlanesWidget.hxx"
81 #include "VISU_SphereWidget.hxx"
83 #include "SalomeApp_Study.h"
84 //#include "VVTK_MainWindow.h"
85 #include "VISU_View_i.hh"
87 #ifndef DISABLE_VTKVIEWER
88 #ifndef DISABLE_SALOMEOBJECT
89 #include <SVTK_ViewWindow.h>
90 #include <SVTK_ViewModel.h>
92 #include <VTKViewer_ViewWindow.h>
94 #include <VTKViewer_ViewModel.h>
96 #ifndef DISABLE_OCCVIEWER
97 #include <OCCViewer_ViewWindow.h>
98 #include <OCCViewer_ViewPort3d.h>
99 #ifndef DISABLE_SALOMEOBJECT
100 #include <SOCC_ViewModel.h>
102 #include <OCCViewer_ViewModel.h>
105 #ifndef DISABLE_GLVIEWER
106 #include <GLViewer_ViewFrame.h>
107 #include <GLViewer_ViewPort.h>
109 #ifndef DISABLE_PLOT2DVIEWER
110 #include <Plot2d_ViewWindow.h>
111 #include <Plot2d_ViewFrame.h>
112 #ifndef DISABLE_SALOMEOBJECT
113 #include <SPlot2d_ViewModel.h>
115 #include <Plot2d_ViewModel.h>
121 #include <vtkRenderer.h>
122 #include <vtkCamera.h>
123 #include <vtkTimerLog.h>
124 #include <vtkPlane.h>
130 static int MYDEBUG = 0;
132 static int MYDEBUG = 0;
135 #define SAVE_VISU_STATE 5090
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
146 #define GAUSS_SAVE_CONFIGURATION 5700
147 #define GAUSS_OVERWRITE_CONFIGURATION 5701
148 #define GAUSS_RESTORE_CONFIGURATION 5702
149 #define GAUSS_RENAME_CONFIGURATION 5703
154 CreateCurves( SalomeApp_Module* theModule,
155 VISU::CutLinesBase_i* thePrs,
157 const bool theCreate = true );
159 using namespace VISU;
163 //---------------------------------------------------------------
164 typedef void (SUIT_ViewWindow::* TViewVisibility)();
165 void SetViewVisibility(SalomeApp_Application* app,
166 TViewVisibility theViewVisibility)
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 )
175 QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
176 int aSize = aViews.size();
177 for(int anId = 0; anId < aSize; anId++)
179 if(SUIT_ViewWindow* aView = aViews[anId])
180 (aView->* theViewVisibility)();
186 //---------------------------------------------------------------
187 VisuGUI_Module::VisuGUI_Module() :
189 LightApp_Module("VISU")
194 //---------------------------------------------------------------
195 VisuGUI_Module::~VisuGUI_Module()
200 //---------------------------------------------------------------
201 void VisuGUI_Module::initialize( CAM_Application* theApp )
203 VisuGUI::initialize( theApp );
205 SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
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 );
215 /* aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GAUSS_NEW_VIEWER"));
216 createAction( GAUSS_NEW_VIEWER,
217 tr("MEN_GAUSS_NEW_VIEWER"),
219 tr("MEN_GAUSS_NEW_VIEWER"),
220 tr("MEN_GAUSS_NEW_VIEWER"),
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 );
230 // Add actions to menus
231 createMenu( tr( "MEN_GAUSS" ), -1, -1, 30 );
232 //createMenu( GAUSS_CREATE_PRS, aMenuId, 10 );
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 );
249 connect( getApp(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
250 this, SLOT( OnViewManagerAdded (SUIT_ViewManager*) ) );
252 // Prepare popup menus
253 QtxPopupMgr* mgr = popupMgr();
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'}" );
267 createMenu( action( GAUSS_CREATE_PRS ), createMenu( tr( "MEN_VISUALISATION" ), -1 ), -1 );
268 createTool( GAUSS_CREATE_PRS, createTool( tr( "TOOL_VISUALISATION" ) ), -1 );
270 createAction( GAUSS_RENAME, VisuGUI::tr("MEN_RENAME"), QIcon(),
271 VisuGUI::tr("MEN_RENAME"), "", 0, this, false,
272 this, SLOT(OnRename()));
273 mgr->insert( action( GAUSS_RENAME ), -1, 0, -1 );
274 mgr->setRule( action( GAUSS_RENAME ),
275 "selcount=1 and type='VISU::TGAUSSPOINTS'" );
277 createAction( GAUSS_EDIT_PRS, VisuGUI::tr("MEN_EDIT_PRS"), QIcon(),
278 VisuGUI::tr("MEN_EDIT_PRS"), "", 0, this, false,
279 this, SLOT(OnEditGaussPoints()));
280 mgr->insert( action( GAUSS_EDIT_PRS ), -1, 0, -1 );
281 mgr->setRule( action( GAUSS_EDIT_PRS ),
282 "selcount=1 and type='VISU::TGAUSSPOINTS'" );
284 createAction( GAUSS_COPY_PRS, VisuGUI::tr("MEN_COPY_PRS"), QIcon(),
285 VisuGUI::tr("MEN_COPY_PRS"), "", 0, this, false,
286 this, SLOT(OnCopyPresentation()));
287 mgr->insert( action( GAUSS_COPY_PRS ), -1, 0, -1 );
288 mgr->setRule( action( GAUSS_COPY_PRS ),
289 "selcount=1 and type='VISU::TGAUSSPOINTS'" );
291 action( GAUSS_COPY_PRS )->setEnabled(false);
295 #ifndef DISABLE_OCCVIEWER
296 #ifndef DISABLE_SALOMEOBJECT
297 viewers.append( SOCC_Viewer::Type() );
299 viewers.append( OCCViewer_Viewer::Type() );
302 #ifndef DISABLE_VTKVIEWER
303 #ifndef DISABLE_SALOMEOBJECT
304 viewers.append( SVTK_Viewer::Type() );
305 //viewers.append( VVTK_Viewer::Type() );
307 viewers.append( VTKViewer_Viewer::Type() );
310 #ifndef DISABLE_PLOT2DVIEWER
311 #ifndef DISABLE_SALOMEOBJECT
312 viewers.append( SPlot2d_Viewer::Type() );
314 viewers.append( Plot2d_Viewer::Type() );
318 if( !viewers.isEmpty() )
320 QString strViewers = "{ ", temp = "'%1' ";
321 QStringList::const_iterator anIt = viewers.begin(), aLast = viewers.end();
322 for( ; anIt!=aLast; anIt++ )
323 strViewers+=temp.arg( *anIt );
325 mgr->setRule( action(myEraseAll), QString( "client in %1" ).arg( strViewers ) );
328 aRule = "(selcount>0 and type='VISU::TGAUSSPOINTS')";
330 /* createAction( GAUSS_ERASE_PRS, VisuGUI::tr("MEN_HIDE"), QIcon(),
331 VisuGUI::tr("MEN_HIDE"), "", 0, this, false,
332 this, SLOT(OnErasePrs()));
333 mgr->insert( action( GAUSS_ERASE_PRS ), -1, -1, -1 ); // erase
334 mgr->setRule( action( GAUSS_ERASE_PRS ),
335 aRule + " and ({true} in $canBeDisplayed) and (isVisible=true)" );
337 createAction( GAUSS_DISPLAY_PRS, VisuGUI::tr("MEN_SHOW"), QIcon(),
338 VisuGUI::tr("MEN_SHOW"), "", 0, this, false,
339 this, SLOT(OnDisplayPrs()));
340 mgr->insert( action( GAUSS_DISPLAY_PRS ), -1, -1, -1 ); // display
341 mgr->setRule( action( GAUSS_DISPLAY_PRS ),
342 aRule + " and ({true} in $canBeDisplayed) and (isVisible=false)" );
344 createAction( GAUSS_DISPLAY_ONLY_PRS, VisuGUI::tr("MEN_DISPLAY_ONLY"), QIcon(),
345 VisuGUI::tr("MEN_DISPLAY_ONLY"), "", 0, this, false,
346 this, SLOT(OnDisplayOnlyPrs()));
347 mgr->insert( action( GAUSS_DISPLAY_ONLY_PRS ), -1, -1, -1 ); // display only
348 mgr->setRule( action( GAUSS_DISPLAY_ONLY_PRS ),
349 aRule + " and ({true} in $canBeDisplayed)" );*/
351 createAction( GAUSS_RENAME_CONFIGURATION, VisuGUI::tr("MEN_RENAME"), QIcon(),
352 VisuGUI::tr("MEN_RENAME"), "", 0, this, false,
353 this, SLOT(OnRename()));
354 mgr->insert( action( GAUSS_RENAME_CONFIGURATION ), -1, -1, -1 );
355 mgr->setRule( action( GAUSS_RENAME_CONFIGURATION ), "selcount=1 and type='VISU::TGAUSSVIEW'" );
357 createAction( GAUSS_SAVE_CONFIGURATION, tr("MEN_SAVE_CONFIGURATION"), QIcon(),
358 tr("MEN_SAVE_CONFIGURATION"), "", 0, this, false,
359 this, SLOT(OnSaveConfiguration()));
360 mgr->insert( action( GAUSS_SAVE_CONFIGURATION ), -1, -1, -1 );
361 mgr->setRule( action( GAUSS_SAVE_CONFIGURATION ),
362 "selcount>=0 and client='SVTK' and activeView='SVTK'" );
364 createAction( GAUSS_OVERWRITE_CONFIGURATION, tr("MEN_OVERWRITE_CONFIGURATION"), QIcon(),
365 tr("MEN_OVERWRITE_CONFIGURATION"), "", 0, this, false,
366 this, SLOT(OnOverwriteConfiguration()));
367 mgr->insert( action( GAUSS_OVERWRITE_CONFIGURATION ), -1, -1, -1 );
368 mgr->setRule( action( GAUSS_OVERWRITE_CONFIGURATION ),
369 "selcount>0 and type='VISU::TGAUSSVIEW' and activeView='SVTK'" );
371 createAction( GAUSS_RESTORE_CONFIGURATION, tr("MEN_RESTORE_CONFIGURATION"), QIcon(),
372 tr("MEN_RESTORE_CONFIGURATION"), "", 0, this, false,
373 this, SLOT(OnRestoreConfiguration()));
374 mgr->insert( action( GAUSS_RESTORE_CONFIGURATION ), -1, -1, -1 );
375 mgr->setRule( action( GAUSS_RESTORE_CONFIGURATION ),
376 "selcount=1 and type='VISU::TGAUSSVIEW'" );
379 // //---------------------------------------------------------------
380 // bool VisuGUI_Module::activateModule( SUIT_Study* theStudy )
382 // VisuGUI::activateModule( theStudy );
384 // //SetViewVisibility(getApp(),&SUIT_ViewWindow::show);
389 //---------------------------------------------------------------
390 // bool VisuGUI_Module::deactivateModule( SUIT_Study* theStudy )
392 // return VisuGUI::deactivateModule( theStudy );
394 // //SetViewVisibility(getApp(),&SUIT_ViewWindow::hide);
400 //---------------------------------------------------------------
401 // SUIT_ViewManager* VisuGUI_Module::onCreateViewManager()
403 // SalomeApp_Application* anApp = getApp();
404 // SUIT_ResourceMgr* aResourceMgr = anApp->resourceMgr();
405 // VVTK_ViewManager* aViewManager = new VVTK_ViewManager( anApp->activeStudy(), anApp->desktop() );
406 // VVTK_Viewer* aViewer = (VVTK_Viewer*)aViewManager->getViewModel();
407 // aViewer->setBackgroundColor( aResourceMgr->colorValue( "VTKViewer", "background", aViewer->backgroundColor() ) );
408 // aViewer->setProjectionMode( aResourceMgr->integerValue( "VTKViewer", "projection_mode", aViewer->projectionMode() ) );
409 // aViewer->setTrihedronSize( aResourceMgr->integerValue( "VTKViewer", "trihedron_size", aViewer->trihedronSize() ),
410 // aResourceMgr->booleanValue( "VTKViewer", "relative_size", aViewer->trihedronRelative() ) );
411 // aViewer->setIncrementalSpeed( aResourceMgr->integerValue( "VTKViewer", "speed_value", aViewer->incrementalSpeed() ),
412 // aResourceMgr->integerValue( "VTKViewer", "speed_mode", aViewer->incrementalSpeedMode() ) );
413 // aViewer->setInteractionStyle( aResourceMgr->integerValue( "VTKViewer", "navigation_mode", aViewer->interactionStyle() ) );
414 // aViewer->setSpacemouseButtons( aResourceMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", aViewer->spacemouseBtn(1) ),
415 // aResourceMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", aViewer->spacemouseBtn(1) ),
416 // aResourceMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", aViewer->spacemouseBtn(1) ) );
418 // new LightApp_VTKSelector( aViewer, anApp->selectionMgr() );
420 // anApp->addViewManager( aViewManager );
422 // return aViewer->getViewManager();
426 //---------------------------------------------------------------
427 void VisuGUI_Module::createPreferences()
429 VisuGUI::createPreferences();
431 createGaussPointsPreferences();
432 createInsideCursorPreferences();
433 createOutsideCursorPreferences();
434 createPickingPreferences();
435 // createSpaceMousePreferences();
436 //createRecorderPreferences();
440 //---------------------------------------------------------------
441 void VisuGUI_Module::createGaussPointsPreferences()
443 int gaussTab = addPreference( tr( "VISU_GAUSS_PREF_TAB_TTL" ) );
444 int primitiveGr = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_GROUP_TTL" ), gaussTab );
445 setPreferenceProperty( primitiveGr, "columns", 2 );
447 int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr,
448 LightApp_Preferences::Selector, "VISU",
449 "point_sprite_primitive_type" );
452 values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) );
453 values.append( tr( "VISU_GAUSS_PREF_OPENGLPOINT" ) );
454 values.append( tr( "VISU_GAUSS_PREF_GEOMSPHERE" ) );
455 QList<QVariant> indices;
459 setPreferenceProperty( primitiveTypePref, "strings", values );
460 setPreferenceProperty( primitiveTypePref, "indexes", indices );
462 int clampPref = addPreference( tr( "VISU_GAUSS_PREF_CLAMP" ), primitiveGr,
463 LightApp_Preferences::IntSpin, "VISU", "point_sprite_clamp" );
464 setPreferenceProperty( clampPref, "min", 1 );
465 setPreferenceProperty( clampPref, "max", 512 );
467 addPreference( tr( "VISU_GAUSS_PREF_MAIN_TEXTURE" ), primitiveGr,
468 LightApp_Preferences::File, "VISU", "point_sprite_main_texture" );
470 addPreference( tr( "VISU_GAUSS_PREF_ALPHA_TEXTURE" ), primitiveGr,
471 LightApp_Preferences::File, "VISU", "point_sprite_alpha_texture" );
473 int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr,
474 LightApp_Preferences::DblSpin, "VISU",
475 "point_sprite_alpha_threshold" );
476 setPreferenceProperty( alphaThresholdPref, "min", 0.0 );
477 setPreferenceProperty( alphaThresholdPref, "max", 1.0 );
478 setPreferenceProperty( alphaThresholdPref, "step", 0.1 );
480 int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr,
481 LightApp_Preferences::IntSpin, "VISU", "geom_sphere_resolution" );
482 setPreferenceProperty( resolutionPref, "min", 3 );
483 setPreferenceProperty( resolutionPref, "max", 100 );
485 int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr,
486 LightApp_Preferences::IntSpin, "VISU", "geom_sphere_face_limit" );
487 setPreferenceProperty( faceLimitPref, "min", 10 );
488 setPreferenceProperty( faceLimitPref, "max", 1000000 );
490 int sizeGr = addPreference( tr( "VISU_GAUSS_PREF_SIZE_GROUP_TTL" ), gaussTab );
491 setPreferenceProperty( sizeGr, "columns", 2 );
493 int minSizePref = addPreference( tr( "VISU_GAUSS_PREF_MIN_SIZE" ), sizeGr,
494 LightApp_Preferences::IntSpin, "VISU", "point_sprite_min_size" );
495 setPreferenceProperty( minSizePref, "min", 1 );
496 setPreferenceProperty( minSizePref, "max", 100 );
498 int maxSizePref = addPreference( tr( "VISU_GAUSS_PREF_MAX_SIZE" ), sizeGr,
499 LightApp_Preferences::IntSpin, "VISU", "point_sprite_max_size" );
500 setPreferenceProperty( maxSizePref, "min", 1 );
501 setPreferenceProperty( maxSizePref, "max", 100 );
503 int magnificationPref = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION" ), sizeGr,
504 LightApp_Preferences::IntSpin, "VISU",
505 "point_sprite_magnification" );
506 setPreferenceProperty( magnificationPref, "min", 10 );
507 setPreferenceProperty( magnificationPref, "max", 1000 );
509 int incrementPref = addPreference( tr( "VISU_GAUSS_PREF_INCREMENT" ), sizeGr,
510 LightApp_Preferences::DblSpin, "VISU", "point_sprite_increment" );
511 setPreferenceProperty( incrementPref, "min", 0.01 );
512 setPreferenceProperty( incrementPref, "max", 10 );
513 setPreferenceProperty( incrementPref, "step", 0.1 );
515 int geomGr = addPreference( tr( "VISU_GAUSS_PREF_GEOM_GROUP_TTL" ), gaussTab );
516 setPreferenceProperty( geomGr, "columns", 2 );
518 int sizePref = addPreference( tr( "VISU_GAUSS_PREF_SIZE" ), geomGr,
519 LightApp_Preferences::IntSpin, "VISU", "point_sprite_size" );
520 setPreferenceProperty( sizePref, "min", 1 );
521 setPreferenceProperty( sizePref, "max", 100 );
523 addPreference( tr( "VISU_GAUSS_PREF_COLOR" ), geomGr,
524 LightApp_Preferences::Color, "VISU", "point_sprite_color" );
526 // ScalarBar Preferences
527 int scalarBarGr = addPreference( tr( "VISU_GAUSS_SCALAR_BAR_PREF_GROUP_TTL" ), gaussTab );
528 setPreferenceProperty( scalarBarGr, "columns", 2 );
530 int activeBarPref = addPreference( tr( "VISU_GAUSS_PREF_ACTIVE_BAR" ), scalarBarGr,
531 LightApp_Preferences::Selector, "VISU", "scalar_bar_active_local" );
534 values.append( tr( "VISU_GAUSS_PREF_LOCAL" ) );
535 values.append( tr( "VISU_GAUSS_PREF_GLOBAL" ) );
539 setPreferenceProperty( activeBarPref, "strings", values );
540 setPreferenceProperty( activeBarPref, "indexes", indices );
542 addPreference( tr( "VISU_GAUSS_PREF_DISPLAY_GLOBAL" ), scalarBarGr,
543 LightApp_Preferences::Bool, "VISU", "scalar_bar_display_global" );
545 int colorPref = addPreference( tr( "VISU_GAUSS_PREF_SCALAR_BAR_MODE" ), scalarBarGr,
546 LightApp_Preferences::Selector, "VISU", "scalar_bar_bicolor" );
549 values.append( tr( "VISU_GAUSS_PREF_BICOLOR" ) );
550 values.append( tr( "VISU_GAUSS_PREF_RAINBOW" ) );
554 setPreferenceProperty( colorPref, "strings", values );
555 setPreferenceProperty( colorPref, "indexes", indices );
557 int spacingPref = addPreference( tr( "VISU_GAUSS_PREF_SPACING" ), scalarBarGr,
558 LightApp_Preferences::DblSpin, "VISU", "scalar_bar_spacing" );
559 setPreferenceProperty( spacingPref, "min", 0.01 );
560 setPreferenceProperty( spacingPref, "max", 1.0 );
561 setPreferenceProperty( spacingPref, "step", 0.01 );
564 int spacemouseGr = addPreference( tr( "VISU_SPACEMOUSE_PREF" ), gaussTab );
565 setPreferenceProperty( spacemouseGr, "columns", 2 );
566 int spacemousePref3 = addPreference( tr( "VISU_SPACEMOUSE_PREF_3" ), spacemouseGr,
567 LightApp_Preferences::Selector, "VISU",
568 "spacemouse_func3_btn" ); //decrease_gauss_point_magnification
569 int spacemousePref4 = addPreference( tr( "VISU_SPACEMOUSE_PREF_4" ), spacemouseGr,
570 LightApp_Preferences::Selector, "VISU",
571 "spacemouse_func4_btn" ); //increase_gauss_point_magnification
573 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_1" ) );
574 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_2" ) );
575 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_3" ) );
576 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_4" ) );
577 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_5" ) );
578 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_6" ) );
579 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_7" ) );
580 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_8" ) );
581 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_*" ) );
582 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_10" ) );
583 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_11" ) );
593 indices.append( 9 ); // == button_*
594 indices.append( 10 );
595 indices.append( 11 );
596 setPreferenceProperty( spacemousePref3, "strings", values );
597 setPreferenceProperty( spacemousePref3, "indexes", indices );
598 setPreferenceProperty( spacemousePref4, "strings", values );
599 setPreferenceProperty( spacemousePref4, "indexes", indices );
603 //---------------------------------------------------------------
604 void VisuGUI_Module::createInsideCursorPreferences()
606 int insideCursorTab = addPreference( tr( "VISU_GAUSS_INSIDE_CURSOR_PREF_TAB_TTL" ) );
608 int primitiveGr = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_GROUP_TTL" ), insideCursorTab );
609 setPreferenceProperty( primitiveGr, "columns", 2 );
611 int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr,
612 LightApp_Preferences::Selector, "VISU",
613 "inside_point_sprite_primitive_type" );
616 values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) );
617 values.append( tr( "VISU_GAUSS_PREF_OPENGLPOINT" ) );
618 values.append( tr( "VISU_GAUSS_PREF_GEOMSPHERE" ) );
619 QList<QVariant> indices;
623 setPreferenceProperty( primitiveTypePref, "strings", values );
624 setPreferenceProperty( primitiveTypePref, "indexes", indices );
626 int clampPref = addPreference( tr( "VISU_GAUSS_PREF_CLAMP" ), primitiveGr,
627 LightApp_Preferences::IntSpin, "VISU", "inside_point_sprite_clamp" );
628 setPreferenceProperty( clampPref, "min", 1 );
629 setPreferenceProperty( clampPref, "max", 512 );
631 addPreference( tr( "VISU_GAUSS_PREF_MAIN_TEXTURE" ), primitiveGr,
632 LightApp_Preferences::File, "VISU", "inside_point_sprite_main_texture" );
634 addPreference( tr( "VISU_GAUSS_PREF_ALPHA_TEXTURE" ), primitiveGr,
635 LightApp_Preferences::File, "VISU", "inside_point_sprite_alpha_texture" );
637 int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr,
638 LightApp_Preferences::DblSpin, "VISU",
639 "inside_point_sprite_alpha_threshold" );
640 setPreferenceProperty( alphaThresholdPref, "min", 0.0 );
641 setPreferenceProperty( alphaThresholdPref, "max", 1.0 );
642 setPreferenceProperty( alphaThresholdPref, "step", 0.1 );
644 int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr,
645 LightApp_Preferences::IntSpin, "VISU",
646 "inside_geom_sphere_resolution" );
647 setPreferenceProperty( resolutionPref, "min", 3 );
648 setPreferenceProperty( resolutionPref, "max", 100 );
650 int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr,
651 LightApp_Preferences::IntSpin, "VISU",
652 "inside_geom_sphere_face_limit" );
653 setPreferenceProperty( faceLimitPref, "min", 10 );
654 setPreferenceProperty( faceLimitPref, "max", 1000000 );
656 int sizeGr = addPreference( tr( "VISU_GAUSS_PREF_SIZE_GROUP_TTL" ), insideCursorTab );
657 setPreferenceProperty( sizeGr, "columns", 4 );
659 int minSizePref = addPreference( tr( "VISU_GAUSS_PREF_MIN_SIZE" ), sizeGr,
660 LightApp_Preferences::IntSpin, "VISU",
661 "inside_point_sprite_min_size" );
662 setPreferenceProperty( minSizePref, "min", 1 );
663 setPreferenceProperty( minSizePref, "max", 100 );
665 int maxSizePref = addPreference( tr( "VISU_GAUSS_PREF_MAX_SIZE" ), sizeGr,
666 LightApp_Preferences::IntSpin, "VISU",
667 "inside_point_sprite_max_size" );
668 setPreferenceProperty( maxSizePref, "min", 1 );
669 setPreferenceProperty( maxSizePref, "max", 100 );
671 int magnificationGr = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION_GROUP_TTL" ), insideCursorTab );
672 setPreferenceProperty( magnificationGr, "columns", 4 );
674 int magnificationPref = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION" ), magnificationGr,
675 LightApp_Preferences::IntSpin, "VISU",
676 "inside_point_sprite_magnification" );
677 setPreferenceProperty( magnificationPref, "min", 10 );
678 setPreferenceProperty( magnificationPref, "max", 1000 );
680 int incrementPref = addPreference( tr( "VISU_GAUSS_PREF_INCREMENT" ), magnificationGr,
681 LightApp_Preferences::DblSpin, "VISU",
682 "inside_point_sprite_increment" );
683 setPreferenceProperty( incrementPref, "min", 0.01 );
684 setPreferenceProperty( incrementPref, "max", 10 );
685 setPreferenceProperty( incrementPref, "step", 0.1 );
689 //---------------------------------------------------------------
690 void VisuGUI_Module::createOutsideCursorPreferences()
692 int outsideCursorTab = addPreference( tr( "VISU_GAUSS_OUTSIDE_CURSOR_PREF_TAB_TTL" ) );
694 int primitiveGr = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_GROUP_TTL" ), outsideCursorTab );
695 setPreferenceProperty( primitiveGr, "columns", 2 );
697 int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr,
698 LightApp_Preferences::Selector, "VISU",
699 "outside_point_sprite_primitive_type" );
702 values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) );
703 values.append( tr( "VISU_GAUSS_PREF_OPENGLPOINT" ) );
704 values.append( tr( "VISU_GAUSS_PREF_GEOMSPHERE" ) );
705 QList<QVariant> indices;
709 setPreferenceProperty( primitiveTypePref, "strings", values );
710 setPreferenceProperty( primitiveTypePref, "indexes", indices );
712 int clampPref = addPreference( tr( "VISU_GAUSS_PREF_CLAMP" ), primitiveGr,
713 LightApp_Preferences::IntSpin, "VISU", "outside_point_sprite_clamp" );
714 setPreferenceProperty( clampPref, "min", 1 );
715 setPreferenceProperty( clampPref, "max", 512 );
717 addPreference( tr( "VISU_GAUSS_PREF_MAIN_TEXTURE" ), primitiveGr,
718 LightApp_Preferences::File, "VISU", "outside_point_sprite_main_texture" );
720 addPreference( tr( "VISU_GAUSS_PREF_ALPHA_TEXTURE" ), primitiveGr,
721 LightApp_Preferences::File, "VISU", "outside_point_sprite_alpha_texture" );
723 int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr,
724 LightApp_Preferences::DblSpin, "VISU",
725 "outside_point_sprite_alpha_threshold" );
726 setPreferenceProperty( alphaThresholdPref, "min", 0.0 );
727 setPreferenceProperty( alphaThresholdPref, "max", 1.0 );
728 setPreferenceProperty( alphaThresholdPref, "step", 0.1 );
730 int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr,
731 LightApp_Preferences::IntSpin, "VISU",
732 "outside_geom_sphere_resolution" );
733 setPreferenceProperty( resolutionPref, "min", 3 );
734 setPreferenceProperty( resolutionPref, "max", 100 );
736 int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr,
737 LightApp_Preferences::IntSpin, "VISU",
738 "outside_geom_sphere_face_limit" );
739 setPreferenceProperty( faceLimitPref, "min", 10 );
740 setPreferenceProperty( faceLimitPref, "max", 1000000 );
742 int sizeGr = addPreference( tr( "VISU_GAUSS_PREF_SIZE_GROUP_TTL" ), outsideCursorTab );
743 setPreferenceProperty( sizeGr, "columns", 2 );
745 int sizePref = addPreference( tr( "VISU_GAUSS_PREF_SIZE" ), sizeGr,
746 LightApp_Preferences::IntSpin, "VISU", "outside_point_sprite_size" );
747 setPreferenceProperty( sizePref, "min", 1 );
748 setPreferenceProperty( sizePref, "max", 100 );
750 int colorGr = addPreference( tr( "VISU_GAUSS_PREF_COLOR_GROUP_TTL" ), outsideCursorTab );
751 setPreferenceProperty( colorGr, "columns", 2 );
753 addPreference( tr( "VISU_GAUSS_PREF_UNIFORM_COLOR" ), colorGr,
754 LightApp_Preferences::Bool, "VISU", "outside_point_sprite_uniform" );
756 addPreference( tr( "VISU_GAUSS_PREF_COLOR" ), colorGr,
757 LightApp_Preferences::Color, "VISU", "outside_point_sprite_color" );
761 //---------------------------------------------------------------
762 void VisuGUI_Module::createPickingPreferences()
764 int pickingTab = addPreference( tr( "VISU_PICKING_PREF_TAB_TTL" ) );
767 int cursorGr = addPreference( tr( "VISU_PICKING_PREF_CURSOR_GROUP_TTL" ), pickingTab );
768 setPreferenceProperty( cursorGr, "columns", 2 );
770 int cursorSizePref = addPreference( tr( "VISU_PICKING_PREF_CURSOR_SIZE" ), cursorGr,
771 LightApp_Preferences::DblSpin, "VISU", "picking_cursor_size" );
772 setPreferenceProperty( cursorSizePref, "min", 0 );
773 setPreferenceProperty( cursorSizePref, "max", 1.0 );
774 setPreferenceProperty( cursorSizePref, "step", 0.1 );
776 int pyramidHeightPref = addPreference( tr( "VISU_PICKING_PREF_PYRAMID_HEIGHT" ), cursorGr,
777 LightApp_Preferences::DblSpin, "VISU", "picking_pyramid_height" );
778 setPreferenceProperty( pyramidHeightPref, "min", 1 );
779 setPreferenceProperty( pyramidHeightPref, "max", 100 );
781 /*int selectionColorPref = */
782 addPreference( tr( "VISU_PICKING_PREF_SELECTION_COLOR" ), cursorGr,
783 LightApp_Preferences::Color, "VISU", "picking_selection_color" );
786 int toleranceGr = addPreference( tr( "VISU_PICKING_PREF_TOLERANCE_GROUP_TTL" ), pickingTab );
787 setPreferenceProperty( toleranceGr, "columns", 2 );
789 int pointTolerancePref = addPreference( tr( "VISU_PICKING_PREF_POINT_SELECTION_TOLERANCE" ), toleranceGr,
790 LightApp_Preferences::DblSpin, "VISU", "picking_point_tolerance" );
791 setPreferenceProperty( pointTolerancePref, "min", 0.001 );
792 setPreferenceProperty( pointTolerancePref, "max", 10 );
793 setPreferenceProperty( pointTolerancePref, "step", 0.01 );
796 int infoWindowGr = addPreference( tr( "VISU_PICKING_PREF_INFO_WINDOW_GROUP_TTL" ), pickingTab );
797 setPreferenceProperty( infoWindowGr, "columns", 2 );
799 int infoWindowPref = addPreference( tr( "VISU_PICKING_PREF_INFO_WINDOW" ), infoWindowGr,
800 LightApp_Preferences::Bool, "VISU", "picking_info_window" );
801 setPreferenceProperty( infoWindowPref, "columns", 2 );
803 int transparencyPref = addPreference( tr( "VISU_PICKING_PREF_TRANSPARENCY" ), infoWindowGr,
804 LightApp_Preferences::IntSpin, "VISU", "picking_transparency" );
805 setPreferenceProperty( transparencyPref, "min", 0 );
806 setPreferenceProperty( transparencyPref, "max", 100 );
807 setPreferenceProperty( transparencyPref, "step", 10 );
809 int positionPref = addPreference( tr( "VISU_PICKING_PREF_POSITION" ), infoWindowGr,
810 LightApp_Preferences::Selector, "VISU", "picking_position" );
812 values.append( tr( "VISU_PICKING_PREF_BELOW_POINT" ) );
813 values.append( tr( "VISU_PICKING_PREF_TOP_LEFT_CORNER" ) );
814 QList<QVariant> indices;
817 setPreferenceProperty( positionPref, "strings", values );
818 setPreferenceProperty( positionPref, "indexes", indices );
821 int cameraGr = addPreference( tr( "VISU_PICKING_PREF_CAMERA_GROUP_TTL" ), pickingTab );
822 setPreferenceProperty( cameraGr, "columns", 2 );
824 int cameraPref = addPreference( tr( "VISU_PICKING_PREF_CAMERA_MOVEMENT" ), cameraGr,
825 LightApp_Preferences::Bool, "VISU", "picking_camera_movement" );
826 setPreferenceProperty( cameraPref, "columns", 2 );
828 int zoomFactorPref = addPreference( tr( "VISU_PICKING_PREF_ZOOM_FACTOR" ), cameraGr,
829 LightApp_Preferences::DblSpin, "VISU", "picking_zoom_factor" );
830 setPreferenceProperty( zoomFactorPref, "min", 0.1 );
831 setPreferenceProperty( zoomFactorPref, "max", 10.0 );
832 setPreferenceProperty( zoomFactorPref, "step", 0.1 );
834 int stepNumberPref = addPreference( tr( "VISU_PICKING_PREF_STEP_NUMBER" ), cameraGr,
835 LightApp_Preferences::IntSpin, "VISU", "picking_step_number" );
836 setPreferenceProperty( stepNumberPref, "min", 1 );
837 setPreferenceProperty( stepNumberPref, "max", 100 );
839 // Display parent mesh
840 int parentMeshGr = addPreference( tr( "VISU_PICKING_PREF_PARENT_MESH_TTL" ), pickingTab );
841 setPreferenceProperty( parentMeshGr, "columns", 1 );
843 addPreference( tr( "VISU_PICKING_PREF_DISPLAY_PARENT_MESH" ), parentMeshGr,
844 LightApp_Preferences::Bool, "VISU", "picking_display_parent_mesh" );
848 //---------------------------------------------------------------
849 void VisuGUI_Module::createSpaceMousePreferences()
851 int mouseTab = addPreference( tr( "VISU_MOUSE_PREF_TAB_TLT" ) );
853 int mouseGr = addPreference( tr( "VISU_MOUSE_PREF_GROUP_TLT" ), mouseTab );
854 setPreferenceProperty( mouseGr, "columns", 2 );
855 int mousePref = addPreference( tr( "VISU_MOUSE_PREF" ), mouseGr,
856 LightApp_Preferences::Selector, "VISU", "mouse_behaviour" );
858 values.append( tr( "VISU_MOUSE_PREF_STANDARD" ) );
859 values.append( tr( "VISU_MOUSE_PREF_KEYBOARD_FREE" ) );
860 QList<QVariant> indices;
863 setPreferenceProperty( mousePref, "strings", values );
864 setPreferenceProperty( mousePref, "indexes", indices );
866 int keybrdGr = addPreference( tr( "VISU_KEYBOARD_PREF_GROUP_TTL" ), mouseTab );
867 setPreferenceProperty( keybrdGr, "columns", 2 );
868 int keybrdPref = addPreference( tr( "VISU_KEYBOARD_PREF" ), keybrdGr,
869 LightApp_Preferences::IntSpin, "VISU", "speed_increment" );
870 setPreferenceProperty( keybrdPref, "max", 1000 );
872 int spacemouseGr = addPreference( tr( "VISU_SPACEMOUSE_PREF" ), mouseTab );
873 setPreferenceProperty( spacemouseGr, "columns", 2 );
874 int spacemousePref1 = addPreference( tr( "VISU_SPACEMOUSE_PREF_1" ), spacemouseGr,
875 LightApp_Preferences::Selector, "VISU",
876 "spacemouse_func1_btn" ); //decrease_speed_increment
877 int spacemousePref2 = addPreference( tr( "VISU_SPACEMOUSE_PREF_2" ), spacemouseGr,
878 LightApp_Preferences::Selector, "VISU",
879 "spacemouse_func2_btn" ); //increase_speed_increment
880 int spacemousePref3 = addPreference( tr( "VISU_SPACEMOUSE_PREF_3" ), spacemouseGr,
881 LightApp_Preferences::Selector, "VISU",
882 "spacemouse_func3_btn" ); //decrease_gauss_point_magnification
883 int spacemousePref4 = addPreference( tr( "VISU_SPACEMOUSE_PREF_4" ), spacemouseGr,
884 LightApp_Preferences::Selector, "VISU",
885 "spacemouse_func4_btn" ); //increase_gauss_point_magnification
886 int spacemousePref5 = addPreference( tr( "VISU_SPACEMOUSE_PREF_5" ), spacemouseGr,
887 LightApp_Preferences::Selector, "VISU",
888 "spacemouse_func5_btn" ); //dominant_combined_switch
890 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_1" ) );
891 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_2" ) );
892 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_3" ) );
893 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_4" ) );
894 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_5" ) );
895 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_6" ) );
896 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_7" ) );
897 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_8" ) );
898 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_*" ) );
899 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_10" ) );
900 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_11" ) );
910 indices.append( 9 ); // == button_*
911 indices.append( 10 );
912 indices.append( 11 );
913 setPreferenceProperty( spacemousePref1, "strings", values );
914 setPreferenceProperty( spacemousePref1, "indexes", indices );
915 setPreferenceProperty( spacemousePref2, "strings", values );
916 setPreferenceProperty( spacemousePref2, "indexes", indices );
917 setPreferenceProperty( spacemousePref3, "strings", values );
918 setPreferenceProperty( spacemousePref3, "indexes", indices );
919 setPreferenceProperty( spacemousePref4, "strings", values );
920 setPreferenceProperty( spacemousePref4, "indexes", indices );
921 setPreferenceProperty( spacemousePref5, "strings", values );
922 setPreferenceProperty( spacemousePref5, "indexes", indices );
926 //---------------------------------------------------------------
927 void VisuGUI_Module::createRecorderPreferences()
929 int recorderTab = addPreference( tr( "VISU_RECORDER_PREF_TAB_TTL" ) );
931 int recorderGr = addPreference( tr( "VISU_RECORDER_PREF_GROUP_TTL" ), recorderTab );
932 setPreferenceProperty( recorderGr, "columns", 2 );
934 int modePref = addPreference( tr( "VISU_RECORDER_PREF_RECORDING_MODE" ), recorderGr,
935 LightApp_Preferences::Selector, "VISU", "recorder_mode" );
937 values.append( tr( "VISU_RECORDER_PREF_SKIPPED_FRAMES" ) );
938 values.append( tr( "VISU_RECORDER_PREF_ALL_DISLPAYED_FRAMES" ) );
939 QList<QVariant> indices;
942 setPreferenceProperty( modePref, "strings", values );
943 setPreferenceProperty( modePref, "indexes", indices );
945 int fpsPref = addPreference( tr( "VISU_RECORDER_PREF_FPS" ), recorderGr,
946 LightApp_Preferences::DblSpin, "VISU", "recorder_fps" );
947 setPreferenceProperty( fpsPref, "min", 0.1 );
948 setPreferenceProperty( fpsPref, "max", 100 );
950 int qualityPref = addPreference( tr( "VISU_RECORDER_PREF_QUALITY" ), recorderGr,
951 LightApp_Preferences::IntSpin, "VISU", "recorder_quality" );
952 setPreferenceProperty( qualityPref, "min", 1 );
953 setPreferenceProperty( qualityPref, "max", 100 );
955 addPreference( tr( "VISU_RECORDER_PREF_PROGRESSIVE" ), recorderGr,
956 LightApp_Preferences::Bool, "VISU", "recorder_progressive" );
960 //---------------------------------------------------------------
961 void VisuGUI_Module::OnCreateGaussPoints()
963 double initialTime = vtkTimerLog::GetCPUTime();
964 //CreatePrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg, 1>(this, VVTK_Viewer::Type());
965 Prs3d_i* aPrs = CreatePrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg, 1>(this, SVTK_Viewer::Type());
967 emit presentationCreated(aPrs);
968 INFOS( "VisuGUI_Module::OnCreateGaussPoints() : Gauss Points created in " <<
969 vtkTimerLog::GetCPUTime() - initialTime << " seconds" );
972 // void VisuGUI_Module::OnViewManagerAdded(SUIT_ViewManager* viewMgr)
974 // QString type = viewMgr->getViewModel()->getType();
975 // if ( type == VVTK_Viewer::Type() )
976 // connect( viewMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
977 // this, SLOT( OnViewCreated( SUIT_ViewWindow* ) ) );
980 void VisuGUI_Module::OnViewCreated(SUIT_ViewWindow* view)
982 SVTK_ViewWindow* viewWindow = dynamic_cast<SVTK_ViewWindow*>( view );
984 setProperty( viewWindow, "speed_increment" );
985 setProperty( viewWindow, "spacemouse_func1_btn" );
986 setProperty( viewWindow, "spacemouse_func2_btn" );
987 setProperty( viewWindow, "spacemouse_func3_btn" );
988 setProperty( viewWindow, "spacemouse_func4_btn" );
989 setProperty( viewWindow, "spacemouse_func5_btn" );
993 void VisuGUI_Module::setProperty( SVTK_ViewWindow* viewWindow, const QString& pref )
998 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
999 //SVTK_MainWindow* aMainWindow = viewWindow->getMainWindow();
1001 if ( pref == "speed_increment" ) {
1002 val = resMgr->integerValue( "VTKViewer", pref, 10 );
1003 viewWindow->InvokeEvent( SVTK::SetSpeedIncrementEvent, &val );
1005 else if ( pref == "spacemouse_func1_btn" ) {
1006 val = resMgr->integerValue( "VTKViewer", pref, 1 );
1007 viewWindow->InvokeEvent( SVTK::SetSMDecreaseSpeedEvent, &val );
1009 else if ( pref == "spacemouse_func2_btn" ) {
1010 val = resMgr->integerValue( "VTKViewer", pref, 2 );
1011 viewWindow->InvokeEvent( SVTK::SetSMIncreaseSpeedEvent, &val );
1013 else if ( pref == "spacemouse_func3_btn" ) {
1014 val = resMgr->integerValue( "VISU", pref, 10 );
1015 viewWindow->InvokeEvent( VISU::SetSMDecreaseMagnificationEvent, &val );
1017 else if ( pref == "spacemouse_func4_btn" ) {
1018 val = resMgr->integerValue( "VISU", pref, 11 );
1019 viewWindow->InvokeEvent( VISU::SetSMIncreaseMagnificationEvent, &val );
1021 else if ( pref == "spacemouse_func5_btn" ) {
1022 val = resMgr->integerValue( "VTKViewer", pref, 9 );
1023 viewWindow->InvokeEvent( SVTK::SetSMDominantCombinedSwitchEvent, &val );
1027 void VisuGUI_Module::setProperty( SVTK_ViewManager* vm, const QString& prop )
1032 QVector<SUIT_ViewWindow*> windows = vm->getViews();
1033 for ( int n = windows.count(), i = 0; i < n; i++ )
1034 setProperty( dynamic_cast<SVTK_ViewWindow*>( windows[i] ), prop );
1037 void VisuGUI_Module::preferencesChanged( const QString& group, const QString& pref )
1039 VisuGUI::preferencesChanged(group,pref);
1041 // if ( group == "VISU" && ( pref == "speed_increment" || pref == "spacemouse_func1_btn" ||
1042 // pref == "spacemouse_func2_btn" || pref == "spacemouse_func3_btn" ||
1043 // pref == "spacemouse_func4_btn" || pref == "spacemouse_func5_btn" ) ) {
1045 // // update properties of VVTK view windows
1046 // SUIT_ViewManager* vm = getApp()->getViewManager( VVTK_Viewer::Type(), false );
1048 // setProperty( dynamic_cast<SVTK_ViewManager*>( vm ), pref );
1053 //---------------------------------------------------------------
1054 SUIT_ViewManager* VisuGUI_Module::getViewManager(const QString& theType,
1055 const bool theIsCreate)
1057 if (SUIT_ViewManager* aViewManager = VisuGUI::getViewManager(theType,theIsCreate))
1058 return aViewManager;
1060 // if (theIsCreate && theType == VVTK_Viewer::Type())
1061 // return onCreateViewManager();
1066 //---------------------------------------------------------------
1067 void VisuGUI_Module::OnEditGaussPoints()
1069 VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
1070 if(aSelectionInfo.empty())
1073 VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
1074 Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
1076 if(VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dToModify(this, aSelectionItem.myObjectInfo.myBase)){
1077 if (SVTK_ViewWindow* aViewWindow = GetViewWindow<SVTK_Viewer>(this)) {
1078 EditPrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg, 1>(this, anIO, aPrs3d, aViewWindow);
1080 // Create VVTK_ViewWindow, if it does not exist
1081 // if (VVTK_ViewWindow* aViewWindow = GetViewWindow<VVTK_Viewer>(this)) {
1082 // EditPrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg, 1>(this, anIO, aPrs3d, aViewWindow);
1088 //---------------------------------------------------------------
1091 /* void GetViewParams(VVTK_MainWindow* theViewWindow,
1092 const char* theSuffix,
1093 std::ostringstream& theStr)
1095 vtkFloatingPointType aColor[3];
1096 vtkRenderer* aRenderer = theViewWindow->getRenderer();
1097 aRenderer->GetBackground(aColor);
1098 Storable::DataToStream(theStr,(std::string("myColor") + theSuffix + ".R").c_str(),aColor[0]);
1099 Storable::DataToStream(theStr,(std::string("myColor") + theSuffix + ".G").c_str(),aColor[1]);
1100 Storable::DataToStream(theStr,(std::string("myColor") + theSuffix + ".B").c_str(),aColor[2]);
1102 double aPosition[3];
1103 vtkCamera* aCamera = aRenderer->GetActiveCamera();
1104 aCamera->GetPosition(aPosition);
1105 Storable::DataToStream(theStr,(std::string("myPosition") + theSuffix + "[0]").c_str(),aPosition[0]);
1106 Storable::DataToStream(theStr,(std::string("myPosition") + theSuffix + "[1]").c_str(),aPosition[1]);
1107 Storable::DataToStream(theStr,(std::string("myPosition") + theSuffix + "[2]").c_str(),aPosition[2]);
1109 double aFocalPnt[3];
1110 aCamera->GetFocalPoint(aFocalPnt);
1111 Storable::DataToStream(theStr,(std::string("myFocalPnt") + theSuffix + "[0]").c_str(),aFocalPnt[0]);
1112 Storable::DataToStream(theStr,(std::string("myFocalPnt") + theSuffix + "[1]").c_str(),aFocalPnt[1]);
1113 Storable::DataToStream(theStr,(std::string("myFocalPnt") + theSuffix + "[2]").c_str(),aFocalPnt[2]);
1116 aCamera->GetViewUp(aViewUp);
1117 Storable::DataToStream(theStr,(std::string("myViewUp") + theSuffix + "[0]").c_str(),aViewUp[0]);
1118 Storable::DataToStream(theStr,(std::string("myViewUp") + theSuffix + "[1]").c_str(),aViewUp[1]);
1119 Storable::DataToStream(theStr,(std::string("myViewUp") + theSuffix + "[2]").c_str(),aViewUp[2]);
1121 vtkFloatingPointType aParallelScale = aCamera->GetParallelScale();
1122 Storable::DataToStream(theStr,(std::string("myParallelScale") + theSuffix).c_str(),aParallelScale);
1124 double aScaleFactor[3];
1125 theViewWindow->GetScale(aScaleFactor);
1126 Storable::DataToStream(theStr,(std::string("myScaleFactor") + theSuffix + "[0]").c_str(),aScaleFactor[0]);
1127 Storable::DataToStream(theStr,(std::string("myScaleFactor") + theSuffix + "[1]").c_str(),aScaleFactor[1]);
1128 Storable::DataToStream(theStr,(std::string("myScaleFactor") + theSuffix + "[2]").c_str(),aScaleFactor[2]);
1131 //---------------------------------------------------------------
1132 /* void SetViewParams(VVTK_MainWindow* theViewWindow,
1133 const char* theSuffix,
1134 const Storable::TRestoringMap& theMap)
1136 vtkFloatingPointType aColor[3];
1137 aColor[0] = Storable::FindValue(theMap,std::string("myColor") + theSuffix + ".R").toDouble();
1138 aColor[1] = Storable::FindValue(theMap,std::string("myColor") + theSuffix + ".G").toDouble();
1139 aColor[2] = Storable::FindValue(theMap,std::string("myColor") + theSuffix + ".B").toDouble();
1140 vtkRenderer* aRenderer = theViewWindow->getRenderer();
1141 aRenderer->SetBackground(aColor);
1143 double aPosition[3];
1144 aPosition[0] = Storable::FindValue(theMap,std::string("myPosition") + theSuffix + "[0]").toDouble();
1145 aPosition[1] = Storable::FindValue(theMap,std::string("myPosition") + theSuffix + "[1]").toDouble();
1146 aPosition[2] = Storable::FindValue(theMap,std::string("myPosition") + theSuffix + "[2]").toDouble();
1147 vtkCamera* aCamera = aRenderer->GetActiveCamera();
1148 aCamera->SetPosition(aPosition);
1150 double aFocalPnt[3];
1151 aFocalPnt[0] = Storable::FindValue(theMap,std::string("myFocalPnt") + theSuffix + "[0]").toDouble();
1152 aFocalPnt[1] = Storable::FindValue(theMap,std::string("myFocalPnt") + theSuffix + "[1]").toDouble();
1153 aFocalPnt[2] = Storable::FindValue(theMap,std::string("myFocalPnt") + theSuffix + "[2]").toDouble();
1154 aCamera->SetFocalPoint(aFocalPnt);
1157 aViewUp[0] = Storable::FindValue(theMap,std::string("myViewUp") + theSuffix + "[0]").toDouble();
1158 aViewUp[1] = Storable::FindValue(theMap,std::string("myViewUp") + theSuffix + "[1]").toDouble();
1159 aViewUp[2] = Storable::FindValue(theMap,std::string("myViewUp") + theSuffix + "[2]").toDouble();
1160 aCamera->SetViewUp(aViewUp);
1162 vtkFloatingPointType aParallelScale = Storable::FindValue(theMap,std::string("myParallelScale") + theSuffix).toDouble();
1163 aCamera->SetParallelScale(aParallelScale);
1165 double aScaleFactor[3];
1166 aScaleFactor[0] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[0]").toDouble();
1167 aScaleFactor[1] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[1]").toDouble();
1168 aScaleFactor[2] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[2]").toDouble();
1169 theViewWindow->SetScale(aScaleFactor);
1172 //---------------------------------------------------------------
1173 /* void GetViewParams(VVTK_MainWindow1* theViewWindow,
1174 std::ostringstream& theStr)
1176 GetViewParams(theViewWindow,"1",theStr);
1178 VISU_WidgetCtrl* aWidgetCtrl = theViewWindow->GetWidgetCtrl();
1179 if(aWidgetCtrl->GetEnabled()){
1180 std::string aSegmentationMode;
1181 if(aWidgetCtrl->IsPlanesActive()){
1182 VISU_PlanesWidget *aPlanesWidget = aWidgetCtrl->GetPlanesWidget();
1183 vtkFloatingPointType anOrigin[3];
1184 aPlanesWidget->GetOrigin(anOrigin);
1185 Storable::DataToStream(theStr,"myCursorOrigin[0]",anOrigin[0]);
1186 Storable::DataToStream(theStr,"myCursorOrigin[1]",anOrigin[1]);
1187 Storable::DataToStream(theStr,"myCursorOrigin[2]",anOrigin[2]);
1189 vtkFloatingPointType aNormal[3];
1190 aPlanesWidget->GetNormal(aNormal);
1191 Storable::DataToStream(theStr,"myCursorNormal[0]",aNormal[0]);
1192 Storable::DataToStream(theStr,"myCursorNormal[1]",aNormal[1]);
1193 Storable::DataToStream(theStr,"myCursorNormal[2]",aNormal[2]);
1195 vtkFloatingPointType aDepth = aPlanesWidget->Distance();
1196 Storable::DataToStream(theStr,"myCursorDepth",aDepth);
1198 aSegmentationMode = "Planes";
1199 }else if(aWidgetCtrl->IsSphereActive()){
1200 VISU_SphereWidget *aSphereWidget = aWidgetCtrl->GetSphereWidget();
1201 vtkFloatingPointType aCenter[3];
1202 aSphereWidget->GetCenter(aCenter);
1203 Storable::DataToStream(theStr,"mySphereCursorCenter[0]",aCenter[0]);
1204 Storable::DataToStream(theStr,"mySphereCursorCenter[1]",aCenter[1]);
1205 Storable::DataToStream(theStr,"mySphereCursorCenter[2]",aCenter[2]);
1207 vtkFloatingPointType aRadius = aSphereWidget->GetRadius();
1208 Storable::DataToStream(theStr,"mySphereCursorRaduis",aRadius);
1210 aSegmentationMode = "Sphere";
1213 Storable::DataToStream(theStr,"mySegmentationMode",aSegmentationMode.c_str());
1217 //---------------------------------------------------------------
1218 /*void SetViewParams(VVTK_MainWindow1* theViewWindow,
1219 const Storable::TRestoringMap& theMap)
1221 SetViewParams(theViewWindow,"1",theMap);
1225 //---------------------------------------------------------------
1226 /*void GetViewParams(VVTK_MainWindow2* theViewWindow,
1227 std::ostringstream& theStr)
1229 GetViewParams(theViewWindow,"2",theStr);
1232 void SetViewParams(VVTK_MainWindow2* theViewWindow,
1233 const Storable::TRestoringMap& theMap)
1235 SetViewParams(theViewWindow,"2",theMap);
1239 //---------------------------------------------------------------
1240 /*std::string GetViewParams(VVTK_ViewWindow* theViewWindow)
1242 std::ostringstream aStream;
1244 Storable::DataToStream(aStream,"myComment","GAUSSVIEW");
1246 SVTK_Selector* aSelector = theViewWindow->GetSelector();
1247 Selection_Mode aSelectionMode = aSelector->SelectionMode();
1248 Storable::DataToStream(aStream,"mySelectionMode",aSelectionMode);
1250 GetViewParams(theViewWindow->getMainWindow1(),aStream);
1251 GetViewParams(theViewWindow->getMainWindow2(),aStream);
1253 return aStream.str();
1256 //---------------------------------------------------------------
1264 myIsSelected(false),
1270 typedef std::map<std::string,TSelection> TVisibleEntries;
1272 struct TGetVisibleEntries
1274 TVisibleEntries& myVisibleEntries;
1276 TGetVisibleEntries(TVisibleEntries& theVisibleEntries):
1277 myVisibleEntries(theVisibleEntries)
1280 void operator()(VISU_GaussPtsAct* theActor)
1282 if(theActor->GetVisibility()){
1283 const Handle(SALOME_InteractiveObject)& anIO = theActor->getIO();
1284 myVisibleEntries.insert(TVisibleEntries::value_type(anIO->getEntry(),TSelection()));
1289 /*void GetGaussPointsSelection(SVTK_ViewWindow* theViewWindow,
1290 TVisibleEntries& theVisibleEntries)
1292 // First find all visible Gauss Points presentations
1293 vtkRenderer* aRenderer = theViewWindow->getRenderer();
1294 vtkActorCollection* anActors = aRenderer->GetActors();
1295 TGetVisibleEntries aGetVisibleEntries(theVisibleEntries);
1296 SVTK::ForEach<VISU_GaussPtsAct>(anActors,
1297 aGetVisibleEntries);
1299 // Next, find the sub-ids for the visible Gauss Points presentations
1300 SVTK_Selector* aSelector = theViewWindow->GetSelector();
1301 const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
1302 SALOME_ListIteratorOfListIO anIter(aListIO);
1303 for(; anIter.More(); anIter.Next()){
1304 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
1305 std::string anEntry = anIO->getEntry();
1306 TVisibleEntries::iterator anEntriesIter = theVisibleEntries.find(anEntry);
1307 if(anEntriesIter != theVisibleEntries.end()){
1308 TSelection& aSelection = anEntriesIter->second;
1309 aSelection.myIsSelected = true;
1310 TColStd_IndexedMapOfInteger anIndexes;
1311 aSelector->GetIndex(anIO,anIndexes);
1312 if(anIndexes.Extent() > 0){
1313 aSelection.myHasSubId = true;
1314 aSelection.mySubId = anIndexes(1);
1321 //---------------------------------------------------------------
1322 inline void CreateReference(_PTR(Study) theStudyDocument,
1323 _PTR(StudyBuilder) theStudyBuilder,
1324 _PTR(SObject) theFatherSObject,
1325 const string& theRefEntry,
1326 const TSelection& theSelection)
1328 _PTR(SObject) aNewObj = theStudyBuilder->NewObject(theFatherSObject);
1329 _PTR(SObject) aRefSObj = theStudyDocument->FindObjectID(theRefEntry);
1330 theStudyBuilder->Addreference(aNewObj,aRefSObj);
1332 std::ostringstream aStream;
1333 Storable::DataToStream(aStream,"myIsSelected",theSelection.myIsSelected);
1334 Storable::DataToStream(aStream,"myHasSubId",theSelection.myHasSubId);
1335 Storable::DataToStream(aStream,"mySubId",theSelection.mySubId);
1337 _PTR(GenericAttribute) anAttr;
1338 anAttr = theStudyBuilder->FindOrCreateAttribute(aNewObj,"AttributeString");
1339 _PTR(AttributeString) aComment(anAttr);
1340 aComment->SetValue(aStream.str());
1344 //---------------------------------------------------------------
1345 /*void SetGaussPointsSelection(VisuGUI* theModule,
1346 SVTK_ViewWindow* theViewWindow,
1347 _PTR(Study) theCStudy,
1348 _PTR(SObject) theSObject)
1350 SVTK_Selector* aSelector = theViewWindow->GetSelector();
1351 aSelector->ClearIObjects();
1353 bool anIsFirst = true;
1354 _PTR(ChildIterator) aChildIter = theCStudy->NewChildIterator(theSObject);
1355 for (; aChildIter->More(); aChildIter->Next()) {
1356 _PTR(SObject) aChildSObject = aChildIter->Value();
1357 _PTR(SObject) aSObject;
1358 if(aChildSObject->ReferencedObject(aSObject)){
1359 CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
1360 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1361 if(VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in())){
1363 VISU::UpdateViewer(theModule, aPrs3d, anIsFirst, false);
1366 // To update selection
1367 Storable::TRestoringMap aMap = Storable::GetStorableMap(aChildSObject);
1369 bool anIsSelected = aMap["myIsSelected"].toInt();
1370 bool aHasSubId = aMap["myHasSubId"].toInt();
1371 int aSubId = aMap["mySubId"].toInt();
1374 std::string anEntry = aSObject->GetID();
1375 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(anEntry.c_str(),"");
1376 aSelector->AddIObject(anIO);
1378 aSelector->AddOrRemoveIndex(anIO,aSubId,false);
1385 aSelector->EndPickCallback(); // To invoke selection changed signal
1389 //---------------------------------------------------------------
1390 /*void OnStoreConfiguration(SalomeApp_Module* theModule,
1393 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1394 if (CheckLock(aCStudy,GetDesktop(theModule)))
1397 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
1399 SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager();
1400 if(aViewManager->getType() == VVTK_Viewer::Type()){
1401 SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
1402 VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
1404 SUIT_Study* aSStudy = aViewManager->study();
1405 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy);
1406 _PTR(Study) aCStudy = aStudy->studyDS();
1407 _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1409 std::string anEntry;
1410 std::string aValue = GetViewParams(aViewWindow);
1413 _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1415 static int myNbConfigs = 0;
1416 std::string aName = VISU::GenerateName("Config.", ++myNbConfigs).toLatin1().data();
1418 std::string aSComponentEntry = aSComponent->GetID();
1419 anEntry = CreateAttributes(aCStudy,
1420 aSComponentEntry.c_str(),
1427 SALOME_ListIO aListIO;
1428 aSelectionMgr->selectedObjects(aListIO);
1429 SALOME_ListIteratorOfListIO aListIter( aListIO );
1430 for(; aListIter.More(); aListIter.Next()){
1431 Handle(SALOME_InteractiveObject) anIO = aListIter.Value();
1432 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1433 _PTR(GenericAttribute) anAttr;
1434 if(aSObject->FindAttribute(anAttr,"AttributeString")){
1435 _PTR(AttributeString) aComment(anAttr);
1436 std::string aCommentValue(aComment->Value());
1437 if(aCommentValue.compare("myComment=GAUSSVIEW") >= 0){
1438 aComment->SetValue(aValue.c_str());
1439 anEntry = aSObject->GetID();
1441 _PTR(ChildIterator) aChildIter = aCStudy->NewChildIterator(aSObject);
1442 for (; aChildIter->More(); aChildIter->Next()) {
1443 _PTR(SObject) aChildSObject = aChildIter->Value();
1444 aStudyBuilder->RemoveObject(aChildSObject);
1453 TVisibleEntries aVisibleEntries;
1454 GetGaussPointsSelection(aViewWindow,
1457 _PTR(SObject) aSObject = aCStudy->FindObjectID(anEntry);
1458 _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1459 TVisibleEntries::const_iterator anIter = aVisibleEntries.begin();
1460 for(; anIter != aVisibleEntries.end(); anIter++){
1461 const std::string& anEntry = anIter->first;
1462 const TSelection& aSelection = anIter->second;
1464 CreateReference(aCStudy,
1471 //UpdateObjBrowser(theModule,true,aSObject);
1472 UpdateObjBrowser(theModule,true);
1478 //---------------------------------------------------------------
1479 /* template<class TMainWindow>
1480 void SetMainWindowParams(VisuGUI* theModule,
1481 _PTR(SObject) theSObject,
1482 VVTK_ViewWindow* theViewWindow,
1483 TMainWindow* theMainWindow)
1485 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1487 Storable::TRestoringMap aMap = Storable::GetStorableMap(theSObject);
1489 SetViewParams(theMainWindow, aMap);
1494 //---------------------------------------------------------------
1495 // void VisuGUI_Module::OnSaveConfiguration()
1497 // ::OnStoreConfiguration(this,true);
1501 //---------------------------------------------------------------
1502 // void VisuGUI_Module::OnOverwriteConfiguration()
1504 // ::OnStoreConfiguration(this,false);
1508 //---------------------------------------------------------------
1509 /*void VisuGUI_Module::OnRestoreConfiguration()
1511 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1513 SALOME_ListIO aListIO;
1514 aSelectionMgr->selectedObjects(aListIO);
1515 if(aListIO.Extent() > 1)
1518 if(SUIT_ViewManager* aViewManager = getViewManager(VVTK_Viewer::Type(),true)){
1519 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1520 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1521 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1522 myConfigSObject = aSObject;
1523 Storable::TRestoringMap aMap = Storable::GetStorableMap(aSObject);
1525 SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView();
1527 Selection_Mode aSelectionMode = Storable::FindValue(aMap,"mySelectionMode").toInt();
1528 SVTK_Selector* aSelector = aViewWindow->GetSelector();
1529 aSelector->SetSelectionMode(aSelectionMode);
1531 SetGaussPointsSelection(this,aViewWindow,aCStudy,aSObject);
1533 std::string aSegmentationMode;
1534 if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
1535 aMainWindow->SetPlanesSegementation(false);
1536 aMainWindow->SetSphereSegementation(false);
1537 VISU_WidgetCtrl* aWidgetCtrl = aMainWindow->GetWidgetCtrl();
1538 aSegmentationMode = Storable::FindValue(aMap,"mySegmentationMode").toLatin1().data();
1540 if(aSegmentationMode == "Planes"){
1541 VISU_PlanesWidget *aPlanesWidget = aWidgetCtrl->GetPlanesWidget();
1542 vtkFloatingPointType anOrigin[3];
1543 anOrigin[0] = Storable::FindValue(aMap,"myCursorOrigin[0]").toDouble();
1544 anOrigin[1] = Storable::FindValue(aMap,"myCursorOrigin[1]").toDouble();
1545 anOrigin[2] = Storable::FindValue(aMap,"myCursorOrigin[2]").toDouble();
1546 aPlanesWidget->SetOrigin(anOrigin);
1548 vtkFloatingPointType aNormal[3];
1549 aNormal[0] = Storable::FindValue(aMap,"myCursorNormal[0]").toDouble();
1550 aNormal[1] = Storable::FindValue(aMap,"myCursorNormal[1]").toDouble();
1551 aNormal[2] = Storable::FindValue(aMap,"myCursorNormal[2]").toDouble();
1552 aPlanesWidget->SetNormal(aNormal);
1554 vtkFloatingPointType aDepth = Storable::FindValue(aMap,"myCursorDepth").toDouble();
1555 aPlanesWidget->SetDistance(aDepth);
1557 aMainWindow->SetPlanesSegementation(true);
1558 }else if(aSegmentationMode == "Sphere"){
1559 VISU_SphereWidget *aSphereWidget = aWidgetCtrl->GetSphereWidget();
1560 vtkFloatingPointType aCenter[3];
1561 aCenter[0] = Storable::FindValue(aMap,"mySphereCursorCenter[0]").toDouble();
1562 aCenter[1] = Storable::FindValue(aMap,"mySphereCursorCenter[1]").toDouble();
1563 aCenter[2] = Storable::FindValue(aMap,"mySphereCursorCenter[2]").toDouble();
1564 aSphereWidget->SetCenter(aCenter);
1566 vtkFloatingPointType aRadius = Storable::FindValue(aMap,"mySphereCursorRaduis").toDouble();
1567 aSphereWidget->SetRadius(aRadius);
1569 aMainWindow->SetSphereSegementation(true);
1573 if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
1574 SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1575 if(anInteractor->isVisible()){
1576 SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1578 anInteractor->installEventFilter(this);
1581 if(aSegmentationMode != ""){
1582 if(VVTK_MainWindow2* aMainWindow = aViewWindow->getMainWindow2()){
1583 SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1584 if(anInteractor->isVisible())
1585 SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1587 anInteractor->installEventFilter(this);
1591 SetGaussPointsSelection(this,aViewWindow,aCStudy,aSObject);
1597 //---------------------------------------------------------------
1598 //bool VisuGUI_Module::eventFilter( QObject * theWatched, QEvent * theEvent )
1600 // bool aRet = VisuGUI::eventFilter(theWatched,theEvent);
1601 // if(theEvent->type() == QEvent::Show){
1602 // if(SUIT_ViewManager* aViewManager = getViewManager(VVTK_Viewer::Type(),false)){
1603 // SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
1604 // VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
1605 // if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
1606 // SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1607 // if(theWatched == anInteractor){
1608 // SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1609 // anInteractor->removeEventFilter(this);
1612 // if(VVTK_MainWindow2* aMainWindow = aViewWindow->getMainWindow2()){
1613 // SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1614 // if(theWatched == aMainWindow->GetInteractor()){
1615 // SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1616 // anInteractor->removeEventFilter(this);
1625 const char gSeparator = '_'; // character used to separate parameter names
1626 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
1628 * \brief Virtual public
1630 * This method is called just before the study document is saved, so the module has a possibility
1631 * to store visual parameters in AttributeParameter attribue(s)
1633 void VisuGUI_Module::storeVisualParameters(int savePoint)
1635 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
1636 if( !study || !study->studyDS() )
1638 _PTR(Study) studyDS = study->studyDS();
1639 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative", moduleName().toLatin1().data(), savePoint);
1640 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1642 // viewers counters are used for storing view_numbers in IParameters
1643 int svtkViewers( 0 ), /*vvtkViewers( 0 ),*/ plotViewers( 0 );
1645 // componentName is used for encoding of entries when storing them in IParameters
1646 _PTR(SComponent) visuEng = ClientFindOrCreateVisuComponent( studyDS );
1647 std::string componentName = visuEng->ComponentDataType();
1649 QList<SUIT_ViewManager*> lst;
1650 QList<SUIT_ViewManager*>::Iterator it;
1652 // saving VVTK viewer parameters. VVTK (Gauss Viewers) are NOT created by SalomeApp since
1653 // VVTK is declared in VISU, so here we store VVTK view window parameters.
1654 // VisuGUI_Module::restoreVisualParameters() creates VVTK_Views and restores its parameters.
1655 /* ip->setProperty( "ActiveGaussViewer", "-1" );
1656 getApp()->viewManagers( VVTK_Viewer::Type(), lst );
1657 for ( it = lst.begin(); it != lst.end(); it++ ) {
1658 if ( SUIT_ViewWindow* vwin = (*it)->getActiveView() ) {
1659 // using predefined string "GaussViewer" as "entry".. it's a hardcoded "workaround".
1660 // gauss viewer parameters are retrieved using this "entry" string.
1661 // name of parameter = caption of gauss ViewWindow
1662 // value of parameter = ViewWindow's visual parameters
1663 ip->setParameter( "GaussViewer",
1664 vwin->windowTitle().toLatin1().data(),
1665 vwin->getVisualParameters().toLatin1().data() );
1667 if ( application()->desktop()->activeWindow() == vwin )
1668 ip->setProperty( "ActiveGaussViewer", QString::number( vvtkViewers ).toLatin1().data() );
1673 // VISU module opens one SVTK viewer in activateModule(). This causes a bug in save-restore visual
1674 // parameters: it no SVTK view was saved, we need NOT any SVTK on restore. Here we store if any is open..
1677 getApp()->viewManagers( SVTK_Viewer::Type(), lst );
1678 ip->setProperty( "VtkViewersCount", QString::number( lst.count() ).latin1() );
1681 // main cycle to store parameters of displayed objects
1683 getApp()->viewManagers( lst );
1684 /*vvtkViewers = */svtkViewers = plotViewers = 0;
1685 for ( it = lst.begin(); it != lst.end(); it++ ) {
1686 SUIT_ViewManager* vman = *it;
1687 QString vType = vman->getType();
1688 int* viewsCounter = vType == SVTK_Viewer::Type() ? &svtkViewers :
1689 //vType == VVTK_Viewer::Type() ? &vvtkViewers :
1690 vType == SPlot2d_Viewer::Type() ? &plotViewers : 0;
1692 // saving VTK actors' properties
1693 if ( vType == SVTK_Viewer::Type() /*|| // processing SVTK and VVTK viewers in the same
1694 vType == VVTK_Viewer::Type()*/ ) { // way (VVTK_ViewWindow inherits SVTK_ViewWindow)
1696 QVector<SUIT_ViewWindow*> views = vman->getViews();
1697 for ( int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++ ) {
1698 if ( SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>( views[i] ) ) {
1699 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
1700 vtkActorCollection* allActors = aCopy.GetActors();
1701 allActors->InitTraversal();
1702 while ( vtkActor* actor = allActors->GetNextActor() ) {
1703 if ( actor->GetVisibility() ) { // store only visible actors
1704 if ( VISU_Actor* vActor = VISU_Actor::SafeDownCast( actor ) ) {
1705 if ( vActor->hasIO() ) { // actor corresponds to existing obj
1707 Handle(SALOME_InteractiveObject) io = vActor->getIO();
1708 // entry is "ecoded" = it does NOT contain component adress, since it is a
1709 // subject to change on next component loading
1710 std::string entry = ip->encodeEntry( io->getEntry(), componentName );
1712 std::string param, vtkParam = vType.toLatin1().data();
1713 vtkParam += gSeparator;
1714 vtkParam += QString::number( *viewsCounter ).toLatin1().data();
1715 vtkParam += gSeparator;
1717 param = vtkParam + "Visibility";
1718 ip->setParameter( entry, param, "On" );
1719 param = vtkParam + "Name";
1720 ip->setParameter( entry, param, vActor->getName() );
1721 param = vtkParam + "RepresentationMode";
1722 ip->setParameter( entry, param, QString::number( vActor->GetRepresentation() ).toLatin1().data() );
1723 param = vtkParam + "Quadratic2DRepresentation";
1724 ip->setParameter( entry, param, QString::number( vActor->GetQuadratic2DRepresentation() ).toLatin1().data() );
1725 param = vtkParam + "Opacity";
1726 ip->setParameter( entry, param, QString::number( vActor->GetOpacity() ).toLatin1().data() );
1727 vtkFloatingPointType r, g, b;
1728 vActor->GetColor(r, g, b);
1729 QString colorStr = QString::number( r ); colorStr += gDigitsSep;
1730 colorStr += QString::number( g ); colorStr += gDigitsSep;
1731 colorStr += QString::number( b );
1732 param = vtkParam + "Color";
1733 ip->setParameter( entry, param, colorStr.toLatin1().data() );
1734 param = vtkParam + "LineWidth";
1735 ip->setParameter( entry, param, QString::number( vActor->GetLineWidth() ).toLatin1().data() );
1736 if ( vActor->IsShrunkable() && vActor->IsShrunk() ) {
1737 param = vtkParam + "ShrinkMode";
1738 ip->setParameter( entry, param, "On" );
1739 param = vtkParam + "ShrinkFactor";
1740 ip->setParameter( entry, param, QString::number( vActor->GetShrinkFactor() ).toLatin1().data() );
1742 VISU_ScalarMapAct* scalarMapActor = dynamic_cast<VISU_ScalarMapAct*>( vActor );
1743 if ( scalarMapActor && scalarMapActor->IsShading() ) {
1744 param = vtkParam + "Shading";
1745 ip->setParameter( entry, param, "On" );
1747 if ( const VISU::Prs3d_i* vPrs = vActor->GetPrs3d() ) {
1748 param = vtkParam + "ClippingPlane";
1749 int nPlanes = vPrs->GetNumberOfClippingPlanes();
1751 ip->setParameter( entry, param, "Off" );
1752 for ( int p = 0; p < nPlanes; p++ ) {
1753 vtkPlane* plane = vPrs->GetClippingPlane( p );
1754 vtkFloatingPointType normal[3], origin[3];
1755 plane->GetNormal( normal );
1756 plane->GetOrigin( origin );
1757 std::string planeValue = QString::number( normal[0] ).toLatin1().data(); planeValue += gDigitsSep;
1758 planeValue += QString::number( normal[1] ).toLatin1().data(); planeValue += gDigitsSep;
1759 planeValue += QString::number( normal[2] ).toLatin1().data(); planeValue += gDigitsSep;
1760 planeValue += QString::number( origin[0] ).toLatin1().data(); planeValue += gDigitsSep;
1761 planeValue += QString::number( origin[1] ).toLatin1().data(); planeValue += gDigitsSep;
1762 planeValue += QString::number( origin[2] ).toLatin1().data();
1763 param = QString( "%1ClippingPlane_%2" ).arg( vtkParam.c_str() ).arg( p+1 ).toLatin1().data();
1764 ip->setParameter( entry, param, planeValue );
1769 } // salome_actor successfull downcast to the VISU_Actor
1770 else if ( VISU_PointMap3dActor* vActor = VISU_PointMap3dActor::SafeDownCast( actor ) ) { // PointMap3D
1771 if ( vActor->hasIO() ) { // actor corresponds to existing obj
1772 Handle(SALOME_InteractiveObject) io = vActor->getIO();
1773 // entry is "ecoded" = it does NOT contain component adress, since it is a
1774 // subject to change on next component loading
1775 std::string entry = ip->encodeEntry( io->getEntry(), componentName );
1776 std::string param, vtkParam = vType.toLatin1().data();
1777 vtkParam += gSeparator;
1778 vtkParam += QString::number( *viewsCounter ).toLatin1().data();
1779 vtkParam += gSeparator;
1781 param = vtkParam + "Visibility";
1782 ip->setParameter( entry, param, "On" );
1783 param = vtkParam + "Name";
1784 ip->setParameter( entry, param, vActor->getName() );
1785 param = vtkParam + "RepresentationMode";
1786 ip->setParameter( entry, param, QString::number( vActor->GetRepresentation() ).toLatin1().data() );
1787 param = vtkParam + "Opacity";
1788 ip->setParameter( entry, param, QString::number( vActor->GetOpacity() ).toLatin1().data() );
1789 vtkFloatingPointType r, g, b;
1790 vActor->GetColor(r, g, b);
1791 QString colorStr = QString::number( r ); colorStr += gDigitsSep;
1792 colorStr += QString::number( g ); colorStr += gDigitsSep;
1793 colorStr += QString::number( b );
1794 param = vtkParam + "Color";
1795 ip->setParameter( entry, param, colorStr.toLatin1().data() );
1796 param = vtkParam + "LineWidth";
1797 ip->setParameter( entry, param, QString::number( vActor->GetLineWidth() ).toLatin1().data() );
1798 if ( vActor->IsShrunkable() && vActor->IsShrunk() ) {
1799 param = vtkParam + "ShrinkMode";
1800 ip->setParameter( entry, param, "On" );
1801 param = vtkParam + "ShrinkFactor";
1802 ip->setParameter( entry, param, QString::number( vActor->GetShrinkFactor() ).toLatin1().data() );
1805 } // salome actor is downcasted to the VISU_PointMap3dActor
1807 } // end of ..while.. actors traversal
1811 } // if ( SVTK view model )
1812 else if ( vType == SPlot2d_Viewer::Type() ) { // processing Plot2d viewers
1813 QVector<SUIT_ViewWindow*> views = vman->getViews();
1814 for ( int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++ ) {
1815 if ( Plot2d_ViewWindow* plotView = dynamic_cast<Plot2d_ViewWindow*>( views[i] ) ) {
1816 Plot2d_ViewFrame* plotVF = plotView->getViewFrame();
1817 QList<Plot2d_Curve*> curves;
1818 QList<Plot2d_Curve*>::Iterator itCurve;
1819 plotVF->getCurves( curves );
1821 //Plot2d_Curve* curve;
1822 for ( itCurve = curves.begin(); itCurve != curves.end(); itCurve++ ) {
1823 if ( SPlot2d_Curve* sCurve = dynamic_cast<SPlot2d_Curve*>( *itCurve ) ) {
1824 if ( sCurve->hasIO() ) {
1826 Handle(SALOME_InteractiveObject) io = sCurve->getIO();
1827 // entry is "ecoded" = it does NOT contain component adress, since it is a
1828 // subject to change on next component loading
1829 std::string entry = ip->encodeEntry( io->getEntry(), componentName );
1831 std::string param, plotParam = vType.toLatin1().data(); plotParam += gSeparator;
1832 plotParam += QString::number( *viewsCounter ).toLatin1().data(); plotParam += gSeparator;
1834 param = plotParam + "Visibility";
1835 ip->setParameter( entry, param, "On" );
1839 } // if ( plotView )
1842 } // if ( SPlot2d view model )
1846 const int ViewerType = 0;
1847 const int ViewIndex = 1;
1848 const int ParamName = 2;
1849 // visual parameters are stored in strings as follows:
1850 // ViewerType_ViewNumber_ParamName. '_' is used as separator and should not be used in
1851 // viewer type or parameter names
1853 // return viewer type substring from parameter name
1854 std::string getParam( const std::string& paramName, const int index )
1856 QStringList lst = QString( paramName.c_str() ).split( gSeparator, QString::SkipEmptyParts );
1857 if ( !lst.isEmpty() && index < lst.size() )
1858 return lst[index].toLatin1().data();
1864 * \brief Virtual public
1866 * This method is called after the study document is opened, so the module has a possibility to restore
1869 void VisuGUI_Module::restoreVisualParameters(int savePoint)
1871 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
1872 if( !study || !study->studyDS() )
1874 _PTR(Study) studyDS = study->studyDS();
1875 _PTR(AttributeParameter) ap =
1876 studyDS->GetModuleParameters("Interface Applicative", moduleName().toLatin1().data(), savePoint);
1877 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1879 // actors are stored in a map after displaying of them for quicker access in future
1880 QMap<QString, QMap<QString, VISU_Actor*> > vtkActors; // map: entry to map: ViewType_<ID> to actor (SVTK/VVTK)
1882 std::vector<std::string> entries = ip->getEntries();
1884 for ( std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt ) {
1886 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
1887 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
1888 std::vector<std::string>::iterator namesIt = paramNames.begin();
1889 std::vector<std::string>::iterator valuesIt = paramValues.begin();
1891 // if ( *entIt == "GaussViewer" ) {
1892 // // parameter names are view window's captions, values - visual parameters.
1893 // for ( ; namesIt != paramNames.end(); ++namesIt, ++valuesIt ) {
1894 // SUIT_ViewManager* vman = onCreateViewManager();
1895 // SUIT_ViewWindow* vwin = vman->getActiveView();
1896 // vwin->setWindowTitle( (*namesIt).c_str() );
1898 // // wait untill the window is really shown. This step fixes MANY bugs..
1899 // while ( !vwin->isVisible() )
1900 // qApp->processEvents();
1902 // vwin->setVisualParameters( (*valuesIt).c_str() );
1904 // continue; // skip to next entry
1907 // entry is a normal entry - it should be "decoded" (setting base adress of component)
1908 QString entry( ip->decodeEntry( *entIt ).c_str() );
1910 //SRN: Added a check that the entry corresponds to Standard_Real object in the Study
1911 // as the object may be deleted or modified after the visual state is saved.
1912 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
1913 if(!so) continue; //Skip the not existent entry
1915 for ( ; namesIt != paramNames.end(); ++namesIt, ++valuesIt ) {
1916 std::string viewerType = ::getParam( *namesIt, ViewerType );
1918 std::string paramName = ::getParam( *namesIt, ParamName );
1920 std::string viewIndexStr = ::getParam( *namesIt, ViewIndex );
1921 int viewIndex = QString( viewIndexStr.c_str() ).toUInt( &ok );
1922 if ( !ok ) // bad conversion of view index to integer
1925 // cout << " -- " << viewerType << ": entry = " << entry.latin1() << ", paramName = " << paramName << endl;
1927 if ( viewerType == SVTK_Viewer::Type().toLatin1().data() /*||
1928 viewerType == VVTK_Viewer::Type().toLatin1().data()*/ ) {
1930 // used as inner map key for locating the actor.
1931 QString viewerTypeIndex = QString( viewerType.c_str() ) + QString::number( viewIndex );
1933 if ( paramName == "Visibility" && displayer() ) {
1934 // if VVTK, then we must create viewer first, because
1936 QList<SUIT_ViewManager*> lst;
1937 getApp()->viewManagers( viewerType.c_str(), lst );
1939 // SVTK/VVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
1940 if ( viewIndex >= 0 && viewIndex < lst.count() ) {
1941 SUIT_ViewManager* vman = lst.at( viewIndex );
1942 SUIT_ViewModel* vmodel = vman->getViewModel();
1943 // both SVTK and VVTK view models can be casted to SALOME_View
1944 displayer()->Display( entry, true, dynamic_cast<SALOME_View*>( vmodel ) );
1946 // store displayed actor in a temporary map for quicker access later when restoring other parameters
1947 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
1948 QMap<QString, VISU_Actor*> viewActorMap;
1949 if ( vtkActors.contains( entry ) )
1950 viewActorMap = vtkActors[ entry ];
1951 viewActorMap[ viewerTypeIndex ] = FindActor( GetAppStudy(this), vtkView, entry );
1952 vtkActors[ entry ] = viewActorMap;
1955 else { // the rest properties "work" with VISU_Actor, so we initialize it at first
1956 VISU_Actor* vActor = 0;
1957 if ( vtkActors.contains( entry ) ) {
1958 QMap<QString, VISU_Actor*> viewActorMap = vtkActors[ entry ];
1959 if ( viewActorMap.contains( viewerTypeIndex ) )
1960 vActor = viewActorMap[ viewerTypeIndex ];
1965 QString val( (*valuesIt).c_str() );
1967 if ( paramName == "Name" )
1968 vActor->setName( val.toLatin1().data() );
1970 else if ( paramName == "RepresentationMode" )
1971 vActor->SetRepresentation( val.toInt() );
1973 else if (paramName == "Quadratic2DRepresentation")
1974 vActor->SetQuadratic2DRepresentation(VISU_Actor::EQuadratic2DRepresentation(val.toInt()));
1976 else if ( paramName == "Opacity" )
1977 vActor->SetOpacity( val.toFloat() );
1979 else if ( paramName == "Color" ) {
1980 QStringList colors = val.split( gDigitsSep, QString::SkipEmptyParts );
1981 if ( colors.count() == 3 )
1982 vActor->SetColor( colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat() );
1985 else if ( paramName == "LineWidth" )
1986 vActor->SetLineWidth( val.toFloat() );
1988 else if ( paramName == "ShrinkMode" ) {
1989 vActor->SetShrinkable( true );
1990 vActor->SetShrink();
1993 else if ( paramName == "ShrunkFactor" )
1994 vActor->SetShrinkFactor( val.toFloat() );
1996 else if ( paramName == "Shading" ) {
1997 if ( VISU_ScalarMapAct* scalarMapActor = dynamic_cast<VISU_ScalarMapAct*>( vActor ) )
1998 scalarMapActor->SetShading();
2001 else if ( paramName.find( "ClippingPlane" ) != std::string::npos ) {
2002 VISU::Prs3d_i* prs = vActor->GetPrs3d();
2006 //prs->RemoveAllClippingPlanes();
2007 for (int i = prs->GetNumberOfClippingPlanes() - 1; i >= 0 ; i--) {
2008 OrientedPlane* aPlane = dynamic_cast<OrientedPlane*>(prs->GetClippingPlane(i));
2010 prs->RemoveClippingPlane(i);
2012 if ( val != "Off" ) {
2013 QStringList vals = val.split( gDigitsSep, QString::SkipEmptyParts );
2014 if ( vals.count() == 6 ) { // format check: 6 float values
2015 vtkFloatingPointType normal[3], origin[3];
2016 for (int x = 0; x < 3; x++ ) {
2017 normal[x] = vals[x].toFloat();
2018 origin[x] = vals[x+3].toFloat();
2020 OrientedPlane* plane = OrientedPlane::New();
2021 plane->SetNormal( normal );
2022 plane->SetOrigin( origin );
2023 prs->AddClippingPlane( plane );
2031 else if ( viewerType == SPlot2d_Viewer::Type().toLatin1().data() ) {
2033 if ( paramName == "Visibility" && displayer() ) {
2034 QList<SUIT_ViewManager*> lst;
2035 getApp()->viewManagers( viewerType.c_str(), lst );
2037 if ( viewIndex >= 0 && viewIndex < lst.count() ) {
2038 SUIT_ViewManager* vman = lst.at( viewIndex );
2039 SUIT_ViewModel* vmodel = vman->getViewModel();
2040 // SVTK and VVTK view models can be casted to SALOME_View
2041 displayer()->Display( entry, true, dynamic_cast<SALOME_View*>( vmodel ) );
2047 } // for names/parameters iterator
2048 } // for entries iterator
2050 // [ update all SVTK/VVTK/Plot2D views
2051 QList<SUIT_ViewManager*> lst;
2052 getApp()->viewManagers( lst );
2053 for ( QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++ ) {
2054 SUIT_ViewModel* vmodel = (*it)->getViewModel();
2057 if ( vmodel->getType() == SVTK_Viewer::Type() /*|| // processing SVTK and VVTK viewers
2058 vmodel->getType() == VVTK_Viewer::Type()*/ ) { // in the same way
2059 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
2060 vtkView->getRenderer()->ResetCameraClippingRange();
2063 else if ( vmodel->getType() == SPlot2d_Viewer::Type().toLatin1().data() ) {
2064 Plot2d_ViewWindow* plotView = (Plot2d_ViewWindow*) (*it)->getActiveView();
2065 plotView->getViewFrame()->Repaint();
2067 } // ] end of update views
2069 // VISU module opens one SVTK viewer in activateModule(). This causes a bug in save-restore visual
2070 // parameters: it no SVTK view was saved, we need NOT any SVTK on restore. Here we close one
2071 // default SVTK if needed.
2073 QString openedSvtkViewerStr = ip->getProperty( "VtkViewersCount" ).c_str();
2074 int openedSvtkViewer = openedSvtkViewerStr.toInt( &ok );
2075 if ( ok && openedSvtkViewer == 0 ) {
2077 getApp()->viewManagers( SVTK_Viewer::Type(), lst );
2079 lst.at( 0 )->closeAllViews();
2083 // if active Gauss Viewer is set ( != -1) then raise the gauss view window.
2085 // QString activeGaussViewerStr = ip->getProperty( "ActiveGaussViewer" ).c_str();
2086 // int activeGaussViewer = activeGaussViewerStr.toInt( &ok );
2087 // if ( ok && activeGaussViewer != -1 ) {
2089 // getApp()->viewManagers( VVTK_Viewer::Type(), lst );
2090 // if ( activeGaussViewer >= 0 && activeGaussViewer < lst.count() ) {
2091 // SUIT_ViewWindow* activeView = lst.at( activeGaussViewer )->getActiveView();
2092 // if ( activeView ) {
2093 // activeView->activateWindow();
2094 // //activeView->setFocus();