diff options
| author | Tim Redfern <tim@getdrop.com> | 2018-02-03 11:10:20 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2018-02-03 11:10:20 +0000 |
| commit | 022563c4bdc832b1177ed12ef0bac7f85912db95 (patch) | |
| tree | 82db9c1fb31edc38f1b0b6e7e61a27ed1aaba77a /gui/src/ofApp.cpp | |
| parent | 218003c711daf5e20fab77ee9b3ada67e2637922 (diff) | |
scan repositioning
Diffstat (limited to 'gui/src/ofApp.cpp')
| -rw-r--r-- | gui/src/ofApp.cpp | 61 |
1 files changed, 49 insertions, 12 deletions
diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp index e8241c2..3b24b43 100644 --- a/gui/src/ofApp.cpp +++ b/gui/src/ofApp.cpp @@ -57,6 +57,8 @@ void ofApp::setup(){ outputPosition=ofPoint(0,0); outputScale=1.0f; + outputOffsetScale=1.0f; + commandPressed=false; } @@ -190,13 +192,20 @@ void ofApp::draw(){ glTranslatef(2048.0f+outputPosition.x,2048.0f+outputPosition.y,0); - if (bOutputSelected) ofSetColor(255,0,0); + if (bOutputSelected) { + if (commandPressed) { + ofSetColor(0,255,0); + } + else { + ofSetColor(255,0,0); + } + } ofDrawRectangle( - (-outputWindowSize.x/2)*outputScale, - (-outputWindowSize.y/2)*outputScale, - outputWindowSize.x*outputScale, - outputWindowSize.y*outputScale); + (-outputWindowSize.x/2)*outputScale*outputOffsetScale, + (-outputWindowSize.y/2)*outputScale*outputOffsetScale, + outputWindowSize.x*outputScale*outputOffsetScale, + outputWindowSize.y*outputScale*outputOffsetScale); glPopMatrix(); } @@ -403,10 +412,14 @@ void ofApp::drawOutput(ofEventArgs & args){ } } - int num = laser.draw(laserOutput); + int num = 0; + + if (laserOutput.size()){ + num=laser.draw(laserOutput); - for (auto& shape:laserOutput){ - shape.draw(); + for (auto& shape:laserOutput){ + shape.draw(); + } } if (bDrawFrame){ @@ -469,8 +482,15 @@ void ofApp::keyPressed(ofKeyEventArgs &args){ } //-------------------------------------------------------------- -void ofApp::keyReleased(int key){ - if (key==OF_KEY_COMMAND){ +void ofApp::outputKeyReleased(ofKeyEventArgs &args){ + + outputKeyReleased(args); + + +} + +void ofApp::keyReleased(ofKeyEventArgs &args){ + if (args.key==OF_KEY_COMMAND){ commandPressed=false; } } @@ -490,7 +510,18 @@ void ofApp::outputMouseDragged(ofMouseEventArgs & args){ void ofApp::mouseDragged(int x, int y, int button){ if (bOutputSelected){ - outputOffset=ofPoint(x,y)-outputSelectionPoint; + if (commandPressed){ + float startDistance=((outputPosition*guiScale)+ofPoint(300,300)).distance(outputSelectionPoint); + float currentDistance=((outputPosition*guiScale)+ofPoint(300,300)).distance(ofPoint(x,y)); + outputOffsetScale=currentDistance/startDistance; + } + else { + outputOffset=ofPoint(x,y)-outputSelectionPoint; + laser.set_centre(ofPoint( + outputPosition.x+(outputOffset.x/guiScale), + outputPosition.y+(outputOffset.y/guiScale) + )); + } } } @@ -524,9 +555,15 @@ void ofApp::outputMouseReleased(ofMouseEventArgs & args){ void ofApp::mouseReleased(int x, int y, int button){ if (bOutputSelected){ + if (commandPressed){ + outputScale*=outputOffsetScale; + } + else { + outputPosition+=outputOffset/guiScale; + } bOutputSelected=false; - outputPosition+=outputOffset/guiScale; outputOffset=ofPoint(0,0); + outputOffsetScale=1.0f; } } |
