Generated on Thu Mar 22 10:39:32 2012 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-09-03 11:25:49 +0200 (Fri, 03 Sep 2010) $ by $Author: tack $
00011  *     $Revision: 11387 $
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 Layout {
00049   public:
00050     static const int dist_y = 38;
00051     static const int extent = 20;
00052     static const int minimalSeparation = 10;
00053   };
00054 
00056   class BoundingBox {
00057   public:
00059     int left;
00061     int right;
00063     BoundingBox(void) {}
00064   };
00065 
00067   class Extent {
00068   public:
00070     int l;
00072     int r;
00074     Extent(void);
00076     Extent(int l0, int r0);
00078     Extent(int width);
00079 
00081     void extend(int deltaL, int deltaR);
00083     void move(int delta);
00084   };
00085 
00087   class Shape {
00088   private:
00090     int _depth;
00092     BoundingBox bb;
00094     Extent shape[1];
00096     Shape(const Shape&);
00098     Shape& operator =(const Shape&);
00100     Shape(void);
00101   public:
00103     static Shape* allocate(int d);
00104     // Destruct
00105     static void deallocate(Shape*);
00106 
00108     static Shape* leaf;
00110     static Shape* hidden;
00111 
00113     int depth(void) const;
00115     void setDepth(int d);
00117     void computeBoundingBox(void);
00119     const Extent& operator [](int i) const;
00121     Extent& operator [](int i);
00123     bool getExtentAtDepth(int depth, Extent& extent);
00125     const BoundingBox& getBoundingBox(void) const;
00126   };
00127 
00129   class VisualNode : public SpaceNode {
00130   protected:
00132     enum VisualNodeFlags {
00133       DIRTY = SpaceNode::LASTBIT+1,
00134       CHILDRENLAYOUTDONE,
00135       HIDDEN,
00136       MARKED,
00137       ONPATH,
00138       BOOKMARKED
00139     };
00140 
00142     int offset;
00144     Shape* shape;
00145 
00147     bool containsCoordinateAtDepth(int x, int depth);
00148   public:
00150     VisualNode(int p);
00152     VisualNode(Space* root);
00153 
00155     bool isHidden(void);
00157     void setHidden(bool h);
00159     void setStop(bool h);
00161     void dirtyUp(const NodeAllocator& na);
00163     void layout(const NodeAllocator& na);
00165     int getOffset(void);
00167     void setOffset(int n);
00169     bool isDirty(void);
00171     void setDirty(bool d);
00173     bool childrenLayoutIsDone(void);
00175     void setChildrenLayoutDone(bool d);
00177     bool isMarked(void);
00179     void setMarked(bool m);
00181     bool isBookmarked(void);
00183     void setBookmarked(bool m);
00185     void pathUp(const NodeAllocator& na);
00187     void unPathUp(const NodeAllocator& na);
00189     bool isOnPath(void);
00191     int getPathAlternative(const NodeAllocator& na);
00193     void setOnPath(bool onPath0);
00194 
00196     void toggleHidden(const NodeAllocator& na);
00198     void hideFailed(const NodeAllocator& na, bool onlyDirty=false);
00200     void unhideAll(const NodeAllocator& na);
00202     void toggleStop(const NodeAllocator& na);
00204     void unstopAll(const NodeAllocator& na);
00205 
00207     Shape* getShape(void);
00209     void setShape(Shape* s);
00211     void computeShape(const NodeAllocator& na, VisualNode* root);
00213     BoundingBox getBoundingBox(void);
00215     void changedStatus(const NodeAllocator& na);
00217     VisualNode* findNode(const NodeAllocator& na, int x, int y);
00218 
00220     std::string toolTip(BestNode* curBest, int c_d, int a_d);
00221 
00223     size_t size(void) const;
00224     
00226     void dispose(void);
00227   };
00228 
00229 }}
00230 
00231 #include <gecode/gist/node.hpp>
00232 #include <gecode/gist/spacenode.hpp>
00233 #include <gecode/gist/visualnode.hpp>
00234 
00235 #endif
00236 
00237 // STATISTICS: gist-any