Skip to content
Permalink
Browse files

rotated ticks followup : add some data defined settings (just one)

  • Loading branch information
olivierdalang authored and nyalldawson committed Oct 7, 2020
1 parent a251699 commit a85b6c5124fadbf07a00d4137ab8831eaba980cb
@@ -15,6 +15,7 @@
* *
***************************************************************************/

#include "qgsmessagelog.h"
#include "qgslayoutitemmapgrid.h"
#include "qgslayoututils.h"
#include "qgsclipper.h"
@@ -1892,7 +1893,7 @@ bool QgsLayoutItemMapGrid::shouldShowAnnotationForSide( QgsLayoutItemMapGrid::An
switch ( side )
{
case QgsLayoutItemMapGrid::Left:
return shouldShowForDisplayMode( coordinate, mLeftGridAnnotationDisplay );
return shouldShowForDisplayMode( coordinate, mEvaluatedLeftGridAnnotationDisplay );
case QgsLayoutItemMapGrid::Right:
return shouldShowForDisplayMode( coordinate, mRightGridAnnotationDisplay );
case QgsLayoutItemMapGrid::Top:
@@ -1910,6 +1911,19 @@ bool QgsLayoutItemMapGrid::shouldShowForDisplayMode( QgsLayoutItemMapGrid::Annot
|| ( mode == QgsLayoutItemMapGrid::LongitudeOnly && coordinate == QgsLayoutItemMapGrid::Longitude );
}

/*
QgsLayoutItemMapGrid::DisplayMode gridAnnotationDisplayModeFromDD(QString ddValue) {
if( ddValue == QStringLiteral("x_only") )
return QgsLayoutItemMapGrid::LatitudeOnly;
else if ( ddValue == QStringLiteral("y_only") )
return QgsLayoutItemMapGrid::LongitudeOnly;
else if ( ddValue == QStringLiteral("disabled") )
return QgsLayoutItemMapGrid::HideAll;
else // if ( ddValue == QStringLiteral("all") )
return QgsLayoutItemMapGrid::ShowAll;
}
*/

void QgsLayoutItemMapGrid::refreshDataDefinedProperties()
{
QgsExpressionContext context = createExpressionContext();
@@ -1952,6 +1966,16 @@ void QgsLayoutItemMapGrid::refreshDataDefinedProperties()
mEvaluatedAnnotationFrameDistance = mDataDefinedProperties.valueAsDouble( QgsLayoutObject::MapGridLabelDistance, context, mAnnotationFrameDistance );
mEvaluatedCrossLength = mDataDefinedProperties.valueAsDouble( QgsLayoutObject::MapGridCrossSize, context, mCrossLength );
mEvaluatedGridFrameLineThickness = mDataDefinedProperties.valueAsDouble( QgsLayoutObject::MapGridFrameLineThickness, context, mGridFramePenThickness );
QString leftGridAnnotationDisplayStr = mDataDefinedProperties.valueAsString( QgsLayoutObject::MapGridAnnotationDisplayLeft, context, QStringLiteral("all") );
QgsMessageLog::logMessage(QStringLiteral("DEBUG MAPGRID : ") + leftGridAnnotationDisplayStr, QStringLiteral("DEBUGDEBUG"));
if( leftGridAnnotationDisplayStr == QStringLiteral("x_only") )
mEvaluatedLeftGridAnnotationDisplay = LatitudeOnly;
else if ( leftGridAnnotationDisplayStr == QStringLiteral("y_only") )
mEvaluatedLeftGridAnnotationDisplay = LongitudeOnly;
else if ( leftGridAnnotationDisplayStr == QStringLiteral("disabled") )
mEvaluatedLeftGridAnnotationDisplay = HideAll;
else // if ( leftGridAnnotationDisplayStr == QStringLiteral("all") )
mEvaluatedLeftGridAnnotationDisplay = ShowAll;
}

double QgsLayoutItemMapGrid::mapWidth() const
@@ -1186,6 +1186,7 @@ class CORE_EXPORT QgsLayoutItemMapGrid : public QgsLayoutItemMapItem
double mEvaluatedAnnotationFrameDistance = 0;
double mEvaluatedCrossLength = 0;
double mEvaluatedGridFrameLineThickness = 0;
DisplayMode mEvaluatedLeftGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;

/**
* Updates the grid lines annotation positions
@@ -78,6 +78,7 @@ void QgsLayoutObject::initPropertyDefinitions()
{ QgsLayoutObject::MapGridCrossSize, QgsPropertyDefinition( "dataDefinedMapGridCrossSize", QObject::tr( "Grid cross size" ), QgsPropertyDefinition::DoublePositive ) },
{ QgsLayoutObject::MapGridFrameMargin, QgsPropertyDefinition( "dataDefinedMapGridFrameMargin", QObject::tr( "Grid frame margin" ), QgsPropertyDefinition::DoublePositive ) },
{ QgsLayoutObject::MapGridLabelDistance, QgsPropertyDefinition( "dataDefinedMapGridLabelDistance", QObject::tr( "Grid label distance" ), QgsPropertyDefinition::DoublePositive ) },
{ QgsLayoutObject::MapGridAnnotationDisplayLeft, QgsPropertyDefinition( "dataDefinedMapGridAnnotationDisplayLeft", QgsPropertyDefinition::DataTypeString, QObject::tr( "Map grid annotation display left" ), QObject::tr( "string " ) + QLatin1String( "[<b>all</b>|<b>x_only</b>|<b>y_only</b>|<b>disabled</b>]" ) ) },
{ QgsLayoutObject::PictureSource, QgsPropertyDefinition( "dataDefinedSource", QObject::tr( "Picture source (URL)" ), QgsPropertyDefinition::String ) },
{ QgsLayoutObject::SourceUrl, QgsPropertyDefinition( "dataDefinedSourceUrl", QObject::tr( "Source URL" ), QgsPropertyDefinition::String ) },
{ QgsLayoutObject::PictureSvgBackgroundColor, QgsPropertyDefinition( "dataDefinedSvgBackgroundColor", QObject::tr( "SVG background color" ), QgsPropertyDefinition::ColorWithAlpha ) },
@@ -174,6 +174,7 @@ class CORE_EXPORT QgsLayoutObject: public QObject, public QgsExpressionContextGe
MapGridLabelDistance, //!< Map grid label distance
MapGridCrossSize, //!< Map grid cross size
MapGridFrameLineThickness, //!< Map grid frame line thickness
MapGridAnnotationDisplayLeft, //!< Map annotation display left
//composer picture
PictureSource, //!< Picture source url
PictureSvgBackgroundColor, //!< SVG background color
@@ -189,6 +189,7 @@ QgsLayoutMapGridWidget::QgsLayoutMapGridWidget( QgsLayoutItemMapGrid *mapGrid, Q
registerDataDefinedButton( mLabelDistDDBtn, QgsLayoutObject::MapGridLabelDistance );
registerDataDefinedButton( mCrossWidthDDBtn, QgsLayoutObject::MapGridCrossSize );
registerDataDefinedButton( mFrameLineThicknessDDBtn, QgsLayoutObject::MapGridFrameLineThickness );
registerDataDefinedButton( mAnnotationDisplayLeftDDBtn, QgsLayoutObject::MapGridAnnotationDisplayLeft );

updateGuiElements();

@@ -223,6 +224,7 @@ void QgsLayoutMapGridWidget::populateDataDefinedButtons()
updateDataDefinedButton( mLabelDistDDBtn );
updateDataDefinedButton( mCrossWidthDDBtn );
updateDataDefinedButton( mFrameLineThicknessDDBtn );
updateDataDefinedButton( mAnnotationDisplayLeftDDBtn );
}

void QgsLayoutMapGridWidget::setGuiElementValues()
@@ -49,7 +49,7 @@
<x>0</x>
<y>0</y>
<width>492</width>
<height>1209</height>
<height>1211</height>
</rect>
</property>
<property name="sizePolicy">
@@ -232,7 +232,7 @@
<double>9999999.000000000000000</double>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
<bool>true</bool>
</property>
</widget>
</item>
@@ -694,6 +694,9 @@
<property name="toolTip">
<string>Grid lines intersecting the border below this threshold will be ignored.</string>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
<property name="suffix">
<string> °</string>
</property>
@@ -706,9 +709,6 @@
<property name="value">
<double>0.000000000000000</double>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
@@ -723,6 +723,9 @@
<property name="toolTip">
<string>Outwards facing ticks closer to the corners than this margin will be ignored.</string>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
<property name="suffix">
<string> mm</string>
</property>
@@ -732,9 +735,6 @@
<property name="value">
<double>0.000000000000000</double>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
@@ -771,25 +771,35 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0">
<item row="15" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationPositionBottomComboBox"/>
</item>
<item row="10" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationDirectionComboBoxRight"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="mAnnotationPositionLabelRight">
<property name="text">
<string>Right</string>
</property>
</widget>
</item>
<item row="8" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationDisplayRightComboBox"/>
<item row="7" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationDirectionComboBoxLeft"/>
</item>
<item row="6" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationPositionLeftComboBox"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mAnnotationFormatLabel">
<property name="text">
<string>Format</string>
</property>
</widget>
</item>
<item row="8" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationDisplayRightComboBox"/>
</item>
<item row="9" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationPositionRightComboBox"/>
</item>
<item row="10" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationDirectionComboBoxRight"/>
</item>
<item row="0" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
@@ -808,6 +818,19 @@
</item>
</layout>
</item>
<item row="14" column="0">
<widget class="QLabel" name="mAnnotationPositionLabelBottom">
<property name="text">
<string>Bottom</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="15" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationPositionBottomComboBox"/>
</item>
<item row="11" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationDisplayTopComboBox"/>
</item>
@@ -834,29 +857,25 @@
<item row="13" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationDirectionComboBoxTop"/>
</item>
<item row="14" column="0">
<widget class="QLabel" name="mAnnotationPositionLabelBottom">
<property name="text">
<string>Bottom</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<item row="16" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationDirectionComboBoxBottom"/>
</item>
<item row="7" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationDirectionComboBoxLeft"/>
<item row="14" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationDisplayBottomComboBox"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mAnnotationFormatLabel">
<item row="17" column="1" colspan="2">
<widget class="QgsFontButton" name="mAnnotationFontButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Format</string>
<string>Font</string>
</property>
</widget>
</item>
<item row="9" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationPositionRightComboBox"/>
</item>
<item row="20" column="1" colspan="2">
<widget class="QgsSpinBox" name="mCoordinatePrecisionSpinBox">
<property name="showClearButton" stdset="0">
@@ -874,25 +893,19 @@
</property>
</widget>
</item>
<item row="18" column="1">
<widget class="QgsDoubleSpinBox" name="mDistanceToMapFrameSpinBox">
<property name="suffix">
<string> mm</string>
</property>
</widget>
</item>
<item row="18" column="2">
<widget class="QgsPropertyOverrideButton" name="mLabelDistDDBtn">
<property name="text">
<string>…</string>
</property>
</widget>
</item>
<item row="16" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationDirectionComboBoxBottom"/>
</item>
<item row="14" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationDisplayBottomComboBox"/>
<item row="18" column="1">
<widget class="QgsDoubleSpinBox" name="mDistanceToMapFrameSpinBox">
<property name="suffix">
<string> mm</string>
</property>
</widget>
</item>
<item row="20" column="0">
<widget class="QLabel" name="mCoordinatePrecisionLabel">
@@ -904,19 +917,6 @@
</property>
</widget>
</item>
<item row="17" column="1" colspan="2">
<widget class="QgsFontButton" name="mAnnotationFontButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item row="21" column="0" colspan="3">
<widget class="QGroupBox" name="mRotatedAnnotationsGroupBox">
<property name="title">
@@ -935,9 +935,9 @@
</item>
<item row="0" column="1">
<widget class="QComboBox" name="mRotatedAnnotationsLengthModeComboBox">
<property name="toolTip">
<string>Determines how the ticks length is defined when rotated.</string>
</property>
<property name="toolTip">
<string>Determines how the ticks length is defined when rotated.</string>
</property>
</widget>
</item>
<item row="1" column="0">
@@ -952,6 +952,9 @@
<property name="toolTip">
<string>Grid lines intersecting the border below this threshold will be ignored.</string>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
<property name="suffix">
<string> °</string>
</property>
@@ -961,9 +964,6 @@
<property name="maximum">
<double>90.000000000000000</double>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
@@ -978,6 +978,9 @@
<property name="toolTip">
<string>Outwards facing annotations closer to the corners than this margin will be ignored.</string>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
<property name="suffix">
<string> mm</string>
</property>
@@ -987,18 +990,26 @@
<property name="value">
<double>0.000000000000000</double>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QComboBox" name="mAnnotationDisplayLeftComboBox"/>
<item row="1" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QComboBox" name="mAnnotationDisplayLeftComboBox"/>
</item>
<item>
<widget class="QgsPropertyOverrideButton" name="mAnnotationDisplayLeftDDBtn">
<property name="text">
<string>…</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<item row="1" column="0">
<widget class="QLabel" name="mAnnotationPositionLabelLeft">
<property name="text">
<string>Left</string>

0 comments on commit a85b6c5

Please sign in to comment.
You can’t perform that action at this time.