23 if ( measurement.
units() == targetUnits )
28 switch ( targetUnits )
54 if ( size.
units() == targetUnits )
63 switch ( targetUnits )
66 result.
setSize( convertToMillimeters( width ), convertToMillimeters( height ) );
69 result.
setSize( convertToCentimeters( width ), convertToCentimeters( height ) );
72 result.
setSize( convertToMeters( width ), convertToMeters( height ) );
75 result.
setSize( convertToInches( width ), convertToInches( height ) );
78 result.
setSize( convertToFeet( width ), convertToFeet( height ) );
81 result.
setSize( convertToPoints( width ), convertToPoints( height ) );
84 result.
setSize( convertToPicas( width ), convertToPicas( height ) );
87 result.
setSize( convertToPixels( width ), convertToPixels( height ) );
95 if ( point.
units() == targetUnits )
104 switch ( targetUnits )
107 result.
setPoint( convertToMillimeters( x ), convertToMillimeters( y ) );
110 result.
setPoint( convertToCentimeters( x ), convertToCentimeters( y ) );
113 result.
setPoint( convertToMeters( x ), convertToMeters( y ) );
116 result.
setPoint( convertToInches( x ), convertToInches( y ) );
119 result.
setPoint( convertToFeet( x ), convertToFeet( y ) );
122 result.
setPoint( convertToPoints( x ), convertToPoints( y ) );
125 result.
setPoint( convertToPicas( x ), convertToPicas( y ) );
128 result.
setPoint( convertToPixels( x ), convertToPixels( y ) );
134 double QgsLayoutMeasurementConverter::convertToMillimeters(
const QgsLayoutMeasurement measurement )
const
136 switch ( measurement.
units() )
139 return measurement.
length();
141 return measurement.
length() * 10.0;
143 return measurement.
length() * 1000.0;
145 return measurement.
length() * 25.4;
147 return measurement.
length() * 304.8;
149 return measurement.
length() * 0.352777778;
151 return measurement.
length() * 4.23333333;
153 return measurement.
length() * 25.4 / mDpi;
157 return measurement.
length();
160 double QgsLayoutMeasurementConverter::convertToCentimeters(
const QgsLayoutMeasurement measurement )
const
162 return convertToMillimeters( measurement ) / 10.0;
165 double QgsLayoutMeasurementConverter::convertToMeters(
const QgsLayoutMeasurement measurement )
const
167 return convertToMillimeters( measurement ) / 1000.0;
170 double QgsLayoutMeasurementConverter::convertToInches(
const QgsLayoutMeasurement measurement )
const
172 return convertToMillimeters( measurement ) / 25.4;
175 double QgsLayoutMeasurementConverter::convertToFeet(
const QgsLayoutMeasurement measurement )
const
177 return convertToMillimeters( measurement ) / 304.8;
180 double QgsLayoutMeasurementConverter::convertToPoints(
const QgsLayoutMeasurement measurement )
const
182 return convertToMillimeters( measurement ) * 2.83464567;
185 double QgsLayoutMeasurementConverter::convertToPicas(
const QgsLayoutMeasurement measurement )
const
187 return convertToMillimeters( measurement ) * 0.236220472;
190 double QgsLayoutMeasurementConverter::convertToPixels(
const QgsLayoutMeasurement measurement )
const
192 return convertToMillimeters( measurement ) * mDpi / 25.4;