<style> p {margin-top:0px;margin-bottom:0px;} </style> <table border=0 width=100%% cellpadding=0 cellspacing=0 align=center> <tr> <td valign=top style='padding:8pt;'><font size=2><P><BR>
Use vtkXYPlotActor. It will solve your problems.<BR>
<BR>
<BR>
<BR>
<BLOCKQUOTE style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<P></P>
<P></P>
<P>---------[ Received Mail Content ]----------<BR>
</P>
<P></P>
<P><B>Subject : </B>RE: [vtkusers] Drawing a simple line graph<BR>
</P>
<P></P>
<P><B>Date : </B>Fri, 17 Nov 2006 13:32:34 +0000<BR>
</P>
<P></P>
<P><B>From : </B>beth@portugalmail.pt<BR>
</P>
<P></P>
<P><B>To : </B>John Platt <jcplatt@dsl.pipex.com><BR>
</P>
<P></P>
<P><B>Cc : </B>vtkusers@vtk.org<BR>
</P>
<P></P>
<P><BR>
</P>
<P></P>
<P>Hi,</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Yes, I know that Position2 is relative to Position. But evend adjusting other </P>
<P></P>
<P><BR>
values, it does not work.</P>
<P></P>
<P><BR>
No, I can try to use vtkXYPlotActor, however I do want also to create an area </P>
<P></P>
<P><BR>
graph (using a polygon instead a polyline), and for that, I'll have to know </P>
<P></P>
<P><BR>
how to work properly with this situation...</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Any other tip?</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Thanks and best regards,</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Elizabeth</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Citando John Platt <JCPLATT@DSL.PIPEX.COM>:</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Hi,</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
I seem to recall that the Position2 coordinate is relative to Position.</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Is there any reason you cannot use vtkXYPlotActor?</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
John.</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
-----Original Message-----</P>
<P></P>
<P><BR>
From: vtkusers-bounces+jcplatt=dsl.pipex.com@vtk.org</P>
<P></P>
<P><BR>
[mailto:vtkusers-bounces+jcplatt=dsl.pipex.com@vtk.org] On Behalf Of</P>
<P></P>
<P><BR>
beth@portugalmail.pt</P>
<P></P>
<P><BR>
Sent: 16 November 2006 20:53</P>
<P></P>
<P><BR>
To: vtkusers@vtk.org</P>
<P></P>
<P><BR>
Subject: [vtkusers] Drawing a simple line graph </P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Hi,</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
I'm trying to create a simple line graph. For that, I created a polyline</P>
<P></P>
<P><BR>
and 2 </P>
<P></P>
<P><BR>
axis.My piece of code looks like this:</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
// Create a polyline</P>
<P></P>
<P><BR>
vtkPolyData* polydata = vtkPolyData::New();</P>
<P></P>
<P><BR>
polydata->SetPoints(polyLinePoints);</P>
<P></P>
<P><BR>
polydata->SetLines(line);</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
// Maps it to 2D</P>
<P></P>
<P><BR>
vtkPolyDataMapper2D *mapper = vtkPolyDataMapper2D::New();</P>
<P></P>
<P><BR>
mapper->SetInput(polydata);</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
// Creates an actor, defining its limits according the graph area</P>
<P></P>
<P><BR>
defined by </P>
<P></P>
<P><BR>
the axes below</P>
<P></P>
<P><BR>
vtkActor2D *actor = vtkActor2D::New();</P>
<P></P>
<P><BR>
actor->SetMapper(mapper);</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
actor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(</P>
<P></P>
<P><BR>
);</P>
<P></P>
<P><BR>
actor->GetPositionCoordinate()->SetValue(0.05, 0.2);</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
actor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport</P>
<P></P>
<P><BR>
(); // it's not working properly!!!</P>
<P></P>
<P><BR>
actor->GetPosition2Coordinate()->SetValue(0.90, 0.9); // it's not</P>
<P></P>
<P><BR>
working </P>
<P></P>
<P><BR>
properly!!!</P>
<P></P>
<P><BR>
actor->GetProperty()->SetColor(1, 0, 0);</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
// Define axes</P>
<P></P>
<P><BR>
vtkCoordinate *coords_x1 = vtkCoordinate::New();</P>
<P></P>
<P><BR>
coords_x1->SetValue(0.05, 0.2);</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
vtkCoordinate *coords_x2 = vtkCoordinate::New();</P>
<P></P>
<P><BR>
coords_x2->SetValue(0.95, 0.2);</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
vtkCoordinate *coords_y1 = vtkCoordinate::New();</P>
<P></P>
<P><BR>
coords_y1->SetValue(0.05, 0.2);</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
vtkCoordinate *coords_y2 = vtkCoordinate::New();</P>
<P></P>
<P><BR>
coords_y2->SetValue(0.05, 0.95);</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
vtkAxisActor2D *axesX = vtkAxisActor2D::New();</P>
<P></P>
<P><BR>
axesX->SetPoint1(coords_x1->GetValue());</P>
<P></P>
<P><BR>
axesX->SetPoint2(coords_x2->GetValue());</P>
<P></P>
<P><BR>
axesX->SetLabelFormat("%3.2f");</P>
<P></P>
<P><BR>
axesX->SetFontFactor(1.2);</P>
<P></P>
<P><BR>
axesX->SetRange(0, t); // t is the maximum x value in the polyline</P>
<P></P>
<P><BR>
points</P>
<P></P>
<P><BR>
axesX->SetTitle("Time (s)");</P>
<P></P>
<P><BR>
axesX->SetNumberOfLabels(10);</P>
<P></P>
<P><BR>
axesX->AdjustLabelsOn();</P>
<P></P>
<P><BR>
axesX->LabelVisibilityOn();</P>
<P></P>
<P><BR>
axesX->TickVisibilityOn();</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
vtkAxisActor2D *axesY = vtkAxisActor2D::New();</P>
<P></P>
<P><BR>
axesY->SetPoint1(coords_y1->GetValue());</P>
<P></P>
<P><BR>
axesY->SetPoint2(coords_y2->GetValue());</P>
<P></P>
<P><BR>
axesY->SetLabelFormat("%3.2f");</P>
<P></P>
<P><BR>
axesY->SetFontFactor(1);</P>
<P></P>
<P><BR>
axesY->SetRange(0, sCardMax); // Máximum y value in polyline points</P>
<P></P>
<P><BR>
axesY->AdjustLabelsOn();</P>
<P></P>
<P><BR>
axesY->LabelVisibilityOn();</P>
<P></P>
<P><BR>
axesY->TickVisibilityOn();</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
.....the usual stuff....creates the renderer...</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
rw->AddActor2D(actor);</P>
<P></P>
<P><BR>
rw->AddViewProp(axesX);</P>
<P></P>
<P><BR>
rw->AddViewProp(axesY);</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Well, the line graph is drawn, but the problem is that axes values and</P>
<P></P>
<P><BR>
line </P>
<P></P>
<P><BR>
values are not matching. </P>
<P></P>
<P><BR>
It seems that the GetPosition2Coordinate is not working at all, because</P>
<P></P>
<P><BR>
the </P>
<P></P>
<P><BR>
mapping of the line to the graph effective area (that is defined by the</P>
<P></P>
<P><BR>
limits </P>
<P></P>
<P><BR>
of the axes - xmin, ymin and xmax, ymax) is not being done. It just puts</P>
<P></P>
<P><BR>
the </P>
<P></P>
<P><BR>
polyline at the initial position defined by GetPositionCoordinate, and</P>
<P></P>
<P><BR>
draws </P>
<P></P>
<P><BR>
it as the output given by the vtkPolyDataMapper2D.</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
What should I do?</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Thanks for any help!</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Regards,</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
Elizabeth</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
__________________________________________________________</P>
<P></P>
<P><BR>
O email preferido dos portugueses agora com</P>
<P></P>
<P><BR>
2 000 MB de espaço e acesso gratuito à Internet</P>
<P></P>
<P><BR>
http://www.portugalmail.pt/2000mb</P>
<P></P>
<P><BR>
_______________________________________________</P>
<P></P>
<P><BR>
This is the private VTK discussion list. </P>
<P></P>
<P><BR>
Please keep messages on-topic. Check the FAQ at:</P>
<P></P>
<P><BR>
http://www.vtk.org/Wiki/VTK_FAQ</P>
<P></P>
<P><BR>
Follow this link to subscribe/unsubscribe:</P>
<P></P>
<P><BR>
http://www.vtk.org/mailman/listinfo/vtkusers</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
__________________________________________________________</P>
<P></P>
<P><BR>
O email preferido dos portugueses agora com</P>
<P></P>
<P><BR>
2 000 MB de espaço e acesso gratuito à Internet</P>
<P></P>
<P><BR>
http://www.portugalmail.pt/2000mb</P>
<P></P>
<P><BR>
_______________________________________________</P>
<P></P>
<P><BR>
This is the private VTK discussion list. </P>
<P></P>
<P><BR>
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ</P>
<P></P>
<P><BR>
Follow this link to subscribe/unsubscribe:</P>
<P></P>
<P><BR>
http://www.vtk.org/mailman/listinfo/vtkusers</P>
<P></P>
<P><BR>
</P>
<P></P>
<P><BR>
</P></BLOCKQUOTE>
<P></P></font></td></tr>
</table>
<br/>
<div>
<hr style="width:85%;margin-left:0px;text-align:left"/><br/>
Lycos Cinema : Catch up with your friends and see free movies online - watch, chat & connect now >>
<a href="http://cinema.lycos.com/?if_Event=mail" target="_blank"><u>http://cinema.lycos.com</u></a>
</div>