summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/Makefile13
-rw-r--r--gui/config.make142
-rw-r--r--gui/obj/osx/Release/.compiler_flags1
-rw-r--r--gui/src/lineTransformer.cpp117
-rw-r--r--gui/src/lineTransformer.h17
-rw-r--r--gui/src/main.cpp42
-rw-r--r--gui/src/ofApp.cpp172
-rw-r--r--gui/src/ofApp.h38
8 files changed, 542 insertions, 0 deletions
diff --git a/gui/Makefile b/gui/Makefile
new file mode 100644
index 0000000..177e172
--- /dev/null
+++ b/gui/Makefile
@@ -0,0 +1,13 @@
+# Attempt to load a config.make file.
+# If none is found, project defaults in config.project.make will be used.
+ifneq ($(wildcard config.make),)
+ include config.make
+endif
+
+# make sure the the OF_ROOT location is defined
+ifndef OF_ROOT
+ OF_ROOT=$(realpath ../../..)
+endif
+
+# call the project makefile!
+include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk
diff --git a/gui/config.make b/gui/config.make
new file mode 100644
index 0000000..469c495
--- /dev/null
+++ b/gui/config.make
@@ -0,0 +1,142 @@
+################################################################################
+# CONFIGURE PROJECT MAKEFILE (optional)
+# This file is where we make project specific configurations.
+################################################################################
+
+################################################################################
+# OF ROOT
+# The location of your root openFrameworks installation
+# (default) OF_ROOT = ../../..
+################################################################################
+ OF_ROOT = ../../openFrameworks
+
+################################################################################
+# PROJECT ROOT
+# The location of the project - a starting place for searching for files
+# (default) PROJECT_ROOT = . (this directory)
+#
+################################################################################
+# PROJECT_ROOT = .
+
+################################################################################
+# PROJECT SPECIFIC CHECKS
+# This is a project defined section to create internal makefile flags to
+# conditionally enable or disable the addition of various features within
+# this makefile. For instance, if you want to make changes based on whether
+# GTK is installed, one might test that here and create a variable to check.
+################################################################################
+# None
+
+################################################################################
+# PROJECT EXTERNAL SOURCE PATHS
+# These are fully qualified paths that are not within the PROJECT_ROOT folder.
+# Like source folders in the PROJECT_ROOT, these paths are subject to
+# exlclusion via the PROJECT_EXLCUSIONS list.
+#
+# (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank)
+#
+# Note: Leave a leading space when adding list items with the += operator
+################################################################################
+# PROJECT_EXTERNAL_SOURCE_PATHS =
+
+################################################################################
+# PROJECT EXCLUSIONS
+# These makefiles assume that all folders in your current project directory
+# and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations
+# to look for source code. The any folders or files that match any of the
+# items in the PROJECT_EXCLUSIONS list below will be ignored.
+#
+# Each item in the PROJECT_EXCLUSIONS list will be treated as a complete
+# string unless teh user adds a wildcard (%) operator to match subdirectories.
+# GNU make only allows one wildcard for matching. The second wildcard (%) is
+# treated literally.
+#
+# (default) PROJECT_EXCLUSIONS = (blank)
+#
+# Will automatically exclude the following:
+#
+# $(PROJECT_ROOT)/bin%
+# $(PROJECT_ROOT)/obj%
+# $(PROJECT_ROOT)/%.xcodeproj
+#
+# Note: Leave a leading space when adding list items with the += operator
+################################################################################
+# PROJECT_EXCLUSIONS =
+
+################################################################################
+# PROJECT LINKER FLAGS
+# These flags will be sent to the linker when compiling the executable.
+#
+# (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs
+#
+# Note: Leave a leading space when adding list items with the += operator
+################################################################################
+
+# Currently, shared libraries that are needed are copied to the
+# $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to
+# add a runtime path to search for those shared libraries, since they aren't
+# incorporated directly into the final executable application binary.
+# TODO: should this be a default setting?
+# PROJECT_LDFLAGS=-Wl,-rpath=./libs
+
+################################################################################
+# PROJECT DEFINES
+# Create a space-delimited list of DEFINES. The list will be converted into
+# CFLAGS with the "-D" flag later in the makefile.
+#
+# (default) PROJECT_DEFINES = (blank)
+#
+# Note: Leave a leading space when adding list items with the += operator
+################################################################################
+# PROJECT_DEFINES =
+
+################################################################################
+# PROJECT CFLAGS
+# This is a list of fully qualified CFLAGS required when compiling for this
+# project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS
+# defined in your platform specific core configuration files. These flags are
+# presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below.
+#
+# (default) PROJECT_CFLAGS = (blank)
+#
+# Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in
+# your platform specific configuration file will be applied by default and
+# further flags here may not be needed.
+#
+# Note: Leave a leading space when adding list items with the += operator
+################################################################################
+# PROJECT_CFLAGS =
+
+################################################################################
+# PROJECT OPTIMIZATION CFLAGS
+# These are lists of CFLAGS that are target-specific. While any flags could
+# be conditionally added, they are usually limited to optimization flags.
+# These flags are added BEFORE the PROJECT_CFLAGS.
+#
+# PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets.
+#
+# (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank)
+#
+# PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets.
+#
+# (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank)
+#
+# Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the
+# PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration
+# file will be applied by default and further optimization flags here may not
+# be needed.
+#
+# Note: Leave a leading space when adding list items with the += operator
+################################################################################
+# PROJECT_OPTIMIZATION_CFLAGS_RELEASE =
+# PROJECT_OPTIMIZATION_CFLAGS_DEBUG =
+
+################################################################################
+# PROJECT COMPILERS
+# Custom compilers can be set for CC and CXX
+# (default) PROJECT_CXX = (blank)
+# (default) PROJECT_CC = (blank)
+# Note: Leave a leading space when adding list items with the += operator
+################################################################################
+# PROJECT_CXX =
+# PROJECT_CC =
diff --git a/gui/obj/osx/Release/.compiler_flags b/gui/obj/osx/Release/.compiler_flags
new file mode 100644
index 0000000..b41c9fb
--- /dev/null
+++ b/gui/obj/osx/Release/.compiler_flags
@@ -0,0 +1 @@
+-Os -mtune=native -DNDEBUG -stdlib=libc++ -Wall -fexceptions -fpascal-strings -mmacosx-version-min=10.9 -D__MACOSX_CORE__ -x objective-c++ -std=c++11 -I../../openFrameworks/libs/FreeImage/include -I../../openFrameworks/libs/boost/include -I../../openFrameworks/libs/boost/include/boost -I../../openFrameworks/libs/cairo/include -I../../openFrameworks/libs/cairo/include/cairo -I../../openFrameworks/libs/curl/include -I../../openFrameworks/libs/curl/include/curl -I../../openFrameworks/libs/fmodex/include -I../../openFrameworks/libs/freetype/include -I../../openFrameworks/libs/freetype/include/freetype2 -I../../openFrameworks/libs/freetype/include/freetype2/freetype -I../../openFrameworks/libs/freetype/include/freetype2/freetype/config -I../../openFrameworks/libs/freetype/include/freetype2/freetype/internal -I../../openFrameworks/libs/freetype/include/freetype2/freetype/internal/services -I../../openFrameworks/libs/glew/include -I../../openFrameworks/libs/glew/include/GL -I../../openFrameworks/libs/glfw/include -I../../openFrameworks/libs/glfw/include/GLFW -I../../openFrameworks/libs/glm/include -I../../openFrameworks/libs/glm/include/glm -I../../openFrameworks/libs/glm/include/glm/detail -I../../openFrameworks/libs/glm/include/glm/gtc -I../../openFrameworks/libs/glm/include/glm/gtx -I../../openFrameworks/libs/glm/include/glm/simd -I../../openFrameworks/libs/json/include -I../../openFrameworks/libs/kiss/include -I../../openFrameworks/libs/pugixml/include -I../../openFrameworks/libs/rtAudio/include -I../../openFrameworks/libs/tess2/include -I../../openFrameworks/libs/uriparser/include -I../../openFrameworks/libs/uriparser/include/uriparser -I../../openFrameworks/libs/utf8/include -I../../openFrameworks/libs/utf8/include/utf8 -I../../openFrameworks/libs/utf8cpp/include -I../../openFrameworks/libs/utf8cpp/include/utf8 -I../../openFrameworks/libs/openFrameworks -I../../openFrameworks/libs/openFrameworks/3d -I../../openFrameworks/libs/openFrameworks/app -I../../openFrameworks/libs/openFrameworks/communication -I../../openFrameworks/libs/openFrameworks/events -I../../openFrameworks/libs/openFrameworks/gl -I../../openFrameworks/libs/openFrameworks/graphics -I../../openFrameworks/libs/openFrameworks/math -I../../openFrameworks/libs/openFrameworks/sound -I../../openFrameworks/libs/openFrameworks/types -I../../openFrameworks/libs/openFrameworks/utils -I../../openFrameworks/libs/openFrameworks/video -I/work/workspace/raverony/gui/src -stdlib=libc++ -mmacosx-version-min=10.9 -v -framework Accelerate -framework QTKit -framework AGL -framework ApplicationServices -framework AudioToolbox -framework CoreAudio -framework CoreFoundation -framework CoreServices -framework OpenGL -framework IOKit -framework Cocoa -framework CoreVideo -framework AVFoundation -framework CoreMedia -framework QuartzCore -framework Security -framework LDAP
diff --git a/gui/src/lineTransformer.cpp b/gui/src/lineTransformer.cpp
new file mode 100644
index 0000000..bf237d7
--- /dev/null
+++ b/gui/src/lineTransformer.cpp
@@ -0,0 +1,117 @@
+#include "lineTransformer.h"
+
+void lineTransformer::drawWarpFrame(glm::vec2 warpframe[4]){
+ ofSetColor(255,255,255);
+ ofNoFill();
+ for (int i=0;i<4;i++){
+ ofDrawCircle(warpframe[i],25);
+ ofDrawLine(warpframe[i],warpframe[(i+1)%4]);
+ }
+}
+
+void lineTransformer::gaussianElimination(float * input, int n)
+{
+ auto i = 0;
+ auto j = 0;
+ auto m = n - 1;
+
+ while (i < m && j < n)
+ {
+ auto iMax = i;
+ for (auto k = i + 1; k < m; ++k)
+ {
+ if (fabs(input[k * n + j]) > fabs(input[iMax * n + j]))
+ {
+ iMax = k;
+ }
+ }
+
+ if (input[iMax * n + j] != 0)
+ {
+ if (i != iMax)
+ {
+ for (auto k = 0; k < n; ++k)
+ {
+ auto ikIn = input[i * n + k];
+ input[i * n + k] = input[iMax * n + k];
+ input[iMax * n + k] = ikIn;
+ }
+ }
+
+ float ijIn = input[i * n + j];
+ for (auto k = 0; k < n; ++k)
+ {
+ input[i * n + k] /= ijIn;
+ }
+
+ for (auto u = i + 1; u < m; ++u)
+ {
+ auto ujIn = input[u * n + j];
+ for (auto k = 0; k < n; ++k)
+ {
+ input[u * n + k] -= ujIn * input[i * n + k];
+ }
+ }
+
+ ++i;
+ }
+ ++j;
+ }
+
+ for (auto i = m - 2; i >= 0; --i)
+ {
+ for (auto j = i + 1; j < n - 1; ++j)
+ {
+ input[i * n + m] -= input[i * n + j] * input[j * n + m];
+ }
+ }
+}
+
+glm::mat4 lineTransformer::getPerspectiveTransformMatrix(const glm::vec2 src[4], const glm::vec2 dst[4])
+{
+ float p[8][9] =
+ {
+ { -src[0][0], -src[0][1], -1, 0, 0, 0, src[0][0] * dst[0][0], src[0][1] * dst[0][0], -dst[0][0] }, // h11
+ { 0, 0, 0, -src[0][0], -src[0][1], -1, src[0][0] * dst[0][1], src[0][1] * dst[0][1], -dst[0][1] }, // h12
+ { -src[1][0], -src[1][1], -1, 0, 0, 0, src[1][0] * dst[1][0], src[1][1] * dst[1][0], -dst[1][0] }, // h13
+ { 0, 0, 0, -src[1][0], -src[1][1], -1, src[1][0] * dst[1][1], src[1][1] * dst[1][1], -dst[1][1] }, // h21
+ { -src[2][0], -src[2][1], -1, 0, 0, 0, src[2][0] * dst[2][0], src[2][1] * dst[2][0], -dst[2][0] }, // h22
+ { 0, 0, 0, -src[2][0], -src[2][1], -1, src[2][0] * dst[2][1], src[2][1] * dst[2][1], -dst[2][1] }, // h23
+ { -src[3][0], -src[3][1], -1, 0, 0, 0, src[3][0] * dst[3][0], src[3][1] * dst[3][0], -dst[3][0] }, // h31
+ { 0, 0, 0, -src[3][0], -src[3][1], -1, src[3][0] * dst[3][1], src[3][1] * dst[3][1], -dst[3][1] }, // h32
+ };
+
+ gaussianElimination(&p[0][0], 9);
+
+ return glm::mat4(p[0][8], p[3][8], 0, p[6][8],
+ p[1][8], p[4][8], 0, p[7][8],
+ 0, 0, 1, 0,
+ p[2][8], p[5][8], 0, 1);
+}
+
+ofPolyline lineTransformer::polyLineTransform(const ofPolyline& poly, ofMatrix4x4 xform){
+ ofPolyline tempPoly;
+ for (auto& p:poly){
+ tempPoly.addVertex(ofVec3f(p)*xform);
+ }
+ return tempPoly;
+}
+
+ofPolyline lineTransformer::makePolygon(int num,float diam){
+ ofPolyline poly;
+ float step=PI*2/num;
+ for (int i=0;i<=num;i++){
+ poly.addVertex(cos(step*i)*diam,sin(step*i)*diam);
+ }
+ return poly;
+}
+
+void lineTransformer::drawPoly(ofPolyline poly,float x,float y){
+ glPushMatrix();
+ ofTranslate(x,y);
+ poly.draw();
+ for (int i=0;i<poly.size();i++){
+ ofDrawBitmapString(poly.getDegreesAtIndex(i),poly[i].x+10,poly[i].y+10,0);
+ }
+ glPopMatrix();
+}
diff --git a/gui/src/lineTransformer.h b/gui/src/lineTransformer.h
new file mode 100644
index 0000000..8268b81
--- /dev/null
+++ b/gui/src/lineTransformer.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "ofMain.h"
+
+class lineTransformer {
+
+ public:
+ lineTransformer(){
+ }
+ void static drawWarpFrame(glm::vec2 warpframe[4]);
+ void static gaussianElimination(float * input, int n);
+ glm::mat4 static getPerspectiveTransformMatrix(const glm::vec2 src[4], const glm::vec2 dst[4]);
+ ofPolyline static polyLineTransform(const ofPolyline& poly, ofMatrix4x4 xform);
+ ofPolyline static makePolygon(int num,float diam);
+ void static drawPoly(ofPolyline poly,float x,float y);
+
+}; \ No newline at end of file
diff --git a/gui/src/main.cpp b/gui/src/main.cpp
new file mode 100644
index 0000000..ed7e18f
--- /dev/null
+++ b/gui/src/main.cpp
@@ -0,0 +1,42 @@
+#include "ofMain.h"
+#include "ofApp.h"
+
+
+//========================================================================
+int main(int argc, char *argv[]){
+
+
+ ofGLFWWindowSettings settings;
+
+ settings.width = 600;
+ settings.height = 1200;
+ settings.setPosition(ofVec2f(0,0));
+ settings.resizable = true;
+
+ //settings.decorated = false; //doesn't suppress FS title bar
+ shared_ptr<ofAppBaseWindow> guiWindow = ofCreateWindow(settings);
+ guiWindow->setVerticalSync(false);
+
+ // share OpenGL resources with other windows
+ settings.shareContextWith = guiWindow;
+ settings.decorated = true;
+
+ settings.width = 1200;
+ settings.height = 900 ;
+ settings.setPosition(ofVec2f(1700,0));
+ settings.resizable = false;
+
+ shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);
+ mainWindow->setVerticalSync(false);
+
+ shared_ptr<ofApp> mainApp(new ofApp);
+ //mainApp->setupGui();
+
+ ofAddListener(guiWindow->events().draw,mainApp.get(),&ofApp::drawGui);
+ ofAddListener(guiWindow->events().windowResized,mainApp.get(),&ofApp::guiWindowResized);
+ ofAddListener(guiWindow->events().keyPressed,mainApp.get(),&ofApp::guiKeyPressed);
+
+ ofRunApp(mainWindow, mainApp);
+ ofRunMainLoop();
+}
+ \ No newline at end of file
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);
+
+
+ //}
+
+}
diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h
new file mode 100644
index 0000000..d28f393
--- /dev/null
+++ b/gui/src/ofApp.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include "ofMain.h"
+#include "lineTransformer.h"
+
+class ofApp: public ofBaseApp {
+
+ public:
+ void setup();
+ void update();
+ void updateGui(ofEventArgs & args);
+ void draw();
+ void exit();
+
+ void drawGui(ofEventArgs & args);
+ void guiKeyPressed(ofKeyEventArgs & args);
+
+ void keyPressed(ofKeyEventArgs &keyargs);
+ void keyReleased(int key);
+ void mouseMoved(int x, int y );
+ void mouseDragged(int x, int y, int button);
+ void mousePressed(int x, int y, int button);
+ void mouseReleased(int x, int y, int button);
+ void mouseEntered(int x, int y);
+ void mouseExited(int x, int y);
+ void windowResized(int w, int h);
+ void dragEvent(ofDragInfo dragInfo);
+
+ void guiWindowResized(ofResizeEventArgs &resizeargs);
+
+ bool commandPressed;
+
+
+ glm::vec2 warpframe[4];
+ int select_warpframe;
+ bool bDrawFrame;
+
+};