Browse Source

Fix SurfaceType enum so it can be used as type for real

The problem was that wherever we use SurfaceType, the variable type was int, which leads to
confusion sometimes.
master
Krisjanis Rijnieks 9 years ago
parent
commit
ff20c60789
  1. 2
      src/Application/Modes/ProjectionMappingMode.cpp
  2. 2
      src/Application/Modes/ProjectionMappingMode.h
  3. 7
      src/Application/SettingsLoader.cpp
  4. 2
      src/Commands/AddSurfaceCmd.cpp
  5. 4
      src/Commands/AddSurfaceCmd.h
  6. 2
      src/Surfaces/SurfaceFactory.cpp
  7. 2
      src/Surfaces/SurfaceFactory.h
  8. 13
      src/Surfaces/SurfaceType.h

2
src/Application/Modes/ProjectionMappingMode.cpp

@ -459,7 +459,7 @@ void ProjectionMappingMode::moveSelection(Application * app, ofVec2f by){
app->getSurfaceManager(), by)); app->getSurfaceManager(), by));
} }
void ProjectionMappingMode::createSurface(Application *app, int type){ void ProjectionMappingMode::createSurface(Application *app, SurfaceType type){
app->getCmdManager()->exec( app->getCmdManager()->exec(
new AddSurfaceCmd(app->getSurfaceManager(), type)); new AddSurfaceCmd(app->getSurfaceManager(), type));
} }

2
src/Application/Modes/ProjectionMappingMode.h

@ -61,7 +61,7 @@ class ProjectionMappingMode : public ApplicationBaseMode {
void selectNextVertex(Application * app); void selectNextVertex(Application * app);
void selectPrevVertex(Application * app); void selectPrevVertex(Application * app);
void moveSelection(Application * app, ofVec2f by); void moveSelection(Application * app, ofVec2f by);
void createSurface(Application * app, int type); void createSurface(Application * app, SurfaceType type);
private: private:
ProjectionMappingMode(); ProjectionMappingMode();

7
src/Application/SettingsLoader.cpp

@ -54,9 +54,10 @@ bool SettingsLoader::load(
for(int i = 0; i < numSurfaces; i++){ for(int i = 0; i < numSurfaces; i++){
if(xmlSettings->tagExists("surface", i)){ if(xmlSettings->tagExists("surface", i)){
int type = -1; SurfaceType type = SurfaceType::NONE;
if(xmlSettings->attributeExists("surface", "type")){ if(xmlSettings->attributeExists("surface", "type")){
type = xmlSettings->getAttribute("surface", "type", 0, i); type = static_cast<SurfaceType>(
xmlSettings->getAttribute("surface", "type", 0, i));
} }
xmlSettings->pushTag("surface", i); xmlSettings->pushTag("surface", i);
@ -99,7 +100,7 @@ bool SettingsLoader::load(
xmlSettings->popTag(); // vertices xmlSettings->popTag(); // vertices
} }
if(type == -1){ if(type == SurfaceType::NONE){
if(vertexCount == 3){ if(vertexCount == 3){
type = SurfaceType::TRIANGLE_SURFACE; type = SurfaceType::TRIANGLE_SURFACE;
}else if(vertexCount == 4){ }else if(vertexCount == 4){

2
src/Commands/AddSurfaceCmd.cpp

@ -3,7 +3,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
AddSurfaceCmd::AddSurfaceCmd(SurfaceManager * sm, int surfaceType){ AddSurfaceCmd::AddSurfaceCmd(SurfaceManager * sm, SurfaceType surfaceType){
_surfaceManager = sm; _surfaceManager = sm;
_surfaceType = surfaceType; _surfaceType = surfaceType;
} }

4
src/Commands/AddSurfaceCmd.h

@ -14,13 +14,13 @@ namespace piMapper {
class AddSurfaceCmd : public BaseUndoCmd { class AddSurfaceCmd : public BaseUndoCmd {
public: public:
AddSurfaceCmd(SurfaceManager * sm, int surfaceType); AddSurfaceCmd(SurfaceManager * sm, SurfaceType surfaceType);
void exec(); void exec();
void undo(); void undo();
private: private:
SurfaceManager * _surfaceManager; SurfaceManager * _surfaceManager;
int _surfaceType; SurfaceType _surfaceType;
}; };

2
src/Surfaces/SurfaceFactory.cpp

@ -12,7 +12,7 @@ SurfaceFactory * SurfaceFactory::instance(){
return _instance; return _instance;
} }
BaseSurface * SurfaceFactory::createSurface(int type){ BaseSurface * SurfaceFactory::createSurface(SurfaceType type){
if(type == SurfaceType::TRIANGLE_SURFACE){ if(type == SurfaceType::TRIANGLE_SURFACE){
return createTriangleSurface(); return createTriangleSurface();
}else if(type == SurfaceType::QUAD_SURFACE){ }else if(type == SurfaceType::QUAD_SURFACE){

2
src/Surfaces/SurfaceFactory.h

@ -17,7 +17,7 @@ class SurfaceFactory {
static SurfaceFactory * instance(); static SurfaceFactory * instance();
// Create new surface based on type // Create new surface based on type
BaseSurface * createSurface(int type); BaseSurface * createSurface(SurfaceType type);
private: private:
static SurfaceFactory * _instance; static SurfaceFactory * _instance;

13
src/Surfaces/SurfaceType.h

@ -3,13 +3,12 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
struct SurfaceType { enum SurfaceType{
enum { TRIANGLE_SURFACE,
TRIANGLE_SURFACE, QUAD_SURFACE,
QUAD_SURFACE, GRID_WARP_SURFACE,
GRID_WARP_SURFACE, HEXAGON_SURFACE,
HEXAGON_SURFACE NONE
};
}; };
} // namespace piMapper } // namespace piMapper

Loading…
Cancel
Save