summaryrefslogtreecommitdiff
path: root/gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main.cpp1
-rw-r--r--gui/src/ofApp.cpp61
-rw-r--r--gui/src/ofApp.h4
3 files changed, 53 insertions, 13 deletions
diff --git a/gui/src/main.cpp b/gui/src/main.cpp
index bdc0e8a..763fb73 100644
--- a/gui/src/main.cpp
+++ b/gui/src/main.cpp
@@ -39,6 +39,7 @@ int main(int argc, char *argv[]){
ofAddListener(mainWindow->events().draw,mainApp.get(),&ofApp::drawOutput);
ofAddListener(mainWindow->events().windowResized,mainApp.get(),&ofApp::outputWindowResized);
ofAddListener(mainWindow->events().keyPressed,mainApp.get(),&ofApp::outputKeyPressed);
+ ofAddListener(mainWindow->events().keyReleased,mainApp.get(),&ofApp::outputKeyReleased);
ofAddListener(mainWindow->events().mouseDragged,mainApp.get(),&ofApp::outputMouseDragged);
ofAddListener(mainWindow->events().mousePressed,mainApp.get(),&ofApp::outputMousePressed);
ofAddListener(mainWindow->events().mouseReleased,mainApp.get(),&ofApp::outputMouseReleased);
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;
}
}
diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h
index fd0bcc3..5ecbe61 100644
--- a/gui/src/ofApp.h
+++ b/gui/src/ofApp.h
@@ -27,7 +27,7 @@ class ofApp: public ofBaseApp {
void exit();
void keyPressed(ofKeyEventArgs &keyargs);
- void keyReleased(int key);
+ void keyReleased(ofKeyEventArgs & args);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
@@ -40,6 +40,7 @@ class ofApp: public ofBaseApp {
void updateOutput(ofEventArgs & args);
void drawOutput(ofEventArgs & args);
void outputKeyPressed(ofKeyEventArgs & args);
+ void outputKeyReleased(ofKeyEventArgs & args);
void outputMouseDragged(ofMouseEventArgs & args);
void outputMousePressed(ofMouseEventArgs & args);
void outputMouseReleased(ofMouseEventArgs & args);
@@ -111,5 +112,6 @@ class ofApp: public ofBaseApp {
ofPoint outputPosition;
ofPoint outputOffset;
float outputScale;
+ float outputOffsetScale;
};