(root)/wip/src/din_info.cc - Rev 1662
Rev 1628 |
Rev 1668 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include "din.h"
#include "console.h"
#include "ui_list.h"
#include "vector2d.h"
extern string user_data_dir; // user data directory
extern int LEFT, BOTTOM, TOP; // din board extents
extern int HEIGHT; // default number of volumes on the microtonal keyboard
extern int WIDTH; // default number of microtones in a range
din_info::din_info () {
ifstream file ((user_data_dir + "din_info").c_str(), ios::in);
string ignore;
if (file) {
file >> ignore >> BOTTOM >> HEIGHT >> LEFT >> WIDTH;
TOP = BOTTOM + HEIGHT;
file >> ignore >> delay;
file >> ignore >> gater;
file >> ignore >> compress;
file >> ignore >> voice;
file >> ignore >> anchor;
file >> ignore >> vel;
file >> ignore >> accel;
file >> ignore >> fader::TIME;
file >> ignore >> rows >> cols;
gravity.load (file);
file >> ignore >> bounce.n;
file >> ignore >> bounce.speed;
file >> ignore >> bounce.style;
file >> ignore >> show_pitch_volume.board >> show_pitch_volume.drones;
float s, t;
file >> ignore >> s >> t;
drone_rise_time = din_info::s_time_range (s, t);
file >> ignore >> s >> t;
drone_fall_time = din_info::s_time_range (s, t);
file >> ignore >> snap.style >> snap.left >> snap.right;
file >> ignore >> sel_range >> mark_sel_range;
file >> ignore >> set_unset_toggle;
file >> ignore >> mesh_vars.order >> mesh_vars.point >> mesh_vars.duration >> mesh_vars.sync >> mesh_vars.dpp;
file >> mesh_vars.apply_to.active >> mesh_vars.apply_to.am >> mesh_vars.apply_to.fm;
file >> ignore >> drone_pend.n >> drone_pend.depth >> drone_pend.bpm >> drone_pend.orient;
file >> ignore >> create_this;
file >> ignore >> dist.pitch >> dist.vol >> dist.pix;
file >> ignore >> phrasor_right;
file >> ignore >> select_launched;
file >> ignore >> drone_is;
file >> ignore >> change_note;
file >> ignore >> change_note_style;
file >> ignore >> voice_is_voice;
file >> ignore >> drone::stiff;
file >> ignore >> drone::POSAFXVEL::minmag;
file >> ignore >> drone::gabt;
file >> ignore >> cen.style >> cen.x >> cen.y;
dlog << "+++ finished reading din_info +++" << endl;
}
cons.last ();
}
void din_info::save () {
ofstream file ((user_data_dir + "din_info").c_str(), ios::out);
file << "board " << BOTTOM << SPC << HEIGHT << SPC << LEFT << SPC << WIDTH << endl;
file << "delay " << delay << endl;
file << "gater " << gater << endl;
file << "compress " << compress << endl;
file << "voice " << voice << endl;
file << "anchor " << anchor << endl;
file << "vel " << vel << endl;
file << "accel " << accel << endl;
file << "fade_time " << fader::TIME << endl;
file << "drone_mesh " << rows << SPC << cols << endl;
gravity.save (file);
file << "bounces " << bounce.n << endl;
file << "speed " << bounce.speed << endl;
file << "style " << bounce.style << endl;
file << "show_pitch_volume " << show_pitch_volume.board << SPC << show_pitch_volume.drones << endl;
file << "drone_rise_time " << drone_rise_time.min << SPC << drone_rise_time.max << endl;
file << "drone_fall_time " << drone_fall_time.min << SPC << drone_fall_time.max << endl;
file << "drone_snap " << snap.style << SPC << snap.left << SPC << snap.right << SPC << endl;
file << "selected_range " << sel_range << SPC << mark_sel_range << endl;
file << "set_unset_toggle " << set_unset_toggle << endl;
file << "mesh_vars " << mesh_vars.order << SPC << mesh_vars.point << SPC << mesh_vars.duration << SPC << mesh_vars.sync << SPC << mesh_vars.dpp;
file << SPC << mesh_vars.apply_to.active << SPC << mesh_vars.apply_to.am << SPC << mesh_vars.apply_to.fm << endl;
file << "drone_pendulum " << drone_pend.n << SPC << drone_pend.depth << SPC << drone_pend.bpm << SPC << drone_pend.orient << endl;
file << "mesh=0__pend=1 " << create_this << endl;
file << "dist_pitch_vol_pix " << dist.pitch << SPC << dist.vol << SPC << dist.pix << endl;
file << "phrasor_right " << MENU.s_phrase_position.extents.right << endl;
file << "select_launched " << select_launched << endl;
file << "drone_is " << !drone_is << endl;
file << "change_note " << !change_note << endl;
file << "change_note_style " << change_note_style << endl;
file << "voice_is_voice " << voice_is_voice << endl;
file << "stiffness " << drone::stiff << endl;
file << "posafxvel-minmag " << drone::POSAFXVEL::minmag << endl;
file << "drone-gab-time " << drone::gabt << endl;
file << "xform-style-and-center " << cen.style << SPC << cen.x << SPC << cen.y << endl;
dlog << "+++ saved din_info +++" << endl;
}
#define SEED 6
void din_info::cent::draw () {
//if (style) {
glColor3f (1, 0.5, 0.75);
{
#define SZ (4 * SEED)
float pts[8] = {x, y-SZ, x, y+SZ, x-SZ, y, x+SZ, y};
glVertexPointer (2, GL_FLOAT, 0, pts);
glDrawArrays (GL_LINES, 0, 4);
}
{
float xl = x - SEED, yb = y - SEED, xr = x + SEED, yt = y + SEED;
float pts[8] = {xl, yb, xr, yb, xr, yt, xl, yt};
glVertexPointer (2, GL_FLOAT, 0, pts);
glDrawArrays (GL_LINE_LOOP, 0, 4);
}
//}
}
int din_info::cent::handle_input () {
if (lmb) {
if (!lmbclk) {
lmbclk = 1;
if (op == NONE) {
box<float> b (x - SEED, y - SEED, x + SEED, y + SEED);
if (inbox (b, h.x, h.y)) op = SET;
} else op = FINISH;
}
} else {
if (lis && op) lis->gotpoint ();
if (lmbclk) {
lmbclk = 0;
if (op == FINISH) op = NONE;
}
}
return op;
}
void din_info::cent::set (float x, float y) {
h.x = x;
h.y = y;
}