TTK
Loading...
Searching...
No Matches
ttkUserInterfaceBase.h
Go to the documentation of this file.
1
7
8#pragma once
9
10#include <ttkProgramBase.h>
11#include <ttkUserInterfaceBaseModule.h>
12
13// VTK includes
15#include <vtkDataSetSurfaceFilter.h>
16#include <vtkInteractorStyleSwitch.h>
17#include <vtkInteractorStyleTrackballCamera.h>
18#include <vtkObjectFactory.h>
19#include <vtkPNGReader.h>
20#include <vtkPolyDataMapper.h>
21#include <vtkProperty.h>
22#include <vtkRenderWindow.h>
23#include <vtkRenderWindowInteractor.h>
24#include <vtkRenderer.h>
25#include <vtkVRMLExporter.h>
26
27// forward declaration
29
30// Custom interactors
31class TTKUSERINTERFACEBASE_EXPORT ttkCustomInteractor
32 : public vtkInteractorStyleTrackballCamera {
33
34public:
36
37 vtkTypeMacro(ttkCustomInteractor, vtkInteractorStyleTrackballCamera);
38
39 void OnKeyPress() override;
40
41 inline int setUserInterface(ttkUserInterfaceBase *userInterface) {
42
43 userInterface_ = userInterface;
44 return 0;
45 };
46
47protected:
49};
50
51class TTKUSERINTERFACEBASE_EXPORT ttkKeyHandler : public ttk::Debug {
52
53public:
54 virtual int OnKeyPress(vtkRenderWindowInteractor *interactor,
55 std::string &key)
56 = 0;
57};
58
59class TTKUSERINTERFACEBASE_EXPORT ttkUserInterfaceBase : public ttkProgramBase {
60
61public:
63
65
66 int exportScene(const std::string &fileName = "output.wrl") const;
67
69 return keyHandler_;
70 };
71
72 int hideOutputs(const std::vector<int> &outputList) {
73
74 for(int i = 0; i < (int)outputList.size(); i++) {
75 bool isAlreadyIn = false;
76 for(int j = 0; j < (int)hiddenOutputs_.size(); j++) {
77 if(outputList[i] == hiddenOutputs_[j]) {
78 isAlreadyIn = true;
79 break;
80 }
81 }
82 if(!isAlreadyIn)
83 hiddenOutputs_.push_back(outputList[i]);
84 }
85
86 return 0;
87 }
88
89 int init(int &argc, char **argv) override;
90
91 int refresh();
92
93 int run() override;
94
96 keyHandler_ = handler;
97 return 0;
98 }
99
100 int switchOutput(const int &outputId);
101
102 int switchTransparency();
103
104protected:
105 bool hasTexture_, isUp_, repeat_, transparency_, fullscreen_;
106 std::vector<bool> visibleOutputs_;
107 std::vector<int> hiddenOutputs_;
109 std::vector<vtkPolyData *> surfaces_;
111 std::vector<vtkSmartPointer<vtkActor>> mainActors_;
112 std::vector<vtkSmartPointer<vtkDataSetSurfaceFilter>> boundaryFilters_;
114 std::vector<vtkSmartPointer<vtkPolyDataMapper>> boundaryMappers_;
119 std::vector<vtkSmartPointer<ttkTextureMapFromField>> textureMapFromFields_;
120
121 int updateScalarFieldTexture();
122};
123
124template <class ttkModule>
126
127public:
130 vtkWrapper_ = (vtkDataSetAlgorithm *)ttkObject_.GetPointer();
131 ttkModule_ = (Debug *)ttkObject_.GetPointer();
132 };
133
134 int run() override {
136 }
137
139};
static ttkCustomInteractor * New()
int setUserInterface(ttkUserInterfaceBase *userInterface)
ttkUserInterfaceBase * userInterface_
virtual int OnKeyPress(vtkRenderWindowInteractor *interactor, std::string &key)=0
Base VTK editor class for standalone programs. This class parses the the command line,...
vtkDataSetAlgorithm * vtkWrapper_
Interactions and rendering.
std::vector< vtkPolyData * > surfaces_
vtkSmartPointer< vtkRenderWindowInteractor > interactor_
vtkSmartPointer< ttkCustomInteractor > customInteractor_
int setKeyHandler(ttkKeyHandler *handler)
vtkSmartPointer< vtkRenderer > renderer_
vtkSmartPointer< vtkPNGReader > pngReader_
std::vector< vtkSmartPointer< vtkActor > > mainActors_
vtkSmartPointer< vtkRenderWindow > renderWindow_
std::vector< vtkSmartPointer< vtkDataSetSurfaceFilter > > boundaryFilters_
~ttkUserInterfaceBase() override
std::vector< int > hiddenOutputs_
std::vector< bool > visibleOutputs_
std::vector< vtkSmartPointer< ttkTextureMapFromField > > textureMapFromFields_
ttkKeyHandler * getKeyHandler()
std::vector< vtkSmartPointer< vtkPolyDataMapper > > boundaryMappers_
vtkSmartPointer< vtkTexture > texture_
int hideOutputs(const std::vector< int > &outputList)
Minimalist debugging class.
Definition Debug.h:88
vtkSmartPointer< ttkModule > ttkObject_