blob: bfebe10116a0d4c6fcaba04dd990c22432f2baa8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#ifndef DRAWER_H_
#define DRAWER_H_
#include <gtk/gtk.h>
#include <gtk/gtkgl.h>
#include "Vertex.h"
#include "Renderer.h"
class Window;
class Drawer {
private:
GtkWidget *drawer;
GtkWidget *drawingArea;
GtkAdjustment *hAdjustment, *vAdjustment;
int zoomExp;
Renderer renderer;
Window *window;
float scale;
float xTranslate, yTranslate;
// prevent shallow copy
Drawer(const Drawer &w);
const Drawer& operator=(const Drawer &w);
void updateViewport();
void updateScrolling();
void updateScrollbars(float x = 0.5f, float y = 0.5f);
void updateHoveredPoint(float x, float y);
void render();
gint getWidth() const {
return drawingArea->allocation.width;
}
gint getHeight() const {
return drawingArea->allocation.height;
}
static void realize(GtkWidget *widget, Drawer *drawer);
static gboolean eventHandler(GtkWidget *widget, GdkEvent *event, Drawer *drawer);
static void valueChanged(GtkAdjustment *adjustment, Drawer *drawer);
public:
Drawer(Window *window, GdkGLConfig *glconfig);
virtual ~Drawer();
void zoom(int zoom, float x = 0.5f, float y = 0.5f);
void imageToView(Vertex *v) const;
void viewToImage(Vertex *v) const;
float getImageWidth() const;
float getImageHeight() const;
float getXTranslate() const {
return xTranslate;
}
float getYTranslate() const {
return yTranslate;
}
float getScale() const {
return scale;
}
GtkWidget *getWidget() const {
return drawer;
}
void update() {
gtk_widget_queue_draw(drawingArea);
}
};
#endif /*DRAWER_H_*/
|