Generated on Thu Jul 21 2022 00:00:00 for Gecode by doxygen 1.9.5
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
38#include <gecode/kernel.hh>
39#include <string>
40
41namespace 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
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:
135 };
136
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);
211 void changedStatus(const NodeAllocator& na);
213 VisualNode* findNode(const NodeAllocator& na, int x, int y);
214
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>
239
240#endif
241
242// STATISTICS: gist-any
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
Choice for performing commit
Definition: core.hpp:1412
Static reference to the currently best space.
Definition: spacenode.hh:80
BoundingBox(void)
Default constructor.
Definition: visualnode.hh:59
int right
Right coordinate.
Definition: visualnode.hh:57
int left
Left coordinate.
Definition: visualnode.hh:55
Extent representing shape of a tree at one depth level
Definition: visualnode.hh:63
Extent(void)
Default constructor.
Definition: visualnode.hpp:37
int l
Left extent.
Definition: visualnode.hh:66
int r
Right extent.
Definition: visualnode.hh:68
void extend(int deltaL, int deltaR)
Extend extent by deltaL and deltaR.
Definition: visualnode.hpp:50
void move(int delta)
Move extent by delta.
Definition: visualnode.hpp:55
Layout parameters
Definition: visualnode.hh:44
static const int dist_y
Definition: visualnode.hh:46
static const int extent
Definition: visualnode.hh:47
static const int minimalSeparation
Definition: visualnode.hh:48
The shape of a subtree.
Definition: visualnode.hh:83
const BoundingBox & getBoundingBox(void) const
Return bounding box.
Definition: visualnode.hpp:124
bool getExtentAtDepth(int depth, Extent &extent)
Return if extent exists at depth, if yes return it in extent.
Definition: visualnode.hpp:97
const Extent & operator[](int i) const
Return extent at depth i.
Definition: visualnode.hpp:69
static Shape * allocate(int d)
Construct shape of depth d.
Definition: visualnode.hpp:81
void computeBoundingBox(void)
Compute bounding box.
Definition: visualnode.hpp:110
int depth(void) const
Return depth of the shape.
Definition: visualnode.hpp:60
static Shape * leaf
Static shape for leaf nodes.
Definition: visualnode.hh:104
static Shape * hidden
Static shape for hidden nodes.
Definition: visualnode.hh:106
static void deallocate(Shape *)
Definition: visualnode.hpp:91
void setDepth(int d)
Set depth of the shape to d (must be smaller than original depth)
Definition: visualnode.hpp:63
A node of a search tree of Gecode spaces.
Definition: spacenode.hh:89
static const int LASTBIT
Last bit used for SpaceNode flags.
Definition: spacenode.hh:127
Node class that supports visual layout
Definition: visualnode.hh:125
void unstopAll(const NodeAllocator &na)
Do not stop at any stop node in the subtree of this node.
Definition: visualnode.cpp:223
int offset
Relative offset from the parent node.
Definition: visualnode.hh:138
int getPathAlternative(const NodeAllocator &na)
Return the alternative of the child that is on the path (-1 if none)
Definition: visualnode.cpp:144
void unPathUp(const NodeAllocator &na)
Set all nodes from the node to the root not to be on the path.
Definition: visualnode.cpp:135
void unhideAll(const NodeAllocator &na)
Unhide all nodes in the subtree of this node.
Definition: visualnode.cpp:207
void setShape(Shape *s)
Set the shape of this node.
Definition: visualnode.cpp:391
void setOnPath(bool onPath0)
Set whether node is on the path.
Definition: visualnode.hpp:198
VisualNodeFlags
Flags for VisualNodes.
Definition: visualnode.hh:128
int getOffset(void)
Return offset off this node from its parent.
Definition: visualnode.hpp:147
bool isBookmarked(void)
Return whether node is bookmarked.
Definition: visualnode.hpp:183
bool isHidden(void)
Return if node is hidden.
Definition: visualnode.hpp:129
void toggleStop(const NodeAllocator &na)
Do not stop at this node.
Definition: visualnode.cpp:214
void labelBranches(NodeAllocator &na, BestNode *curBest, int c_d, int a_d)
Create or clear branch labels in subtree.
Definition: visualnode.cpp:166
void setBookmarked(bool m)
Set bookmark of this node.
Definition: visualnode.hpp:188
void computeShape(const NodeAllocator &na)
Compute the shape according to the shapes of the children.
Definition: visualnode.cpp:399
Shape * shape
Shape of this node.
Definition: visualnode.hh:140
void dispose(void)
Free allocated memory.
Definition: visualnode.cpp:96
void toggleHidden(const NodeAllocator &na)
Toggle whether this node is hidden.
Definition: visualnode.cpp:153
void setHidden(bool h)
Set hidden state to h.
Definition: visualnode.hpp:134
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:284
bool isMarked(void)
Return whether node is marked.
Definition: visualnode.hpp:173
void labelPath(NodeAllocator &na, BestNode *curBest, int c_d, int a_d)
Create or clear branch labels on path to root.
Definition: visualnode.cpp:175
void pathUp(const NodeAllocator &na)
Set all nodes from the node to the root to be on the path.
Definition: visualnode.cpp:127
void dirtyUp(const NodeAllocator &na)
Mark all nodes up the path to the parent as dirty.
Definition: visualnode.cpp:102
void setOffset(int n)
Set offset of this node, relative to its parent.
Definition: visualnode.hpp:150
void changedStatus(const NodeAllocator &na)
Signal that the status has changed.
Definition: visualnode.cpp:230
void layout(const NodeAllocator &na)
Compute layout for the subtree of this node.
Definition: visualnode.cpp:113
void setDirty(bool d)
Mark node as dirty.
Definition: visualnode.hpp:158
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:279
void hideFailed(const NodeAllocator &na, bool onlyDirty=false)
Hide all failed subtrees of this node.
Definition: visualnode.cpp:159
bool childrenLayoutIsDone(void)
Return whether the layout of the node's children has been completed.
Definition: visualnode.hpp:163
BoundingBox getBoundingBox(void)
Return the bounding box.
Definition: visualnode.hpp:208
VisualNode * findNode(const NodeAllocator &na, int x, int y)
Find a node in this subtree at coordinates x, y.
Definition: visualnode.cpp:249
bool isDirty(void)
Return whether node is marked as dirty.
Definition: visualnode.hpp:153
bool isOnPath(void)
Return whether node is on the path.
Definition: visualnode.hpp:193
bool containsCoordinateAtDepth(int x, int depth)
Check if the x at depth depth lies in this subtree.
Definition: visualnode.cpp:233
void setMarked(bool m)
Set mark of this node.
Definition: visualnode.hpp:178
void setChildrenLayoutDone(bool d)
Mark node whether the layout of the node's children has been completed.
Definition: visualnode.hpp:168
void setStop(bool h)
Set stop state to h.
Definition: visualnode.hpp:139
Shape * getShape(void)
Return the shape of this node.
Definition: visualnode.hpp:203
Computation spaces.
Definition: core.hpp:1742
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:767
Post propagator for SetVar x
Definition: set.hh:767