VTKFIG  0.20.20181114
Easy VTK based in situ visualization
vtkSmartPointer< vtkScalarBarActor > vtkfig::BuildColorBar ( vtkSmartPointer< vtkPolyDataMapper >  mapper,
int  irank = 0 
)
Examples:
examples/example-custom.cxx, and examples/example-custom1.cxx.

Definition at line 88 of file vtkfigTools.cxx.

89  {
90 
91 // http://public.kitware.com/pipermail/vtkusers/2016-March/094540.html :
92 // vtkTextProperty::SetFontSize
93 // vtkScalarBarActor::GetTitleTextProperty
94 // vtkScalarBarActor::GetLabelTextProperty
95 // vtkScalarBarActor::GetAnnotationTextProperty
96 // vtkScalarBarActor::SetUnconstrainedFontSize
97 
98 
99  vtkSmartPointer<vtkScalarBarActor> colorbar = vtkSmartPointer<vtkScalarBarActor>::New();
100 
101  //colorbar->UnconstrainedFontSizeOn();
102  //colorbar->AnnotationTextScalingOff();
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);
112  if (irank>0)
113  colorbar->SetPosition(0.9, 0.1);
114 
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);
121 
122 // colorbar->GetAnnotationTextProperty()->SetFontSize(80);
123 
124  colorbar->GetTitleTextProperty()->SetColor(0,0,0);
125  colorbar->GetTitleTextProperty()->SetFontFamilyToCourier();
126  colorbar->GetLabelTextProperty()->SetColor(0,0,0);
127  colorbar->GetLabelTextProperty()->SetFontFamilyToCourier();
128 // colorbar->GetAnnotationTextProperty()->SetColor(1,0,0);
129 
130  return colorbar;
131  }