vtkSMRangeDomainTemplate.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
43 #ifndef vtkSMRangeDomainTemplate_h
44 #define vtkSMRangeDomainTemplate_h
45 
46 #include "vtkRemotingServerManagerModule.h" //needed for exports
47 #include "vtkSMDomain.h"
48 #include "vtkTuple.h" // needed for vtkTuple.
49 #include <vector> // needed for std::vector
50 
51 template <class T>
53 {
54 public:
56  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
63  int IsInDomain(vtkSMProperty* property) override;
64 
70  bool IsInDomain(unsigned int idx, T val);
71 
77  T GetMinimum(unsigned int idx, int& exists);
78 
84  T GetMaximum(unsigned int idx, int& exists);
85 
90  int GetResolution();
91 
93 
96  bool GetMinimumExists(unsigned int idx);
97  bool GetMaximumExists(unsigned int idx);
99 
103  bool GetResolutionExists();
104 
110  T GetMinimum(unsigned int idx)
111  {
112  int not_used;
113  return this->GetMinimum(idx, not_used);
114  }
115  T GetMaximum(unsigned int idx)
116  {
117  int not_used;
118  return this->GetMaximum(idx, not_used);
119  }
120 
127  unsigned int GetNumberOfEntries();
128 
133  void Update(vtkSMProperty*) override;
134 
138  void SetAnimationValue(vtkSMProperty* property, int idx, double value) override;
139 
141  {
144  MID
145  };
146 
150  DefaultModes GetDefaultMode(unsigned int index = 0);
151 
156  int SetDefaultValues(vtkSMProperty*, bool use_unchecked_values) override;
157 
158 protected:
160  ~vtkSMRangeDomainTemplate() override;
161 
166  int ReadXMLAttributes(vtkSMProperty* prop, vtkPVXMLElement* element) override;
167 
168  struct vtkEntry
169  {
173  {
174  this->Value[0] = this->Value[1] = 0;
175  this->Valid[0] = this->Valid[1] = false;
176  }
177  vtkEntry(T min, bool minValid, T max, bool maxValid)
178  {
179  this->Value[0] = min;
180  this->Value[1] = max;
181  this->Valid[0] = minValid;
182  this->Valid[1] = maxValid;
183  }
184  vtkEntry(T min, T max)
185  {
186  this->Value[0] = min;
187  this->Value[1] = max;
188  this->Valid[0] = this->Valid[1] = true;
189  }
190 
191  bool operator==(const vtkEntry& other) const
192  {
193  return this->Valid == other.Valid && this->Value == other.Value;
194  }
195  };
196 
197  // We keep Entries private so we can carefully manage firing the modified
198  // events since subclasses can often forget the minutia.
199  const std::vector<vtkEntry>& GetEntries() const { return this->Entries; }
200  void SetEntries(const std::vector<vtkEntry>& new_value)
201  {
202  typedef typename std::vector<vtkEntry>::const_iterator cit;
203  cit b = this->Entries.begin();
204  cit e = this->Entries.end();
205  if (this->Entries.size() != new_value.size() || !std::equal(b, e, new_value.begin()))
206  {
207  this->Entries = new_value;
208  this->DomainModified();
209  }
210  }
211  std::vector<DefaultModes> DefaultModeVector;
213 
218 
219 private:
221  void operator=(const vtkSMRangeDomainTemplate&) = delete;
222 
223  bool GetComputedDefaultValue(unsigned int index, T& value);
224 
225  std::vector<vtkEntry> Entries;
226 };
227 
228 #if !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
229 #define VTK_SM_RANGE_DOMAIN_TEMPLATE_INSTANTIATE(T) \
230  template class VTKREMOTINGSERVERMANAGER_EXPORT vtkSMRangeDomainTemplate<T>
231 #else
232 #include "vtkSMRangeDomainTemplate.txx" // needed for templates.
233 #define VTK_SM_RANGE_DOMAIN_TEMPLATE_INSTANTIATE(T)
234 #endif // !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
235 
236 #endif // !defined(vtkSMRangeDomainTemplate_h)
237 
238 // This portion must be OUTSIDE the include blockers. Each
239 // vtkSMRangeDomainTemplate subclass uses this to give its instantiation
240 // of this template a DLL interface.
241 #if defined(VTK_SM_RANGE_DOMAIN_TEMPLATE_TYPE)
242 #if defined(VTK_BUILD_SHARED_LIBS) && defined(_MSC_VER)
243 #pragma warning(push)
244 #pragma warning(disable : 4091) // warning C4091: 'extern ' :
245  // ignored on left of 'int' when no variable is declared
246 #pragma warning(disable : 4231) // Compiler-specific extension warning.
247 // Use an "extern explicit instantiation" to give the class a DLL
248 // interface. This is a compiler-specific extension.
249 extern VTK_SM_RANGE_DOMAIN_TEMPLATE_INSTANTIATE(VTK_SM_RANGE_DOMAIN_TEMPLATE_TYPE);
250 #pragma warning(pop)
251 #endif
252 #undef VTK_SM_RANGE_DOMAIN_TEMPLATE_TYPE
253 #endif
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:76
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:91
int Resolution
Resolution is the number of steps in the values list.
represents the possible values a property can have
Definition: vtkSMDomain.h:37
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:64
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.