[vtkusers] Re: Re: Drawing a simple line graph (CONTINUES...)

Amy Squillacote amy.squillacote at kitware.com
Wed Jul 25 08:38:22 EDT 2007


Yes, I meant 1.0, 1.0, 0.0. Sorry for the typo.

Isidro Moreno wrote:
> You may mean ".... instead of  1.0 1.0 0.0", do you? If yes, I answer: 
> yes,
> i've tried and work OK, but I'm altering the cell's geometry. I'm using a
> similar code to draw a curve line, and that was the solution I've 
> found at
> the moment: filtering the geometry data to normalized viewport values. 
> But
> it would be easier if GetPosition2Coordinate worked! In fact, it works OK
> with vtkActor2D classes that are below it in the hierarchical tree. 
> There's
> could be a bug...
>
>
> > Hi Isidro,
> >
> > Have you tried setting your second point to 0.5, 0.5, 0 instead of 1.0,
> > 1.0, 1.0?
> >
> > - Amy
> >
> > Isidro Moreno wrote:
> >>  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;}
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>   

-- 
Amy Squillacote
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
Phone: (518) 371-3971 x106




More information about the vtkusers mailing list