1 /****************************************************************************** 2 * 3 * Project: OpenCPN 4 * Purpose: Grib Settings Dialog 5 * Author: Sean D'Epagnier 6 * 7 *************************************************************************** 8 * Copyright (C) 2014 by Sean D'Epagnier * 9 * * 10 * This program is free software; you can redistribute it and/or modify * 11 * it under the terms of the GNU General Public License as published by * 12 * the Free Software Foundation; either version 2 of the License, or * 13 * (at your option) any later version. * 14 * * 15 * This program is distributed in the hope that it will be useful, * 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 * GNU General Public License for more details. * 19 * * 20 * You should have received a copy of the GNU General Public License * 21 * along with this program; if not, write to the * 22 * Free Software Foundation, Inc., * 23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 24 *************************************************************************** 25 * 26 */ 27 28 #ifndef __GRIBSETTINGSDIALOG_H__ 29 #define __GRIBSETTINGSDIALOG_H__ 30 31 #include "GribUIDialogBase.h" 32 33 #include "jsonval.h" 34 35 //---------------------------------------------------------------------------------------------------------- 36 // Grib OverlaySettings Specification 37 //---------------------------------------------------------------------------------------------------------- 38 struct GribOverlaySettings 39 { 40 static wxString NameFromIndex(int index); 41 42 void Read(); 43 void Write(); 44 void SaveSettingGroups(wxFileConfig *pConf, int settings, int group); 45 46 wxString SettingsToJSON(wxString json); 47 bool JSONToSettings(wxString json); 48 bool UpdateJSONval( wxJSONValue &v, int settings, int group); 49 50 double CalibrationOffset(int settings); 51 double CalibrationFactor(int settings, double input, bool reverse = false); CalibrateValueGribOverlaySettings52 double CalibrateValue(int settings, double input) 53 { return (input+CalibrationOffset(settings))*CalibrationFactor(settings, input); } 54 int GetMinFromIndex( int index ); 55 wxString GetAltitudeFromIndex( int index, int unit ); 56 double GetmstobfFactor(double input); 57 double GetbftomsFactor(double input); 58 wxString GetUnitSymbol(int settings); 59 double GetMin(int settings); 60 double GetMax(int settings); 61 // playback options 62 bool m_bInterpolate; 63 bool m_bLoopMode; 64 int m_LoopStartPoint; 65 int m_SlicesPerUpdate; 66 int m_UpdatesPerSecond; 67 //display 68 int m_iOverlayTransparency; 69 //gui 70 int m_iCtrlandDataStyle; 71 wxString m_iCtrlBarCtrlVisible[2]; 72 73 enum SettingsType {WIND, WIND_GUST, PRESSURE, WAVE, CURRENT, PRECIPITATION, CLOUD, 74 AIR_TEMPERATURE, SEA_TEMPERATURE, CAPE, COMP_REFL, GEO_ALTITUDE, REL_HUMIDITY, SETTINGS_COUNT}; 75 enum Units0 {KNOTS, M_S, MPH, KPH, BFS}; 76 enum Units1 {MILLIBARS, MMHG, INHG}; 77 enum Units2 {METERS, FEET}; 78 enum Units3 {CELCIUS, FAHRENHEIT}; 79 enum Units4 {MILLIMETERS, INCHES}; 80 enum Units5 {PERCENTAGE}; 81 enum Units6 {JPKG}; 82 enum Units7 {DBZ}; 83 84 struct OverlayDataSettings { 85 int m_Units; 86 bool m_bBarbedArrows; 87 bool m_iBarbedVisibility; 88 int m_iBarbedColour; 89 bool m_bBarbArrFixSpac; 90 int m_iBarbArrSpacing; 91 bool m_bIsoBars; 92 bool m_bAbbrIsoBarsNumbers; 93 bool m_iIsoBarVisibility; 94 double m_iIsoBarSpacing; 95 bool m_bDirectionArrows; 96 int m_iDirectionArrowForm; 97 bool m_bDirArrFixSpac; 98 int m_iDirectionArrowSize; 99 int m_iDirArrSpacing; 100 bool m_bOverlayMap; 101 int m_iOverlayMapColors; 102 bool m_bNumbers; 103 bool m_bNumFixSpac; 104 int m_iNumbersSpacing; 105 bool m_bParticles; 106 double m_dParticleDensity; 107 108 } Settings[SETTINGS_COUNT]; 109 }; 110 111 class GRIBUICtrlBar; 112 113 class GribSettingsDialog : public GribSettingsDialogBase 114 { 115 public: 116 GribSettingsDialog(GRIBUICtrlBar &parent, GribOverlaySettings &extSettings, int &lastdatatype, int fileIntervalIndex); 117 void WriteSettings(); 118 119 void SetSettingsDialogSize(); 120 void SaveLastPage(); GetPageIndex()121 int GetPageIndex() { return m_SetBookpageIndex; } 122 123 private: 124 void SetDataTypeSettings(int settings); 125 void ReadDataTypeSettings(int settings); 126 void PopulateUnits(int settings); 127 void ShowFittingSettings (int settings); 128 void ShowSettings( int params, bool show = true ); 129 void OnDataTypeChoice( wxCommandEvent& event ); 130 void OnUnitChange( wxCommandEvent& event ); 131 void OnTransparencyChange( wxScrollEvent& event ); 132 void OnApply( wxCommandEvent& event ); 133 void OnIntepolateChange( wxCommandEvent& event ); 134 void OnSpacingModeChange( wxCommandEvent& event ); 135 void OnPageChange( wxNotebookEvent& event ); 136 void OnCtrlandDataStyleChanged( wxCommandEvent& event ); 137 138 GRIBUICtrlBar &m_parent; 139 140 GribOverlaySettings m_Settings, &m_extSettings; 141 int &m_lastdatatype; 142 int m_SetBookpageIndex; 143 }; 144 145 #endif 146