From 32c80fbe4f289aab8cc19a5b1b23083c7528dd95 Mon Sep 17 00:00:00 2001 From: mbs Date: Tue, 14 Mar 2023 09:50:44 +0000 Subject: [PATCH] first version with display of bbox of shapes --- CMakeLists.txt | 23 +- SalomeGUIConfig.cmake.in | 10 + src/CMakeLists.txt | 12 + src/LightApp/CMakeLists.txt | 26 + src/LightApp/LightApp_Application.cxx | 90 +- src/LightApp/LightApp_Application.h | 2 +- src/LightApp/LightApp_DataModel.cxx | 4 + src/LightApp/LightApp_Module.cxx | 32 + src/LightApp/LightApp_PV3DSelector.cxx | 179 + src/LightApp/LightApp_PV3DSelector.h | 76 + src/LightApp/LightApp_SelectionMgr.cxx | 2 + src/LightApp/resources/LightApp_msg_en.ts | 4 + src/OCCViewer/OCCViewer_ViewModel.cxx | 5 + src/OCCViewer/OCCViewer_ViewWindow.cxx | 8 + src/PV3DViewer/CMakeLists.txt | 115 + src/PV3DViewer/PV3DViewer.h | 33 + src/PV3DViewer/PV3DViewer_ViewManager.cxx | 75 + src/PV3DViewer/PV3DViewer_ViewManager.h | 45 + src/PV3DViewer/PV3DViewer_ViewModel.cxx | 50 + src/PV3DViewer/PV3DViewer_ViewModel.h | 44 + src/PV3DViewer/PV3DViewer_ViewWindow.cxx | 131 + src/PV3DViewer/PV3DViewer_ViewWindow.h | 55 + src/PV3DViewer/PVViewer_Behaviors.cxx | 129 + src/PV3DViewer/PVViewer_Behaviors.h | 53 + src/PV3DViewer/resources/PV3DViewer_msg_en.ts | 16 + src/PV3DViewer/resources/PV3DViewer_msg_fr.ts | 16 + src/PV3DViewer/resources/PV3DViewer_msg_ja.ts | 17 + src/Prs/SALOME_Prs.cxx | 130 + src/Prs/SALOME_Prs.h | 56 +- src/SALOME_PYQT/SalomePyQt/CMakeLists.txt | 4 + src/SALOME_SWIG/CMakeLists.txt | 2 + src/SPV3D/CMakeLists.txt | 213 ++ src/SPV3D/SPV3D.h | 41 + src/SPV3D/SPV3D_Prs.cxx | 89 + src/SPV3D/SPV3D_Prs.h | 57 + src/SPV3D/SPV3D_ViewManager.cxx | 84 + src/SPV3D/SPV3D_ViewManager.h | 52 + src/SPV3D/SPV3D_ViewModel.cxx | 907 +++++ src/SPV3D/SPV3D_ViewModel.h | 248 ++ src/SPV3D/SPV3D_ViewWindow.cxx | 2952 +++++++++++++++++ src/SPV3D/SPV3D_ViewWindow.h | 518 +++ src/SalomeApp/CMakeLists.txt | 8 + 42 files changed, 6609 insertions(+), 4 deletions(-) create mode 100644 src/LightApp/LightApp_PV3DSelector.cxx create mode 100644 src/LightApp/LightApp_PV3DSelector.h create mode 100644 src/PV3DViewer/CMakeLists.txt create mode 100644 src/PV3DViewer/PV3DViewer.h create mode 100644 src/PV3DViewer/PV3DViewer_ViewManager.cxx create mode 100644 src/PV3DViewer/PV3DViewer_ViewManager.h create mode 100644 src/PV3DViewer/PV3DViewer_ViewModel.cxx create mode 100644 src/PV3DViewer/PV3DViewer_ViewModel.h create mode 100644 src/PV3DViewer/PV3DViewer_ViewWindow.cxx create mode 100644 src/PV3DViewer/PV3DViewer_ViewWindow.h create mode 100644 src/PV3DViewer/PVViewer_Behaviors.cxx create mode 100644 src/PV3DViewer/PVViewer_Behaviors.h create mode 100644 src/PV3DViewer/resources/PV3DViewer_msg_en.ts create mode 100644 src/PV3DViewer/resources/PV3DViewer_msg_fr.ts create mode 100644 src/PV3DViewer/resources/PV3DViewer_msg_ja.ts create mode 100644 src/SPV3D/CMakeLists.txt create mode 100644 src/SPV3D/SPV3D.h create mode 100644 src/SPV3D/SPV3D_Prs.cxx create mode 100644 src/SPV3D/SPV3D_Prs.h create mode 100644 src/SPV3D/SPV3D_ViewManager.cxx create mode 100644 src/SPV3D/SPV3D_ViewManager.h create mode 100644 src/SPV3D/SPV3D_ViewModel.cxx create mode 100644 src/SPV3D/SPV3D_ViewModel.h create mode 100644 src/SPV3D/SPV3D_ViewWindow.cxx create mode 100644 src/SPV3D/SPV3D_ViewWindow.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 113cc34e2..57af5dbb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,8 @@ CMAKE_DEPENDENT_OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OF "NOT SALOME_KERNEL_LIGHT_ONLY" ON) OPTION(SALOME_USE_VTKVIEWER "Enable VTK visualization (Mandatory in classic configurations)" ON) OPTION(SALOME_USE_OCCVIEWER "Enable OCC visualization (Mandatory in classic configurations)" ON) +#MBS +OPTION(SALOME_USE_PV3DVIEWER "Enable ParaView3D visualization (Optionally in classic configurations)" ON) OPTION(SALOME_USE_GLVIEWER "Enable OpenGL visualization (Mandatory in classic configurations)" ON) OPTION(SALOME_USE_GRAPHICSVIEW "Enable GraphicsView visualization (Mandatory in classic configurations)" ON) OPTION(SALOME_USE_PYVIEWER "Enable Python viewer (Mandatory in classic configurations)" ON) @@ -85,7 +87,7 @@ CMAKE_DEPENDENT_OPTION(SALOME_USE_SALOMEOBJECT "Enable Salome Object (Mandatory MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_VTKVIEWER SALOME_USE_GRAPHICSVIEW SALOME_USE_PVVIEWER) MARK_AS_ADVANCED(SALOME_USE_SALOMEOBJECT SALOME_USE_OCCVIEWER SALOME_USE_GLVIEWER SALOME_USE_PLOT2DVIEWER) -MARK_AS_ADVANCED(SALOME_USE_PYCONSOLE SALOME_USE_QXGRAPHVIEWER SALOME_USE_PYVIEWER) +MARK_AS_ADVANCED(SALOME_USE_PYCONSOLE SALOME_USE_QXGRAPHVIEWER SALOME_USE_PYVIEWER SALOME_USE_PV3DVIEWER) # Prerequisites # ============= @@ -191,6 +193,15 @@ ELSE() ADD_DEFINITIONS("-DDISABLE_PVVIEWER") ENDIF() +# - PV3D viewer: ParaView3D +#MBS: +IF (SALOME_USE_PV3DVIEWER) + FIND_PACKAGE(SalomeParaView) + SALOME_LOG_OPTIONAL_PACKAGE(ParaView SALOME_USE_PV3DVIEWER) +ELSE() + ADD_DEFINITIONS("-DDISABLE_PV3DVIEWER") +ENDIF() + # - VTK viewer: VTK IF(SALOME_USE_VTKVIEWER) # Required components are listed in the FindSalomeVTK.cmake file: @@ -362,6 +373,16 @@ IF(SALOME_USE_OCCVIEWER) ENDIF(SALOME_USE_SALOMEOBJECT) ENDIF(SALOME_USE_OCCVIEWER) +# PV3D specific targets: +IF(SALOME_USE_PV3DVIEWER) + LIST(APPEND _${PROJECT_NAME}_exposed_targets + PV3DViewer) + IF(SALOME_USE_SALOMEOBJECT) + LIST(APPEND _${PROJECT_NAME}_exposed_targets + SPV3D) + ENDIF(SALOME_USE_SALOMEOBJECT) +ENDIF(SALOME_USE_PV3DVIEWER) + # Plot2d specific targets: IF(SALOME_USE_PLOT2DVIEWER) LIST(APPEND _${PROJECT_NAME}_exposed_targets diff --git a/SalomeGUIConfig.cmake.in b/SalomeGUIConfig.cmake.in index 62159e832..963fe854c 100644 --- a/SalomeGUIConfig.cmake.in +++ b/SalomeGUIConfig.cmake.in @@ -55,6 +55,8 @@ SET(SALOME_GUI_LIGHT_ONLY @SALOME_LIGHT_ONLY@) SET(SALOME_USE_OCCVIEWER @SALOME_USE_OCCVIEWER@) SET(SALOME_USE_GLVIEWER @SALOME_USE_GLVIEWER@) SET(SALOME_USE_VTKVIEWER @SALOME_USE_VTKVIEWER@) +#MBS: +SET(SALOME_USE_PV3DVIEWER @SALOME_USE_PV3DVIEWER@) SET(SALOME_USE_PLOT2DVIEWER @SALOME_USE_PLOT2DVIEWER@) SET(SALOME_USE_GRAPHICSVIEW @SALOME_USE_GRAPHICSVIEW@) SET(SALOME_USE_QXGRAPHVIEWER @SALOME_USE_QXGRAPHVIEWER@) @@ -78,6 +80,10 @@ ENDIF() IF(NOT SALOME_USE_OCCVIEWER) LIST(APPEND GUI_DEFINITIONS "-DDISABLE_OCCVIEWER") ENDIF() +#MBS: +IF(NOT SALOME_USE_PV3DVIEWER) + LIST(APPEND GUI_DEFINITIONS "-DDISABLE_PV3DVIEWER") +ENDIF() IF(NOT SALOME_USE_GLVIEWER) LIST(APPEND GUI_DEFINITIONS "-DDISABLE_GLVIEWER") ENDIF() @@ -217,6 +223,8 @@ SET(GUI_SalomePy SalomePy) SET(GUI_SalomeSession SalomeSession) SET(GUI_SalomeStyle SalomeStyle) SET(GUI_SOCC SOCC) +#MBS +SET(GUI_SPV3D SPV3D) SET(GUI_SPlot2d SPlot2d) SET(GUI_std std) SET(GUI_SUITApp SUITApp) @@ -226,6 +234,8 @@ SET(GUI_ToolsGUI ToolsGUI) SET(GUI_ViewerTools ViewerTools) SET(GUI_ViewerData ViewerData) SET(GUI_VTKViewer VTKViewer) +#MBS: +SET(GUI_PV3DViewer PV3DViewer) SET(GUI_PVViewer PVViewer) SET(GUI_PVServerService PVServerService) SET(GUI_vtkTools vtkTools) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 32d58f726..be9672a51 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -86,6 +86,18 @@ IF(SALOME_USE_OCCVIEWER) ENDIF(SALOME_USE_SALOMEOBJECT) ENDIF(SALOME_USE_OCCVIEWER) +## +# ParaView3D Viewer +## +#MBS: +IF(SALOME_USE_PV3DVIEWER) + ADD_SUBDIRECTORY(PV3DViewer) + # ADD_SUBDIRECTORY(PV3DServerService) + IF(SALOME_USE_SALOMEOBJECT) + ADD_SUBDIRECTORY(SPV3D) + ENDIF(SALOME_USE_SALOMEOBJECT) +ENDIF() + ## # Plot2d viewer ## diff --git a/src/LightApp/CMakeLists.txt b/src/LightApp/CMakeLists.txt index 993298328..a8b91a9c3 100644 --- a/src/LightApp/CMakeLists.txt +++ b/src/LightApp/CMakeLists.txt @@ -58,6 +58,13 @@ IF(SALOME_USE_OCCVIEWER) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/SOCC) ENDIF() ENDIF() +#MBS: +IF(SALOME_USE_PV3DVIEWER) + INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/PV3DViewer) + IF(SALOME_USE_SALOMEOBJECT) + INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/SPV3D) + ENDIF() +ENDIF() IF(SALOME_USE_PLOT2DVIEWER) INCLUDE_DIRECTORIES(${QWT_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Plot2d) @@ -121,6 +128,13 @@ IF(SALOME_USE_OCCVIEWER) LIST(APPEND _link_LIBRARIES SOCC) ENDIF() ENDIF() +#MBS +IF(SALOME_USE_PV3DVIEWER) + LIST(APPEND _link_LIBRARIES PV3DViewer) + IF(SALOME_USE_SALOMEOBJECT) + LIST(APPEND _link_LIBRARIES SPV3D) + ENDIF() +ENDIF() IF(SALOME_USE_PLOT2DVIEWER) LIST(APPEND _link_LIBRARIES Plot2d) IF(SALOME_USE_SALOMEOBJECT) @@ -174,6 +188,12 @@ ENDIF() IF(SALOME_USE_OCCVIEWER) LIST(APPEND _moc_HEADERS LightApp_OCCSelector.h) ENDIF() +# MBS: +IF(SALOME_USE_PV3DVIEWER) + IF(SALOME_USE_SALOMEOBJECT) + LIST(APPEND _moc_HEADERS LightApp_PV3DSelector.h) + ENDIF() +ENDIF() IF(SALOME_USE_PLOT2DVIEWER) LIST(APPEND _moc_HEADERS LightApp_Plot2dSelector.h) ENDIF() @@ -279,6 +299,12 @@ ENDIF() IF(SALOME_USE_OCCVIEWER) LIST(APPEND _other_SOURCES LightApp_OCCSelector.cxx) ENDIF() +# MBS: +IF(SALOME_USE_PV3DVIEWER) + IF(SALOME_USE_SALOMEOBJECT) + LIST(APPEND _other_SOURCES LightApp_PV3DSelector.cxx) + ENDIF() +ENDIF() IF(SALOME_USE_PLOT2DVIEWER) LIST(APPEND _other_SOURCES LightApp_Plot2dSelector.cxx) ENDIF() diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 85c4834dc..242d4cdba 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -166,6 +166,21 @@ #include #endif +//MBS: +#ifndef DISABLE_PV3DVIEWER +#ifndef DISABLE_SALOMEOBJECT + #include + #include + #include "LightApp_PV3DSelector.h" +#else + #include + #include +#endif + #include + #include + #include "PV3DViewer_ViewWindow.h" +#endif + #define VISIBILITY_COLUMN_WIDTH 25 @@ -804,6 +819,9 @@ void LightApp_Application::createActions() #ifndef DISABLE_PYVIEWER createActionForViewer( NewPyViewerId, newWinMenu, QString::number( 7 ), Qt::ALT+Qt::Key_Y ); #endif +#ifndef DISABLE_PV3DVIEWER + createActionForViewer( NewPV3DViewId, newWinMenu, QString::number( 8 ), Qt::ALT+Qt::Key_3 );//MBS: +#endif createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ), Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) ); @@ -886,6 +904,7 @@ void LightApp_Application::onModuleActivation( const QString& modTitle ) else { // cancelled putInfo( tr("INF_CANCELLED") ); + MSGEL("-----> emit moduleActivated <-----"); emit moduleActivated( QString() ); cancelled = true; } @@ -1136,6 +1155,11 @@ void LightApp_Application::onNewWindow() case NewPyViewerId: type = PyViewer_Viewer::Type(); break; +#endif +#ifndef DISABLE_PV3DVIEWER + case NewPV3DViewId: + type = PV3DViewer_ViewModel::Type();//MBS: + break; #endif } SHOW(type); @@ -1318,6 +1342,12 @@ void LightApp_Application::updateCommandsStatus() if( a ) a->setEnabled( activeStudy() ); #endif + +#ifndef DISABLE_PV3DVIEWER + a = action( NewPV3DViewId );//MBS: + if( a ) + a->setEnabled( activeStudy() ); +#endif } /*! @@ -1852,7 +1882,6 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType resMgr->booleanValue( "OCCViewer", "clipping_modulate", vm->isTextureModulated() ), resMgr->doubleValue( "OCCViewer", "clipping_scale", vm->clippingTextureScale() ) ); - viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr ); } @@ -1897,6 +1926,56 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType } #endif +// //MBS: +// #ifndef DISABLE_PV3DVIEWER +// if( vmType == PV3DViewer_ViewModel::Type() ) +// { +// // if (( viewMgr = dynamic_cast( getViewManager( vmType, false )))) { +// // viewMgr->getActiveView()->setFocus(); +// // return 0; +// // } else { +// // viewMgr = new PV3DViewer_ViewManager( activeStudy(), desktop() ); +// // } +// +// viewMgr = new SPV3D_ViewManager( activeStudy(), desktop() ); +// SPV3D_ViewModel* vm = dynamic_cast( viewMgr->getViewModel() ); +// if (vm) +// { +// // Initalize all view parameters +// //vm->setXXX(); // NYI +// +// //new LightApp_PV3DSelector(vm, mySelMgr); +// } +// } +// #endif + +//MBS: +#ifndef DISABLE_PV3DVIEWER +# ifndef DISABLE_SALOMEOBJECT + if ( vmType == SPV3D_ViewModel::Type() ) +# else + if ( vmType == PV3DViewer_ViewModel::Type() ) +# endif + { + viewMgr = new SPV3D_ViewManager( activeStudy(), desktop() ); + SPV3D_ViewModel* vm = dynamic_cast( viewMgr->getViewModel() ); + if ( vm ) + { + // vm->setBackground(...); //NYI + // vm->... + + new LightApp_PV3DSelector( vm, mySelMgr ); + } +#else + viewMgr = new PV3DViewer_ViewManager( activeStudy(), desktop() ); + PV3DViewer_ViewModel* vm = dynamic_cast( viewMgr->getViewModel() ); + if ( vm ) + { + // vm->setBackground(...); //NYI + } +#endif + } + if ( !viewMgr ) return 0; @@ -2039,6 +2118,7 @@ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy ) getPyInterp()->initStudy(); #endif + MSGEL("-----> emit studyOpened <-----"); emit studyOpened(); } @@ -2050,6 +2130,7 @@ void LightApp_Application::onStudySaved( SUIT_Study* s ) if ( mru && s ) mru->insert( s->studyName() ); + MSGEL("-----> emit studySaved <-----"); emit studySaved(); } @@ -2069,6 +2150,7 @@ void LightApp_Application::onStudyClosed( SUIT_Study* /*s*/ ) mySelMgr->clearSelected(); // Bug 12944: emit signal only after clear selection + MSGEL("-----> emit studyClosed <-----"); emit studyClosed(); activateModule( "" ); @@ -2249,6 +2331,7 @@ void LightApp_Application::onPreferenceChanged( QString& modName, QString& secti else preferencesChanged( section, param ); // emit signal to allow additional preferences changing processing + MSGEL("-----> emit preferenceChanged <-----"); emit preferenceChanged( modName, section, param ); } @@ -4270,6 +4353,7 @@ void LightApp_Application::afterCloseDoc() */ void LightApp_Application::updateModuleActions() { + MSGEL("-----> emit moduleActivated <-----"); emit moduleActivated( activeModule() ? activeModule()->moduleName() : QString() ); } @@ -5089,6 +5173,9 @@ QStringList LightApp_Application::viewManagersTypes() const #else aTypesList< emit operationFinished(\"" << theModuleName.toStdString() << "\", \"" << theOperationName.toStdString() << "\") <-----"); emit operationFinished( theModuleName, theOperationName, theEntryList ); } diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index aae6c005e..145a11562 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -91,7 +91,7 @@ public: CloseId, CloseAllId, GroupAllId, PreferencesId, MRUId, ModulesListId, NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, - NewQxSceneViewId, NewGraphicsViewId, NewPVViewId, NewPyViewerId, StyleId, FullScreenId, + NewQxSceneViewId, NewGraphicsViewId, NewPVViewId, NewPyViewerId, /*MBS:*/ NewPV3DViewId, StyleId, FullScreenId, WebSiteId, ForumId, VideosId, TutorialsId, UserID }; diff --git a/src/LightApp/LightApp_DataModel.cxx b/src/LightApp/LightApp_DataModel.cxx index 6b3b173d1..3f706c0ea 100644 --- a/src/LightApp/LightApp_DataModel.cxx +++ b/src/LightApp/LightApp_DataModel.cxx @@ -66,6 +66,7 @@ LightApp_DataModel::~LightApp_DataModel() bool LightApp_DataModel::open( const QString&, CAM_Study*, QStringList ) { DBG_FUN(); + MSGEL("-----> emit opened <-----"); emit opened(); //TODO: is it really needed? to be removed maybe... return true; } @@ -76,6 +77,7 @@ bool LightApp_DataModel::open( const QString&, CAM_Study*, QStringList ) bool LightApp_DataModel::save( QStringList& ) { DBG_FUN(); + MSGEL("-----> emit saved <-----"); emit saved(); return true; } @@ -86,6 +88,7 @@ bool LightApp_DataModel::save( QStringList& ) bool LightApp_DataModel::saveAs( const QString&, CAM_Study*, QStringList& ) { DBG_FUN(); + MSGEL("-----> emit saved <-----"); emit saved(); return true; } @@ -106,6 +109,7 @@ bool LightApp_DataModel::dumpPython( const QString&, CAM_Study*, bool, QStringLi bool LightApp_DataModel::close() { DBG_FUN(); + MSGEL("-----> emit closed <-----"); emit closed(); return true; } diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index 0ff6109ef..348120b47 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -81,6 +81,24 @@ #include #include #endif +//MBS: +#ifndef DISABLE_PV3DVIEWER +// #ifndef DISABLE_SALOMEOBJECT +// #include +// #include +// #else + #include +// #endif + #include +#endif + +//MBS: +#ifndef DISABLE_PV3DVIEWER + #include + #include +#endif + + #ifndef DISABLE_PLOT2DVIEWER #include #include @@ -394,6 +412,13 @@ void LightApp_Module::update( const int theFlags ) ( (VTKViewer_ViewWindow*)viewWnd )->Repaint(); #endif #endif +//MBS: +#ifndef DISABLE_PV3DVIEWER + // if ( viewWnd->inherits( "SPV3D_ViewWindow" ) ) + // ( (SPV3D_ViewWindow*)viewWnd )->Repaint(); + // if ( viewWnd->inherits( "PV3DViewer_ViewWindow" ) ) + // ( (PV3DViewer_ViewWindow*)viewWnd )->getMultiViewManager()->Repaint(); +#endif #ifndef DISABLE_OCCVIEWER if ( viewWnd->inherits( "OCCViewer_ViewWindow" ) ) ( (OCCViewer_ViewWindow*)viewWnd )->getViewPort()->onUpdate(); @@ -506,6 +531,13 @@ QtxPopupMgr* LightApp_Module::popupMgr() viewers.append( VTKViewer_Viewer::Type() ); #endif #endif +#ifndef DISABLE_PV3DVIEWER +// #ifndef DISABLE_SALOMEOBJECT +// viewers.append( SPV3D_ViewModel::Type() ); +// #else + viewers.append( PV3DViewer_ViewModel::Type() ); +// #endif +#endif #ifndef DISABLE_PLOT2DVIEWER #ifndef DISABLE_SALOMEOBJECT viewers.append( SPlot2d_Viewer::Type() ); diff --git a/src/LightApp/LightApp_PV3DSelector.cxx b/src/LightApp/LightApp_PV3DSelector.cxx new file mode 100644 index 000000000..961cf8b41 --- /dev/null +++ b/src/LightApp/LightApp_PV3DSelector.cxx @@ -0,0 +1,179 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "LightApp_PV3DSelector.h" +#include "LightApp_DataOwner.h" + +#include "SUIT_Desktop.h" + +#ifndef DISABLE_PV3DVIEWER + #include "SPV3D_ViewModel.h" + #include "SPV3D_ViewManager.h" + #include "SPV3D_ViewWindow.h" + #include +#endif + +#ifndef DISABLE_SALOMEOBJECT + // #include "SALOME_Actor.h" + // #include "SALOME_ListIO.hxx" +#endif + +#include + +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "LightApp_PV3DSelector" +#include "MBDebug.h" +//--------------------------------------------------------- + + +#ifndef DISABLE_PV3DVIEWER +/*! + Constructor. +*/ +LightApp_PV3DSelector::LightApp_PV3DSelector( SPV3D_ViewModel* viewer, SUIT_SelectionMgr* mgr ) +: SUIT_Selector( mgr, viewer ), + myViewer( viewer ) +{ + DBG_FUN(); + if ( myViewer ) + connect( myViewer, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); +} + +/*! + Gets viewer. +*/ +SPV3D_ViewModel* LightApp_PV3DSelector::viewer() const +{ + return myViewer; +} + +/*! + Gets type of salome PV3D viewer. +*/ +QString LightApp_PV3DSelector::type() const +{ + return myViewer->getType(); +} + +#endif + +/*! + On selection changed. +*/ +void LightApp_PV3DSelector::onSelectionChanged() +{ + DBG_FUN(); + selectionChanged(); +} + +#ifndef DISABLE_PV3DVIEWER + +/*! + Gets list of selected data owners.(output \a aList). +*/ +void LightApp_PV3DSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const +{ + DBG_FUN(); + + if ( !myViewer ) + return; + + if ( !myViewer->isSelectionEnabled() ) + return; + + // if(SUIT_ViewManager* aViewManager = myViewer->getViewManager()){ + // if(PV3DViewer_ViewManager* aViewMgr = dynamic_cast(aViewManager)){ + // if(PV3DViewer_ViewWindow* aView = dynamic_cast(aViewMgr->getActiveView())){ + // if(SPV3D_Selector* aSelector = aView->GetSelector()){ + // const SALOME_ListIO& aListIO = aSelector->StoredIObjects(); + // SALOME_ListIteratorOfListIO anIter(aListIO); + // for(; anIter.More(); anIter.Next()){ + // Handle(SALOME_InteractiveObject) anIO = anIter.Value(); + // if(anIO->hasEntry()) + // aList.append(new LightApp_SPV3DDataOwner(anIO,aViewMgr->getDesktop())); + // } + // } + // } + // } + // } +} + +/*! + Sets selection to selector from data owner list \a theList. +*/ +void LightApp_PV3DSelector::setSelection( const SUIT_DataOwnerPtrList& theList ) +{ + DBG_FUN(); + + if ( myViewer && ( theList.isEmpty() || myViewer->isSelectionEnabled() )) { + if(SUIT_ViewManager* aViewMgr = myViewer->getViewManager()){ + if(SPV3D_ViewWindow* aView = dynamic_cast(aViewMgr->getActiveView())){ + // if(PV3DViewer_Selector* aSelector = aView->GetSelector()){ + // SALOME_ListIO anAppendList; + // const SALOME_ListIO& aStoredList = aSelector->StoredIObjects(); + // SUIT_DataOwnerPtrList::const_iterator anIter = theList.begin(); + // for(; anIter != theList.end(); ++anIter) { + // const SUIT_DataOwner* aDataOwner = (*anIter).get(); + // if(const LightApp_SPV3DDataOwner* anOwner = dynamic_cast(aDataOwner)) + // { + // MESSAGE("aSelector->SetSelectionMode("<GetMode()<<");"); + // aSelector->SetSelectionMode(anOwner->GetMode()); + // Handle(SALOME_InteractiveObject) anIO = anOwner->IO(); + + // aSelector->AddIObject(anIO); + + // anAppendList.Append(anIO); + // aSelector->AddOrRemoveIndex(anIO,anOwner->GetIds(),false); + // } + // else if(const LightApp_DataOwner* anOwner = dynamic_cast(aDataOwner)) + // { + // Handle(SALOME_InteractiveObject) anIO = + // new SALOME_InteractiveObject(anOwner->entry().toUtf8(),""); + // aSelector->AddIObject(anIO); + // anAppendList.Append(anIO); + // } + // } + // // To remove IOs, which is not selected. + // QMap< QString, Handle( SALOME_InteractiveObject )> toRemove; + // SALOME_ListIteratorOfListIO anIt( aStoredList ); + // for( ; anIt.More(); anIt.Next() ) + // if( !anIt.Value().IsNull() ) + // toRemove[ anIt.Value()->getEntry() ] = anIt.Value(); + + // anIt = SALOME_ListIteratorOfListIO(anAppendList); + // for( ; anIt.More(); anIt.Next() ) + // toRemove.remove( anIt.Value()->getEntry() ); + + // QMap< QString, Handle( SALOME_InteractiveObject )>::const_iterator RIt = toRemove.begin(), + // REnd = toRemove.end(); + // for( ; RIt!=REnd; RIt++ ) + // aSelector->RemoveIObject( RIt.value() ); + + // aView->onSelectionChanged(); + // } + } + } + } +} + +#endif diff --git a/src/LightApp/LightApp_PV3DSelector.h b/src/LightApp/LightApp_PV3DSelector.h new file mode 100644 index 000000000..69f883ea1 --- /dev/null +++ b/src/LightApp/LightApp_PV3DSelector.h @@ -0,0 +1,76 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef LIGHTAPP_PV3DSELECTOR_H +#define LIGHTAPP_PV3DSELECTOR_H + +#include "LightApp.h" + +#include +#include + +#include + + +#ifndef DISABLE_PV3DVIEWER +#ifndef DISABLE_SALOMEOBJECT + #include "SALOME_InteractiveObject.hxx" +#endif + class SPV3D_ViewModel; +#endif + + +/*! + \class LightApp_PV3DSelector + Custom selector to get/set selection from PV3D viewer +*/ +class LIGHTAPP_EXPORT LightApp_PV3DSelector : public QObject, public SUIT_Selector +{ + Q_OBJECT + +public: + virtual ~LightApp_PV3DSelector() {}; +#ifndef DISABLE_PV3DVIEWER + LightApp_PV3DSelector( SPV3D_ViewModel*, SUIT_SelectionMgr* ); + + SPV3D_ViewModel* viewer() const; + + virtual QString type() const; +#else + LightApp_PV3DSelector( SUIT_SelectionMgr* ); +#endif + +private slots: + void onSelectionChanged(); + +#ifndef DISABLE_PV3DVIEWER +protected: + virtual void getSelection( SUIT_DataOwnerPtrList& ) const; + virtual void setSelection( const SUIT_DataOwnerPtrList& ); + +private: + SPV3D_ViewModel* myViewer; + +#endif +}; + +#endif diff --git a/src/LightApp/LightApp_SelectionMgr.cxx b/src/LightApp/LightApp_SelectionMgr.cxx index 4a2220a15..41690c3c5 100644 --- a/src/LightApp/LightApp_SelectionMgr.cxx +++ b/src/LightApp/LightApp_SelectionMgr.cxx @@ -283,6 +283,7 @@ void LightApp_SelectionMgr::selectionChanged( SUIT_Selector* theSel ) myTimeStamp = QTime::currentTime(); + MSGEL("-----> emit currentSelectionChanged <-----"); emit currentSelectionChanged(); } @@ -374,6 +375,7 @@ void LightApp_SelectionMgr::AddOrRemoveIndex( const Handle(SALOME_InteractiveObj bool append = false; setSelected( remainsOwners, append ); + MSGEL("-----> emit currentSelectionChanged <-----"); emit currentSelectionChanged(); // Bug 17269: To avoid calling of selected(aList) diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 15d27efdf..3bb663ce7 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -560,6 +560,10 @@ The changes will be applied on the next application session. NEW_WINDOW_7 P&ython view + + NEW_WINDOW_8 + ParaView&3D view + CREATING_NEW_WINDOW Create new %1 diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index 40844ff3e..eea57c353 100644 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -396,6 +396,7 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t { if (!aHasShift) { myAISContext->ClearCurrents( false ); // todo: ClearCurrents is deprecated + MSGEL("-----> emit deselection <-----"); emit deselection(); } if ( !isPreselectionEnabled() ) { @@ -409,6 +410,7 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t myAISContext->ShiftSelect( Standard_True ); else myAISContext->Select( Standard_True ); + MSGEL("-----> emit selectionChanged <-----"); emit selectionChanged(); } @@ -455,6 +457,7 @@ void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEven case Qt::Key_S: if (!aHasShift) { myAISContext->ClearCurrents( false ); // todo: ClearCurrents is deprecated + MSGEL("-----> emit deselection <-----"); emit deselection(); } @@ -470,6 +473,7 @@ void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEven else myAISContext->Select( Standard_True ); + MSGEL("-----> emit selectionChanged <-----"); emit selectionChanged(); break; @@ -1157,6 +1161,7 @@ void OCCViewer_Viewer::setObjectsSelected(const AIS_ListOfInteractive& theList) */ void OCCViewer_Viewer::performSelectionChanged() { + MSGEL("-----> emit selectionChanged <-----"); emit selectionChanged(); } diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 1872e4531..9ba4760ef 100644 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -394,6 +394,7 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e ) return true; case QEvent::MouseButtonDblClick: + MSGEL("-----> emit mouseDoubleClicked <-----"); emit mouseDoubleClicked(this, (QMouseEvent*)e); return true; @@ -412,6 +413,7 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e ) } } else { + MSGEL("-----> emit vpTransformationStarted(ZOOMVIEW) <-----"); emit vpTransformationStarted ( ZOOMVIEW ); myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() ); double delta = (double)( aEvent->delta() ) / ( 15 * 8 ); @@ -420,6 +422,7 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e ) int x1 = (int)( aEvent->x() + width()*delta/100 ); int y1 = (int)( aEvent->y() + height()*delta/100 ); myViewPort->zoom( x, y, x1, y1 ); + MSGEL("-----> emit vpTransformationFinished(ZOOMVIEW) <-----"); emit vpTransformationFinished ( ZOOMVIEW ); } } @@ -429,6 +432,7 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e ) { QContextMenuEvent * aEvent = (QContextMenuEvent*)e; if ( aEvent->reason() != QContextMenuEvent::Mouse ) + MSGEL("-----> emit contextMenuRequest <-----"); emit contextMenuRequested( aEvent ); } return true; @@ -3085,6 +3089,7 @@ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) void OCCViewer_ViewWindow::showEvent( QShowEvent* theEvent ) { DBG_FUN(); + MSGEL("-----> emit Show <-----"); emit Show( theEvent ); } @@ -3098,6 +3103,7 @@ void OCCViewer_ViewWindow::showEvent( QShowEvent* theEvent ) void OCCViewer_ViewWindow::hideEvent( QHideEvent* theEvent ) { DBG_FUN(); + MSGEL("-----> emit Hide <-----"); emit Hide( theEvent ); } @@ -3334,6 +3340,7 @@ void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal) anAction->setStatusTip( tr( "DSC_MINIMIZE_VIEW" ) ); if ( anAction2 && my2dMode != No2dMode ) toolMgr()->show( ReturnTo3dViewId ); if (toSendSignal) { + MSGEL("-----> emit maximized(true) <-----"); emit maximized( this, true ); } } @@ -3344,6 +3351,7 @@ void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal) anAction->setStatusTip( tr( "DSC_MAXIMIZE_VIEW" ) ); if ( anAction2 && my2dMode != No2dMode ) toolMgr()->hide( ReturnTo3dViewId ); if (toSendSignal) { + MSGEL("-----> emit maximized(false) <-----"); emit maximized( this, false ); } } diff --git a/src/PV3DViewer/CMakeLists.txt b/src/PV3DViewer/CMakeLists.txt new file mode 100644 index 000000000..3da23970b --- /dev/null +++ b/src/PV3DViewer/CMakeLists.txt @@ -0,0 +1,115 @@ +# Copyright (C) 2014-2022 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# Install ParaView filters, etc ... +ADD_SUBDIRECTORY(resources) + +INCLUDE(UseQtExt) + +# --- options --- + +INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR}/src/Qtx + ${PROJECT_SOURCE_DIR}/src/SUIT + ${PROJECT_SOURCE_DIR}/src/PV3DViewer + ${PROJECT_SOURCE_DIR}/src/PVViewer + ${PROJECT_SOURCE_DIR}/src/PVServerService + ) + +ADD_DEFINITIONS( + ${KERNEL_DEFINITIONS} + ${PYTHON_DEFINITIONS} + ) + +SET(_link_LIBRARIES + ${KERNEL_SALOMELocalTrace} + ${KERNEL_OpUtil} + suit + PV3DViewer + PVViewer + PVServerService + ParaView::pqApplicationComponents + ParaView::pqPython + ) + +# --- headers --- + +# header files / to be processed by moc +SET(_moc_HEADERS + PV3DViewer_ViewManager.h + PV3DViewer_ViewModel.h + PV3DViewer_ViewWindow.h + # PV3DViewer_Behaviors.h + # PV3DViewer_GUIElements.h + # PV3DViewer_InitSingleton.h +) + +# header files / no moc processing +SET(_other_HEADERS + PV3DViewer.h + # PV3DViewer_OutputWindow.h + # PV3DViewer_Core.h +) +# header files / to install +SET(PV3DViewer_HEADERS ${_moc_HEADERS} ${_other_HEADERS}) + +# resource files / to be processed by lrelease +SET(_ts_RESOURCES + resources/PV3DViewer_msg_en.ts + resources/PV3DViewer_msg_ja.ts + resources/PV3DViewer_msg_fr.ts +) + +# --- sources --- + +# sources / moc wrappings +QT_WRAP_MOC(_moc_SOURCES ${_moc_HEADERS}) + +# sources / rcc wrappings +QT_ADD_RESOURCES(_rcc_SOURCES ${_rcc_RESOURCES}) + +# sources / static +SET(_other_SOURCES + PV3DViewer_ViewManager.cxx + PV3DViewer_ViewModel.cxx + PV3DViewer_ViewWindow.cxx + # PV3DViewer_OutputWindow.cxx + # PV3DViewer_Behaviors.cxx + # PV3DViewer_GUIElements.cxx + # PV3DViewer_Core.cxx + # PV3DViewer_InitSingleton.cxx + ) + +# sources / to compile +SET(PV3DViewer_SOURCES + ${_other_SOURCES} + ${_moc_SOURCES} + ${_rcc_SOURCES} + ) + +# --- rules --- +ADD_LIBRARY(PV3DViewer ${PV3DViewer_SOURCES}) + +TARGET_LINK_LIBRARIES(PV3DViewer ${_link_LIBRARIES}) +INSTALL(TARGETS PV3DViewer EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +QT_INSTALL_TS_RESOURCES("${_ts_RESOURCES}" "${SALOME_GUI_INSTALL_RES_DATA}") + +# --- header and resources installation --- +INSTALL(FILES ${PV3DViewer_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/PV3DViewer/PV3DViewer.h b/src/PV3DViewer/PV3DViewer.h new file mode 100644 index 000000000..bf3bc93d1 --- /dev/null +++ b/src/PV3DViewer/PV3DViewer.h @@ -0,0 +1,33 @@ +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef PV3DVIEWER_H +#define PV3DVIEWER_H + +#ifdef WIN32 +# if defined PV3DVIEWER_EXPORTS || defined PV3DViewer_EXPORTS +# define PV3DVIEWER_EXPORT __declspec(dllexport) +# else +# define PV3DVIEWER_EXPORT __declspec(dllimport) +# endif +#else +# define PV3DVIEWER_EXPORT +#endif + +#endif // PV3DVIEWER_H diff --git a/src/PV3DViewer/PV3DViewer_ViewManager.cxx b/src/PV3DViewer/PV3DViewer_ViewManager.cxx new file mode 100644 index 000000000..147396936 --- /dev/null +++ b/src/PV3DViewer/PV3DViewer_ViewManager.cxx @@ -0,0 +1,75 @@ +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "PV3DViewer_ViewManager.h" +#include "PV3DViewer_ViewWindow.h" +#include "PV3DViewer_ViewModel.h" +// #include "PV3DViewer_Core.h" +#include "PVViewer_InitSingleton.h" +#include "PVViewer_GUIElements.h" +#include "PVServer_ServiceWrapper.h" + +#include + +#include "SUIT_Desktop.h" +#include "SUIT_Study.h" +#include "SUIT_Session.h" +#include "SUIT_MessageBox.h" +#include "SUIT_ResourceMgr.h" + +#include +#include +#include + +//--------------------------------------------------------- +#define USE_DEBUG +//#define MB_IGNORE_QT +#define MBCLASSNAME "PV3DViewer_ViewManager" +#include "MBDebug.h" +//--------------------------------------------------------- + +/*! + Constructor +*/ +PV3DViewer_ViewManager::PV3DViewer_ViewManager(SUIT_Study* study, SUIT_Desktop* desktop) +: SUIT_ViewManager( study, desktop, new PV3DViewer_ViewModel() ) +{ + DBG_FUN(); + MESSAGE("PV3DViewer - view manager created ..."); + setTitle( tr( "PARAVIEW3D_VIEW_TITLE" ) ); + + // Initialize minimal paraview stuff (if not already done) + PVViewer_InitSingleton::Init(desktop); + + connect( desktop, SIGNAL( windowActivated( SUIT_ViewWindow* ) ), + this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); +} + +/*!Enable toolbars if view \a view is ParaView viewer and disable otherwise. +*/ +void PV3DViewer_ViewManager::onWindowActivated(SUIT_ViewWindow* view) +{ + DBG_FUN(); + if (view) + { + PV3DViewer_ViewWindow* pvWindow = dynamic_cast(view); + PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance( myDesktop ); + guiElements->setToolBarEnabled(pvWindow!=0); + } +} diff --git a/src/PV3DViewer/PV3DViewer_ViewManager.h b/src/PV3DViewer/PV3DViewer_ViewManager.h new file mode 100644 index 000000000..ead40b6fd --- /dev/null +++ b/src/PV3DViewer/PV3DViewer_ViewManager.h @@ -0,0 +1,45 @@ +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef PV3DVIEWER_VIEWMANAGER_H +#define PV3DVIEWER_VIEWMANAGER_H + +#include "PV3DViewer.h" + +#include "SUIT_ViewManager.h" + +class SUIT_Desktop; +class SUIT_Study; +class SUIT_ViewWindow; +class PVServer_ServiceWrapper; +class QMainWindow; + +class PV3DVIEWER_EXPORT PV3DViewer_ViewManager : public SUIT_ViewManager +{ + Q_OBJECT + +public: + PV3DViewer_ViewManager(SUIT_Study*, SUIT_Desktop*); + ~PV3DViewer_ViewManager() {} + +protected slots: + void onWindowActivated(SUIT_ViewWindow*); +}; + +#endif // PV3DVIEWER_VIEWMANAGER_H diff --git a/src/PV3DViewer/PV3DViewer_ViewModel.cxx b/src/PV3DViewer/PV3DViewer_ViewModel.cxx new file mode 100644 index 000000000..291789157 --- /dev/null +++ b/src/PV3DViewer/PV3DViewer_ViewModel.cxx @@ -0,0 +1,50 @@ +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "PV3DViewer_ViewModel.h" +#include "PV3DViewer_ViewWindow.h" + +#include +#include "SUIT_Desktop.h" + +//--------------------------------------------------------- +#define USE_DEBUG +//#define MB_IGNORE_QT +#define MBCLASSNAME "PV3DViewer_ViewModel" +#include "MBDebug.h" +//--------------------------------------------------------- + +//---------------------------------------- +PV3DViewer_ViewModel::PV3DViewer_ViewModel() +:SUIT_ViewModel() +{ + DBG_FUN(); + MESSAGE("PV3DViewer_ViewModel: creating view model ..."); +} + +/*! + Create new instance of view window on desktop \a theDesktop. + \retval SUIT_ViewWindow* - created view window pointer. +*/ +SUIT_ViewWindow* PV3DViewer_ViewModel::createView(SUIT_Desktop* desktop) +{ + DBG_FUN(); + return new PV3DViewer_ViewWindow(desktop, this); +} + diff --git a/src/PV3DViewer/PV3DViewer_ViewModel.h b/src/PV3DViewer/PV3DViewer_ViewModel.h new file mode 100644 index 000000000..6aecead40 --- /dev/null +++ b/src/PV3DViewer/PV3DViewer_ViewModel.h @@ -0,0 +1,44 @@ +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef PV3DVIEWER_VIEWMODEL_H +#define PV3DVIEWER_VIEWMODEL_H + +#include "PV3DViewer.h" + +#include "SUIT_ViewModel.h" + +class SUIT_ViewWindow; +class SUIT_Desktop; +class SUIT_Desktop; + +class PV3DVIEWER_EXPORT PV3DViewer_ViewModel : public SUIT_ViewModel +{ + Q_OBJECT + +public: + PV3DViewer_ViewModel(); + virtual ~PV3DViewer_ViewModel() {} + + virtual SUIT_ViewWindow* createView(SUIT_Desktop*); + virtual QString getType() const { return Type(); } + static QString Type() { return "ParaView3D"; } +}; + +#endif // PV3DVIEWER_VIEWMODEL_H diff --git a/src/PV3DViewer/PV3DViewer_ViewWindow.cxx b/src/PV3DViewer/PV3DViewer_ViewWindow.cxx new file mode 100644 index 000000000..74f2f9205 --- /dev/null +++ b/src/PV3DViewer/PV3DViewer_ViewWindow.cxx @@ -0,0 +1,131 @@ +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "PV3DViewer_ViewWindow.h" +//#include "PV3DViewer_Core.h" +//#include "PV3DViewer_GUIElements.h" +#include "PV3DViewer_ViewModel.h" +#include "PV3DViewer_ViewManager.h" + +#include "SUIT_ViewManager.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Session.h" +#include "SUIT_Desktop.h" +#include "SUIT_Application.h" + +#include +#include + +//--------------------------------------------------------- +#define USE_DEBUG +//#define MB_IGNORE_QT +#define MBCLASSNAME "PV3DViewer_ViewWindow" +#include "MBDebug.h" +//--------------------------------------------------------- + + +/*! + \class PV3DViewer_ViewWindow + \brief PVGUI view window. +*/ + +/*! + \brief Constructor. + \param theDesktop parent desktop window + \param theModel view model +*/ +PV3DViewer_ViewWindow::PV3DViewer_ViewWindow( SUIT_Desktop* theDesktop, PV3DViewer_ViewModel* theModel ) + : SUIT_ViewWindow( theDesktop ), myPVMgr( 0 ) +{ + DBG_FUN(); + myDesktop = theDesktop; + myModel = theModel; + setViewManager(myModel->getViewManager()); + myPVMgr = qobject_cast(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET")); + if (myPVMgr) { + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + if ( app ) + app->addPostRoutine(&PV3DViewer_ViewWindow::removePVMgr); + myPVMgr->setParent( this ); + // This is mandatory, see setParent() method in Qt 4 documentation + myPVMgr->show(); + setCentralWidget( myPVMgr ); + // Hide toolbars + //myPVMgr->hideDecorations(); // MBS:??? + // PV3DViewer_GUIElements * pvge = PV3DViewer_GUIElements::GetInstance(myDesktop); + // pvge->setToolBarVisible(false); + } else + qDebug("No multiViewManager defined"); +} + +/*! + \brief Destructor. + As pqViewManager persists through the whole session, + the destructor first removes it from the children of this PV3DViewer_ViewWindow + to prevent its unexpected deletion. +*/ +PV3DViewer_ViewWindow::~PV3DViewer_ViewWindow() +{ + DBG_FUN(); + if ( myPVMgr ) { + // Hide toolbars + // PV3DViewer_GUIElements * pvge = PV3DViewer_GUIElements::GetInstance(myDesktop); + // pvge->setToolBarEnabled(false); + myPVMgr->setParent( 0 ); + myPVMgr->hide(); + myPVMgr = 0; + setCentralWidget( 0 ); + } +} + +void PV3DViewer_ViewWindow::removePVMgr() +{ + DBG_FUNC(); + pqTabbedMultiViewWidget* aPVMgr = qobject_cast(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET")); + delete aPVMgr; +} + +#if 0 +/*! + \brief Get the visual parameters of the view window. + \return visual parameters of this view window formatted to the string +*/ +QString PV3DViewer_ViewWindow::getVisualParameters() +{ + return SUIT_ViewWindow::getVisualParameters(); +} + +/*! + \brief Restore visual parameters of the view window from the formated string + \param parameters view window visual parameters +*/ +void PV3DViewer_ViewWindow::setVisualParameters( const QString& parameters ) +{ + SUIT_ViewWindow::setVisualParameters( parameters ); +} +#endif + +/*! + \brief Returns the ParaView multi-view manager previously set with setPVManager() +*/ +pqTabbedMultiViewWidget* PV3DViewer_ViewWindow::getMultiViewManager() const +{ + DBG_FUN(); + return myPVMgr; +} diff --git a/src/PV3DViewer/PV3DViewer_ViewWindow.h b/src/PV3DViewer/PV3DViewer_ViewWindow.h new file mode 100644 index 000000000..4f848dd97 --- /dev/null +++ b/src/PV3DViewer/PV3DViewer_ViewWindow.h @@ -0,0 +1,55 @@ +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef PV3DVIEWER_VIEWWINDOW_H +#define PV3DVIEWER_VIEWWINDOW_H + +#include "PV3DViewer.h" + +#include "SUIT_ViewWindow.h" +#include + +class SUIT_Desktop; +class PV3DViewer_ViewModel; +class pqTabbedMultiViewWidget; + +class PV3DVIEWER_EXPORT PV3DViewer_ViewWindow : public SUIT_ViewWindow +{ + Q_OBJECT + +public: + PV3DViewer_ViewWindow( SUIT_Desktop*, PV3DViewer_ViewModel* ); + virtual ~PV3DViewer_ViewWindow(); + + // virtual QString getVisualParameters(); + // virtual void setVisualParameters( const QString& ); + + //virtual void Repaint(bool theUpdateTrihedron = true); + + pqTabbedMultiViewWidget* getMultiViewManager() const; + + static void removePVMgr(); + +private: + SUIT_Desktop* myDesktop; + PV3DViewer_ViewModel* myModel; + pqTabbedMultiViewWidget* myPVMgr; +}; + +#endif // PV3DVIEWER_VIEWWINDOW_H diff --git a/src/PV3DViewer/PVViewer_Behaviors.cxx b/src/PV3DViewer/PVViewer_Behaviors.cxx new file mode 100644 index 000000000..66f22e2c6 --- /dev/null +++ b/src/PV3DViewer/PVViewer_Behaviors.cxx @@ -0,0 +1,129 @@ +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author: Adrien Bruneton (CEA) + +#include "PVViewer_Behaviors.h" + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +int PVViewer_Behaviors::BehaviorLoadingLevel = 0; + +PVViewer_Behaviors::PVViewer_Behaviors(QMainWindow * parent) + : QObject(parent) +{ +} + +/**! Instanciate minimal ParaView behaviors needed when using an instance of PVViewer. + * This method should be updated at each new version of ParaView with what is found in + * Qt/ApplicationComponents/pqParaViewBehaviors.cxx + */ +void PVViewer_Behaviors::instanciateMinimalBehaviors(QMainWindow * /*desk*/) +{ + if (BehaviorLoadingLevel < 1) + { + // Register ParaView interfaces. + pqInterfaceTracker* pgm = pqApplicationCore::instance()->interfaceTracker(); + + // Register standard types of property widgets. + pgm->addInterface(new pqStandardPropertyWidgetInterface(pgm)); + // Register standard types of view-frame actions. + pgm->addInterface(new pqStandardViewFrameActionsImplementation(pgm)); + + new pqPipelineContextMenuBehavior(this); + new pqDefaultViewBehavior(this); // shows a 3D view as soon as a server connection is made + new pqAlwaysConnectedBehavior(this); // client always connected to a server + new pqVerifyRequiredPluginBehavior(this); + new pqPluginSettingsBehavior(this); + new pqCrashRecoveryBehavior(this); + new pqCommandLineOptionsBehavior(this); + + BehaviorLoadingLevel = 1; + } +} + +/**! Instanciate usual ParaView behaviors. + * This method should be updated at each new version of ParaView with what is found in + * Qt/ApplicationComponents/pqParaViewBehaviors.cxx + */ +void PVViewer_Behaviors::instanciateAllBehaviors(QMainWindow * desk) +{ + // "new pqParaViewBehaviors(anApp->desktop(), this);" + // -> (which loads all standard ParaView behaviors at once) has to be replaced in order to + // exclude using of pqQtMessageHandlerBehaviour + + // Define application behaviors. + if (BehaviorLoadingLevel < 1) + instanciateMinimalBehaviors(desk); + + if (BehaviorLoadingLevel < 2) + { + //new pqQtMessageHandlerBehavior(this); // THIS ONE TO EXCLUDE !! see comment above + new pqDataTimeStepBehavior(this); + new pqSpreadSheetVisibilityBehavior(this); + //new pqPipelineContextMenuBehavior(this); + new pqUndoRedoBehavior(this); + new pqAutoLoadPluginXMLBehavior(this); // auto load plugins GUI stuff + new pqPluginDockWidgetsBehavior(desk); + new pqPluginActionGroupBehavior(desk); + // rnv: Disable ParaView main window persistance mechanism, + // because SALOME has own functionality for store/restore windows state. + // new pqPersistentMainWindowStateBehavior(desk); + new pqObjectPickingBehavior(desk); + new pqCollaborationBehavior(this); + new pqViewStreamingBehavior(this); + + // Move instantiation of the pqApplyBehavior to the PVViewer_GUIElements::buildPVWidgets(), + // because without pqPropertiesPanel it doesn't make sense. + /* + pqApplyBehavior* applyBehavior = new pqApplyBehavior(this); + foreach (pqPropertiesPanel* ppanel, desk->findChildren()) + { + applyBehavior->registerPanel(ppanel); + } + */ + BehaviorLoadingLevel = 2; + } +} diff --git a/src/PV3DViewer/PVViewer_Behaviors.h b/src/PV3DViewer/PVViewer_Behaviors.h new file mode 100644 index 000000000..780b039c6 --- /dev/null +++ b/src/PV3DViewer/PVViewer_Behaviors.h @@ -0,0 +1,53 @@ +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author: Adrien Bruneton (CEA) + + +#ifndef PVVIEWER_BEHAVIORS_H +#define PVVIEWER_BEHAVIORS_H + +#include "PVViewer.h" + +#include + +class QMainWindow; +class pqPropertiesPanel; + +/**! + * PARAVIS behaviors - mimic what is done in + * Qt/ApplicationComponents/pqParaViewBehaviors.cxx + * Except a few ones, behaviors are destroyed when the module is destroyed. + */ +class PVVIEWER_EXPORT PVViewer_Behaviors: public QObject +{ + Q_OBJECT + +public: + PVViewer_Behaviors(QMainWindow*); + + void instanciateMinimalBehaviors(QMainWindow*); + void instanciateAllBehaviors(QMainWindow*); + + virtual ~PVViewer_Behaviors() {} + +private: + static int BehaviorLoadingLevel; +}; + +#endif // PVVIEWER_BEHAVIORS_H diff --git a/src/PV3DViewer/resources/PV3DViewer_msg_en.ts b/src/PV3DViewer/resources/PV3DViewer_msg_en.ts new file mode 100644 index 000000000..f8ed2e984 --- /dev/null +++ b/src/PV3DViewer/resources/PV3DViewer_msg_en.ts @@ -0,0 +1,16 @@ + + + + + @default + + + + + PV3DViewer_ViewManager + + PARAVIEW3D_VIEW_TITLE + ParaView3D scene:%M - viewer:%V + + + diff --git a/src/PV3DViewer/resources/PV3DViewer_msg_fr.ts b/src/PV3DViewer/resources/PV3DViewer_msg_fr.ts new file mode 100644 index 000000000..b380b6602 --- /dev/null +++ b/src/PV3DViewer/resources/PV3DViewer_msg_fr.ts @@ -0,0 +1,16 @@ + + + + + @default + + + + + PV3DViewer_ViewManager + + PARAVIEW3D_VIEW_TITLE + Scène ParaView3D:%M - visualiseur:%V + + + diff --git a/src/PV3DViewer/resources/PV3DViewer_msg_ja.ts b/src/PV3DViewer/resources/PV3DViewer_msg_ja.ts new file mode 100644 index 000000000..3a73311d4 --- /dev/null +++ b/src/PV3DViewer/resources/PV3DViewer_msg_ja.ts @@ -0,0 +1,17 @@ + + + + + @default + + + + + + PV3DViewer_ViewManager + + PARAVIEW3D_VIEW_TITLE + ParaView3D シーン:%M - ビューア:%V + + + diff --git a/src/Prs/SALOME_Prs.cxx b/src/Prs/SALOME_Prs.cxx index ce77426f5..70d56d548 100644 --- a/src/Prs/SALOME_Prs.cxx +++ b/src/Prs/SALOME_Prs.cxx @@ -58,6 +58,7 @@ void SALOME_Prs::LocalSelectionIn( SALOME_View*, const std::list ) const // base implementation does nothing } +#undef MBCLASSNAME #define MBCLASSNAME "SALOME_OCCPrs" /*! Dispatches display operation to proper Display() method of SALOME_View @@ -142,6 +143,7 @@ void SALOME_OCCPrs::Update( SALOME_Displayer* d ) if ( d ) d->Update( this ); } +#undef MBCLASSNAME #define MBCLASSNAME "SALOME_VTKPrs" /*! Dispatches display operation to proper Display() method of SALOME_View @@ -215,6 +217,92 @@ void SALOME_VTKPrs::Update( SALOME_Displayer* d ) if ( d ) d->Update( this ); } +#undef MBCLASSNAME +#define MBCLASSNAME "SALOME_PV3DPrs" +/*! + Dispatches display operation to proper Display() method of SALOME_View +*/ +void SALOME_PV3DPrs::DisplayIn( SALOME_View* v ) const +{ + DBG_FUN(); + if ( v ) v->Display( this ); +} + +/*! + Dispatches display operation to proper Erase() method of SALOME_View +*/ +void SALOME_PV3DPrs::EraseIn( SALOME_View* v, const bool forced ) const +{ + DBG_FUN(); + if ( v ) v->Erase( this, forced ); +} + +/*! + Dispatches display operation to proper BeforeDisplay() method of SALOME_Displayer +*/ +void SALOME_PV3DPrs::BeforeDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const +{ + DBG_FUN(); + d->BeforeDisplay( v, this ); +} + +/*! + Dispatches display operation to proper AfterDisplay() method of SALOME_Displayer +*/ +void SALOME_PV3DPrs::AfterDisplayIn( SALOME_Displayer* d, SALOME_View* v ) const +{ + DBG_FUN(); + d->AfterDisplay( v, this ); +} + +/*! + Dispatches display operation to proper BeforeErase() method of SALOME_Displayer +*/ +void SALOME_PV3DPrs::BeforeEraseIn( SALOME_Displayer* d, SALOME_View* v ) const +{ + DBG_FUN(); + d->BeforeErase( v, this ); +} + +/*! + Dispatches display operation to proper AfterErase() method of SALOME_Displayer +*/ +void SALOME_PV3DPrs::AfterEraseIn( SALOME_Displayer* d, SALOME_View* v ) const +{ + DBG_FUN(); + d->AfterErase( v, this ); +} + +/*! + Dispatches operation to proper LocalSelectionIn() method of SALOME_View +*/ +void SALOME_PV3DPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const +{ + DBG_FUN(); + std::list modes; + modes.push_back( mode ); + LocalSelectionIn( v, modes ); +} + +/*! + Dispatches operation to proper LocalSelectionIn() method of SALOME_View +*/ +void SALOME_PV3DPrs::LocalSelectionIn( SALOME_View* v, const std::list modes ) const +{ + DBG_FUN(); + if ( v && !modes.empty() ) v->LocalSelection( this, modes ); +} + +/*! + Dispatches update operation to proper Update() method of SALOME_Displayer +*/ +void SALOME_PV3DPrs::Update( SALOME_Displayer* d ) +{ + DBG_FUN(); + if ( d ) d->Update( this ); +} + +#undef MBCLASSNAME #define MBCLASSNAME "SALOME_Prs2d" /*! Dispatches display operation to proper Display() method of SALOME_View @@ -347,6 +435,16 @@ void SALOME_View::Display( const SALOME_VTKPrs* ) // MESSAGE( "SALOME_View::Display( const SALOME_VTKPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." ); } +//MBS: +/*! + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ +void SALOME_View::Display( const SALOME_PV3DPrs* ) +{ + MSGEL("...SALOME_View::Display(SALOME_PV3DPrs)"); +// MESSAGE( "SALOME_View::Display( const SALOME_PV3DPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." ); +} + /*! Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. */ @@ -374,6 +472,16 @@ void SALOME_View::Erase( const SALOME_VTKPrs*, const bool ) // MESSAGE( "SALOME_View::Erase( const SALOME_VTKPrs& ) called! Probably, presentation is being erased in uncompatible viewframe." ); } +//MBS: +/*! + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ +void SALOME_View::Erase( const SALOME_PV3DPrs*, const bool ) +{ + MSGEL("...SALOME_View::Erase(SALOME_PV3DPrs,bool)"); +// MESSAGE( "SALOME_View::Erase( const SALOME_PV3DPrs& ) called! Probably, presentation is being erased in uncompatible viewframe." ); +} + /*! Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. */ @@ -423,6 +531,17 @@ void SALOME_View::LocalSelection( const SALOME_VTKPrs*, const int ) // Probably, selection is being activated in uncompatible viewframe." ); } +//MBS: +/*! + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ +void SALOME_View::LocalSelection( const SALOME_PV3DPrs*, const int ) +{ + MSGEL("...SALOME_View::LocalSelection(SALOME_PV3DPrs,int)"); +// MESSAGE( "SALOME_View::LocalSelection( const SALOME_PV3DPrs* ) called! +// Probably, selection is being activated in uncompatible viewframe." ); +} + /*! Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. */ @@ -467,6 +586,7 @@ void SALOME_View::AfterErase ( SALOME_Displayer* d, const SALOME_Prs* p ) p->AfterEraseIn( d, this ); } +#undef MBCLASSNAME #define MBCLASSNAME "SALOME_Displayer" /*! Gives control to SALOME_Prs object, so that it could perform double dispatch @@ -495,6 +615,16 @@ void SALOME_Displayer::Update( SALOME_VTKPrs* ) // MESSAGE( "SALOME_Displayer::Update( SALOME_VTKPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." ); } +//MBS: +/*! + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ +void SALOME_Displayer::Update( SALOME_PV3DPrs* ) +{ + MSGEL("...SALOME_Displayer::Update(SALOME_PV3DPrs)"); +// MESSAGE( "SALOME_Displayer::Update( SALOME_PV3DPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." ); +} + /*! Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. */ diff --git a/src/Prs/SALOME_Prs.h b/src/Prs/SALOME_Prs.h index 8f7e5ad9f..d5c94fbda 100644 --- a/src/Prs/SALOME_Prs.h +++ b/src/Prs/SALOME_Prs.h @@ -194,6 +194,52 @@ public: virtual void LocalSelectionIn( SALOME_View*, const int ) const; }; +//MBS: +/*! + \class SALOME_PV3DPrs + Base class for PV3D graphic object (pqPipelineSource) wrappers. + This intermediate class is necessary to avoid dependencies from ParaView libs. +*/ + +class PRS_EXPORT SALOME_PV3DPrs : public SALOME_Prs +{ +public: + //! Constructor + explicit SALOME_PV3DPrs(const char* e) : SALOME_Prs(e) {} + + //! It uses double dispatch in order to + //! invoke Display() method corresponding to the actual type of presentation. + virtual void DisplayIn( SALOME_View* ) const; + + //! It uses double dispatch in order to + //! invoke Erase() method corresponding to the actual type of presentation. + virtual void EraseIn( SALOME_View*, const bool = false ) const; + + //! It uses double dispatch in order to + //! invoke BeforeDisplayIn() method corresponding to the actual type of presentation. + virtual void BeforeDisplayIn( SALOME_Displayer*, SALOME_View* ) const; + + //! It uses double dispatch in order to + //! invoke AfterDisplayIn() method corresponding to the actual type of presentation. + virtual void AfterDisplayIn( SALOME_Displayer*, SALOME_View* ) const; + + //! It uses double dispatch in order to + //! invoke BeforeEraseIn() method corresponding to the actual type of presentation. + virtual void BeforeEraseIn( SALOME_Displayer*, SALOME_View* ) const; + + //! It uses double dispatch in order to + //! invoke AfterEraseIn() method corresponding to the actual type of presentation. + virtual void AfterEraseIn( SALOME_Displayer*, SALOME_View* ) const; + + //! It uses double dispatch in order to + //! invoke Update() method corresponding to the actual type of presentation. + virtual void Update( SALOME_Displayer* ); + + //! Key method for double dispatch of activation of sub-shapes selection + virtual void LocalSelectionIn( SALOME_View*, const int ) const; + virtual void LocalSelectionIn( SALOME_View*, const std::list ) const; +}; + /*! \class SALOME_Prs2d Base class for Plot2d graphic object (Plot2d_Curve) wrappers. @@ -274,12 +320,14 @@ public: // Display() methods for ALL kinds of presentation should appear here virtual void Display( const SALOME_OCCPrs* );//!< Display SALOME_OCCPrs presentation. virtual void Display( const SALOME_VTKPrs* );//!< Display SALOME_VTKPrs presentation. + virtual void Display( const SALOME_PV3DPrs* );//!< Display SALOME_PV3DPrs presentation. //MBS: virtual void Display( const SALOME_Prs2d* );//!< Display SALOME_Prs2d presentation. // Add new Display() methods here... // Erase() methods for ALL kinds of presentation should appear here virtual void Erase( const SALOME_OCCPrs*, const bool = false );//!< Erase SALOME_OCCPrs virtual void Erase( const SALOME_VTKPrs*, const bool = false );//!< Erase SALOME_VTKPrs + virtual void Erase( const SALOME_PV3DPrs*, const bool = false );//!< Erase SALOME_PV3DPrs //MBS: virtual void Erase( const SALOME_Prs2d*, const bool = false );//!< Erase SALOME_Prs2d // Add new Erase() methods here... @@ -287,12 +335,13 @@ public: virtual void LocalSelection( const SALOME_OCCPrs*, const int ); //!< Local selection SALOME_OCCPrs virtual void LocalSelection( const SALOME_OCCPrs*, const std::list );//!< Multiple local selection SALOME_OCCPrs virtual void LocalSelection( const SALOME_VTKPrs*, const int ); //!< Local selection SALOME_VTKPrs + virtual void LocalSelection( const SALOME_PV3DPrs*, const int ); //!< Local selection SALOME_PV3DPrs //MBS: virtual void LocalSelection( const SALOME_Prs2d* , const int ); //!< Local selection SALOME_Prs2d //! Deactivates selection of sub-shapes (must be redefined with OCC viewer) virtual void GlobalSelection( const bool = false ) const; - //! Creates empty presenation of corresponding type + //! Creates empty presentation of corresponding type virtual SALOME_Prs* CreatePrs( const char* /*entry*/ = 0 ) { return 0; } // Axiluary methods called before and after displaying of objects @@ -330,6 +379,7 @@ public: // Update() methods for ALL kinds of presentation should appear here virtual void Update( SALOME_OCCPrs* );//!< Update SALOME_OCCPrs presentation. virtual void Update( SALOME_VTKPrs* );//!< Update SALOME_VTKPrs presentation. + virtual void Update( SALOME_PV3DPrs* );//!< Update SALOME_PV3DPrs presentation.//MBS: virtual void Update( SALOME_Prs2d* );//!< Update SALOME_Prs2d presentation. // Add new Update() methods here... @@ -338,6 +388,8 @@ public: virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here virtual void BeforeDisplay( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here virtual void AfterDisplay ( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here + virtual void BeforeDisplay( SALOME_View*, const SALOME_PV3DPrs* ) {} //! Null body here //MBS: + virtual void AfterDisplay ( SALOME_View*, const SALOME_PV3DPrs* ) {} //! Null body here //MBS: virtual void BeforeDisplay( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here virtual void AfterDisplay ( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here @@ -346,6 +398,8 @@ public: virtual void AfterErase ( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here virtual void BeforeErase( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here virtual void AfterErase ( SALOME_View*, const SALOME_VTKPrs* ) {} //! Null body here + virtual void BeforeErase( SALOME_View*, const SALOME_PV3DPrs* ) {} //! Null body here //MBS: + virtual void AfterErase ( SALOME_View*, const SALOME_PV3DPrs* ) {} //! Null body here //MBS: virtual void BeforeErase( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here virtual void AfterErase ( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here diff --git a/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt b/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt index 2a32e0e5e..0e2543505 100644 --- a/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt +++ b/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt @@ -52,6 +52,10 @@ IF(SALOME_USE_VTKVIEWER) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/VTKViewer) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/SVTK) ENDIF() +IF(SALOME_USE_PV3DVIEWER) + INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/PV3DViewer) + INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/SPV3D) +ENDIF() IF(SALOME_USE_PVVIEWER) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/PVViewer) ENDIF(SALOME_USE_PVVIEWER) diff --git a/src/SALOME_SWIG/CMakeLists.txt b/src/SALOME_SWIG/CMakeLists.txt index 04818851a..7e5d05303 100644 --- a/src/SALOME_SWIG/CMakeLists.txt +++ b/src/SALOME_SWIG/CMakeLists.txt @@ -33,10 +33,12 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/LightApp ${PROJECT_SOURCE_DIR}/src/OBJECT ${PROJECT_SOURCE_DIR}/src/OCCViewer + ${PROJECT_SOURCE_DIR}/src/PV3DViewer ${PROJECT_SOURCE_DIR}/src/Plot2d ${PROJECT_SOURCE_DIR}/src/Prs ${PROJECT_SOURCE_DIR}/src/Qtx ${PROJECT_SOURCE_DIR}/src/SOCC + ${PROJECT_SOURCE_DIR}/src/SPV3D ${PROJECT_SOURCE_DIR}/src/STD ${PROJECT_SOURCE_DIR}/src/SUIT ${PROJECT_SOURCE_DIR}/src/SVTK diff --git a/src/SPV3D/CMakeLists.txt b/src/SPV3D/CMakeLists.txt new file mode 100644 index 000000000..b02004967 --- /dev/null +++ b/src/SPV3D/CMakeLists.txt @@ -0,0 +1,213 @@ +# Copyright (C) 2012-2022 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +INCLUDE(UseQtExt) + +# --- options --- + +# additional include directories +INCLUDE_DIRECTORIES( + ${OpenCASCADE_INCLUDE_DIR} + ${QT_INCLUDES} + ${Boost_INCLUDE_DIRS} + ${PTHREAD_INCLUDE_DIR} + ${PROJECT_SOURCE_DIR}/src/Qtx + ${PROJECT_SOURCE_DIR}/src/SUIT + # ${PROJECT_SOURCE_DIR}/src/ViewerTools + ${PROJECT_SOURCE_DIR}/src/OBJECT + ${PROJECT_SOURCE_DIR}/src/Prs + ${PROJECT_SOURCE_DIR}/src/PV3DViewer + ${PROJECT_SOURCE_DIR}/src/PVViewer + ${PROJECT_SOURCE_DIR}/src/PVServerService +) + # ${PROJECT_SOURCE_DIR}/src/OpenGLUtils + +# additional preprocessor / compiler flags +ADD_DEFINITIONS(${QT_DEFINITIONS} ${OpenCASCADE_DEFINITIONS} ${BOOST_DEFINITIONS}) + +# libraries to link to +SET(_link_LIBRARIES + ${QT_LIBRARIES} + ${OPENGL_LIBRARIES} + ${OpenCASCADE_FoundationClasses_LIBRARIES} ${OpenCASCADE_Visualization_LIBRARIES} + ${KERNEL_OpUtil} + qtx suit + #ViewerTools + SalomeObject SalomePrs PV3DViewer PVViewer PVServerService + ParaView::pqApplicationComponents + ParaView::pqPython +) + #OpenGLUtils + # VTK::RenderingAnnotation + # VTK::ImagingCore + # VTK::CommonSystem + # VTK::IOExportGL2PS + +# --- headers --- + +# header files / to be processed by moc +SET(_moc_HEADERS + SPV3D_ViewManager.h + SPV3D_ViewModel.h + SPV3D_ViewWindow.h + #SPV3D_View.h +) + # SPV3D_ComboAction.h + # SPV3D_FontWidget.h + # SPV3D_GenericRenderWindowInteractor.h + # SPV3D_RecorderDlg.h + # SPV3D_PsOptionsDlg.h + # SPV3D_RenderWindowInteractor.h + # SPV3D_SetRotationPointDlg.h + # SPV3D_ViewModelBase.h + # SPV3D_ViewParameterDlg.h + +# header files / to be processed by moc / internal +# TODO: check for MSVS project +# SET(_moc_internal_HEADERS +# ) + # SPV3D_CubeAxesDlg.h + # SPV3D_NonIsometricDlg.h + # SPV3D_UpdateRateDlg.h + +# header files / no moc processing +SET(_other_HEADERS + SPV3D.h + SPV3D_Prs.h + #SALOME_Actor.h +) + # SPV3D_Actor.h + # SPV3D_AreaPicker.h + # SPV3D_CubeAxesActor2D.h + # SPV3D_DeviceActor.h + # SPV3D_Event.h + # SPV3D_Functor.h + # SPV3D_ImageWriter.h + # SPV3D_ImageWriterMgr.h + # SPV3D_InteractorStyle.h + # SPV3D_KeyFreeInteractorStyle.h + # SPV3D_Recorder.h + # SPV3D_Renderer.h + # SPV3D_Selection.h + # SPV3D_SelectionEvent.h + # SPV3D_Selector.h + # SPV3D_SpaceMouse.h + # SPV3D_Utils.h + # SPV3D_Hash.h + +# header files / no moc processing / internal +# no processing currently: TODO: check for MSVS project +# SET(_internal_HEADERS +# # SPV3D_SelectorDef.h +# # SPV3D_Trihedron.h +# # SPV3D_AxesActor.h +# # SPV3D_AxesWidget.h +# ) + +# header files / to install +SET(SPV3D_HEADERS ${_moc_HEADERS} ${_other_HEADERS}) + +# --- resources --- + +# resource files / to be processed by lrelease +# SET(_ts_RESOURCES +# resources/SPV3D_msg_en.ts +# resources/SPV3D_msg_fr.ts +# resources/SPV3D_msg_ja.ts +# resources/SPV3D_images.ts +# ) + +# resource files / static +# SET(_other_RESOURCES +# # resources/vtk_view_graduated_axes.png +# # resources/vtk_view_highlight.png +# # resources/vtk_view_highlight_dyn.png +# # resources/vtk_view_highlight_off.png +# # resources/vtk_view_highlight_std.png +# # resources/vtk_view_parallel.png +# # resources/vtk_view_parameters.png +# # resources/vtk_view_perspective.png +# # resources/vtk_view_recording_pause.png +# # resources/vtk_view_recording_play.png +# # resources/vtk_view_recording_start.png +# # resources/vtk_view_recording_stop.png +# # resources/vtk_view_rotation_point.png +# # resources/vtk_view_scaling.png +# # resources/vtk_view_selection.png +# # resources/vtk_view_stereo.png +# # resources/vtk_view_style_switch.png +# # resources/vtk_view_update_rate.png +# # resources/vtk_view_zooming_style_switch.png +# ) + +# --- sources --- + +# sources / moc wrappings +QT_WRAP_MOC(_moc_SOURCES ${_moc_HEADERS} ${_moc_internal_HEADERS}) + +# sources / static +SET(_other_SOURCES + SPV3D_Prs.cxx + SPV3D_ViewManager.cxx + SPV3D_ViewModel.cxx + SPV3D_ViewWindow.cxx + #SPV3D_View.cxx + #SALOME_Actor.cxx +) + #SPV3D_Actor.cxx + # SPV3D_AreaPicker.cxx + # SPV3D_ComboAction.cxx + # SPV3D_CubeAxesActor2D.cxx + # SPV3D_CubeAxesDlg.cxx + # SPV3D_DeviceActor.cxx + # SPV3D_FontWidget.cxx + # SPV3D_GenericRenderWindowInteractor.cxx + # SPV3D_ImageWriter.cxx + # SPV3D_ImageWriterMgr.cxx + # SPV3D_InteractorStyle.cxx + # SPV3D_KeyFreeInteractorStyle.cxx + # SPV3D_NonIsometricDlg.cxx + # SPV3D_Recorder.cxx + # SPV3D_RecorderDlg.cxx + # SPV3D_PsOptionsDlg.cxx + # SPV3D_RenderWindowInteractor.cxx + #SPV3D_Renderer.cxx + #SPV3D_Selector.cxx + # SPV3D_SetRotationPointDlg.cxx + # SPV3D_SpaceMouse.cxx + # SPV3D_Trihedron.cxx + # SPV3D_UpdateRateDlg.cxx + # SPV3D_Utils.cxx + #SPV3D_ViewParameterDlg.cxx + # SPV3D_AxesActor.cxx + # SPV3D_AxesWidget.cxx + +# sources / to compile +SET(SPV3D_SOURCES ${_other_SOURCES} ${_moc_SOURCES}) + +# --- rules --- + +ADD_LIBRARY(SPV3D ${SPV3D_SOURCES}) +TARGET_LINK_LIBRARIES(SPV3D ${_link_LIBRARIES}) +INSTALL(TARGETS SPV3D EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +INSTALL(FILES ${SPV3D_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) +# QT_INSTALL_TS_RESOURCES("${_ts_RESOURCES}" "${SALOME_GUI_INSTALL_RES_DATA}") + +INSTALL(FILES ${_other_RESOURCES} DESTINATION ${SALOME_GUI_INSTALL_RES_DATA}) diff --git a/src/SPV3D/SPV3D.h b/src/SPV3D/SPV3D.h new file mode 100644 index 000000000..64871a48f --- /dev/null +++ b/src/SPV3D/SPV3D.h @@ -0,0 +1,41 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef SPV3D_H +#define SPV3D_H + +#ifdef WIN32 +# if defined SPV3D_EXPORTS +# define SPV3D_EXPORT __declspec(dllexport) +# else +# define SPV3D_EXPORT __declspec(dllimport) +# endif +#else +# define SPV3D_EXPORT +#endif + +#if defined WIN32 +#pragma warning ( disable: 4251 ) +#pragma warning ( disable: 4786 ) +#endif + +#endif diff --git a/src/SPV3D/SPV3D_Prs.cxx b/src/SPV3D/SPV3D_Prs.cxx new file mode 100644 index 000000000..2ce19a7c0 --- /dev/null +++ b/src/SPV3D/SPV3D_Prs.cxx @@ -0,0 +1,89 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// SALOME PV3DViewer : build PV3D viewer into Salome desktop +// File : SPV3D_Prs.cxx + +#include "SPV3D_Prs.h" + +#include + +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SPV3D_Prs" +#include "MBDebug.h" +//--------------------------------------------------------- + +/*! + Default constructor +*/ +SPV3D_Prs::SPV3D_Prs( const char* entry ) : SALOME_PV3DPrs(entry), myObjects( 0 ) +{ + DBG_FUN(); + ARG(entry); +} + +/*! + Standard constructor +*/ +SPV3D_Prs::SPV3D_Prs( const char* entry, const vtkActor* obj ) : SALOME_PV3DPrs(entry) +{ + DBG_FUN(); + ARG(entry); + AddObject( obj ); +} + +/*! + Destructor +*/ +SPV3D_Prs:: ~SPV3D_Prs() +{ + DBG_FUN(); + if ( myObjects ) myObjects->Delete(); +} + +/*! + \return actors list +*/ +vtkActorCollection* SPV3D_Prs::GetObjects() const +{ + return myObjects; +} + +/*! + Add actor +*/ +void SPV3D_Prs::AddObject( const vtkActor* obj ) +{ + DBG_FUN(); + if ( !myObjects) + myObjects = vtkActorCollection::New(); + myObjects->AddItem( (vtkActor*)obj ); +} + +/*! + \return 0 if list of the actors is empty [ Reimplemented from SALOME_Prs ] +*/ +bool SPV3D_Prs::IsNull() const +{ + return !myObjects || myObjects->GetNumberOfItems() <= 0; +} diff --git a/src/SPV3D/SPV3D_Prs.h b/src/SPV3D/SPV3D_Prs.h new file mode 100644 index 000000000..933fe776f --- /dev/null +++ b/src/SPV3D/SPV3D_Prs.h @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// SALOME PV3DViewer : build PV3D viewer into Salome desktop +// File : SPV3D_Prs.h + +#ifndef SPV3D_Prs_H +#define SPV3D_Prs_H + +#include "SPV3D.h" +#include "SALOME_Prs.h" + +class vtkActorCollection; +class vtkActor; + +class SPV3D_EXPORT SPV3D_Prs : public SALOME_PV3DPrs +{ +public: + explicit SPV3D_Prs( const char* entry ); + // Default constructor + SPV3D_Prs( const char* entry, const vtkActor* obj ); + // Standard constructor + ~SPV3D_Prs(); + // Destructor + + vtkActorCollection* GetObjects() const; + // Get actors list + void AddObject( const vtkActor* obj ); + // Add actor + + bool IsNull() const; + // Reimplemented from SALOME_Prs + +private: + vtkActorCollection* myObjects; // list of actors +}; + +#endif diff --git a/src/SPV3D/SPV3D_ViewManager.cxx b/src/SPV3D/SPV3D_ViewManager.cxx new file mode 100644 index 000000000..380e55c3d --- /dev/null +++ b/src/SPV3D/SPV3D_ViewManager.cxx @@ -0,0 +1,84 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "SPV3D_ViewManager.h" +#include "SPV3D_ViewModel.h" +#include "SPV3D_ViewWindow.h" + +#include + +#include "PVViewer_InitSingleton.h" +#include "PVViewer_GUIElements.h" +#include "PVServer_ServiceWrapper.h" + +#include + +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SPV3D_ViewManager" +#include "MBDebug.h" +//--------------------------------------------------------- + +/*! + Constructor +*/ +SPV3D_ViewManager::SPV3D_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop ) +: SUIT_ViewManager( study, theDesktop, new SPV3D_ViewModel() ) +{ + DBG_FUN(); + setTitle( PV3DViewer_ViewManager::tr( "PARAVIEW3D_VIEW_TITLE" ) ); + + // Initialize minimal paraview stuff (if not already done) + PVViewer_InitSingleton::Init(theDesktop); + + connect( theDesktop, SIGNAL( windowActivated( SUIT_ViewWindow* ) ), + this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); +} + +/*! + Destructor +*/ +SPV3D_ViewManager::~SPV3D_ViewManager() +{ + DBG_FUN(); +} + +/*! + \return corresponding main window +*/ +SUIT_Desktop* SPV3D_ViewManager::getDesktop() +{ + return myDesktop; +} + +/*!Enable toolbars if view \a view is ParaView viewer and disable otherwise. +*/ +void SPV3D_ViewManager::onWindowActivated(SUIT_ViewWindow* view) +{ + DBG_FUN(); + if (view) + { + SPV3D_ViewWindow* pvWindow = dynamic_cast(view); + PVViewer_GUIElements * guiElements = PVViewer_GUIElements::GetInstance( myDesktop ); + guiElements->setToolBarEnabled(pvWindow!=0); + } +} diff --git a/src/SPV3D/SPV3D_ViewManager.h b/src/SPV3D/SPV3D_ViewManager.h new file mode 100644 index 000000000..4c4c20c2a --- /dev/null +++ b/src/SPV3D/SPV3D_ViewManager.h @@ -0,0 +1,52 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef SPV3D_VIEWMANAGER_H +#define SPV3D_VIEWMANAGER_H + +#include "SUIT_ViewManager.h" +//#include "PV3DViewer_ViewManager.h" +#include "SPV3D.h" + +class SUIT_Desktop; +class SUIT_Study; +class SUIT_ViewWindow; + +//! Extend SUIT_ViewManager to deal with SPV3D_ViewModel +class SPV3D_EXPORT SPV3D_ViewManager : public SUIT_ViewManager +{ + Q_OBJECT + +public: + //! Construct the view manager + SPV3D_ViewManager( SUIT_Study* study, SUIT_Desktop* ); + + //! Destroy the view manager + virtual ~SPV3D_ViewManager(); + + SUIT_Desktop* getDesktop(); + +protected slots: + void onWindowActivated(SUIT_ViewWindow*); +}; + +#endif diff --git a/src/SPV3D/SPV3D_ViewModel.cxx b/src/SPV3D/SPV3D_ViewModel.cxx new file mode 100644 index 000000000..1c7d21bba --- /dev/null +++ b/src/SPV3D/SPV3D_ViewModel.cxx @@ -0,0 +1,907 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include +#include +#include +#include + +// #include +// #include +#include + +//#include "SUIT_Session.h" +#include "SPV3D_ViewModel.h" +#include "SPV3D_ViewWindow.h" +// #include "SPV3D_View.h" +// #include "SPV3D_Renderer.h" +//#include "SPV3D_MainWindow.h" +#include "SPV3D_Prs.h" + +// #include "PV3DViewer_Algorithm.h" +//#include "PV3DViewer_ViewModel.h" + +#include "SUIT_ViewModel.h" +#include "SUIT_ViewManager.h" + +//#include "SALOME_Actor.h" +#include "SALOME_InteractiveObject.hxx" + +#include "QtxActionToolMgr.h" +#include "QtxBackgroundTool.h" + +// VSR: Uncomment below line to allow texture background support in PV3D viewer +#define PV3D_ENABLE_TEXTURED_BACKGROUND + +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SPV3D_ViewModel" +#include "MBDebug.h" +//--------------------------------------------------------- + +/*! + Constructor +*/ +SPV3D_ViewModel::SPV3D_ViewModel() +{ + DBG_FUN(); + // myTrihedronSize = 105; + // myTrihedronRelative = true; + // myIsStaticTrihedronVisible = true; + // myIncrementSpeed = 10; + // myIncrementMode = 0; + // myProjMode = 0; + // myStereoType = 0; + // myAnaglyphFilter = 0; + // myStyle = 0; + // myZoomingStyle = 0; + mySelectionEnabled = true; + // myPreSelectionMode = Standard_Preselection; + // mySpaceBtn[0] = 1; + // mySpaceBtn[1] = 2; + // mySpaceBtn[2] = 9; + // myDefaultBackground = Qtx::BackgroundData( Qt::black ); + // myQuadBufferSupport = false; +} + +/*! + Destructor +*/ +SPV3D_ViewModel::~SPV3D_ViewModel() +{ + DBG_FUN(); +} + +#if 0 +/*! Get data for supported background modes: gradient types, identifiers and supported image formats */ +QString SPV3D_ViewModel::backgroundData( QStringList& gradList, QIntList& idList, QIntList& txtList ) +{ + gradList << tr( "GT_HORIZONTALGRADIENT" ) + << tr( "GT_VERTICALGRADIENT" ) + << tr( "GT_FIRSTDIAGONALGRADIENT" ) + << tr( "GT_SECONDDIAGONALGRADIENT" ) + << tr( "GT_FIRSTCORNERGRADIENT" ) + << tr( "GT_SECONDCORNERGRADIENT" ) + << tr( "GT_THIRDCORNERGRADIENT" ) + << tr( "GT_FOURTHCORNERGRADIENT" ); + idList << HorizontalGradient + << VerticalGradient + << FirstDiagonalGradient + << SecondDiagonalGradient + << FirstCornerGradient + << SecondCornerGradient + << ThirdCornerGradient + << FourthCornerGradient; +#ifdef PV3D_ENABLE_TEXTURED_BACKGROUND + txtList << Qtx::CenterTexture << Qtx::TileTexture << Qtx::StretchTexture; +#endif + return tr("BG_IMAGE_FILES"); +} + +/*! Get data for supported background modes: gradient types, identifiers and supported image formats */ +void SPV3D_ViewModel::stereoData( QStringList& typeList, QIntList& idList ) +{ + typeList << tr("ST_CRYSTALEYES") << tr("ST_REDBLUE") << + tr("ST_INTERLACED") << tr("ST_LEFT") << + tr("ST_RIGHT") << tr("ST_DRESDEN") << + tr("ST_ANAGLYPH") << tr("ST_CHECKERBOARD") << + tr("ST_SPLITVIEWPORTHORIZONTAL"); + idList << CrystalEyesType << RedBlueType << + InterlacedType << LeftType << + RightType << DresdenType << + AnaglyphType << CheckerboardType << + SplitViewPortHorizontalType; +} + +//! Get background color of the viewer [obsolete] +QColor SPV3D_ViewModel::backgroundColor() const +{ + return background().color(); +} + +//! Set background color to the viewer [obsolete] +void SPV3D_ViewModel::setBackgroundColor( const QColor& c ) +{ + DBG_FUN(); + Qtx::BackgroundData bg = background(); + bg.setColor( c ); + setBackground( bg ); +} + +/*! + \return background data +*/ +Qtx::BackgroundData SPV3D_ViewModel::background() const +{ + return myDefaultBackground; +} + +/*! + Changes background + \param theBackground - new background data +*/ +void SPV3D_ViewModel::setBackground( const Qtx::BackgroundData& theBackground ) +{ + DBG_FUN(); + myDefaultBackground = theBackground.isValid() ? theBackground : Qtx::BackgroundData( Qt::black ); + QVector aViews = myViewManager->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ + if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){ + if(SPV3D_ViewWindow* aView = dynamic_cast(aViewWindow)){ + aView->setBackground(myDefaultBackground); + } + } + } +} +#endif + +/*!Create new instance of view window on desktop \a theDesktop. + *\retval SUIT_ViewWindow* - created view window pointer. + */ +SUIT_ViewWindow* SPV3D_ViewModel::createView( SUIT_Desktop* theDesktop ) +{ + DBG_FUN(); + SPV3D_ViewWindow* aViewWindow = new SPV3D_ViewWindow(theDesktop, this); + //aViewWindow->Initialize(this); + + // aViewWindow->setBackground( background() ); + // aViewWindow->SetTrihedronSize( trihedronSize(), trihedronRelative() ); + // aViewWindow->SetStaticTrihedronVisible( isStaticTrihedronVisible() ); + // aViewWindow->SetProjectionMode( projectionMode() ); + // aViewWindow->SetStereoType( stereoType() ); + // aViewWindow->SetAnaglyphFilter( anaglyphFilter() ); + // aViewWindow->SetQuadBufferSupport( isQuadBufferSupport() ); + // aViewWindow->SetInteractionStyle( interactionStyle() ); + // aViewWindow->SetZoomingStyle( zoomingStyle() ); + // aViewWindow->SetPreSelectionMode( preSelectionMode() ); + aViewWindow->SetSelectionEnabled( isSelectionEnabled() ); + // aViewWindow->SetIncrementalSpeed( incrementalSpeed(), incrementalSpeedMode() ); + // aViewWindow->SetSpacemouseButtons( spacemouseBtn(1), spacemouseBtn(2), spacemouseBtn(3) ); + + // connect(aViewWindow, SIGNAL( actorAdded(PV3DViewer_Actor*) ), + // this, SLOT(onActorAdded(PV3DViewer_Actor*))); + // connect(aViewWindow, SIGNAL( actorRemoved(PV3DViewer_Actor*) ), + // this, SLOT(onActorRemoved(PV3DViewer_Actor*))); + + return aViewWindow; +} + +#if 0 +/*! + \return trihedron size +*/ +double SPV3D_ViewModel::trihedronSize() const +{ + return myTrihedronSize; +} + +/*! + \return true if thihedron changes size in accordance with bounding box +*/ +bool SPV3D_ViewModel::trihedronRelative() const +{ + return myTrihedronRelative; +} + +/*! + Sets trihedron size and relativeness( whether thihedron changes size in accordance with bounding box) + \param theSize - new size + \param theRelative - new relativeness +*/ +void SPV3D_ViewModel::setTrihedronSize( const double theSize, const bool theRelative ) +{ + myTrihedronSize = theSize; + myTrihedronRelative = theRelative; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( int i = 0; i < aViews.count(); i++ ) + { + if ( SPV3D_ViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetTrihedronSize( theSize, theRelative ); + } + } +} + +/*! + \return visibility status of the static trihedron +*/ +bool SPV3D_ViewModel::isStaticTrihedronVisible() const +{ + return myIsStaticTrihedronVisible; +} + +/*! + Sets visibility status of the static trihedron + \param theIsVisible - new visibility status +*/ +void SPV3D_ViewModel::setStaticTrihedronVisible( const bool theIsVisible ) +{ + myIsStaticTrihedronVisible = theIsVisible; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( int i = 0; i < aViews.count(); i++ ) + { + if ( SPV3D_ViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetStaticTrihedronVisible( theIsVisible ); + } + } +} + +/*! + \return projection mode +*/ +int SPV3D_ViewModel::projectionMode() const +{ + return myProjMode; +} + + +/*! + Sets projection mode: 0 - orthogonal, 1 - perspective projection + \param theMode - new projection mode +*/ +void SPV3D_ViewModel::setProjectionMode( const int theMode ) +{ + DBG_FUN(); + if ( myProjMode != theMode ) { + if ( theMode != SPV3D_ViewWindow::Stereo ) + myProjMode = theMode; + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( int i = 0; i < aViews.count(); i++ ) + { + if ( SPV3D_ViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetProjectionMode( theMode ); + } + } + } +} + +/*! + \return stereo type +*/ +int SPV3D_ViewModel::stereoType() const +{ + return myStereoType; +} + +/*! + Sets stereo type + \param theType - new stereo type +*/ +void SPV3D_ViewModel::setStereoType( const int theType ) +{ + if ( myStereoType != theType ) { + myStereoType = theType; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( int i = 0; i < aViews.count(); i++ ) + { + if ( SPV3D_ViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetStereoType( theType ); + } + } + } +} + +/*! + \return anaglyph filter +*/ +int SPV3D_ViewModel::anaglyphFilter() const +{ + return myAnaglyphFilter; +} + +/*! + Sets anaglyph filter + \param theFilter - new anaglyph filter +*/ +void SPV3D_ViewModel::setAnaglyphFilter( const int theFilter ) +{ + if ( myAnaglyphFilter != theFilter ) { + myAnaglyphFilter = theFilter; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( int i = 0; i < aViews.count(); i++ ) + { + if ( SPV3D_ViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetAnaglyphFilter( theFilter ); + } + } + } +} + +/*! + \return support quad-buffered stereo +*/ +bool SPV3D_ViewModel::isQuadBufferSupport() const +{ + return myQuadBufferSupport; +} + +/*! + Set support quad-buffered stereo + \param theEnable - enable/disable support quad-buffered stereo +*/ +void SPV3D_ViewModel::setQuadBufferSupport( const bool theEnable ) +{ + DBG_FUN(); + if ( myQuadBufferSupport != theEnable ) { + myQuadBufferSupport = theEnable; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( int i = 0; i < aViews.count(); i++ ) + { + if ( SPV3D_ViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetQuadBufferSupport( theEnable ); + } + } + } +} +/*! + \return interaction style +*/ +int SPV3D_ViewModel::interactionStyle() const +{ + return myStyle; +} + +/*! + Sets interaction style: 0 - standard, 1 - keyboard free interaction + \param theStyle - new interaction style +*/ +void SPV3D_ViewModel::setInteractionStyle( const int theStyle ) +{ + myStyle = theStyle; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( int i = 0; i < aViews.count(); i++ ) + { + if ( SPV3D_ViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetInteractionStyle( theStyle ); + } + } +} + +/*! + \return zooming style +*/ +int SPV3D_ViewModel::zoomingStyle() const +{ + return myZoomingStyle; +} + +/*! + Sets zooming style: 0 - standard, 1 - advanced (at cursor) + \param theStyle - new zooming style +*/ +void SPV3D_ViewModel::setZoomingStyle( const int theStyle ) +{ + myZoomingStyle = theStyle; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( int i = 0; i < aViews.count(); i++ ) + { + if ( SPV3D_ViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetZoomingStyle( theStyle ); + } + } +} + +/*! + \return current preselection mode +*/ +Preselection_Mode SPV3D_ViewModel::preSelectionMode() const +{ + return myPreSelectionMode; +} + +/*! + Sets preselection mode + \param theMode - new preselection mode +*/ +void SPV3D_ViewModel::setPreSelectionMode( Preselection_Mode theMode ) +{ + myPreSelectionMode = theMode; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( int i = 0; i < aViews.count(); i++ ) + { + if ( SPV3D_ViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetPreSelectionMode( theMode ); + } + } +} + +/*! + \return incremental speed value +*/ +int SPV3D_ViewModel::incrementalSpeed() const +{ + return myIncrementSpeed; +} + +/*! + \return modification mode of the incremental speed +*/ +int SPV3D_ViewModel::incrementalSpeedMode() const +{ + return myIncrementMode; +} + +/*! + Set the incremental speed value and modification mode + \param theValue - new value + \param theMode - new mode: 0 - arithmetic, 1 - geometrical progression +*/ +void SPV3D_ViewModel::setIncrementalSpeed( const int theValue, const int theMode ) +{ + myIncrementSpeed = theValue; + myIncrementMode = theMode; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( int i = 0; i < aViews.count(); i++ ) + { + if ( SPV3D_ViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetIncrementalSpeed( theValue, theMode ); + } + } +} + +/*! + \return spacemouse button assigned to the specified function + \param theIndex - function by number (from 1 to 3) +*/ +int SPV3D_ViewModel::spacemouseBtn( const int theIndex ) const +{ + if ( theIndex < 1 || theIndex > 3 ) + return -1; + return mySpaceBtn[theIndex-1]; +} + +/*! + Set the spacemouse buttons + \param theBtn1, theBtn2, theBtn3 - new buttons +*/ +void SPV3D_ViewModel::setSpacemouseButtons( const int theBtn1, const int theBtn2, const int theBtn3 ) +{ + mySpaceBtn[0] = theBtn1; + mySpaceBtn[1] = theBtn2; + mySpaceBtn[2] = theBtn3; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( int i = 0; i < aViews.count(); i++ ) + { + if ( SPV3D_ViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetSpacemouseButtons( theBtn1, theBtn2, theBtn3 ); + } + } +} +#endif + +/*! + Sets new view manager + \param theViewManager - new view manager +*/ +void SPV3D_ViewModel::setViewManager(SUIT_ViewManager* theViewManager) +{ + DBG_FUN(); + SUIT_ViewModel::setViewManager(theViewManager); + + if ( !theViewManager ) + return; + + connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + + connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*))); + + connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); + + connect(theViewManager, SIGNAL(viewCreated(SUIT_ViewWindow*)), + this, SLOT(onViewCreated(SUIT_ViewWindow*))); +} + +/*! + Builds popup for vtk viewer +*/ +void SPV3D_ViewModel::contextMenuPopup( QMenu* thePopup ) +{ + DBG_FUN(); + // thePopup->addAction( PV3DViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); + // thePopup->addAction( PV3DViewer_Viewer::tr( "MEN_CHANGE_BACKGROUND" ), this, SLOT( onChangeBackground() ) ); + + // thePopup->addSeparator(); + + // if(SPV3D_ViewWindow* aView = dynamic_cast(myViewManager->getActiveView())){ + // //Support of several toolbars in the popup menu + // QList lst = aView->findChildren(); + // QList::const_iterator it = lst.begin(), last = lst.end(); + // for( ; it!=last; it++ ) + // thePopup->addAction( (*it)->toggleViewAction() ); + // aView->RefreshDumpImage(); + // } +} + +/*! + SLOT: called on mouse button press, empty implementation +*/ +void SPV3D_ViewModel::onMousePress(SUIT_ViewWindow* /*vw*/, QMouseEvent* /*event*/) +{} + +/*! + SLOT: called on mouse move, empty implementation +*/ +void SPV3D_ViewModel::onMouseMove(SUIT_ViewWindow* /*vw*/, QMouseEvent* /*event*/) +{} + +/*! + SLOT: called on mouse button release, empty implementation +*/ +void SPV3D_ViewModel::onMouseRelease(SUIT_ViewWindow* /*vw*/, QMouseEvent* /*event*/) +{} + +/*! + Enables/disables selection + \param isEnabled - new state +*/ +void SPV3D_ViewModel::enableSelection(bool isEnabled) +{ + DBG_FUN(); + ARG(isEnabled); + mySelectionEnabled = isEnabled; + //!! To be done for view windows + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( int i = 0; i < aViews.count(); i++ ) + { + if ( SPV3D_ViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetSelectionEnabled( isEnabled ); + } + } + + if(!isEnabled) { + //clear current selection in the viewer + bool blocked = blockSignals( true ); + if ( SUIT_ViewManager* aViewMgr = getViewManager() ) { + if( SPV3D_ViewWindow* aViewWindow = dynamic_cast( aViewMgr->getActiveView() ) ){ + //NYI + // if( SPV3D_Selector* aSelector = aViewWindow->GetSelector() ) { + // if(SPV3D_View* aView = aViewWindow->getView()){ + // aSelector->ClearIObjects(); + // aView->onSelectionChanged(); + // } + // } + } + } + blockSignals( blocked ); + } + +} + +#if 0 +/*! + Enables/disables selection of many object + \param isEnabled - new state +*/ +void SPV3D_ViewModel::enableMultiselection(bool isEnable) +{ + myMultiSelectionEnabled = isEnable; + //!! To be done for view windows +} + +/*! + SLOT: called on dump view operation is activated, stores scene to raster file +*/ +void SPV3D_ViewModel::onDumpView() +{ + if(SUIT_ViewWindow* aView = myViewManager->getActiveView()) + aView->onDumpView(); +} + +/*! + SLOT: called if background color is to be changed changed, passes new color to view port +*/ +void SPV3D_ViewModel::onChangeBackground() +{ + SPV3D_ViewWindow* aView = dynamic_cast(myViewManager->getActiveView()); + if ( !aView ) + return; + + // get supported gradient types + QStringList gradList; + QIntList idList, txtList; + QString formats = backgroundData( gradList, idList, txtList ); + + // invoke dialog box + Qtx::BackgroundData bgData = QtxBackgroundDialog::getBackground( aView->background(), // initial background + aView, // parent for dialog box + txtList, // allowed texture modes + true, // enable solid color mode + true, // enable gradient mode + false, // disable custom gradient mode + !txtList.isEmpty(), // enable texture mode + gradList, // gradient names + idList, // gradient identifiers + formats ); // image formats + + // set chosen background data to the viewer + if ( bgData.isValid() ) + aView->setBackground( bgData ); +} +#endif + +/*! + Display presentation + \param prs - presentation +*/ +void SPV3D_ViewModel::Display( const SALOME_PV3DPrs* prs ) +{ + DBG_FUN(); + // try do downcast object + if(const SPV3D_Prs* aPrs = dynamic_cast( prs )){ + if(aPrs->IsNull()) + return; + if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){ + anActorCollection->InitTraversal(); + while(vtkActor* anActor = anActorCollection->GetNextActor()){ + // if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ + // if(!anAct->ShouldBeDisplayed()) + // continue; + // // just display the object + // QVector aViews = myViewManager->getViews(); + // for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ + // if(SPV3D_ViewWindow* aViewWindow = dynamic_cast(aViews.at(i))){ + // // if(SPV3D_View* aView = aViewWindow->getView()){ + // // aView->Display(anAct,false); + // // if(anAct->IsSetCamera()){ + // // vtkRenderer* aRenderer = aView->getRenderer(); + // // anAct->SetCamera( aRenderer->GetActiveCamera() ); + // // } + // // } + // } + // } + // } + } + } + } +} + +/*! + Erase presentation + \param prs - presentation + \param forced - removes object from view +*/ +void SPV3D_ViewModel::Erase( const SALOME_PV3DPrs* prs, const bool forced ) +{ + DBG_FUN(); + // try do downcast object + // if(const SPV3D_Prs* aPrs = dynamic_cast( prs )){ + // if(aPrs->IsNull()) + // return; + // if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){ + // anActorCollection->InitTraversal(); + // while(vtkActor* anActor = anActorCollection->GetNextActor()) + // if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ + // // Set visibility flag + // // Temporarily commented to avoid awful dependecy on SALOMEDS + // // TODO: better mechanism of storing display/erase status in a study + // // should be provided... + // //Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); + // //if(!anObj.IsNull() && anObj->hasEntry()){ + // // ToolsGUI::SetVisibility(anObj->getEntry(),false,this); + // //} + // // just display the object + // QVector aViews = myViewManager->getViews(); + // for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ + // if(SPV3D_ViewWindow* aViewWindow = dynamic_cast(aViews.at(i))) + // if(SPV3D_View* aView = aViewWindow->getView()) + // { + // if ( forced ) + // aView->Remove(anAct,false); + // else + // aView->Erase(anAct,forced); + // } + // } + // } + // } + // } +} + +/*! + Erase all presentations + \param forced - removes all objects from view +*/ +void SPV3D_ViewModel::EraseAll( SALOME_Displayer* d, const bool forced ) +{ + DBG_FUN(); + // QVector aViews = myViewManager->getViews(); + // for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ + // if(SPV3D_ViewWindow* aViewWindow = dynamic_cast(aViews.at(i))) + // if(SPV3D_View* aView = aViewWindow->getView()){ + // vtkRenderer* aRenderer = aView->getRenderer(); + // PV3D::ActorCollectionCopy aCopy(aRenderer->GetActors()); + // vtkActorCollection* anActorCollection = aCopy.GetActors(); + // anActorCollection->InitTraversal(); + // while(vtkActor* anActor = anActorCollection->GetNextActor()){ + // if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ + // // Set visibility flag + // // Temporarily commented to avoid awful dependecy on SALOMEDS + // // TODO: better mechanism of storing display/erse status in a study + // // should be provided... + // //Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); + // //if(!anObj.IsNull() && anObj->hasEntry()) + // // ToolsGUI::SetVisibility(anObj->getEntry(),false,this); + // if(forced){ + // if(SPV3D_Renderer* aRnd = aView->GetRenderer()) + // aRnd->RemoveActor(anAct); + // }else{ + // // just erase actor + // anAct->SetVisibility( false ); + // // erase dependent actors + // vtkActorCollection* aCollection = vtkActorCollection::New(); + // anAct->GetChildActors( aCollection ); + // aCollection->InitTraversal(); + // while(vtkActor* aSubAct = aCollection->GetNextActor()) + // aSubAct->SetVisibility( false ); + // aCollection->Delete(); + // } + // } + // } + // } + // } + + SALOME_View::EraseAll( d, forced ); + + Repaint(); +} + +/*! + Create presentation corresponding to the entry + \param entry - entry +*/ +SALOME_Prs* SPV3D_ViewModel::CreatePrs( const char* entry ) +{ + DBG_FUN(); + ARG(entry); + SPV3D_Prs* prs = new SPV3D_Prs( entry ); + // if ( entry ) { + // if(SPV3D_ViewWindow* aViewWindow = dynamic_cast(getViewManager()->getActiveView())) + // if(SPV3D_View* aView = aViewWindow->getView()){ + // vtkRenderer* aRenderer = aView->getRenderer(); + // PV3D::ActorCollectionCopy aCopy(aRenderer->GetActors()); + // vtkActorCollection* theActors = aCopy.GetActors(); + // theActors->InitTraversal(); + // vtkActor* ac; + // while( ( ac = theActors->GetNextActor() ) ) { + // SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); + // if ( anActor && anActor->hasIO() && !strcmp( anActor->getIO()->getEntry(), entry ) ) { + // prs->AddObject( ac ); + // } + // } + // } + // } + return prs; +} + +/*! + \return true if object is displayed in viewer + \param obj - object to be checked +*/ +bool SPV3D_ViewModel::isVisible( const Handle(SALOME_InteractiveObject)& io ) +{ + // QVector aViews = myViewManager->getViews(); + // for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) + // if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) + // if(SPV3D_ViewWindow* aViewWnd = dynamic_cast(aViewWindow)) + // if(SPV3D_View* aView = aViewWnd->getView()) + // if(!aView->isVisible( io )) + // return false; + return false; +} + +/*! + \Collect objects visible in viewer + \param theList - visible objects collection +*/ +void SPV3D_ViewModel::GetVisible( SALOME_ListIO& theList ) +{ + // here we collect object if it is disaplaed even one view + // QVector aViews = myViewManager->getViews(); + // for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) + // if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) + // if(SPV3D_ViewWindow* aViewWnd = dynamic_cast(aViewWindow)) + // if(SPV3D_View* aView = aViewWnd->getView()) + // aView->GetVisible( theList ); +} + +/*! + Updates current viewer +*/ +void SPV3D_ViewModel::Repaint() +{ + DBG_FUN(); +// if (theUpdateTrihedron) onAdjustTrihedron(); + // QVector aViews = myViewManager->getViews(); + // for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) + // if(SPV3D_ViewWindow* aViewWindow = dynamic_cast(aViews.at(i))) + // if(SPV3D_View* aView = aViewWindow->getView()) + // aView->Repaint(); +} + + +#if 0 +void SPV3D_ViewModel::onActorAdded(PV3DViewer_Actor* theActor) +{ + DBG_FUN(); + MSGEL("-----> emit actorAdded <-----"); + emit actorAdded((SPV3D_ViewWindow*)sender(), theActor); +} + +void SPV3D_ViewModel::onActorRemoved(PV3DViewer_Actor* theActor) +{ + DBG_FUN(); + MSGEL("-----> emit actorRemoved <-----"); + emit actorRemoved((SPV3D_ViewWindow*)sender(), theActor); +} +#endif + +void SPV3D_ViewModel::onViewCreated( SUIT_ViewWindow* view) { + DBG_FUN(); +#ifdef VGL_WORKAROUND + if ( SPV3D_ViewWindow* svw = dynamic_cast( view ) ) + QTimer::singleShot(500, [svw] () { svw->Repaint(); } ); +#endif +} diff --git a/src/SPV3D/SPV3D_ViewModel.h b/src/SPV3D/SPV3D_ViewModel.h new file mode 100644 index 000000000..28610f325 --- /dev/null +++ b/src/SPV3D/SPV3D_ViewModel.h @@ -0,0 +1,248 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef SPV3D_VIEWMODEL_H +#define SPV3D_VIEWMODEL_H + +#include "SPV3D.h" +//#include "SPV3D_ViewModelBase.h" +//#include "SPV3D_Selection.h" +//#include "SUIT_ViewModel.h" +#include "PV3DViewer_ViewModel.h" + +#include "Qtx.h" + +#include +#include +#include + +#include +#include + +class QMouseEvent; + +class SPV3D_ViewWindow; +class PV3DViewer_Actor; + +//! Extends two interfaces #SPV3D_ViewModelBase and #SALOME_View +class SPV3D_EXPORT SPV3D_ViewModel : public PV3DViewer_ViewModel, public SALOME_View +{ + Q_OBJECT + +public: + /*! supported gradient types */ + // enum { + // HorizontalGradient, + // VerticalGradient, + // FirstDiagonalGradient, + // SecondDiagonalGradient, + // FirstCornerGradient, + // SecondCornerGradient, + // ThirdCornerGradient, + // FourthCornerGradient, + // LastGradient = FourthCornerGradient, + // }; + + // enum { + // CrystalEyesType, RedBlueType, + // InterlacedType, LeftType, + // RightType, DresdenType, + // AnaglyphType, CheckerboardType, + // SplitViewPortHorizontalType + // }; + // typedef SPV3D_ViewWindow TViewWindow; + + //! Define string representation of the viewer type + static QString Type() { return "ParaView3D"; } + // static QString backgroundData( QStringList&, QIntList&, QIntList& ); + // static void stereoData( QStringList&, QIntList&); + + SPV3D_ViewModel(); + virtual ~SPV3D_ViewModel(); + + //! See #SUIT_ViewModel::createView + virtual SUIT_ViewWindow* createView(SUIT_Desktop*); + + //! See #SUIT_ViewModel::createView + virtual void setViewManager(SUIT_ViewManager* theViewManager); + + //! See #SUIT_ViewModel::contextMenuPopup + virtual void contextMenuPopup( QMenu* ); + + //! See #SUIT_ViewModel::getType + virtual QString getType() const { return Type(); } + + // //! Get background color of the viewer [obsolete] + // QColor backgroundColor() const; + + // //! Set background color to the viewer [obsolete] + // void setBackgroundColor( const QColor& ); + + // //! Get background color of the viewer + // Qtx::BackgroundData background() const; + + // //! Set background color to the viewer + // void setBackground( const Qtx::BackgroundData& ); + + // //! Get size of trihedron of the viewer (see #SPV3D_Renderer::SetTrihedronSize) + // double trihedronSize() const; + + // //! Shows if the size of trihedron relative (see #SPV3D_Renderer::SetTrihedronSize) + // bool trihedronRelative() const; + + // //! Set size of trihedron of the viewer (see #SPV3D_Renderer::SetTrihedronSize) + // void setTrihedronSize( const double, const bool = true ); + + // //! Get visibility status of the static trihedron + // bool isStaticTrihedronVisible() const; + + // //! Set visibility status of the static trihedron + // void setStaticTrihedronVisible( const bool ); + + // //! Gets projection mode + // int projectionMode() const; + + // //! Sets projection mode + // void setProjectionMode( const int ); + + // //! Gets stereo type + // int stereoType() const; + + // //! Sets stereo type + // void setStereoType( const int ); + + // //! Gets anaglyph filter + // int anaglyphFilter() const; + + // //! Sets anaglyph filter + // void setAnaglyphFilter( const int ); + + // //! Get support quad-buffered stereo + // bool isQuadBufferSupport() const; + + // //! Set support quad-buffered stereo + // void setQuadBufferSupport( const bool ); + + // //! Gets interaction style + // int interactionStyle() const; + + // //! Sets interaction style + // void setInteractionStyle( const int ); + + // //! Gets zooming style + // int zoomingStyle() const; + + // //! Sets zooming style + // void setZoomingStyle( const int ); + + // //! Gets current preselection mode (standard, dynamic or disabled) + // Preselection_Mode preSelectionMode() const; + + // //! Sets new preselection mode + // void setPreSelectionMode( Preselection_Mode ); + + // //! Get incremental speed (see #SPV3D_InteractorStyle::ControllerIncrement) + // int incrementalSpeed() const; + + // //! Returns modification mode of incremental speed (see #SPV3D_InteractorStyle::ControllerIncrement) + // int incrementalSpeedMode() const; + + // //! Set the incremental speed for view operation (see #SPV3D_InteractorStyle::ControllerIncrement) + // void setIncrementalSpeed( const int, const int = 0 ); + + // //! Gets spacemouse button for specified function + // int spacemouseBtn( const int ) const; + + // //! Sets spacemouse buttons + // void setSpacemouseButtons( const int, const int, const int ); + +public: + void enableSelection(bool isEnabled); + bool isSelectionEnabled() const { return mySelectionEnabled; } + + // void enableMultiselection(bool isEnable); + // bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; } + + // int getSelectionCount() const; + + /* Reimplemented from SALOME_View */ + + //! See #SALOME_View::Display( const SALOME_Prs* ) + void Display( const SALOME_PV3DPrs* ); + + //! See #SALOME_View::Erase( const SALOME_PV3DPrs*, const bool = false ) + void Erase( const SALOME_PV3DPrs*, const bool = false ); + + //! See #SALOME_View::EraseAll( SALOME_Displayer*, const bool = false ) + void EraseAll( SALOME_Displayer*, const bool = false ); + + //! See #SALOME_View::getVisible( SALOME_ListIO& ) + virtual void GetVisible( SALOME_ListIO& ); + + //! See #SALOME_View::CreatePrs( const char* entry = 0 ) + SALOME_Prs* CreatePrs( const char* entry = 0 ); + + //! See #SALOME_View::isVisible( const Handle(SALOME_InteractiveObject)& ) + virtual bool isVisible( const Handle(SALOME_InteractiveObject)& ); + + //! See #SALOME_View::Repaint() + virtual void Repaint(); + +// signals: +// void actorAdded(SPV3D_ViewWindow*, PV3DViewer_Actor*); +// void actorRemoved(SPV3D_ViewWindow*, PV3DViewer_Actor*); + +protected slots: + void onMousePress(SUIT_ViewWindow*, QMouseEvent*); + void onMouseMove(SUIT_ViewWindow*, QMouseEvent*); + void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*); + + // void onDumpView(); + // void onChangeBackground(); + + // void onActorAdded(PV3DViewer_Actor*); + // void onActorRemoved(PV3DViewer_Actor*); + + void onViewCreated( SUIT_ViewWindow* ); + +private: + // void updateToolBars(); + + // Qtx::BackgroundData myDefaultBackground; + // double myTrihedronSize; + // bool myTrihedronRelative; + // bool myIsStaticTrihedronVisible; + bool mySelectionEnabled; + // bool myMultiSelectionEnabled; + // int myIncrementSpeed; + // int myIncrementMode; + // int myProjMode; + // int myStereoType; + // int myAnaglyphFilter; + // bool myQuadBufferSupport; + // int myStyle; + // int myZoomingStyle; + // Preselection_Mode myPreSelectionMode; + // int mySpaceBtn[3]; +}; + +#endif diff --git a/src/SPV3D/SPV3D_ViewWindow.cxx b/src/SPV3D/SPV3D_ViewWindow.cxx new file mode 100644 index 000000000..a2e09a40c --- /dev/null +++ b/src/SPV3D/SPV3D_ViewWindow.cxx @@ -0,0 +1,2952 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "SPV3D_ViewWindow.h" + +// #include "SPV3D_NonIsometricDlg.h" +// #include "SPV3D_UpdateRateDlg.h" +// #include "SPV3D_CubeAxesDlg.h" +// #include "SPV3D_PsOptionsDlg.h" +// #include "SPV3D_SetRotationPointDlg.h" +// #include "SPV3D_ViewParameterDlg.h" +#include "SPV3D_ViewModel.h" +// #include "PV3DViewer_Texture.h" +// #include "PV3DViewer_OpenGLRenderer.h" + +//#include "SALOME_Actor.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include + +#include "QtxAction.h" + +#include "SUIT_Session.h" +#include "SUIT_MessageBox.h" +#include "SUIT_Accel.h" +#include "SUIT_Tools.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Accel.h" +#include "SUIT_OverrideCursor.h" +#include "SUIT_ViewManager.h" +#include "QtxActionToolMgr.h" +#include "QtxMultiAction.h" +#include "QtxActionGroup.h" + +// #include "PV3DViewer_Utilities.h" +// #include "PV3DViewer_Trihedron.h" +// #include "PV3DViewer_Actor.h" + +//#include "SPV3D_View.h" +// #include "SPV3D_Selector.h" + +// #include "SPV3D_Event.h" +// #include "SPV3D_Renderer.h" +// #include "SPV3D_InteractorStyle.h" +// #include "SPV3D_RenderWindowInteractor.h" +// #include "SPV3D_GenericRenderWindowInteractor.h" +// #include "SPV3D_CubeAxesActor2D.h" +// #include "SPV3D_ComboAction.h" +// #include "SPV3D_KeyFreeInteractorStyle.h" +// #include "SPV3D_Selector.h" +// #include "SPV3D_Recorder.h" +// #include "SPV3D_RecorderDlg.h" + +// #include "salomevtkPVAxesWidget.h" +// #include "salomevtkPVAxesActor.h" + +#include "SALOME_ListIO.hxx" + +//#include "PV3DViewer_Algorithm.h" +// #include "SPV3D_Functor.h" + +//#include + +// #ifdef __APPLE__ +// #include +// #else +// #include +// #endif + +//--------------------------------------------------------- +#define USE_DEBUG +#define MBCLASSNAME "SPV3D_ViewWindow" +#include "MBDebug.h" +//--------------------------------------------------------- + +// Use workaround for rendering transparent object over MESA +#define USE_WORKAROUND_FOR_MESA + +namespace SPV3D +{ + // int convertAction( const int accelAction ) + // { + // switch ( accelAction ) { + // case SUIT_Accel::PanLeft : return SPV3D::PanLeftEvent; + // case SUIT_Accel::PanRight : return SPV3D::PanRightEvent; + // case SUIT_Accel::PanUp : return SPV3D::PanUpEvent; + // case SUIT_Accel::PanDown : return SPV3D::PanDownEvent; + // case SUIT_Accel::ZoomIn : return SPV3D::ZoomInEvent; + // case SUIT_Accel::ZoomOut : return SPV3D::ZoomOutEvent; + // case SUIT_Accel::RotateLeft : return SPV3D::RotateLeftEvent; + // case SUIT_Accel::RotateRight : return SPV3D::RotateRightEvent; + // case SUIT_Accel::RotateUp : return SPV3D::RotateUpEvent; + // case SUIT_Accel::RotateDown : return SPV3D::RotateDownEvent; + // } + // return accelAction; + // } +} + +/*! + Constructor +*/ +SPV3D_ViewWindow::SPV3D_ViewWindow(SUIT_Desktop* theDesktop, SPV3D_ViewModel* theModel): + PV3DViewer_ViewWindow(theDesktop, theModel), //SUIT_ViewWindow(theDesktop), + myModel(theModel), + myView(NULL)//, + // myKeyFreeInteractorStyle(SPV3D_KeyFreeInteractorStyle::New()), + // myEventCallbackCommand(vtkCallbackCommand::New()), + // myDumpImage(QImage()) +{ + DBG_FUN(); + //setWindowFlags( windowFlags() & ~Qt::Window ); + // // specific of vtkSmartPointer + // myKeyFreeInteractorStyle->Delete(); +} + +#if 0 +/*! + To initialize #SPV3D_ViewWindow instance +*/ +void SPV3D_ViewWindow::Initialize(SPV3D_ViewModel/*Base*/* theModel) +{ + DBG_FUN(); + myModel = theModel; + // myInteractor = new SPV3D_RenderWindowInteractor(this,"SPV3D_RenderWindowInteractor"); + + // SPV3D_Selector* aSelector = SPV3D_Selector::New(); + // int aPreselectionMode = SUIT_Session::session()->resourceMgr()-> + // integerValue( "PV3DViewer", "preselection", Standard_Preselection ); + // aSelector->SetDynamicPreSelection( aPreselectionMode == Dynamic_Preselection ); + // aSelector->SetPreSelectionEnabled( aPreselectionMode != Preselection_Disabled ); + // bool isSelectionEnabled = SUIT_Session::session()->resourceMgr()->booleanValue( "PV3DViewer", "enable_selection", true ); + // aSelector->SetSelectionEnabled( isSelectionEnabled ); + + // SPV3D_GenericRenderWindowInteractor* aDevice = SPV3D_GenericRenderWindowInteractor::New(); + // aDevice->SetRenderWidget(myInteractor); + // aDevice->SetSelector(aSelector); + + // SPV3D_Renderer* aRenderer = SPV3D_Renderer::New(); + // aRenderer->Initialize(aDevice,aSelector); + + // myInteractor->Initialize(aDevice,aRenderer,aSelector); + + // aDevice->Delete(); + // aRenderer->Delete(); + // aSelector->Delete(); + + // myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), // title (language-dependant) + // QString( "PV3DViewerViewOperations" ), // name (language-independant) + // false ); // disable floatable toolbar + + // myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), // title (language-dependant) + // QString( "PV3DRecordingOperations" ), // name (language-independant) + // false ); // disable floatable toolbar + + // createActions( SUIT_Session::session()->resourceMgr() ); + // createToolBar(); + + // SetEventDispatcher(myInteractor->GetDevice()); + // myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground + // myInteractor->setFocusPolicy(Qt::StrongFocus); + // myInteractor->setFocus(); + // bool isSupportQuadBuffer = SUIT_Session::session()->resourceMgr()-> + // booleanValue( "PV3DViewer", "enable_quad_buffer_support", false ); + // myInteractor->getRenderWindow()->SetStereoCapableWindow((int)isSupportQuadBuffer); + // setFocusProxy(myInteractor); + + // myUpdateRateDlg = new SPV3D_UpdateRateDlg( getAction( UpdateRate ), this, "SPV3D_UpdateRateDlg" ); + // myNonIsometricDlg = new SPV3D_NonIsometricDlg( getAction( NonIsometric ), this, "SPV3D_NonIsometricDlg" ); + // myCubeAxesDlg = new SPV3D_CubeAxesDlg( getAction( GraduatedAxes ), this, "SPV3D_CubeAxesDlg" ); + // myCubeAxesDlg->initialize(); + // mySetRotationPointDlg = new SPV3D_SetRotationPointDlg + // ( getAction( ChangeRotationPointId ), this, "SPV3D_SetRotationPointDlg" ); + // myViewParameterDlg = new SPV3D_ViewParameterDlg + // ( getAction( ViewParametersId ), this, "SPV3D_ViewParameterDlg" ); + + // myDefaultInteractorStyle = SPV3D_InteractorStyle::New(); + // myInteractor->PushInteractorStyle(myDefaultInteractorStyle); + // myDefaultInteractorStyle->Delete(); + + // myRecorder = SPV3D_Recorder::New(); + + // myRecorder->SetNbFPS( 17.3 ); + // myRecorder->SetQuality( 100 ); + // myRecorder->SetProgressiveMode( true ); + // myRecorder->SetUseSkippedFrames( true ); + // myRecorder->SetRenderWindow( myInteractor->getRenderWindow() ); + + // setCentralWidget(myInteractor); + + // myAxesWidget = salomevtk::vtkPVAxesWidget::New(); + // myAxesWidget->SetParentRenderer(aRenderer->GetDevice()); + // myAxesWidget->SetViewport(0, 0, 0.25, 0.25); + // myAxesWidget->SetInteractor(myInteractor->GetDevice()); + // myAxesWidget->SetEnabled(1); + // myAxesWidget->SetInteractive(0); + + // salomevtk::vtkPVAxesActor* anAxesActor = myAxesWidget->GetAxesActor(); + // anAxesActor->GetXAxisTipProperty()->SetColor( 1.0, 0.0, 0.0 ); + // anAxesActor->GetXAxisShaftProperty()->SetColor( 1.0, 0.0, 0.0 ); + // anAxesActor->GetXAxisLabelProperty()->SetColor( 1.0, 0.0, 0.0 ); + // anAxesActor->GetYAxisTipProperty()->SetColor( 0.0, 1.0, 0.0 ); + // anAxesActor->GetYAxisShaftProperty()->SetColor( 0.0, 1.0, 0.0 ); + // anAxesActor->GetYAxisLabelProperty()->SetColor( 0.0, 1.0, 0.0 ); + // anAxesActor->GetZAxisTipProperty()->SetColor( 0.0, 0.0, 1.0 ); + // anAxesActor->GetZAxisShaftProperty()->SetColor( 0.0, 0.0, 1.0 ); + // anAxesActor->GetZAxisLabelProperty()->SetColor( 0.0, 0.0, 1.0 ); + + // myView = new SPV3D_View(this); + // Initialize(myView,theModel); + + +// myEventCallbackCommand->SetClientData(this); +// myEventCallbackCommand->SetCallback(SPV3D_ViewWindow::ProcessEvents); +// myEventCallbackCommand->Delete(); + +// GetInteractor()->GetInteractorStyle()->AddObserver(SPV3D::OperationFinished, +// myEventCallbackCommand.GetPointer(), 0.0); +// myKeyFreeInteractorStyle->AddObserver(SPV3D::OperationFinished, +// myEventCallbackCommand.GetPointer(), 0.0); + +// #ifdef USE_WORKAROUND_FOR_MESA +// char *mesavar = getenv("SALOME_USE_MESA"); +// if (mesavar) +// getRenderer()->SetUseDepthPeeling(1); +// #endif //USE_WORKAROUND_FOR_MESA + +// getRenderer()->SetBackgroundAlpha(1.0); +// myInteractor->getRenderWindow()->SetMultiSamples(0); +// myInteractor->getRenderWindow()->Render(); +// setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background +// onResetView(); +} + +/*! + To initialize #SPV3D_ViewWindow instance +*/ +// void SPV3D_ViewWindow::Initialize(SPV3D_View* theView, +// SPV3D_ViewModel/*Base*/* theModel) +// { +// DBG_FUN(); +// connect(theView,SIGNAL(KeyPressed(QKeyEvent*)), +// this,SLOT(onKeyPressed(QKeyEvent*)) ); +// connect(theView,SIGNAL(KeyReleased(QKeyEvent*)), +// this,SLOT(onKeyReleased(QKeyEvent*))); +// connect(theView,SIGNAL(MouseButtonPressed(QMouseEvent*)), +// this,SLOT(onMousePressed(QMouseEvent*))); +// connect(theView,SIGNAL(MouseButtonReleased(QMouseEvent*)), +// this,SLOT(onMouseReleased(QMouseEvent*))); +// connect(theView,SIGNAL(MouseDoubleClicked(QMouseEvent*)), +// this,SLOT(onMouseDoubleClicked(QMouseEvent*))); +// connect(theView,SIGNAL(MouseMove(QMouseEvent*)), +// this,SLOT(onMouseMoving(QMouseEvent*))); +// connect(theView,SIGNAL(contextMenuRequested(QContextMenuEvent*)), +// this,SIGNAL(contextMenuRequested(QContextMenuEvent *))); +// // connect(theView,SIGNAL(selectionChanged()), +// // theModel,SLOT(onSelectionChanged())); + +// // connect( this, SIGNAL( transformed( SPV3D_ViewWindow* ) ), SLOT( emitViewModified() ) ); +// } +#endif + +/*! + Destructor +*/ +SPV3D_ViewWindow::~SPV3D_ViewWindow() +{ + DBG_FUN(); + // myRecorder->Delete(); + // myAxesWidget->Delete(); +} + + +/*! + \return corresponding view +*/ +// SPV3D_View* SPV3D_ViewWindow::getView() +// { +// return myView; +// } + +#if 0 +/*! + \return corresponding vtk render window +*/ +vtkRenderWindow* SPV3D_ViewWindow::getRenderWindow() +{ + return GetInteractor()->getRenderWindow(); +} + +/*! + \return corresponding vtk render window interactor +*/ +SPV3D_RenderWindowInteractor* SPV3D_ViewWindow::GetInteractor() const +{ + return myInteractor; +} + +/*! + \return corresponding vtk render window interactor +*/ +vtkRenderWindowInteractor* SPV3D_ViewWindow::getInteractor() const +{ + return myInteractor->GetDevice(); +} + +/*! + \return corresponding vtk renderer +*/ +vtkRenderer* SPV3D_ViewWindow::getRenderer() const +{ + return GetInteractor()->getRenderer(); +} + +/*! + Redirect the request to SPV3D_RenderWindowInteractor::GetRenderer +*/ +SPV3D_Renderer* SPV3D_ViewWindow::GetRenderer() const +{ + return GetInteractor()->GetRenderer(); +} +#endif + +/*! + \return corresponding vtk selector +*/ +// SPV3D_Selector* SPV3D_ViewWindow::GetSelector() const +// { +// return GetInteractor()->GetSelector(); +// } + +#if 0 +/*! + Processes transformation "front view" +*/ +void SPV3D_ViewWindow::onFrontView() +{ + DBG_FUN(); + GetRenderer()->OnFrontView(); + Repaint(); + emit transformed( this ); +} + +/*! + Processes transformation "back view" +*/ +void SPV3D_ViewWindow::onBackView() +{ + DBG_FUN(); + GetRenderer()->OnBackView(); + Repaint(); + emit transformed( this ); +} + +/*! + Processes transformation "top view" +*/ +void SPV3D_ViewWindow::onTopView() +{ + DBG_FUN(); + GetRenderer()->OnTopView(); + Repaint(); + emit transformed( this ); +} + +/*! + Processes transformation "bottom view" +*/ +void SPV3D_ViewWindow::onBottomView() +{ + DBG_FUN(); + GetRenderer()->OnBottomView(); + Repaint(); + emit transformed( this ); +} + +/*! + Processes transformation "left view" +*/ +void SPV3D_ViewWindow::onLeftView() +{ + DBG_FUN(); + GetRenderer()->OnLeftView(); + Repaint(); + emit transformed( this ); +} + +/*! + Processes transformation "right view" +*/ +void SPV3D_ViewWindow::onRightView() +{ + DBG_FUN(); + GetRenderer()->OnRightView(); + Repaint(); + emit transformed( this ); +} + +/*! + \brief Rotate view 90 degrees clockwise +*/ +void SPV3D_ViewWindow::onClockWiseView() +{ + DBG_FUN(); + GetRenderer()->onClockWiseView(); + Repaint(); + emit transformed( this ); +} + +/*! + \brief Rotate view 90 degrees conterclockwise +*/ +void SPV3D_ViewWindow::onAntiClockWiseView() +{ + DBG_FUN(); + GetRenderer()->onAntiClockWiseView(); + Repaint(); + emit transformed( this ); +} + +/*! + Processes transformation "reset view": sets default orientation of viewport camera +*/ +void SPV3D_ViewWindow::onResetView() +{ + DBG_FUN(); + GetRenderer()->OnResetView(); + Repaint(); + emit transformed( this ); +} + +/*! + Processes transformation "fit all" +*/ +void SPV3D_ViewWindow::onFitAll() +{ + DBG_FUN(); + GetRenderer()->OnFitAll(); + Repaint(); + emit transformed( this ); +} + +/*! + Processes transformation "fit selection" +*/ +void SPV3D_ViewWindow::onFitSelection() +{ + DBG_FUN(); + GetRenderer()->onFitSelection(); + Repaint(); + emit transformed( this ); +} + +/*! + Processes transformation "fit given objects" +*/ +void SPV3D_ViewWindow::onFitIObjects(const SALOME_ListIO& objects) +{ + DBG_FUN(); + GetRenderer()->OnFitIObjects(objects); + Repaint(); + emit transformed( this ); +} + +/*! + SLOT: called if selection is changed +*/ +void SPV3D_ViewWindow::onSelectionChanged() +{ + DBG_FUN(); + myView->onSelectionChanged(); +} + +/*! + Change selection mode + \param theMode - new selection mode +*/ +void SPV3D_ViewWindow::SetSelectionMode(Selection_Mode theMode) +{ + DBG_FUN(); + GetSelector()->SetSelectionMode(theMode); +} + +/*! + \return selection mode +*/ +Selection_Mode SPV3D_ViewWindow::SelectionMode() const +{ + return GetSelector()->SelectionMode(); +} + +/*! + Unhilights all objects in viewer +*/ +void SPV3D_ViewWindow::unHighlightAll() +{ + myView->unHighlightAll(); +} + +/*! + Hilights/unhilights object in viewer + \param theIO - object to be updated + \param theIsHighlight - if it is true, object will be hilighted, otherwise it will be unhilighted + \param theIsUpdate - update current viewer +*/ +void SPV3D_ViewWindow::highlight(const Handle(SALOME_InteractiveObject)& theIO, + bool theIsHighlight, + bool theIsUpdate ) +{ + myView->highlight( theIO, theIsHighlight, theIsUpdate ); +} + +/*! + \return true if object is in viewer or in collector + \param theIO - object to be checked +*/ +bool SPV3D_ViewWindow::isInViewer( const Handle(SALOME_InteractiveObject)& theIO ) +{ + return myView->isInViewer( theIO ); +} +#endif + +#if 0 +/*! + \return true if object is displayed in viewer + \param theIO - object to be checked +*/ +bool SPV3D_ViewWindow::isVisible( const Handle(SALOME_InteractiveObject)& theIO ) +{ + return myView->isVisible( theIO ); +} + +/*! + Display object + \param theEntry - entry that corresponds to intractive objects +*/ +Handle(SALOME_InteractiveObject) SPV3D_ViewWindow::FindIObject(const char* theEntry) +{ + return myView->FindIObject(theEntry); +} +#endif + +/*! + Display object + \param theIO - object + \param theImmediatly - update viewer +*/ +void SPV3D_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO, + bool theImmediatly) +{ + DBG_FUN(); + //myView->Display(theIO,theImmediatly); +} + +/*! + Erase object + \param theIO - object + \param theImmediatly - update viewer +*/ +void SPV3D_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO, + bool theImmediatly) +{ + DBG_FUN(); + //myView->Erase(theIO,theImmediatly); +} + +/*! + Display only passed object + \param theIO - object +*/ +void SPV3D_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO) +{ + DBG_FUN(); + //myView->DisplayOnly(theIO); +} + +/*! + Display all objects in view +*/ +void SPV3D_ViewWindow::DisplayAll() +{ + DBG_FUN(); + //myView->DisplayAll(); +} + +/*! + Erase all objects in view +*/ +void SPV3D_ViewWindow::EraseAll() +{ + DBG_FUN(); + //myView->EraseAll(); +} + +#if 0 +/*! + Sets background color [obsolete] + \param color - new background color +*/ +void SPV3D_ViewWindow::setBackgroundColor( const QColor& c ) +{ + DBG_FUN(); + Qtx::BackgroundData bg = background(); + bg.setColor( c ); + setBackground( bg ); +} + +/*! + \return background color of viewer [obsolete] +*/ +QColor SPV3D_ViewWindow::backgroundColor() const +{ + return background().color(); +} + +/*! + Sets background data + \param bgData - new background data +*/ +void SPV3D_ViewWindow::setBackground( const Qtx::BackgroundData& bgData ) +{ + DBG_FUN(); + bool ok = false; + + if ( bgData.isValid() ) { + switch ( bgData.mode() ) { + case Qtx::ColorBackground: + { + QColor c = bgData.color(); + if ( c.isValid() ) { + // show solid-colored background + getRenderer()->SetTexturedBackground( false ); // cancel texture mode + getRenderer()->SetGradientBackground( false ); // cancel gradient mode + getRenderer()->SetBackground( c.red()/255.0, + c.green()/255.0, + c.blue()/255.0 ); // set background color + ok = true; + } + break; + } + case Qtx::SimpleGradientBackground: + { + QColor c1, c2; + int type = bgData.gradient( c1, c2 ); + if ( c1.isValid() ) + { + if ( !c2.isValid() ) + c2 = c1; + + // show two-color gradient background + getRenderer()->SetTexturedBackground( false ); // cancel texture mode + getRenderer()->SetGradientBackground( true ); // switch to gradient mode + + PV3DViewer_OpenGLRenderer* aRenderer = + PV3DViewer_OpenGLRenderer::SafeDownCast( getRenderer() ); + if( aRenderer ) + { + aRenderer->SetGradientType( type ); + aRenderer->SetBackground( c1.redF(), c1.greenF(), c1.blueF() ); + aRenderer->SetBackground2( c2.redF(), c2.greenF(), c2.blueF() ); + ok = true; + } + } + break; + } + case Qtx::CustomGradientBackground: + { + // NOT IMPLEMENTED YET + getRenderer()->SetTexturedBackground( false ); // cancel texture mode + getRenderer()->SetGradientBackground( false ); // cancel gradient mode + // ......... + break; + } + default: + break; + } + if ( bgData.isTextureShown() ) { + QString fileName; + int textureMode = bgData.texture( fileName ); + QFileInfo fi( fileName ); + if ( !fileName.isEmpty() && fi.exists() ) { + // read texture from file + QString extension = fi.suffix().toLower(); + vtkImageReader2* aReader = 0; + if ( extension == "jpg" || extension == "jpeg" ) + aReader = vtkJPEGReader::New(); + else if ( extension == "bmp" ) + aReader = vtkBMPReader::New(); + else if ( extension == "tif" || extension == "tiff" ) + aReader = vtkTIFFReader::New(); + else if ( extension == "png" ) + aReader = vtkPNGReader::New(); + else if ( extension == "mhd" || extension == "mha" ) + aReader = vtkMetaImageReader::New(); + if ( aReader ) { + // create texture + aReader->SetFileName( fi.absoluteFilePath().toUtf8().constData() ); + aReader->Update(); + PV3DViewer_Texture* aTexture = PV3DViewer_Texture::New(); + vtkImageMapToColors* aMap = 0; + vtkAlgorithmOutput* anOutput; + /* + // special processing for BMP reader + vtkBMPReader* aBMPReader = (vtkBMPReader*)aReader; + if ( aBMPReader ) { + // Special processing for BMP file + aBMPReader->SetAllow8BitBMP(1); + + aMap = vtkImageMapToColors::New(); + aMap->SetInputConnection( aBMPReader->GetOutputPort() ); + aMap->SetLookupTable( (vtkScalarsToColors*)aBMPReader->GetLookupTable() ); + aMap->SetOutputFormatToRGB(); + + anOutput = aMap->GetOutputPort(); + } + else { + } + */ + anOutput = aReader->GetOutputPort( 0 ); + aTexture->SetInputConnection( anOutput ); + // set texture mode + // VSR: Currently, PV3D only supports Stretch mode, so below code will give + // the same results for all modes + switch ( textureMode ) { + case Qtx::TileTexture: + aTexture->SetPosition((int)PV3DViewer_Texture::Tiled); + break; + case Qtx::StretchTexture: + aTexture->SetPosition((int)PV3DViewer_Texture::Stretched); + break; + case Qtx::CenterTexture: + aTexture->SetPosition((int)PV3DViewer_Texture::Centered); + default: + break; + } + // show textured background + getRenderer()->SetTexturedBackground( true ); + getRenderer()->SetBackgroundTexture( aTexture ); + + // clean-up resources + if ( aMap ) + aMap->Delete(); + aReader->Delete(); + aTexture->Delete(); + ok = true; + } + } + } + } + if ( ok ) + myBackground = bgData; +} + +/*! + \return background data of viewer +*/ +Qtx::BackgroundData SPV3D_ViewWindow::background() const +{ + return myBackground; +} + + +/*! + Redirect the request to SPV3D_RenderWindowInteractor::GetInteractorStyle +*/ +vtkInteractorStyle* SPV3D_ViewWindow::GetInteractorStyle() const +{ + return GetInteractor()->GetInteractorStyle(); +} + +/*! + Redirect the request to SPV3D_RenderWindowInteractor::PushInteractorStyle +*/ +void SPV3D_ViewWindow::PushInteractorStyle(vtkInteractorStyle* theStyle) +{ + GetInteractor()->PushInteractorStyle(theStyle); +} + +/*! + Redirect the request to SPV3D_RenderWindowInteractor::PopInteractorStyle +*/ +void SPV3D_ViewWindow::PopInteractorStyle() +{ + GetInteractor()->PopInteractorStyle(); +} +#endif + +/*! + Updates current viewer +*/ +void SPV3D_ViewWindow::Repaint(bool )//(bool theUpdateTrihedron) +{ +// if(theUpdateTrihedron) +// GetRenderer()->OnAdjustTrihedron(); + +// GetInteractor()->update(); + +// SPV3D_InteractorStyle* aStyle = (SPV3D_InteractorStyle*)getInteractor()->GetInteractorStyle(); +// if ( aStyle ) { +// #ifdef VGL_WORKAROUND +// if ( aStyle->GetCurrentRenderer() == nullptr ) { +// if( GetRenderer() ) { +// aStyle->SetCurrentRenderer(GetRenderer()->GetDevice()); +// } +// } +// #endif +// aStyle->OnTimer(); +// } +} + +#if 0 +/*! + Redirect the request to #SPV3D_Renderer::GetScale +*/ +void SPV3D_ViewWindow::GetScale( double theScale[3] ) +{ + GetRenderer()->GetScale( theScale ); +} + +/*! + Redirect the request to #SPV3D_Renderer::SetScale +*/ +void SPV3D_ViewWindow::SetScale( double theScale[3] ) +{ + GetRenderer()->SetScale( theScale ); + Repaint(); + emit transformed( this ); +} + +/*! + Redirect the request to #SPV3D_Renderer::IsTrihedronDisplayed +*/ +bool SPV3D_ViewWindow::isTrihedronDisplayed() +{ + return GetRenderer()->IsTrihedronDisplayed(); +} + +/*! + Redirect the request to #SPV3D_Renderer::IsCubeAxesDisplayed +*/ +bool SPV3D_ViewWindow::isCubeAxesDisplayed() +{ + return GetRenderer()->IsCubeAxesDisplayed(); +} + +/*! + Redirect the request to #SPV3D_Renderer::OnViewTrihedron +*/ +void SPV3D_ViewWindow::onViewTrihedron(bool show) +{ + DBG_FUN(); + GetRenderer()->SetTrihedronVisibility(show); + Repaint(); +} + +/*! + Redirect the request to #SPV3D_Renderer::OnViewCubeAxes +*/ +void SPV3D_ViewWindow::onViewCubeAxes() +{ + GetRenderer()->OnViewCubeAxes(); + Repaint(); +} + +/*! + Redirect the request to #SPV3D_Renderer::GetTrihedron +*/ +PV3DViewer_Trihedron* SPV3D_ViewWindow::GetTrihedron() +{ + return GetRenderer()->GetTrihedron(); +} + +/*! + Redirect the request to #SPV3D_Renderer::GetCubeAxes +*/ +SPV3D_CubeAxesActor2D* SPV3D_ViewWindow::GetCubeAxes() +{ + return GetRenderer()->GetCubeAxes(); +} + +/*! + \return trihedron size +*/ +double SPV3D_ViewWindow::GetTrihedronSize() const +{ + return GetRenderer()->GetTrihedronSize(); +} + +/*! + Sets projection mode + \param theMode - projection mode ( 0 - orthogonal, 1 - perspective, 2 - stereo ) +*/ +void SPV3D_ViewWindow::SetProjectionMode(const int theMode) +{ + DBG_FUN(); + QtxAction* aParallelAction = dynamic_cast( toolMgr()->action( ParallelModeId ) ); + QtxAction* aProjectionAction = dynamic_cast( toolMgr()->action( ProjectionModeId ) ); + QtxAction* aStereoAction = dynamic_cast( toolMgr()->action( StereoModeId ) ); + + switch ( theMode ) { + case Parallel: + onProjectionMode( aParallelAction ); + break; + case Projection: + onProjectionMode( aProjectionAction ); + break; + case Stereo: + onStereoMode( true ); + break; + } + + // update action state if method is called outside + SPV3D_Viewer* aViewer = dynamic_cast(myModel); + QtxAction* aSwitchZoomingStyle = dynamic_cast( toolMgr()->action( SwitchZoomingStyleId ) ); + if ( theMode == Parallel && !aParallelAction->isChecked() ) { + aParallelAction->setChecked( true ); + aSwitchZoomingStyle->setEnabled(true); + aStereoAction->setChecked( false ); + } + if ( theMode == Projection && !aProjectionAction->isChecked() ) { + aProjectionAction->setChecked( true ); + aSwitchZoomingStyle->setEnabled(false); + } + if ( theMode == Stereo ) { + aStereoAction->setChecked( true ); + if ( aParallelAction->isEnabled() ) { + aParallelAction->setEnabled( false ); + aParallelAction->setChecked( false ); + aStereoAction->setChecked( false ); + } + else { + aParallelAction->setEnabled( true ); + aStereoAction->setChecked( false ); + aParallelAction->setChecked( aViewer->projectionMode() == Parallel ); + } + if ( aProjectionAction->isEnabled() ) { + aProjectionAction->setEnabled( false ); + aProjectionAction->setChecked( true ); + if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() && + strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 && + toolMgr()->action( StereoModeId )->isChecked() ) { + SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) ); + } + } + else { + aProjectionAction->setEnabled( true ); + aStereoAction->setChecked( false ); + aProjectionAction->setChecked( aViewer->projectionMode() == Projection ); + onProjectionMode(); + } + } + else { + if ( !aParallelAction->isEnabled() ) + aParallelAction->setEnabled( true ); + if ( !aProjectionAction->isEnabled() ) + aProjectionAction->setEnabled( true ); + } +} + +/*! + Sets stereo type + \param theType - stereo type +*/ +void SPV3D_ViewWindow::SetStereoType(const int theType) +{ + DBG_FUN(); + vtkRenderWindow* aWindow = getRenderWindow(); + switch (theType ) { + case CrystalEyes: + aWindow->SetStereoTypeToCrystalEyes(); + break; + case RedBlue: + aWindow->SetStereoTypeToRedBlue(); + break; + case Interlaced: + aWindow->SetStereoTypeToInterlaced(); + break; + case Left: + aWindow->SetStereoTypeToLeft(); + break; + case Right: + aWindow->SetStereoTypeToRight(); + break; + case Dresden: + aWindow->SetStereoTypeToDresden(); + break; + case Anaglyph: + aWindow->SetStereoTypeToAnaglyph(); + break; + case Checkerboard: + aWindow->SetStereoTypeToCheckerboard(); + break; + case SplitViewPortHorizontal: + aWindow->SetStereoTypeToSplitViewportHorizontal(); + break; + } +} + +/*! + Sets anaglyph filter + \param theFilter - anaglyph filter +*/ +void SPV3D_ViewWindow::SetAnaglyphFilter(const int theFilter) +{ + DBG_FUN(); + vtkRenderWindow* aWindow = getRenderWindow(); + switch (theFilter ) { + case RedCyan: + aWindow->SetAnaglyphColorMask(4,3); + break; + case YellowBlue: + aWindow->SetAnaglyphColorMask(6,1); + break; + case GreenMagenta: + aWindow->SetAnaglyphColorMask(2,5); + break; + } +} + +/*! + Set support quad-buffered stereo + \param theEnable - enable/disable support quad-buffered stereo +*/ +void SPV3D_ViewWindow::SetQuadBufferSupport(const bool theEnable) +{ + DBG_FUN(); + vtkRenderWindow* aWindow = getRenderWindow(); + aWindow->SetStereoCapableWindow((int)theEnable); +} + +/*! + \return OpenGl stereo support +*/ +bool SPV3D_ViewWindow::isOpenGlStereoSupport() const +{ + GLboolean support[1]; + glGetBooleanv (GL_STEREO, support); + if ( support[0] ) + return true; + return false; +} + +/*! + Set the gravity center as a focal point +*/ +void SPV3D_ViewWindow::activateSetFocalPointGravity() +{ + myEventDispatcher->InvokeEvent(SPV3D::SetFocalPointGravity, 0); +} + +/*! + Activate interactive selection +*/ +void SPV3D_ViewWindow::activateInteractiveSelection() +{ + myEventDispatcher->InvokeEvent(SPV3D::StartInteractiveSelection, 0); +} + +/* + Deactivate current active operation +*/ +void SPV3D_ViewWindow::deactivateCurrectOperation() { + myEventDispatcher->InvokeEvent(SPV3D::StopCurrentOperation, 0); +} + +/*! + Set the selected point as a focal point +*/ +void SPV3D_ViewWindow::activateSetFocalPointSelected() +{ + myEventDispatcher->InvokeEvent(SPV3D::SetFocalPointSelected, 0); +} + +/*! + Set the point selected by user as a focal point +*/ +void SPV3D_ViewWindow::activateStartFocalPointSelection() +{ + myEventDispatcher->InvokeEvent(SPV3D::StartFocalPointSelection,0); +} + +void SPV3D_ViewWindow::activateProjectionMode(int theMode) +{ + QtxAction* aParallelAction = dynamic_cast( toolMgr()->action( ParallelModeId ) ); + QtxAction* aProjectionAction = dynamic_cast( toolMgr()->action( ProjectionModeId ) ); + if (theMode) + aParallelAction->setChecked( true ); + else + aProjectionAction->setChecked( true ); + + if ( !aParallelAction->isEnabled() ) + aParallelAction->setEnabled( true ); + if ( !aProjectionAction->isEnabled() ) + aProjectionAction->setEnabled( true ); +} + +/*! + Sets actual interaction style + \param theStyle - type of interaction style ( 0 - standard, 1 - keyboard free ) +*/ +void SPV3D_ViewWindow::SetInteractionStyle(const int theStyle) +{ + DBG_FUN(); + onSwitchInteractionStyle( theStyle==1 ); +} + +/*! + Sets actual zooming style + \param theStyle - type of zooming style ( 0 - standard, 1 - advanced (at cursor) ) +*/ +void SPV3D_ViewWindow::SetZoomingStyle(const int theStyle) +{ + DBG_FUN(); + onSwitchZoomingStyle( theStyle==1 ); +} + +/*! + Set preselection mode. + \param theMode the mode to set (standard, dynamic or disabled) +*/ +void SPV3D_ViewWindow::SetPreSelectionMode( Preselection_Mode theMode ) +{ + DBG_FUN(); + onSwitchPreSelectionMode( theMode ); +} +#endif + +/*! + Enables/disables selection. + \param theEnable if true - selection will be enabled +*/ +void SPV3D_ViewWindow::SetSelectionEnabled( bool theEnable ) +{ + DBG_FUN(); + // GetSelector()->SetSelectionEnabled( theEnable ); + // QtxAction* a = getAction( EnableSelectionId ); + // if ( a->isChecked() != theEnable) + // a->setChecked( theEnable ); + // QtxActionGroup* aPreselectionGroup = + // dynamic_cast( getAction( PreselectionId ) ); + // if ( aPreselectionGroup ) + // aPreselectionGroup->setEnabled( theEnable ); + + // // notify actors + // vtkActorCollection *actors = getRenderer()->GetActors(); + // for (int i = 0; i < actors->GetNumberOfItems(); ++i ) + // if (PV3DViewer_Actor *actor = dynamic_cast(actors->GetItemAsObject(i))) + // { + // actor->EnableSelection( theEnable ); + // } +} + +#if 0 +/*! + Switches "keyboard free" interaction style on/off +*/ +void SPV3D_ViewWindow::onSwitchInteractionStyle(bool theOn) +{ + DBG_FUN(); + if (theOn) { + // check if style is already set + if ( GetInteractorStyle() != myKeyFreeInteractorStyle.GetPointer() ) + { + // keep the same style extensions + SPV3D_InteractorStyle* aStyle = (SPV3D_InteractorStyle*)GetInteractorStyle(); + if ( aStyle ) { + myKeyFreeInteractorStyle->SetControllerIncrement(aStyle->ControllerIncrement()); + myKeyFreeInteractorStyle->SetControllerOnKeyDown(aStyle->ControllerOnKeyDown()); + } + + PushInteractorStyle(myKeyFreeInteractorStyle.GetPointer()); + } + } + else { + // pop only key free style + if ( GetInteractorStyle() == myKeyFreeInteractorStyle.GetPointer() ) + PopInteractorStyle(); + } + + // update action state if method is called outside + QtxAction* a = getAction( SwitchInteractionStyleId ); + if ( a->isChecked() != theOn ) a->setChecked( theOn ); +} + +/*! + Toogles advanced zooming style (relatively to the cursor position) on/off +*/ +void SPV3D_ViewWindow::onSwitchZoomingStyle( bool theOn ) +{ + DBG_FUN(); + if( myDefaultInteractorStyle.GetPointer() ) + myDefaultInteractorStyle->SetAdvancedZoomingEnabled( theOn ); + if( myKeyFreeInteractorStyle.GetPointer() ) + myKeyFreeInteractorStyle->SetAdvancedZoomingEnabled( theOn ); + + // update action state if method is called outside + QtxAction* a = getAction( SwitchZoomingStyleId ); + if ( a->isChecked() != theOn ) + a->setChecked( theOn ); +} + +/*! + Switch preselection mode. + \param theMode the preselection mode +*/ +void SPV3D_ViewWindow::onSwitchPreSelectionMode( int theMode ) +{ + DBG_FUN(); + GetSelector()->SetDynamicPreSelection( theMode == Dynamic_Preselection ); + GetSelector()->SetPreSelectionEnabled( theMode != Preselection_Disabled ); + + // update action state if method is called outside + QtxAction* a = getAction( StandardPreselectionId + theMode ); + if ( a && !a->isChecked() ) + a->setChecked( true ); +} + +/*! + Enables/disables selection. + \param theOn if true - selection will be enabled +*/ +void SPV3D_ViewWindow::onEnableSelection( bool on ) +{ + DBG_FUN(); + SPV3D_Viewer* aViewer = dynamic_cast(myModel); + if(aViewer) + aViewer->enableSelection(on); +} + +/*! + Sets incremental speed + \param theValue - new incremental speed + \param theMode - modification mode +*/ +void SPV3D_ViewWindow::SetIncrementalSpeed(const int theValue, const int theMode) +{ + DBG_FUN(); + if ( (SPV3D_InteractorStyle*)GetInteractorStyle() ) + ((SPV3D_InteractorStyle*)GetInteractorStyle())->SetIncrementSpeed(theValue, theMode); +} + +/*! + Sets spacemouse buttons for the functions + \param theBtn1 - spacemouse button for the "decrease speed increment" + \param theBtn2 - spacemouse button for the "increase speed increment" + \param theBtn3 - spacemouse button for the "dominant combined switch" +*/ +void SPV3D_ViewWindow::SetSpacemouseButtons(const int theBtn1, + const int theBtn2, + const int theBtn3) +{ + DBG_FUN(); + int val = theBtn1; + myEventDispatcher->InvokeEvent(SPV3D::SetSMDecreaseSpeedEvent, &val); + val = theBtn2; + myEventDispatcher->InvokeEvent(SPV3D::SetSMIncreaseSpeedEvent, &val); + val = theBtn3; + myEventDispatcher->InvokeEvent(SPV3D::SetSMDominantCombinedSwitchEvent, &val); +} + +/*! + Sets trihedron size + \param theSize - new trihedron size + \param theRelative - trihedron relativeness +*/ +void SPV3D_ViewWindow::SetTrihedronSize(const double theSize, const bool theRelative) +{ + GetRenderer()->SetTrihedronSize(theSize, theRelative); + Repaint(); +} + +/*! If parameter theIsForcedUpdate is true, recalculate parameters for + * trihedron and cube axes, even if trihedron and cube axes is invisible. + */ +void SPV3D_ViewWindow::AdjustTrihedrons(const bool /*theIsForcedUpdate*/) +{ + GetRenderer()->AdjustActors(); + Repaint(); +} + +/*! + Redirect the request to #SPV3D_Renderer::OnAdjustTrihedron +*/ +void SPV3D_ViewWindow::onAdjustTrihedron() +{ + GetRenderer()->OnAdjustTrihedron(); +} + +/*! + Redirect the request to #SPV3D_Renderer::OnAdjustCubeAxes +*/ +void SPV3D_ViewWindow::onAdjustCubeAxes() +{ + GetRenderer()->OnAdjustCubeAxes(); +} + +void SPV3D_ViewWindow::synchronize(SPV3D_ViewWindow* otherViewWindow ) +{ + DBG_FUN(); + if ( otherViewWindow ) { + bool blocked = blockSignals( true ); + doSetVisualParameters( otherViewWindow->getVisualParameters(), true ); + blockSignals( blocked ); + } +} +#endif + +/*! + Emits key pressed +*/ +void SPV3D_ViewWindow::onKeyPressed(QKeyEvent* event) +{ + emit keyPressed( this, event ); +} + +/*! + Emits key released +*/ +void SPV3D_ViewWindow::onKeyReleased(QKeyEvent* event) +{ + emit keyReleased( this, event ); +} + +/*! + Emits mouse pressed +*/ +void SPV3D_ViewWindow::onMousePressed(QMouseEvent* event) +{ + emit mousePressed(this, event); +} + +/*! + Emits mouse released +*/ +void SPV3D_ViewWindow::onMouseReleased(QMouseEvent* event) +{ + DBG_FUN(); + emit mouseReleased( this, event ); +} + +/*! + Emits mouse moving +*/ +void SPV3D_ViewWindow::onMouseMoving(QMouseEvent* event) +{ + emit mouseMoving( this, event ); +} + +/*! + Emits mouse double clicked +*/ +void SPV3D_ViewWindow::onMouseDoubleClicked( QMouseEvent* event ) +{ + MSGEL("-----> emit mouseDoubleClicked <-----"); + emit mouseDoubleClicked( this, event ); +} + +#if 0 +/*! + Redirect the request to #SPV3D_Renderer::AddActor +*/ +void SPV3D_ViewWindow::AddActor( PV3DViewer_Actor* theActor, + bool theUpdate, + bool theIsAdjustActors ) +{ + DBG_FUN(); + GetRenderer()->AddActor(theActor, theIsAdjustActors); + if(theUpdate) + Repaint(); + emit actorAdded(theActor); +} + +/*! + Redirect the request to #SPV3D_Renderer::RemoveActor +*/ +void SPV3D_ViewWindow::RemoveActor( PV3DViewer_Actor* theActor, + bool theUpdate, + bool theIsAdjustActors ) +{ + DBG_FUN(); + GetRenderer()->RemoveActor(theActor, theIsAdjustActors); + if ( myDefaultInteractorStyle ) + myDefaultInteractorStyle->FreeActors(); + if ( myKeyFreeInteractorStyle ) + myKeyFreeInteractorStyle->FreeActors(); + if(theUpdate) + Repaint(); + emit actorRemoved(theActor); +} + +QImage SPV3D_ViewWindow::dumpViewContent() +{ + vtkRenderWindow* aWindow = getRenderWindow(); + int* aSize = aWindow->GetSize(); + int aWidth = aSize[0]; + int aHeight = aSize[1]; + +#ifndef DISABLE_GLVIEWER + OpenGLUtils_FrameBuffer aFrameBuffer; + if( aFrameBuffer.init( aWidth, aHeight ) ) + { + glPushAttrib( GL_VIEWPORT_BIT ); + glViewport( 0, 0, aWidth, aHeight ); + aFrameBuffer.bind(); + + // draw scene + aWindow->Render(); + + //aFrameBuffer.unbind(); + glPopAttrib(); + + QImage anImage( aWidth, aHeight, QImage::Format_RGB32 ); + //aFrameBuffer.bind(); + + glReadPixels( 0, 0, aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, anImage.bits() ); + aFrameBuffer.unbind(); + + anImage = anImage.rgbSwapped(); + anImage = anImage.mirrored(); + return anImage; + } +#endif + + // if frame buffers are unsupported, use old functionality + unsigned char *aData = + aWindow->GetRGBACharPixelData( 0, 0, aWidth-1, aHeight-1, 0 ); + + QImage anImage( aData, aWidth, aHeight, QImage::Format_ARGB32 ); + + anImage = anImage.rgbSwapped(); + anImage = anImage.mirrored(); + return anImage; +} + +/*! + \return QImage, containing all scene rendering in window +*/ +QImage SPV3D_ViewWindow::dumpView() +{ + if( myDumpImage.isNull() ) + return dumpViewContent(); + + RefreshDumpImage(); + return myDumpImage; +} + +QString SPV3D_ViewWindow::filter() const +{ + return tr( "SPV3D_IMAGE_FILES" ); +} + +bool SPV3D_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format ) +{ + if ( format != "PS" && format != "EPS" && format != "PDF" ) + return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format ); + + SPV3D_PsOptionsDlg* optionsDlg = new SPV3D_PsOptionsDlg(this); + if ( optionsDlg->exec() == QDialog::Accepted ) { + SUIT_OverrideCursor wc; + + vtkGL2PSExporter *anExporter = vtkGL2PSExporter::New(); + anExporter->SetRenderWindow(getRenderWindow()); + + // Set options + anExporter->SetLineWidthFactor(optionsDlg->getLineFactor()); + anExporter->SetPointSizeFactor(optionsDlg->getPointFactor()); + anExporter->SetSort((vtkGL2PSExporter::SortScheme)optionsDlg->getSortType()); + anExporter->SetWrite3DPropsAsRasterImage((int)optionsDlg->isRasterize3D()); + anExporter->SetPS3Shading((int)optionsDlg->isPs3Shading()); + + if ( format == "PS" ) { + anExporter->SetFileFormatToPS(); + anExporter->CompressOff(); + } + + if ( format == "EPS" ) { + anExporter->SetFileFormatToEPS(); + anExporter->CompressOff(); + } + + if ( format == "PDF" ) { + anExporter->SetFileFormatToPDF(); + } + + QString aFilePrefix(fileName); + QString anExtension(SUIT_Tools::extension(fileName)); + aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length()); + anExporter->SetFilePrefix(aFilePrefix.toUtf8().data()); + anExporter->Write(); + anExporter->Delete(); + } + delete optionsDlg; + return true; +} + +/*! + \refresh QImage, containing all scene rendering in window +*/ +void SPV3D_ViewWindow::RefreshDumpImage() +{ + myDumpImage = dumpViewContent(); +} + +/*! + Redirect the request to #SPV3D_Renderer::SetSelectionProp +*/ +void SPV3D_ViewWindow::SetSelectionProp(const double& theRed, + const double& theGreen, + const double& theBlue, + const int& theWidth) +{ + myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth); +} + +/*! + Redirect the request to #SPV3D_Renderer::SetSelectionProp +*/ +void SPV3D_ViewWindow::SetPreselectionProp(const double& theRed, + const double& theGreen, + const double& theBlue, + const int& theWidth) +{ + myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth); +} + +/*! + Redirect the request to #SPV3D_Renderer::SetSelectionTolerance +*/ +void SPV3D_ViewWindow::SetSelectionTolerance(const double& theTolNodes, + const double& theTolItems, + const double& theTolObjects) +{ + myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects); +} + +/*! + Get visibility status of the static trihedron +*/ +bool SPV3D_ViewWindow::IsStaticTrihedronVisible() const +{ + return (bool)myAxesWidget->GetEnabled(); +} + +/*! + Set visibility status of the static trihedron +*/ +void SPV3D_ViewWindow::SetStaticTrihedronVisible( const bool theIsVisible ) +{ + myAxesWidget->SetEnabled( (int)theIsVisible ); +} + +/*! + Performs action + \param accelAction - action +*/ +bool SPV3D_ViewWindow::action( const int accelAction ) +{ + if ( accelAction == SUIT_Accel::ZoomFit ) + onFitAll(); + else { + int anEvent = SPV3D::convertAction( accelAction ); + GetInteractor()->InvokeEvent(anEvent, 0); + } + return true; +} + +/*! + \return action by it's id +*/ +QtxAction* SPV3D_ViewWindow::getAction( int id ) const +{ + return dynamic_cast( toolMgr()->action( id ) ); +} + + +// old visual parameters had 13 values. New format added additional +// 76 values for graduated axes, so both numbers are processed. +const int nNormalParams = 13; // number of view windows parameters excluding graduated axes params +const int nGradAxisParams = 25; // number of parameters of ONE graduated axis (X, Y, or Z) +const int nTrihedronParams = 3; // number of parameters for Trihedron +const int nAllParams = nNormalParams + 3*nGradAxisParams + nTrihedronParams + 1; // number of all visual parameters + +/*! The method returns visual parameters of a graduated axis actor (x,y,z axis of graduated axes) + */ +void getGradAxisVisualParams( QXmlStreamWriter& writer, vtkAxisActor2D* actor, QString theAxis ) +{ + //QString params; + if ( !actor ) + return ;//params; + + // Name + bool isVisible = actor->GetTitleVisibility(); + QString title ( actor->GetTitle() ); + double color[ 3 ]; + int font = PV3D_ARIAL; + int bold = 0; + int italic = 0; + int shadow = 0; + + vtkTextProperty* txtProp = actor->GetTitleTextProperty(); + if ( txtProp ) + { + txtProp->GetColor( color ); + font = txtProp->GetFontFamily(); + bold = txtProp->GetBold(); + italic = txtProp->GetItalic(); + shadow = txtProp->GetShadow(); + } + writer.writeStartElement("GraduatedAxis"); + writer.writeAttribute("Axis", theAxis); + + writer.writeStartElement("Title"); + writer.writeAttribute("isVisible", QString("%1").arg(isVisible)); + writer.writeAttribute("Text", title); + writer.writeAttribute("Font", QString("%1").arg(font)); + writer.writeAttribute("Bold", QString("%1").arg(bold)); + writer.writeAttribute("Italic", QString("%1").arg(italic)); + writer.writeAttribute("Shadow", QString("%1").arg(shadow)); + + writer.writeStartElement("Color"); + writer.writeAttribute("R", QString("%1").arg(color[0])); + writer.writeAttribute("G", QString("%1").arg(color[1])); + writer.writeAttribute("B", QString("%1").arg(color[2])); + writer.writeEndElement(); + writer.writeEndElement(); + + //params.sprintf( "* Graduated Axis: * Name *%u*%s*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, + // title.toLatin1().data(), color[0], color[1], color[2], font, bold, italic, shadow ); + + // Labels + isVisible = actor->GetLabelVisibility(); + int labels = actor->GetNumberOfLabels(); + int offset = actor->GetTickOffset(); + font = PV3D_ARIAL; + bold = false; + italic = false; + shadow = false; + + txtProp = actor->GetLabelTextProperty(); + if ( txtProp ) + { + txtProp->GetColor( color ); + font = txtProp->GetFontFamily(); + bold = txtProp->GetBold(); + italic = txtProp->GetItalic(); + shadow = txtProp->GetShadow(); + } + + writer.writeStartElement("Labels"); + writer.writeAttribute("isVisible", QString("%1").arg(isVisible)); + writer.writeAttribute("Number", QString("%1").arg(labels)); + writer.writeAttribute("Offset", QString("%1").arg(offset)); + writer.writeAttribute("Font", QString("%1").arg(font)); + writer.writeAttribute("Bold", QString("%1").arg(bold)); + writer.writeAttribute("Italic", QString("%1").arg(italic)); + writer.writeAttribute("Shadow", QString("%1").arg(shadow)); + + writer.writeStartElement("Color"); + writer.writeAttribute("R", QString("%1").arg(color[0])); + writer.writeAttribute("G", QString("%1").arg(color[1])); + writer.writeAttribute("B", QString("%1").arg(color[2])); + writer.writeEndElement(); + writer.writeEndElement(); + // params += QString().sprintf( "* Labels *%u*%u*%u*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, labels, offset, + // color[0], color[1], color[2], font, bold, italic, shadow ); + + // Tick marks + isVisible = actor->GetTickVisibility(); + int length = actor->GetTickLength(); + writer.writeStartElement("TickMarks"); + writer.writeAttribute("isVisible", QString("%1").arg(isVisible)); + writer.writeAttribute("Length", QString("%1").arg(length)); + writer.writeEndElement(); + + //params += QString().sprintf( "* Tick marks *%u*%u", isVisible, length ); + + writer.writeEndElement(); + //return params; +} + +void setGradAxisVisualParams(QXmlStreamReader& reader, vtkAxisActor2D* actor) +{ + DBG_FUNC(); + if ( !actor ) + return; + + do { + reader.readNext(); + } while (!reader.isStartElement()); + + // Read title params + QXmlStreamAttributes aAttr = reader.attributes(); + bool isVisible = aAttr.value("isVisible").toString().toUShort(); + QString title = aAttr.value("Text").toString(); + int font = aAttr.value("Font").toString().toInt(); + int bold = aAttr.value("Bold").toString().toInt(); + int italic = aAttr.value("Italic").toString().toInt(); + int shadow = aAttr.value("Shadow").toString().toInt(); + + //printf("#### TITLE: %i, %s, %i, %i, %i, %i\n", isVisible, qPrintable(title), font, bold, italic, shadow); + + do { + reader.readNext(); + } while (!reader.isStartElement()); + + // Read title color + aAttr = reader.attributes(); + + double color[3]; + color[0] = aAttr.value("R").toString().toDouble(); + color[1] = aAttr.value("G").toString().toDouble(); + color[2] = aAttr.value("B").toString().toDouble(); + //printf("#### Color: %f, %f, %f\n", color[0], color[1], color[2]); + + actor->SetTitleVisibility( isVisible ); + actor->SetTitle( title.toUtf8() ); + vtkTextProperty* txtProp = actor->GetTitleTextProperty(); + if ( txtProp ) { + txtProp->SetColor( color ); + txtProp->SetFontFamily( font ); + txtProp->SetBold( bold ); + txtProp->SetItalic( italic ); + txtProp->SetShadow( shadow ); + } + + // Labels + + do { + reader.readNext(); + } while (!reader.isStartElement()); + // Read labels + aAttr = reader.attributes(); + isVisible = aAttr.value("isVisible").toString().toUShort(); + int labels = aAttr.value("Number").toString().toInt(); + int offset = aAttr.value("Offset").toString().toInt(); + font = aAttr.value("Font").toString().toInt(); + bold = aAttr.value("Bold").toString().toInt(); + italic = aAttr.value("Italic").toString().toInt(); + shadow = aAttr.value("Shadow").toString().toInt(); + + do { + reader.readNext(); + } while (!reader.isStartElement()); + // Read Color + aAttr = reader.attributes(); + + color[0] = aAttr.value("R").toString().toDouble(); + color[1] = aAttr.value("G").toString().toDouble(); + color[2] = aAttr.value("B").toString().toDouble(); + + actor->SetLabelVisibility( isVisible ); + actor->SetNumberOfLabels( labels ); + actor->SetTickOffset( offset ); + txtProp = actor->GetLabelTextProperty(); + if ( txtProp ) { + txtProp->SetColor( color ); + txtProp->SetFontFamily( font ); + txtProp->SetBold( bold ); + txtProp->SetItalic( italic ); + txtProp->SetShadow( shadow ); + } + + // Tick Marks + do { + reader.readNext(); + } while (!reader.isStartElement()); + aAttr = reader.attributes(); + + // retrieve and set tick marks properties + isVisible = aAttr.value("isVisible").toString().toUShort(); + int length = aAttr.value("Length").toString().toInt(); + + actor->SetTickVisibility( isVisible ); + actor->SetTickLength( length ); +} + +/*! The method restores visual parameters of a graduated axis actor (x,y,z axis) + */ +void setGradAxisVisualParams( vtkAxisActor2D* actor, const QString& params ) +{ + DBG_FUNC(); + if ( !actor ) + return; + + QStringList paramsLst = params.split( '*' ); + + if ( paramsLst.size() == nGradAxisParams ) { // altogether name, lable, ticks parameters make up 25 values + + // retrieve and set name parameters + bool isVisible = paramsLst[2].toUShort(); + QString title = paramsLst[3]; + double color[3]; + color[0] = paramsLst[4].toDouble(); + color[1] = paramsLst[5].toDouble(); + color[2] = paramsLst[6].toDouble(); + int font = paramsLst[7].toInt(); + int bold = paramsLst[8].toInt(); + int italic = paramsLst[9].toInt(); + int shadow = paramsLst[10].toInt(); + + actor->SetTitleVisibility( isVisible ); + actor->SetTitle( title.toUtf8() ); + vtkTextProperty* txtProp = actor->GetTitleTextProperty(); + if ( txtProp ) { + txtProp->SetColor( color ); + txtProp->SetFontFamily( font ); + txtProp->SetBold( bold ); + txtProp->SetItalic( italic ); + txtProp->SetShadow( shadow ); + } + + // retrieve and set lable parameters + isVisible = paramsLst[12].toUShort(); + int labels = paramsLst[13].toInt(); + int offset = paramsLst[14].toInt(); + color[0] = paramsLst[15].toDouble(); + color[1] = paramsLst[16].toDouble(); + color[2] = paramsLst[17].toDouble(); + font = paramsLst[18].toInt(); + bold = paramsLst[19].toInt(); + italic = paramsLst[20].toInt(); + shadow = paramsLst[21].toInt(); + + actor->SetLabelVisibility( isVisible ); + actor->SetNumberOfLabels( labels ); + actor->SetTickOffset( offset ); + txtProp = actor->GetLabelTextProperty(); + if ( txtProp ) { + txtProp->SetColor( color ); + txtProp->SetFontFamily( font ); + txtProp->SetBold( bold ); + txtProp->SetItalic( italic ); + txtProp->SetShadow( shadow ); + } + + // retrieve and set tick marks properties + isVisible = paramsLst[23].toUShort(); + int length = paramsLst[24].toInt(); + + actor->SetTickVisibility( isVisible ); + actor->SetTickLength( length ); + } +} + +/*! The method returns the visual parameters of this view as a formated string + */ +QString SPV3D_ViewWindow::getVisualParameters() +{ + double pos[3], focalPnt[3], viewUp[3], parScale, scale[3]; + + // save position, focal point, viewUp, scale + vtkCamera* camera = getRenderer()->GetActiveCamera(); + camera->GetPosition( pos ); + camera->GetFocalPoint( focalPnt ); + camera->GetViewUp( viewUp ); + parScale = camera->GetParallelScale(); + GetScale( scale ); + + // Parameters are given in the following format:view position (3 digits), focal point position (3 digits) + // view up values (3 digits), parallel scale (1 digit), scale (3 digits, + // Graduated axes parameters (X, Y, Z axes parameters) + QString retStr; + QXmlStreamWriter aWriter(&retStr); + aWriter.setAutoFormatting(true); + + aWriter.writeStartDocument(); + aWriter.writeStartElement("ViewState"); + + aWriter.writeStartElement("Position"); + aWriter.writeAttribute("X", QString("%1").arg(pos[0])); + aWriter.writeAttribute("Y", QString("%1").arg(pos[1])); + aWriter.writeAttribute("Z", QString("%1").arg(pos[2])); + aWriter.writeEndElement(); + + aWriter.writeStartElement("FocalPoint"); + aWriter.writeAttribute("X", QString::number(focalPnt[0])); + aWriter.writeAttribute("Y", QString::number(focalPnt[1])); + aWriter.writeAttribute("Z", QString::number(focalPnt[2])); + aWriter.writeEndElement(); + + aWriter.writeStartElement("ViewUp"); + aWriter.writeAttribute("X", QString::number(viewUp[0])); + aWriter.writeAttribute("Y", QString::number(viewUp[1])); + aWriter.writeAttribute("Z", QString::number(viewUp[2])); + aWriter.writeEndElement(); + + aWriter.writeStartElement("ViewScale"); + aWriter.writeAttribute("Parallel", QString::number(parScale)); + aWriter.writeAttribute("X", QString::number(scale[0])); + aWriter.writeAttribute("Y", QString::number(scale[1])); + aWriter.writeAttribute("Z", QString::number(scale[2])); + aWriter.writeEndElement(); + + if ( SPV3D_CubeAxesActor2D* gradAxesActor = GetCubeAxes() ) { + aWriter.writeStartElement("DisplayCubeAxis"); + aWriter.writeAttribute("Show", QString( "%1" ).arg( GetRenderer()->IsCubeAxesDisplayed())); + aWriter.writeEndElement(); + + getGradAxisVisualParams(aWriter, gradAxesActor->GetXAxisActor2D(), "X"); + getGradAxisVisualParams(aWriter, gradAxesActor->GetYAxisActor2D(), "Y"); + getGradAxisVisualParams(aWriter, gradAxesActor->GetZAxisActor2D(), "Z"); + } + + aWriter.writeStartElement("Trihedron"); + aWriter.writeAttribute("isShown", QString( "%1" ).arg( isTrihedronDisplayed())); + aWriter.writeAttribute("Size", QString::number(GetTrihedronSize())); + aWriter.writeEndElement(); + + aWriter.writeStartElement("Background"); + aWriter.writeAttribute("Value", QString( "%1" ).arg( Qtx::backgroundToString(background()) )); + aWriter.writeEndElement(); + + aWriter.writeEndElement(); + aWriter.writeEndDocument(); + + return retStr; +} + +/*! + The method restores visual parameters of this view or postpones it untill the view is shown +*/ +void SPV3D_ViewWindow::setVisualParameters( const QString& parameters ) +{ + DBG_FUN(); + //printf("#### %s\n", qPrintable(parameters)); + SPV3D_RenderWindowInteractor* anInteractor = GetInteractor(); + if ( anInteractor->isVisible() ) { + doSetVisualParameters( parameters ); + } + else { + myVisualParams = parameters; + anInteractor->installEventFilter(this); + } +} + +/*! + The method restores visual parameters of this view from a formated string +*/ +void SPV3D_ViewWindow::doSetVisualParameters( const QString& parameters, bool baseParamsOnly ) +{ + DBG_FUN(); + + double pos[3], focalPnt[3], viewUp[3], parScale = 1.0, scale[3]; + + QXmlStreamReader aReader(parameters); + SPV3D_CubeAxesActor2D* gradAxesActor = GetCubeAxes(); + + while(!aReader.atEnd()) { + aReader.readNext(); + if (aReader.isStartElement()) { + QXmlStreamAttributes aAttr = aReader.attributes(); + //printf("### Name = %s\n", qPrintable(aReader.name().toString())); + if (aReader.name() == "Position") { + pos[0] = aAttr.value("X").toString().toDouble(); + pos[1] = aAttr.value("Y").toString().toDouble(); + pos[2] = aAttr.value("Z").toString().toDouble(); + //printf("#### Position %f; %f; %f\n", pos[0], pos[1], pos[2]); + } + else if (aReader.name() == "FocalPoint") { + focalPnt[0] = aAttr.value("X").toString().toDouble(); + focalPnt[1] = aAttr.value("Y").toString().toDouble(); + focalPnt[2] = aAttr.value("Z").toString().toDouble(); + //printf("#### FocalPoint %f; %f; %f\n", focalPnt[0], focalPnt[1], focalPnt[2]); + } + else if (aReader.name() == "ViewUp") { + viewUp[0] = aAttr.value("X").toString().toDouble(); + viewUp[1] = aAttr.value("Y").toString().toDouble(); + viewUp[2] = aAttr.value("Z").toString().toDouble(); + //printf("#### ViewUp %f; %f; %f\n", viewUp[0], viewUp[1], viewUp[2]); + } + else if (aReader.name() == "ViewScale") { + parScale = aAttr.value("Parallel").toString().toDouble(); + scale[0] = aAttr.value("X").toString().toDouble(); + scale[1] = aAttr.value("Y").toString().toDouble(); + scale[2] = aAttr.value("Z").toString().toDouble(); + //printf("#### ViewScale %f; %f; %f\n", scale[0], scale[1], scale[2]); + } + else if (aReader.name() == "DisplayCubeAxis") { + if ( !baseParamsOnly ) { + if (aAttr.value("Show") == "0") + gradAxesActor->VisibilityOff(); + else + gradAxesActor->VisibilityOn(); + } + } + else if (aReader.name() == "GraduatedAxis") { + if ( !baseParamsOnly ) { + if(aAttr.value("Axis") == "X") + setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D()); + else if(aAttr.value("Axis") == "Y") + setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D()); + else if(aAttr.value("Axis") == "Z") + setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D()); + } + } + else if (aReader.name() == "Trihedron") { + if ( !baseParamsOnly ) { + if (aAttr.value("isShown") == "0") + GetTrihedron()->VisibilityOff(); + else + GetTrihedron()->VisibilityOn(); + SetTrihedronSize(aAttr.value("Size").toString().toDouble()); + } + } + else if (aReader.name() == "Background") { + if ( !baseParamsOnly ) { + setBackground( Qtx::stringToBackground( aAttr.value("Value").toString() ) ); + } + } + } + } + if (!aReader.hasError()) { + vtkCamera* camera = getRenderer()->GetActiveCamera(); + camera->SetPosition( pos ); + camera->SetFocalPoint( focalPnt ); + camera->SetViewUp( viewUp ); + camera->SetParallelScale( parScale ); + GetRenderer()->SetScale( scale ); + //SetScale( scale ); + } + else { + QStringList paramsLst = parameters.split( '*' ); + if ( paramsLst.size() >= nNormalParams ) { + // 'reading' list of parameters + pos[0] = paramsLst[0].toDouble(); + pos[1] = paramsLst[1].toDouble(); + pos[2] = paramsLst[2].toDouble(); + focalPnt[0] = paramsLst[3].toDouble(); + focalPnt[1] = paramsLst[4].toDouble(); + focalPnt[2] = paramsLst[5].toDouble(); + viewUp[0] = paramsLst[6].toDouble(); + viewUp[1] = paramsLst[7].toDouble(); + viewUp[2] = paramsLst[8].toDouble(); + parScale = paramsLst[9].toDouble(); + scale[0] = paramsLst[10].toDouble(); + scale[1] = paramsLst[11].toDouble(); + scale[2] = paramsLst[12].toDouble(); + + // applying parameters + vtkCamera* camera = getRenderer()->GetActiveCamera(); + camera->SetPosition( pos ); + camera->SetFocalPoint( focalPnt ); + camera->SetViewUp( viewUp ); + camera->SetParallelScale( parScale ); + GetRenderer()->SetScale( scale ); + //SetScale( scale ); + + // apply graduated axes parameters + if ( !baseParamsOnly ) { + SPV3D_CubeAxesActor2D* gradAxesActor = GetCubeAxes(); + if ( gradAxesActor && paramsLst.size() == nAllParams ) { + int i = nNormalParams+1, j = i + nGradAxisParams - 1; + ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) ); + i = j + 1; j += nGradAxisParams; + ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) ); + i = j + 1; j += nGradAxisParams; + ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) ); + + if ( paramsLst[13].toUShort() ) + gradAxesActor->VisibilityOn(); + else + gradAxesActor->VisibilityOff(); + } + else if ( paramsLst.size() == nAllParams ) { + if ( paramsLst[90].toUShort() ) + GetTrihedron()->VisibilityOn(); + else + GetTrihedron()->VisibilityOff(); + + SetTrihedronSize(paramsLst[91].toDouble()); + } + } + } + } + Repaint(); +} + + +/*! + Delayed setVisualParameters +*/ +bool SPV3D_ViewWindow::eventFilter( QObject* theWatched, QEvent* theEvent ) +{ + if ( theEvent->type() == QEvent::Show && theWatched->inherits( "SPV3D_RenderWindowInteractor" ) ) { + SPV3D_RenderWindowInteractor* anInteractor = (SPV3D_RenderWindowInteractor*)theWatched; + if ( anInteractor->isVisible() ) { + doSetVisualParameters( myVisualParams ); + anInteractor->removeEventFilter( this ); // theWatched = RenderWindowInteractor + } + } + return SUIT_ViewWindow::eventFilter( theWatched, theEvent ); +} + + +/*! + Change rotation point +*/ +void SPV3D_ViewWindow::onChangeRotationPoint(bool theIsActivate) +{ + if(theIsActivate){ + mySetRotationPointDlg->addObserver(); + if ( mySetRotationPointDlg->IsFirstShown() ) + activateSetRotationGravity(); + mySetRotationPointDlg->show(); + }else + mySetRotationPointDlg->hide(); +} + +/*! + Set the gravity center as a rotation point +*/ +void SPV3D_ViewWindow::activateSetRotationGravity() +{ + myEventDispatcher->InvokeEvent(SPV3D::SetRotateGravity,0); +} + +/*! + Set the selected point as a rotation point +*/ +void SPV3D_ViewWindow::activateSetRotationSelected(void* theData) +{ + myEventDispatcher->InvokeEvent(SPV3D::ChangeRotationPoint,theData); +} + +/*! + Set the gravity center of element selected by user as a rotation point +*/ +void SPV3D_ViewWindow::activateStartPointSelection( Selection_Mode theSelectionMode ) +{ + SetSelectionMode( theSelectionMode ); + myEventDispatcher->InvokeEvent(SPV3D::StartPointSelection,0); +} + +/*! + \brief Set the given projection mode. + + Set the given projection mode: Orthographic or Perspective. +*/ +void SPV3D_ViewWindow::onProjectionMode( QAction* theAction ) +{ + DBG_FUN(); + int aMode = Parallel; + if (theAction == toolMgr()->action( ProjectionModeId )) + aMode = Projection; + SPV3D_Viewer* aViewer = dynamic_cast(myModel); + aViewer->setProjectionMode(aMode); + bool anIsParallelMode = (aMode == Parallel); + vtkCamera* aCamera = getRenderer()->GetActiveCamera(); + aCamera->SetParallelProjection(anIsParallelMode); + GetInteractor()->GetDevice()->CreateTimer(PV3DI_TIMER_FIRST); + getRenderWindow()->SetStereoRender(0); + Repaint(); +} + +/*! + \brief Sets Stereo projection mode. + + Sets Stereo projection mode. +*/ +void SPV3D_ViewWindow::onStereoMode( bool activate ) +{ + DBG_FUN(); + if (activate) { + toolMgr()->action( ProjectionModeId )->setChecked(true); + vtkCamera* aCamera = getRenderer()->GetActiveCamera(); + aCamera->SetParallelProjection(false); + toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(false); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + SetStereoType( aResMgr->integerValue( "PV3DViewer", "stereo_type", 0 ) ); + getRenderWindow()->SetStereoRender(1); + Repaint(); + } + else { + toolMgr()->action( ProjectionModeId )->actionGroup()->setEnabled(true); + SPV3D_Viewer* aViewer = dynamic_cast(myModel); + if (aViewer->projectionMode() == Parallel) { + toolMgr()->action( ParallelModeId )->setChecked(true); + onProjectionMode(toolMgr()->action( ParallelModeId )); + } + else if (aViewer->projectionMode() == Projection) { + toolMgr()->action( ProjectionModeId )->setChecked(true); + onProjectionMode(toolMgr()->action( ProjectionModeId )); + } + } + if ( getRenderWindow()->GetStereoCapableWindow() == 1 && !isOpenGlStereoSupport() && + strcmp( "CrystalEyes", getRenderWindow()->GetStereoTypeAsString() ) == 0 && + toolMgr()->action( StereoModeId )->isChecked() ) + SUIT_MessageBox::warning( 0, tr( "WRN_WARNING" ), tr( "WRN_SUPPORT_QUAD_BUFFER" ) ); +} + +/*! + Set the view projection mode: orthogonal or perspective +*/ +void SPV3D_ViewWindow::onProjectionMode() +{ + DBG_FUN(); + if (toolMgr()->action( ParallelModeId )->isChecked()) + SetProjectionMode( Parallel); + if (toolMgr()->action( ProjectionModeId )->isChecked()) + SetProjectionMode( Projection); + if (toolMgr()->action( StereoModeId )->isChecked()) + SetProjectionMode( Stereo); + emit transformed( this ); +} + +void SPV3D_ViewWindow::SetEventDispatcher(vtkObject* theDispatcher) +{ + myEventDispatcher = theDispatcher; +} + +/*! + Creates all actions of svtk main window +*/ +void SPV3D_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr) +{ + DBG_FUN(); + QtxAction* anAction; + QtxActionToolMgr* mgr = toolMgr(); + + // Dump view + anAction = new QtxAction(tr("MNU_DUMP_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_DUMP" ) ), + tr( "MNU_DUMP_VIEW" ), 0, this); + anAction->setStatusTip(tr("DSC_DUMP_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(onDumpView())); + mgr->registerAction( anAction, DumpId ); + + // FitAll + anAction = new QtxAction(tr("MNU_FITALL"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_FITALL" ) ), + tr( "MNU_FITALL" ), 0, this); + anAction->setStatusTip(tr("DSC_FITALL")); + connect(anAction, SIGNAL(triggered()), this, SLOT(onFitAll())); + mgr->registerAction( anAction, FitAllId ); + + // FitRect + anAction = new QtxAction(tr("MNU_FITRECT"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_FITAREA" ) ), + tr( "MNU_FITRECT" ), 0, this); + anAction->setStatusTip(tr("DSC_FITRECT")); + connect(anAction, SIGNAL(triggered()), this, SLOT(activateWindowFit())); + mgr->registerAction( anAction, FitRectId ); + + // FitSelection + anAction = new QtxAction(tr("MNU_FITSELECTION"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_FITSELECTION" ) ), + tr( "MNU_FITSELECTION" ), 0, this); + anAction->setStatusTip(tr("DSC_FITSELECTION")); + connect(anAction, SIGNAL(triggered()), this, SLOT(onFitSelection())); + mgr->registerAction( anAction, FitSelectionId ); + + // Zoom + anAction = new QtxAction(tr("MNU_ZOOM_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_ZOOM" ) ), + tr( "MNU_ZOOM_VIEW" ), 0, this); + anAction->setStatusTip(tr("DSC_ZOOM_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(activateZoom())); + mgr->registerAction( anAction, ZoomId ); + + // Panning + anAction = new QtxAction(tr("MNU_PAN_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_PAN" ) ), + tr( "MNU_PAN_VIEW" ), 0, this); + anAction->setStatusTip(tr("DSC_PAN_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(activatePanning())); + mgr->registerAction( anAction, PanId ); + + // Global Panning + anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_GLOBALPAN" ) ), + tr( "MNU_GLOBALPAN_VIEW" ), 0, this); + anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning())); + mgr->registerAction( anAction, GlobalPanId ); + + // Change rotation point + anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_ROTATION_POINT" ) ), + tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this); + anAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onChangeRotationPoint(bool))); + mgr->registerAction( anAction, ChangeRotationPointId ); + + // Rotation + anAction = new QtxAction(tr("MNU_ROTATE_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_ROTATE" ) ), + tr( "MNU_ROTATE_VIEW" ), 0, this); + anAction->setStatusTip(tr("DSC_ROTATE_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(activateRotation())); + mgr->registerAction( anAction, RotationId ); + + // Projections + anAction = new QtxAction(tr("MNU_FRONT_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_FRONT" ) ), + tr( "MNU_FRONT_VIEW" ), 0, this, false, "Viewers:Front view"); + anAction->setStatusTip(tr("DSC_FRONT_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(onFrontView())); + this->addAction(anAction); + mgr->registerAction( anAction, FrontId ); + + anAction = new QtxAction(tr("MNU_BACK_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_BACK" ) ), + tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view"); + anAction->setStatusTip(tr("DSC_BACK_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(onBackView())); + this->addAction(anAction); + mgr->registerAction( anAction, BackId ); + + anAction = new QtxAction(tr("MNU_TOP_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_TOP" ) ), + tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view"); + anAction->setStatusTip(tr("DSC_TOP_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(onTopView())); + this->addAction(anAction); + mgr->registerAction( anAction, TopId ); + + anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_BOTTOM" ) ), + tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view"); + anAction->setStatusTip(tr("DSC_BOTTOM_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(onBottomView())); + this->addAction(anAction); + mgr->registerAction( anAction, BottomId ); + + anAction = new QtxAction(tr("MNU_LEFT_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_LEFT" ) ), + tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view"); + anAction->setStatusTip(tr("DSC_LEFT_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(onLeftView())); + this->addAction(anAction); + mgr->registerAction( anAction, LeftId ); + + anAction = new QtxAction(tr("MNU_RIGHT_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_RIGHT" ) ), + tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view"); + anAction->setStatusTip(tr("DSC_RIGHT_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(onRightView())); + this->addAction(anAction); + mgr->registerAction( anAction, RightId ); + + // rotate anticlockwise + anAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_ANTICLOCKWISE" ) ), + tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise"); + anAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView())); + this->addAction(anAction); + mgr->registerAction( anAction, AntiClockWiseId ); + + // rotate clockwise + anAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_CLOCKWISE" ) ), + tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise"); + anAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(onClockWiseView())); + this->addAction(anAction); + mgr->registerAction( anAction, ClockWiseId ); + + // Reset + anAction = new QtxAction(tr("MNU_RESET_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_RESET" ) ), + tr( "MNU_RESET_VIEW" ), 0, this, false, "Viewers:Reset view"); + anAction->setStatusTip(tr("DSC_RESET_VIEW")); + connect(anAction, SIGNAL(triggered()), this, SLOT(onResetView())); + this->addAction(anAction); + mgr->registerAction( anAction, ResetId ); + + // onViewTrihedron: Shows - Hides Trihedron + anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_PV3DVIEWER_VIEW_TRIHEDRON" ) ), + tr( "MNU_SHOW_TRIHEDRON" ), 0, this); + anAction->setCheckable( true ); + anAction->setChecked( true ); + + anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON")); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewTrihedron(bool))); + mgr->registerAction( anAction, ViewTrihedronId ); + + // onNonIsometric: Manage non-isometric params + anAction = new QtxAction(tr("MNU_SPV3D_SCALING"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_SCALING" ) ), + tr( "MNU_SPV3D_SCALING" ), 0, this); + anAction->setStatusTip(tr("DSC_SPV3D_SCALING")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool))); + mgr->registerAction( anAction, NonIsometric ); + + // onGraduatedAxes: Manage graduated axes params + anAction = new QtxAction(tr("MNU_SPV3D_GRADUATED_AXES"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_GRADUATED_AXES" ) ), + tr( "MNU_SPV3D_GRADUATED_AXES" ), 0, this); + anAction->setStatusTip(tr("DSC_SPV3D_GRADUATED_AXES")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool))); + mgr->registerAction( anAction, GraduatedAxes ); + + // onGraduatedAxes: Manage graduated axes params + anAction = new QtxAction(tr("MNU_SPV3D_UPDATE_RATE"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_UPDATE_RATE" ) ), + tr( "MNU_SPV3D_UPDATE_RATE" ), 0, this); + anAction->setStatusTip(tr("DSC_SPV3D_UPDATE_RATE")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool))); + mgr->registerAction( anAction, UpdateRate ); + + // Set perspective mode group + anAction = new QtxAction(tr("MNU_SPV3D_PARALLEL_MODE"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_VIEW_PARALLEL" ) ), + tr( "MNU_SPV3D_PARALLEL_MODE" ), 0, this); + anAction->setStatusTip(tr("DSC_SPV3D_PARALLEL_MODE")); + anAction->setCheckable(true); + mgr->registerAction( anAction, ParallelModeId ); + + anAction = new QtxAction(tr("MNU_SPV3D_PERSPECTIVE_MODE"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_VIEW_PERSPECTIVE" ) ), + tr( "MNU_SPV3D_PERSPECTIVE_MODE" ), 0, this); + anAction->setStatusTip(tr("DSC_SPV3D_PERSPECTIVE_MODE")); + anAction->setCheckable(true); + mgr->registerAction( anAction, ProjectionModeId ); + + anAction = new QtxAction(tr("MNU_SPV3D_STEREO_MODE"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_VIEW_STEREO" ) ), + tr( "MNU_SPV3D_STEREO_MODE" ), 0, this); + anAction->setStatusTip(tr("DSC_SPV3D_STEREO_MODE")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onStereoMode(bool))); + mgr->registerAction( anAction, StereoModeId ); + + QActionGroup* aPerspectiveGroup = new QActionGroup( this ); + aPerspectiveGroup->addAction( mgr->action( ParallelModeId ) ); + aPerspectiveGroup->addAction( mgr->action( ProjectionModeId ) ); + connect(aPerspectiveGroup, SIGNAL(triggered(QAction*)), this, SLOT(onProjectionMode(QAction*))); + + // View Parameters + anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_VIEW_PARAMETERS" ) ), + tr( "MNU_VIEWPARAMETERS_VIEW" ), 0, this); + anAction->setStatusTip(tr("DSC_VIEWPARAMETERS_VIEW")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool))); + mgr->registerAction( anAction, ViewParametersId ); + + // Synchronize View + mgr->registerAction( synchronizeAction(), SynchronizeId ); + + // Switch between interaction styles + anAction = new QtxAction(tr("MNU_SPV3D_STYLE_SWITCH"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_STYLE_SWITCH" ) ), + tr( "MNU_SPV3D_STYLE_SWITCH" ), 0, this); + anAction->setStatusTip(tr("DSC_SPV3D_STYLE_SWITCH")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool))); + mgr->registerAction( anAction, SwitchInteractionStyleId ); + + // Switch between zooming styles + anAction = new QtxAction(tr("MNU_SPV3D_ZOOMING_STYLE_SWITCH"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_ZOOMING_STYLE_SWITCH" ) ), + tr( "MNU_SPV3D_ZOOMING_STYLE_SWITCH" ), 0, this); + anAction->setStatusTip(tr("DSC_SPV3D_ZOOMING_STYLE_SWITCH")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool))); + mgr->registerAction( anAction, SwitchZoomingStyleId ); + + // Pre-selection + QSignalMapper* aSignalMapper = new QSignalMapper( this ); + connect(aSignalMapper, SIGNAL(mapped(int)), this, SLOT(onSwitchPreSelectionMode(int))); + + anAction = new QtxAction(tr("MNU_SPV3D_PRESELECTION_STANDARD"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_PRESELECTION_STANDARD" ) ), + tr( "MNU_SPV3D_PRESELECTION_STANDARD" ), 0, this); + anAction->setStatusTip(tr("DSC_SPV3D_PRESELECTION_STANDARD")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map())); + aSignalMapper->setMapping( anAction, Standard_Preselection ); + mgr->registerAction( anAction, StandardPreselectionId ); + + anAction = new QtxAction(tr("MNU_SPV3D_PRESELECTION_DYNAMIC"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_PRESELECTION_DYNAMIC" ) ), + tr( "MNU_SPV3D_PRESELECTION_DYNAMIC" ), 0, this); + anAction->setStatusTip(tr("DSC_SPV3D_PRESELECTION_DYNAMIC")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map())); + aSignalMapper->setMapping( anAction, Dynamic_Preselection ); + mgr->registerAction( anAction, DynamicPreselectionId ); + + anAction = new QtxAction(tr("MNU_SPV3D_PRESELECTION_DISABLED"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_PRESELECTION_DISABLED" ) ), + tr( "MNU_SPV3D_PRESELECTION_DISABLED" ), 0, this); + anAction->setStatusTip(tr("DSC_SPV3D_PRESELECTION_DISABLED")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(triggered()), aSignalMapper, SLOT(map())); + aSignalMapper->setMapping( anAction, Preselection_Disabled ); + mgr->registerAction( anAction, DisablePreselectionId ); + + QtxActionGroup* aPreselectionAction = new QtxActionGroup( this, true ); + aPreselectionAction->add( getAction( StandardPreselectionId ) ); + aPreselectionAction->add( getAction( DynamicPreselectionId ) ); + aPreselectionAction->add( getAction( DisablePreselectionId ) ); + mgr->registerAction( aPreselectionAction, PreselectionId ); + + // Selection + anAction = new QtxAction(tr("MNU_SPV3D_ENABLE_SELECTION"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_SELECTION" ) ), + tr( "MNU_SPV3D_ENABLE_SELECTION" ), 0, this); + anAction->setStatusTip(tr("DSC_SPV3D_ENABLE_SELECTION")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onEnableSelection(bool))); + mgr->registerAction( anAction, EnableSelectionId ); + + // Start recording + myStartAction = new QtxAction(tr("MNU_SPV3D_RECORDING_START"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_RECORDING_START" ) ), + tr( "MNU_SPV3D_RECORDING_START" ), 0, this); + myStartAction->setStatusTip(tr("DSC_SPV3D_RECORDING_START")); + connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStartRecording() ) ); + mgr->registerAction( myStartAction, StartRecordingId ); + + // Play recording + myPlayAction = new QtxAction(tr("MNU_SPV3D_RECORDING_PLAY"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_RECORDING_PLAY" ) ), + tr( "MNU_SPV3D_RECORDING_PLAY" ), 0, this); + myPlayAction->setStatusTip(tr("DSC_SPV3D_RECORDING_PLAY")); + myPlayAction->setEnabled( false ); + connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPlayRecording() ) ); + mgr->registerAction( myPlayAction, PlayRecordingId ); + + // Pause recording + myPauseAction = new QtxAction(tr("MNU_SPV3D_RECORDING_PAUSE"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_RECORDING_PAUSE" ) ), + tr( "MNU_SPV3D_RECORDING_PAUSE" ), 0, this); + myPauseAction->setStatusTip(tr("DSC_SPV3D_RECORDING_PAUSE")); + myPauseAction->setEnabled( false ); + connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPauseRecording() ) ); + mgr->registerAction( myPauseAction, PauseRecordingId ); + + // Stop recording + myStopAction = new QtxAction(tr("MNU_SPV3D_RECORDING_STOP"), + theResourceMgr->loadPixmap( "PV3DViewer", tr( "ICON_SPV3D_RECORDING_STOP" ) ), + tr( "MNU_SPV3D_RECORDING_STOP" ), 0, this); + myStopAction->setStatusTip(tr("DSC_SPV3D_RECORDING_STOP")); + myStopAction->setEnabled( false ); + connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStopRecording() ) ); + mgr->registerAction( myStopAction, StopRecordingId ); +} + +/*! + Creates toolbar of svtk main window +*/ +void SPV3D_ViewWindow::createToolBar() +{ + QtxActionToolMgr* mgr = toolMgr(); + + mgr->append( DumpId, myToolBar ); + mgr->append( SwitchInteractionStyleId, myToolBar ); + mgr->append( SwitchZoomingStyleId, myToolBar ); + + mgr->append( mgr->separator(), myToolBar ); + + mgr->append( PreselectionId, myToolBar ); + mgr->append( EnableSelectionId, myToolBar ); + + mgr->append( mgr->separator(), myToolBar ); + + mgr->append( ViewTrihedronId, myToolBar ); + + QtxMultiAction* aScaleAction = new QtxMultiAction( this ); + aScaleAction->insertAction( getAction( FitAllId ) ); + aScaleAction->insertAction( getAction( FitRectId ) ); + aScaleAction->insertAction( getAction( FitSelectionId ) ); + aScaleAction->insertAction( getAction( ZoomId ) ); + mgr->append( aScaleAction, myToolBar ); + + QtxMultiAction* aPanningAction = new QtxMultiAction( this ); + aPanningAction->insertAction( getAction( PanId ) ); + aPanningAction->insertAction( getAction( GlobalPanId ) ); + mgr->append( aPanningAction, myToolBar ); + + mgr->append( ChangeRotationPointId, myToolBar ); + + mgr->append( RotationId, myToolBar ); + + QtxMultiAction* aViewsAction = new QtxMultiAction( this ); + aViewsAction->insertAction( getAction( FrontId ) ); + aViewsAction->insertAction( getAction( BackId ) ); + aViewsAction->insertAction( getAction( TopId ) ); + aViewsAction->insertAction( getAction( BottomId ) ); + aViewsAction->insertAction( getAction( LeftId ) ); + aViewsAction->insertAction( getAction( RightId ) ); + mgr->append( aViewsAction, myToolBar ); + + mgr->append( AntiClockWiseId, myToolBar ); + mgr->append( ClockWiseId, myToolBar ); + + mgr->append( ResetId, myToolBar ); + + mgr->append( UpdateRate, myToolBar ); + mgr->append( NonIsometric, myToolBar ); + mgr->append( GraduatedAxes, myToolBar ); + + mgr->append( ViewParametersId, myToolBar ); + mgr->append( SynchronizeId, myToolBar ); + + mgr->append( toolMgr()->separator(), myToolBar ); + + mgr->append( ParallelModeId, myToolBar ); + mgr->append( ProjectionModeId, myToolBar ); + mgr->append( StereoModeId, myToolBar ); + + mgr->append( StartRecordingId, myRecordingToolBar ); + mgr->append( PlayRecordingId, myRecordingToolBar ); + mgr->append( PauseRecordingId, myRecordingToolBar ); + mgr->append( StopRecordingId, myRecordingToolBar ); +} + +void SPV3D_ViewWindow::onUpdateRate(bool theIsActivate) +{ + if(theIsActivate){ + myUpdateRateDlg->Update(); + myUpdateRateDlg->show(); + }else + myUpdateRateDlg->hide(); +} + +void SPV3D_ViewWindow::onNonIsometric(bool theIsActivate) +{ + if(theIsActivate){ + myNonIsometricDlg->Update(); + myNonIsometricDlg->show(); + }else + myNonIsometricDlg->hide(); +} + +void SPV3D_ViewWindow::onGraduatedAxes(bool theIsActivate) +{ + if(theIsActivate){ + myCubeAxesDlg->Update(); + myCubeAxesDlg->show(); + }else + myCubeAxesDlg->hide(); +} + +/*! + Starts rotation transformation +*/ +void SPV3D_ViewWindow::activateRotation() +{ + myEventDispatcher->InvokeEvent(SPV3D::StartRotate,0); +} + + +/*! + Starts panning transformation +*/ +void SPV3D_ViewWindow::activatePanning() +{ + myEventDispatcher->InvokeEvent(SPV3D::StartPan,0); +} + +/*! + Starts zoom transformation +*/ +void SPV3D_ViewWindow::activateZoom() +{ + myEventDispatcher->InvokeEvent(SPV3D::StartZoom,0); +} + +/*! + Starts window fit transformation +*/ +void SPV3D_ViewWindow::activateWindowFit() +{ + myEventDispatcher->InvokeEvent(SPV3D::StartFitArea,0); +} + +/*! + Starts global panning transformation +*/ +void SPV3D_ViewWindow::activateGlobalPanning() +{ + myEventDispatcher->InvokeEvent(SPV3D::StartGlobalPan,0); +} + +void SPV3D_ViewWindow::onStartRecording() +{ + myRecorder->CheckExistAVIMaker(); + if (myRecorder->ErrorStatus()) { + SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER") ); + } + else { + SPV3D_RecorderDlg* aRecorderDlg = new SPV3D_RecorderDlg( this, myRecorder ); + + if( !aRecorderDlg->exec() ) + return; + + myStartAction->setEnabled( false ); + myPlayAction->setEnabled( false ); + myPauseAction->setEnabled( true ); + myStopAction->setEnabled( true ); + + // to prevent resizing the window while recording + myPreRecordingMinSize = minimumSize(); + myPreRecordingMaxSize = maximumSize(); + setFixedSize( size() ); + + myRecorder->Record(); + } +} + +void SPV3D_ViewWindow::onPlayRecording() +{ + myStartAction->setEnabled( false ); + myPlayAction->setEnabled( false ); + myPauseAction->setEnabled( true ); + myStopAction->setEnabled( true ); + + myRecorder->Pause(); +} + +void SPV3D_ViewWindow::onPauseRecording() +{ + myStartAction->setEnabled( false ); + myPlayAction->setEnabled( true ); + myPauseAction->setEnabled( false ); + myStopAction->setEnabled( true ); + + myRecorder->Pause(); +} + +void SPV3D_ViewWindow::onStopRecording() +{ + myStartAction->setEnabled( true ); + myPlayAction->setEnabled( false ); + myPauseAction->setEnabled( false ); + myStopAction->setEnabled( false ); + + myRecorder->Stop(); + + setMinimumSize( myPreRecordingMinSize ); + setMaximumSize( myPreRecordingMaxSize ); +} + +/*! + To invoke a PV3D event on SPV3D_RenderWindowInteractor instance +*/ +void SPV3D_ViewWindow::InvokeEvent(unsigned long theEvent, void* theCallData) +{ + GetInteractor()->InvokeEvent(theEvent,theCallData); +} + +/*! + Modify view parameters +*/ +void SPV3D_ViewWindow::onViewParameters(bool theIsActivate) +{ + if(theIsActivate){ + myViewParameterDlg->addObserver(); + myViewParameterDlg->show(); + }else + myViewParameterDlg->hide(); +} +#endif + +/*! + Custom show event handler +*/ +void SPV3D_ViewWindow::showEvent( QShowEvent * theEvent ) +{ + DBG_FUN(); + MSGEL("-----> emit Show <-----"); + emit Show( theEvent ); +} + +/*! + Custom hide event handler +*/ +void SPV3D_ViewWindow::hideEvent( QHideEvent * theEvent ) +{ + DBG_FUN(); + MSGEL("-----> emit Hide <-----"); + emit Hide( theEvent ); +} + +#if 0 +/*! + Emit transformed signal. +*/ +void SPV3D_ViewWindow::emitTransformed() { + transformed(this); +} + +/*! + Processes events +*/ +void SPV3D_ViewWindow::ProcessEvents(vtkObject* vtkNotUsed(theObject), + unsigned long /*theEvent*/, + void* theClientData, + void* /*theCallData*/) +{ + SPV3D_ViewWindow* self = reinterpret_cast(theClientData); + if(self) + self->emitTransformed(); +} + +/*! + Get camera properties for the SPV3D view window. + \return shared pointer on camera properties. +*/ +SUIT_CameraProperties SPV3D_ViewWindow::cameraProperties() +{ + SUIT_CameraProperties aProps; + + // get vtk camera + vtkCamera* aCamera = getRenderer()->GetActiveCamera(); + if ( !aCamera ) + return aProps; + + aProps.setDimension( SUIT_CameraProperties::Dim3D ); + if ( toolMgr()->action( ParallelModeId ) ) { + if ( toolMgr()->action( ParallelModeId )->isChecked() ) + aProps.setProjection( SUIT_CameraProperties::PrjOrthogonal ); + else + aProps.setProjection( SUIT_CameraProperties::PrjPerspective ); + } + + double aFocalPoint[3]; + double aPosition[3]; + double aViewUp[3]; + double anAxialScale[3]; + + aCamera->OrthogonalizeViewUp(); + aCamera->GetFocalPoint( aFocalPoint ); + aCamera->GetPosition( aPosition ); + aCamera->GetViewUp( aViewUp ); + + aProps.setFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] ); + aProps.setPosition( aPosition[0], aPosition[1], aPosition[2] ); + aProps.setViewUp( aViewUp[0], aViewUp[1], aViewUp[2] ); + aProps.setMappingScale( aCamera->GetParallelScale() * 2.0 ); + + if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective ) + { + aProps.setViewAngle( aCamera->GetViewAngle() ); + } + + GetRenderer()->GetScale( anAxialScale ); + aProps.setAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] ); + + return aProps; +} + +/*! + Synchronize views. + This implementation synchronizes camera propreties. +*/ +void SPV3D_ViewWindow::synchronize( SUIT_ViewWindow* theView ) +{ + bool blocked = blockSignals( true ); + + SUIT_CameraProperties aProps = theView->cameraProperties(); + if ( !cameraProperties().isCompatible( aProps ) ) { + // other view, this one is being currently synchronized to, seems has become incompatible + // we have to break synchronization + updateSyncViews(); + return; + } + + // get camera + vtkCamera* aCamera = getRenderer()->GetActiveCamera(); + + double aFocalPoint[3]; + double aPosition[3]; + double aViewUp[3]; + double anAxialScale[3]; + + // get common properties + aProps.getViewUp( aViewUp[0], aViewUp[1], aViewUp[2] ); + aProps.getPosition( aPosition[0], aPosition[1], aPosition[2] ); + aProps.getFocalPoint( aFocalPoint[0], aFocalPoint[1], aFocalPoint[2] ); + aProps.getAxialScale( anAxialScale[0], anAxialScale[1], anAxialScale[2] ); + + // restore properties to the camera + aCamera->SetViewUp( aViewUp ); + aCamera->SetPosition( aPosition ); + aCamera->SetFocalPoint( aFocalPoint ); + aCamera->SetParallelScale( aProps.getMappingScale() / 2.0 ); + + if ( aProps.getProjection() == SUIT_CameraProperties::PrjPerspective ) + { + aCamera->SetViewAngle( aProps.getViewAngle() ); + } + + GetRenderer()->SetScale( anAxialScale ); + + getRenderer()->ResetCameraClippingRange(); + Repaint( false ); + + blockSignals( blocked ); +} + +void SPV3D_ViewWindow::resizeEvent( QResizeEvent* theEvent ) +{ +#ifdef VGL_WORKAROUND + Repaint(); +#endif +} +#endif diff --git a/src/SPV3D/SPV3D_ViewWindow.h b/src/SPV3D/SPV3D_ViewWindow.h new file mode 100644 index 000000000..7b30e0729 --- /dev/null +++ b/src/SPV3D/SPV3D_ViewWindow.h @@ -0,0 +1,518 @@ +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef SPV3D_VIEWWINDOW_H +#define SPV3D_VIEWWINDOW_H + +#ifdef WIN32 +#pragma warning( disable:4251 ) +#endif + +#include "SPV3D.h" +//#include "SPV3D_Selection.h" +#include "Qtx.h" +//#include "SUIT_ViewWindow.h" +#include "PV3DViewer_ViewWindow.h" + +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_ListIO.hxx" + +#include +#include + +class SUIT_Desktop; +class SUIT_ResourceMgr; + +class PV3DViewer_Actor; +class PV3DViewer_Trihedron; + +class SPV3D_ViewModel/*Base*/; +class SPV3D_Selector; +class SPV3D_View; + +class SPV3D_CubeAxesActor2D; + +class vtkRenderer; +class vtkRenderWindow; +class vtkRenderWindowInteractor; +class vtkInteractorStyle; +class vtkCallbackCommand; + +class SPV3D_RenderWindowInteractor; +class SPV3D_Renderer; +class SPV3D_NonIsometricDlg; +class SPV3D_UpdateRateDlg; +class SPV3D_CubeAxesDlg; +class SPV3D_SetRotationPointDlg; +class SPV3D_InteractorStyle; +class SPV3D_KeyFreeInteractorStyle; +class SPV3D_ViewParameterDlg; +class SPV3D_Recorder; + +namespace salomevtk +{ + class vtkPVAxesWidget; +} + +class vtkObject; +class QtxAction; + +namespace SPV3D +{ + // SPV3D_EXPORT + // int convertAction( const int ); +} + +//! Define a container for SALOME PV3D view window +class SPV3D_EXPORT SPV3D_ViewWindow : public PV3DViewer_ViewWindow //SUIT_ViewWindow +{ + Q_OBJECT + + public: + //! To construct #SPV3D_ViewWindow instance + SPV3D_ViewWindow(SUIT_Desktop* theDesktop, SPV3D_ViewModel* theModel); + + virtual ~SPV3D_ViewWindow(); + + //virtual QImage dumpView(); + +#if 0 + //! To initialize #SPV3D_ViewWindow instance + virtual void Initialize(SPV3D_ViewModel/*Base*/* theModel); + + //! Get #SPV3D_View + SPV3D_View* getView(); + + //! Get render window + vtkRenderWindow* getRenderWindow(); + + //! Get interactor + vtkRenderWindowInteractor* getInteractor() const; + + //! Get SPV3D interactor + SPV3D_RenderWindowInteractor* GetInteractor() const; + + //! Get current interactor style + vtkInteractorStyle* GetInteractorStyle() const; + + //! Add interactor style to the stack of styles + void PushInteractorStyle(vtkInteractorStyle* theStyle); + + //! Remove last interactor style from the stack of styles + void PopInteractorStyle(); + + //! Get renderer + vtkRenderer* getRenderer() const; + + //! Get SPV3D renderer + SPV3D_Renderer* GetRenderer() const; +#endif + + //! Get selector + //SPV3D_Selector* GetSelector() const; + +#if 0 + //! Set selection mode + Selection_Mode SelectionMode() const; + + //! Change selection mode + virtual void SetSelectionMode(Selection_Mode theMode); + + //! Set background color [obsolete] + virtual void setBackgroundColor( const QColor& ); + + //! Get background color [obsolete] + QColor backgroundColor() const; + + //! Set background + virtual void setBackground( const Qtx::BackgroundData& ); + + //! Get background + Qtx::BackgroundData background() const; + + //! Return \c true if "display trihedron" flag is set + bool isTrihedronDisplayed(); + + //! Return \c true if "show graduated axes" flag is set + bool isCubeAxesDisplayed(); + + /* interactive object management */ + //! Redirect the request to #SPV3D_View::highlight (to support old code) + virtual void highlight(const Handle(SALOME_InteractiveObject)& theIO, + bool theIsHighlight = true, + bool theIsUpdate = true); + + //! Redirect the request to #SPV3D_View::unHighlightAll (to support old code) + virtual void unHighlightAll(); + + //! Redirect the request to #SPV3D_View::isInViewer (to support old code) + bool isInViewer(const Handle(SALOME_InteractiveObject)& theIObject); + + //! Redirect the request to #SPV3D_View::isVisible (to support old code) + bool isVisible(const Handle(SALOME_InteractiveObject)& theIObject); + + //! Redirect the request to #SPV3D_View::FindIObject (to support old code) + //---------------------------------------------------------------------------- + Handle(SALOME_InteractiveObject) FindIObject(const char* theEntry); +#endif + + /* display */ + //---------------------------------------------------------------------------- + //! Redirect the request to #SPV3D_View::Display (to support old code) + virtual void Display(const Handle(SALOME_InteractiveObject)& theIObject, + bool theImmediatly = true); + + //! Redirect the request to #SPV3D_View::DisplayOnly (to support old code) + virtual void DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject); + + //! Redirect the request to #SPV3D_View::Erase (to support old code) + virtual void Erase(const Handle(SALOME_InteractiveObject)& theIObject, + bool theImmediatly = true); + + //! Redirect the request to #SPV3D_View::DisplayAll (to support old code) + virtual void DisplayAll(); + + //! Redirect the request to #SPV3D_View::EraseAll (to support old code) + virtual void EraseAll(); + + //! To repaint the viewer + virtual void Repaint(bool theUpdateTrihedron = true); + +#if 0 + //---------------------------------------------------------------------------- + //! Redirect the request to #SPV3D_Renderer::SetScale + virtual void SetScale( double theScale[3] ); + + //! Redirect the request to #SPV3D_Renderer::GetScale + virtual void GetScale( double theScale[3] ); + + //! Redirect the request to #SPV3D_Renderer::AddActor + virtual void AddActor(PV3DViewer_Actor* theActor, + bool theIsUpdate = false, + bool theIsAdjustActors = true); + + //! Redirect the request to #SPV3D_Renderer::RemoveActor + virtual void RemoveActor(PV3DViewer_Actor* theActor, + bool theIsUpdate = false, + bool theIsAdjustActors = true); + + //---------------------------------------------------------------------------- + //! Redirect the request to #SPV3D_Renderer::AdjustActors + virtual void AdjustTrihedrons(const bool theIsForced); + + //! Redirect the request to #SPV3D_Renderer::GetTrihedron + PV3DViewer_Trihedron* GetTrihedron(); + + //! Redirect the request to #SPV3D_Renderer::GetCubeAxes + SPV3D_CubeAxesActor2D* GetCubeAxes(); + + //! Redirect the request to #SPV3D_Renderer::GetTrihedronSize + double GetTrihedronSize() const; + + //! Redirect the request to #SPV3D_Renderer::SetTrihedronSize + virtual void SetTrihedronSize( const double, const bool = true ); + + //! Set incremental speed + virtual void SetIncrementalSpeed( const int, const int = 0 ); + + //! Set current projection mode + virtual void SetProjectionMode( const int ); + + //! Sets stereo type + virtual void SetStereoType( const int ); + + //! Sets anaglyph filter + virtual void SetAnaglyphFilter( const int ); + + //! Set support quad-buffered stereo + virtual void SetQuadBufferSupport( const bool ); + + //! Set interactive style + virtual void SetInteractionStyle( const int ); + + //! Set zooming style + virtual void SetZoomingStyle( const int ); + + //! Set preselection mode + virtual void SetPreSelectionMode( Preselection_Mode ); +#endif + + //! Enable/disable selection + virtual void SetSelectionEnabled( bool ); + +#if 0 + //! Customize space mouse buttons + virtual void SetSpacemouseButtons( const int, const int, const int ); + + //! Set selection properties + virtual void SetSelectionProp(const double& theRed = 1, + const double& theGreen = 1, + const double& theBlue = 0, + const int& theWidth = 5); + + //! Redirect the request to #SPV3D_Renderer::SetPreselectionProp + virtual void SetPreselectionProp(const double& theRed = 0, + const double& theGreen = 1, + const double& theBlue = 1, + const int& theWidth = 5); + + //! Redirect the request to #SPV3D_Renderer::SetSelectionTolerance + virtual void SetSelectionTolerance(const double& theTolNodes = 0.025, + const double& theTolCell = 0.001, + const double& theTolObjects = 0.025); + + //! Get visibility status of the static trihedron + bool IsStaticTrihedronVisible() const; + + //! Set visibility status of the static trihedron + virtual void SetStaticTrihedronVisible( const bool ); + + //! Methods to save/restore visual parameters of a view (pan, zoom, etc.) + virtual QString getVisualParameters(); + + virtual void setVisualParameters( const QString& parameters ); + + virtual bool eventFilter( QObject*, QEvent* ); + + virtual void RefreshDumpImage(); + + void emitTransformed(); + + //! To invoke a PV3D event on #SPV3D_RenderWindowInteractor instance + void InvokeEvent(unsigned long theEvent, void* theCallData); + + virtual SUIT_CameraProperties cameraProperties(); +#endif + + signals: + void Show( QShowEvent * ); + void Hide( QHideEvent * ); + +public slots: + virtual void showEvent( QShowEvent * ); + virtual void hideEvent( QHideEvent * ); + +#if 0 + virtual void onSelectionChanged(); + + void onChangeRotationPoint(bool theIsActivate); + + void activateSetRotationGravity(); + void activateSetRotationSelected(void* theData); + void activateStartPointSelection( Selection_Mode ); + + void onUpdateRate(bool theIsActivate); + void onNonIsometric(bool theIsActivate); + void onGraduatedAxes(bool theIsActivate); + + void activateZoom(); + void activateWindowFit(); + void activateRotation(); + void activatePanning(); + void activateGlobalPanning(); + + void onProjectionMode( QAction* theAction ); + void onStereoMode( bool activate ); + void onProjectionMode(); + + void activateProjectionMode(int); + + void activateSetFocalPointGravity(); + void activateSetFocalPointSelected(); + void activateStartFocalPointSelection(); + void activateInteractiveSelection(); + void deactivateCurrectOperation(); + + void onViewParameters(bool theIsActivate); + + void onSwitchInteractionStyle(bool theOn); + void onSwitchZoomingStyle(bool theOn); + + void onSwitchPreSelectionMode(int theMode); + void onEnableSelection(bool theOn); + + void onStartRecording(); + void onPlayRecording(); + void onPauseRecording(); + void onStopRecording(); + +signals: + void selectionChanged(); + void actorAdded(PV3DViewer_Actor*); + void actorRemoved(PV3DViewer_Actor*); + void transformed(SPV3D_ViewWindow*); + +public slots: + //! Redirect the request to #SPV3D_Renderer::OnFrontView + virtual void onFrontView(); + + //! Redirect the request to #SPV3D_Renderer::OnBackView + virtual void onBackView(); + + //! Redirect the request to #SPV3D_Renderer::OnTopView + virtual void onTopView(); + + //! Redirect the request to #SPV3D_Renderer::OnBottomView + virtual void onBottomView(); + + //! Redirect the request to #SPV3D_Renderer::OnRightView + virtual void onRightView(); + + //! Redirect the request to #SPV3D_Renderer::OnLeftView + virtual void onLeftView(); + + //! Redirect the request to #SPV3D_Renderer::onClockWiseView + virtual void onClockWiseView(); + + //! Redirect the request to #SPV3D_Renderer::onAntiClockWiseView + virtual void onAntiClockWiseView(); + + //! Redirect the request to #SPV3D_Renderer::OnResetView + virtual void onResetView(); + + //! Redirect the request to #SPV3D_Renderer::OnFitAll + virtual void onFitAll(); + + //! Redirect the request to #SPV3D_Renderer::OnFitSelection + virtual void onFitSelection(); + + //! Redirect the request to #SPV3D_Renderer::OnFitIObjects + virtual void onFitIObjects(const SALOME_ListIO&); + + //! Redirect the request to #SPV3D_Renderer::OnViewTrihedron + virtual void onViewTrihedron(bool); + + //! Redirect the request to #SPV3D_Renderer::OnViewCubeAxes + virtual void onViewCubeAxes(); + + //! Redirect the request to #SPV3D_Renderer::OnAdjustTrihedron + virtual void onAdjustTrihedron(); + + //! Redirect the request to #SPV3D_Renderer::OnAdjustCubeAxes + virtual void onAdjustCubeAxes(); + + virtual void synchronize(SPV3D_ViewWindow*); +#endif + +protected slots: + //void synchronize( SUIT_ViewWindow* ); + void onKeyPressed(QKeyEvent* event); + void onKeyReleased(QKeyEvent* event); + void onMousePressed(QMouseEvent* event); + void onMouseDoubleClicked(QMouseEvent* event); + void onMouseReleased(QMouseEvent* event); + void onMouseMoving(QMouseEvent* event); + +public: +#if 0 + enum ProjectionType { Parallel, Projection, Stereo }; + + enum StereoType { CrystalEyes, RedBlue, Interlaced, Left, Right, Dresden, Anaglyph, Checkerboard, SplitViewPortHorizontal }; + + enum AnaglyphFilter { RedCyan, YellowBlue, GreenMagenta }; +#endif + +protected: + + // virtual void resizeEvent( QResizeEvent* ); + + // virtual void Initialize(SPV3D_View* theView, + // SPV3D_ViewModel/*Base*/* theModel); + +#if 0 + // Main process event method + static void ProcessEvents(vtkObject* object, + unsigned long event, + void* clientdata, + void* calldata); + + bool isOpenGlStereoSupport() const; + + void doSetVisualParameters( const QString&, bool = false ); + void SetEventDispatcher(vtkObject* theDispatcher); + + QImage dumpViewContent(); + + virtual QString filter() const; + virtual bool dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format ); + + virtual bool action( const int ); + + QtxAction* getAction( int ) const; + void createToolBar(); + void createActions(SUIT_ResourceMgr* theResourceMgr); + + enum { DumpId, FitAllId, FitRectId, FitSelectionId, ZoomId, PanId, GlobalPanId, + ChangeRotationPointId, RotationId, + FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId, ResetId, + ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate, + ParallelModeId, ProjectionModeId, StereoModeId, ViewParametersId, SynchronizeId, SwitchInteractionStyleId, + SwitchZoomingStyleId, + PreselectionId, StandardPreselectionId, DynamicPreselectionId, DisablePreselectionId, + EnableSelectionId, + StartRecordingId, PlayRecordingId, PauseRecordingId, StopRecordingId }; +#endif + + SPV3D_View* myView; + SPV3D_ViewModel/*Base*/* myModel; + +// SPV3D_RenderWindowInteractor* myInteractor; +// vtkSmartPointer myDefaultInteractorStyle; +// vtkSmartPointer myKeyFreeInteractorStyle; + +// QString myVisualParams; // used for delayed setting of view parameters + +// vtkSmartPointer myEventDispatcher; + +// // Used to process events +// vtkSmartPointer myEventCallbackCommand; + +// SPV3D_NonIsometricDlg* myNonIsometricDlg; +// SPV3D_UpdateRateDlg* myUpdateRateDlg; +// SPV3D_CubeAxesDlg* myCubeAxesDlg; +// SPV3D_SetRotationPointDlg* mySetRotationPointDlg; +// SPV3D_ViewParameterDlg* myViewParameterDlg; + +// QSize myPreRecordingMinSize; +// QSize myPreRecordingMaxSize; + +// SPV3D_Recorder* myRecorder; +// QtxAction* myStartAction; +// QtxAction* myPlayAction; +// QtxAction* myPauseAction; +// QtxAction* myStopAction; + +// int myToolBar; +// int myRecordingToolBar; + +// salomevtk::vtkPVAxesWidget* myAxesWidget; +// Qtx::BackgroundData myBackground; + +// private: +// QImage myDumpImage; +}; + +#ifdef WIN32 +#pragma warning( default:4251 ) +#endif + +#endif diff --git a/src/SalomeApp/CMakeLists.txt b/src/SalomeApp/CMakeLists.txt index 05b406eb2..ec62b5a82 100644 --- a/src/SalomeApp/CMakeLists.txt +++ b/src/SalomeApp/CMakeLists.txt @@ -107,6 +107,14 @@ IF(SALOME_USE_OCCVIEWER) ENDIF(SALOME_USE_SALOMEOBJECT) ENDIF() +# MBS: +IF(SALOME_USE_PV3DVIEWER) + LIST(APPEND _link_LIBRARIES PV3DViewer) + IF(SALOME_USE_SALOMEOBJECT) + LIST(APPEND _link_LIBRARIES SPV3D) + ENDIF(SALOME_USE_SALOMEOBJECT) +ENDIF() + IF(SALOME_USE_PVVIEWER) LIST(APPEND _link_LIBRARIES PVViewer) ENDIF() -- 2.39.2