Browse Source

Rename ProjectionEditor to ProjectionEditorWidget

master
Krisjanis Rijnieks 9 years ago
parent
commit
5c37c56ecb
  1. 16
      src/Application/States/ProjectionMappingState.cpp
  2. 2
      src/Commands/AddGridColCmd.h
  3. 2
      src/Commands/AddGridRowCmd.h
  4. 2
      src/Commands/MvSurfaceVertCmd.h
  5. 2
      src/Commands/RmGridColCmd.h
  6. 2
      src/Commands/RmGridRowCmd.h
  7. 46
      src/Gui/Widgets/ProjectionEditorWidget.cpp
  8. 4
      src/Gui/Widgets/ProjectionEditorWidget.h
  9. 34
      src/Surfaces/SurfaceManagerGui.cpp
  10. 6
      src/Surfaces/SurfaceManagerGui.h

16
src/Application/States/ProjectionMappingState.cpp

@ -17,7 +17,7 @@ ProjectionMappingState * ProjectionMappingState::instance(){
} }
void ProjectionMappingState::update(Application * app){ void ProjectionMappingState::update(Application * app){
app->getGui()->getProjectionEditor()->update(); app->getGui()->getProjectionEditorWidget()->update();
Gui::instance()->getScaleWidget().update(); Gui::instance()->getScaleWidget().update();
} }
@ -28,7 +28,7 @@ void ProjectionMappingState::draw(Application * app){
ofPopStyle(); ofPopStyle();
// TODO: Extract projection editor, make it a widget // TODO: Extract projection editor, make it a widget
app->getGui()->getProjectionEditor()->draw(); app->getGui()->getProjectionEditorWidget()->draw();
// Draw scale widget. The size of the widget is being set on surface select. // Draw scale widget. The size of the widget is being set on surface select.
BaseSurface * selectedSurface = app->getSurfaceManager()->getSelectedSurface(); BaseSurface * selectedSurface = app->getSurfaceManager()->getSelectedSurface();
@ -292,11 +292,11 @@ void ProjectionMappingState::onMousePressed(Application * app, ofMouseEventArgs
int hitJointIndex = -1; int hitJointIndex = -1;
BaseSurface * hitSurface = 0; BaseSurface * hitSurface = 0;
hitJoint = app->getGui()->getProjectionEditor()->hitTestJoints(ofVec2f(args.x, args.y)); hitJoint = app->getGui()->getProjectionEditorWidget()->hitTestJoints(ofVec2f(args.x, args.y));
if(hitJoint){ if(hitJoint){
for(int i = app->getGui()->getProjectionEditor()->getJoints()->size() - 1; i >= 0 ; --i){ for(int i = app->getGui()->getProjectionEditorWidget()->getJoints()->size() - 1; i >= 0 ; --i){
if((*app->getGui()->getProjectionEditor()->getJoints())[i] == hitJoint){ if((*app->getGui()->getProjectionEditorWidget()->getJoints())[i] == hitJoint){
hitJointIndex = i; hitJointIndex = i;
break; break;
} }
@ -328,18 +328,18 @@ void ProjectionMappingState::onMousePressed(Application * app, ofMouseEventArgs
void ProjectionMappingState::onMouseReleased(Application * app, ofMouseEventArgs & args){ void ProjectionMappingState::onMouseReleased(Application * app, ofMouseEventArgs & args){
Gui::instance()->onMouseReleased(args); Gui::instance()->onMouseReleased(args);
app->getGui()->stopDrag(); app->getGui()->stopDrag();
app->getGui()->getProjectionEditor()->stopDragJoints(); app->getGui()->getProjectionEditorWidget()->stopDragJoints();
} }
void ProjectionMappingState::onMouseDragged(Application * app, ofMouseEventArgs & args){ void ProjectionMappingState::onMouseDragged(Application * app, ofMouseEventArgs & args){
Gui::instance()->onMouseDragged(args); Gui::instance()->onMouseDragged(args);
app->getGui()->getProjectionEditor()->mouseDragged(args); app->getGui()->getProjectionEditorWidget()->mouseDragged(args);
// TODO: Handle app->getGui()->clickPosition and app->getGui()->bDrag locally. // TODO: Handle app->getGui()->clickPosition and app->getGui()->bDrag locally.
if(app->getGui()->bDrag){ if(app->getGui()->bDrag){
ofVec2f mousePosition = ofVec2f(args.x, args.y); ofVec2f mousePosition = ofVec2f(args.x, args.y);
ofVec2f distance = mousePosition - app->getGui()->clickPosition; ofVec2f distance = mousePosition - app->getGui()->clickPosition;
app->getGui()->getProjectionEditor()->moveSelectedSurface(distance); app->getGui()->getProjectionEditorWidget()->moveSelectedSurface(distance);
app->getGui()->clickPosition = mousePosition; app->getGui()->clickPosition = mousePosition;
} }
} }

2
src/Commands/AddGridColCmd.h

@ -3,7 +3,7 @@
#include "SurfaceManager.h" #include "SurfaceManager.h"
#include "BaseCmd.h" #include "BaseCmd.h"
#include "GridWarpSurface.h" #include "GridWarpSurface.h"
#include "ProjectionEditor.h" #include "ProjectionEditorWidget.h"
class ofxPiMapper; class ofxPiMapper;

2
src/Commands/AddGridRowCmd.h

@ -3,7 +3,7 @@
#include "SurfaceManager.h" #include "SurfaceManager.h"
#include "BaseCmd.h" #include "BaseCmd.h"
#include "GridWarpSurface.h" #include "GridWarpSurface.h"
#include "ProjectionEditor.h" #include "ProjectionEditorWidget.h"
class ofxPiMapper; class ofxPiMapper;

2
src/Commands/MvSurfaceVertCmd.h

@ -6,7 +6,7 @@
#include "BaseCmd.h" #include "BaseCmd.h"
#include "BaseSurface.h" #include "BaseSurface.h"
#include "ProjectionEditor.h" #include "ProjectionEditorWidget.h"
#include "BaseJoint.h" #include "BaseJoint.h"
namespace ofx { namespace ofx {

2
src/Commands/RmGridColCmd.h

@ -3,7 +3,7 @@
#include "SurfaceManager.h" #include "SurfaceManager.h"
#include "BaseCmd.h" #include "BaseCmd.h"
#include "GridWarpSurface.h" #include "GridWarpSurface.h"
#include "ProjectionEditor.h" #include "ProjectionEditorWidget.h"
class ofxPiMapper; class ofxPiMapper;

2
src/Commands/RmGridRowCmd.h

@ -3,7 +3,7 @@
#include "SurfaceManager.h" #include "SurfaceManager.h"
#include "BaseCmd.h" #include "BaseCmd.h"
#include "GridWarpSurface.h" #include "GridWarpSurface.h"
#include "ProjectionEditor.h" #include "ProjectionEditorWidget.h"
class ofxPiMapper; class ofxPiMapper;

46
src/UserInterface/ProjectionEditor.cpp → src/Gui/Widgets/ProjectionEditorWidget.cpp

@ -1,32 +1,32 @@
#include "ProjectionEditor.h" #include "ProjectionEditorWidget.h"
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
ProjectionEditor::ProjectionEditor(){ ProjectionEditorWidget::ProjectionEditorWidget(){
surfaceManager = 0; surfaceManager = 0;
bShiftKeyDown = false; bShiftKeyDown = false;
fSnapDistance = 10.0f; fSnapDistance = 10.0f;
enable(); enable();
} }
void ProjectionEditor::registerAppEvents(){ void ProjectionEditorWidget::registerAppEvents(){
ofAddListener(ofEvents().messageEvent, this, &ProjectionEditor::gotMessage); ofAddListener(ofEvents().messageEvent, this, &ProjectionEditorWidget::gotMessage);
} }
void ProjectionEditor::unregisterAppEvents(){ void ProjectionEditorWidget::unregisterAppEvents(){
ofRemoveListener(ofEvents().messageEvent, this, &ProjectionEditor::gotMessage); ofRemoveListener(ofEvents().messageEvent, this, &ProjectionEditorWidget::gotMessage);
} }
void ProjectionEditor::enable(){ void ProjectionEditorWidget::enable(){
registerAppEvents(); registerAppEvents();
} }
void ProjectionEditor::disable(){ void ProjectionEditorWidget::disable(){
unregisterAppEvents(); unregisterAppEvents();
} }
void ProjectionEditor::update(){ void ProjectionEditorWidget::update(){
// update surface if one of the joints is being dragged // update surface if one of the joints is being dragged
for(int i = 0; i < joints.size(); i++){ for(int i = 0; i < joints.size(); i++){
if(joints[i]->isDragged() || joints[i]->isSelected()){ if(joints[i]->isDragged() || joints[i]->isSelected()){
@ -44,7 +44,7 @@ void ProjectionEditor::update(){
} }
} }
void ProjectionEditor::draw(){ void ProjectionEditorWidget::draw(){
if(surfaceManager == 0){ if(surfaceManager == 0){
return; return;
} }
@ -57,7 +57,7 @@ void ProjectionEditor::draw(){
drawJoints(); drawJoints();
} }
void ProjectionEditor::mouseDragged(ofMouseEventArgs & args){ void ProjectionEditorWidget::mouseDragged(ofMouseEventArgs & args){
// Pass args to joint mouse events // Pass args to joint mouse events
for(unsigned int i = 0; i < joints.size(); ++i){ for(unsigned int i = 0; i < joints.size(); ++i){
@ -94,25 +94,25 @@ void ProjectionEditor::mouseDragged(ofMouseEventArgs & args){
} }
} }
void ProjectionEditor::gotMessage(ofMessage & msg){ void ProjectionEditorWidget::gotMessage(ofMessage & msg){
if(msg.message == "surfaceSelected"){ if(msg.message == "surfaceSelected"){
clearJoints(); clearJoints();
createJoints(); createJoints();
} }
} }
void ProjectionEditor::setSurfaceManager(SurfaceManager * newSurfaceManager){ void ProjectionEditorWidget::setSurfaceManager(SurfaceManager * newSurfaceManager){
surfaceManager = newSurfaceManager; surfaceManager = newSurfaceManager;
} }
void ProjectionEditor::clearJoints(){ void ProjectionEditorWidget::clearJoints(){
while(joints.size()){ while(joints.size()){
delete joints.back(); delete joints.back();
joints.pop_back(); joints.pop_back();
} }
} }
void ProjectionEditor::createJoints(){ void ProjectionEditorWidget::createJoints(){
if(surfaceManager == 0){ if(surfaceManager == 0){
return; return;
} }
@ -132,7 +132,7 @@ void ProjectionEditor::createJoints(){
} }
} }
void ProjectionEditor::updateJoints(){ void ProjectionEditorWidget::updateJoints(){
if(surfaceManager->getSelectedSurface()){ if(surfaceManager->getSelectedSurface()){
vector <ofVec3f> & vertices = vector <ofVec3f> & vertices =
surfaceManager->getSelectedSurface()->getVertices(); surfaceManager->getSelectedSurface()->getVertices();
@ -143,13 +143,13 @@ void ProjectionEditor::updateJoints(){
} }
void ProjectionEditor::unselectAllJoints(){ void ProjectionEditorWidget::unselectAllJoints(){
for(int i = 0; i < joints.size(); i++){ for(int i = 0; i < joints.size(); i++){
joints[i]->unselect(); joints[i]->unselect();
} }
} }
void ProjectionEditor::moveSelectedSurface(ofVec2f by){ void ProjectionEditorWidget::moveSelectedSurface(ofVec2f by){
if(surfaceManager == 0){ if(surfaceManager == 0){
return; return;
} }
@ -160,17 +160,17 @@ void ProjectionEditor::moveSelectedSurface(ofVec2f by){
updateJoints(); updateJoints();
} }
void ProjectionEditor::stopDragJoints(){ void ProjectionEditorWidget::stopDragJoints(){
for(int i = 0; i < joints.size(); i++){ for(int i = 0; i < joints.size(); i++){
joints[i]->stopDrag(); joints[i]->stopDrag();
} }
} }
void ProjectionEditor::setSnapDistance(float newSnapDistance){ void ProjectionEditorWidget::setSnapDistance(float newSnapDistance){
fSnapDistance = newSnapDistance; fSnapDistance = newSnapDistance;
} }
CircleJoint * ProjectionEditor::hitTestJoints(ofVec2f pos){ CircleJoint * ProjectionEditorWidget::hitTestJoints(ofVec2f pos){
for(int i = 0; i < joints.size(); i++){ for(int i = 0; i < joints.size(); i++){
if(joints[i]->hitTest(pos)){ if(joints[i]->hitTest(pos)){
return joints[i]; return joints[i];
@ -179,11 +179,11 @@ CircleJoint * ProjectionEditor::hitTestJoints(ofVec2f pos){
return 0; return 0;
} }
vector <CircleJoint *> * ProjectionEditor::getJoints(){ vector <CircleJoint *> * ProjectionEditorWidget::getJoints(){
return &joints; return &joints;
} }
void ProjectionEditor::drawJoints(){ void ProjectionEditorWidget::drawJoints(){
for(int i = 0; i < joints.size(); i++){ for(int i = 0; i < joints.size(); i++){
joints[i]->draw(); joints[i]->draw();
} }

4
src/UserInterface/ProjectionEditor.h → src/Gui/Widgets/ProjectionEditorWidget.h

@ -6,10 +6,10 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class ProjectionEditor { class ProjectionEditorWidget {
public: public:
ProjectionEditor(); ProjectionEditorWidget();
void registerAppEvents(); void registerAppEvents();
void unregisterAppEvents(); void unregisterAppEvents();

34
src/Surfaces/SurfaceManagerGui.cpp

@ -28,7 +28,7 @@ void SurfaceManagerGui::setSurfaceManager(SurfaceManager * newSurfaceManager){
ofAddListener(newSurfaceManager->vertexSelectedEvent, this, &SurfaceManagerGui::onVertexSelected); ofAddListener(newSurfaceManager->vertexSelectedEvent, this, &SurfaceManagerGui::onVertexSelected);
ofAddListener(newSurfaceManager->vertexUnselectedEvent, this, &SurfaceManagerGui::onVertexUnselected); ofAddListener(newSurfaceManager->vertexUnselectedEvent, this, &SurfaceManagerGui::onVertexUnselected);
projectionEditor.setSurfaceManager(surfaceManager); projectionEditorWidget.setSurfaceManager(surfaceManager);
sourcesEditor.setSurfaceManager(surfaceManager); sourcesEditor.setSurfaceManager(surfaceManager);
} }
@ -64,9 +64,9 @@ void SurfaceManagerGui::setMode(int newGuiMode){
} }
if(guiMode == GuiMode::PROJECTION_MAPPING){ if(guiMode == GuiMode::PROJECTION_MAPPING){
projectionEditor.enable(); projectionEditorWidget.enable();
}else{ }else{
projectionEditor.disable(); projectionEditorWidget.disable();
} }
} }
@ -82,8 +82,8 @@ void SurfaceManagerGui::stopDrag(){
bDrag = false; bDrag = false;
} }
ProjectionEditor * SurfaceManagerGui::getProjectionEditor(){ ProjectionEditorWidget * SurfaceManagerGui::getProjectionEditorWidget(){
return &projectionEditor; return &projectionEditorWidget;
} }
SourcesEditor * SurfaceManagerGui::getSourcesEditor(){ SourcesEditor * SurfaceManagerGui::getSourcesEditor(){
@ -91,39 +91,39 @@ SourcesEditor * SurfaceManagerGui::getSourcesEditor(){
} }
void SurfaceManagerGui::onVertexChanged(int & i){ void SurfaceManagerGui::onVertexChanged(int & i){
bool isDragged = projectionEditor.getJoints()->at(i)->isDragged(); bool isDragged = projectionEditorWidget.getJoints()->at(i)->isDragged();
projectionEditor.createJoints(); projectionEditorWidget.createJoints();
projectionEditor.getJoints()->at(i)->select(); projectionEditorWidget.getJoints()->at(i)->select();
if(isDragged){ if(isDragged){
projectionEditor.getJoints()->at(i)->startDrag(); projectionEditorWidget.getJoints()->at(i)->startDrag();
}else{ }else{
projectionEditor.getJoints()->at(i)->stopDrag(); projectionEditorWidget.getJoints()->at(i)->stopDrag();
} }
} }
void SurfaceManagerGui::onVerticesChanged(vector<ofVec3f> & vertices){ void SurfaceManagerGui::onVerticesChanged(vector<ofVec3f> & vertices){
projectionEditor.createJoints(); projectionEditorWidget.createJoints();
} }
void SurfaceManagerGui::onSurfaceSelected(int & surfaceIndex){ void SurfaceManagerGui::onSurfaceSelected(int & surfaceIndex){
projectionEditor.createJoints(); projectionEditorWidget.createJoints();
} }
void SurfaceManagerGui::onVertexSelected(int & vertexIndex){ void SurfaceManagerGui::onVertexSelected(int & vertexIndex){
if(projectionEditor.getJoints()->size() == 0){ if(projectionEditorWidget.getJoints()->size() == 0){
return; return;
} }
projectionEditor.unselectAllJoints(); projectionEditorWidget.unselectAllJoints();
projectionEditor.getJoints()->at(vertexIndex)->select(); projectionEditorWidget.getJoints()->at(vertexIndex)->select();
} }
void SurfaceManagerGui::onVertexUnselected(int & vertexIndex){ void SurfaceManagerGui::onVertexUnselected(int & vertexIndex){
if(projectionEditor.getJoints()->size() == 0){ if(projectionEditorWidget.getJoints()->size() == 0){
return; return;
} }
projectionEditor.unselectAllJoints(); projectionEditorWidget.unselectAllJoints();
} }
} // namespace piMapper } // namespace piMapper

6
src/Surfaces/SurfaceManagerGui.h

@ -6,7 +6,7 @@
#include "ofGraphics.h" #include "ofGraphics.h"
#include "SurfaceManager.h" #include "SurfaceManager.h"
#include "ProjectionEditor.h" #include "ProjectionEditorWidget.h"
#include "SourcesEditor.h" #include "SourcesEditor.h"
#include "GuiMode.h" #include "GuiMode.h"
#include "CmdManager.h" #include "CmdManager.h"
@ -35,7 +35,7 @@ class SurfaceManagerGui {
void startDrag(); void startDrag();
void stopDrag(); void stopDrag();
ProjectionEditor * getProjectionEditor(); ProjectionEditorWidget * getProjectionEditorWidget();
SourcesEditor * getSourcesEditor(); SourcesEditor * getSourcesEditor();
void onVertexChanged(int & i); void onVertexChanged(int & i);
@ -50,7 +50,7 @@ class SurfaceManagerGui {
private: private:
SurfaceManager * surfaceManager; SurfaceManager * surfaceManager;
MediaServer * mediaServer; MediaServer * mediaServer;
ProjectionEditor projectionEditor; ProjectionEditorWidget projectionEditorWidget;
SourcesEditor sourcesEditor; SourcesEditor sourcesEditor;
int guiMode; int guiMode;

Loading…
Cancel
Save