#include "ofApp.h" #include "glew.h" const ofPoint outputWindowSize=ofPoint(1200,900); //-------------------------------------------------------------- void ofApp::setup(){ midiIn.listInPorts(); //midiIn.openPort(1); //midiIn.addListener(this); //TODO make a midi chooser load_settings(); madlaser.setup("madlaser",1125,510); ofSetFrameRate(60); } //====================== settings void ofApp::default_settings(){ //outputScale=1.0f; } void ofApp::save_settings(){ //XML.setValue("SCALE", outputScale); XML.saveFile("settings.xml"); cout << "settings.xml saved!" < output; if (switcher.network){ vector networkoutput=networkinput.clipOutput(); output.insert(end(output), begin(networkoutput), end(networkoutput)); } if (switcher.svg){ vector svgoutput=svginput.clipOutput(); output.insert(end(output), begin(svgoutput), end(svgoutput)); } if (switcher.text){ vector textoutput=textinput.clipOutput(); output.insert(end(output), begin(textoutput), end(textoutput)); } int points=0; ofPushMatrix(); ofTranslate(825,5); ofSetColor(255); ofNoFill(); ofDrawRectangle(0,0,500,500); ofTranslate(250,250); ofScale(250.0f); for (auto poly:output){ poly.draw(); points+=poly.size(); } ofPopMatrix(); madlaser.panel.draw(); madlaser.drawNormalised(output); ofSetWindowTitle("laser points: "+ofToString(points)); } //-------------------------------------------------------------- void ofApp::exit() { } //-------------------------------------------------------------- void ofApp::keyPressed(ofKeyEventArgs &args){ if (args.key==OF_KEY_COMMAND){ //commandPressed=true; } switch(args.key){ case 'a':{ load_settings(); break; } case 'd':{ default_settings(); break; } case 's':{ save_settings(); break; } } } //-------------------------------------------------------------- void ofApp::keyReleased(ofKeyEventArgs &args){ if (args.key==OF_KEY_COMMAND){ //commandPressed=false; } } //-------------------------------------------------------------- void ofApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mouseEntered(int x, int y){ } //-------------------------------------------------------------- void ofApp::mouseExited(int x, int y){ } //-------------------------------------------------------------- void ofApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void ofApp::dragEvent(ofDragInfo dragInfo){ string filename= *dragInfo.files.begin(); string extension= filename.substr(filename.find_last_of(".") + 1); if (extension == "svg") { if (string::npos==filename.find("fonts")){ svginput.load(filename); } else { ofLog()<<"found a font"; textinput.loadFont(filename); } } else if (extension == "txt"){ textinput.loadText(filename); } else if (extension == "plt"){ textinput.loadPalette(filename); } else { ofLog()<<"cannot load "<