00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef EDGE_H
00021 #define EDGE_H
00022
00023 #include <QObject>
00024 #include <QtScript>
00025 #include <QString>
00026 #include <QGraphicsSvgItem>
00027
00028 #include "rocslib_export.h"
00029
00030 class Node;
00031 class Graph;
00042 class ROCSLIB_EXPORT Edge : public QObject
00043 {
00044 Q_OBJECT
00045
00049 Q_PROPERTY( QString color READ color WRITE setColor )
00050
00051
00052 Q_PROPERTY( QString value READ value WRITE setValue )
00053
00055 Q_PROPERTY( QString name READ name WRITE setName )
00056
00058 Q_PROPERTY( double width READ width WRITE setWidth )
00059
00061 Q_PROPERTY( QString style READ style WRITE setStyle )
00062
00063 public:
00068 Edge( Graph* parent, Node* from, Node* to, QGraphicsSvgItem* cFrom, QGraphicsSvgItem* cTo );
00069
00071 ~Edge();
00072
00079 int relativeIndex() const
00080 {
00081 return _relativeIndex;
00082 }
00083
00085 void remove();
00086
00087 Graph* graph()
00088 {
00089 return _graph;
00090 }
00091 #ifdef USING_QTSCRIPT
00092
00096 QScriptValue scriptValue() const;
00097
00101 void setEngine( QScriptEngine* engine );
00102 #endif
00103
00104 public slots:
00108 Node* from() const
00109 {
00110 return _from;
00111 }
00112
00116 Node* to() const
00117 {
00118 return _to;
00119 }
00120
00124 QGraphicsSvgItem* connectorFrom() const
00125 {
00126 return _cFrom;
00127 }
00128
00132 QGraphicsSvgItem* connectorTo() const
00133 {
00134 return _cTo;
00135 }
00136
00140 const QString& value() const
00141 {
00142 return _value;
00143 }
00144
00148 void setValue( const QString& s )
00149 {
00150 _value = s;
00151 emit changed();
00152 }
00153
00157 const QString& name() const
00158 {
00159 return _name;
00160 }
00161
00165 void setName( const QString& s )
00166 {
00167 _name = s;
00168 emit changed();
00169 }
00170
00174 const QString color() const
00175 {
00176 return _color;
00177 }
00178
00182 void setColor( const QString& s )
00183 {
00184 _color = s;
00185 emit changed();
00186 }
00187
00188 qreal width() const
00189 {
00190 return _width;
00191 }
00192 void setWidth( double w )
00193 {
00194 _width = w;
00195 emit changed();
00196 }
00197
00198 const QString& style() const
00199 {
00200 return _style;
00201 }
00202 void setStyle( const QString& s )
00203 {
00204 _style = s;
00205 emit changed();
00206 }
00207
00212 void addDynamicProperty( QString Property, QVariant value );
00213
00217 void removeDynamicProperty( QString property );
00218
00219 bool showName();
00220 bool showValue();
00221 void hideName( bool b );
00222 void hideValue( bool b );
00223 QString fromConnector();
00224 QString toConnector();
00225 QString toNode();
00226 QString fromNode();
00227
00228 private:
00230 Node* _from;
00231
00233 Node* _to;
00234
00236 QGraphicsSvgItem* _cFrom;
00237
00239 QGraphicsSvgItem* _cTo;
00240
00242 int _relativeIndex;
00243
00245 QString _value;
00246
00248 QString _name;
00249
00251 QString _color;
00252
00253 bool _showName;
00254 bool _showValue;
00255
00256 QString _style;
00257 double _width;
00258
00259 Graph* _graph;
00260
00261 signals:
00263 void removed();
00265 void changed();
00266 };
00267
00268 typedef QList<Edge*> EdgeList;
00269 #endif