Browse Source

Change src code style using ofStyler

master
Krisjanis Rijnieks 10 years ago
parent
commit
95b366ada5
  1. 2
      src/Application/Application.h
  2. 6
      src/Application/ApplicationBaseState.h
  3. 5
      src/Application/PresentationState.cpp
  4. 2
      src/Application/PresentationState.h
  5. 5
      src/Application/ProjectionMappingState.cpp
  6. 2
      src/Application/ProjectionMappingState.h
  7. 5
      src/Application/SourceSelectionState.cpp
  8. 2
      src/Application/SourceSelectionState.h
  9. 5
      src/Application/TextureMappingState.cpp
  10. 2
      src/Application/TextureMappingState.h
  11. 1
      src/Commands/AddSurfaceCmd.h
  12. 18
      src/Commands/BaseCmd.h
  13. 2
      src/Commands/CmdManager.h
  14. 1
      src/Commands/MvAllTexCoordsCmd.h
  15. 3
      src/Commands/MvSurfaceCmd.cpp
  16. 4
      src/Commands/MvSurfaceCmd.h
  17. 3
      src/Commands/MvSurfaceVertCmd.cpp
  18. 4
      src/Commands/MvSurfaceVertCmd.h
  19. 1
      src/Commands/MvTexCoordCmd.h
  20. 1
      src/Commands/RmSurfaceCmd.h
  21. 3
      src/Commands/SelSurfaceCmd.cpp
  22. 4
      src/Commands/SelSurfaceCmd.h
  23. 4
      src/Commands/SetApplicationStateCmd.cpp
  24. 4
      src/Commands/SetApplicationStateCmd.h
  25. 3
      src/Commands/SetSourceCmd.h
  26. 1
      src/MediaServer/DirectoryWatcher.cpp
  27. 34
      src/MediaServer/DirectoryWatcher.h
  28. 14
      src/MediaServer/MediaServer.cpp
  29. 1
      src/MediaServer/MediaServer.h
  30. 6
      src/Sources/BaseSource.cpp
  31. 10
      src/Sources/BaseSource.h
  32. 4
      src/Sources/FboSource.cpp
  33. 10
      src/Sources/FboSource.h
  34. 5
      src/Sources/ImageSource.cpp
  35. 8
      src/Sources/ImageSource.h
  36. 14
      src/Sources/SourceType.h
  37. 1
      src/Sources/VideoSource.cpp
  38. 7
      src/Sources/VideoSource.h
  39. 22
      src/Surfaces/BaseSurface.cpp
  40. 30
      src/Surfaces/BaseSurface.h
  41. 18
      src/Surfaces/QuadSurface.cpp
  42. 7
      src/Surfaces/QuadSurface.h
  43. 15
      src/Surfaces/SurfaceManager.cpp
  44. 8
      src/Surfaces/SurfaceManager.h
  45. 27
      src/Surfaces/SurfaceManagerGui.cpp
  46. 8
      src/Surfaces/SurfaceManagerGui.h
  47. 10
      src/Surfaces/SurfaceType.h
  48. 12
      src/Surfaces/TriangleSurface.cpp
  49. 6
      src/Surfaces/TriangleSurface.h
  50. 41
      src/UserInterface/BaseJoint.cpp
  51. 13
      src/UserInterface/BaseJoint.h
  52. 28
      src/UserInterface/CircleJoint.cpp
  53. 7
      src/UserInterface/CircleJoint.h
  54. 10
      src/UserInterface/EditorType.h
  55. 10
      src/UserInterface/GuiMode.h
  56. 39
      src/UserInterface/ProjectionEditor.cpp
  57. 8
      src/UserInterface/ProjectionEditor.h
  58. 2
      src/UserInterface/RadioList.cpp
  59. 2
      src/UserInterface/RadioList.h
  60. 5
      src/UserInterface/SourcesEditor.cpp
  61. 6
      src/UserInterface/SourcesEditor.h
  62. 36
      src/UserInterface/TextureEditor.cpp
  63. 8
      src/UserInterface/TextureEditor.h
  64. 14
      src/ofxPiMapper.h

2
src/Application/Application.h

@ -24,6 +24,7 @@ namespace ofx {
class ApplicationBaseState; class ApplicationBaseState;
class Application { class Application {
public: public:
Application(ofxPiMapper * opm); Application(ofxPiMapper * opm);
~Application(); ~Application();
@ -43,6 +44,7 @@ namespace ofx {
ApplicationBaseState * _state; ApplicationBaseState * _state;
ofxPiMapper * _ofxPiMapper; ofxPiMapper * _ofxPiMapper;
}; };
} // namespace piMapper } // namespace piMapper

6
src/Application/ApplicationBaseState.h

@ -9,12 +9,14 @@ namespace ofx {
class Application; class Application;
class ApplicationBaseState { class ApplicationBaseState {
public: public:
virtual void draw(Application * app){}; virtual void draw(Application * app){}
virtual void setState(Application * app, ApplicationBaseState * st); virtual void setState(Application * app, ApplicationBaseState * st);
// Event handler virtual methods // Event handler virtual methods
virtual void onKeyPressed(Application * app, ofKeyEventArgs & args){}; virtual void onKeyPressed(Application * app, ofKeyEventArgs & args){}
}; };
} // namespace piMapper } // namespace piMapper

5
src/Application/PresentationState.cpp

@ -13,5 +13,6 @@ namespace ofx {
} }
void PresentationState::draw(Application * app){} void PresentationState::draw(Application * app){}
}
} } // namespace piMapper
} // namespace ofx

2
src/Application/PresentationState.h

@ -9,12 +9,14 @@ namespace ofx {
namespace piMapper { namespace piMapper {
class PresentationState : public ApplicationBaseState { class PresentationState : public ApplicationBaseState {
public: public:
static PresentationState * instance(); static PresentationState * instance();
void draw(Application * app); void draw(Application * app);
private: private:
static PresentationState * _instance; static PresentationState * _instance;
}; };
} // namespace piMapper } // namespace piMapper

5
src/Application/ProjectionMappingState.cpp

@ -42,5 +42,6 @@ namespace ofx {
break; break;
} }
} }
}
} } // namespace piMapper
} // namespace ofx

2
src/Application/ProjectionMappingState.h

@ -11,6 +11,7 @@ namespace ofx {
namespace piMapper { namespace piMapper {
class ProjectionMappingState : public ApplicationBaseState { class ProjectionMappingState : public ApplicationBaseState {
public: public:
static ProjectionMappingState * instance(); static ProjectionMappingState * instance();
void draw(Application * app); void draw(Application * app);
@ -18,6 +19,7 @@ namespace ofx {
private: private:
static ProjectionMappingState * _instance; static ProjectionMappingState * _instance;
}; };
} // namespace piMapper } // namespace piMapper

5
src/Application/SourceSelectionState.cpp

@ -13,5 +13,6 @@ namespace ofx {
} }
void SourceSelectionState::draw(Application * app){} void SourceSelectionState::draw(Application * app){}
}
} } // namespace piMapper
} // namespace ofx

2
src/Application/SourceSelectionState.h

@ -9,12 +9,14 @@ namespace ofx {
namespace piMapper { namespace piMapper {
class SourceSelectionState : public ApplicationBaseState { class SourceSelectionState : public ApplicationBaseState {
public: public:
static SourceSelectionState * instance(); static SourceSelectionState * instance();
void draw(Application * app); void draw(Application * app);
private: private:
static SourceSelectionState * _instance; static SourceSelectionState * _instance;
}; };
} // namespace piMapper } // namespace piMapper

5
src/Application/TextureMappingState.cpp

@ -13,5 +13,6 @@ namespace ofx {
} }
void TextureMappingState::draw(Application * app){} void TextureMappingState::draw(Application * app){}
}
} } // namespace piMapper
} // namespace ofx

2
src/Application/TextureMappingState.h

@ -9,12 +9,14 @@ namespace ofx {
namespace piMapper { namespace piMapper {
class TextureMappingState : public ApplicationBaseState { class TextureMappingState : public ApplicationBaseState {
public: public:
static TextureMappingState * instance(); static TextureMappingState * instance();
void draw(Application * app); void draw(Application * app);
private: private:
static TextureMappingState * _instance; static TextureMappingState * _instance;
}; };
} // namespace piMapper } // namespace piMapper

1
src/Commands/AddSurfaceCmd.h

@ -24,6 +24,7 @@ namespace ofx{
// TODO: Should use some kind of factory class here // TODO: Should use some kind of factory class here
void addTriangleSurface(); void addTriangleSurface();
void addQuadSurface(); void addQuadSurface();
}; };
} // namespace piMapper } // namespace piMapper

18
src/Commands/BaseCmd.h

@ -14,27 +14,35 @@ namespace ofx{
// Base class for all commands // Base class for all commands
class BaseCmd { class BaseCmd {
public: public:
virtual ~BaseCmd(){}; virtual ~BaseCmd(){}
virtual void exec() = 0; virtual void exec() = 0;
// By default a command is not undo // By default a command is not undo
virtual bool isUndoable(){return false;} virtual bool isUndoable(){
return false;
}
protected: protected:
// In order to avoid using this class directly, // In order to avoid using this class directly,
// we make the constructor protected. // we make the constructor protected.
BaseCmd(){}; BaseCmd(){}
}; };
// Base class for all undoable commands // Base class for all undoable commands
class BaseUndoCmd : public BaseCmd { class BaseUndoCmd : public BaseCmd {
public: public:
virtual void undo() = 0; virtual void undo() = 0;
virtual bool isUndoable(){return true;} virtual bool isUndoable(){
return true;
}
protected: protected:
BaseUndoCmd(){}; BaseUndoCmd(){}
}; };
} // namespace piMapper } // namespace piMapper

2
src/Commands/CmdManager.h

@ -8,12 +8,14 @@ namespace ofx{
namespace piMapper { namespace piMapper {
class CmdManager { class CmdManager {
public: public:
void exec(BaseCmd * cmd); void exec(BaseCmd * cmd);
void undo(); void undo();
private: private:
std::vector <BaseUndoCmd *> cmdStack; std::vector <BaseUndoCmd *> cmdStack;
}; };
} // namespace piMapper } // namespace piMapper

1
src/Commands/MvAllTexCoordsCmd.h

@ -22,6 +22,7 @@ namespace ofx{
vector <ofVec2f> _texCoords; vector <ofVec2f> _texCoords;
BaseSurface * _surface; BaseSurface * _surface;
TextureEditor * _texEditor; TextureEditor * _texEditor;
}; };
} // namespace piMapper } // namespace piMapper

3
src/Commands/MvSurfaceCmd.cpp

@ -3,8 +3,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
MvSurfaceCmd::MvSurfaceCmd( MvSurfaceCmd::MvSurfaceCmd(BaseSurface * surface,
BaseSurface * surface,
ProjectionEditor * projectionEditor){ ProjectionEditor * projectionEditor){
_surface = surface; _surface = surface;

4
src/Commands/MvSurfaceCmd.h

@ -14,8 +14,7 @@ namespace ofx{
class MvSurfaceCmd : public BaseUndoCmd { class MvSurfaceCmd : public BaseUndoCmd {
public: public:
MvSurfaceCmd( MvSurfaceCmd(BaseSurface * surface,
BaseSurface * surface,
ProjectionEditor * projectionEditor); ProjectionEditor * projectionEditor);
void exec(); void exec();
void undo(); void undo();
@ -24,6 +23,7 @@ namespace ofx{
BaseSurface * _surface; BaseSurface * _surface;
ProjectionEditor * _projectionEditor; ProjectionEditor * _projectionEditor;
vector <ofVec3f> _previousVertices; vector <ofVec3f> _previousVertices;
}; };
} // namespace piMapper } // namespace piMapper

3
src/Commands/MvSurfaceVertCmd.cpp

@ -3,8 +3,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
MvSurfaceVertCmd::MvSurfaceVertCmd( MvSurfaceVertCmd::MvSurfaceVertCmd(int vertIndex,
int vertIndex,
BaseSurface * surface, BaseSurface * surface,
ProjectionEditor * projectionEditor){ ProjectionEditor * projectionEditor){

4
src/Commands/MvSurfaceVertCmd.h

@ -15,8 +15,7 @@ namespace ofx{
class MvSurfaceVertCmd : public BaseUndoCmd { class MvSurfaceVertCmd : public BaseUndoCmd {
public: public:
MvSurfaceVertCmd( MvSurfaceVertCmd(int vertIndex,
int vertIndex,
BaseSurface * surface, BaseSurface * surface,
ProjectionEditor * projectionEditor); ProjectionEditor * projectionEditor);
void exec(); void exec();
@ -27,6 +26,7 @@ namespace ofx{
ofVec2f _prevVertPos; ofVec2f _prevVertPos;
BaseSurface * _surface; BaseSurface * _surface;
ProjectionEditor * _projectionEditor; ProjectionEditor * _projectionEditor;
}; };
} // namespace piMapper } // namespace piMapper

1
src/Commands/MvTexCoordCmd.h

@ -22,6 +22,7 @@ namespace ofx{
ofVec2f _jointPosition; ofVec2f _jointPosition;
int _jointIndex; int _jointIndex;
TextureEditor * _texEditor; TextureEditor * _texEditor;
}; };
} // namespace piMapper } // namespace piMapper

1
src/Commands/RmSurfaceCmd.h

@ -23,6 +23,7 @@ namespace ofx{
private: private:
ofxPiMapper * _app; ofxPiMapper * _app;
BaseSurface * _surface; BaseSurface * _surface;
}; };
} // namespace piMapper } // namespace piMapper

3
src/Commands/SelSurfaceCmd.cpp

@ -3,8 +3,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
SelSurfaceCmd::SelSurfaceCmd( SelSurfaceCmd::SelSurfaceCmd(SurfaceManager * surfaceManager,
SurfaceManager * surfaceManager,
BaseSurface * surfaceToSelect, BaseSurface * surfaceToSelect,
ProjectionEditor * projectionEditor){ ProjectionEditor * projectionEditor){

4
src/Commands/SelSurfaceCmd.h

@ -15,8 +15,7 @@ namespace ofx{
class SelSurfaceCmd : public BaseUndoCmd { class SelSurfaceCmd : public BaseUndoCmd {
public: public:
SelSurfaceCmd( SelSurfaceCmd(SurfaceManager * surfaceManager,
SurfaceManager * surfaceManager,
BaseSurface * surfaceToSelect, BaseSurface * surfaceToSelect,
ProjectionEditor * projectionEditor); ProjectionEditor * projectionEditor);
void exec(); void exec();
@ -27,6 +26,7 @@ namespace ofx{
SurfaceManager * _surfaceManager; SurfaceManager * _surfaceManager;
BaseSurface * _prevSelectedSurface; BaseSurface * _prevSelectedSurface;
ProjectionEditor * _projectionEditor; ProjectionEditor * _projectionEditor;
}; };
} // namespace piMapper } // namespace piMapper

4
src/Commands/SetApplicationStateCmd.cpp

@ -3,10 +3,8 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
SetApplicationStateCmd::SetApplicationStateCmd( SetApplicationStateCmd::SetApplicationStateCmd(Application * app,
Application * app,
ApplicationBaseState * st, ApplicationBaseState * st,
SurfaceManagerGui * gui, SurfaceManagerGui * gui,
int mode){ int mode){

4
src/Commands/SetApplicationStateCmd.h

@ -12,8 +12,7 @@ namespace ofx {
class SetApplicationStateCmd : public BaseUndoCmd { class SetApplicationStateCmd : public BaseUndoCmd {
public: public:
SetApplicationStateCmd( SetApplicationStateCmd(Application * app,
Application * app,
ApplicationBaseState * st, ApplicationBaseState * st,
SurfaceManagerGui * gui, SurfaceManagerGui * gui,
int mode); int mode);
@ -30,6 +29,7 @@ namespace ofx {
SurfaceManagerGui * _gui; SurfaceManagerGui * _gui;
int _prevGuiMode; int _prevGuiMode;
int _mode; int _mode;
}; };
} // namespace piMapper } // namespace piMapper

3
src/Commands/SetSourceCmd.h

@ -8,8 +8,6 @@
#include "BaseSurface.h" #include "BaseSurface.h"
#include "SourcesEditor.h" #include "SourcesEditor.h"
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
@ -33,6 +31,7 @@ namespace ofx{
int _oldSourceType; int _oldSourceType;
string _oldSourceId; string _oldSourceId;
}; };
} // namespace piMapper } // namespace piMapper

1
src/MediaServer/DirectoryWatcher.cpp

@ -10,6 +10,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
DirectoryWatcher::DirectoryWatcher(std::string path, int watcherMediaType){ DirectoryWatcher::DirectoryWatcher(std::string path, int watcherMediaType){
mediaType = watcherMediaType; mediaType = watcherMediaType;
// Decide what filter we need depending on media type // Decide what filter we need depending on media type

34
src/MediaServer/DirectoryWatcher.h

@ -17,15 +17,15 @@ namespace piMapper {
class BasePathFilter : public ofx::IO::AbstractPathFilter { class BasePathFilter : public ofx::IO::AbstractPathFilter {
public: public:
BasePathFilter() {}; BasePathFilter(){}
virtual ~BasePathFilter() {}; virtual ~BasePathFilter(){}
virtual bool accept(const Poco::Path& path) const {}; virtual bool accept(const Poco::Path & path) const {}
}; };
class VideoPathFilter : public BasePathFilter { class VideoPathFilter : public BasePathFilter {
public: public:
VideoPathFilter() {}; VideoPathFilter(){}
virtual ~VideoPathFilter() {}; virtual ~VideoPathFilter(){}
bool accept(const Poco::Path & path) const { bool accept(const Poco::Path & path) const {
return !Poco::File(path).isHidden() && return !Poco::File(path).isHidden() &&
@ -39,8 +39,8 @@ class VideoPathFilter : public BasePathFilter {
class ImagePathFilter : public BasePathFilter { class ImagePathFilter : public BasePathFilter {
public: public:
ImagePathFilter() {}; ImagePathFilter(){}
virtual ~ImagePathFilter() {}; virtual ~ImagePathFilter(){}
bool accept(const Poco::Path & path) const { bool accept(const Poco::Path & path) const {
return !Poco::File(path).isHidden() && return !Poco::File(path).isHidden() &&
@ -56,8 +56,7 @@ class DirectoryWatcher {
~DirectoryWatcher(); ~DirectoryWatcher();
// TODO make useful stuff with onDirectoryWatcher* // TODO make useful stuff with onDirectoryWatcher*
void onDirectoryWatcherItemAdded( void onDirectoryWatcherItemAdded(const ofx::IO::DirectoryWatcherManager::DirectoryEvent & evt){
const ofx::IO::DirectoryWatcherManager::DirectoryEvent& evt) {
string path = evt.item.path(); string path = evt.item.path();
Poco::Path pocoPath = Poco::Path(path); Poco::Path pocoPath = Poco::Path(path);
if(!filter->accept(pocoPath)){ if(!filter->accept(pocoPath)){
@ -67,8 +66,7 @@ class DirectoryWatcher {
ofNotifyEvent(onItemAdded, path, this); ofNotifyEvent(onItemAdded, path, this);
} }
void onDirectoryWatcherItemRemoved( void onDirectoryWatcherItemRemoved(const ofx::IO::DirectoryWatcherManager::DirectoryEvent & evt){
const ofx::IO::DirectoryWatcherManager::DirectoryEvent& evt) {
string path = evt.item.path(); string path = evt.item.path();
Poco::Path pocoPath = Poco::Path(path); Poco::Path pocoPath = Poco::Path(path);
if(!filter->accept(pocoPath)){ if(!filter->accept(pocoPath)){
@ -84,8 +82,7 @@ class DirectoryWatcher {
ofNotifyEvent(onItemRemoved, path, this); ofNotifyEvent(onItemRemoved, path, this);
} }
void onDirectoryWatcherItemModified( void onDirectoryWatcherItemModified(const ofx::IO::DirectoryWatcherManager::DirectoryEvent & evt){
const ofx::IO::DirectoryWatcherManager::DirectoryEvent& evt) {
string path = evt.item.path(); string path = evt.item.path();
Poco::Path pocoPath = Poco::Path(path); Poco::Path pocoPath = Poco::Path(path);
if(!filter->accept(pocoPath)){ if(!filter->accept(pocoPath)){
@ -94,8 +91,7 @@ class DirectoryWatcher {
ofNotifyEvent(onItemModified, path, this); ofNotifyEvent(onItemModified, path, this);
} }
void onDirectoryWatcherItemMovedFrom( void onDirectoryWatcherItemMovedFrom(const ofx::IO::DirectoryWatcherManager::DirectoryEvent & evt){
const ofx::IO::DirectoryWatcherManager::DirectoryEvent& evt) {
string path = evt.item.path(); string path = evt.item.path();
Poco::Path pocoPath = Poco::Path(path); Poco::Path pocoPath = Poco::Path(path);
if(!filter->accept(pocoPath)){ if(!filter->accept(pocoPath)){
@ -106,8 +102,7 @@ class DirectoryWatcher {
ofNotifyEvent(onItemMovedFrom, path, this); ofNotifyEvent(onItemMovedFrom, path, this);
} }
void onDirectoryWatcherItemMovedTo( void onDirectoryWatcherItemMovedTo(const ofx::IO::DirectoryWatcherManager::DirectoryEvent & evt){
const ofx::IO::DirectoryWatcherManager::DirectoryEvent& evt) {
string path = evt.item.path(); string path = evt.item.path();
Poco::Path pocoPath = Poco::Path(path); Poco::Path pocoPath = Poco::Path(path);
if(!filter->accept(pocoPath)){ if(!filter->accept(pocoPath)){
@ -140,5 +135,6 @@ class DirectoryWatcher {
std::vector <std::string> filePaths; std::vector <std::string> filePaths;
int mediaType; int mediaType;
}; };
}
} } // namespace piMapper
} // namespace ofx

14
src/MediaServer/MediaServer.cpp

@ -19,11 +19,17 @@ namespace piMapper {
MediaServer::~MediaServer(){ MediaServer::~MediaServer(){
removeWatcherListeners(); removeWatcherListeners();
}; }
int MediaServer::getNumImages() { return imageWatcher.getFilePaths().size(); } int MediaServer::getNumImages(){
int MediaServer::getNumVideos() { return videoWatcher.getFilePaths().size(); } return imageWatcher.getFilePaths().size();
int MediaServer::getNumFboSources() { return fboSources.size(); } }
int MediaServer::getNumVideos(){
return videoWatcher.getFilePaths().size();
}
int MediaServer::getNumFboSources(){
return fboSources.size();
}
std::vector <std::string> & MediaServer::getImagePaths(){ std::vector <std::string> & MediaServer::getImagePaths(){
return imageWatcher.getFilePaths(); return imageWatcher.getFilePaths();

1
src/MediaServer/MediaServer.h

@ -110,5 +110,6 @@ class MediaServer {
// FBO source storage before they go to loadedSources // FBO source storage before they go to loadedSources
std::vector <FboSource *> fboSources; // FBO source storage std::vector <FboSource *> fboSources; // FBO source storage
}; };
} // namespace piMapper } // namespace piMapper
} // namespace ofx } // namespace ofx

6
src/Sources/BaseSource.cpp

@ -2,6 +2,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
BaseSource::BaseSource(){ BaseSource::BaseSource(){
//cout << "BaseSource" << endl; //cout << "BaseSource" << endl;
init(); init();
@ -55,5 +56,6 @@ namespace ofx {
//cout << "lastPathPart: " << pathParts[pathParts.size() - 1] << endl; //cout << "lastPathPart: " << pathParts[pathParts.size() - 1] << endl;
name = pathParts[pathParts.size() - 1]; name = pathParts[pathParts.size() - 1];
} }
}
} } // namespace piMapper
} // namespace ofx

10
src/Sources/BaseSource.h

@ -5,8 +5,10 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
// Use this for adding generative sources to your surfaces // Use this for adding generative sources to your surfaces
class BaseSource { class BaseSource {
public: public:
BaseSource(); BaseSource();
BaseSource(ofTexture * newTexture); // Only one clean way of passing the texture BaseSource(ofTexture * newTexture); // Only one clean way of passing the texture
@ -17,7 +19,7 @@ namespace ofx {
bool isLoaded(); // as BaseSourceLoadable bool isLoaded(); // as BaseSourceLoadable
int getType(); int getType();
std::string & getPath(); std::string & getPath();
virtual void clear() {}; virtual void clear(){}
// TODO: add virtual increaseReferenceCount and decreaseReferenceCount methods // TODO: add virtual increaseReferenceCount and decreaseReferenceCount methods
// and make the variable protected // and make the variable protected
@ -34,6 +36,8 @@ namespace ofx {
bool loadable; // If the source can be loaded from disk like image and video bool loadable; // If the source can be loaded from disk like image and video
bool loaded; // Is the source loaded? bool loaded; // Is the source loaded?
int type; int type;
}; };
}
} } // namespace piMapper
} // namespace ofx

4
src/Sources/FboSource.cpp

@ -45,8 +45,8 @@ namespace ofx {
// Check if FBO was allocated in user defined setup // Check if FBO was allocated in user defined setup
// If not, show warning and alocate to avoid panic // If not, show warning and alocate to avoid panic
if(!fbo->isAllocated()){ if(!fbo->isAllocated()){
ofLogWarning("FboSource::onAppSetup") << ofLogWarning("FboSource::onAppSetup")
"FBO not allocated, allocating with default values"; << "FBO not allocated, allocating with default values";
allocate(PIMAPPER_FBO_SOURCE_DEF_WIDTH, allocate(PIMAPPER_FBO_SOURCE_DEF_WIDTH,
PIMAPPER_FBO_SOURCE_DEF_HEIGHT); PIMAPPER_FBO_SOURCE_DEF_HEIGHT);
} }

10
src/Sources/FboSource.h

@ -11,15 +11,16 @@ namespace ofx {
namespace piMapper { namespace piMapper {
class FboSource : public BaseSource { class FboSource : public BaseSource {
public: public:
FboSource(); FboSource();
~FboSource(); ~FboSource();
// Override these in your custom FBO source // Override these in your custom FBO source
virtual void setup() {}; virtual void setup(){}
virtual void update() {}; virtual void update(){}
virtual void draw() {}; virtual void draw(){}
virtual void exit() {}; virtual void exit(){}
// The only method from BaseSource to be overriden // The only method from BaseSource to be overriden
void clear(); void clear();
@ -39,6 +40,7 @@ namespace ofx {
// Some handy getters // Some handy getters
int getWidth(); int getWidth();
int getHeight(); int getHeight();
}; };
} // namespace piMapper } // namespace piMapper

5
src/Sources/ImageSource.cpp

@ -2,6 +2,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
ImageSource::ImageSource(){ ImageSource::ImageSource(){
//cout << "ImageSource" << endl; //cout << "ImageSource" << endl;
loadable = true; loadable = true;
@ -35,5 +36,5 @@ namespace ofx {
loaded = false; loaded = false;
} }
} } // namespace piMapper
} } // namespace ofx

8
src/Sources/ImageSource.h

@ -4,7 +4,9 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class ImageSource : public BaseSource { class ImageSource : public BaseSource {
public: public:
ImageSource(); ImageSource();
~ImageSource(); ~ImageSource();
@ -13,6 +15,8 @@ namespace ofx {
void clear(); void clear();
private: private:
ofImage * image; ofImage * image;
}; };
}
} } // namespace piMapper
} // namespace ofx

14
src/Sources/SourceType.h

@ -9,9 +9,13 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class SourceType { class SourceType {
public: public:
enum { SOURCE_TYPE_NONE, SOURCE_TYPE_IMAGE, SOURCE_TYPE_VIDEO, SOURCE_TYPE_FBO }; enum {
SOURCE_TYPE_NONE, SOURCE_TYPE_IMAGE, SOURCE_TYPE_VIDEO, SOURCE_TYPE_FBO
};
static std::string GetSourceTypeName(int sourceTypeEnum){ static std::string GetSourceTypeName(int sourceTypeEnum){
if(sourceTypeEnum == SOURCE_TYPE_IMAGE){ if(sourceTypeEnum == SOURCE_TYPE_IMAGE){
@ -28,7 +32,7 @@ namespace ofx {
ofLogFatalError("SourceType") << ss.str(); ofLogFatalError("SourceType") << ss.str();
std::exit(EXIT_FAILURE); std::exit(EXIT_FAILURE);
} }
}; }
static int GetSourceTypeEnum(std::string sourceTypeName){ static int GetSourceTypeEnum(std::string sourceTypeName){
if(sourceTypeName == SOURCE_TYPE_NAME_IMAGE){ if(sourceTypeName == SOURCE_TYPE_NAME_IMAGE){
@ -46,6 +50,8 @@ namespace ofx {
std::exit(EXIT_FAILURE); std::exit(EXIT_FAILURE);
} }
} }
}; };
}
} } // namespace piMapper
} // namespace ofx

1
src/Sources/VideoSource.cpp

@ -66,5 +66,6 @@ namespace ofx {
} }
} }
#endif #endif
} // namespace piMapper } // namespace piMapper
} // namespace ofx } // namespace ofx

7
src/Sources/VideoSource.h

@ -9,7 +9,9 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class VideoSource : public BaseSource { class VideoSource : public BaseSource {
public: public:
// TODO: Create enableAudio() and disableAudio() methods // TODO: Create enableAudio() and disableAudio() methods
@ -38,5 +40,6 @@ namespace ofx {
#endif #endif
}; };
}
} } // namespace piMapper
} // namespace ofx

22
src/Surfaces/BaseSurface.cpp

@ -28,16 +28,17 @@ namespace ofx {
for(int x = 0; x < pixels.getHeight(); x += squareSize){ for(int x = 0; x < pixels.getHeight(); x += squareSize){
for(int yi = 0; yi < squareSize; yi++){ for(int yi = 0; yi < squareSize; yi++){
for(int xi = 0; xi < squareSize; xi++){ for(int xi = 0; xi < squareSize; xi++){
if (sx && sy) if(sx && sy){
pixels[(y + yi) * pixels.getWidth() + x + xi] = 255; pixels[(y + yi) * pixels.getWidth() + x + xi] = 255;
else if (sx && !sy) }else if(sx && !sy){
pixels[(y + yi) * pixels.getWidth() + x + xi] = 0; pixels[(y + yi) * pixels.getWidth() + x + xi] = 0;
else if (!sx && sy) }else if(!sx && sy){
pixels[(y + yi) * pixels.getWidth() + x + xi] = 0; pixels[(y + yi) * pixels.getWidth() + x + xi] = 0;
else }else{
pixels[(y + yi) * pixels.getWidth() + x + xi] = 255; pixels[(y + yi) * pixels.getWidth() + x + xi] = 255;
} }
} }
}
sx = !sx; sx = !sx;
} }
sy = !sy; sy = !sy;
@ -59,8 +60,8 @@ namespace ofx {
ofMesh texMesh; ofMesh texMesh;
texMesh.addVertex(position); texMesh.addVertex(position);
texMesh.addVertex(position + ofVec2f(source->getTexture()->getWidth(), 0.0f)); texMesh.addVertex(position + ofVec2f(source->getTexture()->getWidth(), 0.0f));
texMesh.addVertex(position + texMesh.addVertex(position
ofVec2f(source->getTexture()->getWidth(), source->getTexture()->getHeight())); + ofVec2f(source->getTexture()->getWidth(), source->getTexture()->getHeight()));
texMesh.addVertex(position + ofVec2f(0.0f, source->getTexture()->getHeight())); texMesh.addVertex(position + ofVec2f(0.0f, source->getTexture()->getHeight()));
texMesh.addTriangle(0, 2, 3); texMesh.addTriangle(0, 2, 3);
texMesh.addTriangle(0, 1, 2); texMesh.addTriangle(0, 1, 2);
@ -88,7 +89,12 @@ namespace ofx {
return defaultSource; return defaultSource;
} }
void BaseSurface::setMoved(bool moved){ _moved = moved; } void BaseSurface::setMoved(bool moved){
bool BaseSurface::getMoved(){ return _moved; } _moved = moved;
} }
bool BaseSurface::getMoved(){
return _moved;
} }
} // namespace piMapper
} // namespace ofx

30
src/Surfaces/BaseSurface.h

@ -8,21 +8,23 @@ using namespace std;
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class BaseSurface { class BaseSurface {
public: public:
BaseSurface(); BaseSurface();
~BaseSurface(); ~BaseSurface();
virtual void setup() {}; virtual void setup(){}
virtual void draw() {}; virtual void draw(){}
virtual void setVertex(int index, ofVec2f p) {}; virtual void setVertex(int index, ofVec2f p){}
virtual void setTexCoord(int index, ofVec2f t) {}; virtual void setTexCoord(int index, ofVec2f t){}
virtual void moveBy(ofVec2f v) {}; virtual void moveBy(ofVec2f v){}
virtual int getType() {}; virtual int getType(){}
virtual bool hitTest(ofVec2f p) {}; virtual bool hitTest(ofVec2f p){}
virtual ofPolyline getHitArea() {}; virtual ofPolyline getHitArea(){}
virtual ofPolyline getTextureHitArea() {}; virtual ofPolyline getTextureHitArea(){}
virtual vector<ofVec3f>& getVertices() {}; virtual vector <ofVec3f> & getVertices(){}
virtual vector<ofVec2f>& getTexCoords() {}; virtual vector <ofVec2f> & getTexCoords(){}
void drawTexture(ofVec2f position); void drawTexture(ofVec2f position);
void setSource(BaseSource * newSource); void setSource(BaseSource * newSource);
@ -39,6 +41,8 @@ namespace ofx {
BaseSource * defaultSource; BaseSource * defaultSource;
void createDefaultTexture(); void createDefaultTexture();
bool _moved; bool _moved;
}; };
}
} } // namespace piMapper
} // namespace ofx

18
src/Surfaces/QuadSurface.cpp

@ -2,11 +2,14 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
QuadSurface::QuadSurface(){ QuadSurface::QuadSurface(){
setup(); setup();
} }
QuadSurface::~QuadSurface() { cout << "QuadSurface destructor." << endl; } QuadSurface::~QuadSurface(){
cout << "QuadSurface destructor." << endl;
}
void QuadSurface::setup(){ void QuadSurface::setup(){
// Create 4 points for the 2 triangles // Create 4 points for the 2 triangles
@ -120,7 +123,9 @@ void QuadSurface::moveBy(ofVec2f v) {
setMoved(true); setMoved(true);
} }
int QuadSurface::getType() { return SurfaceType::QUAD_SURFACE; } int QuadSurface::getType(){
return SurfaceType::QUAD_SURFACE;
}
bool QuadSurface::hitTest(ofVec2f p){ bool QuadSurface::hitTest(ofVec2f p){
// Construct ofPolyline from vertices // Construct ofPolyline from vertices
@ -179,7 +184,9 @@ vector<ofVec3f>& QuadSurface::getVertices() {
return mesh.getVertices(); return mesh.getVertices();
} }
vector<ofVec2f>& QuadSurface::getTexCoords() { return mesh.getTexCoords(); } vector <ofVec2f> & QuadSurface::getTexCoords(){
return mesh.getTexCoords();
}
void QuadSurface::calculate4dTextureCoords(){ void QuadSurface::calculate4dTextureCoords(){
// Perspective Warping with OpenGL Fixed Pipeline and q coordinates // Perspective Warping with OpenGL Fixed Pipeline and q coordinates
@ -250,5 +257,6 @@ void QuadSurface::calculate4dTextureCoords() {
quadTexCoordinates[13] = t3.y * q3; quadTexCoordinates[13] = t3.y * q3;
quadTexCoordinates[15] = q3; quadTexCoordinates[15] = q3;
} }
}
} } // namespace piMapper
} // namespace ofx

7
src/Surfaces/QuadSurface.h

@ -6,6 +6,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class QuadSurface : public BaseSurface { class QuadSurface : public BaseSurface {
public: public:
QuadSurface(); QuadSurface();
@ -35,6 +36,8 @@ class QuadSurface : public BaseSurface {
GLfloat quadVertices[12]; GLfloat quadVertices[12];
GLubyte quadIndices[6]; GLubyte quadIndices[6];
GLfloat quadTexCoordinates[16]; GLfloat quadTexCoordinates[16];
}; };
}
} } // namespace piMapper
} // namespace ofx

15
src/Surfaces/SurfaceManager.cpp

@ -2,11 +2,14 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
SurfaceManager::SurfaceManager() : SurfaceManager::SurfaceManager() :
mediaServer(NULL), mediaServer(NULL),
selectedSurface(NULL){} selectedSurface(NULL){}
SurfaceManager::~SurfaceManager() { clear(); } SurfaceManager::~SurfaceManager(){
clear();
}
void SurfaceManager::draw(){ void SurfaceManager::draw(){
for(int i = 0; i < surfaces.size(); i++){ for(int i = 0; i < surfaces.size(); i++){
@ -308,9 +311,8 @@ void SurfaceManager::loadXmlSettings(string fileName) {
} }
} }
// it's a quad ? // it's a quad ?
else if (vertexCount == 4) else if(vertexCount == 4){
// if (surface-type == QUAD_SURFACE) // if (surface-type == QUAD_SURFACE)
{
xmlSettings.pushTag("vertex", 0); xmlSettings.pushTag("vertex", 0);
vertices.push_back(ofVec2f(xmlSettings.getValue("x", 0.0f), vertices.push_back(ofVec2f(xmlSettings.getValue("x", 0.0f),
xmlSettings.getValue("y", 0.0f))); xmlSettings.getValue("y", 0.0f)));
@ -419,6 +421,9 @@ BaseSurface* SurfaceManager::getSurface(int index) {
return surfaces[index]; return surfaces[index];
} }
int SurfaceManager::size() { return surfaces.size(); } int SurfaceManager::size(){
} return surfaces.size();
} }
} // namespace piMapper
} // namespace ofx

8
src/Surfaces/SurfaceManager.h

@ -15,7 +15,9 @@ using namespace std;
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class SurfaceManager { class SurfaceManager {
public: public:
SurfaceManager(); SurfaceManager();
~SurfaceManager(); ~SurfaceManager();
@ -53,6 +55,8 @@ class SurfaceManager {
BaseSurface * selectedSurface; BaseSurface * selectedSurface;
ofxXmlSettings xmlSettings; ofxXmlSettings xmlSettings;
MediaServer * mediaServer; MediaServer * mediaServer;
}; };
}
} } // namespace piMapper
} // namespace ofx

27
src/Surfaces/SurfaceManagerGui.cpp

@ -2,6 +2,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
SurfaceManagerGui::SurfaceManagerGui(){ SurfaceManagerGui::SurfaceManagerGui(){
surfaceManager = NULL; surfaceManager = NULL;
guiMode = GuiMode::NONE; guiMode = GuiMode::NONE;
@ -36,7 +37,9 @@ namespace ofx {
} }
void SurfaceManagerGui::draw(){ void SurfaceManagerGui::draw(){
if (surfaceManager == NULL) return; if(surfaceManager == NULL){
return;
}
if(guiMode == GuiMode::NONE){ if(guiMode == GuiMode::NONE){
surfaceManager->draw(); surfaceManager->draw();
@ -191,8 +194,7 @@ namespace ofx {
projectionEditor.clearJoints(); projectionEditor.clearJoints();
surfaceManager->deselectSurface(); surfaceManager->deselectSurface();
} }
} else if (guiMode == GuiMode::SOURCE_SELECTION) { }else if(guiMode == GuiMode::SOURCE_SELECTION){}
}
} }
void SurfaceManagerGui::mouseReleased(ofMouseEventArgs & args){ void SurfaceManagerGui::mouseReleased(ofMouseEventArgs & args){
@ -285,7 +287,9 @@ namespace ofx {
} }
void SurfaceManagerGui::drawSelectedSurfaceHighlight(){ void SurfaceManagerGui::drawSelectedSurfaceHighlight(){
if (surfaceManager->getSelectedSurface() == NULL) return; if(surfaceManager->getSelectedSurface() == NULL){
return;
}
ofPolyline line = surfaceManager->getSelectedSurface()->getHitArea(); ofPolyline line = surfaceManager->getSelectedSurface()->getHitArea();
ofPushStyle(); ofPushStyle();
ofSetLineWidth(1); ofSetLineWidth(1);
@ -295,7 +299,9 @@ namespace ofx {
} }
void SurfaceManagerGui::drawSelectedSurfaceTextureHighlight(){ void SurfaceManagerGui::drawSelectedSurfaceTextureHighlight(){
if (surfaceManager->getSelectedSurface() == NULL) return; if(surfaceManager->getSelectedSurface() == NULL){
return;
}
ofPolyline line = surfaceManager->getSelectedSurface()->getTextureHitArea(); ofPolyline line = surfaceManager->getSelectedSurface()->getTextureHitArea();
ofPushStyle(); ofPushStyle();
ofSetLineWidth(1); ofSetLineWidth(1);
@ -304,8 +310,13 @@ namespace ofx {
ofPopStyle(); ofPopStyle();
} }
void SurfaceManagerGui::startDrag() { bDrag = true; } void SurfaceManagerGui::startDrag(){
bDrag = true;
void SurfaceManagerGui::stopDrag() { bDrag = false; }
} }
void SurfaceManagerGui::stopDrag(){
bDrag = false;
} }
} // namespace piMapper
} // namespace ofx

8
src/Surfaces/SurfaceManagerGui.h

@ -19,7 +19,9 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class SurfaceManagerGui { class SurfaceManagerGui {
public: public:
SurfaceManagerGui(); SurfaceManagerGui();
~SurfaceManagerGui(); ~SurfaceManagerGui();
@ -53,6 +55,8 @@ namespace ofx {
bool bDrag; bool bDrag;
ofVec2f clickPosition; ofVec2f clickPosition;
CmdManager * _cmdManager; CmdManager * _cmdManager;
}; };
}
} } // namespace piMapper
} // namespace ofx

10
src/Surfaces/SurfaceType.h

@ -2,8 +2,12 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
struct SurfaceType { struct SurfaceType {
enum { TRIANGLE_SURFACE, QUAD_SURFACE }; enum {
TRIANGLE_SURFACE, QUAD_SURFACE
};
}; };
}
} } // namespace piMapper
} // namespace ofx

12
src/Surfaces/TriangleSurface.cpp

@ -2,6 +2,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
TriangleSurface::TriangleSurface(){ TriangleSurface::TriangleSurface(){
setup(); setup();
} }
@ -79,7 +80,9 @@ void TriangleSurface::moveBy(ofVec2f v) {
setMoved(true); setMoved(true);
} }
int TriangleSurface::getType() { return SurfaceType::TRIANGLE_SURFACE; } int TriangleSurface::getType(){
return SurfaceType::TRIANGLE_SURFACE;
}
bool TriangleSurface::hitTest(ofVec2f p){ bool TriangleSurface::hitTest(ofVec2f p){
// Construct ofPolyline from vertices // Construct ofPolyline from vertices
@ -137,6 +140,9 @@ vector<ofVec3f>& TriangleSurface::getVertices() {
return mesh.getVertices(); return mesh.getVertices();
} }
vector<ofVec2f>& TriangleSurface::getTexCoords() { return mesh.getTexCoords(); } vector <ofVec2f> & TriangleSurface::getTexCoords(){
} return mesh.getTexCoords();
} }
} // namespace piMapper
} // namespace ofx

6
src/Surfaces/TriangleSurface.h

@ -6,6 +6,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class TriangleSurface : public BaseSurface { class TriangleSurface : public BaseSurface {
public: public:
TriangleSurface(); TriangleSurface();
@ -28,5 +29,6 @@ class TriangleSurface : public BaseSurface {
vector <ofVec3f> & getVertices(); vector <ofVec3f> & getVertices();
vector <ofVec2f> & getTexCoords(); vector <ofVec2f> & getTexCoords();
}; };
}
} } // namespace piMapper
} // namespace ofx

41
src/UserInterface/BaseJoint.cpp

@ -9,7 +9,9 @@ BaseJoint::BaseJoint() {
registerMouseEvents(); registerMouseEvents();
} }
BaseJoint::~BaseJoint() { unregisterMouseEvents(); } BaseJoint::~BaseJoint(){
unregisterMouseEvents();
}
void BaseJoint::registerMouseEvents(){ void BaseJoint::registerMouseEvents(){
ofAddListener(ofEvents().mousePressed, this, &BaseJoint::mousePressed); ofAddListener(ofEvents().mousePressed, this, &BaseJoint::mousePressed);
@ -29,28 +31,44 @@ void BaseJoint::mousePressed(ofMouseEventArgs& args) {
} }
} }
void BaseJoint::mouseReleased(int x, int y, int button) { stopDrag(); } void BaseJoint::mouseReleased(int x, int y, int button){
stopDrag();
}
void BaseJoint::mouseDragged(ofMouseEventArgs & args){ void BaseJoint::mouseDragged(ofMouseEventArgs & args){
if (!bDrag) return; if(!bDrag){
return;
}
position = ofVec2f(args.x, args.y) + clickDistance; position = ofVec2f(args.x, args.y) + clickDistance;
} }
void BaseJoint::startDrag() { bDrag = true; } void BaseJoint::startDrag(){
bDrag = true;
}
void BaseJoint::stopDrag() { bDrag = false; } void BaseJoint::stopDrag(){
bDrag = false;
}
void BaseJoint::select() { selected = true; } void BaseJoint::select(){
selected = true;
}
void BaseJoint::unselect() { selected = false; } void BaseJoint::unselect(){
selected = false;
}
void BaseJoint::setClickDistance(ofVec2f newClickDistance){ void BaseJoint::setClickDistance(ofVec2f newClickDistance){
clickDistance = newClickDistance; clickDistance = newClickDistance;
} }
bool BaseJoint::isDragged() { return bDrag; } bool BaseJoint::isDragged(){
return bDrag;
}
bool BaseJoint::isSelected() { return selected; } bool BaseJoint::isSelected(){
return selected;
}
void BaseJoint::setDefaultColors(){ void BaseJoint::setDefaultColors(){
fillColor = ofColor(0, 255, 255, 0); fillColor = ofColor(0, 255, 255, 0);
@ -68,5 +86,6 @@ void BaseJoint::setDefaultProperties() {
selected = false; selected = false;
strokeWidth = 1.5f; strokeWidth = 1.5f;
} }
}
} } // namespace piMapper
} // namespace ofx

13
src/UserInterface/BaseJoint.h

@ -6,6 +6,7 @@ namespace ofx {
namespace piMapper { namespace piMapper {
class BaseJoint { class BaseJoint {
public: public:
BaseJoint(); BaseJoint();
~BaseJoint(); ~BaseJoint();
@ -29,9 +30,9 @@ class BaseJoint {
bool isDragged(); bool isDragged();
bool isSelected(); bool isSelected();
virtual void update() {}; virtual void update(){}
virtual void draw() {}; virtual void draw(){}
virtual bool hitTest(ofVec2f position) {}; virtual bool hitTest(ofVec2f position){}
protected: protected:
ofColor fillColor; ofColor fillColor;
@ -46,6 +47,8 @@ class BaseJoint {
private: private:
void setDefaultColors(); void setDefaultColors();
void setDefaultProperties(); void setDefaultProperties();
}; };
}
} } // namespace piMapper
} // namespace ofx

28
src/UserInterface/CircleJoint.cpp

@ -3,15 +3,23 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
CircleJoint::CircleJoint() { setDefaultProperties(); } CircleJoint::CircleJoint(){
setDefaultProperties();
}
void CircleJoint::update(){ void CircleJoint::update(){
if (!enabled) return; if(!enabled){
return;
}
} }
void CircleJoint::draw(){ void CircleJoint::draw(){
if (!visible) return; if(!visible){
if (!enabled) return; return;
}
if(!enabled){
return;
}
ofPushStyle(); ofPushStyle();
ofFill(); ofFill();
@ -36,14 +44,18 @@ void CircleJoint::draw() {
ofPopStyle(); ofPopStyle();
} }
void CircleJoint::setDefaultProperties() { radius = 10.0f; } void CircleJoint::setDefaultProperties(){
radius = 10.0f;
}
bool CircleJoint::hitTest(ofVec2f pos){ bool CircleJoint::hitTest(ofVec2f pos){
float distance = position.distance(pos); float distance = position.distance(pos);
if (distance < radius) if(distance < radius){
return true; return true;
else }else{
return false; return false;
} }
} }
}
} // namespace piMapper
} // namespace ofx

7
src/UserInterface/CircleJoint.h

@ -6,6 +6,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class CircleJoint : public BaseJoint { class CircleJoint : public BaseJoint {
public: public:
CircleJoint(); CircleJoint();
@ -17,6 +18,8 @@ class CircleJoint : public BaseJoint {
float radius; float radius;
void setDefaultProperties(); void setDefaultProperties();
}; };
}
} } // namespace piMapper
} // namespace ofx

10
src/UserInterface/EditorType.h

@ -2,8 +2,12 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
struct EditorType { struct EditorType {
enum { TEXTURE, PROJECTION }; enum {
TEXTURE, PROJECTION
};
}; };
}
} } // namespace piMapper
} // namespace ofx

10
src/UserInterface/GuiMode.h

@ -2,8 +2,12 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
struct GuiMode { struct GuiMode {
enum { NONE, TEXTURE_MAPPING, PROJECTION_MAPPING, SOURCE_SELECTION }; enum {
NONE, TEXTURE_MAPPING, PROJECTION_MAPPING, SOURCE_SELECTION
};
}; };
}
} } // namespace piMapper
} // namespace ofx

39
src/UserInterface/ProjectionEditor.cpp

@ -2,6 +2,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
ProjectionEditor::ProjectionEditor(){ ProjectionEditor::ProjectionEditor(){
surfaceManager = NULL; surfaceManager = NULL;
bShiftKeyDown = false; bShiftKeyDown = false;
@ -77,9 +78,15 @@ namespace ofx {
} }
void ProjectionEditor::draw(){ void ProjectionEditor::draw(){
if (surfaceManager == NULL) return; if(surfaceManager == NULL){
if (surfaceManager->getSelectedSurface() == NULL) return; return;
if (joints.size() <= 0) createJoints(); }
if(surfaceManager->getSelectedSurface() == NULL){
return;
}
if(joints.size() <= 0){
createJoints();
}
drawJoints(); drawJoints();
} }
@ -120,24 +127,29 @@ namespace ofx {
int key = args.key; int key = args.key;
float moveStep; float moveStep;
if (bShiftKeyDown) if(bShiftKeyDown){
moveStep = 10.0f; moveStep = 10.0f;
else }else{
moveStep = 0.5f; moveStep = 0.5f;
}
switch(key){ switch(key){
case OF_KEY_LEFT: case OF_KEY_LEFT:
moveSelection(ofVec2f(-moveStep, 0.0f)); moveSelection(ofVec2f(-moveStep, 0.0f));
break; break;
case OF_KEY_RIGHT: case OF_KEY_RIGHT:
moveSelection(ofVec2f(moveStep, 0.0f)); moveSelection(ofVec2f(moveStep, 0.0f));
break; break;
case OF_KEY_UP: case OF_KEY_UP:
moveSelection(ofVec2f(0.0f, -moveStep)); moveSelection(ofVec2f(0.0f, -moveStep));
break; break;
case OF_KEY_DOWN: case OF_KEY_DOWN:
moveSelection(ofVec2f(0.0f, moveStep)); moveSelection(ofVec2f(0.0f, moveStep));
break; break;
case OF_KEY_SHIFT: case OF_KEY_SHIFT:
bShiftKeyDown = true; bShiftKeyDown = true;
break; break;
@ -173,7 +185,9 @@ namespace ofx {
} }
void ProjectionEditor::createJoints(){ void ProjectionEditor::createJoints(){
if (surfaceManager == NULL) return; if(surfaceManager == NULL){
return;
}
clearJoints(); clearJoints();
if(surfaceManager->getSelectedSurface() == NULL){ if(surfaceManager->getSelectedSurface() == NULL){
@ -208,8 +222,12 @@ namespace ofx {
} }
void ProjectionEditor::moveSelectedSurface(ofVec2f by){ void ProjectionEditor::moveSelectedSurface(ofVec2f by){
if (surfaceManager == NULL) return; if(surfaceManager == NULL){
if (surfaceManager->getSelectedSurface() == NULL) return; return;
}
if(surfaceManager->getSelectedSurface() == NULL){
return;
}
surfaceManager->getSelectedSurface()->moveBy(by); surfaceManager->getSelectedSurface()->moveBy(by);
/*vector<ofVec3f>& vertices = /*vector<ofVec3f>& vertices =
surfaceManager->getSelectedSurface()->getVertices(); surfaceManager->getSelectedSurface()->getVertices();
@ -266,5 +284,6 @@ namespace ofx {
joints[i]->draw(); joints[i]->draw();
} }
} }
}
} } // namespace piMapper
} // namespace ofx

8
src/UserInterface/ProjectionEditor.h

@ -5,7 +5,9 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class ProjectionEditor { class ProjectionEditor {
public: public:
ProjectionEditor(); ProjectionEditor();
~ProjectionEditor(); ~ProjectionEditor();
@ -46,6 +48,8 @@ namespace ofx {
float fSnapDistance; float fSnapDistance;
void drawJoints(); void drawJoints();
}; };
}
} } // namespace piMapper
} // namespace ofx

2
src/UserInterface/RadioList.cpp

@ -2,6 +2,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
RadioList::RadioList(){ RadioList::RadioList(){
storedTitle = ""; storedTitle = "";
storedSelectedItem = 0; storedSelectedItem = 0;
@ -195,5 +196,6 @@ namespace ofx{
} }
} }
} }
} // namespace piMapper } // namespace piMapper
} // namespace ofx } // namespace ofx

2
src/UserInterface/RadioList.h

@ -7,6 +7,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class RadioList { class RadioList {
public: public:
RadioList(); RadioList();
@ -50,5 +51,6 @@ namespace ofx{
void onToggleClicked(bool & toggleValue); void onToggleClicked(bool & toggleValue);
}; };
} // namespace piMapper } // namespace piMapper
} // namespace ofx } // namespace ofx

5
src/UserInterface/SourcesEditor.cpp

@ -2,6 +2,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
SourcesEditor::SourcesEditor(){ SourcesEditor::SourcesEditor(){
init(); init();
// Create new MediaServer instance, // Create new MediaServer instance,
@ -368,5 +369,5 @@ namespace piMapper {
void SourcesEditor::handleFboSourceLoaded(std::string & name){} void SourcesEditor::handleFboSourceLoaded(std::string & name){}
void SourcesEditor::handleFboSourceUnloaded(std::string & name){} void SourcesEditor::handleFboSourceUnloaded(std::string & name){}
} } // namespace piMapper
} } // namespace ofx

6
src/UserInterface/SourcesEditor.h

@ -10,6 +10,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class SourcesEditor { class SourcesEditor {
public: public:
// Default contructor that initializes media server locally, // Default contructor that initializes media server locally,
@ -85,5 +86,6 @@ class SourcesEditor {
void handleFboSourceUnloaded(std::string & name); void handleFboSourceUnloaded(std::string & name);
}; };
}
} } // namespace piMapper
} // namespace ofx

36
src/UserInterface/TextureEditor.cpp

@ -2,6 +2,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
TextureEditor::TextureEditor(){ TextureEditor::TextureEditor(){
clear(); clear();
enable(); enable();
@ -42,7 +43,9 @@ void TextureEditor::disable() {
} }
void TextureEditor::update(ofEventArgs & args){ void TextureEditor::update(ofEventArgs & args){
if (surface == NULL) return; if(surface == NULL){
return;
}
// update surface if one of the joints is being dragged // update surface if one of the joints is being dragged
ofVec2f textureSize = ofVec2f(surface->getSource()->getTexture()->getWidth(), ofVec2f textureSize = ofVec2f(surface->getSource()->getTexture()->getWidth(),
@ -79,24 +82,29 @@ void TextureEditor::keyPressed(ofKeyEventArgs& args) {
int key = args.key; int key = args.key;
float moveStep; float moveStep;
if (bShiftKeyDown) if(bShiftKeyDown){
moveStep = 10.0f; moveStep = 10.0f;
else }else{
moveStep = 0.5f; moveStep = 0.5f;
}
switch(key){ switch(key){
case OF_KEY_LEFT: case OF_KEY_LEFT:
moveSelection(ofVec2f(-moveStep, 0.0f)); moveSelection(ofVec2f(-moveStep, 0.0f));
break; break;
case OF_KEY_RIGHT: case OF_KEY_RIGHT:
moveSelection(ofVec2f(moveStep, 0.0f)); moveSelection(ofVec2f(moveStep, 0.0f));
break; break;
case OF_KEY_UP: case OF_KEY_UP:
moveSelection(ofVec2f(0.0f, -moveStep)); moveSelection(ofVec2f(0.0f, -moveStep));
break; break;
case OF_KEY_DOWN: case OF_KEY_DOWN:
moveSelection(ofVec2f(0.0f, moveStep)); moveSelection(ofVec2f(0.0f, moveStep));
break; break;
case OF_KEY_SHIFT: case OF_KEY_SHIFT:
bShiftKeyDown = true; bShiftKeyDown = true;
break; break;
@ -113,7 +121,9 @@ void TextureEditor::keyReleased(ofKeyEventArgs& args) {
} }
void TextureEditor::draw(){ void TextureEditor::draw(){
if (surface == NULL) return; if(surface == NULL){
return;
}
// Reset default color to white // Reset default color to white
ofSetColor(255, 255, 255, 255); ofSetColor(255, 255, 255, 255);
@ -137,7 +147,9 @@ void TextureEditor::clear() {
} }
void TextureEditor::createJoints(){ void TextureEditor::createJoints(){
if (surface == NULL) return; if(surface == NULL){
return;
}
clearJoints(); clearJoints();
vector <ofVec2f> & texCoords = surface->getTexCoords(); vector <ofVec2f> & texCoords = surface->getTexCoords();
ofVec2f textureSize = ofVec2f(surface->getSource()->getTexture()->getWidth(), ofVec2f textureSize = ofVec2f(surface->getSource()->getTexture()->getWidth(),
@ -163,7 +175,9 @@ void TextureEditor::unselectAllJoints() {
} }
void TextureEditor::moveTexCoords(ofVec2f by){ void TextureEditor::moveTexCoords(ofVec2f by){
if (surface == NULL) return; if(surface == NULL){
return;
}
vector <ofVec2f> & texCoords = surface->getTexCoords(); vector <ofVec2f> & texCoords = surface->getTexCoords();
ofVec2f textureSize = ofVec2f(surface->getSource()->getTexture()->getWidth(), ofVec2f textureSize = ofVec2f(surface->getSource()->getTexture()->getWidth(),
surface->getSource()->getTexture()->getHeight()); surface->getSource()->getTexture()->getHeight());
@ -198,24 +212,26 @@ void TextureEditor::moveSelection(ofVec2f by) {
} }
} }
void TextureEditor::constrainJointsToQuad(int selectedJointIndex) void TextureEditor::constrainJointsToQuad(int selectedJointIndex){
{
switch(selectedJointIndex){ switch(selectedJointIndex){
case 0: case 0:
joints[1]->position = ofVec2f(joints[1]->position.x, joints[0]->position.y); joints[1]->position = ofVec2f(joints[1]->position.x, joints[0]->position.y);
joints[2]->position = ofVec2f(joints[1]->position.x, joints[3]->position.y); joints[2]->position = ofVec2f(joints[1]->position.x, joints[3]->position.y);
joints[3]->position = ofVec2f(joints[0]->position.x, joints[3]->position.y); joints[3]->position = ofVec2f(joints[0]->position.x, joints[3]->position.y);
break; break;
case 1: case 1:
joints[0]->position = ofVec2f(joints[0]->position.x, joints[1]->position.y); joints[0]->position = ofVec2f(joints[0]->position.x, joints[1]->position.y);
joints[2]->position = ofVec2f(joints[1]->position.x, joints[2]->position.y); joints[2]->position = ofVec2f(joints[1]->position.x, joints[2]->position.y);
joints[3]->position = ofVec2f(joints[0]->position.x, joints[2]->position.y); joints[3]->position = ofVec2f(joints[0]->position.x, joints[2]->position.y);
break; break;
case 2: case 2:
joints[1]->position = ofVec2f(joints[2]->position.x, joints[1]->position.y); joints[1]->position = ofVec2f(joints[2]->position.x, joints[1]->position.y);
joints[3]->position = ofVec2f(joints[3]->position.x, joints[2]->position.y); joints[3]->position = ofVec2f(joints[3]->position.x, joints[2]->position.y);
joints[0]->position = ofVec2f(joints[3]->position.x, joints[1]->position.y); joints[0]->position = ofVec2f(joints[3]->position.x, joints[1]->position.y);
break; break;
case 3: case 3:
joints[0]->position = ofVec2f(joints[3]->position.x, joints[0]->position.y); joints[0]->position = ofVec2f(joints[3]->position.x, joints[0]->position.y);
joints[2]->position = ofVec2f(joints[2]->position.x, joints[3]->position.y); joints[2]->position = ofVec2f(joints[2]->position.x, joints[3]->position.y);
@ -237,5 +253,5 @@ CircleJoint* TextureEditor::hitTestJoints(ofVec2f pos) {
return joints; return joints;
} }
} } // namespace piMapper
} } // namespace ofx

8
src/UserInterface/TextureEditor.h

@ -7,7 +7,9 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
class TextureEditor { class TextureEditor {
public: public:
TextureEditor(); TextureEditor();
~TextureEditor(); ~TextureEditor();
@ -40,6 +42,8 @@ class TextureEditor {
BaseSurface * surface; BaseSurface * surface;
vector <CircleJoint *> joints; vector <CircleJoint *> joints;
bool bShiftKeyDown; bool bShiftKeyDown;
}; };
}
} } // namespace piMapper
} // namespace ofx

14
src/ofxPiMapper.h

@ -20,6 +20,7 @@ namespace ofx {
} }
class ofxPiMapper { class ofxPiMapper {
public: public:
ofxPiMapper(); ofxPiMapper();
@ -28,9 +29,15 @@ class ofxPiMapper {
void registerFboSource(ofx::piMapper::FboSource & fboSource); void registerFboSource(ofx::piMapper::FboSource & fboSource);
void addTriangleSurface(); void addTriangleSurface();
void addQuadSurface(); void addQuadSurface();
void showInfo() { bShowInfo = true; }; void showInfo(){
void hideInfo() { bShowInfo = false; }; bShowInfo = true;
void toggleInfo() { bShowInfo = !bShowInfo; } }
void hideInfo(){
bShowInfo = false;
}
void toggleInfo(){
bShowInfo = !bShowInfo;
}
ofx::piMapper::CmdManager & getCmdManager(); ofx::piMapper::CmdManager & getCmdManager();
ofx::piMapper::SurfaceManagerGui & getGui(); ofx::piMapper::SurfaceManagerGui & getGui();
@ -45,4 +52,5 @@ class ofxPiMapper {
ofx::piMapper::MediaServer mediaServer; ofx::piMapper::MediaServer mediaServer;
ofx::piMapper::SurfaceManagerGui gui; ofx::piMapper::SurfaceManagerGui gui;
ofx::piMapper::Application * _application; ofx::piMapper::Application * _application;
}; };
Loading…
Cancel
Save