Generated on Sat Feb 7 2015 02:01:19 for Gecode by doxygen 1.8.9.1
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:
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);
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
bool isOnPath(void)
Return whether node is on the path.
Definition: visualnode.hpp:197
std::string toolTip(NodeAllocator &na, BestNode *curBest, int c_d, int a_d)
Return string that is used as a tool tip.
Definition: visualnode.cpp:283
void unhideAll(const NodeAllocator &na)
Unhide all nodes in the subtree of this node.
Definition: visualnode.cpp:211
int right
Right coordinate.
Definition: visualnode.hh:61
void labelPath(NodeAllocator &na, BestNode *curBest, int c_d, int a_d)
Create or clear branch labels on path to root.
Definition: visualnode.cpp:179
void setOnPath(bool onPath0)
Set whether node is on the path.
Definition: visualnode.hpp:202
int left
Left coordinate.
Definition: visualnode.hh:59
void setMarked(bool m)
Set mark of this node.
Definition: visualnode.hpp:182
static const int extent
Definition: visualnode.hh:51
void dispose(void)
Free allocated memory.
Definition: visualnode.cpp:100
int l
Left extent.
Definition: visualnode.hh:70
Static reference to the currently best space.
Definition: spacenode.hh:84
void computeBoundingBox(void)
Compute bounding box.
Definition: visualnode.hpp:114
bool isDirty(void)
Return whether node is marked as dirty.
Definition: visualnode.hpp:157
void layout(const NodeAllocator &na)
Compute layout for the subtree of this node.
Definition: visualnode.cpp:117
BoundingBox getBoundingBox(void)
Return the bounding box.
Definition: visualnode.hpp:212
bool isHidden(void)
Return if node is hidden.
Definition: visualnode.hpp:133
void setChildrenLayoutDone(bool d)
Mark node whether the layout of the node's children has been completed.
Definition: visualnode.hpp:172
void setStop(bool h)
Set stop state to h.
Definition: visualnode.hpp:143
void setDirty(bool d)
Mark node as dirty.
Definition: visualnode.hpp:162
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
void setHidden(bool h)
Set hidden state to h.
Definition: visualnode.hpp:138
static Shape * allocate(int d)
Construct shape of depth d.
Definition: visualnode.hpp:85
void toggleStop(const NodeAllocator &na)
Do not stop at this node.
Definition: visualnode.cpp:218
Computation spaces.
Definition: core.hpp:1362
void setBookmarked(bool m)
Set bookmark of this node.
Definition: visualnode.hpp:192
std::string getBranchLabel(NodeAllocator &na, VisualNode *p, const Choice *c, BestNode *curBest, int c_d, int a_d, int alt)
Return string that describes the branch.
Definition: visualnode.cpp:288
Gecode::IntSet d(v, 7)
Layout parameters
Definition: visualnode.hh:48
void labelBranches(NodeAllocator &na, BestNode *curBest, int c_d, int a_d)
Create or clear branch labels in subtree.
Definition: visualnode.cpp:170
Gecode::FloatVal c(-8, 8)
void unstopAll(const NodeAllocator &na)
Do not stop at any stop node in the subtree of this node.
Definition: visualnode.cpp:227
bool getExtentAtDepth(int depth, Extent &extent)
Return if extent exists at depth, if yes return it in extent.
Definition: visualnode.hpp:101
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
void extend(int deltaL, int deltaR)
Extend extent by deltaL and deltaR.
Definition: visualnode.hpp:54
static const int dist_y
Definition: visualnode.hh:50
void setOffset(int n)
Set offset of this node, relative to its parent.
Definition: visualnode.hpp:154
void move(int delta)
Move extent by delta.
Definition: visualnode.hpp:59
int getPathAlternative(const NodeAllocator &na)
Return the alternative of the child that is on the path (-1 if none)
Definition: visualnode.cpp:148
VisualNodeFlags
Flags for VisualNodes.
Definition: visualnode.hh:132
void changedStatus(const NodeAllocator &na)
Signal that the status has changed.
Definition: visualnode.cpp:234
Shape * getShape(void)
Return the shape of this node.
Definition: visualnode.hpp:207
int depth(void) const
Return depth of the shape.
Definition: visualnode.hpp:64
bool childrenLayoutIsDone(void)
Return whether the layout of the node's children has been completed.
Definition: visualnode.hpp:167
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Choice for performing commit
Definition: core.hpp:1036
Extent(void)
Default constructor.
Definition: visualnode.hpp:41
void dirtyUp(const NodeAllocator &na)
Mark all nodes up the path to the parent as dirty.
Definition: visualnode.cpp:106
bool isMarked(void)
Return whether node is marked.
Definition: visualnode.hpp:177
static Shape * hidden
Static shape for hidden nodes.
Definition: visualnode.hh:110
Shape * shape
Shape of this node.
Definition: visualnode.hh:144
void toggleHidden(const NodeAllocator &na)
Toggle whether this node is hidden.
Definition: visualnode.cpp:157
bool isBookmarked(void)
Return whether node is bookmarked.
Definition: visualnode.hpp:187
const BoundingBox & getBoundingBox(void) const
Return bounding box.
Definition: visualnode.hpp:128
BoundingBox(void)
Default constructor.
Definition: visualnode.hh:63
void unPathUp(const NodeAllocator &na)
Set all nodes from the node to the root not to be on the path.
Definition: visualnode.cpp:139
Node class that supports visual layout
Definition: visualnode.hh:129
int getOffset(void)
Return offset off this node from its parent.
Definition: visualnode.hpp:151
const Extent & operator[](int i) const
Return extent at depth i.
Definition: visualnode.hpp:73
VisualNode * findNode(const NodeAllocator &na, int x, int y)
Find a node in this subtree at coordinates x, y.
Definition: visualnode.cpp:253
VisualNode(int p)
Construct with parent p.
Definition: visualnode.cpp:73
const unsigned int c_d
Create a clone after every c_d commits (commit distance)
Definition: search.hh:97
void computeShape(const NodeAllocator &na, VisualNode *root)
Compute the shape according to the shapes of the children.
Definition: visualnode.cpp:403
static void deallocate(Shape *)
Definition: visualnode.hpp:95
The shape of a subtree.
Definition: visualnode.hh:87
A node of a search tree of Gecode spaces.
Definition: spacenode.hh:93
void pathUp(const NodeAllocator &na)
Set all nodes from the node to the root to be on the path.
Definition: visualnode.cpp:131
static Shape * leaf
Static shape for leaf nodes.
Definition: visualnode.hh:108
Gecode toplevel namespace
void setDepth(int d)
Set depth of the shape to d (must be smaller than original depth)
Definition: visualnode.hpp:67
bool containsCoordinateAtDepth(int x, int depth)
Check if the x at depth depth lies in this subtree.
Definition: visualnode.cpp:237
int r
Right extent.
Definition: visualnode.hh:72
void setShape(Shape *s)
Set the shape of this node.
Definition: visualnode.cpp:395
Extent representing shape of a tree at one depth level
Definition: visualnode.hh:67
static const int minimalSeparation
Definition: visualnode.hh:52
void hideFailed(const NodeAllocator &na, bool onlyDirty=false)
Hide all failed subtrees of this node.
Definition: visualnode.cpp:163