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 #include <vector>
00030
00031 #include <wx/scrolwin.h>
00032 #include <wx/progdlg.h>
00033
00034 #include "wxluxframe.h"
00035 #include "wxviewer.h"
00036
00037 namespace lux
00038 {
00039
00040 #define ID_RENDERUPDATE 2000
00041 #define ID_STATSUPDATE 2001
00042 #define ID_LOADUPDATE 2002
00043 #define ID_SAVEUPDATE 2003
00044 #define ID_NETUPDATE 2004
00045
00046
00047
00048 class LuxError {
00049 public:
00050 LuxError(int code, int severity, const char *msg): m_code(code), m_severity(severity), m_msg(msg) {}
00051
00052 int GetCode() { return m_code; }
00053 int GetSeverity() { return m_severity; }
00054 const std::string& GetMessage() { return m_msg; }
00055
00056 protected:
00057 int m_code;
00058 int m_severity;
00059 std::string m_msg;
00060 };
00061
00062 class wxLuxErrorEvent : public wxEvent {
00063 public:
00064 wxLuxErrorEvent(const boost::shared_ptr<LuxError> error, wxEventType eventType = wxEVT_NULL, int id = 0): wxEvent(id, eventType), m_error(error) {}
00065
00066 boost::shared_ptr<LuxError> GetError() { return m_error; }
00067
00068
00069 wxEvent* Clone(void) const { return new wxLuxErrorEvent(*this); }
00070
00071 protected:
00072 boost::shared_ptr<LuxError> m_error;
00073 };
00074
00075 DECLARE_LOCAL_EVENT_TYPE(wxEVT_LUX_ERROR, -1)
00076 DECLARE_LOCAL_EVENT_TYPE(wxEVT_LUX_PARSEERROR, -1)
00077 DECLARE_LOCAL_EVENT_TYPE(wxEVT_LUX_FINISHED, -1)
00078 DECLARE_LOCAL_EVENT_TYPE(wxEVT_LUX_TONEMAPPED, -1)
00079 DECLARE_LOCAL_EVENT_TYPE(wxEVT_LUX_FLMLOADERROR, -1)
00080 DECLARE_LOCAL_EVENT_TYPE(wxEVT_LUX_SAVEDFLM, -1)
00081
00082 typedef void (wxEvtHandler::*wxLuxErrorEventFunction)(wxLuxErrorEvent&);
00083
00084 #define EVT_LUX_ERROR(id, fn) \
00085 DECLARE_EVENT_TABLE_ENTRY( wxEVT_LUX_ERROR, id, -1, \
00086 (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) \
00087 wxStaticCastEvent( wxLuxErrorEventFunction, & fn ), (wxObject *) NULL ),
00088
00089
00090
00091 class LuxOutputWin : public wxScrolledWindow, public wxViewerBase {
00092 public:
00093 LuxOutputWin(wxWindow *parent);
00094 virtual wxWindow* GetWindow();
00095 virtual void Reload();
00096
00097 protected:
00098 DECLARE_EVENT_TABLE()
00099 void OnDraw(wxDC &dc);
00100 };
00101
00102
00103
00104
00105 enum LuxGuiRenderState
00106 {
00107 WAITING,
00108 PARSING,
00109 RENDERING,
00110 STOPPING,
00111 STOPPED,
00112 PAUSED,
00113 FINISHED,
00114 TONEMAPPING
00115 };
00116 enum LuxGuiWindowState
00117 {
00118 SHOWN,
00119 HIDDEN
00120 };
00121
00122 class LuxGui : public LuxMainFrame {
00123 public:
00125 LuxGui(wxWindow* parent, bool opengl, bool copylog2console);
00126 ~LuxGui();
00127
00128 void RenderScenefile(wxString filename);
00129 void RenderScenefile(wxString sceneFilename, wxString flmFilename);
00130 void SetRenderThreads(int num);
00131
00132 protected:
00133 DECLARE_EVENT_TABLE()
00134
00135 void OnMenu(wxCommandEvent &event);
00136 void OnMouse(wxMouseEvent &event);
00137 void OnOpen(wxCommandEvent &event);
00138 void OnResumeFLM(wxCommandEvent &event);
00139 void OnLoadFLM(wxCommandEvent &event);
00140 void OnSaveFLM(wxCommandEvent &event);
00141 void OnExit(wxCloseEvent &event);
00142 void OnError(wxLuxErrorEvent &event);
00143 void OnTimer(wxTimerEvent& event);
00144 void OnCommand(wxCommandEvent &event);
00145 void OnIconize(wxIconizeEvent& event);
00146 void OnSelection(wxViewerEvent& event);
00147 void OnSpin( wxSpinEvent& event );
00148 void OnSpinText(wxCommandEvent& event);
00149 void OnScroll( wxScrollEvent& event );
00150 void OnText(wxCommandEvent &event);
00151 void OnFocus(wxFocusEvent &event);
00152 void OnCheckBox(wxCommandEvent &event);
00153 void OnColourChanged(wxColourPickerEvent &event);
00154
00160 bool CanStopRendering();
00165 void StopRendering();
00166
00167 void ChangeRenderState(LuxGuiRenderState state);
00168 void LoadImages();
00169
00170
00171 void EngineThread(wxString filename);
00172 void UpdateThread();
00173 void FlmLoadThread(wxString filename);
00174 void FlmSaveThread(wxString filename);
00175 int m_numThreads;
00176
00177 void UpdateStatistics();
00178 void ApplyTonemapping(bool withlayercomputation = false);
00179
00180 boost::thread *m_engineThread, *m_updateThread, *m_flmloadThread, *m_flmsaveThread;
00181 bool m_opengl;
00182 bool m_copyLog2Console;
00183
00184 bool m_showWarningDialog;
00185 double m_samplesSec;
00186 LuxGuiRenderState m_guiRenderState;
00187 LuxGuiWindowState m_guiWindowState;
00188
00189 wxProgressDialog* m_progDialog;
00190
00191 wxViewerBase* m_renderOutput;
00192
00193 wxTimer* m_loadTimer;
00194 wxTimer* m_saveTimer;
00195 wxTimer* m_renderTimer;
00196 wxTimer* m_statsTimer;
00197 wxTimer* m_netTimer;
00198
00199 wxBitmap m_splashbmp;
00200
00201
00202 class luxTreeData : public wxTreeItemData
00203 {
00204 public:
00205
00206 wxString m_SlaveName;
00207 wxString m_SlaveFile;
00208 wxString m_SlavePort;
00209 wxString m_SlaveID;
00210
00211 unsigned int m_secsSinceLastContact;
00212 double m_numberOfSamplesReceived;
00213 };
00214
00215 wxString m_CurrentFile;
00216
00217 void UpdateNetworkTree( void );
00218
00219 void AddServer( void );
00220 void RemoveServer( void );
00221
00222 void OnTreeSelChanged( wxTreeEvent& event );
00223
00224 void UpdatedTonemapParam();
00225 void UpdateTonemapWidgetValues( void );
00226 void ResetToneMapping( void );
00227 void ResetToneMappingFromFilm( bool useDefaults=true );
00228
00229 void UpdateLightGroupWidgetValues( void );
00230 void ResetLightGroups( void );
00231 void ResetLightGroupsFromFilm( bool useDefaults=true );
00232
00233 void SetColorSpacePreset(int choice);
00234 void SetWhitepointPreset(int choice);
00235 void SetTonemapKernel(int choice);
00236
00237 int ValueToLogSliderVal(float value, const float logLowerBound, const float logUpperBound);
00238 float LogSliderValToValue(int sliderval, const float logLowerBound, const float logUpperBound);
00239
00240
00241 bool m_auto_tonemap;
00242 int m_TM_kernel;
00243
00244 double m_TM_reinhard_prescale;
00245 double m_TM_reinhard_postscale;
00246 double m_TM_reinhard_burn;
00247
00248 double m_TM_linear_exposure;
00249 double m_TM_linear_sensitivity;
00250 double m_TM_linear_fstop;
00251 double m_TM_linear_gamma;
00252
00253 double m_TM_contrast_ywa;
00254
00255 double m_TORGB_xwhite, m_TORGB_ywhite;
00256 double m_TORGB_xred, m_TORGB_yred;
00257 double m_TORGB_xgreen, m_TORGB_ygreen;
00258 double m_TORGB_xblue, m_TORGB_yblue;
00259
00260 bool m_Gamma_enabled;
00261 double m_TORGB_gamma;
00262
00263 bool m_Lenseffects_enabled;
00264
00265 double m_bloomradius, m_bloomweight;
00266
00267 bool m_Vignetting_Enabled;
00268 double m_Vignetting_Scale;
00269
00270 bool m_Aberration_enabled;
00271 double m_Aberration_amount;
00272
00273 double m_Glare_amount, m_Glare_radius;
00274 int m_Glare_blades;
00275
00276 bool m_Noisereduction_enabled;
00277
00278 bool m_GREYC_enabled, m_GREYC_fast_approx;
00279 double m_GREYC_amplitude, m_GREYC_sharpness, m_GREYC_anisotropy,
00280 m_GREYC_alpha, m_GREYC_sigma, m_GREYC_gauss_prec, m_GREYC_dl, m_GREYC_da;
00281 double m_GREYC_nb_iter;
00282 int m_GREYC_interp;
00283
00284 bool m_Chiu_enabled, m_Chiu_includecenter;
00285 double m_Chiu_radius;
00286
00287
00288 class LuxLightGroupPanel : public LightGroupPanel {
00289 public:
00290 LuxLightGroupPanel(
00291 LuxGui* gui,
00292 wxWindow* parent, wxWindowID id = wxID_ANY,
00293 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ),
00294 long style = wxTAB_TRAVERSAL );
00295
00296 void SetIndex( int index );
00297 int GetIndex() const;
00298
00299 void UpdateWidgetValues();
00300 void ResetValues();
00301 void ResetValuesFromFilm( bool useDefaults=true );
00302
00303 protected:
00304 int ScaleToSliderVal(float scale);
00305 float SliderValToScale(int sliderval);
00306
00307 void SetWidgetsEnabled( bool enabled );
00308
00309 void OnText(wxCommandEvent& event);
00310 void OnMouse(wxMouseEvent &event);
00311 void OnCheckBox(wxCommandEvent &event);
00312 void OnColourChanged(wxColourPickerEvent &event);
00313 void OnScroll(wxScrollEvent& event);
00314 private:
00315 LuxGui* const m_Gui;
00316 int m_Index;
00317
00318 bool m_LG_enable;
00319 double m_LG_scale;
00320 bool m_LG_temperature_enabled;
00321 double m_LG_temperature;
00322 bool m_LG_rgb_enabled;
00323 double m_LG_scaleRed, m_LG_scaleGreen, m_LG_scaleBlue;
00324 double m_LG_scaleX, m_LG_scaleY;
00325 };
00326
00327 std::vector<LuxLightGroupPanel*> m_LightGroupPanels;
00328
00329
00330 class ImageWindow : public wxWindow {
00331 public:
00332 ImageWindow(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxPanelNameStr);
00333 ~ImageWindow();
00334 void SetImage(const wxImage& img);
00335 protected:
00336 void OnPaint(wxPaintEvent& event);
00337 void OnEraseBackground(wxEraseEvent& event);
00338 private:
00339 wxBitmap* m_bitmap;
00340 };
00341
00342
00343 class LuxHistogramWindow : public ImageWindow {
00344 public:
00345 LuxHistogramWindow(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition);
00346 ~LuxHistogramWindow();
00347 void Update();
00348 void SetOption(int option);
00349 void ClearOption(int option);
00350 void SetEnabled(bool enabled);
00351 protected:
00352 void OnSize(wxSizeEvent& event);
00353 private:
00354 int m_Options;
00355 bool m_IsEnabled;
00356 };
00357
00358 LuxHistogramWindow *m_HistogramWindow;
00359
00360 };
00361
00362
00363
00364
00365 void LuxGuiErrorHandler(int code, int severity, const char *msg);
00366
00367 }
00368
00369 #endif // LUX_WXLUXGUI_H