Bub Espinja
Bub Espinja

Reputation: 4571

Setting the position of a vtkLegendScaleActor object

I've defined my vtkLegendScaleActor like this:

    vtkSmartPointer<vtkLegendScaleActor> legendScaleActor = vtkSmartPointer<vtkLegendScaleActor>::New();
    legendScaleActor->GetLegendLabelProperty()->SetColor(0,0,0);
    legendScaleActor->GetLegendTitleProperty()->SetColor(0,0,0);
    legendScaleActor->SetBottomAxisVisibility(0);
    legendScaleActor->SetTopAxisVisibility(0);
    legendScaleActor->SetRightAxisVisibility(0);
    legendScaleActor->SetLeftAxisVisibility(0);
    legendScaleActor->GetLegendLabelProperty()->SetFontSize(legendScaleActor->GetLegendLabelProperty()->GetFontSize() * 2);
    legendScaleActor->GetLegendTitleProperty()->SetFontSize(legendScaleActor->GetLegendTitleProperty()->GetFontSize() * 2);

I wanted to increase the font size in both label and title, and hide all the axis.

The result is: enter image description here

Where I can see the geometry with the scale rule, but it is cropped by the limits of the window.

I would like to move up the legend, but I could find the right attribute of the given class. Any idea about how to do it?

EDIT

I've continued working on this issue and what I've done is to add a negative offset to the label and the title of the vtkLegendScaleActor object, with:

    legendScaleActor->GetLegendTitleProperty()->SetLineOffset(-25);
    legendScaleActor->GetLegendLabelProperty()->SetLineOffset(-25);

Having as a result: enter image description here

Nevertheless, I cannot move the ruler, neither the whole set together... that's why I imagine that there should be a better solution.

Upvotes: 1

Views: 254

Answers (1)

Taron
Taron

Reputation: 1235

Subclass the vtkLegendScaleActor. Then reimplement the BuildRepresentation method and modify the Coordinates of the LabelActors. With this you have full control of the representation, since all Actors and Mappers are protected and therefore modifieable.

Upvotes: 2

Related Questions