22
22
#include " qgisapp.h"
23
23
#include " qgsapplication.h"
24
24
#include " qgsdiagramproperties.h"
25
+ #include " qgsdiagramrendererv2.h"
25
26
#include " qgslabelengineconfigdialog.h"
27
+ #include " qgsmessagebar.h"
26
28
#include " qgsvectorlayerproperties.h"
27
- #include " qgsdiagramrendererv2.h"
28
29
#include " qgsvectordataprovider.h"
29
30
30
31
#include < QColorDialog>
31
32
#include < QFontDialog>
32
33
#include < QList>
33
34
#include < QMessageBox>
35
+ #include < QSettings>
34
36
35
37
QgsDiagramProperties::QgsDiagramProperties ( QgsVectorLayer* layer, QWidget* parent )
36
38
: QWidget( parent )
@@ -44,6 +46,10 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
44
46
45
47
setupUi ( this );
46
48
49
+ int tabIdx = QSettings ().value ( " /Windows/VectorLayerProperties/diagram/tab" , 0 ).toInt ();
50
+
51
+ mDiagramPropertiesTabWidget ->setCurrentIndex ( tabIdx );
52
+
47
53
mBackgroundColorButton ->setColorDialogTitle ( tr ( " Background color" ) );
48
54
mBackgroundColorButton ->setColorDialogOptions ( QColorDialog::ShowAlphaChannel );
49
55
mDiagramPenColorButton ->setColorDialogTitle ( tr ( " Pen color" ) );
@@ -142,7 +148,9 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
142
148
mLabelPlacementComboBox ->setCurrentIndex ( mLabelPlacementComboBox ->findText ( tr ( " x-height" ) ) );
143
149
mDiagramSizeSpinBox ->setValue ( 30 );
144
150
mBarWidthSpinBox ->setValue ( 5 );
145
- mVisibilityGroupBox ->setChecked ( false );
151
+ mVisibilityGroupBox ->setChecked ( layer->hasScaleBasedVisibility () );
152
+ mMaximumDiagramScaleLineEdit ->setText ( QString::number ( layer->maximumScale () ) );
153
+ mMinimumDiagramScaleLineEdit ->setText ( QString::number ( layer->minimumScale () ) );
146
154
147
155
switch ( layerType )
148
156
{
@@ -467,6 +475,9 @@ void QgsDiagramProperties::on_mEngineSettingsButton_clicked()
467
475
468
476
void QgsDiagramProperties::apply ()
469
477
{
478
+ QSettings ().setValue ( " /Windows/VectorLayerProperties/diagram/tab" ,
479
+ mDiagramPropertiesTabWidget ->currentIndex () );
480
+
470
481
if ( !mDisplayDiagramsGroupBox ->isChecked () )
471
482
{
472
483
mLayer ->setDiagramRenderer ( 0 );
@@ -484,20 +495,40 @@ void QgsDiagramProperties::apply()
484
495
}
485
496
486
497
bool scaleAttributeValueOk = false ;
487
- if ( diagramType == DIAGRAM_NAME_HISTOGRAM )
488
- {
489
- // We don't need a scale attribute, the field is used as a multiplicator
490
- scaleAttributeValueOk = true ;
491
- }
492
- else
493
- {
494
- // Check if a (usable) scale attribute value is inserted
495
- mValueLineEdit ->text ().toDouble ( &scaleAttributeValueOk );
496
- }
498
+ // Check if a (usable) scale attribute value is inserted
499
+ mValueLineEdit ->text ().toDouble ( &scaleAttributeValueOk );
500
+
497
501
if ( !mFixedSizeCheckBox ->isChecked () && !scaleAttributeValueOk )
498
502
{
499
- QMessageBox::warning ( this , tr ( " No attribute value specified" ),
500
- tr ( " You did not specify a maximum value for the diagram size. Please specify the attribute and a reference value as a base for scaling in the Tab Diagram / Size." ), QMessageBox::Ok );
503
+ double maxVal = DBL_MIN;
504
+ QgsVectorDataProvider* provider = mLayer ->dataProvider ();
505
+
506
+ if ( provider )
507
+ {
508
+ if ( diagramType == DIAGRAM_NAME_HISTOGRAM )
509
+ {
510
+ // Find maximum value
511
+ for ( int i = 0 ; i < mDiagramAttributesTreeWidget ->topLevelItemCount (); ++i )
512
+ {
513
+ maxVal = qMax ( maxVal, provider->maximumValue ( mDiagramAttributesTreeWidget ->topLevelItem ( i )->data ( 0 , Qt::UserRole ).toInt () ).toDouble () );
514
+ }
515
+ }
516
+ else
517
+ {
518
+ maxVal = provider->maximumValue ( mSizeAttributeComboBox ->itemData ( mSizeAttributeComboBox ->currentIndex () ).toInt () ).toDouble ();
519
+ }
520
+ }
521
+
522
+ if ( maxVal != DBL_MIN )
523
+ {
524
+ QgisApp::instance ()->messageBar ()->pushMessage (
525
+ tr ( " Interpolation value" ),
526
+ tr ( " You did not specify an interpolation value. A default value of %1 has been set." ).arg ( QString::number ( maxVal ) ),
527
+ QgsMessageBar::INFO,
528
+ 5 );
529
+
530
+ mValueLineEdit ->setText ( QString::number ( maxVal ) );
531
+ }
501
532
}
502
533
503
534
if ( diagramType == DIAGRAM_NAME_TEXT )
0 commit comments