<div dir="ltr"><div>There is an additional feature I am interested in, which is using the panel_widget="list" option for listing the strings. It again causes a segfault when change it within the XML. Thanks for the help. <br>
<br></div>Regards,<br>Girish<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 18 August 2014 16:44, Girish Ramesh <span dir="ltr"><<a href="mailto:rgirish28@gmail.com" target="_blank">rgirish28@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks Utkarsh. I was also making the mistake of not allocating the memory for a SmartPointer as I was changing the code from vtkNew and forgot to adapt it. I've changed it now and it works finally! Thanks a lot guys. I'll probably add some documentation for this as there is nothing mentioned in the Wiki that is close to this at all. <br>
<br>Regards,<br>Girish<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On 18 August 2014 16:26, Utkarsh Ayachit <span dir="ltr"><<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Girish,<br>
<br>
GetCPOList() is incorrect. You cannot return references to variables<br>
that go out of scope at the end of the method. Just as a hack, mark<br>
the labels variable as static and it will work. You should change the<br>
code to make Labels an<br>
member variable of the class and return that.<br>
<span><font color="#888888"><br>
Utkarsh<br>
</font></span><div><div><br>
On Mon, Aug 18, 2014 at 10:19 AM, Girish Ramesh <<a href="mailto:rgirish28@gmail.com" target="_blank">rgirish28@gmail.com</a>> wrote:<br>
> Well, I did try with a vtkSmartPointer but it didn't work either. Still<br>
> segfaulting. This is the code state at the moment and I can't figure out<br>
> why! It is definitely the problem of this bit as the rest of the plugin is<br>
> compiling and running without segfaulting. So, I hope you can help me.<br>
> Thanks.<br>
><br>
> XML:<br>
><br>
> <StringVectorProperty<br>
> name="CPOList"<br>
> label="CPOList"<br>
> command="SetCPOList"<br>
> number_of_elements_per_<br>
> command="1"<br>
> information_property="CPOListInfo"<br>
><br>
> panel_visibility="default"><br>
> <StringListDomain name="array_list"><br>
> <RequiredProperties><br>
> <Property function="ArrayList"<br>
> name="CPOListInfo"/><br>
> </RequiredProperties><br>
> </StringListDomain><br>
><br>
> <Documentation><br>
> This property helps select the CPO.<br>
> </Documentation><br>
> </StringVectorProperty><br>
><br>
> <StringVectorProperty<br>
> name="CPOListInfo"<br>
> label="CPOListInfo"<br>
> command="GetCPOList"<br>
> information_only="1" ><br>
> <StringArrayHelper /><br>
> </StringVectorProperty><br>
><br>
><br>
> C++:<br>
><br>
><br>
> vtkStringArray* ReadUALGrid::GetCPOList(){<br>
><br>
><br>
> vtkSmartPointer<vtkStringArray> labels;<br>
><br>
><br>
><br>
> labels->InsertNextValue("hello");<br>
> labels->InsertNextValue("world");<br>
><br>
><br>
> return labels;<br>
><br>
> }<br>
><br>
> void ReadUALGrid::SetCPOList(const char* name)<br>
><br>
> {<br>
><br>
> }<br>
><br>
><br>
><br>
><br>
> On 18 August 2014 15:49, Cory Quammen <<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>> wrote:<br>
>><br>
>> The biggest problem is that vtkNew will decrement the reference count<br>
>> when you go out of scope in GetCPOList(), so it will be garbage<br>
>> collected and anything using the return value may cause a crash. For<br>
>> your quick proof-of-concept work, use a vtkSmartPointer instead, or<br>
>> even just a raw pointer.<br>
>><br>
>> Also, SetCPOList takes an int, but shouldn't it take a char* or const<br>
>> char*?<br>
>><br>
>> Cory<br>
>><br>
>> On Mon, Aug 18, 2014 at 9:42 AM, Girish Ramesh <<a href="mailto:rgirish28@gmail.com" target="_blank">rgirish28@gmail.com</a>><br>
>> wrote:<br>
>> > Sorry but I'm still getting a seg fault and I'm not sure why. This is<br>
>> > the<br>
>> > relevant code within the plugin. Thanks.<br>
>> ><br>
>> > XML:<br>
>> ><br>
>> > <StringVectorProperty<br>
>> > name="CPOList"<br>
>> > label="CPOList"<br>
>> > command="SetCPOList"<br>
>> > number_of_elements_per_command="1"<br>
>> > information_property="CPOListInfo"<br>
>> ><br>
>> > panel_visibility="default"><br>
>> > <StringListDomain name="array_list"><br>
>> > <RequiredProperties><br>
>> > <Property function="ArrayList"<br>
>> > name="CPOListInfo"/><br>
>> > </RequiredProperties><br>
>> > </StringListDomain><br>
>> ><br>
>> > <Documentation><br>
>> > This property helps select the CPO.<br>
>> > </Documentation><br>
>> > </StringVectorProperty><br>
>> ><br>
>> > <StringVectorProperty<br>
>> > name="CPOListInfo"<br>
>> > label="CPOListInfo"<br>
>> > command="GetCPOList"<br>
>> > information_only="1" ><br>
>> > <StringArrayHelper /><br>
>> > </StringVectorProperty><br>
>> ><br>
>> > C++:<br>
>> ><br>
>> > vtkStringArray* ReadUALGrid::GetCPOList(){<br>
>> ><br>
>> ><br>
>> > vtkNew<vtkStringArray> labels;<br>
>> ><br>
>> ><br>
>> > labels->InsertNextValue("hello");<br>
>> > labels->InsertNextValue("world");<br>
>> ><br>
>> ><br>
>> > return labels.GetPointer();<br>
>> ><br>
>> > }<br>
>> ><br>
>> > void ReadUALGrid::SetCPOList(int index)<br>
>> ><br>
>> > {<br>
>> ><br>
>> > }<br>
>> ><br>
>> ><br>
>> > I'm just using a random vtkStringArray for testing, but it still<br>
>> > segfaults.<br>
>> > Thank you for the help.<br>
>> ><br>
>> > Regards,<br>
>> > Girish<br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> > On 18 August 2014 15:31, Girish Ramesh <<a href="mailto:rgirish28@gmail.com" target="_blank">rgirish28@gmail.com</a>> wrote:<br>
>> >><br>
>> >> Thank you very much Cory for your help. I guess the forum shall be<br>
>> >> peppered with any more problems I have!<br>
>> >><br>
>> >> Regards,<br>
>> >> Girish<br>
>> >><br>
>> >><br>
>> >> On 18 August 2014 15:29, Cory Quammen <<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>> wrote:<br>
>> >>><br>
>> >>> Girish,<br>
>> >>><br>
>> >>> Unfortunately, there isn't much documentation about the server manager<br>
>> >>> XMLs. Finding something that looks like what you are trying to do in<br>
>> >>> the UI and then tracking it down in the XML is currently the best way.<br>
>> >>><br>
>> >>> Thanks,<br>
>> >>> Cory<br>
>> >>><br>
>> >>> On Mon, Aug 18, 2014 at 9:25 AM, Girish Ramesh <<a href="mailto:rgirish28@gmail.com" target="_blank">rgirish28@gmail.com</a>><br>
>> >>> wrote:<br>
>> >>> > Dear Cory,<br>
>> >>> ><br>
>> >>> > Thank you very much. Your hints were very helpful. Option 2 was what<br>
>> >>> > I<br>
>> >>> > was<br>
>> >>> > looking for, but I didn't use the StringListDomain in the second<br>
>> >>> > property to<br>
>> >>> > connect the information. So my plugin was seg faulting repeatedly<br>
>> >>> > even<br>
>> >>> > though I thought my logic was correct. Also, is there any resource<br>
>> >>> > to<br>
>> >>> > find<br>
>> >>> > more about servermanager xmls and how to connect the different<br>
>> >>> > classes<br>
>> >>> > together or is the only option to look at examples. Sorry for the<br>
>> >>> > trouble<br>
>> >>> > :)Thanks again!<br>
>> >>> ><br>
>> >>> > Regards,<br>
>> >>> > Girish<br>
>> >>> ><br>
>> >>> ><br>
>> >>> ><br>
>> >>> ><br>
>> >>> > On 18 August 2014 15:16, Cory Quammen <<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>><br>
>> >>> > wrote:<br>
>> >>> >><br>
>> >>> >> Girish,<br>
>> >>> >><br>
>> >>> >> Is the list of strings fixed, or can it vary depending on the file?<br>
>> >>> >> There are three things you can do depending on what you need:<br>
>> >>> >><br>
>> >>> >> 1). If you have a fixed set of strings, you can use an<br>
>> >>> >> IntVectorProperty, and set its domain as a list of strings with an<br>
>> >>> >> associated integer, i.e., an enumeration.<br>
>> >>> >><br>
>> >>> >> <IntVectorProperty command="SetVariableType"<br>
>> >>> >> default_values="0"<br>
>> >>> >> name="VariableType"<br>
>> >>> >> number_of_elements="1"><br>
>> >>> >> <EnumerationDomain name="enum"><br>
>> >>> >> <Entry text="Variable 1"<br>
>> >>> >> value="0" /><br>
>> >>> >> <Entry text="Variable 2"<br>
>> >>> >> value="1" /><br>
>> >>> >> <Entry text="Variable 3"<br>
>> >>> >> value="2" /><br>
>> >>> >> </EnumerationDomain><br>
>> >>> >> </IntVectorProperty><br>
>> >>> >><br>
>> >>> >> This generates a combo box in the UI, and only one element can be<br>
>> >>> >> selected at a time. It will expect your reader to have methods with<br>
>> >>> >> the signature<br>
>> >>> >><br>
>> >>> >> virtual void SetVariableType(int i);<br>
>> >>> >> virtual int GetVariableType();<br>
>> >>> >><br>
>> >>> >> Within your reader, you can use this enumeration value to do<br>
>> >>> >> whatever<br>
>> >>> >> you'd like.<br>
>> >>> >><br>
>> >>> >> 2). If you just have a list of strings generated in your reader and<br>
>> >>> >> want to enable the selection of one, you can use a<br>
>> >>> >> StringVectorProperty with a StringListDomain, e.g.<br>
>> >>> >><br>
>> >>> >> <StringVectorProperty command="GetAllDimensions"<br>
>> >>> >> information_only="1"<br>
>> >>> >> name="DimensionInfo"><br>
>> >>> >> <StringArrayHelper /><br>
>> >>> >> </StringVectorProperty><br>
>> >>> >> <StringVectorProperty animatelable="0"<br>
>> >>> >> command="SetDimensions"<br>
>> >>> >> name="Dimensions"<br>
>> >>> >> number_of_elements="1"<br>
>> >>> >> panel_visibility="default"><br>
>> >>> >> <StringListDomain name="array_list"><br>
>> >>> >> <RequiredProperties><br>
>> >>> >> <Property function="ArrayList"<br>
>> >>> >> name="DimensionInfo" /><br>
>> >>> >> </RequiredProperties><br>
>> >>> >> </StringListDomain><br>
>> >>> >> </StringVectorProperty><br>
>> >>> >><br>
>> >>> >> The first property here is an "information-only" property. ParaView<br>
>> >>> >> will invoke the method "GetAllDimensions" in your reader which<br>
>> >>> >> should<br>
>> >>> >> return a vtkStringArray. The second property is responsible for<br>
>> >>> >> displaying the string array as a combobox, and invokes the method<br>
>> >>> >> "SetDimensions" with the value selected in the combobox. You need<br>
>> >>> >> the<br>
>> >>> >> StringListDomain in the second property to connect the<br>
>> >>> >> information-only property to the second property.<br>
>> >>> >><br>
>> >>> >> 3). If you need to populate the list depending on what is in the<br>
>> >>> >> file<br>
>> >>> >> and be able to select/deselect list entries (e.g., to pick which<br>
>> >>> >> variables are loaded from the file), then see the XML file<br>
>> >>> >><br>
>> >>> >><br>
>> >>> >><br>
>> >>> >> ParaView/ParaViewCore/ServerManager/SMApplication/Resources/readers.xml<br>
>> >>> >><br>
>> >>> >> and search for the SourceProxy named "FlashReaderCore". You'll find<br>
>> >>> >> this XML property definition:<br>
>> >>> >><br>
>> >>> >> <!-- Array Selection GUI Component --><br>
>> >>> >> <StringVectorProperty information_only="1"<br>
>> >>> >> name="CellArrayInfo"><br>
>> >>> >> <ArraySelectionInformationHelper attribute_name="Cell" /><br>
>> >>> >> </StringVectorProperty><br>
>> >>> >> <StringVectorProperty command="SetCellArrayStatus"<br>
>> >>> >> element_types="2 0"<br>
>> >>> >> information_property="CellArrayInfo"<br>
>> >>> >> label="Cell Arrays"<br>
>> >>> >> name="CellArrayStatus"<br>
>> >>> >> number_of_elements="0"<br>
>> >>> >> number_of_elements_per_command="2"<br>
>> >>> >> repeat_command="1"><br>
>> >>> >> <ArraySelectionDomain name="array_list"><br>
>> >>> >> <RequiredProperties><br>
>> >>> >> <Property function="ArrayList"<br>
>> >>> >> name="CellArrayInfo" /><br>
>> >>> >> </RequiredProperties><br>
>> >>> >> </ArraySelectionDomain><br>
>> >>> >> <Documentation>This property lists which cell-centered<br>
>> >>> >> arrays<br>
>> >>> >> to<br>
>> >>> >> read.</Documentation><br>
>> >>> >> </StringVectorProperty><br>
>> >>> >> <StringVectorProperty information_only="1"<br>
>> >>> >> name="PointArrayInfo"><br>
>> >>> >> <ArraySelectionInformationHelper attribute_name="Point" /><br>
>> >>> >> </StringVectorProperty><br>
>> >>> >><br>
>> >>> >> This XML is responsible for showing in the GUI the list of<br>
>> >>> >> cell-associated arrays. In the vtkAMRFlashReader, there are a<br>
>> >>> >> number<br>
>> >>> >> of<br>
>> >>> >> methods that are defined to make this work. (These are actually<br>
>> >>> >> defined in vtkAMRFlashReader's parent class, vtkAMRBaseReader.h)<br>
>> >>> >><br>
>> >>> >> // Description:<br>
>> >>> >> // Get the data array selection tables used to configure which<br>
>> >>> >> data<br>
>> >>> >> // arrays are loaded by the reader.<br>
>> >>> >> vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);<br>
>> >>> >><br>
>> >>> >> // Description:<br>
>> >>> >> // Get the number of point or cell arrays available in the input.<br>
>> >>> >> int GetNumberOfCellArrays();<br>
>> >>> >><br>
>> >>> >> // Description:<br>
>> >>> >> // Get the name of the point or cell array with the given index<br>
>> >>> >> in<br>
>> >>> >> // the input.<br>
>> >>> >> const char* GetCellArrayName(int index);<br>
>> >>> >><br>
>> >>> >> // Description:<br>
>> >>> >> // Get/Set whether the point or cell array with the given name is<br>
>> >>> >> to<br>
>> >>> >> // be read.<br>
>> >>> >> int GetCellArrayStatus(const char* name);<br>
>> >>> >> void SetCellArrayStatus(const char* name, int status);<br>
>> >>> >><br>
>> >>> >> The first method listed above might not be necessary in your<br>
>> >>> >> reader;<br>
>> >>> >> I'm not sure. The rest are necessary.<br>
>> >>> >><br>
>> >>> >> Note in this XML and method definitions that "Cell" is the name of<br>
>> >>> >> the<br>
>> >>> >> given to the association of array the reader can load. You can<br>
>> >>> >> replace<br>
>> >>> >> all occurrences of "Cell" with whatever name is more appropriate<br>
>> >>> >> for<br>
>> >>> >> your needs.<br>
>> >>> >><br>
>> >>> >> I hope that helps,<br>
>> >>> >> Cory<br>
>> >>> >><br>
>> >>> >> On Mon, Aug 18, 2014 at 5:46 AM, Girish Ramesh<br>
>> >>> >> <<a href="mailto:rgirish28@gmail.com" target="_blank">rgirish28@gmail.com</a>><br>
>> >>> >> wrote:<br>
>> >>> >> > Hi,<br>
>> >>> >> ><br>
>> >>> >> > I have been breaking my head over this problem for a while now as<br>
>> >>> >> > there<br>
>> >>> >> > are<br>
>> >>> >> > no servermanager xml explanations anywhere. So, what I want to<br>
>> >>> >> > accomplish is<br>
>> >>> >> > populate a GUI list with a vtkStringArray and be able to select<br>
>> >>> >> > strings<br>
>> >>> >> > within the list in order to fill a variable . Can someone please<br>
>> >>> >> > help me<br>
>> >>> >> > or<br>
>> >>> >> > point me in the right direction in this task? I am writing my own<br>
>> >>> >> > plugin<br>
>> >>> >> > reader as you may have understood, but I'm stuck at this point<br>
>> >>> >> > for a<br>
>> >>> >> > while.<br>
>> >>> >> > Thanks.<br>
>> >>> >> ><br>
>> >>> >> > Regards,<br>
>> >>> >> > Girish<br>
>> >>> >> ><br>
>> >>> >> > _______________________________________________<br>
>> >>> >> > Paraview-developers mailing list<br>
>> >>> >> > <a href="mailto:Paraview-developers@paraview.org" target="_blank">Paraview-developers@paraview.org</a><br>
>> >>> >> > <a href="http://public.kitware.com/mailman/listinfo/paraview-developers" target="_blank">http://public.kitware.com/mailman/listinfo/paraview-developers</a><br>
>> >>> >> ><br>
>> >>> ><br>
>> >>> ><br>
>> >><br>
>> >><br>
>> ><br>
><br>
><br>
><br>
> _______________________________________________<br>
> Paraview-developers mailing list<br>
> <a href="mailto:Paraview-developers@paraview.org" target="_blank">Paraview-developers@paraview.org</a><br>
> <a href="http://public.kitware.com/mailman/listinfo/paraview-developers" target="_blank">http://public.kitware.com/mailman/listinfo/paraview-developers</a><br>
><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>