[vtkusers] Drawing a simple line graph (CONTINUES...)
Isidro Moreno
morenoisidro at yahoo.com.ar
Mon Jul 23 08:44:22 EDT 2007
Hi! I think this method definitely doesn'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. If the commented lines below are enabled, the behaviour it's the same*/
#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/20070723/d2d3f977/attachment.htm>
More information about the vtkusers
mailing list