visualnode.hh
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Guido Tack <tack@gecode.org>
*
* Copyright:
* Guido Tack, 2006
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef GECODE_GIST_VISUALNODE_HH
#define GECODE_GIST_VISUALNODE_HH
#include <gecode/gist/spacenode.hh>
#include <gecode/kernel.hh>
#include <string>
namespace Gecode { namespace Gist {
class Layout {
public:
static const int dist_y = 38;
static const int extent = 20;
static const int minimalSeparation = 10;
};
class BoundingBox {
public:
int left;
int right;
BoundingBox(void) {}
};
class Extent {
public:
int l;
int r;
Extent(void);
Extent(int l0, int r0);
Extent(int width);
void extend(int deltaL, int deltaR);
void move(int delta);
};
class Shape {
private:
int _depth;
BoundingBox bb;
Extent shape[1];
Shape(const Shape&);
Shape& operator =(const Shape&);
Shape(void);
public:
static Shape* allocate(int d);
// Destruct
static void deallocate(Shape*);
static Shape* leaf;
static Shape* hidden;
int depth(void) const;
void setDepth(int d);
void computeBoundingBox(void);
const Extent& operator [](int i) const;
Extent& operator [](int i);
bool getExtentAtDepth(int depth, Extent& extent);
const BoundingBox& getBoundingBox(void) const;
};
class VisualNode : public SpaceNode {
protected:
enum VisualNodeFlags {
DIRTY = SpaceNode::LASTBIT+1,
CHILDRENLAYOUTDONE,
HIDDEN,
MARKED,
ONPATH,
BOOKMARKED
};
int offset;
Shape* shape;
bool containsCoordinateAtDepth(int x, int depth);
public:
VisualNode(int p);
VisualNode(Space* root);
bool isHidden(void);
void setHidden(bool h);
void setStop(bool h);
void dirtyUp(const NodeAllocator& na);
void layout(const NodeAllocator& na);
int getOffset(void);
void setOffset(int n);
bool isDirty(void);
void setDirty(bool d);
bool childrenLayoutIsDone(void);
void setChildrenLayoutDone(bool d);
bool isMarked(void);
void setMarked(bool m);
bool isBookmarked(void);
void setBookmarked(bool m);
void pathUp(const NodeAllocator& na);
void unPathUp(const NodeAllocator& na);
bool isOnPath(void);
int getPathAlternative(const NodeAllocator& na);
void setOnPath(bool onPath0);
void toggleHidden(const NodeAllocator& na);
void hideFailed(const NodeAllocator& na, bool onlyDirty=false);
void unhideAll(const NodeAllocator& na);
void toggleStop(const NodeAllocator& na);
void unstopAll(const NodeAllocator& na);
Shape* getShape(void);
void setShape(Shape* s);
void computeShape(const NodeAllocator& na);
BoundingBox getBoundingBox(void);
void changedStatus(const NodeAllocator& na);
VisualNode* findNode(const NodeAllocator& na, int x, int y);
void labelBranches(NodeAllocator& na,
BestNode* curBest, int c_d, int a_d);
void labelPath(NodeAllocator& na,
BestNode* curBest, int c_d, int a_d);
std::string getBranchLabel(NodeAllocator& na,
VisualNode* p, const Choice* c,
BestNode* curBest, int c_d, int a_d, int alt);
std::string toolTip(NodeAllocator& na, BestNode* curBest,
int c_d, int a_d);
void dispose(void);
};
}}
#include <gecode/gist/node.hpp>
#include <gecode/gist/spacenode.hpp>
#include <gecode/gist/visualnode.hpp>
#endif
// STATISTICS: gist-any
Gecode::Choice
Choice for performing commit
Definition core.hpp:1412
Gecode::Gist::BestNode
Static reference to the currently best space.
Definition spacenode.hh:80
Gecode::Gist::BoundingBox
Bounding box.
Definition visualnode.hh:52
Gecode::Gist::BoundingBox::BoundingBox
BoundingBox(void)
Default constructor.
Definition visualnode.hh:59
Gecode::Gist::BoundingBox::right
int right
Right coordinate.
Definition visualnode.hh:57
Gecode::Gist::BoundingBox::left
int left
Left coordinate.
Definition visualnode.hh:55
Gecode::Gist::Extent
Extent representing shape of a tree at one depth level
Definition visualnode.hh:63
Gecode::Gist::Extent::Extent
Extent(void)
Default constructor.
Definition visualnode.hpp:37
Gecode::Gist::Extent::l
int l
Left extent.
Definition visualnode.hh:66
Gecode::Gist::Extent::r
int r
Right extent.
Definition visualnode.hh:68
Gecode::Gist::Extent::extend
void extend(int deltaL, int deltaR)
Extend extent by deltaL and deltaR.
Definition visualnode.hpp:50
Gecode::Gist::Extent::move
void move(int delta)
Move extent by delta.
Definition visualnode.hpp:55
Gecode::Gist::Layout
Layout parameters
Definition visualnode.hh:44
Gecode::Gist::Layout::dist_y
static const int dist_y
Definition visualnode.hh:46
Gecode::Gist::Layout::extent
static const int extent
Definition visualnode.hh:47
Gecode::Gist::Layout::minimalSeparation
static const int minimalSeparation
Definition visualnode.hh:48
Gecode::Gist::Node::NodeAllocator
NodeAllocatorBase< VisualNode > NodeAllocator
Definition node.hh:143
Gecode::Gist::Shape
The shape of a subtree.
Definition visualnode.hh:83
Gecode::Gist::Shape::getBoundingBox
const BoundingBox & getBoundingBox(void) const
Return bounding box.
Definition visualnode.hpp:124
Gecode::Gist::Shape::getExtentAtDepth
bool getExtentAtDepth(int depth, Extent &extent)
Return if extent exists at depth, if yes return it in extent.
Definition visualnode.hpp:97
Gecode::Gist::Shape::operator[]
const Extent & operator[](int i) const
Return extent at depth i.
Definition visualnode.hpp:69
Gecode::Gist::Shape::allocate
static Shape * allocate(int d)
Construct shape of depth d.
Definition visualnode.hpp:81
Gecode::Gist::Shape::computeBoundingBox
void computeBoundingBox(void)
Compute bounding box.
Definition visualnode.hpp:110
Gecode::Gist::Shape::depth
int depth(void) const
Return depth of the shape.
Definition visualnode.hpp:60
Gecode::Gist::Shape::leaf
static Shape * leaf
Static shape for leaf nodes.
Definition visualnode.hh:104
Gecode::Gist::Shape::hidden
static Shape * hidden
Static shape for hidden nodes.
Definition visualnode.hh:106
Gecode::Gist::Shape::deallocate
static void deallocate(Shape *)
Definition visualnode.hpp:91
Gecode::Gist::Shape::setDepth
void setDepth(int d)
Set depth of the shape to d (must be smaller than original depth).
Definition visualnode.hpp:63
Gecode::Gist::SpaceNode::LASTBIT
static const int LASTBIT
Last bit used for SpaceNode flags.
Definition spacenode.hh:127
Gecode::Gist::SpaceNode::SpaceNode
SpaceNode(int p)
Construct node with parent p.
Definition spacenode.hpp:89
Gecode::Gist::VisualNode::unstopAll
void unstopAll(const NodeAllocator &na)
Do not stop at any stop node in the subtree of this node.
Definition visualnode.cpp:223
Gecode::Gist::VisualNode::offset
int offset
Relative offset from the parent node.
Definition visualnode.hh:138
Gecode::Gist::VisualNode::getPathAlternative
int getPathAlternative(const NodeAllocator &na)
Return the alternative of the child that is on the path (-1 if none).
Definition visualnode.cpp:144
Gecode::Gist::VisualNode::unPathUp
void unPathUp(const NodeAllocator &na)
Set all nodes from the node to the root not to be on the path.
Definition visualnode.cpp:135
Gecode::Gist::VisualNode::unhideAll
void unhideAll(const NodeAllocator &na)
Unhide all nodes in the subtree of this node.
Definition visualnode.cpp:207
Gecode::Gist::VisualNode::setShape
void setShape(Shape *s)
Set the shape of this node.
Definition visualnode.cpp:391
Gecode::Gist::VisualNode::setOnPath
void setOnPath(bool onPath0)
Set whether node is on the path.
Definition visualnode.hpp:198
Gecode::Gist::VisualNode::VisualNodeFlags
VisualNodeFlags
Flags for VisualNodes.
Definition visualnode.hh:128
Gecode::Gist::VisualNode::ONPATH
@ ONPATH
Definition visualnode.hh:133
Gecode::Gist::VisualNode::MARKED
@ MARKED
Definition visualnode.hh:132
Gecode::Gist::VisualNode::CHILDRENLAYOUTDONE
@ CHILDRENLAYOUTDONE
Definition visualnode.hh:130
Gecode::Gist::VisualNode::HIDDEN
@ HIDDEN
Definition visualnode.hh:131
Gecode::Gist::VisualNode::DIRTY
@ DIRTY
Definition visualnode.hh:129
Gecode::Gist::VisualNode::BOOKMARKED
@ BOOKMARKED
Definition visualnode.hh:134
Gecode::Gist::VisualNode::getOffset
int getOffset(void)
Return offset off this node from its parent.
Definition visualnode.hpp:147
Gecode::Gist::VisualNode::isBookmarked
bool isBookmarked(void)
Return whether node is bookmarked.
Definition visualnode.hpp:183
Gecode::Gist::VisualNode::isHidden
bool isHidden(void)
Return if node is hidden.
Definition visualnode.hpp:129
Gecode::Gist::VisualNode::toggleStop
void toggleStop(const NodeAllocator &na)
Do not stop at this node.
Definition visualnode.cpp:214
Gecode::Gist::VisualNode::labelBranches
void labelBranches(NodeAllocator &na, BestNode *curBest, int c_d, int a_d)
Create or clear branch labels in subtree.
Definition visualnode.cpp:166
Gecode::Gist::VisualNode::setBookmarked
void setBookmarked(bool m)
Set bookmark of this node.
Definition visualnode.hpp:188
Gecode::Gist::VisualNode::computeShape
void computeShape(const NodeAllocator &na)
Compute the shape according to the shapes of the children.
Definition visualnode.cpp:399
Gecode::Gist::VisualNode::shape
Shape * shape
Shape of this node.
Definition visualnode.hh:140
Gecode::Gist::VisualNode::dispose
void dispose(void)
Free allocated memory.
Definition visualnode.cpp:96
Gecode::Gist::VisualNode::toggleHidden
void toggleHidden(const NodeAllocator &na)
Toggle whether this node is hidden.
Definition visualnode.cpp:153
Gecode::Gist::VisualNode::setHidden
void setHidden(bool h)
Set hidden state to h.
Definition visualnode.hpp:134
Gecode::Gist::VisualNode::getBranchLabel
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
Gecode::Gist::VisualNode::isMarked
bool isMarked(void)
Return whether node is marked.
Definition visualnode.hpp:173
Gecode::Gist::VisualNode::labelPath
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
Gecode::Gist::VisualNode::pathUp
void pathUp(const NodeAllocator &na)
Set all nodes from the node to the root to be on the path.
Definition visualnode.cpp:127
Gecode::Gist::VisualNode::dirtyUp
void dirtyUp(const NodeAllocator &na)
Mark all nodes up the path to the parent as dirty.
Definition visualnode.cpp:102
Gecode::Gist::VisualNode::setOffset
void setOffset(int n)
Set offset of this node, relative to its parent.
Definition visualnode.hpp:150
Gecode::Gist::VisualNode::changedStatus
void changedStatus(const NodeAllocator &na)
Signal that the status has changed.
Definition visualnode.cpp:230
Gecode::Gist::VisualNode::layout
void layout(const NodeAllocator &na)
Compute layout for the subtree of this node.
Definition visualnode.cpp:113
Gecode::Gist::VisualNode::setDirty
void setDirty(bool d)
Mark node as dirty.
Definition visualnode.hpp:158
Gecode::Gist::VisualNode::toolTip
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
Gecode::Gist::VisualNode::VisualNode
VisualNode(int p)
Construct with parent p.
Definition visualnode.cpp:69
Gecode::Gist::VisualNode::hideFailed
void hideFailed(const NodeAllocator &na, bool onlyDirty=false)
Hide all failed subtrees of this node.
Definition visualnode.cpp:159
Gecode::Gist::VisualNode::childrenLayoutIsDone
bool childrenLayoutIsDone(void)
Return whether the layout of the node's children has been completed.
Definition visualnode.hpp:163
Gecode::Gist::VisualNode::getBoundingBox
BoundingBox getBoundingBox(void)
Return the bounding box.
Definition visualnode.hpp:208
Gecode::Gist::VisualNode::findNode
VisualNode * findNode(const NodeAllocator &na, int x, int y)
Find a node in this subtree at coordinates x, y.
Definition visualnode.cpp:249
Gecode::Gist::VisualNode::isDirty
bool isDirty(void)
Return whether node is marked as dirty.
Definition visualnode.hpp:153
Gecode::Gist::VisualNode::isOnPath
bool isOnPath(void)
Return whether node is on the path.
Definition visualnode.hpp:193
Gecode::Gist::VisualNode::containsCoordinateAtDepth
bool containsCoordinateAtDepth(int x, int depth)
Check if the x at depth depth lies in this subtree.
Definition visualnode.cpp:233
Gecode::Gist::VisualNode::setMarked
void setMarked(bool m)
Set mark of this node.
Definition visualnode.hpp:178
Gecode::Gist::VisualNode::setChildrenLayoutDone
void setChildrenLayoutDone(bool d)
Mark node whether the layout of the node's children has been completed.
Definition visualnode.hpp:168
Gecode::Gist::VisualNode::setStop
void setStop(bool h)
Set stop state to h.
Definition visualnode.hpp:139
Gecode::Gist::VisualNode::getShape
Shape * getShape(void)
Return the shape of this node.
Definition visualnode.hpp:203
Gecode::Space
Computation spaces.
Definition core.hpp:1742
node.hpp
kernel.hh
Gecode::Gist
The Gecode Interactive Search Tool.
Gecode
Gecode toplevel namespace
spacenode.hh
spacenode.hpp
visualnode.hpp