vtkSMTransferFunctionProxy.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
12 #ifndef vtkSMTransferFunctionProxy_h
13 #define vtkSMTransferFunctionProxy_h
14 
15 #include "vtkRemotingViewsModule.h" // needed for export macro
16 #include "vtkSMProxy.h"
17 #include "vtkSmartPointer.h" // for ivars
18 #include "vtkTable.h" // for vtkTable
19 
20 #include <vtk_jsoncpp_fwd.h> // for forward declarations
21 
22 // Forward declarations
24 
26 {
27 public:
30  void PrintSelf(ostream& os, vtkIndent indent) override;
31 
38  virtual bool RescaleTransferFunction(const double range[2], bool extend = false)
39  {
40  return this->RescaleTransferFunction(range[0], range[1], extend);
41  }
42  virtual bool RescaleTransferFunction(double rangeMin, double rangeMax, bool extend = false);
43 
45 
49  static bool RescaleTransferFunction(
50  vtkSMProxy* proxy, double rangeMin, double rangeMax, bool extend = false);
51  static bool RescaleTransferFunction(vtkSMProxy* proxy, const double range[2], bool extend = false)
52  {
53  return vtkSMTransferFunctionProxy::RescaleTransferFunction(proxy, range[0], range[1], extend);
54  }
56 
58 
63  virtual bool RescaleTransferFunctionToDataRange(bool extend = false);
64  static bool RescaleTransferFunctionToDataRange(vtkSMProxy* proxy, bool extend = false)
65  {
67  return self ? self->RescaleTransferFunctionToDataRange(extend) : false;
68  }
70 
74  virtual bool InvertTransferFunction();
75 
80  static bool InvertTransferFunction(vtkSMProxy*);
81 
89  virtual bool MapControlPointsToLogSpace(bool inverse = false);
90  virtual bool MapControlPointsToLinearSpace() { return this->MapControlPointsToLogSpace(true); }
91 
93 
97  static bool MapControlPointsToLogSpace(vtkSMProxy* proxy, bool inverse = false)
98  {
100  return self ? self->MapControlPointsToLogSpace(inverse) : false;
101  }
103 
109  {
111  }
112 
114 
122  virtual bool ApplyPreset(const Json::Value& value, bool rescale = true);
123  static bool ApplyPreset(vtkSMProxy* proxy, const Json::Value& value, bool rescale = true)
124  {
126  return self ? self->ApplyPreset(value, rescale) : false;
127  }
129 
130  virtual bool ApplyPreset(const char* presetname, bool rescale = true);
131  static bool ApplyPreset(vtkSMProxy* proxy, const char* presetname, bool rescale = true)
132  {
134  return self ? self->ApplyPreset(presetname, rescale) : false;
135  }
136 
138 
142  virtual Json::Value GetStateAsPreset();
143  static Json::Value GetStateAsPreset(vtkSMProxy* proxy);
145 
147 
152  virtual bool ApplyColorMap(const char* text);
153  virtual bool ApplyColorMap(vtkPVXMLElement* xml);
155 
157 
161  static bool ApplyColorMap(vtkSMProxy* proxy, const char* text)
162  {
164  return self ? self->ApplyColorMap(text) : false;
165  }
167 
169 
173  static bool ApplyColorMap(vtkSMProxy* proxy, vtkPVXMLElement* xml)
174  {
176  return self ? self->ApplyColorMap(xml) : false;
177  }
179 
184  virtual bool SaveColorMap(vtkPVXMLElement* xml);
185 
187 
191  static bool SaveColorMap(vtkSMProxy* proxy, vtkPVXMLElement* xml)
192  {
194  return self ? self->SaveColorMap(xml) : false;
195  }
197 
203  virtual bool IsScalarBarVisible(vtkSMProxy* view);
204 
206 
210  static bool IsScalarBarVisible(vtkSMProxy* proxy, vtkSMProxy* view)
211  {
213  return self ? self->IsScalarBarVisible(view) : false;
214  }
216 
222  virtual vtkSMProxy* FindScalarBarRepresentation(vtkSMProxy* view);
223 
225 
230  {
232  return self ? self->FindScalarBarRepresentation(view) : nullptr;
233  }
235 
237 
242  virtual bool UpdateScalarBarsComponentTitle(vtkPVArrayInformation* arrayInfo);
244  {
246  return self ? self->UpdateScalarBarsComponentTitle(arrayInfo) : false;
247  }
249 
251 
256  virtual bool ComputeDataRange(double range[2]);
257  static bool ComputeDataRange(vtkSMProxy* proxy, double range[2])
258  {
260  return self ? self->ComputeDataRange(range) : false;
261  }
263 
265 
272  virtual vtkTable* ComputeDataHistogramTable(int numberOfBins);
273  static vtkTable* ComputeDataHistogramTable(vtkSMProxy* proxy, int numberOfBins)
274  {
276  return self ? self->ComputeDataHistogramTable(numberOfBins) : nullptr;
277  }
279 
281 
285  virtual vtkTable* GetHistogramTableCache() { return this->HistogramTableCache; }
287  {
289  return self ? self->GetHistogramTableCache() : nullptr;
290  }
292 
293  // Helper method to compute the active annotated values in visible
294  // representations that use the transfer function.
295  virtual bool ComputeAvailableAnnotations(bool extend = false);
296  static bool ComputeAvailableAnnotations(vtkSMProxy* proxy, bool extend = false)
297  {
299  return self ? self->ComputeAvailableAnnotations(extend) : false;
300  }
301 
303 
308  virtual void ResetPropertiesToDefaults(const char* arrayName, bool preserve_range);
310  vtkSMProxy* proxy, const char* arrayName, bool preserve_range = false)
311  {
313  if (self)
314  {
315  self->ResetPropertiesToDefaults(arrayName, preserve_range);
316  }
317  }
318  using Superclass::ResetPropertiesToXMLDefaults;
320 
322 
327  static Json::Value ConvertLegacyColorMapXMLToJSON(vtkPVXMLElement* xml);
328  static Json::Value ConvertLegacyColorMapXMLToJSON(const char* xmlcontents);
330 
332 
336  static Json::Value ConvertMultipleLegacyColorMapXMLToJSON(vtkPVXMLElement* xml);
337  static Json::Value ConvertMultipleLegacyColorMapXMLToJSON(const char* xmlcontents);
339 
343  static bool ConvertLegacyColorMapsToJSON(const char* inxmlfile, const char* outjsonfile);
344 
346 
349  static Json::Value ConvertVisItColorMapXMLToJSON(vtkPVXMLElement* xml);
350  static Json::Value ConvertVisItColorMapXMLToJSON(const char* xmlcontents);
352 
354 
358  virtual bool GetRange(double range[2]);
359  static bool GetRange(vtkSMProxy* proxy, double range[2])
360  {
362  return self ? self->GetRange(range) : false;
363  }
365 
371  static bool ExportTransferFunction(vtkSMTransferFunctionProxy* colorTransferFunction,
372  vtkSMTransferFunctionProxy* opacityTransferFunction, const char* tfname, const char* filename,
373  vtkTypeUInt32 location = 0x10 /*vtkPVSession::CLIENT*/);
374 
375 protected:
376  vtkSMTransferFunctionProxy() = default;
377  ~vtkSMTransferFunctionProxy() override = default;
378 
383  void RestoreFromSiteSettingsOrXML(const char* arrayName);
384 
385  /*
386  * Stores the last range used to rescale to transfer function
387  * Used by ComputeDataHistogram
388  */
389  double LastRange[2] = { 0, 1 };
390 
391  /*
392  * Cache for the histogram table
393  */
395 
396 private:
398  void operator=(const vtkSMTransferFunctionProxy&) = delete;
399 };
400 
401 #endif
static vtkTable * GetHistogramTableCache(vtkSMProxy *proxy)
Helper method used to recover the last histogram computed by ComputeDataHistogram Returns the histogr...
static vtkSMProxy * FindScalarBarRepresentation(vtkSMProxy *proxy, vtkSMProxy *view)
Safely call FindScalarBarRepresentation(..) after casting the proxy to the appropriate type...
virtual bool MapControlPointsToLogSpace(bool inverse=false)
Remaps control points by normalizing in linear-space and then interpolating in log-space.
location
virtual bool RescaleTransferFunction(const double range[2], bool extend=false)
Rescale the "RGBPoints" for the transfer function to match the new range.
#define VTKREMOTINGVIEWS_EXPORT
void PrintSelf(ostream &os, vtkIndent indent) override
static bool MapControlPointsToLogSpace(vtkSMProxy *proxy, bool inverse=false)
Safely call MapControlPointsToLogSpace() after casting the proxy to the appropriate type...
static bool MapControlPointsToLinearSpace(vtkSMProxy *proxy)
Safely call MapControlPointsToLinearSpace() after casting the proxy to the appropriate type...
static bool ApplyPreset(vtkSMProxy *proxy, const Json::Value &value, bool rescale=true)
Apply a preset.
vtkSMTransferFunctionProxy is the proxy used for "PVLookupTable", "ColorTransferFunction" and "Piecew...
static bool ApplyPreset(vtkSMProxy *proxy, const char *presetname, bool rescale=true)
static bool RescaleTransferFunctionToDataRange(vtkSMProxy *proxy, bool extend=false)
Locates all representations that are currently using this transfer function and then rescales the tra...
static void ResetPropertiesToDefaults(vtkSMProxy *proxy, const char *arrayName, bool preserve_range=false)
Helper method to reset a transfer function proxy to its defaults.
static bool SaveColorMap(vtkSMProxy *proxy, vtkPVXMLElement *xml)
Safely call ApplyColorMap(..) after casting the proxy to the appropriate type.
static bool ComputeDataRange(vtkSMProxy *proxy, double range[2])
Helper method used by RescaleTransferFunctionToDataRange() to compute range from all visible represen...
static bool ApplyColorMap(vtkSMProxy *proxy, vtkPVXMLElement *xml)
Safely call ApplyColorMap(..) after casting the proxy to the appropriate type.
static bool ComputeAvailableAnnotations(vtkSMProxy *proxy, bool extend=false)
static vtkSMProxy * New()
range
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:140
static bool IsScalarBarVisible(vtkSMProxy *proxy, vtkSMProxy *view)
Safely call IsScalarBarVisible(..) after casting the proxy to the appropriate type.
provides meta data about arrays.
value
vtkSmartPointer< vtkTable > HistogramTableCache
static bool GetRange(vtkSMProxy *proxy, double range[2])
Returns current transfer function data range.
void operator=(const vtkSMProxy &)=delete
static bool RescaleTransferFunction(vtkSMProxy *proxy, const double range[2], bool extend=false)
Safely call RescaleTransferFunction() after casting the proxy to appropriate type.
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
static bool ApplyColorMap(vtkSMProxy *proxy, const char *text)
Safely call ApplyColorMap(..) after casting the proxy to the appropriate type.
static vtkTable * ComputeDataHistogramTable(vtkSMProxy *proxy, int numberOfBins)
Helper method used to compute a histogram with provided number of bins based on the data from all the...
static bool UpdateScalarBarsComponentTitle(vtkSMProxy *proxy, vtkPVArrayInformation *arrayInfo)
Update component titles for all scalar bars connected to this transfer function proxy.
static vtkSMTransferFunctionProxy * SafeDownCast(vtkObject *o)
virtual vtkTable * GetHistogramTableCache()
Helper method used to recover the last histogram computed by ComputeDataHistogram Returns the histogr...