diff --git a/ParaViewCore/ServerManager/Core/vtkSMDoubleVectorProperty.cxx b/ParaViewCore/ServerManager/Core/vtkSMDoubleVectorProperty.cxx index a94c5ee0645f8c59cf90b4c1bd90b69ee734eac0..3641eba32579e0afb35c9795672d659f8fdb493e 100644 --- a/ParaViewCore/ServerManager/Core/vtkSMDoubleVectorProperty.cxx +++ b/ParaViewCore/ServerManager/Core/vtkSMDoubleVectorProperty.cxx @@ -193,6 +193,33 @@ int vtkSMDoubleVectorProperty::SetUncheckedElements(const double* values, unsign return this->Internals->SetUncheckedElements(values, numValues); } +//--------------------------------------------------------------------------- +int vtkSMDoubleVectorProperty::SetElements(const std::vector& values) +{ + return this->Internals->SetElements( + values.size() > 0 ? &values[0] : nullptr, static_cast(values.size())); +} + +//--------------------------------------------------------------------------- +int vtkSMDoubleVectorProperty::SetUncheckedElements(const std::vector& values) +{ + return this->Internals->SetUncheckedElements( + values.size() > 0 ? &values[0] : nullptr, static_cast(values.size())); +} + +//--------------------------------------------------------------------------- +const std::vector& vtkSMDoubleVectorProperty::GetElements(const std::vector&) const +{ + return this->Internals->Values; +} + +//--------------------------------------------------------------------------- +const std::vector& vtkSMDoubleVectorProperty::GetUnCheckedElements( + const std::vector&) const +{ + return this->Internals->UncheckedValues; +} + //--------------------------------------------------------------------------- int vtkSMDoubleVectorProperty::ReadXMLAttributes(vtkSMProxy* proxy, vtkPVXMLElement* element) { diff --git a/ParaViewCore/ServerManager/Core/vtkSMDoubleVectorProperty.h b/ParaViewCore/ServerManager/Core/vtkSMDoubleVectorProperty.h index 73bc4b42c7403f4b685a2bb035c0f947bd3c756d..ad215ce4400812859b1190c99d6de4eb50da2b85 100644 --- a/ParaViewCore/ServerManager/Core/vtkSMDoubleVectorProperty.h +++ b/ParaViewCore/ServerManager/Core/vtkSMDoubleVectorProperty.h @@ -28,6 +28,8 @@ #include "vtkPVServerManagerCoreModule.h" //needed for exports #include "vtkSMVectorProperty.h" +#include // for std::vector + class vtkSMStateLocator; class VTKPVSERVERMANAGERCORE_EXPORT vtkSMDoubleVectorProperty : public vtkSMVectorProperty @@ -68,6 +70,24 @@ public: double* GetElements(); //@} + // typedef to circumvent wrapping issues. + typedef std::vector VectorOfDoubles; + + //@{ + /** + * Get/Set elements (and unchecked elements) API using std::vector. + * The `Set` methods return 1 if the property was modified, otherwise 0. + * + * The `Get` methods take in an optional unused argument to disambiguate from + * variants that return `double*`. + */ + int SetElements(const std::vector& values); + int SetUncheckedElements(const std::vector& values); + const VectorOfDoubles& GetElements(const VectorOfDoubles& notused = VectorOfDoubles()) const; + const VectorOfDoubles& GetUnCheckedElements( + const VectorOfDoubles& notused = VectorOfDoubles()) const; + //@} + //@{ /** * Sets the values of all the unchecked elements. diff --git a/ParaViewCore/ServerManager/Core/vtkSMIdTypeVectorProperty.cxx b/ParaViewCore/ServerManager/Core/vtkSMIdTypeVectorProperty.cxx index 86b1a967f6ff04ad3ba2798720362d4e1d4521dc..e9d3b23e3eb93ab0a7192c5f86898850c11f00c9 100644 --- a/ParaViewCore/ServerManager/Core/vtkSMIdTypeVectorProperty.cxx +++ b/ParaViewCore/ServerManager/Core/vtkSMIdTypeVectorProperty.cxx @@ -174,6 +174,34 @@ int vtkSMIdTypeVectorProperty::SetUncheckedElements(const vtkIdType* values, uns return this->Internals->SetUncheckedElements(values, numValues); } +//--------------------------------------------------------------------------- +int vtkSMIdTypeVectorProperty::SetElements(const std::vector& values) +{ + return this->Internals->SetElements( + values.size() > 0 ? &values[0] : nullptr, static_cast(values.size())); +} + +//--------------------------------------------------------------------------- +int vtkSMIdTypeVectorProperty::SetUncheckedElements(const std::vector& values) +{ + return this->Internals->SetUncheckedElements( + values.size() > 0 ? &values[0] : nullptr, static_cast(values.size())); +} + +//--------------------------------------------------------------------------- +const std::vector& vtkSMIdTypeVectorProperty::GetElements( + const std::vector&) const +{ + return this->Internals->Values; +} + +//--------------------------------------------------------------------------- +const std::vector& vtkSMIdTypeVectorProperty::GetUnCheckedElements( + const std::vector&) const +{ + return this->Internals->UncheckedValues; +} + //--------------------------------------------------------------------------- int vtkSMIdTypeVectorProperty::ReadXMLAttributes(vtkSMProxy* parent, vtkPVXMLElement* element) { diff --git a/ParaViewCore/ServerManager/Core/vtkSMIdTypeVectorProperty.h b/ParaViewCore/ServerManager/Core/vtkSMIdTypeVectorProperty.h index 691dcf5235294d8a2cb5aa0831b262b18ae017e6..da050698e31dcf0204b40cfe91c531a5a908f88e 100644 --- a/ParaViewCore/ServerManager/Core/vtkSMIdTypeVectorProperty.h +++ b/ParaViewCore/ServerManager/Core/vtkSMIdTypeVectorProperty.h @@ -28,6 +28,8 @@ #include "vtkPVServerManagerCoreModule.h" //needed for exports #include "vtkSMVectorProperty.h" +#include // for std::vector + class vtkSMStateLocator; class VTKPVSERVERMANAGERCORE_EXPORT vtkSMIdTypeVectorProperty : public vtkSMVectorProperty @@ -75,6 +77,24 @@ public: int SetUncheckedElements(const vtkIdType* values, unsigned int numValues); //@} + // typedef to circumvent wrapping issues. + typedef std::vector VectorOfIdTypes; + + //@{ + /** + * Get/Set elements (and unchecked elements) API using std::vector. + * The `Set` methods return 1 if the property was modified, otherwise 0. + * + * The `Get` methods take in an optional unused argument to disambiguate from + * variants that return `vtkIdType*`. + */ + int SetElements(const std::vector& values); + int SetUncheckedElements(const std::vector& values); + const VectorOfIdTypes& GetElements(const VectorOfIdTypes& notused = VectorOfIdTypes()) const; + const VectorOfIdTypes& GetUnCheckedElements( + const VectorOfIdTypes& notused = VectorOfIdTypes()) const; + //@} + /** * Set the value of 1st element. The vector is resized as necessary. * Returns 0 if Set fails either because the property is read only diff --git a/ParaViewCore/ServerManager/Core/vtkSMIntVectorProperty.cxx b/ParaViewCore/ServerManager/Core/vtkSMIntVectorProperty.cxx index 57d712c822a88246437bdee645f912afc27f7eb7..a59a31b6c078278e9dc51f868e876de6549d16e0 100644 --- a/ParaViewCore/ServerManager/Core/vtkSMIntVectorProperty.cxx +++ b/ParaViewCore/ServerManager/Core/vtkSMIntVectorProperty.cxx @@ -202,6 +202,32 @@ int vtkSMIntVectorProperty::SetUncheckedElements(const int* values, unsigned int return this->Internals->SetUncheckedElements(values, numValues); } +//--------------------------------------------------------------------------- +int vtkSMIntVectorProperty::SetElements(const std::vector& values) +{ + return this->Internals->SetElements( + values.size() > 0 ? &values[0] : nullptr, static_cast(values.size())); +} + +//--------------------------------------------------------------------------- +int vtkSMIntVectorProperty::SetUncheckedElements(const std::vector& values) +{ + return this->Internals->SetUncheckedElements( + values.size() > 0 ? &values[0] : nullptr, static_cast(values.size())); +} + +//--------------------------------------------------------------------------- +const std::vector& vtkSMIntVectorProperty::GetElements(const std::vector&) const +{ + return this->Internals->Values; +} + +//--------------------------------------------------------------------------- +const std::vector& vtkSMIntVectorProperty::GetUnCheckedElements(const std::vector&) const +{ + return this->Internals->UncheckedValues; +} + //--------------------------------------------------------------------------- int vtkSMIntVectorProperty::ReadXMLAttributes(vtkSMProxy* parent, vtkPVXMLElement* element) { diff --git a/ParaViewCore/ServerManager/Core/vtkSMIntVectorProperty.h b/ParaViewCore/ServerManager/Core/vtkSMIntVectorProperty.h index c3e541866cd65a545e45ee73985177ad9db5e19d..ffe68325deeb8afc01afb6e858c03c6ee55e29c9 100644 --- a/ParaViewCore/ServerManager/Core/vtkSMIntVectorProperty.h +++ b/ParaViewCore/ServerManager/Core/vtkSMIntVectorProperty.h @@ -28,6 +28,8 @@ #include "vtkPVServerManagerCoreModule.h" //needed for exports #include "vtkSMVectorProperty.h" +#include // needed for std::vector + class vtkSMStateLocator; class VTKPVSERVERMANAGERCORE_EXPORT vtkSMIntVectorProperty : public vtkSMVectorProperty @@ -77,6 +79,23 @@ public: int* GetUnCheckedElements(); //@} + // typedef to circumvent wrapping issues. + typedef std::vector VectorOfInt; + + //@{ + /** + * Get/Set elements (and unchecked elements) API using std::vector. + * The `Set` methods return 1 if the property was modified, otherwise 0. + * + * The `Get` methods take in an optional unused argument to disambiguate from + * variants that return `int*`. + */ + int SetElements(const std::vector& values); + int SetUncheckedElements(const std::vector& values); + const VectorOfInt& GetElements(const VectorOfInt& notused = VectorOfInt()) const; + const VectorOfInt& GetUnCheckedElements(const VectorOfInt& notused = VectorOfInt()) const; + //@} + /** * Set the value of 1st element. The vector is resized as necessary. * Returns 0 if Set fails either because the property is read only diff --git a/ParaViewCore/ServerManager/Core/vtkSMProperty.h b/ParaViewCore/ServerManager/Core/vtkSMProperty.h index f2641367281b43401fde818fdade02326d9fbf02..f516e7c715a75e3eec9c2f03b6b04b9774177953 100644 --- a/ParaViewCore/ServerManager/Core/vtkSMProperty.h +++ b/ParaViewCore/ServerManager/Core/vtkSMProperty.h @@ -335,65 +335,65 @@ public: * By default, all properties have "default" visibility. */ - vtkSetStringMacro(PanelVisibility) - //@} - - //@{ - /** - * Returns the panel visibility for the property. - */ - vtkGetStringMacro(PanelVisibility) - //@} - - //@{ - /** - * Sets the panel visibility to default if the current - * representation type matches \p representation. - */ - vtkSetStringMacro(PanelVisibilityDefaultForRepresentation) - //@} - - //@{ - /** - * Returns which representation type the property will be shown by - * default for. - */ - vtkGetStringMacro(PanelVisibilityDefaultForRepresentation) - //@} - - //@{ - /** - * Sets the name of the custom panel widget to use for the property. - */ - vtkSetStringMacro(PanelWidget) - //@} - - //@{ - /** - * Returns name of the panel widget for the property. - */ - vtkGetStringMacro(PanelWidget) - //@} - - //@{ - /** - * Sets the tracing of sub property of this property - */ - vtkSetStringMacro(DisableSubTrace) - //@} - - //@{ - /** - * Returns the tracing state of the properties of this property - */ - vtkGetStringMacro(DisableSubTrace) - //@} - - /** - * Copy all property values. This will copy both checked and unchecked values, - * if applicable. - */ - virtual void Copy(vtkSMProperty* src); + vtkSetStringMacro(PanelVisibility); + //@} + + //@{ + /** + * Returns the panel visibility for the property. + */ + vtkGetStringMacro(PanelVisibility); + //@} + + //@{ + /** + * Sets the panel visibility to default if the current + * representation type matches \p representation. + */ + vtkSetStringMacro(PanelVisibilityDefaultForRepresentation); + //@} + + //@{ + /** + * Returns which representation type the property will be shown by + * default for. + */ + vtkGetStringMacro(PanelVisibilityDefaultForRepresentation); + //@} + + //@{ + /** + * Sets the name of the custom panel widget to use for the property. + */ + vtkSetStringMacro(PanelWidget); + //@} + + //@{ + /** + * Returns name of the panel widget for the property. + */ + vtkGetStringMacro(PanelWidget); + //@} + + //@{ + /** + * Sets the tracing of sub property of this property + */ + vtkSetStringMacro(DisableSubTrace); + //@} + + //@{ + /** + * Returns the tracing state of the properties of this property + */ + vtkGetStringMacro(DisableSubTrace); + //@} + + /** + * Copy all property values. This will copy both checked and unchecked values, + * if applicable. + */ + virtual void Copy(vtkSMProperty* src); //@{ /** @@ -491,8 +491,10 @@ public: */ vtkSMProxy* GetParent(); - // Flag used to ignore property when building Proxy state for Undo/Redo state. - // The default value is false. + /** + * Flag used to ignore property when building Proxy state for Undo/Redo state. + * The default value is false. + */ virtual bool IsStateIgnored() { return this->StateIgnored; } /** @@ -693,8 +695,10 @@ private: vtkSMProperty(const vtkSMProperty&) = delete; void operator=(const vtkSMProperty&) = delete; - // Callback to fire vtkCommand::DomainModifiedEvent every time any of the - // domains change. + /** + * Callback to fire vtkCommand::DomainModifiedEvent every time any of the + * domains change. + */ void InvokeDomainModifiedEvent(); /** diff --git a/ParaViewCore/ServerManager/Core/vtkSMStringVectorProperty.cxx b/ParaViewCore/ServerManager/Core/vtkSMStringVectorProperty.cxx index a447e95681f56da8c9c1ecea920538557c5ce07d..8053d5a2c4b7460e5552c0872347c1bc4258bf11 100644 --- a/ParaViewCore/ServerManager/Core/vtkSMStringVectorProperty.cxx +++ b/ParaViewCore/ServerManager/Core/vtkSMStringVectorProperty.cxx @@ -20,7 +20,6 @@ #include "vtkSMMessage.h" #include "vtkSMStateLocator.h" #include "vtkSMVectorPropertyTemplate.h" -#include "vtkStdString.h" #include "vtkStringList.h" #include @@ -28,13 +27,13 @@ vtkStandardNewMacro(vtkSMStringVectorProperty); -class vtkSMStringVectorProperty::vtkInternals : public vtkSMVectorPropertyTemplate +class vtkSMStringVectorProperty::vtkInternals : public vtkSMVectorPropertyTemplate { public: std::vector ElementTypes; - vtkInternals(vtkSMStringVectorProperty* ivp) - : vtkSMVectorPropertyTemplate(ivp) + vtkInternals(vtkSMStringVectorProperty* svp) + : vtkSMVectorPropertyTemplate(svp) { } }; @@ -163,6 +162,19 @@ void vtkSMStringVectorProperty::GetUncheckedElements(vtkStringList* list) } } +//--------------------------------------------------------------------------- +const std::vector& vtkSMStringVectorProperty::GetElements( + const std::vector&) const +{ + return this->Internals->Values; +} + +//--------------------------------------------------------------------------- +const std::vector& vtkSMStringVectorProperty::GetUncheckedElements() const +{ + return this->Internals->UncheckedValues; +} + //--------------------------------------------------------------------------- const char* vtkSMStringVectorProperty::GetUncheckedElement(unsigned int idx) { @@ -183,7 +195,7 @@ void vtkSMStringVectorProperty::SetUncheckedElement(unsigned int idx, const char int vtkSMStringVectorProperty::SetElements(vtkStringList* list) { unsigned int count = static_cast(list->GetLength()); - vtkStdString* values = new vtkStdString[count + 1]; + std::string* values = new std::string[count + 1]; for (unsigned int cc = 0; cc < count; cc++) { values[cc] = list->GetString(cc) ? list->GetString(cc) : ""; @@ -197,7 +209,7 @@ int vtkSMStringVectorProperty::SetElements(vtkStringList* list) int vtkSMStringVectorProperty::SetUncheckedElements(vtkStringList* list) { unsigned int count = static_cast(list->GetLength()); - vtkStdString* values = new vtkStdString[count + 1]; + std::string* values = new std::string[count + 1]; for (unsigned int cc = 0; cc < count; cc++) { values[cc] = list->GetString(cc) ? list->GetString(cc) : ""; @@ -210,7 +222,7 @@ int vtkSMStringVectorProperty::SetUncheckedElements(vtkStringList* list) //--------------------------------------------------------------------------- int vtkSMStringVectorProperty::SetElements(const char* values[], unsigned int count) { - vtkStdString* std_values = new vtkStdString[count + 1]; + std::string* std_values = new std::string[count + 1]; for (unsigned int cc = 0; cc < count; cc++) { std_values[cc] = values[cc] ? values[cc] : ""; @@ -223,15 +235,14 @@ int vtkSMStringVectorProperty::SetElements(const char* values[], unsigned int co //--------------------------------------------------------------------------- int vtkSMStringVectorProperty::SetElements(const std::vector& values) { - std::vector svalues(values.size() + 1); - std::copy(values.begin(), values.end(), svalues.begin()); - return this->Internals->SetElements(&svalues[0], static_cast(values.size())); + return this->Internals->SetElements( + values.size() > 0 ? &values[0] : nullptr, static_cast(values.size())); } //--------------------------------------------------------------------------- int vtkSMStringVectorProperty::SetUncheckedElements(const char* values[], unsigned int count) { - vtkStdString* std_values = new vtkStdString[count + 1]; + std::string* std_values = new std::string[count + 1]; for (unsigned int cc = 0; cc < count; cc++) { std_values[cc] = values[cc] ? values[cc] : ""; @@ -244,10 +255,8 @@ int vtkSMStringVectorProperty::SetUncheckedElements(const char* values[], unsign //--------------------------------------------------------------------------- int vtkSMStringVectorProperty::SetUncheckedElements(const std::vector& values) { - std::vector svalues(values.size() + 1); - std::copy(values.begin(), values.end(), svalues.begin()); return this->Internals->SetUncheckedElements( - &svalues[0], static_cast(values.size())); + values.size() > 0 ? &values[0] : nullptr, static_cast(values.size())); } //--------------------------------------------------------------------------- @@ -316,18 +325,18 @@ int vtkSMStringVectorProperty::ReadXMLAttributes(vtkSMProxy* proxy, vtkPVXMLElem const char* delimiter = element->GetAttribute("default_values_delimiter"); if (tmp && delimiter) { - vtkStdString initVal = tmp; - vtkStdString delim = delimiter; - vtkStdString::size_type pos1 = 0; - vtkStdString::size_type pos2 = 0; - for (int i = 0; i < numEls && pos2 != vtkStdString::npos; i++) + std::string initVal = tmp; + std::string delim = delimiter; + std::string::size_type pos1 = 0; + std::string::size_type pos2 = 0; + for (int i = 0; i < numEls && pos2 != std::string::npos; i++) { if (i != 0) { pos1 += delim.size(); } pos2 = initVal.find(delimiter, pos1); - vtkStdString v = pos1 == pos2 ? "" : initVal.substr(pos1, pos2 - pos1); + std::string v = pos1 == pos2 ? "" : initVal.substr(pos1, pos2 - pos1); this->Internals->DefaultValues.push_back(v); this->Internals->DefaultsValid = true; this->SetElement(i, v.c_str()); diff --git a/ParaViewCore/ServerManager/Core/vtkSMStringVectorProperty.h b/ParaViewCore/ServerManager/Core/vtkSMStringVectorProperty.h index 7d45d24b99bdc58b1a8749d12fe21f0636533b67..0a53831e10e10b988f3d17e3b9aa06c7330c0e0d 100644 --- a/ParaViewCore/ServerManager/Core/vtkSMStringVectorProperty.h +++ b/ParaViewCore/ServerManager/Core/vtkSMStringVectorProperty.h @@ -100,6 +100,22 @@ public: */ unsigned int GetElementIndex(const char* value, int& exists); + // typedef to circumvent wrapping issues. + typedef std::vector VectorOfStrings; + + /** + * Returns values as a std::vector. + * + * The optional argument is only for consistency with other + * vtkSMVectorProperty subclasses. + */ + const VectorOfStrings& GetElements(const VectorOfStrings& notused = VectorOfStrings()) const; + + /** + * Returns unchecked values as a std::vector. + */ + const std::vector& GetUncheckedElements() const; + //@{ /** * Set the cast type used when passing a value to the stream.