Browse Source

Integrate SurfaceHighlightWidget into Application

master
Krisjanis Rijnieks 9 years ago
parent
commit
5efee9111c
  1. 4
      src/Application/Gui.cpp
  2. 3
      src/Application/Gui.h
  3. 3
      src/Application/ProjectionMappingState.cpp
  4. 3
      src/Application/SourceSelectionState.cpp
  5. 1
      src/Application/SourceSelectionState.h
  6. 3
      src/Application/TextureMappingState.cpp
  7. 1
      src/Application/TextureMappingState.h
  8. 38
      src/Surfaces/SurfaceManagerGui.cpp
  9. 1
      src/Surfaces/SurfaceManagerGui.h

4
src/Application/Gui.cpp

@ -88,6 +88,10 @@ LayerPanelWidget & Gui::getLayerPanelWidget(){
return _layerPanelWidget; return _layerPanelWidget;
} }
SurfaceHighlightWidget & Gui::getSurfaceHighlightWidget(){
return _surfaceHighlightWidget;
}
void Gui::onScaleWidgetEvent(GuiWidgetEvent & event){ void Gui::onScaleWidgetEvent(GuiWidgetEvent & event){
GuiEvent e; GuiEvent e;
e.args = event.args; e.args = event.args;

3
src/Application/Gui.h

@ -6,6 +6,7 @@
#include "GuiBaseWidget.h" #include "GuiBaseWidget.h"
#include "ScaleWidget.h" #include "ScaleWidget.h"
#include "LayerPanelWidget.h" #include "LayerPanelWidget.h"
#include "SurfaceHighlightWidget.h"
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
@ -63,6 +64,7 @@ class Gui {
ScaleWidget & getScaleWidget(); ScaleWidget & getScaleWidget();
LayerPanelWidget & getLayerPanelWidget(); LayerPanelWidget & getLayerPanelWidget();
SurfaceHighlightWidget & getSurfaceHighlightWidget();
void onMousePressed(ofMouseEventArgs & args); void onMousePressed(ofMouseEventArgs & args);
void onMouseReleased(ofMouseEventArgs & args); void onMouseReleased(ofMouseEventArgs & args);
@ -80,6 +82,7 @@ class Gui {
ScaleWidget _scaleWidget; ScaleWidget _scaleWidget;
LayerPanelWidget _layerPanelWidget; LayerPanelWidget _layerPanelWidget;
SurfaceHighlightWidget _surfaceHighlightWidget;
}; };
} // piMapper } // piMapper

3
src/Application/ProjectionMappingState.cpp

@ -29,6 +29,9 @@ void ProjectionMappingState::draw(Application * app){
Gui::instance()->getLayerPanelWidget().setSurfaceManager(app->getSurfaceManager()); Gui::instance()->getLayerPanelWidget().setSurfaceManager(app->getSurfaceManager());
Gui::instance()->getLayerPanelWidget().draw(); Gui::instance()->getLayerPanelWidget().draw();
Gui::instance()->getSurfaceHighlightWidget().setSurfaceManager(app->getSurfaceManager());
Gui::instance()->getSurfaceHighlightWidget().draw();
} }
void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args){ void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args){

3
src/Application/SourceSelectionState.cpp

@ -14,6 +14,9 @@ SourceSelectionState * SourceSelectionState::instance(){
void SourceSelectionState::draw(Application * app){ void SourceSelectionState::draw(Application * app){
app->getGui()->draw(); app->getGui()->draw();
Gui::instance()->getSurfaceHighlightWidget().setSurfaceManager(app->getSurfaceManager());
Gui::instance()->getSurfaceHighlightWidget().draw();
} }
} // namespace piMapper } // namespace piMapper

1
src/Application/SourceSelectionState.h

@ -4,6 +4,7 @@
#include "ofEvents.h" #include "ofEvents.h"
#include "ofLog.h" #include "ofLog.h"
#include "ofGraphics.h" #include "ofGraphics.h"
#include "Gui.h"
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {

3
src/Application/TextureMappingState.cpp

@ -14,6 +14,9 @@ TextureMappingState * TextureMappingState::instance(){
void TextureMappingState::draw(Application * app){ void TextureMappingState::draw(Application * app){
app->getGui()->draw(); app->getGui()->draw();
Gui::instance()->getSurfaceHighlightWidget().setSurfaceManager(app->getSurfaceManager());
Gui::instance()->getSurfaceHighlightWidget().draw();
} }
void TextureMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args){ void TextureMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args){

1
src/Application/TextureMappingState.h

@ -10,6 +10,7 @@
#include "SetNextSourceCmd.h" #include "SetNextSourceCmd.h"
#include "SelNextSurfaceCmd.h" #include "SelNextSurfaceCmd.h"
#include "ToggleAnimatedSourceCmd.h" #include "ToggleAnimatedSourceCmd.h"
#include "Gui.h"
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {

38
src/Surfaces/SurfaceManagerGui.cpp

@ -64,9 +64,6 @@ void SurfaceManagerGui::draw(){
surfaceManager->draw(); surfaceManager->draw();
ofPopStyle(); ofPopStyle();
// highlight selected surface
drawSelectedSurfaceHighlight();
// hilight selected surface texture // hilight selected surface texture
drawSelectedSurfaceTextureHighlight(); drawSelectedSurfaceTextureHighlight();
@ -77,9 +74,6 @@ void SurfaceManagerGui::draw(){
// draw projection surfaces first // draw projection surfaces first
surfaceManager->draw(); surfaceManager->draw();
// highlight selected surface
drawSelectedSurfaceHighlight();
// draw projection mapping editing gui // draw projection mapping editing gui
projectionEditor.draw(); projectionEditor.draw();
@ -87,9 +81,6 @@ void SurfaceManagerGui::draw(){
// draw projection surfaces first // draw projection surfaces first
surfaceManager->draw(); surfaceManager->draw();
// highlight selected surface
drawSelectedSurfaceHighlight();
sourcesEditor.draw(); sourcesEditor.draw();
} }
} }
@ -281,35 +272,6 @@ int SurfaceManagerGui::getMode(){
return guiMode; 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(){ void SurfaceManagerGui::drawSelectedSurfaceTextureHighlight(){
if(surfaceManager->getSelectedSurface() == 0){ if(surfaceManager->getSelectedSurface() == 0){
return; return;

1
src/Surfaces/SurfaceManagerGui.h

@ -42,7 +42,6 @@ class SurfaceManagerGui {
void setMode(int newGuiMode); void setMode(int newGuiMode);
int getMode(); int getMode();
void drawSelectedSurfaceHighlight();
void drawSelectedSurfaceTextureHighlight(); void drawSelectedSurfaceTextureHighlight();
void startDrag(); void startDrag();
void stopDrag(); void stopDrag();

Loading…
Cancel
Save