-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcanvas.h
107 lines (89 loc) · 2.74 KB
/
canvas.h
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* $Id: canvas.h,v 1.6 2002/07/17 07:29:59 inou Exp $
*/
#ifndef CANVAS_H
#define CANVAS_H
#include "pixmap.h"
#include "plugin.h"
#include <qwidget.h>
#include <qpoint.h>
#include <qstring.h>
//Added by qt3to4:
#include <QResizeEvent>
#include <QMouseEvent>
#include <QPaintEvent>
//
#include <QPainterPath>
#include <QRect>
class QResizeEvent;
class QAction;
namespace QFract {
class Point;
class Canvas: public QWidget
{
Q_OBJECT
public:
Canvas( QWidget *parent = 0);
void setParamNum( int n ) { param.setNum(n); }
void setParam( Parameter p )
{ param.setNum(p.Num()); param.set(p); pix.setParam(p); }
void setFunc( Point (*f)(Point, Point, Parameter ) ) { map=f; }
void setInitFunc( Point (*f)(Point, Parameter ) ) { init=f; }
void setIterFunc( int (*f)(Point, Parameter, int ) ) { pix.setFunc(f); }
void setParamInitFunc( void (*pi)(Parameter) ){ pix.setParamInitFunc(pi); }
void loadColorMap( const char *filename ) { pix.loadColorMap(filename); }
void setColorMap( ColorMap c ) { pix.setColorMap(c); }
int maxOrbit() { return maxorbit; }
int orbitStep() { return orbitstep; }
int paramNum() { return param.Num(); }
ColorMap colorMap() { return pix.colorMap(); }
double getParam(int i) { return param.Value(i); }
const char ** ParamDesc() { return plugin->ParamDesc(); }
Rect Region() { return pix.Region(); }
void draw();
void setPlugin( Plugin *i );
void setPluginName( const char *pn ) { pluginname=QString(pn); }
void mouseEvent( QMouseEvent *e );
Point getPoint( QMouseEvent *e );
void drawOrbit( QMouseEvent *e );
void zoom( QMouseEvent *e );
void zoomRect( QMouseEvent *e );
void setStatusBar( QString s );
QImage* getImage() { return pix.getImage(); }
void setRedrawEnabled( bool b ) { redrawEnabled=b; }
public slots:
void save();
void setRegion( Rect r ) { pix.setRegion( r ); }
void setMaxOrbit(int m) { maxorbit=m; }
void setOrbitStep(int m) { orbitstep=m; }
void setMaxIter(int m) { pix.setMaxIter(m); }
void toggleOrbit( bool b );
void mousePressEvent( QMouseEvent *e );
void mouseReleaseEvent( QMouseEvent *e );
void mouseMoveEvent( QMouseEvent *e );
void print();
signals:
void sendParam( Point, Parameter );
void _setStatusBar_( QString );
protected:
void resizeEvent( QResizeEvent *e );
void paintEvent( QPaintEvent * );
Pixmap pix;
int maxorbit;
int orbitstep;
Parameter param;
Point (*map)(Point, Point, Parameter ); // calculation function (map once)
Point (*init)(Point, Parameter ); // get initial point
Plugin *plugin;
QString pluginname;
//QString colormapname;
QPainterPath *path;
QRect rect;
bool redrawEnabled;
bool isOrbit;
bool leftButtonPressed;
bool rightButtonPressed;
QPoint zoomStart;
};
}
#endif // CANVAS_H