From 5efee9111cc1334ef6b0626ae38d697412ab59fe Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Tue, 6 Sep 2016 20:51:15 +0200 Subject: [PATCH] Integrate SurfaceHighlightWidget into Application --- src/Application/Gui.cpp | 4 +++ src/Application/Gui.h | 3 ++ src/Application/ProjectionMappingState.cpp | 3 ++ src/Application/SourceSelectionState.cpp | 3 ++ src/Application/SourceSelectionState.h | 1 + src/Application/TextureMappingState.cpp | 3 ++ src/Application/TextureMappingState.h | 1 + src/Surfaces/SurfaceManagerGui.cpp | 38 ---------------------- src/Surfaces/SurfaceManagerGui.h | 1 - 9 files changed, 18 insertions(+), 39 deletions(-) diff --git a/src/Application/Gui.cpp b/src/Application/Gui.cpp index 86fb958..7b8f23e 100644 --- a/src/Application/Gui.cpp +++ b/src/Application/Gui.cpp @@ -88,6 +88,10 @@ LayerPanelWidget & Gui::getLayerPanelWidget(){ return _layerPanelWidget; } +SurfaceHighlightWidget & Gui::getSurfaceHighlightWidget(){ + return _surfaceHighlightWidget; +} + void Gui::onScaleWidgetEvent(GuiWidgetEvent & event){ GuiEvent e; e.args = event.args; diff --git a/src/Application/Gui.h b/src/Application/Gui.h index e98f827..f4d0ffc 100644 --- a/src/Application/Gui.h +++ b/src/Application/Gui.h @@ -6,6 +6,7 @@ #include "GuiBaseWidget.h" #include "ScaleWidget.h" #include "LayerPanelWidget.h" +#include "SurfaceHighlightWidget.h" namespace ofx { namespace piMapper { @@ -63,6 +64,7 @@ class Gui { ScaleWidget & getScaleWidget(); LayerPanelWidget & getLayerPanelWidget(); + SurfaceHighlightWidget & getSurfaceHighlightWidget(); void onMousePressed(ofMouseEventArgs & args); void onMouseReleased(ofMouseEventArgs & args); @@ -80,6 +82,7 @@ class Gui { ScaleWidget _scaleWidget; LayerPanelWidget _layerPanelWidget; + SurfaceHighlightWidget _surfaceHighlightWidget; }; } // piMapper diff --git a/src/Application/ProjectionMappingState.cpp b/src/Application/ProjectionMappingState.cpp index 25b95c5..0091e16 100644 --- a/src/Application/ProjectionMappingState.cpp +++ b/src/Application/ProjectionMappingState.cpp @@ -29,6 +29,9 @@ void ProjectionMappingState::draw(Application * app){ Gui::instance()->getLayerPanelWidget().setSurfaceManager(app->getSurfaceManager()); Gui::instance()->getLayerPanelWidget().draw(); + + Gui::instance()->getSurfaceHighlightWidget().setSurfaceManager(app->getSurfaceManager()); + Gui::instance()->getSurfaceHighlightWidget().draw(); } void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args){ diff --git a/src/Application/SourceSelectionState.cpp b/src/Application/SourceSelectionState.cpp index 7019b07..7684dfb 100644 --- a/src/Application/SourceSelectionState.cpp +++ b/src/Application/SourceSelectionState.cpp @@ -14,6 +14,9 @@ SourceSelectionState * SourceSelectionState::instance(){ void SourceSelectionState::draw(Application * app){ app->getGui()->draw(); + + Gui::instance()->getSurfaceHighlightWidget().setSurfaceManager(app->getSurfaceManager()); + Gui::instance()->getSurfaceHighlightWidget().draw(); } } // namespace piMapper diff --git a/src/Application/SourceSelectionState.h b/src/Application/SourceSelectionState.h index fb0b1b8..d6c1ba0 100644 --- a/src/Application/SourceSelectionState.h +++ b/src/Application/SourceSelectionState.h @@ -4,6 +4,7 @@ #include "ofEvents.h" #include "ofLog.h" #include "ofGraphics.h" +#include "Gui.h" namespace ofx { namespace piMapper { diff --git a/src/Application/TextureMappingState.cpp b/src/Application/TextureMappingState.cpp index 20f0d6a..512e662 100644 --- a/src/Application/TextureMappingState.cpp +++ b/src/Application/TextureMappingState.cpp @@ -14,6 +14,9 @@ TextureMappingState * TextureMappingState::instance(){ void TextureMappingState::draw(Application * app){ app->getGui()->draw(); + + Gui::instance()->getSurfaceHighlightWidget().setSurfaceManager(app->getSurfaceManager()); + Gui::instance()->getSurfaceHighlightWidget().draw(); } void TextureMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args){ diff --git a/src/Application/TextureMappingState.h b/src/Application/TextureMappingState.h index f66dd68..c905f26 100644 --- a/src/Application/TextureMappingState.h +++ b/src/Application/TextureMappingState.h @@ -10,6 +10,7 @@ #include "SetNextSourceCmd.h" #include "SelNextSurfaceCmd.h" #include "ToggleAnimatedSourceCmd.h" +#include "Gui.h" namespace ofx { namespace piMapper { diff --git a/src/Surfaces/SurfaceManagerGui.cpp b/src/Surfaces/SurfaceManagerGui.cpp index 467675a..f3c9c0a 100644 --- a/src/Surfaces/SurfaceManagerGui.cpp +++ b/src/Surfaces/SurfaceManagerGui.cpp @@ -64,9 +64,6 @@ void SurfaceManagerGui::draw(){ surfaceManager->draw(); ofPopStyle(); - // highlight selected surface - drawSelectedSurfaceHighlight(); - // hilight selected surface texture drawSelectedSurfaceTextureHighlight(); @@ -77,9 +74,6 @@ void SurfaceManagerGui::draw(){ // draw projection surfaces first surfaceManager->draw(); - // highlight selected surface - drawSelectedSurfaceHighlight(); - // draw projection mapping editing gui projectionEditor.draw(); @@ -87,9 +81,6 @@ void SurfaceManagerGui::draw(){ // draw projection surfaces first surfaceManager->draw(); - // highlight selected surface - drawSelectedSurfaceHighlight(); - sourcesEditor.draw(); } } @@ -281,35 +272,6 @@ int SurfaceManagerGui::getMode(){ return guiMode; } -void SurfaceManagerGui::drawSelectedSurfaceHighlight(){ - if(surfaceManager->getSelectedSurface() == 0){ - return; - } - - if(surfaceManager->getSelectedSurface()->getType() == SurfaceType::QUAD_SURFACE && - ((QuadSurface *)surfaceManager->getSelectedSurface())->getPerspectiveWarping()){ - ofPolyline line = surfaceManager->getSelectedSurface()->getHitArea(); - ofPushStyle(); - ofSetLineWidth(1); - ofSetColor(255, 255, 255, 255); - line.draw(); - ofPopStyle(); - }else if(surfaceManager->getSelectedSurface()->getType() == SurfaceType::GRID_WARP_SURFACE){ - surfaceManager->getSelectedSurface()->getMesh().drawWireframe(); - }else{ - ofPolyline p; - for(unsigned int i = 0; - i < surfaceManager->getSelectedSurface()->getMesh().getVertices().size(); - ++i){ - - p.addVertex(ofPoint( - surfaceManager->getSelectedSurface()->getMesh().getVertices()[i])); - } - p.close(); - p.draw(); - } -} - void SurfaceManagerGui::drawSelectedSurfaceTextureHighlight(){ if(surfaceManager->getSelectedSurface() == 0){ return; diff --git a/src/Surfaces/SurfaceManagerGui.h b/src/Surfaces/SurfaceManagerGui.h index c802ace..727c4bc 100644 --- a/src/Surfaces/SurfaceManagerGui.h +++ b/src/Surfaces/SurfaceManagerGui.h @@ -42,7 +42,6 @@ class SurfaceManagerGui { void setMode(int newGuiMode); int getMode(); - void drawSelectedSurfaceHighlight(); void drawSelectedSurfaceTextureHighlight(); void startDrag(); void stopDrag();