Browse Source

Implement `SurfaceManager` `selectNextVertex` and `selectPrevVertex` methods

master
Krisjanis Rijnieks 9 years ago
parent
commit
456845f33f
  1. 35
      src/Surfaces/SurfaceManager.cpp
  2. 7
      src/Surfaces/SurfaceManager.h

35
src/Surfaces/SurfaceManager.cpp

@ -8,6 +8,7 @@ SurfaceManager::SurfaceManager(){
selectedSurface = 0;
ofAddListener(_surfaces.vertexChangedEvent, this, &SurfaceManager::onVertexChanged);
ofAddListener(_surfaces.verticesChangedEvent, this, &SurfaceManager::onVerticesChanged);
_selectedVertexIndex = 0;
}
void SurfaceManager::draw(){
@ -151,12 +152,38 @@ BaseSurface * SurfaceManager::getSelectedSurface(){
return selectedSurface;
}
int SurfaceManager::selectNextVertex(){
//
// TODO: select vertex should be implemented ad BaseSurface level
void SurfaceManager::selectNextVertex(){
if(selectedSurface == 0){
return;
}
int numVertices = selectedSurface->getVertices().size();
if(_selectedVertexIndex < numVertices - 1){
_selectedVertexIndex += 1;
}else{
_selectedVertexIndex = 0;
}
ofNotifyEvent(vertexSelectedEvent, _selectedVertexIndex, this);
}
int SurfaceManager::selectPrevVertex(){
//
// TODO: select vertex should be implemented at BaseSurface level
void SurfaceManager::selectPrevVertex(){
if(selectedSurface == 0){
return;
}
int numVertices = selectedSurface->getVertices().size();
if(_selectedVertexIndex > 0){
_selectedVertexIndex -= 1;
}else{
_selectedVertexIndex = numVertices - 1;
}
ofNotifyEvent(vertexSelectedEvent, _selectedVertexIndex, this);
}
void SurfaceManager::deselectSurface(){

7
src/Surfaces/SurfaceManager.h

@ -44,14 +44,15 @@ class SurfaceManager {
BaseSurface * getSelectedSurface();
// These should trigger an event for the GUI layer to catch
int selectNextVertex();
int selectPrevVertex();
void selectNextVertex();
void selectPrevVertex();
int size();
ofEvent <ofVec3f> vertexChangedEvent;
ofEvent <vector<ofVec3f>> verticesChangedEvent;
ofEvent <int> surfaceSelectedEvent;
ofEvent <int> vertexSelectedEvent;
void onVertexChanged(ofVec3f & vertex);
void onVerticesChanged(vector<ofVec3f> & vertices);
@ -61,6 +62,8 @@ class SurfaceManager {
ofxXmlSettings xmlSettings;
MediaServer * mediaServer;
SurfaceStack _surfaces;
int _selectedVertexIndex;
};
} // namespace piMapper

Loading…
Cancel
Save