[QGIS Commit] r12183 - in trunk/qgis: images/themes/default python/core src/app src/app/composer src/core src/core/composer src/gui src/ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Nov 19 04:04:40 EST 2009


Author: mhugent
Date: 2009-11-19 04:04:33 -0500 (Thu, 19 Nov 2009)
New Revision: 12183

Added:
   trunk/qgis/images/themes/default/mActionAddBasicShape.png
   trunk/qgis/python/core/qgscomposershape.sip
   trunk/qgis/src/app/composer/qgscomposershapewidget.cpp
   trunk/qgis/src/app/composer/qgscomposershapewidget.h
   trunk/qgis/src/core/composer/qgscomposershape.cpp
   trunk/qgis/src/core/composer/qgscomposershape.h
   trunk/qgis/src/ui/qgscomposershapewidgetbase.ui
Modified:
   trunk/qgis/python/core/qgscomposeritem.sip
   trunk/qgis/python/core/qgscomposerlegend.sip
   trunk/qgis/python/core/qgscomposermap.sip
   trunk/qgis/python/core/qgscomposerpicture.sip
   trunk/qgis/python/core/qgscomposerscalebar.sip
   trunk/qgis/src/app/CMakeLists.txt
   trunk/qgis/src/app/composer/qgscomposer.cpp
   trunk/qgis/src/app/composer/qgscomposer.h
   trunk/qgis/src/app/composer/qgscomposermapwidget.cpp
   trunk/qgis/src/app/composer/qgscomposerpicturewidget.cpp
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/core/CMakeLists.txt
   trunk/qgis/src/core/composer/qgscomposeritem.cpp
   trunk/qgis/src/core/composer/qgscomposeritem.h
   trunk/qgis/src/core/composer/qgscomposeritemgroup.h
   trunk/qgis/src/core/composer/qgscomposerlegend.h
   trunk/qgis/src/core/composer/qgscomposermap.cpp
   trunk/qgis/src/core/composer/qgscomposermap.h
   trunk/qgis/src/core/composer/qgscomposerpicture.cpp
   trunk/qgis/src/core/composer/qgscomposerpicture.h
   trunk/qgis/src/core/composer/qgscomposerscalebar.h
   trunk/qgis/src/gui/qgscomposerview.cpp
   trunk/qgis/src/gui/qgscomposerview.h
   trunk/qgis/src/ui/qgscomposerbase.ui
Log:
Add a new composer item to draw basic shapes (atm ellipse, rectangle, triangle), fix some composer related bugs and bring rotation to composer item level

Added: trunk/qgis/images/themes/default/mActionAddBasicShape.png
===================================================================
(Binary files differ)


Property changes on: trunk/qgis/images/themes/default/mActionAddBasicShape.png
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + application/octet-stream

Modified: trunk/qgis/python/core/qgscomposeritem.sip
===================================================================
--- trunk/qgis/python/core/qgscomposeritem.sip	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/python/core/qgscomposeritem.sip	2009-11-19 09:04:33 UTC (rev 12183)
@@ -1,7 +1,7 @@
 /** \ingroup MapComposer
  * A item that forms part of a map composition.
  */
-class QgsComposerItem: QGraphicsRectItem
+class QgsComposerItem: public QObject, public QGraphicsRectItem
 {
 %TypeHeaderCode
 #include <qgscomposeritem.h>
@@ -130,6 +130,23 @@
     /**Returns a font where size is in pixel and font size is upscaled with FONT_WORKAROUND_SCALE*/
     QFont scaledFontPixelSize( const QFont& font ) const;
 
+    /**Locks / unlocks the item position for mouse drags
+    @note this method was added in version 1.2*/
+    void setPositionLock( bool lock );
+
+    /**Returns position lock for mouse drags (true means locked)
+    @note this method was added in version 1.2*/
+    bool positionLock() const;
+
+    /**Update mouse cursor at (item) position
+    @note this method was added in version 1.2*/
+    void updateCursor( const QPointF& itemPos );
+
+    double rotation() const;
+
+  public slots:
+    void setRotation( double r);
+
   protected:
 
     //event handlers
@@ -163,4 +180,28 @@
 
     /**Draw background*/
     virtual void drawBackground( QPainter* p );
-};
\ No newline at end of file
+
+    /**Returns the current (zoom level dependent) tolerance to decide if mouse position is close enough to the \
+    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;
+
+    /**Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation*/
+    bool imageSizeConsideringRotation( double& width, double& height ) const;
+    /**Calculates corner point after rotation and scaling*/
+    bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const;
+    /**Returns a point on the line from startPoint to directionPoint that is a certain distance away from the starting point*/
+    QPointF pointOnLineWithDistance( const QPointF& startPoint, const QPointF& directionPoint, double distance ) const;
+
+    signals:
+     /**Is emitted on rotation change to notify north arrow pictures*/
+    void rotationChanged( double newRotation );
+};

Modified: trunk/qgis/python/core/qgscomposerlegend.sip
===================================================================
--- trunk/qgis/python/core/qgscomposerlegend.sip	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/python/core/qgscomposerlegend.sip	2009-11-19 09:04:33 UTC (rev 12183)
@@ -1,7 +1,7 @@
 /** \ingroup MapComposer
  * A legend that can be placed onto a map composition
  */
-class QgsComposerLegend: QObject, QgsComposerItem
+class QgsComposerLegend: QgsComposerItem
 {
 %TypeHeaderCode
 #include <qgscomposerlegend.h>

Modified: trunk/qgis/python/core/qgscomposermap.sip
===================================================================
--- trunk/qgis/python/core/qgscomposermap.sip	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/python/core/qgscomposermap.sip	2009-11-19 09:04:33 UTC (rev 12183)
@@ -3,7 +3,7 @@
  *  \brief Object representing map window.
  */
 // NOTE: QgsComposerMapBase must be first, otherwise does not compile
-class QgsComposerMap : QObject, QgsComposerItem
+class QgsComposerMap : QgsComposerItem
 {
 %TypeHeaderCode
 #include <qgscomposermap.h>
@@ -211,11 +211,6 @@
     @note this function was added in version 1.4*/
     void updateBoundingRect();
 
-    /**Sets the rotation of the map content
-    @note this function was added in version 1.4*/
-    void setRotation(double r);
-    double rotation() const;
-
     /**Sets length of the cros segments (if grid style is cross)
     @note this function was added in version 1.4*/
     void setCrossLength(double l);
@@ -231,6 +226,4 @@
   signals:
     /**Is emitted when width/height is changed as a result of user interaction*/
     void extentChanged();
-    /**Is emitted on rotation change to notify north arrow pictures*/
-    void rotationChanged( double newRotation );
 };

Modified: trunk/qgis/python/core/qgscomposerpicture.sip
===================================================================
--- trunk/qgis/python/core/qgscomposerpicture.sip	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/python/core/qgscomposerpicture.sip	2009-11-19 09:04:33 UTC (rev 12183)
@@ -1,7 +1,7 @@
 /** \ingroup MapComposer
  * A composer class that displays svg files or raster format (jpg, png, ...)
  * */
-class QgsComposerPicture: QObject, QgsComposerItem
+class QgsComposerPicture: QgsComposerItem
 {
 
 %TypeHeaderCode
@@ -23,10 +23,6 @@
        corresponds to 1 scene size unit*/
     void setSceneRect( const QRectF& rectangle );
 
-    void setRotation( double rotation );
-
-    double rotation() const;
-
     /** stores state in Dom node
        * @param node is Dom node corresponding to 'Composer' tag
        * @param temp write template file

Modified: trunk/qgis/python/core/qgscomposerscalebar.sip
===================================================================
--- trunk/qgis/python/core/qgscomposerscalebar.sip	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/python/core/qgscomposerscalebar.sip	2009-11-19 09:04:33 UTC (rev 12183)
@@ -2,7 +2,7 @@
  * A scale bar item that can be added to a map composition.
  */
 
-class QgsComposerScaleBar: QObject, QgsComposerItem
+class QgsComposerScaleBar: QgsComposerItem
 {
 %TypeHeaderCode
 #include "qgscomposerscalebar.h"

Added: trunk/qgis/python/core/qgscomposershape.sip
===================================================================
--- trunk/qgis/python/core/qgscomposershape.sip	                        (rev 0)
+++ trunk/qgis/python/core/qgscomposershape.sip	2009-11-19 09:04:33 UTC (rev 12183)
@@ -0,0 +1,43 @@
+/**A composer items that draws common shapes (ellipse, triangle, rectangle)*/
+class QgsComposerShape: public QgsComposerItem
+{
+%TypeHeaderCode
+#include "qgscomposershape.h"
+%End
+  public:
+
+    enum Shape
+    {
+      Ellipse,
+      Rectangle,
+      Triangle
+    };
+
+    QgsComposerShape( QgsComposition* composition /TransferThis/);
+    QgsComposerShape( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition );
+    ~QgsComposerShape();
+
+    /** \brief Reimplementation of QCanvasItem::paint - draw on canvas */
+    void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
+
+    /** stores state in Dom node
+     * @param node is Dom node corresponding to 'Composer' tag
+     * @param temp write template file
+     */
+    bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
+
+    /** sets state from Dom document
+     * @param itemElem is Dom node corresponding to item tag
+     */
+    bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+
+    //setters and getters
+    void setLineWidth( double width );
+    double lineWidth() const;
+    void setOutlineColor( const QColor& color );
+    QColor outlineColor() const;
+    void setFillColor( const QColor& color );
+    QColor fillColor() const;
+    QgsComposerShape::Shape shapeType() const;
+    void setShapeType( QgsComposerShape::Shape s );
+}; 

Modified: trunk/qgis/src/app/CMakeLists.txt
===================================================================
--- trunk/qgis/src/app/CMakeLists.txt	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/app/CMakeLists.txt	2009-11-19 09:04:33 UTC (rev 12183)
@@ -80,6 +80,7 @@
   composer/qgscomposermanager.cpp
   composer/qgscomposermapwidget.cpp
   composer/qgscomposerscalebarwidget.cpp
+  composer/qgscomposershapewidget.cpp
   composer/qgscomposerlegenditemdialog.cpp
   composer/qgscomposerlegendwidget.cpp
   composer/qgscompositionwidget.cpp
@@ -179,6 +180,7 @@
   composer/qgscomposermapwidget.h
   composer/qgscomposerpicturewidget.h
   composer/qgscomposerscalebarwidget.h
+  composer/qgscomposershapewidget.h
   composer/qgscompositionwidget.h
   composer/qgsitempositiondialog.h
 

Modified: trunk/qgis/src/app/composer/qgscomposer.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposer.cpp	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/app/composer/qgscomposer.cpp	2009-11-19 09:04:33 UTC (rev 12183)
@@ -31,6 +31,8 @@
 #include "qgscomposerpicturewidget.h"
 #include "qgscomposerscalebar.h"
 #include "qgscomposerscalebarwidget.h"
+#include "qgscomposershape.h"
+#include "qgscomposershapewidget.h"
 #include "qgsexception.h"
 #include "qgsproject.h"
 #include "qgsmapcanvas.h"
@@ -106,6 +108,7 @@
   toggleActionGroup->addAction( mActionAddNewScalebar );
   toggleActionGroup->addAction( mActionAddImage );
   toggleActionGroup->addAction( mActionSelectMoveItem );
+  toggleActionGroup->addAction( mActionAddBasicShape );
   toggleActionGroup->setExclusive( true );
 
   mActionAddNewMap->setCheckable( true );
@@ -115,6 +118,7 @@
   mActionAddNewScalebar->setCheckable( true );
   mActionAddImage->setCheckable( true );
   mActionMoveItemContent->setCheckable( true );
+  mActionAddBasicShape->setCheckable( true );
 
 #ifdef Q_WS_MAC
   QMenu *appMenu = menuBar()->addMenu( tr( "QGIS" ) );
@@ -150,6 +154,7 @@
   layoutMenu->addAction( mActionAddImage );
   layoutMenu->addAction( mActionSelectMoveItem );
   layoutMenu->addAction( mActionMoveItemContent );
+  layoutMenu->addAction( mActionAddBasicShape );
   layoutMenu->addSeparator();
   layoutMenu->addAction( mActionGroupItems );
   layoutMenu->addAction( mActionUngroupItems );
@@ -243,6 +248,7 @@
   mActionAddNewLabel->setIcon( QgisApp::getThemeIcon( "/mActionLabel.png" ) );
   mActionAddNewLegend->setIcon( QgisApp::getThemeIcon( "/mActionAddLegend.png" ) );
   mActionAddNewScalebar->setIcon( QgisApp::getThemeIcon( "/mActionScaleBar.png" ) );
+  mActionAddBasicShape->setIcon( QgisApp::getThemeIcon( "/mActionAddBasicShape.png" ) );
   mActionSelectMoveItem->setIcon( QgisApp::getThemeIcon( "/mActionSelectPan.png" ) );
   mActionMoveItemContent->setIcon( QgisApp::getThemeIcon( "/mActionMoveItemContent.png" ) );
   mActionGroupItems->setIcon( QgisApp::getThemeIcon( "/mActionGroupItems.png" ) );
@@ -268,6 +274,7 @@
   connect( mView, SIGNAL( composerScaleBarAdded( QgsComposerScaleBar* ) ), this, SLOT( addComposerScaleBar( QgsComposerScaleBar* ) ) );
   connect( mView, SIGNAL( composerLegendAdded( QgsComposerLegend* ) ), this, SLOT( addComposerLegend( QgsComposerLegend* ) ) );
   connect( mView, SIGNAL( composerPictureAdded( QgsComposerPicture* ) ), this, SLOT( addComposerPicture( QgsComposerPicture* ) ) );
+  connect( mView, SIGNAL( composerShapeAdded( QgsComposerShape* ) ), this, SLOT( addComposerShape( QgsComposerShape* ) ) );
   connect( mView, SIGNAL( actionFinished() ), this, SLOT( setSelectionTool() ) );
 }
 
@@ -330,6 +337,10 @@
 {
   mTitle = title;
   setWindowTitle( mTitle );
+  if ( mWindowAction )
+  {
+    mWindowAction->setText( title );
+  }
 }
 
 void QgsComposer::showCompositionOptions( QWidget *w )
@@ -786,6 +797,14 @@
   }
 }
 
+void QgsComposer::on_mActionAddBasicShape_triggered()
+{
+  if ( mView )
+  {
+    mView->setCurrentTool( QgsComposerView::AddShape );
+  }
+}
+
 void QgsComposer::on_mActionSaveAsTemplate_triggered()
 {
   //show file dialog
@@ -1015,6 +1034,16 @@
 {
   QDomElement composerElem = doc.createElement( "Composer" );
   composerElem.setAttribute( "title", mTitle );
+
+  //store if composer is open or closed
+  if ( isVisible() )
+  {
+    composerElem.setAttribute( "visible", 1 );
+  }
+  else
+  {
+    composerElem.setAttribute( "visible", 0 );
+  }
   parentNode.appendChild( composerElem );
 
   //store composer items:
@@ -1173,6 +1202,21 @@
     showItemOptions( newPicture );
   }
 
+  //composer shapes
+  QDomNodeList composerShapeList = composerElem.elementsByTagName( "ComposerShape" );
+  for ( int i = 0; i < composerShapeList.size(); ++i )
+  {
+    QDomElement currentShapeElem = composerShapeList.at( i ).toElement();
+    QgsComposerShape* newShape = new QgsComposerShape( mComposition );
+    newShape->readXML( currentShapeElem, doc );
+    addComposerShape( newShape );
+    mComposition->addItem( newShape );
+    mComposition->update();
+    mComposition->clearSelection();
+    newShape->setSelected( true );
+    showItemOptions( newShape );
+  }
+
   mComposition->sortZList();
   mView->setComposition( mComposition );
 
@@ -1247,6 +1291,16 @@
   mItemWidgetMap.insert( picture, pWidget );
 }
 
+void QgsComposer::addComposerShape( QgsComposerShape* shape )
+{
+  if ( !shape )
+  {
+    return;
+  }
+  QgsComposerShapeWidget* sWidget = new QgsComposerShapeWidget( shape );
+  mItemWidgetMap.insert( shape, sWidget );
+}
+
 void QgsComposer::deleteItem( QgsComposerItem* item )
 {
   QMap<QgsComposerItem*, QWidget*>::iterator it = mItemWidgetMap.find( item );

Modified: trunk/qgis/src/app/composer/qgscomposer.h
===================================================================
--- trunk/qgis/src/app/composer/qgscomposer.h	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/app/composer/qgscomposer.h	2009-11-19 09:04:33 UTC (rev 12183)
@@ -27,6 +27,7 @@
 class QgsComposerMap;
 class QgsComposerPicture;
 class QgsComposerScaleBar;
+class QgsComposerShape;
 class QgsComposerView;
 class QgsComposition;
 class QgsMapCanvas;
@@ -142,6 +143,9 @@
     //! Add new picture
     void on_mActionAddImage_triggered();
 
+    //! Add ellipse shape item
+    void on_mActionAddBasicShape_triggered();
+
     //! Save composer as template
     void on_mActionSaveAsTemplate_triggered();
 
@@ -204,6 +208,9 @@
     /**Adds a composer picture to the item/widget map and creates a configuration widget*/
     void addComposerPicture( QgsComposerPicture* picture );
 
+    /**Adds a composer shape to the item/widget map and creates a configuration widget*/
+    void addComposerShape( QgsComposerShape* shape );
+
     /**Removes item from the item/widget map and deletes the configuration widget*/
     void deleteItem( QgsComposerItem* item );
 

Modified: trunk/qgis/src/app/composer/qgscomposermapwidget.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposermapwidget.cpp	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/app/composer/qgscomposermapwidget.cpp	2009-11-19 09:04:33 UTC (rev 12183)
@@ -162,7 +162,7 @@
     return;
   }
 
-  mComposerMap->setRotation( value );
+  mComposerMap->setMapRotation( value );
   mComposerMap->cache();
   mComposerMap->update();
 }

Modified: trunk/qgis/src/app/composer/qgscomposerpicturewidget.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposerpicturewidget.cpp	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/app/composer/qgscomposerpicturewidget.cpp	2009-11-19 09:04:33 UTC (rev 12183)
@@ -46,6 +46,7 @@
   //add preview icons
   addStandardDirectoriesToPreview();
   connect( mPicture, SIGNAL( settingsChanged() ), this, SLOT( setGuiElementValues() ) );
+  connect( mPicture, SIGNAL( rotationChanged( double ) ), this, SLOT( setGuiElementValues() ) );
 }
 
 QgsComposerPictureWidget::~QgsComposerPictureWidget()

Added: trunk/qgis/src/app/composer/qgscomposershapewidget.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposershapewidget.cpp	                        (rev 0)
+++ trunk/qgis/src/app/composer/qgscomposershapewidget.cpp	2009-11-19 09:04:33 UTC (rev 12183)
@@ -0,0 +1,178 @@
+/***************************************************************************
+                         qgscomposershapewidget.cpp
+                         --------------------------
+    begin                : November 2009
+    copyright            : (C) 2009 by Marco Hugentobler
+    email                : marco at hugis.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program 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.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "qgscomposershapewidget.h"
+#include "qgscomposershape.h"
+#include "qgscomposeritemwidget.h"
+#include <QColorDialog>
+
+QgsComposerShapeWidget::QgsComposerShapeWidget( QgsComposerShape* composerShape ): QWidget( 0 ), mComposerShape( composerShape )
+{
+  setupUi( this );
+  QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, composerShape );
+  gridLayout->addWidget( itemPropertiesWidget, 6, 0, 1, 1 );
+
+  blockAllSignals( true );
+
+  //shape types
+  mShapeComboBox->addItem( tr( "Ellipse" ) );
+  mShapeComboBox->addItem( tr( "Rectangle" ) );
+  mShapeComboBox->addItem( tr( "Triangle" ) );
+
+  setGuiElementValues();
+
+  blockAllSignals( false );
+}
+
+QgsComposerShapeWidget::~QgsComposerShapeWidget()
+{
+
+}
+
+void QgsComposerShapeWidget::blockAllSignals( bool block )
+{
+  mShapeComboBox->blockSignals( block );
+  mOutlineColorButton->blockSignals( block );
+  mOutlineWidthSpinBox->blockSignals( block );
+  mFillColorButton->blockSignals( block );
+  mRotationSpinBox->blockSignals( block );
+  mTransparentCheckBox->blockSignals( block );
+}
+
+void QgsComposerShapeWidget::setGuiElementValues()
+{
+  if ( !mComposerShape )
+  {
+    return;
+  }
+  mOutlineWidthSpinBox->setValue( mComposerShape->lineWidth() );
+  mRotationSpinBox->setValue( mComposerShape->rotation() );
+  if ( mComposerShape->shapeType() == QgsComposerShape::Ellipse )
+  {
+    mShapeComboBox->setCurrentIndex( mShapeComboBox->findText( tr( "Ellipse" ) ) );
+  }
+  else if ( mComposerShape->shapeType() == QgsComposerShape::Rectangle )
+  {
+    mShapeComboBox->setCurrentIndex( mShapeComboBox->findText( tr( "Rectangle" ) ) );
+  }
+  else if ( mComposerShape->shapeType() == QgsComposerShape::Triangle )
+  {
+    mShapeComboBox->setCurrentIndex( mShapeComboBox->findText( tr( "Triangle" ) ) );
+  }
+
+  if ( mComposerShape->transparentFill() )
+  {
+    mTransparentCheckBox->setCheckState( Qt::Checked );
+    mFillColorButton->setEnabled( false );
+  }
+  else
+  {
+    mTransparentCheckBox->setCheckState( Qt::Unchecked );
+    mFillColorButton->setEnabled( true );
+  }
+}
+
+void QgsComposerShapeWidget::on_mRotationSpinBox_valueChanged( int val )
+{
+  if ( mComposerShape )
+  {
+    mComposerShape->setRotation( val );
+    mComposerShape->update();
+  }
+}
+
+void QgsComposerShapeWidget::on_mShapeComboBox_currentIndexChanged( const QString& text )
+{
+  if ( !mComposerShape )
+  {
+    return;
+  }
+
+  if ( text == tr( "Ellipse" ) )
+  {
+    mComposerShape->setShapeType( QgsComposerShape::Ellipse );
+  }
+  else if ( text == tr( "Rectangle" ) )
+  {
+    mComposerShape->setShapeType( QgsComposerShape::Rectangle );
+  }
+  else if ( text == tr( "Triangle" ) )
+  {
+    mComposerShape->setShapeType( QgsComposerShape::Triangle );
+  }
+  mComposerShape->update();
+}
+
+void QgsComposerShapeWidget::on_mOutlineColorButton_clicked()
+{
+  if ( !mComposerShape )
+  {
+    return;
+  }
+  QColor existingColor = mComposerShape->outlineColor();
+  QColor newColor = QColorDialog::getColor( existingColor, 0 );
+  if ( newColor.isValid() )
+  {
+    mComposerShape->setOutlineColor( newColor );
+    mComposerShape->update();
+  }
+}
+
+void QgsComposerShapeWidget::on_mOutlineWidthSpinBox_valueChanged( double d )
+{
+  if ( !mComposerShape )
+  {
+    return;
+  }
+  mComposerShape->setLineWidth( d );
+  mComposerShape->update();
+}
+
+void QgsComposerShapeWidget::on_mTransparentCheckBox_stateChanged( int state )
+{
+  if ( !mComposerShape )
+  {
+    return;
+  }
+
+  if ( state == Qt::Checked )
+  {
+    mComposerShape->setTransparentFill( true );
+    mFillColorButton->setEnabled( false );
+  }
+  else
+  {
+    mComposerShape->setTransparentFill( false );
+    mFillColorButton->setEnabled( true );
+  }
+  mComposerShape->update();
+}
+
+void QgsComposerShapeWidget::on_mFillColorButton_clicked()
+{
+  if ( !mComposerShape )
+  {
+    return;
+  }
+  QColor existingColor = mComposerShape->fillColor();
+  QColor newColor = QColorDialog::getColor( existingColor, 0 );
+  if ( newColor.isValid() )
+  {
+    mComposerShape->setFillColor( newColor );
+    mComposerShape->update();
+  }
+}

Added: trunk/qgis/src/app/composer/qgscomposershapewidget.h
===================================================================
--- trunk/qgis/src/app/composer/qgscomposershapewidget.h	                        (rev 0)
+++ trunk/qgis/src/app/composer/qgscomposershapewidget.h	2009-11-19 09:04:33 UTC (rev 12183)
@@ -0,0 +1,50 @@
+/***************************************************************************
+                         qgscomposershapewidget.h
+                         ------------------------
+    begin                : November 2009
+    copyright            : (C) 2009 by Marco Hugentobler
+    email                : marco at hugis.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program 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.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef QGSCOMPOSERSHAPEWIDGET_H
+#define QGSCOMPOSERSHAPEWIDGET_H
+
+#include "ui_qgscomposershapewidgetbase.h"
+
+class QgsComposerShape;
+
+/**Input widget for QgsComposerShape*/
+class QgsComposerShapeWidget: public QWidget, private Ui::QgsComposerShapeWidgetBase
+{
+    Q_OBJECT
+  public:
+    QgsComposerShapeWidget( QgsComposerShape* composerShape );
+    ~QgsComposerShapeWidget();
+
+  private:
+    QgsComposerShape* mComposerShape;
+
+    /**Blocks / unblocks the signal of all GUI elements*/
+    void blockAllSignals( bool block );
+    /**Sets the GUI elements to the currentValues of mComposerShape*/
+    void setGuiElementValues();
+
+  private slots:
+    void on_mShapeComboBox_currentIndexChanged( const QString& text );
+    void on_mOutlineColorButton_clicked();
+    void on_mOutlineWidthSpinBox_valueChanged( double d );
+    void on_mTransparentCheckBox_stateChanged( int state );
+    void on_mFillColorButton_clicked();
+    void on_mRotationSpinBox_valueChanged( int val );
+};
+
+#endif // QGSCOMPOSERSHAPEWIDGET_H

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/app/qgisapp.cpp	2009-11-19 09:04:33 UTC (rev 12183)
@@ -4261,6 +4261,10 @@
     composer->showMinimized();
 #endif
     composer->zoomFull();
+    if ( composerNodes.at( i ).toElement().attribute( "visible", "1" ).toInt() < 1 )
+    {
+      composer->close();
+    }
   }
   return true;
 }

Modified: trunk/qgis/src/core/CMakeLists.txt
===================================================================
--- trunk/qgis/src/core/CMakeLists.txt	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/core/CMakeLists.txt	2009-11-19 09:04:33 UTC (rev 12183)
@@ -76,6 +76,7 @@
   composer/qgscomposerpicture.cpp
   composer/qgscomposermap.cpp
   composer/qgscomposerscalebar.cpp
+  composer/qgscomposershape.cpp
   composer/qgslegendmodel.cpp
   composer/qgscomposerlegend.cpp
   composer/qgspaperitem.cpp
@@ -198,6 +199,7 @@
 composer/qgscomposermap.h
 composer/qgscomposerpicture.h
 composer/qgscomposerscalebar.h
+composer/qgscomposeritem.h
 composer/qgscomposeritemgroup.h
 composer/qgscomposition.h
 composer/qgslegendmodel.h

Modified: trunk/qgis/src/core/composer/qgscomposeritem.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposeritem.cpp	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/core/composer/qgscomposeritem.cpp	2009-11-19 09:04:33 UTC (rev 12183)
@@ -31,10 +31,16 @@
 #include "qgsrectangle.h" //just for debugging
 #include "qgslogger.h"
 
+#ifndef Q_OS_MACX
+#include <cmath>
+#else
+#include <math.h>
+#endif
+
 #define FONT_WORKAROUND_SCALE 10 //scale factor for upscaling fontsize and downscaling painter
 
-QgsComposerItem::QgsComposerItem( QgsComposition* composition, bool manageZValue ): QGraphicsRectItem( 0 ), mComposition( composition ), mBoundingResizeRectangle( 0 ), \
-    mFrame( true ), mItemPositionLocked( false ), mLastValidViewScaleFactor( -1 )
+QgsComposerItem::QgsComposerItem( QgsComposition* composition, bool manageZValue ): QObject( 0 ), QGraphicsRectItem( 0 ), mComposition( composition ), mBoundingResizeRectangle( 0 ), \
+    mFrame( true ), mItemPositionLocked( false ), mLastValidViewScaleFactor( -1 ), mRotation( 0 )
 {
   setFlag( QGraphicsItem::ItemIsSelectable, true );
   setAcceptsHoverEvents( true );
@@ -53,7 +59,8 @@
 }
 
 QgsComposerItem::QgsComposerItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition, bool manageZValue ): \
-    QGraphicsRectItem( 0, 0, width, height, 0 ), mComposition( composition ), mBoundingResizeRectangle( 0 ), mFrame( true ), mItemPositionLocked( false ), mLastValidViewScaleFactor( -1 )
+    QObject( 0 ), QGraphicsRectItem( 0, 0, width, height, 0 ), mComposition( composition ), mBoundingResizeRectangle( 0 ), mFrame( true ), \
+    mItemPositionLocked( false ), mLastValidViewScaleFactor( -1 ), mRotation( 0 )
 {
   setFlag( QGraphicsItem::ItemIsSelectable, true );
   setAcceptsHoverEvents( true );
@@ -124,6 +131,7 @@
   composerItemElem.setAttribute( "height", rect().height() );
   composerItemElem.setAttribute( "zValue", QString::number( zValue() ) );
   composerItemElem.setAttribute( "outlineWidth", QString::number( pen().widthF() ) );
+  composerItemElem.setAttribute( "rotation", mRotation );
 
   //position lock for mouse moves/resizes
   if ( mItemPositionLocked )
@@ -168,6 +176,9 @@
     return false;
   }
 
+  //rotation
+  mRotation = itemElem.attribute( "rotation", "0" ).toDouble();
+
   //frame
   QString frame = itemElem.attribute( "frame" );
   if ( frame.compare( "true", Qt::CaseInsensitive ) == 0 )
@@ -794,3 +805,147 @@
 {
   setCursor( cursorForPosition( itemPos ) );
 }
+
+void QgsComposerItem::setRotation( double r )
+{
+  if ( r > 360 )
+  {
+    mRotation = (( int )r ) % 360;
+  }
+  else
+  {
+    mRotation = r;
+  }
+  emit rotationChanged( r );
+  update();
+}
+
+bool QgsComposerItem::imageSizeConsideringRotation( double& width, double& height ) const
+{
+  if ( abs( mRotation ) <= 0 ) //width and height stays the same if there is no rotation
+  {
+    return true;
+  }
+
+  double x1 = 0;
+  double y1 = 0;
+  double x2 = width;
+  double y2 = 0;
+  double x3 = width;
+  double y3 = height;
+  double x4 = 0;
+  double y4 = height;
+  double midX = width / 2.0;
+  double midY = height / 2.0;
+
+  if ( !cornerPointOnRotatedAndScaledRect( x1, y1, width, height ) )
+  {
+    return false;
+  }
+  if ( !cornerPointOnRotatedAndScaledRect( x2, y2, width, height ) )
+  {
+    return false;
+  }
+  if ( !cornerPointOnRotatedAndScaledRect( x3, y3, width, height ) )
+  {
+    return false;
+  }
+  if ( !cornerPointOnRotatedAndScaledRect( x4, y4, width, height ) )
+  {
+    return false;
+  }
+
+
+  //assume points 1 and 3 are on the rectangle boundaries. Calculate 2 and 4.
+  double distM1 = sqrt(( x1 - midX ) * ( x1 - midX ) + ( y1 - midY ) * ( y1 - midY ) );
+  QPointF p2 = pointOnLineWithDistance( QPointF( midX, midY ), QPointF( x2, y2 ), distM1 );
+  QPointF p4 = pointOnLineWithDistance( QPointF( midX, midY ), QPointF( x4, y4 ), distM1 );
+
+  if ( p2.x() < width && p2.x() > 0 && p2.y() < height && p2.y() > 0 )
+  {
+    width = sqrt(( p2.x() - x1 ) * ( p2.x() - x1 ) + ( p2.y() - y1 ) * ( p2.y() - y1 ) );
+    height = sqrt(( x3 - p2.x() ) * ( x3 - p2.x() ) + ( y3 - p2.y() ) * ( y3 - p2.y() ) );
+    return true;
+  }
+
+  //else assume that points 2 and 4 are on the rectangle boundaries. Calculate 1 and 3
+  double distM2 = sqrt(( x2 - midX ) * ( x2 - midX ) + ( y2 - midY ) * ( y2 - midY ) );
+  QPointF p1 = pointOnLineWithDistance( QPointF( midX, midY ), QPointF( x1, y1 ), distM2 );
+  QPointF p3 = pointOnLineWithDistance( QPointF( midX, midY ), QPointF( x3, y3 ), distM2 );
+  width = sqrt(( x2 - p1.x() ) * ( x2 - p1.x() ) + ( y2 - p1.y() ) * ( y2 - p1.y() ) );
+  height = sqrt(( p3.x() - x2 ) * ( p3.x() - x2 ) + ( p3.y() - y2 ) * ( p3.y() - y2 ) );
+  return true;
+
+
+#if 0
+  double x1 = 0;
+  double y1 = 0;
+  double x2 = width;
+  double y2 = 0;
+  double x3 = width;
+  double y3 = height;
+
+  if ( !cornerPointOnRotatedAndScaledRect( x1, y1, width, height ) )
+  {
+    return false;
+  }
+  if ( !cornerPointOnRotatedAndScaledRect( x2, y2, width, height ) )
+  {
+    return false;
+  }
+  if ( !cornerPointOnRotatedAndScaledRect( x3, y3, width, height ) )
+  {
+    return false;
+  }
+
+  width = sqrt(( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) );
+  height = sqrt(( x3 - x2 ) * ( x3 - x2 ) + ( y3 - y2 ) * ( y3 - y2 ) );
+  return true;
+#endif //0
+}
+
+bool QgsComposerItem::cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const
+{
+  //first rotate point clockwise
+  double rotToRad = mRotation * M_PI / 180.0;
+  QPointF midpoint( width / 2.0, height / 2.0 );
+  double xVector = x - midpoint.x();
+  double yVector = y - midpoint.y();
+  //double xRotated = cos(rotToRad) * xVector + sin(rotToRad) * yVector;
+  //double yRotated = -sin(rotToRad) * xVector + cos(rotToRad) * yVector;
+  double xRotated = cos( rotToRad ) * xVector - sin( rotToRad ) * yVector;
+  double yRotated = sin( rotToRad ) * xVector + cos( rotToRad ) * yVector;
+
+  //create line from midpoint to rotated point
+  QLineF line( midpoint.x(), midpoint.y(), midpoint.x() + xRotated, midpoint.y() + yRotated );
+
+  //intersect with all four borders and return result
+  QList<QLineF> borders;
+  borders << QLineF( 0, 0, width, 0 );
+  borders << QLineF( width, 0, width, height );
+  borders << QLineF( width, height, 0, height );
+  borders << QLineF( 0, height, 0, 0 );
+
+  QList<QLineF>::const_iterator it = borders.constBegin();
+  QPointF intersectionPoint;
+
+  for ( ; it != borders.constEnd(); ++it )
+  {
+    if ( line.intersect( *it, &intersectionPoint ) == QLineF::BoundedIntersection )
+    {
+      x = intersectionPoint.x();
+      y = intersectionPoint.y();
+      return true;
+    }
+  }
+  return false;
+}
+
+QPointF QgsComposerItem::pointOnLineWithDistance( const QPointF& startPoint, const QPointF& directionPoint, double distance ) const
+{
+  double dx = directionPoint.x() - startPoint.x();
+  double dy = directionPoint.y() - startPoint.y();
+  double length = sqrt( dx * dx + dy * dy );
+  double scaleFactor = distance / length;
+  return QPointF( startPoint.x() + dx * scaleFactor, startPoint.y() + dy * scaleFactor );
+}

Modified: trunk/qgis/src/core/composer/qgscomposeritem.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposeritem.h	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/core/composer/qgscomposeritem.h	2009-11-19 09:04:33 UTC (rev 12183)
@@ -19,6 +19,7 @@
 
 #include "qgscomposition.h"
 #include <QGraphicsRectItem>
+#include <QObject>
 
 class QWidget;
 class QDomDocument;
@@ -29,9 +30,9 @@
 /** \ingroup MapComposer
  * A item that forms part of a map composition.
  */
-class CORE_EXPORT QgsComposerItem: public QGraphicsRectItem
+class CORE_EXPORT QgsComposerItem: public QObject, public QGraphicsRectItem
 {
-
+    Q_OBJECT
   public:
 
     /**Describes the action (move or resize in different directon) to be done during mouse move*/
@@ -168,6 +169,11 @@
     @note this method was added in version 1.2*/
     void updateCursor( const QPointF& itemPos );
 
+    double rotation() const {return mRotation;}
+
+  public slots:
+    void setRotation( double r );
+
   protected:
 
     QgsComposition* mComposition;
@@ -191,6 +197,9 @@
     /**Backup to restore item appearance if no view scale factor is available*/
     mutable double mLastValidViewScaleFactor;
 
+    /**Item rotation in degrees, clockwise*/
+    double mRotation;
+
     //event handlers
     virtual void mouseMoveEvent( QGraphicsSceneMouseEvent * event );
     virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
@@ -235,6 +244,17 @@
       @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;
+
+    /**Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation*/
+    bool imageSizeConsideringRotation( double& width, double& height ) const;
+    /**Calculates corner point after rotation and scaling*/
+    bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const;
+    /**Returns a point on the line from startPoint to directionPoint that is a certain distance away from the starting point*/
+    QPointF pointOnLineWithDistance( const QPointF& startPoint, const QPointF& directionPoint, double distance ) const;
+
+  signals:
+    /**Is emitted on rotation change to notify north arrow pictures*/
+    void rotationChanged( double newRotation );
 };
 
 #endif

Modified: trunk/qgis/src/core/composer/qgscomposeritemgroup.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposeritemgroup.h	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/core/composer/qgscomposeritemgroup.h	2009-11-19 09:04:33 UTC (rev 12183)
@@ -16,13 +16,12 @@
  ***************************************************************************/
 
 #include "qgscomposeritem.h"
-#include <QObject>
 #include <QSet>
 
 /** \ingroup MapComposer
  * A container for grouping several QgsComposerItems
  */
-class CORE_EXPORT QgsComposerItemGroup: public QObject, public QgsComposerItem
+class CORE_EXPORT QgsComposerItemGroup: public QgsComposerItem
 {
     Q_OBJECT
   public:

Modified: trunk/qgis/src/core/composer/qgscomposerlegend.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerlegend.h	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/core/composer/qgscomposerlegend.h	2009-11-19 09:04:33 UTC (rev 12183)
@@ -20,14 +20,13 @@
 
 #include "qgscomposeritem.h"
 #include "qgslegendmodel.h"
-#include <QObject>
 
 class QgsSymbol;
 
 /** \ingroup MapComposer
  * A legend that can be placed onto a map composition
  */
-class CORE_EXPORT QgsComposerLegend: public QObject, public QgsComposerItem
+class CORE_EXPORT QgsComposerLegend: public QgsComposerItem
 {
     Q_OBJECT
 

Modified: trunk/qgis/src/core/composer/qgscomposermap.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposermap.cpp	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/core/composer/qgscomposermap.cpp	2009-11-19 09:04:33 UTC (rev 12183)
@@ -42,8 +42,7 @@
 QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int width, int height )
     : QgsComposerItem( x, y, width, height, composition ), mKeepLayerSet( false ), mGridEnabled( false ), mGridStyle( Solid ), \
     mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mGridAnnotationPrecision( 3 ), mShowGridAnnotation( false ), \
-    mGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ), mGridAnnotationDirection( Horizontal ), \
-    mRotation( 0 ), mCrossLength( 3 )
+    mGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ), mGridAnnotationDirection( Horizontal ), mCrossLength( 3 )
 {
   mComposition = composition;
   mId = mComposition->composerMapItems().size();
@@ -74,8 +73,7 @@
 QgsComposerMap::QgsComposerMap( QgsComposition *composition )
     : QgsComposerItem( 0, 0, 10, 10, composition ), mKeepLayerSet( false ), mGridEnabled( false ), mGridStyle( Solid ), \
     mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mGridAnnotationPrecision( 3 ), mShowGridAnnotation( false ), \
-    mGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ), mGridAnnotationDirection( Horizontal ), \
-    mRotation( 0 ), mCrossLength( 3 )
+    mGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ), mGridAnnotationDirection( Horizontal ), mCrossLength( 3 )
 {
   //Offset
   mXOffset = 0.0;
@@ -505,9 +503,9 @@
   mYOffset = yOffset;
 }
 
-void QgsComposerMap::setRotation( double r )
+void QgsComposerMap::setMapRotation( double r )
 {
-  mRotation = r;
+  setRotation( r );
   emit rotationChanged( r );
 }
 
@@ -588,8 +586,6 @@
   {
     composerMapElem.setAttribute( "keepLayerSet", "false" );
   }
-  //rotation
-  composerMapElem.setAttribute( "rotation", mRotation );
 
   //extent
   QDomElement extentElem = doc.createElement( "Extent" );
@@ -670,9 +666,6 @@
     mPreviewMode = Rectangle;
   }
 
-  //rotation
-  mRotation = itemElem.attribute( "rotation", "0" ).toDouble();
-
   //extent
   QDomNodeList extentNodeList = itemElem.elementsByTagName( "Extent" );
   if ( extentNodeList.size() > 0 )
@@ -1400,6 +1393,7 @@
   y = yRot;
 }
 
+#if 0
 QPointF QgsComposerMap::pointOnLineWithDistance( const QPointF& startPoint, const QPointF& directionPoint, double distance ) const
 {
   double dx = directionPoint.x() - startPoint.x();
@@ -1408,3 +1402,4 @@
   double scaleFactor = distance / length;
   return QPointF( startPoint.x() + dx * scaleFactor, startPoint.y() + dy * scaleFactor );
 }
+#endif //0

Modified: trunk/qgis/src/core/composer/qgscomposermap.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposermap.h	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/core/composer/qgscomposermap.h	2009-11-19 09:04:33 UTC (rev 12183)
@@ -21,7 +21,6 @@
 #include "qgscomposeritem.h"
 #include "qgsrectangle.h"
 #include <QGraphicsRectItem>
-#include <QObject>
 
 class QgsComposition;
 class QgsMapRenderer;
@@ -35,7 +34,7 @@
  *  \brief Object representing map window.
  */
 // NOTE: QgsComposerMapBase must be first, otherwise does not compile
-class CORE_EXPORT QgsComposerMap : /*public QWidget, private Ui::QgsComposerMapBase,*/ public QObject, public QgsComposerItem
+class CORE_EXPORT QgsComposerMap : public QgsComposerItem
 {
     Q_OBJECT
 
@@ -239,16 +238,13 @@
     @note this function was added in version 1.4*/
     void updateBoundingRect();
 
-    /**Sets the rotation of the map content
-    @note this function was added in version 1.4*/
-    void setRotation( double r );
-    double rotation() const { return mRotation; }
-
     /**Sets length of the cros segments (if grid style is cross)
     @note this function was added in version 1.4*/
     void setCrossLength( double l ) {mCrossLength = l;}
     double crossLength() {return mCrossLength;}
 
+    void setMapRotation( double r );
+
   public slots:
 
     /**Called if map canvas has changed*/
@@ -259,8 +255,6 @@
   signals:
     /**Is emitted when width/height is changed as a result of user interaction*/
     void extentChanged();
-    /**Is emitted on rotation change to notify north arrow pictures*/
-    void rotationChanged( double newRotation );
 
   private:
 
@@ -345,9 +339,6 @@
     GridAnnotationDirection mGridAnnotationDirection;
     /**Current bounding rectangle. This is used to check if notification to the graphics scene is necessary*/
     QRectF mCurrentRectangle;
-
-    /**Rotation of the map. Clockwise in degrees, north direction is 0*/
-    double mRotation;
     /**The length of the cross sides for mGridStyle Cross*/
     double mCrossLength;
 
@@ -395,8 +386,10 @@
         @param x in/out: x coordinate before / after the rotation
         @param y in/out: y cooreinate before / after the rotation*/
     void rotate( double angle, double& x, double& y ) const;
+#if 0
     /**Returns a point on the line from startPoint to directionPoint that is a certain distance away from the starting point*/
     QPointF pointOnLineWithDistance( const QPointF& startPoint, const QPointF& directionPoint, double distance ) const;
+#endif //0
 };
 
 #endif

Modified: trunk/qgis/src/core/composer/qgscomposerpicture.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerpicture.cpp	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/core/composer/qgscomposerpicture.cpp	2009-11-19 09:04:33 UTC (rev 12183)
@@ -26,18 +26,12 @@
 #include <QPainter>
 #include <QSvgRenderer>
 
-#ifndef Q_OS_MACX
-#include <cmath>
-#else
-#include <math.h>
-#endif
-
-QgsComposerPicture::QgsComposerPicture( QgsComposition *composition ): QObject( 0 ), QgsComposerItem( composition ), mRotation( 0.0 ), mMode( Unknown ), \
-    mSvgCacheUpToDate( false ), mCachedDpi( 0 ), mRotationMap( 0 )
+QgsComposerPicture::QgsComposerPicture( QgsComposition *composition ): QgsComposerItem( composition ), mMode( Unknown ), \
+    mSvgCacheUpToDate( false ), mCachedDpi( 0 ), mCachedRotation( 0 ), mRotationMap( 0 )
 {
 }
 
-QgsComposerPicture::QgsComposerPicture(): QgsComposerItem( 0 ), mRotation( 0.0 ), mMode( Unknown ), mSvgCacheUpToDate( false ), mRotationMap( 0 )
+QgsComposerPicture::QgsComposerPicture(): QgsComposerItem( 0 ), mMode( Unknown ), mSvgCacheUpToDate( false ), mCachedRotation( 0 ), mRotationMap( 0 )
 {
 
 }
@@ -57,7 +51,7 @@
   drawBackground( painter );
 
   int newDpi = ( painter->device()->logicalDpiX() + painter->device()->logicalDpiY() ) / 2;
-  if ( newDpi != mCachedDpi )
+  if ( newDpi != mCachedDpi || mCachedRotation != mRotation )
   {
     mSvgCacheUpToDate = false;
   }
@@ -103,6 +97,7 @@
   }
 
   mCachedDpi = newDpi;
+  mCachedRotation = mRotation;
 
   //frame and selection boxes
   drawFrame( painter );
@@ -204,80 +199,8 @@
   mSvgCacheUpToDate = true;
 }
 
-bool QgsComposerPicture::imageSizeConsideringRotation( double& width, double& height ) const
-{
-  double x1 = 0;
-  double y1 = 0;
-  double x2 = width;
-  double y2 = 0;
-  double x3 = width;
-  double y3 = height;
-#if 0
-  double x4 = 0;
-  double y4 = height;
-#endif
 
-  if ( !cornerPointOnRotatedAndScaledRect( x1, y1, width, height ) )
-  {
-    return false;
-  }
-  if ( !cornerPointOnRotatedAndScaledRect( x2, y2, width, height ) )
-  {
-    return false;
-  }
-  if ( !cornerPointOnRotatedAndScaledRect( x3, y3, width, height ) )
-  {
-    return false;
-  }
-#if 0
-  if ( !cornerPointOnRotatedAndScaledRect( x4, y4, width, height ) )
-  {
-    return false;
-  }
-#endif
 
-  width = sqrt(( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) );
-  height = sqrt(( x3 - x2 ) * ( x3 - x2 ) + ( y3 - y2 ) * ( y3 - y2 ) );
-  return true;
-}
-
-bool QgsComposerPicture::cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const
-{
-  //first rotate point clockwise
-  double rotToRad = mRotation * M_PI / 180.0;
-  QPointF midpoint( width / 2.0, height / 2.0 );
-  double xVector = x - midpoint.x();
-  double yVector = y - midpoint.y();
-  //double xRotated = cos(rotToRad) * xVector + sin(rotToRad) * yVector;
-  //double yRotated = -sin(rotToRad) * xVector + cos(rotToRad) * yVector;
-  double xRotated = cos( rotToRad ) * xVector - sin( rotToRad ) * yVector;
-  double yRotated = sin( rotToRad ) * xVector + cos( rotToRad ) * yVector;
-
-  //create line from midpoint to rotated point
-  QLineF line( midpoint.x(), midpoint.y(), midpoint.x() + xRotated, midpoint.y() + yRotated );
-
-  //intersect with all four borders and return result
-  QList<QLineF> borders;
-  borders << QLineF( 0, 0, width, 0 );
-  borders << QLineF( width, 0, width, height );
-  borders << QLineF( width, height, 0, height );
-  borders << QLineF( 0, height, 0, 0 );
-
-  QList<QLineF>::const_iterator it = borders.constBegin();
-  QPointF intersectionPoint;
-
-  for ( ; it != borders.constEnd(); ++it )
-  {
-    if ( line.intersect( *it, &intersectionPoint ) == QLineF::BoundedIntersection )
-    {
-      x = intersectionPoint.x();
-      y = intersectionPoint.y();
-      return true;
-    }
-  }
-  return false;
-}
-
 void QgsComposerPicture::setSceneRect( const QRectF& rectangle )
 {
   mSvgCacheUpToDate = false;
@@ -285,20 +208,6 @@
   emit settingsChanged();
 }
 
-void QgsComposerPicture::setRotation( double rotation )
-{
-  if ( rotation > 360 )
-  {
-    mRotation = (( int )rotation ) % 360;
-  }
-  else
-  {
-    mRotation = rotation;
-  }
-  emit settingsChanged();
-  update();
-}
-
 void QgsComposerPicture::setRotationMap( int composerMapId )
 {
   if ( !mComposition )
@@ -324,6 +233,7 @@
   mRotation = map->rotation();
   QObject::connect( map, SIGNAL( rotationChanged( double ) ), this, SLOT( setRotation( double ) ) );
   mRotationMap = map;
+  setRotation( map->rotation() );
 }
 
 QString QgsComposerPicture::pictureFile() const
@@ -339,7 +249,6 @@
   }
   QDomElement composerPictureElem = doc.createElement( "ComposerPicture" );
   composerPictureElem.setAttribute( "file", QgsProject::instance()->writePath( mSourceFile.fileName() ) );
-  composerPictureElem.setAttribute( "rotation", QString::number( mRotation ) );
   if ( !mRotationMap )
   {
     composerPictureElem.setAttribute( "mapId", -1 );
@@ -375,8 +284,6 @@
   QString fileName = QgsProject::instance()->readPath( itemElem.attribute( "file" ) );
   setPictureFile( fileName );
 
-  mRotation = itemElem.attribute( "rotation" ).toDouble();
-
   //rotation map
   int rotationMapId = itemElem.attribute( "mapId", "-1" ).toInt();
   if ( rotationMapId == -1 )

Modified: trunk/qgis/src/core/composer/qgscomposerpicture.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerpicture.h	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/core/composer/qgscomposerpicture.h	2009-11-19 09:04:33 UTC (rev 12183)
@@ -20,12 +20,11 @@
 #include "qgscomposeritem.h"
 #include <QFile>
 #include <QImage>
-#include <QObject>
 
 /** \ingroup MapComposer
  * A composer class that displays svg files or raster format (jpg, png, ...)
  * */
-class CORE_EXPORT QgsComposerPicture: public QObject, public QgsComposerItem
+class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
 {
     Q_OBJECT
   public:
@@ -43,8 +42,6 @@
        corresponds to 1 scene size unit*/
     void setSceneRect( const QRectF& rectangle );
 
-    double rotation() const {return mRotation;}
-
     /** stores state in Dom node
        * @param node is Dom node corresponding to 'Composer' tag
        * @param temp write template file
@@ -63,10 +60,6 @@
     /**True if the rotation is taken from a map item*/
     bool useRotationMap() const {return mRotationMap;}
 
-  public slots:
-
-    void setRotation( double rotation );
-
   private:
 
     enum Mode //SVG or raster graphic format
@@ -87,18 +80,15 @@
     @param out: boundWidth width of mImage that is used by the svg renderer. May different from mImage.width() to preserve aspect ratio
     @param out: boundHeight height of mImage that is used by the svg renderer*/
     void updateImageFromSvg();
-    /**Calculates width and hight of the picture (in mm) such that it fits into the item frame with the given rotation*/
-    bool imageSizeConsideringRotation( double& width, double& height ) const;
-    /**Calculates corner point after rotation and scaling*/
-    bool cornerPointOnRotatedAndScaledRect( double& x, double& y, double width, double height ) const;
 
+
     QImage mImage;
-    double mRotation;
     QFile mSourceFile;
     Mode mMode;
     /**False if image needs to be rendered from svg*/
     bool mSvgCacheUpToDate;
     int mCachedDpi; //store dpis for which the svg cache is valid
+    double mCachedRotation; //store last rotation value to generate new pixmap from svg on change
     QSize mDefaultSvgSize;
     /**Map that sets the rotation (or 0 if this picture uses map independent rotation)*/
     const QgsComposerMap* mRotationMap;

Modified: trunk/qgis/src/core/composer/qgscomposerscalebar.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerscalebar.h	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/core/composer/qgscomposerscalebar.h	2009-11-19 09:04:33 UTC (rev 12183)
@@ -17,7 +17,6 @@
 #define QGSCOMPOSERSCALEBAR_H
 
 #include "qgscomposeritem.h"
-#include <QObject>
 #include <QPen>
 
 class QgsComposerMap;
@@ -26,7 +25,7 @@
  * A scale bar item that can be added to a map composition.
  */
 
-class CORE_EXPORT QgsComposerScaleBar: public QObject, public QgsComposerItem
+class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem
 {
 
     Q_OBJECT

Added: trunk/qgis/src/core/composer/qgscomposershape.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposershape.cpp	                        (rev 0)
+++ trunk/qgis/src/core/composer/qgscomposershape.cpp	2009-11-19 09:04:33 UTC (rev 12183)
@@ -0,0 +1,203 @@
+/***************************************************************************
+                         qgscomposershape.cpp
+                         ----------------------
+    begin                : November 2009
+    copyright            : (C) 2009 by Marco Hugentobler
+    email                : marco at hugis.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program 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.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "qgscomposershape.h"
+#include <QPainter>
+
+QgsComposerShape::QgsComposerShape( QgsComposition* composition ): QgsComposerItem( composition ), mShape( Ellipse )
+{
+  initBrushAndPen();
+}
+
+QgsComposerShape::QgsComposerShape( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition ): QgsComposerItem( x, y, width, height, composition ), mShape( Ellipse )
+{
+  setSceneRect( QRectF( x, y, width, height ) );
+  initBrushAndPen();
+}
+
+QgsComposerShape::~QgsComposerShape()
+{
+
+}
+
+void QgsComposerShape::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
+{
+  double width = rect().width();
+  double height = rect().height();
+  imageSizeConsideringRotation( width, height );
+
+  painter->save();
+  painter->setRenderHint( QPainter::Antialiasing );
+  painter->setPen( mPen );
+  painter->setBrush( mBrush );
+
+  painter->translate( rect().width() / 2.0, rect().height() / 2.0 );
+  painter->rotate( mRotation );
+  painter->translate( -width / 2.0, -height / 2.0 );
+
+  double halfPenWidth = mPen.widthF() / 2.0;
+
+  switch ( mShape )
+  {
+    case Ellipse:
+      painter->drawEllipse( QRectF( halfPenWidth, halfPenWidth , width - mPen.widthF(), height - mPen.widthF() ) );
+      break;
+    case Rectangle:
+      painter->drawRect( QRectF( halfPenWidth, halfPenWidth , width - mPen.widthF(), height - mPen.widthF() ) );
+      break;
+    case Triangle:
+      QPolygonF triangle;
+      triangle << QPointF( halfPenWidth, height - halfPenWidth );
+      triangle << QPointF( width - halfPenWidth, height - halfPenWidth );
+      triangle << QPointF( width / 2.0, halfPenWidth );
+      painter->drawPolygon( triangle );
+      break;
+  }
+
+  painter->restore();
+
+  drawFrame( painter );
+  if ( isSelected() )
+  {
+    drawSelectionBoxes( painter );
+  }
+}
+
+bool QgsComposerShape::writeXML( QDomElement& elem, QDomDocument & doc ) const
+{
+  QDomElement composerShapeElem = doc.createElement( "ComposerShape" );
+  composerShapeElem.setAttribute( "shapeType", mShape );
+  composerShapeElem.setAttribute( "outlineWidth", mPen.widthF() );
+  composerShapeElem.setAttribute( "transparentFill", mBrush.style() == Qt::NoBrush );
+  QDomElement outlineColorElem = doc.createElement( "OutlineColor" );
+  outlineColorElem.setAttribute( "red", mPen.color().red() );
+  outlineColorElem.setAttribute( "green", mPen.color().green() );
+  outlineColorElem.setAttribute( "blue", mPen.color().blue() );
+  composerShapeElem.appendChild( outlineColorElem );
+  QDomElement fillColorElem = doc.createElement( "FillColor" );
+  fillColorElem.setAttribute( "red", mBrush.color().red() );
+  fillColorElem.setAttribute( "green", mBrush.color().green() );
+  fillColorElem.setAttribute( "blue", mBrush.color().blue() );
+  composerShapeElem.appendChild( fillColorElem );
+  elem.appendChild( composerShapeElem );
+  return _writeXML( composerShapeElem, doc );
+}
+
+bool QgsComposerShape::readXML( const QDomElement& itemElem, const QDomDocument& doc )
+{
+  mShape = QgsComposerShape::Shape( itemElem.attribute( "shapeType", "0" ).toInt() );
+  mPen.setWidthF( itemElem.attribute( "outlineWidth", "0.4" ).toDouble() );
+
+  //transparent fill
+  bool transparent = itemElem.attribute( "transparentFill", "1" ).toInt() == 1;
+  if ( transparent )
+  {
+    mBrush.setStyle( Qt::NoBrush );
+  }
+  else
+  {
+    mBrush.setStyle( Qt::SolidPattern );
+  }
+
+  //outline color
+  QDomNodeList outlineColorList = itemElem.elementsByTagName( "OutlineColor" );
+  if ( outlineColorList.size() > 0 )
+  {
+    QDomElement outlineColorElem = outlineColorList.at( 0 ).toElement();
+    int penRed = outlineColorElem.attribute( "red", "0" ).toInt();
+    int penGreen = outlineColorElem.attribute( "green", "0" ).toInt();
+    int penBlue = outlineColorElem.attribute( "blue", "0" ).toInt();
+    mPen.setColor( QColor( penRed, penGreen, penBlue ) );
+  }
+
+  //fill color
+  QDomNodeList fillNodeList = itemElem.elementsByTagName( "FillColor" );
+  if ( fillNodeList.size() > 0 )
+  {
+    QDomElement fillColorElem = fillNodeList.at( 0 ).toElement();
+    int brushRed = fillColorElem.attribute( "red", "0" ).toInt();
+    int brushGreen = fillColorElem.attribute( "green", "0" ).toInt();
+    int brushBlue = fillColorElem.attribute( "blue", "0" ).toInt();
+    mBrush.setColor( QColor( brushRed, brushGreen, brushBlue ) );
+  }
+
+
+  //restore general composer item properties
+  QDomNodeList composerItemList = itemElem.elementsByTagName( "ComposerItem" );
+  if ( composerItemList.size() > 0 )
+  {
+    QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
+    _readXML( composerItemElem, doc );
+  }
+  return true;
+}
+
+void QgsComposerShape::setLineWidth( double width )
+{
+  mPen.setWidthF( width );
+}
+
+double QgsComposerShape::lineWidth() const
+{
+  return mPen.widthF();
+}
+
+void QgsComposerShape::setOutlineColor( const QColor& color )
+{
+  mPen.setColor( color );
+}
+
+QColor QgsComposerShape::outlineColor() const
+{
+  return mPen.color();
+}
+
+void QgsComposerShape::setFillColor( const QColor& color )
+{
+  mBrush.setColor( color );
+}
+
+QColor QgsComposerShape::fillColor() const
+{
+  return mBrush.color();
+}
+
+bool QgsComposerShape::transparentFill() const
+{
+  return mBrush.style() == Qt::NoBrush;
+}
+
+void QgsComposerShape::setTransparentFill( bool transparent )
+{
+  if ( transparent )
+  {
+    mBrush.setStyle( Qt::NoBrush );
+  }
+  else
+  {
+    mBrush.setStyle( Qt::SolidPattern );
+  }
+}
+
+void QgsComposerShape::initBrushAndPen()
+{
+  mPen.setColor( QColor( 0, 0, 0 ) );
+  mPen.setWidthF( 1 );
+  mPen.setJoinStyle( Qt::RoundJoin );
+  mBrush.setColor( QColor( 0, 0, 0 ) );
+  mBrush.setStyle( Qt::NoBrush );
+}


Property changes on: trunk/qgis/src/core/composer/qgscomposershape.cpp
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/qgis/src/core/composer/qgscomposershape.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposershape.h	                        (rev 0)
+++ trunk/qgis/src/core/composer/qgscomposershape.h	2009-11-19 09:04:33 UTC (rev 12183)
@@ -0,0 +1,80 @@
+/***************************************************************************
+                         qgscomposershape.h
+                         ----------------------
+    begin                : November 2009
+    copyright            : (C) 2009 by Marco Hugentobler
+    email                : marco at hugis.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program 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.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef QGSCOMPOSERSHAPE_H
+#define QGSCOMPOSERSHAPE_H
+
+#include "qgscomposeritem.h"
+
+/**A composer items that draws common shapes (ellipse, triangle, rectangle)*/
+class QgsComposerShape: public QgsComposerItem
+{
+  public:
+
+    enum Shape
+    {
+      Ellipse,
+      Rectangle,
+      Triangle
+    };
+
+    QgsComposerShape( QgsComposition* composition );
+    QgsComposerShape( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition );
+    ~QgsComposerShape();
+
+    /** \brief Reimplementation of QCanvasItem::paint - draw on canvas */
+    void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
+
+    /** stores state in Dom node
+     * @param node is Dom node corresponding to 'Composer' tag
+     * @param temp write template file
+     */
+    bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
+
+    /** sets state from Dom document
+     * @param itemElem is Dom node corresponding to item tag
+     */
+    bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+
+    //setters and getters
+    void setLineWidth( double width );
+    double lineWidth() const;
+    void setOutlineColor( const QColor& color );
+    QColor outlineColor() const;
+    void setFillColor( const QColor& color );
+    QColor fillColor() const;
+    QgsComposerShape::Shape shapeType() const {return mShape;}
+    void setShapeType( QgsComposerShape::Shape s ) {mShape = s;}
+    bool transparentFill() const;
+    void setTransparentFill( bool transparent );
+
+
+  private:
+    /**Ellipse, rectangle or triangle*/
+    Shape mShape;
+    /**Shape outline*/
+    QPen mPen;
+    /**Shape fill*/
+    QBrush mBrush;
+    /**Apply default graphics settings*/
+    void initBrushAndPen();
+
+    /**Returns a point on the line from startPoint to directionPoint that is a certain distance away from the starting point*/
+    QPointF pointOnLineWithDistance( const QPointF& startPoint, const QPointF& directionPoint, double distance ) const;
+};
+
+#endif // QGSCOMPOSERSHAPEITEM_H


Property changes on: trunk/qgis/src/core/composer/qgscomposershape.h
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/qgis/src/gui/qgscomposerview.cpp
===================================================================
--- trunk/qgis/src/gui/qgscomposerview.cpp	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/gui/qgscomposerview.cpp	2009-11-19 09:04:33 UTC (rev 12183)
@@ -26,6 +26,7 @@
 #include "qgscomposeritemgroup.h"
 #include "qgscomposerpicture.h"
 #include "qgscomposerscalebar.h"
+#include "qgscomposershape.h"
 
 QgsComposerView::QgsComposerView( QWidget* parent, const char* name, Qt::WFlags f ) :
     QGraphicsView( parent ), mShiftKeyPressed( false ), mRubberBandItem( 0 ), mMoveContentItem( 0 )
@@ -96,8 +97,9 @@
       break;
     }
 
-    //create rubber band
+    //create rubber band for map and ellipse items
     case AddMap:
+    case AddShape:
     {
       QTransform t;
       mRubberBandItem = new QGraphicsRectItem( 0, 0, 0, 0 );
@@ -186,6 +188,23 @@
       break;
     }
 
+    case AddShape:
+    {
+      if ( !mRubberBandItem || mRubberBandItem->rect().width() < 0.1 || mRubberBandItem->rect().width() < 0.1 )
+      {
+        scene()->removeItem( mRubberBandItem );
+        delete mRubberBandItem;
+        return;
+      }
+
+      QgsComposerShape* composerShape = new QgsComposerShape( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height(), composition() );
+      addComposerShape( composerShape );
+      scene()->removeItem( mRubberBandItem );
+      delete mRubberBandItem;
+      emit actionFinished();
+      break;
+    }
+
     case AddMap:
     {
       if ( !mRubberBandItem || mRubberBandItem->rect().width() < 0.1 || mRubberBandItem->rect().width() < 0.1 )
@@ -233,6 +252,7 @@
         break;
 
       case AddMap:
+      case AddShape:
         //adjust rubber band item
       {
         double x = 0;
@@ -446,6 +466,15 @@
   emit selectedItemChanged( picture );
 }
 
+void QgsComposerView::addComposerShape( QgsComposerShape* shape )
+{
+  scene()->addItem( shape );
+  emit composerShapeAdded( shape );
+  scene()->clearSelection();
+  shape->setSelected( true );
+  emit selectedItemChanged( shape );
+}
+
 void QgsComposerView::groupItems()
 {
   if ( !composition() )

Modified: trunk/qgis/src/gui/qgscomposerview.h
===================================================================
--- trunk/qgis/src/gui/qgscomposerview.h	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/gui/qgscomposerview.h	2009-11-19 09:04:33 UTC (rev 12183)
@@ -30,6 +30,7 @@
 class QgsComposerMap;
 class QgsComposerPicture;
 class QgsComposerScaleBar;
+class QgsComposerShape;
 
 /** \ingroup MapComposer
  * \ingroup gui
@@ -53,6 +54,7 @@
       AddLabel,        // add label
       AddScalebar,     // add scalebar
       AddPicture,       // add raster/vector picture
+      AddShape, //add shape item (ellipse, rectangle, triangle)
       MoveItemContent //move content of item (e.g. content of map)
     };
 
@@ -82,6 +84,8 @@
     void addComposerLegend( QgsComposerLegend* legend );
     /**Adds picture to the graphics scene and advices composer to create a widget for it (through signal)*/
     void addComposerPicture( QgsComposerPicture* picture );
+    /**Adds a composer shape to the graphics scene and acvices composer to create a widget for it (through signal)*/
+    void addComposerShape( QgsComposerShape* shape );
 
     /**Returns the composer main window*/
     QMainWindow* composerWindow();
@@ -127,6 +131,8 @@
     void composerLegendAdded( QgsComposerLegend* legend );
     /**Is emitted when a new composer picture has been added*/
     void composerPictureAdded( QgsComposerPicture* picture );
+    /**Is emitted when a new composer shape has been added*/
+    void composerShapeAdded( QgsComposerShape* shape );
     /**Is emitted when a composer item has been removed from the scene*/
     void itemRemoved( QgsComposerItem* );
     /**Current action (e.g. adding composer map) has been finished. The purpose of this signal is that

Modified: trunk/qgis/src/ui/qgscomposerbase.ui
===================================================================
--- trunk/qgis/src/ui/qgscomposerbase.ui	2009-11-19 07:31:07 UTC (rev 12182)
+++ trunk/qgis/src/ui/qgscomposerbase.ui	2009-11-19 09:04:33 UTC (rev 12183)
@@ -169,6 +169,7 @@
    <addaction name="mActionAddNewLabel"/>
    <addaction name="mActionAddNewLegend"/>
    <addaction name="mActionAddNewScalebar"/>
+   <addaction name="mActionAddBasicShape"/>
    <addaction name="mActionSelectMoveItem"/>
    <addaction name="mActionMoveItemContent"/>
    <addaction name="mActionGroupItems"/>
@@ -443,6 +444,14 @@
     <string>Ctrl+Q</string>
    </property>
   </action>
+  <action name="mActionAddBasicShape">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Add Basic Shape</string>
+   </property>
+  </action>
  </widget>
  <tabstops>
   <tabstop>mCompositionNameComboBox</tabstop>

Added: trunk/qgis/src/ui/qgscomposershapewidgetbase.ui
===================================================================
--- trunk/qgis/src/ui/qgscomposershapewidgetbase.ui	                        (rev 0)
+++ trunk/qgis/src/ui/qgscomposershapewidgetbase.ui	2009-11-19 09:04:33 UTC (rev 12183)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QgsComposerShapeWidgetBase</class>
+ <widget class="QWidget" name="QgsComposerShapeWidgetBase">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>162</width>
+    <height>193</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QComboBox" name="mShapeComboBox"/>
+   </item>
+   <item row="1" column="0">
+    <widget class="QPushButton" name="mOutlineColorButton">
+     <property name="text">
+      <string>Shape outline color...</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="0">
+    <widget class="QDoubleSpinBox" name="mOutlineWidthSpinBox">
+     <property name="prefix">
+      <string>Outline width </string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0">
+    <widget class="QCheckBox" name="mTransparentCheckBox">
+     <property name="text">
+      <string>Transparent fill</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="0">
+    <widget class="QPushButton" name="mFillColorButton">
+     <property name="text">
+      <string>Shape fill Color...</string>
+     </property>
+    </widget>
+   </item>
+   <item row="5" column="0">
+    <widget class="QSpinBox" name="mRotationSpinBox">
+     <property name="prefix">
+      <string comment="Rotation" extracomment="Rotation">Rotation </string>
+     </property>
+     <property name="maximum">
+      <number>359</number>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>



More information about the QGIS-commit mailing list