00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef LUX_WXLUXGUI_H
00024 #define LUX_WXLUXGUI_H
00025
00026 #include <boost/shared_ptr.hpp>
00027 #include <boost/thread.hpp>
00028 #include <string>
00029
00030 #include <wx/scrolwin.h>
00031 #include <wx/progdlg.h>
00032
00033 #include "wxluxframe.h"
00034
00035 namespace lux
00036 {
00037
00038 #define ID_RENDERUPDATE 2000
00039 #define ID_STATSUPDATE 2001
00040 #define ID_LOADUPDATE 2002
00041
00042
00043
00044 class LuxError {
00045 public:
00046 LuxError(int code, int severity, const char *msg): m_code(code), m_severity(severity), m_msg(msg) {}
00047
00048 int GetCode() { return m_code; }
00049 int GetSeverity() { return m_severity; }
00050 const std::string& GetMessage() { return m_msg; }
00051
00052 protected:
00053 int m_code;
00054 int m_severity;
00055 std::string m_msg;
00056 };
00057
00058 class wxLuxErrorEvent : public wxEvent {
00059 public:
00060 wxLuxErrorEvent(const boost::shared_ptr<LuxError> error, wxEventType eventType = wxEVT_NULL, int id = 0): wxEvent(id, eventType), m_error(error) {}
00061
00062 boost::shared_ptr<LuxError> GetError() { return m_error; }
00063
00064
00065 wxEvent* Clone(void) const { return new wxLuxErrorEvent(*this); }
00066
00067 protected:
00068 boost::shared_ptr<LuxError> m_error;
00069 };
00070
00071 DECLARE_EVENT_TYPE(wxEVT_LUX_ERROR, -1)
00072 DECLARE_EVENT_TYPE(wxEVT_LUX_PARSEERROR, -1)
00073 DECLARE_EVENT_TYPE(wxEVT_LUX_FINISHED, -1)
00074 DECLARE_EVENT_TYPE(wxEVT_LUX_TONEMAPPED, -1)
00075
00076 typedef void (wxEvtHandler::*wxLuxErrorEventFunction)(wxLuxErrorEvent&);
00077
00078 #define EVT_LUX_ERROR(id, fn) \
00079 DECLARE_EVENT_TABLE_ENTRY( wxEVT_LUX_ERROR, id, -1, \
00080 (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) \
00081 wxStaticCastEvent( wxLuxErrorEventFunction, & fn ), (wxObject *) NULL ),
00082
00083
00084
00085 class LuxOutputWin : public wxScrolledWindow {
00086 public:
00087 LuxOutputWin(wxWindow *parent);
00088
00089 protected:
00090 DECLARE_EVENT_TABLE()
00091 void OnDraw(wxDC &dc);
00092 };
00093
00094
00095
00096
00097 enum LuxGuiRenderState
00098 {
00099 WAITING,
00100 RENDERING,
00101 IDLE,
00102 FINISHED
00103 };
00104 enum LuxGuiWindowState
00105 {
00106 SHOWN,
00107 HIDDEN
00108 };
00109
00110 class LuxGui : public LuxMainFrame {
00111 public:
00113 LuxGui(wxWindow* parent, bool opengl);
00114
00115 void RenderScenefile(wxString filename);
00116 void SetRenderThreads(int num);
00117
00118 protected:
00119 DECLARE_EVENT_TABLE()
00120
00121 void OnMenu(wxCommandEvent &event);
00122 void OnOpen(wxCommandEvent &event);
00123 void OnExit(wxCloseEvent &event);
00124 void OnError(wxLuxErrorEvent &event);
00125 void OnTimer(wxTimerEvent& event);
00126 void OnSpin(wxSpinEvent& event);
00127 void OnCommand(wxCommandEvent &event);
00128 void OnIconize(wxIconizeEvent& event);
00129
00130 void ChangeRenderState(LuxGuiRenderState state);
00131 void LoadImages();
00132
00133
00134 void EngineThread(wxString filename);
00135 void UpdateThread();
00136 int m_numThreads;
00137
00138 void UpdateStatistics();
00139
00140 boost::thread *m_engineThread, *m_updateThread;
00141 bool m_opengl;
00142 LuxGuiRenderState m_guiRenderState;
00143 LuxGuiWindowState m_guiWindowState;
00144
00145 wxProgressDialog* m_progDialog;
00146 wxWindow* m_renderOutput;
00147 wxTimer* m_loadTimer;
00148 wxTimer* m_renderTimer;
00149 wxTimer* m_statsTimer;
00150
00151 wxBitmap m_splashbmp;
00152 };
00153
00154
00155
00156
00157 void LuxGuiErrorHandler(int code, int severity, const char *msg);
00158
00159 }
00160
00161 #endif // LUX_WXLUXGUI_H