[OpendTect_Developers] Fwd: Fwd: help...how recieves a pair of coordinate

Ranojay Sen ranojay.sen at dgbes.com
Wed Mar 13 11:27:50 CET 2013


Hi Glenn,

If I understand correctly from your previous posts, you need some kind 
of mechanism to send and receive coordinate values to and from other 
application using sockets. For that you have chosen SeparString class 
for converting the coordinates to string and then send them over the 
network, this I would say not a bad way to do this, other wise you could 
also have used IOPars, as they provide more features. In any case let me 
elaborate how you can use SeparString to include multiple coordinate 
values and send them via socket in the code snippet below.

Coord coord( 100, 120 );
SeparString coordstring;
coordstring += coord.x;
coordstring += coord.y;

// now the socket part
TcpSocket socket;
socket.connectToHost( "host", port ); // e.g. host = "192.168.5.112" 
(any host on the network), port = 1212 (any port which you want to connect)
socket.write( coordstring .buf() );


// on the receiving end.

There should be a callback when the data is received.

void YourClass::dataReceivedCB( CallBacker* cb )
{
       mCBCapsuleUnpack(int,socketid,cb); // we need the socket id as 
multiple client can connect to the server.

       TcpServer server;
       BufferString datarecvd;
       server.read( socketid, datarecvd );
       SeparString coordstring( datarecvd  );
      Coord newcoord;
      newcoord.x = coordstring.getDValue( 0 ); // fist value X
      newcoord.y = coordstring.getDValue( 1 ); // second value Y
}

This code snippet roughly shows the mechanism of sending and recieving 
coordinate values with SeparString and sockets, please note copying this 
code directly will not work. In case you need more help please come back 
to me.


Regards
Ranojay






Hi Everyone:

I previously didn´t  an adequate and accurate information about the 
problem I had and offer an apology. I've been researching what I really 
need, the problem is as follows:
-Show the pocision (coordinates) of a well in the scene OpendTect.

I raised the issue of the following way:

-Receive a pair of coordinates (x, y)

                    class uiOP_PlugwBringer : public uiDialog

                    {

                      public:

                      uiOP_PlugwBringer( uiParent* p)

                            : uiDialog(p,Setup("Well Positions",
                    "Specify coordinates",

                        mNoHelpID))

                          {


                      BufferString crdunit( "Coordinate " );

                              crdunit += SI().getXYUnitString();

                              coordx = new uiGenInput( this, crdunit, 

                        PositionInpSpec(PositionInpSpec::Setup(true)));

                          }


The problem in above the class is that the variable coordx only save a 
one coordinate (x), then when the class /SeparString str( data ); /then 
when the class receives the buffer string data, cannot separating 
because only contains one coordinate (x).

                          bool acceptOK(CallBacker*)

                          {

                            BufferString data = coordx->text();


                            if( ! *data)

                            {

                             uiMSG().error("Please type coordinates");

                        return false;

                            }

                             SeparString str( data );

                             BufferString type = str[0];

                             const int sceneid =
                        ODMainWin()->sceneMgr().askSelectScene();

                        PtrMan<CtxtIOObj> ctio = mMkCtxtIOObj( Well );

                        ctio->setName( str[1] );

                        ctio->ctxt.forread = false;

                        uiIOObjSelDlg dlg( ODMainWin(), *ctio );

                        if ( !dlg.go() )

                             return true;


                        const IOObj* wellioobj = dlg.ioObj();

                        if ( !wellioobj ) return true;


                        WellImporter importer( str, *wellioobj );

                        if ( !importer.go() )

                             uiMSG().error( importer.errorMessage() );

                        else

                          ODMainWin()->sceneMgr().addWellItem(
                        wellioobj->key() , sceneid );

                        return true;

                            }


                            uiGenInput* coordxy;

                            uiGenInput* coordx;

                            uiGenInput* coordy;


                          };



if they have any idea how to fix this thank you for your help. best Glenn


Dear all,

Via OpendTect support, I got a request from Glenn for help in
developing a plugin using sockets. This is typically a question
one would post on OpendTect's developers list. Moreover, since
I do not have a clue myself.

He is referring to a contribution of Ranojay Sen to this developers
mailing list, but the author is currently unavailable for celebrating
his honeymoon.

http://lists.opendtect.org/pipermail/developers/2011-April/000253.html


=========================================================================

Glenn LB <blueck_1923 at hotmail.com> wrote:

 > Thanks for answer me, i working in a Company that develop applications
 > for SIG and extensions for same, but this occasion, i will develop a
 > plugin in OpendTect that must receive a pair of coordinates x and y
 > or a file .shp or .txt of positions of wells, and display this ubication
 > of wells in the scene of OpendTect, i proof some ideas for example
 > how used a sockets, and how make a Callback, but hardly i know little
 > or nothing about the development in OpendTect, thanks for you help.

 > the examples I wanted to load are the following:

 > http://web.archiveorange.com/archive/v/L9Q23izaijPJS8r4EY6E ,

 > but i not know how to do it. thanks. best.

 > Glenn

============================================================================= 


Best regards,


Jaap Glas




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opendtect.org/pipermail/developers/attachments/20130313/966c1bb2/attachment.html>


More information about the Developers mailing list