Generated on Fri Oct 19 11:25:00 2018 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  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *
00013  * Permission is hereby granted, free of charge, to any person obtaining
00014  * a copy of this software and associated documentation files (the
00015  * "Software"), to deal in the Software without restriction, including
00016  * without limitation the rights to use, copy, modify, merge, publish,
00017  * distribute, sublicense, and/or sell copies of the Software, and to
00018  * permit persons to whom the Software is furnished to do so, subject to
00019  * the following conditions:
00020  *
00021  * The above copyright notice and this permission notice shall be
00022  * included in all copies or substantial portions of the Software.
00023  *
00024  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00028  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00029  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 #ifndef GECODE_GIST_VISUALNODE_HH
00035 #define GECODE_GIST_VISUALNODE_HH
00036 
00037 #include <gecode/gist/spacenode.hh>
00038 #include <gecode/kernel.hh>
00039 #include <string>
00040 
00041 namespace Gecode { namespace Gist {
00042 
00044   class Layout {
00045   public:
00046     static const int dist_y = 38;
00047     static const int extent = 20;
00048     static const int minimalSeparation = 10;
00049   };
00050 
00052   class BoundingBox {
00053   public:
00055     int left;
00057     int right;
00059     BoundingBox(void) {}
00060   };
00061 
00063   class Extent {
00064   public:
00066     int l;
00068     int r;
00070     Extent(void);
00072     Extent(int l0, int r0);
00074     Extent(int width);
00075 
00077     void extend(int deltaL, int deltaR);
00079     void move(int delta);
00080   };
00081 
00083   class Shape {
00084   private:
00086     int _depth;
00088     BoundingBox bb;
00090     Extent shape[1];
00092     Shape(const Shape&);
00094     Shape& operator =(const Shape&);
00096     Shape(void);
00097   public:
00099     static Shape* allocate(int d);
00100     // Destruct
00101     static void deallocate(Shape*);
00102 
00104     static Shape* leaf;
00106     static Shape* hidden;
00107 
00109     int depth(void) const;
00111     void setDepth(int d);
00113     void computeBoundingBox(void);
00115     const Extent& operator [](int i) const;
00117     Extent& operator [](int i);
00119     bool getExtentAtDepth(int depth, Extent& extent);
00121     const BoundingBox& getBoundingBox(void) const;
00122   };
00123 
00125   class VisualNode : public SpaceNode {
00126   protected:
00128     enum VisualNodeFlags {
00129       DIRTY = SpaceNode::LASTBIT+1,
00130       CHILDRENLAYOUTDONE,
00131       HIDDEN,
00132       MARKED,
00133       ONPATH,
00134       BOOKMARKED
00135     };
00136 
00138     int offset;
00140     Shape* shape;
00141 
00143     bool containsCoordinateAtDepth(int x, int depth);
00144   public:
00146     VisualNode(int p);
00148     VisualNode(Space* root);
00149 
00151     bool isHidden(void);
00153     void setHidden(bool h);
00155     void setStop(bool h);
00157     void dirtyUp(const NodeAllocator& na);
00159     void layout(const NodeAllocator& na);
00161     int getOffset(void);
00163     void setOffset(int n);
00165     bool isDirty(void);
00167     void setDirty(bool d);
00169     bool childrenLayoutIsDone(void);
00171     void setChildrenLayoutDone(bool d);
00173     bool isMarked(void);
00175     void setMarked(bool m);
00177     bool isBookmarked(void);
00179     void setBookmarked(bool m);
00181     void pathUp(const NodeAllocator& na);
00183     void unPathUp(const NodeAllocator& na);
00185     bool isOnPath(void);
00187     int getPathAlternative(const NodeAllocator& na);
00189     void setOnPath(bool onPath0);
00190 
00192     void toggleHidden(const NodeAllocator& na);
00194     void hideFailed(const NodeAllocator& na, bool onlyDirty=false);
00196     void unhideAll(const NodeAllocator& na);
00198     void toggleStop(const NodeAllocator& na);
00200     void unstopAll(const NodeAllocator& na);
00201 
00203     Shape* getShape(void);
00205     void setShape(Shape* s);
00207     void computeShape(const NodeAllocator& na);
00209     BoundingBox getBoundingBox(void);
00211     void changedStatus(const NodeAllocator& na);
00213     VisualNode* findNode(const NodeAllocator& na, int x, int y);
00214 
00216     void labelBranches(NodeAllocator& na,
00217                        BestNode* curBest, int c_d, int a_d);
00219     void labelPath(NodeAllocator& na,
00220                    BestNode* curBest, int c_d, int a_d);
00222     std::string getBranchLabel(NodeAllocator& na,
00223                                VisualNode* p, const Choice* c,
00224                                BestNode* curBest, int c_d, int a_d, int alt);
00225 
00227     std::string toolTip(NodeAllocator& na, BestNode* curBest,
00228                         int c_d, int a_d);
00229 
00231     void dispose(void);
00232   };
00233 
00234 }}
00235 
00236 #include <gecode/gist/node.hpp>
00237 #include <gecode/gist/spacenode.hpp>
00238 #include <gecode/gist/visualnode.hpp>
00239 
00240 #endif
00241 
00242 // STATISTICS: gist-any