annotate grid.h @ 29:fabb3a5cdfc9

Timed session improvements. Desperate pathetic attempts to send a simple HTTP POST.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Fri, 22 Feb 2013 17:41:38 +0000
parents a4908ad8c78e
children 94df2cd72d7b
rev   line source
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@7 18 class Preset;
rt300@0 19
rt300@0 20 class Grid {
rt300@24 21
rt300@24 22 public:
rt300@24 23 bool snapped;
rt300@24 24
rt300@24 25
rt300@24 26 Grid();
rt300@24 27 ~Grid();
rt300@24 28 void init();
rt300@24 29 void move(TwoVector moveP); // shift view by pixels
rt300@24 30 void zoom(float factor);
rt300@24 31
rt300@24 32
rt300@24 33 void snapCheck();
rt300@24 34 void shiftCentreToSnapped();
rt300@24 35 void draw(); // draw lines
rt300@24 36
rt300@24 37 void update(); // change according to zoom
rt300@24 38
rt300@24 39 vector<int> getParams();
rt300@24 40 TwoVector getCoord();
rt300@24 41 void setMinZoom();
rt300@24 42 void setMaxZoom();
rt300@24 43
rt300@24 44 vector<int> calculateParamsFromCoord(TwoVector coord) const;
rt300@24 45 TwoVector calculateCoordFromParams(vector<int> params) const;
rt300@24 46 TwoVector coordToPixel(TwoVector coord);
rt300@24 47
rt300@24 48 // the inverse stuff
rt300@24 49 void setParams(vector<int>);
rt300@24 50
rt300@0 51 private:
rt300@24 52 double scale; // surface units per pixel GUI
rt300@0 53
rt300@3 54 const double maxValue; // width of entire space
rt300@3 55 const double minValue; // smallest zoom
rt300@3 56 const int paramsPerDim; // no of parameters per dimension (
rt300@3 57 int codeLength; // the 1d size of the code, determines max extent of single tile, related to params per dim
rt300@3 58 const int paramBitDepth; // number of bits for the parameter control data - i.e. always 7 for midi CC
rt300@3 59
rt300@5 60
rt300@5 61
rt300@24 62 TwoVector topLeft; // top left corner of view, surface coords GUI
rt300@0 63 TwoVector bottomRight;
rt300@0 64 TwoVector size; // size of view, surface coords
rt300@0 65 TwoVector pixSize; // size of view pixels (ie screen size!)
rt300@24 66
rt300@0 67 TwoVector centre;
rt300@5 68 TwoVector snapCentre;
rt300@24 69 TwoVector snapDist; // number of pixels to snap to GUI
rt300@7 70 Preset * closestPreset; // pointer to the currently selected (snapped to ) preset.. NULL if none.
rt300@5 71
rt300@0 72 bool maxZoom, minZoom;
rt300@0 73 int cubeWidth; // side of hypercube. 2 for binary coding.
rt300@3 74
rt300@0 75 vector< vector<bool> > vcode; //
rt300@0 76 vector<int> icode;
rt300@0 77 vector<int> transSeq;
rt300@0 78 int midiCC[10]; // the actual params SHOULD BE INITED FROM 2*paramsPerDim
rt300@0 79
rt300@0 80 // private functions
rt300@0 81
rt300@0 82 void makeCode();
rt300@0 83 void checkLimits();
rt300@0 84 void viewWasChanged();
rt300@0 85 void checkConsistencies();
rt300@0 86
rt300@3 87 vector<bool> intToGray(int num, int dimToTravel=3) const;
rt300@3 88 vector<int> coordTobase32(double coord) const;
rt300@3 89 vector<int> grayToMidi(vector<vector <bool> > grayCodes) const;
rt300@0 90
rt300@0 91 // the inverse stuff
rt300@3 92 int grayToInt(vector<bool>) const;
rt300@3 93 double base32toCoord(vector<int>) const;
rt300@3 94 vector<vector <bool> > midiToGray(vector<int>) const;
rt300@3 95 vector<int> codesToBase32(vector<vector<bool> >) const;
rt300@0 96
rt300@0 97 vector<int> walkDiff(vector<bool> left, vector<bool> right); // not used... not worth it!
rt300@0 98
rt300@0 99 void displayInfo();
rt300@3 100 void drawPresets();
rt300@0 101
rt300@0 102 void setCoord(TwoVector coord);
rt300@5 103 void drawCrossHairs();
rt300@9 104
rt300@5 105
rt300@3 106
rt300@3 107
rt300@0 108
rt300@0 109
rt300@0 110 };
rt300@0 111
rt300@0 112 #endif /* defined(__oscSenderExample__grid__) */