00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef SDAGVIEWEDGE_H
00015 #define SDAGVIEWEDGE_H
00016
00017
00018 #include <LEDA/graph.h>
00019 #include <LEDA/list.h>
00020 #include <LEDA/point.h>
00021
00022
00023 #include "../model/STaskSystem.h"
00024 #include "SViewEl.h"
00025
00026
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