diff options
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/ofApp.cpp | 67 | ||||
| -rw-r--r-- | gui/src/ofApp.h | 6 |
2 files changed, 65 insertions, 8 deletions
diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp index fb179e9..05314d1 100644 --- a/gui/src/ofApp.cpp +++ b/gui/src/ofApp.cpp @@ -7,12 +7,6 @@ const float guiScale=560.0f/4096.0f; //-------------------------------------------------------------- void ofApp::setup(){ - warpframe[0]=glm::vec2(0,0); - warpframe[1]=glm::vec2(outputWindowSize.x,0); - warpframe[2]=glm::vec2(outputWindowSize.x,outputWindowSize.y); - warpframe[3]=glm::vec2(0,outputWindowSize.y); - select_warpframe=-1; - bDrawFrame=false; gui.setup(); @@ -55,12 +49,64 @@ void ofApp::setup(){ bShowPositionInterface=false; bOutputSelected=false; - outputPosition=ofPoint(0,0); - outputScale=1.0f; outputOffsetScale=1.0f; commandPressed=false; + select_warpframe=-1; + bDrawFrame=false; + + if( XML.loadFile("settings.xml") ){ + cout << "settings.xml loaded!" <<std::endl; + + } + else{ + cout << "unable to load settings.xml"<<std::endl; + } + + warpframe[0]=glm::vec2( + XML.getValue("WARP:p0:X", 0), + XML.getValue("WARP:p0:Y", 0) + ); + warpframe[1]=glm::vec2( + XML.getValue("WARP:p1:X", outputWindowSize.x), + XML.getValue("WARP:p1:Y", 0) + ); + warpframe[2]=glm::vec2( + XML.getValue("WARP:p2:X", outputWindowSize.x), + XML.getValue("WARP:p2:Y", outputWindowSize.y) + ); + warpframe[3]=glm::vec2( + XML.getValue("WARP:p3:X", 0), + XML.getValue("WARP:p3:Y", outputWindowSize.y) + ); + + outputPosition=ofPoint( + XML.getValue("POSITION:X", 0), + XML.getValue("POSITION:Y", 0) + ); + + outputScale=XML.getValue("SCALE", 1.0f); + +} + +void ofApp::save_settings(){ + XML.setValue("WARP:p0:X", warpframe[0].x); + XML.setValue("WARP:p0:Y", warpframe[0].y); + XML.setValue("WARP:p1:X", warpframe[1].x); + XML.setValue("WARP:p1:Y", warpframe[1].y); + XML.setValue("WARP:p2:X", warpframe[2].x); + XML.setValue("WARP:p2:Y", warpframe[2].y); + XML.setValue("WARP:p3:X", warpframe[3].x); + XML.setValue("WARP:p3:Y", warpframe[3].y); + + XML.setValue("POSITION:X", outputPosition.x); + XML.setValue("POSITION:Y", outputPosition.y); + + XML.setValue("SCALE", outputScale); + + XML.saveFile("settings.xml"); + cout << "settings.xml saved!" <<std::endl; } //-------------------------------------------------------------- @@ -504,6 +550,11 @@ void ofApp::keyPressed(ofKeyEventArgs &args){ } case OF_KEY_COMMAND:{ commandPressed=true; + break; + } + case 's':{ + save_settings(); + break; } } } diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h index 5ecbe61..8865da5 100644 --- a/gui/src/ofApp.h +++ b/gui/src/ofApp.h @@ -8,6 +8,7 @@ #include "ofxOpenCv.h" #include "ofxSVG.h" #include "lineSegmenter.h" +#include "ofxXmlSettings.h" enum Source{ TEST, @@ -47,6 +48,7 @@ class ofApp: public ofBaseApp { void outputWindowResized(ofResizeEventArgs &resizeargs); void select_random_shapes(); + void save_settings(); bool commandPressed; @@ -114,4 +116,8 @@ class ofApp: public ofBaseApp { float outputScale; float outputOffsetScale; + //======================================= //saving settings + + ofxXmlSettings XML; + }; |
