Skip to content

Commit

Permalink
Changes to the unique value renderer and -dialog: 'classify' and 'del…
Browse files Browse the repository at this point in the history
…ete class' button. Features which do not have a matching symbol are rendered with NoPen and NoBrush

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6472 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jan 29, 2007
1 parent f4ec374 commit a8cec13
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 65 deletions.
53 changes: 37 additions & 16 deletions src/app/qgsuniquevaluedialog.cpp
Expand Up @@ -77,12 +77,9 @@ QgsUniqueValueDialog::QgsUniqueValueDialog(QgsVectorLayer* vl): QDialog(), mVect
mClassBreakBox->insertItem(symbolvalue);
}
}
else
{
changeClassificationAttribute(0);
}

QObject::connect(mClassificationComboBox, SIGNAL(activated(int)), this, SLOT(changeClassificationAttribute(int)));
QObject::connect(mClassifyButton, SIGNAL(clicked()), this, SLOT(changeClassificationAttribute()));
QObject::connect(mDeletePushButton, SIGNAL(clicked()), this, SLOT(deleteCurrentClass()));
QObject::connect(mClassBreakBox, SIGNAL(selectionChanged()), this, SLOT(changeCurrentValue()));
QObject::connect(&sydialog, SIGNAL(settingsChanged()), this, SLOT(applySymbologyChanges()));
mSymbolWidgetStack->addWidget(&sydialog);
Expand Down Expand Up @@ -126,8 +123,9 @@ void QgsUniqueValueDialog::apply()
mVectorLayer->setRenderer(renderer);
}

void QgsUniqueValueDialog::changeClassificationAttribute(int nr)
void QgsUniqueValueDialog::changeClassificationAttribute()
{
int nr = mClassificationComboBox->currentIndex();
//delete old entries
for(std::map<QString,QgsSymbol*>::iterator it=mValues.begin();it!=mValues.end();++it)
{
Expand All @@ -151,7 +149,7 @@ void QgsUniqueValueDialog::changeClassificationAttribute(int nr)
while(provider->getNextFeature(feat, false, attlist))
{
const QgsAttributeMap& vec = feat.attributeMap();
value=vec[0].fieldValue();
value=vec[nr].fieldValue();

if(mValues.find(value)==mValues.end())
{
Expand All @@ -162,7 +160,6 @@ void QgsUniqueValueDialog::changeClassificationAttribute(int nr)

//set symbology for all QgsSiSyDialogs
QColor thecolor;
double frac;

for(std::map<QString,QgsSymbol*>::iterator it=mValues.begin();it!=mValues.end();++it)
{
Expand Down Expand Up @@ -200,18 +197,42 @@ void QgsUniqueValueDialog::changeCurrentValue()
{
sydialog.blockSignals(true);//block signal to prevent sydialog from changing the current QgsRenderItem
Q3ListBoxItem* item=mClassBreakBox->selectedItem();
QString value=item->text();
std::map<QString,QgsSymbol*>::iterator it=mValues.find(value);
if(it!=mValues.end())
if(item)
{
QString value=item->text();
std::map<QString,QgsSymbol*>::iterator it=mValues.find(value);
if(it!=mValues.end())
{
sydialog.set( it->second);
sydialog.setLabel(it->second->label());
}
else
{
//no entry found
}
}
sydialog.blockSignals(false);
}

void QgsUniqueValueDialog::deleteCurrentClass()
{
QString classValue = mClassBreakBox->currentText();
int currentIndex = mClassBreakBox->currentItem();
mValues.erase(classValue);
mClassBreakBox->removeItem(currentIndex);
qWarning("numRows: ");
qWarning(QString::number(mClassBreakBox->numRows()));
//
if(mClassBreakBox->numRows() < (currentIndex + 1))
{
sydialog.set( it->second);
sydialog.setLabel(it->second->label());
qWarning("selecting numRows - 1");
mClassBreakBox->setSelected(mClassBreakBox->numRows() - 1, true);
}
else
else
{
//no entry found
qWarning("selecting currentIndex");
mClassBreakBox->setSelected(currentIndex, true);
}
sydialog.blockSignals(false);
}

void QgsUniqueValueDialog::applySymbologyChanges()
Expand Down
4 changes: 3 additions & 1 deletion src/app/qgsuniquevaluedialog.h
Expand Up @@ -47,9 +47,11 @@ class QgsUniqueValueDialog: public QDialog, private Ui::QgsUniqueValueDialogBase

protected slots:
/**Set new attribut for classification*/
void changeClassificationAttribute(int nr);
void changeClassificationAttribute();
/**Changes the display of the single symbol dialog*/
void changeCurrentValue();
/**Removes a class from the classification*/
void deleteCurrentClass();
/**Writes changes in the single symbol dialog to the corresponding QgsSymbol*/
void applySymbologyChanges();
};
Expand Down
15 changes: 11 additions & 4 deletions src/core/renderer/qgsuniquevaluerenderer.cpp
Expand Up @@ -114,7 +114,7 @@ void QgsUniqueValueRenderer::renderFeature(QPainter* p, QgsFeature& f,QImage* im
}

// Line, polygon
if ( mVectorType != QGis::Point )
else if ( mVectorType != QGis::Point )
{
if( !selected )
{
Expand All @@ -137,9 +137,16 @@ void QgsUniqueValueRenderer::renderFeature(QPainter* p, QgsFeature& f,QImage* im
}
else
{
#ifdef QGISDEBUG
qWarning("Warning, no render item found in QgsUniqueValueRenderer::renderFeature");
#endif
//no matching symbol found. In this case, set Qt::NoPen, Qt::NoBrush or transparent image
if ( img && mVectorType == QGis::Point )
{
//todo: fill image transparent
}
else if ( mVectorType != QGis::Point )
{
p->setPen(Qt::NoPen);
p->setBrush(Qt::NoBrush);
}
}

}
Expand Down
96 changes: 52 additions & 44 deletions src/ui/qgsuniquevaluedialogbase.ui
@@ -1,45 +1,48 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>QgsUniqueValueDialogBase</class>
<widget class="QDialog" name="QgsUniqueValueDialogBase" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>279</height>
<width>505</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form1</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>8</number>
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="2" colspan="2" >
<widget class="Q3ListBox" name="mClassBreakBox" />
<item row="0" column="0" >
<widget class="QLabel" name="mClassVarLabel" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="text" >
<string>Classification Field:</string>
</property>
<property name="buddy" >
<cstring>mClassificationComboBox</cstring>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<widget class="Q3WidgetStack" name="mSymbolWidgetStack" >
<widget class="QWidget" name="WStackPage" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>156</width>
<height>234</height>
</rect>
</property>
</widget>
<item row="0" column="4" >
<widget class="QPushButton" name="mDeletePushButton" >
<property name="text" >
<string>Delete class</string>
</property>
</widget>
</item>
<item row="0" column="3" >
<item row="0" column="5" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
Expand All @@ -49,12 +52,15 @@
</property>
<property name="sizeHint" >
<size>
<width>210</width>
<height>21</height>
<width>51</width>
<height>25</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2" colspan="4" >
<widget class="Q3ListBox" name="mClassBreakBox" />
</item>
<item row="0" column="1" colspan="2" >
<widget class="QComboBox" name="mClassificationComboBox" >
<property name="minimumSize" >
Expand All @@ -65,40 +71,42 @@
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="mClassVarLabel" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<item row="0" column="3" >
<widget class="QPushButton" name="mClassifyButton" >
<property name="text" >
<string>Classification Field:</string>
</property>
<property name="buddy" >
<cstring>mClassificationComboBox</cstring>
<string>Classify</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<widget class="Q3WidgetStack" name="mSymbolWidgetStack" >
<widget class="QWidget" name="WStackPage" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>190</width>
<height>246</height>
</rect>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>Q3ListBox</class>
<extends>Q3Frame</extends>
<header>q3listbox.h</header>
</customwidget>
<customwidget>
<class>Q3WidgetStack</class>
<extends></extends>
<extends>Q3WidgetStack</extends>
<header>q3widgetstack.h</header>
<container>1</container>
<pixmap></pixmap>
</customwidget>
<customwidget>
<class>Q3ListBox</class>
<extends></extends>
<header>q3listbox.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
</customwidgets>
<resources/>
Expand Down

0 comments on commit a8cec13

Please sign in to comment.