libigl v2.5.0
Loading...
Searching...
No Matches
ViewerPlugin.h
Go to the documentation of this file.
1// This file is part of libigl, a simple c++ geometry processing library.
2//
3// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>
4//
5// This Source Code Form is subject to the terms of the Mozilla Public License
6// v. 2.0. If a copy of the MPL was not distributed with this file, You can
7// obtain one at http://mozilla.org/MPL/2.0/.
8#ifndef IGL_OPENGL_GLFW_VIEWERPLUGIN_H
9#define IGL_OPENGL_GLFW_VIEWERPLUGIN_H
10
11// TODO:
12// * create plugins/skeleton.h
13// * pass time in draw function
14// * remove Preview3D from comments
15// * clean comments
16#include <string>
17#include "../../igl_inline.h"
18#include <vector>
19
20namespace igl
21{
22 namespace opengl
23 {
24 namespace glfw
25 {
26
27
28 // Forward declaration of the viewer
29 class Viewer;
30
39 {
40 public:
42 virtual ~ViewerPlugin(){}
44 IGL_INLINE virtual void init(Viewer *_viewer) { viewer = _viewer; }
46 IGL_INLINE virtual void shutdown() { }
48 IGL_INLINE virtual bool load(std::string /*filename*/) { return false; }
50 IGL_INLINE virtual bool save(std::string /*filename*/) { return false; }
52 IGL_INLINE virtual bool serialize(std::vector<char>& /*buffer*/) const
53 { return false; }
55 IGL_INLINE virtual bool deserialize(const std::vector<char>& /*buffer*/)
56 { return false; }
58 IGL_INLINE virtual bool post_load() { return false; }
60 IGL_INLINE virtual bool pre_draw() { return false; }
62 IGL_INLINE virtual bool post_draw() { return false; }
64 IGL_INLINE virtual void post_resize(int /*w*/, int /*h*/) { }
65 IGL_INLINE virtual bool mouse_down(int /*button*/, int /*modifier*/)
66 { return false; }
67 IGL_INLINE virtual bool mouse_up(int /*button*/, int /*modifier*/)
68 { return false; }
69 IGL_INLINE virtual bool mouse_move(int /*mouse_x*/, int /*mouse_y*/)
70 { return false; }
71 IGL_INLINE virtual bool mouse_scroll(float /*delta_y*/)
72 { return false; }
73 IGL_INLINE virtual bool key_pressed(unsigned int /*key*/, int /*modifiers*/)
74 { return false; }
75 IGL_INLINE virtual bool key_down(int /*key*/, int /*modifiers*/)
76 { return false; }
77 IGL_INLINE virtual bool key_up(int /*key*/, int /*modifiers*/)
78 { return false; }
79 std::string plugin_name;
80 protected:
81 // Pointer to the main Viewer class
83 };
84
85 namespace serialization
86 {
87 inline void serialize(const ViewerPlugin& obj,std::vector<char>& buffer)
88 {
89 obj.serialize(buffer);
90 }
91
92 inline void deserialize(ViewerPlugin& obj,const std::vector<char>& buffer)
93 {
94 obj.deserialize(buffer);
95 }
96 }
97
98 }
99 }
100}
101
102#endif
Abstract class for plugins All plugins MUST have this class as their parent and may implement any/all...
Definition ViewerPlugin.h:39
virtual bool mouse_up(int, int)
Definition ViewerPlugin.h:67
virtual bool save(std::string)
This function is called before a mesh is saved.
Definition ViewerPlugin.h:50
virtual bool deserialize(const std::vector< char > &)
This function is called when the scene is deserialized.
Definition ViewerPlugin.h:55
virtual bool key_up(int, int)
Definition ViewerPlugin.h:77
virtual bool key_down(int, int)
Definition ViewerPlugin.h:75
std::string plugin_name
Definition ViewerPlugin.h:79
virtual bool post_load()
Runs immediately after a new mesh has been loaded.
Definition ViewerPlugin.h:58
virtual bool load(std::string)
This function is called before a mesh is loaded.
Definition ViewerPlugin.h:48
Viewer * viewer
Definition ViewerPlugin.h:82
virtual void shutdown()
This function is called before shutdown.
Definition ViewerPlugin.h:46
virtual void post_resize(int, int)
This function is called after the window has been resized.
Definition ViewerPlugin.h:64
virtual bool serialize(std::vector< char > &) const
This function is called when the scene is serialized.
Definition ViewerPlugin.h:52
virtual bool pre_draw()
This function is called before the draw procedure of Viewer.
Definition ViewerPlugin.h:60
virtual bool post_draw()
This function is called after the draw procedure of Viewer.
Definition ViewerPlugin.h:62
virtual bool mouse_scroll(float)
Definition ViewerPlugin.h:71
virtual bool key_pressed(unsigned int, int)
Definition ViewerPlugin.h:73
ViewerPlugin()
Definition ViewerPlugin.h:41
virtual void init(Viewer *_viewer)
This function is called when the viewer is initialized (no mesh will be loaded at this stage)
Definition ViewerPlugin.h:44
virtual ~ViewerPlugin()
Definition ViewerPlugin.h:42
virtual bool mouse_down(int, int)
Definition ViewerPlugin.h:65
virtual bool mouse_move(int, int)
Definition ViewerPlugin.h:69
Definition Viewer.h:43
#define IGL_INLINE
Definition igl_inline.h:15
void serialize(const ViewerPlugin &obj, std::vector< char > &buffer)
Definition ViewerPlugin.h:87
void deserialize(ViewerPlugin &obj, const std::vector< char > &buffer)
Definition ViewerPlugin.h:92
Definition AABB.h:17