QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
dxf
qgsdxfpaintdevice.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsdxpaintdevice.cpp
3
--------------------
4
begin : November 2013
5
copyright : (C) 2013 by Marco Hugentobler
6
email : marco at sourcepole dot ch
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#include "
qgsdxfpaintdevice.h
"
19
20
#include "
qgsdxfpaintengine.h
"
21
#include "
qgspoint.h
"
22
23
QgsDxfPaintDevice::QgsDxfPaintDevice
(
QgsDxfExport
*dxf )
24
{
25
mPaintEngine = std::make_unique<QgsDxfPaintEngine>(
this
, dxf );
26
}
27
28
QgsDxfPaintDevice::~QgsDxfPaintDevice
()
29
{}
30
31
QPaintEngine *
QgsDxfPaintDevice::paintEngine
()
const
32
{
33
return
mPaintEngine.get();
34
}
35
36
int
QgsDxfPaintDevice::metric
( PaintDeviceMetric
metric
)
const
37
{
38
// NOLINTBEGIN(bugprone-branch-clone)
39
switch
(
metric
)
40
{
41
case
QPaintDevice::PdmWidth:
42
return
mDrawingSize.width();
43
case
QPaintDevice::PdmHeight:
44
return
mDrawingSize.height();
45
case
QPaintDevice::PdmWidthMM:
46
return
mDrawingSize.width();
47
case
QPaintDevice::PdmHeightMM:
48
return
mDrawingSize.height();
49
case
QPaintDevice::PdmNumColors:
50
return
std::numeric_limits<int>::max();
51
case
QPaintDevice::PdmDepth:
52
return
32;
53
case
QPaintDevice::PdmDpiX:
54
case
QPaintDevice::PdmDpiY:
55
case
QPaintDevice::PdmPhysicalDpiX:
56
case
QPaintDevice::PdmPhysicalDpiY:
57
return
96;
58
case
QPaintDevice::PdmDevicePixelRatio:
59
return
1;
60
case
QPaintDevice::PdmDevicePixelRatioScaled:
61
return
static_cast<
int
>
( 1 * QPaintDevice::devicePixelRatioFScale() );
62
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 8, 0 ) )
63
case
PdmDevicePixelRatioF_EncodedA:
64
return
QPaintDevice::encodeMetricF( PdmDevicePixelRatioF_EncodedA, 1.0 );
65
case
PdmDevicePixelRatioF_EncodedB:
66
return
QPaintDevice::encodeMetricF( PdmDevicePixelRatioF_EncodedB, 1.0 );
67
#endif
68
}
69
// NOLINTEND(bugprone-branch-clone)
70
return
0;
71
}
72
73
double
QgsDxfPaintDevice::widthScaleFactor
()
const
74
{
75
if
( !mDrawingSize.isValid() || mRectangle.isEmpty() )
76
{
77
return
1.0;
78
}
79
80
const
double
widthFactor = mRectangle.width() / mDrawingSize.width();
81
const
double
heightFactor = mRectangle.height() / mDrawingSize.height();
82
return
( widthFactor + heightFactor ) / 2.0;
83
}
84
85
QPointF
QgsDxfPaintDevice::dxfCoordinates
( QPointF pt )
const
86
{
87
if
( !mDrawingSize.isValid() || mRectangle.isEmpty() )
88
{
89
return
QPointF( pt.x(), pt.y() );
90
}
91
92
const
double
x = mRectangle.left() + pt.x() * ( mRectangle.width() / mDrawingSize.width() );
93
const
double
y = mRectangle.bottom() - pt.y() * ( mRectangle.height() / mDrawingSize.height() );
94
return
QPointF( x, y );
95
}
96
97
void
QgsDxfPaintDevice::setLayer
(
const
QString &layer )
98
{
99
if
( mPaintEngine )
100
{
101
mPaintEngine->setLayer( layer );
102
}
103
}
104
105
void
QgsDxfPaintDevice::setShift
( QPointF shift )
106
{
107
if
( mPaintEngine )
108
{
109
mPaintEngine->setShift( shift );
110
}
111
}
QgsDxfExport
Exports QGIS layers to the DXF format.
Definition
qgsdxfexport.h:70
QgsDxfPaintDevice::widthScaleFactor
double widthScaleFactor() const
Returns scale factor for line width.
Definition
qgsdxfpaintdevice.cpp:73
QgsDxfPaintDevice::paintEngine
QPaintEngine * paintEngine() const override
Definition
qgsdxfpaintdevice.cpp:31
QgsDxfPaintDevice::setShift
void setShift(QPointF shift)
Definition
qgsdxfpaintdevice.cpp:105
QgsDxfPaintDevice::dxfCoordinates
QPointF dxfCoordinates(QPointF pt) const
Converts a point from device coordinates to dxf coordinates.
Definition
qgsdxfpaintdevice.cpp:85
QgsDxfPaintDevice::~QgsDxfPaintDevice
~QgsDxfPaintDevice() override
Definition
qgsdxfpaintdevice.cpp:28
QgsDxfPaintDevice::setLayer
void setLayer(const QString &layer)
Definition
qgsdxfpaintdevice.cpp:97
QgsDxfPaintDevice::metric
int metric(PaintDeviceMetric metric) const override
Definition
qgsdxfpaintdevice.cpp:36
QgsDxfPaintDevice::QgsDxfPaintDevice
QgsDxfPaintDevice(QgsDxfExport *dxf)
Definition
qgsdxfpaintdevice.cpp:23
qgsdxfpaintdevice.h
qgsdxfpaintengine.h
qgspoint.h
Generated on
for QGIS API Documentation by
1.17.0