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){
app->getGui()->getProjectionEditor()->update();
app->getGui()->getProjectionEditorWidget()->update();
Gui::instance()->getScaleWidget().update();
}
@ -28,7 +28,7 @@ void ProjectionMappingState::draw(Application * app){
ofPopStyle();
// 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.
BaseSurface * selectedSurface = app->getSurfaceManager()->getSelectedSurface();
@ -292,11 +292,11 @@ void ProjectionMappingState::onMousePressed(Application * app, ofMouseEventArgs
int hitJointIndex = -1;
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){
for(int i = app->getGui()->getProjectionEditor()->getJoints()->size() - 1; i >= 0 ; --i){
if((*app->getGui()->getProjectionEditor()->getJoints())[i] == hitJoint){
for(int i = app->getGui()->getProjectionEditorWidget()->getJoints()->size() - 1; i >= 0 ; --i){
if((*app->getGui()->getProjectionEditorWidget()->getJoints())[i] == hitJoint){
hitJointIndex = i;
break;
}
@ -328,18 +328,18 @@ void ProjectionMappingState::onMousePressed(Application * app, ofMouseEventArgs
void ProjectionMappingState::onMouseReleased(Application * app, ofMouseEventArgs & args){
Gui::instance()->onMouseReleased(args);
app->getGui()->stopDrag();
app->getGui()->getProjectionEditor()->stopDragJoints();
app->getGui()->getProjectionEditorWidget()->stopDragJoints();
}
void ProjectionMappingState::onMouseDragged(Application * app, ofMouseEventArgs & 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.
if(app->getGui()->bDrag){
ofVec2f mousePosition = ofVec2f(args.x, args.y);
ofVec2f distance = mousePosition - app->getGui()->clickPosition;
app->getGui()->getProjectionEditor()->moveSelectedSurface(distance);
app->getGui()->getProjectionEditorWidget()->moveSelectedSurface(distance);
app->getGui()->clickPosition = mousePosition;
}
}

2
src/Commands/AddGridColCmd.h

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

2
src/Commands/AddGridRowCmd.h

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

2
src/Commands/MvSurfaceVertCmd.h

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

2
src/Commands/RmGridColCmd.h

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

2
src/Commands/RmGridRowCmd.h

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

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

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

34
src/Surfaces/SurfaceManagerGui.cpp

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

6
src/Surfaces/SurfaceManagerGui.h

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

Loading…
Cancel
Save