[vtkusers] vtkActor2D problem

Isidro Moreno morenoisidro at yahoo.com.ar
Mon Jul 16 07:17:55 EDT 2007


Hi! I think this method don't work: vtkActor2D->GetPosition2Coordinate->SetValue(x,y,z).

This is my code (a simple straight line):

/*This should draw a diagonal in the left-bottom quarter of the window, but the diagonal crosses the whole screen.

#include "vtkActor2D.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkPolyDataMapper2D.h"
#include "vtkProperty2D.h"
#include "vtkPolyData.h"
#include "vtkPoints.h"
#include "vtkCellArray.h"
#include "vtkCamera.h"

int main(int argc, char *argv[]){

    vtkPolyData *linea=vtkPolyData::New();
    vtkPoints *puntos=vtkPoints::New();
    vtkCellArray *lineas=vtkCellArray::New();

    vtkPolyDataMapper2D *mapper=vtkPolyDataMapper2D::New();
    vtkActor2D *actor=vtkActor2D::New();
    vtkRenderer *render=vtkRenderer::New();
    vtkRenderWindow *ventana=vtkRenderWindow::New();
    vtkRenderWindowInteractor *interac=vtkRenderWindowInteractor::New();
    vtkCoordinate *coor=vtkCoordinate::New();

    lineas->InsertNextCell(2);
    lineas->InsertCellPoint(0);
    lineas->InsertCellPoint(1);

    puntos->InsertPoint(0,0.0,0.0,0.0);
    puntos->InsertPoint(1,1.0,1.0,0.0);

    linea->SetPoints(puntos);
    linea->SetLines(lineas);

    coor->SetCoordinateSystemToNormalizedViewport();

    mapper->SetInput(linea);
    mapper->SetTransformCoordinate(coor);

    actor->SetMapper(mapper);
    actor->GetProperty()->SetColor(1.0,0.0,0.0);
    actor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
    actor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
    //actor->GetPosition2Coordinate()->SetReferenceCoordinate(NULL);
    
    actor->GetPositionCoordinate()->SetValue(0.0,0.0,0.0);
    actor->GetPosition2Coordinate()->SetValue(0.5,0.5,0.0); // ¡¡¡Here!!!

 render->AddActor2D(actor);
    render->SetBackground(0.1,0.2,0.4);
//    render->ResetCamera();
//    render->ResetCameraClippingRange();

    ventana->AddRenderer(render);

    interac->SetRenderWindow(ventana);

    ventana->Render();
    interac->Start();

    linea->Delete();
    puntos->Delete();
    lineas->Delete();

    mapper->Delete();
    actor->Delete();
    render->Delete();
    ventana->Delete();
    interac->Delete();
    coor->Delete();

    return 0;}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070716/510eb6b7/attachment.htm>


More information about the vtkusers mailing list