Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

MobileInterface.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2011 The Board of Trustees of the           
00004  *cr                        University of Illinois                       
00005  *cr                         All Rights Reserved                        
00006  *cr                                                                   
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: MobileInterface.h,v $
00013  *      $Author: kvandivo $     $Locker:  $             $State: Exp $
00014  *      $Revision: 1.11 $       $Date: 2012/03/18 00:26:58 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *
00019  * The Mobile UI object, which maintains the current state of the 
00020  * mobile phone, tablet, or other WiFi input or auxiliary display device.
00021  *
00022  ***************************************************************************/
00023 #ifndef MOBILEINTERFACE_H
00024 #define MOBILEINTERFACE_H
00025 
00026 #include "UIObject.h"
00027 #include "Command.h"
00028 #include "JString.h"
00029 #include "NameList.h"
00030 #include "WKFUtils.h"
00031 
00032 class MobileClientList {
00033   public:
00034     MobileClientList() {}
00035     MobileClientList(const JString n, const JString i, const bool a) :
00036              nick(n), ip(i), active(a) {}
00037   private:
00038     JString nick;
00039     JString ip;
00040     bool active;
00041 };
00042 
00044 class Mobile : public UIObject {
00045 public:
00047   enum MoveMode { OFF, MOVE, ANIMATE, TRACKER, USER };
00048 
00049   enum TouchMode { ROTATE, TRANSLATE, SCALEROTZ };
00050 
00052   static const char *get_mode_str(MoveMode mode);
00053 
00054 private:
00055   void *mobile;
00056   int port;          
00057 
00058   MoveMode moveMode; 
00059   int maxstride;     
00060   float transInc;    
00061   float rotInc;      
00062   float scaleInc;    
00063   float animInc;     
00064   int buttonDown;    
00065 
00066   int touchinprogress;
00067   int touchcount;
00068   int touchmode;
00069   wkf_timerhandle packtimer;
00070   float touchstartX;
00071   float touchstartY;
00072   float touchdeltaX;
00073   float touchdeltaY;
00074   float touchscale;
00075   float touchscalestartdist;
00076   float touchrotstartangle;
00077 
00078   float tranScaling; 
00079   float rotScaling;
00080   float zoomScaling;
00081 
00082 
00084   float trtx;
00085   float trty;
00086   float trtz;
00087   float trrx;
00088   float trry;
00089   float trrz;
00090   int trbuttons;
00091 
00092   ResizeArray <JString *> clientNick;
00093   ResizeArray <JString *> clientIP;
00094   ResizeArray <bool> clientActive;
00095   ResizeArray <int> clientListenerPort;
00096   ResizeArray <wkf_timerhandle> clientLastContact;
00097 
00098   bool isInControl(JString* nick, JString* ip, const int port, 
00099                    const int packtype);
00100 
00101   void sendStatus(const int event);
00102   void checkAndSendStatus();
00103   wkf_timerhandle statustimer;
00104 
00105   float statusSendSeconds;
00106 
00107   // 65507 is max length we can send (wikipedia.org/wiki/User_Datagram_Protocol)
00108   // same value is specified in UDPServer.java on the mobile side.
00109   char statusSendBuffer[1536];
00110   int statusSendBufferLength;
00111 
00112 
00113   void prepareSendBuffer(const int event);
00114 
00115 public:
00116   Mobile(VMDApp *);      
00117   virtual ~Mobile(void); 
00118   
00119   //
00120   // virtual routines for UI init/display
00121   //
00122    
00124   virtual void reset(void);
00125   
00130   virtual int act_on_command(int, Command *); 
00131   
00133   virtual int check_event(void);
00134 
00135   // get the currently configured port number
00136   int get_port ();
00137 
00138   // get the currently supported API level
00139   int get_APIsupported ();
00140 
00141   // get the currently configured mode
00142   int get_move_mode ();
00143 
00144   // get the current list of connected clients
00145   void  get_client_list (ResizeArray <JString*>* &nick, 
00146                          ResizeArray <JString*>* &ip, ResizeArray <bool>* &active);
00147 
00148   int move_mode(MoveMode mm);
00149 
00151 int set_activeClient(const char *nick, const char *ip);
00152 
00154 int sendMsgToClient(const char *nick, const char *ip, const char *msgType, const char *msg);
00155 
00157   int network_port(int newport);
00158 
00160   void set_max_stride(int ms) {
00161     maxstride = ms;
00162   }
00163 
00166   void get_tracker_status(float &tx, float &ty, float &tz, 
00167                           float &rx, float &ry, float &rz, int &buttons);
00168 
00169 
00170   int  addNewClient(JString* nick,  JString* ip, const int port, 
00171                                     const bool active);
00172   int  removeClient(const int num);
00173   void removeAllClients();
00174 
00175 };
00176 
00177 
00181 class CmdMobileMode : public Command {
00182 public:
00184   CmdMobileMode(int mm)
00185   : Command(MOBILE_MODE), mobileMode(mm) {}
00186 
00188   int mobileMode;
00189 };
00190 
00191 #endif
00192 

Generated on Sat May 26 01:48:10 2012 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002