Skip to content

Commit

Permalink
saving and loading of symbology
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@597 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jan 26, 2004
1 parent 75460eb commit 57e1623
Show file tree
Hide file tree
Showing 11 changed files with 438 additions and 61 deletions.
60 changes: 46 additions & 14 deletions qgis.dtd
Expand Up @@ -22,7 +22,7 @@
-- General Map Layer Properties
-- (apply to both vector and raster)
-->
<!ELEMENT maplayer (layername, datasource, zorder, symbol) >
<!ELEMENT maplayer (layername, datasource, zorder, (singlesymbol|graduatedsymbol|continuoussymbol|rasterproperties) >
<!ELEMENT layername (#PCDATA) >
<!ELEMENT datasource (#PCDATA) >
<!ELEMENT zorder (#PCDATA) >
Expand All @@ -31,25 +31,57 @@
type (vector|raster|database) "vector"
visible (1|0) "0"
>

<!--
-- Vector Layer Properties
-- Element symbol contains the settings for a qpainter
--
-->
<!ELEMENT symbol (linewidth, outlinecolor, fillcolor) >
<!ELEMENT linewidth (#PCDATA) >
<!ELEMENT fillcolor EMPTY>
<!ELEMENT outlinecolor EMPTY>
<!-- Attribute Lists -->
<!ATTLIST fillcolor
red CDATA #IMPLIED
green CDATA #IMPLIED
blue CDATA #IMPLIED

<!ELEMENT symbol (outlinecolor,outlinestyle,outlinewidth,fillcolor,fillpattern) >
<!ELEMENT outlinecolor EMPTY >
<!ELEMENT outlinestyle (#PCDATA) >
<!ELEMENT outlinewidth (#PCDATA) >
<!ELEMENT fillcolor EMPTY >
<!ELEMENT fillpattern (#PCDATA) >

<!ATTLIST outlinecolor
red CDATA #REQUIRED
green CDATA #REQUIRED
blue CDATA #REQUIRED
>

<!ATTLIST outlinecolor
red CDATA #IMPLIED
green CDATA #IMPLIED
blue CDATA #IMPLIED
red CDATA #REQUIRED
green CDATA #REQUIRED
blue CDATA #REQUIRED
>

<!--
-- renderitem and rangerenderitem
--
-->

<!ELEMENT renderitem (value,symbol,label) >
<!ELEMENT value (#PCDATA) >
<!ELEMENT label (#PCDATA) >

<!ELEMENT rangerenderitem (lowervalue,uppervalue,symbol,label) >
<!ELEMENT lowervalue (#PCDATA) >
<!ELEMENT uppervalue (#PCDATA) >

<!--
-- elements to store the settings of the different symbology types
--
-->

<!ELEMENT singlesymbol (renderitem) >
<!ELEMENT graduatedsymbol (classificationfield,rangerenderitem+) >
<!ELEMENT classificationfield (#PCDATA) >
<!ELEMENT continuoussymbol (classificationfield,lowestitem,highestitem) >
<!ELEMENT lowestitem (renderitem) >
<!ELEMENT highestitem (renderitem) >


<!--
-- Raster Layer Properties
--
Expand Down
5 changes: 4 additions & 1 deletion src/qgscontcoldialog.cpp
Expand Up @@ -192,7 +192,10 @@ void QgsContColDialog::apply()
p.drawText(leftspace+gradientwidth+wordspace,rangeoffset+gradientheight,QString::number(maximum,'f',2));

m_vectorlayer->triggerRepaint();
m_vectorlayer->legendItem()->setPixmap(0,(*pix));
if(m_vectorlayer->legendItem())
{
m_vectorlayer->legendItem()->setPixmap(0,(*pix));
}
}

void QgsContColDialog::selectMinimumColor()
Expand Down
4 changes: 2 additions & 2 deletions src/qgscontcoldialog.h
Expand Up @@ -12,9 +12,9 @@ class QgsContColDialog: public QgsContColDialogBase
public:
QgsContColDialog(QgsVectorLayer* layer);
~QgsContColDialog();

public slots:
void apply();
protected slots:
void apply();
void selectMinimumColor();
void selectMaximumColor();
protected:
Expand Down
7 changes: 7 additions & 0 deletions src/qgscontinuouscolrenderer.h
Expand Up @@ -38,6 +38,8 @@ class QgsContinuousColRenderer: public QgsRenderer
void initializeSymbology(QgsVectorLayer* layer);
/**Renders the feature using the minimum and maximum value of the classification field*/
void renderFeature(QPainter* p, QgsFeature* f, QgsCoordinateTransform* t);
/**Returns the number of the classification field*/
int classificationField() const;
/**Sets the id of the classification field*/
void setClassificationField(int id);
/**Sets the item for the minimum value. The item has to be created using the new operator and is automatically deleted when inserting a new item or when the instance is destroyed*/
Expand All @@ -64,6 +66,11 @@ inline QgsContinuousColRenderer::QgsContinuousColRenderer(): m_minimumItem(0), m

}

inline int QgsContinuousColRenderer::classificationField() const
{
return m_classificationField;
}

inline void QgsContinuousColRenderer::setClassificationField(int id)
{
m_classificationField=id;
Expand Down
2 changes: 1 addition & 1 deletion src/qgsgraduatedsymrenderer.h
Expand Up @@ -37,7 +37,7 @@ class QgsGraduatedSymRenderer: public QgsRenderer
/**Adds a new item
\param ri a pointer to the QgsRangeRenderItem to be inserted. It has to be created using the new operator and is automatically destroyed when 'removeItems' is called or when the instance is destroyed*/
void addItem(QgsRangeRenderItem* ri);
/**Returns the name of the classification field*/
/**Returns the number of the classification field*/
int classificationField() const;
/**Removes all items*/
void removeItems();
Expand Down
7 changes: 4 additions & 3 deletions src/qgsgrasydialog.cpp
Expand Up @@ -86,7 +86,6 @@ QgsGraSyDialog::QgsGraSyDialog(QgsVectorLayer* layer): QgsGraSyDialogBase(), ext
int number=0;
for(std::list<QgsRangeRenderItem*>::iterator it=list.begin();it!=list.end();++it)
{
qWarning("inside loop");
((QLineEdit*)(ext->getWidget(0,number)))->setText((*it)->value());
((QLineEdit*)ext->getWidget(1,number))->setText((*it)->upper_value());
((QLineEdit*)ext->getWidget(2,number))->setText((*it)->label());
Expand Down Expand Up @@ -307,7 +306,6 @@ void QgsGraSyDialog::apply() const

if(lbcontainsletter==false&&ubcontainsletter==false&&lower_bound.length()>0&&upper_bound.length()>0)//only add the item if the value bounds do not contain letters and are not null strings
{
qWarning("adde ein renderitem");
QgsRangeRenderItem* item = new QgsRangeRenderItem(sy, lower_bound, upper_bound, ((QLineEdit*)(ext->getWidget(2,i)))->text());

renderer->addItem(item);
Expand Down Expand Up @@ -337,7 +335,10 @@ void QgsGraSyDialog::apply() const
renderer->setClassificationField(ext->classfield());

m_vectorlayer->triggerRepaint();
m_vectorlayer->legendItem()->setPixmap(0,(*pix));
if(m_vectorlayer->legendItem())
{
m_vectorlayer->legendItem()->setPixmap(0,(*pix));
}
}

else//number of classes is 0
Expand Down
3 changes: 2 additions & 1 deletion src/qgsgrasydialog.h
Expand Up @@ -33,10 +33,11 @@ class QgsGraSyDialog: public QgsGraSyDialogBase
enum mode{EMPTY, EQUAL_INTERVAL, QUANTILES};
QgsGraSyDialog(QgsVectorLayer* layer);
~QgsGraSyDialog();
public slots:
void apply() const;
protected slots:
/**Creates a new extension widget*/
void adjustNumberOfClasses();
void apply() const;
protected:
/**Pointer to the curret extension widget*/
QgsGraSyExtensionWidget* ext;
Expand Down

0 comments on commit 57e1623

Please sign in to comment.