2
* wbitems.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
23
#include <QDomElement>
25
#include <QGraphicsPathItem>
26
#include <QGraphicsScene>
27
#include <QGraphicsSceneMouseEvent>
30
#include <QPushButton>
32
#include <QHBoxLayout>
33
#include <QVBoxLayout>
34
#include <QColorDialog>
35
#include <QFontDialog>
37
#include <QStyleOptionGraphicsItem>
39
#include "iconaction.h"
42
/*! \brief A class used for storing an edit while it's being queued.*/
45
/*! \brief Describes which kind of edit item defines.*/
46
enum Type {NewEdit, MoveEdit, RemoveEdit, AttributeEdit, ParentEdit, ContentEdit};
47
/*! \brief Constructor
48
* Constructs an edit of \a type with \a xml.
50
Edit(Type type, const QDomElement &xml);
51
/*! \brief Constructor
52
* Constructs an AttributeEdit or ParentEdit with the given oldValue and target.
54
Edit(Type type, const QString &target, const QDomElement &edit, const QString &oldValue);
55
/*! \brief Constructor
56
* Constructs a ContentEdit with the given oldContent and target.
58
Edit(const QString &target, const QDomElement &edit, QDomNodeList oldContent);
59
/*! \brief The type of edit.*/
61
/*! \brief The XML element representing the edit.*/
63
/*! \brief The target of the edit.
64
* Only applicable with AttributeEdit, ContentEdit and ParentEdit.
67
/*! \brief The attribute value before the edit.
68
* Only applicable with AttributeEdit
71
/*! \brief The content before the edit.
72
* Only applicable with ContentEdit
74
QDomNodeList oldContent;
75
/*! \brief The parent before the edit.
76
* Only applicable with ContentEdit
81
/*! \brief An undo structure to save a <configure/> undo item
82
* Stores the new version, the attribute name and the previous value.
83
* An instance of this class is created for each undo and stored in
84
* a list in the WbItem.
89
/*! \brief Constructor
90
* Constructs an EditUndo from the given version and Edit.
92
EditUndo(const int &version, const Edit &edit);
93
/*! \brief Constructor
94
* Constructs an AttributeEdit undo with the given version, attribute and oldValue.
96
EditUndo(const int &version, const QString &attribute, const QString &oldValue);
97
/*! \brief Constructor
98
* Constructs a ParentEdit undo with the given version and oldParent.
100
EditUndo(const int &version, const QString &oldParent);
101
/*! \brief Constructor
102
* Constructs a ContentEdit undo with the given version and oldContent.
104
EditUndo(const int &version, QDomNodeList oldContent);
105
/*! \brief The new version.*/
107
/*! \brief The type of undo.*/
109
/*! \brief The changed attribute.*/
111
/*! \brief The attribute value before the edit.*/
113
/*! \brief The content before the edit.*/
114
QDomNodeList oldContent;
115
/*! \brief The parent before the edit.*/
119
/*! \brief The context menu for WbItems
120
* This menu pops up when as the context menu for WbItems and displays
123
class WbItemMenu : public QMenu {
126
/*! \brief Constructor
127
* Constructs a new empty menu.
129
WbItemMenu(QWidget* parent);
130
/*! \brief Destructor
131
* Deletes all the actiongroups and their actions.
134
/*! \brief Add actiongroup to the menu.*/
135
void addActionGroup(QActionGroup*);
138
/*! \brief Destruct self.*/
142
/*! \brief The actiongroups that the menu shows.*/
143
QList<QActionGroup*> groups_;
146
/*! \brief The base class for all whiteboard items.
147
* Every whiteboard item class must inherit this along with QGraphicsItem
148
* if the class is visualized on the scene. The derived class must implement at least
149
* type() and, if it's visualised, graphicsItem() and QGraphicsItem::mouseMoveEvent()
150
* and QGraphicsItem::mouseReleaseEvent() which should pass the events to
151
* handleMouseMoveEvent() and handleMouseReleaseEvent() respectively.
153
* This class stores all SVG attributes and provides parsing for the common
154
* attributes. Also provide support for the basic operations (translate,
159
class WbItem : public QObject {
163
/*! \brief Constructor
164
* Constructs a new item with values \a id and \a index.
166
WbItem(const QString &id);
168
/*! \brief Return the ID of the parent item.*/
169
QString parentWbItem();
170
/*! \brief Set the parent.
171
* Used secondarily, if graphicsItem()->parentItem == 0
173
void setParentWbItem(const QString &, bool emitChanges = false);
174
/*! \brief Return the ID of the item.*/
176
/*! \brief Return the index of the item.*/
178
/*! \brief Set the index of the item.*/
179
void setIndex(qreal index, bool emitChanges = false);
180
/*! \brief Construct a context menu with the default items.*/
181
WbItemMenu* constructContextMenu();
182
/*! \brief Set the 'stroke' attribute of the item.*/
183
virtual void setStrokeColor(QColor color);
184
/*! \brief Set the 'fill' attribute of the item.*/
185
virtual void setFillColor(QColor color);
186
/*! \brief Set the 'stroke-width' attribute of the item.*/
187
virtual void setStrokeWidth(int width);
188
/*! \brief Return the type of the item.*/
189
virtual int type() const = 0;
190
/*! \brief Return a pointer to the QGraphicsItem.*/
191
virtual QGraphicsItem* graphicsItem() { return 0; };
192
/*! \brief Return the item as an SVG element.*/
193
virtual QDomElement svg();
194
/*! \brief Parses the item specific SVG properties and returns the list of changed attributes.*/
195
virtual QList<QString> parseSvg(QDomElement &, bool emitChanges = false);
196
/*! \brief Regenerate and signal the SVG transformation matrix.*/
197
virtual void regenerateTransform();
198
/*! \brief Return the center of the item in item coordinates.*/
199
virtual QPointF center();
200
/*! \brief Returns a deep copy of this object but without a scene association.*/
201
virtual WbItem* clone() = 0;
203
/*! \brief The current version of the item.*/
205
/*! \brief A list of EditUndo objects that contain the history of the item.*/
206
QList<EditUndo> undos;
210
// static QString xmlSimplify(const QString &str);
211
static QList<qreal> parseNumbersList(QString::const_iterator &itr);
212
static QList<qreal> parsePercentageList(QString::const_iterator &itr);
213
inline static bool isUnreserved(const QChar &c, bool first_char = false);
214
static QString idFromUrl(const QString &url);
215
static QMatrix parseTransformationMatrix(const QString &value);
216
static QColor resolveColor(const QString &colorStr);
217
static QColor constructColor(const QString &colorStr, const QString &opacity);
218
static qreal parseLength(const QString &str);
219
static QPen parseQPen(QString stroke, const QString &dashArray, const QString &dashOffset, const QString &linecap, const QString &linejoin, const QString &miterlimit, QString strokeopacity, QString opacity, const QString &width);
220
// static QPen defaultPen;
223
/*! \brief Signals that an attribute of the element is changed.
224
* \param id The ID of this element.
225
* \param attribute The name of the changed attribute.
226
* \param value The new value of the attribute.
227
* \param oldvalue The old value of the attribute.
229
void attributeChanged(const QString &id, const QString &attribute, const QString &value, const QString &oldvalue);
230
/*! \brief Emitted when the parent of the element is changed.*/
231
void parentChanged(const QString &id, const QString &value, const QString &oldvalue);
232
/*! \brief Emitted when the content of the element is changed.*/
233
void contentChanged(const QString &id, const QDomNodeList &value, const QDomNodeList &oldvalue);
234
/*! \brief Emitted when the index of the element is changed.*/
235
void indexChanged(const QString &id, const qreal &deltaIndex);
238
/*! \brief Implements the default item interaction behaviour.
239
* The action depends on the modifier keys being pressed:
240
* \li Ctrl: Translate
241
* \li Ctrl + Alt: Rotate
242
* \li Ctrl + Shift: Scale
244
void handleMouseMoveEvent(QGraphicsSceneMouseEvent * event);
245
/*! \brief Implements the default item interaction behaviour.
246
* The action depends on the modifier keys being pressed:
247
* \li Ctrl: Translate
248
* \li Ctrl + Alt: Rotate
249
* \li Ctrl + Shift: Scale
251
void handleMouseReleaseEvent(QGraphicsSceneMouseEvent * event);
252
/*! \brief Contains the SVG attributes of the element.*/
253
QHash<QString, QString> attributes;
256
/*! \brief The ID of the item.*/
258
/*! \brief The parent of the item.*/
260
/*! \brief The index of the item.*/
264
/*! \brief An item for storing the unkown SVG elements.
267
* The purpose of this item is to store the unkown element. It is not visualized.
270
class WbUnknown : public WbItem
273
/*! \brief Constructor
274
* Constructs a new root item.
276
WbUnknown(QDomElement &svg, const QString &id, const qreal &index, const QString &parent = "root", QGraphicsScene * scene = 0);
277
/*! \brief Returns the type of the item (0x87654999).*/
278
virtual int type() const { return 87654999; };
279
/*! \brief Returns the stored SVG element.*/
280
virtual QDomElement svg();
281
/*! \brief Saves the SVG element.*/
282
virtual QList<QString> parseSvg(QDomElement &, bool emitChanges = false);
283
/*! \brief Returns a deep copy of this object but without a scene association.*/
284
virtual WbItem* clone();
287
QDomElement svgElement_;
290
/*! \brief An item for storing the SVG root element.
293
* The main function of the element is to store the root element's attributes.
294
* The item is not visualized on the scene.
297
class WbRoot : public WbItem
300
/*! \brief Constructor
301
* Constructs a new root item.
303
WbRoot(QGraphicsScene* scene);
304
/*! \brief Returns the type of the item (0x87654000).*/
305
virtual int type() const { return 87654000; };
306
/*! \brief Saves the SVG element.*/
307
virtual QList<QString> parseSvg(QDomElement &, bool emitChanges = false);
308
/*! \brief Returns a deep copy of this object but without a scene association.*/
309
virtual WbItem* clone();
311
QGraphicsScene* scene_;
314
/*! \brief An item for representing an SVG path element.
315
* Inherits QGraphicsPathItem and WbItem.
317
* Reimplements the methods dictated in WbItem's description.
319
* Provides parsing for the 'd' and 'fill-rule' attributes.
320
* Also provides lineTo() and quadTo() methods (note that they don't
321
* emit an attributeChanged().)
325
class WbPath : public QGraphicsPathItem, public WbItem
328
/*! \brief Constructor
329
* Constructs a new item with values \a id, \a index, \a parent and
330
* \a scene with other attributes parsed from the SVG element \a svg.
332
WbPath(QDomElement &svg, const QString &id, const qreal &index, const QString &parent = "root", QGraphicsScene * scene = 0);
334
/*! \brief Returns the type of the item (0x87654001).*/
335
virtual int type() const { return 87654001; };
336
/*! \brief Returns a corrected version of the shape.*/
337
virtual QPainterPath shape() const;
338
/*! \brief Returns a QGraphicsItem* to self.*/
339
virtual QGraphicsItem* graphicsItem() { return this; };
340
/*! \brief Parses the item specific SVG properties and returns the list of changed attributes.*/
341
virtual QList<QString> parseSvg(QDomElement &, bool emitChanges = false);
342
/*! \brief Returns a deep copy of this object but without a scene association.*/
343
virtual WbItem* clone();
345
/*! \brief Adds a line to to the end of the path.*/
346
void lineTo(const QPointF &newPoint);
347
/*! \brief Adds a quadratic bezier curve to the end of the path.*/
348
void quadTo(const QPointF &controlPoint, const QPointF &newPoint);
350
static bool parsePathDataFast(const QString &data, QPainterPath &path);
351
static void pathArcSegment(QPainterPath &path, qreal xc, qreal yc, qreal th0, qreal th1, qreal rx, qreal ry, qreal xAxisRotation);
352
static void pathArc(QPainterPath &path, qreal rx, qreal ry, qreal x_axis_rotation, int large_arc_flag, int sweep_flag, qreal x, qreal y, qreal curx, qreal cury);
355
/*! \brief Constructs and popsup the default context menu.*/
356
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *);
357
/*! \brief Passes the event to WbItem::handleMousMoveEvent.
358
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
360
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
361
/*! \brief Passes the event to WbItem::handleMousReleaseEvent.
362
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
364
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
367
/*! \brief An item for an SVG ellipse element.
368
* Inherits QGraphicsEllipseItem and WbItem.
370
* Reimplements the methods dictated in WbItem's description.
372
* Provides parsing for the 'rx' and 'ry' attributes.
376
class WbEllipse : public QGraphicsEllipseItem, public WbItem {
378
/*! \brief Constructor
379
* Constructs a new item with values \a id, \a index, \a parent and
380
* \a scene with other attributes parsed from the SVG element \a svg.
382
WbEllipse(QDomElement &svg, const QString &id, const qreal &index, const QString &parent = "root", QGraphicsScene * scene = 0);
384
/*! \brief Returns the type of the item (0x87654002).*/
385
virtual int type() const { return 87654002; };
386
/*! \brief Returns a QGraphicsItem* to self.*/
387
virtual QGraphicsItem* graphicsItem() { return this; };
388
/*! \brief Parses the item specific SVG properties and returns the list of changed attributes.*/
389
virtual QList<QString> parseSvg(QDomElement &, bool emitChanges = false);
390
/*! \brief Returns a deep copy of this object but without a scene association.*/
391
virtual WbItem* clone();
394
/*! \brief Constructs and popsup the default context menu.*/
395
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *);
396
/*! \brief Passes the event to WbItem::handleMousMoveEvent.
397
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
399
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
400
/*! \brief Passes the event to WbItem::handleMousReleaseEvent.
401
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
403
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
406
/*! \brief An item for an SVG circle element.
407
* Inherits WbEllipse.
409
* Provides parsing for the r attribute.
413
class WbCircle : public WbEllipse {
415
/*! \brief Constructor
416
* Constructs a new item with values \a id, \a index, \a parent and
417
* \a scene with other attributes parsed from the SVG element \a svg.
419
WbCircle(QDomElement &svg, const QString &id, const qreal &index, const QString &parent = "root", QGraphicsScene * scene = 0);
421
/*! \brief Returns the type of the item (0x87654003).*/
422
virtual int type() const { return 87654003; };
423
/*! \brief Parses the item specific SVG properties and returns the list of changed attributes.*/
424
virtual QList<QString> parseSvg(QDomElement &, bool emitChanges = false);
425
/*! \brief Returns a deep copy of this object but without a scene association.*/
426
virtual WbItem* clone();
429
/*! \brief An item for an SVG rectangle element.
430
* Inherits QGraphicsRectItem and WbItem.
432
* Reimplements the methods dictated in WbItem's description.
434
* Provides parsing for the 'width' and 'height' attributes.
438
class WbRectangle : public QGraphicsRectItem, public WbItem {
440
/*! \brief Constructor
441
* Constructs a new item with values \a id, \a index, \a parent and
442
* \a scene with other attributes parsed from the SVG element \a svg.
444
WbRectangle(QDomElement &svg, const QString &id, const qreal &index, const QString &parent = "root", QGraphicsScene * scene = 0);
446
/*! \brief Returns the type of the item (0x87654002).*/
447
virtual int type() const { return 87654004; };
448
/*! \brief Returns a QGraphicsItem* to self.*/
449
virtual QGraphicsItem* graphicsItem() { return this; };
450
/*! \brief Parses the item specific SVG properties and returns the list of changed attributes.*/
451
virtual QList<QString> parseSvg(QDomElement &, bool emitChanges = false);
452
/*! \brief Returns a deep copy of this object but without a scene association.*/
453
virtual WbItem* clone();
456
/*! \brief Constructs and popsup the default context menu.*/
457
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *);
458
/*! \brief Passes the event to WbItem::handleMousMoveEvent.
459
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
461
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
462
/*! \brief Passes the event to WbItem::handleMousReleaseEvent.
463
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
465
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
468
/*! \brief An item for representing an SVG line element.
469
* Inherits QGraphicsPathItem and WbItem.
471
* Reimplements the methods dictated in WbItem's description.
473
* Provides parsing for the 'x1', 'y1', 'x2', 'y2' attributes.
477
class WbLine : public QGraphicsPathItem, public WbItem
480
/*! \brief Constructor
481
* Constructs a new item with values \a id, \a index, \a parent and
482
* \a scene with other attributes parsed from the SVG element \a svg.
484
WbLine(QDomElement &svg, const QString &id, const qreal &index, const QString &parent = "root", QGraphicsScene * scene = 0);
486
/*! \brief Returns the type of the item (0x87654005).*/
487
virtual int type() const { return 87654005; };
488
/*! \brief Returns a corrected version of the shape.*/
489
virtual QPainterPath shape() const;
490
/*! \brief Returns a QGraphicsItem* to self.*/
491
virtual QGraphicsItem* graphicsItem() { return this; };
492
/*! \brief Parses the item specific SVG properties and returns the list of changed attributes.*/
493
virtual QList<QString> parseSvg(QDomElement &, bool emitChanges = false);
494
/*! \brief Returns a deep copy of this object but without a scene association.*/
495
virtual WbItem* clone();
498
/*! \brief Constructs and popsup the default context menu.*/
499
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *);
500
/*! \brief Passes the event to WbItem::handleMousMoveEvent.
501
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
503
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
504
/*! \brief Passes the event to WbItem::handleMousReleaseEvent.
505
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
507
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
510
/*! \brief An item for representing an SVG polyline element.
511
* Inherits QGraphicsPathItem and WbItem.
513
* Reimplements the methods dictated in WbItem's description.
515
* Provides parsing for the 'points' attribute.
519
class WbPolyline : public QGraphicsPathItem, public WbItem
522
/*! \brief Constructor
523
* Constructs a new item with values \a id, \a index, \a parent and
524
* \a scene with other attributes parsed from the SVG element \a svg.
526
WbPolyline(QDomElement &svg, const QString &id, const qreal &index, const QString &parent = "root", QGraphicsScene * scene = 0);
528
/*! \brief Returns the type of the item (0x87654006).*/
529
virtual int type() const { return 87654006; };
530
/*! \brief Returns a corrected version of the shape.*/
531
virtual QPainterPath shape() const;
532
/*! \brief Returns a QGraphicsItem* to self.*/
533
virtual QGraphicsItem* graphicsItem() { return this; };
534
/*! \brief Parses the item specific SVG properties and returns the list of changed attributes.*/
535
virtual QList<QString> parseSvg(QDomElement &, bool emitChanges = false);
536
/*! \brief Returns a deep copy of this object but without a scene association.*/
537
virtual WbItem* clone();
540
/*! \brief Constructs and popsup the default context menu.*/
541
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *);
542
/*! \brief Passes the event to WbItem::handleMousMoveEvent.
543
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
545
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
546
/*! \brief Passes the event to WbItem::handleMousReleaseEvent.
547
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
549
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
552
/*! \brief An item for an SVG circle element.
553
* Inherits WbEllipse.
555
* Provides parsing for the r attribute.
559
class WbPolygon : public WbPolyline {
561
/*! \brief Constructor
562
* Constructs a new item with values \a id, \a index, \a parent and
563
* \a scene with other attributes parsed from the SVG element \a svg.
565
WbPolygon(QDomElement &svg, const QString &id, const qreal &index, const QString &parent = "root", QGraphicsScene * scene = 0);
567
/*! \brief Returns the type of the item (0x87654007).*/
568
virtual int type() const { return 87654007; };
569
/*! \brief Parses the item specific SVG properties and returns the list of changed attributes.*/
570
virtual QList<QString> parseSvg(QDomElement &, bool emitChanges = false);
571
/*! \brief Returns a deep copy of this object but without a scene association.*/
572
virtual WbItem* clone();
577
/*! \brief The visualized part of WbText.
578
* This class provides the QGraphicsItem for the WbText because multiple inheritance doesn't work
579
* when both WbItem and and QGraphicsTextItem inherit from QObject.
583
class WbGraphicsTextItem : public QGraphicsTextItem {
585
/*! \brief Constructor
586
* Constructs a new visualized item for \a wbtext on \a scene.
588
WbGraphicsTextItem(WbText* wbtext, QGraphicsScene* scene = 0);
591
/*! \brief Constructs and popsup the context menu.*/
592
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *);
593
/*! \brief Causes the text to be checked for changes.*/
594
virtual void focusOutEvent (QFocusEvent *);
595
/*! \brief Makes the text editable.*/
596
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *);
597
/*! \brief Passes the event to WbItem::handleMousMoveEvent.
598
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
600
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
601
/*! \brief Passes the event to WbItem::handleMousReleaseEvent.
602
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
604
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
607
/*! \brief A pointer to the "parent" WbItem.*/
611
/*! \brief An item for an SVG text element.
612
* Inherits WbItem and implements WbGraphicsTextItem as a friend class.
614
* Reimplements the methods dictated in WbItem's description.
616
* Provides parsing for the text content of the text element.
620
class WbText : public WbItem {
622
friend class WbGraphicsTextItem;
624
/*! \brief Constructor
625
* Constructs a new item with values \a id, \a index, \a parent and
626
* \a scene with other attributes parsed from the SVG element \a svg.
628
WbText(QDomElement &svg, const QString &id, const qreal &index, const QString &parent = "root", QGraphicsScene * scene = 0);
629
/*! \brief Destructor*/
632
/*! \brief Returns the type of the item (0x87654101).*/
633
virtual int type() const { return 87654101; };
634
/*! \brief Returns a QGraphicsItem* to self.*/
635
virtual QGraphicsItem* graphicsItem() { return graphicsitem_; };
636
/*! \brief Return the item as an SVG element.*/
637
virtual QDomElement svg();
638
/*! \brief Parses the item specific SVG properties and returns the list of changed attributes.*/
639
virtual QList<QString> parseSvg(QDomElement &, bool emitChanges = false);
640
/*! \brief Returns a deep copy of this object but without a scene association.*/
641
virtual WbItem* clone();
642
/*! \brief Checks if the text has changed and emits a signal accordingly.*/
643
void checkTextChanges();
646
/*! \brief Popsup a font dialog and sets the selected font.*/
650
/*! \brief The character data content of the element.*/
652
WbGraphicsTextItem* graphicsitem_;
655
/*! \brief An item for representing an SVG image element.
656
* Inherits QGraphicsPixmapItem and WbItem.
658
* Reimplements the methods dictated in WbItem's description.
660
* Provides parsing for the 'points' attribute.
664
class WbImage : public QGraphicsPixmapItem, public WbItem
667
/*! \brief Constructor
668
* Constructs a new item with values \a id, \a index, \a parent and
669
* \a scene with other attributes parsed from the SVG element \a svg.
671
WbImage(QDomElement &svg, const QString &id, const qreal &index, const QString &parent = "root", QGraphicsScene * scene = 0);
673
/*! \brief Returns the type of the item (0x87654102).*/
674
virtual int type() const { return 87654102; };
675
/*! \brief Returns a QGraphicsItem* to self.*/
676
virtual QGraphicsItem* graphicsItem() { return this; };
677
/*! \brief Parses the item specific SVG properties and returns the list of changed attributes.*/
678
virtual QList<QString> parseSvg(QDomElement &, bool emitChanges = false);
679
/*! \brief Returns a deep copy of this object but without a scene association.*/
680
virtual WbItem* clone();
683
/*! \brief Constructs and popsup the default context menu.*/
684
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *);
685
/*! \brief Passes the event to WbItem::handleMousMoveEvent.
686
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
688
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
689
/*! \brief Passes the event to WbItem::handleMousReleaseEvent.
690
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
692
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
695
/*! \brief An item for representing an SVG group element.
696
* Inherits QGraphicsGroupItem and WbItem.
698
* Reimplements the methods dictated in WbItem's description.
700
* Note that calling svg() of this class won't return the child elements
704
class WbGroup : public QGraphicsItem, public WbItem
707
/*! \brief Constructor
708
* Constructs a new item with values \a id, \a index, \a parent and
709
* \a scene with other attributes parsed from the SVG element \a svg.
711
WbGroup(QDomElement &svg, const QString &id, const qreal &index, const QString &parent = "root", QGraphicsScene * scene = 0);
713
/*! \brief Returns the type of the item (0x87654201).*/
714
virtual int type() const { return 87654201; };
715
/*! \brief Returns a QGraphicsItem* to self.*/
716
virtual QGraphicsItem* graphicsItem() { return this; };
717
/*! \brief Returns a deep copy of this object but without a scene association.*/
718
virtual WbItem* clone();
720
/*! \brief Paints the bounding rect if selected.*/
721
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
722
/*! \brief Returns the bounding rectangle containing all group member items.*/
723
virtual QRectF boundingRect() const;
726
/*! \brief Updates the bounding rectangle when children are added or removed.*/
727
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
729
/*! \brief Constructs and popsup the default context menu.*/
730
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *);
731
/*! \brief Passes the event to WbItem::handleMousMoveEvent.
732
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
734
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
735
/*! \brief Passes the event to WbItem::handleMousReleaseEvent.
736
* The event is also passed to QGraphicsItem::mouseMoveEvent if not accepted..
738
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
741
void addToBoundingRect(const QRectF &itemRect);
742
QRectF boundingRect_;