/usr/include/paraview/vtkSMPropertyHelper.h is in paraview-dev 5.0.1+dfsg1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | /*=========================================================================
Program: ParaView
Module: vtkSMPropertyHelper.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.
=========================================================================*/
/*
* Copyright (c) 2007, Sandia Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Sandia Corporation nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Sandia Corporation ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Sandia Corporation BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// .NAME vtkSMPropertyHelper - helper class to get/set property values.
// .SECTION Description
// vtkSMPropertyHelper is a helper class to get/set property values in a type
// independent fashion.
// eg.
// \code
// vtkSMPropertyHelper(proxy, "Visibility").Set(0);
// vtkSMPropertyHelper(proxy, "Input").Set(inputProxy, 0);
//
// double center[3] = {...};
// vtkSMPropertyHelper(proxy, "Center").Set(center, 3);
// \endcode
// .SECTION Caveat
// This class is not wrapped, hence not available in any of the wrapped
// languagues such as python.
#ifndef vtkSMPropertyHelper_h
#define vtkSMPropertyHelper_h
#include "vtkPVServerManagerCoreModule.h" //needed for exports
#include "vtkSMObject.h"
#include "vtkVariant.h"
#include <vector>
#ifdef INT
#undef INT
#endif
#ifdef DOUBLE
#undef DOUBLE
#endif
#ifdef NONE
#undef NONE
#endif
class vtkSMProperty;
class vtkSMProxy;
class vtkSMVectorProperty;
class vtkSMIntVectorProperty;
class vtkSMDoubleVectorProperty;
class vtkSMIdTypeVectorProperty;
class vtkSMStringVectorProperty;
class vtkSMProxyProperty;
class vtkSMInputProperty;
class VTKPVSERVERMANAGERCORE_EXPORT vtkSMPropertyHelper
{
public:
// Description:
// If quiet is true, then no errors or warning are raised if the property is
// missing or of incorrect type.
vtkSMPropertyHelper(vtkSMProxy* proxy, const char* name, bool quiet=false);
vtkSMPropertyHelper(vtkSMProperty *property, bool quiet = false);
~vtkSMPropertyHelper();
// Description:
// Updates the property value by fetching the value from the server. This only
// works for properties with \c InformationOnly attribute set to 1. For all
// other properties, this has no effect.
void UpdateValueFromServer();
// Description:
// Set the number of elements in the property. For vtkSMProxyProperty, this is
// equivalent to SetNumberOfProxies().
void SetNumberOfElements(unsigned int elems);
// Description:
// Get the number of elements in the property.
// For vtkSMProxyProperty, this is equivalent to GetNumberOfProxies().
unsigned int GetNumberOfElements() const;
// Description:
// Equivalent to SetNumberOfElements(0).
void RemoveAllValues() { this->SetNumberOfElements(0); }
// Description:
// Get value as a variant.
vtkVariant GetAsVariant(unsigned int index);
// Description:
// Templated method to call GetIntArray(), GetDoubleArray(), GetIdTypeArray().
// Note, we only provide implementations for T==double, int, vtkIdType.
template <class T>
std::vector<T> GetArray();
// Description:
// Templated method to call GetAsInt(), GetAsDouble(), GetAsIdType()
// Note, we only provide implementations for T==double, int, vtkIdType.
template <class T>
T GetAs(unsigned int index=0);
// Description:
// Set/Get methods with \c int API. Calling these method on
// vtkSMStringVectorProperty or vtkSMProxyProperty will raise errors.
void Set(int value)
{ this->Set(0, value); }
void Set(unsigned int index, int value);
void Set(const int* values, unsigned int count);
int GetAsInt(unsigned int index = 0);
unsigned int Get(int* values, unsigned int count = 1);
std::vector<int> GetIntArray();
// Description:
// Set/Get methods with \c double API. Calling these method on
// vtkSMStringVectorProperty or vtkSMProxyProperty will raise errors.
void Set(double value)
{ this->Set(0, value); }
void Set(unsigned int index, double value);
void Set(const double* values, unsigned int count);
double GetAsDouble(unsigned int index = 0);
unsigned int Get(double* values, unsigned int count = 1);
std::vector<double> GetDoubleArray();
#if VTK_SIZEOF_ID_TYPE != VTK_SIZEOF_INT
// Description:
// Set/Get methods with \c vtkIdType API. Calling these method on
// vtkSMStringVectorProperty or vtkSMProxyProperty will raise errors.
void Set(vtkIdType value)
{ this->Set(0, value); }
void Set(unsigned int index, vtkIdType value);
void Set(const vtkIdType* values, unsigned int count);
unsigned int Get(vtkIdType* values, unsigned int count = 1);
#endif
vtkIdType GetAsIdType(unsigned int index = 0);
std::vector<vtkIdType> GetIdTypeArray();
// Description:
// Set/Get methods for vtkSMStringVectorProperty. Calling these methods on any
// other type of property will raise errors.
// These overloads can be used for vtkSMIntVectorProperty with an enumeration
// domain as well, in which case the string-to-int (and vice-versa)
// translations are done internally.
void Set(const char* value)
{ this->Set(0, value); }
void Set(unsigned int index, const char* value);
const char* GetAsString(unsigned int index = 0);
// Description:
// Set/Get methods for vtkSMProxyProperty or vtkSMInputProperty.
// Calling these methods on any other type of property will raise errors.
// The option \c outputport(s) argument is used only for vtkSMInputProperty.
void Set(vtkSMProxy* value, unsigned int outputport=0)
{ this->Set(0, value, outputport); }
void Set(unsigned int index, vtkSMProxy* value, unsigned int outputport=0);
void Set(vtkSMProxy** value, unsigned int count, unsigned int *outputports=NULL);
void Add(vtkSMProxy* value, unsigned int outputport=0);
void Remove(vtkSMProxy* value);
vtkSMProxy* GetAsProxy(unsigned int index=0);
unsigned int GetOutputPort(unsigned int index=0);
// Description:
// This API is useful for setting values on vtkSMStringVectorProperty that is
// used for status where the first value is the name of the array (for
// example) and the second value is it's status.
void SetStatus(const char* key, int value);
int GetStatus(const char* key, int default_value=0);
// Description:
// This API is useful for setting values on vtkSMStringVectorProperty that is
// used for status where the first value is the name of the array (for
// example) and the second value is it's status.
void SetStatus(const char* key, double *values, int num_values);
bool GetStatus(const char* key, double *values, int num_values);
// Description:
// This API is useful for setting values on vtkSMStringVectorProperty that is
// used for status where the first value is the name of the array (for
// example) and the second value is it's status (as a string)
void SetStatus(const char* key, const char* value);
const char* GetStatus(const char* key, const char* default_value);
// Description:
// For vtkSMStringVectorProperty that is used to setting input array to
// process on algorithms, this provides a convenient API to get/set the
// values.
void SetInputArrayToProcess(int fieldAssociation, const char* arrayName);
int GetInputArrayAssociation();
const char* GetInputArrayNameToProcess();
// Description:
// Get/Set whether to use unchecked properties.
void SetUseUnchecked(bool val) { this->UseUnchecked = val; }
bool GetUseUnchecked() { return this->UseUnchecked; }
protected:
void setUseUnchecked(bool useUnchecked) { this->UseUnchecked = useUnchecked; }
//BTX
private:
vtkSMPropertyHelper(const vtkSMPropertyHelper&); // Not implemented
void operator=(const vtkSMPropertyHelper&); // Not implemented
void Initialize(vtkSMProperty *property);
template<typename T> T GetProperty(unsigned int index) const;
template<typename T> std::vector<T> GetPropertyArray() const;
template<typename T> unsigned int GetPropertyArray(T *values, unsigned int count = 1);
template<typename T> void SetProperty(unsigned int index, T value);
template<typename T> void SetPropertyArray(const T *values, unsigned int count);
void SetPropertyArrayIdType(const vtkIdType *values, unsigned int count);
enum PType {
INT,
DOUBLE,
IDTYPE,
STRING,
PROXY,
INPUT,
NONE
};
bool Quiet;
bool UseUnchecked;
vtkSMProxy* Proxy;
PType Type;
union
{
vtkSMProperty *Property;
vtkSMVectorProperty *VectorProperty;
vtkSMIntVectorProperty *IntVectorProperty;
vtkSMDoubleVectorProperty *DoubleVectorProperty;
vtkSMIdTypeVectorProperty *IdTypeVectorProperty;
vtkSMStringVectorProperty *StringVectorProperty;
vtkSMProxyProperty *ProxyProperty;
vtkSMInputProperty *InputProperty;
};
//ETX
};
template<>
inline std::vector<int> vtkSMPropertyHelper::GetArray()
{
return this->GetIntArray();
}
template<>
inline std::vector<double> vtkSMPropertyHelper::GetArray()
{
return this->GetDoubleArray();
}
#if VTK_SIZEOF_ID_TYPE != VTK_SIZEOF_INT
template<>
inline std::vector<vtkIdType> vtkSMPropertyHelper::GetArray()
{
return this->GetIdTypeArray();
}
#endif
template<>
inline int vtkSMPropertyHelper::GetAs(unsigned int index)
{
return this->GetAsInt(index);
}
template<>
inline double vtkSMPropertyHelper::GetAs(unsigned int index)
{
return this->GetAsDouble(index);
}
#if VTK_SIZEOF_ID_TYPE != VTK_SIZEOF_INT
template<>
inline vtkIdType vtkSMPropertyHelper::GetAs(unsigned int index)
{
return this->GetAsIdType(index);
}
#endif
#endif
// VTK-HeaderTest-Exclude: vtkSMPropertyHelper.h
|