You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.6 KiB
90 lines
2.6 KiB
14 years ago
|
#ifndef NODE_H
|
||
|
#define NODE_H
|
||
|
|
||
|
#include <QGraphicsTextItem>
|
||
14 years ago
|
#include <QTextCursor>
|
||
14 years ago
|
|
||
|
#include "edge.h"
|
||
|
#include "graphwidget.h"
|
||
|
|
||
|
class GraphWidget;
|
||
|
|
||
|
class Node : public QGraphicsTextItem
|
||
|
{
|
||
|
public:
|
||
14 years ago
|
|
||
14 years ago
|
Node(GraphWidget *graphWidget = 0);
|
||
14 years ago
|
~Node();
|
||
14 years ago
|
|
||
14 years ago
|
void moveNode(QGraphicsSceneMouseEvent *event);
|
||
14 years ago
|
void addEdge(Edge *edge, bool startsFromThisNode);
|
||
14 years ago
|
void deleteEdge(Node *otherEnd);
|
||
14 years ago
|
void removeEdgeFromList(Edge *edge);
|
||
14 years ago
|
// void adjustEdges();
|
||
14 years ago
|
|
||
14 years ago
|
void setBorder(const bool &hasBorder);
|
||
14 years ago
|
void setActive(const bool &active = true);
|
||
14 years ago
|
void setEditable(const bool &editable = true);
|
||
14 years ago
|
void setColor(const QColor &color);
|
||
|
QColor color() const { return m_color; }
|
||
|
void setTextColor(const QColor &color);
|
||
|
QColor textColor() const { return m_textColor; }
|
||
14 years ago
|
void setScale(const qreal &factor, const QRectF &sceneRect);
|
||
14 years ago
|
|
||
14 years ago
|
void showNumber(const int &number, const bool& show = true,
|
||
|
const bool &numberIsSpecial = false);
|
||
14 years ago
|
void insertPicture(const QString &picture, const int &pos = 0);
|
||
14 years ago
|
double calculateBiggestAngle();
|
||
14 years ago
|
|
||
|
// changing visibility from prot to pub
|
||
|
void keyPressEvent(QKeyEvent *event);
|
||
14 years ago
|
bool isConnected(const Node *node) const;
|
||
14 years ago
|
QPointF intersect(const QLineF &line, const bool &reverse = false) const;
|
||
14 years ago
|
|
||
14 years ago
|
QList<Edge *> edgesFrom(const bool &excludeSecondaries = true) const;
|
||
|
QList<Edge *> edgesToThis(const bool &excludeSecondaries = true) const;
|
||
|
Edge * edgeTo(const Node* node) const;
|
||
14 years ago
|
QList<Node *> subtree() const;
|
||
14 years ago
|
|
||
|
protected:
|
||
14 years ago
|
|
||
14 years ago
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||
|
QWidget *widget);
|
||
14 years ago
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||
14 years ago
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||
14 years ago
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||
14 years ago
|
QPainterPath shape () const;
|
||
14 years ago
|
void focusOutEvent(QFocusEvent *event);
|
||
14 years ago
|
|
||
14 years ago
|
private:
|
||
14 years ago
|
|
||
14 years ago
|
double doubleModulo(const double &devided, const double &devisor);
|
||
|
|
||
14 years ago
|
struct EdgeElement
|
||
|
{
|
||
|
Edge *edge;
|
||
|
bool startsFromThisNode;
|
||
|
EdgeElement(Edge *e, bool s) : edge(e), startsFromThisNode(s) {}
|
||
|
};
|
||
|
|
||
|
QList<EdgeElement> m_edgeList;
|
||
14 years ago
|
GraphWidget *m_graph;
|
||
14 years ago
|
bool m_isActive;
|
||
|
int m_number;
|
||
14 years ago
|
bool m_hasBorder;
|
||
14 years ago
|
bool m_numberIsSpecial;
|
||
14 years ago
|
QColor m_color;
|
||
|
QColor m_textColor;
|
||
14 years ago
|
|
||
14 years ago
|
static const double m_pi;
|
||
|
static const double m_oneAndHalfPi;
|
||
|
static const double m_twoPi;
|
||
14 years ago
|
|
||
|
static const QColor m_orange;
|
||
14 years ago
|
static const QColor m_gold;
|
||
14 years ago
|
};
|
||
|
|
||
|
#endif // NODE_H
|