00001
00002
00003 #ifndef INCLUDED_SketchDataRoot_h
00004 #define INCLUDED_SketchDataRoot_h
00005
00006 #include <string>
00007
00008 #include "Shared/ProjectInterface.h"
00009
00010 #include "SketchTypes.h"
00011 #include "SketchSpace.h"
00012 #include "ShapeRoot.h"
00013
00014 namespace DualCoding {
00015
00016
00017 class SketchDataRoot {
00018 private:
00019
00020 SketchSpace *space;
00021
00022
00023 std::string name;
00024
00025
00026 int id;
00027
00028
00029 int parentId;
00030
00031
00032 int refcount;
00033
00034
00035 bool viewable;
00036
00037
00038 int refreshTag;
00039
00040
00041 bool clearPending;
00042
00043
00044
00045 rgb color;
00046
00047
00048
00049
00050 ColorMapType_t colormap;
00051
00052 template<typename T> friend class SketchPool;
00053 template<typename T> friend class Sketch;
00054 template<typename T> friend class SketchData;
00055 friend class SketchRoot;
00056
00057 public:
00058 SketchDataRoot(SketchSpace *s) :
00059 space(s), name(), id(0), parentId(0),
00060 refcount(0), viewable(false), refreshTag(0), clearPending(false),
00061 color((ProjectInterface::getNumColors() != -1U) ? ProjectInterface::getColorRGB(1) : rgb(0,0,255)),
00062 colormap(segMap) {}
00063
00064 virtual ~SketchDataRoot() {};
00065
00066
00067 SketchSpace& getSpace() const { return *space; }
00068
00069
00070 ShapeSpace& getDualSpace() const { return space->getDualSpace(); }
00071
00072 int getId() const { return id; }
00073 int getParentId() const { return parentId; }
00074 int getViewableId() const { return (isViewable() ? getId() : getParentId()); }
00075 void setParentId(int const _id) { parentId = _id; }
00076 bool isViewable() const { return viewable; }
00077 void setViewable(bool const v) { viewable=v; }
00078 rgb getColor() const { return color; }
00079 void setColor(const rgb _color) { color = _color; }
00080 ColorMapType_t getColorMap() const { return colormap; }
00081 void setColorMap(const ColorMapType_t _map) { colormap = _map; }
00082 const std::string& getName() const { return name; }
00083 void setName(const std::string &_name) { name = _name; }
00084
00085 virtual SketchType_t getType() const=0;
00086
00087 void V(std::string const &_name="");
00088 void N(std::string const &_name="");
00089
00090 void inheritFrom(const SketchDataRoot &parent);
00091 void inheritFrom(const ShapeRoot &parent);
00092 void inheritFrom(const BaseData &parent);
00093
00094
00095
00096 const size_t getWidth() const;
00097 const size_t getHeight() const;
00098 const size_t getNumPixels() const;
00099
00100
00101
00102 int indexX(int index) { return index % getWidth(); }
00103
00104
00105 int indexY(int index) { return index / getWidth(); }
00106
00107
00108 int indexOf(int x, int y) { return y*getWidth() + x; }
00109
00110 virtual unsigned int saveBuffer(char buf[], unsigned int avail) const=0;
00111
00112 private:
00113 SketchDataRoot(const SketchDataRoot&);
00114 SketchDataRoot& operator=(const SketchDataRoot&);
00115 };
00116
00117 }
00118
00119 #endif