SketchDataRoot.h
Go to the documentation of this file.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 "Point.h"
00012
00013 namespace DualCoding {
00014
00015 class BaseData;
00016 class ShapeRoot;
00017 class ShapeSpace;
00018 class SketchSpace;
00019
00020
00021 class SketchDataRoot {
00022 private:
00023
00024 SketchSpace *space;
00025
00026
00027 std::string name;
00028
00029
00030 int id;
00031
00032
00033 int parentId;
00034
00035
00036 int refcount;
00037
00038
00039 bool retained;
00040
00041
00042 bool viewable;
00043
00044
00045 int refreshTag;
00046
00047
00048 bool clearPending;
00049
00050
00051
00052
00053 rgb color;
00054
00055
00056
00057
00058 ColorMapType_t colormap;
00059
00060 template<typename T> friend class SketchPool;
00061 template<typename T> friend class Sketch;
00062 template<typename T> friend class SketchData;
00063 friend class SketchRoot;
00064
00065 public:
00066 SketchDataRoot(SketchSpace *s) :
00067 space(s), name(), id(0), parentId(0),
00068 refcount(0), retained(false), viewable(false), refreshTag(0), clearPending(false),
00069 color((ProjectInterface::getNumColors() != -1U) ? ProjectInterface::getColorRGB(1) : rgb(0,0,255)),
00070 colormap(segMap) {}
00071
00072 virtual ~SketchDataRoot() {};
00073
00074
00075 SketchSpace& getSpace() const { return *space; }
00076
00077
00078 ShapeSpace& getDualSpace() const;
00079
00080
00081 int getId() const { return id; }
00082
00083
00084 int getParentId() const { return parentId; }
00085
00086
00087 void setParentId(int const _id) { parentId = _id; }
00088
00089
00090 int getViewableId() const { return (isViewable() ? getId() : getParentId()); }
00091
00092
00093 bool isViewable() const { return viewable; }
00094
00095
00096 void setViewable(bool const v=true) { viewable=v; }
00097
00098
00099 void retain(bool const r=true) { retained=r; }
00100
00101
00102 bool isRetained() const { return retained; }
00103
00104
00105 int getRefcount() const { return refcount; }
00106
00107
00108 rgb getColor() const { return color; }
00109
00110
00111
00112 void setColor(const rgb &_color) { color = _color; }
00113 void setColor(const std::string &colorname);
00114 void setColor(const color_index cindex);
00115
00116
00117
00118 ColorMapType_t getColorMap() const { return colormap; }
00119
00120
00121 void setColorMap(const ColorMapType_t _map) { colormap = _map; }
00122
00123
00124 const std::string& getName() const { return name; }
00125
00126
00127 void setName(const std::string &_name) { name = _name; }
00128
00129
00130 virtual SketchType_t getType() const=0;
00131
00132
00133 void V(std::string const &_name="");
00134
00135
00136 void N(std::string const &_name="");
00137
00138
00139
00140 void inheritFrom(const SketchDataRoot &parent);
00141 void inheritFrom(const ShapeRoot &parent);
00142 void inheritFrom(const BaseData &parent);
00143
00144
00145
00146
00147 const unsigned int getWidth() const;
00148 const unsigned int getHeight() const;
00149 const unsigned int getNumPixels() const;
00150
00151
00152
00153 int indexX(int index) { return index % getWidth(); }
00154
00155
00156 int indexY(int index) { return index / getWidth(); }
00157
00158
00159 Point indexPoint(const int index);
00160
00161
00162 int indexOf(int x, int y) { return y*getWidth() + x; }
00163
00164
00165 virtual unsigned int saveBuffer(char buf[], unsigned int avail) const;
00166
00167 virtual size_t savePixels(char buf[], size_t avail) const =0;
00168
00169 private:
00170 SketchDataRoot(const SketchDataRoot&);
00171 SketchDataRoot& operator=(const SketchDataRoot&);
00172 };
00173
00174 }
00175
00176 #endif