<div dir="ltr">Instead of adding actor like <font color="#000080" face="Verdana" size="2"><div>vtkRenderer ren = image_viewer2.GetRenderer();</div>
<div>ren.AddActor(lineActor);</div></font><font><font color="#000080" face="Verdana" size="2"><br><br>Try </font></font><font><font color="#000080" face="Verdana" size="2">image_viewer2.GetRenderer()->AddActor(line).<br>
<br>Please, keep the messages on the list.<br><br>Jothy<br></font></font><br><div class="gmail_quote">On Thu, Oct 21, 2010 at 8:58 AM, myaqua1982 <span dir="ltr"><<a href="mailto:myaqua1982@163.com">myaqua1982@163.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="margin: 10px; font-family: verdana; font-size: 10pt;">
<div><font color="#000080" face="Verdana" size="2"><font color="#000080" face="Verdana" size="2">Hi,</font>
<div><font color="#000080"></font> </div>
<div><font color="#000080">When I click the button just only the first line can be
add to the viewer. I want to add more lines when I click the button follow by
the first two clicks. Here is the key code. Could you please check it for me to
see where the problem is? It is in the form of c# the same as c++. Thank
you !</font></div>
<div><font color="#000080"></font> </div>
<div><font color="#000080">//////////////////////////////////////////////////////////</font></div>
<div><font color="#000080">bool mouseDown = false;</font></div>
<div><font color="#000080">int pointNum = 0;</font></div>
<div><font color="#000080">double[] P0 = new double[3]; double [] P1 = new
double[3];</font></div>
<div><font color="#000080"></font> </div>
<div><font color="#000080">vtkPoints pts = new vtkPoint();</font></div>
<div><font color="#000080">vtkCellArray lineCell = new
vtkCellArray();</font></div>
<div><font color="#000080">vtkPolyData linesPolyData = new
vtkPolyData();</font></div>
<div><font color="#000080">vtkPolyDataMapper lineMapper = new
vtkPolyDataMapper();</font></div>
<div><font color="#000080">vtkActor lineActor = new vtkActor();</font></div>
<div><font color="#000080"></font> </div>
<div><font color="#000080">ArrayList iniPointList = new
ArrayList(); //to save the point of
the lines</font></div>
<div><font color="#000080"></font> </div>
<div>
<div>
<div> public void
RenderLine(double[] p0, double[] p1, int pN) //render the line with two
points p0 and p1, pN is pointNum</div>
<div>
{ </div>
<div> if ((pN
- 1) > 0)</div>
<div> {</div>
<div></div>
<div>
pts.InsertNextPoint(p0);</div>
<div>
pts.InsertNextPoint(p1);</div>
<div></div>
<div>
vtkLine line = new vtkLine();</div>
<div>
line.GetPointIds().SetId(0, pN - 2);</div>
<div>
line.GetPointIds().SetId(1, pN - 1);</div>
<div></div>
<div>
lineCell.InsertNextCell(line);</div>
<div></div>
<div>
linesPolyData.SetPoints(pts);</div>
<div>
linesPolyData.SetLines(lineCell);</div>
<div></div>
<div>
lineMapper.SetInput(linesPolyData);</div>
<div></div>
<div>
lineActor.SetMapper(lineMapper);</div>
<div></div>
<div>
lineActor.GetProperty().SetColor(1.0, 0.0, 0.0);</div>
<div></div>
<div>
vtkRenderer ren = image_viewer2.GetRenderer();</div>
<div>
ren.AddActor(lineActor);</div>
<div>
ren.Render();</div>
<div>
} </div>
<div> }</div></div>
<div> </div>
<div style="text-indent: 2em;"> private void wnd1_MouseDown(object sender,
MouseEventArgs e) //left button
down </div>
<div style="text-indent: 2em;"> {</div>
<div> if
(mouseDown)</div>
<div> {</div>
<div>
int xp, yp;</div>
<div>
vtkPropPicker picker = new vtkPropPicker();</div>
<div>
vtkImageActor imageActor = image_viewer2.GetImageActor();</div>
<div>
vtkImageData imageData = image_viewer2.GetInput();</div>
<div>
vtkRenderer ren = image_viewer2.GetRenderer();</div>
<div>
int[] pos = iren.GetEventPosition();</div>
<div>
xp = pos[0]; yp = pos[1];</div>
<div>
picker.Pick(xp, yp, 0.0, ren);</div>
<div>
pickPos1 = picker.GetPickPosition();</div>
<div> </div>
<div></div>
<div>
double[] pickPos_new = new double[3] { pickPos1[0], pickPos1[1], <font color="#ff0000">1.0</font> }; //the Z coordinate I've
changed followed by your advice</div>
<div></div>
<div>
iniPointList.Add(pickPos_new); </div>
<div>
pointNum = iniPointList.Count; //the num of the point in the list</div>
<div></div>
<div></div>
<div>
P1 = (double[])iniPointList[pointNum - 1]; //acquire the coordinate
of the point specified by the index</div>
<div> </div>
<div></div>
<div>
if (pointNum > 1)</div>
<div>
{</div>
<div>
P0 = (double[])iniPointList[pointNum - 2];</div>
<div>
}</div>
<div> }</div>
<div> }</div>
<div> </div>
<div>
<div> private void wnd1_MouseUp(object
sender, MouseEventArgs e) //left button up</div>
<div> {</div>
<div> if
(mouseDown)</div>
<div> {</div>
<div>
RenderLine(P0, P1,
pointNum);
</div>
<div> }</div>
<div> }</div>
<div> </div></div></div>
<div><font color="#000080" face="Verdana" size="2">//////////////////////////////////////////////////////////</font></div></font></div>
<div><font color="#000080" face="Verdana" size="2"></font> </div>
<div><font color="#000080" face="Verdana" size="2"></font> </div>
<div><font color="#c0c0c0" face="Verdana" size="2">2010-10-21 </font></div><div class="im"><font color="#000080" face="Verdana" size="2">
<hr style="width: 100px;" align="left" color="#b5c4df" size="1">
</font>
<div><font color="#c0c0c0" face="Verdana" size="2"><span>myaqua1982</span>
</font></div>
<hr color="#b5c4df" size="1">
<div><font face="Verdana" size="2"><b>发件人:</b> Jothy </font></div>
<div><font face="Verdana" size="2"><b>发送时间:</b> 2010-10-20 17:09:44
</font></div>
<div><font face="Verdana" size="2"><b>收件人:</b> myaqua1982 </font></div>
<div><font face="Verdana" size="2"><b>抄送:</b> vtkusers </font></div>
<div><font face="Verdana" size="2"><b>主题:</b> Re: [vtkusers] problem in
add line in vtkImageViewer2 </font></div>
<div><font face="Verdana" size="2"></font> </div>
</div><div><div></div><div class="h5"><div><font face="Verdana" size="2">
<div dir="ltr">Try p0 = {0.0, 0.0, <span style="color: rgb(255, 0, 0);">100.0</span>},p1 = {0.0, 100.0, <span style="color: rgb(255, 0, 0);">100.0</span>} or -100 make sure your z corodinate of
the line is always greater such that the line is always above the image
actor.<br><br><br>Jothy<br><br>
<div class="gmail_quote">2010/10/20 myaqua1982 <span dir="ltr"><<a href="mailto:myaqua1982@163.com" target="_blank">myaqua1982@163.com</a>></span><br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<div style="margin: 10px; font-family: verdana; font-size: 10pt;">
<div><font face="Verdana" size="2">Hi, </font></div>
<div> </div>
<div>I have shown Dicom images in vtkImageViewer2. And now I want to add lines
in the viewer . Such as , I click left button to select two point ,and then
show the line defined by these two points. The problem is that the line can
not show above the image. When I set p0 = {0.0, 0.0, 0.0},p1 = {0.0, 100.0,
0.0},the line can be shown in the leftmost of the image (it looks like Y
axes). But when I change p1 = {20.0, 100.0, 0.0}, the line can not show. What
is the problem? Please give me some help. Thank you very much!</div>
<div><font face="Verdana" size="2"></font> </div>
<div align="left"><font color="#c0c0c0" face="Verdana" size="2">2010-10-20
</font></div><font face="Verdana" size="2">
<hr style="min-height: 2px; width: 122px;" align="left" size="2">
<div><font color="#c0c0c0" face="Verdana" size="2"><span>myaqua1982</span>
</font></div></font></div><br>_______________________________________________<br>Powered
by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br><br>Visit other Kitware open-source
projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br><br>Please
keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to
subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br><br></blockquote></div><br></div></font></div></div></div></div>
</blockquote></div><br></div>