2009-02-27 13:57:26 +00:00
|
|
|
/** \ingroup MapComposer
|
|
|
|
* A item that forms part of a map composition.
|
|
|
|
*/
|
2014-07-10 20:17:42 +10:00
|
|
|
class QgsComposerItem : QgsComposerObject, QGraphicsRectItem
|
2009-02-27 13:57:26 +00:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgscomposeritem.h>
|
2010-11-22 12:53:24 +00:00
|
|
|
#include <qgscomposerlabel.h>
|
|
|
|
#include <qgscomposerlegend.h>
|
|
|
|
#include <qgscomposermap.h>
|
2010-11-25 21:45:52 +00:00
|
|
|
#include <qgspaperitem.h>
|
2010-11-22 12:53:24 +00:00
|
|
|
#include <qgscomposerpicture.h>
|
|
|
|
#include <qgscomposerscalebar.h>
|
|
|
|
#include <qgscomposershape.h>
|
2010-11-26 10:39:06 +00:00
|
|
|
#include <qgscomposertable.h>
|
|
|
|
#include <qgscomposerattributetable.h>
|
2010-11-22 12:53:24 +00:00
|
|
|
%End
|
|
|
|
|
|
|
|
%ConvertToSubClassCode
|
2010-11-25 21:45:52 +00:00
|
|
|
// the conversions have to be static, because they're using multiple inheritance
|
|
|
|
// (seen in PyQt4 .sip files for some QGraphicsItem classes)
|
|
|
|
switch (sipCpp->type())
|
|
|
|
{
|
|
|
|
case QgsComposerItem::ComposerItem:
|
2010-11-27 11:26:05 +00:00
|
|
|
sipClass = sipClass_QgsComposerItem;
|
2010-11-25 21:45:52 +00:00
|
|
|
*sipCppRet = static_cast<QgsComposerItem*>(sipCpp);
|
|
|
|
break;
|
2012-09-24 02:28:15 +02:00
|
|
|
#if 0
|
2010-11-27 11:26:05 +00:00
|
|
|
case QgsComposerItem::ComposerArrow:
|
|
|
|
sipClass = sipClass_QgsComposerArrow;
|
2010-11-25 21:45:52 +00:00
|
|
|
*sipCppRet = static_cast<QgsComposerArrow*>(sipCpp);
|
|
|
|
break;
|
|
|
|
case QgsComposerItem::ComposerItemGroup:
|
2010-11-27 11:26:05 +00:00
|
|
|
sipClass = sipClass_QgsComposerItemGroup;
|
2010-11-25 21:45:52 +00:00
|
|
|
*sipCppRet = static_cast<QgsComposerItemGroup*>(sipCpp);
|
2010-11-27 11:26:05 +00:00
|
|
|
break;
|
2012-09-24 02:28:15 +02:00
|
|
|
#endif
|
2010-11-25 21:45:52 +00:00
|
|
|
case QgsComposerItem::ComposerLabel:
|
2010-11-27 11:26:05 +00:00
|
|
|
sipClass = sipClass_QgsComposerLabel;
|
2010-11-25 21:45:52 +00:00
|
|
|
*sipCppRet = static_cast<QgsComposerLabel*>(sipCpp);
|
|
|
|
break;
|
|
|
|
case QgsComposerItem::ComposerLegend:
|
2010-11-27 11:26:05 +00:00
|
|
|
sipClass = sipClass_QgsComposerLegend;
|
2010-11-25 21:45:52 +00:00
|
|
|
*sipCppRet = static_cast<QgsComposerLegend*>(sipCpp);
|
|
|
|
break;
|
|
|
|
case QgsComposerItem::ComposerMap:
|
2010-11-27 11:26:05 +00:00
|
|
|
sipClass = sipClass_QgsComposerMap;
|
2010-11-25 21:45:52 +00:00
|
|
|
*sipCppRet = static_cast<QgsComposerMap*>(sipCpp);
|
|
|
|
break;
|
|
|
|
case QgsComposerItem::ComposerPaper:
|
2010-11-27 11:26:05 +00:00
|
|
|
sipClass = sipClass_QgsPaperItem;
|
2010-11-25 21:45:52 +00:00
|
|
|
*sipCppRet = static_cast<QgsPaperItem*>(sipCpp);
|
|
|
|
break;
|
|
|
|
case QgsComposerItem::ComposerPicture:
|
2010-11-27 11:26:05 +00:00
|
|
|
sipClass = sipClass_QgsComposerPicture;
|
2010-11-25 21:45:52 +00:00
|
|
|
*sipCppRet = static_cast<QgsComposerPicture*>(sipCpp);
|
|
|
|
break;
|
|
|
|
case QgsComposerItem::ComposerScaleBar:
|
2010-11-27 11:26:05 +00:00
|
|
|
sipClass = sipClass_QgsComposerScaleBar;
|
2010-11-25 21:45:52 +00:00
|
|
|
*sipCppRet = static_cast<QgsComposerScaleBar*>(sipCpp);
|
|
|
|
break;
|
|
|
|
case QgsComposerItem::ComposerShape:
|
2010-11-27 11:26:05 +00:00
|
|
|
sipClass = sipClass_QgsComposerShape;
|
2010-11-25 21:45:52 +00:00
|
|
|
*sipCppRet = static_cast<QgsComposerShape*>(sipCpp);
|
|
|
|
break;
|
2010-11-26 10:39:06 +00:00
|
|
|
case QgsComposerItem::ComposerTable:
|
2010-11-27 11:26:05 +00:00
|
|
|
sipClass = sipClass_QgsComposerTable;
|
2010-11-25 21:45:52 +00:00
|
|
|
*sipCppRet = static_cast<QgsComposerTable*>(sipCpp);
|
|
|
|
break;
|
|
|
|
case QgsComposerItem::ComposerAttributeTable:
|
2010-11-27 11:26:05 +00:00
|
|
|
sipClass = sipClass_QgsComposerAttributeTable;
|
2010-11-25 21:45:52 +00:00
|
|
|
*sipCppRet = static_cast<QgsComposerAttributeTable*>(sipCpp);
|
|
|
|
break;
|
2010-11-27 11:26:05 +00:00
|
|
|
/*
|
|
|
|
case QgsComposerItem::ComposerTextTable:
|
|
|
|
sipClass = sipClass_QgsComposerTextTable;
|
2010-11-25 21:45:52 +00:00
|
|
|
*sipCppRet = static_cast<QgsComposerTextTable*>(sipCpp);
|
2010-11-27 11:26:05 +00:00
|
|
|
break;
|
|
|
|
*/
|
2010-11-25 21:45:52 +00:00
|
|
|
default:
|
2010-11-27 11:26:05 +00:00
|
|
|
sipClass = 0;
|
2010-11-25 21:45:52 +00:00
|
|
|
}
|
2009-02-27 13:57:26 +00:00
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2010-11-25 21:45:52 +00:00
|
|
|
enum ItemType
|
|
|
|
{
|
|
|
|
// base class for the items
|
2014-05-27 23:22:50 +02:00
|
|
|
ComposerItem,
|
2010-11-25 21:45:52 +00:00
|
|
|
|
|
|
|
// derived classes
|
|
|
|
ComposerArrow,
|
|
|
|
ComposerItemGroup,
|
|
|
|
ComposerLabel,
|
|
|
|
ComposerLegend,
|
|
|
|
ComposerMap,
|
|
|
|
ComposerPaper, // QgsPaperItem
|
|
|
|
ComposerPicture,
|
|
|
|
ComposerScaleBar,
|
|
|
|
ComposerShape,
|
|
|
|
ComposerTable,
|
|
|
|
ComposerAttributeTable,
|
2012-09-24 02:28:15 +02:00
|
|
|
ComposerTextTable,
|
|
|
|
ComposerFrame
|
2010-11-25 21:45:52 +00:00
|
|
|
};
|
|
|
|
|
2009-02-27 13:57:26 +00:00
|
|
|
/**Describes the action (move or resize in different directon) to be done during mouse move*/
|
|
|
|
enum MouseMoveAction
|
|
|
|
{
|
|
|
|
MoveItem,
|
|
|
|
ResizeUp,
|
|
|
|
ResizeDown,
|
|
|
|
ResizeLeft,
|
|
|
|
ResizeRight,
|
|
|
|
ResizeLeftUp,
|
|
|
|
ResizeRightUp,
|
|
|
|
ResizeLeftDown,
|
2012-09-24 02:28:15 +02:00
|
|
|
ResizeRightDown,
|
|
|
|
NoAction
|
2009-02-27 13:57:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ItemPositionMode
|
|
|
|
{
|
|
|
|
UpperLeft,
|
|
|
|
UpperMiddle,
|
|
|
|
UpperRight,
|
|
|
|
MiddleLeft,
|
|
|
|
Middle,
|
|
|
|
MiddleRight,
|
|
|
|
LowerLeft,
|
|
|
|
LowerMiddle,
|
|
|
|
LowerRight
|
|
|
|
};
|
|
|
|
|
|
|
|
/**Constructor
|
2012-09-24 02:28:15 +02:00
|
|
|
@param composition parent composition
|
2009-02-27 13:57:26 +00:00
|
|
|
@param manageZValue true if the z-Value of this object should be managed by mComposition*/
|
2010-11-25 21:45:52 +00:00
|
|
|
QgsComposerItem( QgsComposition* composition /TransferThis/, bool manageZValue = true );
|
2009-02-27 13:57:26 +00:00
|
|
|
/**Constructor with box position and composer object
|
2012-09-24 02:28:15 +02:00
|
|
|
@param x x coordinate of item
|
|
|
|
@param y y coordinate of item
|
|
|
|
@param width width of item
|
|
|
|
@param height height of item
|
|
|
|
@param composition parent composition
|
2009-02-27 13:57:26 +00:00
|
|
|
@param manageZValue true if the z-Value of this object should be managed by mComposition*/
|
2010-11-25 21:45:52 +00:00
|
|
|
QgsComposerItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition /TransferThis/, bool manageZValue = true );
|
2009-02-27 13:57:26 +00:00
|
|
|
virtual ~QgsComposerItem();
|
|
|
|
|
2010-11-25 21:45:52 +00:00
|
|
|
/** return correct graphics item type. Added in v1.7 */
|
|
|
|
virtual int type() const;
|
|
|
|
|
2009-02-27 13:57:26 +00:00
|
|
|
/** \brief Set selected, selected item should be highlighted */
|
|
|
|
virtual void setSelected( bool s );
|
2011-07-04 16:32:40 +02:00
|
|
|
|
2009-02-27 13:57:26 +00:00
|
|
|
/** \brief Is selected */
|
2014-01-27 09:22:24 +01:00
|
|
|
virtual bool selected() const;
|
2009-02-27 13:57:26 +00:00
|
|
|
|
|
|
|
/**Moves item in canvas coordinates*/
|
|
|
|
void move( double dx, double dy );
|
|
|
|
|
|
|
|
/**Move Content of item. Does nothing per default (but implemented in composer map)
|
|
|
|
@param dx move in x-direction (canvas coordinates)
|
|
|
|
@param dy move in y-direction(canvas coordinates)*/
|
|
|
|
virtual void moveContent( double dx, double dy );
|
|
|
|
|
|
|
|
/**Zoom content of item. Does nothing per default (but implemented in composer map)
|
2014-05-27 23:22:50 +02:00
|
|
|
@param delta value from wheel event that describes magnitude and direction (positive /negative number)
|
|
|
|
@param x x-position of mouse cursor (in item coordinates)
|
|
|
|
@param y y-position of mouse cursor (in item coordinates)*/
|
2009-02-27 13:57:26 +00:00
|
|
|
virtual void zoomContent( int delta, double x, double y );
|
|
|
|
|
2014-06-01 13:05:36 +10:00
|
|
|
/**Gets the page the item is currently on.
|
|
|
|
* @returns page number for item
|
|
|
|
* @see pagePos
|
|
|
|
* @see updatePagePos
|
|
|
|
* @note this method was added in version 2.4
|
|
|
|
*/
|
2014-05-28 15:48:07 +02:00
|
|
|
int page() const;
|
|
|
|
|
2014-06-01 13:05:36 +10:00
|
|
|
/**Returns the item's position relative to its current page.
|
|
|
|
* @returns position relative to the page's top left corner.
|
|
|
|
* @see page
|
|
|
|
* @see updatePagePos
|
|
|
|
* @note this method was added in version 2.4
|
|
|
|
*/
|
2014-05-28 15:48:07 +02:00
|
|
|
QPointF pagePos() const;
|
|
|
|
|
2014-06-01 13:05:36 +10:00
|
|
|
/**Moves the item so that it retains its relative position on the page
|
|
|
|
* when the paper size changes.
|
|
|
|
* @param newPageWidth new width of the page in mm
|
|
|
|
* @param newPageHeight new height of the page in mm
|
|
|
|
* @see page
|
|
|
|
* @see pagePos
|
|
|
|
* @note this method was added in version 2.4
|
|
|
|
*/
|
2014-05-28 15:48:07 +02:00
|
|
|
void updatePagePos( double newPageWidth, double newPageHeight );
|
|
|
|
|
2009-02-27 13:57:26 +00:00
|
|
|
/**Moves the item to a new position (in canvas coordinates)*/
|
|
|
|
void setItemPosition( double x, double y, ItemPositionMode itemPoint = UpperLeft );
|
|
|
|
|
2010-10-08 08:32:06 +00:00
|
|
|
/**Sets item position and width / height in one go
|
2014-05-27 23:22:50 +02:00
|
|
|
@param x item position x
|
|
|
|
@param y item position y
|
|
|
|
@param width item width
|
|
|
|
@param height item height
|
|
|
|
@param itemPoint item position mode
|
|
|
|
@param posIncludesFrame set to true if the position and size arguments include the item's frame border
|
|
|
|
|
2010-10-08 08:32:06 +00:00
|
|
|
@note: this method was added in version 1.6*/
|
2014-02-04 18:34:47 +11:00
|
|
|
void setItemPosition( double x, double y, double width, double height, ItemPositionMode itemPoint = UpperLeft, bool posIncludesFrame = false );
|
2010-10-08 08:32:06 +00:00
|
|
|
|
2013-02-12 12:30:54 +01:00
|
|
|
/**Returns item's last used position mode.
|
|
|
|
@note: This property has no effect on actual's item position, which is always the top-left corner.
|
|
|
|
@note: this method was added in version 2.0*/
|
|
|
|
ItemPositionMode lastUsedPositionMode();
|
|
|
|
|
2009-02-27 13:57:26 +00:00
|
|
|
/**Sets this items bound in scene coordinates such that 1 item size units
|
|
|
|
corresponds to 1 scene size unit*/
|
|
|
|
virtual void setSceneRect( const QRectF& rectangle );
|
|
|
|
|
|
|
|
/**Writes parameter that are not subclass specific in document. Usually called from writeXML methods of subclasses*/
|
|
|
|
bool _writeXML( QDomElement& itemElem, QDomDocument& doc ) const;
|
|
|
|
|
|
|
|
/**Reads parameter that are not subclass specific in document. Usually called from readXML methods of subclasses*/
|
|
|
|
bool _readXML( const QDomElement& itemElem, const QDomDocument& doc );
|
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Whether this item has a frame or not.
|
2012-09-24 02:28:15 +02:00
|
|
|
* @returns true if there is a frame around this item, otherwise false.
|
2012-02-28 08:00:57 +02:00
|
|
|
* @note introduced since 1.8
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see setFrameEnabled
|
|
|
|
* @see frameOutlineWidth
|
|
|
|
* @see frameJoinStyle
|
2012-02-28 08:00:57 +02:00
|
|
|
*/
|
2014-01-27 09:22:24 +01:00
|
|
|
bool hasFrame() const;
|
2012-12-20 12:35:09 +02:00
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Set whether this item has a frame drawn around it or not.
|
2012-09-24 02:28:15 +02:00
|
|
|
* @param drawFrame draw frame
|
|
|
|
* @returns nothing
|
2012-03-12 22:47:12 +01:00
|
|
|
* @note introduced in 1.8
|
2012-02-28 08:00:57 +02:00
|
|
|
* @see hasFrame
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see setFrameOutlineWidth
|
|
|
|
* @see setFrameJoinStyle
|
2012-02-28 08:00:57 +02:00
|
|
|
*/
|
2014-07-16 22:46:30 +10:00
|
|
|
void setFrameEnabled( const bool drawFrame );
|
2009-02-27 13:57:26 +00:00
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Sets frame outline width
|
2014-02-04 18:34:47 +11:00
|
|
|
* @param outlineWidth new width for outline frame
|
|
|
|
* @returns nothing
|
|
|
|
* @note introduced in 2.2
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see frameOutlineWidth
|
2014-02-04 18:34:47 +11:00
|
|
|
* @see setFrameEnabled
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see setFrameJoinStyle
|
2014-02-04 18:34:47 +11:00
|
|
|
*/
|
2014-07-16 22:46:30 +10:00
|
|
|
virtual void setFrameOutlineWidth( const double outlineWidth );
|
2014-05-27 23:22:50 +02:00
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Returns the frame's outline width. Only used if hasFrame is true.
|
2014-04-28 20:59:20 +10:00
|
|
|
* @returns Frame outline width
|
|
|
|
* @note introduced in 2.3
|
|
|
|
* @see hasFrame
|
|
|
|
* @see setFrameOutlineWidth
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see frameJoinStyle
|
2014-04-28 20:59:20 +10:00
|
|
|
*/
|
2014-05-27 23:22:50 +02:00
|
|
|
double frameOutlineWidth() const;
|
2014-02-04 18:34:47 +11:00
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Returns the join style used for drawing the item's frame
|
2014-04-08 20:18:14 +10:00
|
|
|
* @returns Join style for outline frame
|
|
|
|
* @note introduced in 2.3
|
|
|
|
* @see hasFrame
|
|
|
|
* @see setFrameJoinStyle
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see frameOutlineWidth
|
2014-04-08 20:18:14 +10:00
|
|
|
*/
|
|
|
|
Qt::PenJoinStyle frameJoinStyle() const;
|
2014-07-16 22:46:30 +10:00
|
|
|
|
|
|
|
/**Sets join style used when drawing the item's frame
|
2014-04-08 20:18:14 +10:00
|
|
|
* @param style Join style for outline frame
|
|
|
|
* @returns nothing
|
|
|
|
* @note introduced in 2.3
|
|
|
|
* @see setFrameEnabled
|
|
|
|
* @see frameJoinStyle
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see setFrameOutlineWidth
|
2014-04-08 20:18:14 +10:00
|
|
|
*/
|
2014-07-16 22:46:30 +10:00
|
|
|
void setFrameJoinStyle( const Qt::PenJoinStyle style );
|
2014-04-08 20:18:14 +10:00
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Returns the estimated amount the item's frame bleeds outside the item's
|
|
|
|
* actual rectangle. For instance, if the item has a 2mm frame outline, then
|
|
|
|
* 1mm of this frame is drawn outside the item's rect. In this case the
|
|
|
|
* return value will be 1.0
|
2014-02-04 18:34:47 +11:00
|
|
|
* @note introduced in 2.2
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see rectWithFrame
|
2014-02-04 18:34:47 +11:00
|
|
|
*/
|
|
|
|
virtual double estimatedFrameBleed() const;
|
|
|
|
|
|
|
|
/** Returns the item's rectangular bounds, including any bleed caused by the item's frame.
|
|
|
|
* The bounds are returned in the item's coordinate system (see Qt's QGraphicsItem docs for
|
|
|
|
* more details about QGraphicsItem coordinate systems). The results differ from Qt's rect()
|
|
|
|
* function, as rect() makes no allowances for the portion of outlines which are drawn
|
|
|
|
* outside of the item.
|
|
|
|
* @note introduced in 2.2
|
|
|
|
* @see estimatedFrameBleed
|
|
|
|
*/
|
|
|
|
virtual QRectF rectWithFrame() const;
|
2013-06-23 16:00:16 +02:00
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Whether this item has a Background or not.
|
2013-06-23 16:00:16 +02:00
|
|
|
* @returns true if there is a Background around this item, otherwise false.
|
|
|
|
* @note introduced since 2.0
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see setBackgroundEnabled
|
|
|
|
* @see backgroundColor
|
2013-06-23 16:00:16 +02:00
|
|
|
*/
|
|
|
|
bool hasBackground() const;
|
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Set whether this item has a Background drawn around it or not.
|
2013-06-23 16:00:16 +02:00
|
|
|
* @param drawBackground draw Background
|
|
|
|
* @returns nothing
|
|
|
|
* @note introduced in 2.0
|
|
|
|
* @see hasBackground
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see setBackgroundColor
|
2013-06-23 16:00:16 +02:00
|
|
|
*/
|
2014-07-16 22:46:30 +10:00
|
|
|
void setBackgroundEnabled( const bool drawBackground );
|
2013-06-23 16:00:16 +02:00
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Gets the background color for this item
|
2013-06-23 16:00:16 +02:00
|
|
|
* @returns background color
|
|
|
|
* @note introduced in 2.0
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see setBackgroundColor
|
|
|
|
* @see hasBackground
|
2013-06-23 16:00:16 +02:00
|
|
|
*/
|
|
|
|
QColor backgroundColor() const;
|
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Sets the background color for this item
|
2013-06-23 16:00:16 +02:00
|
|
|
* @param backgroundColor new background color
|
|
|
|
* @returns nothing
|
|
|
|
* @note introduced in 2.0
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see backgroundColor
|
|
|
|
* @see setBackgroundEnabled
|
2013-06-23 16:00:16 +02:00
|
|
|
*/
|
|
|
|
void setBackgroundColor( const QColor& backgroundColor );
|
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Returns the item's composition blending mode.
|
|
|
|
* @returns item blending mode
|
|
|
|
* @see setBlendMode
|
|
|
|
*/
|
2013-06-23 16:00:16 +02:00
|
|
|
QPainter::CompositionMode blendMode() const;
|
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Sets the item's composition blending mode
|
|
|
|
* @param blendMode blending mode for item
|
|
|
|
* @see blendMode
|
|
|
|
*/
|
|
|
|
void setBlendMode( const QPainter::CompositionMode blendMode );
|
2013-06-23 16:00:16 +02:00
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Returns the item's transparency
|
|
|
|
* @returns transparency as integer between 0 (transparent) and 255 (opaque)
|
|
|
|
* @see setTransparency
|
|
|
|
*/
|
2013-06-23 16:00:16 +02:00
|
|
|
int transparency() const;
|
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Sets the item's transparency
|
|
|
|
* @param transparency integer between 0 (transparent) and 255 (opaque)
|
|
|
|
* @see transparency
|
|
|
|
*/
|
|
|
|
void setTransparency( const int transparency );
|
|
|
|
|
|
|
|
/**Returns whether effects (eg blend modes) are enabled for the item
|
|
|
|
* @returns true if effects are enabled
|
2013-06-23 16:00:16 +02:00
|
|
|
* @note introduced in 2.0
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see setEffectsEnabled
|
|
|
|
* @see transparency
|
|
|
|
* @see blendMode
|
2013-06-23 16:00:16 +02:00
|
|
|
*/
|
|
|
|
bool effectsEnabled() const;
|
2014-07-16 22:46:30 +10:00
|
|
|
|
|
|
|
/**Sets whether effects (eg blend modes) are enabled for the item
|
|
|
|
* @param effectsEnabled set to true to enable effects
|
2013-06-23 16:00:16 +02:00
|
|
|
* @note introduced in 2.0
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see effectsEnabled
|
|
|
|
* @see setTransparency
|
|
|
|
* @see setBlendMode
|
2013-06-23 16:00:16 +02:00
|
|
|
*/
|
2014-07-16 22:46:30 +10:00
|
|
|
void setEffectsEnabled( const bool effectsEnabled );
|
2013-06-23 16:00:16 +02:00
|
|
|
|
2009-02-27 13:57:26 +00:00
|
|
|
/**Composite operations for item groups do nothing per default*/
|
|
|
|
virtual void addItem( QgsComposerItem* item );
|
|
|
|
virtual void removeItems();
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual void beginItemCommand( const QString& text );
|
|
|
|
|
|
|
|
/**Starts new composer undo command
|
|
|
|
@param commandText command title
|
|
|
|
@param c context for mergeable commands (unknown for non-mergeable commands*/
|
|
|
|
void beginCommand( const QString& commandText, QgsComposerMergeCommand::Context c = QgsComposerMergeCommand::Unknown );
|
|
|
|
|
|
|
|
virtual void endItemCommand();
|
|
|
|
/**Finish current command and push it onto the undo stack */
|
|
|
|
void endCommand();
|
|
|
|
void cancelCommand();
|
|
|
|
|
2009-02-27 13:57:26 +00:00
|
|
|
//functions that encapsulate the workaround for the Qt font bug (that is to scale the font size up and then scale the
|
|
|
|
//painter down by the same factor for drawing
|
|
|
|
|
|
|
|
/**Draws Text. Takes care about all the composer specific issues (calculation to pixel, scaling of font and painter
|
2012-03-09 17:09:50 +01:00
|
|
|
to work around the Qt font bug)*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void drawText( QPainter* p, double x, double y, const QString& text, const QFont& font ) const;
|
2009-02-27 13:57:26 +00:00
|
|
|
|
2014-05-15 10:04:23 +10:00
|
|
|
/**Like the above, but with a rectangle for multiline text
|
2014-05-27 23:22:50 +02:00
|
|
|
* @param p painter to use
|
|
|
|
* @param rect rectangle to draw into
|
|
|
|
* @param text text to draw
|
|
|
|
* @param font font to use
|
|
|
|
* @param halignment optional horizontal alignment
|
|
|
|
* @param valignment optional vertical alignment
|
|
|
|
* @param flags allows for passing Qt::TextFlags to control appearance of rendered text
|
2014-05-15 10:04:23 +10:00
|
|
|
*/
|
|
|
|
void drawText( QPainter* p, const QRectF& rect, const QString& text, const QFont& font, Qt::AlignmentFlag halignment = Qt::AlignLeft, Qt::AlignmentFlag valignment = Qt::AlignTop, int flags = Qt::TextWordWrap ) const;
|
2009-02-27 13:57:26 +00:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/**Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
|
2009-02-27 13:57:26 +00:00
|
|
|
double textWidthMillimeters( const QFont& font, const QString& text ) const;
|
|
|
|
|
2011-04-16 08:34:02 +00:00
|
|
|
/**Returns the font height of a character in millimeters
|
|
|
|
@note this method was added in version 1.7*/
|
|
|
|
double fontHeightCharacterMM( const QFont& font, const QChar& c ) const;
|
|
|
|
|
2009-02-27 13:57:26 +00:00
|
|
|
/**Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
|
|
|
|
double fontAscentMillimeters( const QFont& font ) const;
|
|
|
|
|
2014-06-03 11:51:37 +02:00
|
|
|
/**Returns the font descent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
|
2013-06-23 16:00:16 +02:00
|
|
|
double fontDescentMillimeters( const QFont& font ) const;
|
2014-06-03 11:51:37 +02:00
|
|
|
|
|
|
|
/**Returns the font height in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE.
|
|
|
|
* Font height equals the font ascent+descent+1 (for baseline).
|
|
|
|
* @note Added in version 2.4
|
|
|
|
*/
|
|
|
|
double fontHeightMillimeters( const QFont& font ) const;
|
2013-06-23 16:00:16 +02:00
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Calculates font size in mm from a font point size
|
|
|
|
* @deprecated use QgsComposerUtils::mmFontSize instead
|
|
|
|
*/
|
|
|
|
double pixelFontSize( double pointSize ) const /Deprecated/;
|
2009-02-27 13:57:26 +00:00
|
|
|
|
|
|
|
/**Returns a font where size is in pixel and font size is upscaled with FONT_WORKAROUND_SCALE*/
|
|
|
|
QFont scaledFontPixelSize( const QFont& font ) const;
|
|
|
|
|
2009-11-19 09:04:33 +00:00
|
|
|
/**Locks / unlocks the item position for mouse drags
|
2014-07-16 22:46:30 +10:00
|
|
|
* @param lock set to true to prevent item movement and resizing via the mouse
|
|
|
|
* @note this method was added in version 1.2
|
|
|
|
* @see positionLock
|
|
|
|
*/
|
|
|
|
void setPositionLock( const bool lock );
|
2009-11-19 09:04:33 +00:00
|
|
|
|
2014-07-16 22:46:30 +10:00
|
|
|
/**Returns whether position lock for mouse drags is enabled
|
|
|
|
* returns true if item is locked for mouse movement and resizing
|
|
|
|
* @note this method was added in version 1.2
|
|
|
|
* @see setPositionLock
|
|
|
|
*/
|
2009-11-19 09:04:33 +00:00
|
|
|
bool positionLock() const;
|
|
|
|
|
2014-07-05 20:08:20 +10:00
|
|
|
/**Returns the current rotation for the composer item.
|
|
|
|
* @returns rotation for composer item
|
|
|
|
* @param valueType controls whether the returned value is the user specified rotation,
|
|
|
|
* or the current evaluated rotation (which may be affected by data driven rotation
|
|
|
|
* settings).
|
|
|
|
* @note this method was added in version 2.1
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see setItemRotation
|
2014-07-05 20:08:20 +10:00
|
|
|
*/
|
2014-07-16 22:46:30 +10:00
|
|
|
double itemRotation( const QgsComposerObject::PropertyValueType valueType = QgsComposerObject::EvaluatedValue ) const;
|
2013-12-30 19:50:00 +11:00
|
|
|
|
|
|
|
/**Returns the rotation for the composer item
|
|
|
|
* @deprecated Use itemRotation()
|
|
|
|
* instead
|
2014-01-27 09:22:24 +01:00
|
|
|
*/
|
2014-04-28 19:11:11 +10:00
|
|
|
double rotation() const /Deprecated/;
|
2009-11-19 09:04:33 +00:00
|
|
|
|
2011-05-16 14:25:54 +02:00
|
|
|
/**Updates item, with the possibility to do custom update for subclasses*/
|
|
|
|
virtual void updateItem();
|
|
|
|
|
2013-02-20 21:13:05 +01:00
|
|
|
/**Get item's id (which is not necessarly unique)
|
2014-07-16 22:46:30 +10:00
|
|
|
* @returns item id
|
|
|
|
* @note this method was added in version 1.7
|
|
|
|
* @see setId
|
|
|
|
*/
|
2011-07-04 20:28:20 +10:00
|
|
|
QString id() const;
|
|
|
|
|
2013-02-20 21:13:05 +01:00
|
|
|
/**Set item's id (which is not necessarly unique)
|
2014-07-16 22:46:30 +10:00
|
|
|
* @param id new id for item
|
|
|
|
* @note this method was added in version 1.7
|
|
|
|
* @see id
|
|
|
|
*/
|
2011-07-04 20:28:20 +10:00
|
|
|
void setId( const QString& id );
|
|
|
|
|
2013-02-20 21:13:05 +01:00
|
|
|
/**Get item identification name
|
2014-07-16 22:46:30 +10:00
|
|
|
* @returns unique item identification string
|
|
|
|
* @note this method was added in version 2.0
|
|
|
|
* @note there is not setter since one can't manually set the id
|
|
|
|
* @see id
|
|
|
|
* @see setId
|
|
|
|
*/
|
2013-02-20 21:13:05 +01:00
|
|
|
QString uuid() const;
|
2014-07-04 20:08:59 +10:00
|
|
|
|
|
|
|
/**Returns whether this item is part of a group
|
|
|
|
* @returns true if item is in a group
|
|
|
|
* @note added in version 2.5
|
|
|
|
* @see setIsGroupMember
|
|
|
|
*/
|
|
|
|
bool isGroupMember() const;
|
|
|
|
|
|
|
|
/**Sets whether this item is part of a group
|
|
|
|
* @param isGroupMember set to true if item is in a group
|
|
|
|
* @note added in version 2.5
|
|
|
|
* @see isGroupMember
|
|
|
|
*/
|
2014-07-16 22:46:30 +10:00
|
|
|
void setIsGroupMember( const bool isGroupMember );
|
2013-02-20 21:13:05 +01:00
|
|
|
|
2014-04-16 19:47:40 +10:00
|
|
|
/**Get the number of layers that this item requires for exporting as layers
|
|
|
|
* @returns 0 if this item is to be placed on the same layer as the previous item,
|
|
|
|
* 1 if it should be placed on its own layer, and >1 if it requires multiple export layers
|
|
|
|
* @note this method was added in version 2.4
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see setCurrentExportLayer
|
2014-04-16 19:47:40 +10:00
|
|
|
*/
|
2014-04-15 14:41:16 +02:00
|
|
|
int numberExportLayers() const;
|
|
|
|
|
2014-04-16 19:47:40 +10:00
|
|
|
/**Sets the current layer to draw for exporting
|
|
|
|
* @param layerIdx can be set to -1 to draw all item layers, and must be less than numberExportLayers()
|
|
|
|
* @note this method was added in version 2.4
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see numberExportLayers
|
2014-04-16 19:47:40 +10:00
|
|
|
*/
|
2014-07-16 22:46:30 +10:00
|
|
|
void setCurrentExportLayer( const int layerIdx = -1 );
|
2014-04-15 14:41:16 +02:00
|
|
|
|
2009-11-19 09:04:33 +00:00
|
|
|
public slots:
|
2013-12-30 19:50:00 +11:00
|
|
|
/**Sets the item rotation
|
|
|
|
* @deprecated Use setItemRotation( double rotation ) instead
|
2014-01-27 09:22:24 +01:00
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual void setRotation( double r );
|
2013-12-30 19:50:00 +11:00
|
|
|
|
|
|
|
/**Sets the item rotation
|
2014-07-05 14:12:40 +10:00
|
|
|
* @param r item rotation in degrees
|
|
|
|
* @param adjustPosition set to true if item should be shifted so that rotation occurs
|
|
|
|
* around item center. If false, rotation occurs around item origin
|
|
|
|
* @note this method was added in version 2.1
|
2014-07-16 22:46:30 +10:00
|
|
|
* @see itemRotation
|
2013-12-30 19:50:00 +11:00
|
|
|
*/
|
2014-07-16 22:46:30 +10:00
|
|
|
virtual void setItemRotation( const double r, const bool adjustPosition = false );
|
2014-01-27 09:22:24 +01:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
void repaint();
|
2009-11-19 09:04:33 +00:00
|
|
|
|
2014-07-05 14:12:40 +10:00
|
|
|
/**Refreshes a data defined property for the item by reevaluating the property's value
|
|
|
|
* and redrawing the item with this new value.
|
|
|
|
* @param property data defined property to refresh. If property is set to
|
|
|
|
* QgsComposerItem::AllProperties then all data defined properties for the item will be
|
|
|
|
* refreshed.
|
|
|
|
* @note this method was added in version 2.5
|
|
|
|
*/
|
2014-07-16 22:46:30 +10:00
|
|
|
virtual void refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property = QgsComposerObject::AllProperties );
|
|
|
|
|
2014-07-05 14:12:40 +10:00
|
|
|
|
2009-02-27 13:57:26 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
//event handlers
|
|
|
|
virtual void mouseMoveEvent( QGraphicsSceneMouseEvent * event );
|
|
|
|
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
|
|
|
|
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event );
|
|
|
|
|
|
|
|
virtual void hoverMoveEvent( QGraphicsSceneHoverEvent * event );
|
|
|
|
|
|
|
|
/**Draw selection boxes around item*/
|
|
|
|
virtual void drawSelectionBoxes( QPainter* p );
|
|
|
|
|
|
|
|
/**Draw black frame around item*/
|
|
|
|
virtual void drawFrame( QPainter* p );
|
|
|
|
|
|
|
|
/**Draw background*/
|
|
|
|
virtual void drawBackground( QPainter* p );
|
2009-11-19 09:04:33 +00:00
|
|
|
|
2010-04-19 14:30:59 +00:00
|
|
|
/**Draws arrowhead*/
|
|
|
|
void drawArrowHead( QPainter* p, double x, double y, double angle, double arrowHeadWidth ) const;
|
|
|
|
|
|
|
|
/**Returns angle of the line from p1 to p2 (clockwise, starting at N)*/
|
|
|
|
double angle( const QPointF& p1, const QPointF& p2 ) const;
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/**Returns the current (zoom level dependent) tolerance to decide if mouse position is close enough to the
|
2009-11-19 09:04:33 +00:00
|
|
|
item border for resizing*/
|
|
|
|
double rectHandlerBorderTolerance() const;
|
|
|
|
|
|
|
|
/**Returns the size of the lock symbol depending on the composer zoom level and the item size
|
|
|
|
@note: this function was introduced in version 1.2*/
|
|
|
|
double lockSymbolSize() const;
|
|
|
|
|
|
|
|
/**Returns the zoom factor of the graphics view.
|
|
|
|
@return the factor or -1 in case of error (e.g. graphic view does not exist)
|
|
|
|
@note: this function was introduced in version 1.2*/
|
|
|
|
double horizontalViewScaleFactor() const;
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
//some utility functions
|
|
|
|
|
2014-07-10 20:17:42 +10:00
|
|
|
/**Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation.
|
|
|
|
* @deprecated will be removed in QGIS 3.0
|
|
|
|
*/
|
|
|
|
bool imageSizeConsideringRotation( double& width, double& height, double rotation ) const /Deprecated/;
|
|
|
|
|
2013-12-30 19:50:00 +11:00
|
|
|
/**Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation
|
2014-07-10 20:17:42 +10:00
|
|
|
* @deprecated will be removed in QGIS 3.0
|
2013-12-30 19:50:00 +11:00
|
|
|
*/
|
2014-04-28 19:11:11 +10:00
|
|
|
bool imageSizeConsideringRotation( double& width, double& height ) const /Deprecated/;
|
2014-01-27 09:22:24 +01:00
|
|
|
|
|
|
|
/**Calculates the largest scaled version of originalRect which fits within boundsRect, when it is rotated by
|
2014-07-10 20:17:42 +10:00
|
|
|
* a specified amount
|
|
|
|
* @param originalRect QRectF to be rotated and scaled
|
|
|
|
* @param boundsRect QRectF specifying the bounds which the rotated and scaled rectangle must fit within
|
|
|
|
* @param rotation the rotation in degrees to be applied to the rectangle
|
|
|
|
* @deprecated use QgsComposerUtils::largestRotatedRectWithinBounds instead
|
|
|
|
*/
|
|
|
|
QRectF largestRotatedRectWithinBounds( QRectF originalRect, QRectF boundsRect, double rotation ) const /Deprecated/;
|
2014-01-27 09:22:24 +01:00
|
|
|
|
2013-12-30 19:50:00 +11:00
|
|
|
/**Calculates corner point after rotation and scaling
|
2014-07-10 20:17:42 +10:00
|
|
|
* @deprecated will be removed in QGIS 3.0
|
|
|
|
*/
|
|
|
|
bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height, double rotation ) const /Deprecated/;
|
|
|
|
|
|
|
|
/**Calculates corner point after rotation and scaling
|
|
|
|
* @deprecated will be removed in QGIS 3.0
|
2014-01-27 09:22:24 +01:00
|
|
|
*/
|
2014-04-28 19:11:11 +10:00
|
|
|
bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const /Deprecated/;
|
2011-08-30 11:20:40 +02:00
|
|
|
|
2014-07-10 20:17:42 +10:00
|
|
|
/**Calculates corner point after rotation and scaling
|
|
|
|
* @deprecated will be removed in QGIS 3.0
|
|
|
|
*/
|
|
|
|
void sizeChangedByRotation( double& width, double& height, double rotation ) /Deprecated/;
|
|
|
|
|
2014-01-27 09:22:24 +01:00
|
|
|
/**Calculates width / height of the bounding box of a rotated rectangle
|
2014-07-10 20:17:42 +10:00
|
|
|
* @deprecated will be removed in QGIS 3.0
|
2014-01-27 09:22:24 +01:00
|
|
|
*/
|
2014-04-28 19:11:11 +10:00
|
|
|
void sizeChangedByRotation( double& width, double& height ) /Deprecated/;
|
2014-07-10 20:17:42 +10:00
|
|
|
|
2009-11-26 13:56:08 +00:00
|
|
|
/**Rotates a point / vector
|
2014-07-10 20:17:42 +10:00
|
|
|
* @param angle rotation angle in degrees, counterclockwise
|
|
|
|
* @param x in/out: x coordinate before / after the rotation
|
|
|
|
* @param y in/out: y cooreinate before / after the rotation
|
|
|
|
* @deprecated use QgsComposerUtils:rotate instead
|
|
|
|
*/
|
|
|
|
void rotate( double angle, double& x, double& y ) const /Deprecated/;
|
2009-11-19 09:04:33 +00:00
|
|
|
|
2013-06-23 16:00:16 +02:00
|
|
|
/**Return horizontal align snap item. Creates a new graphics line if 0*/
|
|
|
|
QGraphicsLineItem* hAlignSnapItem();
|
|
|
|
void deleteHAlignSnapItem();
|
|
|
|
/**Return vertical align snap item. Creates a new graphics line if 0*/
|
|
|
|
QGraphicsLineItem* vAlignSnapItem();
|
|
|
|
void deleteVAlignSnapItem();
|
|
|
|
void deleteAlignItems();
|
|
|
|
|
2014-07-06 00:50:33 +10:00
|
|
|
/**Update an item rect to consider data defined position and size of item*/
|
|
|
|
QRectF evalItemRect( const QRectF &newRect );
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
signals:
|
2014-01-27 09:22:24 +01:00
|
|
|
/**Is emitted on item rotation change*/
|
2013-12-30 19:50:00 +11:00
|
|
|
void itemRotationChanged( double newRotation );
|
2012-09-24 02:28:15 +02:00
|
|
|
/**Emitted if the rectangle changes*/
|
|
|
|
void sizeChanged();
|
2014-02-04 18:34:47 +11:00
|
|
|
/**Emitted if the item's frame style changes
|
|
|
|
* @note: this function was introduced in version 2.2
|
|
|
|
*/
|
|
|
|
void frameChanged();
|
|
|
|
|
2009-11-19 09:04:33 +00:00
|
|
|
};
|