source: projects/paper-tape-project/trunk/visualisator/gtkpapertapezoom.h @ 78

Last change on this file since 78 was 78, checked in by sven, 11 years ago

Major improvements in making the Paper Tape Projects ready for deploying:

  • Written a 21 page manual in German (LaTeX, PDF)
  • Visualisator is running, export works, lesser bugs
  • some new perl-tools
  • a bin directory with softlinks
  • You can "install" the paper tape projects right now.
File size: 3.0 KB
Line 
1#ifndef __GTK_PAPER_TAPE_ZOOM__
2#define __GTK_PAPER_TAPE_ZOOM__
3
4#include <gtkmm/dialog.h>
5#include <gtkmm/actiongroup.h>
6#include <gtkmm/action.h>
7#include <gtkmm/spinbutton.h>
8
9#include <map>
10
11#include <gtk/gtk.h>
12
13
14namespace Gtk
15{ class PaperTapeZoom; }
16#include "gtkpapertapeview.h"
17
18namespace Gtk {
19
20
21
22/*enum PaperTapeRotation {
23        ROTATE_90_CW,
24        ROTATE_90_CCW,
25        NO_ROTATION
26}*/
27
28enum PaperTapeFlip {
29        FLIP_HOR,
30        FLIP_VER,
31        NO_FLIP
32};
33
34enum PaperTapeAutoZoomType {
35        ZOOM_LOCHSTREIFEN_WIDTH,
36        ZOOM_LOCHSTREIFEN_LENGTH
37};
38
39class PaperTapeZoom : public Cairo::Matrix {
40        /**
41         * The default matrix. This is the return point whenever
42         * you think your matrix is bad, and you want to reset() it.
43         * Change it with set_default() or via the constructor arguments.
44         * Normally this should be something like 1:1 "original" view
45         *
46         **/
47        Cairo::Matrix default_matrix;
48
49        /**
50         * For automatical settings
51         *
52         **/
53        double rotation;
54        PaperTapeFlip flip;
55        double zoom_factor;
56
57        /**
58         * Switch: Manual settings (raw matrix editing) or
59         * automatical matrix generation.
60         **/
61        bool manually;
62       
63        void update_dialog_on_zoom_changes();
64        void on_toggle_manually(CheckButton* manually_toggle);
65        void on_change_field(double* field);
66        void calc_matrix();
67
68        Dialog* matrix_dialog;
69        std::map<double*, SpinButton*> matrix_entries;
70       
71        // auto zoom:
72        bool auto_zoom_enabled;
73        sigc::connection auto_zoom_resize_con;
74        bool on_auto_zoom_resize(GdkEventConfigure* event);
75       
76        static GtkActionEntry ui_action_entries[];
77
78        /// When the zoom has changed somehow, this is emitted (and recieved ;-))
79        sigc::signal<void> zoom_changed;
80public:
81        PaperTapeZoom(double default_rotation = 0.0, double default_zoom_factor = 1.0, PaperTapeFlip default_flip = NO_FLIP);
82
83        void set_default(double rotation = 0.0, double zoom_factor = 1.0, PaperTapeFlip flip = NO_FLIP);
84
85        /**
86         * Resets the matrix to the default. This keeps the manual control,
87         * doen't set it back to automatic control.
88         **/
89        void reset();
90
91        void set_rotate(double radians, bool relative);
92        void set_zoom(double zoom_factor, bool relative);
93        void set_flip(PaperTapeFlip flip, bool relative);
94       
95        void set_auto_zoom(PaperTapeView& view, PaperTapeAutoZoomType type);
96        void disable_auto_zoom();
97       
98        bool is_controlled_manually() { return manually; }
99        void show_dialog();
100       
101        Glib::RefPtr<ActionGroup> get_action_group();
102        void transform_action(const Glib::RefPtr<Action>& action);
103
104        sigc::signal<void> signal_changed() {
105                return zoom_changed;
106        }
107
108        PaperTapeZoom& operator=(const Cairo::Matrix& right) {
109                // self-assignment makes not much sense ;-)
110                if(this == &right) return *this;
111                this->xx = right.xx; this->xy = right.xy; this->x0 = right.x0;
112                this->yx = right.yx; this->yy = right.yy; this->y0 = right.y0;
113                return *this;
114        }
115
116}; // class
117
118  inline std::ostream& operator<<(std::ostream& out, const Cairo::Matrix& s) {
119    out << "Cairo Matrix:\n";
120    out << "[ xx,xy,x0 = " << s.xx << ", " << s.xy << " , " << s.x0 << "\n";
121    out << "  yx,yy,y0 = " << s.yx << ", " << s.yy << " , " << s.y0 << " ]\n";
122    return out;
123  }
124
125}; // namespace Gtk
126
127#endif // __GTK_PAPER_TAPE_ZOOM__
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License