2 #include <vtkColorTransferFunction.h> 3 #include <vtkTextProperty.h> 15 char *spinstr=getenv(
"VTKFIG_NSPIN");
17 return std::numeric_limits<size_t>::max();
29 void PrintArray(vtkSmartPointer<vtkDataArray> data, std::ostream & os)
31 auto nt=data->GetNumberOfTuples();
32 auto nc=data->GetNumberOfComponents();
34 for (
int it=0;it<nt;it++)
37 data->GetTuple(it,tuple);
38 for (
int ic=0;ic<nc ; ic++)
40 cout << tuple[ic] <<
" ";
48 void PrintPoints(vtkSmartPointer<vtkPoints> pts, std::ostream & os)
56 vtkSmartPointer<vtkLookupTable>
BuildLookupTable(std::vector<RGBPoint> & xrgb,
size_t size)
58 vtkSmartPointer<vtkColorTransferFunction> ctf = vtkSmartPointer<vtkColorTransferFunction>::New();
59 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
61 for (
size_t i=0;i<xrgb.size(); i++)
63 if (xrgb[i].x<-1.0e-10)
65 lut->SetBelowRangeColor(xrgb[i].r,xrgb[i].g, xrgb[i].b,1);
66 lut->UseBelowRangeColorOn();
68 else if (xrgb[i].x>1.0+1.0e-10)
70 lut->SetAboveRangeColor(xrgb[i].r,xrgb[i].g, xrgb[i].b,1);
71 lut->UseAboveRangeColorOn();
74 ctf->AddRGBPoint(xrgb[i].x,xrgb[i].r,xrgb[i].g, xrgb[i].b);
77 lut->SetNumberOfTableValues(size);
79 for(
size_t i = 0; i < size; ++i)
82 ctf->GetColor(static_cast<double>(i)/(
double)size,rgb);
83 lut->SetTableValue(i,rgb[0],rgb[1],rgb[2]);
88 vtkSmartPointer<vtkScalarBarActor>
BuildColorBar(vtkSmartPointer<vtkPolyDataMapper> mapper,
int irank)
99 vtkSmartPointer<vtkScalarBarActor> colorbar = vtkSmartPointer<vtkScalarBarActor>::New();
103 colorbar->SetLookupTable(mapper->GetLookupTable());
104 colorbar->SetWidth(0.175);
105 colorbar->SetHeight(0.8);
106 colorbar->SetLabelFormat(
" %+9.2e");
107 colorbar->SetMaximumWidthInPixels(150);
108 colorbar->SetBarRatio(0.1);
109 colorbar->SetVerticalTitleSeparation(0);
110 colorbar->SetNumberOfLabels(11);
111 colorbar->SetPosition(0.8, 0.1);
113 colorbar->SetPosition(0.9, 0.1);
115 colorbar->GetTitleTextProperty()->ItalicOff();
116 colorbar->GetLabelTextProperty()->ItalicOff();
117 colorbar->GetTitleTextProperty()->BoldOn();
118 colorbar->GetLabelTextProperty()->BoldOn();
119 colorbar->GetTitleTextProperty()->SetFontSize(10);
120 colorbar->GetLabelTextProperty()->SetFontSize(80);
124 colorbar->GetTitleTextProperty()->SetColor(0,0,0);
125 colorbar->GetTitleTextProperty()->SetFontFamilyToCourier();
126 colorbar->GetLabelTextProperty()->SetColor(0,0,0);
127 colorbar->GetLabelTextProperty()->SetFontFamilyToCourier();
void PrintArray(vtkSmartPointer< vtkDataArray > data, std::ostream &os)
void PrintPoints(vtkSmartPointer< vtkPoints > pts, std::ostream &os)
vtkSmartPointer< vtkLookupTable > BuildLookupTable(RGBTable &xrgb, size_t size)
vtkSmartPointer< vtkScalarBarActor > BuildColorBar(vtkSmartPointer< vtkPolyDataMapper > mapper, int irank=0)