Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

Model.H

Go to the documentation of this file.
00001 
00016 #ifndef _MODEL_H
00017 #define _MODEL_H
00018 
00019 #include <wrapGL.H>
00020 #include <UserInterface.H>
00021 #include <Attributes.H>
00022 
00023 
00024 namespace xchen
00025 {
00026   class glModel;
00027 
00028   class Model
00029   {
00030       friend class glModel;
00031   protected:
00032       Attributes attrs;
00033       UI* ui;
00034       
00035       template<typename T>
00036       void Register(string const& id, T const&v)          { attrs.Register(id,v); }         
00037       template<typename T>
00038       void SetAttribute(string const& id, T const& v)     { attrs[id].SetValue(v); }        
00039       void SetAttributes(string const& str)               { attrs.ReadFrom(str); }          
00040       void const* GetAttribute(string const& id)          { return attrs[id].GetValue(); }  
00041 
00042         
00043       void register_attributes();
00044       virtual void GenerateUI();                                                            
00045       void SetUI(UI* u)                                   { ui = u; }
00046                                                                                                                            
00047       virtual void DrawBrief() const                      { Draw(); }                       
00048       virtual void Draw() const = 0;
00049       
00050   public:
00051       Model() : ui(0)                                     { register_attributes(); }
00052       static vector<Model*> ConstructModelsFromFile(char const*);                           
00053   };
00054  
00055 
00056   inline void Model :: register_attributes()
00057   {
00058     Register("rgbas", E5(0.6,0.1,0.6, 1.0, 0.5));
00059     Register("line-width", 1);
00060     Register("point-size", 1);
00061   }
00062 
00063   inline void Model :: GenerateUI()
00064   {
00065     fE5 rgbas = *((E5*)GetAttribute("rgbas"));
00066     ui->AddfVectorControl("RGBAS", ": color(including alpha and shininess[0-300] for selected model.", 'c', rgbas);
00067     ui->AddfloatControl("Line Width", ": for selected model, range[0-5]", 'l', *(int*)GetAttribute("line-width"), 0, 5);
00068     ui->AddfloatControl("Point Size", ": for selected model, range[0-5]", 'p', *(int*)GetAttribute("point-size"), 0, 5);
00069   }
00070   
00071 }
00072 
00073 #endif

Generated on Wed Apr 7 21:40:49 2004 by doxygen1.2.18