Skip to content

Commit d8402ac

Browse files
committedJan 17, 2018
Remove composer from more code, port georeferencer reports to layouts
1 parent 5804745 commit d8402ac

15 files changed

+204
-147
lines changed
 

‎doc/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ IF(WITH_APIDOC)
5656
${CMAKE_SOURCE_DIR}/src/core/3d
5757
${CMAKE_SOURCE_DIR}/src/core/annotations
5858
${CMAKE_SOURCE_DIR}/src/core/auth
59-
${CMAKE_SOURCE_DIR}/src/core/composer
6059
${CMAKE_SOURCE_DIR}/src/core/diagram
6160
${CMAKE_SOURCE_DIR}/src/core/dxf
6261
${CMAKE_SOURCE_DIR}/src/core/effects

‎python/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ INCLUDE_DIRECTORIES(
107107
${CMAKE_SOURCE_DIR}/src/core/auth
108108
${CMAKE_SOURCE_DIR}/src/core/expression
109109
${CMAKE_SOURCE_DIR}/src/core/pal
110-
${CMAKE_SOURCE_DIR}/src/core/composer
111110
${CMAKE_SOURCE_DIR}/src/core/diagram
112111
${CMAKE_SOURCE_DIR}/src/core/effects
113112
${CMAKE_SOURCE_DIR}/src/core/fieldformatter

‎src/app/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,6 @@ INCLUDE_DIRECTORIES(
576576
${CMAKE_SOURCE_DIR}/src/core
577577
${CMAKE_SOURCE_DIR}/src/core/annotations
578578
${CMAKE_SOURCE_DIR}/src/core/auth
579-
${CMAKE_SOURCE_DIR}/src/core/composer
580579
${CMAKE_SOURCE_DIR}/src/core/expression
581580
${CMAKE_SOURCE_DIR}/src/core/gps
582581
${CMAKE_SOURCE_DIR}/src/core/dxf
@@ -636,7 +635,6 @@ INCLUDE_DIRECTORIES(
636635
../core
637636
../core/annotations
638637
../core/auth
639-
../core/composer
640638
../core/gps
641639
../core/dxf
642640
../core/geometry

‎src/app/locator/qgsinbuiltlocatorfilters.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "qgisapp.h"
2424
#include "qgsstringutils.h"
2525
#include "qgsmaplayermodel.h"
26-
#include "qgscomposition.h"
2726
#include "qgslayoutmanager.h"
2827
#include "qgsmapcanvas.h"
2928
#include <QToolButton>

‎src/core/qgslegendstyle.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
***************************************************************************/
1717

1818
#include "qgslegendstyle.h"
19-
#include "qgscomposition.h"
2019
#include "qgsfontutils.h"
2120
#include "qgssettings.h"
2221

‎src/plugins/georeferencer/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ INCLUDE_DIRECTORIES(
7979
${CMAKE_SOURCE_DIR}/src/core/geometry
8080
${CMAKE_SOURCE_DIR}/src/core/metadata
8181
${CMAKE_SOURCE_DIR}/src/core/raster
82-
${CMAKE_SOURCE_DIR}/src/core/composer
82+
${CMAKE_SOURCE_DIR}/src/core/layout
83+
${CMAKE_SOURCE_DIR}/src/core/symbology
8384
${CMAKE_SOURCE_DIR}/src/gui
8485
${CMAKE_SOURCE_DIR}/src/gui/editorwidgets
8586
${CMAKE_SOURCE_DIR}/src/gui/layertree

‎src/plugins/georeferencer/qgsgeorefplugingui.cpp

Lines changed: 104 additions & 105 deletions
Large diffs are not rendered by default.

‎src/plugins/georeferencer/qgsresidualplotitem.cpp

Lines changed: 74 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515

1616
#include "qgsresidualplotitem.h"
1717
#include "qgsgeorefdatapoint.h"
18-
#include "qgscomposerutils.h"
18+
#include "qgslayoututils.h"
1919
#include <QPainter>
2020
#include <cfloat>
2121
#include <cmath>
2222

23-
QgsResidualPlotItem::QgsResidualPlotItem( QgsComposition *c )
24-
: QgsComposerItem( c )
23+
QgsResidualPlotItem::QgsResidualPlotItem( QgsLayout *layout )
24+
: QgsLayoutItem( layout )
2525
, mConvertScaleToMapUnits( false )
2626
{
27-
27+
setBackgroundEnabled( false );
2828
}
2929

3030
void QgsResidualPlotItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
@@ -68,7 +68,7 @@ void QgsResidualPlotItem::paint( QPainter *painter, const QStyleOptionGraphicsIt
6868
painter->setBrush( disabledBrush );
6969
}
7070
painter->drawRect( QRectF( gcpItemMMX - 0.5, gcpItemMMY - 0.5, 1, 1 ) );
71-
QgsComposerUtils::drawText( painter, QPointF( gcpItemMMX + 2, gcpItemMMY + 2 ), QString::number( ( *gcpIt )->id() ), QFont() );
71+
QgsLayoutUtils::drawText( painter, QPointF( gcpItemMMX + 2, gcpItemMMY + 2 ), QString::number( ( *gcpIt )->id() ), QFont() );
7272

7373
mmPixelRatio = maxMMToPixelRatioForGCP( *gcpIt, gcpItemMMX, gcpItemMMY );
7474
if ( mmPixelRatio < minMMPixelRatio )
@@ -97,7 +97,7 @@ void QgsResidualPlotItem::paint( QPainter *painter, const QStyleOptionGraphicsIt
9797
QPointF p2( gcpItemMMX + ( *gcpIt )->residual().x() * minMMPixelRatio, gcpItemMMY + ( *gcpIt )->residual().y() * minMMPixelRatio );
9898
painter->drawLine( p1, p2 );
9999
painter->setBrush( QBrush( painter->pen().color() ) );
100-
QgsComposerUtils::drawArrowHead( painter, p2.x(), p2.y(), QgsComposerUtils::angle( p1, p2 ), 1 );
100+
drawArrowHead( painter, p2.x(), p2.y(), angle( p1, p2 ), 1 );
101101
}
102102

103103
//draw scale bar
@@ -132,20 +132,29 @@ void QgsResidualPlotItem::paint( QPainter *painter, const QStyleOptionGraphicsIt
132132
scaleBarFont.setPointSize( 9 );
133133
if ( mConvertScaleToMapUnits )
134134
{
135-
QgsComposerUtils::drawText( painter, QPointF( 5, rect().height() - 4 + QgsComposerUtils::fontAscentMM( scaleBarFont ) ), QStringLiteral( "%1 map units" ).arg( scaleBarWidthUnits ), QFont() );
135+
QgsLayoutUtils::drawText( painter, QPointF( 5, rect().height() - 4 + QgsLayoutUtils::fontAscentMM( scaleBarFont ) ), QStringLiteral( "%1 map units" ).arg( scaleBarWidthUnits ), QFont() );
136136
}
137137
else
138138
{
139-
QgsComposerUtils::drawText( painter, QPointF( 5, rect().height() - 4 + QgsComposerUtils::fontAscentMM( scaleBarFont ) ), QStringLiteral( "%1 pixels" ).arg( scaleBarWidthUnits ), QFont() );
139+
QgsLayoutUtils::drawText( painter, QPointF( 5, rect().height() - 4 + QgsLayoutUtils::fontAscentMM( scaleBarFont ) ), QStringLiteral( "%1 pixels" ).arg( scaleBarWidthUnits ), QFont() );
140140
}
141141

142-
drawFrame( painter );
143-
if ( isSelected() )
142+
if ( frameEnabled() )
144143
{
145-
drawSelectionBoxes( painter );
144+
painter->save();
145+
painter->setPen( pen() );
146+
painter->setBrush( Qt::NoBrush );
147+
painter->setRenderHint( QPainter::Antialiasing, true );
148+
painter->drawRect( QRectF( 0, 0, rect().width(), rect().height() ) );
149+
painter->restore();
146150
}
147151
}
148152

153+
void QgsResidualPlotItem::draw( QgsRenderContext &, const QStyleOptionGraphicsItem * )
154+
{
155+
156+
}
157+
149158
double QgsResidualPlotItem::maxMMToPixelRatioForGCP( const QgsGeorefDataPoint *p, double pixelXMM, double pixelYMM )
150159
{
151160
if ( !p )
@@ -207,23 +216,65 @@ double QgsResidualPlotItem::maxMMToPixelRatioForGCP( const QgsGeorefDataPoint *p
207216
}
208217
}
209218

210-
bool QgsResidualPlotItem::writeXml( QDomElement &elem, QDomDocument &doc ) const
219+
double QgsResidualPlotItem::dist( QPointF p1, QPointF p2 ) const
211220
{
212-
Q_UNUSED( elem );
213-
Q_UNUSED( doc );
214-
return false;
221+
double dx = p2.x() - p1.x();
222+
double dy = p2.y() - p1.y();
223+
return std::sqrt( dx * dx + dy * dy );
215224
}
216225

217-
bool QgsResidualPlotItem::readXml( const QDomElement &itemElem, const QDomDocument &doc )
226+
void QgsResidualPlotItem::drawArrowHead( QPainter *p, const double x, const double y, const double angle, const double arrowHeadWidth )
218227
{
219-
Q_UNUSED( itemElem );
220-
Q_UNUSED( doc );
221-
return false;
228+
if ( !p )
229+
{
230+
return;
231+
}
232+
233+
double angleRad = angle / 180.0 * M_PI;
234+
QPointF middlePoint( x, y );
235+
//rotate both arrow points
236+
QPointF p1 = QPointF( -arrowHeadWidth / 2.0, arrowHeadWidth );
237+
QPointF p2 = QPointF( arrowHeadWidth / 2.0, arrowHeadWidth );
238+
239+
QPointF p1Rotated, p2Rotated;
240+
p1Rotated.setX( p1.x() * std::cos( angleRad ) + p1.y() * -std::sin( angleRad ) );
241+
p1Rotated.setY( p1.x() * std::sin( angleRad ) + p1.y() * std::cos( angleRad ) );
242+
p2Rotated.setX( p2.x() * std::cos( angleRad ) + p2.y() * -std::sin( angleRad ) );
243+
p2Rotated.setY( p2.x() * std::sin( angleRad ) + p2.y() * std::cos( angleRad ) );
244+
245+
QPolygonF arrowHeadPoly;
246+
arrowHeadPoly << middlePoint;
247+
arrowHeadPoly << QPointF( middlePoint.x() + p1Rotated.x(), middlePoint.y() + p1Rotated.y() );
248+
arrowHeadPoly << QPointF( middlePoint.x() + p2Rotated.x(), middlePoint.y() + p2Rotated.y() );
249+
250+
p->save();
251+
252+
QPen arrowPen = p->pen();
253+
arrowPen.setJoinStyle( Qt::RoundJoin );
254+
QBrush arrowBrush = p->brush();
255+
arrowBrush.setStyle( Qt::SolidPattern );
256+
p->setPen( arrowPen );
257+
p->setBrush( arrowBrush );
258+
arrowBrush.setStyle( Qt::SolidPattern );
259+
p->drawPolygon( arrowHeadPoly );
260+
261+
p->restore();
222262
}
223263

224-
double QgsResidualPlotItem::dist( QPointF p1, QPointF p2 ) const
264+
double QgsResidualPlotItem::angle( QPointF p1, QPointF p2 )
225265
{
226-
double dx = p2.x() - p1.x();
227-
double dy = p2.y() - p1.y();
228-
return std::sqrt( dx * dx + dy * dy );
266+
double xDiff = p2.x() - p1.x();
267+
double yDiff = p2.y() - p1.y();
268+
double length = std::sqrt( xDiff * xDiff + yDiff * yDiff );
269+
if ( length <= 0 )
270+
{
271+
return 0;
272+
}
273+
274+
double angle = std::acos( ( -yDiff * length ) / ( length * length ) ) * 180 / M_PI;
275+
if ( xDiff < 0 )
276+
{
277+
return ( 360 - angle );
278+
}
279+
return angle;
229280
}

‎src/plugins/georeferencer/qgsresidualplotitem.h

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
#ifndef QGSRESIDUALPLOTITEM_H
1717
#define QGSRESIDUALPLOTITEM_H
1818

19-
#include "qgscomposeritem.h"
19+
#include "qgslayoutitem.h"
2020
#include "qgsgcplist.h"
2121
#include "qgsrectangle.h"
2222

2323
/**
2424
* A composer item to visualise the distribution of georeference residuals. For the visualisation,
2525
the length of the residual arrows are scaled*/
26-
class QgsResidualPlotItem: public QgsComposerItem
26+
class QgsResidualPlotItem: public QgsLayoutItem
2727
{
2828
Q_OBJECT
2929

3030
public:
31-
explicit QgsResidualPlotItem( QgsComposition *c );
31+
explicit QgsResidualPlotItem( QgsLayout *layout );
3232

3333
//! \brief Reimplementation of QCanvasItem::paint
3434
void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
@@ -42,9 +42,7 @@ class QgsResidualPlotItem: public QgsComposerItem
4242
void setConvertScaleToMapUnits( bool convert ) { mConvertScaleToMapUnits = convert; }
4343
bool convertScaleToMapUnits() const { return mConvertScaleToMapUnits; }
4444

45-
bool writeXml( QDomElement &elem, QDomDocument &doc ) const override;
46-
bool readXml( const QDomElement &itemElem, const QDomDocument &doc ) override;
47-
45+
void draw( QgsRenderContext &context, const QStyleOptionGraphicsItem *itemStyle = nullptr ) override;
4846
private:
4947
//gcp list
5048
QgsGCPList mGCPList;
@@ -58,6 +56,26 @@ class QgsResidualPlotItem: public QgsComposerItem
5856

5957
//! Returns distance between two points
6058
double dist( QPointF p1, QPointF p2 ) const;
59+
60+
/**
61+
* Draws an arrow head on to a QPainter.
62+
* \param p destination painter
63+
* \param x x-coordinate of arrow center
64+
* \param y y-coordinate of arrow center
65+
* \param angle angle in degrees which arrow should point toward, measured
66+
* clockwise from pointing vertical upward
67+
* \param arrowHeadWidth size of arrow head
68+
*/
69+
static void drawArrowHead( QPainter *p, const double x, const double y, const double angle, const double arrowHeadWidth );
70+
71+
/**
72+
* Calculates the angle of the line from p1 to p2 (counter clockwise,
73+
* starting from a line from north to south)
74+
* \param p1 start point of line
75+
* \param p2 end point of line
76+
* \returns angle in degrees, clockwise from south
77+
*/
78+
static double angle( QPointF p1, QPointF p2 );
6179
};
6280

6381
#endif // QGSRESIDUALPLOTITEM_H

‎src/server/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ INCLUDE_DIRECTORIES(
110110
${CMAKE_SOURCE_DIR}/src/core/metadata
111111
${CMAKE_SOURCE_DIR}/src/core/raster
112112
${CMAKE_SOURCE_DIR}/src/core/symbology
113-
${CMAKE_SOURCE_DIR}/src/core/composer
114113
${CMAKE_SOURCE_DIR}/src/core/layout
115114
${CMAKE_SOURCE_DIR}/src/core/layertree
116115
${CMAKE_SOURCE_DIR}/src/analysis/interpolation

‎src/server/services/wcs/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ INCLUDE_DIRECTORIES(
3636
../../../core/metadata
3737
../../../core/raster
3838
../../../core/symbology
39-
../../../core/composer
4039
../../../core/layertree
4140
../..
4241
..

‎src/server/services/wfs/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ INCLUDE_DIRECTORIES(
4646
../../../core/metadata
4747
../../../core/raster
4848
../../../core/symbology
49-
../../../core/composer
5049
../../../core/layertree
5150
../..
5251
..

‎src/server/services/wms/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ INCLUDE_DIRECTORIES(
5151
${CMAKE_SOURCE_DIR}/src/core/metadata
5252
${CMAKE_SOURCE_DIR}/src/core/raster
5353
${CMAKE_SOURCE_DIR}/src/core/symbology
54-
${CMAKE_SOURCE_DIR}/src/core/composer
5554
${CMAKE_SOURCE_DIR}/src/core/layertree
5655
${CMAKE_SOURCE_DIR}/src/core/layout
5756
${CMAKE_SOURCE_DIR}/src/gui

‎tests/src/3d/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
1313
${CMAKE_SOURCE_DIR}/src/core
1414
${CMAKE_SOURCE_DIR}/src/core/expression
1515
${CMAKE_SOURCE_DIR}/src/core/auth
16-
${CMAKE_SOURCE_DIR}/src/core/composer
1716
${CMAKE_SOURCE_DIR}/src/core/geometry
1817
${CMAKE_SOURCE_DIR}/src/core/layout
1918
${CMAKE_SOURCE_DIR}/src/core/metadata

‎tests/src/app/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ INCLUDE_DIRECTORIES(
55
${CMAKE_CURRENT_SOURCE_DIR}
66
${CMAKE_SOURCE_DIR}/src/core
77
${CMAKE_SOURCE_DIR}/src/core/auth
8-
${CMAKE_SOURCE_DIR}/src/core/composer
98
${CMAKE_SOURCE_DIR}/src/core/expression
109
${CMAKE_SOURCE_DIR}/src/core/geometry
1110
${CMAKE_SOURCE_DIR}/src/core/layout

0 commit comments

Comments
 (0)
Please sign in to comment.