[vtk-developers] Taming contrained font size in vtkTextMapper

John Platt jcplatt at lineone.net
Thu Jul 7 17:11:49 EDT 2005


Hi all,

 

The font size used in scalar bar and XY plots titles often becomes
excessive when only a small number of characters are involved. A simple
way to mitigate this is to set a font size ceiling on the vtkTextMapper
constrained font size methods.

 

Typical use for vtkXYPlotActor, for example, would be

 

myXYPlotActor->GetXAxisActor2D()->GetTitleMapper()->SetFontSizeCeiling(1
2);

 

The required changes are

 

vtkTextMapper.h

 

  // Description:

  // Set a ceiling on the font size determined by the constrained font
size

  // methods. No ceiling is applied for a zero size (the default).

  vtkSetClampMacro(FontSizeCeiling, int, 0, 100);

  vtkGetMacro(FontSizeCeiling, int);

 

protected:

  int  FontSizeCeiling;

 

vtkTextMapper.cxx

 

vtkTextMapperEx::vtkTextMapperEx()

.

  // No ceiling on the font size is applied on construction.

  this->FontSizeCeiling = 0;

 

void vtkTextMapperEx::PrintSelf(ostream& os, vtkIndent indent)

.

  os << indent << "FontSizeCeiling: " << this->FontSizeCeiling << "\n";


 

int vtkTextMapperEx::SetConstrainedFontSize()

 

before return insert

 

  if ( this->FontSizeCeiling && fontSize > this->FontSizeCeiling 

  {

     fontSize = this->FontSizeCeiling;

     tprop->SetFontSize( this->FontSizeCeiling );

  }

 

Some further work will be required to expose more of the text actors but
this gets the ball rolling.

 

If there are no obvious problems, I would really appreciate it if this
enhancement could be made.

 

Many thanks

 

John.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20050707/57a59e93/attachment.html>


More information about the vtk-developers mailing list