Salome HOME
updated copyright message
[modules/gui.git] / src / SPV3D / SPV3D_Prs.h
1 // Copyright (C) 2023  CEA, EDF
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 "SALOME_Prs.h"
24
25 class vtkActor;
26 class pqPipelineSource;
27 class pqDataRepresentation;
28
29 class SPV3D_EXPORTSPV3DData
30 {
31 public:
32   SPV3D_EXPORTSPV3DData() = default;
33   SPV3D_EXPORTSPV3DData *deepCopy() { return new SPV3D_EXPORTSPV3DData(*this); }
34   void SetSourceProducer(pqPipelineSource *sourceProducer) const { _sourceProducer = sourceProducer; }
35   pqPipelineSource *GetSourceProducer() const { return _sourceProducer; }
36   
37   void SetRepresentation(pqDataRepresentation *repr) const { _repr = repr; }
38   pqDataRepresentation *GetRepresentation() const { return _repr; }
39   
40   bool IsNull() const { return !_sourceProducer && !_repr; }
41
42   bool IsVisible() const;
43   void Hide() const;
44 private:
45   SPV3D_EXPORTSPV3DData(const SPV3D_EXPORTSPV3DData& other) = default;
46 private:
47   mutable pqPipelineSource *_sourceProducer = nullptr;
48   mutable pqDataRepresentation *_repr = nullptr;
49 };
50
51 class SPV3D_ViewWindow;
52
53 class SPV3D_EXPORT SPV3D_Prs : public SALOME_PV3DPrs
54 {
55 public:
56   explicit SPV3D_Prs( const char* entry, SPV3D_ViewWindow *view);
57   ~SPV3D_Prs();
58   
59   void SetName(const std::string& name) { _name = name; }
60   
61   SPV3D_Prs *deepCopy() const;
62   
63   void FillUsingActor(vtkActor *actor) const;
64
65   void DisplayIn( SALOME_View* v ) const override;
66
67   void CopyInfo(SPV3D_EXPORTSPV3DData *info) const;
68
69   void SetPVRenderInfo(SPV3D_EXPORTSPV3DData *pvRendInfo) { _pvRendInfo = pvRendInfo; }
70
71   void SetSourceProducer(pqPipelineSource *sourceProducer) const { if(_pvRendInfo) _pvRendInfo->SetSourceProducer(sourceProducer); }
72   pqPipelineSource *GetSourceProducer() const { if(_pvRendInfo) return _pvRendInfo->GetSourceProducer(); return nullptr; }
73   
74   void SetRepresentation(pqDataRepresentation *repr) const { if(_pvRendInfo) _pvRendInfo->SetRepresentation(repr); }
75   pqDataRepresentation *GetRepresentation() const { if(_pvRendInfo) return _pvRendInfo->GetRepresentation(); return nullptr; }
76
77   bool IsNull() const override;
78
79 private:
80
81   SPV3D_Prs(const SPV3D_Prs& other) = default;
82
83 public:
84   void hide() const { if(_pvRendInfo) return _pvRendInfo->Hide(); }
85   bool isVisible() const { if(_pvRendInfo) return _pvRendInfo->IsVisible(); return false; }
86
87 private:
88   
89   SPV3D_EXPORTSPV3DData *_pvRendInfo = nullptr;
90   SPV3D_ViewWindow *_view = nullptr;
91   //! Name attached to the displayable object in the study
92   std::string _name;
93 };