ParaView
vtkSMRangeDomainTemplate.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkSMRangeDomainTemplate.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
53 #ifndef vtkSMRangeDomainTemplate_h
54 #define vtkSMRangeDomainTemplate_h
55 
56 #include "vtkPVServerManagerCoreModule.h" //needed for exports
57 #include "vtkSMDomain.h"
58 #include "vtkTuple.h" // needed for vtkTuple.
59 #include <vector> // needed for std::vector
60 
61 template <class T>
62 class VTKPVSERVERMANAGERCORE_EXPORT vtkSMRangeDomainTemplate : public vtkSMDomain
63 {
64 public:
66  void PrintSelf(ostream& os, vtkIndent indent);
67 
73  virtual int IsInDomain(vtkSMProperty* property);
74 
80  bool IsInDomain(unsigned int idx, T val);
81 
87  T GetMinimum(unsigned int idx, int& exists);
88 
94  T GetMaximum(unsigned int idx, int& exists);
95 
97 
100  bool GetMinimumExists(unsigned int idx);
101  bool GetMaximumExists(unsigned int idx);
103 
109  T GetMinimum(unsigned int idx)
110  {
111  int not_used;
112  return this->GetMinimum(idx, not_used);
113  }
114  T GetMaximum(unsigned int idx)
115  {
116  int not_used;
117  return this->GetMaximum(idx, not_used);
118  }
119 
126  unsigned int GetNumberOfEntries();
127 
132  virtual void Update(vtkSMProperty*);
133 
137  virtual void SetAnimationValue(vtkSMProperty* property, int idx, double value);
138 
140  {
143  MID
144  };
145 
149  DefaultModes GetDefaultMode(unsigned int index = 0);
150 
155  virtual int SetDefaultValues(vtkSMProperty*, bool use_unchecked_values);
156 
157 protected:
160 
165  virtual int ReadXMLAttributes(vtkSMProperty* prop, vtkPVXMLElement* element);
166 
167  struct vtkEntry
168  {
169  vtkTuple<T, 2> Value;
170  vtkTuple<bool, 2> Valid;
172  {
173  this->Value[0] = this->Value[1] = 0;
174  this->Valid[0] = this->Valid[1] = false;
175  }
176  vtkEntry(T min, bool minValid, T max, bool maxValid)
177  {
178  this->Value[0] = min;
179  this->Value[1] = max;
180  this->Valid[0] = minValid;
181  this->Valid[1] = maxValid;
182  }
183  vtkEntry(T min, T max)
184  {
185  this->Value[0] = min;
186  this->Value[1] = max;
187  this->Valid[0] = this->Valid[1] = true;
188  }
189 
190  bool operator==(const vtkEntry& other) const
191  {
192  return this->Valid == other.Valid && this->Value == other.Value;
193  }
194  };
195 
196  // We keep Entries private so we can carefully manage firing the modified
197  // events since subclasses can often forget the minutia.
198  const std::vector<vtkEntry>& GetEntries() const { return this->Entries; }
199  void SetEntries(const std::vector<vtkEntry>& new_value)
200  {
201  typedef typename std::vector<vtkEntry>::const_iterator cit;
202  cit b = this->Entries.begin();
203  cit e = this->Entries.end();
204  if (this->Entries.size() != new_value.size() || !std::equal(b, e, new_value.begin()))
205  {
206  this->Entries = new_value;
207  this->DomainModified();
208  }
209  }
210  std::vector<DefaultModes> DefaultModeVector;
212 
213 private:
214  vtkSMRangeDomainTemplate(const vtkSMRangeDomainTemplate&) VTK_DELETE_FUNCTION;
215  void operator=(const vtkSMRangeDomainTemplate&) VTK_DELETE_FUNCTION;
216 
217  bool GetComputedDefaultValue(unsigned int index, T& value);
218 
219  std::vector<vtkEntry> Entries;
220 };
221 
222 #if !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
223 #define VTK_SM_RANGE_DOMAIN_TEMPLATE_INSTANTIATE(T) \
224  template class VTKPVSERVERMANAGERCORE_EXPORT vtkSMRangeDomainTemplate<T>
225 #else
226 #include "vtkSMRangeDomainTemplate.txx" // needed for templates.
227 #define VTK_SM_RANGE_DOMAIN_TEMPLATE_INSTANTIATE(T)
228 #endif // !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
229 
230 #endif // !defined(vtkSMRangeDomainTemplate_h)
231 
232 // This portion must be OUTSIDE the include blockers. Each
233 // vtkSMRangeDomainTemplate subclass uses this to give its instantiation
234 // of this template a DLL interface.
235 #if defined(VTK_SM_RANGE_DOMAIN_TEMPLATE_TYPE)
236 #if defined(VTK_BUILD_SHARED_LIBS) && defined(_MSC_VER)
237 #pragma warning(push)
238 #pragma warning(disable : 4091) // warning C4091: 'extern ' :
239  // ignored on left of 'int' when no variable is declared
240 #pragma warning(disable : 4231) // Compiler-specific extension warning.
241 // Use an "extern explicit instantiation" to give the class a DLL
242 // interface. This is a compiler-specific extension.
243 extern VTK_SM_RANGE_DOMAIN_TEMPLATE_INSTANTIATE(VTK_SM_RANGE_DOMAIN_TEMPLATE_TYPE);
244 #pragma warning(pop)
245 #endif
246 #undef VTK_SM_RANGE_DOMAIN_TEMPLATE_TYPE
247 #endif
248 
249 // VTK-HeaderTest-Exclude: vtkSMRangeDomainTemplate.h
superclass for type-specific range domains i.e.
virtual void SetAnimationValue(vtkSMProperty *, int vtkNotUsed(index), double vtkNotUsed(value))
Set the value of an element of a property from the animation editor.
Definition: vtkSMDomain.h:70
virtual void Update(vtkSMProperty *requestingProperty)
Update self based on the "unchecked" values of all required properties.
Definition: vtkSMDomain.h:65
virtual int IsInDomain(vtkSMProperty *property)=0
Is the (unchecked) value of the property in the domain? Overwritten by sub-classes.
superclass for all SM properties
virtual int SetDefaultValues(vtkSMProperty *, bool vtkNotUsed(use_unchecked_values))
A vtkSMProperty is often defined with a default value in the XML itself.
Definition: vtkSMDomain.h:85
represents the possible values a property can have
Definition: vtkSMDomain.h:48
#define VTK_SM_RANGE_DOMAIN_TEMPLATE_INSTANTIATE(T)
virtual int ReadXMLAttributes(vtkSMProperty *prop, vtkPVXMLElement *elem)
Set the appropriate ivars from the xml element.
std::vector< DefaultModes > DefaultModeVector
bool operator==(const vtkEntry &other) const
vtkEntry(T min, bool minValid, T max, bool maxValid)
const std::vector< vtkEntry > & GetEntries() const
void SetEntries(const std::vector< vtkEntry > &new_value)
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
void PrintSelf(ostream &os, vtkIndent indent)
T GetMinimum(unsigned int idx)
Returns the minimum/maximum value, is exists, otherwise 0 is returned.