forked from qgis/QGIS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gui] Introduce StackedDiagramProperties and use it as dialog and as …
…vector properties page. For the moment, it works with single diagrams, hiding controls for stacked diagrams
- Loading branch information
1 parent
77cdffe
commit c56cd64
Showing
20 changed files
with
446 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# The following has been generated automatically from src/core/diagram/qgsstackeddiagram.h | ||
try: | ||
QgsStackedDiagram.__group__ = ['diagram'] | ||
except NameError: | ||
pass | ||
try: | ||
QgsStackedDiagram.DiagramData.__group__ = ['diagram'] | ||
except NameError: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# The following has been generated automatically from src/core/diagram/qgsstackeddiagram.h | ||
try: | ||
QgsStackedDiagram.__group__ = ['diagram'] | ||
except NameError: | ||
pass | ||
try: | ||
QgsStackedDiagram.DiagramData.__group__ = ['diagram'] | ||
except NameError: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/*************************************************************************** | ||
qgsstackeddiagramproperties.h | ||
Properties for stacked diagram layers | ||
------------------- | ||
begin : August 2024 | ||
copyright : (C) Germán Carrillo | ||
email : german at opengis dot ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsstackeddiagramproperties.h" | ||
#include "qgsdiagramproperties.h" | ||
|
||
|
||
QgsStackedDiagramProperties::QgsStackedDiagramProperties( QgsVectorLayer *layer, QWidget *parent, QgsMapCanvas *canvas ) | ||
: QWidget{parent} | ||
, mMapCanvas( canvas ) | ||
{ | ||
mLayer = layer; | ||
if ( !layer ) | ||
{ | ||
return; | ||
} | ||
|
||
setupUi( this ); | ||
connect( mDiagramTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsStackedDiagramProperties::mDiagramTypeComboBox_currentIndexChanged ); | ||
|
||
// Initialize stacked diagram controls | ||
mDiagramTypeComboBox->addItem( tr( "Single diagram" ), QgsDiagramLayerSettings::Single ); | ||
mDiagramTypeComboBox->addItem( tr( "Stacked diagrams" ), QgsDiagramLayerSettings::Stacked ); | ||
mStackedDiagramModeComboBox->addItem( tr( "Horizontal" ), QgsDiagramSettings::Horizontal ); | ||
mStackedDiagramModeComboBox->addItem( tr( "Vertical" ), QgsDiagramSettings::Vertical ); | ||
|
||
mStackedDiagramSpacingSpinBox->setClearValue( 0 ); | ||
mStackedDiagramSpacingUnitComboBox->setUnits( { Qgis::RenderUnit::Millimeters, | ||
Qgis::RenderUnit::MetersInMapUnits, | ||
Qgis::RenderUnit::MapUnits, | ||
Qgis::RenderUnit::Pixels, | ||
Qgis::RenderUnit::Points, | ||
Qgis::RenderUnit::Inches } ); | ||
|
||
// Add default subdiagram tab | ||
gui = new QgsDiagramProperties( layer, this, mMapCanvas ); | ||
gui->layout()->setContentsMargins( 0, 0, 0, 0 ); | ||
QVBoxLayout *vLayout = new QVBoxLayout(); | ||
vLayout->addWidget( gui ); | ||
QWidget *w = new QWidget(); | ||
w->setLayout( vLayout ); | ||
|
||
connect( gui, &QgsDiagramProperties::auxiliaryFieldCreated, this, &QgsStackedDiagramProperties::auxiliaryFieldCreated ); | ||
|
||
mSubDiagramsTabWidget->addTab( w, tr( "Diagram 1" ) ); | ||
} | ||
|
||
void QgsStackedDiagramProperties::apply() | ||
{ | ||
if ( mDiagramTypeComboBox->currentData( Qt::UserRole ) == QgsDiagramLayerSettings::Single ) | ||
{ | ||
gui->apply(); | ||
} | ||
} | ||
|
||
void QgsStackedDiagramProperties::syncToLayer() | ||
{ | ||
if ( mDiagramTypeComboBox->currentData( Qt::UserRole ) == QgsDiagramLayerSettings::Single ) | ||
{ | ||
gui->syncToLayer(); | ||
} | ||
} | ||
|
||
void QgsStackedDiagramProperties::mDiagramTypeComboBox_currentIndexChanged( int index ) | ||
{ | ||
if ( index == 0 ) | ||
{ | ||
mStackedDiagramSettingsFrame->hide(); | ||
} | ||
else | ||
{ | ||
mStackedDiagramSettingsFrame->show(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/*************************************************************************** | ||
qgsstackeddiagramproperties.h | ||
Properties for stacked diagram layers | ||
------------------- | ||
begin : August 2024 | ||
copyright : (C) Germán Carrillo | ||
email : german at opengis dot ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSSTACKEDDIAGRAMPROPERTIES_H | ||
#define QGSSTACKEDDIAGRAMPROPERTIES_H | ||
|
||
// We don't want to expose this in the public API | ||
#define SIP_NO_FILE | ||
|
||
#include "qgis_gui.h" | ||
#include "ui_qgsstackeddiagrampropertiesbase.h" | ||
|
||
#include <QWidget> | ||
#include <QDialog> | ||
|
||
class QgsVectorLayer; | ||
class QgsMapCanvas; | ||
class QgsDiagramProperties; | ||
|
||
|
||
/** | ||
* \ingroup gui | ||
* \class QgsStackedDiagramProperties | ||
* | ||
* \since QGIS 3.40 | ||
*/ | ||
class GUI_EXPORT QgsStackedDiagramProperties : public QWidget, private Ui::QgsStackedDiagramPropertiesBase | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit QgsStackedDiagramProperties( QgsVectorLayer *layer, QWidget *parent, QgsMapCanvas *canvas ); | ||
|
||
/** | ||
* Updates the widget to reflect the layer's current diagram settings. | ||
*/ | ||
void syncToLayer(); | ||
|
||
signals: | ||
void auxiliaryFieldCreated(); | ||
|
||
public slots: | ||
void apply(); | ||
void mDiagramTypeComboBox_currentIndexChanged( int index ); | ||
|
||
private: | ||
QgsVectorLayer *mLayer = nullptr; | ||
QgsMapCanvas *mMapCanvas = nullptr; | ||
QgsDiagramProperties *gui = nullptr; | ||
|
||
}; | ||
|
||
#endif // QGSSTACKEDDIAGRAMPROPERTIES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.