Hello,<br>
I am able to display features using unique value renderer now :).<br>
Could you please tell me how to give different &quot;symbols&quot; to different attributes in a particular field.<br>
<br>
Here is the code with which i am trying to display features:<br>
<br>
<span style="font-weight: bold;">mypRenderer-&gt;setClassificationField (2);</span><br style="font-weight: bold;">
<span style="font-weight: bold;"><span style="font-weight: bold;">//</span>std::list&lt;int&gt; attributes=mypRenderer-&gt;classificationAttributes();</span><br style="font-weight: bold;">
<span style="font-weight: bold;">mypRenderer-&gt;insertValue (&quot;1st attribute&quot;,symbol);</span><br style="font-weight: bold;">
<span style="font-weight: bold;">mypRenderer-&gt;insertValue (&quot;2dn attribute&quot;,symbol1);</span><br>
Here i am hardcoding to give different colors for diferent attributes.<br>
Is there any way do to it in a generic way.<br>
Thanking you<br>
cheers<br>
satya<br>
<br><div><span class="gmail_quote">On 3/7/07, <b class="gmail_sendername">satya satya</b> &lt;<a href="mailto:satya341@gmail.com">satya341@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thank you very much Marco.<br>
Now i am able to display features.<div><span class="e" id="q_1112d8927c38d74a_1"><br>
regards,<br>
satya<br><br><div><span class="gmail_quote">On 3/7/07, <b class="gmail_sendername">Marco Hugentobler</b> &lt;<a href="mailto:marco.hugentobler@karto.baug.ethz.ch" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
marco.hugentobler@karto.baug.ethz.ch</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Satya,<br><br>Is &quot;Dmg_zip&quot; an attribute name or an attribute value?<br>You need to specify the attribute _value_ for which you want the symbol to
<br>apply. Additionally, you need to give the classification field index to the<br>renderer, so that it knows in which attribute to look.<br><br>You can see how the QGIS application itself does it. Look at the unique value
<br>dialog class QgsUniqueValueDialog.cpp/h.<br><br>All the best,<br>Marco<br><br>Am Mittwoch, 7. März 2007 17:17 schrieb satya satya:<br>&gt; Hi Marco,<br>&gt; I uncommented //mypRenderer-&gt;insertValue(&quot;point&quot;,symbol); , I changed
<br>&gt; &quot;POINT&quot; to &quot;Dmg_zip&quot; which is one of the attributes of my shape file.<br>&gt; Unfortunately it displayed nothing. Do i need to iterate all the points in<br>&gt; the shaped file??<br>&gt; Thaking you
<br>&gt; regards<br>&gt; satya<br>&gt;<br>&gt; On 3/7/07, Marco Hugentobler &lt;<a href="mailto:marco.hugentobler@karto.baug.ethz.ch" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">marco.hugentobler@karto.baug.ethz.ch
</a>&gt; wrote:<br>&gt; &gt; Hi Satya,<br>&gt; &gt;
<br>&gt; &gt; Just use the Method QgsUniqueValueRenderer::insertValue(QString name,<br>&gt; &gt; QgsSymbol* symbol). The first parameter is the attribute value for which<br>&gt; &gt; the<br>&gt; &gt; symbol is valid, the second a pointer to your symbol (ok, &#39;name&#39; is a
<br>&gt; &gt; misleading name for the parameter...)<br>&gt; &gt;<br>&gt; &gt; In the code below, there is the outcommented line<br>&gt; &gt; //mypRenderer-&gt;insertValue(&quot;point&quot;,symbol);<br>&gt; &gt; I suppose &quot;point&quot; is not the attribute value for which you want the
<br>&gt; &gt; symbol to<br>&gt; &gt; be applied? Try to replace it with the attribute value and see if it<br>&gt; &gt; works.<br>&gt; &gt;<br>&gt; &gt; If you want the symbol to be valid for all features, then you can use
<br>&gt; &gt; QgsSingleSymbolRenderer, method<br>&gt; &gt; QgsSingleSymbolRenderer::addSymbol(QgsSymbol*)<br>&gt; &gt;<br>&gt; &gt; Best regards,<br>&gt; &gt; Marco<br>&gt; &gt;<br>&gt; &gt; Am Mittwoch, 7. März 2007 15:38 schrieb satya satya:
<br>&gt; &gt; &gt; Hi tim,<br>&gt; &gt; &gt; Here is the code<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; // QGIS Includes<br>&gt; &gt; &gt; // Qt Includes<br>&gt; &gt; &gt; // Std Includes<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; int main(int argc, char ** argv)
<br>&gt; &gt; &gt; {<br>&gt; &gt; &gt;&nbsp;&nbsp; // Start the Application<br>&gt; &gt; &gt;&nbsp;&nbsp; QgsApplication app(argc, argv, true);<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp; QString myPluginsDir&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &quot;...../lib/qgis&quot;;<br>

&gt; &gt; &gt;&nbsp;&nbsp; QString myLayerPath1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = &quot;.............................<br>&gt; &gt; &gt; .......shp&quot;; QString myLayerBaseName1&nbsp;&nbsp;&nbsp;&nbsp; = &quot;....................shp&quot;;<br>&gt; &gt; &gt;&nbsp;&nbsp; QString myProviderName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= &quot;ogr&quot;;
<br>&gt; &gt; &gt;&nbsp;&nbsp; QgsSymbol* symbol;<br>&gt; &gt; &gt;&nbsp;&nbsp; QColor* color;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; color = new QColor(255,0,0,255);<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; symbol = new QgsSymbol(color-&gt;rgb());
<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp; // Instantiate Provider Registry<br>&gt; &gt; &gt;&nbsp;&nbsp; QgsProviderRegistry::instance(myPluginsDir);<br>&gt; &gt; &gt;&nbsp;&nbsp; QgsVectorLayer * mypLayer = new QgsVectorLayer(myLayerPath1,<br>

&gt; &gt; &gt; myLayerBaseName1, myProviderName);<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;//get the field list associated with the layer<br>&gt; &gt; &gt; std::vector&lt;QgsField&gt; myFields=mypLayer-&gt;fields();<br>&gt; &gt; &gt;&nbsp;&nbsp; QgsUniqueValueRenderer *mypRenderer=new
<br>&gt; &gt; &gt; QgsUniqueValueRenderer(mypLayer-&gt;vectorType());<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp; mypRenderer-&gt;setClassificationField(5);<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; symbol-&gt;setColor(Qt::red);<br>
&gt; &gt; &gt;&nbsp;&nbsp; symbol-&gt;setFillColor(QColor(255,0,0));
<br>&gt; &gt; &gt;&nbsp;&nbsp; symbol-&gt;setLabel(&quot;HELLO&quot;);<br>&gt; &gt; &gt;&nbsp;&nbsp; symbol-&gt;setPointSize (5);<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp; std::deque&lt;QString&gt; myLayerSet;<br>&gt; &gt; &gt;&nbsp;&nbsp; mypLayer-&gt;setRenderer(mypRenderer);
<br>&gt; &gt; &gt; //mypRenderer-&gt;insertValue(&quot;point&quot;,symbol);<br>&gt; &gt; &gt; if (mypLayer-&gt;isValid())<br>&gt; &gt; &gt;&nbsp;&nbsp; {<br>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; qDebug(&quot;Layer is valid&quot;);<br>&gt; &gt; &gt;&nbsp;&nbsp; }
<br>&gt; &gt; &gt;&nbsp;&nbsp; else<br>&gt; &gt; &gt;&nbsp;&nbsp; {<br>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; qDebug(&quot;Layer is NOT valid&quot;);<br>&gt; &gt; &gt;&nbsp;&nbsp; }<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp; // Add the Vector Layer to the Layer Registry<br>&gt; &gt; &gt;
<br>&gt; &gt; &gt;&nbsp;&nbsp; QgsMapLayerRegistry::instance()-&gt;addMapLayer(mypLayer, TRUE);<br>&gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; // Add the Layer to the Layer Set<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp; myLayerSet.push_back

(mypLayer-&gt;getLayerID());<br>&gt; &gt; &gt;&nbsp;&nbsp; mypLayer-&gt;setVisible(TRUE);<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp; // Create the Map Canvas<br>&gt; &gt; &gt;&nbsp;&nbsp; QgsMapCanvas * mypMapCanvas = new QgsMapCanvas(0, 0);
<br>&gt; &gt; &gt;&nbsp;&nbsp; mypMapCanvas-&gt;setExtent(mypLayer-&gt;extent());<br>&gt; &gt; &gt;&nbsp;&nbsp; // cbit qDebug(mypMapCanvas-&gt;extent().stringRep(2));<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;&nbsp;&nbsp; mypMapCanvas-&gt;enableAntiAliasing(true);
<br>&gt; &gt; &gt;&nbsp;&nbsp; mypMapCanvas-&gt;setCanvasColor(QColor(255, 255, 255));<br>&gt; &gt; &gt;&nbsp;&nbsp; mypMapCanvas-&gt;freeze(false);<br>&gt; &gt; &gt;&nbsp;&nbsp; // Set the Map Canvas Layer Set<br>&gt; &gt; &gt;&nbsp;&nbsp; mypMapCanvas-&gt;setLayerSet(myLayerSet);
<br>&gt; &gt; &gt;&nbsp;&nbsp; mypMapCanvas-&gt;setVisible(true);<br>&gt; &gt; &gt;&nbsp;&nbsp; mypMapCanvas-&gt;refresh();<br>&gt; &gt; &gt;&nbsp;&nbsp;// Start the Application Event Loop<br>&gt; &gt; &gt; //cout&lt;&lt;marker_symbol-&gt;picture().toStdString()&lt;&lt;endl;
<br>&gt; &gt; &gt; app.exec();<br>&gt; &gt; &gt;&nbsp;&nbsp;//QgsMapCanvas myMapCanvas(0, 0);<br>&gt; &gt; &gt;&nbsp;&nbsp;QgsMapLayerRegistry::instance()-&gt;removeAllMapLayers();<br>&gt; &gt; &gt; return 0;<br>&gt; &gt; &gt; }<br>&gt; &gt; &gt;
<br>&gt; &gt; &gt; I created symbol, but don&#39;t know how to add that to the unique value<br>&gt; &gt; &gt; renderer.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Thanking you<br>&gt; &gt; &gt; cheers<br>&gt; &gt; &gt; satya<br>

&gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; On 3/5/07, Tim Sutton &lt;<a href="mailto:tim@linfiniti.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">tim@linfiniti.com</a>&gt; wrote:<br>&gt; &gt; &gt; &gt; &gt; Hi
<br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; How about posting code examples of what you have tried and we can
<br>&gt; &gt;<br>&gt; &gt; try<br>&gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; to help you from there....<br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; Regards<br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; Tim
<br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; 2007/3/5, satya satya &lt;<a href="mailto:satya341@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">satya341@gmail.com</a> &gt;:<br>
&gt; &gt; &gt; &gt; &gt; &gt; Hello all,<br>&gt;
&gt; &gt; &gt; &gt;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
I am trying to develop a simple application using<br>&gt; &gt;<br>&gt; &gt; QGis<br>&gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; API.<br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;I have read all tutorials on QGis blog. I would like to use
<br>&gt; &gt; &gt; &gt; &gt; &gt; &quot;QgsUniqueValueRenderer&quot; in my application to display features in<br>&gt; &gt; &gt; &gt; &gt; &gt; diff<br>&gt; &gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; &gt; colors. I tried that&nbsp;&nbsp;&quot;QgsUniqueValueRenderer&quot; , but no luck.
<br>&gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;could some body help me .<br>&gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;cheers<br>&gt; &gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;satya<br>&gt; &gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; &gt; _______________________________________________
<br>&gt; &gt; &gt; &gt; &gt; &gt; Qgis-developer mailing list<br>&gt; &gt; &gt; &gt; &gt; &gt; <a href="mailto:Qgis-developer@lists.qgis.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Qgis-developer@lists.qgis.org
</a><br>&gt; &gt; &gt; &gt; &gt; &gt; <a href="http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer</a><br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; --<br>&gt; &gt; &gt; &gt; &gt; --<br>&gt; &gt; &gt; &gt; &gt; Tim Sutton<br>&gt; &gt; &gt; &gt; &gt;
<br>&gt; &gt; &gt; &gt; &gt; Visit <a href="http://qgis.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://qgis.org</a> for a great Open Source GIS<br>&gt; &gt; &gt; &gt; &gt; Home Page: <a href="http://linfiniti.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://linfiniti.com</a><br>&gt; &gt; &gt; &gt; &gt; Skype: timlinux
<br>&gt; &gt; &gt; &gt; &gt; MSN: <a href="mailto:tim_bdworld@msn.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">tim_bdworld@msn.com</a><br>&gt; &gt; &gt; &gt; &gt; Yahoo: <a href="mailto:tim_bdworld@yahoo.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
tim_bdworld@yahoo.com</a><br>&gt; &gt; &gt; &gt; &gt; Jabber: timlinux
<br>&gt; &gt; &gt; &gt; &gt; Irc: timlinux on #qgis at <a href="http://freenode.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">freenode.net</a><br></blockquote></div><br>
</span></div></blockquote></div><br>