Generated on Mon Nov 30 23:53:19 2009 for Gecode by doxygen 1.6.1

visualnode.hh

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Guido Tack, 2006
00008  *
00009  *  Last modified:
00010  *     $Date: 2009-05-13 00:53:54 +0200 (Wed, 13 May 2009) $ by $Author: tack $
00011  *     $Revision: 9076 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  * Permission is hereby granted, free of charge, to any person obtaining
00018  * a copy of this software and associated documentation files (the
00019  * "Software"), to deal in the Software without restriction, including
00020  * without limitation the rights to use, copy, modify, merge, publish,
00021  * distribute, sublicense, and/or sell copies of the Software, and to
00022  * permit persons to whom the Software is furnished to do so, subject to
00023  * the following conditions:
00024  *
00025  * The above copyright notice and this permission notice shall be
00026  * included in all copies or substantial portions of the Software.
00027  *
00028  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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     // Destruct
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 // STATISTICS: gist-any