Showing with 90 additions and 10 deletions.
  1. +3 −0 python/core/composer/qgscomposition.sip
  2. +3 −1 src/app/composer/qgscomposer.cpp
  3. +80 −8 src/core/composer/qgscomposition.cpp
  4. +4 −1 src/core/composer/qgscomposition.h
  5. BIN tests/testdata/control_images/expected_atlas_autoscale1/expected_atlas_autoscale1.png
  6. BIN tests/testdata/control_images/expected_atlas_autoscale2/expected_atlas_autoscale2.png
  7. BIN ...s/testdata/control_images/expected_atlas_autoscale_old_api1/expected_atlas_autoscale_old_api1.png
  8. BIN ...s/testdata/control_images/expected_atlas_autoscale_old_api2/expected_atlas_autoscale_old_api2.png
  9. BIN tests/testdata/control_images/expected_atlas_filtering1/expected_atlas_filtering1.png
  10. BIN tests/testdata/control_images/expected_atlas_fixedscale1/expected_atlas_fixedscale1.png
  11. BIN tests/testdata/control_images/expected_atlas_fixedscale2/expected_atlas_fixedscale2.png
  12. BIN ...testdata/control_images/expected_atlas_fixedscale_old_api1/expected_atlas_fixedscale_old_api1.png
  13. BIN ...testdata/control_images/expected_atlas_fixedscale_old_api2/expected_atlas_fixedscale_old_api2.png
  14. BIN tests/testdata/control_images/expected_atlas_hiding1/expected_atlas_hiding1.png
  15. BIN tests/testdata/control_images/expected_atlas_hiding2/expected_atlas_hiding2.png
  16. BIN tests/testdata/control_images/expected_atlas_sorting1/expected_atlas_sorting1.png
  17. BIN tests/testdata/control_images/expected_atlas_sorting2/expected_atlas_sorting2.png
  18. BIN tests/testdata/control_images/expected_atlas_two_maps1/expected_atlas_two_maps1.png
  19. BIN tests/testdata/control_images/expected_atlas_two_maps2/expected_atlas_two_maps2.png
  20. BIN tests/testdata/control_images/expected_composereffects_blend/expected_composereffects_blend.png
  21. BIN ...ta/control_images/expected_composereffects_transparency/expected_composereffects_transparency.png
  22. BIN ...s/testdata/control_images/expected_composerhtml_multiframe1/expected_composerhtml_multiframe1.png
  23. BIN tests/testdata/control_images/expected_composerhtml_table/expected_composerhtml_table.png
  24. BIN tests/testdata/control_images/expected_composermap_grid/expected_composermap_grid.png
  25. BIN tests/testdata/control_images/expected_composermap_overview/expected_composermap_overview.png
  26. BIN .../control_images/expected_composermap_overview_blending/expected_composermap_overview_blending.png
  27. BIN ...data/control_images/expected_composermap_overview_center/expected_composermap_overview_center.png
  28. BIN ...data/control_images/expected_composermap_overview_invert/expected_composermap_overview_invert.png
  29. BIN tests/testdata/control_images/expected_composermap_render/expected_composermap_render.png
  30. BIN tests/testdata/control_images/expected_composermap_zebrastyle/expected_composermap_zebrastyle.png
  31. BIN ...ol_images/expected_composerrotation_mapitemrotation/expected_composerrotation_mapitemrotation.png
  32. BIN ...ta/control_images/expected_composerrotation_maprotation/expected_composerrotation_maprotation.png
  33. BIN ...ges/expected_composerrotation_maprotation_oldapi/expected_composerrotation_maprotation_oldapi.png
  34. BIN ...s/expected_composerrotation_pictureitemrotation/expected_composerrotation_pictureitemrotation.png
  35. BIN ...ol_images/expected_composerrotation_picturerotation/expected_composerrotation_picturerotation.png
  36. BIN ...cted_composerrotation_picturerotation_oldapi/expected_composerrotation_picturerotation_oldapi.png
  37. BIN tests/testdata/control_images/expected_composerrotation_shape/expected_composerrotation_shape.png
  38. BIN .../control_images/expected_composerrotation_shape_oldapi/expected_composerrotation_shape_oldapi.png
  39. BIN ...stdata/control_images/expected_composerscalebar_doublebox/expected_composerscalebar_doublebox.png
  40. BIN ...s/testdata/control_images/expected_composerscalebar_numeric/expected_composerscalebar_numeric.png
  41. BIN ...stdata/control_images/expected_composerscalebar_singlebox/expected_composerscalebar_singlebox.png
  42. BIN tests/testdata/control_images/expected_composerscalebar_tick/expected_composerscalebar_tick.png
  43. BIN ...s/testdata/control_images/expected_composershapes_rectangle/expected_composershapes_rectangle.png
  44. BIN tests/testdata/control_images/expected_composershapes_triangle/expected_composershapes_triangle.png
3 changes: 3 additions & 0 deletions python/core/composer/qgscomposition.sip
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ class QgsComposition : QGraphicsScene
after reading all the items from xml file*/
void sortZList();

/**Rebuilds the z order list based on current order of items in scene*/
void refreshZList();

/**Snaps a scene coordinate point to grid*/
QPointF snapPointToGrid( const QPointF& scenePoint ) const;

Expand Down
4 changes: 3 additions & 1 deletion src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2628,7 +2628,9 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&
mComposition->setWorldFileMap( worldFileMap );
}

mComposition->sortZList();
//make sure z values are consistent
mComposition->refreshZList();

mView->setComposition( mComposition );

if ( mUndoView )
Expand Down
88 changes: 80 additions & 8 deletions src/core/composer/qgscomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,12 @@ void QgsComposition::addItemsFromXML( const QDomElement& elem, const QDomDocumen
bool addUndoCommands, QPointF* pos, bool pasteInPlace )
{
QPointF* pasteInPlacePt = 0;

//if we are adding items to a composition which already contains items, we need to make sure
//these items are placed at the top of the composition and that zValues are not duplicated
//so, calculate an offset which needs to be added to the zValue of created items
int zOrderOffset = mItemZList.size();

if ( pasteInPlace )
{
pasteInPlacePt = new QPointF( 0, pageNumberAt( *pos ) * ( mPageHeight + mSpaceBetweenPages ) );
Expand All @@ -744,6 +750,7 @@ void QgsComposition::addItemsFromXML( const QDomElement& elem, const QDomDocumen
}
}
addComposerLabel( newLabel );
newLabel->setZValue( newLabel->zValue() + zOrderOffset );
if ( addUndoCommands )
{
pushAddRemoveCommand( newLabel, tr( "Label added" ) );
Expand All @@ -764,7 +771,7 @@ void QgsComposition::addItemsFromXML( const QDomElement& elem, const QDomDocumen
newMap->setPreviewMode( QgsComposerMap::Rectangle );
}
addComposerMap( newMap, false );

newMap->setZValue( newMap->zValue() + zOrderOffset );
if ( pos )
{
if ( pasteInPlace )
Expand Down Expand Up @@ -818,6 +825,7 @@ void QgsComposition::addItemsFromXML( const QDomElement& elem, const QDomDocumen
}
}
addComposerArrow( newArrow );
newArrow->setZValue( newArrow->zValue() + zOrderOffset );
if ( addUndoCommands )
{
pushAddRemoveCommand( newArrow, tr( "Arrow added" ) );
Expand All @@ -843,6 +851,7 @@ void QgsComposition::addItemsFromXML( const QDomElement& elem, const QDomDocumen
}
}
addComposerScaleBar( newScaleBar );
newScaleBar->setZValue( newScaleBar->zValue() + zOrderOffset );
if ( addUndoCommands )
{
pushAddRemoveCommand( newScaleBar, tr( "Scale bar added" ) );
Expand Down Expand Up @@ -870,6 +879,7 @@ void QgsComposition::addItemsFromXML( const QDomElement& elem, const QDomDocumen
}
}
addComposerShape( newShape );
newShape->setZValue( newShape->zValue() + zOrderOffset );
if ( addUndoCommands )
{
pushAddRemoveCommand( newShape, tr( "Shape added" ) );
Expand All @@ -895,6 +905,7 @@ void QgsComposition::addItemsFromXML( const QDomElement& elem, const QDomDocumen
}
}
addComposerPicture( newPicture );
newPicture->setZValue( newPicture->zValue() + zOrderOffset );
if ( addUndoCommands )
{
pushAddRemoveCommand( newPicture, tr( "Picture added" ) );
Expand All @@ -920,6 +931,7 @@ void QgsComposition::addItemsFromXML( const QDomElement& elem, const QDomDocumen
}
}
addComposerLegend( newLegend );
newLegend->setZValue( newLegend->zValue() + zOrderOffset );
if ( addUndoCommands )
{
pushAddRemoveCommand( newLegend, tr( "Legend added" ) );
Expand All @@ -945,12 +957,14 @@ void QgsComposition::addItemsFromXML( const QDomElement& elem, const QDomDocumen
}
}
addComposerTable( newTable );
newTable->setZValue( newTable->zValue() + zOrderOffset );
if ( addUndoCommands )
{
pushAddRemoveCommand( newTable, tr( "Table added" ) );
}
}
// html
//TODO - fix this. pasting html items has no effect
QDomNodeList composerHtmlList = elem.elementsByTagName( "ComposerHtml" );
for ( int i = 0; i < composerHtmlList.size(); ++i )
{
Expand All @@ -959,10 +973,19 @@ void QgsComposition::addItemsFromXML( const QDomElement& elem, const QDomDocumen
newHtml->readXML( currentHtmlElem, doc );
newHtml->setCreateUndoCommands( true );
this->addMultiFrame( newHtml );
}

//offset z values for frames
//TODO - fix this after fixing html item paste
/*for ( int frameIdx = 0; frameIdx < newHtml->frameCount(); ++frameIdx )
{
QgsComposerFrame * frame = newHtml->frame( frameIdx );
frame->setZValue( frame->zValue() + zOrderOffset );
}*/
}

// groups (must be last as it references uuids of above items)
//TODO - pasted groups lose group properties, since the uuids of group items
//changes
QDomNodeList groupList = elem.elementsByTagName( "ComposerItemGroup" );
for ( int i = 0; i < groupList.size(); ++i )
{
Expand All @@ -971,6 +994,12 @@ void QgsComposition::addItemsFromXML( const QDomElement& elem, const QDomDocumen
newGroup->readXML( groupElem, doc );
addItem( newGroup );
}

//Since this function adds items grouped by type, and each item is added to end of
//z order list in turn, it will now be inconsistent with the actual order of items in the scene.
//Make sure z order list matches the actual order of items in the scene.
refreshZList();

}

void QgsComposition::addItemToZList( QgsComposerItem* item )
Expand Down Expand Up @@ -1385,26 +1414,40 @@ void QgsComposition::unlockAllItems()
mUndoStack.push( parentCommand );
}

void QgsComposition::updateZValues()
void QgsComposition::updateZValues( bool addUndoCommands )
{
int counter = 1;
QLinkedList<QgsComposerItem*>::iterator it = mItemZList.begin();
QgsComposerItem* currentItem = 0;

QUndoCommand* parentCommand = new QUndoCommand( tr( "Item z-order changed" ) );
QUndoCommand* parentCommand;
if ( addUndoCommands )
{
parentCommand = new QUndoCommand( tr( "Item z-order changed" ) );
}
for ( ; it != mItemZList.end(); ++it )
{
currentItem = *it;
if ( currentItem )
{
QgsComposerItemCommand* subcommand = new QgsComposerItemCommand( *it, "", parentCommand );
subcommand->savePreviousState();
QgsComposerItemCommand* subcommand;
if ( addUndoCommands )
{
subcommand = new QgsComposerItemCommand( *it, "", parentCommand );
subcommand->savePreviousState();
}
currentItem->setZValue( counter );
subcommand->saveAfterState();
if ( addUndoCommands )
{
subcommand->saveAfterState();
}
}
++counter;
}
mUndoStack.push( parentCommand );
if ( addUndoCommands )
{
mUndoStack.push( parentCommand );
}
}

void QgsComposition::sortZList()
Expand Down Expand Up @@ -1433,6 +1476,35 @@ void QgsComposition::sortZList()
mItemZList = sortedList;
}

void QgsComposition::refreshZList()
{
QLinkedList<QgsComposerItem*> sortedList;

//rebuild the item z order list based on the current zValues of items in the scene

//get items in descending zValue order
QList<QGraphicsItem*> itemList = items();
QList<QGraphicsItem*>::iterator itemIt = itemList.begin();
for ( ; itemIt != itemList.end(); ++itemIt )
{
QgsComposerItem* composerItem = dynamic_cast<QgsComposerItem*>( *itemIt );
if ( composerItem )
{
if ( composerItem->type() != QgsComposerItem::ComposerPaper && composerItem->type() != QgsComposerItem::ComposerFrame )
{
//since the z order list is in ascending zValue order (opposite order to itemList), we prepend each item
sortedList.prepend( composerItem );
}
}
}

mItemZList = sortedList;

//Finally, rebuild the zValue of all items to remove any duplicate zValues and make sure there's
//no missing zValues.
updateZValues( false );
}

QPointF QgsComposition::snapPointToGrid( const QPointF& scenePoint ) const
{
if ( !mSnapToGrid || mSnapGridResolution <= 0 )
Expand Down
5 changes: 4 additions & 1 deletion src/core/composer/qgscomposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
after reading all the items from xml file*/
void sortZList();

/**Rebuilds the z order list based on current order of items in scene*/
void refreshZList();

/**Snaps a scene coordinate point to grid*/
QPointF snapPointToGrid( const QPointF& scenePoint ) const;

Expand Down Expand Up @@ -511,7 +514,7 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
QgsComposition(); //default constructor is forbidden

/**Reset z-values of items based on position in z list*/
void updateZValues();
void updateZValues( bool addUndoCommands = true );

/**Returns the bounding rectangle of the selected items in scene coordinates
@return 0 in case of success*/
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.