From: Anthony Geay Date: Mon, 6 Mar 2023 17:45:44 +0000 (+0000) Subject: First integration of a new PV3D viewer. X-Git-Tag: V9_11_0a1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fgui.git;a=commitdiff_plain;h=b48b1667684c18181de10f168c81ca80c6ac7679 First integration of a new PV3D viewer. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 113cc34e2..581242328 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,7 @@ 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) +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 +86,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 +192,14 @@ ELSE() ADD_DEFINITIONS("-DDISABLE_PVVIEWER") ENDIF() +# - PV3D viewer: ParaView3D +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 +371,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..457cd61c8 100644 --- a/SalomeGUIConfig.cmake.in +++ b/SalomeGUIConfig.cmake.in @@ -55,6 +55,7 @@ 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@) +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 +79,9 @@ ENDIF() IF(NOT SALOME_USE_OCCVIEWER) LIST(APPEND GUI_DEFINITIONS "-DDISABLE_OCCVIEWER") ENDIF() +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 +221,7 @@ SET(GUI_SalomePy SalomePy) SET(GUI_SalomeSession SalomeSession) SET(GUI_SalomeStyle SalomeStyle) SET(GUI_SOCC SOCC) +SET(GUI_SPV3D SPV3D) SET(GUI_SPlot2d SPlot2d) SET(GUI_std std) SET(GUI_SUITApp SUITApp) @@ -226,6 +231,7 @@ SET(GUI_ToolsGUI ToolsGUI) SET(GUI_ViewerTools ViewerTools) SET(GUI_ViewerData ViewerData) SET(GUI_VTKViewer VTKViewer) +SET(GUI_PV3DViewer PV3DViewer) SET(GUI_PVViewer PVViewer) SET(GUI_PVServerService PVServerService) SET(GUI_vtkTools vtkTools) diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index 2e6f51e43..51e76fcfa 100644 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -950,4 +950,4 @@ bool CAM_Application::abortAllOperations() aborted = (*it)->abortAllOperations(); } return aborted; -} +} \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f5f768494..02ebfb228 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -83,6 +83,17 @@ IF(SALOME_USE_OCCVIEWER) ENDIF(SALOME_USE_SALOMEOBJECT) ENDIF(SALOME_USE_OCCVIEWER) +## +# ParaView3D Viewer +## +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..084f12931 100644 --- a/src/LightApp/CMakeLists.txt +++ b/src/LightApp/CMakeLists.txt @@ -58,6 +58,12 @@ IF(SALOME_USE_OCCVIEWER) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/SOCC) ENDIF() ENDIF() +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 +127,12 @@ IF(SALOME_USE_OCCVIEWER) LIST(APPEND _link_LIBRARIES SOCC) ENDIF() ENDIF() +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 +186,11 @@ ENDIF() IF(SALOME_USE_OCCVIEWER) LIST(APPEND _moc_HEADERS LightApp_OCCSelector.h) ENDIF() +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 +296,11 @@ ENDIF() IF(SALOME_USE_OCCVIEWER) LIST(APPEND _other_SOURCES LightApp_OCCSelector.cxx) ENDIF() +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 49972104e..4758aa40e 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -166,6 +166,20 @@ #include #endif +#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 @@ -784,6 +798,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 ); +#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() ) ); @@ -1104,6 +1121,11 @@ void LightApp_Application::onNewWindow() case NewPyViewerId: type = PyViewer_Viewer::Type(); break; +#endif +#ifndef DISABLE_PV3DVIEWER + case NewPV3DViewId: + type = PV3DViewer_ViewModel::Type(); + break; #endif } @@ -1278,6 +1300,12 @@ void LightApp_Application::updateCommandsStatus() if( a ) a->setEnabled( activeStudy() ); #endif + +#ifndef DISABLE_PV3DVIEWER + a = action( NewPV3DViewId ); + if( a ) + a->setEnabled( activeStudy() ); +#endif } /*! @@ -1843,6 +1871,32 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType } #endif +#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; @@ -4966,6 +5020,9 @@ QStringList LightApp_Application::viewManagersTypes() const #else aTypesList< #include #endif +#ifndef DISABLE_PV3DVIEWER + #include + #include +#endif #ifndef DISABLE_PLOT2DVIEWER #include #include @@ -377,6 +381,12 @@ void LightApp_Module::update( const int theFlags ) ( (VTKViewer_ViewWindow*)viewWnd )->Repaint(); #endif #endif +#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(); @@ -486,6 +496,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..c1c23aeb0 --- /dev/null +++ b/src/LightApp/LightApp_PV3DSelector.cxx @@ -0,0 +1,168 @@ +// 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 + +#ifndef DISABLE_PV3DVIEWER +/*! + Constructor. +*/ +LightApp_PV3DSelector::LightApp_PV3DSelector( SPV3D_ViewModel* viewer, SUIT_SelectionMgr* mgr ) +: SUIT_Selector( mgr, viewer ), + myViewer( viewer ) +{ + 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() +{ + selectionChanged(); +} + +#ifndef DISABLE_PV3DVIEWER + +/*! + Gets list of selected data owners.(output \a aList). +*/ +void LightApp_PV3DSelector::getSelection( SUIT_DataOwnerPtrList& /*aList*/ ) const +{ + 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 ) +{ + 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..4586b8520 --- /dev/null +++ b/src/LightApp/LightApp_PV3DSelector.h @@ -0,0 +1,73 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index 98cf24485..0e1c4249e 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -46,6 +46,7 @@ + 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/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..2b00f79ef --- /dev/null +++ b/src/PV3DViewer/PV3DViewer.h @@ -0,0 +1,33 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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..d4c0faaeb --- /dev/null +++ b/src/PV3DViewer/PV3DViewer_ViewManager.cxx @@ -0,0 +1,65 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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 + +/*! + Constructor +*/ +PV3DViewer_ViewManager::PV3DViewer_ViewManager(SUIT_Study* study, SUIT_Desktop* desktop) +: SUIT_ViewManager( study, desktop, new PV3DViewer_ViewModel() ) +{ + 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) +{ + 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..84dee0430 --- /dev/null +++ b/src/PV3DViewer/PV3DViewer_ViewManager.h @@ -0,0 +1,45 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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..dc230eb9c --- /dev/null +++ b/src/PV3DViewer/PV3DViewer_ViewModel.cxx @@ -0,0 +1,38 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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" + +PV3DViewer_ViewModel::PV3DViewer_ViewModel():SUIT_ViewModel() +{ + 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) +{ + 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..bfb82e0dd --- /dev/null +++ b/src/PV3DViewer/PV3DViewer_ViewModel.h @@ -0,0 +1,44 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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..9ae9cf47a --- /dev/null +++ b/src/PV3DViewer/PV3DViewer_ViewWindow.cxx @@ -0,0 +1,77 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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 + +/*! + \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 ) +{ + myDesktop = theDesktop; + myModel = theModel; + setViewManager(myModel->getViewManager()); +} + +/*! + \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() +{ + if ( myPVMgr ) { + myPVMgr->setParent( nullptr ); + myPVMgr->hide(); + myPVMgr = nullptr; + setCentralWidget( nullptr ); + } +} + +void PV3DViewer_ViewWindow::removePVMgr() +{ + pqTabbedMultiViewWidget* aPVMgr = qobject_cast(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET")); + delete aPVMgr; +} + + +/*! + \brief Returns the ParaView multi-view manager previously set with setPVManager() +*/ +pqTabbedMultiViewWidget *PV3DViewer_ViewWindow::getMultiViewManager() const +{ + return myPVMgr; +} diff --git a/src/PV3DViewer/PV3DViewer_ViewWindow.h b/src/PV3DViewer/PV3DViewer_ViewWindow.h new file mode 100644 index 000000000..6060616ce --- /dev/null +++ b/src/PV3DViewer/PV3DViewer_ViewWindow.h @@ -0,0 +1,50 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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(); + + 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/CMakeLists.txt b/src/PV3DViewer/resources/CMakeLists.txt new file mode 100644 index 000000000..c5b2f86f9 --- /dev/null +++ b/src/PV3DViewer/resources/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (C) 2010-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 +# + +SET(dist_salomeres_DATA + ParaViewFilters.xml + ParaViewSources.xml + ) + +FOREACH(f ${dist_salomeres_DATA}) + INSTALL(FILES ${f} DESTINATION ${SALOME_GUI_INSTALL_RES_DATA}) +ENDFOREACH(f ${dist_salomeres_DATA}) diff --git a/src/PV3DViewer/resources/PV3DViewer_msg_en.ts b/src/PV3DViewer/resources/PV3DViewer_msg_en.ts new file mode 100644 index 000000000..1d8868208 --- /dev/null +++ b/src/PV3DViewer/resources/PV3DViewer_msg_en.ts @@ -0,0 +1,16 @@ + + + + + @default + + + + + SPV3D_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..df0aa0116 --- /dev/null +++ b/src/PV3DViewer/resources/PV3DViewer_msg_fr.ts @@ -0,0 +1,16 @@ + + + + + @default + + + + + SPV3D_ViewManager + + PARAVIEW3D_VIEW_TITLE + Scène ParaView3D:%1 - visualiseur:%2 + + + diff --git a/src/PV3DViewer/resources/PV3DViewer_msg_ja.ts b/src/PV3DViewer/resources/PV3DViewer_msg_ja.ts new file mode 100644 index 000000000..7853a427e --- /dev/null +++ b/src/PV3DViewer/resources/PV3DViewer_msg_ja.ts @@ -0,0 +1,17 @@ + + + + + @default + + + + + + SPV3D_ViewManager + + PARAVIEW3D_VIEW_TITLE + ParaView3D シーン:%1 - ビューア:%2 + + + diff --git a/src/PV3DViewer/resources/ParaViewFilters.xml b/src/PV3DViewer/resources/ParaViewFilters.xml new file mode 100644 index 000000000..060d098ba --- /dev/null +++ b/src/PV3DViewer/resources/ParaViewFilters.xml @@ -0,0 +1,309 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PV3DViewer/resources/ParaViewReaders.xml b/src/PV3DViewer/resources/ParaViewReaders.xml new file mode 100644 index 000000000..dd88e53a0 --- /dev/null +++ b/src/PV3DViewer/resources/ParaViewReaders.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PV3DViewer/resources/ParaViewSources.xml b/src/PV3DViewer/resources/ParaViewSources.xml new file mode 100644 index 000000000..f89f10efe --- /dev/null +++ b/src/PV3DViewer/resources/ParaViewSources.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PV3DViewer/resources/ParaViewWriters.xml b/src/PV3DViewer/resources/ParaViewWriters.xml new file mode 100644 index 000000000..db7fd3e1c --- /dev/null +++ b/src/PV3DViewer/resources/ParaViewWriters.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PV3DViewer/resources/README b/src/PV3DViewer/resources/README new file mode 100644 index 000000000..287b0ff3b --- /dev/null +++ b/src/PV3DViewer/resources/README @@ -0,0 +1,12 @@ +README +------ + +The purpose of the XML files in this folder is the following: + +1. ParaViewFilters.xml - this file describes ParaView filters which are available in the SALOME +2. ParaViewSources.xml - this file describes ParaView sources which are available in the SALOME +3. ParaViewReaders.xml - deprecated +4. ParaViewWriters.xml - deprecated + +Initially these files are available in the ParaView sources, they ensure proper loading of the ParaView resources such as icons and names of an actions. +ParaViewFilters.xml and ParaViewSources.xml should be updated during migration to newer ParaView version. diff --git a/src/PVViewer/PVViewer_Core.cxx b/src/PVViewer/PVViewer_Core.cxx index 6b4205eef..d50b18c5a 100644 --- a/src/PVViewer/PVViewer_Core.cxx +++ b/src/PVViewer/PVViewer_Core.cxx @@ -44,23 +44,18 @@ #include #include - //---------- Static init ----------------- -pqPVApplicationCore* PVViewer_Core::MyCoreApp = 0; +pqPVApplicationCore* PVViewer_Core::MyCoreApp = nullptr; +bool PVViewer_Core::MyPqTabWidSingletonLoaded = false; bool PVViewer_Core::ConfigLoaded = false; -PVViewer_Behaviors * PVViewer_Core::ParaviewBehaviors = NULL; +PVViewer_Behaviors * PVViewer_Core::ParaviewBehaviors = nullptr; pqPVApplicationCore * PVViewer_Core::GetPVApplication() { return MyCoreApp; } -/*! - \brief Static method, performs initialization of ParaView session. - \param fullSetup whether to instanciate all behaviors or just the minimal ones. - \return \c true if ParaView has been initialized successfully, otherwise false -*/ -bool PVViewer_Core::ParaviewInitApp(QMainWindow * /*aDesktop*/) +bool PVViewer_Core::ParaViewInitAppCore() { if ( ! MyCoreApp) { // Obtain command-line arguments @@ -99,28 +94,44 @@ bool PVViewer_Core::ParaviewInitApp(QMainWindow * /*aDesktop*/) } // MyCoreApp = new pqPVApplicationCore (argc, argv); + for (int i = 0; i < argc; i++) + free(argv[i]); + delete[] argv; if (MyCoreApp->getOptions()->GetHelpSelected() || MyCoreApp->getOptions()->GetUnknownArgument() || MyCoreApp->getOptions()->GetErrorMessage() || MyCoreApp->getOptions()->GetTellVersion()) { return false; } + } + return true; +} - // Direct VTK log messages to our SALOME window - TODO: review this - PVViewer_OutputWindow * w = PVViewer_OutputWindow::New(); - vtkOutputWindow::SetInstance(w); - - new pqTabbedMultiViewWidget(); // registers a "MULTIVIEW_WIDGET" on creation - - for (int i = 0; i < argc; i++) - free(argv[i]); - delete[] argv; +/*! + \brief Static method, performs initialization of ParaView session. + \param fullSetup whether to instanciate all behaviors or just the minimal ones. + \return \c true if ParaView has been initialized successfully, otherwise false +*/ +bool PVViewer_Core::ParaviewInitApp() +{ + if( ! MyPqTabWidSingletonLoaded ) + { + if( ! ParaViewInitAppCore() ) + return false; + + // Direct VTK log messages to our SALOME window - TODO: review this + PVViewer_OutputWindow * w = PVViewer_OutputWindow::New(); + vtkOutputWindow::SetInstance(w); + pqActiveObjects::instance().setActiveView(nullptr); + new pqTabbedMultiViewWidget(); // registers a "MULTIVIEW_WIDGET" on creation + // Initialization of ParaView GUI widgets will be done when these widgets are + // really needed. + // PVViewer_GUIElements* inst = PVViewer_GUIElements::GetInstance(aDesktop); + // inst->getPropertiesPanel(); + PVViewer_Core::MyPqTabWidSingletonLoaded = true; + return true; } - // Initialization of ParaView GUI widgets will be done when these widgets are - // really needed. - // PVViewer_GUIElements* inst = PVViewer_GUIElements::GetInstance(aDesktop); - // inst->getPropertiesPanel(); - return true; + return true; } void PVViewer_Core::ParaviewInitBehaviors(bool fullSetup, QMainWindow* aDesktop) diff --git a/src/PVViewer/PVViewer_Core.h b/src/PVViewer/PVViewer_Core.h index 9d56dfda9..369c1a957 100644 --- a/src/PVViewer/PVViewer_Core.h +++ b/src/PVViewer/PVViewer_Core.h @@ -38,9 +38,11 @@ class PVVIEWER_EXPORT PVViewer_Core { public: static pqPVApplicationCore* GetPVApplication(); + static bool ParaViewInitAppCore(); + static pqPVApplicationCore *GetPVAppCore() { return MyCoreApp; } //! Initialize ParaView if not yet done (once per session) - static bool ParaviewInitApp(QMainWindow*); + static bool ParaviewInitApp(); static void ParaviewInitBehaviors(bool = false, QMainWindow* = 0); static void ParaviewLoadConfigurations(const QString&, bool = false); static void ParaviewCleanup(); @@ -50,6 +52,7 @@ private: virtual ~PVViewer_Core(){}; static pqPVApplicationCore* MyCoreApp; + static bool MyPqTabWidSingletonLoaded; static bool ConfigLoaded; static PVViewer_Behaviors* ParaviewBehaviors; }; diff --git a/src/PVViewer/PVViewer_GUIElements.cxx b/src/PVViewer/PVViewer_GUIElements.cxx index 057354cba..4958535f1 100644 --- a/src/PVViewer/PVViewer_GUIElements.cxx +++ b/src/PVViewer/PVViewer_GUIElements.cxx @@ -257,7 +257,7 @@ void PVViewer_GUIElements::buildPVWidgets() } void PVViewer_GUIElements::setToolBarVisible(bool show) -{ +{ QCoreApplication::processEvents(); if (!myPVWidgetsFlag) return; diff --git a/src/PVViewer/PVViewer_InitSingleton.cxx b/src/PVViewer/PVViewer_InitSingleton.cxx index ea138dbaa..c401af392 100644 --- a/src/PVViewer/PVViewer_InitSingleton.cxx +++ b/src/PVViewer/PVViewer_InitSingleton.cxx @@ -28,7 +28,7 @@ void PVViewer_InitSingleton::Init(QMainWindow* desktop) { if(IS_INIT) return ; - PVViewer_Core::ParaviewInitApp(desktop); + PVViewer_Core::ParaviewInitApp(); // Finish ParaView set up: behaviors, connection and configurations. const QString configPath(PVViewer_ViewManager::GetPVConfigPath()); PVViewer_Core::ParaviewInitBehaviors(true, desktop); diff --git a/src/PVViewer/PVViewer_ViewModel.cxx b/src/PVViewer/PVViewer_ViewModel.cxx index 55cc5e447..d5b136c80 100644 --- a/src/PVViewer/PVViewer_ViewModel.cxx +++ b/src/PVViewer/PVViewer_ViewModel.cxx @@ -39,4 +39,3 @@ SUIT_ViewWindow* PVViewer_Viewer::createView(SUIT_Desktop* desktop) { return new PVViewer_ViewWindow(desktop, this); } - diff --git a/src/PVViewer/PVViewer_ViewWindow.cxx b/src/PVViewer/PVViewer_ViewWindow.cxx index 0f860d8e9..cd8ed9ebc 100644 --- a/src/PVViewer/PVViewer_ViewWindow.cxx +++ b/src/PVViewer/PVViewer_ViewWindow.cxx @@ -32,7 +32,7 @@ #include #include - +#include "pqActiveObjects.h" /*! \class PVViewer_ViewWindow @@ -50,6 +50,7 @@ PVViewer_ViewWindow::PVViewer_ViewWindow( SUIT_Desktop* theDesktop, PVViewer_Vie myDesktop = theDesktop; myModel = theModel; setViewManager(myModel->getViewManager()); + pqActiveObjects::instance().setActiveView(nullptr); myPVMgr = qobject_cast(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET")); if (myPVMgr) { SUIT_Application* app = SUIT_Session::session()->activeApplication(); @@ -109,7 +110,6 @@ void PVViewer_ViewWindow::setVisualParameters( const QString& parameters ) SUIT_ViewWindow::setVisualParameters( parameters ); } - /*! \brief Returns the ParaView multi-view manager previously set with setMultiViewManager() */ diff --git a/src/Prs/SALOME_Prs.cxx b/src/Prs/SALOME_Prs.cxx index 15385f346..681cb7068 100644 --- a/src/Prs/SALOME_Prs.cxx +++ b/src/Prs/SALOME_Prs.cxx @@ -187,6 +187,80 @@ void SALOME_VTKPrs::Update( SALOME_Displayer* d ) if ( d ) d->Update( this ); } +/*! + Dispatches display operation to proper Display() method of SALOME_View +*/ +void SALOME_PV3DPrs::DisplayIn( SALOME_View* v ) const +{ + 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 +{ + 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 +{ + 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 +{ + 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 +{ + 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 +{ + d->AfterErase( v, this ); +} + +/*! + Dispatches operation to proper LocalSelectionIn() method of SALOME_View +*/ +void SALOME_PV3DPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const +{ + 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 +{ + 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 ) +{ + if ( d ) d->Update( this ); +} + /*! Dispatches display operation to proper Display() method of SALOME_View */ @@ -303,6 +377,14 @@ void SALOME_View::Display( const SALOME_VTKPrs* ) // MESSAGE( "SALOME_View::Display( const SALOME_VTKPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." ); } +/*! + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ +void SALOME_View::Display( const 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. */ @@ -327,6 +409,14 @@ 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." ); } +/*! + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ +void SALOME_View::Erase( const SALOME_PV3DPrs*, const 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. */ @@ -371,6 +461,15 @@ void SALOME_View::LocalSelection( const SALOME_VTKPrs*, const int ) // Probably, selection is being activated in uncompatible viewframe." ); } +/*! + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ +void SALOME_View::LocalSelection( const SALOME_PV3DPrs*, const 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. */ @@ -433,6 +532,14 @@ void SALOME_Displayer::Update( SALOME_VTKPrs* ) // MESSAGE( "SALOME_Displayer::Update( SALOME_VTKPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." ); } +/*! + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ +void 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..72d349f3b 100644 --- a/src/Prs/SALOME_Prs.h +++ b/src/Prs/SALOME_Prs.h @@ -194,6 +194,51 @@ public: virtual void LocalSelectionIn( SALOME_View*, const int ) const; }; +/*! + \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 +319,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. 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 virtual void Erase( const SALOME_Prs2d*, const bool = false );//!< Erase SALOME_Prs2d // Add new Erase() methods here... @@ -287,12 +334,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 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,26 +378,31 @@ 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. virtual void Update( SALOME_Prs2d* );//!< Update SALOME_Prs2d presentation. // Add new Update() methods here... - // Axiluary methods called before and after displaying of objects + // Auxiliary methods called before and after displaying of objects virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here 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 + virtual void AfterDisplay ( SALOME_View*, const SALOME_PV3DPrs* ) {} //! Null body here virtual void BeforeDisplay( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here virtual void AfterDisplay ( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here - // Axiluary methods called before and after erasing of objects + // Auxiliary methods called before and after erasing of objects virtual void BeforeErase( SALOME_View*, const SALOME_OCCPrs* ) {} //! Null body here 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 + virtual void AfterErase ( SALOME_View*, const SALOME_PV3DPrs* ) {} //! Null body here virtual void BeforeErase( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here virtual void AfterErase ( SALOME_View*, const SALOME_Prs2d* ) {} //! Null body here - // Axiluary method called to update visibility state of presentation + // Auxiliary method called to update visibility state of presentation virtual void UpdateVisibility( SALOME_View*, const SALOME_Prs*, bool ); }; 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_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index eea242463..2ac40ecd4 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -53,6 +53,10 @@ #include "PVViewer_ViewManager.h" #include "PVViewer_ViewModel.h" #endif // DISABLE_PVVIEWER +#ifndef DISABLE_PV3DVIEWER +#include "PV3DViewer_ViewManager.h" +#include "PV3DViewer_ViewModel.h" +#endif // DISABLE_PV3DVIEWER #include "QtxActionMenuMgr.h" #include "QtxWorkstack.h" #include "QtxTreeView.h" @@ -3450,6 +3454,18 @@ public: myResult = true; } #endif // DISABLE_PVVIEWER + } + else if ( type == "ParaView3D") { +#ifndef DISABLE_PV3DVIEWER + // specific processing for ParaView3D viewer: + // hierarchy of ParaView3D viewer is much more complex than for usual view; + // we look for sub-widget named "Viewport" + QList lst = wnd->findChildren( "Viewport" ); + if ( !lst.isEmpty() ) { + lst[0]->resize( myWndWidth, myWndHeight ); + myResult = true; + } +#endif // DISABLE_PV3DVIEWER } else { if ( wnd->centralWidget() ) { 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..423141e0e --- /dev/null +++ b/src/SPV3D/CMakeLists.txt @@ -0,0 +1,99 @@ +# Copyright (C) 2023 CEA/DEN, EDF R&D +# +# 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/OBJECT + ${PROJECT_SOURCE_DIR}/src/Prs + ${PROJECT_SOURCE_DIR}/src/PV3DViewer + ${PROJECT_SOURCE_DIR}/src/PVViewer + ${PROJECT_SOURCE_DIR}/src/PVServerService +) + +# 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 + SalomeObject SalomePrs PV3DViewer PVViewer PVServerService + ParaView::pqApplicationComponents + ParaView::pqPython +) + +# --- headers --- + +# header files / to be processed by moc +SET(_moc_HEADERS + SPV3D_ViewManager.h + SPV3D_ViewModel.h + SPV3D_ViewWindow.h + SPV3D_CADSelection.h +) + +# header files / no moc processing +SET(_other_HEADERS + SPV3D.h + SPV3D_Prs.h +) + +# header files / to install +SET(SPV3D_HEADERS ${_moc_HEADERS} ${_other_HEADERS}) + +# --- 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_CADSelection.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_CADSelection.cxx b/src/SPV3D/SPV3D_CADSelection.cxx new file mode 100644 index 000000000..34331783c --- /dev/null +++ b/src/SPV3D/SPV3D_CADSelection.cxx @@ -0,0 +1,443 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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_CADSelection.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//----------------------------------------------------------------------------- +SPV3D_CADSelection::SPV3D_CADSelection(QObject *parent, + pqRenderView* view, SelectionMode mode):QObject(parent) +{ + this->View = view; + this->Mode = mode; + this->PreviousRenderViewMode = -1; + this->MousePosition[0] = 0; + this->MousePosition[1] = 0; + //this->selectionComboBox = comboBox; + + for (size_t i = 0; i < sizeof(this->ObserverIds) / sizeof(this->ObserverIds[0]); ++i) + { + this->ObserverIds[i] = 0; + } + + //QObject::connect(button, SIGNAL(toggled(bool)), this, SLOT(actionTriggered(bool))); + + // if view == nullptr, we track the active view. + if (view == nullptr) + { + QObject::connect( + &pqActiveObjects::instance(), SIGNAL(viewChanged(pqView*)), this, SLOT(setView(pqView*))); + // this ensure that the enabled-state is set correctly. + this->setView(nullptr); + } + + this->setRepresentation(nullptr); + QObject::connect(&pqActiveObjects::instance(), + SIGNAL(representationChanged(pqDataRepresentation*)), this, + SLOT(setRepresentation(pqDataRepresentation*))); + + vtkPVRenderViewSettings::GetInstance()->SetEnableFastPreselection(true); + + this->updateEnableState(); +} + +//----------------------------------------------------------------------------- +SPV3D_CADSelection::~SPV3D_CADSelection() +{ + this->cleanupObservers(); +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::SetMode(const SPV3D_CADSelection::SelectionMode mode) +{ + this->Mode = mode; +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::updateEnableState() +{ + this->endSelection(); + + //auto paction = this->parentAction(); + //bool state = false; + if (this->Representation) + { + vtkSMProxy* proxy = this->Representation->getProxy(); + vtkSMStringVectorProperty* prop = + vtkSMStringVectorProperty::SafeDownCast(proxy->GetProperty("ColorArrayName")); + if (prop) + { + int association = std::atoi(prop->GetElement(3)); + const char* arrayName = prop->GetElement(4); + + vtkPVDataInformation* dataInfo = this->Representation->getInputDataInformation(); + + vtkPVDataSetAttributesInformation* info = nullptr; + if (association == vtkDataObject::CELL && + this->Mode == SELECT_FACES) + { + info = dataInfo->GetCellDataInformation(); + } + if (association == vtkDataObject::POINT && + this->Mode == SELECT_VERTICES) + { + info = dataInfo->GetPointDataInformation(); + } + + if (info) + { + /*vtkPVArrayInformation* arrayInfo = */info->GetArrayInformation(arrayName); + //state = arrayInfo && arrayInfo->GetDataType() == VTK_ID_TYPE; + } + } + } + //paction->setEnabled(state); +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::actionTriggered(bool val) +{ + if (val) + { + this->beginSelection(); + } + else + { + this->endSelection(); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::setView(pqView* view) +{ + if (this->View != view) + { + // if we were currently in selection, finish that before changing the view. + this->endSelection(); + } + + this->View = qobject_cast(view); + + // update enable state. + //this->parentAction()->setEnabled(this->View != nullptr); +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::setRepresentation(pqDataRepresentation* representation) +{ + if (this->Representation != representation) + { + // if we are currently in selection, finish that before changing the representation. + this->endSelection(); + + if (this->Representation != nullptr) + { + QObject::disconnect(this->RepresentationConnection); + } + + this->Representation = representation; + + if (this->Representation != nullptr) + { + this->RepresentationConnection = this->connect( + this->Representation, SIGNAL(colorArrayNameModified()), SLOT(updateEnableState())); + } + + // update enable state. + this->updateEnableState(); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::beginSelection() +{ + if (!this->View) + { + return; + } + + //QAction* actn = this->parentAction(); + //if (actn->isCheckable()) + { + //this->selectionComboBox->setEnabled(false); + + vtkSMRenderViewProxy* rmp = this->View->getRenderViewProxy(); + vtkSMPropertyHelper(rmp, "InteractionMode").Get(&this->PreviousRenderViewMode); + + //QString currentPrimitive = this->selectionComboBox->currentText(); + pqCoreUtilities::promptUser("SPV3D_CADSelection", QMessageBox::Information, + "Interactive Selection Information", + "You are entering interactive selection mode to highlight.\n" + "Move the mouse point over the dataset to interactively highlight elements.\n\n" + "Press Ctrl + click to add the currently highlighted element.\n" + "Press Shift + click to remove the element.\n\n" + "Click on Select button to exit this mode.", + QMessageBox::Ok | QMessageBox::Save); + this->View->setCursor(Qt::CrossCursor); + vtkSMPropertyHelper(rmp, "InteractionMode").Set(vtkPVRenderView::INTERACTION_MODE_SELECTION); + + rmp->UpdateVTKObjects(); + + // Setup observer. + assert(this->ObserverIds[0] == 0 && this->ObservedObject == nullptr && this->ObserverIds[1] == 0); + this->ObservedObject = rmp->GetInteractor(); + this->ObserverIds[0] = this->ObservedObject->AddObserver( + vtkCommand::MouseMoveEvent, this, &SPV3D_CADSelection::onMouseMove); + this->ObserverIds[1] = this->ObservedObject->AddObserver(vtkCommand::LeftButtonReleaseEvent, + this, &SPV3D_CADSelection::onLeftButtonRelease); + this->ObserverIds[2] = this->ObservedObject->AddObserver(vtkCommand::RightButtonPressEvent, + this, &SPV3D_CADSelection::onRightButtonPress); + this->ObserverIds[3] = this->ObservedObject->AddObserver(vtkCommand::RightButtonReleaseEvent, + this, &SPV3D_CADSelection::onRightButtonRelease); + + //this->parentAction()->setChecked(true); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::endSelection() +{ + if (!this->View) + { + return; + } + + if (this->PreviousRenderViewMode == -1) + { + return; + } + + //QAction* actn = this->parentAction(); + //if (actn->isCheckable()) + { + vtkSMRenderViewProxy* rmp = this->View->getRenderViewProxy(); + vtkSMPropertyHelper(rmp, "InteractionMode").Set(this->PreviousRenderViewMode); + this->PreviousRenderViewMode = -1; + rmp->UpdateVTKObjects(); + this->View->setCursor(QCursor()); + this->cleanupObservers(); + //this->parentAction()->setChecked(false); + + if (this->CurrentRepresentation != nullptr) + { + vtkSMSessionProxyManager* pxm = rmp->GetSessionProxyManager(); + vtkSMProxy* emptySel = pxm->NewProxy("sources", "IDSelectionSource"); + + this->CurrentRepresentation->UpdateVTKObjects(); + this->CurrentRepresentation = nullptr; + emptySel->Delete(); + + rmp->StillRender(); + } + + //this->selectionComboBox->setEnabled(true); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::onMouseMove() +{ + if (!this->DisablePreSelection && vtkPVRenderViewSettings::GetInstance()->GetEnableFastPreselection()) + { + this->fastSelection(true); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::onLeftButtonRelease() +{ + if (vtkPVRenderViewSettings::GetInstance()->GetEnableFastPreselection()) + { + this->fastSelection(); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::onRightButtonPress() +{ + this->DisablePreSelection = true; +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::onRightButtonRelease() +{ + this->DisablePreSelection = false; +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::fastSelection(bool presel) +{ + vtkSMRenderViewProxy* rmp = this->View->getRenderViewProxy(); + assert(rmp != nullptr); + + int x = rmp->GetInteractor()->GetEventPosition()[0]; + int y = rmp->GetInteractor()->GetEventPosition()[1]; + this->MousePosition[0] = x; + this->MousePosition[1] = y; + + int region[4] = { x, y, x, y }; + + vtkNew selectedRepresentations; + vtkNew selectionSources; + bool status = false; + // Do the selection on the current region + switch (this->Mode) + { + case SELECT_SOLIDS: + status = rmp->SelectSurfaceCells(region, selectedRepresentations, selectionSources, false, 0, false, "Solid id"); + break; + case SELECT_FACES: + status = rmp->SelectSurfaceCells(region, selectedRepresentations, selectionSources, false, 0, false, "Face id"); + break; + case SELECT_EDGES: + status = rmp->SelectSurfaceCells(region, selectedRepresentations, selectionSources, false, 0, false, "Edge id"); + break; + case SELECT_VERTICES: + status = rmp->SelectSurfaceCells(region, selectedRepresentations, selectionSources, false, 0, false, "Vertex id"); + break; + default: + qCritical("Invalid call to SPV3D_CADSelection::fastSelection"); + return; + } + + vtkSMRepresentationProxy* repr = + vtkSMRepresentationProxy::SafeDownCast(selectedRepresentations->GetItemAsObject(0)); + + if (repr && !presel) + { + repr->InvokeCommand("BeginSelect"); + } + + // If something has been preselected or selected + if (status) + { + vtkSMRepresentationProxy* repr = + vtkSMRepresentationProxy::SafeDownCast(selectedRepresentations->GetItemAsObject(0)); + + // If the selection occurs on a new represention, clean the selection on the + // current representation before continuing + if (this->CurrentRepresentation != nullptr && repr != this->CurrentRepresentation) + { + vtkSMSessionProxyManager* pxm = repr->GetSessionProxyManager(); + vtkSMProxy* emptySel = pxm->NewProxy("sources", "IDSelectionSource"); + + vtkSMPropertyHelper(this->CurrentRepresentation, "Selection").Set(emptySel); + this->CurrentRepresentation->UpdateVTKObjects(); + emptySel->Delete(); + } + + this->CurrentRepresentation = repr; + + // Set the selection (selection source) to the current representation + vtkSMSourceProxy* sel = vtkSMSourceProxy::SafeDownCast(selectionSources->GetItemAsObject(0)); + vtkSMPropertyHelper(repr, "Selection").Set(sel); + repr->UpdateVTKObjects(); + } + // If nothing has been selected then clean current representation + // with an "empty" selection source + else if (this->CurrentRepresentation != nullptr) + { + vtkSMSessionProxyManager* pxm = rmp->GetSessionProxyManager(); + vtkSMProxy* emptySel = pxm->NewProxy("sources", "IDSelectionSource"); + + vtkSMPropertyHelper(this->CurrentRepresentation, "Selection").Set(emptySel); + this->CurrentRepresentation->UpdateVTKObjects(); + this->CurrentRepresentation = nullptr; + emptySel->Delete(); + } + + this->View->forceRender(); + this->View->forceRender(); + // TODO improve this to avoid double render + + if (repr && !presel) + { + repr->InvokeCommand("EndSelect"); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::selectionChanged(vtkObject*, unsigned long, void* calldata) +{ + BEGIN_UNDO_EXCLUDE(); + + int selectionModifier = this->getSelectionModifier(); + int* region = reinterpret_cast(calldata); +// Simple version check to change once 5.10 support is dropped + this->View->selectCellsOnSurface(region, selectionModifier); + //this->View->selectOnSurface(region, selectionModifier); + END_UNDO_EXCLUDE(); + + this->endSelection(); +} + +//----------------------------------------------------------------------------- +int SPV3D_CADSelection::getSelectionModifier() +{ + int selectionModifier = pqView::PV_SELECTION_DEFAULT;//this->Superclass::getSelectionModifier(); + + vtkSMRenderViewProxy* rmp = this->View->getRenderViewProxy(); + assert(rmp != nullptr); + + bool ctrl = rmp->GetInteractor()->GetControlKey() == 1; + bool shift = rmp->GetInteractor()->GetShiftKey() == 1; + selectionModifier = pqView::PV_SELECTION_TOGGLE; + + if (ctrl) + { + selectionModifier = pqView::PV_SELECTION_ADDITION; + } + else if (shift) + { + selectionModifier = pqView::PV_SELECTION_SUBTRACTION; + } + return selectionModifier; +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::cleanupObservers() +{ + for (size_t i = 0; i < sizeof(this->ObserverIds) / sizeof(this->ObserverIds[0]); ++i) + { + if (this->ObservedObject != nullptr && this->ObserverIds[i] > 0) + { + this->ObservedObject->RemoveObserver(this->ObserverIds[i]); + } + this->ObserverIds[i] = 0; + } + this->ObservedObject = nullptr; +} diff --git a/src/SPV3D/SPV3D_CADSelection.h b/src/SPV3D/SPV3D_CADSelection.h new file mode 100644 index 000000000..b73fa7d92 --- /dev/null +++ b/src/SPV3D/SPV3D_CADSelection.h @@ -0,0 +1,160 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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 +// + +#pragma once + +#include + +#include +#include + +#include +#include +#include +#include +#include + +class vtkObject; +class pqView; +class pqRenderView; +class vtkIntArray; +class pqDataRepresentation; +class vtkSMRepresentationProxy; +class vtkSMSourceProxy; + +/** + * SPV3D_CADSelection handles various selection modes available on + * RenderViews. Simply create multiple instances of + * SPV3D_CADSelection to handle selection modes for that RenderView. + * SPV3D_CADSelection uses internal static members to ensure that + * at most 1 view (and 1 type of selection) is in selection-mode at any given + * time. + */ +class SPV3D_CADSelection : public QObject +{ + Q_OBJECT + +public: + enum SelectionMode + { + SELECT_SOLIDS, + SELECT_FACES, + SELECT_EDGES, + SELECT_VERTICES + }; + + /** + * If \c view is nullptr, this reaction will track the active-view maintained by + * pqActiveObjects. + */ + SPV3D_CADSelection(QObject *parent, pqRenderView* view, SelectionMode mode); + + ~SPV3D_CADSelection() override; + + /** + * Set the selectionMode + */ + void SetMode(const SPV3D_CADSelection::SelectionMode mode); + +public Q_SLOTS: + /** + * For checkable actions, this calls this->beginSelection() or + * this->endSelection() is val is true or false, respectively. For + * non-checkable actions, this call this->beginSelection() and + * this->endSelection() in that order. + */ + virtual void actionTriggered(bool val); + +private Q_SLOTS: + /** + * Called when this object was created with nullptr as the view and the active + * view changes. + */ + void setView(pqView* view); + + /** + * Called when the active representation changes. + */ + void setRepresentation(pqDataRepresentation* representation); + + /** + * starts the selection i.e. setup render view in selection mode. + */ + void beginSelection(); + + /** + * finishes the selection. Doesn't cause the selection, just returns the + * render view to previous interaction mode. + */ + void endSelection(); + + void updateEnableState(); + + ///@{ + /** + * Disable preselection during rotation using the right button. + */ + void onRightButtonPress(); + void onRightButtonRelease(); + ///@} + +private: + + /** + * callback called when the vtkPVRenderView is done with selection. + */ + void selectionChanged(vtkObject*, unsigned long, void* calldata); + + /** + * callback called for mouse move events when in 'interactive selection' + * modes. + */ + void onMouseMove(); + + /** + * callback called for click events when in 'interactive selection' modes. + */ + void onLeftButtonRelease(); + + // Get the current state of selection modifier + int getSelectionModifier(); + + /** + * makes fast selection. + */ + void fastSelection(bool presel = false); + + /** + * cleans up observers. + */ + void cleanupObservers(); + + Q_DISABLE_COPY(SPV3D_CADSelection) + QPointer View; + QPointer Representation; + QMetaObject::Connection RepresentationConnection; + vtkSMRepresentationProxy* CurrentRepresentation = nullptr; + SelectionMode Mode; + int PreviousRenderViewMode; + vtkWeakPointer ObservedObject; + unsigned long ObserverIds[4]; + int MousePosition[2]; + QComboBox* selectionComboBox; + bool DisablePreSelection = false; +}; diff --git a/src/SPV3D/SPV3D_Prs.cxx b/src/SPV3D/SPV3D_Prs.cxx new file mode 100644 index 000000000..60520b935 --- /dev/null +++ b/src/SPV3D/SPV3D_Prs.cxx @@ -0,0 +1,136 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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 "SPV3D_ViewWindow.h" + +#include "vtkActor.h" +#include "vtkPolyData.h" +#include "vtkCellData.h" +#include "vtkMapper.h" +#include "pqServer.h" +#include "pqApplicationCore.h" +#include "pqServerManagerModel.h" +#include "pqObjectBuilder.h" +#include "pqPipelineSource.h" +#include "vtkSMSourceProxy.h" +#include "vtkPVTrivialProducer.h" +#include + +bool SPV3D_EXPORTSPV3DData::IsVisible() const +{ + if( IsNull() ) + return false; + return GetRepresentation()->isVisible(); +} + +void SPV3D_EXPORTSPV3DData::Hide() const +{ + if( GetRepresentation() ) + GetRepresentation()->setVisible(0); +} + +SPV3D_Prs::SPV3D_Prs( const char* entry , SPV3D_ViewWindow *view) : SALOME_PV3DPrs(entry),_view(view) +{ +} + +SPV3D_Prs *SPV3D_Prs::deepCopy() const +{ + SPV3D_Prs *ret = new SPV3D_Prs( *this ); + return ret; +} + +pqProxy *getPQProxy(vtkSMProxy *proxy) +{ + pqServerManagerModel* smmodel = pqApplicationCore::instance()->getServerManagerModel(); + return smmodel->findItem(proxy); +} + +void SPV3D_Prs::FillUsingActor(vtkActor *actor) const +{ + SPV3D_EXPORTSPV3DData *alreadyExistingSrc = nullptr; + alreadyExistingSrc = _view->isEntryAlreadyExist( GetEntry() ); + if(alreadyExistingSrc && !alreadyExistingSrc->GetSourceProducer()) + { + actor->GetMapper()->Update(); + vtkDataObject *ds = actor->GetMapper()->GetInput(); + vtkPolyData *ds3 = vtkPolyData::SafeDownCast(ds); + vtkNew ds4; + if(ds3) + { + ds4->ShallowCopy( ds3 ); + vtkNew solidIdArray; + auto nbCells( ds4->GetNumberOfCells() ); + solidIdArray->SetNumberOfComponents(1); + solidIdArray->SetNumberOfTuples( nbCells ); + solidIdArray->SetName("Solid id"); + vtkIdType *pt( solidIdArray->GetPointer(0) ); + std::for_each(pt,pt+nbCells,[](vtkIdType& elt) { elt = 0; }); + ds4->GetCellData()->AddArray( solidIdArray ); + } + // + pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:"))); + pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); + pqPipelineSource *mySourceProducer(builder->createSource("sources","PVTrivialProducer",serv)); + vtkSMProxy *producerBase = mySourceProducer->getProxy(); + vtkSMSourceProxy *producer(vtkSMSourceProxy::SafeDownCast(producerBase)); + vtkObjectBase *clientSideObject(producer->GetClientSideObject()); + vtkPVTrivialProducer *clientSideObjectCast = vtkPVTrivialProducer::SafeDownCast(clientSideObject); + clientSideObjectCast->SetOutput(ds4); + mySourceProducer->updatePipeline(); + pqProxy *producerBase2( getPQProxy(producerBase) ); + if(producerBase2 && !_name.empty()) + producerBase2->rename( _name.c_str() ); + this->SetSourceProducer( mySourceProducer ); + } + else + { + this->CopyInfo( alreadyExistingSrc ); + } +} + +SPV3D_Prs:: ~SPV3D_Prs() +{ +} + +void SPV3D_Prs::DisplayIn( SALOME_View* v ) const +{ + SALOME_PV3DPrs::DisplayIn(v); +} + +void SPV3D_Prs::CopyInfo(SPV3D_EXPORTSPV3DData *info) const +{ + if(!_pvRendInfo || !info) + return ; + if(_pvRendInfo == info) + return ; + *_pvRendInfo = *info; +} + +bool SPV3D_Prs::IsNull() const +{ + if(_pvRendInfo) + return _pvRendInfo->IsNull(); + return true; +} + + diff --git a/src/SPV3D/SPV3D_Prs.h b/src/SPV3D/SPV3D_Prs.h new file mode 100644 index 000000000..e6a0db650 --- /dev/null +++ b/src/SPV3D/SPV3D_Prs.h @@ -0,0 +1,93 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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 +// + +#pragma once + +#include "SPV3D.h" +#include "SALOME_Prs.h" + +class vtkActor; +class pqPipelineSource; +class pqDataRepresentation; + +class SPV3D_EXPORTSPV3DData +{ +public: + SPV3D_EXPORTSPV3DData() = default; + SPV3D_EXPORTSPV3DData *deepCopy() { return new SPV3D_EXPORTSPV3DData(*this); } + void SetSourceProducer(pqPipelineSource *sourceProducer) const { _sourceProducer = sourceProducer; } + pqPipelineSource *GetSourceProducer() const { return _sourceProducer; } + + void SetRepresentation(pqDataRepresentation *repr) const { _repr = repr; } + pqDataRepresentation *GetRepresentation() const { return _repr; } + + bool IsNull() const { return !_sourceProducer && !_repr; } + + bool IsVisible() const; + void Hide() const; +private: + SPV3D_EXPORTSPV3DData(const SPV3D_EXPORTSPV3DData& other) = default; +private: + mutable pqPipelineSource *_sourceProducer = nullptr; + mutable pqDataRepresentation *_repr = nullptr; +}; + +class SPV3D_ViewWindow; + +class SPV3D_EXPORT SPV3D_Prs : public SALOME_PV3DPrs +{ +public: + explicit SPV3D_Prs( const char* entry, SPV3D_ViewWindow *view); + ~SPV3D_Prs(); + + void SetName(const std::string& name) { _name = name; } + + SPV3D_Prs *deepCopy() const; + + void FillUsingActor(vtkActor *actor) const; + + void DisplayIn( SALOME_View* v ) const override; + + void CopyInfo(SPV3D_EXPORTSPV3DData *info) const; + + void SetPVRenderInfo(SPV3D_EXPORTSPV3DData *pvRendInfo) { _pvRendInfo = pvRendInfo; } + + void SetSourceProducer(pqPipelineSource *sourceProducer) const { if(_pvRendInfo) _pvRendInfo->SetSourceProducer(sourceProducer); } + pqPipelineSource *GetSourceProducer() const { if(_pvRendInfo) return _pvRendInfo->GetSourceProducer(); return nullptr; } + + void SetRepresentation(pqDataRepresentation *repr) const { if(_pvRendInfo) _pvRendInfo->SetRepresentation(repr); } + pqDataRepresentation *GetRepresentation() const { if(_pvRendInfo) return _pvRendInfo->GetRepresentation(); return nullptr; } + + bool IsNull() const override; + +private: + + SPV3D_Prs(const SPV3D_Prs& other) = default; + +public: + void hide() const { if(_pvRendInfo) return _pvRendInfo->Hide(); } + bool isVisible() const { if(_pvRendInfo) return _pvRendInfo->IsVisible(); return false; } + +private: + + SPV3D_EXPORTSPV3DData *_pvRendInfo = nullptr; + SPV3D_ViewWindow *_view = nullptr; + //! Name attached to the displayable object in the study + std::string _name; +}; diff --git a/src/SPV3D/SPV3D_ViewManager.cxx b/src/SPV3D/SPV3D_ViewManager.cxx new file mode 100644 index 000000000..5ae676394 --- /dev/null +++ b/src/SPV3D/SPV3D_ViewManager.cxx @@ -0,0 +1,102 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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 + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/*! + Constructor +*/ +SPV3D_ViewManager::SPV3D_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop ) +: SUIT_ViewManager( study, theDesktop, new SPV3D_ViewModel() ) +{ + setTitle( SPV3D_ViewManager::tr( "PARAVIEW3D_VIEW_TITLE" ) ); + /*QStringList args = QCoreApplication::arguments(); + int argc = args.length(); + char **argv = new char *[argc+1]; + for(auto i = 0 ; i < argc ; ++i) + argv[i] = strdup(args[i].toStdString().c_str()); + argv[argc] = nullptr; + pqPVApplicationCore appPV(argc,argv); + QApplication::instance()->installEventFilter(&appPV); + new pqParaViewBehaviors(theDesktop,theDesktop); + pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); + pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:"))); + pqView *view=builder->createView(QString("RenderView"),serv); + static_cast(this->getViewModel())->setView(view);*/ + //QVBoxLayout *lay(new QVBoxLayout(theDesktop)); + //lay->addWidget( view->widget() ); + //view->widget()->setParent( theDesktop); + // Initialize minimal paraview stuff (if not already done) + //PVViewer_InitSingleton::Init(theDesktop); + + connect( theDesktop, SIGNAL( windowActivated( SUIT_ViewWindow* ) ), + this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); + + SPV3D_ViewModel *vm = dynamic_cast(getViewModel()); + if (vm) + vm->initialize(); +} + +/*! + Destructor +*/ +SPV3D_ViewManager::~SPV3D_ViewManager() +{ +} + +/*! + \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) +{ + 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..35bbb87e0 --- /dev/null +++ b/src/SPV3D/SPV3D_ViewManager.h @@ -0,0 +1,48 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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 "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..6827398b4 --- /dev/null +++ b/src/SPV3D/SPV3D_ViewModel.cxx @@ -0,0 +1,358 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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 "SPV3D_ViewModel.h" +#include "SPV3D_ViewWindow.h" +#include "SPV3D_Prs.h" +#include "PVViewer_Core.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "SUIT_ViewModel.h" +#include "SUIT_ViewManager.h" + +#include "SALOME_InteractiveObject.hxx" + +#include "QtxActionToolMgr.h" +#include "QtxBackgroundTool.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +// VSR: Uncomment below line to allow texture background support in PV3D viewer +#define PV3D_ENABLE_TEXTURED_BACKGROUND + +/*! + Constructor +*/ +SPV3D_ViewModel::SPV3D_ViewModel() +{ + mySelectionEnabled = true; +} + +/*! + Destructor +*/ +SPV3D_ViewModel::~SPV3D_ViewModel() +{ +} + + +void SPV3D_ViewModel::initialize() +{ +} + +void SPV3D_ViewModel::render() const +{ + if( _view ) + _view->render(); +} + +/*!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 ) +{ + SPV3D_ViewWindow* aViewWindow = new SPV3D_ViewWindow(theDesktop, this); + + aViewWindow->SetSelectionEnabled( isSelectionEnabled() ); + PVViewer_Core::ParaviewInitApp(); + QApplication::instance()->installEventFilter( PVViewer_Core::GetPVAppCore() ); + new pqParaViewBehaviors(aViewWindow,aViewWindow); + pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); + QObject::connect(builder, &pqObjectBuilder::sourceCreated, this, &SPV3D_ViewModel::onSourceCreated); + pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:"))); + pqView *view=builder->createView(QString("RenderView"),serv); + setView(view); + + aViewWindow->init(); + + return aViewWindow; +} + +/*! + Sets new view manager + \param theViewManager - new view manager +*/ +void SPV3D_ViewModel::setViewManager(SUIT_ViewManager* theViewManager) +{ + 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*/ ) +{ + // NYI +} + +/*! + 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) +{ + 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 + } + }*/ + blockSignals( blocked ); + } + +} + +pqView *SPV3D_ViewModel::getView() const +{ + return _view; +} + +/*! + Display presentation + \param prs - presentation +*/ +void SPV3D_ViewModel::Display( const SALOME_PV3DPrs* prs ) +{ + if(const SPV3D_Prs* aPrs = dynamic_cast( prs )) + { + if( !aPrs->GetRepresentation() ) + { + pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); + pqActiveObjects::instance().setActiveView(getView()); + pqPipelineSource *mySourceProducer = aPrs->GetSourceProducer(); + aPrs->SetSourceProducer( mySourceProducer ); + pqDataRepresentation* myRepr(builder->createDataRepresentation(mySourceProducer->getOutputPort(0),getView(),"CADRepresentation"));//"GeometryRepresentation" + vtkSMViewProxy::RepresentationVisibilityChanged(myRepr->getViewProxy(), myRepr->getProxy(), true); + aPrs->SetRepresentation(myRepr); + } + pqDataRepresentation* myRepr = aPrs->GetRepresentation(); + myRepr->setVisible(1); + vtkSMPVRepresentationProxy* proxy(dynamic_cast(myRepr->getProxy())); + if(proxy) + { + vtkSMPropertyHelper inputHelper(proxy, "Input"); + vtkSMSourceProxy* input = vtkSMSourceProxy::SafeDownCast(inputHelper.GetAsProxy()); + input->UpdatePipeline(); + } + getView()->resetDisplay(); + getView()->render(); + } +} + +/*! + Erase presentation + \param prs - presentation + \param forced - removes object from view +*/ +void SPV3D_ViewModel::Erase( const SALOME_PV3DPrs* prs, const bool /*forced*/ ) +{ + // NYI - hide a source + if(const SPV3D_Prs* aPrs = dynamic_cast( prs )){ + if(aPrs->IsNull()) + return; + aPrs->GetRepresentation()->setVisible(0); + getView()->render(); + //pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder(); + //pqServer* activeServer = pqActiveObjects::instance().activeServer(); + //builder->destroySources(activeServer); + } +} + +/*! + Erase all presentations + \param forced - removes all objects from view +*/ +void SPV3D_ViewModel::EraseAll( SALOME_Displayer* d, const bool forced ) +{ + SALOME_View::EraseAll( d, forced ); + if(SPV3D_ViewWindow* aViewWindow = dynamic_cast(getViewManager()->getActiveView())) + aViewWindow->EraseAll(); + Repaint(); +} + +/*! + Create presentation corresponding to the entry + \param entry - entry +*/ +SALOME_Prs* SPV3D_ViewModel::CreatePrs( const char* entry ) +{ + if(SPV3D_ViewWindow* aViewWindow = dynamic_cast(getViewManager()->getActiveView())) + { + return aViewWindow->findOrCreatePrs( entry ); + } + return nullptr; +} + +/*! + \return true if object is displayed in viewer + \param obj - object to be checked +*/ +bool SPV3D_ViewModel::isVisible( const Handle(SALOME_InteractiveObject)& io ) +{ + if(SPV3D_ViewWindow* aViewWindow = dynamic_cast(getViewManager()->getActiveView())) + return aViewWindow->isVisible( io ); + return false; +} + +/*! + \Collect objects visible in viewer + \param theList - visible objects collection +*/ +void SPV3D_ViewModel::GetVisible( SALOME_ListIO &/*theList*/ ) +{ + // NYI +} + +/*! + Updates current viewer +*/ +void SPV3D_ViewModel::Repaint() +{ + // NYI +} + + +void SPV3D_ViewModel::onViewCreated( SUIT_ViewWindow */*view*/) { +#ifdef VGL_WORKAROUND + if ( SPV3D_ViewWindow* svw = dynamic_cast( view ) ) + QTimer::singleShot(500, [svw] () { svw->Repaint(); } ); +#endif +} + +//----------------------------------------------------------------------------- +void SPV3D_ViewModel::onSourceCreated(pqPipelineSource* source) +{ + std::string sourceXMLName(source->getSourceProxy()->GetXMLName()); + pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder(); + if (sourceXMLName == "XMLPolyDataReader" || sourceXMLName == "GeometryGenerator" || sourceXMLName == "ShapeSource" || sourceXMLName == "CubeSource") + { + if (this->GeometrySource) + { + if (this->GeometrySource == source) { + } + else + builder->destroy(this->GeometrySource); + } + this->GeometrySource = source; + } + else + { + qWarning("Unsupported Source"); + return; + } + this->showSelectedMode(); +} + +//----------------------------------------------------------------------------- +void SPV3D_ViewModel::showSelectedMode() +{ + vtkNew controller; + pqView* activeView = pqActiveObjects::instance().activeView(); + if (activeView) + { + if (this->GeometrySource) + { +#if PARAVIEW_VERSION_MINOR <= 10 + this->GeometrySource->updatePipeline(); + this->GeometrySource->setModifiedState(pqProxy::UNMODIFIED); +#endif + + vtkSMSourceProxy *sourceProxy = this->GeometrySource->getSourceProxy(); + vtkSMViewProxy *viewProxy = activeView->getViewProxy(); + //const char *representationType = "CADRepresentation"; + controller->Show(sourceProxy, 0, viewProxy);//, representationType); + + } + } + activeView->render(); + activeView->resetDisplay(); +} diff --git a/src/SPV3D/SPV3D_ViewModel.h b/src/SPV3D/SPV3D_ViewModel.h new file mode 100644 index 000000000..b9690501f --- /dev/null +++ b/src/SPV3D/SPV3D_ViewModel.h @@ -0,0 +1,106 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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 +// + +#pragma once + +#include "SPV3D.h" +#include "PV3DViewer_ViewModel.h" + +#include +#include +#include + +class QMouseEvent; +class pqPipelineSource; +class pqView; + +//! Extends two interfaces #SPV3D_ViewModelBase and #SALOME_View +class SPV3D_EXPORT SPV3D_ViewModel : public PV3DViewer_ViewModel, public SALOME_View +{ + Q_OBJECT +public: + void setView(pqView *view) { _view = view; } + pqView *getView() const; + void render() const; +public: + //! Define string representation of the viewer type + static QString Type() { return "ParaView3D"; } + + SPV3D_ViewModel(); + virtual ~SPV3D_ViewModel(); + + virtual void initialize(); + + //! 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(); } + +public: + void enableSelection(bool isEnabled); + bool isSelectionEnabled() const { return mySelectionEnabled; } + + /* 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(); + +protected slots: + void onMousePress(SUIT_ViewWindow*, QMouseEvent*); + void onMouseMove(SUIT_ViewWindow*, QMouseEvent*); + void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*); + + void onViewCreated( SUIT_ViewWindow* ); + + void onSourceCreated(pqPipelineSource* source); + void showSelectedMode(); + +protected: + pqPipelineSource* GeometrySource = nullptr; + pqPipelineSource* MeshSource = nullptr; + +private: + bool mySelectionEnabled; + pqView *_view = nullptr; +}; diff --git a/src/SPV3D/SPV3D_ViewWindow.cxx b/src/SPV3D/SPV3D_ViewWindow.cxx new file mode 100644 index 000000000..48cf059d0 --- /dev/null +++ b/src/SPV3D/SPV3D_ViewWindow.cxx @@ -0,0 +1,413 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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_ViewModel.h" + +#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 +#include +#include + +#include "SALOME_ListIO.hxx" +#include "SPV3D_Prs.h" + +#include + +// Use workaround for rendering transparent object over MESA +#define USE_WORKAROUND_FOR_MESA + +/*! + Constructor +*/ +SPV3D_ViewWindow::SPV3D_ViewWindow(SUIT_Desktop* theDesktop, SPV3D_ViewModel* theModel): + PV3DViewer_ViewWindow(theDesktop, theModel), + myModel(theModel) +{ +} + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SPV3D_CADSelection.h" + +void SPV3D_ViewWindow::init() +{ + pqView *view(myModel->getView()); + pqRenderView *renderView(qobject_cast(view)); + QWidget *wid = view->widget(); + wid->setParent( this ); + setCentralWidget( wid ); + // + this-> + myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), // title (language-dependant) + QString( "PV3DViewerViewOperations" ), // name (language-independant) + false ); + QAction* resetCenterAction = + toolMgr()->toolBar(myToolBar)->addAction(QIcon(":/pqWidgets/Icons/pqResetCamera.svg"), tr( "MNU_FITALL" ) ); + new pqCameraReaction(resetCenterAction, pqCameraReaction::RESET_CAMERA); + QAction *showCenterAction = + toolMgr()->toolBar(myToolBar)->addAction(QIcon(":/pqWidgets/Icons/pqShowCenterAxes.svg"), tr( "DSC_SHOW_TRIHEDRON" ) ); + showCenterAction->setCheckable(true); + QObject::connect(showCenterAction, &QAction::toggled, this, &SPV3D_ViewWindow::showCenterAxes); + + // Pick a new center of rotation on the surface of the mesh + QAction* pickCenterAction = toolMgr()->toolBar(myToolBar)->addAction(QIcon(":/pqWidgets/Icons/pqPickCenter.svg"), tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ) ); + pickCenterAction->setCheckable(true); + pqRenderViewSelectionReaction* selectionReaction = new pqRenderViewSelectionReaction( + pickCenterAction, renderView, pqRenderViewSelectionReaction::SELECT_CUSTOM_BOX); + + QObject::connect(selectionReaction, + QOverload::of(&pqRenderViewSelectionReaction::selectedCustomBox), this, + &SPV3D_ViewWindow::pickCenterOfRotation); + // + mySelection = new SPV3D_CADSelection(this,renderView,SPV3D_CADSelection::SELECT_SOLIDS); + QAction *selectionAction = toolMgr()->toolBar(myToolBar)->addAction(SUIT_Session::session()->resourceMgr()->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_STANDARD" ) ), tr( "MNU_SVTK_PRESELECTION_STANDARD" ) ); + selectionAction->setCheckable(true); + QObject::connect(selectionAction, &QAction::toggled, this, &SPV3D_ViewWindow::goSelect); +} + +void SPV3D_ViewWindow::goSelect(bool val) +{ + if(val) + { + pqView* activeView(myModel->getView()); + if (!activeView) + { + return; + } + for(const auto& elt : myPrs) + { + pqPipelineSource *geometrySource = elt.second->GetSourceProducer(); + if(geometrySource) + { + vtkSMProxy* repr = activeView->getViewProxy()->FindRepresentation( + geometrySource->getSourceProxy(), 0); + repr->InvokeCommand("Reset"); + } + } + activeView->forceRender(); + activeView->render(); + activeView->resetDisplay(); + } + mySelection->actionTriggered(val); +} + +//----------------------------------------------------------------------------- +void SPV3D_ViewWindow::pickCenterOfRotation(int posx, int posy) +{ + pqView *view(myModel->getView()); + pqRenderView *renderView(qobject_cast(view)); + if (!renderView) + return; + + // Taken from vtkSMRenderViewProxy::ConvertDisplayToPointOnSurface + // TODO : we can use this function directly if we make a simple correction in ParaView : + // replace the vtkSMPVRepresentationProxy::SafeDownCast(...) by + // vtkSMRepresentationProxy::SafeDownCast(...), like done bellow + int region[4] = { posx, posy, posx, posy }; + vtkNew representations; + vtkNew sources; + + vtkSMRenderViewProxy* renderViewProxy = renderView->getRenderViewProxy(); + renderViewProxy->SelectSurfaceCells(region, representations, sources, false); + + // If a point has been selected + if (representations->GetNumberOfItems() > 0 && sources->GetNumberOfItems() > 0) + { + vtkSMRepresentationProxy* rep = + vtkSMRepresentationProxy::SafeDownCast(representations->GetItemAsObject(0)); + vtkSMProxy* input = vtkSMPropertyHelper(rep, "Input").GetAsProxy(0); + vtkSMSourceProxy* selection = vtkSMSourceProxy::SafeDownCast(sources->GetItemAsObject(0)); + + // Setup a ray that starts at the center of the camera and ends + // at the end of the scene + double nearDisplayPoint[3] = { (double)posx, (double)posy, 0.0 }; + double farDisplayPoint[3] = { (double)posx, (double)posy, 1.0 }; + double farLinePoint[3] = { 0.0, 0.0, 0.0 }; + double nearLinePoint[3] = { 0.0, 0.0, 0.0 }; + + vtkRenderer* renderer = renderViewProxy->GetRenderer(); + + // Compute the near ray point + renderer->SetDisplayPoint(nearDisplayPoint); + renderer->DisplayToWorld(); + const double* world = renderer->GetWorldPoint(); + for (int i = 0; i < 3; i++) + { + nearLinePoint[i] = world[i] / world[3]; + } + + // Compute the far ray point + renderer->SetDisplayPoint(farDisplayPoint); + renderer->DisplayToWorld(); + world = renderer->GetWorldPoint(); + for (int i = 0; i < 3; i++) + { + farLinePoint[i] = world[i] / world[3]; + } + + // Compute the intersection of the ray with the mesh + vtkSMProxyManager* proxyManager = vtkSMProxyManager::GetProxyManager(); + vtkSMSessionProxyManager* sessionProxyManager = proxyManager->GetActiveSessionProxyManager(); + vtkSMProxy* pickingHelper = sessionProxyManager->NewProxy("misc", "PickingHelper"); + + vtkSMPropertyHelper(pickingHelper, "Input").Set(input); + vtkSMPropertyHelper(pickingHelper, "Selection").Set(selection); + vtkSMPropertyHelper(pickingHelper, "PointA").Set(nearLinePoint, 3); + vtkSMPropertyHelper(pickingHelper, "PointB").Set(farLinePoint, 3); + vtkSMPropertyHelper(pickingHelper, "SnapOnMeshPoint").Set(false); + pickingHelper->UpdateVTKObjects(); + pickingHelper->UpdateProperty("Update", 1); + + double center[3] = { 0.0, 0.0, 0.0 }; + vtkSMPropertyHelper(pickingHelper, "Intersection").UpdateValueFromServer(); + vtkSMPropertyHelper(pickingHelper, "Intersection").Get(center, 3); + pickingHelper->Delete(); + + // Update the camera + vtkSMRenderViewProxy* renderViewProxy = renderView->getRenderViewProxy(); + vtkSMPropertyHelper(renderViewProxy, "CenterOfRotation").Set(center, 3); + vtkSMPropertyHelper(renderViewProxy, "CameraFocalPoint").Set(center, 3); + renderViewProxy->UpdateVTKObjects(); + renderView->render(); + } +} + +void SPV3D_ViewWindow::showCenterAxes(bool show_axes) +{ + if(!myModel) + return; + pqRenderView* renderView = qobject_cast(myModel->getView()); + if (!renderView) + return; + renderView->setCenterAxesVisibility(show_axes); + renderView->render(); +} + +SPV3D_Prs *SPV3D_ViewWindow::findOrCreatePrs( const char* entry ) +{ + std::string entryCpp( entry ); + SPV3D_Prs *prsOut( new SPV3D_Prs( entry, this ) ); + for(auto& prs : myPrs) + { + if(entryCpp == prs.first) + { + prsOut->SetPVRenderInfo( prs.second.get() ); + return prsOut; + } + } + std::unique_ptr data(new SPV3D_EXPORTSPV3DData); + prsOut->SetPVRenderInfo( data.get() ); + std::pair > p(entryCpp,std::move(data)); + myPrs.emplace_back( std::move(p) ); + return prsOut; +} + +SPV3D_EXPORTSPV3DData *SPV3D_ViewWindow::isEntryAlreadyExist( const char* entry ) const +{ + std::string entryCpp( entry ); + for(const auto& prs : myPrs) + { + if(entryCpp == prs.first) + return prs.second.get(); + } + return nullptr; +} + +/*! + Destructor +*/ +SPV3D_ViewWindow::~SPV3D_ViewWindow() +{ +} + +bool SPV3D_ViewWindow::isVisible(const Handle(SALOME_InteractiveObject)& theIObject) +{ + std::string entryCpp( theIObject->getEntry() ); + for(auto& prs : myPrs) + { + if(entryCpp == prs.first ) + return prs.second->IsVisible(); + } + return false; +} + +/*! + Display object + \param theIO - object + \param theImmediatly - update viewer +*/ +void SPV3D_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& /*theIO*/, + bool /*theImmediatly*/) +{ +} + +/*! + Erase object + \param theIO - object + \param theImmediatly - update viewer +*/ +void SPV3D_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& /*theIO*/, + bool /*theImmediatly*/) +{ +} + +/*! + Display only passed object + \param theIO - object +*/ +void SPV3D_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& /*theIO*/) +{ +} + + +/*! + Display all objects in view +*/ +void SPV3D_ViewWindow::DisplayAll() +{ +} + +/*! + Erase all objects in view +*/ +void SPV3D_ViewWindow::EraseAll() +{ + for(auto& prs : myPrs) + { + prs.second->Hide(); + } + if(myModel) + myModel->render(); +} + +/*! + Updates current viewer +*/ +void SPV3D_ViewWindow::Repaint(bool )//(bool theUpdateTrihedron) +{ + if(myModel) + myModel->render(); +} + +/*! + Enables/disables selection. + \param theEnable if true - selection will be enabled +*/ +void SPV3D_ViewWindow::SetSelectionEnabled( bool /*theEnable*/ ) +{ +} + +/*! + 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) +{ + 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 ) +{ + emit mouseDoubleClicked( this, event ); +} + +/*! + Custom show event handler +*/ +void SPV3D_ViewWindow::showEvent( QShowEvent * theEvent ) +{ + emit Show( theEvent ); +} + +/*! + Custom hide event handler +*/ +void SPV3D_ViewWindow::hideEvent( QHideEvent * theEvent ) +{ + emit Hide( theEvent ); +} diff --git a/src/SPV3D/SPV3D_ViewWindow.h b/src/SPV3D/SPV3D_ViewWindow.h new file mode 100644 index 000000000..3ec1af321 --- /dev/null +++ b/src/SPV3D/SPV3D_ViewWindow.h @@ -0,0 +1,112 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// 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 +// + +#pragma once + +#ifdef WIN32 +#pragma warning( disable:4251 ) +#endif + +#include "SPV3D.h" +#include "Qtx.h" +#include "PV3DViewer_ViewWindow.h" +#include "SPV3D_Prs.h" + +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_ListIO.hxx" + +#include +#include + +class SPV3D_ViewModel; +class SPV3D_CADSelection; + +//! Define a container for SALOME PV3D view window +class SPV3D_EXPORT SPV3D_ViewWindow : public PV3DViewer_ViewWindow +{ + Q_OBJECT + + public: + //! To construct #SPV3D_ViewWindow instance + SPV3D_ViewWindow(SUIT_Desktop* theDesktop, SPV3D_ViewModel* theModel); + + SPV3D_Prs *findOrCreatePrs( const char* entry ); + + SPV3D_EXPORTSPV3DData *isEntryAlreadyExist( const char* entry ) const; + + void init(); + + virtual ~SPV3D_ViewWindow(); + + bool isVisible(const Handle(SALOME_InteractiveObject)& theIObject); + + /* 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); + + //! Enable/disable selection + virtual void SetSelectionEnabled( bool ); + + signals: + void Show( QShowEvent * ); + void Hide( QHideEvent * ); + +public slots: + virtual void showEvent( QShowEvent * ); + virtual void hideEvent( QHideEvent * ); + void showCenterAxes(bool); + void pickCenterOfRotation(int posx, int posy); + void goSelect(bool val); + +protected slots: + void onKeyPressed(QKeyEvent* event); + void onKeyReleased(QKeyEvent* event); + void onMousePressed(QMouseEvent* event); + void onMouseDoubleClicked(QMouseEvent* event); + void onMouseReleased(QMouseEvent* event); + void onMouseMoving(QMouseEvent* event); + +protected: + SPV3D_CADSelection *mySelection = nullptr; + int myToolBar = -1; + SPV3D_ViewModel* myModel; + std::list< std::pair > > myPrs; +}; + +#ifdef WIN32 +#pragma warning( default:4251 ) +#endif diff --git a/src/SUIT/SUIT_SelectionMgr.cxx b/src/SUIT/SUIT_SelectionMgr.cxx index 567ca5488..17dfa646c 100644 --- a/src/SUIT/SUIT_SelectionMgr.cxx +++ b/src/SUIT/SUIT_SelectionMgr.cxx @@ -367,4 +367,4 @@ void SUIT_SelectionMgr::filterOwners( const SUIT_DataOwnerPtrList& in, SUIT_Data if ( isOk( *it ) ) out.append( *it ); } -} +} \ No newline at end of file diff --git a/src/SUIT/SUIT_Selector.cxx b/src/SUIT/SUIT_Selector.cxx index a3e49cc58..0d103479c 100644 --- a/src/SUIT/SUIT_Selector.cxx +++ b/src/SUIT/SUIT_Selector.cxx @@ -204,4 +204,4 @@ void SUIT_Selector::selectionModes( QList& lst ) const QObject* SUIT_Selector::owner() const { return myDestroyer ? myDestroyer->parent() : 0; -} +} \ No newline at end of file diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index 3c031a976..dbacd417f 100644 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -362,4 +362,4 @@ SUIT_ResourceMgr* SUIT_Session::createResourceMgr( const QString& appName ) cons void SUIT_Session::onApplicationActivated( SUIT_Application* app ) { myActiveApp = app; -} +} \ No newline at end of file diff --git a/src/SUIT/SUIT_ViewModel.cxx b/src/SUIT/SUIT_ViewModel.cxx index 715e45d67..6a3201b94 100644 --- a/src/SUIT/SUIT_ViewModel.cxx +++ b/src/SUIT/SUIT_ViewModel.cxx @@ -117,4 +117,4 @@ void SUIT_ViewModel::getHotButton( InteractionStyle theInteractionStyle, HotOper { theState = myStateMap[theInteractionStyle][theOper]; theButton = myButtonMap[theInteractionStyle][theOper]; -} +} \ No newline at end of file diff --git a/src/SUIT/SUIT_ViewWindow.cxx b/src/SUIT/SUIT_ViewWindow.cxx index 6f8f2243e..7480df9ea 100644 --- a/src/SUIT/SUIT_ViewWindow.cxx +++ b/src/SUIT/SUIT_ViewWindow.cxx @@ -560,4 +560,4 @@ void SUIT_ViewWindow::setVisible( bool on ) QApplication::sendPostedEvents( 0, QEvent::ChildPolished ); if ( !property( "blockShow" ).toBool() ) QMainWindow::setVisible( on ); -} +} \ No newline at end of file diff --git a/src/SalomeApp/CMakeLists.txt b/src/SalomeApp/CMakeLists.txt index 05b406eb2..3a69e3d0e 100644 --- a/src/SalomeApp/CMakeLists.txt +++ b/src/SalomeApp/CMakeLists.txt @@ -107,6 +107,13 @@ IF(SALOME_USE_OCCVIEWER) ENDIF(SALOME_USE_SALOMEOBJECT) ENDIF() +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() diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 876289b1b..2d02db84b 100644 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -495,6 +495,7 @@ int AbstractGUIAppMain(int argc, char **argv) // Create Qt application instance: this should be done as early as possible! // Note: QApplication forces setting locale LC_ALL to system one: setlocale(LC_ALL, ""). + SetArgcArgv(argc,argv); Application app(argc, argv); // Initialize Python (only once)