Hi Marco,<br>
I uncommented <span style="font-weight: bold;">//mypRenderer->insertValue("point",symbol); </span>,
I changed "POINT" to "Dmg_zip" which is one of the attributes of my
shape file. Unfortunately it displayed nothing. Do i need to iterate
all the points in the shaped file??<br>
Thaking you<br>
regards<br>
satya<br>
<br><br><div><span class="gmail_quote">On 3/7/07, <b class="gmail_sendername">Marco Hugentobler</b> <<a href="mailto:marco.hugentobler@karto.baug.ethz.ch">marco.hugentobler@karto.baug.ethz.ch</a>> 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>Just use the Method QgsUniqueValueRenderer::insertValue(QString name,<br>QgsSymbol* symbol). The first parameter is the attribute value for which the<br>symbol is valid, the second a pointer to your symbol (ok, 'name' is a
<br>misleading name for the parameter...)<br><br>In the code below, there is the outcommented line<br>//mypRenderer->insertValue("point",symbol);<br>I suppose "point" is not the attribute value for which you want the symbol to
<br>be applied? Try to replace it with the attribute value and see if it works.<br><br>If you want the symbol to be valid for all features, then you can use<br>QgsSingleSymbolRenderer, method<br>QgsSingleSymbolRenderer::addSymbol(QgsSymbol*)
<br><br>Best regards,<br>Marco<br><br>Am Mittwoch, 7. März 2007 15:38 schrieb satya satya:<br>> Hi tim,<br>> Here is the code<br>><br>> // QGIS Includes<br>> // Qt Includes<br>> // Std Includes<br>><br>
> int main(int argc, char ** argv)<br>> {<br>> // Start the Application<br>> QgsApplication app(argc, argv, true);<br>><br>> QString myPluginsDir = "...../lib/qgis";<br>> QString myLayerPath1 = ".............................
<br>> .......shp"; QString myLayerBaseName1 = "....................shp";<br>> QString myProviderName = "ogr";<br>> QgsSymbol* symbol;<br>> QColor* color;<br>><br>>
<br>> color = new QColor(255,0,0,255);<br>><br>> symbol = new QgsSymbol(color->rgb());<br>><br>> // Instantiate Provider Registry<br>> QgsProviderRegistry::instance(myPluginsDir);<br>> QgsVectorLayer * mypLayer = new QgsVectorLayer(myLayerPath1,
<br>> myLayerBaseName1, myProviderName);<br>><br>> //get the field list associated with the layer<br>> std::vector<QgsField> myFields=mypLayer->fields();<br>> QgsUniqueValueRenderer *mypRenderer=new
<br>> QgsUniqueValueRenderer(mypLayer->vectorType());<br>><br>> mypRenderer->setClassificationField(5);<br>><br>> symbol->setColor(Qt::red);<br>> symbol->setFillColor(QColor(255,0,0));<br>
> symbol->setLabel("HELLO");<br>> symbol->setPointSize (5);<br>><br>><br>> std::deque<QString> myLayerSet;<br>> mypLayer->setRenderer(mypRenderer);<br>> //mypRenderer->insertValue("point",symbol);
<br>> if (mypLayer->isValid())<br>> {<br>> qDebug("Layer is valid");<br>> }<br>> else<br>> {<br>> qDebug("Layer is NOT valid");<br>> }<br>><br>> // Add the Vector Layer to the Layer Registry
<br>><br>> QgsMapLayerRegistry::instance()->addMapLayer(mypLayer, TRUE);<br>> // Add the Layer to the Layer Set<br>><br>><br>><br>> myLayerSet.push_back(mypLayer->getLayerID());<br>> mypLayer->setVisible(TRUE);
<br>><br>><br>><br>> // Create the Map Canvas<br>> QgsMapCanvas * mypMapCanvas = new QgsMapCanvas(0, 0);<br>> mypMapCanvas->setExtent(mypLayer->extent());<br>> // cbit qDebug(mypMapCanvas->extent().stringRep(2));
<br>><br>> mypMapCanvas->enableAntiAliasing(true);<br>> mypMapCanvas->setCanvasColor(QColor(255, 255, 255));<br>> mypMapCanvas->freeze(false);<br>> // Set the Map Canvas Layer Set<br>> mypMapCanvas->setLayerSet(myLayerSet);
<br>> mypMapCanvas->setVisible(true);<br>> mypMapCanvas->refresh();<br>> // Start the Application Event Loop<br>> //cout<<marker_symbol->picture().toStdString()<<endl;<br>> app.exec
();<br>> //QgsMapCanvas myMapCanvas(0, 0);<br>> QgsMapLayerRegistry::instance()->removeAllMapLayers();<br>> return 0;<br>> }<br>><br>> I created symbol, but don't know how to add that to the unique value
<br>> renderer.<br>><br>> Thanking you<br>> cheers<br>> satya<br>><br>> > On 3/5/07, Tim Sutton <<a href="mailto:tim@linfiniti.com">tim@linfiniti.com</a>> wrote:<br>> > > Hi<br>> > >
<br>> > > How about posting code examples of what you have tried and we can try<br>> > > to help you from there....<br>> > ><br>> > > Regards<br>> > ><br>> > > Tim<br>
> > ><br>> > > 2007/3/5, satya satya <<a href="mailto:satya341@gmail.com">satya341@gmail.com</a> >:<br>> > > > Hello all,<br>>
> >
>
I am trying to develop a simple application using QGis<br>> > ><br>> > > API.<br>> > ><br>> > > > I have read all tutorials on QGis blog. I would like to use<br>> > > > "QgsUniqueValueRenderer" in my application to display features in
<br>> > > > diff<br>> > > ><br>> > > > colors. I tried that "QgsUniqueValueRenderer" , but no luck.<br>> > > > could some body help me .<br>> > > > cheers
<br>> > > > satya<br>> > > ><br>> > > > _______________________________________________<br>> > > > Qgis-developer mailing list<br>> > > > <a href="mailto:Qgis-developer@lists.qgis.org">
Qgis-developer@lists.qgis.org</a><br>> > > > <a href="http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer">http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer</a><br>> > ><br>> > > --
<br>> > > --<br>> > > Tim Sutton<br>> > ><br>> > > Visit <a href="http://qgis.org">http://qgis.org</a> for a great Open Source GIS<br>> > > Home Page: <a href="http://linfiniti.com">
http://linfiniti.com</a><br>> > > Skype: timlinux<br>> > > MSN: <a href="mailto:tim_bdworld@msn.com">tim_bdworld@msn.com</a><br>> > > Yahoo: <a href="mailto:tim_bdworld@yahoo.com">tim_bdworld@yahoo.com
</a><br>> > > Jabber: timlinux<br>> > > Irc: timlinux on #qgis at <a href="http://freenode.net">freenode.net</a><br></blockquote></div><br>