Generated on Sat Oct 20 2018 12:43:45 for Gecode by doxygen 1.8.13
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  * This file is part of Gecode, the generic constraint
10  * development environment:
11  * http://www.gecode.org
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining
14  * a copy of this software and associated documentation files (the
15  * "Software"), to deal in the Software without restriction, including
16  * without limitation the rights to use, copy, modify, merge, publish,
17  * distribute, sublicense, and/or sell copies of the Software, and to
18  * permit persons to whom the Software is furnished to do so, subject to
19  * the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be
22  * included in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31  *
32  */
33 
34 #ifndef GECODE_GIST_VISUALNODE_HH
35 #define GECODE_GIST_VISUALNODE_HH
36 
37 #include <gecode/gist/spacenode.hh>
38 #include <gecode/kernel.hh>
39 #include <string>
40 
41 namespace Gecode { namespace Gist {
42 
44  class Layout {
45  public:
46  static const int dist_y = 38;
47  static const int extent = 20;
48  static const int minimalSeparation = 10;
49  };
50 
52  class BoundingBox {
53  public:
55  int left;
57  int right;
59  BoundingBox(void) {}
60  };
61 
63  class Extent {
64  public:
66  int l;
68  int r;
70  Extent(void);
72  Extent(int l0, int r0);
74  Extent(int width);
75 
77  void extend(int deltaL, int deltaR);
79  void move(int delta);
80  };
81 
83  class Shape {
84  private:
86  int _depth;
88  BoundingBox bb;
90  Extent shape[1];
92  Shape(const Shape&);
94  Shape& operator =(const Shape&);
96  Shape(void);
97  public:
99  static Shape* allocate(int d);
100  // Destruct
101  static void deallocate(Shape*);
102 
104  static Shape* leaf;
106  static Shape* hidden;
107 
109  int depth(void) const;
111  void setDepth(int d);
113  void computeBoundingBox(void);
115  const Extent& operator [](int i) const;
117  Extent& operator [](int i);
119  bool getExtentAtDepth(int depth, Extent& extent);
121  const BoundingBox& getBoundingBox(void) const;
122  };
123 
125  class VisualNode : public SpaceNode {
126  protected:
134  BOOKMARKED
135  };
136 
138  int offset;
141 
143  bool containsCoordinateAtDepth(int x, int depth);
144  public:
146  VisualNode(int p);
148  VisualNode(Space* root);
149 
151  bool isHidden(void);
153  void setHidden(bool h);
155  void setStop(bool h);
157  void dirtyUp(const NodeAllocator& na);
159  void layout(const NodeAllocator& na);
161  int getOffset(void);
163  void setOffset(int n);
165  bool isDirty(void);
167  void setDirty(bool d);
169  bool childrenLayoutIsDone(void);
171  void setChildrenLayoutDone(bool d);
173  bool isMarked(void);
175  void setMarked(bool m);
177  bool isBookmarked(void);
179  void setBookmarked(bool m);
181  void pathUp(const NodeAllocator& na);
183  void unPathUp(const NodeAllocator& na);
185  bool isOnPath(void);
187  int getPathAlternative(const NodeAllocator& na);
189  void setOnPath(bool onPath0);
190 
192  void toggleHidden(const NodeAllocator& na);
194  void hideFailed(const NodeAllocator& na, bool onlyDirty=false);
196  void unhideAll(const NodeAllocator& na);
198  void toggleStop(const NodeAllocator& na);
200  void unstopAll(const NodeAllocator& na);
201 
203  Shape* getShape(void);
205  void setShape(Shape* s);
207  void computeShape(const NodeAllocator& na);
209  BoundingBox getBoundingBox(void);
211  void changedStatus(const NodeAllocator& na);
213  VisualNode* findNode(const NodeAllocator& na, int x, int y);
214 
216  void labelBranches(NodeAllocator& na,
217  BestNode* curBest, int c_d, int a_d);
219  void labelPath(NodeAllocator& na,
220  BestNode* curBest, int c_d, int a_d);
222  std::string getBranchLabel(NodeAllocator& na,
223  VisualNode* p, const Choice* c,
224  BestNode* curBest, int c_d, int a_d, int alt);
225 
227  std::string toolTip(NodeAllocator& na, BestNode* curBest,
228  int c_d, int a_d);
229 
231  void dispose(void);
232  };
233 
234 }}
235 
236 #include <gecode/gist/node.hpp>
237 #include <gecode/gist/spacenode.hpp>
239 
240 #endif
241 
242 // STATISTICS: gist-any
int right
Right coordinate.
Definition: visualnode.hh:57
int left
Left coordinate.
Definition: visualnode.hh:55
static const int extent
Definition: visualnode.hh:47
int l
Left extent.
Definition: visualnode.hh:66
Static reference to the currently best space.
Definition: spacenode.hh:80
Node allocator.
Definition: node.hh:48
int offset
Relative offset from the parent node.
Definition: visualnode.hh:138
static const int LASTBIT
Last bit used for SpaceNode flags.
Definition: spacenode.hh:127
Computation spaces.
Definition: core.hpp:1701
Gecode::IntSet d(v, 7)
Layout parameters
Definition: visualnode.hh:44
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Gecode::IntArgs i({1, 2, 3, 4})
const unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance) ...
Definition: search.hh:115
static const int dist_y
Definition: visualnode.hh:46
VisualNodeFlags
Flags for VisualNodes.
Definition: visualnode.hh:128
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:767
Choice for performing commit
Definition: core.hpp:1371
static Shape * hidden
Static shape for hidden nodes.
Definition: visualnode.hh:106
Shape * shape
Shape of this node.
Definition: visualnode.hh:140
BoundingBox(void)
Default constructor.
Definition: visualnode.hh:59
Node class that supports visual layout
Definition: visualnode.hh:125
const unsigned int c_d
Create a clone after every c_d commits (commit distance)
Definition: search.hh:113
Post propagator for SetVar x
Definition: set.hh:767
The shape of a subtree.
Definition: visualnode.hh:83
A node of a search tree of Gecode spaces.
Definition: spacenode.hh:89
static Shape * leaf
Static shape for leaf nodes.
Definition: visualnode.hh:104
Gecode toplevel namespace
FloatView extend(Home home, Region &r, Term *&t, int &n)
Extend terms by adding view for result.
Definition: post.cpp:85
int r
Right extent.
Definition: visualnode.hh:68
Extent representing shape of a tree at one depth level
Definition: visualnode.hh:63
static const int minimalSeparation
Definition: visualnode.hh:48