diff --git a/src/Application/Modes/TextureMappingMode.cpp b/src/Application/Modes/TextureMappingMode.cpp index 2836dfd..76cb98b 100644 --- a/src/Application/Modes/TextureMappingMode.cpp +++ b/src/Application/Modes/TextureMappingMode.cpp @@ -21,7 +21,6 @@ TextureMappingMode::TextureMappingMode(){ void TextureMappingMode::setup(Application * app){ Gui::instance()->getTextureHighlightWidget().setSurfaceManager(app->getSurfaceManager()); - Gui::instance()->getTextureConsumersWidget().setSurfaceManager(app->getSurfaceManager()); } void TextureMappingMode::update(Application * app){ @@ -68,7 +67,6 @@ void TextureMappingMode::draw(Application * app){ ofPushMatrix(); ofTranslate(_canvasTranslate.x, _canvasTranslate.y); - Gui::instance()->getTextureConsumersWidget().draw(); Gui::instance()->getTextureHighlightWidget().draw(); Gui::instance()->getTextureEditorWidget().draw(); ofPopMatrix(); diff --git a/src/Commands/SetApplicationModeCmd.cpp b/src/Commands/SetApplicationModeCmd.cpp index d6bb149..69f8686 100644 --- a/src/Commands/SetApplicationModeCmd.cpp +++ b/src/Commands/SetApplicationModeCmd.cpp @@ -20,7 +20,7 @@ void SetApplicationModeCmd::exec(){ Gui::instance()->getTextureEditorWidget().setSurface( _application->getSurfaceManager()->getSelectedSurface()); - Gui::instance()->getTextureConsumersWidget().findConsumerSurfaces(); + Gui::instance()->getTextureHighlightWidget().findConsumerSurfaces(); if(_applicationState != PresentationMode::instance()){ ofShowCursor(); diff --git a/src/Gui/Gui.cpp b/src/Gui/Gui.cpp index c547b53..da147f1 100644 --- a/src/Gui/Gui.cpp +++ b/src/Gui/Gui.cpp @@ -108,10 +108,6 @@ SourcesEditorWidget & Gui::getSourcesEditorWidget(){ return _sourcesEditorWidget; } -TextureConsumersWidget & Gui::getTextureConsumersWidget(){ - return _textureConsumersWidget; -} - void Gui::onScaleWidgetEvent(GuiWidgetEvent & event){ GuiEvent e; e.args = event.args; diff --git a/src/Gui/Gui.h b/src/Gui/Gui.h index c24e836..2b04367 100644 --- a/src/Gui/Gui.h +++ b/src/Gui/Gui.h @@ -11,7 +11,6 @@ #include "TextureEditorWidget.h" #include "ProjectionEditorWidget.h" #include "SourcesEditorWidget.h" -#include "TextureConsumersWidget.h" namespace ofx { namespace piMapper { @@ -74,7 +73,6 @@ class Gui { TextureEditorWidget & getTextureEditorWidget(); ProjectionEditorWidget & getProjectionEditorWidget(); SourcesEditorWidget & getSourcesEditorWidget(); - TextureConsumersWidget & getTextureConsumersWidget(); // Consider these as a part of the application states/modes. void onMousePressed(ofMouseEventArgs & args); @@ -98,7 +96,6 @@ class Gui { TextureEditorWidget _textureEditorWidget; ProjectionEditorWidget _projectionEditorWidget; SourcesEditorWidget _sourcesEditorWidget; - TextureConsumersWidget _textureConsumersWidget; }; } // piMapper diff --git a/src/Gui/Widgets/TextureConsumersWidget.cpp b/src/Gui/Widgets/TextureConsumersWidget.cpp deleted file mode 100644 index 158f99b..0000000 --- a/src/Gui/Widgets/TextureConsumersWidget.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "TextureConsumersWidget.h" - -namespace ofx { -namespace piMapper { - -TextureConsumersWidget::TextureConsumersWidget(){ - _sm = 0; -} - -void TextureConsumersWidget::draw(){ - if(_sm == 0){ - return; - } - - if(_sm->getSelectedSurface() == 0){ - return; - } - - ofPushStyle(); - ofSetLineWidth(2); - ofSetColor(0, 255, 255, 150); - for(unsigned int i = 0; i < _consumerSurfaces.size(); ++i){ - _consumerSurfaces[i]->getTextureHitArea().draw(); - } - ofPopStyle(); -} - -void TextureConsumersWidget::findConsumerSurfaces(){ - if(_sm == 0){ - return; - } - - if(_sm->getSelectedSurface() == 0){ - return; - } - - BaseSource * activeSource = _sm->getSelectedSurface()->getSource(); - - _consumerSurfaces.clear(); - for(unsigned int i = 0; i < _sm->getActivePreset()->size(); ++i){ - if( activeSource == _sm->getActivePreset()->at(i)->getSource() && - _sm->getSelectedSurface() != _sm->getActivePreset()->at(i)){ - _consumerSurfaces.push_back(_sm->getActivePreset()->at(i)); - } - } -} - -} // namespace piMapper -} // namespace ofx diff --git a/src/Gui/Widgets/TextureConsumersWidget.h b/src/Gui/Widgets/TextureConsumersWidget.h deleted file mode 100644 index 2c2f93c..0000000 --- a/src/Gui/Widgets/TextureConsumersWidget.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include "GuiBaseWidget.h" -#include "SurfaceManager.h" -#include "BaseSurface.h" - -namespace ofx { -namespace piMapper { - -class TextureConsumersWidget : public GuiBaseWidget { - public: - TextureConsumersWidget(); - - void setup(){} - void update(){} - void draw(); - - void onMousePressed(ofMouseEventArgs & args){} - void onMouseReleased(ofMouseEventArgs & args){} - void onMouseDragged(ofMouseEventArgs & args){} - - bool inside(float x, float y){ return false; } - - void setSurfaceManager(SurfaceManager * sm){ _sm = sm; } - void findConsumerSurfaces(); - - private: - SurfaceManager * _sm; - - vector _consumerSurfaces; -}; - -} // namespace piMapper -} // namespace ofx \ No newline at end of file diff --git a/src/Gui/Widgets/TextureHighlightWidget.cpp b/src/Gui/Widgets/TextureHighlightWidget.cpp index 8863dcc..062787e 100644 --- a/src/Gui/Widgets/TextureHighlightWidget.cpp +++ b/src/Gui/Widgets/TextureHighlightWidget.cpp @@ -16,13 +16,41 @@ void TextureHighlightWidget::draw(){ return; } - ofPolyline line = _sm->getSelectedSurface()->getTextureHitArea(); + // Draw texture coordinates of the surfaces consuming this source ofPushStyle(); ofSetLineWidth(2); + ofSetColor(0, 255, 255, 150); + for(unsigned int i = 0; i < _consumerSurfaces.size(); ++i){ + _consumerSurfaces[i]->getTextureHitArea().draw(); + } + + // Draw the texture coordinates of the selected surface + ofPolyline line = _sm->getSelectedSurface()->getTextureHitArea(); + ofSetLineWidth(2); ofSetColor(0, 255, 255); line.draw(); ofPopStyle(); } +void TextureHighlightWidget::findConsumerSurfaces(){ + if(_sm == 0){ + return; + } + + if(_sm->getSelectedSurface() == 0){ + return; + } + + BaseSource * activeSource = _sm->getSelectedSurface()->getSource(); + + _consumerSurfaces.clear(); + for(unsigned int i = 0; i < _sm->getActivePreset()->size(); ++i){ + if( activeSource == _sm->getActivePreset()->at(i)->getSource() && + _sm->getSelectedSurface() != _sm->getActivePreset()->at(i)){ + _consumerSurfaces.push_back(_sm->getActivePreset()->at(i)); + } + } +} + } // namespace piMapper } // namespace ofx diff --git a/src/Gui/Widgets/TextureHighlightWidget.h b/src/Gui/Widgets/TextureHighlightWidget.h index 7328fd0..9ea51ae 100644 --- a/src/Gui/Widgets/TextureHighlightWidget.h +++ b/src/Gui/Widgets/TextureHighlightWidget.h @@ -2,6 +2,7 @@ #include "GuiBaseWidget.h" #include "SurfaceManager.h" +#include "BaseSurface.h" namespace ofx { namespace piMapper { @@ -21,9 +22,12 @@ class TextureHighlightWidget : public GuiBaseWidget { bool inside(float x, float y){ return false; } void setSurfaceManager(SurfaceManager * sm){ _sm = sm; } + void findConsumerSurfaces(); private: SurfaceManager * _sm; + + vector _consumerSurfaces; }; } // namespace piMapper