<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hey Weimin,<div><br></div><div>(I'm doing this with VTK 5.10, so hopefully it's similar enough to the current dev…)</div><div><br></div><div>First, selections in VTK take a bit of getting used to. Here's an explanation of some of it that Jeff Baumes wrote a while back:</div><div><br></div><div><a href="http://www.kitware.com/media/html/SelectionsInVTK.html">http://www.kitware.com/media/html/SelectionsInVTK.html</a></div><div><br></div><div>Then there is also the vtkAnnotationLink, which contains a selection, and is used to pass selections between (originally InfoVis) views. You can look at some of the examples and tests linked off of the doc page:</div><div><br></div><div><a href="http://www.vtk.org/doc/nightly/html/classvtkAnnotationLink.html">http://www.vtk.org/doc/nightly/html/classvtkAnnotationLink.html</a></div><div><br></div><div>You can make selections in a parallel coordinates (PC) chart by creating an index selection and putting it in the chart's annotation link. The PC chart only seems to be set up to do selections by Index, so if your ID array (table column) is always going to match up with the row index, then life can be simpler for you. You can just set up an annotation link into your PC chart and then create a vtkIdTypeArray containing the ID you want to select, and put that in </div><div><br></div><div>annotationLink->GetCurrentSelection()->GetNode(0)->SetSelectionList(idArray);</div><div><br></div><div>If your IDs are not always going to match up with the row indices, then the only way I can figure out how to make the correct selection is to create a vtkSelection and vtkSelectionNode which will select by PedigreeIds (or GlobalIds), and then when you put the ID you want in the SelectionList for that selection node, then use vtkConvertSelection, passing this pedigree id selection along with your table (where you've set the ID array as the pedigree ids) and convert the selection to an Index selection. You can then pass this "converted to index" selection into your PC chart annotation link and it will select the proper line in your plot.</div><div><br></div><div>I know that's confusing. Maybe someone else can pipe in with a simpler way or a more clear explanation. I'm attaching a Python example that shows the method. Notice that the ID array in my table contains non-sequential IDs that don't start at 0 like the Index does. But, when I choose pedigree id 4020, the proper line is selected (and highlighted) in the chart, even though there is no line or table row with index 4020, but there is a matching pedigree ID.</div><div><br></div><div>(Sorry if Python isn't best for you – I already has an example that was close, and it's easier for me to play there.)</div><div><br></div><div>Good luck,</div><div>-Eric</div><div><br></div><div><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·</div><div>Eric E Monson</div><div>Duke Visualization Technology Group</div><div><br class="webkit-block-placeholder"></div><div><img id="78392703-b06e-4c3a-955c-cc38a79148d8" height="295" width="483" apple-width="yes" apple-height="yes" src="cid:4B88E5C7-C801-4513-92F9-4134DD2F602E@trinity.duke.edu"></div><div><br></div></div></span>=================================================</span></div><div><br></div><div><span class="Apple-style-span" style="orphans: 2; text-indent: 0px; widows: 2; -webkit-text-decorations-in-effect: none; "><div># Translated to Python from [VTK]/Charts/Testing/Cxx/TestPCPlot.cxx</div><div><br></div><div>import vtk</div><div>import math</div><div>import vtk.util.numpy_support as VN</div><div><br></div><div># Set up a 2D scene, add an XY chart to it</div><div>view = vtk.vtkContextView()</div><div>view.GetRenderer().SetBackground(1.0, 1.0, 1.0)</div><div>view.GetRenderWindow().SetSize(600,300)</div><div><br></div><div>chart = vtk.vtkChartParallelCoordinates()</div><div><br></div><div># Create a annotation link to access selection in parallel coordinates view</div><div>annotationLink = vtk.vtkAnnotationLink()</div><div>annotationLink.GetCurrentSelection().GetNode(0).SetFieldType(1) # Point</div><div>annotationLink.GetCurrentSelection().GetNode(0).SetContentType(4) # 1 = GlobalIds, 2 = PedigreeIds, 4 = Indices</div><div><br></div><div># Connect the annotation link to the parallel coordinates representation</div><div># PCoords chart only seems to actually highlight with Index content</div><div># even if the table has Pedigree or Global IDs...</div><div>chart.SetAnnotationLink(annotationLink)</div><div><br></div><div># Create another vtkSelection to allow Pedigree IDs selections (conversion to Index later)</div><div>pedIdSel = vtk.vtkSelection()</div><div>pedIdNode = vtk.vtkSelectionNode()</div><div>pedIdNode.SetFieldType(1)</div><div>pedIdNode.SetContentType(2)</div><div>pedIdSel.AddNode(pedIdNode)</div><div><br></div><div>view.GetScene().AddItem(chart)</div><div><br></div><div># Test charting with a few more points...</div><div>numPoints = 50</div><div>inc = 7.5 / (numPoints-1)</div><div><br></div><div># Create arrays that will end up as table columns</div><div>arrP = vtk.vtkIntArray()</div><div>arrP.SetName('ID')</div><div>arrX = vtk.vtkFloatArray()</div><div>arrX.SetName("XAxis")</div><div>arrC = vtk.vtkFloatArray()</div><div>arrC.SetName("Cosine")</div><div>arrS = vtk.vtkFloatArray()</div><div>arrS.SetName("Sine")</div><div><br></div><div># For some reason table.SetValue() is not wrapped</div><div># <span class="Apple-tab-span" style="white-space:pre">        </span>so need to build arrays and then add as columns</div><div># Would be more elegant to use numpy, but wanted to keep it out for now...</div><div>for i in range(numPoints):</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>arrP.InsertNextValue(2*i+4000)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>arrX.InsertNextValue(i * inc)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>arrC.InsertNextValue(math.cos(i * inc) + 0.0)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>arrS.InsertNextValue(math.sin(i * inc) + 0.0)</div><div><br></div><div># Create a table with some points in it...</div><div>table = vtk.vtkTable()</div><div>table.AddColumn(arrP)</div><div>table.AddColumn(arrX)</div><div>table.AddColumn(arrC)</div><div>table.AddColumn(arrS)</div><div><br></div><div># Set ID as the PedigreeIds so can select by those later</div><div>table.GetRowData().SetActivePedigreeIds('ID')</div><div><br></div><div>chart.GetPlot(0).SetInput(table)</div><div><br></div><div>def selectionCallback(caller, event):</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>annSel = annotationLink.GetCurrentSelection()</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if annSel.GetNumberOfNodes() > 0:</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>idxArr = annSel.GetNode(0).GetSelectionList()</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if idxArr.GetNumberOfTuples() > 0:</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>print VN.vtk_to_numpy(idxArr)</div><div><br></div><div># Set up callback to do something when selections are changed in parallel coordinates view</div><div>annotationLink.AddObserver("AnnotationChangedEvent", selectionCallback)</div><div><br></div><div># Fill selection with pedigree IDs</div><div>ped_id_array = vtk.vtkIdTypeArray()</div><div>ped_id_array.SetName('ID')</div><div>ped_id_array.InsertNextValue(4020)</div><div><br></div><div># Apply the selection to the PedigreeIds selection node</div><div>pedIdNode.SetSelectionList(ped_id_array)</div><div><br></div><div># Convert pedigree ids to index selection for PC view highlighting</div><div>cs = vtk.vtkConvertSelection()</div><div>idxSel = cs.ToIndexSelection(pedIdSel, table)</div><div><br></div><div># Set that index selection to the annotation link for PC chart selection</div><div># Note: This will fire the AnnotationChangedEvent</div><div>annotationLink.SetCurrentSelection(idxSel)</div><div><br></div><div>view.ResetCamera()</div><div>view.Render()</div><div><br></div><div># Start interaction event loop</div><div>view.GetInteractor().Start()</div><div style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><br></div></span><br class="Apple-interchange-newline">
</div>
<br><div><div>On Jul 23, 2012, at 12:22 PM, Weimin Li wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta name="Generator" content="Microsoft Word 14 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Sprechblasentext Zchn";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.E-MailFormatvorlage17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.SprechblasentextZchn
        {mso-style-name:"Sprechblasentext Zchn";
        mso-style-priority:99;
        mso-style-link:Sprechblasentext;
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--><div lang="DE-AT" link="blue" vlink="purple"><div class="WordSection1"><p class="MsoNormal"><span lang="EN-US">Hi Dear all,<o:p></o:p></span></p><p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p><p class="MsoNormal"><span lang="EN-US">I have now a question about how to select a single line in a VtkChartParellelCoordinates view.<o:p></o:p></span></p><p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p><p class="MsoNormal"><span lang="EN-US">I am using the vtk nightly version, Qt 4.8.2 and VS 2008.<o:p></o:p></span></p><p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p><p class="MsoNormal"><span lang="EN-US">And the question is: <o:p></o:p></span></p><p class="MsoNormal"><span lang="EN-US">My first column of the input VtkTable for VtkChartParallelCoordinates is an ID Column. Now I want to select a single line or multi-lines in the ChartParallelCoordinates view by giving the ID number. <o:p></o:p></span></p><p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p><p class="MsoNormal"><span lang="EN-US">Is there anybody knows how to solve this? That would be great! Thanks a lot! <o:p></o:p></span></p><p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p><p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:"Arial","sans-serif"">________________________________________________<o:p></o:p></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:"Arial","sans-serif"">Dipl.-Ing. Weimin Li<o:p></o:p></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:"Arial","sans-serif"">Junior Reseacher / Industrial X-ray Computed Tomography<o:p></o:p></span></p><p class="MsoNormal"><span lang="EN-US" style="font-size:8.0pt;font-family:"Arial","sans-serif""> <o:p></o:p></span></p><p class="MsoNormal"><b><span lang="DE" style="font-size:8.0pt;font-family:"Arial","sans-serif"">FH OÖ Forschungs- & Entwicklungs GmbH<br></span></b><span lang="DE" style="font-size:8.0pt;font-family:"Arial","sans-serif"">Stelzhamerstraße 23 <br>4600 Wels / Austria<br>Tel: +43 (0)50804-44420<o:p></o:p></span></p><p class="MsoNormal"><span lang="DE" style="font-size:8.0pt;font-family:"Arial","sans-serif"">E-Mail: <a href="mailto:Li.Weimin@fh-wels.at"><span style="color:blue">Li.Weimin@fh-wels.at</span></a><o:p></o:p></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:8.0pt;font-family:"Arial","sans-serif"">Web: </span><span lang="DE" style="font-size:8.0pt;font-family:"Arial","sans-serif""><a href="https://webmail.fh-wels.at/exchweb/bin/redir.asp?URL=http://www.fh-ooe.at" target="_blank" title="blocked::http://www.fh-ooe.at/"><span lang="DE-AT" style="color:blue">www.fh-ooe.at</span></a> & <a href="http://www.3dct.at/" target="_blank"><span style="color:blue">www.3dct.at</span></a> <o:p></o:p></span></p><p class="MsoNormal" style="margin-bottom:12.0pt"><a href="http://www.3dct.at/ict2012"><span style="color:blue;text-decoration:none"><span><image001.jpg></span></span></a><span lang="DE" style="font-size:8.0pt;font-family:"Arial","sans-serif""><o:p></o:p></span></p><p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Arial","sans-serif";color:gray">Firmenbuchgericht/Court of registry: Landesgericht Wels</span><span lang="DE" style="font-size:8.0pt;font-family:"Arial","sans-serif""><o:p></o:p></span></p><p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Arial","sans-serif";color:gray">Firmenbuchnummer/Company registration: FN 236733 m</span><span lang="DE" style="font-size:8.0pt;font-family:"Arial","sans-serif""><o:p></o:p></span></p><p class="MsoNormal"><o:p> </o:p></p></div></div>_______________________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">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">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">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></blockquote></div><br></div></body></html>