Skip to content

Commit 57e1623

Browse files
author
mhugent
committedJan 26, 2004
saving and loading of symbology
git-svn-id: http://svn.osgeo.org/qgis/trunk@597 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 75460eb commit 57e1623

11 files changed

+438
-61
lines changed
 

‎qgis.dtd

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
-- General Map Layer Properties
2323
-- (apply to both vector and raster)
2424
-->
25-
<!ELEMENT maplayer (layername, datasource, zorder, symbol) >
25+
<!ELEMENT maplayer (layername, datasource, zorder, (singlesymbol|graduatedsymbol|continuoussymbol|rasterproperties) >
2626
<!ELEMENT layername (#PCDATA) >
2727
<!ELEMENT datasource (#PCDATA) >
2828
<!ELEMENT zorder (#PCDATA) >
@@ -31,25 +31,57 @@
3131
type (vector|raster|database) "vector"
3232
visible (1|0) "0"
3333
>
34+
3435
<!--
35-
-- Vector Layer Properties
36+
-- Element symbol contains the settings for a qpainter
3637
--
3738
-->
38-
<!ELEMENT symbol (linewidth, outlinecolor, fillcolor) >
39-
<!ELEMENT linewidth (#PCDATA) >
40-
<!ELEMENT fillcolor EMPTY>
41-
<!ELEMENT outlinecolor EMPTY>
42-
<!-- Attribute Lists -->
43-
<!ATTLIST fillcolor
44-
red CDATA #IMPLIED
45-
green CDATA #IMPLIED
46-
blue CDATA #IMPLIED
39+
40+
<!ELEMENT symbol (outlinecolor,outlinestyle,outlinewidth,fillcolor,fillpattern) >
41+
<!ELEMENT outlinecolor EMPTY >
42+
<!ELEMENT outlinestyle (#PCDATA) >
43+
<!ELEMENT outlinewidth (#PCDATA) >
44+
<!ELEMENT fillcolor EMPTY >
45+
<!ELEMENT fillpattern (#PCDATA) >
46+
47+
<!ATTLIST outlinecolor
48+
red CDATA #REQUIRED
49+
green CDATA #REQUIRED
50+
blue CDATA #REQUIRED
4751
>
52+
4853
<!ATTLIST outlinecolor
49-
red CDATA #IMPLIED
50-
green CDATA #IMPLIED
51-
blue CDATA #IMPLIED
54+
red CDATA #REQUIRED
55+
green CDATA #REQUIRED
56+
blue CDATA #REQUIRED
5257
>
58+
59+
<!--
60+
-- renderitem and rangerenderitem
61+
--
62+
-->
63+
64+
<!ELEMENT renderitem (value,symbol,label) >
65+
<!ELEMENT value (#PCDATA) >
66+
<!ELEMENT label (#PCDATA) >
67+
68+
<!ELEMENT rangerenderitem (lowervalue,uppervalue,symbol,label) >
69+
<!ELEMENT lowervalue (#PCDATA) >
70+
<!ELEMENT uppervalue (#PCDATA) >
71+
72+
<!--
73+
-- elements to store the settings of the different symbology types
74+
--
75+
-->
76+
77+
<!ELEMENT singlesymbol (renderitem) >
78+
<!ELEMENT graduatedsymbol (classificationfield,rangerenderitem+) >
79+
<!ELEMENT classificationfield (#PCDATA) >
80+
<!ELEMENT continuoussymbol (classificationfield,lowestitem,highestitem) >
81+
<!ELEMENT lowestitem (renderitem) >
82+
<!ELEMENT highestitem (renderitem) >
83+
84+
5385
<!--
5486
-- Raster Layer Properties
5587
--

‎src/qgscontcoldialog.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ void QgsContColDialog::apply()
192192
p.drawText(leftspace+gradientwidth+wordspace,rangeoffset+gradientheight,QString::number(maximum,'f',2));
193193

194194
m_vectorlayer->triggerRepaint();
195-
m_vectorlayer->legendItem()->setPixmap(0,(*pix));
195+
if(m_vectorlayer->legendItem())
196+
{
197+
m_vectorlayer->legendItem()->setPixmap(0,(*pix));
198+
}
196199
}
197200

198201
void QgsContColDialog::selectMinimumColor()

‎src/qgscontcoldialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ class QgsContColDialog: public QgsContColDialogBase
1212
public:
1313
QgsContColDialog(QgsVectorLayer* layer);
1414
~QgsContColDialog();
15-
15+
public slots:
16+
void apply();
1617
protected slots:
17-
void apply();
1818
void selectMinimumColor();
1919
void selectMaximumColor();
2020
protected:

‎src/qgscontinuouscolrenderer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class QgsContinuousColRenderer: public QgsRenderer
3838
void initializeSymbology(QgsVectorLayer* layer);
3939
/**Renders the feature using the minimum and maximum value of the classification field*/
4040
void renderFeature(QPainter* p, QgsFeature* f, QgsCoordinateTransform* t);
41+
/**Returns the number of the classification field*/
42+
int classificationField() const;
4143
/**Sets the id of the classification field*/
4244
void setClassificationField(int id);
4345
/**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*/
@@ -64,6 +66,11 @@ inline QgsContinuousColRenderer::QgsContinuousColRenderer(): m_minimumItem(0), m
6466

6567
}
6668

69+
inline int QgsContinuousColRenderer::classificationField() const
70+
{
71+
return m_classificationField;
72+
}
73+
6774
inline void QgsContinuousColRenderer::setClassificationField(int id)
6875
{
6976
m_classificationField=id;

‎src/qgsgraduatedsymrenderer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class QgsGraduatedSymRenderer: public QgsRenderer
3737
/**Adds a new item
3838
\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*/
3939
void addItem(QgsRangeRenderItem* ri);
40-
/**Returns the name of the classification field*/
40+
/**Returns the number of the classification field*/
4141
int classificationField() const;
4242
/**Removes all items*/
4343
void removeItems();

‎src/qgsgrasydialog.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ QgsGraSyDialog::QgsGraSyDialog(QgsVectorLayer* layer): QgsGraSyDialogBase(), ext
8686
int number=0;
8787
for(std::list<QgsRangeRenderItem*>::iterator it=list.begin();it!=list.end();++it)
8888
{
89-
qWarning("inside loop");
9089
((QLineEdit*)(ext->getWidget(0,number)))->setText((*it)->value());
9190
((QLineEdit*)ext->getWidget(1,number))->setText((*it)->upper_value());
9291
((QLineEdit*)ext->getWidget(2,number))->setText((*it)->label());
@@ -307,7 +306,6 @@ void QgsGraSyDialog::apply() const
307306

308307
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
309308
{
310-
qWarning("adde ein renderitem");
311309
QgsRangeRenderItem* item = new QgsRangeRenderItem(sy, lower_bound, upper_bound, ((QLineEdit*)(ext->getWidget(2,i)))->text());
312310

313311
renderer->addItem(item);
@@ -337,7 +335,10 @@ void QgsGraSyDialog::apply() const
337335
renderer->setClassificationField(ext->classfield());
338336

339337
m_vectorlayer->triggerRepaint();
340-
m_vectorlayer->legendItem()->setPixmap(0,(*pix));
338+
if(m_vectorlayer->legendItem())
339+
{
340+
m_vectorlayer->legendItem()->setPixmap(0,(*pix));
341+
}
341342
}
342343

343344
else//number of classes is 0

‎src/qgsgrasydialog.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ class QgsGraSyDialog: public QgsGraSyDialogBase
3333
enum mode{EMPTY, EQUAL_INTERVAL, QUANTILES};
3434
QgsGraSyDialog(QgsVectorLayer* layer);
3535
~QgsGraSyDialog();
36+
public slots:
37+
void apply() const;
3638
protected slots:
3739
/**Creates a new extension widget*/
3840
void adjustNumberOfClasses();
39-
void apply() const;
4041
protected:
4142
/**Pointer to the curret extension widget*/
4243
QgsGraSyExtensionWidget* ext;

0 commit comments

Comments
 (0)