Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DasherModel.h

Go to the documentation of this file.
00001 // DasherModel.h
00002 //
00004 //
00005 // Copyright (c) 2001-2002 David Ward
00006 //
00008 
00009 #ifndef __DasherModel_h__
00010 #define __DasherModel_h__
00011 
00012 #include <iostream>
00013 #include "MSVC_Unannoy.h"
00014 #include "DashEdit.h"
00015 #include "DasherNode.h"
00016 #include "LanguageModel.h"
00017 #include "NoClones.h"
00018 #include <math.h>
00019 #include "DasherTypes.h"
00020 #include "FrameRate.h"
00021 #include <vector>
00022 
00023 // The CDasherModel represents the current state of Dasher
00024 // It contains a pointer to a structure of DasherNodes
00025 // The knows the current viewpoint
00026 // It also knows how to evolve the viewpoint
00027 
00028 namespace Dasher {class CDasherModel;}
00029 class Dasher::CDasherModel : private NoClones
00030 {
00031 public:
00032         
00033         CDasherModel(CDashEditbox* Editbox, CLanguageModel* LanguageModel, bool Dimensions);
00034         ~CDasherModel();
00035         
00036         // framerate functions
00037         void NewFrame(unsigned long Time) {m_fr.NewFrame(Time);}    // called everytime we render a new frame
00038         const double Framerate () {return m_fr.Framerate();}        // return the framerate
00039         
00040         // User control of speed
00041         void SetBitrate(double TargetRate) {m_fr.SetBitrate(TargetRate);} // Use or start at this bitrate
00042         void SetMaxBitrate(double MaxRate) {m_fr.SetMaxBitrate(MaxRate);} // Cap any adaption at this rate
00043         
00044         // functions returning private data (read only access)
00045         const myint Rootmin() const {return m_Rootmin;}
00046         const myint Rootmax() const {return m_Rootmax;}
00047         const myint DasherOX() const {return m_DasherOX;}
00048         CDasherNode* Root() const {return m_Root;}
00049         int Normalization() const {return m_languagemodel->normalization();}
00050         myint DasherY() const {return m_DasherY;}
00051         bool Dimensions() const {return m_Dimensions;}
00052 
00053         void Dump() const;                                              // diagnostics
00054         void Flush(const myint smousex,const myint smousey);            // flush to the edit control
00055         //void Learn_symbol(symbol Symbol) {m_languagemodel->learn_symbol(Symbol);} // feed character to language model
00056 
00057        void Set_dimensions(bool dimensions) {m_Dimensions=dimensions;}
00058         
00059         void Tap_on_display(myint,myint, unsigned long Time);           // evolves the current viewpoint
00060         void Start();                                                   // initializes the data structure
00061         void Make_root(int whichchild);                                 // find a new root node
00062         void Reparent_root(int lower, int upper);                                 // change back to the previous root
00063         void Reset_framerate(unsigned long Time) {m_fr.Reset(Time);}
00064 
00065         CAlphabet* m_alphabet;             // pointer to the alphabet
00066         
00067         CAlphabet* GetAlphabet() { return m_alphabet; }
00068 private:
00069 
00070         // Old root notes
00071         std::vector<CDasherNode*> oldroots;
00072 
00073         // Rootmin and Rootmax specify the position of the root node in Dasher coords
00074         myint m_Rootmin,m_Rootmax;
00075 
00076         // Size of Dasher's arithmetic coding interval - it defines the Dasher coordinate system
00077         myint m_DasherY;
00078 
00079         // x position of crosshair in Dasher coords - distance from RHS is square Dasher
00080         myint m_DasherOX;    
00081 
00082         // y position of crosshair in Dasher coords - distance from top in square Dasher
00083         myint m_DasherOY;     
00084 
00085         // Number of input dimensions
00086         bool m_Dimensions;
00087 
00088         CDashEditbox* m_editbox;           // pointer to the editbox
00089         CLanguageModel* m_languagemodel;   // pointer to the language model
00090         CLanguageModel::CNodeContext* LearnContext;        // Used to add data to model as it is entered
00091         CFrameRate m_fr;                   // keep track of framerate
00092         
00093         // TODO - move somewhere
00094         // the probability that gets added to every symbol
00095         double m_dAddProb;             
00096         
00097         CDasherNode* Get_node_under_mouse(myint smousex,myint smousey);
00098         CDasherNode* Get_node_under_crosshair();
00099         CDasherNode* m_Root;
00100         void Get_new_root_coords(myint mousex,myint mousey);
00101         void Get_string_under_mouse(const myint smousex,const myint smousey,std::vector<symbol> &str);
00102         void Update(CDasherNode* node,CDasherNode* under,int safe);
00103 
00104 
00105 
00106 
00107 
00108 };
00109 
00110 
00111 #endif /* #ifndef __DasherModel_h__ */

Generated on Sat Nov 5 16:16:00 2005 for OPIE by  doxygen 1.4.2