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