00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef SGANTTVIEW_H
00016 #define SGANTTVIEW_H
00017
00018
00019
00020
00021 #include "SView.h"
00022 #include "../general/SObserver.h"
00023 #include "../logging/SGanttLog.h"
00024
00025
00026 #include <qaction.h>
00027 #include <qcanvas.h>
00028 #include <qfont.h>
00029 #include <qpixmap.h>
00030 #include <qpopupmenu.h>
00031 #include <qevent.h>
00032 #include <qstring.h>
00033 #include <qscrollview.h>
00034 #include <qtoolbar.h>
00035
00039 class SGanttView : public QCanvasView, public SObserver
00040 {
00041 Q_OBJECT
00042
00043
00044 public:
00045
00050 enum HitInfo { OnContext, OnJob, OnMachine };
00051
00052
00055 SGanttView( STaskSystem &ts, QWidget* parent = 0, QString name = 0 );
00056
00057 ~SGanttView();
00058
00059
00060
00061
00062
00064 void addToToolbar(QToolBar* toolbar);
00065
00066
00067 public slots:
00068
00072 void load();
00073
00074
00075 protected:
00076
00079 virtual void contentsMousePressEvent( QMouseEvent* );
00080
00081
00084
00085
00086
00087
00088
00091 QRegion getRegion() ;
00092
00093
00097 virtual bool isAffectedBy( QMouseEvent* e );
00098
00099
00103 void setPos( QPoint p );
00104
00105
00106 virtual void update( const class SEvent & );
00107
00108
00109
00110
00111
00112 QColor lighterGray() { return QColor(220, 220, 225); };
00113
00114
00117 void draw3DRect(int x, int y, int w, int h, const QColor &color);
00118 void draw3DRect(const QRect &r, const QColor &color) {
00119 draw3DRect(r.x(), r.y(), r.width(), r.height(), color); };
00120
00122 void drawText(int x, int y, int textFlags, const QString &text, const QColor &color = black);
00123
00124
00125 void resizeCheck();
00126
00127
00128 private:
00129
00130
00132 QCanvas *_pCanvas;
00133
00135 STaskSystem *_pTaskSystem;
00136
00137
00141 SGanttLog *_pGanttLog;
00142
00143
00146 double _curSimTime;
00147
00148
00151 QPopupMenu *_pContextMenu, *_pJobMenu, *_pMachMenu;
00152 int _placeHere, _autoAdjust, _defSize, _fitSize,
00153 _zoomIn, _zoomOut, _showFuture;
00154
00155 bool _bAutoAdjust, _bShowFuture;
00156
00157
00161 int _minW;
00162
00163
00167 int _minH;
00168
00169
00174 bool _resetNeeded;
00175
00176
00179 int _machines;
00180
00181
00184 int _x;
00185
00186
00189 int _y;
00190
00191
00195 int _w;
00196
00197
00200 int _h;
00201
00202
00206 int _selectedItem;
00207
00208
00209 QFont _myFont;
00210
00211
00212
00213 QAction* _zoomOutAction;
00214
00215
00216
00217 QAction* _zoomInAction;
00218
00219
00220
00221 QAction* _defSizeAction;
00222
00223
00224
00225 QAction* _autoAdjustAction;
00226
00227
00228
00229 QAction* _fitSizeAction;
00230
00231
00232
00233 QAction* _showFutureAction;
00234
00235
00236
00237 QAction* _placeAction;
00238
00239
00240
00241 QAction* _jobPropertiesAction;
00242
00243
00244
00245 QAction* _machPropertiesAction;
00246
00247
00248
00249 QPixmap* _pBuffer;
00250
00254 void init();
00255
00256
00262 HitInfo hitTest( QPoint p );
00263
00264
00270 void adjustTimeline();
00271
00272
00276 void paintChart();
00277
00278
00282 void paintBackground();
00283
00284
00285
00286
00287
00288
00289
00291 void updateChart();
00292
00293 private slots:
00294
00298 void place();
00299
00300
00305 void autoAdjust(bool adjust);
00306
00307
00310 void defSize();
00311
00312
00317 void fitSize();
00318
00319
00322 void zoomIn();
00323
00324
00327 void zoomOut();
00328
00329
00332 void toggleShowFuture(bool show);
00333
00334
00337 void jobProperties();
00338
00339
00342 void machProperties();
00343 };
00344
00345 #endif //SGANTTVIEW_H