[vtkusers] vtkBorderWidget position & size

Leonardo M. Ramé l.rame at griensu.com
Mon Oct 25 15:30:09 EDT 2010


I'm trying to create a vtkBorderWidget with the dimension data obtained
from a vtkInteractorStyleRubberBand2D.

To get the bounds of vtkInteractorStyleRubberBand2D I use this subclass:

class MyRubberBand : public vtkInteractorStyleRubberBand2D
{
  public:
    static MyRubberBand* New();
    vtkTypeRevisionMacro(MyRubberBand, vtkInteractorStyleRubberBand2D);

    void GetPosition(int &x0, int &y0, int &x1, int &y1)
    {
        x0 = this->StartPosition[0];
        y0 = this->StartPosition[1];
        x1 = this->EndPosition[0];
        y1 = this->EndPosition[1];
    };
};


Aparently, SetPosition and SetPosition2 methods of
vtkBorderRepresentation allows to define the position and bounds of the
vtkBorderWidget, but, instead of that, I can't see the widget:

This is my code:

int x0;
int y0;
int x1;
int y1;

MyRubberBand::SafeDownCast(m_rubberBand)->GetPosition(x0, y0,x1, y1);
m_rubberBand->Delete();
m_rubberBand = NULL;

m_border = vtkBorderWidget::New();
m_border->SetInteractor(this->GetInteractor());
m_border->CreateDefaultRepresentation();
vtkBorderRepresentation::SafeDownCast(m_border->GetRepresentation())->SetPosition(x0, y0);
vtkBorderRepresentation::SafeDownCast(m_border->GetRepresentation())->SetPosition2(x1, y1);
m_border->On();

Are the positions obtanied from the vtkInteractorStyleRubberBand2D
Screen positions instead of world positions? Should I translate them?
how?

Thanks in advance,
-- 
Leonardo M. Ramé
http://leonardorame.blogspot.com



More information about the vtkusers mailing list