Skip to content

Commit

Permalink
Merge pull request #8406 from 3nids/fix20321
Browse files Browse the repository at this point in the history
 fix device size in decoration item
  • Loading branch information
3nids committed Nov 3, 2018
2 parents ec98dfc + 1fbcab9 commit 15b2352
Show file tree
Hide file tree
Showing 23 changed files with 49 additions and 28 deletions.
47 changes: 25 additions & 22 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,6 @@ SET(QGIS_APP_SRCS
qgscustomization.cpp
qgscustomprojectiondialog.cpp
qgsdatumtransformtablewidget.cpp
qgsdecorationitem.cpp
qgsdecorationcopyright.cpp
qgsdecorationcopyrightdialog.cpp
qgsdecorationlayoutextent.cpp
qgsdecorationlayoutextentdialog.cpp
qgsdecorationnortharrow.cpp
qgsdecorationnortharrowdialog.cpp
qgsdecorationscalebar.cpp
qgsdecorationscalebardialog.cpp
qgsdecorationgrid.cpp
qgsdecorationgriddialog.cpp
qgsdiscoverrelationsdlg.cpp
qgsdxfexportdialog.cpp
qgsformannotationdialog.cpp
Expand Down Expand Up @@ -119,6 +108,18 @@ SET(QGIS_APP_SRCS
qgsmaptoolsvgannotation.cpp
qgsmaptooltextannotation.cpp

decorations/qgsdecorationitem.cpp
decorations/qgsdecorationcopyright.cpp
decorations/qgsdecorationcopyrightdialog.cpp
decorations/qgsdecorationlayoutextent.cpp
decorations/qgsdecorationlayoutextentdialog.cpp
decorations/qgsdecorationnortharrow.cpp
decorations/qgsdecorationnortharrowdialog.cpp
decorations/qgsdecorationscalebar.cpp
decorations/qgsdecorationscalebardialog.cpp
decorations/qgsdecorationgrid.cpp
decorations/qgsdecorationgriddialog.cpp

vertextool/qgsselectedfeature.cpp
vertextool/qgsvertexentry.cpp
vertextool/qgsvertexeditor.cpp
Expand Down Expand Up @@ -258,17 +259,6 @@ SET (QGIS_APP_MOC_HDRS
qgscustomization.h
qgscustomprojectiondialog.h
qgsdatumtransformtablewidget.h
qgsdecorationitem.h
qgsdecorationcopyright.h
qgsdecorationcopyrightdialog.h
qgsdecorationlayoutextent.h
qgsdecorationlayoutextentdialog.h
qgsdecorationnortharrow.h
qgsdecorationnortharrowdialog.h
qgsdecorationscalebar.h
qgsdecorationscalebardialog.h
qgsdecorationgrid.h
qgsdecorationgriddialog.h
qgsdelattrdialog.h
qgsdiagramproperties.h
qgsdiscoverrelationsdlg.h
Expand Down Expand Up @@ -370,6 +360,18 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptoolregularpolygoncenterpoint.h
qgsmaptoolregularpolygoncentercorner.h

decorations/qgsdecorationitem.h
decorations/qgsdecorationcopyright.h
decorations/qgsdecorationcopyrightdialog.h
decorations/qgsdecorationlayoutextent.h
decorations/qgsdecorationlayoutextentdialog.h
decorations/qgsdecorationnortharrow.h
decorations/qgsdecorationnortharrowdialog.h
decorations/qgsdecorationscalebar.h
decorations/qgsdecorationscalebardialog.h
decorations/qgsdecorationgrid.h
decorations/qgsdecorationgriddialog.h

vertextool/qgsselectedfeature.h
vertextool/qgsvertexeditor.h
vertextool/qgsvertextool.h
Expand Down Expand Up @@ -632,6 +634,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/external/nmea

${CMAKE_SOURCE_DIR}/src/app
${CMAKE_SOURCE_DIR}/src/app/decorations
${CMAKE_SOURCE_DIR}/src/app/layout
${CMAKE_SOURCE_DIR}/src/app/pluginmanager
${CMAKE_SOURCE_DIR}/src/app/gps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,14 @@ void QgsDecorationCopyright::render( const QgsMapSettings &mapSettings, QgsRende
double textWidth = QgsTextRenderer::textWidth( context, mTextFormat, displayStringList, &fm );
double textHeight = QgsTextRenderer::textHeight( context, mTextFormat, displayStringList, QgsTextRenderer::Point, &fm );

int deviceHeight = context.painter()->device()->height();
int deviceWidth = context.painter()->device()->width();
QPaintDevice *device = context.painter()->device();
#if QT_VERSION < 0x050600
int deviceHeight = device->height() / device->devicePixelRatio();
int deviceWidth = device->width() / device->devicePixelRatio();
#else
int deviceHeight = device->height() / device->devicePixelRatioF();
int deviceWidth = device->width() / device->devicePixelRatioF();
#endif

float xOffset( 0 ), yOffset( 0 );

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,14 @@ void QgsDecorationNorthArrow::render( const QgsMapSettings &mapSettings, QgsRend
( centerYDouble * std::cos( radiansDouble ) )
) - centerYDouble );
// need width/height of paint device
int deviceHeight = context.painter()->device()->height();
int deviceWidth = context.painter()->device()->width();
QPaintDevice *device = context.painter()->device();
#if QT_VERSION < 0x050600
int deviceHeight = device->height() / device->devicePixelRatio();
int deviceWidth = device->width() / device->devicePixelRatio();
#else
int deviceHeight = device->height() / device->devicePixelRatioF();
int deviceWidth = device->width() / device->devicePixelRatioF();
#endif

// Set margin according to selected units
int xOffset = 0;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,14 @@ void QgsDecorationScaleBar::render( const QgsMapSettings &mapSettings, QgsRender
return;

//Get canvas dimensions
int deviceHeight = context.painter()->device()->height();
int deviceWidth = context.painter()->device()->width();
QPaintDevice *device = context.painter()->device();
#if QT_VERSION < 0x050600
int deviceHeight = device->height() / device->devicePixelRatio();
int deviceWidth = device->width() / device->devicePixelRatio();
#else
int deviceHeight = device->height() / device->devicePixelRatioF();
int deviceWidth = device->width() / device->devicePixelRatioF();
#endif

//Get map units per pixel. This can be negative at times (to do with
//projections) and that just confuses the rest of the code in this
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 15b2352

Please sign in to comment.