vtkSMTransferFunctionPresets.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkSMTransferFunctionPresets.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 =========================================================================*/
30 #ifndef vtkSMTransferFunctionPresets_h
31 #define vtkSMTransferFunctionPresets_h
32 
33 #include "vtkSMObject.h"
34 
35 #include "vtkRemotingViewsModule.h" // needed for exports
36 #include "vtkSmartPointer.h" // for ivars
37 #include <vector> // for vector
38 #include <vtk_jsoncpp_fwd.h> // for forward declarations
39 
40 class vtkPVXMLElement;
42 {
43 public:
44  // Used to return information about the imported presets to the caller of ImportPresets
46  {
47  std::string name;
48  struct
49  {
50  bool isValid = false;
51  std::vector<std::string> groups;
52  } potentialGroups;
53  };
54 
55  static vtkSMTransferFunctionPresets* New();
57  void PrintSelf(ostream& os, vtkIndent indent) override;
58 
62  static vtkSMTransferFunctionPresets* GetInstance();
63 
68  unsigned int GetNumberOfPresets();
69 
74  std::string GetPresetAsString(unsigned int index);
75 
82  bool AddPreset(const char* name, const std::string& preset);
83 
87  bool RemovePreset(unsigned int index);
88 
90 
95  const Json::Value& GetFirstPresetWithName(const char* name, int& idx);
96  const Json::Value& GetFirstPresetWithName(const char* name);
98 
102  const Json::Value& GetPreset(unsigned int index);
103 
107  std::string GetPresetName(unsigned int index);
108 
112  bool HasPreset(const char* name);
113 
117  bool GetPresetHasOpacities(const Json::Value& preset);
118  bool GetPresetHasOpacities(unsigned int index)
119  {
120  return this->GetPresetHasOpacities(this->GetPreset(index));
121  }
122 
126  bool GetPresetHasIndexedColors(const Json::Value& preset);
127  bool GetPresetHasIndexedColors(unsigned int index)
128  {
129  return this->GetPresetHasIndexedColors(this->GetPreset(index));
130  }
131 
135  bool GetPresetHasAnnotations(const Json::Value& preset);
136  bool GetPresetHasAnnotations(unsigned int index)
137  {
138  return this->GetPresetHasAnnotations(this->GetPreset(index));
139  }
140 
145  bool SetPreset(const char* name, const Json::Value& preset);
146 
150  bool AddPreset(const char* name, const Json::Value& preset);
151 
156  std::string AddUniquePreset(const Json::Value& preset, const char* prefix = nullptr);
157 
162  bool IsPresetBuiltin(unsigned int index);
163 
167  bool RenamePreset(unsigned int index, const char* newname);
168 
170 
176  bool ImportPresets(const char* filename);
177  bool ImportPresets(const char* filename, std::vector<ImportedPreset>* importedPresets);
178  bool ImportPresets(const Json::Value& presets);
179  bool ImportPresets(const Json::Value& presets, std::vector<ImportedPreset>* importedPresets);
181 
185  void ReloadPresets();
186 
187 protected:
189  ~vtkSMTransferFunctionPresets() override;
190 
191 private:
193  void operator=(const vtkSMTransferFunctionPresets&) = delete;
194 
195  class vtkInternals;
196  vtkInternals* Internals;
197 
199 };
200 
201 #endif
#define VTKREMOTINGVIEWS_EXPORT
bool GetPresetHasOpacities(unsigned int index)
manages presets for color, opacity, and annotation presets.
name
superclass for most server manager classes
Definition: vtkSMObject.h:29
bool GetPresetHasIndexedColors(unsigned int index)
bool GetPresetHasAnnotations(unsigned int index)
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
index