00001 #ifndef _vuSpecPalette_h_
00002 #define _vuSpecPalette_h_
00003
00004 #include <wx/wx.h>
00005 #include <wx/dialog.h>
00006 #include <wx/textctrl.h>
00007 #include <wx/checkbox.h>
00008 #include <wx/listbox.h>
00009
00010 #include "vuColourXYZa.h"
00011 #include "vuSpectral/SPalette.h"
00012 #ifdef WIN32
00013 #include <wx/msw/winundef.h>
00014 #endif
00015
00017
00018 class vuSpecPalette : public wxDialog
00019 {
00020 public:
00021
00022 enum
00023 {
00024 idCREATESP,
00025 idLOADPAL,
00026 idSAVEPAL,
00027 idLOADSP,
00028 idSAVESP,
00029 idRED_SLIDER,
00030 idGREEN_SLIDER,
00031 idBLUE_SLIDER,
00032 idWEIGHT_SLIDER,
00033 idDCDES,
00034 idDCGET,
00035 idDCGETALL,
00036 idDCFC,
00037 idFCUSEB,
00038 idFCUB,
00039 idFCLB,
00040 idSPNAME,
00041 idSPDES,
00042 idSPUSEB,
00043 idSPUB,
00044 idSPLB,
00045 idADDREF,
00046 idADDLIG,
00047 idWSMOOTH,
00048 idWERROR,
00049 idUSEV7,
00050 idMUL,
00051 idDIV,
00052 idSETPLANCK,
00053 idNORMNORM,
00054 idNORMLUM,
00055 idLAST
00056 };
00057
00059
00065 vuSpecPalette(wxWindow *parent, SPalette &pal);
00066
00068 ~vuSpecPalette();
00069
00071 const SPalette& getSPalette() const;
00072
00075 void selectSpec(int rid, int lid);
00076
00079 void UpdateWidgets();
00080
00082 void FitAllDesignColours() {
00083 #if wxMINOR_VERSION < 5
00084 OnGetAllDCColours();
00085 #else
00086 wxCommandEvent ev;
00087 OnGetAllDCColours(ev);
00088 #endif
00089 }
00090
00091 protected:
00092 enum TYPE_COLOUR_CLICK {CC_GET, CC_PUT, CC_TOGGLE_DESIGN,};
00094
00098 void OnColourClick(int refl, int light, TYPE_COLOUR_CLICK what);
00100 void CalculateMeasurements();
00102 void CreateWidgets();
00104 void ClearAndHighlight(wxDC& dc);
00106 void PaintColours(wxDC& dc);
00108 void PaintColour(wxDC& dc);
00110 void PaintSpectrum(wxDC& dc);
00111
00112
00114 void OnMouseEvent(wxMouseEvent& event);
00116 void OnPaint(wxPaintEvent& event);
00118 void OnOK(wxCommandEvent &ev);
00120 void OnLoadPal(wxCommandEvent &ev);
00122 void OnSavePal(wxCommandEvent &ev);
00124 void OnLoadSP(wxCommandEvent &ev);
00126 void OnSaveSP(wxCommandEvent &ev);
00128 void OnMultiplyScalar(wxCommandEvent &ev);
00130 void OnDivideScalar(wxCommandEvent &ev);
00133 void OnNormVal(wxCommandEvent &ev) {
00134 switch(ev.GetId()) {
00135 case idNORMNORM :
00136 m_SScale->SetValue(m_SP_Norm->GetValue());
00137 break;
00138 case idNORMLUM:
00139 m_SScale->SetValue(m_SP_Y->GetValue());
00140 break;
00141 }
00142 OnDivideScalar(ev);
00143 }
00145 void OnAddReflectance(wxCommandEvent &ev) {
00146 m_Palette->addReflectance(vuColour31a(1.0f));
00147 UpdateWidgets();
00148 };
00150 void OnAddLight(wxCommandEvent &ev) {
00151 m_Palette->addLight(vuColour31a(1.0f));
00152 UpdateWidgets();
00153 };
00156 void OnCreatePlanckian(wxCommandEvent &ev);
00157
00159 bool validSpecSelected() {
00160 return ((m_SelRefl==-1) ^ (m_SelLight==-1) &&
00161 (m_SelRefl<(int)getNRefls()) && (m_SelLight<(int)getNLights()));
00162 }
00164 #if wxMINOR_VERSION < 5
00165 void OnCBSPDesign(void) {
00166 #else
00167 void OnCBSPDesign(wxCommandEvent&) {
00168 #endif
00169 if(validSpecSelected()) {
00170 bool &des = m_Palette->getSpecDesignState(m_SelRefl,m_SelLight);
00171 des = m_SP_design->GetValue();
00172 }
00173 };
00175 #if wxMINOR_VERSION < 5
00176 void OnSPUpperBound(void) {
00177 #else
00178 void OnSPUpperBound(wxCommandEvent&) {
00179 #endif
00180 if(validSpecSelected()) {
00181 double val;
00182 m_SP_upperBound->GetValue().ToDouble(&val);
00183 m_Palette->getSpecUB(m_SelRefl,m_SelLight) = val;
00184 }
00185 };
00187 #if wxMINOR_VERSION < 5
00188 void OnSPLowerBound(void) {
00189 #else
00190 void OnSPLowerBound(wxCommandEvent&) {
00191 #endif
00192 if(validSpecSelected()) {
00193 double val;
00194 m_SP_lowerBound->GetValue().ToDouble(&val);
00195 m_Palette->getSpecLB(m_SelRefl,m_SelLight) = val;
00196 }
00197 };
00199 #if wxMINOR_VERSION < 5
00200 void OnSPName(void) {
00201 #else
00202 void OnSPName(wxCommandEvent&) {
00203 #endif
00204 if(validSpecSelected())
00205 m_Palette->setSpecName(m_SelRefl,m_SelLight,
00206 m_SP_name->GetValue());
00207 };
00209 #if wxMINOR_VERSION < 5
00210 void OnCBSPUseB(void) {
00211 #else
00212 void OnCBSPUseB(wxCommandEvent&) {
00213 #endif
00214 if(validSpecSelected()) {
00215 bool &b = m_Palette->useSpecBounds(m_SelRefl,m_SelLight);
00216 b = m_SP_useBounds->GetValue();
00217 }
00218 };
00220 #if wxMINOR_VERSION < 5
00221 void OnCBDCDesign(void) {
00222 #else
00223 void OnCBDCDesign(wxCommandEvent&) {
00224 #endif
00225 if(m_SelDesColourR>=0 && m_SelDesColourL>=0)
00226 m_Palette->getDesignState(m_SelDesColourR,m_SelDesColourL)
00227 = m_DC_design->GetValue();
00228 };
00230 #if wxMINOR_VERSION < 5
00231 void OnGetDCColour(void) {
00232 #else
00233 void OnGetDCColour(wxCommandEvent&) {
00234 #endif
00235 if(m_SelDesColourR>=0 && m_SelDesColourL>=0) {
00236 m_Palette->getDesignRGBW(m_SelDesColourR,m_SelDesColourL)
00237 = m_Palette->getRLColour(m_SelDesColourR,m_SelDesColourL, m_useV7->GetValue());
00238 OnColourClick(m_SelDesColourR,m_SelDesColourL,CC_GET);
00239 }
00240 };
00242 #if wxMINOR_VERSION < 5
00243 void OnGetAllDCColours() {
00244 #else
00245 void OnGetAllDCColours(wxCommandEvent&) {
00246 #endif
00247 for (int refl = 0; refl < (int)getNRefls(); refl++) {
00248 for (int light = 0; light < (int)getNLights(); light++) {
00249 m_Palette->getDesignRGBW(refl,light)
00250 = m_Palette->getRLColour(refl,light, m_useV7->GetValue());
00251 }
00252 }
00253
00254 if(m_SelDesColourR>=0 && m_SelDesColourL>=0)
00255 OnColourClick(m_SelDesColourR,m_SelDesColourL,CC_GET);
00256 }
00258 #if wxMINOR_VERSION < 5
00259 void OnChangeDCRGBW(void);
00260 #else
00261 void OnChangeDCRGBW(wxCommandEvent&);
00262 #endif
00263
00264 #if wxMINOR_VERSION < 5
00265 void OnDCFC(void);
00266 #else
00267 void OnDCFC(wxCommandEvent&);
00268 #endif
00269
00270 #if wxMINOR_VERSION < 5
00271 void OnCBFCUseB(void);
00272 #else
00273 void OnCBFCUseB(wxCommandEvent&);
00274 #endif
00275
00276 #if wxMINOR_VERSION < 5
00277 void OnFCUpperBound(void);
00278 #else
00279 void OnFCUpperBound(wxCommandEvent&);
00280 #endif
00281
00282 #if wxMINOR_VERSION < 5
00283 void OnFCLowerBound(void);
00284 #else
00285 void OnFCLowerBound(wxCommandEvent&);
00286 #endif
00287
00288 #if wxMINOR_VERSION < 5
00289 void OnSmoothW(void) {
00290 #else
00291 void OnSmoothW(wxCommandEvent&) {
00292 #endif
00293 double val;
00294 m_SmoothW->GetValue().ToDouble(&val);
00295 m_Palette->setSmoothnessWeight(val);
00296 };
00298 #if wxMINOR_VERSION < 5
00299 void OnErrorW(void) {
00300 #else
00301 void OnErrorW(wxCommandEvent&) {
00302 #endif
00303 double val;
00304 m_ErrorW->GetValue().ToDouble(&val);
00305 m_Palette->setErrorMinWeight(val);
00306 };
00308 #if wxMINOR_VERSION < 5
00309 void OnCBUseV7(void) {
00310 #else
00311 void OnCBUseV7(wxCommandEvent&) {
00312 #endif
00313 m_Palette->useV7(m_useV7->GetValue());
00314 };
00315
00316 #if wxMINOR_VERSION < 5
00317 void OnCreateSpectrum() {
00318 #else
00319 void OnCreateSpectrum(wxCommandEvent& ev) {
00320 #endif
00321 m_Palette->createSpectrum();
00322 UpdateWidgets();
00323 };
00324
00326 #if wxMINOR_VERSION < 5
00327 void OnCompSlider( wxScrollEvent& event);
00328 #else
00329 void OnCompSlider( wxCommandEvent& event);
00330 #endif
00331
00332
00334 bool TransferDataToWindow() {return true;};
00336 bool TransferDataFromWindow() {return true;};
00337
00338 dword getNLights() {return m_Palette->getNLights();};
00339 dword getNRefls() {return m_Palette->getNRefls();};
00340
00341 protected:
00343 SPalette *m_Palette;
00344
00346 bool m_DCSelected;
00348 int m_SelDesColourR, m_SelDesColourL;
00349
00350 int m_SelRefl;
00351 int m_SelLight;
00352
00354 wxRect m_PalRect;
00356 wxPoint m_ColourSize;
00358 wxPoint m_Border;
00359
00361 int m_GridSpacing;
00363 int m_SectionSpacing;
00364
00366 wxSlider *m_CompSlider[4];
00367
00369 wxCheckBox *m_DC_design, *m_FC_useBounds, *m_SP_useBounds,
00370 *m_SP_design, *m_useV7;
00372 wxTextCtrl *m_FC_upperBound, *m_FC_lowerBound,
00373 *m_SP_upperBound, *m_SP_lowerBound, *m_SP_name,
00374 *m_SmoothW, *m_ErrorW, *m_SScale,
00375 *m_SP_Y, *m_SP_Norm, *m_PlanckT;
00377 wxListBox *m_DC_FreeCol;
00378
00381 wxSizer *m_DiagSpacer, *m_DColSpacer, *m_PalSpacer;
00383 wxRect m_DiagRect, m_DColRect;
00385 wxSizer* m_TopSizer;
00386
00387 DECLARE_EVENT_TABLE()
00388 };
00389
00390 #endif