2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2014-01-29 18:37:45 +00:00
|
|
|
Copyright 2006-2014 The QElectroTech Team
|
2007-12-01 10:47:15 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech 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 General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2007-02-24 00:26:04 +00:00
|
|
|
#ifndef ELEMENT_TEXT_ITEM_H
|
2007-04-09 02:56:47 +00:00
|
|
|
#define ELEMENT_TEXT_ITEM_H
|
2014-07-21 20:44:32 +00:00
|
|
|
|
2007-09-26 22:57:53 +00:00
|
|
|
#include "diagramtextitem.h"
|
2014-07-21 20:44:32 +00:00
|
|
|
|
2010-04-18 17:59:54 +00:00
|
|
|
class Element;
|
2014-07-21 20:44:32 +00:00
|
|
|
|
2007-04-09 02:56:47 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This class represents a text item attached to an element. Users can change its
|
|
|
|
value, adjust its position (defined relatively to its parent element), and
|
|
|
|
direct it to any angle.
|
2007-04-09 02:56:47 +00:00
|
|
|
*/
|
2007-09-26 22:57:53 +00:00
|
|
|
class ElementTextItem : public DiagramTextItem {
|
2009-04-04 21:47:07 +00:00
|
|
|
Q_OBJECT
|
2014-12-13 14:01:09 +00:00
|
|
|
// constructors, destructor
|
2007-04-09 02:56:47 +00:00
|
|
|
public:
|
2014-12-14 13:06:21 +00:00
|
|
|
ElementTextItem(Element * = 0);
|
|
|
|
ElementTextItem(const QString &, Element * = 0);
|
2014-12-13 14:01:09 +00:00
|
|
|
virtual ~ElementTextItem();
|
2007-04-09 02:56:47 +00:00
|
|
|
|
2014-12-13 14:01:09 +00:00
|
|
|
// attributes
|
2007-04-12 03:13:13 +00:00
|
|
|
public:
|
2014-12-13 14:01:09 +00:00
|
|
|
enum { Type = UserType + 1003 };
|
|
|
|
virtual int type () const { return Type; }
|
2007-04-12 03:13:13 +00:00
|
|
|
|
2007-04-09 02:56:47 +00:00
|
|
|
private:
|
2014-12-13 14:01:09 +00:00
|
|
|
Element *parent_element_;
|
|
|
|
bool follow_parent_rotations;
|
|
|
|
QPointF original_position;
|
|
|
|
qreal original_rotation_angle_;
|
|
|
|
QString tagg_;
|
2007-04-09 02:56:47 +00:00
|
|
|
|
2014-12-13 14:01:09 +00:00
|
|
|
// methods
|
|
|
|
public:
|
|
|
|
Element *parentElement () const;
|
|
|
|
void fromXml ( const QDomElement & );
|
|
|
|
QDomElement toXml ( QDomDocument & ) const;
|
|
|
|
void setOriginalPos ( const QPointF & );
|
|
|
|
QPointF originalPos () const;
|
|
|
|
void setOriginalRotationAngle ( const qreal & );
|
|
|
|
qreal originalRotationAngle () const;
|
|
|
|
virtual void setFont ( const QFont & );
|
|
|
|
void setTagg ( const QString &str ) {tagg_ = str;}
|
|
|
|
QString tagg () const {return tagg_;}
|
|
|
|
void setFollowParentRotations ( bool fpr);
|
|
|
|
bool followParentRotations () const;
|
2009-12-13 22:12:52 +00:00
|
|
|
|
|
|
|
public slots:
|
2014-12-13 14:01:09 +00:00
|
|
|
void adjustItemPosition(int = 0);
|
2009-12-13 22:12:52 +00:00
|
|
|
|
|
|
|
protected:
|
2014-12-13 14:01:09 +00:00
|
|
|
virtual void mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *event );
|
|
|
|
virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent *event );
|
|
|
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent *event );
|
|
|
|
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent *event );
|
|
|
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent *event );
|
2014-01-11 18:09:04 +00:00
|
|
|
|
|
|
|
private:
|
2014-12-13 14:01:09 +00:00
|
|
|
void build ();
|
2007-04-09 02:56:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
Element text items can optionally be applied a counter-rotation when their
|
|
|
|
parent element is rotated, thus preserving their readability.
|
|
|
|
@return whether this text item follows the rotations of its parent element.
|
2007-04-09 02:56:47 +00:00
|
|
|
*/
|
|
|
|
inline bool ElementTextItem::followParentRotations() const {
|
|
|
|
return(follow_parent_rotations);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
Element text items can optionally be applied a counter-rotation when their
|
|
|
|
parent element is rotated, thus preserving their readability.
|
|
|
|
@param frp whether this text item should follow the rotations of its parent
|
|
|
|
element.
|
2007-04-09 02:56:47 +00:00
|
|
|
*/
|
|
|
|
inline void ElementTextItem::setFollowParentRotations(bool frp) {
|
|
|
|
follow_parent_rotations = frp;
|
|
|
|
}
|
|
|
|
|
2007-02-24 00:26:04 +00:00
|
|
|
#endif
|