diff options
| author | Tim Redfern <tim@getdrop.com> | 2018-02-03 09:58:48 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2018-02-03 09:58:48 +0000 |
| commit | 218003c711daf5e20fab77ee9b3ada67e2637922 (patch) | |
| tree | ff56e2326e232b0f592509b93709f530416aed5f /gui/src | |
| parent | f19740af946bd1faa6d364995b72b8a32e2315e3 (diff) | |
building output interface
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/ofApp.cpp | 199 | ||||
| -rw-r--r-- | gui/src/ofApp.h | 9 |
2 files changed, 139 insertions, 69 deletions
diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp index 689d5ad..e8241c2 100644 --- a/gui/src/ofApp.cpp +++ b/gui/src/ofApp.cpp @@ -1,16 +1,16 @@ #include "ofApp.h" #include "glew.h" -const ofPoint mainwindowsize=ofPoint(1200,900); - +const ofPoint outputWindowSize=ofPoint(1200,900); +const float guiScale=560.0f/4096.0f; //-------------------------------------------------------------- void ofApp::setup(){ warpframe[0]=glm::vec2(0,0); - warpframe[1]=glm::vec2(mainwindowsize.x,0); - warpframe[2]=glm::vec2(mainwindowsize.x,mainwindowsize.y); - warpframe[3]=glm::vec2(0,mainwindowsize.y); + 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; @@ -49,6 +49,16 @@ void ofApp::setup(){ framecounter=0; + + //======================================= //positioning interface + + bShowPositionInterface=false; + bOutputSelected=false; + + outputPosition=ofPoint(0,0); + outputScale=1.0f; + + } //-------------------------------------------------------------- @@ -166,96 +176,123 @@ void ofApp::draw(){ ofSetColor(255); ofNoFill(); - gui.draw(); + if (bShowPositionInterface){ + + glPushMatrix(); + + glTranslatef(20,20,0); + + ofDrawRectangle(0,0,560,560); + + glTranslatef(outputOffset.x,outputOffset.y,0); + + glScalef(guiScale,guiScale,guiScale ); + + glTranslatef(2048.0f+outputPosition.x,2048.0f+outputPosition.y,0); + + if (bOutputSelected) ofSetColor(255,0,0); + + ofDrawRectangle( + (-outputWindowSize.x/2)*outputScale, + (-outputWindowSize.y/2)*outputScale, + outputWindowSize.x*outputScale, + outputWindowSize.y*outputScale); + + glPopMatrix(); + } + else { + + gui.draw(); //================================== NDI /* - glPushMatrix(); + glPushMatrix(); - glTranslatef(230,0,0); + glTranslatef(230,0,0); - ofDrawRectangle(20,20,previewframesize.x+4,previewframesize.y+4); + ofDrawRectangle(20,20,previewframesize.x+4,previewframesize.y+4); - char str[256]; + char str[256]; - if(bNDIreceiver) { + if(bNDIreceiver) { - ndiImage.draw(22, 22, previewframesize.x, previewframesize.y); - - // Show fps etc. - if(nSenders > 0) { - if(bNDIreceiver) { - #ifdef _MSC_VER - sprintf_s(str, 256, "[%s] (%dx%d) - fps %2.0f", senderName, senderWidth, senderHeight, fps); - #else - // !CHECK MACOS - snprintf(str, 256, "[%s] (%dx%d) - fps %2.0f", senderName, senderWidth, senderHeight, fps); - str[255] = 0; - #endif - ofDrawBitmapString(str, 20, previewframesize.y+42); - } + ndiImage.draw(22, 22, previewframesize.x, previewframesize.y); - if(nSenders == 1) { - ofDrawBitmapString("1 network source", 25, 32); - } - else { - #ifdef _MSC_VER - sprintf_s(str, 256, "%d network sources", nSenders); - #else - // !CHECK MACOS - snprintf(str, 256, "%d network sources", nSenders); - str[255] = 0; - #endif - ofDrawBitmapString(str, 25, 32); - //ofDrawBitmapString("'SPACE' to list senders or RH click to open sender dialog", 20, ofGetHeight()-20); + // Show fps etc. + if(nSenders > 0) { + if(bNDIreceiver) { + #ifdef _MSC_VER + sprintf_s(str, 256, "[%s] (%dx%d) - fps %2.0f", senderName, senderWidth, senderHeight, fps); + #else + // !CHECK MACOS + snprintf(str, 256, "[%s] (%dx%d) - fps %2.0f", senderName, senderWidth, senderHeight, fps); + str[255] = 0; + #endif + ofDrawBitmapString(str, 20, previewframesize.y+42); + } + + if(nSenders == 1) { + ofDrawBitmapString("1 network source", 25, 32); + } + else { + #ifdef _MSC_VER + sprintf_s(str, 256, "%d network sources", nSenders); + #else + // !CHECK MACOS + snprintf(str, 256, "%d network sources", nSenders); + str[255] = 0; + #endif + ofDrawBitmapString(str, 25, 32); + //ofDrawBitmapString("'SPACE' to list senders or RH click to open sender dialog", 20, ofGetHeight()-20); + } } } - } - else { - ofDrawBitmapString("Connecting . . .", 25, 32); - } + else { + ofDrawBitmapString("Connecting . . .", 25, 32); + } - glPopMatrix(); + glPopMatrix(); - //================================== NDI + //================================== NDI - glPushMatrix(); + glPushMatrix(); - glTranslatef(230,300,0); -*/ - //================================== video + glTranslatef(230,300,0); + */ + //================================== video - glPushMatrix(); + glPushMatrix(); - glTranslatef(230,0,0); + glTranslatef(230,0,0); - ofDrawRectangle(20,20,previewframesize.x+4,previewframesize.y+4); + ofDrawRectangle(20,20,previewframesize.x+4,previewframesize.y+4); - if (movie.isLoaded()){ - movie.draw(22, 22, previewframesize.x, previewframesize.y); - } + if (movie.isLoaded()){ + movie.draw(22, 22, previewframesize.x, previewframesize.y); + } - glPopMatrix(); + glPopMatrix(); - //================================== SVG + //================================== SVG - glPushMatrix(); + glPushMatrix(); - float scale=previewframesize.x/mainwindowsize.x; + float scale=previewframesize.x/outputWindowSize.x; - glTranslatef(230,300,0); + glTranslatef(230,300,0); - ofDrawRectangle(20,20,previewframesize.x+4,previewframesize.y+4); + ofDrawRectangle(20,20,previewframesize.x+4,previewframesize.y+4); - glTranslatef(22,22,0); + glTranslatef(22,22,0); - glScalef(scale,scale,scale); + glScalef(scale,scale,scale); - for (auto shape=segmenters.begin();shape!=segmenters.end();shape++){ - shape->getPoly().draw(); - } + for (auto shape=segmenters.begin();shape!=segmenters.end();shape++){ + shape->getPoly().draw(); + } - glPopMatrix(); + glPopMatrix(); + } } @@ -295,13 +332,13 @@ void ofApp::drawOutput(ofEventArgs & args){ } case NDI:{ - ofPoint scale=ofPoint(mainwindowsize.x/ndiImage.getWidth(),mainwindowsize.x/ndiImage.getHeight()); + ofPoint scale=ofPoint(outputWindowSize.x/ndiImage.getWidth(),outputWindowSize.x/ndiImage.getHeight()); //does not work no matter what the fuck you do //grayImage.setFromPixels(pixels.getData(),ndiImage.getWidth(),ndiImage.getHeight()); - //grayImage.draw(0,0,mainwindowsize.x,mainwindowsize.y); + //grayImage.draw(0,0,outputWindowSize.x,outputWindowSize.y); grayImage = colorImg; @@ -328,7 +365,7 @@ void ofApp::drawOutput(ofEventArgs & args){ } case Player:{ if (movie.isLoaded()){ - ofPoint scale=ofPoint(mainwindowsize.x/movie.getWidth(),mainwindowsize.y/movie.getHeight()); + ofPoint scale=ofPoint(outputWindowSize.x/movie.getWidth(),outputWindowSize.y/movie.getHeight()); colorImg.setFromPixels(movie.getPixels()); grayImage = colorImg; grayImage.threshold(contour_threshold); @@ -406,6 +443,10 @@ void ofApp::keyPressed(ofKeyEventArgs &args){ } switch(args.key){ + case '`':{ + bShowPositionInterface=!bShowPositionInterface; + break; + } case 'q':{ source--; if (source<0){ @@ -448,6 +489,9 @@ void ofApp::outputMouseDragged(ofMouseEventArgs & args){ } void ofApp::mouseDragged(int x, int y, int button){ + if (bOutputSelected){ + outputOffset=ofPoint(x,y)-outputSelectionPoint; + } } //-------------------------------------------------------------- @@ -460,6 +504,17 @@ void ofApp::outputMousePressed(ofMouseEventArgs & args){ } void ofApp::mousePressed(int x, int y, int button){ + if (bShowPositionInterface){ + if (x>(300+((outputPosition.x-((outputWindowSize.x/2)*outputScale))*guiScale))&& + x<(300+((outputPosition.x+((outputWindowSize.x/2)*outputScale))*guiScale))&& + y>(300+((outputPosition.y-((outputWindowSize.y/2)*outputScale))*guiScale))&& + y<(300+((outputPosition.y+((outputWindowSize.y/2)*outputScale))*guiScale)) + ){ + outputSelectionPoint=ofPoint(x,y); + bOutputSelected=true; + } + } + } //-------------------------------------------------------------- @@ -468,6 +523,12 @@ void ofApp::outputMouseReleased(ofMouseEventArgs & args){ } void ofApp::mouseReleased(int x, int y, int button){ + if (bOutputSelected){ + bOutputSelected=false; + outputPosition+=outputOffset/guiScale; + outputOffset=ofPoint(0,0); + } + } //-------------------------------------------------------------- diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h index ae0ef60..fd0bcc3 100644 --- a/gui/src/ofApp.h +++ b/gui/src/ofApp.h @@ -103,4 +103,13 @@ class ofApp: public ofBaseApp { set <int> shape_selection; int framecounter; + //======================================= //positioning interface + + bool bShowPositionInterface; + bool bOutputSelected; + ofPoint outputSelectionPoint; + ofPoint outputPosition; + ofPoint outputOffset; + float outputScale; + }; |
