Mercurial > hg > wabletios
diff mesh.h @ 9:0e03760cf2d9
save preset stuff, not quite there
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Tue, 14 May 2013 18:05:08 +0100 |
parents | 4ea605899aca |
children | df1d4beb6994 |
line wrap: on
line diff
--- a/mesh.h Tue May 14 10:34:32 2013 +0100 +++ b/mesh.h Tue May 14 18:05:08 2013 +0100 @@ -44,11 +44,13 @@ enum constrainMode { CONSTRAIN_CORNERS, CONSTRAIN_EDGES,CONSTRAIN_EDGES_XY, CONSTRAIN_SINGLE_POINT, CONSTRAIN_SINGLE_POINT_X, CONSTRAIN_SINGLE_POINT_Y, CONSTRAIN_GRAB_REGION,CONSTRAIN_GRAB_REGION_X,CONSTRAIN_GRAB_REGION_Y, CONSTRAIN_ALL_X, CONSTRAIN_ALL_Y}; double GRAB_RANGE; - enum MeshType {SQUARE_CROSS_MESH, SPIDER_MESH, SPIDER_CROSS_MESH, DROPLET_MESH, LINE_MESH, TRIANGLE_MESH, GROUNDED_LINE_MESH, HOLED_SPIDER_MESH}; + enum MeshType {SQUARE_MESH, SQUARE_CROSS_MESH, SPIDER_MESH, SPIDER_CROSS_MESH, DROPLET_MESH, LINE_MESH, TRIANGLE_MESH, GROUNDED_LINE_MESH, HOLED_SPIDER_MESH}; MeshType meshType; // MEMBER FUNCTIONS Mesh(); + Mesh(Json::Value& savedMesh); // contructor using saved mesh + virtual ~Mesh(); void draw(); @@ -119,7 +121,7 @@ // save stuff Json::Value convertToJsonForSaving(); - + Json::Value saveConnectionsAsJson(); protected: int prevLump; @@ -130,7 +132,13 @@ virtual void setLumpPositions(); virtual void makeConnections(); virtual void makeDefaultScanPath(); - + + // alternatively get from saved: + + void setLumpPositionsFromJson(Json::Value lumpPositions); + void makeConnectionsFromJson(Json::Value connections); + void makeScanPathFromJson(Json::Value scanPathElements); + void constrainFromJson(Json::Value constrainedLumps); // UTILS TwoVector calculateCentre(); void connect(int springnum,int lumpnum); @@ -177,20 +185,30 @@ void makeDefaultScanPath(); // same }; //--------------------------------------------------------- -// square grid with all diagonals connected -class SquareCrossMesh : public Mesh{ +// square grid +class SquareMesh : public Mesh{ public: // square specific int height; int width; - - SquareCrossMesh(int height, int width); + SquareMesh(); + SquareMesh(int height, int width); + ~SquareMesh(); + void constrain(double x, double y, constrainMode aMode); + void makeComponents(int adimension1, int adimension2); + void setLumpPositions(); + void makeConnections(); + void makeDefaultScanPath(); +}; +//--------------------------------------------------------- +// square grid with all diagonals connected i.e. we override makeConnections +class SquareCrossMesh : public SquareMesh{ +public: + SquareCrossMesh(){}; + SquareCrossMesh(int height, int width); ~SquareCrossMesh(); - void constrain(double x, double y, constrainMode aMode); - void makeComponents(int adimension1, int adimension2); - void setLumpPositions(); void makeConnections(); - void makeDefaultScanPath(); + }; //--------------------------------------------------------- // simple 1d line