this repo has no description
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_QT_DRAWINGCURSOR_HH
35#define GECODE_GIST_QT_DRAWINGCURSOR_HH
36
37#include <gecode/gist/nodecursor.hh>
38#include <gecode/gist/layoutcursor.hh>
39#include <QtGui>
40
41namespace Gecode { namespace Gist {
42
43 /// \brief A cursor that draws a tree on a QWidget
44 class DrawingCursor : public NodeCursor<VisualNode> {
45 private:
46 /// The painter where the tree is drawn
47 QPainter& painter;
48 /// The clipping area
49 QRect clippingRect;
50 /// The best solution (for branch-and-bound)
51 BestNode* curBest;
52 /// The current coordinates
53 double x, y;
54
55 bool copies;
56
57 /// Test if current node is clipped
58 bool isClipped(void);
59 public:
60 /// The color for failed nodes
61 static const QColor red;
62 /// The color for solved nodes
63 static const QColor green;
64 /// The color for choice nodes
65 static const QColor blue;
66 /// The color for the best solution
67 static const QColor orange;
68 /// White color
69 static const QColor white;
70
71 /// The color for expanded failed nodes
72 static const QColor lightRed;
73 /// The color for expanded solved nodes
74 static const QColor lightGreen;
75 /// The color for expanded choice nodes
76 static const QColor lightBlue;
77
78 /// Constructor
79 DrawingCursor(VisualNode* root,
80 const VisualNode::NodeAllocator& na,
81 BestNode* curBest0,
82 QPainter& painter0,
83 const QRect& clippingRect0, bool showCopies);
84
85 ///\name Cursor interface
86 //@{
87 /// Move cursor to parent
88 void moveUpwards(void);
89 /// Test if cursor may move to child
90 bool mayMoveDownwards(void);
91 /// Move cursor to child
92 void moveDownwards(void);
93 /// Move cursor to sibling
94 void moveSidewards(void);
95 /// Draw the node
96 void processCurrentNode(void);
97 //@}
98 };
99
100}}
101
102#include <gecode/gist/drawingcursor.hpp>
103
104#endif
105
106// STATISTICS: gist-any