MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/Tools/Graphical/uMS/ScopeGrid.h
Go to the documentation of this file.
00001 
00002 //
00003 //   MOOS - Mission Oriented Operating Suite 
00004 //  
00005 //   A suit of Applications and Libraries for Mobile Robotics Research 
00006 //   Copyright (C) 2001-2005 Massachusetts Institute of Technology and 
00007 //   Oxford University. 
00008 //    
00009 //   This software was written by Paul Newman at MIT 2001-2002 and Oxford 
00010 //   University 2003-2005. email: pnewman@robots.ox.ac.uk. 
00011 //      
00012 //   This file is part of a  MOOS Utility Component. 
00013 //        
00014 //   This program is free software; you can redistribute it and/or 
00015 //   modify it under the terms of the GNU General Public License as 
00016 //   published by the Free Software Foundation; either version 2 of the 
00017 //   License, or (at your option) any later version. 
00018 //          
00019 //   This program is distributed in the hope that it will be useful, 
00020 //   but WITHOUT ANY WARRANTY; without even the implied warranty of 
00021 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
00022 //   General Public License for more details. 
00023 //            
00024 //   You should have received a copy of the GNU General Public License 
00025 //   along with this program; if not, write to the Free Software 
00026 //   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 
00027 //   02111-1307, USA. 
00028 //
00030 
00031 // ScopeGrid.h: interface for the CScopeGrid class.
00032 
00033 
00034 #if !defined(AFX_SCOPEGRID_H__E91D0ABA_84EC_4E7A_8AA8_FCC45E216208__INCLUDED_)
00035 #define AFX_SCOPEGRID_H__E91D0ABA_84EC_4E7A_8AA8_FCC45E216208__INCLUDED_
00036 #if _MSC_VER > 1000
00037 #pragma once
00038 #endif // _MSC_VER > 1000
00039 
00040 #include <string>
00041 #include <cstring>
00042 #include <FL/fl_draw.H>
00043 #include <FLTKVW/Flv_Table.H>
00044 #include <FL/Fl_Menu_Window.H>
00045 #include "DBImage.h"
00046 #include <MOOSLIB/MOOSCommClient.h>
00047 
00048 
00049 
00050 
00051 
00052 // FLOATING TIP WINDOW
00053 
00054 
00055 class CTipWindow : public Fl_Menu_Window {
00056 
00057 //    std::string m_sText;
00058     char m_sText[4096];
00059 public:
00060     CTipWindow():Fl_Menu_Window(1,1) {    // will autosize
00061         set_override();
00062         end();
00063     }
00064     void draw() {
00065         draw_box(FL_BORDER_BOX, 0, 0, w(), h(), Fl_Color(175));
00066         fl_color(FL_BLACK);
00067         fl_font(labelfont(), 10);
00068         fl_draw(m_sText, 3, 3, w()-6, h()-6, Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_TOP|FL_ALIGN_WRAP));
00069     }
00070 
00071     void value(const std::string & sStr) 
00072     {
00073         if(sStr.size()<sizeof(m_sText))
00074         {
00075             strncpy(m_sText,sStr.c_str(),sizeof(m_sText));
00076         }
00077 
00078         fl_font(labelfont(), labelsize());
00079         int W = w(), H = h();
00080         fl_measure(m_sText, W, H, Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_WRAP|FL_ALIGN_TOP));
00081         size(W+10, H+10);
00082         redraw();
00083     }
00084 };
00085 
00086 class CScopeGrid : public Flv_Table  
00087 {
00088 public:
00089     void SetDBImage(CDBImage * pDBImage);
00090     void SetComms(CMOOSCommClient* pComms){m_pComms = pComms;};
00091     void SetTitle(std::string sTitle);
00092 
00093     static void GridCallback(CScopeGrid *pMe, void * )
00094     {
00095         pMe->OnGridCallBack();
00096     }
00097     CScopeGrid( int X, int Y, int W, int H, const char *l=0 );
00098     virtual void draw_cell( int Offset, int &X, int &Y, int &W, int &H, int R, int C );
00099     virtual void get_style( Flv_Style &s, int R, int C );
00100     virtual void redraw();
00101     virtual int handle(int e);
00102     void OnGridCallBack();
00103     int col_width( int C );
00104     int m_nCount;
00105 
00106 protected:
00107     std::string GetDataValue(int R,int C);
00108     bool PokeMOOS(CDBImage::CVar & Var, bool bNew);
00109     CTipWindow * m_pTW;
00110     CDBImage * m_pDBImage;
00111     char m_csTitle[256];
00112 
00113     CMOOSCommClient* m_pComms;
00114 
00115 private :
00116     typedef Flv_Table BASE ;
00117 };
00118 
00119 #endif // !defined(AFX_SCOPEGRID_H__E91D0ABA_84EC_4E7A_8AA8_FCC45E216208__INCLUDED_)
00120 
00121 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines