diff options
Diffstat (limited to 'gui/src/ofApp.cpp')
| -rw-r--r-- | gui/src/ofApp.cpp | 172 |
1 files changed, 172 insertions, 0 deletions
diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp new file mode 100644 index 0000000..100c107 --- /dev/null +++ b/gui/src/ofApp.cpp @@ -0,0 +1,172 @@ +#include "ofApp.h" +#include "glew.h" + + +//-------------------------------------------------------------- +void ofApp::setup(){ + warpframe[0]=glm::vec2(0,0); + warpframe[1]=glm::vec2(ofGetWidth(),0); + warpframe[2]=glm::vec2(ofGetWidth(),ofGetHeight()); + warpframe[3]=glm::vec2(0,ofGetHeight()); + select_warpframe=-1; + bDrawFrame=false; +} + +//-------------------------------------------------------------- +void ofApp::update(){ + + +} + +void ofApp::updateGui(ofEventArgs & args){ + + +} + + +//-------------------------------------------------------------- +void ofApp::drawGui(ofEventArgs & args){ + ofBackground(0); + +} + +void ofApp::draw(){ + ofBackground(0); + //composite output window + + ofSetColor(255,255,255); + + ofMatrix4x4 m = ofMatrix4x4::newIdentityMatrix(); + m.rotateRad(ofGetElapsedTimef(),0,0,1); + m.translate(ofGetWidth()/2,ofGetHeight()/2,0); + + glm::vec2 src[]={ + glm::vec2(0,0), + glm::vec2(ofGetWidth(),0), + glm::vec2(ofGetWidth(),ofGetHeight()), + glm::vec2(0,ofGetHeight()) + }; + + ofMatrix4x4 warp =lineTransformer::getPerspectiveTransformMatrix(src,warpframe); + + //drawPoly(polyLineTransform(makePolygon(4,200),m),200,200); + //drawPoly(polyLineTransform(makePolygon(5,200),m),-200,200); + //drawPoly(polyLineTransform(makePolygon(6,200),m),-200,-200); + + lineTransformer::drawPoly( + lineTransformer::polyLineTransform( + lineTransformer::polyLineTransform( + lineTransformer::makePolygon(6,200) + ,m) + ,warp) + ,0,0); + + if (bDrawFrame){ + lineTransformer::drawWarpFrame(warpframe); + } + +} + +//-------------------------------------------------------------- +void ofApp::exit() { + +} + + + +//-------------------------------------------------------------- +void ofApp::keyPressed(ofKeyEventArgs &args){ + + if (args.key==OF_KEY_COMMAND){ + commandPressed=true; + } + + switch(args.key){ + case 'w':{ + bDrawFrame=!bDrawFrame; + break; + } + case OF_KEY_COMMAND:{ + commandPressed=true; + } + } + + +} + +void ofApp::guiKeyPressed(ofKeyEventArgs &args){ + +} + +//-------------------------------------------------------------- +void ofApp::keyReleased(int key){ + if (key==OF_KEY_COMMAND){ + commandPressed=false; + } +} + +//-------------------------------------------------------------- +void ofApp::mouseMoved(int x, int y ){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseDragged(int x, int y, int button){ + if (select_warpframe>-1){ + warpframe[select_warpframe]=glm::vec2(x,y); + } +} + +//-------------------------------------------------------------- +void ofApp::mousePressed(int x, int y, int button){ + for (int i=0;i<4;i++){ + if (ofPoint(x,y).distance(warpframe[i])<25){ + select_warpframe=i; + } + } +} + +//-------------------------------------------------------------- +void ofApp::mouseReleased(int x, int y, int button){ + select_warpframe=-1; +} + +//-------------------------------------------------------------- +void ofApp::mouseEntered(int x, int y){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseExited(int x, int y){ + +} + +//-------------------------------------------------------------- +void ofApp::windowResized(int w, int h){ + +} + +void ofApp::guiWindowResized(ofResizeEventArgs &resizeargs){ + +} + + +//-------------------------------------------------------------- +void ofApp::dragEvent(ofDragInfo dragInfo){ + //std::string filenames; + + //for (auto f = dragInfo.files.begin(); f != dragInfo.files.end(); f++){ + // if (f!=dragInfo.files.begin()){ + // filenames=filenames+", "; + // } + // filenames=filenames+*f; + + // if (dragInfo.position.y<200){ + // sets[0].addfiles(dragInfo.files); //,dragInfo.position); + // } + // else sets[1].addfiles(dragInfo.files); //,dragInfo.position); + + + //} + +} |
