File indexing completed on 2024-05-12 05:44:25

0001 /***************************************************************************
0002  *   Copyright (C) 2006-2009 by Rajko Albrecht                             *
0003  *   ral@alwins-world.de                                                   *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0019  ***************************************************************************/
0020 #ifndef GRAPHTREELABEL_H
0021 #define GRAPHTREELABEL_H
0022 
0023 #include "graphtree/drawparams.h"
0024 
0025 #include <QGraphicsRectItem>
0026 #include <QPixmap>
0027 
0028 /**
0029     @author Rajko Albrecht <ral@alwins-world.de>
0030 */
0031 class GraphTreeLabel : public QGraphicsRectItem, StoredDrawParams
0032 {
0033 public:
0034     GraphTreeLabel(const QString &, const QString &, const QRectF &r, QGraphicsItem *p = nullptr);
0035     ~GraphTreeLabel() override;
0036 
0037     int type() const override;
0038     // virtual void drawShape(QPainter& p);
0039     void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
0040 
0041     void setBgColor(const QColor &);
0042 
0043     const QString &nodename() const;
0044     const QString &source() const;
0045     void setSource(const QString &);
0046     virtual void setSelected(bool);
0047 
0048 protected:
0049     QString m_Nodename;
0050     QString m_SourceNode;
0051 };
0052 
0053 class GraphEdge;
0054 
0055 class GraphEdgeArrow : public QGraphicsPolygonItem
0056 {
0057 public:
0058     explicit GraphEdgeArrow(GraphEdge *, QGraphicsItem *p = nullptr);
0059     GraphEdge *edge();
0060     void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
0061     int type() const override;
0062 
0063 private:
0064     GraphEdge *_edge;
0065 };
0066 
0067 /* line */
0068 class GraphEdge : public QGraphicsPathItem
0069 {
0070 public:
0071     explicit GraphEdge(QGraphicsItem *p = nullptr);
0072     ~GraphEdge() override;
0073 
0074     void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
0075     const QPolygonF &controlPoints() const;
0076     void setControlPoints(const QPolygonF &a);
0077     int type() const override;
0078 
0079 private:
0080     QPolygonF _points;
0081 };
0082 
0083 class GraphMark : public QGraphicsRectItem
0084 {
0085 public:
0086     explicit GraphMark(GraphTreeLabel *, QGraphicsItem *p = nullptr);
0087     ~GraphMark() override;
0088     int type() const override;
0089     virtual bool hit(const QPoint &) const;
0090     void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
0091 
0092 private:
0093     static QPixmap *_p;
0094 };
0095 
0096 #endif