Mercurial > hg > soniczoomios
comparison grid.h @ 44:a1e75b94c505
Snap to eval points. Double tap to go to preset (doesn't quite work yet). Coloured locks. Changed Question 2. Fixed some leaks.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Mon, 22 Apr 2013 18:32:34 +0100 |
parents | b91a1859829a |
children | 1e266647840d |
comparison
equal
deleted
inserted
replaced
43:b91a1859829a | 44:a1e75b94c505 |
---|---|
17 #include "hilbert.h" | 17 #include "hilbert.h" |
18 | 18 |
19 using namespace std; | 19 using namespace std; |
20 class Preset; | 20 class Preset; |
21 | 21 |
22 | |
23 | |
24 class Grid { | 22 class Grid { |
25 | 23 |
26 public: | 24 public: |
27 bool snapped; | 25 bool snapped; |
28 | 26 bool automatedMovement; |
27 bool presetWasTapped; | |
29 Hilbert hilbert; | 28 Hilbert hilbert; |
30 | 29 |
31 Grid(); | 30 Grid(); |
32 ~Grid(); | 31 ~Grid(); |
33 void init(); | 32 void init(); |
34 void move(TwoVector moveP); // shift view by pixels | 33 void move(TwoVector moveP); // shift view by pixels |
35 void zoom(float factor); | 34 void zoom(float factor); |
36 | 35 |
36 void tap(TwoVector pixel); // user has tapped a point | |
37 | |
37 typedef enum{NO_INTERPOLATION, INTERPOLATE_GRID, INTERPOLATE_PRESET} interpolateModeType; | 38 typedef enum{NO_INTERPOLATION, INTERPOLATE_GRID, INTERPOLATE_PRESET} interpolateModeType; |
38 interpolateModeType interpolateMode; | 39 interpolateModeType interpolateMode; |
39 void snapCheck(); | 40 void snapCheck(); |
40 void shiftCentreToSnapped(); | 41 void shiftCentreToSnapped(); |
41 void draw(); | 42 void draw(); |
47 TwoVector getCoord(); | 48 TwoVector getCoord(); |
48 double getScale(){return scale;}; | 49 double getScale(){return scale;}; |
49 void setMinZoom(); | 50 void setMinZoom(); |
50 void setMaxZoom(); | 51 void setMaxZoom(); |
51 void setInterpolation(interpolateModeType mode); | 52 void setInterpolation(interpolateModeType mode); |
53 | |
54 Preset * getClosestPresetOf(vector<Preset *> closePresets); | |
55 void interpolateTo(TwoVector coord); | |
52 // HILBERT now does each coord for this | 56 // HILBERT now does each coord for this |
53 vector<int> calculateParamsFromCoord(TwoVector coord); | 57 vector<int> calculateParamsFromCoord(TwoVector coord); |
54 TwoVector calculateCoordFromParams(vector<int> params); | 58 TwoVector calculateCoordFromParams(vector<int> params); |
55 vector<int> calculateInterpolatedParamsFromCoord(TwoVector coord); | 59 vector<int> calculateInterpolatedParamsFromCoord(TwoVector coord); |
56 TwoVector coordToPixel(TwoVector coord); | 60 TwoVector coordToPixel(TwoVector coord); |
61 TwoVector pixelToCoord(TwoVector pixel); | |
62 | |
57 void setScale(double scaleLevel); | 63 void setScale(double scaleLevel); |
58 // the inverse stuff | 64 // the inverse stuff |
59 void setParams(vector<int>); | 65 void setParams(vector<int>); |
60 TwoVector getCoordForPresetSave(); | 66 TwoVector getCoordForPresetSave(); |
61 | 67 |
79 | 85 |
80 TwoVector centre; | 86 TwoVector centre; |
81 TwoVector snapCentre; | 87 TwoVector snapCentre; |
82 TwoVector snapDist; // number of pixels to snap to GUI | 88 TwoVector snapDist; // number of pixels to snap to GUI |
83 Preset * closestPreset; // pointer to the currently selected (snapped to ) preset.. NULL if none. | 89 Preset * closestPreset; // pointer to the currently selected (snapped to ) preset.. NULL if none. |
84 | 90 Preset * tappedPreset; // pointer to currently highlighted (tapped) |
85 bool maxZoom, minZoom; | 91 bool maxZoom, minZoom; |
86 | 92 |
87 vector<int> midiCC; // the actual params | 93 vector<int> midiCC; // the actual params |
88 | 94 |
89 // private functions | 95 // private functions |
100 void displayInfo(); | 106 void displayInfo(); |
101 void drawPresets(); | 107 void drawPresets(); |
102 | 108 |
103 void setCoord(TwoVector coord); | 109 void setCoord(TwoVector coord); |
104 void drawCrossHairs(); | 110 void drawCrossHairs(); |
111 | |
105 | 112 |
106 double calculateInterpolateLevel(); | 113 double calculateInterpolateLevel(); |
107 vector<int> interpVector(vector<int> upper, vector<int> lower, float frac); | 114 vector<int> interpVector(vector<int> upper, vector<int> lower, float frac); |
108 vector<int> interpHilbert(int bitlevel, TwoVector coord); | 115 vector<int> interpHilbert(int bitlevel, TwoVector coord); |
109 | 116 |