Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
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:
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.
int n
Number of negative literals for node type.
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.
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.
void move(int delta)
Move extent by delta.
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.
bool getExtentAtDepth(int depth, Extent &extent)
Return if extent exists at depth, if yes return it in extent.
const Extent & operator[](int i) const
Return extent at depth i.
static Shape * allocate(int d)
Construct shape of depth d.
void computeBoundingBox(void)
Compute bounding box.
int depth(void) const
Return depth of the shape.
static Shape * leaf
Static shape for leaf nodes.
static Shape * hidden
Static shape for hidden nodes.
static void deallocate(Shape *)
void setDepth(int d)
Set depth of the shape to d (must be smaller than original depth)
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
void unstopAll(const NodeAllocator &na)
Do not stop at any stop node in the subtree of this node.
int offset
Relative offset from the parent node.
int getPathAlternative(const NodeAllocator &na)
Return the alternative of the child that is on the path (-1 if none)
void unPathUp(const NodeAllocator &na)
Set all nodes from the node to the root not to be on the path.
void unhideAll(const NodeAllocator &na)
Unhide all nodes in the subtree of this node.
void setShape(Shape *s)
Set the shape of this node.
void setOnPath(bool onPath0)
Set whether node is on the path.
VisualNodeFlags
Flags for VisualNodes.
int getOffset(void)
Return offset off this node from its parent.
bool isBookmarked(void)
Return whether node is bookmarked.
bool isHidden(void)
Return if node is hidden.
void toggleStop(const NodeAllocator &na)
Do not stop at this node.
void labelBranches(NodeAllocator &na, BestNode *curBest, int c_d, int a_d)
Create or clear branch labels in subtree.
void setBookmarked(bool m)
Set bookmark of this node.
void computeShape(const NodeAllocator &na)
Compute the shape according to the shapes of the children.
Shape * shape
Shape of this node.
void dispose(void)
Free allocated memory.
void toggleHidden(const NodeAllocator &na)
Toggle whether this node is hidden.
void setHidden(bool h)
Set hidden state to h.
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.
bool isMarked(void)
Return whether node is marked.
void labelPath(NodeAllocator &na, BestNode *curBest, int c_d, int a_d)
Create or clear branch labels on path to root.
void pathUp(const NodeAllocator &na)
Set all nodes from the node to the root to be on the path.
void dirtyUp(const NodeAllocator &na)
Mark all nodes up the path to the parent as dirty.
void setOffset(int n)
Set offset of this node, relative to its parent.
void changedStatus(const NodeAllocator &na)
Signal that the status has changed.
void layout(const NodeAllocator &na)
Compute layout for the subtree of this node.
void setDirty(bool d)
Mark node as dirty.
std::string toolTip(NodeAllocator &na, BestNode *curBest, int c_d, int a_d)
Return string that is used as a tool tip.
VisualNode(int p)
Construct with parent p.
void hideFailed(const NodeAllocator &na, bool onlyDirty=false)
Hide all failed subtrees of this node.
bool childrenLayoutIsDone(void)
Return whether the layout of the node's children has been completed.
BoundingBox getBoundingBox(void)
Return the bounding box.
VisualNode * findNode(const NodeAllocator &na, int x, int y)
Find a node in this subtree at coordinates x, y.
bool isDirty(void)
Return whether node is marked as dirty.
bool isOnPath(void)
Return whether node is on the path.
bool containsCoordinateAtDepth(int x, int depth)
Check if the x at depth depth lies in this subtree.
void setMarked(bool m)
Set mark of this node.
void setChildrenLayoutDone(bool d)
Mark node whether the layout of the node's children has been completed.
void setStop(bool h)
Set stop state to h.
Shape * getShape(void)
Return the shape of this node.
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