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 Application {
public:
Application(ofxPiMapper * opm);
~Application();
@ -43,6 +44,7 @@ namespace ofx {
ApplicationBaseState * _state;
ofxPiMapper * _ofxPiMapper;
};
} // namespace piMapper

6
src/Application/ApplicationBaseState.h

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

5
src/Application/PresentationState.cpp

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

2
src/Application/PresentationState.h

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

5
src/Application/ProjectionMappingState.cpp

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

2
src/Application/ProjectionMappingState.h

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

5
src/Application/SourceSelectionState.cpp

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

2
src/Application/SourceSelectionState.h

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

5
src/Application/TextureMappingState.cpp

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

2
src/Application/TextureMappingState.h

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

1
src/Commands/AddSurfaceCmd.h

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

18
src/Commands/BaseCmd.h

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

2
src/Commands/CmdManager.h

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

1
src/Commands/MvAllTexCoordsCmd.h

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

3
src/Commands/MvSurfaceCmd.cpp

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

4
src/Commands/MvSurfaceCmd.h

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

3
src/Commands/MvSurfaceVertCmd.cpp

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

4
src/Commands/MvSurfaceVertCmd.h

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

1
src/Commands/MvTexCoordCmd.h

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

1
src/Commands/RmSurfaceCmd.h

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

3
src/Commands/SelSurfaceCmd.cpp

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

4
src/Commands/SelSurfaceCmd.h

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

4
src/Commands/SetApplicationStateCmd.cpp

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

4
src/Commands/SetApplicationStateCmd.h

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

3
src/Commands/SetSourceCmd.h

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

1
src/MediaServer/DirectoryWatcher.cpp

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

14
src/MediaServer/MediaServer.cpp

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

1
src/MediaServer/MediaServer.h

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

6
src/Sources/BaseSource.cpp

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

10
src/Sources/BaseSource.h

@ -5,8 +5,10 @@
namespace ofx {
namespace piMapper {
// Use this for adding generative sources to your surfaces
class BaseSource {
public:
BaseSource();
BaseSource(ofTexture * newTexture); // Only one clean way of passing the texture
@ -17,7 +19,7 @@ namespace ofx {
bool isLoaded(); // as BaseSourceLoadable
int getType();
std::string & getPath();
virtual void clear() {};
virtual void clear(){}
// TODO: add virtual increaseReferenceCount and decreaseReferenceCount methods
// 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 loaded; // Is the source loaded?
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
// If not, show warning and alocate to avoid panic
if(!fbo->isAllocated()){
ofLogWarning("FboSource::onAppSetup") <<
"FBO not allocated, allocating with default values";
ofLogWarning("FboSource::onAppSetup")
<< "FBO not allocated, allocating with default values";
allocate(PIMAPPER_FBO_SOURCE_DEF_WIDTH,
PIMAPPER_FBO_SOURCE_DEF_HEIGHT);
}

10
src/Sources/FboSource.h

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

5
src/Sources/ImageSource.cpp

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

8
src/Sources/ImageSource.h

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

14
src/Sources/SourceType.h

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

1
src/Sources/VideoSource.cpp

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

7
src/Sources/VideoSource.h

@ -9,7 +9,9 @@
namespace ofx {
namespace piMapper {
class VideoSource : public BaseSource {
public:
// TODO: Create enableAudio() and disableAudio() methods
@ -38,5 +40,6 @@ namespace ofx {
#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 yi = 0; yi < squareSize; yi++){
for(int xi = 0; xi < squareSize; xi++){
if (sx && sy)
if(sx && sy){
pixels[(y + yi) * pixels.getWidth() + x + xi] = 255;
else if (sx && !sy)
}else if(sx && !sy){
pixels[(y + yi) * pixels.getWidth() + x + xi] = 0;
else if (!sx && sy)
}else if(!sx && sy){
pixels[(y + yi) * pixels.getWidth() + x + xi] = 0;
else
}else{
pixels[(y + yi) * pixels.getWidth() + x + xi] = 255;
}
}
}
sx = !sx;
}
sy = !sy;
@ -59,8 +60,8 @@ namespace ofx {
ofMesh texMesh;
texMesh.addVertex(position);
texMesh.addVertex(position + ofVec2f(source->getTexture()->getWidth(), 0.0f));
texMesh.addVertex(position +
ofVec2f(source->getTexture()->getWidth(), source->getTexture()->getHeight()));
texMesh.addVertex(position
+ ofVec2f(source->getTexture()->getWidth(), source->getTexture()->getHeight()));
texMesh.addVertex(position + ofVec2f(0.0f, source->getTexture()->getHeight()));
texMesh.addTriangle(0, 2, 3);
texMesh.addTriangle(0, 1, 2);
@ -88,7 +89,12 @@ namespace ofx {
return defaultSource;
}
void BaseSurface::setMoved(bool moved){ _moved = moved; }
bool BaseSurface::getMoved(){ return _moved; }
void BaseSurface::setMoved(bool 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 piMapper {
class BaseSurface {
public:
BaseSurface();
~BaseSurface();
virtual void setup() {};
virtual void draw() {};
virtual void setVertex(int index, ofVec2f p) {};
virtual void setTexCoord(int index, ofVec2f t) {};
virtual void moveBy(ofVec2f v) {};
virtual int getType() {};
virtual bool hitTest(ofVec2f p) {};
virtual ofPolyline getHitArea() {};
virtual ofPolyline getTextureHitArea() {};
virtual vector<ofVec3f>& getVertices() {};
virtual vector<ofVec2f>& getTexCoords() {};
virtual void setup(){}
virtual void draw(){}
virtual void setVertex(int index, ofVec2f p){}
virtual void setTexCoord(int index, ofVec2f t){}
virtual void moveBy(ofVec2f v){}
virtual int getType(){}
virtual bool hitTest(ofVec2f p){}
virtual ofPolyline getHitArea(){}
virtual ofPolyline getTextureHitArea(){}
virtual vector <ofVec3f> & getVertices(){}
virtual vector <ofVec2f> & getTexCoords(){}
void drawTexture(ofVec2f position);
void setSource(BaseSource * newSource);
@ -39,6 +41,8 @@ namespace ofx {
BaseSource * defaultSource;
void createDefaultTexture();
bool _moved;
};
}
}
} // namespace piMapper
} // namespace ofx

18
src/Surfaces/QuadSurface.cpp

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

7
src/Surfaces/QuadSurface.h

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

15
src/Surfaces/SurfaceManager.cpp

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

27
src/Surfaces/SurfaceManagerGui.cpp

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

8
src/Surfaces/SurfaceManagerGui.h

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

10
src/Surfaces/SurfaceType.h

@ -2,8 +2,12 @@
namespace ofx {
namespace piMapper {
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 piMapper {
TriangleSurface::TriangleSurface(){
setup();
}
@ -79,7 +80,9 @@ void TriangleSurface::moveBy(ofVec2f v) {
setMoved(true);
}
int TriangleSurface::getType() { return SurfaceType::TRIANGLE_SURFACE; }
int TriangleSurface::getType(){
return SurfaceType::TRIANGLE_SURFACE;
}
bool TriangleSurface::hitTest(ofVec2f p){
// Construct ofPolyline from vertices
@ -137,6 +140,9 @@ vector<ofVec3f>& TriangleSurface::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 piMapper {
class TriangleSurface : public BaseSurface {
public:
TriangleSurface();
@ -28,5 +29,6 @@ class TriangleSurface : public BaseSurface {
vector <ofVec3f> & getVertices();
vector <ofVec2f> & getTexCoords();
};
}
}
} // namespace piMapper
} // namespace ofx

41
src/UserInterface/BaseJoint.cpp

@ -9,7 +9,9 @@ BaseJoint::BaseJoint() {
registerMouseEvents();
}
BaseJoint::~BaseJoint() { unregisterMouseEvents(); }
BaseJoint::~BaseJoint(){
unregisterMouseEvents();
}
void BaseJoint::registerMouseEvents(){
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){
if (!bDrag) return;
if(!bDrag){
return;
}
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){
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(){
fillColor = ofColor(0, 255, 255, 0);
@ -68,5 +86,6 @@ void BaseJoint::setDefaultProperties() {
selected = false;
strokeWidth = 1.5f;
}
}
}
} // namespace piMapper
} // namespace ofx

13
src/UserInterface/BaseJoint.h

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

28
src/UserInterface/CircleJoint.cpp

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

7
src/UserInterface/CircleJoint.h

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

10
src/UserInterface/EditorType.h

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

10
src/UserInterface/GuiMode.h

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

8
src/UserInterface/ProjectionEditor.h

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

2
src/UserInterface/RadioList.cpp

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

2
src/UserInterface/RadioList.h

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

5
src/UserInterface/SourcesEditor.cpp

@ -2,6 +2,7 @@
namespace ofx {
namespace piMapper {
SourcesEditor::SourcesEditor(){
init();
// Create new MediaServer instance,
@ -368,5 +369,5 @@ namespace piMapper {
void SourcesEditor::handleFboSourceLoaded(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 piMapper {
class SourcesEditor {
public:
// Default contructor that initializes media server locally,
@ -85,5 +86,6 @@ class SourcesEditor {
void handleFboSourceUnloaded(std::string & name);
};
}
}
} // namespace piMapper
} // namespace ofx

36
src/UserInterface/TextureEditor.cpp

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

8
src/UserInterface/TextureEditor.h

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

14
src/ofxPiMapper.h

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