18 changes: 11 additions & 7 deletions python/core/composer/qgscomposershape.sip
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,22 @@ class QgsComposerShape: QgsComposerItem
QgsComposerShape::Shape shapeType() const;
void setShapeType( QgsComposerShape::Shape s );

/**Sets this items bound in scene coordinates such that 1 item size units
corresponds to 1 scene size unit. Also, the shape is scaled*/
void setSceneRect( const QRectF& rectangle );

/**Sets radius for rounded rectangle corners. Added in v2.1 */
void setCornerRadius( double radius );
/**Returns the radius for rounded rectangle corners*/
double cornerRadius() const;

/**Sets the QgsFillSymbolV2 used to draw the shape. Must also call setUseSymbolV2( true ) to
* enable drawing with a symbol.
* Note: added in version 2.1*/
void setShapeStyleSymbol( QgsFillSymbolV2* symbol );
/**Returns the QgsFillSymbolV2 used to draw the shape.
* Note: added in version 2.1*/
QgsFillSymbolV2* shapeStyleSymbol();

public slots:
/**Sets item rotation and resizes item bounds such that the shape always has the same size*/
virtual void setItemRotation( double r );
/**Controls whether the shape should be drawn using a QgsFillSymbolV2.
* Note: Added in v2.1 */
void setUseSymbolV2( bool useSymbolV2 );

protected:
/* reimplement drawFrame, since it's not a rect, but a custom shape */
Expand Down
10 changes: 10 additions & 0 deletions src/app/composer/qgscomposeritemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ QgsComposerItemWidget::~QgsComposerItemWidget()

}

void QgsComposerItemWidget::showBackgroundGroup( bool showGroup )
{
mBackgroundGroupBox->setVisible( showGroup );
}

void QgsComposerItemWidget::showFrameGroup( bool showGroup )
{
mFrameGroupBox->setVisible( showGroup );
}

//slots
void QgsComposerItemWidget::on_mFrameColorButton_clicked()
{
Expand Down
4 changes: 4 additions & 0 deletions src/app/composer/qgscomposeritemwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class QgsComposerItemWidget: public QWidget, private Ui::QgsComposerItemWidgetBa
/**A combination of upper/middle/lower and left/middle/right*/
QgsComposerItem::ItemPositionMode positionMode() const;

/**Toggles display of the background group*/
void showBackgroundGroup( bool showGroup );
/**Toggles display of the frame group*/
void showFrameGroup( bool showGroup );

public slots:
void on_mFrameColorButton_clicked();
Expand Down
43 changes: 43 additions & 0 deletions src/app/composer/qgscomposershapewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include "qgscomposershapewidget.h"
#include "qgscomposershape.h"
#include "qgscomposeritemwidget.h"
#include "qgscomposition.h"
#include "qgsstylev2.h"
#include "qgssymbolv2selectordialog.h"
#include "qgssymbollayerv2utils.h"
#include <QColorDialog>

QgsComposerShapeWidget::QgsComposerShapeWidget( QgsComposerShape* composerShape ): QWidget( 0 ), mComposerShape( composerShape )
Expand All @@ -26,6 +30,11 @@ QgsComposerShapeWidget::QgsComposerShapeWidget( QgsComposerShape* composerShape

//add widget for general composer item properties
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, composerShape );

//shapes don't use background or frame, since the symbol style is set through a QgsSymbolV2SelectorDialog
itemPropertiesWidget->showBackgroundGroup( false );
itemPropertiesWidget->showFrameGroup( false );

mainLayout->addWidget( itemPropertiesWidget );

blockAllSignals( true );
Expand Down Expand Up @@ -54,6 +63,7 @@ void QgsComposerShapeWidget::blockAllSignals( bool block )
{
mShapeComboBox->blockSignals( block );
mCornerRadiusSpinBox->blockSignals( block );
mShapeStyleButton->blockSignals( block );
}

void QgsComposerShapeWidget::setGuiElementValues()
Expand All @@ -65,6 +75,8 @@ void QgsComposerShapeWidget::setGuiElementValues()

blockAllSignals( true );

updateShapeStyle();

mCornerRadiusSpinBox->setValue( mComposerShape->cornerRadius() );
if ( mComposerShape->shapeType() == QgsComposerShape::Ellipse )
{
Expand All @@ -85,6 +97,37 @@ void QgsComposerShapeWidget::setGuiElementValues()
blockAllSignals( false );
}

void QgsComposerShapeWidget::on_mShapeStyleButton_clicked()
{
if ( !mComposerShape )
{
return;
}

QgsVectorLayer* coverageLayer = 0;
// use the atlas coverage layer, if any
if ( mComposerShape->composition()->atlasComposition().enabled() )
{
coverageLayer = mComposerShape->composition()->atlasComposition().coverageLayer();
}

QgsSymbolV2SelectorDialog d( mComposerShape->shapeStyleSymbol(), QgsStyleV2::defaultStyle(), coverageLayer );

if ( d.exec() == QDialog::Accepted )
{
updateShapeStyle();
}
}

void QgsComposerShapeWidget::updateShapeStyle()
{
if ( mComposerShape )
{
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mComposerShape->shapeStyleSymbol(), mShapeStyleButton->iconSize() );
mShapeStyleButton->setIcon( icon );
}
}

void QgsComposerShapeWidget::on_mCornerRadiusSpinBox_valueChanged( double val )
{
if ( mComposerShape )
Expand Down
3 changes: 3 additions & 0 deletions src/app/composer/qgscomposershapewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ class QgsComposerShapeWidget: public QWidget, private Ui::QgsComposerShapeWidget
private slots:
void on_mShapeComboBox_currentIndexChanged( const QString& text );
void on_mCornerRadiusSpinBox_valueChanged( double val );
void on_mShapeStyleButton_clicked();

/**Sets the GUI elements to the currentValues of mComposerShape*/
void setGuiElementValues();

void updateShapeStyle();

/**Enables or disables the rounded radius spin box based on shape type*/
void toggleRadiusSpin( const QString& shapeText );
};
Expand Down
9 changes: 9 additions & 0 deletions src/core/composer/qgsatlascomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "qgsexpression.h"
#include "qgsgeometry.h"
#include "qgscomposerlabel.h"
#include "qgscomposershape.h"
#include "qgspaperitem.h"
#include "qgsmaplayerregistry.h"

Expand Down Expand Up @@ -375,6 +376,14 @@ void QgsAtlasComposition::prepareForFeature( int featureI )
( *lit )->setExpressionContext( &mCurrentFeature, mCoverageLayer );
}

// update shapes (in case they use data defined symbology with atlas properties)
QList<QgsComposerShape*> shapes;
mComposition->composerItems( shapes );
for ( QList<QgsComposerShape*>::iterator lit = shapes.begin(); lit != shapes.end(); ++lit )
{
( *lit )->update();
}

// update page background (in case it uses data defined symbology with atlas properties)
QList<QgsPaperItem*> pages;
mComposition->composerItems( pages );
Expand Down
Loading