Mercurial > hg > soniczoomios
view grid.h @ 0:307e5fb699fb
First commit.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Mon, 19 Nov 2012 12:56:47 +0000 |
parents | |
children | 43df75088d85 |
line wrap: on
line source
// // grid.h // oscSenderExample // // Created by Robert Tubb on 03/10/2012. // // This is the view onto the zoomable movable grid #ifndef __oscSenderExample__grid__ #define __oscSenderExample__grid__ #include <iostream> #include "2dvector.h" using namespace std; class Grid { private: double scale; // surface units per pixel double maxValue; // width of entire space double minValue; // smallest zoom TwoVector topLeft; // top left corner of view, surface coords TwoVector bottomRight; TwoVector size; // size of view, surface coords TwoVector pixSize; // size of view pixels (ie screen size!) TwoVector centre; bool maxZoom, minZoom; int cubeWidth; // side of hypercube. 2 for binary coding. int paramsPerDim; // no of parameters per dimension ( int codeLength; // the 1d size of the code, determines max extent of single tile, related to params per dim int paramBitDepth; // number of bits for the parameter control data - i.e. always 7 for midi CC vector< vector<bool> > vcode; // vector<int> icode; vector<int> transSeq; int midiCC[10]; // the actual params SHOULD BE INITED FROM 2*paramsPerDim // private functions void makeCode(); void checkLimits(); void viewWasChanged(); void checkConsistencies(); vector<int> calculateParamsFromCoord(TwoVector coord); TwoVector calculateCoordFromParams(vector<int> params); vector<bool> intToGray(int num, int dimToTravel=3); vector<int> coordTobase32(double coord); vector<int> grayToMidi(vector<vector <bool> > grayCodes); // the inverse stuff int grayToInt(vector<bool>); double base32toCoord(vector<int>); vector<vector <bool> > midiToGray(vector<int>); vector<int> codesToBase32(vector<vector<bool> >); vector<int> walkDiff(vector<bool> left, vector<bool> right); // not used... not worth it! void displayInfo(); void setCoord(TwoVector coord); public: Grid(); ~Grid(); void init(); void move(int moveX, int moveY); // shift view by pixels void zoom(float factor); void draw(); // draw lines void update(); // change according to zoom vector<int> getParams(); TwoVector getCoord(); // the inverse stuff void setParams(vector<int>); }; #endif /* defined(__oscSenderExample__grid__) */