72a989fd5c5fc88ff1a5c8e29571a7c9ca6abe1d
[occt.git] / samples / qt / FuncDemo / src / graphwidget.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2006-2007 Trolltech ASA. All rights reserved.
4 **
5 ** This file is part of the example classes of the Qt Toolkit.
6 **
7 ** Licensees holding a valid Qt License Agreement may use this file in
8 ** accordance with the rights, responsibilities and obligations
9 ** contained therein.  Please consult your licensing agreement or
10 ** contact sales@trolltech.com if any conditions of this licensing
11 ** agreement are not clear to you.
12 **
13 ** Further information about Qt licensing is available at:
14 ** http://www.trolltech.com/products/qt/licensing.html or by
15 ** contacting info@trolltech.com.
16 **
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 **
20 ****************************************************************************/
21
22 #ifndef GRAPHWIDGET_H
23 #define GRAPHWIDGET_H
24
25 #include <QGraphicsView>
26
27 #include "FThread.h"
28
29 #include <TDocStd_Document.hxx>
30 #include <TDF_Label.hxx>
31
32 class Node;
33
34 class GraphWidget : public QGraphicsView
35 {
36     Q_OBJECT
37
38 public:
39     GraphWidget(QWidget* parent);
40     ~GraphWidget();
41     
42     bool createModel(const Handle(TDocStd_Document)& doc);
43     Handle(TDocStd_Document) getDocument() { return myDocument; }
44
45     Node* findNode(const TDF_Label& );
46     void  setNbThreads(const int nb);
47     int   getNbThreads();
48     void  accelerateThread(const int thread_index);
49     void  slowDownThread(const int thread_index);
50     void  compute();
51
52     void setFinished();
53     bool isFinished();
54
55 protected:
56     void wheelEvent(QWheelEvent *event);
57     void drawBackground(QPainter *painter, const QRectF &rect);
58     void scaleView(qreal scaleFactor);
59
60 private:
61     Handle(TDocStd_Document) myDocument;
62     int                      myNbThreads;
63     FThread*                 myThread1;
64     FThread*                 myThread2;
65     FThread*                 myThread3;
66     FThread*                 myThread4;
67     int                      myNbFinishedThreads;
68 };
69
70 #endif