-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPresenter.h
102 lines (67 loc) · 1.92 KB
/
Presenter.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
#ifndef __PIROGRONIAN__ELASTIC_BODY_SIMULATOR__PRESENTER__H__
#define __PIROGRONIAN__ELASTIC_BODY_SIMULATOR__PRESENTER__H__
#include <QtGui/QtGui>
#include <QtWidgets/QtWidgets>
#include "ElasticBodySimulator.h"
namespace Pirogronian {
class Presenter;
class GranuleItem : public QObject, public QGraphicsEllipseItem {
Q_OBJECT
protected:
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
Presenter *_presenter;
public:
ElasticBodySimulator::Granule *granule;
GranuleItem(Presenter *, double x = 0, double y = 0);
void setPresenter(Presenter *p) { _presenter = p; }
Presenter *presenter() { return _presenter; }
int posx, posy;
// void udpatePosition();
// void mapPosition();
void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
private slots:
void switchMovable();
};
class LinkItem : public QGraphicsLineItem {
public:
GranuleItem *g1, *g2;
ElasticBodySimulator::Link *link;
LinkItem();
};
class Presenter : public QWidget {
Q_OBJECT
public:
enum Axis { X, Y, Z };
private:
Axis ax;
int pos;
bool _editable;
QList<GranuleItem*> _itemList;
QVector<QVector<GranuleItem*> > _itemMatrix;
QList<LinkItem*> _linkList;
QGraphicsScene *scene;
QGraphicsView *view;
ElasticBodySimulator *sim;
double _scale;
void resizeEvent(QResizeEvent *);
LinkItem *createLink(GranuleItem *, GranuleItem *, Axis);
public:
void setAxis(Axis a) { ax = a; }
Axis axis() { return ax; }
void setPos(int i) { pos = i; }
int axisPos() { return pos; }
void setScale(double a) { _scale = a; }
double scale() { return _scale; }
void setSimulator(ElasticBodySimulator *s) { sim = s; }
void setEditable();
void setUneditable();
bool isEditable();
Presenter(ElasticBodySimulator *s =0, QWidget *parent = 0);
~Presenter();
void init();
void putMatrix();
public slots:
void update();
};
}
#endif