Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

TestLocate.cc

Go to the documentation of this file.
00001 /*
00002 
00003     Test UI for locate
00004     Copyright (C) 2000 Jussi Laako
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 */
00021 
00022 
00023 #include <stdio.h>
00024 #include <signal.h>
00025 
00026 #include <ptc/ptc.h>
00027 
00028 #include <Alloc.hh>
00029 
00030 #include "Config.h"
00031 #include "Messages.hh"
00032 #include "SockClie.hh"
00033 #include "SockOp.hh"
00034 
00035 
00036 bool bRun = true;
00037 Console Con;
00038 Format Fmt(32, 0x00ff0000, 0x0000ff00, 0x000000ff);
00039 
00040 
00041 void SigHandler (int iSigNum)
00042 {
00043     bRun = false;
00044 }
00045 
00046 
00047 void PlotData (Surface &Sfc, GDT *fpData, int iWidth, int iHeight)
00048 {
00049     int iDataCntr;
00050     /*unsigned int iR;
00051     unsigned int iG;
00052     unsigned int iB;*/
00053     unsigned int *ipSfc;
00054 
00055     ipSfc = (unsigned int *) Sfc.lock();
00056     for (iDataCntr = 0; iDataCntr < (iWidth * iHeight); iDataCntr++)
00057     {
00058         if (fpData[iDataCntr] > 1) fpData[iDataCntr] = 1;
00059         ipSfc[iDataCntr] =
00060             ((unsigned int) (fpData[iDataCntr] * 0xff) << 16) |
00061             ((unsigned int) (fpData[iDataCntr] * 0xff) << 8) |
00062             ((unsigned int) (fpData[iDataCntr] * 0xff));
00063         /*iR = (unsigned int) (fpData[iDataCntr] * 0xff) + 
00064             sSeabed.pixel_data[iDataCntr * 4];
00065         if (iR > 0xff) iR = 0xff;
00066         iG = sSeabed.pixel_data[iDataCntr * 4 + 1];
00067         iB = sSeabed.pixel_data[iDataCntr * 4 + 2];
00068         ipSfc[iDataCntr] = ((iR << 16) | (iG << 8) | iB);*/
00069     }
00070     Sfc.unlock();
00071 }
00072 
00073 
00074 int main (int argc, char *argv[])
00075 {
00076     int iDataSize;
00077     char cpMsgHdr[GLOBAL_HEADER_LEN];
00078     stLocateHdr sHdr;
00079     stLocateRes sRes;
00080     clAlloc InData;
00081     clAlloc ResData;
00082     clSockClie SClient;
00083     clSockOp SOp;
00084     clLocateMsg Msg;
00085 
00086     signal(SIGINT, SigHandler);
00087     SOp.SetHandle(SClient.Connect("localhost", NULL, 30002));
00088     if (SOp.ReadN(cpMsgHdr, GLOBAL_HEADER_LEN) == GLOBAL_HEADER_LEN)
00089     {
00090         Msg.GetHeader(cpMsgHdr, &sHdr);
00091         iDataSize = GLOBAL_HEADER_LEN + 
00092             sHdr.iWidth * sHdr.iHeight * sizeof(GDT);
00093         InData.Size(iDataSize);
00094         ResData.Size(sHdr.iWidth * sHdr.iHeight * sizeof(GDT));
00095         Con.open("Locate test", sHdr.iWidth, sHdr.iHeight, Fmt);
00096         Surface Sfc(sHdr.iWidth, sHdr.iHeight, Fmt);
00097         while (bRun && !Con.key() && SOp.ReadN(InData, iDataSize) == iDataSize)
00098         {
00099             Msg.GetResult(InData, &sRes, (GDT *) ResData);
00100             PlotData(Sfc, ResData, sHdr.iWidth, sHdr.iHeight);
00101             Sfc.copy(Con);
00102             Con.update();
00103         }
00104         Con.close();
00105     }
00106     return 0;
00107 }
00108 

Generated on Sun Oct 26 19:11:23 2003 for HASAS by doxygen 1.3.3