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

visualization/SDAGEdgeViewEl.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: SDAGEdgeViewEl.h,v 1.5 2003/02/12 16:16:06 taeubig Exp $
00008 
00009  Purpose : This view element paints an edge (a line if undirected or
00010            an arrow if directed) from one node element to another.
00011 
00012  * #end# ************************************************************* */   
00013 
00014 #ifndef SDAGVIEWEDGE_H
00015 #define SDAGVIEWEDGE_H
00016 
00017 // system header files
00018 #include <LEDA/graph.h>
00019 #include <LEDA/list.h>
00020 #include <LEDA/point.h>
00021 
00022 // project header files
00023 #include "../model/STaskSystem.h"
00024 #include "SViewEl.h"
00025 
00026 // QT header files
00027 #include <qbrush.h>
00028 #include <qpen.h>
00029 #include <qpointarray.h>
00030 #include <qregion.h>
00031 
00032 class SDAGNodeViewEl;
00033 class SDAGViewEl;
00037 class SDAGEdgeViewEl : public SViewEl
00038 {
00039  public:
00046   SDAGEdgeViewEl( STaskSystem *ts, SDAGViewEl *dagel, 
00047       QColor edgecolor = QColor( "black" ), 
00048       int edgewidth = 1,
00049       Qt::PenStyle edgestyle = Qt::SolidLine );
00050   ~SDAGEdgeViewEl();
00051   
00054   void paint( QPaintDevice *pd, QRect rect );
00059   void update();
00063   void hide() { _visible = FALSE; };
00066   void show() { _visible = TRUE; };
00069   bool isVisible() { return _visible; };
00073   void appendBend( int x, int y );
00077   void appendBend( QPoint p ) { appendBend( p.x(), p.y() ); };
00083   void moveSource( int x, int y ) { move( 0, x, y ); };
00087   void moveSource( QPoint p ) { moveSource( p.x(), p.y() ); };
00093   void moveTarget( int x, int y ) { move( _bends.size() - 1, x, y ); };
00097   void moveTarget( QPoint p ) { moveTarget( p.x(), p.y() ); };
00105   void moveDrag( int x, int y ) { move( _dragIndex, x, y ); }; 
00109   void moveDrag( QPoint p ) { moveDrag( p.x(), p.y() ); };
00116   void moveBends( int x, int y );
00120   void moveBends( QPoint p ) { moveBends( p.x(), p.y() ); };
00131   SDAGNodeViewEl* beginEdgeDrag( QPoint pos );
00137   void endEdgeDrag( SDAGNodeViewEl *node );
00142   void setColor( QColor c ) { _pen.setColor( c ); _brush.setColor( c ); }; 
00147   void setWidth( int w ) { _pen.setWidth( w ); };
00152   void setStyle( Qt::PenStyle s ) { _pen.setStyle( s ); }; 
00157   void setSource( SDAGNodeViewEl *node );
00162   void setTarget( SDAGNodeViewEl *node );
00165   bool isSourceNode( SDAGNodeViewEl *node ) { return ( _pSourceNode == node ); };
00168   bool isTargetNode( SDAGNodeViewEl *node ) { return ( _pTargetNode == node ); };
00171   SDAGNodeViewEl* getSource() { return _pSourceNode; };
00174   SDAGNodeViewEl* getTarget() { return _pTargetNode; };
00177   QRegion getRegion();
00180   const QRect &getBoundBox() const { static QRect r; 
00181     r = ((SDAGEdgeViewEl *) this)->getRegion().boundingRect(); return r; };
00184   bool isDirected();
00190   void setLEDAEdge( leda_edge e ) { _ledaEdge = e; };
00196   leda_list<leda_point> getBends();
00197 
00198 private:
00201   leda_edge _ledaEdge;
00206   SDAGViewEl *_pDAGViewEl;
00210   bool _visible;
00214   QPointArray _arrow;
00218   QPointArray _bends;
00222   unsigned int _dragIndex;
00226   QPen _pen;
00230   QBrush _brush;
00235   SDAGNodeViewEl *_pSourceNode, *_pTargetNode;
00240   void move( unsigned int index, int x, int y );
00244   void move( unsigned int index, QPoint dest ) { move( index, dest.x(), dest.y() ); };
00249   void calcSourcePoint( int x1, int y1 );
00253   void calcSourcePoint( QPoint p ) { calcSourcePoint( p.x(), p.y() ); }; 
00258   void calcTargetPoint( int x2, int y2 );
00262   void calcTargetPoint( QPoint p ) { calcTargetPoint( p.x(), p.y() ); };
00266   void calcArrow();
00267 };
00268 
00269 #endif //SDAGVIEWEDGE_H

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