1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 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
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.hxx"
42 #include "SalomeApp_Application.h"
43 #include "LightApp_SelectionMgr.h"
44 #include "LightApp_VTKSelector.h"
45 #include "LightApp_Preferences.h"
46 #include "LightApp_Displayer.h"
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_MainWindow.h"
58 #include "SVTK_RenderWindowInteractor.h"
59 #include "VISU_Event.h"
61 #include "VisuGUI_Prs3dTools.h"
62 #include "VisuGUI_ClippingDlg.h"
64 #include "VISU_GaussPoints_i.hh"
65 #include "VISU_GaussPtsAct.h"
66 #include "VisuGUI_GaussPointsDlg.h"
68 #include "VisuGUI_Slider.h"
70 #include "VISU_Gen_i.hh"
71 #include "VISU_Result_i.hh"
72 #include "VISU_CutLines_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>
129 static int MYDEBUG = 0;
131 static int MYDEBUG = 0;
134 #define SAVE_VISU_STATE 5090
136 #define GAUSS_NEW_VIEWER 5100
137 #define GAUSS_CREATE_PRS 5200
138 #define GAUSS_RENAME 5210
139 #define GAUSS_EDIT_PRS 5300
140 #define GAUSS_COPY_PRS 5310
141 #define GAUSS_ERASE_PRS 5400
142 #define GAUSS_DISPLAY_PRS 5500
143 #define GAUSS_DISPLAY_ONLY_PRS 5600
145 #define GAUSS_SAVE_CONFIGURATION 5700
146 #define GAUSS_OVERWRITE_CONFIGURATION 5701
147 #define GAUSS_RESTORE_CONFIGURATION 5702
148 #define GAUSS_RENAME_CONFIGURATION 5703
151 CreateCurves( SalomeApp_Module* theModule,
152 VISU::CutLines_i* thePrs,
154 const bool theCreate = true );
156 using namespace VISU;
160 //---------------------------------------------------------------
161 typedef void (SUIT_ViewWindow::* TViewVisibility)();
163 SetViewVisibility(SalomeApp_Application* app,
164 TViewVisibility theViewVisibility)
167 app->viewManagers( VVTK_Viewer::Type(), l );
168 ViewManagerList::const_iterator anIt = l.begin(), aLast = l.end();
169 for( ; anIt!=aLast; anIt++ )
170 if( SUIT_ViewManager* aViewManager = *anIt )
172 QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
173 int aSize = aViews.size();
174 for(int anId = 0; anId < aSize; anId++)
176 if(SUIT_ViewWindow* aView = aViews[anId])
177 (aView->* theViewVisibility)();
183 //---------------------------------------------------------------
191 //---------------------------------------------------------------
198 //---------------------------------------------------------------
201 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" ), QIconSet(),
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 = VVTK_Viewer::Type();
235 SUIT_Accel* accel = getApp()->accel();
236 accel->setActionKey( SUIT_Accel::PanLeft, Key_Left, aViewerType );
237 accel->setActionKey( SUIT_Accel::PanRight, Key_Right, aViewerType );
238 accel->setActionKey( SUIT_Accel::PanUp, Key_Up, aViewerType );
239 accel->setActionKey( SUIT_Accel::PanDown, Key_Down, aViewerType );
240 accel->setActionKey( SUIT_Accel::ZoomIn, Key_PageUp, aViewerType );
241 accel->setActionKey( SUIT_Accel::ZoomOut, Key_PageDown, aViewerType );
242 accel->setActionKey( SUIT_Accel::RotateLeft, CTRL+Key_Left, aViewerType );
243 accel->setActionKey( SUIT_Accel::RotateRight, CTRL+Key_Right, aViewerType );
244 accel->setActionKey( SUIT_Accel::RotateUp, CTRL+Key_Up, aViewerType );
245 accel->setActionKey( SUIT_Accel::RotateDown, CTRL+Key_Down, aViewerType );
246 accel->setActionKey( SVTK::PlusSpeedIncrementEvent, Key_Plus, aViewerType );
247 accel->setActionKey( SVTK::MinusSpeedIncrementEvent, 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'} ",
268 createMenu( action( GAUSS_CREATE_PRS ), createMenu( tr( "MEN_VISUALISATION" ), -1 ), -1 );
269 createTool( GAUSS_CREATE_PRS, createTool( tr( "TOOL_VISUALISATION" ) ), -1 );
271 createAction( GAUSS_RENAME, VisuGUI::tr("MEN_RENAME"), QIconSet(),
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'",
279 createAction( GAUSS_EDIT_PRS, VisuGUI::tr("MEN_EDIT_PRS"), QIconSet(),
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'",
287 createAction( GAUSS_COPY_PRS, VisuGUI::tr("MEN_COPY_PRS"), QIconSet(),
288 VisuGUI::tr("MEN_COPY_PRS"), "", 0, this, false,
289 this, SLOT(OnCopyPresentation()));
290 mgr->insert( action( GAUSS_COPY_PRS ), -1, 0, -1 );
291 mgr->setRule( action( GAUSS_COPY_PRS ),
292 "selcount=1 and type='VISU::TGAUSSPOINTS'",
294 action( GAUSS_COPY_PRS )->setEnabled(false);
298 #ifndef DISABLE_OCCVIEWER
299 #ifndef DISABLE_SALOMEOBJECT
300 viewers.append( SOCC_Viewer::Type() );
302 viewers.append( OCCViewer_Viewer::Type() );
305 #ifndef DISABLE_VTKVIEWER
306 #ifndef DISABLE_SALOMEOBJECT
307 viewers.append( SVTK_Viewer::Type() );
308 viewers.append( VVTK_Viewer::Type() );
310 viewers.append( VTKViewer_Viewer::Type() );
313 #ifndef DISABLE_PLOT2DVIEWER
314 #ifndef DISABLE_SALOMEOBJECT
315 viewers.append( SPlot2d_Viewer::Type() );
317 viewers.append( Plot2d_Viewer::Type() );
321 if( !viewers.isEmpty() )
323 QString strViewers = "{ ", temp = "'%1' ";
324 QStringList::const_iterator anIt = viewers.begin(), aLast = viewers.end();
325 for( ; anIt!=aLast; anIt++ )
326 strViewers+=temp.arg( *anIt );
328 mgr->setRule( action(myEraseAll), QString( "client in %1" ).arg( strViewers ), true );
331 aRule = "(selcount>0 and type='VISU::TGAUSSPOINTS')";
333 createAction( GAUSS_ERASE_PRS, VisuGUI::tr("MEN_HIDE"), QIconSet(),
334 VisuGUI::tr("MEN_HIDE"), "", 0, this, false,
335 this, SLOT(OnErasePrs()));
336 mgr->insert( action( GAUSS_ERASE_PRS ), -1, -1, -1 ); // erase
337 mgr->setRule( action( GAUSS_ERASE_PRS ),
338 aRule + " and ({true} in $canBeDisplayed) and (isVisible=true)", true );
340 createAction( GAUSS_DISPLAY_PRS, VisuGUI::tr("MEN_SHOW"), QIconSet(),
341 VisuGUI::tr("MEN_SHOW"), "", 0, this, false,
342 this, SLOT(OnDisplayPrs()));
343 mgr->insert( action( GAUSS_DISPLAY_PRS ), -1, -1, -1 ); // display
344 mgr->setRule( action( GAUSS_DISPLAY_PRS ),
345 aRule + " and ({true} in $canBeDisplayed) and (isVisible=false)", true );
347 createAction( GAUSS_DISPLAY_ONLY_PRS, VisuGUI::tr("MEN_DISPLAY_ONLY"), QIconSet(),
348 VisuGUI::tr("MEN_DISPLAY_ONLY"), "", 0, this, false,
349 this, SLOT(OnDisplayOnlyPrs()));
350 mgr->insert( action( GAUSS_DISPLAY_ONLY_PRS ), -1, -1, -1 ); // display only
351 mgr->setRule( action( GAUSS_DISPLAY_ONLY_PRS ),
352 aRule + " and ({true} in $canBeDisplayed)", true );
354 createAction( GAUSS_RENAME_CONFIGURATION, VisuGUI::tr("MEN_RENAME"), QIconSet(),
355 VisuGUI::tr("MEN_RENAME"), "", 0, this, false,
356 this, SLOT(OnRename()));
357 mgr->insert( action( GAUSS_RENAME_CONFIGURATION ), -1, -1, -1 );
358 mgr->setRule( action( GAUSS_RENAME_CONFIGURATION ), "selcount=1 and type='VISU::TGAUSSVIEW'", true );
360 createAction( GAUSS_SAVE_CONFIGURATION, tr("MEN_SAVE_CONFIGURATION"), QIconSet(),
361 tr("MEN_SAVE_CONFIGURATION"), "", 0, this, false,
362 this, SLOT(OnSaveConfiguration()));
363 mgr->insert( action( GAUSS_SAVE_CONFIGURATION ), -1, -1, -1 );
364 mgr->setRule( action( GAUSS_SAVE_CONFIGURATION ),
365 "selcount>=0 and client='VVTK' and activeView='VVTK'", true );
367 createAction( GAUSS_OVERWRITE_CONFIGURATION, tr("MEN_OVERWRITE_CONFIGURATION"), QIconSet(),
368 tr("MEN_OVERWRITE_CONFIGURATION"), "", 0, this, false,
369 this, SLOT(OnOverwriteConfiguration()));
370 mgr->insert( action( GAUSS_OVERWRITE_CONFIGURATION ), -1, -1, -1 );
371 mgr->setRule( action( GAUSS_OVERWRITE_CONFIGURATION ),
372 "selcount>0 and type='VISU::TGAUSSVIEW' and activeView='VVTK'", true );
374 createAction( GAUSS_RESTORE_CONFIGURATION, tr("MEN_RESTORE_CONFIGURATION"), QIconSet(),
375 tr("MEN_RESTORE_CONFIGURATION"), "", 0, this, false,
376 this, SLOT(OnRestoreConfiguration()));
377 mgr->insert( action( GAUSS_RESTORE_CONFIGURATION ), -1, -1, -1 );
378 mgr->setRule( action( GAUSS_RESTORE_CONFIGURATION ),
379 "selcount=1 and type='VISU::TGAUSSVIEW'", true );
382 //---------------------------------------------------------------
385 activateModule( SUIT_Study* theStudy )
387 VisuGUI::activateModule( theStudy );
389 SetViewVisibility(getApp(),&SUIT_ViewWindow::show);
395 //---------------------------------------------------------------
398 deactivateModule( SUIT_Study* theStudy )
400 VisuGUI::deactivateModule( theStudy );
402 SetViewVisibility(getApp(),&SUIT_ViewWindow::hide);
408 //---------------------------------------------------------------
411 onCreateViewManager()
413 SalomeApp_Application* anApp = getApp();
414 SUIT_ResourceMgr* aResourceMgr = anApp->resourceMgr();
415 VVTK_ViewManager* aViewManager = new VVTK_ViewManager( anApp->activeStudy(), anApp->desktop() );
416 VVTK_Viewer* aViewer = (VVTK_Viewer*)aViewManager->getViewModel();
417 aViewer->setBackgroundColor( aResourceMgr->colorValue( "VTKViewer", "background", aViewer->backgroundColor() ) );
418 aViewer->setTrihedronSize( aResourceMgr->integerValue( "VTKViewer", "trihedron_size", aViewer->trihedronSize() ),
419 aResourceMgr->booleanValue( "VTKViewer", "relative_size", aViewer->trihedronRelative() ) );
420 new LightApp_VTKSelector( aViewer, anApp->selectionMgr() );
421 anApp->addViewManager( aViewManager );
423 VVTK_ViewWindow* aViewWindow = ( VVTK_ViewWindow* )aViewManager->createViewWindow();
426 new VisuGUI_Slider( this, aViewWindow, anApp->selectionMgr() );
429 return aViewer->getViewManager();
433 //---------------------------------------------------------------
438 VisuGUI::createPreferences();
440 createGaussPointsPreferences();
441 createInsideCursorPreferences();
442 createOutsideCursorPreferences();
443 createPickingPreferences();
444 createSpaceMousePreferences();
445 createRecorderPreferences();
449 //---------------------------------------------------------------
452 createGaussPointsPreferences()
454 int gaussTab = addPreference( tr( "VISU_GAUSS_PREF_TAB_TTL" ) );
455 int primitiveGr = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_GROUP_TTL" ), gaussTab );
456 setPreferenceProperty( primitiveGr, "columns", 1 );
458 int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr,
459 LightApp_Preferences::Selector, "VISU",
460 "point_sprite_primitive_type" );
463 values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) );
464 values.append( tr( "VISU_GAUSS_PREF_OPENGLPOINT" ) );
465 values.append( tr( "VISU_GAUSS_PREF_GEOMSPHERE" ) );
466 QValueList<QVariant> indices;
470 setPreferenceProperty( primitiveTypePref, "strings", values );
471 setPreferenceProperty( primitiveTypePref, "indexes", indices );
473 int clampPref = addPreference( tr( "VISU_GAUSS_PREF_CLAMP" ), primitiveGr,
474 LightApp_Preferences::IntSpin, "VISU", "point_sprite_clamp" );
475 setPreferenceProperty( clampPref, "min", 1 );
476 setPreferenceProperty( clampPref, "max", 512 );
478 addPreference( tr( "VISU_GAUSS_PREF_MAIN_TEXTURE" ), primitiveGr,
479 LightApp_Preferences::File, "VISU", "point_sprite_main_texture" );
481 addPreference( tr( "VISU_GAUSS_PREF_ALPHA_TEXTURE" ), primitiveGr,
482 LightApp_Preferences::File, "VISU", "point_sprite_alpha_texture" );
484 int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr,
485 LightApp_Preferences::DblSpin, "VISU",
486 "point_sprite_alpha_threshold" );
487 setPreferenceProperty( alphaThresholdPref, "min", 0.0 );
488 setPreferenceProperty( alphaThresholdPref, "max", 1.0 );
489 setPreferenceProperty( alphaThresholdPref, "step", 0.1 );
491 int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr,
492 LightApp_Preferences::IntSpin, "VISU", "geom_sphere_resolution" );
493 setPreferenceProperty( resolutionPref, "min", 3 );
494 setPreferenceProperty( resolutionPref, "max", 100 );
496 int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr,
497 LightApp_Preferences::IntSpin, "VISU", "geom_sphere_face_limit" );
498 setPreferenceProperty( faceLimitPref, "min", 10 );
499 setPreferenceProperty( faceLimitPref, "max", 1000000 );
501 int sizeGr = addPreference( tr( "VISU_GAUSS_PREF_SIZE_GROUP_TTL" ), gaussTab );
502 setPreferenceProperty( sizeGr, "columns", 2 );
504 int minSizePref = addPreference( tr( "VISU_GAUSS_PREF_MIN_SIZE" ), sizeGr,
505 LightApp_Preferences::IntSpin, "VISU", "point_sprite_min_size" );
506 setPreferenceProperty( minSizePref, "min", 1 );
507 setPreferenceProperty( minSizePref, "max", 100 );
509 int maxSizePref = addPreference( tr( "VISU_GAUSS_PREF_MAX_SIZE" ), sizeGr,
510 LightApp_Preferences::IntSpin, "VISU", "point_sprite_max_size" );
511 setPreferenceProperty( maxSizePref, "min", 1 );
512 setPreferenceProperty( maxSizePref, "max", 100 );
514 int magnificationPref = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION" ), sizeGr,
515 LightApp_Preferences::IntSpin, "VISU",
516 "point_sprite_magnification" );
517 setPreferenceProperty( magnificationPref, "min", 10 );
518 setPreferenceProperty( magnificationPref, "max", 1000 );
520 int incrementPref = addPreference( tr( "VISU_GAUSS_PREF_INCREMENT" ), sizeGr,
521 LightApp_Preferences::DblSpin, "VISU", "point_sprite_increment" );
522 setPreferenceProperty( incrementPref, "min", 0.01 );
523 setPreferenceProperty( incrementPref, "max", 10 );
524 setPreferenceProperty( incrementPref, "step", 0.1 );
526 int geomGr = addPreference( tr( "VISU_GAUSS_PREF_GEOM_GROUP_TTL" ), gaussTab );
527 setPreferenceProperty( geomGr, "columns", 1 );
529 int sizePref = addPreference( tr( "VISU_GAUSS_PREF_SIZE" ), geomGr,
530 LightApp_Preferences::IntSpin, "VISU", "point_sprite_size" );
531 setPreferenceProperty( sizePref, "min", 1 );
532 setPreferenceProperty( sizePref, "max", 100 );
534 addPreference( tr( "VISU_GAUSS_PREF_COLOR" ), geomGr,
535 LightApp_Preferences::Color, "VISU", "point_sprite_color" );
537 // ScalarBar Preferences
538 int scalarBarGr = addPreference( tr( "VISU_GAUSS_SCALAR_BAR_PREF_GROUP_TTL" ), gaussTab );
539 setPreferenceProperty( scalarBarGr, "columns", 1 );
541 int activeBarPref = addPreference( tr( "VISU_GAUSS_PREF_ACTIVE_BAR" ), scalarBarGr,
542 LightApp_Preferences::Selector, "VISU", "scalar_bar_active_local" );
545 values.append( tr( "VISU_GAUSS_PREF_LOCAL" ) );
546 values.append( tr( "VISU_GAUSS_PREF_GLOBAL" ) );
550 setPreferenceProperty( activeBarPref, "strings", values );
551 setPreferenceProperty( activeBarPref, "indexes", indices );
553 addPreference( tr( "VISU_GAUSS_PREF_DISPLAY_GLOBAL" ), scalarBarGr,
554 LightApp_Preferences::Bool, "VISU", "scalar_bar_display_global" );
556 int colorPref = addPreference( tr( "VISU_GAUSS_PREF_SCALAR_BAR_MODE" ), scalarBarGr,
557 LightApp_Preferences::Selector, "VISU", "scalar_bar_bicolor" );
560 values.append( tr( "VISU_GAUSS_PREF_BICOLOR" ) );
561 values.append( tr( "VISU_GAUSS_PREF_RAINBOW" ) );
565 setPreferenceProperty( colorPref, "strings", values );
566 setPreferenceProperty( colorPref, "indexes", indices );
568 int spacingPref = addPreference( tr( "VISU_GAUSS_PREF_SPACING" ), scalarBarGr,
569 LightApp_Preferences::DblSpin, "VISU", "scalar_bar_spacing" );
570 setPreferenceProperty( spacingPref, "min", 0.01 );
571 setPreferenceProperty( spacingPref, "max", 1.0 );
572 setPreferenceProperty( spacingPref, "step", 0.01 );
576 //---------------------------------------------------------------
579 createInsideCursorPreferences()
581 int insideCursorTab = addPreference( tr( "VISU_GAUSS_INSIDE_CURSOR_PREF_TAB_TTL" ) );
583 int primitiveGr = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_GROUP_TTL" ), insideCursorTab );
584 setPreferenceProperty( primitiveGr, "columns", 1 );
586 int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr,
587 LightApp_Preferences::Selector, "VISU",
588 "inside_point_sprite_primitive_type" );
591 values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) );
592 values.append( tr( "VISU_GAUSS_PREF_OPENGLPOINT" ) );
593 values.append( tr( "VISU_GAUSS_PREF_GEOMSPHERE" ) );
594 QValueList<QVariant> indices;
598 setPreferenceProperty( primitiveTypePref, "strings", values );
599 setPreferenceProperty( primitiveTypePref, "indexes", indices );
601 int clampPref = addPreference( tr( "VISU_GAUSS_PREF_CLAMP" ), primitiveGr,
602 LightApp_Preferences::IntSpin, "VISU", "inside_point_sprite_clamp" );
603 setPreferenceProperty( clampPref, "min", 1 );
604 setPreferenceProperty( clampPref, "max", 512 );
606 addPreference( tr( "VISU_GAUSS_PREF_MAIN_TEXTURE" ), primitiveGr,
607 LightApp_Preferences::File, "VISU", "inside_point_sprite_main_texture" );
609 addPreference( tr( "VISU_GAUSS_PREF_ALPHA_TEXTURE" ), primitiveGr,
610 LightApp_Preferences::File, "VISU", "inside_point_sprite_alpha_texture" );
612 int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr,
613 LightApp_Preferences::DblSpin, "VISU",
614 "inside_point_sprite_alpha_threshold" );
615 setPreferenceProperty( alphaThresholdPref, "min", 0.0 );
616 setPreferenceProperty( alphaThresholdPref, "max", 1.0 );
617 setPreferenceProperty( alphaThresholdPref, "step", 0.1 );
619 int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr,
620 LightApp_Preferences::IntSpin, "VISU",
621 "inside_geom_sphere_resolution" );
622 setPreferenceProperty( resolutionPref, "min", 3 );
623 setPreferenceProperty( resolutionPref, "max", 100 );
625 int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr,
626 LightApp_Preferences::IntSpin, "VISU",
627 "inside_geom_sphere_face_limit" );
628 setPreferenceProperty( faceLimitPref, "min", 10 );
629 setPreferenceProperty( faceLimitPref, "max", 1000000 );
631 int sizeGr = addPreference( tr( "VISU_GAUSS_PREF_SIZE_GROUP_TTL" ), insideCursorTab );
632 setPreferenceProperty( sizeGr, "columns", 2 );
634 int minSizePref = addPreference( tr( "VISU_GAUSS_PREF_MIN_SIZE" ), sizeGr,
635 LightApp_Preferences::IntSpin, "VISU",
636 "inside_point_sprite_min_size" );
637 setPreferenceProperty( minSizePref, "min", 1 );
638 setPreferenceProperty( minSizePref, "max", 100 );
640 int maxSizePref = addPreference( tr( "VISU_GAUSS_PREF_MAX_SIZE" ), sizeGr,
641 LightApp_Preferences::IntSpin, "VISU",
642 "inside_point_sprite_max_size" );
643 setPreferenceProperty( maxSizePref, "min", 1 );
644 setPreferenceProperty( maxSizePref, "max", 100 );
646 int magnificationGr = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION_GROUP_TTL" ), insideCursorTab );
647 setPreferenceProperty( magnificationGr, "columns", 2 );
649 int magnificationPref = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION" ), magnificationGr,
650 LightApp_Preferences::IntSpin, "VISU",
651 "inside_point_sprite_magnification" );
652 setPreferenceProperty( magnificationPref, "min", 10 );
653 setPreferenceProperty( magnificationPref, "max", 1000 );
655 int incrementPref = addPreference( tr( "VISU_GAUSS_PREF_INCREMENT" ), magnificationGr,
656 LightApp_Preferences::DblSpin, "VISU",
657 "inside_point_sprite_increment" );
658 setPreferenceProperty( incrementPref, "min", 0.01 );
659 setPreferenceProperty( incrementPref, "max", 10 );
660 setPreferenceProperty( incrementPref, "step", 0.1 );
664 //---------------------------------------------------------------
667 createOutsideCursorPreferences()
669 int outsideCursorTab = addPreference( tr( "VISU_GAUSS_OUTSIDE_CURSOR_PREF_TAB_TTL" ) );
671 int primitiveGr = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_GROUP_TTL" ), outsideCursorTab );
672 setPreferenceProperty( primitiveGr, "columns", 1 );
674 int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr,
675 LightApp_Preferences::Selector, "VISU",
676 "outside_point_sprite_primitive_type" );
679 values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) );
680 values.append( tr( "VISU_GAUSS_PREF_OPENGLPOINT" ) );
681 values.append( tr( "VISU_GAUSS_PREF_GEOMSPHERE" ) );
682 QValueList<QVariant> indices;
686 setPreferenceProperty( primitiveTypePref, "strings", values );
687 setPreferenceProperty( primitiveTypePref, "indexes", indices );
689 int clampPref = addPreference( tr( "VISU_GAUSS_PREF_CLAMP" ), primitiveGr,
690 LightApp_Preferences::IntSpin, "VISU", "outside_point_sprite_clamp" );
691 setPreferenceProperty( clampPref, "min", 1 );
692 setPreferenceProperty( clampPref, "max", 512 );
694 addPreference( tr( "VISU_GAUSS_PREF_MAIN_TEXTURE" ), primitiveGr,
695 LightApp_Preferences::File, "VISU", "outside_point_sprite_main_texture" );
697 addPreference( tr( "VISU_GAUSS_PREF_ALPHA_TEXTURE" ), primitiveGr,
698 LightApp_Preferences::File, "VISU", "outside_point_sprite_alpha_texture" );
700 int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr,
701 LightApp_Preferences::DblSpin, "VISU",
702 "outside_point_sprite_alpha_threshold" );
703 setPreferenceProperty( alphaThresholdPref, "min", 0.0 );
704 setPreferenceProperty( alphaThresholdPref, "max", 1.0 );
705 setPreferenceProperty( alphaThresholdPref, "step", 0.1 );
707 int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr,
708 LightApp_Preferences::IntSpin, "VISU",
709 "outside_geom_sphere_resolution" );
710 setPreferenceProperty( resolutionPref, "min", 3 );
711 setPreferenceProperty( resolutionPref, "max", 100 );
713 int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr,
714 LightApp_Preferences::IntSpin, "VISU",
715 "outside_geom_sphere_face_limit" );
716 setPreferenceProperty( faceLimitPref, "min", 10 );
717 setPreferenceProperty( faceLimitPref, "max", 1000000 );
719 int sizeGr = addPreference( tr( "VISU_GAUSS_PREF_SIZE_GROUP_TTL" ), outsideCursorTab );
721 int sizePref = addPreference( tr( "VISU_GAUSS_PREF_SIZE" ), sizeGr,
722 LightApp_Preferences::IntSpin, "VISU", "outside_point_sprite_size" );
723 setPreferenceProperty( sizePref, "min", 1 );
724 setPreferenceProperty( sizePref, "max", 100 );
726 int colorGr = addPreference( tr( "VISU_GAUSS_PREF_COLOR_GROUP_TTL" ), outsideCursorTab );
727 setPreferenceProperty( colorGr, "columns", 1 );
729 addPreference( tr( "VISU_GAUSS_PREF_UNIFORM_COLOR" ), colorGr,
730 LightApp_Preferences::Bool, "VISU", "outside_point_sprite_uniform" );
732 addPreference( tr( "VISU_GAUSS_PREF_COLOR" ), colorGr,
733 LightApp_Preferences::Color, "VISU", "outside_point_sprite_color" );
737 //---------------------------------------------------------------
740 createPickingPreferences()
742 int pickingTab = addPreference( tr( "VISU_PICKING_PREF_TAB_TTL" ) );
745 int cursorGr = addPreference( tr( "VISU_PICKING_PREF_CURSOR_GROUP_TTL" ), pickingTab );
746 setPreferenceProperty( cursorGr, "columns", 1 );
748 int cursorSizePref = addPreference( tr( "VISU_PICKING_PREF_CURSOR_SIZE" ), cursorGr,
749 LightApp_Preferences::DblSpin, "VISU", "picking_cursor_size" );
750 setPreferenceProperty( cursorSizePref, "min", 0 );
751 setPreferenceProperty( cursorSizePref, "max", 1.0 );
752 setPreferenceProperty( cursorSizePref, "step", 0.1 );
754 int pyramidHeightPref = addPreference( tr( "VISU_PICKING_PREF_PYRAMID_HEIGHT" ), cursorGr,
755 LightApp_Preferences::DblSpin, "VISU", "picking_pyramid_height" );
756 setPreferenceProperty( pyramidHeightPref, "min", 1 );
757 setPreferenceProperty( pyramidHeightPref, "max", 100 );
759 /*int selectionColorPref = */
760 addPreference( tr( "VISU_PICKING_PREF_SELECTION_COLOR" ), cursorGr,
761 LightApp_Preferences::Color, "VISU", "picking_selection_color" );
764 int toleranceGr = addPreference( tr( "VISU_PICKING_PREF_TOLERANCE_GROUP_TTL" ), pickingTab );
766 int pointTolerancePref = addPreference( tr( "VISU_PICKING_PREF_POINT_SELECTION_TOLERANCE" ), toleranceGr,
767 LightApp_Preferences::DblSpin, "VISU", "picking_point_tolerance" );
768 setPreferenceProperty( pointTolerancePref, "min", 0.001 );
769 setPreferenceProperty( pointTolerancePref, "max", 10 );
770 setPreferenceProperty( pointTolerancePref, "step", 0.01 );
773 int infoWindowGr = addPreference( tr( "VISU_PICKING_PREF_INFO_WINDOW_GROUP_TTL" ), pickingTab );
774 setPreferenceProperty( infoWindowGr, "columns", 1 );
776 int transparencyPref = addPreference( tr( "VISU_PICKING_PREF_TRANSPARENCY" ), infoWindowGr,
777 LightApp_Preferences::IntSpin, "VISU", "picking_transparency" );
778 setPreferenceProperty( transparencyPref, "min", 0 );
779 setPreferenceProperty( transparencyPref, "max", 100 );
780 setPreferenceProperty( transparencyPref, "step", 10 );
782 int positionPref = addPreference( tr( "VISU_PICKING_PREF_POSITION" ), infoWindowGr,
783 LightApp_Preferences::Selector, "VISU", "picking_position" );
785 values.append( tr( "VISU_PICKING_PREF_BELOW_POINT" ) );
786 values.append( tr( "VISU_PICKING_PREF_TOP_LEFT_CORNER" ) );
787 QValueList<QVariant> indices;
790 setPreferenceProperty( positionPref, "strings", values );
791 setPreferenceProperty( positionPref, "indexes", indices );
794 int cameraGr = addPreference( tr( "VISU_PICKING_PREF_CAMERA_GROUP_TTL" ), pickingTab );
795 setPreferenceProperty( cameraGr, "columns", 1 );
797 int zoomFactorPref = addPreference( tr( "VISU_PICKING_PREF_ZOOM_FACTOR" ), cameraGr,
798 LightApp_Preferences::DblSpin, "VISU", "picking_zoom_factor" );
799 setPreferenceProperty( zoomFactorPref, "min", 0.1 );
800 setPreferenceProperty( zoomFactorPref, "max", 10.0 );
801 setPreferenceProperty( zoomFactorPref, "step", 0.1 );
803 int stepNumberPref = addPreference( tr( "VISU_PICKING_PREF_STEP_NUMBER" ), cameraGr,
804 LightApp_Preferences::IntSpin, "VISU", "picking_step_number" );
805 setPreferenceProperty( stepNumberPref, "min", 1 );
806 setPreferenceProperty( stepNumberPref, "max", 100 );
808 // Display parent mesh
809 int parentMeshGr = addPreference( tr( "VISU_PICKING_PREF_PARENT_MESH_TTL" ), pickingTab );
810 setPreferenceProperty( parentMeshGr, "columns", 1 );
812 addPreference( tr( "VISU_PICKING_PREF_DISPLAY_PARENT_MESH" ), parentMeshGr,
813 LightApp_Preferences::Bool, "VISU", "picking_display_parent_mesh" );
817 //---------------------------------------------------------------
820 createSpaceMousePreferences()
822 int mouseTab = addPreference( tr( "VISU_MOUSE_PREF_TAB_TLT" ) );
824 int mouseGr = addPreference( tr( "VISU_MOUSE_PREF_GROUP_TLT" ), mouseTab );
825 int mousePref = addPreference( tr( "VISU_MOUSE_PREF" ), mouseGr,
826 LightApp_Preferences::Selector, "VISU", "mouse_behaviour" );
828 values.append( tr( "VISU_MOUSE_PREF_STANDARD" ) );
829 values.append( tr( "VISU_MOUSE_PREF_KEYBOARD_FREE" ) );
830 QValueList<QVariant> indices;
833 setPreferenceProperty( mousePref, "strings", values );
834 setPreferenceProperty( mousePref, "indexes", indices );
836 int keybrdGr = addPreference( tr( "VISU_KEYBOARD_PREF_GROUP_TTL" ), mouseTab );
837 int keybrdPref = addPreference( tr( "VISU_KEYBOARD_PREF" ), keybrdGr,
838 LightApp_Preferences::IntSpin, "VISU", "speed_increment" );
839 setPreferenceProperty( keybrdPref, "max", 1000 );
841 int spacemouseGr = addPreference( tr( "VISU_SPACEMOUSE_PREF" ), mouseTab );
842 setPreferenceProperty( spacemouseGr, "columns", 1 );
843 int spacemousePref1 = addPreference( tr( "VISU_SPACEMOUSE_PREF_1" ), spacemouseGr,
844 LightApp_Preferences::Selector, "VISU",
845 "spacemouse_func1_btn" ); //decrease_speed_increment
846 int spacemousePref2 = addPreference( tr( "VISU_SPACEMOUSE_PREF_2" ), spacemouseGr,
847 LightApp_Preferences::Selector, "VISU",
848 "spacemouse_func2_btn" ); //increase_speed_increment
849 int spacemousePref3 = addPreference( tr( "VISU_SPACEMOUSE_PREF_3" ), spacemouseGr,
850 LightApp_Preferences::Selector, "VISU",
851 "spacemouse_func3_btn" ); //decrease_gauss_point_magnification
852 int spacemousePref4 = addPreference( tr( "VISU_SPACEMOUSE_PREF_4" ), spacemouseGr,
853 LightApp_Preferences::Selector, "VISU",
854 "spacemouse_func4_btn" ); //increase_gauss_point_magnification
855 int spacemousePref5 = addPreference( tr( "VISU_SPACEMOUSE_PREF_5" ), spacemouseGr,
856 LightApp_Preferences::Selector, "VISU",
857 "spacemouse_func5_btn" ); //dominant_combined_switch
859 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_1" ) );
860 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_2" ) );
861 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_3" ) );
862 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_4" ) );
863 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_5" ) );
864 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_6" ) );
865 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_7" ) );
866 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_8" ) );
867 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_*" ) );
868 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_10" ) );
869 values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_11" ) );
879 indices.append( 9 ); // == button_*
880 indices.append( 10 );
881 indices.append( 11 );
882 setPreferenceProperty( spacemousePref1, "strings", values );
883 setPreferenceProperty( spacemousePref1, "indexes", indices );
884 setPreferenceProperty( spacemousePref2, "strings", values );
885 setPreferenceProperty( spacemousePref2, "indexes", indices );
886 setPreferenceProperty( spacemousePref3, "strings", values );
887 setPreferenceProperty( spacemousePref3, "indexes", indices );
888 setPreferenceProperty( spacemousePref4, "strings", values );
889 setPreferenceProperty( spacemousePref4, "indexes", indices );
890 setPreferenceProperty( spacemousePref5, "strings", values );
891 setPreferenceProperty( spacemousePref5, "indexes", indices );
895 //---------------------------------------------------------------
898 createRecorderPreferences()
900 int recorderTab = addPreference( tr( "VISU_RECORDER_PREF_TAB_TTL" ) );
902 int recorderGr = addPreference( tr( "VISU_RECORDER_PREF_GROUP_TTL" ), recorderTab );
903 setPreferenceProperty( recorderGr, "columns", 1 );
905 int modePref = addPreference( tr( "VISU_RECORDER_PREF_RECORDING_MODE" ), recorderGr,
906 LightApp_Preferences::Selector, "VISU", "recorder_mode" );
908 values.append( tr( "VISU_RECORDER_PREF_SKIPPED_FRAMES" ) );
909 values.append( tr( "VISU_RECORDER_PREF_ALL_DISLPAYED_FRAMES" ) );
910 QValueList<QVariant> indices;
913 setPreferenceProperty( modePref, "strings", values );
914 setPreferenceProperty( modePref, "indexes", indices );
916 int fpsPref = addPreference( tr( "VISU_RECORDER_PREF_FPS" ), recorderGr,
917 LightApp_Preferences::DblSpin, "VISU", "recorder_fps" );
918 setPreferenceProperty( fpsPref, "min", 0.1 );
919 setPreferenceProperty( fpsPref, "max", 100 );
921 int qualityPref = addPreference( tr( "VISU_RECORDER_PREF_QUALITY" ), recorderGr,
922 LightApp_Preferences::IntSpin, "VISU", "recorder_quality" );
923 setPreferenceProperty( qualityPref, "min", 1 );
924 setPreferenceProperty( qualityPref, "max", 100 );
926 addPreference( tr( "VISU_RECORDER_PREF_PROGRESSIVE" ), recorderGr,
927 LightApp_Preferences::Bool, "VISU", "recorder_progressive" );
931 //---------------------------------------------------------------
934 OnCreateGaussPoints()
936 double initialTime = vtkTimerLog::GetCPUTime();
937 CreatePrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg, 1>(this, VVTK_Viewer::Type());
938 INFOS( "VisuGUI_Module::OnCreateGaussPoints() : Gauss Points created in " <<
939 vtkTimerLog::GetCPUTime() - initialTime << " seconds" );
944 OnViewManagerAdded(SUIT_ViewManager* viewMgr)
946 QString type = viewMgr->getViewModel()->getType();
947 if ( type == VVTK_Viewer::Type() )
948 connect( viewMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
949 this, SLOT( OnViewCreated( SUIT_ViewWindow* ) ) );
954 OnViewCreated(SUIT_ViewWindow* view)
956 SVTK_ViewWindow* viewWindow = dynamic_cast<SVTK_ViewWindow*>( view );
958 setProperty( viewWindow, "speed_increment" );
959 setProperty( viewWindow, "spacemouse_func1_btn" );
960 setProperty( viewWindow, "spacemouse_func2_btn" );
961 setProperty( viewWindow, "spacemouse_func3_btn" );
962 setProperty( viewWindow, "spacemouse_func4_btn" );
963 setProperty( viewWindow, "spacemouse_func5_btn" );
969 setProperty( SVTK_ViewWindow* viewWindow, const QString& pref )
974 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
975 SVTK_MainWindow* aMainWindow = viewWindow->getMainWindow();
977 if ( pref == "speed_increment" ) {
978 val = resMgr->integerValue( "VISU", pref, 10 );
979 aMainWindow->InvokeEvent( SVTK::SetSpeedIncrementEvent, &val );
981 else if ( pref == "spacemouse_func1_btn" ) {
982 val = resMgr->integerValue( "VISU", pref, 1 );
983 aMainWindow->InvokeEvent( SVTK::SetSMDecreaseSpeedEvent, &val );
985 else if ( pref == "spacemouse_func2_btn" ) {
986 val = resMgr->integerValue( "VISU", pref, 2 );
987 aMainWindow->InvokeEvent( SVTK::SetSMIncreaseSpeedEvent, &val );
989 else if ( pref == "spacemouse_func3_btn" ) {
990 val = resMgr->integerValue( "VISU", pref, 10 );
991 aMainWindow->InvokeEvent( VISU::SetSMDecreaseMagnificationEvent, &val );
993 else if ( pref == "spacemouse_func4_btn" ) {
994 val = resMgr->integerValue( "VISU", pref, 11 );
995 aMainWindow->InvokeEvent( VISU::SetSMIncreaseMagnificationEvent, &val );
997 else if ( pref == "spacemouse_func5_btn" ) {
998 val = resMgr->integerValue( "VISU", pref, 9 );
999 aMainWindow->InvokeEvent( SVTK::SetSMDominantCombinedSwitchEvent, &val );
1005 setProperty( SVTK_ViewManager* vm, const QString& prop )
1010 QPtrVector<SUIT_ViewWindow> windows = vm->getViews();
1011 for ( int n = windows.count(), i = 0; i < n; i++ )
1012 setProperty( dynamic_cast<SVTK_ViewWindow*>( windows[i] ), prop );
1017 preferencesChanged( const QString& group, const QString& pref )
1019 VisuGUI::preferencesChanged(group,pref);
1021 if ( group == "VISU" && ( pref == "speed_increment" || pref == "spacemouse_func1_btn" ||
1022 pref == "spacemouse_func2_btn" || pref == "spacemouse_func3_btn" ||
1023 pref == "spacemouse_func4_btn" || pref == "spacemouse_func5_btn" ) ) {
1025 // update properties of VVTK view windows
1026 SUIT_ViewManager* vm = getApp()->getViewManager( VVTK_Viewer::Type(), false );
1028 setProperty( dynamic_cast<SVTK_ViewManager*>( vm ), pref );
1033 //---------------------------------------------------------------
1036 getViewManager(const QString& theType,
1037 const bool theIsCreate)
1039 if (SUIT_ViewManager* aViewManager = VisuGUI::getViewManager(theType,theIsCreate))
1040 return aViewManager;
1042 if (theIsCreate && theType == VVTK_Viewer::Type())
1043 return onCreateViewManager();
1048 //---------------------------------------------------------------
1053 VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
1054 if(aSelectionInfo.empty())
1057 VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
1058 Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
1060 if(VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dToModify(this, aSelectionItem.myObjectInfo.myBase)){
1061 // Create VVTK_ViewWindow, if it does not exist
1062 if (VVTK_ViewWindow* aViewWindow = GetViewWindow<VVTK_Viewer>(this)) {
1063 EditPrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg, 1>(this, anIO, aPrs3d, aViewWindow);
1069 //---------------------------------------------------------------
1073 GetViewParams(VVTK_MainWindow* theViewWindow,
1074 const char* theSuffix,
1075 std::ostringstream& theStr)
1077 vtkFloatingPointType aColor[3];
1078 vtkRenderer* aRenderer = theViewWindow->getRenderer();
1079 aRenderer->GetBackground(aColor);
1080 Storable::DataToStream(theStr,(std::string("myColor") + theSuffix + ".R").c_str(),aColor[0]);
1081 Storable::DataToStream(theStr,(std::string("myColor") + theSuffix + ".G").c_str(),aColor[1]);
1082 Storable::DataToStream(theStr,(std::string("myColor") + theSuffix + ".B").c_str(),aColor[2]);
1084 double aPosition[3];
1085 vtkCamera* aCamera = aRenderer->GetActiveCamera();
1086 aCamera->GetPosition(aPosition);
1087 Storable::DataToStream(theStr,(std::string("myPosition") + theSuffix + "[0]").c_str(),aPosition[0]);
1088 Storable::DataToStream(theStr,(std::string("myPosition") + theSuffix + "[1]").c_str(),aPosition[1]);
1089 Storable::DataToStream(theStr,(std::string("myPosition") + theSuffix + "[2]").c_str(),aPosition[2]);
1091 double aFocalPnt[3];
1092 aCamera->GetFocalPoint(aFocalPnt);
1093 Storable::DataToStream(theStr,(std::string("myFocalPnt") + theSuffix + "[0]").c_str(),aFocalPnt[0]);
1094 Storable::DataToStream(theStr,(std::string("myFocalPnt") + theSuffix + "[1]").c_str(),aFocalPnt[1]);
1095 Storable::DataToStream(theStr,(std::string("myFocalPnt") + theSuffix + "[2]").c_str(),aFocalPnt[2]);
1098 aCamera->GetViewUp(aViewUp);
1099 Storable::DataToStream(theStr,(std::string("myViewUp") + theSuffix + "[0]").c_str(),aViewUp[0]);
1100 Storable::DataToStream(theStr,(std::string("myViewUp") + theSuffix + "[1]").c_str(),aViewUp[1]);
1101 Storable::DataToStream(theStr,(std::string("myViewUp") + theSuffix + "[2]").c_str(),aViewUp[2]);
1103 vtkFloatingPointType aParallelScale = aCamera->GetParallelScale();
1104 Storable::DataToStream(theStr,(std::string("myParallelScale") + theSuffix).c_str(),aParallelScale);
1106 double aScaleFactor[3];
1107 theViewWindow->GetScale(aScaleFactor);
1108 Storable::DataToStream(theStr,(std::string("myScaleFactor") + theSuffix + "[0]").c_str(),aScaleFactor[0]);
1109 Storable::DataToStream(theStr,(std::string("myScaleFactor") + theSuffix + "[1]").c_str(),aScaleFactor[1]);
1110 Storable::DataToStream(theStr,(std::string("myScaleFactor") + theSuffix + "[2]").c_str(),aScaleFactor[2]);
1113 //---------------------------------------------------------------
1115 SetViewParams(VVTK_MainWindow* theViewWindow,
1116 const char* theSuffix,
1117 const Storable::TRestoringMap& theMap)
1119 vtkFloatingPointType aColor[3];
1120 aColor[0] = Storable::FindValue(theMap,std::string("myColor") + theSuffix + ".R").toDouble();
1121 aColor[1] = Storable::FindValue(theMap,std::string("myColor") + theSuffix + ".G").toDouble();
1122 aColor[2] = Storable::FindValue(theMap,std::string("myColor") + theSuffix + ".B").toDouble();
1123 vtkRenderer* aRenderer = theViewWindow->getRenderer();
1124 aRenderer->SetBackground(aColor);
1126 double aPosition[3];
1127 aPosition[0] = Storable::FindValue(theMap,std::string("myPosition") + theSuffix + "[0]").toDouble();
1128 aPosition[1] = Storable::FindValue(theMap,std::string("myPosition") + theSuffix + "[1]").toDouble();
1129 aPosition[2] = Storable::FindValue(theMap,std::string("myPosition") + theSuffix + "[2]").toDouble();
1130 vtkCamera* aCamera = aRenderer->GetActiveCamera();
1131 aCamera->SetPosition(aPosition);
1133 double aFocalPnt[3];
1134 aFocalPnt[0] = Storable::FindValue(theMap,std::string("myFocalPnt") + theSuffix + "[0]").toDouble();
1135 aFocalPnt[1] = Storable::FindValue(theMap,std::string("myFocalPnt") + theSuffix + "[1]").toDouble();
1136 aFocalPnt[2] = Storable::FindValue(theMap,std::string("myFocalPnt") + theSuffix + "[2]").toDouble();
1137 aCamera->SetFocalPoint(aFocalPnt);
1140 aViewUp[0] = Storable::FindValue(theMap,std::string("myViewUp") + theSuffix + "[0]").toDouble();
1141 aViewUp[1] = Storable::FindValue(theMap,std::string("myViewUp") + theSuffix + "[1]").toDouble();
1142 aViewUp[2] = Storable::FindValue(theMap,std::string("myViewUp") + theSuffix + "[2]").toDouble();
1143 aCamera->SetViewUp(aViewUp);
1145 vtkFloatingPointType aParallelScale = Storable::FindValue(theMap,std::string("myParallelScale") + theSuffix).toDouble();
1146 aCamera->SetParallelScale(aParallelScale);
1148 double aScaleFactor[3];
1149 aScaleFactor[0] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[0]").toDouble();
1150 aScaleFactor[1] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[1]").toDouble();
1151 aScaleFactor[2] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[2]").toDouble();
1152 theViewWindow->SetScale(aScaleFactor);
1155 //---------------------------------------------------------------
1157 GetViewParams(VVTK_MainWindow1* theViewWindow,
1158 std::ostringstream& theStr)
1160 GetViewParams(theViewWindow,"1",theStr);
1162 VISU_WidgetCtrl* aWidgetCtrl = theViewWindow->GetWidgetCtrl();
1163 if(aWidgetCtrl->GetEnabled()){
1164 std::string aSegmentationMode;
1165 if(aWidgetCtrl->IsPlanesActive()){
1166 VISU_PlanesWidget *aPlanesWidget = aWidgetCtrl->GetPlanesWidget();
1167 vtkFloatingPointType anOrigin[3];
1168 aPlanesWidget->GetOrigin(anOrigin);
1169 Storable::DataToStream(theStr,"myCursorOrigin[0]",anOrigin[0]);
1170 Storable::DataToStream(theStr,"myCursorOrigin[1]",anOrigin[1]);
1171 Storable::DataToStream(theStr,"myCursorOrigin[2]",anOrigin[2]);
1173 vtkFloatingPointType aNormal[3];
1174 aPlanesWidget->GetNormal(aNormal);
1175 Storable::DataToStream(theStr,"myCursorNormal[0]",aNormal[0]);
1176 Storable::DataToStream(theStr,"myCursorNormal[1]",aNormal[1]);
1177 Storable::DataToStream(theStr,"myCursorNormal[2]",aNormal[2]);
1179 vtkFloatingPointType aDepth = aPlanesWidget->Distance();
1180 Storable::DataToStream(theStr,"myCursorDepth",aDepth);
1182 aSegmentationMode = "Planes";
1183 }else if(aWidgetCtrl->IsSphereActive()){
1184 VISU_SphereWidget *aSphereWidget = aWidgetCtrl->GetSphereWidget();
1185 vtkFloatingPointType aCenter[3];
1186 aSphereWidget->GetCenter(aCenter);
1187 Storable::DataToStream(theStr,"mySphereCursorCenter[0]",aCenter[0]);
1188 Storable::DataToStream(theStr,"mySphereCursorCenter[1]",aCenter[1]);
1189 Storable::DataToStream(theStr,"mySphereCursorCenter[2]",aCenter[2]);
1191 vtkFloatingPointType aRadius = aSphereWidget->GetRadius();
1192 Storable::DataToStream(theStr,"mySphereCursorRaduis",aRadius);
1194 aSegmentationMode = "Sphere";
1197 Storable::DataToStream(theStr,"mySegmentationMode",aSegmentationMode.c_str());
1201 //---------------------------------------------------------------
1203 SetViewParams(VVTK_MainWindow1* theViewWindow,
1204 const Storable::TRestoringMap& theMap)
1206 SetViewParams(theViewWindow,"1",theMap);
1210 //---------------------------------------------------------------
1212 GetViewParams(VVTK_MainWindow2* theViewWindow,
1213 std::ostringstream& theStr)
1215 GetViewParams(theViewWindow,"2",theStr);
1219 SetViewParams(VVTK_MainWindow2* theViewWindow,
1220 const Storable::TRestoringMap& theMap)
1222 SetViewParams(theViewWindow,"2",theMap);
1226 //---------------------------------------------------------------
1228 GetViewParams(VVTK_ViewWindow* theViewWindow)
1230 std::ostringstream aStream;
1232 Storable::DataToStream(aStream,"myComment","GAUSSVIEW");
1234 SVTK_Selector* aSelector = theViewWindow->GetSelector();
1235 Selection_Mode aSelectionMode = aSelector->SelectionMode();
1236 Storable::DataToStream(aStream,"mySelectionMode",aSelectionMode);
1238 GetViewParams(theViewWindow->getMainWindow1(),aStream);
1239 GetViewParams(theViewWindow->getMainWindow2(),aStream);
1241 return aStream.str();
1244 //---------------------------------------------------------------
1252 myIsSelected(false),
1258 typedef std::map<std::string,TSelection> TVisibleEntries;
1260 struct TGetVisibleEntries
1262 TVisibleEntries& myVisibleEntries;
1264 TGetVisibleEntries(TVisibleEntries& theVisibleEntries):
1265 myVisibleEntries(theVisibleEntries)
1269 operator()(VISU_GaussPtsAct* theActor)
1271 if(theActor->GetVisibility()){
1272 const Handle(SALOME_InteractiveObject)& anIO = theActor->getIO();
1273 myVisibleEntries.insert(TVisibleEntries::value_type(anIO->getEntry(),TSelection()));
1279 GetGaussPointsSelection(VVTK_ViewWindow* theViewWindow,
1280 TVisibleEntries& theVisibleEntries)
1282 // First find all visible Gauss Points presentations
1283 vtkRenderer* aRenderer = theViewWindow->getRenderer();
1284 vtkActorCollection* anActors = aRenderer->GetActors();
1285 TGetVisibleEntries aGetVisibleEntries(theVisibleEntries);
1286 SVTK::ForEach<VISU_GaussPtsAct>(anActors,
1287 aGetVisibleEntries);
1289 // Next, find the sub-ids for the visible Gauss Points presentations
1290 SVTK_Selector* aSelector = theViewWindow->GetSelector();
1291 const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
1292 SALOME_ListIteratorOfListIO anIter(aListIO);
1293 for(; anIter.More(); anIter.Next()){
1294 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
1295 std::string anEntry = anIO->getEntry();
1296 TVisibleEntries::iterator anEntriesIter = theVisibleEntries.find(anEntry);
1297 if(anEntriesIter != theVisibleEntries.end()){
1298 TSelection& aSelection = anEntriesIter->second;
1299 aSelection.myIsSelected = true;
1300 TColStd_IndexedMapOfInteger anIndexes;
1301 aSelector->GetIndex(anIO,anIndexes);
1302 if(anIndexes.Extent() > 0){
1303 aSelection.myHasSubId = true;
1304 aSelection.mySubId = anIndexes(1);
1311 //---------------------------------------------------------------
1314 CreateReference(_PTR(Study) theStudyDocument,
1315 _PTR(StudyBuilder) theStudyBuilder,
1316 _PTR(SObject) theFatherSObject,
1317 const string& theRefEntry,
1318 const TSelection& theSelection)
1320 _PTR(SObject) aNewObj = theStudyBuilder->NewObject(theFatherSObject);
1321 _PTR(SObject) aRefSObj = theStudyDocument->FindObjectID(theRefEntry);
1322 theStudyBuilder->Addreference(aNewObj,aRefSObj);
1324 std::ostringstream aStream;
1325 Storable::DataToStream(aStream,"myIsSelected",theSelection.myIsSelected);
1326 Storable::DataToStream(aStream,"myHasSubId",theSelection.myHasSubId);
1327 Storable::DataToStream(aStream,"mySubId",theSelection.mySubId);
1329 _PTR(GenericAttribute) anAttr;
1330 anAttr = theStudyBuilder->FindOrCreateAttribute(aNewObj,"AttributeString");
1331 _PTR(AttributeString) aComment(anAttr);
1332 aComment->SetValue(aStream.str());
1336 //---------------------------------------------------------------
1338 SetGaussPointsSelection(VisuGUI* theModule,
1339 VVTK_ViewWindow* theViewWindow,
1340 _PTR(Study) theCStudy,
1341 _PTR(SObject) theSObject)
1343 SVTK_Selector* aSelector = theViewWindow->GetSelector();
1344 aSelector->ClearIObjects();
1346 bool anIsFirst = true;
1347 _PTR(ChildIterator) aChildIter = theCStudy->NewChildIterator(theSObject);
1348 for (; aChildIter->More(); aChildIter->Next()) {
1349 _PTR(SObject) aChildSObject = aChildIter->Value();
1350 _PTR(SObject) aSObject;
1351 if(aChildSObject->ReferencedObject(aSObject)){
1352 CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
1353 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1354 if(VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in())){
1356 VISU::UpdateViewer(theModule, aPrs3d, /*disp_only = */anIsFirst, /*highlight = */false);
1359 // To update selection
1360 Storable::TRestoringMap aMap = Storable::GetStorableMap(aChildSObject);
1362 bool anIsSelected = aMap["myIsSelected"].toInt();
1363 bool aHasSubId = aMap["myHasSubId"].toInt();
1364 int aSubId = aMap["mySubId"].toInt();
1367 std::string anEntry = aSObject->GetID();
1368 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(anEntry.c_str(),"");
1369 aSelector->AddIObject(anIO);
1371 aSelector->AddOrRemoveIndex(anIO,aSubId,false);
1378 aSelector->EndPickCallback(); // To invoke selection changed signal
1382 //---------------------------------------------------------------
1384 OnStoreConfiguration(SalomeApp_Module* theModule,
1387 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1388 if (CheckLock(aCStudy,GetDesktop(theModule)))
1391 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
1393 SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager();
1394 if(aViewManager->getType() == VVTK_Viewer::Type()){
1395 SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
1396 VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
1398 SUIT_Study* aSStudy = aViewManager->study();
1399 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy);
1400 _PTR(Study) aCStudy = aStudy->studyDS();
1401 _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1403 std::string anEntry;
1404 std::string aValue = GetViewParams(aViewWindow);
1407 _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
1409 static int myNbConfigs = 0;
1410 std::string aName = VISU::GenerateName("Config.", ++myNbConfigs).latin1();
1412 std::string aSComponentEntry = aSComponent->GetID();
1413 anEntry = CreateAttributes(aCStudy,
1414 aSComponentEntry.c_str(),
1421 SALOME_ListIO aListIO;
1422 aSelectionMgr->selectedObjects(aListIO);
1423 SALOME_ListIteratorOfListIO aListIter( aListIO );
1424 for(; aListIter.More(); aListIter.Next()){
1425 Handle(SALOME_InteractiveObject) anIO = aListIter.Value();
1426 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1427 _PTR(GenericAttribute) anAttr;
1428 if(aSObject->FindAttribute(anAttr,"AttributeString")){
1429 _PTR(AttributeString) aComment(anAttr);
1430 std::string aCommentValue(aComment->Value());
1431 if(aCommentValue.compare("myComment=GAUSSVIEW") >= 0){
1432 aComment->SetValue(aValue.c_str());
1433 anEntry = aSObject->GetID();
1435 _PTR(ChildIterator) aChildIter = aCStudy->NewChildIterator(aSObject);
1436 for (; aChildIter->More(); aChildIter->Next()) {
1437 _PTR(SObject) aChildSObject = aChildIter->Value();
1438 aStudyBuilder->RemoveObject(aChildSObject);
1447 TVisibleEntries aVisibleEntries;
1448 GetGaussPointsSelection(aViewWindow,
1451 _PTR(SObject) aSObject = aCStudy->FindObjectID(anEntry);
1452 _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1453 TVisibleEntries::const_iterator anIter = aVisibleEntries.begin();
1454 for(; anIter != aVisibleEntries.end(); anIter++){
1455 const std::string& anEntry = anIter->first;
1456 const TSelection& aSelection = anIter->second;
1458 CreateReference(aCStudy,
1465 //UpdateObjBrowser(theModule,true,aSObject);
1466 UpdateObjBrowser(theModule,true);
1472 //---------------------------------------------------------------
1473 template<class TMainWindow>
1475 SetMainWindowParams(VisuGUI* theModule,
1476 _PTR(SObject) theSObject,
1477 VVTK_ViewWindow* theViewWindow,
1478 TMainWindow* theMainWindow)
1480 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1482 Storable::TRestoringMap aMap = Storable::GetStorableMap(theSObject);
1484 SetViewParams(theMainWindow, aMap);
1489 //---------------------------------------------------------------
1492 OnSaveConfiguration()
1494 ::OnStoreConfiguration(this,true);
1498 //---------------------------------------------------------------
1501 OnOverwriteConfiguration()
1503 ::OnStoreConfiguration(this,false);
1507 //---------------------------------------------------------------
1510 OnRestoreConfiguration()
1512 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1514 SALOME_ListIO aListIO;
1515 aSelectionMgr->selectedObjects(aListIO);
1516 if(aListIO.Extent() > 1)
1519 if(SUIT_ViewManager* aViewManager = getViewManager(VVTK_Viewer::Type(),true)){
1520 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1521 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1522 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1523 myConfigSObject = aSObject;
1524 Storable::TRestoringMap aMap = Storable::GetStorableMap(aSObject);
1526 SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
1527 VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
1529 Selection_Mode aSelectionMode = Storable::FindValue(aMap,"mySelectionMode").toInt();
1530 SVTK_Selector* aSelector = aViewWindow->GetSelector();
1531 aSelector->SetSelectionMode(aSelectionMode);
1533 SetGaussPointsSelection(this,aViewWindow,aCStudy,aSObject);
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").latin1();
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);
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);
1556 vtkFloatingPointType aDepth = Storable::FindValue(aMap,"myCursorDepth").toDouble();
1557 aPlanesWidget->SetDistance(aDepth);
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);
1568 vtkFloatingPointType aRadius = Storable::FindValue(aMap,"mySphereCursorRaduis").toDouble();
1569 aSphereWidget->SetRadius(aRadius);
1571 aMainWindow->SetSphereSegementation(true);
1575 if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
1576 SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1577 if(anInteractor->isVisible()){
1578 SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1580 anInteractor->installEventFilter(this);
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);
1589 anInteractor->installEventFilter(this);
1593 SetGaussPointsSelection(this,aViewWindow,aCStudy,aSObject);
1599 //---------------------------------------------------------------
1602 eventFilter( QObject * theWatched, QEvent * theEvent )
1604 bool aRet = VisuGUI::eventFilter(theWatched,theEvent);
1605 if(theEvent->type() == QEvent::Show){
1606 if(SUIT_ViewManager* aViewManager = getViewManager(VVTK_Viewer::Type(),false)){
1607 SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
1608 VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
1609 if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
1610 SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1611 if(theWatched == anInteractor){
1612 SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1613 anInteractor->removeEventFilter(this);
1616 if(VVTK_MainWindow2* aMainWindow = aViewWindow->getMainWindow2()){
1617 SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
1618 if(theWatched == aMainWindow->GetInteractor()){
1619 SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
1620 anInteractor->removeEventFilter(this);
1629 const char gSeparator = '_'; // character used to separate parameter names
1630 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
1632 * \brief Virtual public
1634 * This method is called just before the study document is saved, so the module has a possibility
1635 * to store visual parameters in AttributeParameter attribue(s)
1637 void VisuGUI_Module::storeVisualParameters(int savePoint)
1639 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
1640 if( !study || !study->studyDS() )
1642 _PTR(Study) studyDS = study->studyDS();
1643 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative", moduleName().latin1(), savePoint);
1644 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1646 // viewers counters are used for storing view_numbers in IParameters
1647 int svtkViewers( 0 ), vvtkViewers( 0 ), plotViewers( 0 );
1649 // componentName is used for encoding of entries when storing them in IParameters
1650 _PTR(SComponent) visuEng = ClientFindOrCreateVisuComponent( studyDS );
1651 std::string componentName = visuEng->ComponentDataType();
1653 QPtrList<SUIT_ViewManager> lst;
1655 // saving VVTK viewer parameters. VVTK (Gauss Viewers) are NOT created by SalomeApp since
1656 // VVTK is declared in VISU, so here we store VVTK view window parameters.
1657 // VisuGUI_Module::restoreVisualParameters() creates VVTK_Views and restores its parameters.
1658 ip->setProperty( "ActiveGaussViewer", "-1" );
1659 getApp()->viewManagers( VVTK_Viewer::Type(), lst );
1660 for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it ) {
1661 SUIT_ViewManager* vman = it.current();
1662 if ( SUIT_ViewWindow* vwin = vman->getActiveView() ) {
1663 // using predefined string "GaussViewer" as "entry".. it's a hardcoded "workaround".
1664 // gauss viewer parameters are retrieved using this "entry" string.
1665 // name of parameter = caption of gauss ViewWindow
1666 // value of parameter = ViewWindow's visual parameters
1667 ip->setParameter( "GaussViewer", vwin->caption().latin1(), vwin->getVisualParameters().latin1() );
1669 if ( application()->desktop()->activeWindow() == vwin )
1670 ip->setProperty( "ActiveGaussViewer", QString::number( vvtkViewers ).latin1() );
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..
1679 getApp()->viewManagers( SVTK_Viewer::Type(), lst );
1680 ip->setProperty( "VtkViewersCount", QString::number( lst.count() ).latin1() );
1683 // main cycle to store parameters of displayed objects
1685 getApp()->viewManagers( lst );
1686 vvtkViewers = svtkViewers = plotViewers = 0;
1687 for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it ) {
1688 SUIT_ViewManager* vman = it.current();
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;
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)
1698 QPtrVector<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 vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
1702 allActors->InitTraversal();
1703 while ( vtkActor* actor = allActors->GetNextActor() ) {
1704 if ( actor->GetVisibility() ) { // store only visible actors
1705 if ( VISU_Actor* vActor = VISU_Actor::SafeDownCast( actor ) ) {
1706 if ( vActor->hasIO() ) { // actor corresponds to existing obj
1708 Handle(SALOME_InteractiveObject) io = vActor->getIO();
1709 // entry is "ecoded" = it does NOT contain component adress, since it is a
1710 // subject to change on next component loading
1711 std::string entry = ip->encodeEntry( io->getEntry(), componentName );
1713 std::string param, vtkParam = vType.latin1(); vtkParam += gSeparator;
1714 vtkParam += QString::number( *viewsCounter ).latin1(); vtkParam += gSeparator;
1716 param = vtkParam + "Visibility";
1717 ip->setParameter( entry, param, "On" );
1718 param = vtkParam + "Name";
1719 ip->setParameter( entry, param, vActor->getName() );
1720 param = vtkParam + "RepresentationMode";
1721 ip->setParameter( entry, param, QString::number( vActor->GetRepresentation() ).latin1() );
1722 param = vtkParam + "Opacity";
1723 ip->setParameter( entry, param, QString::number( vActor->GetOpacity() ).latin1() );
1724 vtkFloatingPointType r, g, b;
1725 vActor->GetColor(r, g, b);
1726 QString colorStr = QString::number( r ); colorStr += gDigitsSep;
1727 colorStr += QString::number( g ); colorStr += gDigitsSep;
1728 colorStr += QString::number( b );
1729 param = vtkParam + "Color";
1730 ip->setParameter( entry, param, colorStr.latin1() );
1731 param = vtkParam + "LineWidth";
1732 ip->setParameter( entry, param, QString::number( vActor->GetLineWidth() ).latin1() );
1733 if ( vActor->IsShrunkable() && vActor->IsShrunk() ) {
1734 param = vtkParam + "ShrinkMode";
1735 ip->setParameter( entry, param, "On" );
1736 param = vtkParam + "ShrinkFactor";
1737 ip->setParameter( entry, param, QString::number( vActor->GetShrinkFactor() ).latin1() );
1739 VISU_ScalarMapAct* scalarMapActor = dynamic_cast<VISU_ScalarMapAct*>( vActor );
1740 if ( scalarMapActor && scalarMapActor->IsShading() ) {
1741 param = vtkParam + "Shading";
1742 ip->setParameter( entry, param, "On" );
1744 if ( const VISU::Prs3d_i* vPrs = vActor->GetPrs3d() ) {
1745 param = vtkParam + "ClippingPlane";
1746 int nPlanes = vPrs->GetNumberOfClippingPlanes();
1748 ip->setParameter( entry, param, "Off" );
1749 for ( int p = 0; p < nPlanes; p++ ) {
1750 vtkPlane* plane = vPrs->GetClippingPlane( p );
1751 vtkFloatingPointType normal[3], origin[3];
1752 plane->GetNormal( normal );
1753 plane->GetOrigin( origin );
1754 std::string planeValue = QString::number( normal[0] ).latin1(); planeValue += gDigitsSep;
1755 planeValue += QString::number( normal[1] ).latin1(); planeValue += gDigitsSep;
1756 planeValue += QString::number( normal[2] ).latin1(); planeValue += gDigitsSep;
1757 planeValue += QString::number( origin[0] ).latin1(); planeValue += gDigitsSep;
1758 planeValue += QString::number( origin[1] ).latin1(); planeValue += gDigitsSep;
1759 planeValue += QString::number( origin[2] ).latin1();
1760 param = QString( "%1ClippingPlane_%2" ).arg( vtkParam.c_str() ).arg( p+1 ).latin1();
1761 ip->setParameter( entry, param, planeValue );
1766 } // salome_actor successfull downcast
1768 } // end of ..while.. actors traversal
1772 } // if ( SVTK view model )
1773 else if ( vType == SPlot2d_Viewer::Type() ) { // processing Plot2d viewers
1774 QPtrVector<SUIT_ViewWindow> views = vman->getViews();
1775 for ( int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++ ) {
1776 if ( Plot2d_ViewWindow* plotView = dynamic_cast<Plot2d_ViewWindow*>( views[i] ) ) {
1777 Plot2d_ViewFrame* plotVF = plotView->getViewFrame();
1778 QPtrList<Plot2d_Curve> curves;
1779 plotVF->getCurves( curves );
1781 Plot2d_Curve* curve;
1782 for ( curve = curves.first(); curve; curve = curves.next() ) {
1783 if ( SPlot2d_Curve* sCurve = dynamic_cast<SPlot2d_Curve*>( curve ) ) {
1784 if ( sCurve->hasIO() ) {
1786 Handle(SALOME_InteractiveObject) io = sCurve->getIO();
1787 // entry is "ecoded" = it does NOT contain component adress, since it is a
1788 // subject to change on next component loading
1789 std::string entry = ip->encodeEntry( io->getEntry(), componentName );
1791 std::string param, plotParam = vType.latin1(); plotParam += gSeparator;
1792 plotParam += QString::number( *viewsCounter ).latin1(); plotParam += gSeparator;
1794 param = plotParam + "Visibility";
1795 ip->setParameter( entry, param, "On" );
1799 } // if ( plotView )
1802 } // if ( SPlot2d view model )
1806 const int ViewerType = 0;
1807 const int ViewIndex = 1;
1808 const int ParamName = 2;
1809 // visual parameters are stored in strings as follows:
1810 // ViewerType_ViewNumber_ParamName. '_' is used as separator and should not be used in
1811 // viewer type or parameter names
1813 // return viewer type substring from parameter name
1814 std::string getParam( const std::string& paramName, const int index )
1816 QStringList lst = QStringList::split( gSeparator, QString( paramName.c_str() ) );
1817 if ( !lst.isEmpty() && index < lst.size() )
1818 return lst[index].latin1();
1824 * \brief Virtual public
1826 * This method is called after the study document is opened, so the module has a possibility to restore
1829 void VisuGUI_Module::restoreVisualParameters(int savePoint)
1831 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
1832 if( !study || !study->studyDS() )
1834 _PTR(Study) studyDS = study->studyDS();
1835 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative", moduleName().latin1(), savePoint);
1836 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
1838 // actors are stored in a map after displaying of them for quicker access in future
1839 QMap<QString, QMap<QString, VISU_Actor*> > vtkActors; // map: entry to map: ViewType_<ID> to actor (SVTK/VVTK)
1841 std::vector<std::string> entries = ip->getEntries();
1843 for ( std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt ) {
1845 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
1846 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
1847 std::vector<std::string>::iterator namesIt = paramNames.begin();
1848 std::vector<std::string>::iterator valuesIt = paramValues.begin();
1850 if ( *entIt == "GaussViewer" ) {
1851 // parameter names are view window's captions, values - visual parameters.
1852 for ( ; namesIt != paramNames.end(); ++namesIt, ++valuesIt ) {
1853 SUIT_ViewManager* vman = onCreateViewManager();
1854 SUIT_ViewWindow* vwin = vman->getActiveView();
1855 vwin->setCaption( (*namesIt).c_str() );
1857 // wait untill the window is really shown. This step fixes MANY bugs..
1858 while ( !vwin->isVisible() )
1859 qApp->processEvents();
1861 vwin->setVisualParameters( (*valuesIt).c_str() );
1863 continue; // skip to next entry
1866 // entry is a normal entry - it should be "decoded" (setting base adress of component)
1867 QString entry( ip->decodeEntry( *entIt ).c_str() );
1869 //SRN: Added a check that the entry corresponds to Standard_Real object in the Study
1870 // as the object may be deleted or modified after the visual state is saved.
1871 _PTR(SObject) so = studyDS->FindObjectID(entry.latin1());
1872 if(!so) continue; //Skip the not existent entry
1874 for ( ; namesIt != paramNames.end(); ++namesIt, ++valuesIt ) {
1875 std::string viewerType = ::getParam( *namesIt, ViewerType );
1877 std::string paramName = ::getParam( *namesIt, ParamName );
1879 std::string viewIndexStr = ::getParam( *namesIt, ViewIndex );
1880 int viewIndex = QString( viewIndexStr.c_str() ).toUInt( &ok );
1881 if ( !ok ) // bad conversion of view index to integer
1884 // cout << " -- " << viewerType << ": entry = " << entry.latin1() << ", paramName = " << paramName << endl;
1886 if ( viewerType == SVTK_Viewer::Type().latin1() ||
1887 viewerType == VVTK_Viewer::Type().latin1() ) {
1889 // used as inner map key for locating the actor.
1890 QString viewerTypeIndex = QString( viewerType.c_str() ) + QString::number( viewIndex );
1892 if ( paramName == "Visibility" && displayer() ) {
1893 // if VVTK, then we must create viewer first, because
1895 QPtrList<SUIT_ViewManager> lst;
1896 getApp()->viewManagers( viewerType.c_str(), lst );
1898 // SVTK/VVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
1899 if ( viewIndex >= 0 && viewIndex < lst.count() ) {
1900 SUIT_ViewManager* vman = lst.at( viewIndex );
1901 SUIT_ViewModel* vmodel = vman->getViewModel();
1902 // both SVTK and VVTK view models can be casted to SALOME_View
1903 displayer()->Display( entry, true, dynamic_cast<SALOME_View*>( vmodel ) );
1905 // store displayed actor in a temporary map for quicker access later when restoring other parameters
1906 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
1907 QMap<QString, VISU_Actor*> viewActorMap;
1908 if ( vtkActors.contains( entry ) )
1909 viewActorMap = vtkActors[ entry ];
1910 viewActorMap[ viewerTypeIndex ] = FindActor( GetAppStudy(this), vtkView, entry );
1911 vtkActors[ entry ] = viewActorMap;
1914 else { // the rest properties "work" with VISU_Actor, so we initialize it at first
1915 VISU_Actor* vActor = 0;
1916 if ( vtkActors.contains( entry ) ) {
1917 QMap<QString, VISU_Actor*> viewActorMap = vtkActors[ entry ];
1918 if ( viewActorMap.contains( viewerTypeIndex ) )
1919 vActor = viewActorMap[ viewerTypeIndex ];
1924 QString val( (*valuesIt).c_str() );
1926 if ( paramName == "Name" )
1927 vActor->setName( val.latin1() );
1929 else if ( paramName == "RepresentationMode" )
1930 vActor->SetRepresentation( val.toInt() );
1932 else if ( paramName == "Opacity" )
1933 vActor->SetOpacity( val.toFloat() );
1935 else if ( paramName == "Color" ) {
1936 QStringList colors = QStringList::split( gDigitsSep, val );
1937 if ( colors.count() == 3 )
1938 vActor->SetColor( colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat() );
1941 else if ( paramName == "LineWidth" )
1942 vActor->SetLineWidth( val.toFloat() );
1944 else if ( paramName == "ShrinkMode" ) {
1945 vActor->SetShrinkable( true );
1946 vActor->SetShrink();
1949 else if ( paramName == "ShrunkFactor" )
1950 vActor->SetShrinkFactor( val.toFloat() );
1952 else if ( paramName == "Shading" ) {
1953 if ( VISU_ScalarMapAct* scalarMapActor = dynamic_cast<VISU_ScalarMapAct*>( vActor ) )
1954 scalarMapActor->SetShading();
1957 else if ( paramName.find( "ClippingPlane" ) != std::string::npos ) {
1958 VISU::Prs3d_i* prs = vActor->GetPrs3d();
1962 prs->RemoveAllClippingPlanes();
1963 if ( val != "Off" ) {
1964 QStringList vals = QStringList::split( gDigitsSep, val );
1965 if ( vals.count() == 6 ) { // format check: 6 float values
1966 vtkFloatingPointType normal[3], origin[3];
1967 for (int x = 0; x < 3; x++ ) {
1968 normal[x] = vals[x].toFloat();
1969 origin[x] = vals[x+3].toFloat();
1971 OrientedPlane* plane = OrientedPlane::New();
1972 plane->SetNormal( normal );
1973 plane->SetOrigin( origin );
1974 prs->AddClippingPlane( plane );
1982 else if ( viewerType == SPlot2d_Viewer::Type().latin1() ) {
1984 if ( paramName == "Visibility" && displayer() ) {
1985 QPtrList<SUIT_ViewManager> lst;
1986 getApp()->viewManagers( viewerType.c_str(), lst );
1988 if ( viewIndex >= 0 && viewIndex < lst.count() ) {
1989 SUIT_ViewManager* vman = lst.at( viewIndex );
1990 SUIT_ViewModel* vmodel = vman->getViewModel();
1991 // SVTK and VVTK view models can be casted to SALOME_View
1992 displayer()->Display( entry, true, dynamic_cast<SALOME_View*>( vmodel ) );
1998 } // for names/parameters iterator
1999 } // for entries iterator
2001 // [ update all SVTK/VVTK/Plot2D views
2002 QPtrList<SUIT_ViewManager> lst;
2003 getApp()->viewManagers( lst );
2004 for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it ) {
2005 SUIT_ViewManager* vman = it.current();
2006 SUIT_ViewModel* vmodel = vman->getViewModel();
2009 if ( vmodel->getType() == SVTK_Viewer::Type() || // processing SVTK and VVTK viewers
2010 vmodel->getType() == VVTK_Viewer::Type() ) { // in the same way
2011 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
2012 vtkView->getRenderer()->ResetCameraClippingRange();
2015 else if ( vmodel->getType() == SPlot2d_Viewer::Type().latin1() ) {
2016 Plot2d_ViewWindow* plotView = (Plot2d_ViewWindow*) vman->getActiveView();
2017 plotView->getViewFrame()->Repaint();
2019 } // ] end of update views
2021 // VISU module opens one SVTK viewer in activateModule(). This causes a bug in save-restore visual
2022 // parameters: it no SVTK view was saved, we need NOT any SVTK on restore. Here we close one
2023 // default SVTK if needed.
2025 QString openedSvtkViewerStr = ip->getProperty( "VtkViewersCount" ).c_str();
2026 int openedSvtkViewer = openedSvtkViewerStr.toInt( &ok );
2027 if ( ok && openedSvtkViewer == 0 ) {
2029 getApp()->viewManagers( SVTK_Viewer::Type(), lst );
2031 lst.at( 0 )->closeAllViews();
2035 // if active Gauss Viewer is set ( != -1) then raise the gauss view window.
2037 QString activeGaussViewerStr = ip->getProperty( "ActiveGaussViewer" ).c_str();
2038 int activeGaussViewer = activeGaussViewerStr.toInt( &ok );
2039 if ( ok && activeGaussViewer != -1 ) {
2041 getApp()->viewManagers( VVTK_Viewer::Type(), lst );
2042 if ( activeGaussViewer >= 0 && activeGaussViewer < lst.count() ) {
2043 SUIT_ViewWindow* activeView = lst.at( activeGaussViewer )->getActiveView();
2045 activeView->setActiveWindow();
2046 activeView->setFocus();