Commit de794374 authored by Clinton Stimpson's avatar Clinton Stimpson
Browse files

BUG:  Fix default value initialization for array selections.
parent 2a2826d3
......@@ -298,17 +298,7 @@ QList<QList<QVariant> > pqSMAdaptor::getSelectionProperty(vtkSMProperty* Propert
if(StringProperty)
{
int numSelections = 0;
vtkSMStringVectorProperty* infoProp = NULL;
infoProp = vtkSMStringVectorProperty::SafeDownCast(
StringProperty->GetInformationProperty());
if(infoProp)
{
numSelections = infoProp->GetNumberOfElements() / 2;
}
else
{
numSelections = StringProperty->GetNumberOfElements() / 2;
}
numSelections = StringProperty->GetNumberOfElements() / 2;
for(int i=0; i<numSelections; i++)
{
......@@ -361,21 +351,11 @@ QList<QVariant> pqSMAdaptor::getSelectionProperty(vtkSMProperty* Property,
break;
}
}
// check the information property for a default value
if(!value.isValid())
{
vtkSMStringVectorProperty* infoProp = NULL;
infoProp = vtkSMStringVectorProperty::SafeDownCast(
StringProperty->GetInformationProperty());
if(infoProp)
{
value = infoProp->GetElement(Index*2 + 1);
}
}
}
// make up a zero
if(!value.isValid())
{
qWarning("had to make up a value for selection\n");
value = "0";
}
if(StringDomain->GetIntDomainMode() ==
......
......@@ -18,7 +18,7 @@
#include "vtkSMStringVectorProperty.h"
vtkStandardNewMacro(vtkSMArraySelectionDomain);
vtkCxxRevisionMacro(vtkSMArraySelectionDomain, "1.2");
vtkCxxRevisionMacro(vtkSMArraySelectionDomain, "1.3");
//---------------------------------------------------------------------------
vtkSMArraySelectionDomain::vtkSMArraySelectionDomain()
......@@ -53,6 +53,30 @@ void vtkSMArraySelectionDomain::Update(vtkSMProperty* prop)
this->InvokeModified();
}
}
int vtkSMArraySelectionDomain::SetDefaultValues(vtkSMProperty* prop)
{
vtkSMStringVectorProperty* svp = vtkSMStringVectorProperty::SafeDownCast(prop);
if(!svp || this->GetNumberOfRequiredProperties() == 0 ||
this->GetNumberOfStrings() == 0)
{
return this->Superclass::SetDefaultValues(prop);
}
// info property has default values
vtkSMStringVectorProperty* isvp;
isvp = vtkSMStringVectorProperty::SafeDownCast(prop->GetInformationProperty());
if(isvp)
{
unsigned int numEls = isvp->GetNumberOfElements();
for (unsigned int i=0; i<numEls; i++)
{
svp->SetElement(i, isvp->GetElement(i));
}
}
return 1;
}
//---------------------------------------------------------------------------
void vtkSMArraySelectionDomain::PrintSelf(ostream& os, vtkIndent indent)
......
......@@ -39,6 +39,17 @@ public:
// Populate the values of the domain from the given information
// property.
virtual void Update(vtkSMProperty*);
// Description:
// A vtkSMProperty is often defined with a default value in the
// XML itself. However, many times, the default value must be determined
// at run time. To facilitate this, domains can override this method
// to compute and set the default value for the property.
// Note that unlike the compile-time default values, the
// application must explicitly call this method to initialize the
// property.
// Returns 1 if the domain updated the property.
virtual int SetDefaultValues(vtkSMProperty*);
protected:
vtkSMArraySelectionDomain();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment