Browse Source

Add `selectVertex` to `SurfaceManager`

master
Krisjanis Rijnieks 9 years ago
parent
commit
14aa1aedfe
  1. 18
      src/Surfaces/SurfaceManager.cpp
  2. 2
      src/Surfaces/SurfaceManager.h

18
src/Surfaces/SurfaceManager.cpp

@ -193,6 +193,20 @@ void SurfaceManager::selectPrevVertex(){
ofNotifyEvent(vertexSelectedEvent, _selectedVertexIndex, this);
}
void SurfaceManager::selectVertex(int i){
if(selectedSurface == 0){
return;
}
if(i > selectedSurface->getVertices().size() - 1){
ofLogError("SurfaceManager::selectVertex") << "index out of bounds" << endl;
return;
}
_selectedVertexIndex = i;
ofNotifyEvent(vertexSelectedEvent, _selectedVertexIndex, this);
}
void SurfaceManager::moveSelectionBy(ofVec2f v){
if(selectedSurface == 0){
return;
@ -226,6 +240,10 @@ int SurfaceManager::size(){
return _surfaces.size();
}
int SurfaceManager::getSelectedVertexIndex(){
return _selectedVertexIndex;
}
void SurfaceManager::onVertexChanged(int & i){
ofNotifyEvent(vertexChangedEvent, i, this);
}

2
src/Surfaces/SurfaceManager.h

@ -46,10 +46,12 @@ class SurfaceManager {
// These should trigger an event for the GUI layer to catch
void selectNextVertex();
void selectPrevVertex();
void selectVertex(int i);
void moveSelectionBy(ofVec2f v);
int size();
int getSelectedVertexIndex();
ofEvent <int> vertexChangedEvent;
ofEvent <vector<ofVec3f>> verticesChangedEvent;

Loading…
Cancel
Save