-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.h
More file actions
139 lines (124 loc) · 3.09 KB
/
plot.h
File metadata and controls
139 lines (124 loc) · 3.09 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#ifndef plot_h
#define plot_h
typedef unsigned char uchar;
typedef unsigned int uint;
static char notes[] = {'C','D','E','F','G','A','B'};
#define DEFAULT_MIDICHANNEL -1
#define DEFAULT_MIDIVOLUME 60
//Default sizes
#define PLOT_DEFAULT_I 60
#define PLOT_DEFAULT_J 60
#define PLOT_DEFAULT_M 60
#define PLOT_DEFAULT_N 60
#define PLOT_TAB_CELLS 0
#define PLOT_TAB_NOTES 1
#define WWM_NONE 0
#define WWM_WIRE 1
#define WWM_TAIL 2
#define WWM_HEAD 3
#define DEFAULT_SPEED 4
#define MINIMAL_SPEED 1
#define MAXIMAL_SPEED 16
#define MAKE_MSG(X, Y, Z) (X + (Y<<8) + (Z<<16))
typedef class Plot
{
public:
//Size of matrix
uint m;
uint n;
//Matrixes
uchar *CellMatrix;
uchar *SwapMatrix;
uchar *NoteMatrix;
//Vector with off notes
std::vector<uchar> OffNotes;
//Midi channel
int midich;
//Midi volume
int volume;
//MIDI handle
HMIDIOUT hdev;
//Drawing control
GLuint font;
//Main control
float x,y,z; //position
float w,h; //size
//Cells area
float cx,cy,cz;
float cw,ch;
float cdw,cdh; //width and height deltas
//Mouse position
float mx,my;
//Cell position
uint mposx,mposy;
uint mpos; //This is the cell position
uint tab; //current tab: 0-> automaton; 1-> notes
int mousein; //Which tab is mouse over
int state; //State of tabs
uchar pencil; //Current painting color
uchar eraser; //Current erase color
uchar selected_note;
uchar eraser_note;
bool visible; //True to draw plot
bool mleft; //Left mouse button is pressed
bool mright; //Right mouse button is pressed
char dtxt[64]; //debug text
//Constructor
Plot(void);
Plot(float _x, float _y, float _z, float _w, float _h, bool _v, GLuint _font);
//This method
void Draw(void);
void Render(void);
//Initialize midi port
void InitMidi(void);
//Matrixes method collection
void DropMatrixes(void);
void CreateMatrixes(void);
void ResizeMatrixes(uint _m, uint _n);
void ClearMatrixes(void);
//Cells matrix operations
void ClearWires(void);
void ClearCellMatrix(void);
//Note matrix operations
void ClearNoteMatrix(void);
//RULES CONTROL
void CalculateMatrix(void);
void AddNoteOff(uchar _note);
void NotesOff(void);
//These methods get information of neighboor cells
int CheckTop(uint pos);
int CheckBottom(uint pos);
int CheckLeft(uint pos);
int CheckRight(uint pos);
int CheckTopLeft(uint pos);
int CheckTopRight(uint pos);
int CheckBottomLeft(uint pos);
int CheckBottomRight(uint pos);
//Gets ammount of heads in near a specified cell
int CheckNeighbourHeads(uint pos);
//EVENTS
//Left mouse button down
int LDown(float _x, float _y);
//Left mouse button up
int LUp(float _x, float _y);
//Right mouse button down
int RDown(float _x, float _y);
//Right mouse button up
int RUp(float _x, float _y);
//Mouse move
int MMove(float _x, float _y, bool _mleft);
//These grants ability to control mouse wheel
int MWheel(float _x, float _y, bool _mleft, short _delta);
//FILE FORMAT FUNCTIONS
FILE *fout,*fin;
//Basic functions
void ps(const char *s);
void pn(int c, uint v);
const char* gs(int c);
int gn(int c);
//Read file
int Read(char *fname);
//Write file
int Write(char *fname);
} Plot;
#endif