Browse Source

Improve SurfaceHighlightWidget

Add drawing other surface outlines as sometimes parts of them overlap with the background
and it is not possible to see where are the other surfaces.
master
Krisjanis Rijnieks 9 years ago
parent
commit
3b37b4e4c2
  1. 45
      src/Gui/Widgets/SurfaceHighlightWidget.cpp
  2. 2
      src/Gui/Widgets/SurfaceHighlightWidget.h

45
src/Gui/Widgets/SurfaceHighlightWidget.cpp

@ -12,6 +12,8 @@ void SurfaceHighlightWidget::draw(){
return;
}
drawAllSurfaceOutlines();
if(_sm->getSelectedSurface() == 0){
return;
}
@ -20,28 +22,49 @@ void SurfaceHighlightWidget::draw(){
ofSetLineWidth(2);
ofSetColor(255);
if(_sm->getSelectedSurface()->getType() == SurfaceType::QUAD_SURFACE &&
((QuadSurface *)_sm->getSelectedSurface())->getPerspectiveWarping()){
ofPolyline line = _sm->getSelectedSurface()->getHitArea();
drawSurfaceOutlines(_sm->getSelectedSurface());
ofPopStyle();
}
void SurfaceHighlightWidget::drawAllSurfaceOutlines(){
if(_sm == 0){
return;
}
ofPushStyle();
ofSetColor(255, 255, 255, 150);
ofSetLineWidth(2);
for(unsigned int i = 0; i < _sm->size(); ++i){
if(_sm->getSurface(i) != _sm->getSelectedSurface()){
drawSurfaceOutlines(_sm->getSurface(i));
}
}
ofPopStyle();
}
void SurfaceHighlightWidget::drawSurfaceOutlines(BaseSurface * s){
// TODO: Use Surface::drawOutline here
if(s->getType() == SurfaceType::QUAD_SURFACE &&
((QuadSurface *)s)->getPerspectiveWarping()){
ofPolyline line = s->getHitArea();
line.draw();
}else if(_sm->getSelectedSurface()->getType() == SurfaceType::GRID_WARP_SURFACE){
_sm->getSelectedSurface()->getMesh().drawWireframe();
}else if(_sm->getSelectedSurface()->getType() == SurfaceType::HEXAGON_SURFACE){
_sm->getSelectedSurface()->getMesh().drawWireframe();
}else if(s->getType() == SurfaceType::GRID_WARP_SURFACE){
s->getMesh().drawWireframe();
}else if(s->getType() == SurfaceType::HEXAGON_SURFACE){
s->getMesh().drawWireframe();
}else{
ofPolyline p;
for(unsigned int i = 0;
i < _sm->getSelectedSurface()->getMesh().getVertices().size();
i < s->getMesh().getVertices().size();
++i){
p.addVertex(ofPoint(
_sm->getSelectedSurface()->getMesh().getVertices()[i]));
s->getMesh().getVertices()[i]));
}
p.close();
p.draw();
}
ofPopStyle();
}
} // namespace piMapper

2
src/Gui/Widgets/SurfaceHighlightWidget.h

@ -21,6 +21,8 @@ class SurfaceHighlightWidget : public GuiBaseWidget {
bool inside(float x, float y){ return false; }
void setSurfaceManager(SurfaceManager * sm){ _sm = sm; }
void drawAllSurfaceOutlines();
void drawSurfaceOutlines(BaseSurface * s);
private:
SurfaceManager * _sm;

Loading…
Cancel
Save