[vtkusers] MODIFICATIONS to be ADDED to VTK 3.1

Hugues Wisniewski h_wski at yahoo.com
Thu Jun 15 14:29:47 EDT 2000


vtkScalarBarActor doesn't display well multiple line titles. That meens titles made of '\n'
It can be seen very easily when the vtkScalarBarActor is vertical.
I added modifications to the source code of VTK 3.1 in C++.
I'm working with Visual C++ under NT and I hope you, guys from Kitware will add
these modifications to VTK in the next version.
If not, just tell me so that I'll maintain my own version of VTK.

In order to be able to display correctly a multiple line title in a vtkScalarBarActor
the following modifications have been added to VTK 3.1 :

- The protected method "int vtkTextMapper::GetNumberOfLines(char *input);" has been
moved to public

- vtkScalarBarActor::RenderOpaqueGeometry has been modified :

To compute the right font size for the title, replace the following line :

while (tempi[1] < target && fontSize < 100)

by :

while (tempi[1] < target*this->TitleMapper->GetNumberOfLines(this->TitleMapper->GetInput()) &&
fontSize < 100)

the following line :

while ((tempi[1] > target || tempi[0] > size[0])&& fontSize > 0)

by :

while ((tempi[1] > target*this->TitleMapper->GetNumberOfLines(this->TitleMapper->GetInput()) ||
tempi[0] > size[0])&& fontSize > 0)


In vertical position, we can see that text values are shifted downward the screen
of an offset equal to the height of the title, so we have to add the following modifications :
In the the loop that is positioning all the text values, we have to add a new data :
int sizeTextData[2];, like that :

    // Now position everything properly
    //
    if (this->Orientation == VTK_ORIENT_VERTICAL)
    {
    int sizeTextData[2];

and replace the following line :

this->TextActors[i]->SetPosition(barWidth+3,val - stringHeight/2);

by the two lines :

this->TextMappers[i]->GetSize(viewport,sizeTextData);
this->TextActors[i]->SetPosition(barWidth+3,val - sizeTextData[1]/2);


Just tell me if I didn't forget anything
Thank you
Hugues


__________________________________________________
Do You Yahoo!?
Yahoo! Photos -- now, 100 FREE prints!
http://photos.yahoo.com




More information about the vtkusers mailing list