Browse Source

Put contents of TextureConsumersWidget into TextureHighlightWidget

master
Krisjanis Rijnieks 9 years ago
parent
commit
da547889d6
  1. 2
      src/Application/Modes/TextureMappingMode.cpp
  2. 2
      src/Commands/SetApplicationModeCmd.cpp
  3. 4
      src/Gui/Gui.cpp
  4. 3
      src/Gui/Gui.h
  5. 49
      src/Gui/Widgets/TextureConsumersWidget.cpp
  6. 34
      src/Gui/Widgets/TextureConsumersWidget.h
  7. 30
      src/Gui/Widgets/TextureHighlightWidget.cpp
  8. 4
      src/Gui/Widgets/TextureHighlightWidget.h

2
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();

2
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();

4
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;

3
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

49
src/Gui/Widgets/TextureConsumersWidget.cpp

@ -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

34
src/Gui/Widgets/TextureConsumersWidget.h

@ -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<BaseSurface *> _consumerSurfaces;
};
} // namespace piMapper
} // namespace ofx

30
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

4
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<BaseSurface *> _consumerSurfaces;
};
} // namespace piMapper

Loading…
Cancel
Save