visualnode.hh
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef GECODE_GIST_VISUALNODE_HH
00039 #define GECODE_GIST_VISUALNODE_HH
00040
00041 #include <gecode/gist/spacenode.hh>
00042 #include <gecode/kernel.hh>
00043 #include <string>
00044
00045 namespace Gecode { namespace Gist {
00046
00048 class BoundingBox {
00049 public:
00051 int left;
00053 int right;
00055 BoundingBox(int l, int r);
00057 BoundingBox(void) {}
00058 };
00059
00061 class Extent {
00062 public:
00064 int l;
00066 int r;
00068 Extent(void);
00070 Extent(int l0, int r0);
00072 Extent(int width);
00073
00075 void extend(int deltaL, int deltaR);
00077 void move(int delta);
00078 };
00079
00081 class Shape {
00082 private:
00084 int _depth;
00086 Extent shape[1];
00088 Shape(const Shape&);
00090 Shape& operator =(const Shape&);
00092 Shape(void);
00093 public:
00095 static Shape* allocate(int d);
00097 static Shape* allocate(Extent e);
00099 static Shape* allocate(Extent e, const Shape* subShape);
00101 static Shape* allocate(const Shape* subShape);
00102
00103 static void deallocate(Shape*);
00104
00106 static Shape* leaf;
00108 static Shape* hidden;
00109
00111 int depth(void) const;
00113 const Extent& operator [](int i) const;
00115 Extent& operator [](int i);
00117 bool getExtentAtDepth(int depth, Extent& extent);
00119 BoundingBox getBoundingBox(void);
00120 };
00121
00123 class VisualNode : public SpaceNode {
00124 protected:
00126 enum VisualNodeFlags {
00127 DIRTY = SpaceNode::LASTBIT+1,
00128 CHILDRENLAYOUTDONE,
00129 HIDDEN,
00130 MARKED,
00131 ONPATH
00132 };
00133
00135 Shape* shape;
00137 int offset;
00139 BoundingBox box;
00141 bool containsCoordinateAtDepth(int x, int depth);
00142 public:
00144 VisualNode(void);
00146 VisualNode(Space* root);
00148 ~VisualNode(void);
00149
00151 bool isHidden(void);
00153 void setHidden(bool h);
00155 void dirtyUp(void);
00157 void layout(void);
00159 int getOffset(void);
00161 void setOffset(int n);
00163 bool isDirty(void);
00165 void setDirty(bool d);
00167 bool childrenLayoutIsDone(void);
00169 void setChildrenLayoutDone(bool d);
00171 bool isMarked(void);
00173 void setMarked(bool m);
00175 void pathUp(void);
00177 void unPathUp(void);
00179 bool isOnPath(void);
00181 int getPathAlternative(void);
00183 void setOnPath(bool onPath0);
00184
00186 void toggleHidden(void);
00188 void hideFailed(void);
00190 void unhideAll(void);
00191
00193 Shape* getShape(void);
00195 void setShape(Shape* s);
00197 void computeShape(VisualNode* root);
00199 void setBoundingBox(BoundingBox b);
00201 BoundingBox getBoundingBox(void);
00203 void changedStatus();
00205 VisualNode* getParent(void);
00207 VisualNode* getChild(int i);
00209 VisualNode* findNode(int x, int y);
00210
00212 std::string toolTip(BestNode* curBest, int c_d, int a_d);
00213
00215 size_t size(void) const;
00216 };
00217
00218 }}
00219
00220 #include <gecode/gist/visualnode.hpp>
00221
00222 #endif
00223
00224