mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-20 00:06:36 -04:00
graduated dialogs keep settings now if classification field or classification mode are changed
git-svn-id: http://svn.osgeo.org/qgis/trunk@1407 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
c2fd2985d3
commit
0936e4304e
@ -111,8 +111,8 @@ QgsGraMaDialog::QgsGraMaDialog(QgsVectorLayer* layer): QgsGraMaDialogBase(), ext
|
|||||||
|
|
||||||
//do the necessary signal/slot connections
|
//do the necessary signal/slot connections
|
||||||
QObject::connect(mNumberOfClassesSpinbox, SIGNAL(valueChanged(int)), this, SLOT(adjustNumberOfClasses()));
|
QObject::connect(mNumberOfClassesSpinbox, SIGNAL(valueChanged(int)), this, SLOT(adjustNumberOfClasses()));
|
||||||
QObject::connect(mClassificationComboBox, SIGNAL(activated(int)), this, SLOT(adjustNumberOfClasses()));
|
QObject::connect(mClassificationComboBox, SIGNAL(activated(int)), this, SLOT(adjustClassification()));
|
||||||
QObject::connect(mModeComboBox, SIGNAL(activated(int)), this, SLOT(adjustNumberOfClasses()));
|
QObject::connect(mModeComboBox, SIGNAL(activated(int)), this, SLOT(adjustClassification()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsGraMaDialog::QgsGraMaDialog()
|
QgsGraMaDialog::QgsGraMaDialog()
|
||||||
@ -358,3 +358,29 @@ void QgsGraMaDialog::adjustNumberOfClasses()
|
|||||||
QgsGraMaDialogBaseLayout->addMultiCellWidget(ext, 5, 5, 0, 3);
|
QgsGraMaDialogBaseLayout->addMultiCellWidget(ext, 5, 5, 0, 3);
|
||||||
ext->show();
|
ext->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsGraMaDialog::adjustClassification()
|
||||||
|
{
|
||||||
|
//find out the number of the classification field
|
||||||
|
QString fieldstring = mClassificationComboBox->currentText();
|
||||||
|
if (fieldstring.isEmpty()) //don't do anything, it there is no classification field
|
||||||
|
{
|
||||||
|
show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map < QString, int >::iterator iter = mFieldMap.find(fieldstring);
|
||||||
|
int field = iter->second;
|
||||||
|
|
||||||
|
if(ext)
|
||||||
|
{
|
||||||
|
if (mModeComboBox->currentText() == "Empty")
|
||||||
|
{
|
||||||
|
ext->setClassification(QgsGraSyDialog::EMPTY,field);
|
||||||
|
}
|
||||||
|
else if(mModeComboBox->currentText() == "Equal Interval")
|
||||||
|
{
|
||||||
|
ext->setClassification(QgsGraSyDialog::EQUAL_INTERVAL,field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -43,6 +43,8 @@ public slots:
|
|||||||
protected slots:
|
protected slots:
|
||||||
/**Creates a new extension widget*/
|
/**Creates a new extension widget*/
|
||||||
void adjustNumberOfClasses();
|
void adjustNumberOfClasses();
|
||||||
|
/**Tells the extensionwidget to change the values of the lower and upper text fields*/
|
||||||
|
void adjustClassification();
|
||||||
private:
|
private:
|
||||||
/**Default constructor is privat to not use is*/
|
/**Default constructor is privat to not use is*/
|
||||||
QgsGraMaDialog();
|
QgsGraMaDialog();
|
||||||
|
@ -118,8 +118,6 @@ QgsGraMaExtensionWidget::QgsGraMaExtensionWidget(QWidget* parent, int classfield
|
|||||||
}
|
}
|
||||||
|
|
||||||
addChild(mWidget);
|
addChild(mWidget);
|
||||||
//resizeContents(200,50*(mNumberOfClasses+1));
|
|
||||||
//updateContents();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,3 +218,40 @@ void QgsGraMaExtensionWidget::handleReturnPressed()
|
|||||||
}
|
}
|
||||||
adjustMarker(indexnumber);
|
adjustMarker(indexnumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsGraMaExtensionWidget::setClassification(QgsGraSyDialog::mode mode, int field)
|
||||||
|
{
|
||||||
|
mClassField=field;
|
||||||
|
mMode=mode;
|
||||||
|
|
||||||
|
QgsDataProvider *provider=mVectorLayer->getDataProvider();
|
||||||
|
|
||||||
|
if (provider)
|
||||||
|
{
|
||||||
|
if (mMode == QgsGraSyDialog::EQUAL_INTERVAL)
|
||||||
|
{
|
||||||
|
double minimum=0;
|
||||||
|
double maximum=0;
|
||||||
|
|
||||||
|
minimum = provider->minValue(mClassField).toDouble();
|
||||||
|
maximum = provider->maxValue(mClassField).toDouble();
|
||||||
|
|
||||||
|
for(int i=0;i<mNumberOfClasses;++i)
|
||||||
|
{
|
||||||
|
((QLineEdit*)getWidget(0,i))->setText(QString::number(minimum + (maximum - minimum) / mNumberOfClasses * i, 'f', 2));
|
||||||
|
((QLineEdit*)getWidget(1,i))->setText(QString::number(minimum + (maximum - minimum) / mNumberOfClasses * (i+1), 'f', 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (mMode == QgsGraSyDialog::EMPTY) //don't waste performance if mMode is QgsGraSyDialog::EMPTY
|
||||||
|
{
|
||||||
|
for(int i=0;i<mNumberOfClasses;++i)
|
||||||
|
{
|
||||||
|
((QLineEdit*)getWidget(0,i))->clear();
|
||||||
|
((QLineEdit*)getWidget(1,i))->clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -47,6 +47,8 @@ class QgsGraMaExtensionWidget: public QScrollView
|
|||||||
void adjustMarkers();
|
void adjustMarkers();
|
||||||
/**Adjusts the marker size in one row*/
|
/**Adjusts the marker size in one row*/
|
||||||
void adjustMarker(int row);
|
void adjustMarker(int row);
|
||||||
|
/**Changes the classification*/
|
||||||
|
void setClassification(QgsGraSyDialog::mode mode,int field);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**Number of the field to classify*/
|
/**Number of the field to classify*/
|
||||||
|
@ -137,8 +137,8 @@ QgsGraSyDialog::QgsGraSyDialog(QgsVectorLayer * layer):QgsGraSyDialogBase(), ext
|
|||||||
|
|
||||||
//do the necessary signal/slot connections
|
//do the necessary signal/slot connections
|
||||||
QObject::connect(numberofclassesspinbox, SIGNAL(valueChanged(int)), this, SLOT(adjustNumberOfClasses()));
|
QObject::connect(numberofclassesspinbox, SIGNAL(valueChanged(int)), this, SLOT(adjustNumberOfClasses()));
|
||||||
QObject::connect(classificationComboBox, SIGNAL(activated(int)), this, SLOT(adjustNumberOfClasses()));
|
QObject::connect(classificationComboBox, SIGNAL(activated(int)), this, SLOT(adjustClassification()));
|
||||||
QObject::connect(modeComboBox, SIGNAL(activated(int)), this, SLOT(adjustNumberOfClasses()));
|
QObject::connect(modeComboBox, SIGNAL(activated(int)), this, SLOT(adjustClassification()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsGraSyDialog::QgsGraSyDialog()
|
QgsGraSyDialog::QgsGraSyDialog()
|
||||||
@ -384,3 +384,29 @@ void QgsGraSyDialog::apply()
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsGraSyDialog::adjustClassification()
|
||||||
|
{
|
||||||
|
//find out the number of the classification field
|
||||||
|
QString fieldstring = classificationComboBox->currentText();
|
||||||
|
if (fieldstring.isEmpty()) //don't do anything, it there is no classification field
|
||||||
|
{
|
||||||
|
show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map < QString, int >::iterator iter = mFieldMap.find(fieldstring);
|
||||||
|
int field = iter->second;
|
||||||
|
|
||||||
|
if(ext)
|
||||||
|
{
|
||||||
|
if (modeComboBox->currentText() == "Empty")
|
||||||
|
{
|
||||||
|
ext->setClassification(QgsGraSyDialog::EMPTY,field);
|
||||||
|
}
|
||||||
|
else if(modeComboBox->currentText() == "Equal Interval")
|
||||||
|
{
|
||||||
|
ext->setClassification(QgsGraSyDialog::EQUAL_INTERVAL,field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -39,6 +39,8 @@ class QgsGraSyDialog: public QgsGraSyDialogBase
|
|||||||
protected slots:
|
protected slots:
|
||||||
/**Creates a new extension widget*/
|
/**Creates a new extension widget*/
|
||||||
void adjustNumberOfClasses();
|
void adjustNumberOfClasses();
|
||||||
|
/**Tells the extensionwidget to change the values of the lower and upper text fields*/
|
||||||
|
void adjustClassification();
|
||||||
protected:
|
protected:
|
||||||
/**Pointer to the curret extension widget*/
|
/**Pointer to the curret extension widget*/
|
||||||
QgsGraSyExtensionWidget* ext;
|
QgsGraSyExtensionWidget* ext;
|
||||||
|
@ -257,3 +257,41 @@ void QgsGraSyExtensionWidget::selectOutlineStyle()
|
|||||||
((QPushButton *) sender())->setPixmap(QgsSymbologyUtils::penStyle2Pixmap(linestyledialog.style()));
|
((QPushButton *) sender())->setPixmap(QgsSymbologyUtils::penStyle2Pixmap(linestyledialog.style()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsGraSyExtensionWidget::setClassification(QgsGraSyDialog::mode mode,int field)
|
||||||
|
{
|
||||||
|
double minimum=0;
|
||||||
|
double maximum=0;
|
||||||
|
|
||||||
|
m_classfield=field;
|
||||||
|
mMode=mode;
|
||||||
|
|
||||||
|
QgsDataProvider *provider=mVectorLayer->getDataProvider();
|
||||||
|
|
||||||
|
if (provider)
|
||||||
|
{
|
||||||
|
if (mMode == QgsGraSyDialog::EQUAL_INTERVAL)
|
||||||
|
{
|
||||||
|
double minimum=0;
|
||||||
|
double maximum=0;
|
||||||
|
|
||||||
|
minimum = provider->minValue(m_classfield).toDouble();
|
||||||
|
maximum = provider->maxValue(m_classfield).toDouble();
|
||||||
|
|
||||||
|
for(int i=0;i<mNumberOfClasses;++i)
|
||||||
|
{
|
||||||
|
((QLineEdit*)getWidget(0,i))->setText(QString::number(minimum + (maximum - minimum) / mNumberOfClasses * i, 'f', 2));
|
||||||
|
((QLineEdit*)getWidget(1,i))->setText(QString::number(minimum + (maximum - minimum) / mNumberOfClasses * (i+1), 'f', 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (mMode == QgsGraSyDialog::EMPTY) //don't waste performance if mMode is QgsGraSyDialog::EMPTY
|
||||||
|
{
|
||||||
|
for(int i=0;i<mNumberOfClasses;++i)
|
||||||
|
{
|
||||||
|
((QLineEdit*)getWidget(0,i))->clear();
|
||||||
|
((QLineEdit*)getWidget(1,i))->clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -45,6 +45,8 @@ class QgsGraSyExtensionWidget: public QScrollView
|
|||||||
int classfield();
|
int classfield();
|
||||||
/**Access to the widget objects. In QgsGraSyDialog, the widgets have to be casted to the proper subclasses to retrieve their information*/
|
/**Access to the widget objects. In QgsGraSyDialog, the widgets have to be casted to the proper subclasses to retrieve their information*/
|
||||||
QWidget* getWidget(int column, int row);
|
QWidget* getWidget(int column, int row);
|
||||||
|
/**Changes the classification*/
|
||||||
|
void setClassification(QgsGraSyDialog::mode mode,int field);
|
||||||
protected:
|
protected:
|
||||||
/**Number of the field to classify*/
|
/**Number of the field to classify*/
|
||||||
int m_classfield;
|
int m_classfield;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user