Skip to content
Snippets Groups Projects
QGVNode.h 1.88 KiB
Newer Older
nicolas.bergont's avatar
nicolas.bergont committed
/***************************************************************
QGVCore
Copyright (c) 2014, Bergont Nicolas, All rights reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library.
***************************************************************/
Nicolas's avatar
Nicolas committed
#ifndef QGVNODE_H
#define QGVNODE_H

Janosch Machowinski's avatar
Janosch Machowinski committed
#include "qgv.h"
Nicolas's avatar
Nicolas committed
#include <QGraphicsItem>
#include <QPen>

class QGVEdge;
class QGVScene;
Nicolas's avatar
Nicolas committed

nicolas.bergont's avatar
nicolas.bergont committed
/**
 * @brief Node item
 *
 */
class QGVCORE_EXPORT QGVNode : public QGraphicsItem
Nicolas's avatar
Nicolas committed
{
public:
    ~QGVNode();

nicolas.bergont's avatar
nicolas.bergont committed
    QString label() const;
    void setLabel(const QString &label);
Nicolas's avatar
Nicolas committed

    QRectF boundingRect() const;
    void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
nicolas.bergont's avatar
nicolas.bergont committed
    void setAttribute(const QString &label, const QString &value);
    QString getAttribute(const QString &name) const;

    void setIcon(const QImage &icon);
Nicolas's avatar
Nicolas committed

    enum { Type = UserType + 2 };
    int type() const
    {
        return Type;
    }

private:
nicolas.bergont's avatar
nicolas.bergont committed
    friend class QGVScene;
    friend class QGVSubGraph;
    void updateLayout();
		QGVNode(QGVNodePrivate* node, QGVScene *scene);
Nicolas's avatar
Nicolas committed

		// Not implemented in QGVNode.cpp
//		QPainterPath makeShape(Agnode_t* node) const;
//		QPolygonF makeShapeHelper(Agnode_t* node) const;
Nicolas's avatar
Nicolas committed

    QPainterPath _path;
    QPen _pen;
    QBrush _brush;
nicolas.bergont's avatar
nicolas.bergont committed
    QImage _icon;
Nicolas's avatar
Nicolas committed

nicolas.bergont's avatar
nicolas.bergont committed
    QGVScene *_scene;
Nicolas's avatar
Nicolas committed
};


#endif // QGVNODE_H