Nori  23
gui.h
1 /*
2  This file is part of Nori, a simple educational ray tracer
3 
4  Copyright (c) 2015 by Wenzel Jakob, Romain Prévost
5 
6  Nori is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Nori is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #if !defined(__NORI_GUI_H)
20 #define __NORI_GUI_H
21 
22 #include <nori/common.h>
23 #include <nanogui/screen.h>
24 #include <nanogui/renderpass.h>
25 #include <nanogui/shader.h>
26 #include <nanogui/canvas.h>
27 #include <nori/render.h>
28 
29 NORI_NAMESPACE_BEGIN
30 
31 class NoriCanvas : public nanogui::Canvas {
32 public:
33  NoriCanvas(nanogui::Widget* parent, const ImageBlock& block);
34  void draw_contents() override;
35  void update();
36  void set_scale(float scale) {
37  m_scale = scale;
38  }
39 private:
40  const ImageBlock& m_block;
41  nanogui::ref<nanogui::Shader> m_shader;
42  nanogui::ref<nanogui::Texture> m_texture;
43  nanogui::ref<nanogui::RenderPass> m_renderPass;
44  float m_scale = 1.f;
45 };
46 
47 class NoriScreen : public nanogui::Screen {
48 public:
49  NoriScreen(ImageBlock& block);
50  void draw_contents() override;
51 
52  virtual bool keyboard_event(int key, int scancode, int action, int modifiers) override;
53  virtual bool drop_event(const std::vector<std::string>& filenames) override;
54 
55  void updateLayout();
56 
57  void requestLayoutUpdate() {
58  m_requiresLayoutUpdate = true;
59  }
60 
61  void openXML(const std::string& filename);
62  void openEXR(const std::string& filename);
63 
64 private:
65  ImageBlock& m_block;
66  nanogui::ref<NoriCanvas> m_render_canvas;
67  nanogui::ref<nanogui::Shader> m_shader;
68  nanogui::ref<nanogui::RenderPass> m_renderPass;
69  nanogui::Slider* m_slider = nullptr;
70  nanogui::ProgressBar* m_progressBar = nullptr;
71  nanogui::ref<nanogui::Texture> m_texture;
72  bool m_requiresLayoutUpdate = false;
73  float m_scale = 1.f;
74  Widget* panel = nullptr;
75 
76  RenderThread m_renderThread;
77 };
78 
79 NORI_NAMESPACE_END
80 
81 #endif /* __NORI_GUI_H */
Weighted pixel storage for a rectangular subregion of an image.
Definition: block.h:48
Definition: gui.h:31
Definition: gui.h:47