| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
#pragma warning(disable: 4786) |
|---|
| 7 |
#pragma once |
|---|
| 8 |
|
|---|
| 9 |
#include <qwidget.h> |
|---|
| 10 |
#include <qpainter.h> |
|---|
| 11 |
#include <qpixmap.h> |
|---|
| 12 |
|
|---|
| 13 |
#include <set> |
|---|
| 14 |
using std::set; |
|---|
| 15 |
|
|---|
| 16 |
const int DEFAULT_ZOOM = 0; |
|---|
| 17 |
const double FACTOR_MIN = .01; |
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
class GraphDisplay : public QWidget |
|---|
| 21 |
{ |
|---|
| 22 |
Q_OBJECT |
|---|
| 23 |
public: |
|---|
| 24 |
GraphDisplay(QWidget *parent=0, const char *name=0); |
|---|
| 25 |
~GraphDisplay() {delete buffer;} |
|---|
| 26 |
|
|---|
| 27 |
QSizePolicy sizePolicy() const; |
|---|
| 28 |
QPixmap *buffer; |
|---|
| 29 |
|
|---|
| 30 |
bool modified; |
|---|
| 31 |
bool suppress_repaint; |
|---|
| 32 |
|
|---|
| 33 |
int zoom; |
|---|
| 34 |
float factor; |
|---|
| 35 |
int cx, cy, oldcx, oldcy; |
|---|
| 36 |
int minx, miny, maxx, maxy; |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
public slots: |
|---|
| 41 |
void setZoom(int zoom); |
|---|
| 42 |
void repaint(int x, int y, int w, int h, bool clear); |
|---|
| 43 |
void repaint(); |
|---|
| 44 |
void center(); |
|---|
| 45 |
void fit(); |
|---|
| 46 |
|
|---|
| 47 |
signals: |
|---|
| 48 |
void zoomChanged(int); |
|---|
| 49 |
|
|---|
| 50 |
protected: |
|---|
| 51 |
inline int z(int i) {return int(i * factor);} |
|---|
| 52 |
inline int z(double i) {return int(i * factor);} |
|---|
| 53 |
inline int dez(int i) {return int(i * (1/factor));} |
|---|
| 54 |
inline int dez(double i) {return int(i * (1/factor));} |
|---|
| 55 |
inline int tx(int i) {return dez(i - (width()/2) - z(cx));} |
|---|
| 56 |
inline int ty(int i) {return dez(i - (height()/2) - z(cy));} |
|---|
| 57 |
|
|---|
| 58 |
virtual void boundingBox() = 0; |
|---|
| 59 |
void fit(int width, int height); |
|---|
| 60 |
virtual void draw(QPaintDevice *surface, int width, int height) = 0; |
|---|
| 61 |
|
|---|
| 62 |
void paintEvent(QPaintEvent *); |
|---|
| 63 |
void resizeEvent(QResizeEvent *); |
|---|
| 64 |
|
|---|
| 65 |
int clickx, clicky, oldx, oldy; |
|---|
| 66 |
bool moving_icon, moving_pane; |
|---|
| 67 |
class GraphIcon *moving; |
|---|
| 68 |
|
|---|
| 69 |
bool fit_pending; |
|---|
| 70 |
}; |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
class PlanGraphDisplay : public GraphDisplay |
|---|
| 75 |
{ |
|---|
| 76 |
Q_OBJECT |
|---|
| 77 |
public: |
|---|
| 78 |
PlanGraphDisplay(class PlanNode *root, QWidget *parent=0, const char *name=0); |
|---|
| 79 |
|
|---|
| 80 |
class PlanNode *root; |
|---|
| 81 |
|
|---|
| 82 |
protected: |
|---|
| 83 |
virtual void draw(QPaintDevice *surface, int width, int height); |
|---|
| 84 |
void draw_recursive(QPainter &p, class PlanNode *n); |
|---|
| 85 |
|
|---|
| 86 |
virtual void boundingBox(); |
|---|
| 87 |
|
|---|
| 88 |
set<PlanNode *> node_set; |
|---|
| 89 |
}; |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
class AuthorGraphDisplay : public GraphDisplay |
|---|
| 94 |
{ |
|---|
| 95 |
Q_OBJECT |
|---|
| 96 |
public: |
|---|
| 97 |
AuthorGraphDisplay(class AuthorForm_impl *author, QWidget *parent=0, const char *name=0); |
|---|
| 98 |
|
|---|
| 99 |
class AuthorForm_impl *author; |
|---|
| 100 |
|
|---|
| 101 |
class GraphIcon* intersect(int x, int y); |
|---|
| 102 |
|
|---|
| 103 |
protected: |
|---|
| 104 |
virtual void draw(QPaintDevice *surface, int width, int height); |
|---|
| 105 |
void draw_recursive(QPainter &p, class AuthorNode *n); |
|---|
| 106 |
|
|---|
| 107 |
void mousePressEvent(QMouseEvent *); |
|---|
| 108 |
void mouseDoubleClickEvent(QMouseEvent *); |
|---|
| 109 |
void mouseMoveEvent(QMouseEvent *); |
|---|
| 110 |
void mouseReleaseEvent(QMouseEvent *); |
|---|
| 111 |
|
|---|
| 112 |
virtual void boundingBox(); |
|---|
| 113 |
}; |
|---|
| 114 |
|
|---|