00001 #ifndef _VIEW_MANAGER_H_
00002 #define _VIEW_MANAGER_H_
00003 #include"types.h"
00004 #include"GraphicData.h"
00005 #include"GraphicsSettings.h"
00006 #include"Vec3D.h"
00007 #include"BBox3D.h"
00008 #include"View.h"
00009 #include"Object.h"
00010 #include"Legend.h"
00011 #include"RContext.h"
00012 #include"fv_dictstr.h"
00013 #include"fv_timer.h"
00014 #include "fv_config.h"
00015 #include "Enums.h"
00016 #include<vector>
00017 #include<string>
00018
00019 namespace FemViewer
00020 {
00021 class VtxAccumulator;
00022 class Tile;
00023 class GraphicsSettings;
00024 class BBox3D;
00025
00026 class ViewManager
00027 {
00028 public:
00029
00030 friend ViewManager& ViewManagerInst(void);
00031 friend class RContext;
00032
00033
00034
00035 ViewManager(int destWidth = DFLT_IMAGE_WIDTH, int destHeight = DFLT_IMAGE_HEIGHT);
00036 public:
00037 ~ViewManager();
00038
00039
00040 void Init(const BBox3D& pBBox);
00041
00042
00043 void Reset();
00044
00045
00046
00047
00048
00049 void AddView(const View& pView);
00050
00051
00052 void AddStatusMsg(const std::string& msg);
00053
00054
00055 void ClearStatusMsg();
00056
00057
00058 void Display(const Tile& pTile);
00059
00060 void DisplayCallback();
00061
00062 GraphicData& GetGraphicData();
00063
00064 GraphicsSettings* GetSettings() { return &UserSettings; }
00065 const GraphicsSettings* GetSettings() const { return &UserSettings; }
00066
00067 bool IdleCallback();
00068
00069 bool KeyboardCallback(unsigned char key);
00070
00071 bool KeyboardSpecialCallback(int key);
00072
00073 bool MenuCallback(const int& iEvent);
00074
00075 bool MouseButtonCallback(int button,
00076 int state,
00077 unsigned keystate,
00078 int x,
00079 int y);
00080
00081 bool MouseMotionCallback(int pX, int pY);
00082
00083 void ReshapeCallback(int pWidth, int pHeight);
00084
00085 void InitGL(int width,int height);
00086
00087 void SetTitle(const std::string* pTitle);
00088
00089 void SetLegend(const Legend& pLegend);
00090 Legend& GetLegend() { return legend; }
00091
00092 enum ViewResetMode { ViewReset_None, ViewReset_BBoxOnly, ViewReset_FullReset };
00093
00094 void SetViewResetMode(ViewResetMode pMode) { eViewResetMode = pMode; }
00095
00096 bool IsGLSupported() const { return bGLinited; }
00097 bool& GLSupport() { return bGLinited; }
00098 const bool& GLSupport() const { return bGLinited; }
00099
00100 bool IsVBOSuported() const { return vboSupported; }
00101
00102 bool IsVBOUsed() const { return vboUsed; }
00103
00104
00105 const View& GetCurrentView() const { return currentView; }
00106
00107 int GetWidth() const { return iWndWidth; }
00108 void SetWidth(int w) {
00109 iWndWidth = w;
00110 fAspectRatio = (float) iWndWidth / (float) iWndHeight;
00111 }
00112 int GetHeight() const { return iWndHeight; }
00113 void SetHeight(int h) {
00114 iWndHeight = h;
00115 fAspectRatio = (float) iWndWidth / (float) iWndHeight;
00116 }
00117 int GetMouseMode() const { return eMoveMode; }
00118
00119 void DrawAccelStruct(const float [],const float [],const grid_t* grid);
00120 private:
00121
00122 BBox3D aBBox;
00123 bool bGLinited;
00124 Object oAxes;
00125 View currentView;
00126 GraphicData aGraphicData;
00127 Legend legend;
00128 Object oGrid;
00129 Object oLegend;
00130 int iLastMouseX;
00131 int iLastMouseY;
00132 MouseMode eMoveMode;
00133 bool bNewViewAdded;
00134 ViewResetMode eViewResetMode;
00135 std::vector<std::string> vecStatusMsgs;
00136 const std::string* sTitle;
00137 GraphicsSettings UserSettings;
00138 int iViewIndex;
00139 std::vector<View> vecViews;
00140 int iWndWidth;
00141 int iWndHeight;
00142 float fAspectRatio;
00143 bool vboSupported;
00144 bool vboUsed;
00145 bool bGLEWInited;
00146 bool bUseExternalModule;
00147 unsigned int uFrameCount;
00148 bool bMeasurePerformance;
00149 fv_timer cTimer;
00150 double dLastTime;
00151 GLuint gl_grid[2], gl_axes;
00152 GLuint grid3D[2];
00153
00154 void InitGLEW(bool quiet = true);
00155 void DrawAxes();
00156 void DrawGrid();
00157 void DrawLegend();
00158 void DrawCubeSides();
00159 void DrawFPS();
00160 void DrawMouseMovementIndicators();
00161 void DrawTextLayer(const Tile& pTile);
00162 void Render(const Tile& pTile);
00163 void ResetCamera();
00164 void SetupLighting();
00165 void CreateCubeGrid();
00166 void RenderByCastRays();
00167
00168
00169 ViewManager(const ViewManager& rhs);
00170 ViewManager& operator=(const ViewManager& rhs);
00171 };
00172
00173 extern ViewManager& ViewManagerInst(void);
00174
00175 }
00176
00177 #endif