Mercurial > hg > soniczoomios
view grid.h @ 24:a4908ad8c78e
Top and bottom toolbars. Intro page.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Fri, 01 Feb 2013 11:16:56 +0000 |
parents | e44dc6f7f12e |
children | 94df2cd72d7b |
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" #include "ofMain.h" #include "eventLogger.h" #include "presetManager.h" using namespace std; class Preset; class Grid { public: bool snapped; Grid(); ~Grid(); void init(); void move(TwoVector moveP); // shift view by pixels void zoom(float factor); void snapCheck(); void shiftCentreToSnapped(); void draw(); // draw lines void update(); // change according to zoom vector<int> getParams(); TwoVector getCoord(); void setMinZoom(); void setMaxZoom(); vector<int> calculateParamsFromCoord(TwoVector coord) const; TwoVector calculateCoordFromParams(vector<int> params) const; TwoVector coordToPixel(TwoVector coord); // the inverse stuff void setParams(vector<int>); private: double scale; // surface units per pixel GUI const double maxValue; // width of entire space const double minValue; // smallest zoom const 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 const int paramBitDepth; // number of bits for the parameter control data - i.e. always 7 for midi CC TwoVector topLeft; // top left corner of view, surface coords GUI TwoVector bottomRight; TwoVector size; // size of view, surface coords TwoVector pixSize; // size of view pixels (ie screen size!) TwoVector centre; TwoVector snapCentre; TwoVector snapDist; // number of pixels to snap to GUI Preset * closestPreset; // pointer to the currently selected (snapped to ) preset.. NULL if none. bool maxZoom, minZoom; int cubeWidth; // side of hypercube. 2 for binary coding. 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<bool> intToGray(int num, int dimToTravel=3) const; vector<int> coordTobase32(double coord) const; vector<int> grayToMidi(vector<vector <bool> > grayCodes) const; // the inverse stuff int grayToInt(vector<bool>) const; double base32toCoord(vector<int>) const; vector<vector <bool> > midiToGray(vector<int>) const; vector<int> codesToBase32(vector<vector<bool> >) const; vector<int> walkDiff(vector<bool> left, vector<bool> right); // not used... not worth it! void displayInfo(); void drawPresets(); void setCoord(TwoVector coord); void drawCrossHairs(); }; #endif /* defined(__oscSenderExample__grid__) */