00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef NODE_H
00021 #define NODE_H
00022
00023 #include <QObject>
00024 #include <QList>
00025 #include <QString>
00026 #include <QPixmap>
00027
00028 #include "rocslib_export.h"
00029 #include "edge.h"
00030 #include <QGraphicsSvgItem>
00031
00032 class Node;
00033
00034
00035 typedef QList<Node*> NodeList;
00036
00037 class ROCSLIB_EXPORT Node : public QObject
00038 {
00039 Q_OBJECT
00040 Q_PROPERTY( qreal x READ x WRITE setX )
00041 Q_PROPERTY( qreal y READ y WRITE setY )
00042 Q_PROPERTY( qreal width READ width WRITE setWidth )
00043 Q_PROPERTY( QString name READ name WRITE setName )
00044 Q_PROPERTY( QString color READ color WRITE setColor )
00045 Q_PROPERTY( bool begin READ begin WRITE setBegin )
00046 Q_PROPERTY( bool end READ end WRITE setEnd )
00047 Q_PROPERTY( QVariant value READ value WRITE setValue )
00048 Q_PROPERTY( QPixmap image READ image WRITE setImage )
00049 Q_PROPERTY( int maxInEdges READ maxInEdges WRITE setMaxInEdges )
00050 Q_PROPERTY( int maxOutEdges READ maxOutEdges WRITE setMaxOutEdges )
00051 Q_PROPERTY( int maxSelfEdges READ maxSelfEdges WRITE setMaxSelfEdges )
00052 Q_PROPERTY( QString iconPackage READ iconPackage WRITE setIconPackage )
00053 Q_PROPERTY( QString icon READ icon WRITE setIcon )
00054
00055 public:
00056 Node( Graph* parent );
00057 ~Node();
00058 void addInEdge( Edge* e );
00059 void addOutEdge( Edge* e );
00060 void addSelfEdge( Edge* e );
00061 void removeEdge( Edge* e, int edgeList );
00062 void removeEdge( Edge* e, EdgeList& list );
00063 void remove();
00064 enum EdgeLists {In, Out, Self};
00065 void startChange();
00066 void endChange();
00067 bool showName();
00068 bool showImage();
00069 bool showValue();
00070 bool inEdgesCapacityReached() const;
00071 bool outEdgesCapacityReached() const;
00072 bool selfEdgesCapacityReached() const;
00073
00074 Graph* graph()
00075 {
00076 return _graph;
00077 }
00078
00079 public slots:
00080 NodeList adjacent_nodes() const;
00081 EdgeList adjacent_edges() const;
00082 EdgeList edges( Node* n );
00083 EdgeList in_edges() const;
00084 EdgeList out_edges() const;
00085 EdgeList self_edges() const;
00086
00087 void setX( int x );
00088 void setY( int y );
00089 void setWidth( double w );
00090 void setPos( qreal x, qreal y );
00091 qreal x() const;
00092 qreal y() const;
00093 qreal width() const;
00094 void setColor( const QString& s );
00095 const QString& color() const;
00096 void setName( const QString& s );
00097 const QString& name() const;
00098 bool begin() const;
00099 bool end() const;
00100 void setBegin( bool begin = true );
00101 void setEnd( bool end = true );
00102 void setValue( const QVariant v );
00103 void setValue( const QString& s );
00104 void setValueHeader( const QString& s )
00105 {
00106 _valueHeader = s;
00107 }
00108 const QString valueHeader()
00109 {
00110 return _valueHeader;
00111 }
00112 const QVariant value() const;
00113 const QPixmap& image() const;
00114 void setImage( const QPixmap& p );
00115 void setMaxInEdges( const int& m );
00116 const int& maxInEdges() const;
00117 void setMaxOutEdges( const int& m );
00118 const int& maxOutEdges() const;
00119 void setMaxSelfEdges( const int& m );
00120 const int& maxSelfEdges() const;
00121 void setIcon( const QString& s );
00122 const QString& icon() const;
00123 const QString& iconPackage() const;
00124 void setIconPackage( const QString& s );
00125 void hideName( bool b );
00126 void hideImage( bool b );
00127 void hideValue( bool b );
00128 void setType( QString type );
00129 QString type();
00130 QGraphicsSvgItem* nodeItem();
00131 void setNodeItem( QGraphicsSvgItem* ni );
00136 void addDynamicProperty( QString property, QVariant value );
00137
00141 void removeDynamicProperty( QString property );
00142
00143
00144
00145 private:
00146 EdgeList _in_edges;
00147 EdgeList _out_edges;
00148 EdgeList _self_edges;
00149 void empty( EdgeList& list );
00150
00152 qreal _x;
00153 qreal _y;
00154 qreal _width;
00155
00156 bool _begin;
00157 bool _end;
00158 bool _changing;
00159 bool _showName;
00160 bool _showValue;
00161 bool _showImage;
00162
00163 Graph* _graph;
00164
00165 QString _name;
00166 QString _color;
00167 QString _iconpackage;
00168 QString _icon;
00169
00170 QVariant _value;
00171 QPixmap _image;
00172 int _maxInEdges;
00173 int _maxOutEdges;
00174 int _maxSelfEdges;
00175 QString _type;
00176 QGraphicsSvgItem* _nitem;
00177 QString _valueHeader;
00178
00179 signals:
00180 void removed();
00181 void changed();
00182 };
00183
00184
00185 #endif