rt300@0
|
1 //
|
rt300@0
|
2 // grid.h
|
rt300@0
|
3 // oscSenderExample
|
rt300@0
|
4 //
|
rt300@0
|
5 // Created by Robert Tubb on 03/10/2012.
|
rt300@0
|
6 //
|
rt300@0
|
7 // This is the view onto the zoomable movable grid
|
rt300@0
|
8
|
rt300@0
|
9 #ifndef __oscSenderExample__grid__
|
rt300@0
|
10 #define __oscSenderExample__grid__
|
rt300@0
|
11
|
rt300@0
|
12 #include <iostream>
|
rt300@0
|
13 #include "2dvector.h"
|
rt300@0
|
14 using namespace std;
|
rt300@0
|
15
|
rt300@0
|
16 class Grid {
|
rt300@0
|
17 private:
|
rt300@0
|
18 double scale; // surface units per pixel
|
rt300@0
|
19
|
rt300@0
|
20 double maxValue; // width of entire space
|
rt300@0
|
21 double minValue; // smallest zoom
|
rt300@0
|
22 TwoVector topLeft; // top left corner of view, surface coords
|
rt300@0
|
23 TwoVector bottomRight;
|
rt300@0
|
24 TwoVector size; // size of view, surface coords
|
rt300@0
|
25 TwoVector pixSize; // size of view pixels (ie screen size!)
|
rt300@0
|
26 TwoVector centre;
|
rt300@0
|
27 bool maxZoom, minZoom;
|
rt300@0
|
28 int cubeWidth; // side of hypercube. 2 for binary coding.
|
rt300@0
|
29 int paramsPerDim; // no of parameters per dimension (
|
rt300@0
|
30 int codeLength; // the 1d size of the code, determines max extent of single tile, related to params per dim
|
rt300@0
|
31 int paramBitDepth; // number of bits for the parameter control data - i.e. always 7 for midi CC
|
rt300@0
|
32 vector< vector<bool> > vcode; //
|
rt300@0
|
33 vector<int> icode;
|
rt300@0
|
34 vector<int> transSeq;
|
rt300@0
|
35 int midiCC[10]; // the actual params SHOULD BE INITED FROM 2*paramsPerDim
|
rt300@0
|
36
|
rt300@0
|
37 // private functions
|
rt300@0
|
38
|
rt300@0
|
39 void makeCode();
|
rt300@0
|
40 void checkLimits();
|
rt300@0
|
41 void viewWasChanged();
|
rt300@0
|
42 void checkConsistencies();
|
rt300@0
|
43
|
rt300@0
|
44 vector<int> calculateParamsFromCoord(TwoVector coord);
|
rt300@0
|
45 TwoVector calculateCoordFromParams(vector<int> params);
|
rt300@0
|
46
|
rt300@0
|
47 vector<bool> intToGray(int num, int dimToTravel=3);
|
rt300@0
|
48 vector<int> coordTobase32(double coord);
|
rt300@0
|
49 vector<int> grayToMidi(vector<vector <bool> > grayCodes);
|
rt300@0
|
50
|
rt300@0
|
51 // the inverse stuff
|
rt300@0
|
52 int grayToInt(vector<bool>);
|
rt300@0
|
53 double base32toCoord(vector<int>);
|
rt300@0
|
54 vector<vector <bool> > midiToGray(vector<int>);
|
rt300@0
|
55 vector<int> codesToBase32(vector<vector<bool> >);
|
rt300@0
|
56
|
rt300@0
|
57 vector<int> walkDiff(vector<bool> left, vector<bool> right); // not used... not worth it!
|
rt300@0
|
58
|
rt300@0
|
59 void displayInfo();
|
rt300@0
|
60
|
rt300@0
|
61 void setCoord(TwoVector coord);
|
rt300@0
|
62 public:
|
rt300@0
|
63 Grid();
|
rt300@0
|
64 ~Grid();
|
rt300@0
|
65 void init();
|
rt300@0
|
66 void move(int moveX, int moveY); // shift view by pixels
|
rt300@0
|
67 void zoom(float factor);
|
rt300@0
|
68
|
rt300@0
|
69 void draw(); // draw lines
|
rt300@0
|
70 void update(); // change according to zoom
|
rt300@0
|
71
|
rt300@0
|
72 vector<int> getParams();
|
rt300@0
|
73 TwoVector getCoord();
|
rt300@0
|
74 // the inverse stuff
|
rt300@0
|
75 void setParams(vector<int>);
|
rt300@0
|
76
|
rt300@0
|
77
|
rt300@0
|
78 };
|
rt300@0
|
79
|
rt300@0
|
80 #endif /* defined(__oscSenderExample__grid__) */
|