vtkTransferFunctionChartHistogram2D.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
3 #ifndef vtkTransferFunctionChartHistogram2D_h
4 #define vtkTransferFunctionChartHistogram2D_h
5 
6 #include "vtkChartHistogram2D.h"
7 
8 #include "vtkCommand.h" // needed for vtkCommand::UserEvent
9 #include "vtkRemotingViewsModule.h" // needed for export macro
10 #include "vtkWeakPointer.h" // needed for vtkWeakPointer
11 
12 #include <vector> // needed for ivar
13 
14 // Forward declarations
15 class vtkContext2D;
19 
21 {
22 public:
25 
26  // Events fires by this class (and subclasses).
27  // \li TransferFunctionModified is fired when the 2D transfer function is modified.
28  enum
29  {
30  TransferFunctionModified = vtkCommand::UserEvent + 1000,
31  };
32 
36  bool IsInitialized();
37 
39 
47  const vtkRectd& r, double* color, double alpha, bool addToTF2D = true);
48  void AddBox(vtkSmartPointer<vtkTransferFunctionBoxItem> box, bool addToTF2D = true);
50 
54  virtual void RemoveBox(vtkSmartPointer<vtkTransferFunctionBoxItem> box);
55 
59  bool MouseDoubleClickEvent(const vtkContextMouseEvent& mouse) override;
60 
64  bool KeyPressEvent(const vtkContextKeyEvent& key) override;
65 
69  void SetInputData(vtkImageData*, vtkIdType z = 0) override;
70 
72 
75  virtual void SetTransferFunction2D(vtkPVTransferFunction2D* transfer2D);
76  virtual vtkPVTransferFunction2D* GetTransferFunction2D();
78 
80 
84  void SetActiveBox(vtkSmartPointer<vtkTransferFunctionBoxItem> box);
86 
88 
91  void SetActiveBoxColorAlpha(double r, double g, double b, double a);
92  void SetActiveBoxColorAlpha(double color[3], double alpha);
94 
98  bool Paint(vtkContext2D* painter) override;
99 
100 protected:
102  ~vtkTransferFunctionChartHistogram2D() override = default;
103 
107  void UpdateItemsBounds(double xMin, double xMax, double yMin, double yMax);
108 
112  virtual void GenerateTransfer2D();
113 
118  void OnTransferFunctionBoxItemModified(vtkObject* caller, unsigned long eid, void* callData);
119 
120  // Member variables;
123  std::vector<int> BoxesToRemove;
124 
125 private:
128 };
129 
130 #endif // vtkTransferFunctionChartHistogram2D_h
vtkSmartPointer< vtkTransferFunctionBoxItem > ActiveBox
#define VTKREMOTINGVIEWS_EXPORT
virtual bool KeyPressEvent(const vtkContextKeyEvent &key)
static vtkChartHistogram2D * New()
int vtkIdType
virtual void SetInputData(vtkImageData *data, vtkIdType z=0)
Defines a 2D transfer function for mapping to RGBA values for volume rendering.
vtkWeakPointer< vtkPVTransferFunction2D > TransferFunction2D
virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse)
void operator=(const vtkObjectBase &)
virtual bool Paint(vtkContext2D *painter)