VTKFIG  0.25.0
Easy VTK based in situ visualization
vtkfigScalarView.h
Go to the documentation of this file.
1 
7 #ifndef VTKFIG_SCALARVIEW_H
8 #define VTKFIG_SCALARVIEW_H
9 
10 #include <vtkRenderer.h>
11 #include <vtkCommand.h>
12 #include <vtkDataSetAttributes.h>
13 #include <vtkGeometryFilter.h>
14 #include <vtkRectilinearGridGeometryFilter.h>
15 
16 #include "vtkfigDataSet.h"
17 #include "vtkfigTools.h"
18 #include "vtkfigFigure.h"
19 
20 
21 
22 namespace vtkfig
23 {
24 
28  class ScalarView: public Figure
29  {
30 
31  public:
32 
34  static std::shared_ptr<ScalarView> New();
35 
36  virtual std::string SubClassName() override final {return std::string("ScalarView");}
37 
39  void ShowSurface(bool b) {state.show_surface=b;}
40 
42  void ShowIsolines(bool b) {state.show_isolines=b;}
43 
45  void ShowIsosurfaces(bool b) {state.show_isosurfaces=b;}
46 
48  void ShowSurfaceColorbar(bool b) {state.show_surface_colorbar=b;}
49 
51  void SetSurfaceColorbarLabelFormat(std::string fmt) {strncpy(state.surface_colorbar_label_format,fmt.c_str(),20);}
52 
54  void SetSurfaceColorbarNumberOfLabels(int n) {state.surface_colorbar_num_labels=n;}
55 
57  void ShowElevation(bool b) {state.show_elevation=b; RefreshState();}
58 
60  void SetNumberOfIsocontours(int n) {isoline_filter->SetNumberOfContours(n);}
61 
63  void SetIsolineWidth(double w) {state.isoline_width=w;}
64 
66  void SetElevationZShift(double val);
67 
69  void SetElevationScale(double val);
70 
71 
82  template <class V>
83  void SetSurfaceRGBTable(const V & tab, int lutsize);
84 
90  void SetSurfaceRGBTable(RGBTable & tab, int lutsize);
91 
92  protected:
93  ScalarView();
94  ~ScalarView(){};
95 
96  private:
97 
98 
99  void RTBuildVTKPipeline() override final;
100 
101 
102  void ServerMPSend(vtkSmartPointer<internals::Communicator> communicator) override final;
103  void ClientMPReceive(vtkSmartPointer<internals::Communicator> communicator) override final;
104 
105 
106  template <class GRIDFUNC, class FILTER>
107  void RTBuildVTKPipeline2D();
108 
109  template <class GRIDFUNC, class FILTER>
110  void RTBuildVTKPipeline3D();
111 
112  };
113 
114 
116 
117  template <class V>
118  inline
119  void ScalarView::SetSurfaceRGBTable(const V & tab, int lutsize)
120  {
121  RGBTable rgbtab;
122  rgbtab.resize(tab.size()/4);
123  for (int i=0,j=0; i<tab.size(); i+=4,j++)
124  {
125  rgbtab[j].x=tab[i+0];
126  rgbtab[j].r=tab[i+1];
127  rgbtab[j].g=tab[i+2];
128  rgbtab[j].b=tab[i+3];
129  }
130  SetSurfaceRGBTable(rgbtab, lutsize);
131  }
132 
133 
134 
135 
136 }
137 
138 
139 
140 
141 #endif
vtkfig::ScalarView::ShowElevation
void ShowElevation(bool b)
Toggle elevation view (yet to be implemented)
Definition: vtkfigScalarView.h:57
vtkfig::ScalarView
Surface and contour plot of 2/3D scalar data.
Definition: vtkfigScalarView.h:28
vtkfig::ScalarView::ShowSurfaceColorbar
void ShowSurfaceColorbar(bool b)
Toggle colorbar visualization.
Definition: vtkfigScalarView.h:48
vtkfig::Figure::state
struct vtkfig::Figure::@0 state
figure state
vtkfig::ScalarView::SubClassName
virtual std::string SubClassName() override final
Get subclass name (for s-c communication, should be replaced by tag.
Definition: vtkfigScalarView.h:36
vtkfig::ScalarView::SetSurfaceRGBTable
void SetSurfaceRGBTable(const V &tab, int lutsize)
Set Surface RGB table from vector.
Definition: vtkfigScalarView.h:119
vtkfigFigure.h
vtkfig::ScalarView::SetElevationZShift
void SetElevationZShift(double val)
Change zshift for elevation plot.
vtkfig::ScalarView::SetSurfaceColorbarNumberOfLabels
void SetSurfaceColorbarNumberOfLabels(int n)
Set number of labels in colorbar.
Definition: vtkfigScalarView.h:54
vtkfig::Figure::isoline_filter
vtkSmartPointer< vtkContourFilter > isoline_filter
Isoline plot filter.
Definition: vtkfigFigure.h:356
vtkfig::ScalarView::SetIsolineWidth
void SetIsolineWidth(double w)
Set width of isolines.
Definition: vtkfigScalarView.h:63
vtkfig::ScalarView::New
static std::shared_ptr< ScalarView > New()
Create smart pointer to ScalarView instance.
vtkfig::ScalarView::ShowSurface
void ShowSurface(bool b)
Toggle surface plot on plane.
Definition: vtkfigScalarView.h:39
vtkfig::ScalarView::SetNumberOfIsocontours
void SetNumberOfIsocontours(int n)
Set number of isocontours to show.
Definition: vtkfigScalarView.h:60
vtkfig::ScalarView::SetSurfaceColorbarLabelFormat
void SetSurfaceColorbarLabelFormat(std::string fmt)
Set label format for colorbar.
Definition: vtkfigScalarView.h:51
vtkfig::Figure
Base class for all figures.
Definition: vtkfigFigure.h:61
vtkfig::RGBTable
std::vector< RGBPoint > RGBTable
Color table.
Definition: vtkfigTools.h:43
vtkfigTools.h
vtkfigDataSet.h
vtkfig::ScalarView::ShowIsolines
void ShowIsolines(bool b)
Toggle isoline rendering.
Definition: vtkfigScalarView.h:42
vtkfig::ScalarView::ShowIsosurfaces
void ShowIsosurfaces(bool b)
Toggle isosurface rendering.
Definition: vtkfigScalarView.h:45
vtkfig::ScalarView::SetElevationScale
void SetElevationScale(double val)
Change scale for elevation plot.