hello everybody<br>i am using QGIS 0.7.9<br>Aim of my plugin: To display points received from various algorithms simultaneously on canvas.<br><br>Situation is like on top of map i am displaying location of points received from a client-socket using TCP/IP. It works fine till only one such socket is opened and read from .Updation and movement of points goes well. But as soon as i start reading from multiple client/sockets and try to display data , all situation goes awery. Then only data from recently activated socket/client is updated and displayed. This is where i am looking for help.
<br><br>How i have implemented: For storing data from various socket i am using QHash with key as socket Descriptor id and Value as in a QList.<br>For each readyRead() received signal i gets i add in hash with correspondent socket descriptor as key.
<br>here is part of code i am putting:<br><br>// this slot will be called for newConnection() signal<br>void tcpCock::activatingNewConnection()<br>{<br>&nbsp;&nbsp;&nbsp; &nbsp;tcpSocket=tcpServer-&gt;nextPendingConnection();<br>&nbsp;&nbsp;&nbsp; connect( tcpSocket, SIGNAL(disconnected()),tcpSocket, SLOT(deleteLater()));
<br>&nbsp;&nbsp;&nbsp; connect( tcpSocket,SIGNAL(readyRead()),this,SLOT(updatePixmap()));<br>&nbsp;&nbsp;&nbsp; //provide a connect for linking socket exiting status to one of slo which disconnects drawShape() from refresh signal.<br>&nbsp;&nbsp;&nbsp; connect( tcpSocket,SIGNAL(disconnected()),this,SLOT(socketDisconnected()));
<br>&nbsp;&nbsp;&nbsp; pIntQlist= new QList&lt;int&gt; ;<br>&nbsp;&nbsp;&nbsp; hash.insert(tcpSocket-&gt;socketDescriptor(),pIntQlist);<br>}<br><br><br>//drawshape() function defination for QgsMapCanvasItem's pure virtual one<br>void tcpCock::drawShape(QPainter &amp; p)
<br>{<br>&nbsp;&nbsp;&nbsp; //load the pixamap to be displayed<br>&nbsp;&nbsp;&nbsp; QString myFileNameQString= &quot;/home1/qgis/images/cock/cock.png&quot;;<br>&nbsp;&nbsp;&nbsp; QPixmap myQPixmap;<br>&nbsp;&nbsp;&nbsp; myQPixmap.load(myFileNameQString);<br>&nbsp;&nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp; QHashIterator&lt;int, QList&lt;int&gt;* &gt; itr(hash);
<br>&nbsp;&nbsp;&nbsp; while ( itr.hasNext())<br>&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp; itr.next() ;//possible outcome of error<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //tempList=itr.value();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; QListIterator&lt;int&gt; tempListItr(*itr.value());<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; tempListItr.toBack
();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; y=tempListItr.previous();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; x=tempListItr.previous();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; QgsPoint qpt(x,y);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; QPoint pt=toCanvasCoords(qpt);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; move(pt.x(),pt.y());// added to check for movement of all elements-questionable
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; p.drawPixmap(pt.x(),pt.y(),myQPixmap);<br>&nbsp;&nbsp;&nbsp; &nbsp; }<br>}<br><br><br>//This slot will be called for every readyRead()signal<br>void tcpCock::updatePixmap()<br>{<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; QTcpSocket *tempSock=dynamic_cast&lt;QTcpSocket *&gt;(sender());
<br>&nbsp;&nbsp;&nbsp; if(tempSock)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; QHash&lt;int, QList&lt;int&gt;* &gt;::const_iterator itr=hash.find(tempSock-&gt;socketDescriptor());<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; QString st;<br>&nbsp;&nbsp;&nbsp; QDataStream in(tcpSocket);<br>&nbsp;&nbsp;&nbsp; in.setVersion(QDataStream::Qt_4_0);
<br>&nbsp;&nbsp;&nbsp; if( tempSock-&gt;bytesAvailable() &lt;= 0 )// changed from tcpSocket since tcpsocket will look for newely activeted connection only<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //cout&lt;&lt;&quot;\nNothing&nbsp;&nbsp;&nbsp; Available for reading&quot;;
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; in &gt;&gt;st;<br>&nbsp;&nbsp;&nbsp; int i=0;<br>&nbsp;&nbsp;&nbsp; QChar *data = st.data();<br>&nbsp;&nbsp;&nbsp; while (*data!=' ')<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ++data;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; i++;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; QString s1=st.left(i);<br>&nbsp;&nbsp;&nbsp; x=s1.toInt
();<br>&nbsp;&nbsp;&nbsp; QString s2=st.mid(i+1);<br>&nbsp;&nbsp;&nbsp; y=s2.toInt();<br>&nbsp;&nbsp;&nbsp; itr.value()-&gt;append(x);<br>&nbsp;&nbsp;&nbsp; itr.value()-&gt;append(y);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; move(x,y);<br>&nbsp;&nbsp;&nbsp; QgsRect r=mQGisApp-&gt;getMapCanvas()-&gt;fullExtent();<br>&nbsp;&nbsp;&nbsp; setRect(r);
<br>&nbsp;&nbsp;&nbsp; show();<br>&nbsp;&nbsp;&nbsp; updateCanvas();<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>What i feel is not ok with this piece of code is i am not able to address to canvas item corresponding to&nbsp; data received from each client.&nbsp; To avoid it&nbsp; i am&nbsp; drawing&nbsp; each&nbsp; canvas item again&nbsp; at their last available location in 
hash.value() ie list. But output is that only newely created socket -canvs item is updated.<br>While using gdb i observed with 3 client connections. Every canvas item starts again from location provided by newly activated client. and after that all follow the path.
<br>kindly help me in this matter.<br><br>regards<br>quick nitin<br><br>