2
* wbitem.h - the item classes for the SVG WB
3
* Copyright (C) 2006 Joonas Govenius
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
#include <QGraphicsSvgItem>
25
#include <QGraphicsScene>
26
#include <QGraphicsSceneMouseEvent>
28
#include "iconaction.h"
29
#include "../sxe/sxesession.h"
34
/*! \brief The context menu for WbItems
35
* This menu pops up when as the context menu for WbItems and displays
38
class WbItemMenu : public QMenu {
41
/*! \brief Constructor
42
* Constructs a new empty menu.
44
WbItemMenu(QWidget* parent);
46
* Deletes all the actiongroups and their actions.
49
/*! \brief Add actiongroup to the menu.*/
50
void addActionGroup(QActionGroup*);
53
/*! \brief Destruct self.*/
57
/*! \brief The actiongroups that the menu shows.*/
58
QList<QActionGroup*> groups_;
61
class WbItem : public QGraphicsSvgItem {
64
/*! \brief Constructor
65
* Constructs a new whiteboard item that visualized \a node.
67
WbItem(SxeSession* session, QSvgRenderer* renderer, QDomElement node, WbScene* scene, WbWidget* widget);
69
* Makes sure that the item gets deleted from the underlying <svg/> document
73
/*! \brief Returns the xml:id of the node.*/
75
/*! \brief Returns the underlying node.*/
78
/*! \brief Regenerates the SVG transformation matrix.*/
79
void regenerateTransform();
81
/*! \brief Adds the item to the scene.
82
Generates an 'id' attribute for the node if none exists. */
84
/*! \brief Removes the item from the scene. */
85
void removeFromScene();
87
/*! \brief Resets the position of the item according to the SVG and clears any QGraphicsItem transformations.*/
90
/*! \brief Returns a QTransform based on \a string provided in the SVG 'transform' attribute format.*/
91
static QMatrix parseSvgTransform(QString string);
92
/*! \brief Returns a QString in the SVG 'transform' attribute format based on \a matrix.*/
93
static QString toSvgTransform(const QMatrix &matrix);
96
/*! \brief Constructs and popsup the default context menu.*/
97
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *);
98
/*! \brief Implements the default item interaction behaviour.
99
* The action depends on the mode of widget_;
101
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
102
/*! \brief Implements the default item interaction behaviour.
103
* The action depends on the mode of widget_;
105
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
108
/*! \brief Construct a context menu with the default items.*/
109
WbItemMenu* constructContextMenu();
110
/*! \brief Return the center of the item in item coordinates.*/
113
// The session that the item belongs to
114
SxeSession* session_;
115
// The WbScene that the item belongs to
117
// The WbWidget that shows the item
119
// The node SVG node that's being visualized