This file is indexed.

/usr/include/gecode/gist/treecanvas.hh is in libgecode-dev 4.4.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
 *  Main authors:
 *     Guido Tack <tack@gecode.org>
 *
 *  Copyright:
 *     Guido Tack, 2006
 *
 *  Last modified:
 *     $Date: 2013-05-06 09:02:17 +0200 (Mon, 06 May 2013) $ by $Author: tack $
 *     $Revision: 13613 $
 *
 *  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_TREECANVAS_HH
#define GECODE_GIST_TREECANVAS_HH

#include <QtGui>
#if QT_VERSION >= 0x050000
#include <QtWidgets>
#endif

#include <gecode/kernel.hh>
#include <gecode/gist.hh>

#include <gecode/gist/visualnode.hh>

namespace Gecode {  namespace Gist {

  /// \brief Parameters for the tree layout
  namespace LayoutConfig {
    /// Minimum scale factor
    const int minScale = 10;
    /// Maximum scale factor
    const int maxScale = 400;
    /// Default scale factor
    const int defScale = 100;
    /// Maximum scale factor for automatic zoom
    const int maxAutoZoomScale = defScale;
  }

  class TreeCanvas;

  /// \brief A thread that concurrently explores the tree
  class SearcherThread : public QThread {
    Q_OBJECT
  private:
    VisualNode* node;
    int depth;
    bool a;
    TreeCanvas* t;
    void updateCanvas(void);
  public:
    void search(VisualNode* n, bool all, TreeCanvas* ti);

  Q_SIGNALS:
    void update(int w, int h, int scale0);
    void statusChanged(bool);
    void scaleChanged(int);
    void solution(const Space*);
    void searchFinished(void);
    void moveToNode(VisualNode* n,bool);
  protected:
    void run(void);
  };

  /// \brief A canvas that displays the search tree
  class GECODE_GIST_EXPORT TreeCanvas : public QWidget {
    Q_OBJECT

    friend class SearcherThread;
    friend class Gist;

  public:
    /// Constructor
    TreeCanvas(Space* rootSpace, bool bab, QWidget* parent, 
               const Options& opt);
    /// Destructor
    ~TreeCanvas(void);

    /// Add inspector \a i
    void addDoubleClickInspector(Inspector* i);
    /// Set active inspector
    void activateDoubleClickInspector(int i, bool active);
    /// Add inspector \a i
    void addSolutionInspector(Inspector* i);
    /// Set active inspector
    void activateSolutionInspector(int i, bool active);
    /// Add inspector \a i
    void addMoveInspector(Inspector* i);
    /// Set active inspector
    void activateMoveInspector(int i, bool active);
    /// Add comparator \a c
    void addComparator(Comparator* c);
    /// Set active comparator
    void activateComparator(int i, bool active);

  public Q_SLOTS:
    /// Set scale factor to \a scale0
    void scaleTree(int scale0, int zoomx=-1, int zoomy=-1);

    /// Explore complete subtree of selected node
    void searchAll(void);
    /// Find next solution below selected node
    void searchOne(void);
    /// Toggle hidden state of selected node
    void toggleHidden(void);
    /// Hide failed subtrees of selected node
    void hideFailed(void);
    /// Unhide all nodes below selected node
    void unhideAll(void);
    /// Do not stop at selected stop node
    void toggleStop(void);
    /// Do not stop at any stop node
    void unstopAll(void);
    /// Export pdf of the current subtree
    void exportPDF(void);
    /// Export pdf of the whole tree
    void exportWholeTreePDF(void);
    /// Print the tree
    void print(void);
    /// Zoom the canvas so that the whole tree fits
    void zoomToFit(void);
    /// Center the view on the currently selected node
    void centerCurrentNode(void);
    /**
     * \brief Call the double click inspector for the currently selected node
     *
     * If \a fix is true, then the node is inspected after fixpoint
     * computation, otherwise its status after branching but before
     * fixpoint computation is inspected.
     */
    void inspectCurrentNode(bool fix=true, int inspectorNo=-1);
    /// Calls inspectCurrentNode(false)
    void inspectBeforeFP(void);
    /// Label all branches in subtree under current node
    void labelBranches(void);
    /// Label all branches on path to root node
    void labelPath(void);

    /// Stop current search
    void stopSearch(void);

    /// Reset
    void reset(void);

    /// Move selection to the parent of the selected node
    void navUp(void);
    /// Move selection to the first child of the selected node
    void navDown(void);
    /// Move selection to the left sibling of the selected node
    void navLeft(void);
    /// Move selection to the right sibling of the selected node
    void navRight(void);
    /// Move selection to the root node
    void navRoot(void);
    /// Move selection to next solution (in DFS order)
    void navNextSol(bool back = false);
    /// Move selection to previous solution (in DFS order)
    void navPrevSol(void);

    /// Bookmark current node
    void bookmarkNode(void);
    /// Set the current node to be the head of the path
    void setPath(void);
    /// Call the double click inspector for all nodes on the path from root to head of the path
    void inspectPath(void);
    /// Wait for click on node to compare with current node
    void startCompareNodes(void);
    /// Wait for click on node to compare with current node before fixpoint
    void startCompareNodesBeforeFP(void);
    
    /// Re-emit status change information for current node
    void emitStatusChanged(void);

    /// Set recomputation distances
    void setRecompDistances(int c_d, int a_d);
    /// Set preference whether to automatically hide failed subtrees
    void setAutoHideFailed(bool b);
    /// Set preference whether to automatically zoom to fit
    void setAutoZoom(bool b);
    /// Return preference whether to automatically hide failed subtrees
    bool getAutoHideFailed(void);
    /// Return preference whether to automatically zoom to fit
    bool getAutoZoom(void);
    /// Set preference whether to show copies in the tree
    void setShowCopies(bool b);
    /// Return preference whether to show copies in the tree
    bool getShowCopies(void);
    /// Set refresh rate
    void setRefresh(int i);
    /// Set refresh pause in msec
    void setRefreshPause(int i);
    /// Return preference whether to use smooth scrolling and zooming
    bool getSmoothScrollAndZoom(void);
    /// Set preference whether to use smooth scrolling and zooming
    void setSmoothScrollAndZoom(bool b);
    /// Return preference whether to move cursor during search
    bool getMoveDuringSearch(void);
    /// Set preference whether to move cursor during search
    void setMoveDuringSearch(bool b);
    /// Resize to the outer widget size if auto zoom is enabled
    void resizeToOuter(void);

    /// Stop search and wait for it to finish
    bool finish(void);

  Q_SIGNALS:
    /// The scale factor has changed
    void scaleChanged(int);
    /// The auto-zoom state was changed
    void autoZoomChanged(bool);
    /// Context menu triggered
    void contextMenu(QContextMenuEvent*);
    /// Status bar update
    void statusChanged(VisualNode*,const Statistics&, bool);
    /// Signals that a solution has been found
    void solution(const Space*);
    /// Signals that %Gist is finished
    void searchFinished(void);
    /// Signals that a bookmark has been added
    void addedBookmark(const QString& id);
    /// Signals that a bookmark has been removed
    void removedBookmark(int idx);
  protected:
    /// Mutex for synchronizing acccess to the tree
    QMutex mutex;
    /// Mutex for synchronizing layout and drawing
    QMutex layoutMutex;
    /// Search engine thread
    SearcherThread searcher;
    /// Flag signalling the search to stop
    bool stopSearchFlag;
    /// Flag signalling that Gist is ready to be closed
    bool finishedFlag;
    /// Allocator for nodes
    Node::NodeAllocator* na;
    /// The root node of the tree
    VisualNode* root;
    /// The currently best solution (for branch-and-bound)
    BestNode* curBest;
    /// The currently selected node
    VisualNode* currentNode;
    /// The head of the currently selected path
    VisualNode* pathHead;
    /// The registered click inspectors, and whether they are active
    QVector<QPair<Inspector*,bool> > doubleClickInspectors;
    /// The registered solution inspectors, and whether they are active
    QVector<QPair<Inspector*,bool> > solutionInspectors;
    /// The registered move inspectors, and whether they are active
    QVector<QPair<Inspector*,bool> > moveInspectors;
    /// The registered comparators, and whether they are active
    QVector<QPair<Comparator*,bool> > comparators;

    /// The bookmarks map
    QVector<VisualNode*> bookmarks;

    /// Whether node comparison action is running
    bool compareNodes;
    /// Whether node comparison action computes fixpoint
    bool compareNodesBeforeFP;

    /// The scale bar
    QSlider* scaleBar;

    /// Statistics about the search tree
    Statistics stats;

    /// Current scale factor
    double scale;
    /// Offset on the x axis so that the tree is centered
    int xtrans;

    /// Whether to hide failed subtrees automatically
    bool autoHideFailed;
    /// Whether to zoom automatically
    bool autoZoom;
    /// Whether to show copies in the tree
    bool showCopies;
    /// Refresh rate
    int refresh;
    /// Time (in msec) to pause after each refresh
    int refreshPause;
    /// Whether to use smooth scrolling and zooming
    bool smoothScrollAndZoom;
    /// Whether to move cursor during search
    bool moveDuringSearch;
    
    /// The recomputation distance
    int c_d;
    /// The adaptive recomputation distance
    int a_d;

    /// Return the node corresponding to the \a event position
    VisualNode* eventNode(QEvent *event);
    /// General event handler, used for displaying tool tips
    bool event(QEvent *event);
    /// Paint the tree
    void paintEvent(QPaintEvent* event);
    /// Handle mouse press event
    void mousePressEvent(QMouseEvent* event);
    /// Handle mouse double click event
    void mouseDoubleClickEvent(QMouseEvent* event);
    /// Handle context menu event
    void contextMenuEvent(QContextMenuEvent* event);
    /// Handle resize event
    void resizeEvent(QResizeEvent* event);
    /// Handle mouse wheel events
    void wheelEvent(QWheelEvent* event);

    /// Timer for smooth zooming
    QTimeLine zoomTimeLine;
    /// Timer for smooth scrolling
    QTimeLine scrollTimeLine;
    /// Target x coordinate after smooth scrolling
    int targetX;
    /// Source x coordinate after smooth scrolling
    int sourceX;
    /// Target y coordinate after smooth scrolling
    int targetY;
    /// Target y coordinate after smooth scrolling
    int sourceY;

    /// Target width after layout
    int targetW;
    /// Target height after layout
    int targetH;
    /// Target scale after layout
    int targetScale;
    /// Timer id for delaying the update
    int layoutDoneTimerId;

    /// Timer invoked for smooth zooming and scrolling
    virtual void timerEvent(QTimerEvent* e);

  public Q_SLOTS:
    /// Update display
    void update(void);
    /// React to scroll events
    void scroll(void);
    /// Layout done
    void layoutDone(int w, int h, int scale0);
    /// Set the selected node to \a n
    void setCurrentNode(VisualNode* n, bool finished=true, bool update=true);
  private Q_SLOTS:
    /// Search has finished
    void statusChanged(bool);
    /// Export PDF of the subtree of \a n
    void exportNodePDF(VisualNode* n);
    /// A new solution \a s has been found
    void inspectSolution(const Space* s);
    /// Scroll to \a i percent of the target
    void scroll(int i);
  };

}}

#endif

// STATISTICS: gist-any