BOOL CUpdateUtil::DownloadXMLfileEx(CString& strSrcURL, CString& strXMLdoc, CString& strFilePath, CString& strLoginId, CString& strLoginPassword) { BOOL retval = FALSE; CHttpFileDownload *pHttpFileDownload =NULL; UTIL_CANCEL(); pHttpFileDownload = new CHttpFileDownload(strSrcURL, HTTP_DOWNLOAD_PATH_TEMP, strLoginId, strLoginPassword); TRACE("Download Start : %s\n", strSrcURL); BOOL bDownResult = pHttpFileDownload->Start(); if (bDownResult) { pHttpFileDownload->GetDownFilePath(strFilePath); } else { PTR_REMOVE(pHttpFileDownload); SetLastError(UPDATE_ERROR_FAIL_DOWNLOADXMLFILE); return FALSE; } PTR_REMOVE(pHttpFileDownload); UTIL_CANCEL(); return OpenXML(strFilePath, strXMLdoc); }
void WeatherRouting::OnOpen( wxCommandEvent& event ) { wxString error; wxFileDialog openDialog ( this, _( "Select Configuration" ), _("~"), wxT ( "" ), wxT ( "XML files (*.xml)|*.XML;*.xml|All files (*.*)|*.*" ), wxFD_OPEN ); if( openDialog.ShowModal() == wxID_OK ) OpenXML(openDialog.GetPath()); }
void InternetRetrievalDialog::Load() { if(m_bLoaded) return; m_bLoaded = true; // create a image list for the list with check wxImageList *imglist = new wxImageList(20, 20, true, 1); imglist->Add(wxBitmap(check_xpm)); m_lUrls->AssignImageList(imglist, wxIMAGE_LIST_SMALL); m_lUrls->InsertColumn(SELECTED, _("Selected")); m_lUrls->InsertColumn(SERVER, _("Server")); m_lUrls->InsertColumn(CONTENTS, _("Contents")); m_lUrls->InsertColumn(MAP_AREA, _("Map Area")); wxFileConfig *pConf = m_weatherfax_pi.m_pconfig; /* remove from config all cordinate sets */ pConf->SetPath ( _T ( "/Settings/WeatherFax/InternetRetrieval" ) ); wxString s; pConf->Read ( _T ( "ContainsLat" ), &s, _T("") ); m_tContainsLat->SetValue(s); pConf->Read ( _T ( "ContainsLon" ), &s, _T("") ); m_tContainsLon->SetValue(s); wxString servers; pConf->Read ( _T ( "Servers" ), &servers, _T("")); /* split at each ; to get all the names in a list */ std::list<wxString> serverlist; while(servers.size()) { serverlist.push_back(servers.BeforeFirst(';')); servers = servers.AfterFirst(';'); } s = wxFileName::GetPathSeparator(); OpenXML(*GetpSharedDataLocation() + _T("plugins") + s + _T("weatherfax_pi") + s + _T("data") + s + _T("WeatherFaxInternetRetrieval.xml")); m_lServers->DeselectAll(); for(unsigned int i=0; i < m_lServers->GetCount(); i++) for(std::list<wxString>::iterator it = serverlist.begin(); it != serverlist.end(); it++) if(m_lServers->GetString(i) == *it) m_lServers->SetSelection(i); m_bDisableFilter = false; Filter(); }
GDALDataset * VRTDataset::Create( const char * pszName, int nXSize, int nYSize, int nBands, GDALDataType eType, char ** papszOptions ) { VRTDataset *poDS = NULL; int iBand = 0; (void) papszOptions; if( EQUALN(pszName,"<VRTDataset",11) ) { GDALDataset *poDS = OpenXML( pszName, NULL, GA_Update ); if (poDS) poDS->SetDescription( "<FromXML>" ); return poDS; } else { const char *pszSubclass = CSLFetchNameValue( papszOptions, "SUBCLASS" ); if( pszSubclass == NULL || EQUAL(pszSubclass,"VRTDataset") ) poDS = new VRTDataset( nXSize, nYSize ); else if( EQUAL(pszSubclass,"VRTWarpedDataset") ) { poDS = new VRTWarpedDataset( nXSize, nYSize ); } else { CPLError( CE_Failure, CPLE_AppDefined, "SUBCLASS=%s not recognised.", pszSubclass ); return NULL; } poDS->eAccess = GA_Update; poDS->SetDescription( pszName ); for( iBand = 0; iBand < nBands; iBand++ ) poDS->AddBand( eType, NULL ); poDS->bNeedsFlush = 1; poDS->oOvManager.Initialize( poDS, pszName ); return poDS; } }
int main() { FILE *rFile = fopen("Parsefile.txt", "w"); FILE *bFile = fopen("Samplefile.bin", "rb"); field fd = parseFieldStructure(); fseek (bFile, 0, SEEK_END); long fSize = ftell (bFile); fseek (bFile, 0, SEEK_SET); BYTE *buffer = new BYTE[fSize]; fread(buffer, fSize, 1, bFile); int numRec = fSize / fd.totBytes; int fieldIdx = 0, fieldIncIdx = 0, intPosIdx = 0, strIdx = 0; int fInt = 0; char fStr[255]; bool typeInt = false; XML* xml = new XML(); xml->LoadText("<data></data>"); XMLElement* root = xml->GetRootElement(); XMLElement* record[numRec]; XMLElement* fields[115 * numRec]; for (int recIdx = 0; recIdx < numRec; recIdx++) { record[recIdx] = new XMLElement(root, "record"); root->InsertElement(recIdx, record[recIdx]); bytesToIntger(fStr, recIdx + 1); record[recIdx]->AddVariable("id", fStr); for (int xmlIdx = 115 * recIdx; xmlIdx < (1 + recIdx) * 115; xmlIdx++) { fields[xmlIdx] = new XMLElement(record[recIdx], "field"); record[recIdx]->InsertElement(xmlIdx, fields[xmlIdx]); } } int xmlIdx = 0; for (int idx = 0; idx <= fSize - 1; idx++) { if(idx >= fieldIncIdx) { if(typeInt) { bytesToIntger(fStr, fInt); } else { bytesToStr(fStr, strIdx); } if(fieldIdx > 0) { fields[xmlIdx - 1]->AddVariable(fd.name[fieldIdx - 1], fStr); } else if(idx != 0) { fields[xmlIdx - 1]->AddVariable(fd.name[114], fStr); } xmlIdx++; typeInt = fd.type[fieldIdx] == 'I'; fprintf(rFile, "%s", fStr); fprintf(rFile, "\t"); fieldIncIdx += fd.bytes[fieldIdx]; fieldIdx = fieldIdx < 114 ? fieldIdx + 1 : 0; if (fieldIdx == 0) fprintf(rFile, "\n"); } if(buffer[idx] == 0xe9) { fieldIncIdx++; } else if(typeInt) { fInt <<= 8; fInt = (fInt | buffer[idx]); } else if (buffer[idx] > 0x1f && buffer[idx] < 0x7f) { fStr[strIdx++] = buffer[idx]; } } xml->Save("XMLfile.xml"); fclose(rFile); fclose(bFile); /* And now we can search for a attrinute like subscriber_no in our xml-file. */ OpenXML("XMLfile.xml", "subscriber_no"); return 0; }
MainWindow::MainWindow() : mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)), mApplications(new ApplicationList(this)), mTranslation(new TranslationHandler(this)), mLanguages(new QActionGroup(this)), mLogView(NULL), mHelpWindow(NULL), mProject(NULL), mExiting(false) { mUI.setupUi(this); mUI.mResults->Initialize(mSettings, mApplications); mThread = new ThreadHandler(this); mLogView = new LogView(mSettings); connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles())); connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); connect(mUI.mActionOpenXML, SIGNAL(triggered()), this, SLOT(OpenXML())); connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool))); connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool))); connect(mUI.mActionShowWarnings, SIGNAL(toggled(bool)), this, SLOT(ShowWarnings(bool))); connect(mUI.mActionShowPortability, SIGNAL(toggled(bool)), this, SLOT(ShowPortability(bool))); connect(mUI.mActionShowPerformance, SIGNAL(toggled(bool)), this, SLOT(ShowPerformance(bool))); connect(mUI.mActionShowInformation, SIGNAL(toggled(bool)), this, SLOT(ShowInformation(bool))); connect(mUI.mActionCheckAll, SIGNAL(triggered()), this, SLOT(CheckAll())); connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll())); connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults())); connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults())); connect(mUI.mActionShowHidden, SIGNAL(triggered()), mUI.mResults, SLOT(ShowHiddenResults())); connect(mUI.mActionViewLog, SIGNAL(triggered()), this, SLOT(ShowLogView())); connect(mUI.mActionViewStats, SIGNAL(triggered()), this, SLOT(ShowStatistics())); connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck())); connect(mUI.mActionStop, SIGNAL(triggered()), this, SLOT(StopChecking())); connect(mUI.mActionSave, SIGNAL(triggered()), this, SLOT(Save())); connect(mUI.mActionAbout, SIGNAL(triggered()), this, SLOT(About())); connect(mUI.mActionLicense, SIGNAL(triggered()), this, SLOT(ShowLicense())); connect(mUI.mActionToolBarMain, SIGNAL(toggled(bool)), this, SLOT(ToggleMainToolBar())); connect(mUI.mActionToolBarView, SIGNAL(toggled(bool)), this, SLOT(ToggleViewToolBar())); connect(mUI.mActionAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors())); connect(mThread, SIGNAL(Done()), this, SLOT(CheckDone())); connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded())); connect(mUI.mResults, SIGNAL(ResultsHidden(bool)), mUI.mActionShowHidden, SLOT(setEnabled(bool))); connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu())); connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFile())); connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(OpenProjectFile())); connect(mUI.mActionCloseProjectFile, SIGNAL(triggered()), this, SLOT(CloseProjectFile())); connect(mUI.mActionEditProjectFile, SIGNAL(triggered()), this, SLOT(EditProjectFile())); connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents())); CreateLanguageMenuItems(); LoadSettings(); mThread->Initialize(mUI.mResults); FormatAndSetTitle(); EnableCheckButtons(true); mUI.mActionClearResults->setEnabled(false); mUI.mActionSave->setEnabled(false); mUI.mActionRecheck->setEnabled(false); EnableProjectOpenActions(true); EnableProjectActions(false); QStringList args = QCoreApplication::arguments(); //Remove the application itself args.removeFirst(); if (!args.isEmpty()) { DoCheckFiles(args); } }
MainWindow::MainWindow() : mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)), mApplications(new ApplicationList(this)), mTranslation(new TranslationHandler(this)), mLogView(NULL), mProject(NULL), mPlatformActions(new QActionGroup(this)), mExiting(false) { mUI.setupUi(this); mUI.mResults->Initialize(mSettings, mApplications); mThread = new ThreadHandler(this); mLogView = new LogView; // Filter timer to delay filtering results slightly while typing mFilterTimer = new QTimer(this); mFilterTimer->setInterval(500); mFilterTimer->setSingleShot(true); connect(mFilterTimer, SIGNAL(timeout()), this, SLOT(FilterResults())); // "Filter" toolbar mLineEditFilter = new QLineEdit(mUI.mToolBarFilter); mLineEditFilter->setPlaceholderText(tr("Quick Filter:")); mUI.mToolBarFilter->addWidget(mLineEditFilter); connect(mLineEditFilter, SIGNAL(textChanged(const QString&)), mFilterTimer, SLOT(start())); connect(mLineEditFilter, SIGNAL(returnPressed()), this, SLOT(FilterResults())); connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles())); connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); connect(mUI.mActionOpenXML, SIGNAL(triggered()), this, SLOT(OpenXML())); connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool))); connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool))); connect(mUI.mActionShowWarnings, SIGNAL(toggled(bool)), this, SLOT(ShowWarnings(bool))); connect(mUI.mActionShowPortability, SIGNAL(toggled(bool)), this, SLOT(ShowPortability(bool))); connect(mUI.mActionShowPerformance, SIGNAL(toggled(bool)), this, SLOT(ShowPerformance(bool))); connect(mUI.mActionShowInformation, SIGNAL(toggled(bool)), this, SLOT(ShowInformation(bool))); connect(mUI.mActionCheckAll, SIGNAL(triggered()), this, SLOT(CheckAll())); connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll())); connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults())); connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults())); connect(mUI.mActionShowHidden, SIGNAL(triggered()), mUI.mResults, SLOT(ShowHiddenResults())); connect(mUI.mActionViewLog, SIGNAL(triggered()), this, SLOT(ShowLogView())); connect(mUI.mActionViewStats, SIGNAL(triggered()), this, SLOT(ShowStatistics())); connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck())); connect(mUI.mActionStop, SIGNAL(triggered()), this, SLOT(StopChecking())); connect(mUI.mActionSave, SIGNAL(triggered()), this, SLOT(Save())); // About menu connect(mUI.mActionAbout, SIGNAL(triggered()), this, SLOT(About())); connect(mUI.mActionLicense, SIGNAL(triggered()), this, SLOT(ShowLicense())); // View > Toolbar menu connect(mUI.mActionToolBarMain, SIGNAL(toggled(bool)), this, SLOT(ToggleMainToolBar())); connect(mUI.mActionToolBarView, SIGNAL(toggled(bool)), this, SLOT(ToggleViewToolBar())); connect(mUI.mActionToolBarFilter, SIGNAL(toggled(bool)), this, SLOT(ToggleFilterToolBar())); connect(mUI.mActionAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors())); connect(mThread, SIGNAL(Done()), this, SLOT(CheckDone())); connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded())); connect(mUI.mResults, SIGNAL(ResultsHidden(bool)), mUI.mActionShowHidden, SLOT(setEnabled(bool))); connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu())); // File menu connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFile())); connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(OpenProjectFile())); connect(mUI.mActionCloseProjectFile, SIGNAL(triggered()), this, SLOT(CloseProjectFile())); connect(mUI.mActionEditProjectFile, SIGNAL(triggered()), this, SLOT(EditProjectFile())); connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents())); LoadSettings(); mThread->Initialize(mUI.mResults); FormatAndSetTitle(); EnableCheckButtons(true); mUI.mActionClearResults->setEnabled(false); mUI.mActionSave->setEnabled(false); mUI.mActionRecheck->setEnabled(false); EnableProjectOpenActions(true); EnableProjectActions(false); // Must setup MRU menu before CLI param handling as it can load a // project file and update MRU menu. for (int i = 0; i < MaxRecentProjects; ++i) { mRecentProjectActs[i] = new QAction(this); mRecentProjectActs[i]->setVisible(false); connect(mRecentProjectActs[i], SIGNAL(triggered()), this, SLOT(OpenRecentProject())); } mRecentProjectActs[MaxRecentProjects] = NULL; // The separator mUI.mActionProjectMRU->setVisible(false); UpdateMRUMenuItems(); QStringList args = QCoreApplication::arguments(); //Remove the application itself args.removeFirst(); if (!args.isEmpty()) { HandleCLIParams(args); } for (int i = 0; i < mPlatforms.getCount(); i++) { Platform plat = mPlatforms.mPlatforms[i]; QAction *act = new QAction(this); plat.mActMainWindow = act; mPlatforms.mPlatforms[i] = plat; act->setText(plat.mTitle); act->setData(plat.mType); act->setCheckable(true); act->setActionGroup(mPlatformActions); mUI.mMenuCheck->insertAction(mUI.mActionPlatforms, act); connect(act, SIGNAL(triggered()), this, SLOT(SelectPlatform())); } // For Windows platforms default to Win32 checked platform. // For other platforms default to unspecified/default which means the // platform Cppcheck GUI was compiled on. #if defined(_WIN32) Platform &plat = mPlatforms.get(Settings::Win32A); #else Platform &plat = mPlatforms.get(Settings::Unspecified); #endif plat.mActMainWindow->setChecked(true); mSettings->setValue(SETTINGS_CHECKED_PLATFORM, plat.mType); }
GDALDataset *VRTDataset::Open( GDALOpenInfo * poOpenInfo ) { char *pszVRTPath = NULL; /* -------------------------------------------------------------------- */ /* Does this appear to be a virtual dataset definition XML */ /* file? */ /* -------------------------------------------------------------------- */ if( !Identify( poOpenInfo ) ) return NULL; /* -------------------------------------------------------------------- */ /* Try to read the whole file into memory. */ /* -------------------------------------------------------------------- */ char *pszXML; VSILFILE *fp = VSIFOpenL(poOpenInfo->pszFilename, "rb"); if( fp != NULL ) { unsigned int nLength; VSIFSeekL( fp, 0, SEEK_END ); nLength = (int) VSIFTellL( fp ); VSIFSeekL( fp, 0, SEEK_SET ); nLength = MAX(0,nLength); pszXML = (char *) VSIMalloc(nLength+1); if( pszXML == NULL ) { VSIFCloseL(fp); CPLError( CE_Failure, CPLE_OutOfMemory, "Failed to allocate %d byte buffer to hold VRT xml file.", nLength ); return NULL; } if( VSIFReadL( pszXML, 1, nLength, fp ) != nLength ) { VSIFCloseL(fp); CPLFree( pszXML ); CPLError( CE_Failure, CPLE_FileIO, "Failed to read %d bytes from VRT xml file.", nLength ); return NULL; } pszXML[nLength] = '\0'; pszVRTPath = CPLStrdup(CPLGetPath(poOpenInfo->pszFilename)); VSIFCloseL(fp); } /* -------------------------------------------------------------------- */ /* Or use the filename as the XML input. */ /* -------------------------------------------------------------------- */ else { pszXML = CPLStrdup( poOpenInfo->pszFilename ); } /* -------------------------------------------------------------------- */ /* Turn the XML representation into a VRTDataset. */ /* -------------------------------------------------------------------- */ VRTDataset *poDS = (VRTDataset *) OpenXML( pszXML, pszVRTPath, poOpenInfo->eAccess ); if( poDS != NULL ) poDS->bNeedsFlush = FALSE; CPLFree( pszXML ); CPLFree( pszVRTPath ); /* -------------------------------------------------------------------- */ /* Open overviews. */ /* -------------------------------------------------------------------- */ if( fp != NULL && poDS != NULL ) poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); return poDS; }
MainWindow::MainWindow() : mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)), mApplications(new ApplicationList(this)), mTranslation(new TranslationHandler(this)), mLogView(NULL), mProject(NULL), mExiting(false) { mUI.setupUi(this); mUI.mResults->Initialize(mSettings, mApplications); mThread = new ThreadHandler(this); mLogView = new LogView; // Filter timer to delay filtering results slightly while typing mFilterTimer = new QTimer(this); mFilterTimer->setInterval(500); mFilterTimer->setSingleShot(true); connect(mFilterTimer, SIGNAL(timeout()), this, SLOT(FilterResults())); // "Filter" toolbar mLineEditFilter = new QLineEdit(mUI.mToolBarFilter); mLineEditFilter->setPlaceholderText(tr("Quick Filter:")); mUI.mToolBarFilter->addWidget(mLineEditFilter); connect(mLineEditFilter, SIGNAL(textChanged(const QString&)), mFilterTimer, SLOT(start())); connect(mLineEditFilter, SIGNAL(returnPressed()), this, SLOT(FilterResults())); connect(mUI.mActionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(mUI.mActionCheckFiles, SIGNAL(triggered()), this, SLOT(CheckFiles())); connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); connect(mUI.mActionOpenXML, SIGNAL(triggered()), this, SLOT(OpenXML())); connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool))); connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool))); connect(mUI.mActionShowWarnings, SIGNAL(toggled(bool)), this, SLOT(ShowWarnings(bool))); connect(mUI.mActionShowPortability, SIGNAL(toggled(bool)), this, SLOT(ShowPortability(bool))); connect(mUI.mActionShowPerformance, SIGNAL(toggled(bool)), this, SLOT(ShowPerformance(bool))); connect(mUI.mActionShowInformation, SIGNAL(toggled(bool)), this, SLOT(ShowInformation(bool))); connect(mUI.mActionCheckAll, SIGNAL(triggered()), this, SLOT(CheckAll())); connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll())); connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults())); connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults())); connect(mUI.mActionShowHidden, SIGNAL(triggered()), mUI.mResults, SLOT(ShowHiddenResults())); connect(mUI.mActionViewLog, SIGNAL(triggered()), this, SLOT(ShowLogView())); connect(mUI.mActionViewStats, SIGNAL(triggered()), this, SLOT(ShowStatistics())); connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck())); connect(mUI.mActionStop, SIGNAL(triggered()), this, SLOT(StopChecking())); connect(mUI.mActionSave, SIGNAL(triggered()), this, SLOT(Save())); // About menu connect(mUI.mActionAbout, SIGNAL(triggered()), this, SLOT(About())); connect(mUI.mActionLicense, SIGNAL(triggered()), this, SLOT(ShowLicense())); // View > Toolbar menu connect(mUI.mActionToolBarMain, SIGNAL(toggled(bool)), this, SLOT(ToggleMainToolBar())); connect(mUI.mActionToolBarView, SIGNAL(toggled(bool)), this, SLOT(ToggleViewToolBar())); connect(mUI.mActionToolBarFilter, SIGNAL(toggled(bool)), this, SLOT(ToggleFilterToolBar())); connect(mUI.mActionAuthors, SIGNAL(triggered()), this, SLOT(ShowAuthors())); connect(mThread, SIGNAL(Done()), this, SLOT(CheckDone())); connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded())); connect(mUI.mResults, SIGNAL(ResultsHidden(bool)), mUI.mActionShowHidden, SLOT(setEnabled(bool))); connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu())); // File menu connect(mUI.mActionNewProjectFile, SIGNAL(triggered()), this, SLOT(NewProjectFile())); connect(mUI.mActionOpenProjectFile, SIGNAL(triggered()), this, SLOT(OpenProjectFile())); connect(mUI.mActionCloseProjectFile, SIGNAL(triggered()), this, SLOT(CloseProjectFile())); connect(mUI.mActionEditProjectFile, SIGNAL(triggered()), this, SLOT(EditProjectFile())); connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents())); LoadSettings(); mThread->Initialize(mUI.mResults); FormatAndSetTitle(); EnableCheckButtons(true); mUI.mActionClearResults->setEnabled(false); mUI.mActionSave->setEnabled(false); mUI.mActionRecheck->setEnabled(false); EnableProjectOpenActions(true); EnableProjectActions(false); QStringList args = QCoreApplication::arguments(); //Remove the application itself args.removeFirst(); if (!args.isEmpty()) { HandleCLIParams(args); } for (int i = 0; i < MaxRecentProjects; ++i) { mRecentProjectActs[i] = new QAction(this); mRecentProjectActs[i]->setVisible(false); connect(mRecentProjectActs[i], SIGNAL(triggered()), this, SLOT(OpenRecentProject())); } mUI.mActionProjectMRU->setVisible(false); UpdateMRUMenuItems(); }
WeatherRouting::WeatherRouting(wxWindow *parent, weather_routing_pi &plugin) : WeatherRoutingBase(parent), m_ConfigurationDialog(this), m_ConfigurationBatchDialog(this), m_SettingsDialog(this), m_StatisticsDialog(this), m_ReportDialog(this), m_FilterRoutesDialog(this), m_bRunning(false), m_bSkipUpdateCurrentItem(false), m_bShowConfiguration(false), m_bShowConfigurationBatch(false), m_bShowSettings(false), m_bShowStatistics(false), m_bShowReport(false), m_bShowFilter(false), m_weather_routing_pi(plugin) { m_SettingsDialog.LoadSettings(); m_lPositions->InsertColumn(POSITION_NAME, _("Name")); m_lPositions->InsertColumn(POSITION_LAT, _("Lat")); m_lPositions->InsertColumn(POSITION_LON, _("Lon")); wxImageList *imglist = new wxImageList(20, 20, true, 1); imglist->Add(wxBitmap(eye)); m_lWeatherRoutes->AssignImageList(imglist, wxIMAGE_LIST_SMALL); m_lWeatherRoutes->InsertColumn(VISIBLE, _T("")); m_lWeatherRoutes->SetColumnWidth(0, 28); m_lWeatherRoutes->InsertColumn(START, _("Start")); m_lWeatherRoutes->InsertColumn(STARTTIME, _("Start Time")); m_lWeatherRoutes->InsertColumn(END, _("End")); m_lWeatherRoutes->InsertColumn(TIME, _("Time")); m_lWeatherRoutes->InsertColumn(DISTANCE, _("Distance")); m_lWeatherRoutes->InsertColumn(AVGSPEED, _("Average Speed")); m_lWeatherRoutes->InsertColumn(STATE, _("State")); m_default_configuration_path = weather_routing_pi::StandardPath() + _T("WeatherRoutingConfiguration.xml"); if(!OpenXML(m_default_configuration_path, false)) { /* create directory for plugin files if it doesn't already exist */ wxFileName fn(m_default_configuration_path); wxFileName fn2 = fn.GetPath(); if(!fn.DirExists()) { fn2.Mkdir(); fn.Mkdir(); } } wxFileConfig *pConf = GetOCPNConfigObject(); pConf->SetPath ( _T( "/PlugIns/WeatherRouting" ) ); wxPoint p = GetPosition(); pConf->Read ( _T ( "DialogX" ), &p.x, p.x); pConf->Read ( _T ( "DialogY" ), &p.y, p.y); SetPosition(p); wxSize s = GetSize(); pConf->Read ( _T ( "DialogWidth" ), &s.x, s.x); pConf->Read ( _T ( "DialogHeight" ), &s.y, s.y); SetSize(s); /* periodically check for updates from computation thread */ m_tCompute.Connect(wxEVT_TIMER, wxTimerEventHandler ( WeatherRouting::OnComputationTimer ), NULL, this); m_tHideConfiguration.Connect(wxEVT_TIMER, wxTimerEventHandler ( WeatherRouting::OnHideConfigurationTimer ), NULL, this); SetEnableConfigurationMenu(); /* initialize crossing land routine from main thread as it is not re-entrant */ PlugIn_GSHHS_CrossesLand(0, 0, 0, 0); }
CelestialNavigationDialog::CelestialNavigationDialog(wxWindow *parent) : CelestialNavigationDialogBase(parent), m_FixDialog(this), m_ClockCorrectionDialog(this) { wxFileConfig *pConf = GetOCPNConfigObject(); pConf->SetPath( _T("/PlugIns/CelestialNavigation") ); //#ifdef __WXGTK__ // Move(0, 0); // workaround for gtk autocentre dialog behavior //#endif // Move(pConf->Read ( _T ( "DialogPosX" ), 20L ), pConf->Read ( _T ( "DialogPosY" ), 20L )); wxPoint p = GetPosition(); pConf->Read ( _T ( "DialogX" ), &p.x, p.x); pConf->Read ( _T ( "DialogY" ), &p.y, p.y); SetPosition(p); wxSize s = GetSize(); pConf->Read ( _T ( "DialogWidth" ), &s.x, s.x); pConf->Read ( _T ( "DialogHeight" ), &s.y, s.y); SetSize(s); // create a image list for the list with just the eye icon wxImageList *imglist = new wxImageList(20, 20, true, 1); imglist->Add(wxBitmap(eye)); m_lSights->AssignImageList(imglist, wxIMAGE_LIST_SMALL); m_lSights->InsertColumn(rmVISIBLE, wxT("")); m_lSights->SetColumnWidth(0, 28); m_lSights->InsertColumn(rmTYPE, _("Type")); m_lSights->InsertColumn(rmBODY, _("Body")); m_lSights->InsertColumn(rmTIME, _("Time (UT)")); m_lSights->InsertColumn(rmMEASUREMENT, _("Measurement")); m_lSights->InsertColumn(rmCOLOR, _("Color")); m_sights_path = celestial_navigation_pi::StandardPath() + _T("Sights.xml"); if(!OpenXML(m_sights_path, false)) { /* create directory for plugin files if it doesn't already exist */ wxFileName fn(m_sights_path); wxFileName fn2 = fn.GetPath(); if(!fn.DirExists()) { fn2.Mkdir(); fn.Mkdir(); } } wxString filename = DataDirectory() + "vsop87d.txt"; wxFileName fn(filename); if(!fn.Exists()) filename = UserDataDirectory() + "vsop87d.txt"; astrolabe::globals::vsop87d_text_path = (const char *)filename.mb_str(); #ifndef WIN32 // never hit because data is distribued easier to not compile compression support wxMessageDialog mdlg(this, _("Astrolab data unavailable.\n") + _("\nWould you like to download?"), _("Failure Alert"), wxYES | wxNO | wxICON_ERROR); if(mdlg.ShowModal() == wxID_YES) { wxString url = "https://cfhcable.dl.sourceforge.net/project/opencpnplugins/celestial_navigation_pi/"; wxString path = UserDataDirectory(); wxString fn = "vsop87d.txt.gz"; _OCPN_DLStatus status = OCPN_downloadFile( url+fn, path+fn, _("downloading celestial navigation data file"), "downloading...", *_img_celestial_navigation, this, OCPN_DLDS_CAN_ABORT|OCPN_DLDS_ELAPSED_TIME|OCPN_DLDS_ESTIMATED_TIME|OCPN_DLDS_REMAINING_TIME|OCPN_DLDS_SPEED|OCPN_DLDS_SIZE|OCPN_DLDS_URL|OCPN_DLDS_AUTO_CLOSE, 20); if(status == OCPN_DL_NO_ERROR) { // now decompress downloaded file ZUFILE *f = zu_open(path+fn.mb_str(), "rb", ZU_COMPRESS_AUTO); if(f) { FILE *out = fopen(path+"vsop87d.txt", "w"); if(out) { char buf[1024]; for(;;) { size_t size = zu_read(f, buf, sizeof buf); fwrite(buf, size, 1, out); if(size != sizeof buf) break; } fclose(out); } zu_close(f); } } } #endif #ifdef __OCPN__ANDROID__ GetHandle()->setStyleSheet( qtStyleSheet); Move(0, 0); #endif }
void Dlg::Calculate( wxCommandEvent& event, bool write_file, int Pattern ){ if(OpenXML()){ bool error_occured=false; // double dist, fwdAz, revAz; double lat1,lon1; // if(!this->m_Lat1->GetValue().ToDouble(&lat1)){ lat1=0.0;} // if(!this->m_Lon1->GetValue().ToDouble(&lon1)){ lon1=0.0;} int num_hours; num_hours = this->m_Nship->GetSelection(); // wxString str_countPts = wxString::Format(wxT("%d"), (int)num_hours); // wxMessageBox(str_countPts,_T("count_hours")); lat1 = 0.0; lon1 = 0.0; //if (error_occured) wxMessageBox(_T("error in conversion of input coordinates")); //error_occured=false; wxString s; if (write_file){ wxFileDialog dlg(this, _("Export DR Positions in GPX file as"), wxEmptyString, wxEmptyString, _T("GPX files (*.gpx)|*.gpx|All files (*.*)|*.*"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT); if (dlg.ShowModal() == wxID_CANCEL){ error_occured=true; // the user changed idea... return; } //dlg.ShowModal(); s=dlg.GetPath(); // std::cout<<s<< std::endl; if (dlg.GetPath() == wxEmptyString){ error_occured=true; if (dbg) printf("Empty Path\n");} } //Validate input ranges if (!error_occured){ if (std::abs(lat1)>90){ error_occured=true; } if (std::abs(lon1)>180){ error_occured=true; } if (error_occured) wxMessageBox(_("error in input range validation")); } //Start GPX TiXmlDocument doc; TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "utf-8", "" ); doc.LinkEndChild( decl ); TiXmlElement * root = new TiXmlElement( "gpx" ); TiXmlElement * Route = new TiXmlElement( "rte" ); TiXmlElement * RouteName = new TiXmlElement( "name" ); TiXmlText * text4 = new TiXmlText( this->m_Route->GetValue().ToUTF8() ); if (write_file){ doc.LinkEndChild( root ); root->SetAttribute("version", "0.1"); root->SetAttribute("creator", "DR_pi by Rasbats"); root->SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); root->SetAttribute("xmlns:gpxx","http://www.garmin.com/xmlschemas/GpxExtensions/v3" ); root->SetAttribute("xsi:schemaLocation", "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"); root->SetAttribute("xmlns:opencpn","http://www.opencpn.org"); Route->LinkEndChild( RouteName ); RouteName->LinkEndChild( text4 ); TiXmlElement * Extensions = new TiXmlElement( "extensions" ); TiXmlElement * StartN = new TiXmlElement( "opencpn:start" ); TiXmlText * text5 = new TiXmlText( "Start" ); Extensions->LinkEndChild( StartN ); StartN->LinkEndChild( text5 ); TiXmlElement * EndN = new TiXmlElement( "opencpn:end" ); TiXmlText * text6 = new TiXmlText( "End" ); Extensions->LinkEndChild( EndN ); EndN->LinkEndChild( text6 ); Route->LinkEndChild( Extensions ); } switch ( Pattern ) { case 1: { if (dbg) cout<<"DR Calculation\n"; double speed=0; int interval=1; if(!this->m_Speed_PS->GetValue().ToDouble(&speed)){ speed=5.0;} // 5 kts default speed interval = m_Nship->GetCurrentSelection();//S=1 speed = speed*interval; int n=0; //int multiplier=1; double lati, loni; double latN[100], lonN[100]; double latF, lonF; Position my_point; double value, value1; for(std::vector<Position>::iterator it = my_positions.begin(); it != my_positions.end(); it++){ if(!(*it).lat.ToDouble(&value)){ /* error! */ } lati = value; if(!(*it).lon.ToDouble(&value1)){ /* error! */ } loni = value1; latN[n] = lati; lonN[n] = loni; n++;//0,1,2,3 } my_positions.clear(); n--;//n = 2, 0,1,2 int routepoints = n+1; //3 double myDist, myBrng, myDistForBrng; int count_pts; double remaining_dist, myLast, route_dist; remaining_dist = 0; route_dist= 0; myLast = 0; myDistForBrng =0; double total_dist = 0; int i,c; bool skip = false; bool inloop = false; bool setF = false; latF = latN[0]; lonF = lonN[0]; // Start of new logic // // for (i=0; i<n; i++){ // save the routepoint my_point.lat = wxString::Format(wxT("%f"),latN[i]); my_point.lon = wxString::Format(wxT("%f"),lonN[i]); my_point.routepoint = 1; my_point.wpt_num = wxString::Format(wxT("%d"),(int)i); my_points.push_back(my_point); if (i==0){ // First F is a routepoint latF = latN[i]; lonF = lonN[i]; } distRhumb(latF, lonF, latN[i+1], lonN[i+1], &myDist, &myBrng); total_dist = total_dist + myDist; if (total_dist > speed){ // DR point after route point // route_dist = total_dist - myDist; //305 remaining_dist = speed - route_dist; distRhumb(latN[i], lonN[i], latN[i+1], lonN[i+1], &myLast, &myBrng); destRhumb(latN[i], lonN[i], myBrng,remaining_dist, &lati, &loni); // Put in DR after many route points my_point.lat = wxString::Format(wxT("%f"),lati); my_point.lon = wxString::Format(wxT("%f"),loni); my_point.routepoint = 0; my_points.push_back(my_point); latF = lati; lonF = loni; total_dist = 0; // // End of speed distRhumb(latF, lonF, latN[i+1], lonN[i+1], &myDistForBrng, &myBrng); if (myDistForBrng > speed){ // put in the DR positions // count_pts = (int)floor(myDistForBrng/speed); // remaining_dist = myDistForBrng - (count_pts*speed); // distRhumb(latF, lonF, latN[i+1], lonN[i+1], &myDistForBrng, &myBrng); for (c = 1; c <= count_pts ; c++){ destRhumb(latF, lonF, myBrng,speed*c, &lati, &loni); // print mid points my_point.lat = wxString::Format(wxT("%f"),lati); my_point.lon = wxString::Format(wxT("%f"),loni); my_point.routepoint = 0; my_points.push_back(my_point); // End of prints } latF = lati; lonF = loni; total_dist = 0; // // // All the DR positions inserted } if (total_dist == 0){ distRhumb(latF, lonF, latN[i+1], lonN[i+1], &myDistForBrng, &myBrng); total_dist = myDistForBrng; latF = latN[i+1]; lonF = lonN[i+1]; } } else{ // latF = latN[i+1]; lonF = lonN[i+1]; // // // // } // } // End of new logic // print the last routepoint my_point.lat = wxString::Format(wxT("%f"),latN[i]); my_point.lon = wxString::Format(wxT("%f"),lonN[i]); my_point.routepoint = 1; my_point.wpt_num = wxString::Format(wxT("%d"),(int)i); my_points.push_back(my_point); // for(std::vector<Position>::iterator itOut = my_points.begin(); itOut != my_points.end(); itOut++){ //wxMessageBox((*it).lat, _T("*it.lat")); double value, value1; if(!(*itOut).lat.ToDouble(&value)){ /* error! */ } lati = value; if(!(*itOut).lon.ToDouble(&value1)){ /* error! */ } loni = value1; if ((*itOut).routepoint == 1){ if (write_file){Addpoint(Route, wxString::Format(wxT("%f"),lati), wxString::Format(wxT("%f"),loni), (*itOut).wpt_num ,_T("diamond"),_T("WPT"));} } else{ if ((*itOut).routepoint == 0){ if (write_file){Addpoint(Route, wxString::Format(wxT("%f"),lati), wxString::Format(wxT("%f"),loni), _T("DR") ,_T("square"),_T("WPT"));} } } } my_points.clear(); break; } default: { // Note the colon, not a semicolon cout<<"Error, bad input, quitting\n"; break; } } if (write_file){ root->LinkEndChild( Route ); // check if string ends with .gpx or .GPX if (!wxFileExists(s)){ s = s + _T(".gpx"); } wxCharBuffer buffer=s.ToUTF8(); if (dbg) std::cout<< buffer.data()<<std::endl; doc.SaveFile( buffer.data() );} //} //end of if no error occured if (error_occured==true) { wxLogMessage(_("Error in calculation. Please check input!") ); wxMessageBox(_("Error in calculation. Please check input!") ); } } }