00001 /* 00002 Modular Psi - A graph tracker of the Parapsychologcal scientific development 00003 Copyright (C) 2005 Leonardo Stern 00004 00005 This program is free software; you can redistribute it and/or modify it under 00006 the terms of the Common Public License Version 1.0 or (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00009 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00010 See the Common Public License for more details. 00011 00012 You should have received a copy of the Common Public License along with this program; 00013 */ 00014 00015 #ifndef EDGE_HPP 00016 #define EDGE_HPP 00017 00018 #include <qwidget.h> 00019 #include <qpoint.h> 00020 #include <qpointarray.h> 00021 #include <qstring.h> 00022 #include "nodelist.hpp" 00023 #include "node.hpp" 00024 #include "graph.hpp" 00025 00026 00032 class Edge : public QWidget 00033 { 00034 Q_OBJECT 00035 00036 00037 public: 00042 Edge (QWidget *parent, Node* origem, Node* destino ); 00043 ~Edge(); 00050 float trust() { return p_trust; }; 00054 QString trustString() 00055 { 00056 QString r; 00057 r.setNum(p_trust); 00058 return r; 00059 } 00065 float combinedTrust() { return p_combinedTrust; } 00069 Node* source() { return p_source; }; 00073 Node* target() { return p_target; }; 00077 QPoint start() const { return p_start; }; 00081 QPoint end() const { return p_end; }; 00085 QString sourceName(); 00089 QString targetName(); 00090 bool changed() { return p_changed; }; 00091 00092 void setChanged(bool alterado); 00093 void setTrust (float confianca); 00094 void setTrust (QString s_trust ); 00095 void setCombinedTrust (float combined); 00096 void setSource ( Node *origem ); 00097 void setTarget ( Node *destino ); 00098 void setStart ( QPoint inicio ); 00099 void setEnd ( QPoint fim ); 00103 QPointArray vNodes; 00104 QPointArray arrowPoints; 00105 00106 QPoint DL; 00111 void processBends(); 00112 void changeActive( QColor thisColor); 00113 00117 Node opposite (Node* an_end); 00118 00119 void draw(QPainter* painter); 00120 QColor lineColor; 00121 QColor propLineColor; 00122 00123 00124 protected: 00125 00126 void paintEvent(QPaintEvent *event); 00127 void mousePressEvent (QMouseEvent *e); 00128 void updateMask(); 00129 float p_trust; 00130 float p_combinedTrust; 00131 bool p_changed; 00132 Node* p_source; 00133 Node* p_target; 00134 QPoint p_start; 00135 QPoint p_end; 00139 void init(); 00140 }; 00141 00142 #endif //EDGE_HPP