Skip to content

Commit ab4606d

Browse files
committedNov 7, 2017
Start work on porting grid ui
1 parent 835653b commit ab4606d

File tree

7 files changed

+2288
-3
lines changed

7 files changed

+2288
-3
lines changed
 

‎python/core/layout/qgslayoutitem.sip

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
6868
UndoMapRotation,
6969
UndoZoomContent,
7070
UndoOverviewStyle,
71+
UndoGridFramePenColor,
72+
UndoMapGridFrameFill1Color,
73+
UndoMapGridFrameFill2Color,
74+
UndoMapAnnotationDistance,
75+
UndoMapGridAnnotationFontColor,
7176
};
7277

7378
explicit QgsLayoutItem( QgsLayout *layout, bool manageZValue = true );

‎src/app/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ SET(QGIS_APP_SRCS
180180
layout/qgslayoutitemslistview.cpp
181181
layout/qgslayoutappmenuprovider.cpp
182182
layout/qgslayoutmapwidget.cpp
183+
layout/qgslayoutmapgridwidget.cpp
183184
layout/qgslayoutpagepropertieswidget.cpp
184185
layout/qgslayoutpolygonwidget.cpp
185186
layout/qgslayoutpolylinewidget.cpp
@@ -380,6 +381,7 @@ SET (QGIS_APP_MOC_HDRS
380381
layout/qgslayoutguidewidget.h
381382
layout/qgslayoutitemslistview.h
382383
layout/qgslayoutmapwidget.h
384+
layout/qgslayoutmapgridwidget.h
383385
layout/qgslayoutpagepropertieswidget.h
384386
layout/qgslayoutpolygonwidget.h
385387
layout/qgslayoutpolylinewidget.h

‎src/app/layout/qgslayoutmapgridwidget.cpp

Lines changed: 1265 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/***************************************************************************
2+
qgslayoutmapgridwidget.h
3+
----------------------
4+
begin : October 2017
5+
copyright : (C) 2017 by Nyall Dawson
6+
email : nyall dot dawson at gmail dot com
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+
#ifndef QGSLAYOUTMAPGRIDWIDGET_H
19+
#define QGSLAYOUTMAPGRIDWIDGET_H
20+
21+
#include "ui_qgslayoutmapgridwidgetbase.h"
22+
#include "qgslayoutitemwidget.h"
23+
#include "qgslayoutitemmapgrid.h"
24+
25+
/**
26+
* \ingroup app
27+
* Input widget for the configuration of QgsLayoutItemMapGrids
28+
* */
29+
class QgsLayoutMapGridWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutMapGridWidgetBase
30+
{
31+
Q_OBJECT
32+
33+
public:
34+
explicit QgsLayoutMapGridWidget( QgsLayoutItemMapGrid *mapGrid, QgsLayoutItemMap *map );
35+
36+
public slots:
37+
38+
void setGridItems();
39+
void mGridLineStyleButton_clicked();
40+
void mGridMarkerStyleButton_clicked();
41+
void mIntervalXSpinBox_editingFinished();
42+
void mIntervalYSpinBox_editingFinished();
43+
void mOffsetXSpinBox_valueChanged( double value );
44+
void mOffsetYSpinBox_valueChanged( double value );
45+
void mCrossWidthSpinBox_valueChanged( double val );
46+
void mFrameWidthSpinBox_valueChanged( double val );
47+
void mFrameStyleComboBox_currentIndexChanged( const QString &text );
48+
void mGridFramePenSizeSpinBox_valueChanged( double d );
49+
void mGridFramePenColorButton_colorChanged( const QColor &newColor );
50+
void mGridFrameFill1ColorButton_colorChanged( const QColor &newColor );
51+
void mGridFrameFill2ColorButton_colorChanged( const QColor &newColor );
52+
void mGridTypeComboBox_currentIndexChanged( const QString &text );
53+
void mMapGridCRSButton_clicked();
54+
void mMapGridUnitComboBox_currentIndexChanged( const QString &text );
55+
void mGridBlendComboBox_currentIndexChanged( int index );
56+
void mCheckGridLeftSide_toggled( bool checked );
57+
void mCheckGridRightSide_toggled( bool checked );
58+
void mCheckGridTopSide_toggled( bool checked );
59+
void mCheckGridBottomSide_toggled( bool checked );
60+
61+
//frame divisions display
62+
void mFrameDivisionsLeftComboBox_currentIndexChanged( int index );
63+
void mFrameDivisionsRightComboBox_currentIndexChanged( int index );
64+
void mFrameDivisionsTopComboBox_currentIndexChanged( int index );
65+
void mFrameDivisionsBottomComboBox_currentIndexChanged( int index );
66+
67+
void mDrawAnnotationGroupBox_toggled( bool state );
68+
void mAnnotationFormatButton_clicked();
69+
70+
//annotation display
71+
void mAnnotationDisplayLeftComboBox_currentIndexChanged( const QString &text );
72+
void mAnnotationDisplayRightComboBox_currentIndexChanged( const QString &text );
73+
void mAnnotationDisplayTopComboBox_currentIndexChanged( const QString &text );
74+
void mAnnotationDisplayBottomComboBox_currentIndexChanged( const QString &text );
75+
76+
//annotation position
77+
void mAnnotationPositionLeftComboBox_currentIndexChanged( const QString &text );
78+
void mAnnotationPositionRightComboBox_currentIndexChanged( const QString &text );
79+
void mAnnotationPositionTopComboBox_currentIndexChanged( const QString &text );
80+
void mAnnotationPositionBottomComboBox_currentIndexChanged( const QString &text );
81+
82+
//annotation direction
83+
void mAnnotationDirectionComboBoxLeft_currentIndexChanged( int index );
84+
void mAnnotationDirectionComboBoxRight_currentIndexChanged( int index );
85+
void mAnnotationDirectionComboBoxTop_currentIndexChanged( int index );
86+
void mAnnotationDirectionComboBoxBottom_currentIndexChanged( int index );
87+
88+
void mAnnotationFormatComboBox_currentIndexChanged( int index );
89+
void mCoordinatePrecisionSpinBox_valueChanged( int value );
90+
void mDistanceToMapFrameSpinBox_valueChanged( double d );
91+
void mAnnotationFontColorButton_colorChanged( const QColor &color );
92+
93+
protected:
94+
95+
//! Sets the current composer map values to the GUI elements
96+
virtual void updateGuiElements();
97+
98+
protected slots:
99+
//! Initializes data defined buttons to current atlas coverage layer
100+
void populateDataDefinedButtons();
101+
102+
private slots:
103+
104+
//! Sets the GUI elements to the values of mPicture
105+
void setGuiElementValues();
106+
107+
void updateGridLineStyleFromWidget();
108+
void cleanUpGridLineStyleSelector( QgsPanelWidget *container );
109+
void updateGridMarkerStyleFromWidget();
110+
void cleanUpGridMarkerStyleSelector( QgsPanelWidget *container );
111+
void annotationFontChanged();
112+
113+
private:
114+
QgsLayoutItemMap *mMap = nullptr;
115+
QgsLayoutItemMapGrid *mMapGrid = nullptr;
116+
117+
//! Blocks / unblocks the signals of all GUI elements
118+
void blockAllSignals( bool b );
119+
120+
void handleChangedFrameDisplay( QgsLayoutItemMapGrid::BorderSide border, const QgsLayoutItemMapGrid::DisplayMode mode );
121+
void handleChangedAnnotationDisplay( QgsLayoutItemMapGrid::BorderSide border, const QString &text );
122+
void handleChangedAnnotationPosition( QgsLayoutItemMapGrid::BorderSide border, const QString &text );
123+
void handleChangedAnnotationDirection( QgsLayoutItemMapGrid::BorderSide border, QgsLayoutItemMapGrid::AnnotationDirection direction );
124+
125+
void insertFrameDisplayEntries( QComboBox *c );
126+
void insertAnnotationDisplayEntries( QComboBox *c );
127+
void insertAnnotationPositionEntries( QComboBox *c );
128+
void insertAnnotationDirectionEntries( QComboBox *c );
129+
130+
void initFrameDisplayBox( QComboBox *c, QgsLayoutItemMapGrid::DisplayMode display );
131+
void initAnnotationDisplayBox( QComboBox *c, QgsLayoutItemMapGrid::DisplayMode display );
132+
void initAnnotationPositionBox( QComboBox *c, QgsLayoutItemMapGrid::AnnotationPosition pos );
133+
void initAnnotationDirectionBox( QComboBox *c, QgsLayoutItemMapGrid::AnnotationDirection dir );
134+
135+
void updateGridLineSymbolMarker();
136+
void updateGridMarkerSymbolMarker();
137+
138+
//! Enables/disables grid frame related controls
139+
void toggleFrameControls( bool frameEnabled, bool frameFillEnabled, bool frameSizeEnabled );
140+
141+
//! Is there some predefined scales, globally or as project's options ?
142+
bool hasPredefinedScales() const;
143+
144+
};
145+
146+
#endif //QGSLAYOUTMAPGRIDWIDGET_H

‎src/app/layout/qgslayoutmapwidget.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "qgsmapcanvas.h"
2727
#include "qgssymbolselectordialog.h"
2828
#include "qgssymbollayerutils.h"
29+
#include "qgslayoutmapgridwidget.h"
2930
#include "qgsstyle.h"
3031
#include <QMenu>
3132
#include <QMessageBox>
@@ -1244,10 +1245,8 @@ void QgsLayoutMapWidget::mGridPropertiesButton_clicked()
12441245
return;
12451246
}
12461247

1247-
#if 0 //TODO
1248-
QgsLayoutItemMapGridWidget *w = new QgsLayoutItemMapGridWidget( grid, mMapItem );
1248+
QgsLayoutMapGridWidget *w = new QgsLayoutMapGridWidget( grid, mMapItem );
12491249
openPanel( w );
1250-
#endif
12511250
}
12521251

12531252
QListWidgetItem *QgsLayoutMapWidget::addGridListItem( const QString &id, const QString &name )

‎src/core/layout/qgslayoutitem.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
101101
UndoMapRotation, //!< Map rotation changed
102102
UndoZoomContent, //!< Item content zoomed
103103
UndoOverviewStyle, //!< Map overview style
104+
UndoGridFramePenColor, //!< Map grid frame pen color
105+
UndoMapGridFrameFill1Color, //!< Map grid frame fill color 1
106+
UndoMapGridFrameFill2Color, //!< Map grid frame fill color 2
107+
UndoMapAnnotationDistance, //!< Map frame annotation distance
108+
UndoMapGridAnnotationFontColor, //!< Map frame annotation color
104109
};
105110

106111
/**

‎src/ui/layout/qgslayoutmapgridwidgetbase.ui

Lines changed: 863 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.