00001 #include "GuiControl.h"
00002 #include "GUI.h"
00003
00004 using namespace WURDE;
00005
00006 typedef struct pixel {
00007 char r, g, b;
00008 };
00009
00010 void ColorPixel(void * pImg, int pX, int pY, char pR, char pG, char pB) {
00011 pixel *img = (pixel *)pImg;
00012 if(pX >= 0 && pX < 640 && pY >= 0 && pY < 480) {
00013 img[pY * 640 + pX].r = pB;
00014 img[pY * 640 + pX].g = pG;
00015 img[pY * 640 + pX].b = pR;
00016 }
00017 }
00018
00019
00020 GuiControl::GuiControl() {
00021 mGui = NULL;
00022 mImage = NULL;
00023 oldImage=NULL;
00024 gotInfo=false;
00025 }
00026
00027 GuiControl::~GuiControl() {
00028
00029 }
00030
00031 void GuiControl::PTUKeyPressed(int pKey) {
00032 printf("Key pressed: %d", pKey);
00033 }
00034
00035 void GuiControl::Tick(double pDTime) {
00036
00037
00038 if(!mGui) {
00039
00040 return;
00041 }
00042
00043 m_source->doPing();
00044 if(mCom){
00045 if(mCom->runUpdate()==STATE_QUIT){
00046 g_loginfo << "Received quit from WURDE." << endl;
00047 exit(0);
00048 }
00049 }
00050
00051 if(m_source->newInfo()){
00052 m_source->getNextInfo();
00053
00054 gotInfo=true;
00055 }
00056
00057 if(m_source->newData()){
00058 m_source->getNextData();
00059 if(gotInfo){
00060 WURDE::WURDEImage newimage=m_source->getImage();
00061
00062
00063
00064 if(newimage.second){
00065 if(m_source->info.format.getValue()==FORMAT_CHAR_1_GRAY){
00066 mImage = new Fl_RGB_Image((unsigned char *)newimage.second->imageData, 320,240,1);
00067 }else{
00068 mImage = new Fl_RGB_Image((unsigned char *)newimage.second->imageData, 320,240);
00069
00070 }
00071 mGui->mViewBox->image(mImage);
00072 mGui->mViewBox->redraw();
00073 if(oldImage){
00074 delete oldImage;
00075 }
00076 oldImage=mImage;
00077 }
00078 }else{
00079 m_source->doPing();
00080 }
00081
00082 }
00083
00084 if(gotInfo){
00085 m_source->requests.mType=MESSAGE_REQUEST;
00086
00087 m_source->publishRequest();
00088 }else{
00089 m_source->requests.mType=MESSAGE_PING;
00090 m_source->publishRequest();
00091 }
00092
00093 }
00094
00095