Generated on Mon May 10 06:46:31 2010 for Gecode by doxygen 1.6.3

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: 2010-04-08 11:25:15 +0200 (Thu, 08 Apr 2010) $ by $Author: tack $
00011  *     $Revision: 10682 $
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       BOOKMARKED
00133     };
00134 
00136     Shape* shape;
00138     int offset;
00140     BoundingBox box;
00142     bool containsCoordinateAtDepth(int x, int depth);
00143   public:
00145     VisualNode(void);
00147     VisualNode(Space* root);
00149     ~VisualNode(void);
00150 
00152     bool isHidden(void);
00154     void setHidden(bool h);
00156     void setStop(bool h);
00158     void dirtyUp(void);
00160     void layout(void);
00162     int getOffset(void);
00164     void setOffset(int n);
00166     bool isDirty(void);
00168     void setDirty(bool d);
00170     bool childrenLayoutIsDone(void);
00172     void setChildrenLayoutDone(bool d);
00174     bool isMarked(void);
00176     void setMarked(bool m);
00178     bool isBookmarked(void);
00180     void setBookmarked(bool m);
00182     void pathUp(void);
00184     void unPathUp(void);
00186     bool isOnPath(void);
00188     int getPathAlternative(void);
00190     void setOnPath(bool onPath0);
00191 
00193     void toggleHidden(void);
00195     void hideFailed(void);
00197     void unhideAll(void);
00199     void toggleStop(void);
00201     void unstopAll(void);
00202 
00204     Shape* getShape(void);
00206     void setShape(Shape* s);
00208     void computeShape(VisualNode* root);
00210     void setBoundingBox(BoundingBox b);
00212     BoundingBox getBoundingBox(void);
00214     void changedStatus();
00216     VisualNode* getParent(void);
00218     VisualNode* getChild(int i);
00220     VisualNode* findNode(int x, int y);
00221 
00223     std::string toolTip(BestNode* curBest, int c_d, int a_d);
00224 
00226     size_t size(void) const;
00227   };
00228 
00229 }}
00230 
00231 #include <gecode/gist/visualnode.hpp>
00232 
00233 #endif
00234 
00235 // STATISTICS: gist-any