vtkSMTransferFunctionProxy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: $RCSfile$
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 =========================================================================*/
24 #ifndef vtkSMTransferFunctionProxy_h
25 #define vtkSMTransferFunctionProxy_h
26 
27 #include "vtkRemotingViewsModule.h" // needed for export macro
28 #include "vtkSMProxy.h"
29 #include "vtkSmartPointer.h" // for ivars
30 #include "vtkTable.h" // for vtkTable
31 
32 #include <vtk_jsoncpp_fwd.h> // for forward declarations
33 
34 // Forward declarations
36 
38 {
39 public:
42  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
50  virtual bool RescaleTransferFunction(const double range[2], bool extend = false)
51  {
52  return this->RescaleTransferFunction(range[0], range[1], extend);
53  }
54  virtual bool RescaleTransferFunction(double rangeMin, double rangeMax, bool extend = false);
55 
57 
61  static bool RescaleTransferFunction(
62  vtkSMProxy* proxy, double rangeMin, double rangeMax, bool extend = false);
63  static bool RescaleTransferFunction(vtkSMProxy* proxy, const double range[2], bool extend = false)
64  {
65  return vtkSMTransferFunctionProxy::RescaleTransferFunction(proxy, range[0], range[1], extend);
66  }
68 
70 
75  virtual bool RescaleTransferFunctionToDataRange(bool extend = false);
76  static bool RescaleTransferFunctionToDataRange(vtkSMProxy* proxy, bool extend = false)
77  {
79  return self ? self->RescaleTransferFunctionToDataRange(extend) : false;
80  }
82 
86  virtual bool InvertTransferFunction();
87 
92  static bool InvertTransferFunction(vtkSMProxy*);
93 
101  virtual bool MapControlPointsToLogSpace(bool inverse = false);
102  virtual bool MapControlPointsToLinearSpace() { return this->MapControlPointsToLogSpace(true); }
103 
105 
109  static bool MapControlPointsToLogSpace(vtkSMProxy* proxy, bool inverse = false)
110  {
112  return self ? self->MapControlPointsToLogSpace(inverse) : false;
113  }
115 
121  {
123  }
124 
126 
134  virtual bool ApplyPreset(const Json::Value& value, bool rescale = true);
135  static bool ApplyPreset(vtkSMProxy* proxy, const Json::Value& value, bool rescale = true)
136  {
138  return self ? self->ApplyPreset(value, rescale) : false;
139  }
141 
142  virtual bool ApplyPreset(const char* presetname, bool rescale = true);
143  static bool ApplyPreset(vtkSMProxy* proxy, const char* presetname, bool rescale = true)
144  {
146  return self ? self->ApplyPreset(presetname, rescale) : false;
147  }
148 
150 
154  virtual Json::Value GetStateAsPreset();
155  static Json::Value GetStateAsPreset(vtkSMProxy* proxy);
157 
159 
164  virtual bool ApplyColorMap(const char* text);
165  virtual bool ApplyColorMap(vtkPVXMLElement* xml);
167 
169 
173  static bool ApplyColorMap(vtkSMProxy* proxy, const char* text)
174  {
176  return self ? self->ApplyColorMap(text) : false;
177  }
179 
181 
185  static bool ApplyColorMap(vtkSMProxy* proxy, vtkPVXMLElement* xml)
186  {
188  return self ? self->ApplyColorMap(xml) : false;
189  }
191 
196  virtual bool SaveColorMap(vtkPVXMLElement* xml);
197 
199 
203  static bool SaveColorMap(vtkSMProxy* proxy, vtkPVXMLElement* xml)
204  {
206  return self ? self->SaveColorMap(xml) : false;
207  }
209 
215  virtual bool IsScalarBarVisible(vtkSMProxy* view);
216 
218 
222  static bool IsScalarBarVisible(vtkSMProxy* proxy, vtkSMProxy* view)
223  {
225  return self ? self->IsScalarBarVisible(view) : false;
226  }
228 
234  virtual vtkSMProxy* FindScalarBarRepresentation(vtkSMProxy* view);
235 
237 
242  {
244  return self ? self->FindScalarBarRepresentation(view) : nullptr;
245  }
247 
249 
254  virtual bool UpdateScalarBarsComponentTitle(vtkPVArrayInformation* arrayInfo);
256  {
258  return self ? self->UpdateScalarBarsComponentTitle(arrayInfo) : false;
259  }
261 
263 
268  virtual bool ComputeDataRange(double range[2]);
269  static bool ComputeDataRange(vtkSMProxy* proxy, double range[2])
270  {
272  return self ? self->ComputeDataRange(range) : false;
273  }
275 
277 
284  virtual vtkTable* ComputeDataHistogramTable(int numberOfBins);
285  static vtkTable* ComputeDataHistogramTable(vtkSMProxy* proxy, int numberOfBins)
286  {
288  return self ? self->ComputeDataHistogramTable(numberOfBins) : nullptr;
289  }
291 
293 
297  virtual vtkTable* GetHistogramTableCache() { return this->HistogramTableCache; }
299  {
301  return self ? self->GetHistogramTableCache() : nullptr;
302  }
304 
305  // Helper method to compute the active annotated values in visible
306  // representations that use the transfer function.
307  virtual bool ComputeAvailableAnnotations(bool extend = false);
308  static bool ComputeAvailableAnnotations(vtkSMProxy* proxy, bool extend = false)
309  {
311  return self ? self->ComputeAvailableAnnotations(extend) : false;
312  }
313 
315 
320  virtual void ResetPropertiesToDefaults(const char* arrayName, bool preserve_range);
322  vtkSMProxy* proxy, const char* arrayName, bool preserve_range = false)
323  {
325  if (self)
326  {
327  self->ResetPropertiesToDefaults(arrayName, preserve_range);
328  }
329  }
330  using Superclass::ResetPropertiesToXMLDefaults;
332 
334 
339  static Json::Value ConvertLegacyColorMapXMLToJSON(vtkPVXMLElement* xml);
340  static Json::Value ConvertLegacyColorMapXMLToJSON(const char* xmlcontents);
342 
344 
348  static Json::Value ConvertMultipleLegacyColorMapXMLToJSON(vtkPVXMLElement* xml);
349  static Json::Value ConvertMultipleLegacyColorMapXMLToJSON(const char* xmlcontents);
351 
355  static bool ConvertLegacyColorMapsToJSON(const char* inxmlfile, const char* outjsonfile);
356 
358 
362  virtual bool GetRange(double range[2]);
363  static bool GetRange(vtkSMProxy* proxy, double range[2])
364  {
366  return self ? self->GetRange(range) : false;
367  }
369 
375  static bool ExportTransferFunction(vtkSMTransferFunctionProxy* colorTransferFunction,
376  vtkSMTransferFunctionProxy* opacityTransferFunction, const char* tfname, const char* filename);
377 
378 protected:
379  vtkSMTransferFunctionProxy() = default;
380  ~vtkSMTransferFunctionProxy() override = default;
381 
386  void RestoreFromSiteSettingsOrXML(const char* arrayName);
387 
388  /*
389  * Stores the last range used to rescale to transfer function
390  * Used by ComputeDataHistogram
391  */
392  double LastRange[2] = { 0, 1 };
393 
394  /*
395  * Cache for the histogram table
396  */
398 
399 private:
401  void operator=(const vtkSMTransferFunctionProxy&) = delete;
402 };
403 
404 #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.
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:152
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...