How to set the default value for representation?

(Caobaolu) #1

Dear all,
I am trying to change the default value of the representation through adding a plugin.
for example, i want to change the default line width from 1 to 4, how can i acheive this?
I tried to change the xml settings below, but paraview crashed when I was loading the data.

<DoubleVectorProperty name="LineWidth"
                            command="SetLineWidth"
                            default_values="4"
                            number_of_elements="1">
<DoubleRangeDomain min="1"
                           name="range" />
</DoubleVectorProperty>

Any help would be appreciated~

(Mathieu Westphal (Kitware)) #2

This is not really supported, as the Representation xml system is quite complex.

You should be able to create your own complete representation xml and add it to ParaView as a plugin.

(Cory Quammen (Kitware)) #3

There is another mechanism to change defaults in a custom application. Take a look at how TomViz changes some RenderView defaults here: https://github.com/OpenChemistry/tomviz/blob/60b1e8bccfcb926b6f86388754f6396ebe8ff2f7/tomviz/Behaviors.cxx

To see what JSON you should have in your settings string, you can create a test geometry in ParaView, change the line width in the representation to 4, click the little floppy disk icon to the right of the Display (GeometryRepresentation), and take a look at ~/.config/ParaView/ParaView-UserSettings.json. This is what is should look like:

{
        "representations" : 
        {
                "GeometryRepresentation" : 
                {
                        "LineWidth" : 4.0,
                }
        }
}
(Caobaolu) #4

Hi,
Thanks for your reply~ I create my own representation as a plugin, and the line width appears to be my setting value, howevery the value displayed on the pannel is still “1” instead of my setting value which is correctly shown on the viewer.
Any idea why this is happening? Thank you~