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 int getRefcount() const { return refcount; }
00079 rgb getColor() const { return color; }
00080 void setColor(const rgb &_color) { color = _color; }
00081 void setColor(const std::string &colorname);
00082 void setColor(const color_index cindex);
00083 ColorMapType_t getColorMap() const { return colormap; }
00084 void setColorMap(const ColorMapType_t _map) { colormap = _map; }
00085 const std::string& getName() const { return name; }
00086 void setName(const std::string &_name) { name = _name; }
00087
00088 virtual SketchType_t getType() const=0;
00089
00090 void V(std::string const &_name="");
00091 void N(std::string const &_name="");
00092
00093 void inheritFrom(const SketchDataRoot &parent);
00094 void inheritFrom(const ShapeRoot &parent);
00095 void inheritFrom(const BaseData &parent);
00096
00097
00098
00099 const size_t getWidth() const;
00100 const size_t getHeight() const;
00101 const size_t getNumPixels() const;
00102
00103
00104
00105 int indexX(int index) { return index % getWidth(); }
00106
00107
00108 int indexY(int index) { return index / getWidth(); }
00109
00110
00111 int indexOf(int x, int y) { return y*getWidth() + x; }
00112
00113 virtual unsigned int saveBuffer(char buf[], unsigned int avail) const=0;
00114
00115 private:
00116 SketchDataRoot(const SketchDataRoot&);
00117 SketchDataRoot& operator=(const SketchDataRoot&);
00118 };
00119
00120 }
00121
00122 #endif