Version: 9.15.0
SPV3D_Prs.h
Go to the documentation of this file.
1 // Copyright (C) 2023-2025 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 #include "vtkPolyData.h"
26 #include "vtkCellData.h"
27 #include <vtkMultiBlockDataSet.h>
28 #include <vtkSmartPointer.h>
29 
30 #include <set>
31 class vtkActor;
32 class pqPipelineSource;
33 class pqDataRepresentation;
34 
36 {
37 public:
40  void SetPrs(vtkPolyData* ds, const char* entry);
41  void SetPolyData(vtkPolyData* ds);
42  void RemovePrs(const char* entry);
43 
44  // the source producer is initialized in the instantiation of SPV3D_EXPORTSPV3DData
45  // Normaly, we shouldn't copy another src in SPV3D_EXPORTSPV3DData
46  //void SetSourceProducer(pqPipelineSource *sourceProducer) const { _sourceProducer = sourceProducer; }
47  pqPipelineSource *GetSourceProducer() const { return _sourceProducer; }
48 
49  void SetRepresentation(pqDataRepresentation *repr) const { _repr = repr; }
50  pqDataRepresentation *GetRepresentation() const { return _repr; }
51 
53  bool IsNull() const { return !_sourceProducer && !_repr; }
54 
55  bool IsVisible() const;
56  bool havePrs(const char* entry, unsigned int & id);
57  void Hide() const;
58 
59 private:
61 private:
62  vtkSmartPointer<vtkMultiBlockDataSet> _multiGEOMData;
63  vtkIdType nbsolid;
64  mutable pqPipelineSource *_sourceProducer = nullptr;
65  mutable pqDataRepresentation *_repr = nullptr;
66 };
67 
68 class SPV3D_ViewWindow;
69 
71 {
72 public:
73  explicit SPV3D_Prs( const char* entry, SPV3D_ViewWindow *view);
74  ~SPV3D_Prs();
75 
76  void SetName(const std::string& name) { _name = name; }
77 
78  SPV3D_Prs *deepCopy() const;
79 
80  void FillUsingActor(vtkActor *actor) const;
81 
82  void DisplayIn( SALOME_View* v ) const override;
83 
84  void SetPVRenderInfo(SPV3D_EXPORTSPV3DData *pvRendInfo) { _pvRendInfo = pvRendInfo; }
85 
86  // the source producer is initialized in the instantiation of SPV3D_EXPORTSPV3DData
87  // Normaly, we shouldn't copy another src in SPV3D_EXPORTSPV3DData
88  //void SetSourceProducer(pqPipelineSource *sourceProducer) const { if(_pvRendInfo) _pvRendInfo->SetSourceProducer(sourceProducer); }
89  pqPipelineSource *GetSourceProducer() const { if(_pvRendInfo) return _pvRendInfo->GetSourceProducer(); return nullptr; }
90 
91  void SetRepresentation(pqDataRepresentation *repr) const { if(_pvRendInfo) _pvRendInfo->SetRepresentation(repr); }
92  pqDataRepresentation *GetRepresentation() const { if(_pvRendInfo) return _pvRendInfo->GetRepresentation(); return nullptr; }
93 
94  bool IsNull() const override;
95  static vtkIdType FromEntryToVtkId (const char*);
96  static const char* FromVtkIdToEntry (vtkIdType);
97 
98 private:
99 
100  SPV3D_Prs(const SPV3D_Prs& other) = default;
101 
102 public:
103  void hide() const { if(_pvRendInfo) return _pvRendInfo->RemovePrs(GetEntry()); }
104  bool isVisible() const { if(_pvRendInfo) return _pvRendInfo->IsVisible(); return false; }
105 
106 private:
107 
108  SPV3D_EXPORTSPV3DData *_pvRendInfo = nullptr;
109  SPV3D_ViewWindow *_view = nullptr;
111  std::string _name;
112  static vtkIdType cellid;
113  static vtkIdType nbsolid;
114 
115 };
#define SPV3D_EXPORT
Definition: SPV3D.h:33
Definition: SALOME_Prs.h:204
virtual void DisplayIn(SALOME_View *) const
It uses double dispatch in order to invoke Display() method corresponding to the actual type of prese...
Definition: SALOME_Prs.cxx:193
const char * GetEntry() const
Get entry.
Definition: SALOME_Prs.cxx:39
virtual bool IsNull() const =0
Should return true, if this presentation contains a graphic object.
Definition: SALOME_Prs.h:292
Definition: SPV3D_Prs.h:36
SPV3D_EXPORTSPV3DData(const SPV3D_EXPORTSPV3DData &other)=default
pqDataRepresentation * _repr
Definition: SPV3D_Prs.h:65
void SetRepresentation(pqDataRepresentation *repr) const
Definition: SPV3D_Prs.h:49
SPV3D_EXPORTSPV3DData * deepCopy()
Definition: SPV3D_Prs.h:39
bool IsVisible() const
Definition: SPV3D_Prs.cxx:133
bool IsNull() const
Definition: SPV3D_Prs.h:53
vtkIdType nbsolid
Definition: SPV3D_Prs.h:63
pqPipelineSource * _sourceProducer
Definition: SPV3D_Prs.h:64
void SetPrs(vtkPolyData *ds, const char *entry)
Definition: SPV3D_Prs.cxx:59
void SetPolyData(vtkPolyData *ds)
Definition: SPV3D_Prs.cxx:53
pqDataRepresentation * GetRepresentation() const
Definition: SPV3D_Prs.h:50
void RemovePrs(const char *entry)
Definition: SPV3D_Prs.cxx:89
vtkSmartPointer< vtkMultiBlockDataSet > _multiGEOMData
Definition: SPV3D_Prs.h:62
void Hide() const
Definition: SPV3D_Prs.cxx:159
pqPipelineSource * GetSourceProducer() const
Definition: SPV3D_Prs.h:47
void updateSource_for_display()
Definition: SPV3D_Prs.cxx:101
SPV3D_EXPORTSPV3DData()
Definition: SPV3D_Prs.cxx:45
bool havePrs(const char *entry, unsigned int &id)
Definition: SPV3D_Prs.cxx:140
Definition: SPV3D_Prs.h:71
void hide() const
Definition: SPV3D_Prs.h:103
static vtkIdType cellid
Definition: SPV3D_Prs.h:112
bool isVisible() const
Definition: SPV3D_Prs.h:104
void SetRepresentation(pqDataRepresentation *repr) const
Definition: SPV3D_Prs.h:91
pqDataRepresentation * GetRepresentation() const
Definition: SPV3D_Prs.h:92
pqPipelineSource * GetSourceProducer() const
Definition: SPV3D_Prs.h:89
static vtkIdType nbsolid
Definition: SPV3D_Prs.h:113
std::string _name
Name attached to the displayable object in the study.
Definition: SPV3D_Prs.h:111
void SetName(const std::string &name)
Definition: SPV3D_Prs.h:76
void SetPVRenderInfo(SPV3D_EXPORTSPV3DData *pvRendInfo)
Definition: SPV3D_Prs.h:84
SPV3D_Prs(const SPV3D_Prs &other)=default
Define a container for SALOME PV3D view window.
Definition: SPV3D_ViewWindow.h:42