<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16481" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi, I have been dealing with vtkActor2D problem for
the last 3 week and got no solutions. I found somebody in vtkusers archive who
had the same problem. For those who don know excactly what I'm talking about,
please visit:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><A
href="http://public.kitware.com/pipermail/vtkusers/2006-November/088196.html">http://public.kitware.com/pipermail/vtkusers/2006-November/088196.html</A></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>It's unbelievable that a simple line or polygon
can't be drawn in the plane properly. I think somebody must have the answer to
my question. Now, supposing you must have seen Beth's code while following
the subject in the link above, I'll show you my own code (and the answers from
those who have tried give me some help):</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>vtkLineSource
*linea=vtkLineSource::New();<BR> vtkPolyDataMapper2D
*mapper=vtkPolyDataMapper2D::New();<BR> vtkActor2D
*actor=vtkActor2D::New();<BR> vtkRenderer
*render=vtkRenderer::New();<BR> vtkRenderWindow
*ventana=vtkRenderWindow::New();<BR> vtkRenderWindowInteractor
*interac=vtkRenderWindowInteractor::New();<BR> vtkCoordinate
*coor=vtkCoordinate::New();</FONT></DIV>
<DIV> </DIV><FONT face=Arial size=2>
<DIV><BR> int *dim_ven=new int [2];<BR>
dim_ven[0]=600;<BR> dim_ven[1]=400;</DIV>
<DIV> </DIV>
<DIV> int segmentos;<BR>
cout<<"Ingrese cantidad de segmentos: ";<BR>
cin>>segmentos;<BR>
cout<<endl;<BR>
linea->SetResolution(segmentos);<BR>
linea->Update();</DIV>
<DIV> </DIV>
<DIV> double PI=3.1416;</DIV>
<DIV> </DIV>
<DIV> double
delta=2*PI/(dim_ven[0]*1.0);<BR> double
resolucion=(dim_ven[0]*1.0)/(segmentos*1.0);</DIV>
<DIV> </DIV>
<DIV> for(int
i=0;i<linea->GetOutput()->GetPoints()->GetNumberOfPoints();i++){<BR>
linea-><BR>
GetOutput()-><BR>
GetPoints()-><BR>
SetPoint(i,<BR>
i*resolucion,<BR>
(dim_ven[1]/2)*sin(i*resolucion*delta)+(dim_ven[1]/2),<BR>
0.0);}</DIV>
<DIV> </DIV>
<DIV> mapper->SetInput(linea->GetOutput());</DIV>
<DIV> </DIV>
<DIV> actor->SetMapper(mapper);<BR>
actor->GetProperty()->SetColor(1.0,0.0,0.0);</DIV>
<DIV> </DIV>
<DIV> render->AddActor2D(actor);<BR>
render->SetBackground(0.1,0.2,0.4);</DIV>
<DIV> </DIV>
<DIV> ventana->AddRenderer(render);</DIV>
<DIV> </DIV>
<DIV>
interac->SetRenderWindow(ventana);<BR>
<BR> ventana->Render();<BR>
interac->Start();</DIV>
<DIV> </DIV>
<DIV> linea->Delete();<BR>
mapper->Delete();<BR>
actor->Delete();<BR>
render->Delete();<BR>
ventana->Delete();<BR>
interac->Delete();<BR>
coor->Delete();<BR> delete [] dim_ven;</DIV>
<DIV> </DIV>
<DIV>Thanks for your time/help!!</DIV>
<DIV> </DIV>
<DIV><U>These are the responses ordered from the newest to the
oldest:</U></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>> OK, let's see; as you must have seen the code below, it consist of
drawing <BR>> a diagonal line. Width a Height are the dimensions the
rectangle in which <BR>> this line is defined in. Using these two methods is
the same as doing <BR>>
vtkActor2D->GetPosition2Coordinate->SetValue(x,y) (where x=width &
<BR>> y=height - see HTML help of vtkActor2D) as I've explained below. The
<BR>> pourpose of all these is to autoscale any figure in the plane when the
<BR>> window's size changes (not just a line but also a polygon, rectangle,
<BR>> etc). In fact, I've used this code to draw a period of the sinus
function <BR>> and it was fine! But I can't make it fit my window. It put a
simple line <BR>> in the code below to make the things easier to understand,
but you're the <BR>> second who asks me the same question. Should I be more
clear and put the <BR>> actual code? Sorry for my english, I'm spanish
speaker.<BR>> I know I can do this with actor 3D, but I
think It's not good using it <BR>> in terms of design since I'm working in
the plane and many unused memory <BR>> would be kept in if I use
actor3D.<BR>><BR>><BR>>> Isidro,<BR>>><BR>>> Could you
be a bit more clear about what you want to do exactly?<BR>>> Does not a
line have zero 'width' and 'height' by definition?<BR>>> If you want to
change the size of your line, perhaps you could change <BR>>>
Point1<BR>>> and Point2 on your line when you needed. Otherwise you
could also <BR>>> position<BR>>> your line in 3D instead of using an
Actor2D, this would give you some <BR>>> more<BR>>>
flexibility.<BR>>><BR>>> -SN<BR>>><BR>>> -----Original
Message-----<BR>>><BR>>> I've been trying so hard, and It seems
vtkActor2D ignores SetPositon2()<BR>>> method (or
vtkActor2D->GetPosition2Coordinate->SetValue(x,y) method - see<BR>>>
HTML vtkActor2D help). Could somebody help me if this is what's
actually<BR>>> happening?<BR>>><BR>>><BR>>>>> On
6/26/07, Isidro Moreno <<A
href="mailto:morenoisidro@yahoo.com.ar">morenoisidro@yahoo.com.ar</A>>
wrote:<BR>>>>>>
Mark,<BR>>>>>><BR>>>>>>
SetWidth() and SetHeight() methods (vtkProp's methods),define
the<BR>>>>>> dimensions of the rectangle in which the line is
drawn (it could be <BR>>>>>> not<BR>>>>>>
a<BR>>>>>> line, but also a circle, a polygon, etc.). In fact,
that rectangle is<BR>>>>>> which<BR>>>>>> I want
to autoscale when window's size changes. As a result, the
line<BR>>>>>> would<BR>>>>>> fit to it. That's
what I've understood till now. But I could be <BR>>>>>>
wrong...<BR>>>>>><BR>>>>>>
Isidro<BR>>>>>><BR>>>>>><BR>>>>>>
><BR>>>>>> > On 6/26/07, Isidro Moreno <<A
href="mailto:morenoisidro@yahoo.com.ar">morenoisidro@yahoo.com.ar</A>>
wrote:<BR>>>>>> >><BR>>>>>>
>><BR>>>>>> >> Hello! I've made a simple VTK/C++ test
program. It's just a 2D <BR>>>>>> >>
line.<BR>>>>>> >> Now,<BR>>>>>> >>
I<BR>>>>>> >> don't know how to make the line size change.
I've tried many <BR>>>>>> >>
methods;<BR>>>>>> >> and<BR>>>>>> >>
changing vtkActor's coordinate system (vtkActor2D's), but no
<BR>>>>>> >> results.<BR>>>>>> >>
I<BR>>>>>> >> even<BR>>>>>> >> wonder
what coordinate system is vtkLineSource defined in (see
code<BR>>>>>> >> below).<BR>>>>>>
>><BR>>>>>> >> Here's my
code:<BR>>>>>> >><BR>>>>>> >>
vtkLineSource *line=vtkLineSource::New();<BR>>>>>>
>>
line->SetPoint1(20.0,20.0,0.0); // what Coordinate
System??<BR>>>>>> >>
line->SetPoint2(80.0,150.0,0.0); // what Coordinate
System??<BR>>>>>> >><BR>>>>>> >>
vtkPolyDataMapper2D *mapper=vtkPolyDataMapper2D::New();<BR>>>>>>
>>
mapper->SetInput(line->GetOutput());<BR>>>>>>
>><BR>>>>>> >> vtkActor2D
*actor=vtkActor2D::New();<BR>>>>>>
>>
actor->SetMapper(mapper);<BR>>>>>>
>>
actor->GetProperty()->SetColor(1.0,0.0,0.0);<BR>>>>>>
>> actor->SetWidth(0.5); //
Doesn't work!! - The same happens<BR>>>>>> >> with
vtkActor2D->GetPosition2Coordinate->SetValue(double width
,<BR>>>>>> >> double height)<BR>>>>>>
>> actor->SetHeight(0.5); //
Doesn't work!! - The same happens<BR>>>>>> >> with
vtkActor2D->GetPosition2Coordinate->SetValue(double width
,<BR>>>>>> >> double height)<BR>>>>>>
>><BR>>>>>> >> vtkRenderer
*render=vtkRenderer::New();<BR>>>>>> >> vtkRenderWindow
*win=vtkRenderWindow::New();<BR>>>>>>
>>
win->AddRenderer(render);<BR>>>>>>
>><BR>>>>>> >>
vtkRenderWindowInteractor<BR>>>>>> >>
*interac=vtkRenderWindowInteractor::New();<BR>>>>>>
>>
interac->SetRenderWindow(win);<BR>>>>>>
>><BR>>>>>> >>
render->AddActor2D(actor);<BR>>>>>>
>>
render->SetBackground(0.1,0.2,0.4);<BR>>>>>>
>><BR>>>>>> >>
win->Render();<BR>>>>>> >><BR>>>>>>
>>
interac->Initialize();<BR>>>>>>
>> interac->Start();<BR>>>>>>
>><BR>>>>>> >>
line->Delete();<BR>>>>>> >>
mapper->Delete();<BR>>>>>> >>
actor->Delete();<BR>>>>>> >>
render->Delete();<BR>>>>>> >>
win->Delete();<BR>>>>>> >>
interac->Delete();<BR>>>>>> >><BR>>>>>>
>> I want to make the line resize when changing windows size. I'd
be<BR>>>>>> >> very<BR>>>>>> >>
grateful if somebody could help me with this.
Thanks!!!<BR>>><BR></DIV></BODY></HTML>