Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

visualization/SGanttView.h

Go to the documentation of this file.
00001 /* #start# ***********************************************************
00002 
00003            Scheduling Simulator
00004         Lehrstuhl f"ur Effiziente Algorithmen
00005            Technische Universit"at M"unchen
00006 
00007  File    : $Id: SGanttView.h,v 1.11 2003/03/12 09:07:41 woerster Exp $
00008 
00009  Purpose : This view is the parent view for the gantt view element. It manages
00010            the graphical context and the mouse events.
00011            It is a pure SViewEl-Container.
00012 
00013  * #end# ************************************************************* */
00014 
00015 #ifndef SGANTTVIEW_H
00016 #define SGANTTVIEW_H
00017 
00018 // system header files
00019 
00020 // project header files
00021 #include "SView.h"
00022 #include "../general/SObserver.h"
00023 #include "../logging/SGanttLog.h"
00024 
00025 // QT header files
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   // void repaint( QRect rect );
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   //virtual void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph);
00085   //virtual void viewportPaintEvent(QPaintEvent* pe);
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 //  virtual void repaint( QRect rect );
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   /* Action to zoom out the GanttView */
00213   QAction* _zoomOutAction;
00214 
00215 
00216   /* Action to zoom in the GanttView */
00217   QAction* _zoomInAction;
00218 
00219 
00220   /* Action to set the size of the GanttView to the default value */
00221   QAction* _defSizeAction;
00222 
00223 
00224   /* Action to set the Autaadjustment of the GanttView size on/off */
00225   QAction* _autoAdjustAction;
00226 
00227 
00228   /* Action to set the size of the GanttView to the size of the window */
00229   QAction* _fitSizeAction;
00230 
00231 
00232   /* Action to enable/disable the display of the future jobs */
00233   QAction* _showFutureAction;
00234 
00235 
00236   /* Action to zoom to the current cursor position */
00237   QAction* _placeAction;
00238 
00239 
00240   /* Action to display the properties of the selected job */
00241   QAction* _jobPropertiesAction;
00242 
00243 
00244   /* Action to show the properties of teh selected machine */
00245   QAction* _machPropertiesAction;
00246 
00247 
00248   /* the backgroundbuffer */
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 /*  void repaintContents() { 
00285     QScrollView::repaintContents(contentsX(), contentsY(), 
00286          contentsWidth(), contentsHeight());
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

Generated on Thu May 22 16:48:09 2003 for Sketch-it! by doxygen1.2.18