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 =========================================================================*/
55 #ifndef vtkSMRangeDomainTemplate_h
56 #define vtkSMRangeDomainTemplate_h
57 
58 #include "vtkRemotingServerManagerModule.h" //needed for exports
59 #include "vtkSMDomain.h"
60 #include "vtkTuple.h" // needed for vtkTuple.
61 #include <vector> // needed for std::vector
62 
63 template <class T>
65 {
66 public:
68  void PrintSelf(ostream& os, vtkIndent indent) override;
69 
75  int IsInDomain(vtkSMProperty* property) override;
76 
82  bool IsInDomain(unsigned int idx, T val);
83 
89  T GetMinimum(unsigned int idx, int& exists);
90 
96  T GetMaximum(unsigned int idx, int& exists);
97 
102  int GetResolution();
103 
105 
108  bool GetMinimumExists(unsigned int idx);
109  bool GetMaximumExists(unsigned int idx);
111 
115  bool GetResolutionExists();
116 
122  T GetMinimum(unsigned int idx)
123  {
124  int not_used;
125  return this->GetMinimum(idx, not_used);
126  }
127  T GetMaximum(unsigned int idx)
128  {
129  int not_used;
130  return this->GetMaximum(idx, not_used);
131  }
132 
139  unsigned int GetNumberOfEntries();
140 
145  void Update(vtkSMProperty*) override;
146 
150  void SetAnimationValue(vtkSMProperty* property, int idx, double value) override;
151 
153  {
156  MID
157  };
158 
162  DefaultModes GetDefaultMode(unsigned int index = 0);
163 
168  int SetDefaultValues(vtkSMProperty*, bool use_unchecked_values) override;
169 
170 protected:
172  ~vtkSMRangeDomainTemplate() override;
173 
178  int ReadXMLAttributes(vtkSMProperty* prop, vtkPVXMLElement* element) override;
179 
180  struct vtkEntry
181  {
185  {
186  this->Value[0] = this->Value[1] = 0;
187  this->Valid[0] = this->Valid[1] = false;
188  }
189  vtkEntry(T min, bool minValid, T max, bool maxValid)
190  {
191  this->Value[0] = min;
192  this->Value[1] = max;
193  this->Valid[0] = minValid;
194  this->Valid[1] = maxValid;
195  }
196  vtkEntry(T min, T max)
197  {
198  this->Value[0] = min;
199  this->Value[1] = max;
200  this->Valid[0] = this->Valid[1] = true;
201  }
202 
203  bool operator==(const vtkEntry& other) const
204  {
205  return this->Valid == other.Valid && this->Value == other.Value;
206  }
207  };
208 
209  // We keep Entries private so we can carefully manage firing the modified
210  // events since subclasses can often forget the minutia.
211  const std::vector<vtkEntry>& GetEntries() const { return this->Entries; }
212  void SetEntries(const std::vector<vtkEntry>& new_value)
213  {
214  typedef typename std::vector<vtkEntry>::const_iterator cit;
215  cit b = this->Entries.begin();
216  cit e = this->Entries.end();
217  if (this->Entries.size() != new_value.size() || !std::equal(b, e, new_value.begin()))
218  {
219  this->Entries = new_value;
220  this->DomainModified();
221  }
222  }
223  std::vector<DefaultModes> DefaultModeVector;
225 
230 
231 private:
233  void operator=(const vtkSMRangeDomainTemplate&) = delete;
234 
235  bool GetComputedDefaultValue(unsigned int index, T& value);
236 
237  std::vector<vtkEntry> Entries;
238 };
239 
240 #if !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
241 #define VTK_SM_RANGE_DOMAIN_TEMPLATE_INSTANTIATE(T) \
242  template class VTKREMOTINGSERVERMANAGER_EXPORT vtkSMRangeDomainTemplate<T>
243 #else
244 #include "vtkSMRangeDomainTemplate.txx" // needed for templates.
245 #define VTK_SM_RANGE_DOMAIN_TEMPLATE_INSTANTIATE(T)
246 #endif // !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
247 
248 #endif // !defined(vtkSMRangeDomainTemplate_h)
249 
250 // This portion must be OUTSIDE the include blockers. Each
251 // vtkSMRangeDomainTemplate subclass uses this to give its instantiation
252 // of this template a DLL interface.
253 #if defined(VTK_SM_RANGE_DOMAIN_TEMPLATE_TYPE)
254 #if defined(VTK_BUILD_SHARED_LIBS) && defined(_MSC_VER)
255 #pragma warning(push)
256 #pragma warning(disable : 4091) // warning C4091: 'extern ' :
257  // ignored on left of 'int' when no variable is declared
258 #pragma warning(disable : 4231) // Compiler-specific extension warning.
259 // Use an "extern explicit instantiation" to give the class a DLL
260 // interface. This is a compiler-specific extension.
261 extern VTK_SM_RANGE_DOMAIN_TEMPLATE_INSTANTIATE(VTK_SM_RANGE_DOMAIN_TEMPLATE_TYPE);
262 #pragma warning(pop)
263 #endif
264 #undef VTK_SM_RANGE_DOMAIN_TEMPLATE_TYPE
265 #endif
266 
267 // VTK-HeaderTest-Exclude: vtkSMRangeDomainTemplate.h
superclass for type-specific range domains i.e.
#define VTKREMOTINGSERVERMANAGER_EXPORT
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:88
virtual void Update(vtkSMProperty *requestingProperty)
Update self based on the "unchecked" values of all required properties.
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:103
int Resolution
Resolution is the number of steps in the values list.
represents the possible values a property can have
Definition: vtkSMDomain.h:49
void PrintSelf(ostream &os, vtkIndent indent) override
#define VTK_SM_RANGE_DOMAIN_TEMPLATE_INSTANTIATE(T)
virtual int ReadXMLAttributes(vtkSMProperty *prop, vtkPVXMLElement *elem)
Set the appropriate ivars from the xml element.
virtual int IsInDomain(vtkSMProperty *vtkNotUsed(property))
Is the (unchecked) value of the property in the domain? Overwritten by sub-classes.
Definition: vtkSMDomain.h:76
std::vector< DefaultModes > DefaultModeVector
bool operator==(const vtkEntry &other) const
vtkEntry(T min, bool minValid, T max, bool maxValid)
value
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.
T GetMinimum(unsigned int idx)
Returns the minimum/maximum value, is exists, otherwise 0 is returned.