Mercurial > hg > soniczoomios
view grid.h @ 37:8ed7522deaaa
Interpolation.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Tue, 09 Apr 2013 17:14:31 +0100 |
parents | 790939017078 |
children | 0dfe9e0c01aa |
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" #include "hilbert.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); typedef enum{NO_INTERPOLATION, INTERPOLATE_GRID, INTERPOLATE_PRESET} interpolateModeType; interpolateModeType interpolateMode; void snapCheck(); void shiftCentreToSnapped(); void draw(); void drawGridLines(); void update(); // change according to zoom int interpLevel; int smallestGridSpacing; // number of pixels when small grid dissappears from view vector<int> getParams(); TwoVector getCoord(); void setMinZoom(); void setMaxZoom(); // HILBERT now does each coord for this vector<int> calculateParamsFromCoord(TwoVector coord); TwoVector calculateCoordFromParams(vector<int> params); vector<int> calculateInterpolatedParamsFromCoord(TwoVector coord); 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 int paramsPerDim; // no of parameters per dimension ( int paramBitDepth; // number of bits for the parameter control data - i.e. always 7 for midi CC /* HILBERT int codeLength; // the 1d size of the code, determines max extent of single tile, related to params per dim */ 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; /* HILBERT vector< vector<bool> > vcode; // vector<int> icode; vector<int> transSeq; */ int midiCC[10]; // the actual params SHOULD BE INITED FROM 2*paramsPerDim // private functions // HILBERT void makeCode(); void checkLimits(); void viewWasChanged(); void checkConsistencies(); // HILBERT vector<bool> intToGray(int num, int dimToTravel=3) const; // HILBERT vector<int> coordTobase32(double coord) const; // HILBERT vector<int> grayToMidi(vector<vector <bool> > grayCodes) const; // the inverse stuff // HILBERT int grayToInt(vector<bool>) const; // HILBERT double base32toCoord(vector<int>) const; // HILBERT vector<vector <bool> > midiToGray(vector<int>) const; // HILBERT 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(); int calculateInterpolateLevel(); vector<int> interpVector(vector<int> upper, vector<int> lower, float frac); }; #endif /* defined(__oscSenderExample__grid__) */