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"
30 #include "vtkTable.h"
31 
32 #include <vtk_jsoncpp_fwd.h> // for forward declarations
33 
36 {
37 public:
40  void PrintSelf(ostream& os, vtkIndent indent) override;
41 
48  virtual bool RescaleTransferFunction(const double range[2], bool extend = false)
49  {
50  return this->RescaleTransferFunction(range[0], range[1], extend);
51  }
52  virtual bool RescaleTransferFunction(double rangeMin, double rangeMax, bool extend = false);
53 
55 
59  static bool RescaleTransferFunction(
60  vtkSMProxy* proxy, double rangeMin, double rangeMax, bool extend = false);
61  static bool RescaleTransferFunction(vtkSMProxy* proxy, const double range[2], bool extend = false)
62  {
63  return vtkSMTransferFunctionProxy::RescaleTransferFunction(proxy, range[0], range[1], extend);
64  }
66 
68 
73  virtual bool RescaleTransferFunctionToDataRange(bool extend = false);
74  static bool RescaleTransferFunctionToDataRange(vtkSMProxy* proxy, bool extend = false)
75  {
77  return self ? self->RescaleTransferFunctionToDataRange(extend) : false;
78  }
80 
84  virtual bool InvertTransferFunction();
85 
90  static bool InvertTransferFunction(vtkSMProxy*);
91 
99  virtual bool MapControlPointsToLogSpace(bool inverse = false);
100  virtual bool MapControlPointsToLinearSpace() { return this->MapControlPointsToLogSpace(true); }
101 
103 
107  static bool MapControlPointsToLogSpace(vtkSMProxy* proxy, bool inverse = false)
108  {
110  return self ? self->MapControlPointsToLogSpace(inverse) : false;
111  }
113 
119  {
121  }
122 
124 
132  virtual bool ApplyPreset(const Json::Value& value, bool rescale = true);
133  static bool ApplyPreset(vtkSMProxy* proxy, const Json::Value& value, bool rescale = true)
134  {
136  return self ? self->ApplyPreset(value, rescale) : false;
137  }
139 
140  virtual bool ApplyPreset(const char* presetname, bool rescale = true);
141  static bool ApplyPreset(vtkSMProxy* proxy, const char* presetname, bool rescale = true)
142  {
144  return self ? self->ApplyPreset(presetname, rescale) : false;
145  }
146 
148 
152  virtual Json::Value GetStateAsPreset();
153  static Json::Value GetStateAsPreset(vtkSMProxy* proxy);
155 
157 
162  virtual bool ApplyColorMap(const char* text);
163  virtual bool ApplyColorMap(vtkPVXMLElement* xml);
165 
167 
171  static bool ApplyColorMap(vtkSMProxy* proxy, const char* text)
172  {
174  return self ? self->ApplyColorMap(text) : false;
175  }
177 
179 
183  static bool ApplyColorMap(vtkSMProxy* proxy, vtkPVXMLElement* xml)
184  {
186  return self ? self->ApplyColorMap(xml) : false;
187  }
189 
194  virtual bool SaveColorMap(vtkPVXMLElement* xml);
195 
197 
201  static bool SaveColorMap(vtkSMProxy* proxy, vtkPVXMLElement* xml)
202  {
204  return self ? self->SaveColorMap(xml) : false;
205  }
207 
213  virtual bool IsScalarBarVisible(vtkSMProxy* view);
214 
216 
220  static bool IsScalarBarVisible(vtkSMProxy* proxy, vtkSMProxy* view)
221  {
223  return self ? self->IsScalarBarVisible(view) : false;
224  }
226 
232  virtual vtkSMProxy* FindScalarBarRepresentation(vtkSMProxy* view);
233 
235 
240  {
242  return self ? self->FindScalarBarRepresentation(view) : NULL;
243  }
245 
247 
252  virtual bool UpdateScalarBarsComponentTitle(vtkPVArrayInformation* arrayInfo);
254  {
256  return self ? self->UpdateScalarBarsComponentTitle(arrayInfo) : false;
257  }
259 
261 
266  virtual bool ComputeDataRange(double range[2]);
267  static bool ComputeDataRange(vtkSMProxy* proxy, double range[2])
268  {
270  return self ? self->ComputeDataRange(range) : false;
271  }
273 
275 
282  virtual vtkTable* ComputeDataHistogramTable(int numberOfBins);
283  static vtkTable* ComputeDataHistogramTable(vtkSMProxy* proxy, int numberOfBins)
284  {
286  return self ? self->ComputeDataHistogramTable(numberOfBins) : nullptr;
287  }
289 
291 
295  virtual vtkTable* GetHistogramTableCache() { return this->HistogramTableCache; }
297  {
299  return self ? self->GetHistogramTableCache() : nullptr;
300  }
302 
303  // Helper method to compute the active annotated values in visible
304  // representations that use the transfer function.
305  virtual bool ComputeAvailableAnnotations(bool extend = false);
306  static bool ComputeAvailableAnnotations(vtkSMProxy* proxy, bool extend = false)
307  {
309  return self ? self->ComputeAvailableAnnotations(extend) : false;
310  }
311 
313 
318  virtual void ResetPropertiesToDefaults(const char* arrayName, bool preserve_range);
320  vtkSMProxy* proxy, const char* arrayName, bool preserve_range = false)
321  {
323  if (self)
324  {
325  self->ResetPropertiesToDefaults(arrayName, preserve_range);
326  }
327  }
328  using Superclass::ResetPropertiesToXMLDefaults;
330 
335  void ResetRescaleModeToGlobalSetting();
336 
338 
343  static Json::Value ConvertLegacyColorMapXMLToJSON(vtkPVXMLElement* xml);
344  static Json::Value ConvertLegacyColorMapXMLToJSON(const char* xmlcontents);
346 
348 
352  static Json::Value ConvertMultipleLegacyColorMapXMLToJSON(vtkPVXMLElement* xml);
353  static Json::Value ConvertMultipleLegacyColorMapXMLToJSON(const char* xmlcontents);
355 
359  static bool ConvertLegacyColorMapsToJSON(const char* inxmlfile, const char* outjsonfile);
360 
362 
366  virtual bool GetRange(double range[2]);
367  static bool GetRange(vtkSMProxy* proxy, double range[2])
368  {
370  return self ? self->GetRange(range) : false;
371  }
373 
379  static bool ExportTransferFunction(vtkSMTransferFunctionProxy* colorTransferFunction,
380  vtkSMTransferFunctionProxy* opacityTransferFunction, const char* tfname, const char* filename);
381 
382 protected:
383  vtkSMTransferFunctionProxy() = default;
384  ~vtkSMTransferFunctionProxy() override = default;
385 
390  void RestoreFromSiteSettingsOrXML(const char* arrayName);
391 
392  /*
393  * Stores the last range used to rescale to transfer function
394  * Used by ComputeDataHistogram
395  */
396  double LastRange[2] = { 0, 1 };
397 
398  /*
399  * Cache for the histogram table
400  */
402 
403 private:
405  void operator=(const vtkSMTransferFunctionProxy&) = delete;
406 };
407 
408 #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.
Data array information like type.
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...