<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* 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;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</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]-->
</head>
<body lang=EN-GB link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal>I get a lot of data where scalars are defined by names like
Density, density, rho, RHO, m_c_rho, rho_ – or any other possibly name
that vaguely describes the data.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I’ve added a couple of new fields to the string array XML
– an example is best<o:p></o:p></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;
font-family:"Courier New";color:blue'>
</span><span style='font-size:9.0pt;font-family:"Courier New";color:red'>name</span><span
style='font-size:9.0pt;font-family:"Courier New";color:blue'>=</span><span
style='font-size:9.0pt;font-family:"Courier New"'>"<span style='color:
blue'>Yarray</span>"<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;
font-family:"Courier New";color:blue'>
</span><span style='font-size:9.0pt;font-family:"Courier New";color:red'>command</span><span
style='font-size:9.0pt;font-family:"Courier New";color:blue'>=</span><span
style='font-size:9.0pt;font-family:"Courier New"'>"<span style='color:
blue'>SetYarray</span>"<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;
font-family:"Courier New";color:blue'>
</span><span style='font-size:9.0pt;font-family:"Courier New";color:red'>default_values</span><span
style='font-size:9.0pt;font-family:"Courier New";color:blue'>=</span><span
style='font-size:9.0pt;font-family:"Courier New"'>"<span style='color:
blue'>Coords_1</span>"<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;
font-family:"Courier New";color:blue'>
</span><span style='font-size:9.0pt;font-family:"Courier New";color:red'>default_regex_delimiter</span><span
style='font-size:9.0pt;font-family:"Courier New";color:blue'>=</span><span
style='font-size:9.0pt;font-family:"Courier New"'>"<span style='color:
blue'>,</span>"<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;
font-family:"Courier New";color:blue'>
</span><span style='font-size:9.0pt;font-family:"Courier New";color:red'>default_regex</span><span
style='font-size:9.0pt;font-family:"Courier New";color:blue'>=</span><span
style='font-size:9.0pt;font-family:"Courier New"'>"<span style='color:
blue'>.*Y,.*y,.*oords_1</span>"<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;
font-family:"Courier New";color:blue'>
</span><span style='font-size:9.0pt;font-family:"Courier New";color:red'>number_of_elements</span><span
style='font-size:9.0pt;font-family:"Courier New";color:blue'>=</span><span
style='font-size:9.0pt;font-family:"Courier New"'>"<span style='color:
blue'>1</span>"<span style='color:blue'>><o:p></o:p></span></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Now the regex is used to search all possible scalar arrays
to find the first match. Not very complex, but my first tests show that for
reasonably simple regexs (and data arrays), all seems good and I’m now
able to save several array selection clicks by getting the default found for
me.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>In order to make this work, I added to
vtkSMStringVectorProperty<o:p></o:p></p>
<p class=MsoNormal style='text-autospace:none'><b><span style='font-size:9.0pt;
font-family:"Courier New"'> <span style='color:navy'>// Description:</span></span></b><span
style='font-size:9.0pt;font-family:"Courier New";color:navy'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><b><span style='font-size:9.0pt;
font-family:"Courier New"'> <span style='color:navy'>// If this string
vector has regular expression searches attached</span></span></b><span
style='font-size:9.0pt;font-family:"Courier New";color:navy'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><b><span style='font-size:9.0pt;
font-family:"Courier New"'> <span style='color:navy'>// then provide a
hook so that the a string list domain can pass in a list</span></span></b><span
style='font-size:9.0pt;font-family:"Courier New";color:navy'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><b><span style='font-size:9.0pt;
font-family:"Courier New"'> <span style='color:navy'>// of possible
strings from which a default can be selected</span></span></b><span
style='font-size:9.0pt;font-family:"Courier New";color:navy'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><b><span style='font-size:9.0pt;
font-family:"Courier New"'> <span style='color:maroon'>bool</span> <span
style='color:green'>GetDefaultUsesRegex</span><span style='color:olive'>();</span></span></b><span
style='font-size:9.0pt;font-family:"Courier New";color:olive'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;
font-family:"Courier New";color:olive'><o:p> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><b><span style='font-size:9.0pt;
font-family:"Courier New"'> <span style='color:navy'>// Description:</span></span></b><span
style='font-size:9.0pt;font-family:"Courier New";color:navy'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><b><span style='font-size:9.0pt;
font-family:"Courier New"'> <span style='color:navy'>// Using the regular
expression list, pick one of the possible string</span></span></b><span
style='font-size:9.0pt;font-family:"Courier New";color:navy'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><b><span style='font-size:9.0pt;
font-family:"Courier New"'> <span style='color:navy'>// to be used as the
default value</span></span></b><span style='font-size:9.0pt;font-family:"Courier New";
color:navy'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><b><span style='font-size:9.0pt;
font-family:"Courier New"'> <span style='color:maroon'>const</span> <span
style='color:maroon'>char</span><span style='color:olive'>*</span> <span
style='color:green'>GetDefaultValue</span><span style='color:olive'>(</span><span
style='color:green'>vtkStringList</span> <span style='color:olive'>*</span><span
style='color:green'>list</span><span style='color:olive'>);</span></span></b><span
style='font-size:9.0pt;font-family:"Courier New";color:olive'><o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:12.0pt;
font-family:"Courier New";color:olive'><o:p> </o:p></span></p>
<p class=MsoNormal>and some tweaks to <b><span style='font-size:9.0pt;
font-family:"Courier New";color:blue'>vtkSMStringListDomain</span></b> so that
the calls are made appropriately.<o:p></o:p></p>
<p class=MsoNormal>unfortunately, in order to pick a default, the <b><span
style='font-size:9.0pt;font-family:"Courier New";color:blue'>vtkSMStringListDomain</span></b>
has to copy all of its internal array values into a vtkStringList, pass them to
the VectorProperty, let it choose one and then destroy the list afterwards.
This is because we are not allowed to use vtkstd::anything in headers and the
list is already stored internally as a vtkstd::vector< ... ><o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I don’t like it.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>however, when I’m sure I’ve not broken anything I’ll
check the stuff in. I’d be grateful if one of the ServerManager Proxy
whizzes from Kitware would take a glance at the code when it goes in to see if
there’s a tidier (/better) way of doing it. I’m never quite sure of
the ArrayListDomain/StringListDomain/StringVectorProperty/etc etc as to who is
supposed to own what.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Thanks<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>JB<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:Consolas'>--
<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:Consolas'>John
Biddiscombe,
email:biddisco @ cscs.ch<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:Consolas'><a
href="http://www.cscs.ch/"><span style='color:blue'>http://www.cscs.ch/</span></a><o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:Consolas'>CSCS,
Swiss National Supercomputing Centre | Tel: +41 (91) 610.82.07<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:Consolas'>Via
Cantonale, 6928 Manno, Switzerland | Fax:
+41 (91) 610.82.82<o:p></o:p></span></p>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>