-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[composer] Refactor QgsComposerItem:
- New class QgsComposerObject, which both QgsComposerItem and QgsComposerMultiFrame derive from. This class contains the framework for data defined composition properties. - New class QgsComposerUtils, containing helpful static functions previously in QgsComposerItem - Test suites for data defined settings in QgsComposerObject and functions in QgsComposerUtils
- Loading branch information
1 parent
49bc38c
commit 2041fc2
Showing
35 changed files
with
1,792 additions
and
652 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/** \ingroup MapComposer | ||
* A item that forms part of a map composition. | ||
*/ | ||
class QgsComposerObject : QObject | ||
{ | ||
%TypeHeaderCode | ||
#include <qgscomposerobject.h> | ||
%End | ||
|
||
public: | ||
|
||
/** Data defined properties for different item types | ||
*/ | ||
enum DataDefinedProperty | ||
{ | ||
NoProperty = 0, /*< no property */ | ||
AllProperties, /*< all properties for item */ | ||
//composer page properties | ||
PresetPaperSize, /*< preset paper size for composition */ | ||
PaperWidth, /*< paper width */ | ||
PaperHeight, /*< paper height */ | ||
NumPages, /*< number of pages in composition */ | ||
PaperOrientation, /*< paper orientation */ | ||
//general composer item properties | ||
PageNumber, /*< page number for item placement */ | ||
PositionX, /*< x position on page */ | ||
PositionY, /*< y position on page */ | ||
ItemWidth, /*< width of item */ | ||
ItemHeight, /*< height of item */ | ||
ItemRotation, /*< rotation of item */ | ||
Transparency, /*< item transparency */ | ||
BlendMode, /*< item blend mode */ | ||
//composer map | ||
MapRotation, /*< map rotation */ | ||
MapScale, /*< map scale */ | ||
MapXMin, /*< map extent x minimum */ | ||
MapYMin, /*< map extent y minimum */ | ||
MapXMax, /*< map extent x maximum */ | ||
MapYMax /*< map extent y maximum */ | ||
}; | ||
|
||
/** Specifies whether the value returned by a function should be the original, user | ||
* set value, or the current evaluated value for the property. This may differ if | ||
* a property has a data defined expression active. | ||
*/ | ||
enum PropertyValueType | ||
{ | ||
EvaluatedValue = 0, /*< return the current evaluated value for the property */ | ||
OriginalValue /*< return the original, user set value */ | ||
}; | ||
|
||
/**Constructor | ||
* @param composition parent composition | ||
*/ | ||
QgsComposerObject( QgsComposition* composition ); | ||
virtual ~QgsComposerObject(); | ||
|
||
/**Returns the composition the item is attached to. | ||
* @returns QgsComposition for item. | ||
*/ | ||
const QgsComposition* composition() const; | ||
|
||
/**Stores item state in DOM element | ||
* @param elem is DOM element corresponding to 'Composer' tag | ||
* @param doc is the DOM document | ||
*/ | ||
virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const; | ||
|
||
/**Sets item state from DOM element | ||
* @param itemElem is DOM node corresponding to item tag | ||
* @param doc is DOM document | ||
*/ | ||
virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc ); | ||
|
||
/**Returns a reference to the data defined settings for one of the item's data defined properties. | ||
* @param property data defined property to return | ||
* @note this method was added in version 2.5 | ||
*/ | ||
QgsDataDefined* dataDefinedProperty( const DataDefinedProperty property ); | ||
|
||
/**Sets parameters for a data defined property for the item | ||
* @param property data defined property to set | ||
* @param active true if data defined property is active, false if it is disabled | ||
* @param useExpression true if the expression should be used | ||
* @param expression expression for data defined property | ||
* @field field name if the data defined property should take its value from a field | ||
* @note this method was added in version 2.5 | ||
*/ | ||
void setDataDefinedProperty( const DataDefinedProperty property, const bool active, const bool useExpression, const QString &expression, const QString &field ); | ||
|
||
public slots: | ||
|
||
/**Triggers a redraw for the item*/ | ||
virtual void repaint(); | ||
|
||
protected: | ||
|
||
/**Evaluate a data defined property and return the calculated value | ||
* @returns true if data defined property could be successfully evaluated | ||
* @param property data defined property to evaluate | ||
* @param expressionValue QVariant for storing the evaluated value | ||
* @note this method was added in version 2.5 | ||
*/ | ||
bool dataDefinedEvaluate( QgsComposerObject::DataDefinedProperty property, QVariant &expressionValue ); | ||
|
||
signals: | ||
/**Emitted when the item changes. Signifies that the item widgets must update the | ||
* gui elements. | ||
*/ | ||
void itemChanged(); | ||
|
||
}; |
Oops, something went wrong.