Commit 24a860aa authored by Berk Geveci's avatar Berk Geveci
Browse files

Added new domains to support array selection and xdmf parameters

parent 0edccea4
......@@ -4,6 +4,8 @@ SET( ServerManagerCommon_SRCS
vtkSMApplication.cxx
vtkSMArrayListDomain.cxx
vtkSMArrayRangeDomain.cxx
vtkSMArraySelectionDomain.cxx
vtkSMArraySelectionInformationHelper.cxx
vtkSMBooleanDomain.cxx
vtkSMBoundsDomain.cxx
vtkSMDataTypeDomain.cxx
......@@ -39,8 +41,11 @@ SET( ServerManagerCommon_SRCS
vtkSMSimpleStringInformationHelper.cxx
vtkSMSourceProxy.cxx
vtkSMStringListDomain.cxx
vtkSMStringListRangeDomain.cxx
vtkSMStringVectorProperty.cxx
vtkSMSubPropertyIterator.cxx
vtkSMXDMFInformationHelper.cxx
vtkSMXDMFPropertyDomain.cxx
vtkSMVectorProperty.cxx
)
......
This diff is collapsed.
/*=========================================================================
Program: ParaView
Module: vtkSMArraySelectionDomain.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkSMArraySelectionDomain.h"
#include "vtkObjectFactory.h"
#include "vtkSMStringVectorProperty.h"
vtkStandardNewMacro(vtkSMArraySelectionDomain);
vtkCxxRevisionMacro(vtkSMArraySelectionDomain, "1.1");
//---------------------------------------------------------------------------
vtkSMArraySelectionDomain::vtkSMArraySelectionDomain()
{
}
//---------------------------------------------------------------------------
vtkSMArraySelectionDomain::~vtkSMArraySelectionDomain()
{
}
//---------------------------------------------------------------------------
void vtkSMArraySelectionDomain::Update(vtkSMProperty* prop)
{
vtkSMStringVectorProperty* svp = vtkSMStringVectorProperty::SafeDownCast(prop);
if (svp && svp->GetInformationOnly())
{
this->RemoveAllStrings();
this->SetIntDomainMode(vtkSMStringListRangeDomain::BOOLEAN);
unsigned int numEls = svp->GetNumberOfElements();
if (numEls % 2 != 0)
{
vtkErrorMacro("The required property seems to have wrong number of "
"elements. It should be a multiple of 2");
return;
}
for (unsigned int i=0; i<numEls/2; i++)
{
this->AddString(svp->GetElement(i*2));
}
}
}
//---------------------------------------------------------------------------
void vtkSMArraySelectionDomain::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: vtkSMArraySelectionDomain.h
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkSMArraySelectionDomain - adds all strings from information property
// .SECTION Description
// vtkSMArraySelectionDomain overwrites vtkSMStringListRangeDomain's Update
// in which it adds all strings from a required information property to
// the domain. The information property must have been populated by
// an vtkSMArraySelectionInformationHelper. It also sets the IntDomainMode
// to BOOLEAN.
// .SECTION See Also
// vtkSMStringListRangeDomain vtkSMStringVectorProperty
// vtkSMArraySelectionInformationHelper
#ifndef __vtkSMArraySelectionDomain_h
#define __vtkSMArraySelectionDomain_h
#include "vtkSMStringListRangeDomain.h"
class VTK_EXPORT vtkSMArraySelectionDomain : public vtkSMStringListRangeDomain
{
public:
static vtkSMArraySelectionDomain* New();
vtkTypeRevisionMacro(vtkSMArraySelectionDomain, vtkSMStringListRangeDomain);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Populate the values of the domain from the given information
// property.
virtual void Update(vtkSMProperty*);
protected:
vtkSMArraySelectionDomain();
~vtkSMArraySelectionDomain();
private:
vtkSMArraySelectionDomain(const vtkSMArraySelectionDomain&); // Not implemented
void operator=(const vtkSMArraySelectionDomain&); // Not implemented
};
#endif
/*=========================================================================
Program: ParaView
Module: vtkSMArraySelectionInformationHelper.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkSMArraySelectionInformationHelper.h"
#include "vtkClientServerStream.h"
#include "vtkObjectFactory.h"
#include "vtkPVXMLElement.h"
#include "vtkProcessModule.h"
#include "vtkSMStringVectorProperty.h"
vtkStandardNewMacro(vtkSMArraySelectionInformationHelper);
vtkCxxRevisionMacro(vtkSMArraySelectionInformationHelper, "1.1");
//---------------------------------------------------------------------------
vtkSMArraySelectionInformationHelper::vtkSMArraySelectionInformationHelper()
{
this->AttributeName = 0;
}
//---------------------------------------------------------------------------
vtkSMArraySelectionInformationHelper::~vtkSMArraySelectionInformationHelper()
{
this->SetAttributeName(0);
}
//---------------------------------------------------------------------------
void vtkSMArraySelectionInformationHelper::UpdateProperty(
int serverIds, vtkClientServerID objectId, vtkSMProperty* prop)
{
vtkSMStringVectorProperty* svp = vtkSMStringVectorProperty::SafeDownCast(prop);
if (!svp)
{
vtkErrorMacro("A null property or a property of a different type was "
"passed when vtkSMStringVectorProperty was needed.");
return;
}
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
// Create server-side helper if necessary.
vtkClientServerStream str;
vtkClientServerID serverSideID =
pm->NewStreamObject("vtkPVServerArraySelection", str);
str << vtkClientServerStream::Invoke
<< serverSideID << "SetProcessModule" << pm->GetProcessModuleID()
<< vtkClientServerStream::End;
// Get the parameters from the server.
str << vtkClientServerStream::Invoke
<< serverSideID << "GetArraySettings" << objectId << this->AttributeName
<< vtkClientServerStream::End;
pm->SendStream(vtkProcessModule::GetRootId(serverIds), str, 1);
vtkClientServerStream arrays;
int retVal =
pm->GetLastResult(vtkProcessModule::GetRootId(serverIds)).GetArgument(0, 0, &arrays);
pm->DeleteStreamObject(serverSideID, str);
pm->SendStream(vtkProcessModule::GetRootId(serverIds), str, 0);
if(!retVal)
{
vtkErrorMacro("Error getting array settings from server.");
return;
}
int numArrays = arrays.GetNumberOfArguments(0)/2;
svp->SetNumberOfElements(numArrays*2);
for(int i=0; i < numArrays; ++i)
{
// Get the array name.
const char* name;
if(!arrays.GetArgument(0, i*2, &name))
{
vtkErrorMacro("Error getting array name from reader.");
break;
}
// Get the array status.
int status;
if(!arrays.GetArgument(0, i*2 + 1, &status))
{
vtkErrorMacro("Error getting array status from reader.");
break;
}
// Set the selection to match the reader.
svp->SetElement(2*i, name);
if(status)
{
svp->SetElement(2*i+1, "1");
}
else
{
svp->SetElement(2*i+1, "0");
}
}
}
//---------------------------------------------------------------------------
int vtkSMArraySelectionInformationHelper::ReadXMLAttributes(
vtkSMProperty* prop, vtkPVXMLElement* element)
{
if (!this->Superclass::ReadXMLAttributes(prop, element))
{
return 0;
}
const char* attribute_name = element->GetAttribute("attribute_name");
if(attribute_name)
{
this->SetAttributeName(attribute_name);
}
else
{
vtkErrorMacro("No attribute_name specified.");
return 0;
}
return 1;
}
//---------------------------------------------------------------------------
void vtkSMArraySelectionInformationHelper::PrintSelf(
ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: vtkSMArraySelectionInformationHelper.h
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkSMArraySelectionInformationHelper - populates vtkSMStringVectorProperty using a vtkPVServerArraySelection
// .SECTION Description
// vtkSMArraySelectionInformationHelper only works with
// vtkSMStringVectorProperties. It populates the property using the server
// side helper object. Each array is represented by two components:
// name, state (on/off)
// .SECTION See Also
// vtkSMInformationHelper vtkPVServerArraySelection vtkSMStringVectorProperty
#ifndef __vtkSMArraySelectionInformationHelper_h
#define __vtkSMArraySelectionInformationHelper_h
#include "vtkSMInformationHelper.h"
#include "vtkClientServerID.h" // needed for vtkClientServerID
class vtkSMProperty;
class VTK_EXPORT vtkSMArraySelectionInformationHelper : public vtkSMInformationHelper
{
public:
static vtkSMArraySelectionInformationHelper* New();
vtkTypeRevisionMacro(vtkSMArraySelectionInformationHelper, vtkSMInformationHelper);
void PrintSelf(ostream& os, vtkIndent indent);
//BTX
// Description:
// Updates the property using value obtained for server. It creates
// an instance of the server helper class vtkPVServerArraySelection
// and passes the objectId (which the helper class gets as a pointer)
// and populates the property using the values returned.
// Each array is represented by two components:
// name, state (on/off)
virtual void UpdateProperty(
int serverIds, vtkClientServerID objectId, vtkSMProperty* prop);
//ETX
protected:
vtkSMArraySelectionInformationHelper();
~vtkSMArraySelectionInformationHelper();
char* AttributeName;
vtkSetStringMacro(AttributeName);
vtkGetStringMacro(AttributeName);
int ReadXMLAttributes(vtkSMProperty* prop, vtkPVXMLElement* element);
private:
vtkSMArraySelectionInformationHelper(const vtkSMArraySelectionInformationHelper&); // Not implemented
void operator=(const vtkSMArraySelectionInformationHelper&); // Not implemented
};
#endif
......@@ -12,9 +12,17 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkSMInformationHelper -
// .NAME vtkSMInformationHelper - abstract superclass of all information helpers
// .SECTION Description
// Information helpers are used by information property to obtain
// information from the server. Since there can be more than way
// to populate an information property, this functionality was moved
// to a separate hierarchy of helper classes.
// Each information property has an associated information helper that
// is specified in the XML configuration file.
// .SECTION See Also
// vtkSMSimpleIntInformationHelper vtkSMSimpleDoubleInformationHelper
// vtkSMSimpleStringInformationHelper
#ifndef __vtkSMInformationHelper_h
#define __vtkSMInformationHelper_h
......@@ -22,6 +30,7 @@
#include "vtkSMObject.h"
#include "vtkClientServerID.h" // needed for vtkClientServerID
class vtkPVXMLElement;
class vtkSMProperty;
class VTK_EXPORT vtkSMInformationHelper : public vtkSMObject
......@@ -32,6 +41,8 @@ public:
//BTX
// Description:
// Fill in the property with values obtained from server. The
// way in which the information is obtained depends on the sub-class.
virtual void UpdateProperty(
int serverIds, vtkClientServerID objectId, vtkSMProperty* prop) = 0;
//ETX
......@@ -40,6 +51,18 @@ protected:
vtkSMInformationHelper();
~vtkSMInformationHelper();
//BTX
friend class vtkSMProperty;
//ETX
// Description:
// Set the appropriate ivars from the xml element. Should
// be overwritten by subclass if adding ivars.
virtual int ReadXMLAttributes(vtkSMProperty*, vtkPVXMLElement*)
{
return 1;
};
private:
vtkSMInformationHelper(const vtkSMInformationHelper&); // Not implemented
void operator=(const vtkSMInformationHelper&); // Not implemented
......
......@@ -21,7 +21,7 @@
#include <vtkstd/vector>
vtkStandardNewMacro(vtkSMIntRangeDomain);
vtkCxxRevisionMacro(vtkSMIntRangeDomain, "1.9");
vtkCxxRevisionMacro(vtkSMIntRangeDomain, "1.10");
struct vtkSMIntRangeDomainInternals
{
......@@ -229,7 +229,7 @@ void vtkSMIntRangeDomain::SaveState(
*file << indent
<< "<Domain name=\"" << this->XMLName << "\" id=\"" << name << "\">"
<< endl;
unsigned int size = this->IRInternals->Entries.size();
unsigned int size = this->GetNumberOfEntries();
unsigned int i;
for(i=0; i<size; i++)
{
......
......@@ -93,6 +93,13 @@ public:
// Clear all maximum values.
void RemoveAllMaxima();
// Description:
// Returns the number of entries in the internal
// maxima/minima list. No maxima/minima exists beyond
// this index. Maxima/minima below this number may or
// may not exist.
unsigned int GetNumberOfEntries();
// Description:
// Update self checking the "unchecked" values of all required
// properties. Overwritten by sub-classes.
......@@ -120,7 +127,6 @@ protected:
// Internal use only.
// Set/Get the number of min/max entries.
unsigned int GetNumberOfEntries();
void SetNumberOfEntries(unsigned int size);
vtkSMIntRangeDomainInternals* IRInternals;
......
......@@ -31,7 +31,7 @@
#include "vtkSMPropertyInternals.h"
vtkStandardNewMacro(vtkSMProperty);
vtkCxxRevisionMacro(vtkSMProperty, "1.19");
vtkCxxRevisionMacro(vtkSMProperty, "1.20");
vtkCxxSetObjectMacro(vtkSMProperty, Proxy, vtkSMProxy);
vtkCxxSetObjectMacro(vtkSMProperty, InformationHelper, vtkSMInformationHelper);
......@@ -323,7 +323,10 @@ int vtkSMProperty::ReadXMLAttributes(vtkSMProxy* proxy,
}
else if (ih)
{
this->SetInformationHelper(ih);
if (ih->ReadXMLAttributes(this, domainEl))
{
this->SetInformationHelper(ih);
}
}
else
{
......
......@@ -20,6 +20,10 @@
// this state to the vtk object it refers to. vtkSMPropery only supports
// methods with no arguments. Sub-classes support methods with different
// arguments types and numbers.
// A property can also be marked as an "information" property in which case
// it's values are obtained from the server with the UpdateInformation()
// call. This call is forwarded to an information helper. The type of
// the information helper used is specified in the XML file.
// Each property can have one or more sub-properties. The sub-properties
// can be accessed using an iterator. It is possible to create composite
// properties of any depth this way.
......@@ -30,6 +34,7 @@
// .SECTION See Also
// vtkSMProxyProperty vtkSMInputProperty vtkSMVectorProperty
// vtkSMDoubleVectorPropery vtkSMIntVectorPropery vtkSMStringVectorProperty
// vtkSMDomain vtkSMInformationHelper
#ifndef __vtkSMProperty_h
#define __vtkSMProperty_h
......@@ -107,6 +112,11 @@ public:
// as well as all dependant domains. This is usually called
// after SetUncheckedXXX() to tell all dependant domains to
// update themselves according to the new value.
// Note that when calling Update() on domains contained by
// this property, a NULL is passed as the argument. This is
// because the domain does not really "depend" on the property.
// When calling Update() on dependent domains, the property
// passes itself as the argument.
void UpdateDependentDomains();
// Description:
......@@ -158,8 +168,7 @@ protected:
// Description:
// If this is an information property (InformationOnly is true),
// this method fills the vector with the values obtained from
// the server using the Command (using the provided server id
// -only root node- and object id).
// the server. This work is forwarded to the information helper.
virtual void UpdateInformation(int serverids, vtkClientServerID objectId);
//ETX
......@@ -211,6 +220,11 @@ protected:
// Save the state in XML.
virtual void SaveState(const char* name, ostream* file, vtkIndent indent);
// Description:
// Set from the XML file, information helpers fill in the property
// values with information obtained from server.
void SetInformationHelper(vtkSMInformationHelper* helper);
char* Command;
vtkSMPropertyInternals* PInternals;
......@@ -232,7 +246,6 @@ protected:
vtkSetMacro(InformationOnly, int);
int InformationOnly;
void SetInformationHelper(vtkSMInformationHelper* helper);
vtkSMInformationHelper* InformationHelper;
private:
......
......@@ -133,8 +133,10 @@ public:
vtkGetStringMacro(XMLName);
// Description:
// Updates all property informations by calling the method
// and populating the values.
// Updates all property informations by calling UpdateInformation()
// and populating the values. It also calls UpdateDependentDomains()
// on all properties to make sure that domains that depend on the
// information are updated.
virtual void UpdateInformation();
protected:
......
......@@ -20,7 +20,7 @@
#include "vtkSMDoubleVectorProperty.h"
vtkStandardNewMacro(vtkSMSimpleDoubleInformationHelper);
vtkCxxRevisionMacro(vtkSMSimpleDoubleInformationHelper, "1.1");
vtkCxxRevisionMacro(vtkSMSimpleDoubleInformationHelper, "1.2");
//---------------------------------------------------------------------------
vtkSMSimpleDoubleInformationHelper::vtkSMSimpleDoubleInformationHelper()
......@@ -44,6 +44,7 @@ void vtkSMSimpleDoubleInformationHelper::UpdateProperty(
return;
}
// Invoke property's method on the root node of the server
vtkClientServerStream str;
str << vtkClientServerStream::Invoke
<< objectId << prop->GetCommand()
......@@ -52,6 +53,7 @@ void vtkSMSimpleDoubleInformationHelper::UpdateProperty(
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
pm->SendStream(vtkProcessModule::GetRootId(serverIds), str, 0);
// Get the result
const vtkClientServerStream& res =
pm->GetLastResult(vtkProcessModule::GetRootId(serverIds));
......@@ -70,6 +72,7 @@ void vtkSMSimpleDoubleInformationHelper::UpdateProperty(
int argType = res.GetArgumentType(0, 0);
// If single value, both float and double works
if (argType == vtkClientServerStream::float64_value ||
argType == vtkClientServerStream::float32_value)
{
......@@ -83,6 +86,7 @@ void vtkSMSimpleDoubleInformationHelper::UpdateProperty(
dvp->SetNumberOfElements(1);
dvp->SetElement(0, ires);
}
// If array, handle 32 bit and 64 bit separately
else if (argType == vtkClientServerStream::float64_array)
{
vtkTypeUInt32 length;
......
......@@ -12,9 +12,14 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkSMSimpleDoubleInformationHelper -
// .NAME vtkSMSimpleDoubleInformationHelper - populates vtkSMDoubleVectorProperty with the results of it's command
// .SECTION Description
// vtkSMSimpleDoubleInformationHelper only works with
// vtkSMDoubleVectorProperties. It calls the property's Command on the
// root node of the associated server and populates the property using
// the values returned.
// .SECTION See Also
// vtkSMInformationHelper vtkSMDoubleVectorProperty
#ifndef __vtkSMSimpleDoubleInformationHelper_h
#define __vtkSMSimpleDoubleInformationHelper_h
......@@ -33,6 +38,9 @@ public:
//BTX
// Description:
// Updates the property using values obtained for server. Calls
// property's Command on the root node of the server and uses the
// return value(s).
virtual void UpdateProperty(
int serverIds, vtkClientServerID objectId, vtkSMProperty* prop);
//ETX
......