Generated on Tue May 31 2016 10:19:21 for Gecode by doxygen 1.8.11
visualnode.hh
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Guido Tack <tack@gecode.org>
5  *
6  * Copyright:
7  * Guido Tack, 2006
8  *
9  * Last modified:
10  * $Date: 2013-07-11 12:30:18 +0200 (Thu, 11 Jul 2013) $ by $Author: schulte $
11  * $Revision: 13840 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #ifndef GECODE_GIST_VISUALNODE_HH
39 #define GECODE_GIST_VISUALNODE_HH
40 
41 #include <gecode/gist/spacenode.hh>
42 #include <gecode/kernel.hh>
43 #include <string>
44 
45 namespace Gecode { namespace Gist {
46 
48  class Layout {
49  public:
50  static const int dist_y = 38;
51  static const int extent = 20;
52  static const int minimalSeparation = 10;
53  };
54 
56  class BoundingBox {
57  public:
59  int left;
61  int right;
63  BoundingBox(void) {}
64  };
65 
67  class Extent {
68  public:
70  int l;
72  int r;
74  Extent(void);
76  Extent(int l0, int r0);
78  Extent(int width);
79 
81  void extend(int deltaL, int deltaR);
83  void move(int delta);
84  };
85 
87  class Shape {
88  private:
90  int _depth;
92  BoundingBox bb;
94  Extent shape[1];
96  Shape(const Shape&);
98  Shape& operator =(const Shape&);
100  Shape(void);
101  public:
103  static Shape* allocate(int d);
104  // Destruct
105  static void deallocate(Shape*);
106 
108  static Shape* leaf;
110  static Shape* hidden;
111 
113  int depth(void) const;
115  void setDepth(int d);
117  void computeBoundingBox(void);
119  const Extent& operator [](int i) const;
121  Extent& operator [](int i);
123  bool getExtentAtDepth(int depth, Extent& extent);
125  const BoundingBox& getBoundingBox(void) const;
126  };
127 
129  class VisualNode : public SpaceNode {
130  protected:
138  BOOKMARKED
139  };
140 
142  int offset;
145 
147  bool containsCoordinateAtDepth(int x, int depth);
148  public:
150  VisualNode(int p);
152  VisualNode(Space* root);
153 
155  bool isHidden(void);
157  void setHidden(bool h);
159  void setStop(bool h);
161  void dirtyUp(const NodeAllocator& na);
163  void layout(const NodeAllocator& na);
165  int getOffset(void);
167  void setOffset(int n);
169  bool isDirty(void);
171  void setDirty(bool d);
173  bool childrenLayoutIsDone(void);
175  void setChildrenLayoutDone(bool d);
177  bool isMarked(void);
179  void setMarked(bool m);
181  bool isBookmarked(void);
183  void setBookmarked(bool m);
185  void pathUp(const NodeAllocator& na);
187  void unPathUp(const NodeAllocator& na);
189  bool isOnPath(void);
191  int getPathAlternative(const NodeAllocator& na);
193  void setOnPath(bool onPath0);
194 
196  void toggleHidden(const NodeAllocator& na);
198  void hideFailed(const NodeAllocator& na, bool onlyDirty=false);
200  void unhideAll(const NodeAllocator& na);
202  void toggleStop(const NodeAllocator& na);
204  void unstopAll(const NodeAllocator& na);
205 
207  Shape* getShape(void);
209  void setShape(Shape* s);
211  void computeShape(const NodeAllocator& na, VisualNode* root);
213  BoundingBox getBoundingBox(void);
215  void changedStatus(const NodeAllocator& na);
217  VisualNode* findNode(const NodeAllocator& na, int x, int y);
218 
220  void labelBranches(NodeAllocator& na,
221  BestNode* curBest, int c_d, int a_d);
223  void labelPath(NodeAllocator& na,
224  BestNode* curBest, int c_d, int a_d);
226  std::string getBranchLabel(NodeAllocator& na,
227  VisualNode* p, const Choice* c,
228  BestNode* curBest, int c_d, int a_d, int alt);
229 
231  std::string toolTip(NodeAllocator& na, BestNode* curBest,
232  int c_d, int a_d);
233 
235  void dispose(void);
236  };
237 
238 }}
239 
240 #include <gecode/gist/node.hpp>
241 #include <gecode/gist/spacenode.hpp>
243 
244 #endif
245 
246 // STATISTICS: gist-any
int right
Right coordinate.
Definition: visualnode.hh:61
int left
Left coordinate.
Definition: visualnode.hh:59
static const int extent
Definition: visualnode.hh:51
int l
Left extent.
Definition: visualnode.hh:70
Static reference to the currently best space.
Definition: spacenode.hh:84
Node allocator.
Definition: node.hh:52
int offset
Relative offset from the parent node.
Definition: visualnode.hh:142
static const int LASTBIT
Last bit used for SpaceNode flags.
Definition: spacenode.hh:131
Computation spaces.
Definition: core.hpp:1362
Gecode::IntSet d(v, 7)
Layout parameters
Definition: visualnode.hh:48
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
const unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance) ...
Definition: search.hh:99
static const int dist_y
Definition: visualnode.hh:50
VisualNodeFlags
Flags for VisualNodes.
Definition: visualnode.hh:132
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Choice for performing commit
Definition: core.hpp:1036
static Shape * hidden
Static shape for hidden nodes.
Definition: visualnode.hh:110
Shape * shape
Shape of this node.
Definition: visualnode.hh:144
BoundingBox(void)
Default constructor.
Definition: visualnode.hh:63
Node class that supports visual layout
Definition: visualnode.hh:129
const unsigned int c_d
Create a clone after every c_d commits (commit distance)
Definition: search.hh:97
The shape of a subtree.
Definition: visualnode.hh:87
A node of a search tree of Gecode spaces.
Definition: spacenode.hh:93
static Shape * leaf
Static shape for leaf nodes.
Definition: visualnode.hh:108
Gecode toplevel namespace
FloatView extend(Home home, Region &r, Term *&t, int &n)
Extend terms by adding view for result.
Definition: post.cpp:78
int r
Right extent.
Definition: visualnode.hh:72
Extent representing shape of a tree at one depth level
Definition: visualnode.hh:67
static const int minimalSeparation
Definition: visualnode.hh:52