00001 00002 #ifndef ATTRIBUTES_KIVIAT_H 00003 #define ATTRIBUTES_KIVIAT_H 00004 00005 00006 #include <QString> 00007 #include <QList> 00008 00009 #include "KiviatView.h" 00010 #include "MetricsConfig.h" 00011 00012 class QMouseEvent; 00013 class QListWidget; 00014 class QGraphicsRectItem; 00015 class QGraphicsTextItem; 00016 00017 class SgNode; 00018 class MetricsConfig; 00019 class KiviatInfo; 00020 00026 class MetricsKiviat : public KiviatView 00027 { 00028 Q_OBJECT 00029 00030 public: 00031 MetricsKiviat( QWidget *parent = NULL ); 00032 00033 virtual ~MetricsKiviat(); 00034 00035 typedef QVector<SgNode *>::iterator nodes_iterator; 00036 00037 nodes_iterator nodesBegin() 00038 { 00039 return nodes.begin(); 00040 } 00041 nodes_iterator nodesEnd() 00042 { 00043 return nodes.end(); 00044 } 00045 00046 int getNodeId( SgNode* node ) 00047 { 00048 return nodes.indexOf( node ); 00049 } 00050 00051 SgNode* getNodeFromId( int id ) 00052 { 00053 return nodes[id]; 00054 } 00055 00056 void init( SgNode *root ); 00057 00058 signals: 00059 void nodeActivated ( SgNode *astNode ); 00060 void nodeActivatedAlt( SgNode *astNode ); 00061 00062 public slots: 00063 void updateView( SgNode *astNode ); 00064 void updateView( int id ); 00065 00066 void addNode( SgNode *astNode ); 00067 void delNode( SgNode *astNode ); 00068 void delNode( int nodeId ); 00069 00070 void configureMetrics( bool dialog = true ); 00071 00072 void setNode ( SgNode *astNode ) 00073 { addNode( astNode ); } 00074 void gotoNode( SgNode *astNode ) 00075 { updateView( astNode ); } 00076 00077 protected: 00078 virtual void mousePressEvent( QMouseEvent *ev); 00079 virtual void resizeEvent( QResizeEvent * ev ); 00080 virtual void contextMenuEvent( QContextMenuEvent *ev ); 00081 virtual void dropEvent( QDropEvent * ev); 00082 virtual void dragMoveEvent( QDragMoveEvent * ev); 00083 virtual void dragEnterEvent( QDragEnterEvent * ev); 00084 00085 private slots: 00086 void configChanged() 00087 { configureMetrics( false ); } 00088 00089 private: 00090 void drawData( SgNode *astNode ); 00091 00092 MetricsConfig metricsConfig; 00093 00094 SgNode *currentNode; 00095 QVector<SgNode *> nodes; 00096 00097 QGraphicsRectItem *legend; 00098 QList<QGraphicsTextItem *> legendText; 00099 QList<QGraphicsRectItem *> legendColor; 00100 00101 friend class KiviatInfo; 00102 }; 00103 00104 #endif
1.4.7