diff --git a/android/androidUTIL.cpp b/android/androidUTIL.cpp index 5acdaf24d5..7f6a852bb0 100644 --- a/android/androidUTIL.cpp +++ b/android/androidUTIL.cpp @@ -263,7 +263,6 @@ extern bool g_bAutoAnchorMark; extern wxAuiManager *g_pauimgr; extern wxString g_AisTargetList_perspective; - WX_DEFINE_ARRAY_PTR(ChartCanvas *, arrayofCanvasPtr); extern arrayofCanvasPtr g_canvasArray; @@ -357,7 +356,7 @@ int futimens(int fd, const struct timespec times[2]) { // Event handler for Raw NMEA messages coming from Java upstream class AndroidNMEAEvent : public wxEvent { public: - AndroidNMEAEvent( wxEventType commandType, int id); + AndroidNMEAEvent(wxEventType commandType, int id); ~AndroidNMEAEvent(); // accessors @@ -365,39 +364,39 @@ class AndroidNMEAEvent : public wxEvent { std::shared_ptr> GetPayload(); // required for sending with wxPostEvent() - wxEvent* Clone() const; + wxEvent *Clone() const; + private: std::shared_ptr> m_payload; }; wxDECLARE_EVENT(wxEVT_ANDROID_NMEA_RAW, AndroidNMEAEvent); - wxDEFINE_EVENT(wxEVT_ANDROID_NMEA_RAW, AndroidNMEAEvent); -AndroidNMEAEvent::AndroidNMEAEvent( wxEventType commandType, int id = 0) - : wxEvent(id, commandType){}; +AndroidNMEAEvent::AndroidNMEAEvent(wxEventType commandType, int id = 0) + : wxEvent(id, commandType) {}; -AndroidNMEAEvent::~AndroidNMEAEvent(){}; +AndroidNMEAEvent::~AndroidNMEAEvent() {}; -void AndroidNMEAEvent::SetPayload(std::shared_ptr> data) { - m_payload = data; +void AndroidNMEAEvent::SetPayload( + std::shared_ptr> data) { + m_payload = data; +} +std::shared_ptr> AndroidNMEAEvent::GetPayload() { + return m_payload; } -std::shared_ptr> AndroidNMEAEvent::GetPayload() { return m_payload; } - // required for sending with wxPostEvent() -wxEvent* AndroidNMEAEvent::Clone() const { - AndroidNMEAEvent* newevent = - new AndroidNMEAEvent(*this); - newevent->m_payload = this->m_payload; - return newevent; +// required for sending with wxPostEvent() +wxEvent *AndroidNMEAEvent::Clone() const { + AndroidNMEAEvent *newevent = new AndroidNMEAEvent(*this); + newevent->m_payload = this->m_payload; + return newevent; }; - - class androidUtilHandler : public wxEvtHandler { public: - androidUtilHandler(DriverListener& listener); + androidUtilHandler(DriverListener &listener); ~androidUtilHandler(); void onTimerEvent(wxTimerEvent &event); @@ -405,7 +404,7 @@ class androidUtilHandler : public wxEvtHandler { void OnResizeTimer(wxTimerEvent &event); void OnScheduledEvent(wxCommandEvent &event); - void handle_N0183_MSG(AndroidNMEAEvent& event); + void handle_N0183_MSG(AndroidNMEAEvent &event); wxString GetStringResult() { return m_stringResult; } void LoadAuxClasses(); @@ -420,7 +419,7 @@ class androidUtilHandler : public wxEvtHandler { int m_bskipConfirm; bool m_migratePermissionSetDone; - DriverListener& m_listener; + DriverListener &m_listener; DECLARE_EVENT_TABLE() }; @@ -435,9 +434,8 @@ EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, END_EVENT_TABLE() -androidUtilHandler::androidUtilHandler(DriverListener& listener) - : m_listener(listener) -{ +androidUtilHandler::androidUtilHandler(DriverListener &listener) + : m_listener(listener) { m_eventTimer.SetOwner(this, ANDROID_EVENT_TIMER); m_stressTimer.SetOwner(this, ANDROID_STRESS_TIMER); m_resizeTimer.SetOwner(this, ANDROID_RESIZE_TIMER); @@ -446,20 +444,17 @@ androidUtilHandler::androidUtilHandler(DriverListener& listener) LoadAuxClasses(); - // Prepare the wxEventHandler to accept events from upstream - Bind(wxEVT_ANDROID_NMEA_RAW, &androidUtilHandler::handle_N0183_MSG, - this); - + // Prepare the wxEventHandler to accept events from upstream + Bind(wxEVT_ANDROID_NMEA_RAW, &androidUtilHandler::handle_N0183_MSG, this); } androidUtilHandler::~androidUtilHandler() { - Unbind(wxEVT_ANDROID_NMEA_RAW, &androidUtilHandler::handle_N0183_MSG, - this); + Unbind(wxEVT_ANDROID_NMEA_RAW, &androidUtilHandler::handle_N0183_MSG, this); } -void androidUtilHandler::handle_N0183_MSG(AndroidNMEAEvent& event) { +void androidUtilHandler::handle_N0183_MSG(AndroidNMEAEvent &event) { auto p = event.GetPayload(); - std::vector* payload = p.get(); + std::vector *payload = p.get(); // Extract the NMEA0183 sentence std::string full_sentence = std::string(payload->begin(), payload->end()); @@ -474,8 +469,8 @@ void androidUtilHandler::handle_N0183_MSG(AndroidNMEAEvent& event) { auto address = std::make_shared(NavAddr0183("Android_RAW")); - auto msg = std::make_shared(identifier, full_sentence, - address); + auto msg = + std::make_shared(identifier, full_sentence, address); auto msg_all = std::make_shared(*msg, "ALL"); m_listener.Notify(std::move(msg)); @@ -483,8 +478,7 @@ void androidUtilHandler::handle_N0183_MSG(AndroidNMEAEvent& event) { } } -void androidUtilHandler::LoadAuxClasses() -{ +void androidUtilHandler::LoadAuxClasses() { // We do a few little dummy class accesses here, to cause the static link to // wxWidgets to bring in some class members required by some plugins, that // would be missing otherwise. @@ -498,7 +492,6 @@ void androidUtilHandler::LoadAuxClasses() wxZipEntry *entry = new wxZipEntry(); wxSplitterWindow *swin = new wxSplitterWindow(); - } void androidUtilHandler::onTimerEvent(wxTimerEvent &event) { @@ -587,7 +580,8 @@ void androidUtilHandler::onTimerEvent(wxTimerEvent &event) { } // Tide/Current window - if (gFrame->GetPrimaryCanvas() && gFrame->GetPrimaryCanvas()->getTCWin()) { + if (gFrame->GetPrimaryCanvas() && + gFrame->GetPrimaryCanvas()->getTCWin()) { bool bshown = gFrame->GetPrimaryCanvas()->getTCWin()->IsShown(); gFrame->GetPrimaryCanvas()->getTCWin()->Hide(); gFrame->GetPrimaryCanvas()->getTCWin()->RecalculateSize(); @@ -621,8 +615,8 @@ void androidUtilHandler::onTimerEvent(wxTimerEvent &event) { } if (g_options) { - g_options->RecalculateSize( - g_options->GetSize().x, g_options->GetSize().y ); + g_options->RecalculateSize(g_options->GetSize().x, + g_options->GetSize().y); } bInConfigChange = false; @@ -765,7 +759,6 @@ void androidUtilHandler::onTimerEvent(wxTimerEvent &event) { } } - break; } @@ -802,7 +795,7 @@ void androidUtilHandler::onTimerEvent(wxTimerEvent &event) { // qDebug() << "isFileChooserFinished returned null"; } else if ((jenv)->GetStringLength(s)) { const char *ret_string = (jenv)->GetStringUTFChars(s, NULL); - //qDebug() << "isFileChooserFinished returned" << ret_string; + // qDebug() << "isFileChooserFinished returned" << ret_string; if (!strncmp(ret_string, "cancel:", 7)) { m_migratePermissionSetDone = true; m_stringResult = _T("cancel:"); @@ -812,11 +805,11 @@ void androidUtilHandler::onTimerEvent(wxTimerEvent &event) { } } - if(m_migratePermissionSetDone){ + if (m_migratePermissionSetDone) { g_androidUtilHandler->m_action = ACTION_NONE; g_androidUtilHandler->m_eventTimer.Stop(); - if(g_migrateDialog) + if (g_migrateDialog) g_migrateDialog->onPermissionGranted(m_stringResult); } } @@ -824,8 +817,6 @@ void androidUtilHandler::onTimerEvent(wxTimerEvent &event) { break; } - - default: break; } @@ -991,7 +982,7 @@ void androidUtilHandler::OnScheduledEvent(wxCommandEvent &event) { bool androidUtilInit(void) { qDebug() << "androidUtilInit()"; - auto& msgbus = NavMsgBus::GetInstance(); + auto &msgbus = NavMsgBus::GetInstance(); g_androidUtilHandler = new androidUtilHandler(msgbus); // Initialize some globals @@ -1029,7 +1020,6 @@ bool androidUtilInit(void) { token = tk.GetNextToken(); g_androidDownloadDirectory = token; - } g_mask = -1; @@ -1072,18 +1062,15 @@ void resizeAndroidPersistents() { } void sendNMEAMessageEvent(wxString &msg) { - std::string string = msg.ToStdString(); auto buffer = std::make_shared>(); - std::vector* vec = buffer.get(); + std::vector *vec = buffer.get(); - for (int i=0; i < string.size(); i++) - vec->push_back(string[i]); + for (int i = 0; i < string.size(); i++) vec->push_back(string[i]); AndroidNMEAEvent Nevent(wxEVT_ANDROID_NMEA_RAW, 0); Nevent.SetPayload(buffer); g_androidUtilHandler->AddPendingEvent(Nevent); - } // OCPNNativeLib @@ -1100,18 +1087,15 @@ JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_test(JNIEnv *env, } extern "C" { -JNIEXPORT jint JNICALL - Java_org_opencpn_OCPNNativeLib_onSoundDone(JNIEnv *env, - jobject obj, - long soundPtr) { - auto sound = reinterpret_cast(soundPtr); - DEBUG_LOG << "on SoundDone, ptr: " << soundPtr; - sound->OnSoundDone(); - return 57; +JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_onSoundDone( + JNIEnv *env, jobject obj, long soundPtr) { + auto sound = reinterpret_cast(soundPtr); + DEBUG_LOG << "on SoundDone, ptr: " << soundPtr; + sound->OnSoundDone(); + return 57; } } - extern "C" { JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_processSailTimer( JNIEnv *env, jobject obj, double WindAngleMagnetic, double WindSpeedKnots) { @@ -1268,10 +1252,9 @@ JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_processNMEA( if (consumer) { auto buffer = std::make_shared>(); - std::vector* vec = buffer.get(); + std::vector *vec = buffer.get(); - for (int i=0; i < strlen(string); i++) - vec->push_back(string[i]); + for (int i = 0; i < strlen(string); i++) vec->push_back(string[i]); CommDriverN0183SerialEvent Nevent(wxEVT_COMMDRIVER_N0183_SERIAL, 0); Nevent.SetPayload(buffer); @@ -1296,12 +1279,12 @@ JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_processNMEAInt( if (consumer) { auto buffer = std::make_shared>(); - std::vector* vec = buffer.get(); + std::vector *vec = buffer.get(); - for (int i=0; i < strlen(string); i++) - vec->push_back(string[i]); + for (int i = 0; i < strlen(string); i++) vec->push_back(string[i]); - CommDriverN0183AndroidIntEvent Nevent(wxEVT_COMMDRIVER_N0183_ANDROID_INT, 0); + CommDriverN0183AndroidIntEvent Nevent(wxEVT_COMMDRIVER_N0183_ANDROID_INT, + 0); Nevent.SetPayload(buffer); consumer->AddPendingEvent(Nevent); } @@ -1313,7 +1296,6 @@ JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_processNMEAInt( extern "C" { JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_processBTNMEA( JNIEnv *env, jobject obj, jstring nmea_string) { - wxEvtHandler *consumer = s_pAndroidBTNMEAMessageConsumer; const char *string = env->GetStringUTFChars(nmea_string, NULL); @@ -1322,10 +1304,9 @@ JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_processBTNMEA( if (consumer) { auto buffer = std::make_shared>(); - std::vector* vec = buffer.get(); + std::vector *vec = buffer.get(); - for (int i=0; i < strlen(string); i++) - vec->push_back(string[i]); + for (int i = 0; i < strlen(string); i++) vec->push_back(string[i]); vec->push_back('\r'); vec->push_back('\n'); @@ -1352,10 +1333,9 @@ JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_processARBNMEA( if (consumer) { auto buffer = std::make_shared>(); - std::vector* vec = buffer.get(); + std::vector *vec = buffer.get(); - for (int i=0; i < strlen(string); i++) - vec->push_back(string[i]); + for (int i = 0; i < strlen(string); i++) vec->push_back(string[i]); vec->push_back('\r'); vec->push_back('\n'); @@ -1574,7 +1554,7 @@ JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_invokeCmdEventCmdString( wxString wx_sparm; JNIEnv *jenv; - if (!java_vm) return 73; + if (!java_vm) return 73; // Need a Java environment to decode the string parameter if (java_vm->GetEnv((void **)&jenv, JNI_VERSION_1_6) != JNI_OK) { @@ -1814,7 +1794,7 @@ JNIEXPORT jint JNICALL Java_org_opencpn_OCPNNativeLib_sendPluginMessage( wxString Msg; JNIEnv *jenv; - if (!java_vm) return 79; + if (!java_vm) return 79; // Need a Java environment to decode the string parameter if (java_vm->GetEnv((void **)&jenv, JNI_VERSION_1_6) != JNI_OK) { @@ -2097,13 +2077,15 @@ wxString androidGetDeviceInfo() { wxString b = s1.Mid(a + 1, 2); memset(android_plat_spc.msdk, 0, sizeof(android_plat_spc.msdk)); strncpy(android_plat_spc.msdk, b.c_str(), 2); - g_Android_SDK_Version = atoi( android_plat_spc.msdk ); + g_Android_SDK_Version = atoi(android_plat_spc.msdk); } } if (wxNOT_FOUND != s1.Find(_T("opencpn"))) { strcpy(&android_plat_spc.hn[0], s1.c_str()); } - if (wxNOT_FOUND != s1.Find(_T("Model (and Product): "))) { //Model (and Product): LML413DL (cv3_lao_com) + if (wxNOT_FOUND != + s1.Find(_T("Model (and Product): "))) { // Model (and Product): + // LML413DL (cv3_lao_com) wxString smp = s1.Mid(21); wxString smp1 = smp.BeforeFirst('('); g_android_Device_Model = smp1.Trim(false).Trim(true).Truncate(8); @@ -2123,16 +2105,16 @@ wxString androidGetDeviceInfo() { return g_deviceInfo; } -bool androidIsDirWritable( wxString dir ) -{ +bool androidIsDirWritable(wxString dir) { if (g_Android_SDK_Version < 30) return true; - else{ + else { // This is theorectically most accurate, but slow to execute - //wxString result = callActivityMethod_ss("isDirWritable", dir); - //return (result.IsSameAs("YES")); + // wxString result = callActivityMethod_ss("isDirWritable", dir); + // return (result.IsSameAs("YES")); - // This is a practical alternative, for things like chart storage qualification. + // This is a practical alternative, for things like chart storage + // qualification. return (dir.Contains("org.opencpn.opencpn")); } } @@ -2207,7 +2189,7 @@ androidGetCacheDir() // Used for raster_texture_cache, mmsitoname.csv, etc wxString androidGetExtStorageDir() // Used for Chart storage, typically { if (g_Android_SDK_Version >= 30) - return g_androidExtFilesDir; // Scoped storage model + return g_androidExtFilesDir; // Scoped storage model else return g_androidExtStorageDir; } @@ -2400,9 +2382,9 @@ double GetAndroidDisplaySize() { if (ldpi < 160) ldpi = 160.; // Find the max dimension among all possibilities -// double maxDim = wxMax(screen_size.x, screen_size.y); -// maxDim = wxMax(maxDim, androidHeight); -// maxDim = wxMax(maxDim, androidWidth); + // double maxDim = wxMax(screen_size.x, screen_size.y); + // maxDim = wxMax(maxDim, androidHeight); + // maxDim = wxMax(maxDim, androidWidth); double maxDim = screen_size.x; maxDim = wxMax(maxDim, androidWidth); @@ -2480,7 +2462,6 @@ double getAndroidDisplayDensity() { } wxSize getAndroidDisplayDimensions(void) { - wxSize sz_ret = ::wxGetDisplaySize(); // default, probably reasonable, but // maybe not accurate if (!java_vm) return sz_ret; @@ -3410,7 +3391,7 @@ int androidApplySettingsString(wxString settings, ArrayOfCDI *pACDI) { } if (b_action && cp) { // something to do? -//FIXME (dave) +// FIXME (dave) #if 0 // Terminate and remove any existing stream with the same port name @@ -3520,7 +3501,7 @@ int androidApplySettingsString(wxString settings, ArrayOfCDI *pACDI) { } if (b_action && cp) { // something to do? -//FIXME (dave) +// FIXME (dave) #if 0 rr |= NEED_NEW_OPTIONS; @@ -3554,12 +3535,12 @@ int androidApplySettingsString(wxString settings, ArrayOfCDI *pACDI) { cp->b_IsSetup = true; } #endif - } } - } // found pref + } + } // found pref - i++; - } // while + i++; + } // while return rr; } @@ -3762,12 +3743,13 @@ wxString getFontQtStylesheet(wxFont *font) { return qstyle; } -bool androidPlaySound(const wxString soundfile, AndroidSound* sound) { +bool androidPlaySound(const wxString soundfile, AndroidSound *sound) { DEBUG_LOG << "androidPlaySound"; std::ostringstream oss; oss << sound; wxString wxSound(oss.str()); - wxString result = callActivityMethod_s2s("playSound", soundfile, wxSound.Mid(2)); + wxString result = + callActivityMethod_s2s("playSound", soundfile, wxSound.Mid(2)); return true; } @@ -3796,7 +3778,8 @@ wxString androidGetSupplementalLicense(void) { wxArrayString androidTraverseDir(wxString dir, wxString filespec) { wxArrayString result; - if (g_Android_SDK_Version != 17) // skip unless running Android 4.2.2, especially Samsung... + if (g_Android_SDK_Version != + 17) // skip unless running Android 4.2.2, especially Samsung... return result; wxString ir = @@ -4039,7 +4022,6 @@ QScrollBar::sub-line:vertical {\ subcontrol-origin: margin;\ }"; - QString qtStyleSheetWideScrollBars = "QScrollBar:horizontal {\ border: 0px solid grey;\ @@ -4301,11 +4283,11 @@ wxBitmap loadAndroidSVG(const wxString filename, unsigned int width, fn.SetExt(_T("png")); // Try to find the target image, at the proper resolution. - if(fn.FileExists()){ + if (fn.FileExists()) { wxBitmap bmp_test(fn.GetFullPath(), wxBITMAP_TYPE_PNG); - if(bmp_test.IsOk()){ - if((bmp_test.GetWidth() == (int)width) && (bmp_test.GetHeight() == - (int)height)) + if (bmp_test.IsOk()) { + if ((bmp_test.GetWidth() == (int)width) && + (bmp_test.GetHeight() == (int)height)) return bmp_test; } } @@ -4538,88 +4520,70 @@ Java_org_opencpn_OCPNNativeLib_ScheduleCleanExit(JNIEnv *env, jobject obj) { } } -void CheckMigrateCharts() -{ +void CheckMigrateCharts() { qDebug() << "CheckMigrateCharts"; - if (g_Android_SDK_Version < 30) // Only on Android/11 + + if (g_Android_SDK_Version < 30) // Only on Android/11 + return; // Force access to correct home directory, as a hint.... pInit_Chart_Dir->Clear(); // Scan the config file chart directory array. - wxArrayString chartDirs = GetConfigChartDirectories(); //GetChartDirArrayString(); + wxArrayString chartDirs = + GetConfigChartDirectories(); // GetChartDirArrayString(); wxArrayString migrateDirs; qDebug() << chartDirs.GetCount(); - for (unsigned int i=0; i < chartDirs.GetCount(); i++){ + for (unsigned int i = 0; i < chartDirs.GetCount(); i++) { qDebug() << chartDirs[i].mb_str(); bool bOK = false; - if ( chartDirs[i].StartsWith(g_androidGetFilesDirs0) ) + if (chartDirs[i].StartsWith(g_androidGetFilesDirs0)) bOK = true; - else if (!g_androidGetFilesDirs1.StartsWith("?")){ - if ( chartDirs[i].StartsWith(g_androidGetFilesDirs1) ) - bOK = true; + else if (!g_androidGetFilesDirs1.StartsWith("?")) { + if (chartDirs[i].StartsWith(g_androidGetFilesDirs1)) bOK = true; } if (!bOK) { migrateDirs.Add(chartDirs[i]); } } - if (!migrateDirs.GetCount()) - return; - + if (!migrateDirs.GetCount()) return; // Run the chart migration assistant g_migrateDialog = new MigrateAssistantDialog(gFrame, false); - g_migrateDialog->SetSize( gFrame->GetSize()); + g_migrateDialog->SetSize(gFrame->GetSize()); g_migrateDialog->Centre(); g_migrateDialog->Raise(); g_migrateDialog->ShowModal(); - - } -wxString androidGetDownloadDirectory() -{ - return g_androidDownloadDirectory; -} +wxString androidGetDownloadDirectory() { return g_androidDownloadDirectory; } +wxString WrapText(wxWindow *win, const wxString &text, int widthMax) { + class HardBreakWrapper : public wxTextWrapper { + public: + HardBreakWrapper(wxWindow *win, const wxString &text, int widthMax) { + Wrap(win, text, widthMax); + } + wxString const &GetWrapped() const { return m_wrapped; } + protected: + virtual void OnOutputLine(const wxString &line) { m_wrapped += line; } + virtual void OnNewLine() { m_wrapped += '\n'; } -wxString WrapText(wxWindow *win, const wxString& text, int widthMax) -{ - class HardBreakWrapper : public wxTextWrapper - { - public: - HardBreakWrapper(wxWindow *win, const wxString& text, int widthMax) - { - Wrap(win, text, widthMax); - } - wxString const& GetWrapped() const { return m_wrapped; } - protected: - virtual void OnOutputLine(const wxString& line) - { - m_wrapped += line; - } - virtual void OnNewLine() - { - m_wrapped += '\n'; - } - private: - wxString m_wrapped; - }; - HardBreakWrapper wrapper(win, text, widthMax); - return wrapper.GetWrapped(); + private: + wxString m_wrapped; + }; + HardBreakWrapper wrapper(win, text, widthMax); + return wrapper.GetWrapped(); } /////////////////////////////////////////////////////////////////////////////// /// Class MigrateAssistantDialog Implementation /////////////////////////////////////////////////////////////////////////////// - BEGIN_EVENT_TABLE(MigrateAssistantDialog, wxDialog) EVT_BUTTON(ID_MIGRATE_CANCEL, MigrateAssistantDialog::OnMigrateCancelClick) EVT_BUTTON(ID_MIGRATE_OK, MigrateAssistantDialog::OnMigrateOKClick) @@ -4628,13 +4592,13 @@ EVT_BUTTON(ID_MIGRATE_CONTINUE, MigrateAssistantDialog::OnMigrate1Click) EVT_TIMER(MIGRATION_STATUS_TIMER, MigrateAssistantDialog::onTimerEvent) END_EVENT_TABLE() -MigrateAssistantDialog::MigrateAssistantDialog(wxWindow* parent, bool bskipScan, - wxWindowID id, const wxString& caption, - const wxPoint& pos, const wxSize& size, - long style) +MigrateAssistantDialog::MigrateAssistantDialog(wxWindow *parent, bool bskipScan, + wxWindowID id, + const wxString &caption, + const wxPoint &pos, + const wxSize &size, long style) : wxDialog(parent, id, caption, pos, size, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) -{ + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { m_Status = ""; m_permissionResult = ""; m_bsdcard = false; @@ -4651,34 +4615,30 @@ MigrateAssistantDialog::MigrateAssistantDialog(wxWindow* parent, bool bskipScan, Centre(); } -MigrateAssistantDialog::~MigrateAssistantDialog(void) { - -} - +MigrateAssistantDialog::~MigrateAssistantDialog(void) {} void MigrateAssistantDialog::CreateControls(void) { - wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); SetSizer(mainSizer); - wxStaticBox* mmsiBox = - new wxStaticBox(this, wxID_ANY, _("OpenCPN for Android Migration Assistant")); + wxStaticBox *mmsiBox = new wxStaticBox( + this, wxID_ANY, _("OpenCPN for Android Migration Assistant")); - wxStaticBoxSizer* infoSizer = new wxStaticBoxSizer(mmsiBox, wxVERTICAL); + wxStaticBoxSizer *infoSizer = new wxStaticBoxSizer(mmsiBox, wxVERTICAL); mainSizer->Add(infoSizer, 0, wxEXPAND | wxALL, 5); m_infoText = NULL; - if (!m_bskipScan){ + if (!m_bskipScan) { // Scan the chart directory array from the config file. wxArrayString chartDirs = GetConfigChartDirectories(); - for (unsigned int i=0; i < chartDirs.GetCount(); i++){ + for (unsigned int i = 0; i < chartDirs.GetCount(); i++) { bool bOK = false; - if ( chartDirs[i].StartsWith(g_androidGetFilesDirs0) ) + if (chartDirs[i].StartsWith(g_androidGetFilesDirs0)) bOK = true; - else if (!g_androidGetFilesDirs1.StartsWith("?")){ - if ( chartDirs[i].StartsWith(g_androidGetFilesDirs1) ) - bOK = true; + else if (!g_androidGetFilesDirs1.StartsWith("?")) { + if (chartDirs[i].StartsWith(g_androidGetFilesDirs1)) bOK = true; } if (!bOK) { m_migrateDirs.Add(chartDirs[i]); @@ -4686,96 +4646,116 @@ void MigrateAssistantDialog::CreateControls(void) { } } - if (m_migrateDirs.GetCount()){ - wxString infoText1(_("OpenCPN has detected chart folders in your configuration file that cannot be accessed on this version of Android")); + if (m_migrateDirs.GetCount()) { + wxString infoText1( + _("OpenCPN has detected chart folders in your configuration file that " + "cannot be accessed on this version of Android")); - wxString infoText1w = WrapText(this, infoText1, gFrame->GetSize().x * 95 / 100); + wxString infoText1w = + WrapText(this, infoText1, gFrame->GetSize().x * 95 / 100); m_infoText = new wxStaticText(this, wxID_STATIC, infoText1w); - infoSizer->AddSpacer( 1 * GetCharWidth()); + infoSizer->AddSpacer(1 * GetCharWidth()); infoSizer->Add(m_infoText, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 10); - infoSizer->AddSpacer( 1 * GetCharWidth()); + infoSizer->AddSpacer(1 * GetCharWidth()); wxString dirsMsg; - for (unsigned int i=0; i < m_migrateDirs.GetCount(); i++){ + for (unsigned int i = 0; i < m_migrateDirs.GetCount(); i++) { dirsMsg += wxString(" "); dirsMsg += m_migrateDirs[i]; dirsMsg += wxString("\n"); } - //dirsMsg += wxString("\n"); + // dirsMsg += wxString("\n"); m_infoDirs = new wxStaticText(this, wxID_STATIC, dirsMsg); infoSizer->Add(m_infoDirs, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 10); - wxString migrateMsg1 = _("OpenCPN can copy these chart folders to a suitable location, if desired."); + wxString migrateMsg1 = + _("OpenCPN can copy these chart folders to a suitable location, if " + "desired."); migrateMsg1 += "\n\n"; - migrateMsg1 += _("To proceed with chart folder migration, choose the chart source folder, and follow the instructions given."); + migrateMsg1 += + _("To proceed with chart folder migration, choose the chart source " + "folder, and follow the instructions given."); - wxString migrateMsg1w = WrapText(this, migrateMsg1, gFrame->GetSize().x * 95/ 100); + wxString migrateMsg1w = + WrapText(this, migrateMsg1, gFrame->GetSize().x * 95 / 100); m_migrateStep1 = new wxStaticText(this, wxID_STATIC, migrateMsg1w); - infoSizer->Add(m_migrateStep1, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 10); - - } - else { + infoSizer->Add(m_migrateStep1, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, + 10); - wxString migrateMsg1 = _("Some chart folders may be inaccessible to OpenCPN on this version of Android. "); - migrateMsg1 += _("OpenCPN can copy these chart folders to a suitable location, if desired."); + } else { + wxString migrateMsg1 = + _("Some chart folders may be inaccessible to OpenCPN on this version " + "of Android. "); + migrateMsg1 += + _("OpenCPN can copy these chart folders to a suitable location, if " + "desired."); migrateMsg1 += "\n\n"; - migrateMsg1 += _("To proceed with chart folder migration, choose the chart source folder, and follow the instructions given."); + migrateMsg1 += + _("To proceed with chart folder migration, choose the chart source " + "folder, and follow the instructions given."); - wxString migrateMsg1w = WrapText(this, migrateMsg1, gFrame->GetSize().x * 9 / 10); + wxString migrateMsg1w = + WrapText(this, migrateMsg1, gFrame->GetSize().x * 9 / 10); m_migrateStep1 = new wxStaticText(this, wxID_STATIC, migrateMsg1w); - infoSizer->Add(m_migrateStep1, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 10); + infoSizer->Add(m_migrateStep1, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, + 10); } - mainSizer->AddSpacer( 1 * GetCharWidth()); + mainSizer->AddSpacer(1 * GetCharWidth()); // Is SDCard available? - if (!g_androidGetFilesDirs1.StartsWith("?")){ - - wxStaticBoxSizer* sourceSizer = new wxStaticBoxSizer( + if (!g_androidGetFilesDirs1.StartsWith("?")) { + wxStaticBoxSizer *sourceSizer = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, _("Migrate destination")), wxVERTICAL); mainSizer->Add(sourceSizer, 0, wxEXPAND | wxALL, 5); - mainSizer->AddSpacer( 2 * GetCharWidth()); + mainSizer->AddSpacer(2 * GetCharWidth()); - m_radioInternal = new wxRadioButton (this, wxID_ANY, _("OpenCPN Internal Storage"),wxDefaultPosition, wxDefaultSize, wxRB_GROUP); - sourceSizer->Add( m_radioInternal, 0, /*wxEXPAND |*/ wxALL | wxALIGN_CENTER_HORIZONTAL, 5); + m_radioInternal = + new wxRadioButton(this, wxID_ANY, _("OpenCPN Internal Storage"), + wxDefaultPosition, wxDefaultSize, wxRB_GROUP); + sourceSizer->Add(m_radioInternal, 0, + /*wxEXPAND |*/ wxALL | wxALIGN_CENTER_HORIZONTAL, 5); - m_radioSDCard = new wxRadioButton (this, wxID_ANY, _("OpenCPN SDCard Storage"),wxDefaultPosition, wxDefaultSize); - sourceSizer->Add( m_radioSDCard, 0, /*wxEXPAND |*/ wxALL | wxALIGN_CENTER_HORIZONTAL, 5); + m_radioSDCard = + new wxRadioButton(this, wxID_ANY, _("OpenCPN SDCard Storage"), + wxDefaultPosition, wxDefaultSize); + sourceSizer->Add(m_radioSDCard, 0, + /*wxEXPAND |*/ wxALL | wxALIGN_CENTER_HORIZONTAL, 5); - m_radioInternal->SetValue( true ); + m_radioInternal->SetValue(true); } - // control buttons - m_migrateButton = new wxButton(this, ID_MIGRATE_START, _("Choose chart source folder.")); + m_migrateButton = + new wxButton(this, ID_MIGRATE_START, _("Choose chart source folder.")); mainSizer->Add(m_migrateButton, 0, wxEXPAND | wxALL, 5); - //mainSizer->AddSpacer( 1 * GetCharWidth()); + // mainSizer->AddSpacer( 1 * GetCharWidth()); statusSizer = new wxStaticBoxSizer( - new wxStaticBox(this, wxID_ANY, _("Status")), wxVERTICAL); - mainSizer->Add(statusSizer, 0, wxEXPAND | wxALL, 5); + new wxStaticBox(this, wxID_ANY, _("Status")), wxVERTICAL); + mainSizer->Add(statusSizer, 0, wxEXPAND | wxALL, 5); + m_ipGauge = new InProgressIndicator( + this, wxID_ANY, 100, wxDefaultPosition, + wxSize(gFrame->GetSize().x * 8 / 10, gFrame->GetCharHeight() * 2)); + statusSizer->Add(m_ipGauge, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 5); - m_ipGauge = new InProgressIndicator(this, wxID_ANY, 100, wxDefaultPosition, - wxSize(gFrame->GetSize().x * 8 / 10, gFrame->GetCharHeight() * 2)); - statusSizer->Add(m_ipGauge, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5); - - mainSizer->AddSpacer( 1 * GetCharWidth()); + mainSizer->AddSpacer(1 * GetCharWidth()); m_statusText = new wxStaticText(this, wxID_STATIC, m_Status); statusSizer->Add(m_statusText, 0, wxEXPAND | wxALL, 5); GetSizer()->Hide(statusSizer); - wxBoxSizer* btnSizer = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL); mainSizer->Add(btnSizer, 0, wxALIGN_RIGHT | wxALL, 5); m_CancelButton = new wxButton(this, ID_MIGRATE_CANCEL, _("Cancel")); m_CancelButton->SetDefault(); @@ -4784,42 +4764,37 @@ void MigrateAssistantDialog::CreateControls(void) { m_OKButton = new wxButton(this, ID_MIGRATE_OK, _("OK")); btnSizer->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); m_OKButton->Hide(); - } - -void MigrateAssistantDialog::OnMigrateCancelClick(wxCommandEvent& event) { - +void MigrateAssistantDialog::OnMigrateCancelClick(wxCommandEvent &event) { m_statusTimer.Stop(); callActivityMethod_vs("cancelMigration"); EndModal(wxID_CANCEL); } -void MigrateAssistantDialog::OnMigrateOKClick(wxCommandEvent& event) { +void MigrateAssistantDialog::OnMigrateOKClick(wxCommandEvent &event) { EndModal(wxID_OK); } -void MigrateAssistantDialog::OnMigrateClick(wxCommandEvent& event) -{ - - wxString clickText1(_("On the next page, find and choose the root folder containing chart files to migrate\n\n\ +void MigrateAssistantDialog::OnMigrateClick(wxCommandEvent &event) { + wxString clickText1(_( + "On the next page, find and choose the root folder containing chart files to migrate\n\n\ Example: /storage/emulated/0/Charts\n\n")); clickText1 += _("This entire folder will be migrated.\n"); clickText1 += _("Proceed?"); - if (wxID_OK == OCPNMessageBox( - NULL, clickText1, _("OpenCPN for Android Migration Assistant"), wxOK | wxCANCEL )){ - - if(m_infoText) m_infoText->Hide(); + if (wxID_OK == OCPNMessageBox(NULL, clickText1, + _("OpenCPN for Android Migration Assistant"), + wxOK | wxCANCEL)) { + if (m_infoText) m_infoText->Hide(); m_migrateStep1->Hide(); GetSizer()->Show(statusSizer); Layout(); if (g_androidUtilHandler) { - m_Status = _("Waiting for permission grant...."); - setStatus( m_Status ); + setStatus(m_Status); g_androidUtilHandler->m_eventTimer.Stop(); g_androidUtilHandler->m_migratePermissionSetDone = false; @@ -4836,143 +4811,131 @@ Example: /storage/emulated/0/Charts\n\n")); } } -void MigrateAssistantDialog::OnMigrate1Click(wxCommandEvent& event) { - +void MigrateAssistantDialog::OnMigrate1Click(wxCommandEvent &event) { // Construct the migration arguments - //Destination is either internal, or SDCard, if available - if( !m_bsdcard ) + // Destination is either internal, or SDCard, if available + if (!m_bsdcard) m_migrateDestinationFolder = g_androidGetFilesDirs0 + "/Charts"; else m_migrateDestinationFolder = g_androidGetFilesDirs1 + "/Charts"; qDebug() << "m_migrateSourceFolder" << m_migrateSourceFolder.mb_str(); - qDebug() << "m_migrateDestinationFolder" << m_migrateDestinationFolder.mb_str(); + qDebug() << "m_migrateDestinationFolder" + << m_migrateDestinationFolder.mb_str(); wxString activityResult; - activityResult = callActivityMethod_s2s("migrateFolder", m_migrateSourceFolder, m_migrateDestinationFolder); + activityResult = callActivityMethod_s2s( + "migrateFolder", m_migrateSourceFolder, m_migrateDestinationFolder); m_Status = _("Migration started..."); - setStatus( m_Status ); + setStatus(m_Status); m_statusTimer.Start(500, wxTIMER_CONTINUOUS); m_ipGauge->Show(); Layout(); - - } -void MigrateAssistantDialog::onPermissionGranted( wxString result ) { +void MigrateAssistantDialog::onPermissionGranted(wxString result) { m_permissionResult = result; qDebug() << "onPermissionGranted " << result.mb_str(); - if(result.StartsWith("file")){ + if (result.StartsWith("file")) { m_migrateSourceFolder = result.Mid(5); m_Status = _("Permission granted to "); m_Status += m_migrateSourceFolder; - setStatus( m_Status ); + setStatus(m_Status); // Carry on to the next step m_migrateButton->Hide(); Layout(); // Capture the destination - if(m_radioSDCard) - m_bsdcard = m_radioSDCard->GetValue(); + if (m_radioSDCard) m_bsdcard = m_radioSDCard->GetValue(); - wxString clickText2(_("OpenCPN has obtained temporary permission to access the selected chart folders.")); + wxString clickText2( + _("OpenCPN has obtained temporary permission to access the selected " + "chart folders.")); clickText2 += "\n\n"; clickText2 += _("Chart migration is ready to proceed."); clickText2 += "\n\n"; clickText2 += _("Source: "); clickText2 += m_migrateSourceFolder; clickText2 += "\n\n"; - if(!m_bsdcard) + if (!m_bsdcard) clickText2 += _("Destination: OpenCPN Internal Storage"); else clickText2 += _("Destination: OpenCPN SDCard Storage"); clickText2 += "\n\n"; clickText2 += _("Migrate charts now?"); - - - if (wxID_OK == OCPNMessageBox( - NULL, clickText2, _("OpenCPN for Android Migration Assistant"), wxOK | wxCANCEL )){ - + if (wxID_OK == OCPNMessageBox(NULL, clickText2, + _("OpenCPN for Android Migration Assistant"), + wxOK | wxCANCEL)) { wxCommandEvent evt(wxEVT_BUTTON); evt.SetId(ID_MIGRATE_CONTINUE); AddPendingEvent(evt); - } - else{ - m_Status = ""; - setStatus( m_Status ); + } else { + m_Status = ""; + setStatus(m_Status); - m_migrateButton->Show(); - Layout(); + m_migrateButton->Show(); + Layout(); } - } - else{ + } else { m_Status = ""; - setStatus( m_Status ); + setStatus(m_Status); } - } -void MigrateAssistantDialog::onTimerEvent(wxTimerEvent &event) -{ - // Get and show the current status from Java upstream - qDebug() << "Migration: onTimerEvent"; - - m_Status = callActivityMethod_vs("getMigrateStatus"); - setStatus( m_Status ); - - if (m_Status.StartsWith("Counting")) - m_ipGauge->Pulse(); - - if (m_Status.StartsWith("Migrating")){ - wxString prog = m_Status.Mid(10); - //qDebug() << prog.mb_str(); - wxString np = prog.BeforeFirst('/'); - //qDebug() << np.mb_str(); - wxString np1 = prog.AfterFirst('/'); - wxString np2 = np1.BeforeFirst(';'); - //qDebug() << np2.mb_str(); - - long i, n; - np.ToLong(&i); - np2.ToLong(&n); - if (m_ipGauge->GetRange() != n) - m_ipGauge->SetRange( n ); - m_ipGauge->SetValue( i ); - } - +void MigrateAssistantDialog::onTimerEvent(wxTimerEvent &event) { + // Get and show the current status from Java upstream + qDebug() << "Migration: onTimerEvent"; + m_Status = callActivityMethod_vs("getMigrateStatus"); + setStatus(m_Status); + if (m_Status.StartsWith("Counting")) m_ipGauge->Pulse(); - // Finished? - if (m_Status.Contains("Migration complete")){ - m_statusTimer.Stop(); + if (m_Status.StartsWith("Migrating")) { + wxString prog = m_Status.Mid(10); + // qDebug() << prog.mb_str(); + wxString np = prog.BeforeFirst('/'); + // qDebug() << np.mb_str(); + wxString np1 = prog.AfterFirst('/'); + wxString np2 = np1.BeforeFirst(';'); + // qDebug() << np2.mb_str(); - wxString clickText3(_("Chart migration is finished.")); - clickText3 += "\n\n"; - clickText3 += _("Migrated chart folders are now accessible to OpenCPN."); - clickText3 += "\n"; - clickText3 += _("You may need to adjust your chart folders further, to accommodate individual chart groups"); - clickText3 += "\n\n"; - clickText3 += _("OpenCPN will now restart to apply changes."); - - if (wxID_OK == OCPNMessageBox( - NULL, clickText3, _("OpenCPN for Android Migration Assistant"), wxOK )){ - - FinishMigration(); + long i, n; + np.ToLong(&i); + np2.ToLong(&n); + if (m_ipGauge->GetRange() != n) m_ipGauge->SetRange(n); + m_ipGauge->SetValue(i); + } - } + // Finished? + if (m_Status.Contains("Migration complete")) { + m_statusTimer.Stop(); + + wxString clickText3(_("Chart migration is finished.")); + clickText3 += "\n\n"; + clickText3 += _("Migrated chart folders are now accessible to OpenCPN."); + clickText3 += "\n"; + clickText3 += + _("You may need to adjust your chart folders further, to accommodate " + "individual chart groups"); + clickText3 += "\n\n"; + clickText3 += _("OpenCPN will now restart to apply changes."); + + if (wxID_OK == OCPNMessageBox(NULL, clickText3, + _("OpenCPN for Android Migration Assistant"), + wxOK)) { + FinishMigration(); } - + } } -wxArrayString GetConfigChartDirectories() -{ +wxArrayString GetConfigChartDirectories() { wxArrayString rv; pConfig->SetPath(_T ( "/ChartDirectories" )); int iDirMax = pConfig->GetNumberOfEntries(); @@ -4984,60 +4947,55 @@ wxArrayString GetConfigChartDirectories() pConfig->Read(str, &val); // Get a Directory name rv.Add(val.BeforeFirst('^')); bCont = pConfig->GetNextEntry(str, dummy); - } } return rv; } +void MigrateAssistantDialog::FinishMigration() { + m_Status = _("Finishing migration"); + setStatus(m_Status); -void MigrateAssistantDialog::FinishMigration() -{ - m_Status = _("Finishing migration"); - setStatus( m_Status ); - - // Craft the migrated (destination) folder - - qDebug() << "m_migrateSourceFolder " << m_migrateSourceFolder.mb_str(); - qDebug() << "m_migrateDestinationFolder " << m_migrateDestinationFolder.mb_str(); - - - - // Edit the config file, removing old inaccessible folders, - // and adding migrated folders. + // Craft the migrated (destination) folder - wxArrayString finalArray; - wxArrayString chartDirs = GetConfigChartDirectories(); //ChartData->GetChartDirArrayString(); - for (unsigned int i=0; i < chartDirs.GetCount(); i++){ + qDebug() << "m_migrateSourceFolder " << m_migrateSourceFolder.mb_str(); + qDebug() << "m_migrateDestinationFolder " + << m_migrateDestinationFolder.mb_str(); - //qDebug() << "Checking: " << chartDirs[i].mb_str(); + // Edit the config file, removing old inaccessible folders, + // and adding migrated folders. - // Leave the OK folders - bool bOK = false; - if ( chartDirs[i].StartsWith(g_androidGetFilesDirs0) ) - bOK = true; + wxArrayString finalArray; + wxArrayString chartDirs = + GetConfigChartDirectories(); // ChartData->GetChartDirArrayString(); + for (unsigned int i = 0; i < chartDirs.GetCount(); i++) { + // qDebug() << "Checking: " << chartDirs[i].mb_str(); - else if (!g_androidGetFilesDirs1.StartsWith("?")){ - if ( chartDirs[i].StartsWith(g_androidGetFilesDirs1) ) - bOK = true; - } + // Leave the OK folders + bool bOK = false; + if (chartDirs[i].StartsWith(g_androidGetFilesDirs0)) + bOK = true; - // Check inaccessible folders to see if they were (part of) the migration - if (!bOK) { - if(!chartDirs[i].StartsWith(m_migrateSourceFolder)) // not part of migration - bOK = true; // so, keep it. - // To be migrated on next round - } + else if (!g_androidGetFilesDirs1.StartsWith("?")) { + if (chartDirs[i].StartsWith(g_androidGetFilesDirs1)) bOK = true; + } - if(bOK){ - //qDebug() << "Add: " << chartDirs[i].mb_str(); - finalArray.Add(chartDirs[i]); - } + // Check inaccessible folders to see if they were (part of) the migration + if (!bOK) { + if (!chartDirs[i].StartsWith( + m_migrateSourceFolder)) // not part of migration + bOK = true; // so, keep it. + // To be migrated on next round + } + if (bOK) { + // qDebug() << "Add: " << chartDirs[i].mb_str(); + finalArray.Add(chartDirs[i]); } + } - finalArray.Add(m_migrateDestinationFolder + "/MigratedCharts"); + finalArray.Add(m_migrateDestinationFolder + "/MigratedCharts"); #if 0 // Now manage the migrate folder @@ -5098,77 +5056,63 @@ void MigrateAssistantDialog::FinishMigration() } #endif - for (unsigned int j=0 ; j < finalArray.GetCount() ; j++){ - qDebug() << "finalEntry: " << finalArray[j].mb_str(); - } - - - // Now delete and replace the chart directory list in the config file - wxRemoveFile(ChartListFileName); + for (unsigned int j = 0; j < finalArray.GetCount(); j++) { + qDebug() << "finalEntry: " << finalArray[j].mb_str(); + } - pConfig->SetPath(_T ( "/ChartDirectories" )); - pConfig->DeleteGroup(_T ( "/ChartDirectories" )); + // Now delete and replace the chart directory list in the config file + wxRemoveFile(ChartListFileName); - pConfig->SetPath(_T ( "/ChartDirectories" )); - for (int iDir = 0; iDir < finalArray.GetCount(); iDir++) { - wxString dirn = finalArray[iDir]; - dirn.Append(_T("^")); + pConfig->SetPath(_T ( "/ChartDirectories" )); + pConfig->DeleteGroup(_T ( "/ChartDirectories" )); - wxString str_buf; - str_buf.Printf(_T ( "ChartDir%d" ), iDir + 1); - pConfig->Write(str_buf, dirn); - } - pConfig->Flush(); + pConfig->SetPath(_T ( "/ChartDirectories" )); + for (int iDir = 0; iDir < finalArray.GetCount(); iDir++) { + wxString dirn = finalArray[iDir]; + dirn.Append(_T("^")); - // Restart - callActivityMethod_vs("restartOCPNAfterMigrate"); + wxString str_buf; + str_buf.Printf(_T ( "ChartDir%d" ), iDir + 1); + pConfig->Write(str_buf, dirn); + } + pConfig->Flush(); + // Restart + callActivityMethod_vs("restartOCPNAfterMigrate"); } - BEGIN_EVENT_TABLE( InProgressIndicator, wxGauge ) - EVT_TIMER( 4356, InProgressIndicator::OnTimer ) - END_EVENT_TABLE() - - InProgressIndicator::InProgressIndicator() - { - } +BEGIN_EVENT_TABLE(InProgressIndicator, wxGauge) +EVT_TIMER(4356, InProgressIndicator::OnTimer) +END_EVENT_TABLE() - InProgressIndicator::InProgressIndicator(wxWindow* parent, wxWindowID id, int range, - const wxPoint& pos, const wxSize& size, - long style, const wxValidator& validator, const wxString& name) -{ - wxGauge::Create(parent, id, range, pos, size, style, validator, name); +InProgressIndicator::InProgressIndicator() {} - m_timer.SetOwner( this, 4356 ); +InProgressIndicator::InProgressIndicator(wxWindow *parent, wxWindowID id, + int range, const wxPoint &pos, + const wxSize &size, long style, + const wxValidator &validator, + const wxString &name) { + wxGauge::Create(parent, id, range, pos, size, style, validator, name); - SetValue(0); - m_bAlive = false; + m_timer.SetOwner(this, 4356); + SetValue(0); + m_bAlive = false; } -InProgressIndicator::~InProgressIndicator() -{ - Stop(); -} +InProgressIndicator::~InProgressIndicator() { Stop(); } -void InProgressIndicator::OnTimer(wxTimerEvent &evt) -{ - if(m_bAlive) - Pulse(); +void InProgressIndicator::OnTimer(wxTimerEvent &evt) { + if (m_bAlive) Pulse(); } - -void InProgressIndicator::Start() -{ - m_bAlive = true; - m_timer.Start( 50 ); - +void InProgressIndicator::Start() { + m_bAlive = true; + m_timer.Start(50); } -void InProgressIndicator::Stop() -{ - m_bAlive = false; - SetValue(0); - m_timer.Stop(); - +void InProgressIndicator::Stop() { + m_bAlive = false; + SetValue(0); + m_timer.Stop(); } diff --git a/gui/include/gui/RoutePropDlgImpl.h b/gui/include/gui/RoutePropDlgImpl.h index 45f50f5744..50fd30addb 100644 --- a/gui/include/gui/RoutePropDlgImpl.h +++ b/gui/include/gui/RoutePropDlgImpl.h @@ -97,7 +97,8 @@ class RoutePropDlgImpl : public RoutePropDlg { const wxString& title = _("Route Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(550, 450), - long style = FRAME_WITH_LINKS_STYLE ); + long style = FRAME_WITH_LINKS_STYLE); + private: void SaveGeometry(); static bool instanceFlag; diff --git a/gui/include/gui/options.h b/gui/include/gui/options.h index d9232c339b..5448bfe07e 100644 --- a/gui/include/gui/options.h +++ b/gui/include/gui/options.h @@ -72,7 +72,7 @@ class wxGenericDirCtrl; class MyConfig; class ChartGroupsUI; -//class ConnectionParams; +// class ConnectionParams; class PluginListPanel; class ChartGroupArray; class ChartGroup; @@ -377,15 +377,16 @@ class options : private Uncopyable, void ClearConfigList(); void BuildConfigList(); void OnConfigMouseSelected(wxMouseEvent &event); - void OnDialogInit(wxInitDialogEvent& event); - + void OnDialogInit(wxInitDialogEvent &event); bool GetNeedNew() { return m_bneedNew; } void SetNeedNew(bool bnew) { m_bneedNew = bnew; } int GetScrollRate() { return m_scrollRate; } - void SetForceNewToolbarOnCancel(bool val) { m_bForceNewToolbaronCancel = val; } + void SetForceNewToolbarOnCancel(bool val) { + m_bForceNewToolbaronCancel = val; + } - wxArrayString *GetSerialArray(){ return m_pSerialArray; } + wxArrayString *GetSerialArray() { return m_pSerialArray; } // Should we show tooltips? static bool ShowToolTips(void); @@ -425,8 +426,9 @@ class options : private Uncopyable, wxTextCtrl *pCmdSoundString; wxChoice *m_pShipIconType, *m_pcTCDatasets; - wxSlider *m_pSlider_Zoom_Raster, *m_pSlider_GUI_Factor, *m_pSlider_Chart_Factor, - *m_pSlider_Ship_Factor, *m_pSlider_Text_Factor, *m_pSlider_ENCText_Factor; + wxSlider *m_pSlider_Zoom_Raster, *m_pSlider_GUI_Factor, + *m_pSlider_Chart_Factor, *m_pSlider_Ship_Factor, *m_pSlider_Text_Factor, + *m_pSlider_ENCText_Factor; wxSlider *m_pMouse_Zoom_Slider; wxSlider *m_pSlider_Zoom_Vector; wxSlider *m_pSlider_CM93_Zoom; @@ -447,7 +449,6 @@ class options : private Uncopyable, void OnCanvasConfigSelectClick(int ID, bool selected); - bool b_haveWMM; bool b_oldhaveWMM; ColorScheme m_cs; @@ -491,9 +492,9 @@ class options : private Uncopyable, int m_nCharWidthMax; wxBoxSizer *boxSizerCharts; wxScrolledWindow *m_scrollWinChartList; - wxScrolledWindow* chartPanelWin; - wxBoxSizer* cmdButtonSizer; - wxStaticBox* loadedBox; + wxScrolledWindow *chartPanelWin; + wxBoxSizer *cmdButtonSizer; + wxStaticBox *loadedBox; std::vector panelVector; wxArrayString activeChartList; @@ -661,7 +662,7 @@ class options : private Uncopyable, ChartGroupsUI *groupsPanel; wxImageList *m_topImgList; - wxCheckBox* m_persist_active_route_chkbox; + wxCheckBox *m_persist_active_route_chkbox; wxScrolledWindow *m_pNMEAForm; void resetMarStdList(bool bsetConfig, bool bsetStd); @@ -688,7 +689,7 @@ class options : private Uncopyable, wxSize m_sliderSize; bool m_bneedNew; - std::shared_ptrcomm_dialog; + std::shared_ptr comm_dialog; DECLARE_EVENT_TABLE() }; @@ -716,7 +717,7 @@ class CanvasConfigSelect : public wxPanel { DECLARE_EVENT_TABLE() }; -class ChartGroupsUI : public wxScrolledWindow { +class ChartGroupsUI : public wxScrolledWindow { public: ChartGroupsUI(wxWindow *parent); ~ChartGroupsUI(void); diff --git a/gui/src/ConfigMgr.cpp b/gui/src/ConfigMgr.cpp index 8b4409d2ae..a8679146a5 100644 --- a/gui/src/ConfigMgr.cpp +++ b/gui/src/ConfigMgr.cpp @@ -39,7 +39,7 @@ #include "dychart.h" #include -//#include +// #include #include #include #include @@ -463,7 +463,8 @@ ConfigPanel::ConfigPanel(OCPNConfigObject *config, wxWindow *parent, SetMinSize(wxSize(-1, 6 * GetCharHeight())); - SetBackgroundColour(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW)); + SetBackgroundColour( + wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW)); // Connect(wxEVT_LEFT_DOWN, // wxMouseEventHandler(ConfigPanel::OnConfigPanelMouseSelected), NULL, this); } @@ -501,7 +502,10 @@ ConfigMgr::ConfigMgr() { LoadCatalog(); } -ConfigMgr::~ConfigMgr() { configList->Clear(); delete configList; } +ConfigMgr::~ConfigMgr() { + configList->Clear(); + delete configList; +} void ConfigMgr::Init() { m_configDir = g_Platform->GetPrivateDataDir(); @@ -912,7 +916,7 @@ bool ConfigMgr::SaveTemplate(wxString fileName) { for (const auto &mm : g_config_display_size_mm) { st0.Append(wxString::Format(_T ( "%zu," ), mm)); } - st0.RemoveLast(); //Strip last comma + st0.RemoveLast(); // Strip last comma conf->Write(_T ( "DisplaySizeMM" ), st0); conf->Write(_T ( "DisplaySizeManual" ), g_config_display_size_manual); @@ -1167,22 +1171,22 @@ bool ConfigMgr::CheckTemplateGUID(wxString GUID) { return rv; } -#define CHECK_INT(s, t) \ - read_int = *t; \ +#define CHECK_INT(s, t) \ + read_int = *t; \ if (!conf.Read(s, &read_int)) wxLogMessage(s); \ if ((int)*t != read_int) return false; #define CHECK_STR(s, t) \ val = t; \ - conf.Read(s, &val); \ + conf.Read(s, &val); \ if (!t.IsSameAs(val)) return false; #define CHECK_STRP(s, t) \ - conf.Read(s, &val); \ + conf.Read(s, &val); \ if (!t->IsSameAs(val)) return false; #define CHECK_FLT(s, t, eps) \ - conf.Read(s, &val); \ + conf.Read(s, &val); \ val.ToDouble(&dval); \ if (fabs(dval - *t) > eps) return false; @@ -1342,8 +1346,9 @@ bool ConfigMgr::CheckTemplate(wxString fileName) { // 2 = "Kilometers", 3 = "Meters" CHECK_INT(_T ( "SpeedFormat" ), &g_iSpeedFormat); // 0 = "kts"), 1 = "mph", 2 = "km/h", 3 = "m/s" - CHECK_INT(_T ( "WindSpeedFormat" ), - &g_iWindSpeedFormat); // 0 = "knots"), 1 = "m/s", 2 = "Mph", 3 = "km/h" + CHECK_INT( + _T ( "WindSpeedFormat" ), + &g_iWindSpeedFormat); // 0 = "knots"), 1 = "m/s", 2 = "Mph", 3 = "km/h" // LIVE ETA OPTION CHECK_INT(_T ( "LiveETA" ), &g_bShowLiveETA); @@ -1598,14 +1603,14 @@ bool ConfigMgr::CheckTemplate(wxString fileName) { // S57 template items -#define CHECK_BFN(s, t) \ - conf.Read(s, &read_int); \ - bval = t; \ - bval0 = read_int != 0; \ +#define CHECK_BFN(s, t) \ + conf.Read(s, &read_int); \ + bval = t; \ + bval0 = read_int != 0; \ if (bval != bval0) return false; -#define CHECK_IFN(s, t) \ - conf.Read(s, &read_int); \ +#define CHECK_IFN(s, t) \ + conf.Read(s, &read_int); \ if (read_int != t) return false; #define CHECK_FFN(s, t) \ diff --git a/gui/src/RoutePropDlg.cpp b/gui/src/RoutePropDlg.cpp index 86933c7726..b1448f6e97 100644 --- a/gui/src/RoutePropDlg.cpp +++ b/gui/src/RoutePropDlg.cpp @@ -45,10 +45,9 @@ EVT_CHAR(RoutePropDlg::OnKeyChar) #endif END_EVENT_TABLE() - -extern Routeman *g_pRouteMan; -extern RoutePropDlgImpl *pRoutePropDialog; -extern RouteManagerDialog *pRouteManagerDialog; +extern Routeman* g_pRouteMan; +extern RoutePropDlgImpl* pRoutePropDialog; +extern RouteManagerDialog* pRouteManagerDialog; RoutePropDlgCtx RoutePropDlg::GetDlgCtx() { struct RoutePropDlgCtx ctx; @@ -214,10 +213,9 @@ RoutePropDlg::RoutePropDlg(wxWindow* parent, wxWindowID id, 5); #ifdef __ANDROID__ int ys = GetCharHeight(); - m_dpDepartureDate->SetMinSize(wxSize(-1, ys * 15/10)); + m_dpDepartureDate->SetMinSize(wxSize(-1, ys * 15 / 10)); #endif - #ifdef __WXGTK__ m_tpDepartureTime = new TimeCtrl(m_pnlBasic, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize); @@ -284,9 +282,8 @@ RoutePropDlg::RoutePropDlg(wxWindow* parent, wxWindowID id, m_stStyle->Wrap(-1); bSizerStyle->Add(m_stStyle, 0, wxALL, 5); - wxString m_choiceStyleChoices[] = {_("Default"), _("Solid"), - _("Dot"), _("Long dash"), - _("Short dash")}; + wxString m_choiceStyleChoices[] = {_("Default"), _("Solid"), _("Dot"), + _("Long dash"), _("Short dash")}; int m_choiceStyleNChoices = sizeof(m_choiceStyleChoices) / sizeof(wxString); m_choiceStyle = new wxChoice(m_pnlBasic, wxID_ANY, wxDefaultPosition, wxDefaultSize, @@ -645,14 +642,16 @@ RoutePropDlg::RoutePropDlg(wxWindow* parent, wxWindowID id, EVT_ROUTEMAN_DEL_TRK); Bind(EVT_ROUTEMAN_DEL_TRK, [&](ObservedEvt& ev) { auto t = std::const_pointer_cast(UnpackEvtPointer(ev)); - RoutemanGui(*g_pRouteMan).DeleteTrack(t.get()); }); + RoutemanGui(*g_pRouteMan).DeleteTrack(t.get()); + }); wxDEFINE_EVENT(EVT_ROUTEMAN_DEL_ROUTE, ObservedEvt); navobj_del_route_listener.Listen(navobj->evt_delete_route, this, EVT_ROUTEMAN_DEL_ROUTE); Bind(EVT_ROUTEMAN_DEL_ROUTE, [&](ObservedEvt& ev) { auto r = std::const_pointer_cast(UnpackEvtPointer(ev)); - g_pRouteMan->DeleteRoute(r.get(), navobj); }); + g_pRouteMan->DeleteRoute(r.get(), navobj); + }); } RoutePropDlg::~RoutePropDlg() { diff --git a/gui/src/RoutePropDlgImpl.cpp b/gui/src/RoutePropDlgImpl.cpp index 38e72ab195..8097854dc3 100644 --- a/gui/src/RoutePropDlgImpl.cpp +++ b/gui/src/RoutePropDlgImpl.cpp @@ -254,8 +254,7 @@ RoutePropDlgImpl::RoutePropDlgImpl(wxWindow* parent, wxWindowID id, NULL, this); #ifdef __WXOSX__ - Connect(wxEVT_ACTIVATE, - wxActivateEventHandler(RoutePropDlgImpl::OnActivate), + Connect(wxEVT_ACTIVATE, wxActivateEventHandler(RoutePropDlgImpl::OnActivate), NULL, this); #endif } @@ -281,13 +280,13 @@ RoutePropDlgImpl* RoutePropDlgImpl::getInstance(wxWindow* parent) { return single; } -void RoutePropDlgImpl::OnActivate(wxActivateEvent& event){ - wxFrame* pWin = wxDynamicCast(event.GetEventObject(), wxFrame); - long int style = pWin->GetWindowStyle(); - if (event.GetActive()) - pWin->SetWindowStyle(style | wxSTAY_ON_TOP); - else - pWin->SetWindowStyle(style ^ wxSTAY_ON_TOP); +void RoutePropDlgImpl::OnActivate(wxActivateEvent& event) { + wxFrame* pWin = wxDynamicCast(event.GetEventObject(), wxFrame); + long int style = pWin->GetWindowStyle(); + if (event.GetActive()) + pWin->SetWindowStyle(style | wxSTAY_ON_TOP); + else + pWin->SetWindowStyle(style ^ wxSTAY_ON_TOP); } void RoutePropDlgImpl::RecalculateSize(void) { @@ -776,8 +775,7 @@ void RoutePropDlgImpl::WaypointsOnDataViewListCtrlSelectionChanged( RoutePoint* prp = m_pRoute->GetPoint(selected_row + 1); if (prp) { if (gFrame->GetFocusCanvas()) { - gFrame->JumpToPosition(gFrame->GetFocusCanvas(), prp->m_lat, - prp->m_lon, + gFrame->JumpToPosition(gFrame->GetFocusCanvas(), prp->m_lat, prp->m_lon, gFrame->GetFocusCanvas()->GetVPScale()); } #ifdef __WXMSW__ @@ -916,7 +914,8 @@ void RoutePropDlgImpl::OnRoutePropMenuSelected(wxCommandEvent& event) { RoutePoint* pRP = m_pRoute->GetPoint( static_cast(reinterpret_cast(selection.GetID()))); - RouteManagerDialog::WptShowPropertiesDialog(std::vector {pRP}, this); + RouteManagerDialog::WptShowPropertiesDialog(std::vector{pRP}, + this); break; } } diff --git a/gui/src/TrackPropDlg.cpp b/gui/src/TrackPropDlg.cpp index 933fcf4ba9..f2685f2f10 100644 --- a/gui/src/TrackPropDlg.cpp +++ b/gui/src/TrackPropDlg.cpp @@ -164,8 +164,7 @@ TrackPropDlg::TrackPropDlg(wxWindow* parent, wxWindowID id, this); #ifdef __WXOSX__ - Connect(wxEVT_ACTIVATE, - wxActivateEventHandler(TrackPropDlg::OnActivate), + Connect(wxEVT_ACTIVATE, wxActivateEventHandler(TrackPropDlg::OnActivate), NULL, this); #endif @@ -261,16 +260,15 @@ TrackPropDlg::~TrackPropDlg() { instanceFlag = false; } -void TrackPropDlg::OnActivate(wxActivateEvent& event){ - DIALOG_PARENT* pWin = wxDynamicCast(event.GetEventObject(), DIALOG_PARENT); - long int style = pWin->GetWindowStyle(); - if (event.GetActive()) - pWin->SetWindowStyle(style | wxSTAY_ON_TOP); - else - pWin->SetWindowStyle(style ^ wxSTAY_ON_TOP); +void TrackPropDlg::OnActivate(wxActivateEvent& event) { + DIALOG_PARENT* pWin = wxDynamicCast(event.GetEventObject(), DIALOG_PARENT); + long int style = pWin->GetWindowStyle(); + if (event.GetActive()) + pWin->SetWindowStyle(style | wxSTAY_ON_TOP); + else + pWin->SetWindowStyle(style ^ wxSTAY_ON_TOP); } - void TrackPropDlg::RecalculateSize(void) { // Make an estimate of the dialog size, without scrollbars showing @@ -497,9 +495,8 @@ void TrackPropDlg::CreateControlsCompact() { itemFlexGridSizer6b->Add(staticTextStyle, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - wxString m_chStyleChoices[] = {_("Default"), _("Solid"), - _("Dot"), _("Long dash"), - _("Short dash")}; + wxString m_chStyleChoices[] = {_("Default"), _("Solid"), _("Dot"), + _("Long dash"), _("Short dash")}; int m_chStyleNChoices = sizeof(m_chStyleChoices) / sizeof(wxString); m_cStyle = new wxChoice(itemDialog1, wxID_ANY, wxDefaultPosition, wxDefaultSize, @@ -664,9 +661,9 @@ void TrackPropDlg::CreateControls(void) { #endif - //#ifdef __ANDROID__ - // m_panelBasic->GetHandle()->setStyleSheet( getQtStyleSheet()); - //#endif + // #ifdef __ANDROID__ + // m_panelBasic->GetHandle()->setStyleSheet( getQtStyleSheet()); + // #endif wxBoxSizer* bSizerBasic = new wxBoxSizer(wxVERTICAL); m_panelBasic->SetSizer(bSizerBasic); @@ -740,7 +737,7 @@ void TrackPropDlg::CreateControls(void) { // m_stStyle->Wrap( -1 ); sbSizerParams->Add(m_stStyle, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - wxString m_cStyleChoices[] = {_("Default"), _("Solid"), _("Dot"), + wxString m_cStyleChoices[] = {_("Default"), _("Solid"), _("Dot"), _("Long dash"), _("Short dash")}; int m_cStyleNChoices = sizeof(m_cStyleChoices) / sizeof(wxString); m_cStyle = new wxChoice(m_panelBasic, wxID_ANY, wxDefaultPosition, @@ -819,18 +816,21 @@ void TrackPropDlg::CreateControls(void) { m_rbShowTimeUTC = new wxRadioButton(m_panel0, wxID_ANY, _("UTC"), wxDefaultPosition, wxDefaultSize, 0); bSizerShowTime->Add(m_rbShowTimeUTC, 0, - wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5); + wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, + 5); m_rbShowTimePC = new wxRadioButton(m_panel0, wxID_ANY, _("Local @ PC"), wxDefaultPosition, wxDefaultSize, 0); bSizerShowTime->Add(m_rbShowTimePC, 0, - wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5); + wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, + 5); m_rbShowTimeLocal = new wxRadioButton(m_panel0, wxID_ANY, _("LMT @ Track Start"), wxDefaultPosition, wxDefaultSize, 0); bSizerShowTime->Add(m_rbShowTimeLocal, 0, - wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5); + wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, + 5); m_rbShowTimePC->SetValue(true); @@ -1177,7 +1177,7 @@ bool TrackPropDlg::UpdateProperties() { // Time wxString time_form; wxTimeSpan time(0, 0, (int)total_seconds, 0); - //TODO Construct a readable time string, e.g. "xx Days, 15:34" + // TODO Construct a readable time string, e.g. "xx Days, 15:34" if (total_seconds > 3600. * 24.) time_form = time.Format("%H:%M"); else if (total_seconds > 0.) @@ -1429,8 +1429,7 @@ void TrackPropDlg::OnTrackPropListClick(wxListEvent& event) { m_sdbBtmBtnsSizerSplit->Enable(true); } if (gFrame->GetFocusCanvas()) { - gFrame->JumpToPosition(gFrame->GetFocusCanvas(), prp->m_lat, - prp->m_lon, + gFrame->JumpToPosition(gFrame->GetFocusCanvas(), prp->m_lat, prp->m_lon, gFrame->GetFocusCanvas()->GetVPScale()); } #ifdef __WXMSW__ @@ -1458,7 +1457,7 @@ void TrackPropDlg::OnToRouteBtnClick(wxCommandEvent& event) { void TrackPropDlg::OnExportBtnClick(wxCommandEvent& event) { wxString suggested_name = _("track"); - std::vector list = { m_pTrack }; + std::vector list = {m_pTrack}; if (m_pTrack->GetName() != wxEmptyString) suggested_name = m_pTrack->GetName(); ExportGPXTracks(this, &list, suggested_name); @@ -1742,9 +1741,8 @@ void TrackPropDlg::OnOKBtnClick(wxCommandEvent& event) { // Look in the track list to be sure the track is still available // (May have been deleted by RouteManagerDialog...) - bool b_found_track = - std::find(g_TrackList.begin(), g_TrackList.end(), m_pTrack) != - g_TrackList.end(); + bool b_found_track = std::find(g_TrackList.begin(), g_TrackList.end(), + m_pTrack) != g_TrackList.end(); if (b_found_track) { SaveChanges(); // write changes to globals and update config @@ -1764,9 +1762,8 @@ void TrackPropDlg::OnOKBtnClick(wxCommandEvent& event) { } void TrackPropDlg::OnCancelBtnClick(wxCommandEvent& event) { - bool b_found_track = - std::find(g_TrackList.begin(), g_TrackList.end(), m_pTrack) != - g_TrackList.end(); + bool b_found_track = std::find(g_TrackList.begin(), g_TrackList.end(), + m_pTrack) != g_TrackList.end(); if (b_found_track) m_pTrack->ClearHighlights(); diff --git a/gui/src/navutil.cpp b/gui/src/navutil.cpp index b64c28bbab..ea035eba60 100644 --- a/gui/src/navutil.cpp +++ b/gui/src/navutil.cpp @@ -35,7 +35,6 @@ #include #include - #ifndef WX_PRECOMP #include #endif // precompiled headers @@ -113,7 +112,7 @@ extern double g_ChartNotRenderScaleFactor; extern int g_restore_stackindex; extern int g_restore_dbindex; extern RouteList *pRouteList; -extern std::vector g_TrackList; +extern std::vector g_TrackList; extern LayerList *pLayerList; extern MyConfig *pConfig; extern double vLat, vLon; @@ -411,8 +410,7 @@ MyConfig::MyConfig(const wxString &LocalFileName) m_pNavObjectChangesSet = NavObjectChanges::getInstance(); } -MyConfig::~MyConfig() { -} +MyConfig::~MyConfig() {} void MyConfig::CreateRotatingNavObjBackup() { // Avoid nonsense log errors... @@ -420,9 +418,10 @@ void MyConfig::CreateRotatingNavObjBackup() { wxLogNull logNo; #endif // Monthly backup, keep max 3 - if(wxFileExists(m_sNavObjSetFile)) { + if (wxFileExists(m_sNavObjSetFile)) { int month = wxDateTime::Now().GetMonth() + 1; - wxString fn = wxString::Format(_T("%s.m%d"), m_sNavObjSetFile.c_str(), month); + wxString fn = + wxString::Format(_T("%s.m%d"), m_sNavObjSetFile.c_str(), month); if (!wxFileExists(fn)) { wxCopyFile(m_sNavObjSetFile, fn); } @@ -748,8 +747,7 @@ int MyConfig::LoadMyConfigRaw(bool bAsTemplate) { // Some undocumented values Read(_T ( "ConfigVersionString" ), &g_config_version_string); Read(_T("CmdSoundString"), &g_CmdSoundString, wxString(OCPN_SOUND_CMD)); - if (wxIsEmpty(g_CmdSoundString)) - g_CmdSoundString = wxString(OCPN_SOUND_CMD); + if (wxIsEmpty(g_CmdSoundString)) g_CmdSoundString = wxString(OCPN_SOUND_CMD); Read(_T ( "NavMessageShown" ), &n_NavMessageShown); Read(_T ( "AndroidVersionCode" ), &g_AndroidVersionCode); @@ -809,8 +807,7 @@ int MyConfig::LoadMyConfigRaw(bool bAsTemplate) { if (!bAsTemplate) { g_config_display_size_mm.clear(); wxStringTokenizer tokenizer(size_mm, ","); - while ( tokenizer.HasMoreTokens() ) - { + while (tokenizer.HasMoreTokens()) { wxString token = tokenizer.GetNextToken(); int size; try { @@ -988,7 +985,8 @@ int MyConfig::LoadMyConfigRaw(bool bAsTemplate) { Read(_T ( "OwnshipCOGPredictorWidth" ), &g_cog_predictor_width); Read(_T ( "OwnshipHDTPredictorStyle" ), &g_ownship_HDTpredictor_style); Read(_T ( "OwnshipHDTPredictorColor" ), &g_ownship_HDTpredictor_color); - Read(_T ( "OwnshipHDTPredictorEndmarker" ), &g_ownship_HDTpredictor_endmarker); + Read(_T ( "OwnshipHDTPredictorEndmarker" ), + &g_ownship_HDTpredictor_endmarker); Read(_T ( "OwnshipHDTPredictorWidth" ), &g_ownship_HDTpredictor_width); Read(_T ( "OwnshipHDTPredictorMiles" ), &g_ownship_HDTpredictor_miles); @@ -1036,9 +1034,9 @@ int MyConfig::LoadMyConfigRaw(bool bAsTemplate) { Read(_T ( "KeepNavobjBackups" ), &g_navobjbackups); NMEALogWindow::GetInstance().SetSize(Read(_T("NMEALogWindowSizeX"), 600L), - Read(_T("NMEALogWindowSizeY"), 400L)); + Read(_T("NMEALogWindowSizeY"), 400L)); NMEALogWindow::GetInstance().SetPos(Read(_T("NMEALogWindowPosX"), 10L), - Read(_T("NMEALogWindowPosY"), 10L)); + Read(_T("NMEALogWindowPosY"), 10L)); NMEALogWindow::GetInstance().CheckPos(display_width, display_height); // Boolean to cater for legacy Input COM Port filer behaviour, i.e. show msg @@ -1163,8 +1161,7 @@ int MyConfig::LoadMyConfigRaw(bool bAsTemplate) { s.ToDouble(&g_ShowMoored_Kts); g_SOGminCOG_kts = 0.2; - if (Read(_T ( "SOGMinimumForCOGDisplay" ), &s)) - s.ToDouble(&g_SOGminCOG_kts); + if (Read(_T ( "SOGMinimumForCOGDisplay" ), &s)) s.ToDouble(&g_SOGminCOG_kts); Read(_T ("bShowScaledTargets"), &g_bAllowShowScaled); Read(_T ( "AISScaledNumber" ), &g_ShowScaled_Num); @@ -1410,10 +1407,13 @@ int MyConfig::LoadMyConfigRaw(bool bAsTemplate) { long dummy; bool bCont = GetFirstEntry(str, dummy); while (bCont) { - Read(str, &val); // Get a file name and add it to the list just in case it is not repeated - // We have seen duplication of dataset entries in https://github.com/OpenCPN/OpenCPN/issues/3042, this - // effectively gets rid of them. - if (std::find(TideCurrentDataSet.begin(), TideCurrentDataSet.end(), val.ToStdString()) == TideCurrentDataSet.end()) { + Read(str, &val); // Get a file name and add it to the list just in case + // it is not repeated + // We have seen duplication of dataset entries in + // https://github.com/OpenCPN/OpenCPN/issues/3042, this effectively gets + // rid of them. + if (std::find(TideCurrentDataSet.begin(), TideCurrentDataSet.end(), + val.ToStdString()) == TideCurrentDataSet.end()) { TideCurrentDataSet.push_back(val.ToStdString()); } bCont = GetNextEntry(str, dummy); @@ -1652,7 +1652,7 @@ void MyConfig::LoadS57Config() { } /** Load changes from a pending changes file path. */ -static bool ReloadPendingChanges(const wxString& changes_path) { +static bool ReloadPendingChanges(const wxString &changes_path) { wxULongLong size = wxFileName::GetSize(changes_path); // We crashed last time :( @@ -1665,8 +1665,7 @@ static bool ReloadPendingChanges(const wxString& changes_path) { // Remove the file before applying the changes, // just in case the changes file itself causes a fault. // If it does fault, at least the next restart will proceed without fault. - if (::wxFileExists(changes_path)) - ::wxRemoveFile(changes_path); + if (::wxFileExists(changes_path)) ::wxRemoveFile(changes_path); if (size == 0 || res.status != pugi::xml_parse_status::status_ok) { wxLogMessage(changes_path + " seems corrupted, not applying it."); @@ -1676,7 +1675,7 @@ static bool ReloadPendingChanges(const wxString& changes_path) { wxLogMessage(_T("Applying NavObjChanges")); pNavObjectChangesSet->ApplyChanges(); - return true; + return true; } wxString MyConfig::FindNewestUsableBackup() const { @@ -1684,7 +1683,9 @@ wxString MyConfig::FindNewestUsableBackup() const { pugi::xml_document doc; for (int i = 1; i <= g_navobjbackups; i++) { wxString backup = m_sNavObjSetFile + "." + wxString::Format("%d", i); - if (wxFileExists(backup) && wxFileName::GetSize(backup) > 461 && doc.load_file(backup.fn_str()).status == pugi::xml_parse_status::status_ok) { + if (wxFileExists(backup) && wxFileName::GetSize(backup) > 461 && + doc.load_file(backup.fn_str()).status == + pugi::xml_parse_status::status_ok) { newest_backup = backup; break; } @@ -1702,51 +1703,78 @@ void MyConfig::LoadNavObjects() { int wpt_dups = 0; wxString newest_backup; if (::wxFileExists(m_sNavObjSetFile)) { - if (wxFileName::GetSize(m_sNavObjSetFile) < 461) { // Empty navobj.xml file with just the gpx tag is 461 bytes, so anything smaller is obvious sign of a fatal crash while saving it last time, replace it with latest backup if available + if (wxFileName::GetSize(m_sNavObjSetFile) < + 461) { // Empty navobj.xml file with just the gpx tag is 461 bytes, so + // anything smaller is obvious sign of a fatal crash while + // saving it last time, replace it with latest backup if + // available wxLogMessage("Navobjects file exists, but seems truncated!"); newest_backup = FindNewestUsableBackup(); if (wxFileExists(newest_backup)) { - wxLogMessage("We do have a backup " + newest_backup + " that looks healthy and will use it."); + wxLogMessage("We do have a backup " + newest_backup + + " that looks healthy and will use it."); wxCopyFile(newest_backup, m_sNavObjSetFile, true); } } - } else { //File does not exist, try to recover from a backup + } else { // File does not exist, try to recover from a backup newest_backup = FindNewestUsableBackup(); if (wxFileExists(newest_backup)) { - wxLogMessage("We do have a backup " + newest_backup + " that looks healthy and will use it."); - wxCopyFile(newest_backup, m_sNavObjSetFile, true); + wxLogMessage("We do have a backup " + newest_backup + + " that looks healthy and will use it."); + wxCopyFile(newest_backup, m_sNavObjSetFile, true); } else { - wxLogMessage("No navobjects.xml file or usable backup exist, will create a new one."); + wxLogMessage( + "No navobjects.xml file or usable backup exist, will create a new " + "one."); } } bool success = false; - // We did all we could to have an usable navobj.xml file in scenarios where it did not exist or was clearly corrupted, let's try to load it - if(::wxFileExists(m_sNavObjSetFile) && m_pNavObjectInputSet->load_file(m_sNavObjSetFile.fn_str()).status == pugi::xml_parse_status::status_ok) { - CreateRotatingNavObjBackup(); // We only create backups when data is good, there is no point in saving something we can't even load + // We did all we could to have an usable navobj.xml file in scenarios where it + // did not exist or was clearly corrupted, let's try to load it + if (::wxFileExists(m_sNavObjSetFile) && + m_pNavObjectInputSet->load_file(m_sNavObjSetFile.fn_str()).status == + pugi::xml_parse_status::status_ok) { + CreateRotatingNavObjBackup(); // We only create backups when data is good, + // there is no point in saving something we + // can't even load success = m_pNavObjectInputSet->LoadAllGPXObjects(false, wpt_dups); } else { - // It was still not valid after all our efforts and did not load as XML, let's rename it to a corrupted file and try to recover from a backup on last time - wxString corrupted_file = m_sNavObjSetFile + wxDateTime::Now().Format(".corrupted.%Y-%m-%d-%H-%M-%S"); + // It was still not valid after all our efforts and did not load as XML, + // let's rename it to a corrupted file and try to recover from a backup on + // last time + wxString corrupted_file = + m_sNavObjSetFile + + wxDateTime::Now().Format(".corrupted.%Y-%m-%d-%H-%M-%S"); wxRenameFile(m_sNavObjSetFile, corrupted_file, true); - wxLogMessage("Error while loading navobjects from " + m_sNavObjSetFile + ", the corrupted file was renamed to " + corrupted_file); - // If we got here with existing navobj.xml file, but it's corrupted, we can still try to recover from a backup - if (newest_backup.IsEmpty()) { // If we got here with empty newest_backup, navobj.xml probably did exist, but was corrupted XML-wise, so we need to find a new backup + wxLogMessage("Error while loading navobjects from " + m_sNavObjSetFile + + ", the corrupted file was renamed to " + corrupted_file); + // If we got here with existing navobj.xml file, but it's corrupted, we can + // still try to recover from a backup + if (newest_backup + .IsEmpty()) { // If we got here with empty newest_backup, + // navobj.xml probably did exist, but was corrupted + // XML-wise, so we need to find a new backup newest_backup = FindNewestUsableBackup(); } m_pNavObjectInputSet->reset(); - if (wxFileExists(newest_backup) && m_pNavObjectInputSet->load_file(newest_backup.fn_str()).status == pugi::xml_parse_status::status_ok) { + if (wxFileExists(newest_backup) && + m_pNavObjectInputSet->load_file(newest_backup.fn_str()).status == + pugi::xml_parse_status::status_ok) { success = m_pNavObjectInputSet->LoadAllGPXObjects(false, wpt_dups); - wxLogMessage("We do have a healthy backup " + newest_backup + " and did load it."); + wxLogMessage("We do have a healthy backup " + newest_backup + + " and did load it."); } else { - wxLogMessage("No usable backup found, a new navobj.xml file will be created."); + wxLogMessage( + "No usable backup found, a new navobj.xml file will be created."); m_pNavObjectInputSet->reset(); } } if (success) { wxLogMessage(_T("Done loading navobjects, %d duplicate waypoints ignored"), - wpt_dups); + wpt_dups); } else { - wxLogMessage(_T("Failed to load navobjects, creating a new navobj.xml file.")); + wxLogMessage( + _T("Failed to load navobjects, creating a new navobj.xml file.")); } delete m_pNavObjectInputSet; @@ -1825,7 +1853,8 @@ bool MyConfig::LoadLayers(wxString &path) { if (::wxFileExists(file_path)) { NavObjectCollection1 *pSet = new NavObjectCollection1; - if (pSet->load_file(file_path.fn_str()).status != pugi::xml_parse_status::status_ok) { + if (pSet->load_file(file_path.fn_str()).status != + pugi::xml_parse_status::status_ok) { wxLogMessage("Error loading GPX file " + file_path); pSet->reset(); } @@ -1910,45 +1939,40 @@ bool MyConfig::LoadChartDirArray(ArrayOfCDI &ChartDirArray) { return true; } -void MyConfig::AddNewRoute(Route *r) { - m_pNavObjectChangesSet->AddNewRoute(r); -} +void MyConfig::AddNewRoute(Route *r) { m_pNavObjectChangesSet->AddNewRoute(r); } -void MyConfig::UpdateRoute(Route *r) { - m_pNavObjectChangesSet->UpdateRoute(r); -} +void MyConfig::UpdateRoute(Route *r) { m_pNavObjectChangesSet->UpdateRoute(r); } void MyConfig::DeleteConfigRoute(Route *pr) { m_pNavObjectChangesSet->DeleteConfigRoute(pr); } void MyConfig::AddNewTrack(Track *pt) { - m_pNavObjectChangesSet->AddNewTrack(pt); + m_pNavObjectChangesSet->AddNewTrack(pt); } void MyConfig::UpdateTrack(Track *pt) { - m_pNavObjectChangesSet->UpdateTrack(pt); + m_pNavObjectChangesSet->UpdateTrack(pt); } void MyConfig::DeleteConfigTrack(Track *pt) { - m_pNavObjectChangesSet->DeleteConfigTrack(pt); + m_pNavObjectChangesSet->DeleteConfigTrack(pt); } void MyConfig::AddNewWayPoint(RoutePoint *pWP, int crm) { - m_pNavObjectChangesSet->AddNewWayPoint(pWP); + m_pNavObjectChangesSet->AddNewWayPoint(pWP); } void MyConfig::UpdateWayPoint(RoutePoint *pWP) { - m_pNavObjectChangesSet->UpdateWayPoint(pWP); + m_pNavObjectChangesSet->UpdateWayPoint(pWP); } void MyConfig::DeleteWayPoint(RoutePoint *pWP) { - m_pNavObjectChangesSet->DeleteWayPoint(pWP); + m_pNavObjectChangesSet->DeleteWayPoint(pWP); } -void MyConfig::AddNewTrackPoint(TrackPoint *pWP, - const wxString &parent_GUID) { - m_pNavObjectChangesSet->AddNewTrackPoint(pWP, parent_GUID); +void MyConfig::AddNewTrackPoint(TrackPoint *pWP, const wxString &parent_GUID) { + m_pNavObjectChangesSet->AddNewTrackPoint(pWP, parent_GUID); } bool MyConfig::UpdateChartDirs(ArrayOfCDI &dir_array) { @@ -2091,7 +2115,6 @@ void MyConfig::LoadCanvasConfigs(bool bApplyAsTemplate) { Read(_T ( "CanvasConfig" ), (int *)&g_canvasConfig, 0); - // Do not recreate canvasConfigs when applying config dynamically if (config_array.GetCount() == 0) { // This is initial load from startup s.Printf(_T("/Canvas/CanvasConfig%d"), 1); @@ -2346,8 +2369,7 @@ void MyConfig::UpdateSettings() { Write(_T ( "CompatOS" ), g_compatOS); Write(_T ( "CompatOsVersion" ), g_compatOsVersion); Write(_T ( "ConfigVersionString" ), g_config_version_string); - if (wxIsEmpty(g_CmdSoundString)) - g_CmdSoundString = wxString(OCPN_SOUND_CMD); + if (wxIsEmpty(g_CmdSoundString)) g_CmdSoundString = wxString(OCPN_SOUND_CMD); Write(_T( "CmdSoundString" ), g_CmdSoundString); Write(_T ( "NavMessageShown" ), n_NavMessageShown); Write(_T ( "InlandEcdis" ), g_bInlandEcdis); @@ -2410,7 +2432,8 @@ void MyConfig::UpdateSettings() { Write(_T ( "ShowCM93DetailSlider" ), g_bShowDetailSlider); Write(_T ( "SkewToNorthUp" ), g_bskew_comp); - if (!g_bdisable_opengl) { // Only modify the saved value if OpenGL is not force-disabled from the command line + if (!g_bdisable_opengl) { // Only modify the saved value if OpenGL is not + // force-disabled from the command line Write(_T ( "OpenGL" ), g_bopengl); } Write(_T ( "SoftwareGL" ), g_bSoftwareGL); @@ -2452,7 +2475,8 @@ void MyConfig::UpdateSettings() { Write(_T ( "OwnshipCOGPredictorWidth" ), g_cog_predictor_width); Write(_T ( "OwnshipHDTPredictorStyle" ), g_ownship_HDTpredictor_style); Write(_T ( "OwnshipHDTPredictorColor" ), g_ownship_HDTpredictor_color); - Write(_T ( "OwnshipHDTPredictorEndmarker" ), g_ownship_HDTpredictor_endmarker); + Write(_T ( "OwnshipHDTPredictorEndmarker" ), + g_ownship_HDTpredictor_endmarker); Write(_T ( "OwnshipHDTPredictorWidth" ), g_ownship_HDTpredictor_width); Write(_T ( "OwnshipHDTPredictorMiles" ), g_ownship_HDTpredictor_miles); @@ -2516,7 +2540,7 @@ void MyConfig::UpdateSettings() { Write(_T ( "TemperatureFormat" ), g_iTempFormat); } Write(_T ( "GPSIdent" ), g_GPS_Ident); - Write("ActiveRoute" , g_active_route); + Write("ActiveRoute", g_active_route); Write("PersistActiveRoute", g_persist_active_route); Write(_T ( "UseGarminHostUpload" ), g_bGarminHostUpload); @@ -2531,7 +2555,7 @@ void MyConfig::UpdateSettings() { for (const auto &mm : g_config_display_size_mm) { st0.Append(wxString::Format(_T ( "%zu," ), mm)); } - st0.RemoveLast(); //Strip last comma + st0.RemoveLast(); // Strip last comma Write(_T ( "DisplaySizeMM" ), st0); Write(_T ( "DisplaySizeManual" ), g_config_display_size_manual); @@ -2762,7 +2786,8 @@ void MyConfig::UpdateSettings() { Write(_T ( "GPXIODir" ), g_gpx_path); Write(_T ( "TCDataDir" ), g_TCData_Dir); Write(_T ( "BasemapDir" ), g_Platform->NormalizePath(gWorldMapLocation)); - Write(_T ( "BaseShapefileDir" ), g_Platform->NormalizePath(gWorldShapefileLocation)); + Write(_T ( "BaseShapefileDir" ), + g_Platform->NormalizePath(gWorldShapefileLocation)); Write(_T ( "pluginInstallDir" ), g_Platform->NormalizePath(g_winPluginDir)); SetPath(_T ( "/Settings/NMEADataSource" )); @@ -2915,8 +2940,10 @@ void MyConfig::UpdateNavObj(bool bRecreate) { m_pNavObjectChangesSet->Init(m_sNavObjSetChangesFile); m_pNavObjectChangesSet->reset(); - if (m_pNavObjectChangesSet->load_file(m_sNavObjSetChangesFile.fn_str()).status != pugi::xml_parse_status::status_ok) { - wxLogMessage("Error while loading " + m_sNavObjSetChangesFile + ", ignoring contents of the file."); + if (m_pNavObjectChangesSet->load_file(m_sNavObjSetChangesFile.fn_str()) + .status != pugi::xml_parse_status::status_ok) { + wxLogMessage("Error while loading " + m_sNavObjSetChangesFile + + ", ignoring contents of the file."); m_pNavObjectChangesSet->reset(); } } @@ -2980,7 +3007,7 @@ bool ExportGPXRoutes(wxWindow *parent, RouteList *pRoutes, return false; } -bool ExportGPXTracks(wxWindow *parent, std::vector *pTracks, +bool ExportGPXTracks(wxWindow *parent, std::vector *pTracks, const wxString suggestedName) { wxFileName fn = exportFileName(parent, suggestedName); if (fn.IsOk()) { @@ -3085,7 +3112,7 @@ void ExportGPX(wxWindow *parent, bool bviz_only, bool blayer) { node1 = node1->GetNext(); } - for (Track* pTrack : g_TrackList) { + for (Track *pTrack : g_TrackList) { bool b_add = true; if (bviz_only && !pTrack->IsVisible()) b_add = false; @@ -3214,7 +3241,8 @@ void UI_ImportGPX(wxWindow *parent, bool islayer, wxString dirpath, if (::wxFileExists(path)) { NavObjectCollection1 *pSet = new NavObjectCollection1; - if (pSet->load_file(path.fn_str()).status != pugi::xml_parse_status::status_ok) { + if (pSet->load_file(path.fn_str()).status != + pugi::xml_parse_status::status_ok) { wxLogMessage("Error loading GPX file " + path); pSet->reset(); delete pSet; @@ -3413,7 +3441,6 @@ double fromUsrWindSpeed(double usr_wspeed, int unit) { return ret; } - /**************************************************************************/ /* Converts the temperature from the units selected by user to Celsius */ /**************************************************************************/ @@ -3437,8 +3464,8 @@ double fromUsrTemp(double usr_temp, int unit) { wxString formatAngle(double angle) { wxString out; if (g_bShowMag && g_bShowTrue) { - out.Printf(wxT("%03.0f %cT (%.0f %cM)"), angle, 0x00B0, - toMagnetic(angle), 0x00B0); + out.Printf(wxT("%03.0f %cT (%.0f %cM)"), angle, 0x00B0, toMagnetic(angle), + 0x00B0); } else if (g_bShowTrue) { out.Printf(wxT("%03.0f %cT"), angle, 0x00B0); } else { @@ -3549,8 +3576,10 @@ void DimeControl(wxWindow *ctrl) { return; // this is seriously broken on wxqt #endif - if(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW).Red() < 128) { - // Dark system color themes usually do better job than we do on diming UI controls, do not fight with them + if (wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW).Red() < + 128) { + // Dark system color themes usually do better job than we do on diming UI + // controls, do not fight with them return; } @@ -3614,9 +3643,8 @@ void DimeControl(wxWindow *ctrl, wxColour col, wxColour window_back_color, if (win->IsKindOf(CLASSINFO(wxListBox)) || win->IsKindOf(CLASSINFO(wxListCtrl)) || - win->IsKindOf(CLASSINFO(wxTextCtrl)) - || win->IsKindOf(CLASSINFO(wxTimePickerCtrl)) - ) { + win->IsKindOf(CLASSINFO(wxTextCtrl)) || + win->IsKindOf(CLASSINFO(wxTimePickerCtrl))) { win->SetBackgroundColour(col); } else if (win->IsKindOf(CLASSINFO(wxStaticText)) || win->IsKindOf(CLASSINFO(wxCheckBox)) || @@ -3680,20 +3708,19 @@ void DimeControl(wxWindow *ctrl, wxColour col, wxColour window_back_color, #define LUMIMOSITY_NIGHT (-0.8) #define LUMIMOSITY_DUSK (-0.5) -wxColor GetDimedColor(const wxColor& c) -{ - switch (global_color_scheme) { +wxColor GetDimedColor(const wxColor &c) { + switch (global_color_scheme) { case ColorScheme::GLOBAL_COLOR_SCHEME_NIGHT: - return ( - wxColor(wxMax(0, wxMin(c.Red() + c.Red() * LUMIMOSITY_NIGHT, 255)), - wxMax(0, wxMin(c.Green() + c.Green() * LUMIMOSITY_NIGHT, 255)), - wxMax(0, wxMin(c.Blue() + c.Blue() * LUMIMOSITY_NIGHT, 255)))); + return (wxColor( + wxMax(0, wxMin(c.Red() + c.Red() * LUMIMOSITY_NIGHT, 255)), + wxMax(0, wxMin(c.Green() + c.Green() * LUMIMOSITY_NIGHT, 255)), + wxMax(0, wxMin(c.Blue() + c.Blue() * LUMIMOSITY_NIGHT, 255)))); case ColorScheme::GLOBAL_COLOR_SCHEME_DUSK: - return ( - wxColor(wxMax(0, wxMin(c.Red() + c.Red() * LUMIMOSITY_DUSK, 255)), - wxMax(0, wxMin(c.Green() + c.Green() * LUMIMOSITY_DUSK, 255)), - wxMax(0, wxMin(c.Blue() + c.Blue() * LUMIMOSITY_DUSK, 255)))); + return ( + wxColor(wxMax(0, wxMin(c.Red() + c.Red() * LUMIMOSITY_DUSK, 255)), + wxMax(0, wxMin(c.Green() + c.Green() * LUMIMOSITY_DUSK, 255)), + wxMax(0, wxMin(c.Blue() + c.Blue() * LUMIMOSITY_DUSK, 255)))); default: - return c; - } + return c; + } } diff --git a/gui/src/ocpn_frame.cpp b/gui/src/ocpn_frame.cpp index 9860c40774..c867b80a4d 100644 --- a/gui/src/ocpn_frame.cpp +++ b/gui/src/ocpn_frame.cpp @@ -36,10 +36,9 @@ #endif // precompiled headers #ifdef __WXMSW__ -//#include "c:\\Program Files\\visual leak detector\\include\\vld.h" +// #include "c:\\Program Files\\visual leak detector\\include\\vld.h" #endif - #ifdef __WXMSW__ #include #include @@ -347,7 +346,6 @@ DWORD color_inactiveborder; #endif - #ifdef __MSVC__ #define _CRTDBG_MAP_ALLOC #include @@ -405,7 +403,8 @@ void BuildiENCToolbar(bool bnew) { if (bnew) { if (g_iENCToolbar) { wxPoint locn = g_iENCToolbar->GetToolbarPosition(); - wxPoint tbp_incanvas = locn; //gFrame->GetPrimaryCanvas()->ScreenToClient(locn); + wxPoint tbp_incanvas = + locn; // gFrame->GetPrimaryCanvas()->ScreenToClient(locn); g_iENCToolbarPosY = tbp_incanvas.y; g_iENCToolbarPosX = tbp_incanvas.x; @@ -421,7 +420,8 @@ void BuildiENCToolbar(bool bnew) { // Overlapping main toolbar? if (g_MainToolbar) { if ((g_iENCToolbarPosY > g_maintoolbar_y) && - (g_iENCToolbarPosY < g_maintoolbar_y + g_MainToolbar->GetToolSize().y)) + (g_iENCToolbarPosY < + g_maintoolbar_y + g_MainToolbar->GetToolSize().y)) g_iENCToolbarPosY = -1; // force a reposition } @@ -430,8 +430,9 @@ void BuildiENCToolbar(bool bnew) { posn.y = 100; if (g_MainToolbar) - posn = wxPoint(g_maintoolbar_x + g_MainToolbar->GetToolbarSize().x + 4, - g_maintoolbar_y); + posn = + wxPoint(g_maintoolbar_x + g_MainToolbar->GetToolbarSize().x + 4, + g_maintoolbar_y); } double tool_scale_factor = @@ -633,13 +634,15 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, const wxPoint &pos, const wxSize &size, long style) : wxFrame(frame, -1, title, pos, size, style, kTopLevelWindowName), comm_overflow_dlg(this) { - g_current_monitor = wxDisplay::GetFromWindow(this); #ifdef __WXOSX__ - // On retina displays there is a difference between the physical size of the OpenGL canvas and the DIP - // This is not observed anywhere else so far, so g_current_monitor_dip_px_ratio cna be kept 1.0 everywhere else + // On retina displays there is a difference between the physical size of the + // OpenGL canvas and the DIP This is not observed anywhere else so far, so + // g_current_monitor_dip_px_ratio cna be kept 1.0 everywhere else if (g_bopengl) { - g_current_monitor_dip_px_ratio = g_monitor_info[g_current_monitor].width_px / g_monitor_info[g_current_monitor].width; + g_current_monitor_dip_px_ratio = + g_monitor_info[g_current_monitor].width_px / + g_monitor_info[g_current_monitor].width; } #endif m_last_track_rotation_ts = 0; @@ -707,28 +710,33 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, const wxPoint &pos, // Establish my children struct MuxLogCallbacks log_callbacks; - log_callbacks.log_is_active = []() { return NMEALogWindow::GetInstance().Active(); }; - log_callbacks.log_message = [](const std::string& s) { - NMEALogWindow::GetInstance().Add(s); }; + log_callbacks.log_is_active = []() { + return NMEALogWindow::GetInstance().Active(); + }; + log_callbacks.log_message = [](const std::string &s) { + NMEALogWindow::GetInstance().Add(s); + }; g_pMUX = new Multiplexer(log_callbacks, g_b_legacy_input_filter_behaviour); - struct AisDecoderCallbacks ais_callbacks; + struct AisDecoderCallbacks ais_callbacks; ais_callbacks.confirm_stop_track = []() { - int r = OCPNMessageBox(NULL, - _("This AIS target has Persistent tracking selected by MMSI properties\n" - "A Persistent track recording will therefore be restarted for this target.\n\n" - "Do you instead want to stop Persistent tracking for this target?"), - _("OpenCPN Info"), wxYES_NO | wxCENTER, 60); + int r = OCPNMessageBox( + NULL, + _("This AIS target has Persistent tracking selected by MMSI " + "properties\n" + "A Persistent track recording will therefore be restarted for this " + "target.\n\n" + "Do you instead want to stop Persistent tracking for this target?"), + _("OpenCPN Info"), wxYES_NO | wxCENTER, 60); return r == wxID_YES; }; - ais_callbacks.get_target_mmsi = []() { + ais_callbacks.get_target_mmsi = []() { auto alert_dlg_active = - dynamic_cast(g_pais_alert_dialog_active); + dynamic_cast(g_pais_alert_dialog_active); assert(alert_dlg_active); return alert_dlg_active->Get_Dialog_MMSI(); }; - g_pAIS = new AisDecoder(ais_callbacks); g_pAISGUI = new AisInfoGui(); @@ -743,9 +751,9 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, const wxPoint &pos, Connect(wxEVT_OCPN_MSG, (wxObjectEventFunction)(wxEventFunction)&MyFrame::OnEvtPlugInMessage); - //FIXME (dave) - //Connect(wxEVT_OCPN_THREADMSG, - // (wxObjectEventFunction)(wxEventFunction)&MyFrame::OnEvtTHREADMSG); + // FIXME (dave) + // Connect(wxEVT_OCPN_THREADMSG, + // (wxObjectEventFunction)(wxEventFunction)&MyFrame::OnEvtTHREADMSG); // And from the thread SENC creator Connect(wxEVT_OCPN_BUILDSENCTHREAD, @@ -787,7 +795,6 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, const wxPoint &pos, m_routes_update_listener.Init(g_pRouteMan->on_routes_update, [&](wxCommandEvent) { Refresh(); }); - #ifdef __WXOSX__ // Enable native fullscreen on macOS EnableFullScreenView(); @@ -816,9 +823,9 @@ MyFrame::~MyFrame() { Disconnect( wxEVT_OCPN_MSG, (wxObjectEventFunction)(wxEventFunction)&MyFrame::OnEvtPlugInMessage); - //FIXME (dave) Was in some datastream file? - //Disconnect(wxEVT_OCPN_THREADMSG, - // (wxObjectEventFunction)(wxEventFunction)&MyFrame::OnEvtTHREADMSG); + // FIXME (dave) Was in some datastream file? + // Disconnect(wxEVT_OCPN_THREADMSG, + // (wxObjectEventFunction)(wxEventFunction)&MyFrame::OnEvtTHREADMSG); } void MyFrame::OnSENCEvtThread(OCPN_BUILDSENC_ThreadEvent &event) { @@ -860,13 +867,13 @@ void MyFrame::RebuildChartDatabase() { if (ChartDirArray.GetCount()) { // Create and Save a new Chart Database based on the hints // given in the config file - if(g_NeedDBUpdate == 1) { + if (g_NeedDBUpdate == 1) { wxString msg1( - _("OpenCPN needs to update the chart database from config file " - "entries....")); + _("OpenCPN needs to update the chart database from config file " + "entries....")); OCPNMessageDialog mdlg(gFrame, msg1, wxString(_("OpenCPN Info")), - wxICON_INFORMATION | wxOK); + wxICON_INFORMATION | wxOK); mdlg.ShowModal(); } @@ -1033,8 +1040,8 @@ void MyFrame::SetAndApplyColorScheme(ColorScheme cs) { } if (pWayPointMan) - WayPointmanGui(*pWayPointMan).SetColorScheme(cs, - g_Platform->GetDisplayDPmm()); + WayPointmanGui(*pWayPointMan) + .SetColorScheme(cs, g_Platform->GetDisplayDPmm()); if (ChartData) ChartData->ApplyColorSchemeToCachedCharts(cs); if (g_options) { @@ -1095,11 +1102,11 @@ void MyFrame::SetAndApplyColorScheme(ColorScheme cs) { // CreateMasterToolbar(); if (!btoolbarFull) { - //g_MainToolbar->Hide(); + // g_MainToolbar->Hide(); RequestNewMasterToolbar(); g_MainToolbar->SetColorScheme(cs); CollapseGlobalToolbar(); - //g_MainToolbar->Show(); + // g_MainToolbar->Show(); } else { RequestNewMasterToolbar(); g_MainToolbar->SetColorScheme(cs); @@ -1150,7 +1157,7 @@ void MyFrame::CreateCanvasLayout(bool b_useStoredSize) { ChartCanvas *cc = g_canvasArray.Item(i); if (cc) { // pthumbwin = NULL; // TODO - //cc->DestroyToolbar(); + // cc->DestroyToolbar(); cc->Destroy(); } } @@ -1475,7 +1482,10 @@ void MyFrame::SwitchKBFocus(ChartCanvas *pCanvas) { #ifdef __WXGTK__ nfinalTarget = nTargetGTK; #endif - target = ConfigMgr::Get().GetCanvasConfigArray().Item(nfinalTarget)->canvas; + target = ConfigMgr::Get() + .GetCanvasConfigArray() + .Item(nfinalTarget) + ->canvas; if (target) { wxWindow *win = wxDynamicCast(target, wxWindow); win->SetFocus(); @@ -1589,9 +1599,10 @@ void MyFrame::OnCloseWindow(wxCloseEvent &event) { RestoreScreenBrightness(); // Persist the toolbar locations - // if (g_MainToolbar) { - // g_MainToolbar->GetFrameRelativePosition(&g_maintoolbar_x, &g_maintoolbar_y); - // } + // if (g_MainToolbar) { + // g_MainToolbar->GetFrameRelativePosition(&g_maintoolbar_x, + // &g_maintoolbar_y); + // } #if 0 if (g_iENCToolbar) { @@ -1706,15 +1717,15 @@ void MyFrame::OnCloseWindow(wxCloseEvent &event) { } #ifndef __ANDROID__ - //if (g_MainToolbar) g_MainToolbar->Destroy(); - //g_MainToolbar = NULL; + // if (g_MainToolbar) g_MainToolbar->Destroy(); + // g_MainToolbar = NULL; #endif if (g_iENCToolbar) { - //wxPoint locn = g_iENCToolbar->GetPosition(); - //g_iENCToolbarPosY = locn.y; - //g_iENCToolbarPosX = locn.x; - //g_iENCToolbar->Destroy(); + // wxPoint locn = g_iENCToolbar->GetPosition(); + // g_iENCToolbarPosY = locn.y; + // g_iENCToolbarPosX = locn.x; + // g_iENCToolbar->Destroy(); } if (g_pAISTargetList) { @@ -1770,14 +1781,13 @@ void MyFrame::OnCloseWindow(wxCloseEvent &event) { g_pi_manager = NULL; } - MyApp& app = wxGetApp(); + MyApp &app = wxGetApp(); app.m_comm_bridge.SaveConfig(); delete pConfig; // All done pConfig = NULL; InitBaseConfig(0); - if (g_pAIS) { delete g_pAIS; g_pAIS = NULL; @@ -1792,7 +1802,7 @@ void MyFrame::OnCloseWindow(wxCloseEvent &event) { g_pMUX = NULL; // Close and delete all comm drivers - auto& registry = CommDriverRegistry::GetInstance(); + auto ®istry = CommDriverRegistry::GetInstance(); registry.CloseAllDrivers(); // Clear some global arrays, lists, and hash maps... @@ -1870,32 +1880,41 @@ void MyFrame::OnCloseWindow(wxCloseEvent &event) { void MyFrame::OnMove(wxMoveEvent &event) { auto idx = wxDisplay::GetFromWindow(this); - if (idx != wxNOT_FOUND && g_current_monitor != static_cast(idx) && static_cast(idx) < g_monitor_info.size()) { + if (idx != wxNOT_FOUND && g_current_monitor != static_cast(idx) && + static_cast(idx) < g_monitor_info.size()) { g_current_monitor = idx; #ifdef __WXOSX__ - // On retina displays there is a difference between the physical size of the OpenGL canvas and the DIP - // This is not observed anywhere else so far, so g_current_monitor_dip_px_ratio cna be kept 1.0 everywhere else + // On retina displays there is a difference between the physical size of the + // OpenGL canvas and the DIP This is not observed anywhere else so far, so + // g_current_monitor_dip_px_ratio cna be kept 1.0 everywhere else if (g_bopengl) { - g_current_monitor_dip_px_ratio = g_monitor_info[idx].width_px / g_monitor_info[idx].width; + g_current_monitor_dip_px_ratio = + g_monitor_info[idx].width_px / g_monitor_info[idx].width; } #endif DEBUG_LOG << "Moved to " << idx #if wxCHECK_VERSION(3, 1, 6) - << " PPI: " << wxDisplay(idx).GetPPI().GetX() << "x" << wxDisplay(idx).GetPPI().GetY() - << " SF wxDisplay: " << wxDisplay(idx).GetScaleFactor() -#endif - << " Size wxDisplay: " << wxDisplay(idx).GetGeometry().GetWidth() << "x" << wxDisplay(idx).GetGeometry().GetHeight() - << " MM wxDisplay: " << wxGetDisplaySizeMM().GetX() << "x" << wxGetDisplaySizeMM().GetY() - << " Name wxDisplay: " << wxDisplay(idx).GetName().c_str() - << " Real: " << g_monitor_info[idx].width_mm << "x" << g_monitor_info[idx].height_mm << "mm " - << g_monitor_info[idx].width_mm << "x" << g_monitor_info[idx].height_mm << "mm " - << g_monitor_info[idx].width << "x" << g_monitor_info[idx].height << "DIP " - << g_monitor_info[idx].width_px << "x" << g_monitor_info[idx].height_px << "px" - << g_monitor_info[idx].scale << "%"; - if(g_config_display_size_manual) { - if(g_config_display_size_mm.size() > static_cast(idx)) { + << " PPI: " << wxDisplay(idx).GetPPI().GetX() << "x" + << wxDisplay(idx).GetPPI().GetY() + << " SF wxDisplay: " << wxDisplay(idx).GetScaleFactor() +#endif + << " Size wxDisplay: " << wxDisplay(idx).GetGeometry().GetWidth() + << "x" << wxDisplay(idx).GetGeometry().GetHeight() + << " MM wxDisplay: " << wxGetDisplaySizeMM().GetX() << "x" + << wxGetDisplaySizeMM().GetY() + << " Name wxDisplay: " << wxDisplay(idx).GetName().c_str() + << " Real: " << g_monitor_info[idx].width_mm << "x" + << g_monitor_info[idx].height_mm << "mm " + << g_monitor_info[idx].width_mm << "x" + << g_monitor_info[idx].height_mm << "mm " + << g_monitor_info[idx].width << "x" << g_monitor_info[idx].height + << "DIP " << g_monitor_info[idx].width_px << "x" + << g_monitor_info[idx].height_px << "px" + << g_monitor_info[idx].scale << "%"; + if (g_config_display_size_manual) { + if (g_config_display_size_mm.size() > static_cast(idx)) { g_display_size_mm = g_config_display_size_mm[idx]; - } // Do nothing if the user did not set any value for this monitor + } // Do nothing if the user did not set any value for this monitor } else { g_display_size_mm = g_monitor_info[idx].width_mm; } @@ -1918,9 +1937,9 @@ void MyFrame::OnMove(wxMoveEvent &event) { if (console && console->IsShown()) PositionConsole(); // If global toolbar is shown, reposition it... - //if (g_MainToolbar) { - //g_MainToolbar->RestoreRelativePosition(g_maintoolbar_x, g_maintoolbar_y); - //g_MainToolbar->Realize(); + // if (g_MainToolbar) { + // g_MainToolbar->RestoreRelativePosition(g_maintoolbar_x, g_maintoolbar_y); + // g_MainToolbar->Realize(); //} PositionIENCToolbar(); @@ -2229,10 +2248,10 @@ void MyFrame::PositionConsole(void) { int yOffset = 60; if (consoleHost) { - if(consoleHost->GetCompass()){ + if (consoleHost->GetCompass()) { wxRect compass_rect = consoleHost->GetCompass()->GetRect(); - // Compass is normal upper right position. - if(compass_rect.y < 100) + // Compass is normal upper right position. + if (compass_rect.y < 100) yOffset = compass_rect.y + compass_rect.height + 45; } } @@ -2303,7 +2322,6 @@ void MyFrame::RefreshGroupIndices(void) { void MyFrame::OnToolLeftClick(wxCommandEvent &event) { if (g_MainToolbar) g_MainToolbar->HideTooltip(); - switch (event.GetId()) { case ID_MENU_SCALE_OUT: DoStackDelta(GetPrimaryCanvas(), 1); @@ -2430,7 +2448,7 @@ void MyFrame::OnToolLeftClick(wxCommandEvent &event) { g_bAIS_CPA_Alert = !g_bAIS_CPA_Alert; SetMenubarItemState(ID_MENU_AIS_CPADIALOG, g_bAIS_CPA_Alert); m_pMenuBar->Enable(ID_MENU_AIS_CPASOUND, g_bAIS_CPA_Alert); - if (g_bAIS_CPA_Alert){ + if (g_bAIS_CPA_Alert) { SetMenubarItemState(ID_MENU_AIS_CPASOUND, g_bAIS_CPA_Alert_Audio); } break; @@ -2660,7 +2678,7 @@ void MyFrame::OnToolLeftClick(wxCommandEvent &event) { case ID_DENSITY: case ID_RMINUS: case ID_RPLUS: { - if (g_iENCToolbar ){ + if (g_iENCToolbar) { g_iENCToolbar->OnToolLeftClick(event); } break; @@ -2686,9 +2704,9 @@ void MyFrame::OnToolLeftClick(wxCommandEvent &event) { } // If we didn't handle the event, allow it to bubble up to other handlers. - // This is required for the system menu items (Hide, etc.) on OS X to work. - // This must only be called if we did NOT handle the event, otherwise it - // stops the menu items from working on Windows. + // This is required for the system menu items (Hide, etc.) on OS X to + // work. This must only be called if we did NOT handle the event, + // otherwise it stops the menu items from working on Windows. event.Skip(); break; @@ -2696,11 +2714,8 @@ void MyFrame::OnToolLeftClick(wxCommandEvent &event) { } // switch - // Finally, force a refresh of the main toolbar - if (g_MainToolbar) - g_MainToolbar->Realize(); - - + // Finally, force a refresh of the main toolbar + if (g_MainToolbar) g_MainToolbar->Realize(); } bool MyFrame::SetGlobalToolbarViz(bool viz) { @@ -2885,7 +2900,7 @@ void MyFrame::ToggleColorScheme() { { is = 1; lastIsNight = false; - } // Goto to Day + } // Goto to Day if (lastIsNight) is = 2; // Back to Dusk on step 3 if (is == 3) lastIsNight = true; // Step 2 Night s = (ColorScheme)is; @@ -2906,7 +2921,7 @@ void MyFrame::ToggleFullScreen() { #endif UpdateAllToolbars(global_color_scheme); - //SurfaceAllCanvasToolbars(); + // SurfaceAllCanvasToolbars(); UpdateControlBar(GetPrimaryCanvas()); Layout(); TriggerRecaptureTimer(); @@ -3288,7 +3303,7 @@ void MyFrame::SetbFollow(ChartCanvas *cc) { JumpToPosition(cc, gLat, gLon, cc->GetVPScale()); cc->m_bFollow = true; - //cc->SetCanvasToolbarItemState(ID_FOLLOW, true); + // cc->SetCanvasToolbarItemState(ID_FOLLOW, true); SetMenubarItemState(ID_MENU_NAV_FOLLOW, true); DoChartUpdate(); @@ -3302,7 +3317,7 @@ void MyFrame::ClearbFollow(ChartCanvas *cc) { vLon = gLon; cc->m_bFollow = false; - //cc->SetCanvasToolbarItemState(ID_FOLLOW, false); + // cc->SetCanvasToolbarItemState(ID_FOLLOW, false); SetMenubarItemState(ID_MENU_NAV_FOLLOW, false); DoChartUpdate(); @@ -3545,10 +3560,10 @@ void MyFrame::RegisterGlobalMenuItems() { #ifndef __WXOSX__ ais_menu->AppendCheckItem(ID_MENU_AIS_CPAWARNING, - _menuText(_("Show CPA Warnings"), _T("W"))); + _menuText(_("Show CPA Warnings"), _T("W"))); #else ais_menu->AppendCheckItem(ID_MENU_AIS_CPAWARNING, - _menuText(_("Show CPA Warnings"), _T("Alt-W"))); + _menuText(_("Show CPA Warnings"), _T("Alt-W"))); #endif ais_menu->AppendSeparator(); @@ -3630,8 +3645,7 @@ void MyFrame::UpdateGlobalMenuItems() { if (g_bAIS_CPA_Alert) { m_pMenuBar->FindItem(ID_MENU_AIS_CPASOUND)->Check(g_bAIS_CPA_Alert_Audio); m_pMenuBar->Enable(ID_MENU_AIS_CPASOUND, true); - } - else { + } else { m_pMenuBar->FindItem(ID_MENU_AIS_CPASOUND)->Check(false); m_pMenuBar->Enable(ID_MENU_AIS_CPASOUND, false); } @@ -3781,7 +3795,8 @@ void MyFrame::JumpToPosition(ChartCanvas *cc, double lat, double lon, void MyFrame::UpdateCanvasConfigDescriptors() { // ..For each canvas... - for (unsigned int i = 0; i < ConfigMgr::Get().GetCanvasConfigArray().GetCount(); i++) { + for (unsigned int i = 0; + i < ConfigMgr::Get().GetCanvasConfigArray().GetCount(); i++) { canvasConfig *cc = ConfigMgr::Get().GetCanvasConfigArray().Item(i); if (cc) { ChartCanvas *chart = cc->canvas; @@ -3804,7 +3819,8 @@ void MyFrame::UpdateCanvasConfigDescriptors() { cc->bFollow = chart->m_bFollow; cc->bLookahead = chart->m_bLookAhead; cc->bCourseUp = false; - cc->bHeadUp = false;; + cc->bHeadUp = false; + ; int upmode = chart->GetUpMode(); if (upmode == COURSE_UP_MODE) cc->bCourseUp = true; @@ -3865,8 +3881,8 @@ int MyFrame::DoOptionsDialog() { #ifdef __WXOSX__ optionsParent = GetPrimaryCanvas(); #endif - g_options = - new options(optionsParent, -1, _("Options"), wxPoint(-1, -1), wxSize(sx, sy)); + g_options = new options(optionsParent, -1, _("Options"), wxPoint(-1, -1), + wxSize(sx, sy)); AbstractPlatform::HideBusySpinner(); } @@ -3907,7 +3923,7 @@ int MyFrame::DoOptionsDialog() { #endif #ifdef __WXOSX__ - //SubmergeAllCanvasToolbars(); + // SubmergeAllCanvasToolbars(); g_MainToolbar->Submerge(); #endif @@ -4002,8 +4018,8 @@ int MyFrame::DoOptionsDialog() { g_MainToolbar->SetDockX(-1); g_MainToolbar->SetDockY(-1); #endif - //g_MainToolbar->Surface(); - //SurfaceAllCanvasToolbars(); + // g_MainToolbar->Surface(); + // SurfaceAllCanvasToolbars(); GetPrimaryCanvas()->SetFocus(); } @@ -4079,7 +4095,8 @@ int MyFrame::DoOptionsDialog() { if (rr & CONFIG_CHANGED) { // Apply the changed canvas configs to each canvas // ..For each canvas... - for (unsigned int i = 0; i < ConfigMgr::Get().GetCanvasConfigArray().GetCount(); i++) { + for (unsigned int i = 0; + i < ConfigMgr::Get().GetCanvasConfigArray().GetCount(); i++) { canvasConfig *cc = ConfigMgr::Get().GetCanvasConfigArray().Item(i); if (cc) { ChartCanvas *chartCanvas = cc->canvas; @@ -4167,7 +4184,7 @@ int MyFrame::DoOptionsDialog() { if (console && console->IsShown()) console->Raise(); auto alert_dlg_active = - dynamic_cast(g_pais_alert_dialog_active); + dynamic_cast(g_pais_alert_dialog_active); if (alert_dlg_active) alert_dlg_active->Raise(); if (NMEALogWindow::GetInstance().Active()) @@ -4340,7 +4357,9 @@ bool MyFrame::ProcessOptionsDialog(int rr, ArrayOfCDI *pNewDirArray) { } #endif - if (g_config_display_size_manual && g_config_display_size_mm.size() > g_current_monitor && g_config_display_size_mm[g_current_monitor] > 0) { + if (g_config_display_size_manual && + g_config_display_size_mm.size() > g_current_monitor && + g_config_display_size_mm[g_current_monitor] > 0) { g_display_size_mm = g_config_display_size_mm[g_current_monitor]; } else { g_display_size_mm = wxMax(50, g_Platform->GetDisplaySizeMM()); @@ -4365,9 +4384,10 @@ bool MyFrame::ProcessOptionsDialog(int rr, ArrayOfCDI *pNewDirArray) { } // update S52 PLIB scale factors - if (ps52plib){ - ps52plib->SetScaleFactorExp(g_Platform->GetChartScaleFactorExp(g_ChartScaleFactor)); - ps52plib-> SetScaleFactorZoomMod(g_chart_zoom_modifier_vector); + if (ps52plib) { + ps52plib->SetScaleFactorExp( + g_Platform->GetChartScaleFactorExp(g_ChartScaleFactor)); + ps52plib->SetScaleFactorZoomMod(g_chart_zoom_modifier_vector); } // Apply any needed updates to each canvas @@ -4730,8 +4750,8 @@ void MyFrame::OnInitTimer(wxTimerEvent &event) { // which is why they have been to defered until here auto colour_func = [](wxString c) { return GetGlobalColor(c); }; pWayPointMan = new WayPointman(colour_func); - WayPointmanGui(*pWayPointMan).SetColorScheme(global_color_scheme, - g_Platform->GetDisplayDPmm()); + WayPointmanGui(*pWayPointMan) + .SetColorScheme(global_color_scheme, g_Platform->GetDisplayDPmm()); // Reload the ownship icon from UserIcons, if present for (unsigned int i = 0; i < g_canvasArray.GetCount(); i++) { ChartCanvas *cc = g_canvasArray.Item(i); @@ -4779,8 +4799,8 @@ void MyFrame::OnInitTimer(wxTimerEvent &event) { console->SetColorScheme(global_color_scheme); // Draw console if persisted route is active - if (g_pRouteMan){ - if (g_pRouteMan->IsAnyRouteActive()){ + if (g_pRouteMan) { + if (g_pRouteMan->IsAnyRouteActive()) { g_pRouteMan->GetDlgContext().show_with_fresh_fonts(); } } @@ -4864,7 +4884,7 @@ void MyFrame::OnInitTimer(wxTimerEvent &event) { g_pi_manager->NotifyAuiPlugIns(); // Give the user dialog on any blacklisted PlugIns - g_pi_manager ->ShowDeferredBlacklistMessages(); + g_pi_manager->ShowDeferredBlacklistMessages(); g_pi_manager->CallLateInit(); @@ -4912,12 +4932,12 @@ void MyFrame::OnInitTimer(wxTimerEvent &event) { pConfig->Read("OptionsSizeX", &sx, -1); pConfig->Read("OptionsSizeY", &sy, -1); - wxWindow *optionsParent = this; + wxWindow *optionsParent = this; #ifdef __WXOSX__ - optionsParent = GetPrimaryCanvas(); + optionsParent = GetPrimaryCanvas(); #endif - g_options = - new options(optionsParent, -1, _("Options"), wxPoint(-1, -1), wxSize(sx, sy)); + g_options = new options(optionsParent, -1, _("Options"), wxPoint(-1, -1), + wxSize(sx, sy)); BuildiENCToolbar(true); @@ -5022,7 +5042,7 @@ void MyFrame::InitAppMsgBusListener() { Bind(EVT_BASIC_NAV_DATA, [&](ObservedEvt ev) { auto ptr = ev.GetSharedPtr(); auto basicnav_msg = std::static_pointer_cast(ptr); - HandleBasicNavMsg( basicnav_msg ); + HandleBasicNavMsg(basicnav_msg); }); // GPS Watchdog expiry status @@ -5034,7 +5054,6 @@ void MyFrame::InitAppMsgBusListener() { auto msg = std::static_pointer_cast(ptr); HandleGPSWatchdogMsg(msg); }); - } /** Setup handling of events from the local ipc/dbus API. */ @@ -5044,29 +5063,27 @@ void MyFrame::ReleaseApiListeners() {} #else void MyFrame::InitApiListeners() { - auto& server = LocalServerApi::GetInstance(); - m_on_raise_listener.Init(server.on_raise, [&](ObservedEvt){ Raise(); }); - m_on_quit_listener.Init(server.on_quit, [&](ObservedEvt){ FastClose(); }); + auto &server = LocalServerApi::GetInstance(); + m_on_raise_listener.Init(server.on_raise, [&](ObservedEvt) { Raise(); }); + m_on_quit_listener.Init(server.on_quit, [&](ObservedEvt) { FastClose(); }); server.SetGetRestApiEndpointCb( - [&]{ return wxGetApp().m_rest_server.GetEndpoint(); }); - server.open_file_cb = - [](const std::string& path) { return wxGetApp().OpenFile(path); }; - + [&] { return wxGetApp().m_rest_server.GetEndpoint(); }); + server.open_file_cb = [](const std::string &path) { + return wxGetApp().OpenFile(path); + }; } void MyFrame::ReleaseApiListeners() { LocalServerApi::ReleaseInstance(); } #endif void MyFrame::HandleGPSWatchdogMsg(std::shared_ptr msg) { - - if (msg->gps_watchdog <= 0){ - if (msg->wd_source == GPSWatchdogMsg::WDSource::position){ + if (msg->gps_watchdog <= 0) { + if (msg->wd_source == GPSWatchdogMsg::WDSource::position) { bool last_bGPSValid = bGPSValid; bGPSValid = false; - m_fixtime = 0; // Invalidate fix time + m_fixtime = 0; // Invalidate fix time if (last_bGPSValid != bGPSValid) UpdateGPSCompassStatusBoxes(true); - } - else if (msg->wd_source == GPSWatchdogMsg::WDSource::velocity){ + } else if (msg->wd_source == GPSWatchdogMsg::WDSource::velocity) { bool last_bVelocityValid = bVelocityValid; bVelocityValid = false; } @@ -5078,7 +5095,7 @@ void MyFrame::HandleGPSWatchdogMsg(std::shared_ptr msg) { void MyFrame::HandleBasicNavMsg(std::shared_ptr msg) { m_fixtime = msg->time; - // Maintain average COG for Course Up Mode + // Maintain average COG for Course Up Mode if (!std::isnan(gCog)) { if (g_COGAvgSec > 0) { // Make a hole @@ -5118,11 +5135,10 @@ void MyFrame::HandleBasicNavMsg(std::shared_ptr msg) { // "cruising" if (gSog > 3.0) g_bCruising = true; - -// Maintain the GPS position validity flag -// Determined by source validity of RMC, GGA, GLL (N0183) -// or PGNs 129029, 129025 (N2K) -// Positions by sK and AIVDO are assumed valid + // Maintain the GPS position validity flag + // Determined by source validity of RMC, GGA, GLL (N0183) + // or PGNs 129029, 129025 (N2K) + // Positions by sK and AIVDO are assumed valid bool last_bGPSValid = bGPSValid; if ((msg->vflag & POS_UPDATE) == POS_UPDATE) { if ((msg->vflag & POS_VALID) == POS_VALID) @@ -5130,8 +5146,7 @@ void MyFrame::HandleBasicNavMsg(std::shared_ptr msg) { else bGPSValid = false; } - if (last_bGPSValid != bGPSValid) - UpdateGPSCompassStatusBoxes(true); + if (last_bGPSValid != bGPSValid) UpdateGPSCompassStatusBoxes(true); bVelocityValid = true; UpdateStatusBar(); @@ -5199,7 +5214,7 @@ void MyFrame::HandleBasicNavMsg(std::shared_ptr msg) { msg += CommandStr; wxLogMessage(msg); wxExecute(CommandStr, wxEXEC_ASYNC); -#endif //__WXMSW__ +#endif //__WXMSW__ } m_bTimeIsSet = true; } else { // no hw-clock set both date and time @@ -5221,14 +5236,13 @@ void MyFrame::HandleBasicNavMsg(std::shared_ptr msg) { msg.Printf(_T("Set Date/Time, Linux command is: %s"), CommandStr); wxLogMessage(msg); wxExecute(CommandStr, wxEXEC_ASYNC); -#endif // !__WXMSW__ +#endif // !__WXMSW__ m_bTimeIsSet = true; } } } -#endif // ocpnUPDATE_SYSTEM_TIME +#endif // ocpnUPDATE_SYSTEM_TIME #endif - } void MyFrame::UpdateStatusBar() { @@ -5248,7 +5262,7 @@ void MyFrame::UpdateStatusBar() { // Show gLat/gLon in StatusWindow0 if (NULL != GetStatusBar()) { - if (1/*pos_valid*/) { + if (1 /*pos_valid*/) { char tick_buf[2]; tick_buf[0] = nmea_tick_chars[m_tick_idx]; tick_buf[1] = 0; @@ -5275,18 +5289,16 @@ void MyFrame::UpdateStatusBar() { if (g_bShowTrue) cogs << wxString::Format(wxString("COG %03d%c "), (int)gCog, 0x00B0); if (g_bShowMag) - cogs << wxString::Format(wxString("COG %03d%c(M) "), (int)toMagnetic(gCog), - 0x00B0); + cogs << wxString::Format(wxString("COG %03d%c(M) "), + (int)toMagnetic(gCog), 0x00B0); } else cogs.Printf(("COG ---%c"), 0x00B0); sogcog.Append(cogs); SetStatusText(sogcog, STAT_FIELD_SOGCOG); } - } - // Manage the application memory footprint on a periodic schedule void MyFrame::OnMemFootTimer(wxTimerEvent &event) { MemFootTimer.Stop(); @@ -5484,7 +5496,6 @@ void MyFrame::OnFrameTimer1(wxTimerEvent &event) { } } - // Build and send a Position Fix event to PlugIns if (g_pi_manager) { GenericPosDatEx GPSData; @@ -5692,7 +5703,7 @@ void MyFrame::OnFrameTimer1(wxTimerEvent &event) { if (!bGPSValid) cc->SetOwnShipState(SHIP_INVALID); if ((bGPSValid != m_last_bGPSValid) || - (bVelocityValid != m_last_bVelocityValid)) { + (bVelocityValid != m_last_bVelocityValid)) { if (!g_bopengl) cc->UpdateShips(); bnew_view = true; // force a full Refresh() @@ -5901,7 +5912,7 @@ void MyFrame::OnFrameCOGTimer(wxTimerEvent &event) { // Restart the timer, max frequency is 10 hz. int period_ms = 100; - //if (g_COGAvgSec > 0) period_ms = g_COGAvgSec * 1000; + // if (g_COGAvgSec > 0) period_ms = g_COGAvgSec * 1000; FrameCOGTimer.Start(period_ms, wxTIMER_CONTINUOUS); } @@ -6271,13 +6282,13 @@ bool GetMemoryStatus(int *mem_total, int *mem_used) { } void MyFrame::DoPrint(void) { - //avoid toolbars being printed + // avoid toolbars being printed g_PrintingInProgress = true; #ifdef ocpnUSE_GL - if(g_bopengl){ + if (g_bopengl) { GetPrimaryCanvas()->GetglCanvas()->Render(); GetPrimaryCanvas()->GetglCanvas()->SwapBuffers(); - }else + } else #endif Refresh(); @@ -6844,8 +6855,7 @@ void MyFrame::applySettingsString(wxString settings) { if (rr & TOOLBAR_CHANGED) b_newToolbar = true; - - // We do this is one case only to remove an orphan recovery window + // We do this is one case only to remove an orphan recovery window #ifdef __ANDROID__ if (previous_expert && !g_bUIexpert) { androidForceFullRepaint(); @@ -6916,13 +6926,12 @@ void MyFrame::OnResume(wxPowerEvent &WXUNUSED(event)) { wxDateTime now = wxDateTime::Now(); wxLogMessage(_T("System resumed from suspend.")); - if ((now.GetTicks() - g_last_resume_ticks) > 5) { SystemEvents::GetInstance().evt_resume.Notify(); wxLogMessage("Restarting streams."); g_last_resume_ticks = now.GetTicks(); -//FIXME (dave) +// FIXME (dave) #if 0 if (g_pMUX) { g_pMUX->ClearStreams(); @@ -6959,7 +6968,7 @@ void MyFrame::RequestNewMasterToolbar(bool bforcenew) { bool b_reshow = true; if (g_MainToolbar) { - b_reshow = true; //g_MainToolbar->IsShown(); + b_reshow = true; // g_MainToolbar->IsShown(); float ff = fabs(g_MainToolbar->GetScaleFactor() - g_toolbar_scalefactor); if ((ff > 0.01f) || bforcenew) { g_MainToolbar->DestroyToolBar(); @@ -6976,8 +6985,8 @@ void MyFrame::RequestNewMasterToolbar(bool bforcenew) { #ifdef __WXOSX__ toolbarParent = GetPrimaryCanvas(); #endif - g_MainToolbar = new ocpnFloatingToolbarDialog(toolbarParent, wxPoint(-1, -1), orient, - g_toolbar_scalefactor); + g_MainToolbar = new ocpnFloatingToolbarDialog( + toolbarParent, wxPoint(-1, -1), orient, g_toolbar_scalefactor); g_MainToolbar->SetBackGroundColorString(_T("GREY3")); g_MainToolbar->SetToolbarHideMethod(TOOLBAR_HIDE_TO_FIRST_TOOL); g_MainToolbar->SetToolConfigString(g_toolbarConfig); @@ -6992,9 +7001,10 @@ void MyFrame::RequestNewMasterToolbar(bool bforcenew) { if (g_MainToolbar) { CreateMasterToolbar(); { - //g_MainToolbar->RestoreRelativePosition(g_maintoolbar_x, g_maintoolbar_y); + // g_MainToolbar->RestoreRelativePosition(g_maintoolbar_x, + // g_maintoolbar_y); g_MainToolbar->SetColorScheme(global_color_scheme); - //g_MainToolbar->Show(b_reshow && g_bshowToolbar); + // g_MainToolbar->Show(b_reshow && g_bshowToolbar); } } @@ -7651,7 +7661,6 @@ wxColor GetDimColor(wxColor c) { return wxColor(nrgb.red, nrgb.green, nrgb.blue); } - // A helper function to check for proper parameters of anchor // watch // @@ -7681,7 +7690,7 @@ double AnchorDistFix(double const d, double const AnchorPointMinDist, static const WORD MAX_CONSOLE_LINES = 500; // maximum mumber of lines the output console should have -//#ifdef _DEBUG +// #ifdef _DEBUG void RedirectIOToConsole() @@ -7734,7 +7743,7 @@ void RedirectIOToConsole() // ios::sync_with_stdio(); } -//#endif +// #endif #endif #ifdef __WXMSW__ @@ -8229,7 +8238,7 @@ void ApplyLocale() { } auto alert_dlg_active = - dynamic_cast(g_pais_alert_dialog_active); + dynamic_cast(g_pais_alert_dialog_active); if (alert_dlg_active) { alert_dlg_active->Destroy(); g_pais_alert_dialog_active = nullptr; @@ -8432,7 +8441,7 @@ void LoadS57() { pConfig->LoadS57Config(); ps52plib->SetPLIBColorScheme(global_color_scheme, ChartCtxFactory()); - if (gFrame){ + if (gFrame) { ps52plib->SetDisplayWidth(g_monitor_info[g_current_monitor].width); ps52plib->SetPPMM(g_BasePlatform->GetDisplayDPmm()); double dip_factor = g_BasePlatform->GetDisplayDIPMult(gFrame); @@ -8441,8 +8450,9 @@ void LoadS57() { } // preset S52 PLIB scale factors - ps52plib->SetScaleFactorExp(g_Platform->GetChartScaleFactorExp(g_ChartScaleFactor)); - ps52plib-> SetScaleFactorZoomMod(g_chart_zoom_modifier_vector); + ps52plib->SetScaleFactorExp( + g_Platform->GetChartScaleFactorExp(g_ChartScaleFactor)); + ps52plib->SetScaleFactorZoomMod(g_chart_zoom_modifier_vector); #ifdef ocpnUSE_GL @@ -8451,8 +8461,8 @@ void LoadS57() { extern GLenum g_texture_rectangle_format; extern OCPN_GLCaps *GL_Caps; - if (g_bopengl){ - if(GL_Caps){ + if (g_bopengl) { + if (GL_Caps) { wxString renderer = wxString(GL_Caps->Renderer.c_str()); ps52plib->SetGLRendererString(renderer); } @@ -8461,7 +8471,6 @@ void LoadS57() { glChartCanvas::s_b_useStencil, glChartCanvas::s_b_useStencilAP, glChartCanvas::s_b_useScissorTest, glChartCanvas::s_b_useFBO, g_b_EnableVBO, g_texture_rectangle_format, 1, 1); - } #endif @@ -8631,11 +8640,11 @@ void ParseAllENC(wxWindow *parent) { // prog->SetSize( sz ); DimeControl(prog); - #ifdef __WXOSX__ +#ifdef __WXOSX__ prog->ShowWindowModal(); - #else +#else prog->Show(); - #endif +#endif } // parse targets diff --git a/gui/src/options.cpp b/gui/src/options.cpp index 144fbd7c33..ff3d3da9ba 100644 --- a/gui/src/options.cpp +++ b/gui/src/options.cpp @@ -118,7 +118,6 @@ extern GLuint g_raster_format; #endif - #ifdef __linux__ #include "udev_rule_mgr.h" #endif @@ -132,13 +131,13 @@ extern GLuint g_raster_format; #endif #ifdef __WXOSX__ - #if wxCHECK_VERSION(3,2,0) - #define SLIDER_STYLE wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS - #else - #define SLIDER_STYLE wxSL_HORIZONTAL | wxSL_AUTOTICKS - #endif +#if wxCHECK_VERSION(3, 2, 0) +#define SLIDER_STYLE wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS +#else +#define SLIDER_STYLE wxSL_HORIZONTAL | wxSL_AUTOTICKS +#endif #else - #define SLIDER_STYLE wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS +#define SLIDER_STYLE wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS #endif wxString GetOCPNKnownLanguage(const wxString lang_canonical, @@ -400,8 +399,7 @@ void prepareSlider(wxSlider* slider) { // sort callback for Connections list Sort by priority. int wxCALLBACK SortConnectionOnPriority(wxIntPtr item1, wxIntPtr item2, - wxIntPtr list) -{ + wxIntPtr list) { wxListCtrl* lc = reinterpret_cast(list); wxListItem it1, it2; @@ -585,9 +583,11 @@ void OCPNChartDirPanel::SetSelected(bool selected) { m_bSelected = selected; if (selected) { - m_boxColour = wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_HIGHLIGHT); + m_boxColour = + wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_HIGHLIGHT); } else { - m_boxColour = wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW); + m_boxColour = + wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW); } Refresh(true); @@ -644,7 +644,8 @@ void OCPNChartDirPanel::OnPaint(wxPaintEvent& event) { wxFont* dFont = GetOCPNScaledFont_PlugIn(_("Dialog")); dc.SetFont(*dFont); - dc.SetTextForeground(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOWTEXT)); + dc.SetTextForeground( + wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOWTEXT)); int yd = height * 20 / 100; for (size_t i = 0; i < nameWrapped.GetCount(); i++) { @@ -658,7 +659,9 @@ void OCPNChartDirPanel::OnPaint(wxPaintEvent& event) { else { dc.SetBrush(wxBrush(m_boxColour)); - dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOWFRAME), 1)); + dc.SetPen(wxPen( + wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOWFRAME), + 1)); int offset = height / 10; dc.DrawRoundedRectangle(offset, offset, width - (2 * offset), @@ -669,7 +672,8 @@ void OCPNChartDirPanel::OnPaint(wxPaintEvent& event) { wxFont* dFont = GetOCPNScaledFont_PlugIn(_("Dialog")); dc.SetFont(*dFont); - dc.SetTextForeground(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOWTEXT)); + dc.SetTextForeground( + wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOWTEXT)); int yd = height * 20 / 100; for (size_t i = 0; i < nameWrapped.GetCount(); i++) { @@ -685,7 +689,6 @@ void OCPNChartDirPanel::OnPaint(wxPaintEvent& event) { ///////////////////////////////////////////////////////////////////////////////////// - static bool LoadAllPlugIns(bool load_enabled) { g_Platform->ShowBusySpinner(); bool b = PluginLoader::getInstance()->LoadAllPlugIns(load_enabled); @@ -1355,7 +1358,7 @@ void MMSI_Props_Panel::UpdateMMSIList(void) { void MMSI_Props_Panel::SetColorScheme(ColorScheme cs) { DimeControl(this); } // WX_DECLARE_OBJARRAY(wxBitmap, ArrayOfBitmaps); -//#include +// #include // WX_DEFINE_OBJARRAY(ArrayOfBitmaps); class OCPNFatCombo : public wxOwnerDrawnComboBox { @@ -1496,7 +1499,7 @@ END_EVENT_TABLE() options::options(wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style) - : pTrackRotateTime(0) { + : pTrackRotateTime(0) { Init(); pParent = parent; @@ -1507,7 +1510,7 @@ options::options(wxWindow* parent, wxWindowID id, const wxString& caption, SetFont(*dialogFont); CreateControls(); - RecalculateSize( size.x, size.y); + RecalculateSize(size.x, size.y); wxDEFINE_EVENT(EVT_COMPAT_OS_CHANGE, wxCommandEvent); GlobalVar compat_os(&g_compatOS); @@ -1516,8 +1519,9 @@ options::options(wxWindow* parent, wxWindowID id, const wxString& caption, PluginLoader::getInstance()->LoadAllPlugIns(false); m_pPlugInCtrl->ReloadPluginPanels(); }); - auto action = [&](wxCommandEvent &evt) { - g_persist_active_route = m_persist_active_route_chkbox->IsChecked(); }; + auto action = [&](wxCommandEvent& evt) { + g_persist_active_route = m_persist_active_route_chkbox->IsChecked(); + }; m_persist_active_route_chkbox->Bind(wxEVT_CHECKBOX, action); m_persist_active_route_chkbox->SetValue(g_persist_active_route); } @@ -1557,18 +1561,16 @@ void options::RecalculateSize(int hint_x, int hint_y) { // Protect against unreasonable small size // And also handle the empty config file init case. - if ((hint_x < 200) || (hint_y < 200)){ - + if ((hint_x < 200) || (hint_y < 200)) { // Constrain size on small displays int display_width, display_height; display_width = g_monitor_info[g_current_monitor].width; display_height = g_monitor_info[g_current_monitor].height; - if(display_height < 600){ - SetSize(wxSize(GetOCPNCanvasWindow()->GetSize() )); - } - else { - vectorPanel-> SetSizeHints(ps57Ctl); + if (display_height < 600) { + SetSize(wxSize(GetOCPNCanvasWindow()->GetSize())); + } else { + vectorPanel->SetSizeHints(ps57Ctl); Fit(); } } @@ -1659,7 +1661,6 @@ void options::Init(void) { m_pagePlugins = -1; m_pageConnections = -1; - auto loader = PluginLoader::getInstance(); b_haveWMM = loader && loader->IsPlugInAvailable(_T("WMM")); b_oldhaveWMM = b_haveWMM; @@ -1676,8 +1677,8 @@ void options::Init(void) { m_PluginCatalogMgrPanel = NULL; m_pNMEAForm = NULL; - //FIXME Do this in CTOR of connections dialog - //mSelectedConnection = NULL; + // FIXME Do this in CTOR of connections dialog + // mSelectedConnection = NULL; #ifdef __ANDROID__ m_scrollRate = 1; @@ -1703,7 +1704,7 @@ void options::Init(void) { dc.GetTextExtent(_T("H"), &width, &height, NULL, NULL, dialogFont); m_colourPickerDefaultSize = - wxSize(4 * height, height* 2 * OCPN_GetWinDIPScaleFactor()); + wxSize(4 * height, height * 2 * OCPN_GetWinDIPScaleFactor()); m_bcompact = false; @@ -1715,12 +1716,11 @@ void options::Init(void) { if (dsizemm < 80) // Probably and Android Phone, portrait mode m_bcompact = true; - auto sound_action = [] (ObservedEvt ev) { + auto sound_action = [](ObservedEvt ev) { auto sound = static_cast(ev.GetClientData()); delete sound; }; m_sound_done_listener.Init(m_on_sound_done, sound_action); - } #if defined(__GNUC__) && __GNUC__ < 8 @@ -1865,7 +1865,6 @@ void options::CreatePanel_NMEA(size_t parent, int border_size, comm_dialog = std::make_shared(m_pNMEAForm, this); } - void options::CreatePanel_Ownship(size_t parent, int border_size, int group_item_spacing) { itemPanelShip = AddPage(parent, _("Own ship")); @@ -1983,7 +1982,8 @@ void options::CreatePanel_Ownship(size_t parent, int border_size, new wxStaticText(itemPanelShip, wxID_STATIC, _("Distance Unit")); radarGrid->Add(unitText, 1, wxEXPAND | wxALL, group_item_spacing); - wxString pDistUnitsStrings[] = {_("Nautical miles"), _("Kilometers"), _("Minutes (time)")}; + wxString pDistUnitsStrings[] = {_("Nautical miles"), _("Kilometers"), + _("Minutes (time)")}; m_itemRadarRingsUnits = new wxChoice(itemPanelShip, ID_RADARDISTUNIT, wxDefaultPosition, m_pShipIconType->GetSize(), 3, pDistUnitsStrings); @@ -2014,9 +2014,8 @@ void options::CreatePanel_Ownship(size_t parent, int border_size, shipToActiveGrid->Add(shipToActiveText1, 1, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, border_size); - wxString LineStyleChoices[] = {_("Default"), _("Solid"), - _("Dot"), _("Long dash"), - _("Short dash")}; + wxString LineStyleChoices[] = {_("Default"), _("Solid"), _("Dot"), + _("Long dash"), _("Short dash")}; int LineStyleNChoices = sizeof(LineStyleChoices) / sizeof(wxString); m_shipToActiveStyle = new wxChoice(itemPanelShip, wxID_ANY, wxDefaultPosition, wxDefaultSize, @@ -2031,9 +2030,9 @@ void options::CreatePanel_Ownship(size_t parent, int border_size, wxString m_LineColorChoices[] = { _("Default color"), _("Black"), _("Dark Red"), _("Dark Green"), - _("Dark Yellow"), _("Dark Blue"), _("Dark Magenta"), _("Dark Cyan"), - _("Light Gray"), _("Dark Gray"), _("Red"), _("Green"), - _("Yellow"), _("Blue"), _("Magenta"), _("Cyan"), + _("Dark Yellow"), _("Dark Blue"), _("Dark Magenta"), _("Dark Cyan"), + _("Light Gray"), _("Dark Gray"), _("Red"), _("Green"), + _("Yellow"), _("Blue"), _("Magenta"), _("Cyan"), _("White")}; int LineColorNChoices = sizeof(m_LineColorChoices) / sizeof(wxString); m_shipToActiveColor = @@ -2142,7 +2141,7 @@ void options::CreatePanel_Ownship(size_t parent, int border_size, dispOwnShipCalcOptionsGrid->AddGrowableCol(1); -pSogCogFromLLCheckBox = + pSogCogFromLLCheckBox = new wxCheckBox(itemPanelShip, ID_SOGCOGFROMLLCHECKBOX, _("Calculate SOG and COG from position changes")); dispOwnShipCalcOptionsGrid->Add(pSogCogFromLLCheckBox, 1, wxALL, 5); @@ -2188,8 +2187,8 @@ void options::CreatePanel_Routes(size_t parent, int border_size, new wxStaticBoxSizer(activeRouteText, wxVERTICAL); m_persist_active_route_chkbox = new wxCheckBox( - itemPanelRoutes, wxID_ANY, - _("Persist active route, automatically activate on start up")); + itemPanelRoutes, wxID_ANY, + _("Persist active route, automatically activate on start up")); activeRouteSizer->Add(m_persist_active_route_chkbox, 0, wxALL, 5); Routes->Add(activeRouteSizer, 0, wxGROW | wxALL, border_size); @@ -2544,7 +2543,6 @@ void options::CreatePanel_ChartsLoad(size_t parent, int border_size, UpdateChartDirList(); chartPanel->Layout(); - } void options::UpdateChartDirList() { @@ -2869,7 +2867,8 @@ void options::OnConfigMouseSelected(wxMouseEvent& event) { wxPanel* panel = wxDynamicCast(win, wxPanel); if (panel) { if (panel == selectedPanel) { - panel->SetBackgroundColour(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_HIGHLIGHT)); + panel->SetBackgroundColour(wxSystemSettings::GetColour( + wxSystemColour::wxSYS_COLOUR_HIGHLIGHT)); ConfigPanel* cPanel = wxDynamicCast(panel, ConfigPanel); if (cPanel) m_selectedConfigPanelGUID = cPanel->GetConfigGUID(); } else @@ -2935,7 +2934,7 @@ void options::CreatePanel_Advanced(size_t parent, int border_size, #endif itemBoxSizerUI->Add(0, border_size * 3); itemBoxSizerUI->Add(0, border_size * 3); -#endif // ocpnUSE_GL +#endif // ocpnUSE_GL // Course Up display update period wxStaticText* crat = new wxStaticText(m_ChartDisplayPage, wxID_ANY, @@ -3256,7 +3255,6 @@ With a higher value, the same zoom level shows a more detailed chart.")); OpenGLSizer->Add(bOpenGL, inputFlags); bOpenGL->Enable(!g_bdisable_opengl && g_Platform->IsGLCapable()); - // spacer itemBoxSizerUI->Add(0, border_size * 3); itemBoxSizerUI->Add(0, border_size * 3); @@ -3271,7 +3269,7 @@ With a higher value, the same zoom level shows a more detailed chart.")); itemBoxSizerUI->Add(ChartBarSizer, 0, 0, 0); pChartBarEX = new wxCheckBox(m_ChartDisplayPage, -1, - _("Show extended chart bar information.")); + _("Show extended chart bar information.")); ChartBarSizer->Add(pChartBarEX, inputFlags); /* @@ -3393,10 +3391,10 @@ void options::CreatePanel_VectorCharts(size_t parent, int border_size, pCheck_SCAMIN->SetValue(FALSE); optionsColumn->Add(pCheck_SCAMIN, inputFlags); - optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, ""), - labelFlags); - pCheck_SuperSCAMIN = new wxCheckBox(ps57Ctl, ID_SUPERSCAMINCHECKBOX, - _("Additional detail reduction at Small Scale")); + optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, ""), labelFlags); + pCheck_SuperSCAMIN = + new wxCheckBox(ps57Ctl, ID_SUPERSCAMINCHECKBOX, + _("Additional detail reduction at Small Scale")); pCheck_SuperSCAMIN->SetValue(FALSE); optionsColumn->Add(pCheck_SuperSCAMIN, inputFlags); @@ -3536,7 +3534,7 @@ void options::CreatePanel_VectorCharts(size_t parent, int border_size, miscSizer->Add(pCheck_SOUNDG, inputFlags); pCheck_META = new wxCheckBox(ps57Ctl, ID_METACHECKBOX, - _("Chart Information Objects")); + _("Chart Information Objects")); pCheck_META->SetValue(FALSE); miscSizer->Add(pCheck_META, inputFlags); @@ -3581,10 +3579,10 @@ void options::CreatePanel_VectorCharts(size_t parent, int border_size, pCheck_SCAMIN->SetValue(FALSE); optionsColumn->Add(pCheck_SCAMIN, inputFlags); - optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, ""), - labelFlags); - pCheck_SuperSCAMIN = new wxCheckBox(ps57Ctl, ID_SUPERSCAMINCHECKBOX, - _("Additional detail reduction at Small Scale")); + optionsColumn->Add(new wxStaticText(ps57Ctl, wxID_ANY, ""), labelFlags); + pCheck_SuperSCAMIN = + new wxCheckBox(ps57Ctl, ID_SUPERSCAMINCHECKBOX, + _("Additional detail reduction at Small Scale")); pCheck_SuperSCAMIN->SetValue(FALSE); optionsColumn->Add(pCheck_SuperSCAMIN, inputFlags); @@ -3783,8 +3781,8 @@ void options::CreatePanel_ChartGroups(size_t parent, int border_size, // and we have the actual widgets in a separate class (because of its // complexity) - wxNotebook *chartsPageNotebook = (wxNotebook *)m_pListbook->GetPage(parent); - wxScrolledWindow *sw = new ChartGroupsUI(chartsPageNotebook); + wxNotebook* chartsPageNotebook = (wxNotebook*)m_pListbook->GetPage(parent); + wxScrolledWindow* sw = new ChartGroupsUI(chartsPageNotebook); sw->SetScrollRate(m_scrollRate, m_scrollRate); chartsPageNotebook->AddPage(sw, _("Chart Groups")); groupsPanel = dynamic_cast(sw); @@ -3900,7 +3898,6 @@ void ChartGroupsUI::CompletePanel(void) { wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(ChartGroupsUI::OnDeleteGroup), NULL, this); - wxBoxSizer* newDeleteGrp = new wxBoxSizer(wxVERTICAL); sizerGroups->Add(newDeleteGrp, 0, wxALL, m_border_size); @@ -4061,7 +4058,8 @@ void options::CreatePanel_Display(size_t parent, int border_size, wxBoxSizer* defaultBoatSpeedSizer = new wxBoxSizer(wxHORIZONTAL); boxDispStatusBar->Add(defaultBoatSpeedSizer, wxALL, group_item_spacing); - m_Text_def_boat_speed = new wxStaticText( pDisplayPanel, wxID_ANY, + m_Text_def_boat_speed = new wxStaticText( + pDisplayPanel, wxID_ANY, _("Default Boat Speed ") + "(" + getUsrSpeedUnit() + ") "); defaultBoatSpeedSizer->Add(m_Text_def_boat_speed, groupLabelFlagsHoriz); @@ -4504,10 +4502,11 @@ void options::CreatePanel_Units(size_t parent, int border_size, unitsSizer->Add(new wxStaticText(panelUnits, wxID_ANY, _("WindSpeed")), labelFlags); wxString pWindSpeedFormats[] = {_("Knots"), _("m/s"), _("Mph"), _("km/h")}; - int m_WindSpeedFormatsNChoices = sizeof(pWindSpeedFormats) / sizeof(wxString); - pWindSpeedFormat = - new wxChoice(panelUnits, ID_WINDSPEEDUNITCHOICE, wxDefaultPosition, - wxDefaultSize, m_WindSpeedFormatsNChoices, pWindSpeedFormats); + int m_WindSpeedFormatsNChoices = + sizeof(pWindSpeedFormats) / sizeof(wxString); + pWindSpeedFormat = new wxChoice( + panelUnits, ID_WINDSPEEDUNITCHOICE, wxDefaultPosition, wxDefaultSize, + m_WindSpeedFormatsNChoices, pWindSpeedFormats); unitsSizer->Add(pWindSpeedFormat, inputFlags); // depth units @@ -4612,69 +4611,59 @@ void options::CreatePanel_Units(size_t parent, int border_size, #endif } -class OCPNSoundPanel: public wxPanel -{ +class OCPNSoundPanel : public wxPanel { public: - OCPNSoundPanel( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, - wxString title, - wxString checkLegend, - wxString selectLegend, - wxString *pSoundFile - ); - - ~OCPNSoundPanel() { delete m_sound; } - - void OnButtonSelectSound(wxCommandEvent& event); - void OnButtonSPTestSound(wxCommandEvent& event); - wxString SelectSoundFile(); - void SetSoundFileLabel(wxString file); - wxCheckBox *GetCheckBox(){ return m_pCheck_Sound; } - wxString GetSoundFile(){ return m_sound_file;} - - wxCheckBox *m_pCheck_Sound; - wxSize m_small_button_size; - wxString m_sound_file; - wxString *m_pSoundFile; - wxStaticText *m_AudioFileNameText; - - wxButton* SelSound; - wxButton* TestSound; - OcpnSound *m_sound; - - /** Notified with a OCPN_Sound* pointer when sound has completed. */ - EventVar m_on_sp_sound_done; - - ObsListener m_sound_sp_done_listener; - bool m_soundPlaying; - - DECLARE_EVENT_TABLE() + OCPNSoundPanel(wxWindow* parent, wxWindowID id, const wxPoint& pos, + const wxSize& size, wxString title, wxString checkLegend, + wxString selectLegend, wxString* pSoundFile); + + ~OCPNSoundPanel() { delete m_sound; } + + void OnButtonSelectSound(wxCommandEvent& event); + void OnButtonSPTestSound(wxCommandEvent& event); + wxString SelectSoundFile(); + void SetSoundFileLabel(wxString file); + wxCheckBox* GetCheckBox() { return m_pCheck_Sound; } + wxString GetSoundFile() { return m_sound_file; } + + wxCheckBox* m_pCheck_Sound; + wxSize m_small_button_size; + wxString m_sound_file; + wxString* m_pSoundFile; + wxStaticText* m_AudioFileNameText; + + wxButton* SelSound; + wxButton* TestSound; + OcpnSound* m_sound; + + /** Notified with a OCPN_Sound* pointer when sound has completed. */ + EventVar m_on_sp_sound_done; + + ObsListener m_sound_sp_done_listener; + bool m_soundPlaying; + + DECLARE_EVENT_TABLE() }; #define ID_SELECTSOUND 9341 #define ID_TESTSOUND 9342 - BEGIN_EVENT_TABLE(OCPNSoundPanel, wxPanel) EVT_BUTTON(ID_SELECTSOUND, OCPNSoundPanel::OnButtonSelectSound) EVT_BUTTON(ID_TESTSOUND, OCPNSoundPanel::OnButtonSPTestSound) - END_EVENT_TABLE() -OCPNSoundPanel::OCPNSoundPanel( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, - wxString title, - wxString checkLegend, - wxString selectLegend, - wxString *pSoundFile) -:wxPanel(parent, id, pos, size, wxBORDER_NONE), - m_soundPlaying(false) -{ +OCPNSoundPanel::OCPNSoundPanel(wxWindow* parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + wxString title, wxString checkLegend, + wxString selectLegend, wxString* pSoundFile) + : wxPanel(parent, id, pos, size, wxBORDER_NONE), m_soundPlaying(false) { wxFont* pif = FontMgr::Get().GetFont(_T("Dialog")); - SetFont( *pif ); + SetFont(*pif); m_pSoundFile = pSoundFile; - if(pSoundFile) - m_sound_file = *pSoundFile; + if (pSoundFile) m_sound_file = *pSoundFile; m_sound = SoundFactory(); @@ -4683,21 +4672,17 @@ OCPNSoundPanel::OCPNSoundPanel( wxWindow *parent, wxWindowID id, const wxPoint & int font_size_y, font_descent, font_lead; GetTextExtent(_T("0"), NULL, &font_size_y, &font_descent, &font_lead); - m_small_button_size = - wxSize(-1, (int)(1.6 * (font_size_y + font_descent))); - + m_small_button_size = wxSize(-1, (int)(1.6 * (font_size_y + font_descent))); wxBoxSizer* wrapperSizer = new wxBoxSizer(wxVERTICAL); SetSizer(wrapperSizer); - wxStaticBox* StaticBox1 = - new wxStaticBox(this, wxID_ANY, title); + wxStaticBox* StaticBox1 = new wxStaticBox(this, wxID_ANY, title); wxStaticBoxSizer* StaticBoxSizer1 = - new wxStaticBoxSizer(StaticBox1, wxVERTICAL); + new wxStaticBoxSizer(StaticBox1, wxVERTICAL); wrapperSizer->Add(StaticBoxSizer1, 0, wxALL | wxEXPAND, border_size); - m_pCheck_Sound = new wxCheckBox(this, ID_ANCHORALERTAUDIO, - checkLegend); + m_pCheck_Sound = new wxCheckBox(this, ID_ANCHORALERTAUDIO, checkLegend); StaticBoxSizer1->Add(m_pCheck_Sound, 1, wxALL, group_item_spacing); // Sound file @@ -4706,10 +4691,11 @@ OCPNSoundPanel::OCPNSoundPanel( wxWindow *parent, wxWindowID id, const wxPoint & #ifdef __ANDROID__ // Count the likely number of lines in the wrapped file name // to set the default wxStaticText size. - ChartDirPanelHardBreakWrapper wrapper(this, m_sound_file, g_pOptions->GetSize().x * 8 / 10); + ChartDirPanelHardBreakWrapper wrapper(this, m_sound_file, + g_pOptions->GetSize().x * 8 / 10); wxArrayString LabelWrappedArray = wrapper.GetLineArray(); - for (unsigned int i=0 ; i < LabelWrappedArray.GetCount() ; i++){ - LabelWrapped += "\n"; + for (unsigned int i = 0; i < LabelWrappedArray.GetCount(); i++) { + LabelWrapped += "\n"; } LabelWrapped += "\n"; #endif @@ -4725,33 +4711,25 @@ OCPNSoundPanel::OCPNSoundPanel( wxWindow *parent, wxWindowID id, const wxPoint & soundSizer1->SetHGap(border_size * 2); StaticBoxSizer1->Add(soundSizer1, 1, wxALL | wxLEFT, border_size); - SelSound = new wxButton( - this, ID_SELECTSOUND, selectLegend, - wxDefaultPosition, m_small_button_size, 0); - soundSizer1->Add(SelSound, 0, wxALL | wxALIGN_RIGHT, - group_item_spacing); + SelSound = new wxButton(this, ID_SELECTSOUND, selectLegend, wxDefaultPosition, + m_small_button_size, 0); + soundSizer1->Add(SelSound, 0, wxALL | wxALIGN_RIGHT, group_item_spacing); soundSizer1->AddSpacer(group_item_spacing * 4); - TestSound = new wxButton( - this, ID_TESTSOUND, _("Test"), - wxDefaultPosition, m_small_button_size, 0); - soundSizer1->Add(TestSound, 0, wxALL | wxALIGN_RIGHT, - group_item_spacing); - auto sound_action = [this] (ObservedEvt ev) { - m_soundPlaying = false; - }; + TestSound = new wxButton(this, ID_TESTSOUND, _("Test"), wxDefaultPosition, + m_small_button_size, 0); + soundSizer1->Add(TestSound, 0, wxALL | wxALIGN_RIGHT, group_item_spacing); + auto sound_action = [this](ObservedEvt ev) { m_soundPlaying = false; }; m_sound_sp_done_listener.Init(m_on_sp_sound_done, sound_action); - } -void OCPNSoundPanel::SetSoundFileLabel(wxString file) -{ - wxString soundLabel = wxString( " " + _("Audio file name:") + "\n " + - file); +void OCPNSoundPanel::SetSoundFileLabel(wxString file) { + wxString soundLabel = wxString(" " + _("Audio file name:") + "\n " + file); - ChartDirPanelHardBreakWrapper wrapper(this, soundLabel, g_pOptions->GetSize().x * 8 / 10); + ChartDirPanelHardBreakWrapper wrapper(this, soundLabel, + g_pOptions->GetSize().x * 8 / 10); wxArrayString LabelWrappedArray = wrapper.GetLineArray(); wxString LabelWrapped; - for (unsigned int i=0 ; i < LabelWrappedArray.GetCount() ; i++){ + for (unsigned int i = 0; i < LabelWrappedArray.GetCount(); i++) { if (i == 0) LabelWrapped += LabelWrappedArray[i].BeforeFirst('/'); else @@ -4763,8 +4741,6 @@ void OCPNSoundPanel::SetSoundFileLabel(wxString file) Layout(); } - - wxString OCPNSoundPanel::SelectSoundFile() { wxString sound_dir = g_Platform->GetSharedDataDir(); sound_dir.Append(_T("sounds")); @@ -4800,11 +4776,10 @@ void OCPNSoundPanel::OnButtonSelectSound(wxCommandEvent& event) { if (!sel_file.IsEmpty()) { m_sound_file = g_Platform->NormalizePath(sel_file); - if(m_pSoundFile) - *m_pSoundFile = m_sound_file; // Update global variable + if (m_pSoundFile) *m_pSoundFile = m_sound_file; // Update global variable SetSoundFileLabel(m_sound_file); - //g_anchorwatch_sound->Stop(); + // g_anchorwatch_sound->Stop(); } } @@ -4819,181 +4794,162 @@ void OCPNSoundPanel::OnButtonSPTestSound(wxCommandEvent& event) { } } - - - -void options::OnUXAudioEnableButtonClickAIS(wxCommandEvent &event) { +void options::OnUXAudioEnableButtonClickAIS(wxCommandEvent& event) { if (event.IsChecked()) - m_pCheck_AlertAudio->SetValue( true ); + m_pCheck_AlertAudio->SetValue(true); else { - if (!m_soundPanelSART->GetCheckBox()->GetValue() - && !m_soundPanelDSC->GetCheckBox()->GetValue()) - m_pCheck_AlertAudio->SetValue( false ); + if (!m_soundPanelSART->GetCheckBox()->GetValue() && + !m_soundPanelDSC->GetCheckBox()->GetValue()) + m_pCheck_AlertAudio->SetValue(false); } } -void options::OnUXAudioEnableButtonClickSART(wxCommandEvent &event) { +void options::OnUXAudioEnableButtonClickSART(wxCommandEvent& event) { if (event.IsChecked()) - m_pCheck_AlertAudio->SetValue( true ); + m_pCheck_AlertAudio->SetValue(true); else { - if (!m_soundPanelAIS->GetCheckBox()->GetValue() - && !m_soundPanelDSC->GetCheckBox()->GetValue()) - m_pCheck_AlertAudio->SetValue( false ); + if (!m_soundPanelAIS->GetCheckBox()->GetValue() && + !m_soundPanelDSC->GetCheckBox()->GetValue()) + m_pCheck_AlertAudio->SetValue(false); } } -void options::OnUXAudioEnableButtonClickDSC(wxCommandEvent &event) { +void options::OnUXAudioEnableButtonClickDSC(wxCommandEvent& event) { if (event.IsChecked()) - m_pCheck_AlertAudio->SetValue( true ); + m_pCheck_AlertAudio->SetValue(true); else { - if (!m_soundPanelAIS->GetCheckBox()->GetValue() - && !m_soundPanelSART->GetCheckBox()->GetValue()) - m_pCheck_AlertAudio->SetValue( false ); + if (!m_soundPanelAIS->GetCheckBox()->GetValue() && + !m_soundPanelSART->GetCheckBox()->GetValue()) + m_pCheck_AlertAudio->SetValue(false); } } void options::CreatePanel_Sounds(size_t parent, int border_size, int group_item_spacing) { + wxScrolledWindow* panelSounds = AddPage(parent, _("Sounds")); - wxScrolledWindow* panelSounds = AddPage(parent, _("Sounds")); + wxBoxSizer* wrapperSizer = new wxBoxSizer(wxVERTICAL); + panelSounds->SetSizer(wrapperSizer); + + // Anchor Alarm + m_soundPanelAnchor = new OCPNSoundPanel( + panelSounds, wxID_ANY, wxDefaultPosition, wxDefaultSize, + _("Anchor Alarm"), _("Play Sound on Anchor Alarm."), + _("Select Anchor Alarm Sound"), &g_anchorwatch_sound_file); + wrapperSizer->Add(m_soundPanelAnchor, 1, wxALL | wxEXPAND, border_size); + + // AIS Alert + m_soundPanelAIS = new OCPNSoundPanel( + panelSounds, wxID_ANY, wxDefaultPosition, wxDefaultSize, _("AIS Alert"), + _("Play Sound on AIS Alert."), _("Select AIS Alert Sound"), + &g_AIS_sound_file); + wrapperSizer->Add(m_soundPanelAIS, 1, wxALL | wxEXPAND, border_size); + + m_soundPanelAIS->GetCheckBox()->Connect( + wxEVT_COMMAND_CHECKBOX_CLICKED, + wxCommandEventHandler(options::OnUXAudioEnableButtonClickAIS), NULL, + this); - wxBoxSizer* wrapperSizer = new wxBoxSizer(wxVERTICAL); - panelSounds->SetSizer(wrapperSizer); - - // Anchor Alarm - m_soundPanelAnchor = new OCPNSoundPanel( panelSounds, wxID_ANY, - wxDefaultPosition, wxDefaultSize, - _("Anchor Alarm"), - _("Play Sound on Anchor Alarm."), - _("Select Anchor Alarm Sound"), - &g_anchorwatch_sound_file - ); - wrapperSizer->Add(m_soundPanelAnchor, 1, wxALL | wxEXPAND, border_size); - - - // AIS Alert - m_soundPanelAIS = new OCPNSoundPanel( panelSounds, wxID_ANY, - wxDefaultPosition, wxDefaultSize, - _("AIS Alert"), - _("Play Sound on AIS Alert."), - _("Select AIS Alert Sound"), - &g_AIS_sound_file - ); - wrapperSizer->Add(m_soundPanelAIS, 1, wxALL | wxEXPAND, border_size); - - m_soundPanelAIS->GetCheckBox()->Connect( - wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(options::OnUXAudioEnableButtonClickAIS), NULL, - this); - - // SART Alert - m_soundPanelSART = new OCPNSoundPanel( panelSounds, wxID_ANY, - wxDefaultPosition, wxDefaultSize, - _("SART Alert"), - _("Play Sound on AIS SART Alert."), - _("Select AIS SART Alert Sound"), - &g_SART_sound_file - ); - wrapperSizer->Add(m_soundPanelSART, 1, wxALL | wxEXPAND, border_size); - - m_soundPanelSART->GetCheckBox()->Connect( - wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(options::OnUXAudioEnableButtonClickSART), NULL, - this); - - // DSC Call - m_soundPanelDSC = new OCPNSoundPanel( panelSounds, wxID_ANY, - wxDefaultPosition, wxDefaultSize, - _("DSC Alert"), - _("Play Sound on DSC notification."), - _("Select DSC notification Sound"), - &g_DSC_sound_file - ); - wrapperSizer->Add(m_soundPanelDSC, 1, wxALL | wxEXPAND, border_size); - - m_soundPanelDSC->GetCheckBox()->Connect( - wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(options::OnUXAudioEnableButtonClickDSC), NULL, - this); - - // Sound Device Configuration - wxStaticBox* StatBoxSoundConfig = - new wxStaticBox(panelSounds, wxID_ANY, _("Sound Device Configuration")); - wxStaticBoxSizer* StatBoxSoundConfigSizer = - new wxStaticBoxSizer(StatBoxSoundConfig, wxVERTICAL); - wrapperSizer->Add(StatBoxSoundConfigSizer, 0, wxALL | wxEXPAND, border_size); - - auto sound = std::unique_ptr(SoundFactory()); - int deviceCount = sound->DeviceCount(); - wxLogMessage("options: got device count: %d", deviceCount); - if (deviceCount >= 1) { - wxArrayString labels; - for (int i = 0; i < deviceCount; i += 1) { - wxString label(sound->GetDeviceInfo(i)); - if (label == "") { - std::ostringstream stm; - stm << i; - label = _("Unknown device :") + stm.str(); - } - if (!sound->IsOutputDevice(i)) { - std::ostringstream stm; - stm << i; - label = _("Input device :") + stm.str(); - } - labels.Add(label); + // SART Alert + m_soundPanelSART = new OCPNSoundPanel( + panelSounds, wxID_ANY, wxDefaultPosition, wxDefaultSize, _("SART Alert"), + _("Play Sound on AIS SART Alert."), _("Select AIS SART Alert Sound"), + &g_SART_sound_file); + wrapperSizer->Add(m_soundPanelSART, 1, wxALL | wxEXPAND, border_size); + + m_soundPanelSART->GetCheckBox()->Connect( + wxEVT_COMMAND_CHECKBOX_CLICKED, + wxCommandEventHandler(options::OnUXAudioEnableButtonClickSART), NULL, + this); + + // DSC Call + m_soundPanelDSC = new OCPNSoundPanel( + panelSounds, wxID_ANY, wxDefaultPosition, wxDefaultSize, _("DSC Alert"), + _("Play Sound on DSC notification."), _("Select DSC notification Sound"), + &g_DSC_sound_file); + wrapperSizer->Add(m_soundPanelDSC, 1, wxALL | wxEXPAND, border_size); + + m_soundPanelDSC->GetCheckBox()->Connect( + wxEVT_COMMAND_CHECKBOX_CLICKED, + wxCommandEventHandler(options::OnUXAudioEnableButtonClickDSC), NULL, + this); + + // Sound Device Configuration + wxStaticBox* StatBoxSoundConfig = + new wxStaticBox(panelSounds, wxID_ANY, _("Sound Device Configuration")); + wxStaticBoxSizer* StatBoxSoundConfigSizer = + new wxStaticBoxSizer(StatBoxSoundConfig, wxVERTICAL); + wrapperSizer->Add(StatBoxSoundConfigSizer, 0, wxALL | wxEXPAND, border_size); + + auto sound = std::unique_ptr(SoundFactory()); + int deviceCount = sound->DeviceCount(); + wxLogMessage("options: got device count: %d", deviceCount); + if (deviceCount >= 1) { + wxArrayString labels; + for (int i = 0; i < deviceCount; i += 1) { + wxString label(sound->GetDeviceInfo(i)); + if (label == "") { + std::ostringstream stm; + stm << i; + label = _("Unknown device :") + stm.str(); + } + if (!sound->IsOutputDevice(i)) { + std::ostringstream stm; + stm << i; + label = _("Input device :") + stm.str(); } + labels.Add(label); + } // if sound device index is uninitialized, set to "default", if found. // Otherwise, set to 0 - int iDefault = labels.Index("default"); - - if (g_iSoundDeviceIndex == -1) { - if (iDefault >= 0) - g_iSoundDeviceIndex = iDefault; - else - g_iSoundDeviceIndex = 0; - } + int iDefault = labels.Index("default"); + if (g_iSoundDeviceIndex == -1) { + if (iDefault >= 0) + g_iSoundDeviceIndex = iDefault; + else + g_iSoundDeviceIndex = 0; + } - pSoundDeviceIndex = new wxChoice(); - if (pSoundDeviceIndex) { - pSoundDeviceIndex->Create(panelSounds, wxID_ANY, wxDefaultPosition, + pSoundDeviceIndex = new wxChoice(); + if (pSoundDeviceIndex) { + pSoundDeviceIndex->Create(panelSounds, wxID_ANY, wxDefaultPosition, wxDefaultSize, labels); - pSoundDeviceIndex->SetSelection(g_iSoundDeviceIndex); - pSoundDeviceIndex->Show(); - wxFlexGridSizer* pSoundDeviceIndexGrid = new wxFlexGridSizer(2); - StatBoxSoundConfigSizer->Add(pSoundDeviceIndexGrid, 0, wxALL | wxEXPAND, - group_item_spacing); + pSoundDeviceIndex->SetSelection(g_iSoundDeviceIndex); + pSoundDeviceIndex->Show(); + wxFlexGridSizer* pSoundDeviceIndexGrid = new wxFlexGridSizer(2); + StatBoxSoundConfigSizer->Add(pSoundDeviceIndexGrid, 0, wxALL | wxEXPAND, + group_item_spacing); - stSoundDeviceIndex = + stSoundDeviceIndex = new wxStaticText(panelSounds, wxID_STATIC, _("Sound Device")); - pSoundDeviceIndexGrid->Add(stSoundDeviceIndex, 0, wxALL, 5); - pSoundDeviceIndexGrid->Add(pSoundDeviceIndex, 0, wxALL, border_size); - } + pSoundDeviceIndexGrid->Add(stSoundDeviceIndex, 0, wxALL, 5); + pSoundDeviceIndexGrid->Add(pSoundDeviceIndex, 0, wxALL, border_size); } + } #ifndef __ANDROID__ - if ((bool)dynamic_cast(SoundFactory())) { - wxBoxSizer* pSoundSizer = new wxBoxSizer(wxVERTICAL); - StatBoxSoundConfigSizer->Add(pSoundSizer, 0, wxALL | wxEXPAND, group_item_spacing); - pCmdSoundString = + if ((bool)dynamic_cast(SoundFactory())) { + wxBoxSizer* pSoundSizer = new wxBoxSizer(wxVERTICAL); + StatBoxSoundConfigSizer->Add(pSoundSizer, 0, wxALL | wxEXPAND, + group_item_spacing); + pCmdSoundString = new wxTextCtrl(panelSounds, wxID_ANY, _T( "" ), wxDefaultPosition, wxSize(450, -1), wxTE_LEFT); - pSoundSizer->Add( + pSoundSizer->Add( new wxStaticText(panelSounds, wxID_ANY, _("Audio Play command:")), 0, wxALIGN_LEFT | wxALL); - pSoundSizer->Add(pCmdSoundString, 1, wxEXPAND | wxALIGN_LEFT, border_size); - } + pSoundSizer->Add(pCmdSoundString, 1, wxEXPAND | wxALIGN_LEFT, border_size); + } #endif - if (!deviceCount) - StatBoxSoundConfig->Hide(); + if (!deviceCount) StatBoxSoundConfig->Hide(); #ifdef __ANDROID__ - stSoundDeviceIndex->Hide(); - pSoundDeviceIndex->Hide(); + stSoundDeviceIndex->Hide(); + pSoundDeviceIndex->Hide(); #endif - } void options::CreatePanel_MMSI(size_t parent, int border_size, @@ -5050,7 +5006,7 @@ void options::CreatePanel_AIS(size_t parent, int border_size, pCPAGrid->Add(m_pCheck_CPA_Warn, 0, wxALL, group_item_spacing); m_pText_CPA_Warn = - new wxTextCtrl(panelAIS, -1,"TEXT ", wxDefaultPosition, wxSize(-1, -1)); + new wxTextCtrl(panelAIS, -1, "TEXT ", wxDefaultPosition, wxSize(-1, -1)); pCPAGrid->Add(m_pText_CPA_Warn, 0, wxALL | wxALIGN_RIGHT, group_item_spacing); m_pCheck_CPA_Warn->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, @@ -5110,11 +5066,11 @@ void options::CreatePanel_AIS(size_t parent, int border_size, group_item_spacing); m_pCheck_Sync_OCOG_ACOG = new wxCheckBox( - panelAIS, -1, _("Sync AIS arrow length with own ship's COG predictor")); + panelAIS, -1, _("Sync AIS arrow length with own ship's COG predictor")); pDisplayGrid->Add(m_pCheck_Sync_OCOG_ACOG, 1, wxALL, group_item_spacing); - m_pCheck_Sync_OCOG_ACOG->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(options::OnSyncCogPredClick), - NULL, this); + m_pCheck_Sync_OCOG_ACOG->Connect( + wxEVT_COMMAND_CHECKBOX_CLICKED, + wxCommandEventHandler(options::OnSyncCogPredClick), NULL, this); wxStaticText* pStatic_Dummy4a = new wxStaticText(panelAIS, -1, _T("")); pDisplayGrid->Add(pStatic_Dummy4a, 1, wxALL, group_item_spacing); @@ -5251,17 +5207,16 @@ void options::CreatePanel_AIS(size_t parent, int border_size, this); wxButton* m_pPlay_Sound = - new wxButton(panelAIS, -1, _("Test AIS Alert Sound"), - wxDefaultPosition, m_small_button_size, 0); - pAlertGrid->Add(m_pPlay_Sound, 0, wxALL | wxALIGN_RIGHT, group_item_spacing); + new wxButton(panelAIS, -1, _("Test AIS Alert Sound"), wxDefaultPosition, + m_small_button_size, 0); + pAlertGrid->Add(m_pPlay_Sound, 0, wxALL | wxALIGN_RIGHT, group_item_spacing); - m_pPlay_Sound->Connect( - wxEVT_COMMAND_BUTTON_CLICKED, - wxCommandEventHandler(options::OnButtonTestSound), NULL, - this); + m_pPlay_Sound->Connect(wxEVT_COMMAND_BUTTON_CLICKED, + wxCommandEventHandler(options::OnButtonTestSound), + NULL, this); - //wxStaticText* pStatic_Dummy5b = new wxStaticText(panelAIS, -1, _T("")); - //pAlertGrid->Add(pStatic_Dummy5b, 1, wxALL, group_item_spacing); + // wxStaticText* pStatic_Dummy5b = new wxStaticText(panelAIS, -1, _T("")); + // pAlertGrid->Add(pStatic_Dummy5b, 1, wxALL, group_item_spacing); m_pCheck_Alert_Moored = new wxCheckBox( panelAIS, -1, _("Suppress Alerts for anchored/moored targets")); @@ -5466,8 +5421,8 @@ void options::CreatePanel_UI(size_t parent, int border_size, pZoomButtons->Hide(); #endif - pInlandEcdis = new wxCheckBox(itemPanelFont, ID_INLANDECDISBOX, - _("Use Inland ECDIS")); + pInlandEcdis = + new wxCheckBox(itemPanelFont, ID_INLANDECDISBOX, _("Use Inland ECDIS")); miscOptions->Add(pInlandEcdis, 0, wxALL, border_size); wxButton* itemEcdisHelp = @@ -5558,9 +5513,9 @@ void options::CreatePanel_UI(size_t parent, int border_size, m_pSlider_ENCText_Factor->GetHandle()->setStyleSheet(getQtStyleSheet()); #endif - sliderSizer->Add( - new wxStaticText(itemPanelFont, wxID_ANY, _("Mouse wheel zoom sensitivity")), - inputFlags); + sliderSizer->Add(new wxStaticText(itemPanelFont, wxID_ANY, + _("Mouse wheel zoom sensitivity")), + inputFlags); m_pMouse_Zoom_Slider = new MouseZoomSlider(itemPanelFont, m_sliderSize); sliderSizer->Add(m_pMouse_Zoom_Slider, 0, wxALL, border_size); @@ -5570,15 +5525,14 @@ void options::CreatePanel_UI(size_t parent, int border_size, void options::OnAlertEnableButtonClick(wxCommandEvent& event) { m_pCheck_AlertAudio->Enable(event.IsChecked()); - if (!event.IsChecked()) - m_pCheck_AlertAudio->SetValue( false ); + if (!event.IsChecked()) m_pCheck_AlertAudio->SetValue(false); } void options::OnAlertAudioEnableButtonClick(wxCommandEvent& event) { if (event.IsChecked()) { - m_soundPanelAIS->GetCheckBox()->SetValue( true ); - m_soundPanelSART->GetCheckBox()->SetValue( true ); - m_soundPanelDSC->GetCheckBox()->SetValue( true ); + m_soundPanelAIS->GetCheckBox()->SetValue(true); + m_soundPanelSART->GetCheckBox()->SetValue(true); + m_soundPanelDSC->GetCheckBox()->SetValue(true); } } @@ -5843,8 +5797,7 @@ void options::CreateControls(void) { } wxString ConnTab = _("Connections"); - if (g_Platform->GetDisplayDIPMult(gFrame) < 1) - ConnTab = _("Connect"); + if (g_Platform->GetDisplayDIPMult(gFrame) < 1) ConnTab = _("Connect"); m_pageConnections = CreatePanel(ConnTab); #ifndef __ANDROID__ @@ -5866,8 +5819,7 @@ void options::CreateControls(void) { CreatePanel_Routes(m_pageShips, border_size, group_item_spacing); wxString UITab = _("User Interface"); - if (g_Platform->GetDisplayDIPMult(gFrame) < 1) - UITab = _("User"); + if (g_Platform->GetDisplayDIPMult(gFrame) < 1) UITab = _("User"); m_pageUI = CreatePanel(UITab); CreatePanel_UI(m_pageUI, border_size, group_item_spacing); @@ -5898,9 +5850,8 @@ void options::CreateControls(void) { #ifndef __WXGTK__ // The s57 chart panel is the one which controls the minimum width required // to avoid horizontal scroll bars - //vectorPanel->SetSizeHints(ps57Ctl); + // vectorPanel->SetSizeHints(ps57Ctl); #endif - } void options::SetInitialPage(int page_sel, int sub_page) { @@ -6165,8 +6116,7 @@ void options::SetInitialSettings(void) { if (pPreserveScale) pPreserveScale->SetValue(g_bPreserveScaleOnX); pPlayShipsBells->SetValue(g_bPlayShipsBells); - if (pCmdSoundString) - pCmdSoundString->SetValue(g_CmdSoundString); + if (pCmdSoundString) pCmdSoundString->SetValue(g_CmdSoundString); if (pSoundDeviceIndex) pSoundDeviceIndex->SetSelection(g_iSoundDeviceIndex); // pFullScreenToolbar->SetValue( g_bFullscreenToolbar ); @@ -6230,7 +6180,7 @@ void options::SetInitialSettings(void) { m_pText_COG_Predictor->SetValue(s); m_pCheck_Sync_OCOG_ACOG->SetValue(g_bSyncCogPredictors); - if(g_bSyncCogPredictors) m_pText_COG_Predictor->Disable(); + if (g_bSyncCogPredictors) m_pText_COG_Predictor->Disable(); m_pCheck_Show_Tracks->SetValue(g_bAISShowTracks); @@ -6270,13 +6220,11 @@ void options::SetInitialSettings(void) { if (g_bAIS_CPA_Alert) { m_pCheck_AlertAudio->Enable(); m_pCheck_AlertAudio->SetValue(g_bAIS_CPA_Alert_Audio); - } - else { + } else { m_pCheck_AlertAudio->Disable(); m_pCheck_AlertAudio->SetValue(false); } - m_pCheck_Alert_Moored->SetValue(g_bAIS_CPA_Alert_Suppress_Moored); m_pCheck_Ack_Timout->SetValue(g_bAIS_ACK_Timeout); @@ -6305,22 +6253,21 @@ void options::SetInitialSettings(void) { wxString screenmm; if (!g_config_display_size_manual) { pRBSizeAuto->SetValue(TRUE); - for (const auto &mm : g_monitor_info) { + for (const auto& mm : g_monitor_info) { screenmm.Append(wxString::Format("%zu,", mm.width_mm)); } - screenmm.RemoveLast(); //Strip last comma + screenmm.RemoveLast(); // Strip last comma pScreenMM->Disable(); } else { - for (const auto &mm : g_config_display_size_mm) { + for (const auto& mm : g_config_display_size_mm) { screenmm.Append(wxString::Format("%zu,", mm)); } - screenmm.RemoveLast(); //Strip last comma + screenmm.RemoveLast(); // Strip last comma pRBSizeManual->SetValue(TRUE); } pScreenMM->SetValue(screenmm); - pDepthUnitSelect->SetSelection(g_nDepthUnitDisplay); UpdateOptionsUnits(); // sets depth values using the user's unit preference @@ -6331,7 +6278,6 @@ void options::SetInitialSettings(void) { s.Printf(_T("%d"), g_nAutoHideToolbar); pToolbarHideSecs->SetValue(s); - // Serial ports delete m_pSerialArray; @@ -6557,10 +6503,10 @@ void options::UpdateOptionsUnits(void) { void options::OnSizeAutoButton(wxCommandEvent& event) { wxString screenmm; - for (const auto &mm : g_monitor_info) { + for (const auto& mm : g_monitor_info) { screenmm.Append(wxString::Format("%zu,", mm.width_mm)); } - screenmm.RemoveLast(); //Strip last comma + screenmm.RemoveLast(); // Strip last comma pScreenMM->SetValue(screenmm); pScreenMM->Disable(); g_config_display_size_manual = FALSE; @@ -6569,15 +6515,15 @@ void options::OnSizeAutoButton(wxCommandEvent& event) { void options::OnSizeManualButton(wxCommandEvent& event) { wxString screenmm; if (g_config_display_size_mm.size() > 0 && g_config_display_size_mm[0] > 0) { - for (const auto &mm : g_config_display_size_mm) { + for (const auto& mm : g_config_display_size_mm) { screenmm.Append(wxString::Format("%zu,", mm)); } } else { - for (const auto &mm : g_monitor_info) { + for (const auto& mm : g_monitor_info) { screenmm.Append(wxString::Format("%zu,", mm.width_mm)); } } - screenmm.RemoveLast(); //Strip last comma + screenmm.RemoveLast(); // Strip last comma pScreenMM->SetValue(screenmm); pScreenMM->Enable(); g_config_display_size_manual = TRUE; @@ -6594,12 +6540,11 @@ void options::OnCPAWarnClick(wxCommandEvent& event) { } } -void options::OnSyncCogPredClick(wxCommandEvent &event) { +void options::OnSyncCogPredClick(wxCommandEvent& event) { if (m_pCheck_Sync_OCOG_ACOG->GetValue()) { m_pText_COG_Predictor->SetValue(m_pText_OSCOG_Predictor->GetValue()); m_pText_COG_Predictor->Disable(); - } - else { + } else { wxString s; s.Printf(_T("%4.0f"), g_ShowCOG_Mins); m_pText_COG_Predictor->SetValue(s); @@ -6835,10 +6780,9 @@ void options::UpdateWorkArrayFromDisplayPanel(void) { } } - void options::OnApplyClick(wxCommandEvent& event) { //::wxBeginBusyCursor(); - //FIXME This function is in ConnectionsDialog StopBTScan(); + // FIXME This function is in ConnectionsDialog StopBTScan(); // Start with the stuff that requires intelligent validation. @@ -6902,7 +6846,7 @@ void options::OnApplyClick(wxCommandEvent& event) { g_bOverruleScaMin = pScaMinOverruleChckB->GetValue(); // Any Font changes? - if (m_bfontChanged){ + if (m_bfontChanged) { #ifdef ocpnUSE_GL if (gFrame->GetPrimaryCanvas()->GetglCanvas()) { gFrame->GetPrimaryCanvas()->GetglCanvas()->ResetGridFont(); @@ -6962,7 +6906,7 @@ void options::OnApplyClick(wxCommandEvent& event) { wxString screenmm = pScreenMM->GetValue(); wxStringTokenizer tkz(screenmm, _T( "," )); g_config_display_size_mm.clear(); - while(tkz.HasMoreTokens()){ + while (tkz.HasMoreTokens()) { wxString token = tkz.GetNextToken(); long mm = -1; if (token.ToLong(&mm) && mm > 0) { @@ -7126,10 +7070,10 @@ void options::OnApplyClick(wxCommandEvent& event) { g_colourOwnshipRangeRingsColour.Blue()); // Sounds - g_bAIS_GCPA_Alert_Audio = m_soundPanelAIS->GetCheckBox()->GetValue(); - g_bAIS_SART_Alert_Audio = m_soundPanelSART->GetCheckBox()->GetValue(); - g_bAIS_DSC_Alert_Audio = m_soundPanelDSC->GetCheckBox()->GetValue(); - g_bAnchor_Alert_Audio = m_soundPanelAnchor->GetCheckBox()->GetValue(); + g_bAIS_GCPA_Alert_Audio = m_soundPanelAIS->GetCheckBox()->GetValue(); + g_bAIS_SART_Alert_Audio = m_soundPanelSART->GetCheckBox()->GetValue(); + g_bAIS_DSC_Alert_Audio = m_soundPanelDSC->GetCheckBox()->GetValue(); + g_bAnchor_Alert_Audio = m_soundPanelAnchor->GetCheckBox()->GetValue(); // AIS Parameters // CPA Box @@ -7167,21 +7111,19 @@ void options::OnApplyClick(wxCommandEvent& event) { // Check for exceptions in MMSI properties for (unsigned int i = 0; i < g_MMSI_Props_Array.GetCount(); i++) { if (pAISTarget->MMSI == g_MMSI_Props_Array[i]->MMSI) { - MmsiProperties *props = g_MMSI_Props_Array[i]; + MmsiProperties* props = g_MMSI_Props_Array[i]; if (TRACKTYPE_NEVER == props->TrackType) { pAISTarget->b_show_track = false; break; - } - else if (TRACKTYPE_ALWAYS == props->TrackType) { + } else if (TRACKTYPE_ALWAYS == props->TrackType) { pAISTarget->b_show_track = true; break; - } - else + } else break; } } // Check for any persistently tracked target, force b_show_track ON - std::map::iterator it; + std::map::iterator it; it = g_pAIS->m_persistent_tracks.find(pAISTarget->MMSI); if (it != g_pAIS->m_persistent_tracks.end()) pAISTarget->b_show_track = true; @@ -7234,8 +7176,7 @@ void options::OnApplyClick(wxCommandEvent& event) { g_ChartScaleFactorExp = g_Platform->GetChartScaleFactorExp(g_ChartScaleFactor); - g_MarkScaleFactorExp = - g_Platform->GetMarkScaleFactorExp(g_ChartScaleFactor); + g_MarkScaleFactorExp = g_Platform->GetMarkScaleFactorExp(g_ChartScaleFactor); g_ShipScaleFactor = m_pSlider_Ship_Factor->GetValue(); g_ShipScaleFactorExp = g_Platform->GetChartScaleFactorExp(g_ShipScaleFactor); g_ENCSoundingScaleFactor = m_pSlider_Text_Factor->GetValue(); @@ -7246,13 +7187,12 @@ void options::OnApplyClick(wxCommandEvent& event) { MouseZoom::ui_to_config(g_mouse_zoom_sensitivity_ui); // Only reload the icons if user has actually visted the UI page - if(m_bVisitLang) - if (pWayPointMan) - WayPointmanGui(*pWayPointMan).ReloadRoutepointIcons(); + if (m_bVisitLang) + if (pWayPointMan) WayPointmanGui(*pWayPointMan).ReloadRoutepointIcons(); - //FIXME Move these two - //g_NMEAAPBPrecision = m_choicePrecision->GetCurrentSelection(); - //g_TalkerIdText = m_TalkerIdText->GetValue().MakeUpper(); + // FIXME Move these two + // g_NMEAAPBPrecision = m_choicePrecision->GetCurrentSelection(); + // g_TalkerIdText = m_TalkerIdText->GetValue().MakeUpper(); #ifdef ocpnUSE_GL if (g_bopengl != pOpenGL->GetValue()) m_returnChanges |= GL_CHANGED; @@ -7377,8 +7317,7 @@ void options::OnApplyClick(wxCommandEvent& event) { if ((stateHash != ps52plib->GetStateHash()) || bUserStdChange) m_returnChanges |= S52_CHANGED; - if (bchange_scale) - m_returnChanges |= S52_CHANGED; + if (bchange_scale) m_returnChanges |= S52_CHANGED; } // User Interface Panel @@ -7427,7 +7366,7 @@ void options::OnApplyClick(wxCommandEvent& event) { m_returnChanges |= TOOLBAR_CHANGED; // And keep config in sync - //if (m_pPlugInCtrl) m_pPlugInCtrl->UpdatePluginsOrder(); FIXME(leamas) + // if (m_pPlugInCtrl) m_pPlugInCtrl->UpdatePluginsOrder(); FIXME(leamas) g_pi_manager->UpdateConfig(); // PlugIns may have added panels @@ -7768,7 +7707,6 @@ void options::OnButtonmigrateClick(wxCommandEvent& event) { } void options::OnButtonEcdisHelp(wxCommandEvent& event) { - wxString testFile = "/doc/iECDIS/index.html"; if (!::wxFileExists(testFile)) { @@ -7778,20 +7716,17 @@ void options::OnButtonEcdisHelp(wxCommandEvent& event) { _("Would you like to visit the iECDIS Manual website for more " "information?"); - if (wxID_YES == - OCPNMessageBox(NULL, msg, _("Inland ECDIS Manual"), wxYES_NO | wxCENTER, 60)) { + if (wxID_YES == OCPNMessageBox(NULL, msg, _("Inland ECDIS Manual"), + wxYES_NO | wxCENTER, 60)) { wxLaunchDefaultBrowser("https://opencpn-manuals.github.io/inland-ecdis"); } } else { #ifdef __WXMSW__ - wxLaunchDefaultBrowser("file:///" + *GetpSharedDataLocation() + - testFile); + wxLaunchDefaultBrowser("file:///" + *GetpSharedDataLocation() + testFile); #else - wxLaunchDefaultBrowser("file://" + *GetpSharedDataLocation() + - testFile); + wxLaunchDefaultBrowser("file://" + *GetpSharedDataLocation() + testFile); #endif } - } void options::OnButtoncompressClick(wxCommandEvent& event) { @@ -7973,7 +7908,6 @@ void options::OnFontChoice(wxCommandEvent& event) { event.Skip(); } - void options::OnChooseFont(wxCommandEvent& event) { #ifdef __ANDROID__ androidDisableRotation(); @@ -8006,8 +7940,7 @@ void options::OnChooseFont(wxCommandEvent& event) { m_bfontChanged = true; OnFontChoice(event); } - } - else + } else #endif { #ifdef __WXGTK__ @@ -8021,7 +7954,8 @@ void options::OnChooseFont(wxCommandEvent& event) { #ifdef __WXQT__ // Make sure that font dialog will fit on the screen without scrolling - // We do this by setting the dialog font size "small enough" to show "n" lines + // We do this by setting the dialog font size "small enough" to show "n" + // lines wxSize proposed_size = GetSize(); float n_lines = 30; float font_size = dialogFont->GetPointSize(); @@ -8240,8 +8174,7 @@ void options::DoOnPageChange(size_t page) { // Look explicitely to see if .mo is available wxString test_dir = lang_dir + lang_suffix; - if (!wxDir::Exists(test_dir)) - continue; + if (!wxDir::Exists(test_dir)) continue; m_itemLangListBox->Append(loc_lang_name); } @@ -8270,8 +8203,10 @@ void options::DoOnPageChange(size_t page) { if (ltest.IsLoaded(_T("opencpn"))) { auto x = wxLocale::GetLanguageInfo(lang_list[it]); wxString s0; - if (x) s0 = x->CanonicalName; - else continue; + if (x) + s0 = x->CanonicalName; + else + continue; wxString sl = wxLocale::GetLanguageName(lang_list[it]); if (wxNOT_FOUND == lang_array.Index(s0)) { lang_array.Add(s0); @@ -8335,9 +8270,8 @@ void options::DoOnPageChange(size_t page) { // Build the PlugIn Manager Panel ::wxBeginBusyCursor(); - m_pPlugInCtrl = - new PluginListPanel(itemPanelPlugins, ID_PANELPIM, wxDefaultPosition, - wxDefaultSize); + m_pPlugInCtrl = new PluginListPanel(itemPanelPlugins, ID_PANELPIM, + wxDefaultPosition, wxDefaultSize); m_pPlugInCtrl->SetScrollRate(m_scrollRate, m_scrollRate); itemBoxSizerPanelPlugins->Add(m_pPlugInCtrl, 01, wxEXPAND | wxGROW | wxALL, 4); @@ -8403,8 +8337,7 @@ void options::OnButtonTestSound(wxCommandEvent& event) { auto sound = SoundFactory(); auto cmd_sound = dynamic_cast(sound); if (cmd_sound) cmd_sound->SetCmd(g_CmdSoundString.mb_str()); - sound->SetFinishedCallback( - [&](void* snd) { m_on_sound_done.Notify(snd); }); + sound->SetFinishedCallback([&](void* snd) { m_on_sound_done.Notify(snd); }); sound->Load(m_soundPanelAIS->GetSoundFile(), g_iSoundDeviceIndex); sound->Play(); } @@ -8459,7 +8392,8 @@ wxString GetOCPNKnownLanguage(wxString lang_canonical, wxString& lang_dir) { dir_suffix = _T("pt_PT"); return_string = wxString("Português", wxConvUTF8); - } else if ((lang_canonical == _T("pt_BR")) || (lang_canonical == _T("pt_BR"))) { + } else if ((lang_canonical == _T("pt_BR")) || + (lang_canonical == _T("pt_BR"))) { dir_suffix = _T("pt_BR"); return_string = wxString("Português Brasileiro", wxConvUTF8); @@ -8491,37 +8425,42 @@ wxString GetOCPNKnownLanguage(wxString lang_canonical, wxString& lang_dir) { dir_suffix = _T("hu_HU"); return_string = wxString("Magyar", wxConvUTF8); - } else if ((lang_canonical == _T("zh_TW")) || (lang_canonical == _T("zh_TW"))) { + } else if ((lang_canonical == _T("zh_TW")) || + (lang_canonical == _T("zh_TW"))) { dir_suffix = _T("zh_TW"); return_string = wxString("正體字", wxConvUTF8); - } else if ((lang_canonical == _T("zh_CN")) || (lang_canonical == _T("zh_CN"))) { - dir_suffix = _T("zh_CN"); - return_string = wxString("Simplified Chinese", wxConvUTF8); + } else if ((lang_canonical == _T("zh_CN")) || + (lang_canonical == _T("zh_CN"))) { + dir_suffix = _T("zh_CN"); + return_string = wxString("Simplified Chinese", wxConvUTF8); } else if ((lang_canonical == _T("ca_ES")) || (lang_canonical == _T("ca"))) { dir_suffix = _T("ca_ES"); return_string = wxString("Catalan", wxConvUTF8); - } else if ((lang_canonical == _T("gl_ES")) || (lang_canonical == _T("gl_ES"))) { + } else if ((lang_canonical == _T("gl_ES")) || + (lang_canonical == _T("gl_ES"))) { dir_suffix = _T("gl_ES"); return_string = wxString("Galician", wxConvUTF8); - } else if ((lang_canonical == _T("ja_JP")) || (lang_canonical == _T("ja_JP"))) { + } else if ((lang_canonical == _T("ja_JP")) || + (lang_canonical == _T("ja_JP"))) { dir_suffix = _T("ja_JP"); return_string = wxString("Japanese", wxConvUTF8); - } else if ((lang_canonical == _T("vi_VN")) || (lang_canonical == _T("vi_VN"))) { + } else if ((lang_canonical == _T("vi_VN")) || + (lang_canonical == _T("vi_VN"))) { dir_suffix = _T("vi_VN"); return_string = wxString("Vietnamese", wxConvUTF8); } else { dir_suffix = lang_canonical; const wxLanguageInfo* info = wxLocale::FindLanguageInfo(lang_canonical); - if(info) - return_string = info->Description; + if (info) + return_string = info->Description; else - return_string = lang_canonical; + return_string = lang_canonical; } lang_dir = dir_suffix; @@ -8529,7 +8468,6 @@ wxString GetOCPNKnownLanguage(wxString lang_canonical, wxString& lang_dir) { return return_string; } - wxString GetOCPNKnownLanguage(const wxString lang_canonical) { wxString lang_dir; return GetOCPNKnownLanguage(lang_canonical, lang_dir); @@ -8567,8 +8505,7 @@ EVT_NOTEBOOK_PAGE_CHANGED( ChartGroupsUI::OnGroupPageChange) // This should work under Windows :-( END_EVENT_TABLE() -ChartGroupsUI::ChartGroupsUI(wxWindow* parent) - : wxScrolledWindow(parent) { +ChartGroupsUI::ChartGroupsUI(wxWindow* parent) : wxScrolledWindow(parent) { m_GroupSelectedPage = -1; m_pActiveChartsTree = 0; pParent = parent; @@ -8612,7 +8549,8 @@ void ChartGroupsUI::PopulateTrees(void) { if (!dirname.IsEmpty()) dir_array.Add(dirname); } - PopulateTreeCtrl(allAvailableCtl->GetTreeCtrl(), dir_array, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), + PopulateTreeCtrl(allAvailableCtl->GetTreeCtrl(), dir_array, + wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), dialogFont); m_pActiveChartsTree = allAvailableCtl->GetTreeCtrl(); @@ -8729,7 +8667,7 @@ void ChartGroupsUI::OnRemoveChartItem(wxCommandEvent& event) { int group_item_index = FindGroupBranch(pGroup, ptree, id, &branch_adder); if (group_item_index >= 0) { - ChartGroupElement &pelement = + ChartGroupElement& pelement = pGroup->m_element_array[group_item_index]; bool b_duplicate = FALSE; for (unsigned int k = 0; k < pelement.m_missing_name_array.size(); @@ -8890,7 +8828,7 @@ int ChartGroupsUI::FindGroupBranch(ChartGroup* pGroup, wxTreeCtrl* ptree, unsigned int target_item_index = -1; for (unsigned int i = 0; i < pGroup->m_element_array.size(); i++) { - const wxString &target = pGroup->m_element_array[i].m_element_name; + const wxString& target = pGroup->m_element_array[i].m_element_name; if (branch_name == target) { target_item_index = i; break; @@ -8916,7 +8854,7 @@ void ChartGroupsUI::OnNodeExpanded(wxTreeEvent& event) { if (target_item_index < 0) return; const ChartGroupElement& target_element = pGroup->m_element_array[target_item_index]; - const wxString &branch_name = target_element.m_element_name; + const wxString& branch_name = target_element.m_element_name; // Walk the children of the expanded node, marking any items which appear in // the "missing" list @@ -8931,8 +8869,8 @@ void ChartGroupsUI::OnNodeExpanded(wxTreeEvent& event) { wxString target_string = full_root; target_string += ptree->GetItemText(child); - for (unsigned int k = 0; - k < target_element.m_missing_name_array.GetCount(); k++) { + for (unsigned int k = 0; k < target_element.m_missing_name_array.GetCount(); + k++) { if (target_element.m_missing_name_array[k] == target_string) { ptree->SetItemTextColour(child, wxColour(128, 128, 128)); break; @@ -8952,7 +8890,7 @@ void ChartGroupsUI::BuildNotebookPages(ChartGroupArray* pGroupArray) { wxString itemname; int nItems = pGroup->m_element_array.size(); for (int i = 0; i < nItems; i++) { - const wxString &itemname = pGroup->m_element_array[i].m_element_name; + const wxString& itemname = pGroup->m_element_array[i].m_element_name; if (!itemname.IsEmpty()) { wxDirItemData* dir_item = new wxDirItemData(itemname, itemname, TRUE); wxTreeItemId id = @@ -9042,7 +8980,6 @@ void options::OnRemoveTideDataLocation(wxCommandEvent& event) { } } - // OpenGLOptionsDlg enum { ID_BUTTON_REBUILD, ID_BUTTON_CLEAR }; @@ -9167,14 +9104,13 @@ int OpenGLOptionsDlg::GetTextureMemorySize(void) const { } void OpenGLOptionsDlg::Populate(void) { - m_cbTextureCompression->SetValue(g_GLOptions.m_bTextureCompression); /* disable caching if unsupported */ -// if (b_glEntryPointsSet && !s_glCompressedTexImage2D) { -// g_GLOptions.m_bTextureCompressionCaching = FALSE; -// m_cbTextureCompression->Disable(); -// m_cbTextureCompression->SetValue(FALSE); -// } + // if (b_glEntryPointsSet && !s_glCompressedTexImage2D) { + // g_GLOptions.m_bTextureCompressionCaching = FALSE; + // m_cbTextureCompression->Disable(); + // m_cbTextureCompression->SetValue(FALSE); + // } m_cbTextureCompressionCaching->Show(g_bGLexpert); m_memorySize->Show(g_bGLexpert); @@ -9310,9 +9246,11 @@ void CanvasConfigSelect::SetSelected(bool selected) { m_bSelected = selected; if (selected) { - m_boxColour = wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_HIGHLIGHT); + m_boxColour = + wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_HIGHLIGHT); } else { - m_boxColour = wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW); + m_boxColour = + wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW); } Refresh(true); @@ -9331,11 +9269,15 @@ void CanvasConfigSelect::OnPaint(wxPaintEvent& event) { if (m_bSelected) { dc.SetBrush(wxBrush(m_boxColour)); - dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_HIGHLIGHT), 3)); + dc.SetPen(wxPen( + wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_HIGHLIGHT), + 3)); dc.DrawRoundedRectangle(0, 0, width - 1, height - 1, height / 10); } else { dc.SetBrush(wxBrush(m_boxColour)); - dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_HIGHLIGHT), 3)); + dc.SetPen(wxPen( + wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_HIGHLIGHT), + 3)); dc.DrawRoundedRectangle(0, 0, width - 1, height - 1, height / 10); } diff --git a/gui/src/pluginmanager.cpp b/gui/src/pluginmanager.cpp index 3f2cca72be..49c2c479fe 100644 --- a/gui/src/pluginmanager.cpp +++ b/gui/src/pluginmanager.cpp @@ -38,8 +38,6 @@ #include #include - - #ifdef __MINGW32__ #undef IPV6STRICT // mingw FTBS fix: missing struct ip_mreq #include @@ -304,7 +302,7 @@ class BlacklistUI { m_defer = false; } - BlacklistUI() : m_defer(true){}; + BlacklistUI() : m_defer(true) {}; private: void show_msg(wxString msg) { @@ -504,8 +502,8 @@ static void gui_uninstall(const PlugInData* pic, const char* plugin) { static bool LoadAllPlugIns(bool load_enabled, bool keep_orphans = false) { g_Platform->ShowBusySpinner(); - bool b = PluginLoader::getInstance()->LoadAllPlugIns(load_enabled, - keep_orphans); + bool b = + PluginLoader::getInstance()->LoadAllPlugIns(load_enabled, keep_orphans); g_Platform->HideBusySpinner(); return b; } @@ -947,7 +945,8 @@ PlugInManager::PlugInManager(MyFrame* parent) { HandlePluginLoaderEvents(); InitCommListeners(); auto msg_sent_action = [](ObservedEvt ev) { - SendNMEASentenceToAllPlugIns(ev.GetString()); }; + SendNMEASentenceToAllPlugIns(ev.GetString()); + }; m_on_msg_sent_listener.Init(g_pRouteMan->on_message_sent, msg_sent_action); } PlugInManager::~PlugInManager() { @@ -3071,7 +3070,9 @@ wxString getUsrDistanceUnit_Plugin(int unit) { wxString getUsrSpeedUnit_Plugin(int unit) { return getUsrSpeedUnit(unit); } -wxString getUsrWindSpeedUnit_Plugin(int unit) { return getUsrWindSpeedUnit(unit); } +wxString getUsrWindSpeedUnit_Plugin(int unit) { + return getUsrWindSpeedUnit(unit); +} wxString getUsrTempUnit_Plugin(int unit) { return getUsrTempUnit(unit); } @@ -3271,7 +3272,8 @@ bool UpdateSingleWaypoint(PlugIn_Waypoint* pwaypoint) { if (prp) prp->ReLoadIcon(); auto canvas = gFrame->GetPrimaryCanvas(); - SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(), canvas->GetScaleValue()); + SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(), + canvas->GetScaleValue()); SelectItem* pFind = pSelect->FindSelection(ctx, lat_save, lon_save, SELTYPE_ROUTEPOINT); if (pFind) { @@ -3905,7 +3907,6 @@ void CatalogMgrPanel::OnUpdateButton(wxCommandEvent& event) { auto cataloghdlr = CatalogHandler::getInstance(); cataloghdlr->ClearCatalogData(); - // Reload all plugins, which will also update the status fields LoadAllPlugIns(false); @@ -4067,8 +4068,8 @@ std::vector GetInstalled() { } auto compare = [](const PlugInData* lhs, const PlugInData* rhs) { std::string slhs, srhs; - for (auto &cl : lhs->Key()) slhs += toupper(cl); - for (auto &cr : rhs->Key()) srhs += toupper(cr); + for (auto& cl : lhs->Key()) slhs += toupper(cl); + for (auto& cr : rhs->Key()) srhs += toupper(cr); return slhs.compare(srhs) < 0; }; std::sort(result.begin(), result.end(), compare); @@ -4116,7 +4117,7 @@ void PluginListPanel::ReloadPluginPanels() { if (safe_mode::get_mode()) { /** Add panels for installed, unloaded plugins. */ auto installed = PluginHandler::getInstance()->GetInstalldataPlugins(); - for (const auto& name : installed) AddPlugin(name) ; + for (const auto& name : installed) AddPlugin(name); } else { /* The catalog entries. */ auto available = getCompatiblePlugins(); @@ -4130,10 +4131,11 @@ void PluginListPanel::ReloadPluginPanels() { // Sort on case-insensitive name struct CompSort { - bool operator()(const PluginMetadata& lhs, const PluginMetadata rhs) const { + bool operator()(const PluginMetadata& lhs, + const PluginMetadata rhs) const { std::string slhs, srhs; - for (auto &cl : lhs.name) slhs += toupper(cl); - for (auto &cr : rhs.name) srhs += toupper(cr); + for (auto& cl : lhs.name) slhs += toupper(cl); + for (auto& cr : rhs.name) srhs += toupper(cr); return slhs.compare(srhs) < 0; } } comp_sort; @@ -4327,7 +4329,6 @@ PluginPanel::PluginPanel(wxPanel* parent, const std::string& name) : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE), m_is_safe_panel(true) { - m_PluginListPanel = dynamic_cast(parent); wxASSERT(m_PluginListPanel != 0); wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL); @@ -4355,14 +4356,13 @@ PluginPanel::PluginPanel(wxPanel* parent, const std::string& name) top_horizontal->Add(m_info_btn); m_pButtonUninstall = new wxButton(this, wxID_ANY, _("Uninstall"), wxDefaultPosition, wxDefaultSize, 0); - top_horizontal->Add(m_pButtonUninstall, 0, - wxALIGN_CENTER_VERTICAL | wxALL, 2); + top_horizontal->Add(m_pButtonUninstall, 0, wxALIGN_CENTER_VERTICAL | wxALL, + 2); auto uninstall = [&](wxCommandEvent ev) { auto n = m_pName->GetLabel().ToStdString(); - int result = OCPNMessageBox(gFrame, - std::string(_("Uninstall plugin ")) + n + "?", - _("Un-Installation"), - wxICON_QUESTION | wxOK | wxCANCEL); + int result = + OCPNMessageBox(gFrame, std::string(_("Uninstall plugin ")) + n + "?", + _("Un-Installation"), wxICON_QUESTION | wxOK | wxCANCEL); if (result != wxID_OK) return; PluginHandler::getInstance()->ClearInstallData(n); m_PluginListPanel->ReloadPluginPanels(); @@ -4509,7 +4509,7 @@ PluginPanel::PluginPanel(wxPanel* parent, wxWindowID id, const wxPoint& pos, if (m_plugin.m_status == PluginStatus::ManagedInstallAvailable || m_plugin.m_status == PluginStatus::System || (m_plugin.m_status == PluginStatus::Unmanaged && - !m_plugin.m_managed_metadata.is_orphan) ) { + !m_plugin.m_managed_metadata.is_orphan)) { m_pVersion->Hide(); } m_pVersion->Bind(wxEVT_LEFT_DOWN, &PluginPanel::OnPluginSelected, this); @@ -4598,8 +4598,10 @@ PluginPanel::PluginPanel(wxPanel* parent, wxWindowID id, const wxPoint& pos, m_itemStatusIconBitmap = new wxStaticBitmap(this, wxID_ANY, statusBitmap); m_itemStatusIconBitmap->SetToolTip(message_by_status(stat)); - m_itemStatusIconBitmap->Bind(wxEVT_LEFT_DOWN, &PluginPanel::OnPluginSelected, this); - m_itemStatusIconBitmap->Bind(wxEVT_LEFT_UP, &PluginPanel::OnPluginSelectedUp, this); + m_itemStatusIconBitmap->Bind(wxEVT_LEFT_DOWN, &PluginPanel::OnPluginSelected, + this); + m_itemStatusIconBitmap->Bind(wxEVT_LEFT_UP, &PluginPanel::OnPluginSelectedUp, + this); itemBoxSizer01->Add(m_itemStatusIconBitmap, 0, wxEXPAND | wxALL, 20); @@ -4619,7 +4621,7 @@ PluginPanel::PluginPanel(wxPanel* parent, wxWindowID id, const wxPoint& pos, PluginPanel::PluginPanel(wxPanel* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, PluginMetadata md) - : PluginPanel(parent, id, pos, size, PlugInData(md)){}; + : PluginPanel(parent, id, pos, size, PlugInData(md)) {}; PluginPanel::~PluginPanel() { Unbind(wxEVT_LEFT_DOWN, &PluginPanel::OnPluginSelected, this); @@ -4719,8 +4721,7 @@ void PluginPanel::SetSelected(bool selected) { unInstallPossible = false; // Orphan plugins can usually be uninstalled, at best effort. - if (m_plugin.m_managed_metadata.is_orphan) - unInstallPossible = true; + if (m_plugin.m_managed_metadata.is_orphan) unInstallPossible = true; m_pButtonUninstall->Show(unInstallPossible); @@ -4785,7 +4786,7 @@ void PluginPanel::SetSelected(bool selected) { SetActionLabel(label); const auto plugin_name = m_plugin.m_common_name.ToStdString(); if (ocpn::exists(PluginHandler::ImportedMetadataPath(plugin_name))) { - m_pButtonAction->Hide(); + m_pButtonAction->Hide(); } Layout(); @@ -4905,13 +4906,12 @@ void PluginPanel::OnPluginAction(wxCommandEvent& event) { return; } -static void SetWindowFontStyle(wxWindow* window, wxFontStyle style) { +static void SetWindowFontStyle(wxWindow* window, wxFontStyle style) { auto font = window->GetFont(); font.SetStyle(style); window->SetFont(font); } - void PluginPanel::SetEnabled(bool enabled) { if (m_is_safe_panel) return; PluginLoader::getInstance()->SetEnabled(m_plugin.m_common_name, enabled); @@ -5511,7 +5511,7 @@ bool ChartPlugInWrapper::RenderRegionViewOnGL(const wxGLContext& glc, glChartCanvas::DisableClipRegion(); } //! empty - } // for + } // for delete r; } } else @@ -5580,7 +5580,7 @@ bool ChartPlugInWrapper::RenderRegionViewOnGLNoText( glChartCanvas::DisableClipRegion(); } //! empty - } // for + } // for delete r; } @@ -7748,7 +7748,8 @@ bool UpdateSingleWaypointEx(PlugIn_Waypoint_Ex* pwaypoint) { if (prp) prp->ReLoadIcon(); auto canvas = gFrame->GetPrimaryCanvas(); - SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(), canvas->GetScaleValue()); + SelectCtx ctx(canvas->m_bShowNavobjects, canvas->GetCanvasTrueScale(), + canvas->GetScaleValue()); SelectItem* pFind = pSelect->FindSelection(ctx, lat_save, lon_save, SELTYPE_ROUTEPOINT); if (pFind) { diff --git a/include/ocpn_plugin.h b/include/ocpn_plugin.h index 273e7ca4e8..a14952ab49 100644 --- a/include/ocpn_plugin.h +++ b/include/ocpn_plugin.h @@ -601,11 +601,13 @@ class DECL_EXP opencpn_plugin_118 : public opencpn_plugin_117 { /// should draw only when priority is OVERLAY_LEGACY (0) /// \return true if overlay was rendered, false otherwise #ifdef _MSC_VER - virtual bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp, - int canvasIndex, int priority = -1); + virtual bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, + PlugIn_ViewPort *vp, int canvasIndex, + int priority = -1); #else - virtual bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp, - int canvasIndex, int priority); + virtual bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, + PlugIn_ViewPort *vp, int canvasIndex, + int priority); bool RenderGLOverlayMultiCanvas(wxGLContext *pcontext, PlugIn_ViewPort *vp, int canvas_ix) override { @@ -613,8 +615,6 @@ class DECL_EXP opencpn_plugin_118 : public opencpn_plugin_117 { } #endif - - /// Render plugin overlay over chart canvas in non-OpenGL mode /// /// \param dc Reference to the "device context" @@ -627,14 +627,13 @@ class DECL_EXP opencpn_plugin_118 : public opencpn_plugin_117 { virtual bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex, int priority = -1); #else - virtual bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvas_ix, - int priority); + virtual bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, + int canvas_ix, int priority); bool RenderOverlayMultiCanvas(wxDC &dc, PlugIn_ViewPort *vp, int canvas_ix) override { return RenderOverlayMultiCanvas(dc, vp, canvas_ix, -1); } #endif - }; //------------------------------------------------------------------ // Route and Waypoint PlugIn support @@ -1581,7 +1580,6 @@ class DECL_EXP PlugIn_Route_Ex { bool m_isVisible; wxString m_Description; - Plugin_WaypointExList *pWaypointList; }; @@ -1674,7 +1672,7 @@ class ObservableListener; /** Facade for NavAddr2000. */ struct NMEA2000Id { const uint64_t id; - NMEA2000Id(int value) : id(static_cast(value)){}; + NMEA2000Id(int value) : id(static_cast(value)) {}; }; extern DECL_EXP std::shared_ptr GetListener( @@ -1683,7 +1681,7 @@ extern DECL_EXP std::shared_ptr GetListener( /** Facade for NavAddr0183. */ struct NMEA0183Id { const std::string id; - NMEA0183Id(const std::string &s) : id(s){}; + NMEA0183Id(const std::string &s) : id(s) {}; }; extern DECL_EXP std::shared_ptr GetListener( @@ -1692,7 +1690,7 @@ extern DECL_EXP std::shared_ptr GetListener( /** Facade for NavAddrSignalK. */ struct SignalkId { const std::string id; - SignalkId(const std::string &s) : id(s){}; + SignalkId(const std::string &s) : id(s) {}; }; extern DECL_EXP std::shared_ptr GetListener( @@ -1820,7 +1818,7 @@ extern DECL_EXP std::vector GetActiveDrivers(); /** Query driver attributes */ extern DECL_EXP const std::unordered_map - GetAttributes(DriverHandle handle); +GetAttributes(DriverHandle handle); /* Writing to a specific driver */ @@ -1830,13 +1828,12 @@ extern DECL_EXP const std::unordered_map * Return value is number of bytes queued for transmission. */ extern DECL_EXP CommDriverResult WriteCommDriver( - DriverHandle handle, - const std::shared_ptr > &payload); + DriverHandle handle, const std::shared_ptr> &payload); /** Send a PGN message to an NMEA2000 address. */ extern DECL_EXP CommDriverResult WriteCommDriverN2K( DriverHandle handle, int PGN, int destinationCANAddress, int priority, - const std::shared_ptr > &payload); + const std::shared_ptr> &payload); /** * Special NMEA2000 requirements @@ -1850,14 +1847,13 @@ extern DECL_EXP CommDriverResult WriteCommDriverN2K( extern DECL_EXP CommDriverResult RegisterTXPGNs(DriverHandle handle, std::vector &pgn_list); - // API 1.19 // /** Facade for NavAddrPluginMsg. */ struct PluginMsgId { const std::string id; - PluginMsgId(const std::string &s) : id(s){}; + PluginMsgId(const std::string &s) : id(s) {}; }; extern DECL_EXP std::shared_ptr GetListener( diff --git a/model/include/model/config_vars.h b/model/include/model/config_vars.h index 88a3357b58..122a039531 100644 --- a/model/include/model/config_vars.h +++ b/model/include/model/config_vars.h @@ -91,7 +91,7 @@ extern wxString g_GPS_Ident; extern wxString g_hostname; extern wxString g_SART_sound_file; extern wxString g_TalkerIdText; -extern wxString g_winPluginDir; // Base plugin directory on Windows. +extern wxString g_winPluginDir; // Base plugin directory on Windows. wxConfigBase* TheBaseConfig(); void InitBaseConfig(wxConfigBase* cfg); diff --git a/plugins/grib_pi/src/CursorData.cpp b/plugins/grib_pi/src/CursorData.cpp index 7618d22687..fcac452bf5 100644 --- a/plugins/grib_pi/src/CursorData.cpp +++ b/plugins/grib_pi/src/CursorData.cpp @@ -388,7 +388,8 @@ void CursorData::UpdateTrackingControls(void) { wxString::Format(_T("%2d bf"), (int)round(vk)))); } - m_tcWindDirection->SetValue(wxString::Format(_T("%03d%c"), (int)(ang), 0x00B0)); + m_tcWindDirection->SetValue( + wxString::Format(_T("%03d%c"), (int)(ang), 0x00B0)); } else { m_tcWindSpeed->SetValue(_("N/A")); m_tcWindSpeedBf->SetValue(_("N/A")); diff --git a/plugins/grib_pi/src/CustomGrid.cpp b/plugins/grib_pi/src/CustomGrid.cpp index 2ef0323335..a4850856dc 100644 --- a/plugins/grib_pi/src/CustomGrid.cpp +++ b/plugins/grib_pi/src/CustomGrid.cpp @@ -65,7 +65,7 @@ CustomGrid::CustomGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, wxFont labelfont = GetOCPNGUIScaledFont_PlugIn(_T("Dialog")).MakeBold(); SetLabelFont(labelfont); wxColour colour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - if(colour.Red() > 128) { + if (colour.Red() > 128) { GetGlobalColor(_T("DILG0"), &colour); GetGlobalColor(_T("GREEN1"), &m_greenColour); GetGlobalColor(_T("DILG1"), &m_greyColour); diff --git a/plugins/grib_pi/src/GrabberWin.cpp b/plugins/grib_pi/src/GrabberWin.cpp index c1e655e5e3..3c4d308c3a 100644 --- a/plugins/grib_pi/src/GrabberWin.cpp +++ b/plugins/grib_pi/src/GrabberWin.cpp @@ -36,9 +36,10 @@ //---------------------------------------------------------------------------- BEGIN_EVENT_TABLE(GribGrabberWin, wxPanel) EVT_MOUSE_EVENTS(GribGrabberWin::OnMouseEvent) - EVT_PAINT(GribGrabberWin::OnPaint) END_EVENT_TABLE() +EVT_PAINT(GribGrabberWin::OnPaint) +END_EVENT_TABLE() - GribGrabberWin::GribGrabberWin(wxWindow* parent) { + GribGrabberWin::GribGrabberWin(wxWindow* parent) { Create(parent); m_bLeftDown = false; @@ -132,7 +133,7 @@ void GribGrabberWin::OnPaint(wxPaintEvent& event) { void GribGrabberWin::Size() { wxBitmap bitmap = (wxBitmap(grabber)); - int height = GetParent()->GetSize().y - 2; //keep a small margin of 2 + int height = GetParent()->GetSize().y - 2; // keep a small margin of 2 int width = height / 2; wxImage scaled_image = bitmap.ConvertToImage(); diff --git a/plugins/grib_pi/src/GribOverlayFactory.cpp b/plugins/grib_pi/src/GribOverlayFactory.cpp index 88c5a24265..63b2839329 100644 --- a/plugins/grib_pi/src/GribOverlayFactory.cpp +++ b/plugins/grib_pi/src/GribOverlayFactory.cpp @@ -223,29 +223,28 @@ int adjustSpacing(int dialogSetSpacing) { //---------------------------------------------------------------------------------------------------------- GRIBOverlayFactory::GRIBOverlayFactory(GRIBUICtrlBar &dlg) : m_dlg(dlg), m_Settings(dlg.m_OverlaySettings) { - if (wxGetDisplaySize().x > 0) { - //#ifdef __WXGTK__ - // GdkScreen *screen = gdk_screen_get_default(); - // m_pixelMM = (double)gdk_screen_get_monitor_width_mm(screen, 0) / - // wxGetDisplaySize().x; - //#else + // #ifdef __WXGTK__ + // GdkScreen *screen = gdk_screen_get_default(); + // m_pixelMM = (double)gdk_screen_get_monitor_width_mm(screen, 0) / + // wxGetDisplaySize().x; + // #else m_pixelMM = (double)PlugInGetDisplaySizeMM() / wxMax(wxGetDisplaySize().x, wxGetDisplaySize().y); - //#endif + // #endif m_pixelMM = wxMax(.02, m_pixelMM); // protect against bad data } else m_pixelMM = 0.27; // semi-standard number... - //qDebug() << "m_pixelMM: " << m_pixelMM; + // qDebug() << "m_pixelMM: " << m_pixelMM; m_pGribTimelineRecordSet = NULL; m_last_vp_scale = 0.; m_oDC = NULL; - #if wxUSE_GRAPHICS_CONTEXT +#if wxUSE_GRAPHICS_CONTEXT m_gdc = NULL; - #endif +#endif m_Font_Message = NULL; InitColorsTable(); @@ -260,12 +259,11 @@ GRIBOverlayFactory::GRIBOverlayFactory(GRIBUICtrlBar &dlg) // Generate the wind arrow cache - if (m_pixelMM < 0.2){ + if (m_pixelMM < 0.2) { windArrowSize = 5.0 / m_pixelMM; // Target scaled arrow size - windArrowSize = wxMin(windArrowSize, - wxMax(wxGetDisplaySize().x, wxGetDisplaySize().y) / 20); - } - else + windArrowSize = wxMin( + windArrowSize, wxMax(wxGetDisplaySize().x, wxGetDisplaySize().y) / 20); + } else windArrowSize = 26; // Standard value for desktop int r = 5, i = 0; // wind is very light, draw a circle @@ -353,10 +351,10 @@ GRIBOverlayFactory::GRIBOverlayFactory(GRIBUICtrlBar &dlg) if (i == 0) { if (m_pixelMM > 0.2) { arrowSize = 5.0 / m_pixelMM; // Target scaled arrow size - arrowSize = wxMin(arrowSize, - wxMax(wxGetDisplaySize().x, wxGetDisplaySize().y) / 20); - dec1 = arrowSize / 6; // pointer length - dec2 = arrowSize / 8; // space between double lines + arrowSize = wxMin( + arrowSize, wxMax(wxGetDisplaySize().x, wxGetDisplaySize().y) / 20); + dec1 = arrowSize / 6; // pointer length + dec2 = arrowSize / 8; // space between double lines } else arrowSize = 26; // Standard value for desktop } else @@ -399,10 +397,10 @@ void GRIBOverlayFactory::SetMessageFont() { fo = GetOCPNGUIScaledFont_PlugIn(_T("Dialog")); #else fo = *OCPNGetFont(_("Dialog"), 10); - fo.SetPointSize((fo.GetPointSize() * g_ContentScaleFactor / OCPN_GetWinDIPScaleFactor())); + fo.SetPointSize( + (fo.GetPointSize() * g_ContentScaleFactor / OCPN_GetWinDIPScaleFactor())); #endif - if (m_Font_Message) - delete m_Font_Message; + if (m_Font_Message) delete m_Font_Message; m_Font_Message = new wxFont(fo); } @@ -434,16 +432,16 @@ bool GRIBOverlayFactory::RenderGLGribOverlay(wxGLContext *pcontext, if (m_oDC) { delete m_oDC; } - #ifdef ocpnUSE_GL - // Set the minimum line width - GLint parms[2]; - #ifndef USE_ANDROID_GLES2 - glGetIntegerv(GL_SMOOTH_LINE_WIDTH_RANGE, &parms[0]); - #else - glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, &parms[0]); - #endif - g_piGLMinSymbolLineWidth = wxMax(parms[0], 1); - #endif +#ifdef ocpnUSE_GL + // Set the minimum line width + GLint parms[2]; +#ifndef USE_ANDROID_GLES2 + glGetIntegerv(GL_SMOOTH_LINE_WIDTH_RANGE, &parms[0]); +#else + glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, &parms[0]); +#endif + g_piGLMinSymbolLineWidth = wxMax(parms[0], 1); +#endif m_oDC = new pi_ocpnDC(); } @@ -548,7 +546,8 @@ void GRIBOverlayFactory::SettingsIdToGribId(int i, int &idx, int &idy, bool GRIBOverlayFactory::DoRenderGribOverlay(PlugIn_ViewPort *vp) { if (!m_pGribTimelineRecordSet) { - DrawMessageWindow((m_Message), vp->pix_width, vp->pix_height, m_Font_Message); + DrawMessageWindow((m_Message), vp->pix_width, vp->pix_height, + m_Font_Message); return false; } @@ -556,8 +555,7 @@ bool GRIBOverlayFactory::DoRenderGribOverlay(PlugIn_ViewPort *vp) { if (!m_pdc) { m_TexFontNumbers.Build(*m_Font_Message); - if (m_oDC) - m_oDC->SetFont(*m_Font_Message); + if (m_oDC) m_oDC->SetFont(*m_Font_Message); } m_Message_Hiden.Empty(); @@ -575,8 +573,7 @@ bool GRIBOverlayFactory::DoRenderGribOverlay(PlugIn_ViewPort *vp) { for (int i = 0; i < GribOverlaySettings::SETTINGS_COUNT; i++) { if (i == GribOverlaySettings::WIND) { if (overlay) { /* render overlays first */ - if (m_dlg.m_bDataPlot[i]) - RenderGribOverlayMap(i, pGR, vp); + if (m_dlg.m_bDataPlot[i]) RenderGribOverlayMap(i, pGR, vp); } else { if (m_dlg.m_bDataPlot[i]) { RenderGribBarbedArrows(i, pGR, vp); @@ -626,7 +623,7 @@ bool GRIBOverlayFactory::DoRenderGribOverlay(PlugIn_ViewPort *vp) { .Append(m_Settings.GetUnitSymbol(GribOverlaySettings::PRESSURE)) .Append(_T(" ! ")); } - if(m_dlg.ProjectionEnabled()) { + if (m_dlg.ProjectionEnabled()) { int x, y; m_dlg.GetProjectedLatLon(x, y); DrawProjectedPosition(x, y); @@ -634,7 +631,7 @@ bool GRIBOverlayFactory::DoRenderGribOverlay(PlugIn_ViewPort *vp) { if (!m_Message_Hiden.IsEmpty()) m_Message_Hiden.Append(_T("\n")); m_Message_Hiden.Append(m_Message); DrawMessageWindow(m_Message_Hiden, vp->pix_width, vp->pix_height, - m_Font_Message); + m_Font_Message); if (m_dlg.m_highlight_latmax - m_dlg.m_highlight_latmin > 0.01 && m_dlg.m_highlight_lonmax - m_dlg.m_highlight_lonmin > 0.01) { @@ -643,17 +640,19 @@ bool GRIBOverlayFactory::DoRenderGribOverlay(PlugIn_ViewPort *vp) { GetCanvasPixLL(vp, &p2, m_dlg.m_highlight_latmax, m_dlg.m_highlight_lonmax); if (m_pdc) { m_pdc->SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT))); - m_pdc->SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT), - wxBRUSHSTYLE_CROSSDIAG_HATCH)); - m_pdc->DrawRectangle(p1.x,p1.y,p2.x-p1.x,p2.y-p1.y); + m_pdc->SetBrush( + wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT), + wxBRUSHSTYLE_CROSSDIAG_HATCH)); + m_pdc->DrawRectangle(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y); } else { - #ifdef ocpnUSE_GL - //GL +#ifdef ocpnUSE_GL + // GL m_oDC->SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT))); - m_oDC->SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT), - wxBRUSHSTYLE_CROSSDIAG_HATCH)); - m_oDC->DrawRectangle(p1.x,p1.y,p2.x-p1.x,p2.y-p1.y); - #endif + m_oDC->SetBrush( + wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT), + wxBRUSHSTYLE_CROSSDIAG_HATCH)); + m_oDC->DrawRectangle(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y); +#endif } } return true; @@ -680,10 +679,8 @@ void GRIBOverlayFactory::GetCalibratedGraphicColor(int settings, double val_in, settings == GribOverlaySettings::CLOUD) && val_in < 0.01) a = 0; - if ((settings == GribOverlaySettings::COMP_REFL) && - val_in < 5) - a = 0; - + if ((settings == GribOverlaySettings::COMP_REFL) && val_in < 5) a = 0; + GetGraphicColor(settings, val_in, r, g, b); } else r = 255, g = 255, b = 255, a = 0; @@ -881,7 +878,7 @@ bool GRIBOverlayFactory::CreateGribGLTexture(GribOverlay *pGO, int settings, glTexParameteri(texture_format, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(texture_format, GL_TEXTURE_MIN_FILTER, GL_LINEAR); -#if 0//ndef USE_ANDROID_GLES2 +#if 0 // ndef USE_ANDROID_GLES2 glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -1019,11 +1016,10 @@ static ColorMap AirTempMap[] = { {82, _T("#ff8100")}, {86, _T("#f1780c")}, {90, _T("#e26a23")}, {95, _T("#d5453c")}, {100, _T("#b53c59")}}; - - // Color map similar to: - // https://www.ospo.noaa.gov/data/sst/contour/global.cf.gif +// Color map similar to: +// https://www.ospo.noaa.gov/data/sst/contour/global.cf.gif static ColorMap SeaTempMap[] = { - {-2, _T("#cc04ae")}, {2, _T("#8f06e4")}, {6, _T("#486afa")}, + {-2, _T("#cc04ae")}, {2, _T("#8f06e4")}, {6, _T("#486afa")}, {10, _T("#00ffff")}, {15, _T("#00d54b")}, {19, _T("#59d800")}, {23, _T("#f2fc00")}, {27, _T("#ff1500")}, {32, _T("#ff0000")}, {36, _T("#d80000")}, {40, _T("#a90000")}, {44, _T("#870000")}, @@ -1780,8 +1776,7 @@ void GRIBOverlayFactory::RenderGribOverlayMap(int settings, GribRecord **pGR, _("Overlays not supported by this graphics hardware (Disable " "OpenGL)")); else { - if (!pGO->m_iTexture) - CreateGribGLTexture(pGO, settings, pGRA); + if (!pGO->m_iTexture) CreateGribGLTexture(pGO, settings, pGRA); if (pGO->m_iTexture) DrawGLTexture(pGO, pGRA, vp); @@ -1969,7 +1964,7 @@ void GRIBOverlayFactory::DrawNumbers(wxPoint p, double value, int settings, m_pdc->DrawBitmap(label, p.x, p.y, true); } else { #ifdef ocpnUSE_GL -#if 0 //ndef USE_ANDROID_GLES2 +#if 0 // ndef USE_ANDROID_GLES2 glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -2113,24 +2108,24 @@ void GRIBOverlayFactory::RenderGribParticles(int settings, GribRecord **pGR, lvp = *vp; } else // just panning, do quicker update - if (vp->clat != lvp.clat || vp->clon != lvp.clon) { - wxPoint p1, p2; - GetCanvasPixLL(vp, &p1, 0, 0); - GetCanvasPixLL(&lvp, &p2, 0, 0); + if (vp->clat != lvp.clat || vp->clon != lvp.clon) { + wxPoint p1, p2; + GetCanvasPixLL(vp, &p1, 0, 0); + GetCanvasPixLL(&lvp, &p2, 0, 0); - p1 -= p2; + p1 -= p2; - for (it = particles.begin(); it != particles.end(); it++) - for (int i = 0; i < it->m_HistorySize; i++) { - Particle::ParticleNode &n = it->m_History[i]; - float(&p)[2] = n.m_Pos; - if (p[0] == -10000) continue; + for (it = particles.begin(); it != particles.end(); it++) + for (int i = 0; i < it->m_HistorySize; i++) { + Particle::ParticleNode &n = it->m_History[i]; + float(&p)[2] = n.m_Pos; + if (p[0] == -10000) continue; - n.m_Screen[0] += p1.x; - n.m_Screen[1] += p1.y; - } - lvp = *vp; - } + n.m_Screen[0] += p1.x; + n.m_Screen[1] += p1.y; + } + lvp = *vp; + } double ptime = 0; @@ -2188,7 +2183,7 @@ void GRIBOverlayFactory::RenderGribParticles(int settings, GribRecord **pGR, float angr = ang / 180 * M_PI; p[0] = pp[0] + sinf(angr) * d / 60; p[1] = pp[1] + cosf(angr) * d / 60; -#else // spherical (close enough) +#else // spherical (close enough) float angr = ang / 180 * M_PI; float latr = pp[1] * M_PI / 180; float D = d / 3443; // earth radius in nm @@ -2420,16 +2415,16 @@ void GRIBOverlayFactory::DrawProjectedPosition(int x, int y) { wxDC &dc = *m_pdc; dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); - dc.DrawRectangle(x,y,20,20); - dc.DrawLine(x,y,x+20,y+20); - dc.DrawLine(x,y+20,x+20,y); + dc.DrawRectangle(x, y, 20, 20); + dc.DrawLine(x, y, x + 20, y + 20); + dc.DrawLine(x, y + 20, x + 20, y); } else { if (m_oDC) { m_oDC->SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); m_oDC->SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); - m_oDC->DrawRectangle(x-10,y-10,20,20); - m_oDC->StrokeLine(x-10,y-10,x+10,y+10); - m_oDC->StrokeLine(x-10,y+10,x+10,y-10); + m_oDC->DrawRectangle(x - 10, y - 10, 20, 20); + m_oDC->StrokeLine(x - 10, y - 10, x + 10, y + 10); + m_oDC->StrokeLine(x - 10, y + 10, x + 10, y - 10); } } } @@ -2438,7 +2433,7 @@ void GRIBOverlayFactory::DrawMessageWindow(wxString msg, int x, int y, wxFont *mfont) { if (msg.empty()) return; - int ScaleBare_H = 30;//futur : get the position/size from API? + int ScaleBare_H = 30; // futur : get the position/size from API? if (m_pdc) { wxDC &dc = *m_pdc; @@ -2549,9 +2544,9 @@ void GRIBOverlayFactory::drawWindArrowWithBarbs(int settings, int x, int y, if (m_Settings.Settings[settings].m_iBarbedColour == 1) arrowColor = GetGraphicColor(settings, vkn); -//TODO -// Needs investigation -// This conditional should not really be necessary, but is safe. +// TODO +// Needs investigation +// This conditional should not really be necessary, but is safe. #ifndef __MSVC__ float penWidth = .6 / m_pixelMM; #else @@ -2659,7 +2654,7 @@ void GRIBOverlayFactory::drawLineBuffer(LineBuffer &buffer, int x, int y, void GRIBOverlayFactory::DrawSingleGLTexture(GribOverlay *pGO, GribRecord *pGR, double uv[], double x, double y, double width, double height) { -#if 1//def __OCPN__ANDROID__ +#if 1 // def __OCPN__ANDROID__ glEnable(texture_format); @@ -2814,7 +2809,7 @@ void GRIBOverlayFactory::DrawGLTexture(GribOverlay *pGO, GribRecord *pGR, // optimization for non-rotated mercator, since longitude is linear if (vp->rotation == 0 && vp->m_projection_type == PI_PROJECTION_MERCATOR) - xsquares = 1; + xsquares = 1; // It is possible to have only 1 square when the viewport covers more than // 180 longitudes but there is more logic needed. This is simpler. @@ -2895,7 +2890,7 @@ void GRIBOverlayFactory::DrawGLTexture(GribOverlay *pGO, GribRecord *pGR, uv[6] = u3; uv[7] = v3; - if(u1 > u0){ + if (u1 > u0) { DrawSingleGLTexture(pGO, pGR, uv, x, y, xs, ys); } } diff --git a/plugins/grib_pi/src/GribRecord.cpp b/plugins/grib_pi/src/GribRecord.cpp index 9630188e11..1c5348a142 100644 --- a/plugins/grib_pi/src/GribRecord.cpp +++ b/plugins/grib_pi/src/GribRecord.cpp @@ -24,7 +24,7 @@ along with this program. If not, see . #include -//#include +// #include #include "GribRecord.h" diff --git a/plugins/grib_pi/src/GribRequestDialog.cpp b/plugins/grib_pi/src/GribRequestDialog.cpp index f21abdbde5..6cba2580ce 100644 --- a/plugins/grib_pi/src/GribRequestDialog.cpp +++ b/plugins/grib_pi/src/GribRequestDialog.cpp @@ -2711,7 +2711,8 @@ void GribRequestSetting::UpdateGribSizeEstimate() { wxString warningStr = ""; if (estimate / (1024 * 1024) > XYGRIB_MAX_DOWNLOADABLE_GRIB_SIZE_MB) { - warningStr = wxString::Format("(Warning GRIB exceeds %d MB limit)", XYGRIB_MAX_DOWNLOADABLE_GRIB_SIZE_MB); + warningStr = wxString::Format("(Warning GRIB exceeds %d MB limit)", + XYGRIB_MAX_DOWNLOADABLE_GRIB_SIZE_MB); } m_xygribPanel->m_sizeestimate_text->SetLabel( diff --git a/plugins/grib_pi/src/GribSettingsDialog.cpp b/plugins/grib_pi/src/GribSettingsDialog.cpp index 0221c59753..d1f8c0a854 100644 --- a/plugins/grib_pi/src/GribSettingsDialog.cpp +++ b/plugins/grib_pi/src/GribSettingsDialog.cpp @@ -196,8 +196,7 @@ void GribOverlaySettings::Read() { int units; pConf->Read(Name + _T ( "Units" ), &units, 0); int j; - for (j = 0; !unit_names[unittype[i]][j].empty(); j++) - ; + for (j = 0; !unit_names[unittype[i]][j].empty(); j++); Settings[i].m_Units = (units < 0 || units > j - 1) ? (SettingsType)0 : (SettingsType)units; @@ -815,7 +814,7 @@ void GribSettingsDialog::SetSettingsDialogSize() { sc->SetSize(wxSize(wxMin(scr.x, w), wxMin(scr.y, h))); // Constrain size on small displays - if(display_height < 600){ + if (display_height < 600) { sc->SetSize(scr.x, h); } diff --git a/plugins/grib_pi/src/GribUIDialog.cpp b/plugins/grib_pi/src/GribUIDialog.cpp index ec2af2df6a..c7403fae01 100644 --- a/plugins/grib_pi/src/GribUIDialog.cpp +++ b/plugins/grib_pi/src/GribUIDialog.cpp @@ -169,7 +169,8 @@ GRIBUICtrlBar::GRIBUICtrlBar(wxWindow *parent, wxWindowID id, : GRIBUICtrlBarBase(parent, id, title, pos, size, style) { pParent = parent; pPlugIn = ppi; - // Preinitialize the vierwport with an existing value, see https://github.com/OpenCPN/OpenCPN/pull/4002/files + // Preinitialize the vierwport with an existing value, see + // https://github.com/OpenCPN/OpenCPN/pull/4002/files m_vp = new PlugIn_ViewPort(pPlugIn->GetCurrentViewPort()); pReq_Dialog = NULL; m_bGRIBActiveFile = NULL; @@ -237,22 +238,22 @@ GRIBUICtrlBar::GRIBUICtrlBar(wxWindow *parent, wxWindowID id, // Read XyGrib related configuration pConf->SetPath(_T ( "/Settings/GRIB/XyGrib" )); - pConf->Read(_T( "AtmModelIndex" ), &xyGribConfig.atmModelIndex , 0); - pConf->Read(_T( "WaveModelIndex" ), &xyGribConfig.waveModelIndex , 0); - pConf->Read(_T( "ResolutionIndex" ), &xyGribConfig.resolutionIndex , 0); - pConf->Read(_T( "DurationIndex" ), &xyGribConfig.durationIndex , 0); - pConf->Read(_T( "RunIndex" ), &xyGribConfig.runIndex , 0); - pConf->Read(_T( "IntervalIndex" ), &xyGribConfig.intervalIndex , 0); - pConf->Read(_T( "Wind" ), &xyGribConfig.wind , true); - pConf->Read(_T( "Gust" ), &xyGribConfig.gust , true); - pConf->Read(_T( "Pressure" ), &xyGribConfig.pressure , false); - pConf->Read(_T( "Temperature" ), &xyGribConfig.temperature , true); - pConf->Read(_T( "Cape" ), &xyGribConfig.cape , false); - pConf->Read(_T( "Reflectivity" ), &xyGribConfig.reflectivity , false); - pConf->Read(_T( "CloudCover" ), &xyGribConfig.cloudCover , true); - pConf->Read(_T( "Precipitation" ), &xyGribConfig.precipitation , true); - pConf->Read(_T( "WaveHeight" ), &xyGribConfig.waveHeight , true); - pConf->Read(_T( "WindWaves" ), &xyGribConfig.windWaves , true); + pConf->Read(_T( "AtmModelIndex" ), &xyGribConfig.atmModelIndex, 0); + pConf->Read(_T( "WaveModelIndex" ), &xyGribConfig.waveModelIndex, 0); + pConf->Read(_T( "ResolutionIndex" ), &xyGribConfig.resolutionIndex, 0); + pConf->Read(_T( "DurationIndex" ), &xyGribConfig.durationIndex, 0); + pConf->Read(_T( "RunIndex" ), &xyGribConfig.runIndex, 0); + pConf->Read(_T( "IntervalIndex" ), &xyGribConfig.intervalIndex, 0); + pConf->Read(_T( "Wind" ), &xyGribConfig.wind, true); + pConf->Read(_T( "Gust" ), &xyGribConfig.gust, true); + pConf->Read(_T( "Pressure" ), &xyGribConfig.pressure, false); + pConf->Read(_T( "Temperature" ), &xyGribConfig.temperature, true); + pConf->Read(_T( "Cape" ), &xyGribConfig.cape, false); + pConf->Read(_T( "Reflectivity" ), &xyGribConfig.reflectivity, false); + pConf->Read(_T( "CloudCover" ), &xyGribConfig.cloudCover, true); + pConf->Read(_T( "Precipitation" ), &xyGribConfig.precipitation, true); + pConf->Read(_T( "WaveHeight" ), &xyGribConfig.waveHeight, true); + pConf->Read(_T( "WindWaves" ), &xyGribConfig.windWaves, true); } // init zone selection parameters m_ZoneSelMode = m_SavedZoneSelMode; @@ -344,7 +345,6 @@ GRIBUICtrlBar::~GRIBUICtrlBar() { pConf->Write(_T( "Precipitation" ), xyGribConfig.precipitation); pConf->Write(_T( "WaveHeight" ), xyGribConfig.waveHeight); pConf->Write(_T( "WindWaves" ), xyGribConfig.windWaves); - } delete m_vp; delete m_pTimelineSet; @@ -662,8 +662,7 @@ class FileCollector : public wxDirTraverser { wxArrayString GRIBUICtrlBar::GetFilesInDirectory() { wxArrayString file_array; - if (!wxDir::Exists(m_grib_dir)) - return file_array; + if (!wxDir::Exists(m_grib_dir)) return file_array; // Get an array of GRIB file names in the target directory, not descending // into subdirs @@ -760,8 +759,8 @@ void GRIBUICtrlBar::SetDialogsStyleSizePosition(bool force_recompute) { } if ((m_DialogStyle >> 1 == SEPARATED || !m_CDataIsShown) && - !m_HasCaption) { // Size and show grabber if necessary - Fit(); // each time CtrlData dialog will be alone + !m_HasCaption) { // Size and show grabber if necessary + Fit(); // each time CtrlData dialog will be alone m_gGrabber->Size(); // or separated m_gGrabber->Show(); } @@ -870,9 +869,9 @@ void GRIBUICtrlBar::OnAltitude(wxCommandEvent &event) { MenuAppend( amenu, ID_CTRLALTITUDE + 1000 + i, - m_OverlaySettings.GetAltitudeFromIndex( - i, m_OverlaySettings.Settings[GribOverlaySettings::PRESSURE] - .m_Units), + m_OverlaySettings.GetAltitudeFromIndex( + i, m_OverlaySettings.Settings[GribOverlaySettings::PRESSURE] + .m_Units), wxITEM_RADIO); } } @@ -944,16 +943,15 @@ void GRIBUICtrlBar::MenuAppend(wxMenu *menu, int id, wxString label, wxItemKind kind, wxBitmap bitmap, wxMenu *submenu) { wxMenuItem *item = new wxMenuItem(menu, id, label, _T(""), kind); - //add a submenu to this item if necessary - if (submenu) - item->SetSubMenu(submenu); - -/* Menu font do not work properly for MSW (wxWidgets 3.2.1) -#ifdef __WXMSW__ - wxFont *qFont = OCPNGetFont(_("Menu"), 10); - item->SetFont(*qFont); -#endif -*/ + // add a submenu to this item if necessary + if (submenu) item->SetSubMenu(submenu); + + /* Menu font do not work properly for MSW (wxWidgets 3.2.1) + #ifdef __WXMSW__ + wxFont *qFont = OCPNGetFont(_("Menu"), 10); + item->SetFont(*qFont); + #endif + */ #if defined(__WXMSW__) || defined(__WXGTK__) if (!bitmap.IsSameAs(wxNullBitmap)) item->SetBitmap(bitmap); @@ -982,18 +980,19 @@ void GRIBUICtrlBar::OnMouseEvent(wxMouseEvent &event) { m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WIND_VY + i) != wxNOT_FOUND)) || i == 0) { - MenuAppend(smenu, ID_CTRLALTITUDE + 1000 + i, - m_OverlaySettings.GetAltitudeFromIndex( - i, m_OverlaySettings - .Settings[GribOverlaySettings::PRESSURE] - .m_Units), - wxITEM_RADIO); + MenuAppend( + smenu, ID_CTRLALTITUDE + 1000 + i, + m_OverlaySettings.GetAltitudeFromIndex( + i, m_OverlaySettings.Settings[GribOverlaySettings::PRESSURE] + .m_Units), + wxITEM_RADIO); } } smenu->Check(ID_CTRLALTITUDE + 1000 + m_Altitude, true); MenuAppend( xmenu, wxID_ANY, _("Select geopotential altitude"), wxITEM_NORMAL, - GetScaledBitmap(wxBitmap(altitude), _T("altitude"), m_ScaledFactor),smenu); + GetScaledBitmap(wxBitmap(altitude), _T("altitude"), m_ScaledFactor), + smenu); } MenuAppend(xmenu, ID_BTNNOW, _("Now"), wxITEM_NORMAL, GetScaledBitmap(wxBitmap(now), _T("now"), m_ScaledFactor)); @@ -1082,8 +1081,7 @@ void GRIBUICtrlBar::SetViewPort(PlugIn_ViewPort *vp) { delete m_vp; m_vp = new PlugIn_ViewPort(*vp); - if (pReq_Dialog) - pReq_Dialog->OnVpChange(vp); + if (pReq_Dialog) pReq_Dialog->OnVpChange(vp); } void GRIBUICtrlBar::OnClose(wxCloseEvent &event) { @@ -1560,18 +1558,17 @@ GribTimelineRecordSet *GRIBUICtrlBar::GetTimeLineRecordSet(wxDateTime time) { return set; } -void GRIBUICtrlBar::GetProjectedLatLon(int &x, int &y) -{ - wxPoint p(0,0); +void GRIBUICtrlBar::GetProjectedLatLon(int &x, int &y) { + wxPoint p(0, 0); auto now = TimelineTime(); auto sog = m_ProjectBoatPanel->GetSpeed(); auto cog = m_ProjectBoatPanel->GetCourse(); - double dist = static_cast(now.GetTicks() - pPlugIn->m_boat_time) * sog / 3600.0; - PositionBearingDistanceMercator_Plugin(pPlugIn->m_boat_lat, pPlugIn->m_boat_lon, - cog, - dist, &m_projected_lat, - &m_projected_lon); - if(m_vp) { + double dist = + static_cast(now.GetTicks() - pPlugIn->m_boat_time) * sog / 3600.0; + PositionBearingDistanceMercator_Plugin(pPlugIn->m_boat_lat, + pPlugIn->m_boat_lon, cog, dist, + &m_projected_lat, &m_projected_lon); + if (m_vp) { GetCanvasPixLL(m_vp, &p, m_projected_lat, m_projected_lon); } x = p.x; @@ -1703,8 +1700,7 @@ void GRIBUICtrlBar::OnOpenFile(wxCommandEvent &event) { wxStandardPathsBase &path = wxStandardPaths::Get(); wxString l_grib_dir = path.GetDocumentsDir(); - if (wxDir::Exists(m_grib_dir)) - l_grib_dir = m_grib_dir; + if (wxDir::Exists(m_grib_dir)) l_grib_dir = m_grib_dir; wxFileDialog *dialog = new wxFileDialog(NULL, _("Select a GRIB file"), l_grib_dir, _T(""), @@ -1720,9 +1716,8 @@ void GRIBUICtrlBar::OnOpenFile(wxCommandEvent &event) { m_grib_dir = dialog->GetDirectory(); dialog->GetPaths(m_file_names); OpenFile(); - if (g_pi){ - if (g_pi->m_bZoomToCenterAtInit) - DoZoomToCenter(); + if (g_pi) { + if (g_pi->m_bZoomToCenterAtInit) DoZoomToCenter(); } SetDialogsStyleSizePosition(true); } @@ -1953,8 +1948,9 @@ void GRIBUICtrlBar::ComputeBestForecastForNow() { SaveSelectionString(); // memorize the new selected wxChoice date time label m_cRecordForecast->SetString( m_Selection_index, - TToString(now, pPlugIn->GetTimeZone())); // write the now date time label - // in the right place in wxChoice + TToString(now, + pPlugIn->GetTimeZone())); // write the now date time label + // in the right place in wxChoice m_cRecordForecast->SetStringSelection( TToString(now, pPlugIn->GetTimeZone())); // put it in the box diff --git a/plugins/grib_pi/src/GribUIDialog.h b/plugins/grib_pi/src/GribUIDialog.h index e4a503edfd..c2b8df770e 100644 --- a/plugins/grib_pi/src/GribUIDialog.h +++ b/plugins/grib_pi/src/GribUIDialog.h @@ -172,8 +172,7 @@ class GRIBUICtrlBar : public GRIBUICtrlBarBase { double m_ScaledFactor; void DoZoomToCenter(); const wxString GetGribDir() { - if (m_grib_dir.IsEmpty() || !wxDirExists(m_grib_dir)) - { + if (m_grib_dir.IsEmpty() || !wxDirExists(m_grib_dir)) { m_grib_dir = GetpPrivateApplicationDataLocation() ->Append(wxFileName::GetPathSeparator()) .Append("grib"); diff --git a/plugins/grib_pi/src/GribUIDialogBase.cpp b/plugins/grib_pi/src/GribUIDialogBase.cpp index a083a3bfbc..3d9f402679 100644 --- a/plugins/grib_pi/src/GribUIDialogBase.cpp +++ b/plugins/grib_pi/src/GribUIDialogBase.cpp @@ -2171,13 +2171,13 @@ GribPreferencesDialogBase::GribPreferencesDialogBase( bSizerPrefsMain->Add(fgSizer47, 0, wxALL | wxEXPAND, 5); #endif - wxButton *SetSaveButton = + wxButton* SetSaveButton = new wxButton(scrollWin, wxID_ANY, _("Select GRIB download directory")); bSizerPrefsMain->Add(SetSaveButton, 0, wxALL | wxEXPAND, 5); SetSaveButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, - wxCommandEventHandler(GribPreferencesDialogBase::OnDirSelClick), NULL, this); - + wxCommandEventHandler(GribPreferencesDialogBase::OnDirSelClick), NULL, + this); Layout(); Fit(); @@ -2319,9 +2319,8 @@ GribPreferencesDialogBase::~GribPreferencesDialogBase() { void GribPreferencesDialogBase::OnDirSelClick(wxCommandEvent& event) { wxString dir_spec; - int response = PlatformDirSelectorDialog(this, &dir_spec, - _("Choose GRIB File Directory"), - m_grib_dir_sel); + int response = PlatformDirSelectorDialog( + this, &dir_spec, _("Choose GRIB File Directory"), m_grib_dir_sel); if (response == wxID_OK) { m_grib_dir_sel = dir_spec; @@ -3138,56 +3137,56 @@ GribRequestSettingBase::GribRequestSettingBase(wxWindow* parent, wxWindowID id, NULL, this); m_xygribPanel->m_wind_cbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_gust_cbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_reflectivity_cbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_precipitation_cbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_cape_cbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_pressure_cbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_cloudcover_cbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_temperature_cbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_waveheight_cbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_windwave_cbox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_resolution_choice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_duration_choice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_interval_choice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); } GribRequestSettingBase::~GribRequestSettingBase() { @@ -3349,56 +3348,56 @@ GribRequestSettingBase::~GribRequestSettingBase() { NULL, this); m_xygribPanel->m_wind_cbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_gust_cbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_reflectivity_cbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_precipitation_cbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_cape_cbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_pressure_cbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_cloudcover_cbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_temperature_cbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_waveheight_cbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_windwave_cbox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_resolution_choice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_duration_choice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); m_xygribPanel->m_interval_choice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, - wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), - NULL, this); + wxCommandEventHandler(GribRequestSettingBase::OnXyGribConfigChange), NULL, + this); } GRIBTableBase::GRIBTableBase(wxWindow* parent, wxWindowID id, diff --git a/plugins/grib_pi/src/GribUIDialogBase.h b/plugins/grib_pi/src/GribUIDialogBase.h index 415ed16aaf..42ef93a563 100644 --- a/plugins/grib_pi/src/GribUIDialogBase.h +++ b/plugins/grib_pi/src/GribUIDialogBase.h @@ -108,30 +108,38 @@ /////////////////////////////////////////////////////////////////////////////// /// Class ProjectBoatPanel /////////////////////////////////////////////////////////////////////////////// -class ProjectBoatPanel : public wxPanel -{ - private: - - protected: - wxCheckBox* m_cbProjectPosition; - wxStaticText* m_stCourse; - wxTextCtrl* m_tCourse; - wxStaticText* m_stSpeed; - wxTextCtrl* m_tSpeed; - wxStaticText* m_stSpeedUnit; - - public: - - ProjectBoatPanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 580,40 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); - - ~ProjectBoatPanel(); - - double GetCourse(); - double GetSpeed(); - bool ProjectionEnabled(); - void SetCourse(const double course) { m_tCourse->SetValue(!wxIsNaN(course) ? wxString::FromDouble(course) : "0.0"); }; - void SetSpeed(const double speed) { m_tSpeed->SetValue(!wxIsNaN(speed) ? wxString::FromDouble(speed) : "6.0"); }; - void EnableProjection(bool enabled) { m_cbProjectPosition->SetValue(enabled); }; +class ProjectBoatPanel : public wxPanel { +private: +protected: + wxCheckBox* m_cbProjectPosition; + wxStaticText* m_stCourse; + wxTextCtrl* m_tCourse; + wxStaticText* m_stSpeed; + wxTextCtrl* m_tSpeed; + wxStaticText* m_stSpeedUnit; + +public: + ProjectBoatPanel(wxWindow* parent, wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(580, 40), + long style = wxTAB_TRAVERSAL, + const wxString& name = wxEmptyString); + + ~ProjectBoatPanel(); + + double GetCourse(); + double GetSpeed(); + bool ProjectionEnabled(); + void SetCourse(const double course) { + m_tCourse->SetValue(!wxIsNaN(course) ? wxString::FromDouble(course) + : "0.0"); + }; + void SetSpeed(const double speed) { + m_tSpeed->SetValue(!wxIsNaN(speed) ? wxString::FromDouble(speed) : "6.0"); + }; + void EnableProjection(bool enabled) { + m_cbProjectPosition->SetValue(enabled); + }; }; /////////////////////////////////////////////////////////////////////////////// @@ -402,7 +410,7 @@ class GribRequestSettingBase : public wxDialog { wxStaticText* m_stForecastLength; wxChoice* m_chForecastLength; wxStaticText* m_stECMWFResolution; - wxChoice* m_chECMWFResolution; + wxChoice* m_chECMWFResolution; wxButton* m_btnDownloadWorld; wxPanel* m_panelLocalModels; wxTreeCtrl* m_SourcesTreeCtrl1; @@ -471,9 +479,9 @@ class GribRequestSettingBase : public wxDialog { // Virtual event handlers, overide them in your derived class virtual void OnClose(wxCloseEvent& event) { event.Skip(); } - virtual void OnNotebookPageChanged( wxNotebookEvent& event ) { event.Skip(); } + virtual void OnNotebookPageChanged(wxNotebookEvent& event) { event.Skip(); } virtual void OnWorldLengthChoice(wxCommandEvent& event) { event.Skip(); } - virtual void OnWorldResolutionChoice( wxCommandEvent& event ) { event.Skip(); } + virtual void OnWorldResolutionChoice(wxCommandEvent& event) { event.Skip(); } virtual void OnWorldDownload(wxCommandEvent& event) { event.Skip(); } virtual void OnLocalTreeItemExpanded(wxTreeEvent& event) { event.Skip(); } virtual void OnLocalTreeSelChanged(wxTreeEvent& event) { event.Skip(); } @@ -495,15 +503,15 @@ class GribRequestSettingBase : public wxDialog { virtual void OnXyGribAtmModelChoice(wxCommandEvent& event) { event.Skip(); } virtual void OnXyGribWaveModelChoice(wxCommandEvent& event) { event.Skip(); } virtual void OnXyGribConfigChange(wxCommandEvent& event) { event.Skip(); } - + public: wxScrolledWindow* m_sScrolledDialog; - GribRequestSettingBase( - wxWindow* parent, wxWindowID id = wxID_ANY, - const wxString& title = _("Get forecast..."), - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxSize(-1, -1), long style = wxDEFAULT_DIALOG_STYLE); + GribRequestSettingBase(wxWindow* parent, wxWindowID id = wxID_ANY, + const wxString& title = _("Get forecast..."), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(-1, -1), + long style = wxDEFAULT_DIALOG_STYLE); ~GribRequestSettingBase(); }; diff --git a/plugins/grib_pi/src/GribV1Record.cpp b/plugins/grib_pi/src/GribV1Record.cpp index d01a50cc39..dd19221e3f 100644 --- a/plugins/grib_pi/src/GribV1Record.cpp +++ b/plugins/grib_pi/src/GribV1Record.cpp @@ -350,14 +350,14 @@ GribV1Record::GribV1Record(ZUFILE* file, int id_) { b_len_add_8 = false; break; } // end 'G' found in the next bytes - } // end no 'G' found in 1st byte. + } // end no 'G' found in 1st byte. } } // end reading four bytes if (b_haveReadGRIB == 0) { // the four bytes have been read if (strncmp(strgrib, "GRIB", 4) != 0) b_len_add_8 = true; //"GRIB" header no valid so apply length adder. - //Further reading will happen + // Further reading will happen else { b_haveReadGRIB = 2; //"GRIB" header is valid so no further reading b_len_add_8 = false; diff --git a/plugins/grib_pi/src/GribV2Record.cpp b/plugins/grib_pi/src/GribV2Record.cpp index c32aa04912..cc61083db0 100644 --- a/plugins/grib_pi/src/GribV2Record.cpp +++ b/plugins/grib_pi/src/GribV2Record.cpp @@ -150,7 +150,7 @@ class GRIBMetadata { class GRIB2Grid { public: - GRIB2Grid() : gridpoints(0){}; + GRIB2Grid() : gridpoints(0) {}; ~GRIB2Grid() { delete[] gridpoints; }; double *gridpoints; @@ -158,7 +158,7 @@ class GRIB2Grid { class GRIBMessage { public: - GRIBMessage() : buffer(0){}; + GRIBMessage() : buffer(0) {}; ~GRIBMessage() { delete[] buffer; }; unsigned char *buffer; int offset; /* offset in bytes to next GRIB2 section */ @@ -1026,7 +1026,8 @@ static zuchar GRBV2_TO_DATA(int productDiscipline, int dataCat, int dataNum) { ret = GRB_DEWPOINT; break; // DATA_TO_GRBV2[DATA_DEWPOINT] = grb2DataType(0,0,6); case 17: - ret = GRB_WTMP; //Skin temperature [C] SFC="Ground or water surface" + ret = GRB_WTMP; // Skin temperature [C] SFC="Ground or water + // surface" break; // DATA_TO_GRBV2[DATA_DEWPOINT] = grb2DataType(0,0,17); } break; @@ -1479,8 +1480,8 @@ void GribV2Record::translateDataType() { } else if (idCenter == 84 && idModel <= 5 && idGrid == 0) { } // MeteoFrance - else if (idCenter==85) { - if (dataType == GRB_CLOUD_TOT && levelType == LV_GND_SURF && + else if (idCenter == 85) { + if (dataType == GRB_CLOUD_TOT && levelType == LV_GND_SURF && levelValue == 0) { levelType = LV_ATMOS_ALL; } diff --git a/plugins/grib_pi/src/IsoLine.cpp b/plugins/grib_pi/src/IsoLine.cpp index 8e763776ce..4f506ada72 100644 --- a/plugins/grib_pi/src/IsoLine.cpp +++ b/plugins/grib_pi/src/IsoLine.cpp @@ -22,8 +22,8 @@ along with this program. If not, see . #include "wx/wx.h" #endif // precompiled headers -//#include "chcanv.h" -//#include "model/georef.h" +// #include "chcanv.h" +// #include "model/georef.h" #include #include "IsoLine.h" @@ -389,21 +389,21 @@ void IsoLine::drawIsoLine(GRIBOverlayFactory *pof, wxDC *dc, dc->SetPen(ppISO); } else { /* opengl */ #ifdef ocpnUSE_GL - //#ifndef USE_ANDROID_GLES2 - // if(m_pixelMM > 0.2){ // pixel size large enough to - // render well - // // Enable anti-aliased lines, at best quality - // glEnable( GL_LINE_SMOOTH ); - // glEnable( GL_BLEND ); - // glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - // glHint( GL_LINE_SMOOTH_HINT, GL_NICEST ); - // glLineWidth( 2 ); - // } - // else{ - // glLineWidth( 0.4/m_pixelMM); // set a target line - // width by MM - // } - //#else + // #ifndef USE_ANDROID_GLES2 + // if(m_pixelMM > 0.2){ // pixel size large enough to + // render well + // // Enable anti-aliased lines, at best quality + // glEnable( GL_LINE_SMOOTH ); + // glEnable( GL_BLEND ); + // glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + // glHint( GL_LINE_SMOOTH_HINT, GL_NICEST ); + // glLineWidth( 2 ); + // } + // else{ + // glLineWidth( 0.4/m_pixelMM); // set a target line + // width by MM + // } + // #else if (pof->m_oDC) { wxPen ppISO(isoLineColor, 2); pof->m_oDC->SetPen(ppISO); @@ -559,7 +559,7 @@ void IsoLine::drawIsoLineLabelsGL(GRIBOverlayFactory *pof, PlugIn_ViewPort *vp, #if 1 prev = r; if (pof->m_oDC) { - //pof->m_oDC->SetFont( *mfont ); + // pof->m_oDC->SetFont( *mfont ); pof->m_oDC->SetPen(*wxBLACK_PEN); pof->m_oDC->SetBrush(color); pof->m_oDC->DrawRectangle(x, y, w, h); diff --git a/plugins/grib_pi/src/XyGribPanel.cpp b/plugins/grib_pi/src/XyGribPanel.cpp index 93478787a0..eb7efdc684 100644 --- a/plugins/grib_pi/src/XyGribPanel.cpp +++ b/plugins/grib_pi/src/XyGribPanel.cpp @@ -9,145 +9,205 @@ /////////////////////////////////////////////////////////////////////////// -XyGribPanel::XyGribPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) -{ - wxGridBagSizer* m_separator_line; - m_separator_line = new wxGridBagSizer( 0, 0 ); - m_separator_line->SetFlexibleDirection( wxBOTH ); - m_separator_line->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_wavemodel_label = new wxStaticText( this, wxID_ANY, _("Wave model"), wxDefaultPosition, wxDefaultSize, 0 ); - m_wavemodel_label->Wrap( -1 ); - m_separator_line->Add( m_wavemodel_label, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - - m_atmmodel_label = new wxStaticText( this, wxID_ANY, _("Weather model"), wxDefaultPosition, wxDefaultSize, 0 ); - m_atmmodel_label->Wrap( -1 ); - m_separator_line->Add( m_atmmodel_label, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - - m_weathermodel = new wxStaticText( this, wxID_ANY, _("Resolution"), wxDefaultPosition, wxDefaultSize, 0 ); - m_weathermodel->Wrap( -1 ); - m_separator_line->Add( m_weathermodel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - - m_duration_label = new wxStaticText( this, wxID_ANY, _("Days"), wxDefaultPosition, wxDefaultSize, 0 ); - m_duration_label->Wrap( -1 ); - m_separator_line->Add( m_duration_label, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - - m_run_label = new wxStaticText( this, wxID_ANY, _("Run"), wxDefaultPosition, wxDefaultSize, 0 ); - m_run_label->Wrap( -1 ); - m_separator_line->Add( m_run_label, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - - m_interval_label = new wxStaticText( this, wxID_ANY, _("Interval"), wxDefaultPosition, wxDefaultSize, 0 ); - m_interval_label->Wrap( -1 ); - m_separator_line->Add( m_interval_label, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - - wxArrayString m_atmmodel_choiceChoices; - m_atmmodel_choice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_atmmodel_choiceChoices, 0 ); - m_atmmodel_choice->SetSelection( 0 ); - m_separator_line->Add( m_atmmodel_choice, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - - wxArrayString m_wavemodel_choiceChoices; - m_wavemodel_choice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_wavemodel_choiceChoices, 0 ); - m_wavemodel_choice->SetSelection( 0 ); - m_separator_line->Add( m_wavemodel_choice, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - - wxArrayString m_interval_choiceChoices; - m_interval_choice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_interval_choiceChoices, 0 ); - m_interval_choice->SetSelection( 0 ); - m_separator_line->Add( m_interval_choice, wxGBPosition( 5, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - - wxArrayString m_resolution_choiceChoices; - m_resolution_choice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_resolution_choiceChoices, 0 ); - m_resolution_choice->SetSelection( 0 ); - m_separator_line->Add( m_resolution_choice, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - - wxArrayString m_duration_choiceChoices; - m_duration_choice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_duration_choiceChoices, 0 ); - m_duration_choice->SetSelection( 0 ); - m_separator_line->Add( m_duration_choice, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - - wxArrayString m_run_choiceChoices; - m_run_choice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_run_choiceChoices, 0 ); - m_run_choice->SetSelection( 0 ); - m_separator_line->Add( m_run_choice, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - - m_dataconfig_nbook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), 0 ); - m_surfacetab_panel = new wxPanel( m_dataconfig_nbook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxGridSizer* m_surfacetab_sizer; - m_surfacetab_sizer = new wxGridSizer( 0, 2, 0, 0 ); - - m_wind_cbox = new wxCheckBox( m_surfacetab_panel, wxID_ANY, _("Wind (10m)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_wind_cbox->SetValue(true); - m_surfacetab_sizer->Add( m_wind_cbox, 0, wxALL, 5 ); - - m_gust_cbox = new wxCheckBox( m_surfacetab_panel, wxID_ANY, _("Wind gust (surface)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_gust_cbox->SetValue(true); - m_surfacetab_sizer->Add( m_gust_cbox, 0, wxALL, 5 ); - - m_pressure_cbox = new wxCheckBox( m_surfacetab_panel, wxID_ANY, _("Pressure (MSL)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_surfacetab_sizer->Add( m_pressure_cbox, 0, wxALL, 5 ); - - m_temperature_cbox = new wxCheckBox( m_surfacetab_panel, wxID_ANY, _("Temperature (2m)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_surfacetab_sizer->Add( m_temperature_cbox, 0, wxALL, 5 ); - - m_cape_cbox = new wxCheckBox( m_surfacetab_panel, wxID_ANY, _("CAPE (surface)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_surfacetab_sizer->Add( m_cape_cbox, 0, wxALL, 5 ); - - m_reflectivity_cbox = new wxCheckBox( m_surfacetab_panel, wxID_ANY, _("Reflectivity (atmosphere)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_surfacetab_sizer->Add( m_reflectivity_cbox, 0, wxALL, 5 ); - - m_cloudcover_cbox = new wxCheckBox( m_surfacetab_panel, wxID_ANY, _("Cloud cover (total)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_surfacetab_sizer->Add( m_cloudcover_cbox, 0, wxALL, 5 ); - - m_precipitation_cbox = new wxCheckBox( m_surfacetab_panel, wxID_ANY, _("Total precipitation"), wxDefaultPosition, wxDefaultSize, 0 ); - m_surfacetab_sizer->Add( m_precipitation_cbox, 0, wxALL, 5 ); - - m_waveheight_cbox = new wxCheckBox( m_surfacetab_panel, wxID_ANY, _("Wave Significant height"), wxDefaultPosition, wxDefaultSize, 0 ); - m_waveheight_cbox->SetValue(true); - m_surfacetab_sizer->Add( m_waveheight_cbox, 0, wxALL, 5 ); - - m_windwave_cbox = new wxCheckBox( m_surfacetab_panel, wxID_ANY, _("Wind waves"), wxDefaultPosition, wxDefaultSize, 0 ); - m_surfacetab_sizer->Add( m_windwave_cbox, 0, wxALL, 5 ); - - - m_surfacetab_panel->SetSizer( m_surfacetab_sizer ); - m_surfacetab_panel->Layout(); - m_surfacetab_sizer->Fit( m_surfacetab_panel ); - m_dataconfig_nbook->AddPage( m_surfacetab_panel, _("Parameters"), false ); - - m_separator_line->Add( m_dataconfig_nbook, wxGBPosition( 0, 2 ), wxGBSpan( 6, 1 ), wxALL|wxEXPAND, 5 ); - - m_separator_1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - m_separator_line->Add( m_separator_1, wxGBPosition( 7, 0 ), wxGBSpan( 1, 3 ), wxEXPAND | wxALL, 5 ); - - m_download_button = new wxButton( this, wxID_ANY, _("Download"), wxDefaultPosition, wxDefaultSize, 0 ); - m_separator_line->Add( m_download_button, wxGBPosition( 9, 0 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - - m_progress_gauge = new wxGauge( this, wxID_ANY, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL ); - m_progress_gauge->SetValue( 0 ); - m_separator_line->Add( m_progress_gauge, wxGBPosition( 9, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); - - m_status_label = new wxStaticText( this, wxID_ANY, _("Status :"), wxDefaultPosition, wxDefaultSize, 0 ); - m_status_label->Wrap( -1 ); - m_separator_line->Add( m_status_label, wxGBPosition( 8, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - - m_status_text = new wxStaticText( this, wxID_ANY, _("Ready"), wxDefaultPosition, wxDefaultSize, 0 ); - m_status_text->Wrap( -1 ); - m_separator_line->Add( m_status_text, wxGBPosition( 8, 1 ), wxGBSpan( 1, 2 ), wxALL, 5 ); - - m_sizeestimate_label = new wxStaticText( this, wxID_ANY, _("Estimated size :"), wxDefaultPosition, wxDefaultSize, 0 ); - m_sizeestimate_label->Wrap( -1 ); - m_separator_line->Add( m_sizeestimate_label, wxGBPosition( 6, 1 ), wxGBSpan( 1, 1 ), wxALIGN_RIGHT|wxALL, 5 ); - - m_sizeestimate_text = new wxStaticText( this, wxID_ANY, _("Unknown"), wxDefaultPosition, wxDefaultSize, 0 ); - m_sizeestimate_text->Wrap( -1 ); - m_separator_line->Add( m_sizeestimate_text, wxGBPosition( 6, 2 ), wxGBSpan( 1, 1 ), wxALL, 5 ); - - - this->SetSizer( m_separator_line ); - this->Layout(); - m_separator_line->Fit( this ); +XyGribPanel::XyGribPanel(wxWindow* parent, wxWindowID id, const wxPoint& pos, + const wxSize& size, long style, const wxString& name) + : wxPanel(parent, id, pos, size, style, name) { + wxGridBagSizer* m_separator_line; + m_separator_line = new wxGridBagSizer(0, 0); + m_separator_line->SetFlexibleDirection(wxBOTH); + m_separator_line->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); + + m_wavemodel_label = new wxStaticText(this, wxID_ANY, _("Wave model"), + wxDefaultPosition, wxDefaultSize, 0); + m_wavemodel_label->Wrap(-1); + m_separator_line->Add(m_wavemodel_label, wxGBPosition(1, 0), wxGBSpan(1, 1), + wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + + m_atmmodel_label = new wxStaticText(this, wxID_ANY, _("Weather model"), + wxDefaultPosition, wxDefaultSize, 0); + m_atmmodel_label->Wrap(-1); + m_separator_line->Add(m_atmmodel_label, wxGBPosition(0, 0), wxGBSpan(1, 1), + wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + + m_weathermodel = new wxStaticText(this, wxID_ANY, _("Resolution"), + wxDefaultPosition, wxDefaultSize, 0); + m_weathermodel->Wrap(-1); + m_separator_line->Add(m_weathermodel, wxGBPosition(2, 0), wxGBSpan(1, 1), + wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + + m_duration_label = new wxStaticText(this, wxID_ANY, _("Days"), + wxDefaultPosition, wxDefaultSize, 0); + m_duration_label->Wrap(-1); + m_separator_line->Add(m_duration_label, wxGBPosition(3, 0), wxGBSpan(1, 1), + wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + + m_run_label = new wxStaticText(this, wxID_ANY, _("Run"), wxDefaultPosition, + wxDefaultSize, 0); + m_run_label->Wrap(-1); + m_separator_line->Add(m_run_label, wxGBPosition(4, 0), wxGBSpan(1, 1), + wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + + m_interval_label = new wxStaticText(this, wxID_ANY, _("Interval"), + wxDefaultPosition, wxDefaultSize, 0); + m_interval_label->Wrap(-1); + m_separator_line->Add(m_interval_label, wxGBPosition(5, 0), wxGBSpan(1, 1), + wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + + wxArrayString m_atmmodel_choiceChoices; + m_atmmodel_choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, + wxDefaultSize, m_atmmodel_choiceChoices, 0); + m_atmmodel_choice->SetSelection(0); + m_separator_line->Add(m_atmmodel_choice, wxGBPosition(0, 1), wxGBSpan(1, 1), + wxALL | wxEXPAND, 5); + + wxArrayString m_wavemodel_choiceChoices; + m_wavemodel_choice = + new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, + m_wavemodel_choiceChoices, 0); + m_wavemodel_choice->SetSelection(0); + m_separator_line->Add(m_wavemodel_choice, wxGBPosition(1, 1), wxGBSpan(1, 1), + wxALL | wxEXPAND, 5); + + wxArrayString m_interval_choiceChoices; + m_interval_choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, + wxDefaultSize, m_interval_choiceChoices, 0); + m_interval_choice->SetSelection(0); + m_separator_line->Add(m_interval_choice, wxGBPosition(5, 1), wxGBSpan(1, 1), + wxALL | wxEXPAND, 5); + + wxArrayString m_resolution_choiceChoices; + m_resolution_choice = + new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, + m_resolution_choiceChoices, 0); + m_resolution_choice->SetSelection(0); + m_separator_line->Add(m_resolution_choice, wxGBPosition(2, 1), wxGBSpan(1, 1), + wxALL | wxEXPAND, 5); + + wxArrayString m_duration_choiceChoices; + m_duration_choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, + wxDefaultSize, m_duration_choiceChoices, 0); + m_duration_choice->SetSelection(0); + m_separator_line->Add(m_duration_choice, wxGBPosition(3, 1), wxGBSpan(1, 1), + wxALL | wxEXPAND, 5); + + wxArrayString m_run_choiceChoices; + m_run_choice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, + m_run_choiceChoices, 0); + m_run_choice->SetSelection(0); + m_separator_line->Add(m_run_choice, wxGBPosition(4, 1), wxGBSpan(1, 1), + wxALL | wxEXPAND, 5); + + m_dataconfig_nbook = + new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxSize(-1, -1), 0); + m_surfacetab_panel = + new wxPanel(m_dataconfig_nbook, wxID_ANY, wxDefaultPosition, + wxDefaultSize, wxTAB_TRAVERSAL); + wxGridSizer* m_surfacetab_sizer; + m_surfacetab_sizer = new wxGridSizer(0, 2, 0, 0); + + m_wind_cbox = new wxCheckBox(m_surfacetab_panel, wxID_ANY, _("Wind (10m)"), + wxDefaultPosition, wxDefaultSize, 0); + m_wind_cbox->SetValue(true); + m_surfacetab_sizer->Add(m_wind_cbox, 0, wxALL, 5); + + m_gust_cbox = + new wxCheckBox(m_surfacetab_panel, wxID_ANY, _("Wind gust (surface)"), + wxDefaultPosition, wxDefaultSize, 0); + m_gust_cbox->SetValue(true); + m_surfacetab_sizer->Add(m_gust_cbox, 0, wxALL, 5); + + m_pressure_cbox = + new wxCheckBox(m_surfacetab_panel, wxID_ANY, _("Pressure (MSL)"), + wxDefaultPosition, wxDefaultSize, 0); + m_surfacetab_sizer->Add(m_pressure_cbox, 0, wxALL, 5); + + m_temperature_cbox = + new wxCheckBox(m_surfacetab_panel, wxID_ANY, _("Temperature (2m)"), + wxDefaultPosition, wxDefaultSize, 0); + m_surfacetab_sizer->Add(m_temperature_cbox, 0, wxALL, 5); + + m_cape_cbox = + new wxCheckBox(m_surfacetab_panel, wxID_ANY, _("CAPE (surface)"), + wxDefaultPosition, wxDefaultSize, 0); + m_surfacetab_sizer->Add(m_cape_cbox, 0, wxALL, 5); + + m_reflectivity_cbox = new wxCheckBox(m_surfacetab_panel, wxID_ANY, + _("Reflectivity (atmosphere)"), + wxDefaultPosition, wxDefaultSize, 0); + m_surfacetab_sizer->Add(m_reflectivity_cbox, 0, wxALL, 5); + + m_cloudcover_cbox = + new wxCheckBox(m_surfacetab_panel, wxID_ANY, _("Cloud cover (total)"), + wxDefaultPosition, wxDefaultSize, 0); + m_surfacetab_sizer->Add(m_cloudcover_cbox, 0, wxALL, 5); + + m_precipitation_cbox = + new wxCheckBox(m_surfacetab_panel, wxID_ANY, _("Total precipitation"), + wxDefaultPosition, wxDefaultSize, 0); + m_surfacetab_sizer->Add(m_precipitation_cbox, 0, wxALL, 5); + + m_waveheight_cbox = + new wxCheckBox(m_surfacetab_panel, wxID_ANY, _("Wave Significant height"), + wxDefaultPosition, wxDefaultSize, 0); + m_waveheight_cbox->SetValue(true); + m_surfacetab_sizer->Add(m_waveheight_cbox, 0, wxALL, 5); + + m_windwave_cbox = + new wxCheckBox(m_surfacetab_panel, wxID_ANY, _("Wind waves"), + wxDefaultPosition, wxDefaultSize, 0); + m_surfacetab_sizer->Add(m_windwave_cbox, 0, wxALL, 5); + + m_surfacetab_panel->SetSizer(m_surfacetab_sizer); + m_surfacetab_panel->Layout(); + m_surfacetab_sizer->Fit(m_surfacetab_panel); + m_dataconfig_nbook->AddPage(m_surfacetab_panel, _("Parameters"), false); + + m_separator_line->Add(m_dataconfig_nbook, wxGBPosition(0, 2), wxGBSpan(6, 1), + wxALL | wxEXPAND, 5); + + m_separator_1 = new wxStaticLine(this, wxID_ANY, wxDefaultPosition, + wxDefaultSize, wxLI_HORIZONTAL); + m_separator_line->Add(m_separator_1, wxGBPosition(7, 0), wxGBSpan(1, 3), + wxEXPAND | wxALL, 5); + + m_download_button = new wxButton(this, wxID_ANY, _("Download"), + wxDefaultPosition, wxDefaultSize, 0); + m_separator_line->Add(m_download_button, wxGBPosition(9, 0), wxGBSpan(1, 1), + wxALL | wxEXPAND, 5); + + m_progress_gauge = new wxGauge(this, wxID_ANY, 100, wxDefaultPosition, + wxDefaultSize, wxGA_HORIZONTAL); + m_progress_gauge->SetValue(0); + m_separator_line->Add(m_progress_gauge, wxGBPosition(9, 1), wxGBSpan(1, 2), + wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 5); + + m_status_label = new wxStaticText(this, wxID_ANY, _("Status :"), + wxDefaultPosition, wxDefaultSize, 0); + m_status_label->Wrap(-1); + m_separator_line->Add(m_status_label, wxGBPosition(8, 0), wxGBSpan(1, 1), + wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + + m_status_text = new wxStaticText(this, wxID_ANY, _("Ready"), + wxDefaultPosition, wxDefaultSize, 0); + m_status_text->Wrap(-1); + m_separator_line->Add(m_status_text, wxGBPosition(8, 1), wxGBSpan(1, 2), + wxALL, 5); + + m_sizeestimate_label = new wxStaticText(this, wxID_ANY, _("Estimated size :"), + wxDefaultPosition, wxDefaultSize, 0); + m_sizeestimate_label->Wrap(-1); + m_separator_line->Add(m_sizeestimate_label, wxGBPosition(6, 1), + wxGBSpan(1, 1), wxALIGN_RIGHT | wxALL, 5); + + m_sizeestimate_text = new wxStaticText(this, wxID_ANY, _("Unknown"), + wxDefaultPosition, wxDefaultSize, 0); + m_sizeestimate_text->Wrap(-1); + m_separator_line->Add(m_sizeestimate_text, wxGBPosition(6, 2), wxGBSpan(1, 1), + wxALL, 5); + + this->SetSizer(m_separator_line); + this->Layout(); + m_separator_line->Fit(this); } -XyGribPanel::~XyGribPanel() -{ -} +XyGribPanel::~XyGribPanel() {} diff --git a/plugins/grib_pi/src/XyGribPanel.h b/plugins/grib_pi/src/XyGribPanel.h index 74560f4845..56f739c209 100644 --- a/plugins/grib_pi/src/XyGribPanel.h +++ b/plugins/grib_pi/src/XyGribPanel.h @@ -34,48 +34,47 @@ /////////////////////////////////////////////////////////////////////////////// /// Class XyGribPanel /////////////////////////////////////////////////////////////////////////////// -class XyGribPanel : public wxPanel -{ - private: +class XyGribPanel : public wxPanel { +private: +protected: + wxStaticText* m_wavemodel_label; + wxStaticText* m_atmmodel_label; + wxStaticText* m_weathermodel; + wxStaticText* m_duration_label; + wxStaticText* m_run_label; + wxStaticText* m_interval_label; + wxNotebook* m_dataconfig_nbook; + wxPanel* m_surfacetab_panel; + wxStaticLine* m_separator_1; + wxStaticText* m_status_label; + wxStaticText* m_sizeestimate_label; - protected: - wxStaticText* m_wavemodel_label; - wxStaticText* m_atmmodel_label; - wxStaticText* m_weathermodel; - wxStaticText* m_duration_label; - wxStaticText* m_run_label; - wxStaticText* m_interval_label; - wxNotebook* m_dataconfig_nbook; - wxPanel* m_surfacetab_panel; - wxStaticLine* m_separator_1; - wxStaticText* m_status_label; - wxStaticText* m_sizeestimate_label; +public: + wxChoice* m_atmmodel_choice; + wxChoice* m_wavemodel_choice; + wxChoice* m_interval_choice; + wxChoice* m_resolution_choice; + wxChoice* m_duration_choice; + wxChoice* m_run_choice; + wxCheckBox* m_wind_cbox; + wxCheckBox* m_gust_cbox; + wxCheckBox* m_pressure_cbox; + wxCheckBox* m_temperature_cbox; + wxCheckBox* m_cape_cbox; + wxCheckBox* m_reflectivity_cbox; + wxCheckBox* m_cloudcover_cbox; + wxCheckBox* m_precipitation_cbox; + wxCheckBox* m_waveheight_cbox; + wxCheckBox* m_windwave_cbox; + wxButton* m_download_button; + wxGauge* m_progress_gauge; + wxStaticText* m_status_text; + wxStaticText* m_sizeestimate_text; - public: - wxChoice* m_atmmodel_choice; - wxChoice* m_wavemodel_choice; - wxChoice* m_interval_choice; - wxChoice* m_resolution_choice; - wxChoice* m_duration_choice; - wxChoice* m_run_choice; - wxCheckBox* m_wind_cbox; - wxCheckBox* m_gust_cbox; - wxCheckBox* m_pressure_cbox; - wxCheckBox* m_temperature_cbox; - wxCheckBox* m_cape_cbox; - wxCheckBox* m_reflectivity_cbox; - wxCheckBox* m_cloudcover_cbox; - wxCheckBox* m_precipitation_cbox; - wxCheckBox* m_waveheight_cbox; - wxCheckBox* m_windwave_cbox; - wxButton* m_download_button; - wxGauge* m_progress_gauge; - wxStaticText* m_status_text; - wxStaticText* m_sizeestimate_text; - - XyGribPanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); - - ~XyGribPanel(); + XyGribPanel(wxWindow* parent, wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(-1, -1), long style = wxTAB_TRAVERSAL, + const wxString& name = wxEmptyString); + ~XyGribPanel(); }; - diff --git a/plugins/grib_pi/src/email.cpp b/plugins/grib_pi/src/email.cpp index 76d7e5432a..65e567dfb2 100644 --- a/plugins/grib_pi/src/email.cpp +++ b/plugins/grib_pi/src/email.cpp @@ -107,9 +107,9 @@ bool wxEmail::Send(wxMailMessage& message, int sendMethod, return false; } - msg << "sh -c \" " << sendmail - << " --utf8 --subject '" << message.m_subject << "' " - <<"--body '" << message.m_body << "'"; + msg << "sh -c \" " << sendmail << " --utf8 --subject '" + << message.m_subject << "' " + << "--body '" << message.m_body << "'"; for (size_t rcpt = 0; rcpt < message.m_to.GetCount(); rcpt++) msg << " '" << message.m_to[rcpt] << "'"; // add recipients msg << "\""; @@ -155,5 +155,5 @@ bool wxEmail::Send(wxMailMessage& message, int sendMethod, #else wxLogMessage(_T("Send eMail not yet implemented for this platform")); return false; -//#error Send not yet implemented for this platform. +// #error Send not yet implemented for this platform. #endif diff --git a/plugins/grib_pi/src/email.h b/plugins/grib_pi/src/email.h index bcc15975e7..222c374cfc 100644 --- a/plugins/grib_pi/src/email.h +++ b/plugins/grib_pi/src/email.h @@ -22,7 +22,7 @@ class WXDLLIMPEXP_NETUTILS wxEmail { public: //// Ctor/dtor - wxEmail(){}; + wxEmail() {}; //// Operations diff --git a/plugins/grib_pi/src/grib_pi.cpp b/plugins/grib_pi/src/grib_pi.cpp index 453b28402e..b453c062ab 100644 --- a/plugins/grib_pi/src/grib_pi.cpp +++ b/plugins/grib_pi/src/grib_pi.cpp @@ -36,7 +36,6 @@ #endif #endif // precompiled headers - #include #include @@ -131,18 +130,20 @@ int grib_pi::Init(void) { // This PlugIn needs a CtrlBar icon, so request its insertion if enabled // locally wxString shareLocn = *GetpSharedDataLocation() + _T("plugins") + - wxFileName::GetPathSeparator() + _T("grib_pi") + - wxFileName::GetPathSeparator() + _T("data") + - wxFileName::GetPathSeparator(); - //Initialize catalog file + wxFileName::GetPathSeparator() + _T("grib_pi") + + wxFileName::GetPathSeparator() + _T("data") + + wxFileName::GetPathSeparator(); + // Initialize catalog file wxString local_grib_catalog = "sources.json"; - wxString data_path = *GetpPrivateApplicationDataLocation() + wxFileName::GetPathSeparator() + "grib_pi"; + wxString data_path = *GetpPrivateApplicationDataLocation() + + wxFileName::GetPathSeparator() + "grib_pi"; if (!wxDirExists(data_path)) { wxMkdir(data_path); } - m_local_sources_catalog = data_path + wxFileName::GetPathSeparator() + local_grib_catalog; + m_local_sources_catalog = + data_path + wxFileName::GetPathSeparator() + local_grib_catalog; if (!wxFileExists(m_local_sources_catalog)) { - wxCopyFile(shareLocn + local_grib_catalog, m_local_sources_catalog); + wxCopyFile(shareLocn + local_grib_catalog, m_local_sources_catalog); } if (m_bGRIBShowIcon) { wxString normalIcon = shareLocn + _T("grib.svg"); @@ -247,7 +248,7 @@ void grib_pi::ShowPreferencesDialog(wxWindow *parent) { Pref->m_rbStartOptions->SetSelection(m_bStartOptions); wxFileConfig *pConf = GetOCPNConfigObject(); - if (pConf){ + if (pConf) { wxString l_grib_dir; pConf->SetPath(_T ( "/Directories" )); pConf->Read(_T ( "GRIBDirectory" ), &l_grib_dir); @@ -277,13 +278,12 @@ void grib_pi::ShowPreferencesDialog(wxWindow *parent) { wxDisplaySize(&display_width, &display_height); int char_width = GetOCPNCanvasWindow()->GetCharWidth(); int char_height = GetOCPNCanvasWindow()->GetCharHeight(); - if(display_height < 600){ + if (display_height < 600) { wxSize canvas_size = GetOCPNCanvasWindow()->GetSize(); Pref->SetMaxSize(GetOCPNCanvasWindow()->GetSize()); Pref->SetSize(wxSize(60 * char_width, canvas_size.x * 8 / 10)); Pref->CentreOnScreen(); - } - else { + } else { Pref->SetMaxSize(GetOCPNCanvasWindow()->GetSize()); Pref->SetSize(wxSize(60 * char_width, 32 * char_height)); } @@ -354,7 +354,6 @@ void grib_pi::UpdatePrefs(GribPreferencesDialog *Pref) { m_pGribCtrlBar->m_grib_dir = Pref->m_grib_dir_sel; m_pGribCtrlBar->m_file_names.Clear(); } - } if (Pref->m_grib_dir_sel.Length()) { @@ -429,7 +428,8 @@ void grib_pi::OnToolbarToolCallback(int id) { bool starting = false; - double scale_factor = GetOCPNGUIToolScaleFactor_PlugIn() * OCPN_GetWinDIPScaleFactor(); + double scale_factor = + GetOCPNGUIToolScaleFactor_PlugIn() * OCPN_GetWinDIPScaleFactor(); #ifdef __WXMSW__ scale_factor *= m_GribIconsScaleFactor; #endif @@ -452,12 +452,12 @@ void grib_pi::OnToolbarToolCallback(int id) { wxMenuItem *table = new wxMenuItem(dummy, wxID_ANY, wxString(_("Weather table")), wxEmptyString, wxITEM_NORMAL); -/* Menu font do not work properly for MSW (wxWidgets 3.2.1) -#ifdef __WXMSW__ - wxFont *qFont = OCPNGetFont(_("Menu"), 10); - table->SetFont(*qFont); -#endif -*/ + /* Menu font do not work properly for MSW (wxWidgets 3.2.1) + #ifdef __WXMSW__ + wxFont *qFont = OCPNGetFont(_("Menu"), 10); + table->SetFont(*qFont); + #endif + */ m_MenuItem = AddCanvasContextMenuItem(table, this); SetCanvasContextMenuItemViz(m_MenuItem, false); @@ -477,12 +477,12 @@ void grib_pi::OnToolbarToolCallback(int id) { // Toggle dialog? if (m_bShowGrib) { - //A new file could have been added since grib plugin opened + // A new file could have been added since grib plugin opened if (!starting && m_bLoadLastOpenFile == 0) { m_pGribCtrlBar->OpenFile(true); starting = true; } - //the dialog font could have been changed since grib plugin opened + // the dialog font could have been changed since grib plugin opened if (m_pGribCtrlBar->GetFont() != *OCPNGetFont(_("Dialog"), 10)) starting = true; if (starting) { @@ -564,7 +564,7 @@ bool grib_pi::DoRenderOverlay(wxDC &dc, PlugIn_ViewPort *vp, int canvasIndex) { m_pGRIBOverlayFactory->RenderGribOverlay(dc, vp); - if ( GetCanvasByIndex(canvasIndex) == GetCanvasUnderMouse() ) { + if (GetCanvasByIndex(canvasIndex) == GetCanvasUnderMouse()) { m_pGribCtrlBar->SetViewPort(vp); if (m_pGribCtrlBar->pReq_Dialog) m_pGribCtrlBar->pReq_Dialog->RenderZoneOverlay(dc); @@ -859,12 +859,12 @@ void grib_pi::SendTimelineMessage(wxDateTime time) { SendPluginMessage(wxString(_T("GRIB_TIMELINE")), out); } -void grib_pi::SetPositionFixEx(PlugIn_Position_Fix_Ex& pfix) { +void grib_pi::SetPositionFixEx(PlugIn_Position_Fix_Ex &pfix) { m_boat_cog = pfix.Cog; m_boat_sog = pfix.Sog; m_boat_lat = pfix.Lat; m_boat_lon = pfix.Lon; - if(pfix.FixTime != 0) { + if (pfix.FixTime != 0) { m_boat_time = pfix.FixTime; } else { m_boat_time = wxDateTime::Now().GetTicks(); diff --git a/plugins/grib_pi/src/grib_pi.h b/plugins/grib_pi/src/grib_pi.h index 058b9a91a4..9f843ee000 100644 --- a/plugins/grib_pi/src/grib_pi.h +++ b/plugins/grib_pi/src/grib_pi.h @@ -189,9 +189,9 @@ class grib_pi : public opencpn_plugin_116 { wxString m_ZyGribLogin; wxString m_ZyGribCode; double m_GUIScaleFactor; - #ifdef __WXMSW__ +#ifdef __WXMSW__ double m_GribIconsScaleFactor; - #endif +#endif bool m_bGRIBShowIcon; bool m_bShowGrib; diff --git a/plugins/grib_pi/src/jsonwriter.cpp b/plugins/grib_pi/src/jsonwriter.cpp index 50e3613c9c..f1722d7187 100644 --- a/plugins/grib_pi/src/jsonwriter.cpp +++ b/plugins/grib_pi/src/jsonwriter.cpp @@ -795,7 +795,7 @@ int wxJSONWriter::WriteStringValue(wxOutputStream& os, const wxString& str) { } } } - } // end for + } // end for os.PutC('\"'); // close quotes return 0; } diff --git a/plugins/grib_pi/src/msg.h b/plugins/grib_pi/src/msg.h index dd257fbfcc..0b87e1b0ef 100644 --- a/plugins/grib_pi/src/msg.h +++ b/plugins/grib_pi/src/msg.h @@ -37,7 +37,7 @@ class WXDLLIMPEXP_NETUTILS wxMailMessage { } } - wxMailMessage(){}; + wxMailMessage() {}; //// Accessors diff --git a/plugins/grib_pi/src/pi_TexFont.cpp b/plugins/grib_pi/src/pi_TexFont.cpp index 5b0398d4ad..067a6cc8dc 100644 --- a/plugins/grib_pi/src/pi_TexFont.cpp +++ b/plugins/grib_pi/src/pi_TexFont.cpp @@ -93,10 +93,8 @@ void TexFont::Build(wxFont &font, bool blur) { wxASSERT(w < 2048 && h < 2048); /* make power of 2 */ - for (tex_w = 1; tex_w < w; tex_w *= 2) - ; - for (tex_h = 1; tex_h < h; tex_h *= 2) - ; + for (tex_w = 1; tex_w < w; tex_w *= 2); + for (tex_h = 1; tex_h < h; tex_h *= 2); wxBitmap tbmp(tex_w, tex_h); wxMemoryDC dc; diff --git a/plugins/grib_pi/src/pi_gl.h b/plugins/grib_pi/src/pi_gl.h index e196a7535d..e5ad398c52 100644 --- a/plugins/grib_pi/src/pi_gl.h +++ b/plugins/grib_pi/src/pi_gl.h @@ -31,21 +31,20 @@ #ifndef _PIGL_H_ #define _PIGL_H_ - #if defined(__OCPN__ANDROID__) - #include - #include // this is a cut-down version of gl.h - #include +#include +#include // this is a cut-down version of gl.h +#include #elif defined(__MSVC__) - #include "glew.h" +#include "glew.h" #elif defined(__WXOSX__) - #include - #include - typedef void (* _GLUfuncptr)(); - #define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#include +#include +typedef void (*_GLUfuncptr)(); +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 #elif defined(__WXQT__) || defined(__WXGTK__) - #include - #include +#include +#include #endif #endif // __FILE__ diff --git a/plugins/grib_pi/src/pi_ocpndc.cpp b/plugins/grib_pi/src/pi_ocpndc.cpp old mode 100755 new mode 100644 index 6c89891327..9280bfb486 --- a/plugins/grib_pi/src/pi_ocpndc.cpp +++ b/plugins/grib_pi/src/pi_ocpndc.cpp @@ -36,9 +36,9 @@ #include "pi_gl.h" #ifndef __OCPN__ANDROID__ -//#include -//#include -//#include +// #include +// #include +// #include #endif #include "ocpn_plugin.h" @@ -91,13 +91,17 @@ int NextPow2(int size) { //---------------------------------------------------------------------------- /* pass the dc to the constructor, or NULL to use opengl */ pi_ocpnDC::pi_ocpnDC(wxGLCanvas &canvas) - : glcanvas(&canvas), dc(NULL), m_pen(wxNullPen), m_brush(wxNullBrush), m_buseGL(true) { + : glcanvas(&canvas), + dc(NULL), + m_pen(wxNullPen), + m_brush(wxNullBrush), + m_buseGL(true) { #ifdef ocpnUSE_GL #if wxUSE_GRAPHICS_CONTEXT pgc = NULL; #endif m_textforegroundcolour = wxColour(0, 0, 0); - m_buseTex = false; //GetLocaleCanonicalName().IsSameAs(_T("en_US")); + m_buseTex = false; // GetLocaleCanonicalName().IsSameAs(_T("en_US")); workBuf = NULL; workBufSize = 0; s_odc_tess_work_buf = NULL; @@ -116,7 +120,11 @@ pi_ocpnDC::pi_ocpnDC(wxGLCanvas &canvas) } pi_ocpnDC::pi_ocpnDC(wxDC &pdc) - : glcanvas(NULL), dc(&pdc), m_pen(wxNullPen), m_brush(wxNullBrush), m_buseGL(false) { + : glcanvas(NULL), + dc(&pdc), + m_pen(wxNullPen), + m_brush(wxNullBrush), + m_buseGL(false) { #if wxUSE_GRAPHICS_CONTEXT pgc = NULL; wxMemoryDC *pmdc = wxDynamicCast(dc, wxMemoryDC); @@ -128,7 +136,7 @@ pi_ocpnDC::pi_ocpnDC(wxDC &pdc) } #endif m_textforegroundcolour = wxColour(0, 0, 0); - m_buseTex = false; //GetLocaleCanonicalName().IsSameAs(_T("en_US")); + m_buseTex = false; // GetLocaleCanonicalName().IsSameAs(_T("en_US")); workBuf = NULL; workBufSize = 0; #ifdef ocpnUSE_GL @@ -137,12 +145,16 @@ pi_ocpnDC::pi_ocpnDC(wxDC &pdc) } pi_ocpnDC::pi_ocpnDC() - : glcanvas(NULL), dc(NULL), m_pen(wxNullPen), m_brush(wxNullBrush), m_buseGL(true) { + : glcanvas(NULL), + dc(NULL), + m_pen(wxNullPen), + m_brush(wxNullBrush), + m_buseGL(true) { #if wxUSE_GRAPHICS_CONTEXT pgc = NULL; #endif m_textforegroundcolour = wxColour(0, 0, 0); - m_buseTex = false; //GetLocaleCanonicalName().IsSameAs(_T("en_US")); + m_buseTex = false; // GetLocaleCanonicalName().IsSameAs(_T("en_US")); workBuf = NULL; workBufSize = 0; #ifdef ocpnUSE_GL @@ -162,11 +174,11 @@ pi_ocpnDC::~pi_ocpnDC() { } void pi_ocpnDC::SetVP(PlugIn_ViewPort *vp) { -//#ifdef __OCPN__ANDROID__ - if ( m_buseGL ) { + // #ifdef __OCPN__ANDROID__ + if (m_buseGL) { configureShaders(vp->pix_width, vp->pix_height); } -//#endif + // #endif m_vpSize = wxSize(vp->pix_width, vp->pix_height); } @@ -420,7 +432,8 @@ void piDrawGLThickLine(float x1, float y1, float x2, float y2, wxPen pen, glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - GLint pos = glGetAttribLocation(GRIBpi_color_tri_shader_program, "position"); + GLint pos = + glGetAttribLocation(GRIBpi_color_tri_shader_program, "position"); glEnableVertexAttribArray(pos); glVertexAttribPointer(pos, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), vert); @@ -428,8 +441,8 @@ void piDrawGLThickLine(float x1, float y1, float x2, float y2, wxPen pen, mat4x4 I; mat4x4_identity(I); - GLint matloc = - glGetUniformLocation(GRIBpi_color_tri_shader_program, "TransformMatrix"); + GLint matloc = glGetUniformLocation(GRIBpi_color_tri_shader_program, + "TransformMatrix"); glUniformMatrix4fv(matloc, 1, GL_FALSE, (const GLfloat *)I); wxColor c = pen.GetColour(); @@ -439,7 +452,8 @@ void piDrawGLThickLine(float x1, float y1, float x2, float y2, wxPen pen, colorv[2] = c.Blue() / float(256); colorv[3] = c.Alpha() / float(256); - GLint colloc = glGetUniformLocation(GRIBpi_color_tri_shader_program, "color"); + GLint colloc = + glGetUniformLocation(GRIBpi_color_tri_shader_program, "color"); glUniform4fv(colloc, 1, colorv); while (lrun < lpix) { @@ -501,7 +515,8 @@ void piDrawGLThickLine(float x1, float y1, float x2, float y2, wxPen pen, glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - GLint pos = glGetAttribLocation(GRIBpi_color_tri_shader_program, "position"); + GLint pos = + glGetAttribLocation(GRIBpi_color_tri_shader_program, "position"); glEnableVertexAttribArray(pos); glVertexAttribPointer(pos, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), vert); @@ -509,8 +524,8 @@ void piDrawGLThickLine(float x1, float y1, float x2, float y2, wxPen pen, mat4x4 I; mat4x4_identity(I); - GLint matloc = - glGetUniformLocation(GRIBpi_color_tri_shader_program, "TransformMatrix"); + GLint matloc = glGetUniformLocation(GRIBpi_color_tri_shader_program, + "TransformMatrix"); glUniformMatrix4fv(matloc, 1, GL_FALSE, (const GLfloat *)I); wxColor c = pen.GetColour(); @@ -520,7 +535,8 @@ void piDrawGLThickLine(float x1, float y1, float x2, float y2, wxPen pen, colorv[2] = c.Blue() / float(256); colorv[3] = c.Alpha() / float(256); - GLint colloc = glGetUniformLocation(GRIBpi_color_tri_shader_program, "color"); + GLint colloc = + glGetUniformLocation(GRIBpi_color_tri_shader_program, "color"); glUniform4fv(colloc, 1, colorv); glDrawArrays(GL_TRIANGLES, 0, 6); @@ -581,14 +597,15 @@ void pi_ocpnDC::DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, glLineWidth(pen_width); } -#if 1 //def USE_ANDROID_GLES2 +#if 1 // def USE_ANDROID_GLES2 if (b_draw_thick) piDrawGLThickLine(x1, y1, x2, y2, m_pen, b_hiqual); else { glUseProgram(GRIBpi_color_tri_shader_program); float fBuf[4]; - GLint pos = glGetAttribLocation(GRIBpi_color_tri_shader_program, "position"); + GLint pos = + glGetAttribLocation(GRIBpi_color_tri_shader_program, "position"); glVertexAttribPointer(pos, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), fBuf); glEnableVertexAttribArray(pos); @@ -604,7 +621,8 @@ void pi_ocpnDC::DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, colorv[2] = m_pen.GetColour().Blue() / float(256); colorv[3] = 1.0; - GLint colloc = glGetUniformLocation(GRIBpi_color_tri_shader_program, "color"); + GLint colloc = + glGetUniformLocation(GRIBpi_color_tri_shader_program, "color"); glUniform4fv(colloc, 1, colorv); wxDash *dashes; @@ -658,7 +676,6 @@ void pi_ocpnDC::DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, glDrawArrays(GL_LINES, 0, 2); glDisableVertexAttribArray(pos); - } glUseProgram(0); @@ -887,7 +904,7 @@ void pi_ocpnDC::DrawLines(int n, wxPoint points[], wxCoord xoffset, return; } -#if 0 //ndef USE_ANDROID_GLES2 +#if 0 // ndef USE_ANDROID_GLES2 glBegin(GL_LINE_STRIP); for (int i = 0; i < n; i++) @@ -909,7 +926,8 @@ void pi_ocpnDC::DrawLines(int n, wxPoint points[], wxCoord xoffset, glUseProgram(GRIBpi_color_tri_shader_program); - GLint pos = glGetAttribLocation(GRIBpi_color_tri_shader_program, "position"); + GLint pos = + glGetAttribLocation(GRIBpi_color_tri_shader_program, "position"); glVertexAttribPointer(pos, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), workBuf); glEnableVertexAttribArray(pos); @@ -925,7 +943,8 @@ void pi_ocpnDC::DrawLines(int n, wxPoint points[], wxCoord xoffset, colorv[3] = m_pen.GetColour().Alpha() / float(256); 1.0; - GLint colloc = glGetUniformLocation(GRIBpi_color_tri_shader_program, "color"); + GLint colloc = + glGetUniformLocation(GRIBpi_color_tri_shader_program, "color"); glUniform4fv(colloc, 1, colorv); glDrawArrays(GL_LINE_STRIP, 0, n); @@ -979,8 +998,7 @@ void pi_ocpnDC::StrokeLines(int n, wxPoint *points) { void pi_ocpnDC::DrawGLLineArray(int n, float *vertex_array, float *color_array, unsigned char *color_array_ub, bool b_hiqual) { - if(!n) - return; + if (!n) return; #ifdef ocpnUSE_GL if (ConfigurePen()) { @@ -1016,7 +1034,7 @@ void pi_ocpnDC::DrawGLLineArray(int n, float *vertex_array, float *color_array, glLineWidth(wxMax(g_piGLMinSymbolLineWidth, 1)); } -#if 0//ndef USE_ANDROID_GLES2 +#if 0 // ndef USE_ANDROID_GLES2 glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); @@ -1038,12 +1056,14 @@ void pi_ocpnDC::DrawGLLineArray(int n, float *vertex_array, float *color_array, #else glUseProgram(GRIBpi_colorv_tri_shader_program); - GLint pos = glGetAttribLocation(GRIBpi_colorv_tri_shader_program, "position"); + GLint pos = + glGetAttribLocation(GRIBpi_colorv_tri_shader_program, "position"); glVertexAttribPointer(pos, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), vertex_array); glEnableVertexAttribArray(pos); - GLint colloc = glGetAttribLocation(GRIBpi_colorv_tri_shader_program, "colorv"); + GLint colloc = + glGetAttribLocation(GRIBpi_colorv_tri_shader_program, "colorv"); glVertexAttribPointer(colloc, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), color_array); glEnableVertexAttribArray(colloc); @@ -1069,7 +1089,7 @@ void pi_ocpnDC::DrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h) { if (dc) dc->DrawRectangle(x, y, w, h); #ifdef ocpnUSE_GL else { -#if 0//ndef USE_ANDROID_GLES2 +#if 0 // ndef USE_ANDROID_GLES2 if (ConfigureBrush()) { glBegin(GL_QUADS); glVertex2i(x, y); @@ -1175,7 +1195,7 @@ void pi_ocpnDC::DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h, wxCoord x1 = x + r, x2 = x + w - r; wxCoord y1 = y + r, y2 = y + h - r; -#if 1//def USE_ANDROID_GLES2 +#if 1 // def USE_ANDROID_GLES2 // Grow the work buffer as necessary size_t bufReq = steps * 8 * 2 * sizeof(float); // large, to be sure @@ -1211,7 +1231,8 @@ void pi_ocpnDC::DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h, bcolorv[2] = m_brush.GetColour().Blue() / float(256); bcolorv[3] = m_brush.GetColour().Alpha() / float(256); - GLint bcolloc = glGetUniformLocation(GRIBpi_color_tri_shader_program, "color"); + GLint bcolloc = + glGetUniformLocation(GRIBpi_color_tri_shader_program, "color"); glUniform4fv(bcolloc, 1, bcolorv); float angle = 0.; @@ -1227,8 +1248,8 @@ void pi_ocpnDC::DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h, Q[3][0] = xoffset; Q[3][1] = yoffset; - GLint matloc = - glGetUniformLocation(GRIBpi_color_tri_shader_program, "TransformMatrix"); + GLint matloc = glGetUniformLocation(GRIBpi_color_tri_shader_program, + "TransformMatrix"); glUniformMatrix4fv(matloc, 1, GL_FALSE, (const GLfloat *)Q); // Perform the actual drawing. @@ -1238,8 +1259,8 @@ void pi_ocpnDC::DrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h, // Restore the per-object transform to Identity Matrix mat4x4 IM; mat4x4_identity(IM); - GLint matlocf = - glGetUniformLocation(GRIBpi_color_tri_shader_program, "TransformMatrix"); + GLint matlocf = glGetUniformLocation(GRIBpi_color_tri_shader_program, + "TransformMatrix"); glUniformMatrix4fv(matlocf, 1, GL_FALSE, (const GLfloat *)IM); glUseProgram(0); @@ -1472,8 +1493,8 @@ void pi_ocpnDC::DrawPolygon(int n, wxPoint points[], wxCoord xoffset, Q[3][0] = xoffset; Q[3][1] = yoffset; - GLint matloc = - glGetUniformLocation(GRIBpi_color_tri_shader_program, "TransformMatrix"); + GLint matloc = glGetUniformLocation(GRIBpi_color_tri_shader_program, + "TransformMatrix"); glUniformMatrix4fv(matloc, 1, GL_FALSE, (const GLfloat *)Q); // Perform the actual drawing. @@ -1507,8 +1528,8 @@ void pi_ocpnDC::DrawPolygon(int n, wxPoint points[], wxCoord xoffset, // Restore the per-object transform to Identity Matrix mat4x4 IM; mat4x4_identity(IM); - GLint matlocf = - glGetUniformLocation(GRIBpi_color_tri_shader_program, "TransformMatrix"); + GLint matlocf = glGetUniformLocation(GRIBpi_color_tri_shader_program, + "TransformMatrix"); glUniformMatrix4fv(matlocf, 1, GL_FALSE, (const GLfloat *)IM); glUseProgram(0); @@ -1558,7 +1579,7 @@ typedef union { } info; } GLvertex; -#if 0 //ndef USE_ANDROID_GLES2 +#if 0 // ndef USE_ANDROID_GLES2 void APIENTRY pi_ocpnDCcombineCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut) { @@ -1598,7 +1619,7 @@ void APIENTRY ocpnDCendCallback() { glEnd(); } // GLSL callbacks -#if 1 //def USE_ANDROID_GLES2 +#if 1 // def USE_ANDROID_GLES2 static std::list odc_combine_work_data; static void pi_odc_combineCallbackD(GLdouble coords[3], @@ -1684,7 +1705,7 @@ void pi_odc_endCallbackD_GLSL(void *data) { } #endif -#endif //#ifdef ocpnUSE_GL +#endif // #ifdef ocpnUSE_GL void pi_ocpnDC::DrawPolygonTessellated(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { @@ -1700,7 +1721,7 @@ void pi_ocpnDC::DrawPolygonTessellated(int n, wxPoint points[], wxCoord xoffset, return; } -#if 1 //def USE_ANDROID_GLES2 +#if 1 // def USE_ANDROID_GLES2 m_tobj = gluNewTess(); s_odc_tess_vertex_idx = 0; @@ -1868,7 +1889,7 @@ void pi_ocpnDC::DrawBitmap(const wxBitmap &bitmap, wxCoord x, wxCoord y, glColor4f(1, 1, 1, 1); GLDrawBlendData(x, y, w, h, GL_RGBA, e); - delete[](e); + delete[] (e); } else { glRasterPos2i(x, y); glPixelZoom(1, -1); /* draw data from top to bottom */ @@ -1899,7 +1920,7 @@ void pi_ocpnDC::DrawText(const wxString &text, wxCoord x, wxCoord y) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); -#if 0//ndef USE_ANDROID_GLES2 +#if 0 // ndef USE_ANDROID_GLES2 glPushMatrix(); glTranslatef(x, y, 0); @@ -1917,15 +1938,16 @@ void pi_ocpnDC::DrawText(const wxString &text, wxCoord x, wxCoord y) { } else { wxScreenDC sdc; sdc.SetFont(m_font); - sdc.GetMultiLineTextExtent(text, &w, &h, NULL, &m_font); /*we need to handle multiline*/ + sdc.GetMultiLineTextExtent(text, &w, &h, NULL, + &m_font); /*we need to handle multiline*/ int ww, hw; - sdc.GetTextExtent("W", &ww, &hw); // metric - w += ww; // RHS padding. + sdc.GetTextExtent("W", &ww, &hw); // metric + w += ww; // RHS padding. w *= OCPN_GetWinDIPScaleFactor(); h *= OCPN_GetWinDIPScaleFactor(); - h *= 2; //TODO //Some trouble with math or text sizing. - // Add "fluff" to text bitmap size. + h *= 2; // TODO //Some trouble with math or text sizing. + // Add "fluff" to text bitmap size. /* create bitmap of appropriate size and select it */ wxBitmap bmp(w, h); @@ -2006,7 +2028,7 @@ void pi_ocpnDC::DrawText(const wxString &text, wxCoord x, wxCoord y) { float u = (float)w / TextureWidth, v = (float)h / TextureHeight; -#if 0//ndef USE_ANDROID_GLES2 +#if 0 // ndef USE_ANDROID_GLES2 glColor3ub(0, 0, 0); glBegin(GL_QUADS); @@ -2046,8 +2068,10 @@ void pi_ocpnDC::DrawText(const wxString &text, wxCoord x, wxCoord y) { glUseProgram(pi_texture_2D_shader_program); // Get pointers to the attributes in the program. - GLint mPosAttrib = glGetAttribLocation(pi_texture_2D_shader_program, "aPos"); - GLint mUvAttrib = glGetAttribLocation(pi_texture_2D_shader_program, "aUV"); + GLint mPosAttrib = + glGetAttribLocation(pi_texture_2D_shader_program, "aPos"); + GLint mUvAttrib = + glGetAttribLocation(pi_texture_2D_shader_program, "aUV"); // Set up the texture sampler to texture unit 0 GLint texUni = glGetUniformLocation(pi_texture_2D_shader_program, "uTex"); diff --git a/plugins/grib_pi/src/pi_shaders.cpp b/plugins/grib_pi/src/pi_shaders.cpp index 37721d137d..dde669148b 100644 --- a/plugins/grib_pi/src/pi_shaders.cpp +++ b/plugins/grib_pi/src/pi_shaders.cpp @@ -30,18 +30,15 @@ #include #endif - - #ifdef USE_ANDROID_GLES2 -const GLchar* PI_shader_preamble = -"\n"; +const GLchar* PI_shader_preamble = "\n"; #else const GLchar* PI_shader_preamble = -"#version 120\n" -"#define precision\n" -"#define lowp\n" -"#define mediump\n" -"#define highp\n"; + "#version 120\n" + "#define precision\n" + "#define lowp\n" + "#define mediump\n" + "#define highp\n"; #endif // Simple colored triangle shader @@ -212,10 +209,13 @@ bool pi_loadShaders() { // Simple colored triangle shader if (!GRIBpi_color_tri_shader_program) { - auto shaderProgram = PI_GLShaderProgram::Builder() - .addShaderFromSource(color_tri_vertex_shader_source, GL_VERTEX_SHADER) - .addShaderFromSource(color_tri_fragment_shader_source, GL_FRAGMENT_SHADER) - .linkProgram(); + auto shaderProgram = + PI_GLShaderProgram::Builder() + .addShaderFromSource(color_tri_vertex_shader_source, + GL_VERTEX_SHADER) + .addShaderFromSource(color_tri_fragment_shader_source, + GL_FRAGMENT_SHADER) + .linkProgram(); GRIBpi_color_tri_shader_program = shaderProgram.programId(); } @@ -269,10 +269,13 @@ bool pi_loadShaders() { // Array colored triangle shader if (!GRIBpi_colorv_tri_shader_program) { - auto shaderProgram = PI_GLShaderProgram::Builder() - .addShaderFromSource(colorv_tri_vertex_shader_source, GL_VERTEX_SHADER) - .addShaderFromSource(colorv_tri_fragment_shader_source, GL_FRAGMENT_SHADER) - .linkProgram(); + auto shaderProgram = + PI_GLShaderProgram::Builder() + .addShaderFromSource(colorv_tri_vertex_shader_source, + GL_VERTEX_SHADER) + .addShaderFromSource(colorv_tri_fragment_shader_source, + GL_FRAGMENT_SHADER) + .linkProgram(); GRIBpi_colorv_tri_shader_program = shaderProgram.programId(); } @@ -326,10 +329,13 @@ bool pi_loadShaders() { // Simple 2D texture shader if (!pi_texture_2D_shader_program) { - auto shaderProgram = PI_GLShaderProgram::Builder() - .addShaderFromSource(texture_2D_vertex_shader_source, GL_VERTEX_SHADER) - .addShaderFromSource(texture_2D_fragment_shader_source, GL_FRAGMENT_SHADER) - .linkProgram(); + auto shaderProgram = + PI_GLShaderProgram::Builder() + .addShaderFromSource(texture_2D_vertex_shader_source, + GL_VERTEX_SHADER) + .addShaderFromSource(texture_2D_fragment_shader_source, + GL_FRAGMENT_SHADER) + .linkProgram(); pi_texture_2D_shader_program = shaderProgram.programId(); } @@ -428,10 +434,13 @@ bool pi_loadShaders() { // Circle shader if (!pi_circle_filled_shader_program) { - auto shaderProgram = PI_GLShaderProgram::Builder() - .addShaderFromSource(circle_filled_vertex_shader_source, GL_VERTEX_SHADER) - .addShaderFromSource(circle_filled_fragment_shader_source, GL_FRAGMENT_SHADER) - .linkProgram(); + auto shaderProgram = + PI_GLShaderProgram::Builder() + .addShaderFromSource(circle_filled_vertex_shader_source, + GL_VERTEX_SHADER) + .addShaderFromSource(circle_filled_fragment_shader_source, + GL_FRAGMENT_SHADER) + .linkProgram(); pi_circle_filled_shader_program = shaderProgram.programId(); } @@ -551,7 +560,8 @@ void configureShaders(float width, float height) { mat4x4_identity(I); glUseProgram(GRIBpi_color_tri_shader_program); - GLint matloc = glGetUniformLocation(GRIBpi_color_tri_shader_program, "MVMatrix"); + GLint matloc = + glGetUniformLocation(GRIBpi_color_tri_shader_program, "MVMatrix"); glUniformMatrix4fv(matloc, 1, GL_FALSE, (const GLfloat*)vp_transform); GLint transloc = glGetUniformLocation(GRIBpi_color_tri_shader_program, "TransformMatrix"); @@ -586,4 +596,3 @@ void configureShaders(float width, float height) { glUseProgram(0); } - diff --git a/plugins/grib_pi/src/pi_shaders.h b/plugins/grib_pi/src/pi_shaders.h index 81f214670a..32b3ff09b9 100644 --- a/plugins/grib_pi/src/pi_shaders.h +++ b/plugins/grib_pi/src/pi_shaders.h @@ -39,104 +39,102 @@ extern GLint pi_circle_filled_shader_program; bool pi_loadShaders(); void configureShaders(float width, float height); -extern const GLchar* PI_shader_preamble; +extern const GLchar *PI_shader_preamble; enum Consts { INFOLOG_LEN = 512 }; -class PI_GLShaderProgram -{ +class PI_GLShaderProgram { public: + class Builder { + public: + Builder() : linked_(false) { programId_ = glCreateProgram(); } + + Builder &addShaderFromSource(std::string const &shaderSource, + GLenum shaderType) { + char const *shaderCStr = shaderSource.c_str(); + GLuint shaderId = glCreateShader(shaderType); + + GLchar const *files[] = {PI_shader_preamble, shaderCStr}; + GLint lengths[] = {(GLint)strlen(PI_shader_preamble), + (GLint)strlen(shaderCStr)}; + + glShaderSource(shaderId, 2, files, lengths); + // glShaderSource(shaderId, 1, &shaderCStr, nullptr); + + glCompileShader(shaderId); + glGetShaderiv(shaderId, GL_COMPILE_STATUS, &success); + if (!success) { + glGetShaderInfoLog(shaderId, INFOLOG_LEN, NULL, infoLog); + printf("ERROR::SHADER::COMPILATION_FAILED\n%s\n", infoLog); + // ret_val = false; + } + + glAttachShader(programId_, shaderId); + return *this; + } + + // void addShaderFromFile(std::string const &shaderFile, GLenum + // shaderType) { + // std::ifstream fileName(shaderFile); + // std::istreambuf_iterator fileBegin(fileName), fileEnd; + // std::string fileContents(fileBegin, fileEnd); + // return addShaderFromSource(fileContents, shaderType); + // } + + PI_GLShaderProgram linkProgram() { + glLinkProgram(programId_); + glGetProgramiv(programId_, GL_LINK_STATUS, + &linkSuccess); // requesting the status + if (linkSuccess == GL_FALSE) { + glGetProgramInfoLog(programId_, INFOLOG_LEN, NULL, infoLog); + printf("ERROR::SHADER::LINK_FAILED\n%s\n", infoLog); + } + + PI_GLShaderProgram theProgram(programId_); + // deleteAttachedShaders(programId_); + linked_ = true; + return theProgram; + } - class Builder { - public: - Builder() : linked_(false) { - programId_ = glCreateProgram(); - } - - Builder & addShaderFromSource(std::string const &shaderSource, GLenum shaderType) { - char const *shaderCStr = shaderSource.c_str(); - GLuint shaderId = glCreateShader(shaderType); - - GLchar const* files[] = { PI_shader_preamble, shaderCStr }; - GLint lengths[] = { (GLint)strlen(PI_shader_preamble), (GLint)strlen(shaderCStr) }; - - glShaderSource(shaderId, 2, files, lengths); - //glShaderSource(shaderId, 1, &shaderCStr, nullptr); - - glCompileShader(shaderId); - glGetShaderiv(shaderId, GL_COMPILE_STATUS, &success); - if (!success) { - glGetShaderInfoLog(shaderId, INFOLOG_LEN, NULL, infoLog); - printf("ERROR::SHADER::COMPILATION_FAILED\n%s\n", infoLog); - //ret_val = false; - } - - glAttachShader(programId_, shaderId); - return *this; - } - -// void addShaderFromFile(std::string const &shaderFile, GLenum shaderType) { -// std::ifstream fileName(shaderFile); -// std::istreambuf_iterator fileBegin(fileName), fileEnd; -// std::string fileContents(fileBegin, fileEnd); -// return addShaderFromSource(fileContents, shaderType); -// } - - PI_GLShaderProgram linkProgram() { - glLinkProgram(programId_); - glGetProgramiv( programId_, GL_LINK_STATUS, &linkSuccess); //requesting the status - if (linkSuccess == GL_FALSE) { - glGetProgramInfoLog(programId_, INFOLOG_LEN, NULL, infoLog); - printf("ERROR::SHADER::LINK_FAILED\n%s\n", infoLog); - } - - PI_GLShaderProgram theProgram(programId_); - //deleteAttachedShaders(programId_); - linked_ = true; - return theProgram; - } - - ~Builder() { - if(!linked_) { - glDeleteProgram(programId_); - } - } - private: - GLuint programId_; - bool linked_; - GLint success; - GLint linkSuccess; - GLchar infoLog[INFOLOG_LEN]; - }; - - PI_GLShaderProgram() : programId_(0) { } - - PI_GLShaderProgram(PI_GLShaderProgram &&other) { - *this = std::move(other); + ~Builder() { + if (!linked_) { + glDeleteProgram(programId_); + } } - PI_GLShaderProgram &operator=(PI_GLShaderProgram &&other) - { - programId_ = other.programId_; - other.programId_ = 0; + private: + GLuint programId_; + bool linked_; + GLint success; + GLint linkSuccess; + GLchar infoLog[INFOLOG_LEN]; + }; + + PI_GLShaderProgram() : programId_(0) {} - if (other.programId_ != 0) { - glDeleteProgram(other.programId_); - } + PI_GLShaderProgram(PI_GLShaderProgram &&other) { *this = std::move(other); } - return *this; + PI_GLShaderProgram &operator=(PI_GLShaderProgram &&other) { + programId_ = other.programId_; + other.programId_ = 0; + + if (other.programId_ != 0) { + glDeleteProgram(other.programId_); } - ~PI_GLShaderProgram() { } + return *this; + } + + ~PI_GLShaderProgram() {} + + GLuint programId() const { return programId_; } - GLuint programId() const { return programId_; } + PI_GLShaderProgram(PI_GLShaderProgram const &other) = delete; + PI_GLShaderProgram &operator=(PI_GLShaderProgram const &other) = delete; - PI_GLShaderProgram(PI_GLShaderProgram const &other) = delete; - PI_GLShaderProgram &operator=(PI_GLShaderProgram const &other) = delete; private: - PI_GLShaderProgram(GLuint programId) : programId_(programId) { } - GLuint programId_; + PI_GLShaderProgram(GLuint programId) : programId_(programId) {} + GLuint programId_; }; - #endif diff --git a/plugins/grib_pi/src/smapi.cpp b/plugins/grib_pi/src/smapi.cpp index 676c126831..01af18d13e 100644 --- a/plugins/grib_pi/src/smapi.cpp +++ b/plugins/grib_pi/src/smapi.cpp @@ -186,8 +186,8 @@ bool wxMapiSession::Logon(const wxString& sProfileName, flags | MAPI_NEW_SESSION, 0, &m_data->m_hSession); if (nError != SUCCESS_SUCCESS && nError != MAPI_E_USER_ABORT) { // Failed to create a create mapi session, try to acquire a shared mapi - // session wxLogDebug(_T("Failed to logon to MAPI using a new session, trying - // to acquire a shared one\n")); + // session wxLogDebug(_T("Failed to logon to MAPI using a new session, + // trying to acquire a shared one\n")); nError = m_data->m_lpfnMAPILogon(nUIParam, NULL, NULL, 0, 0, &m_data->m_hSession); if (nError == SUCCESS_SUCCESS) {