Salome HOME
First integration of a new PV3D viewer.
[modules/gui.git] / src / SPV3D / SPV3D_ViewModel.h
1 // Copyright (C) 2023  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #pragma once
21
22 #include "SPV3D.h"
23 #include "PV3DViewer_ViewModel.h"
24
25 #include <SALOME_Prs.h>
26 #include <SALOME_InteractiveObject.hxx>
27 #include <SALOME_ListIO.hxx>
28
29 class QMouseEvent;
30 class pqPipelineSource;
31 class pqView;
32
33 //! Extends two interfaces #SPV3D_ViewModelBase and #SALOME_View 
34 class SPV3D_EXPORT SPV3D_ViewModel : public PV3DViewer_ViewModel, public SALOME_View 
35 {
36   Q_OBJECT
37 public:
38   void setView(pqView *view) { _view = view; }
39   pqView *getView() const;
40   void render() const;
41 public:
42   //! Define string representation of the viewer type
43   static QString           Type() { return "ParaView3D"; }
44
45   SPV3D_ViewModel();
46   virtual ~SPV3D_ViewModel();
47
48   virtual void initialize();
49   
50   //! See #SUIT_ViewModel::createView
51   virtual SUIT_ViewWindow* createView(SUIT_Desktop*);
52
53   //! See #SUIT_ViewModel::createView
54   virtual void setViewManager(SUIT_ViewManager* theViewManager);
55
56   //! See #SUIT_ViewModel::contextMenuPopup
57   virtual void contextMenuPopup( QMenu* );
58
59   //! See #SUIT_ViewModel::getType
60   virtual QString getType() const { return Type(); }
61
62 public:
63   void enableSelection(bool isEnabled);
64   bool isSelectionEnabled() const { return mySelectionEnabled; }
65
66   /* Reimplemented from SALOME_View */
67
68   //! See #SALOME_View::Display( const SALOME_Prs* )
69   void Display( const SALOME_PV3DPrs* ); 
70
71   //! See #SALOME_View::Erase( const SALOME_PV3DPrs*, const bool = false )
72   void Erase( const SALOME_PV3DPrs*, const bool = false );
73
74   //! See #SALOME_View::EraseAll( SALOME_Displayer*, const bool = false )
75   void EraseAll( SALOME_Displayer*, const bool = false );
76
77   //! See #SALOME_View::getVisible( SALOME_ListIO& )
78   virtual void GetVisible( SALOME_ListIO& );
79
80   //! See #SALOME_View::CreatePrs( const char* entry = 0 )
81   SALOME_Prs* CreatePrs( const char* entry = 0 );
82
83   //! See #SALOME_View::isVisible( const Handle(SALOME_InteractiveObject)& )
84   virtual bool isVisible( const Handle(SALOME_InteractiveObject)& );
85
86   //! See #SALOME_View::Repaint()
87   virtual void Repaint();
88
89 protected slots:
90   void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
91   void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
92   void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
93
94   void onViewCreated( SUIT_ViewWindow* );
95
96   void onSourceCreated(pqPipelineSource* source);
97   void showSelectedMode();
98
99 protected:
100   pqPipelineSource* GeometrySource = nullptr;
101   pqPipelineSource* MeshSource = nullptr;
102
103 private:
104   bool mySelectionEnabled;
105   pqView *_view = nullptr;
106 };