wxExcelChartObjects wxExcelWorksheet::ChartObjects(const wxVector<long>& indices) { wxExcelChartObjects objects; wxCHECK(indices.size() > 0, objects); wxVariant vIndices; vIndices.NullList(); for (size_t i = 0; i < indices.size(); i++) vIndices.Append(indices[i]); WXAUTOEXCEL_CALL_METHOD1_OBJECT("ChartObjects", vIndices, objects); }
void GLPolygons::SetupVAO(wxVector<PMSPolygon> polygons) { wxVector<GLfloat> vertices; GenerateGLBufferVertices(polygons, vertices); m_polygonsCount = polygons.size(); glGenBuffers(1, &m_vbo); glGenVertexArrays(1, &m_vao); glBindVertexArray(m_vao); if (vertices.size() > 0) { glBindBuffer(GL_ARRAY_BUFFER, m_vbo); // We initialize all polygons (not only those present in map). glBufferData(GL_ARRAY_BUFFER, GL_POLYGON_VERTEX_SIZE_BYTES * MAX_POLYGONS_COUNT * GL_POLYGON_VERTICES_COUNT, &vertices[0], GL_DYNAMIC_DRAW); } glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, GL_POLYGON_VERTEX_SIZE_BYTES, (GLvoid*)0); glEnableVertexAttribArray(0); glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, GL_POLYGON_VERTEX_SIZE_BYTES, (GLvoid*)(3 * sizeof(GLfloat))); glEnableVertexAttribArray(1); glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, GL_POLYGON_VERTEX_SIZE_BYTES, (GLvoid*)(7 * sizeof(GLfloat))); glEnableVertexAttribArray(2); glBindVertexArray(0); }
wxDouble wxStackedColumnChart::GetCumulativeMaxValue(const wxVector<wxChartsDoubleDataset::ptr>& datasets) { wxDouble result = 0; size_t i = 0; while (true) { wxDouble sum = 0; bool stop = true; for (size_t j = 0; j < datasets.size(); ++j) { const wxChartsDoubleDataset& dataset = *datasets[j]; if (i < dataset.GetData().size()) { sum += dataset.GetData()[i]; stop = false; } } if (sum > result) { result = sum; } if (stop) { break; } ++i; } return result; }
wxDouble wxPolarAreaChart::GetMaxValue(const wxVector<wxChartSliceData> &slices) { wxDouble result = 0; if (slices.size() > 0) { result = slices[0].GetValue(); } for (size_t i = 1; i < slices.size(); ++i) { wxDouble v = slices[i].GetValue(); if (v > result) { result = v; } } return result; }
wxDataViewItemArray TreeListModel::AppendItems(const wxDataViewItem &parent, const wxVector<wxVector<wxVariant> >& data) { wxDataViewItemArray items; for(size_t i=0; i<data.size(); ++i) { items.push_back( DoAppendItem(parent, data.at(i), false, NULL) ); } ItemsAdded(parent, items); return items; }
virtual void OnExit() { if ( gs_heventShutdown.IsOk() ) { // stop any threads waiting for the termination of asynchronously // running processes if ( !gs_heventShutdown.Set() ) { wxLogDebug(wxT("Failed to set shutdown event in wxExecuteModule")); } gs_heventShutdown.Close(); // now wait until they terminate if ( !gs_asyncThreads.empty() ) { const size_t numThreads = gs_asyncThreads.size(); if ( ::WaitForMultipleObjects ( numThreads, &gs_asyncThreads[0], TRUE, // wait for all of them to become signalled 3000 // long but finite value ) == WAIT_TIMEOUT ) { wxLogDebug(wxT("Failed to stop all wxExecute monitor threads")); } #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for ( size_t n = 0; n < numThreads; n++ ) { ::CloseHandle(gs_asyncThreads[n]); } gs_asyncThreads.clear(); } } if ( gs_classForHiddenWindow ) { if ( !::UnregisterClass(wxMSWEXEC_WNDCLASSNAME, wxGetInstance()) ) { wxLogLastError(wxT("UnregisterClass(wxExecClass)")); } gs_classForHiddenWindow = NULL; } }
virtual ~MyClass() { for ( size_t i=0; i<gs_myClassInstances.size(); i++ ) { if ( gs_myClassInstances[i] == this ) { gs_myClassInstances.erase(gs_myClassInstances.begin()+i); } } }
void GLPolygons::ResetPolygons(wxVector<PMSPolygon> polygons) { wxVector<GLfloat> vertices; GenerateGLBufferVertices(polygons, vertices); m_polygonsCount = polygons.size(); if (vertices.size() > 0) { glBindBuffer(GL_ARRAY_BUFFER, m_vbo); glBufferSubData(GL_ARRAY_BUFFER, 0, GL_POLYGON_VERTEX_SIZE_BYTES * m_polygonsCount * GL_POLYGON_VERTICES_COUNT, &vertices[0]); } }
virtual void OnExit() { if ( gs_heventShutdown ) { // stop any threads waiting for the termination of asynchronously // running processes if ( !::SetEvent(gs_heventShutdown) ) { wxLogDebug(wxT("Failed to set shutdown event in wxExecuteModule")); } ::CloseHandle(gs_heventShutdown); gs_heventShutdown = NULL; // now wait until they terminate if ( !gs_asyncThreads.empty() ) { const size_t numThreads = gs_asyncThreads.size(); if ( ::WaitForMultipleObjects ( numThreads, &gs_asyncThreads[0], TRUE, // wait for all of them to become signalled 3000 // long but finite value ) == WAIT_TIMEOUT ) { wxLogDebug(wxT("Failed to stop all wxExecute monitor threads")); } for ( size_t n = 0; n < numThreads; n++ ) { ::CloseHandle(gs_asyncThreads[n]); } gs_asyncThreads.clear(); } } if ( gs_classForHiddenWindow ) { if ( !::UnregisterClass(wxMSWEXEC_WNDCLASSNAME, wxGetInstance()) ) { wxLogLastError(wxT("UnregisterClass(wxExecClass)")); } gs_classForHiddenWindow = NULL; } }
void wxAxIdentifyView::FillTree(const wxVector<FILLTREEDATA> &data) { m_pTreeCtrl->DeleteAllItems(); m_pFeatureDetailsPanel->Clear(); //add root wxTreeItemId nRootId = m_pTreeCtrl->AddRoot(wxT("Layers"), 0); m_pTreeCtrl->SetItemBold(nRootId); //add layers for(size_t i = 0; i < data.size(); ++i) { if(data[i].Cursor.size() == 0) continue; wxGISEnumDatasetType eType = data[i].pLayer->GetType(); wxTreeItemId nLayerId = m_pTreeCtrl->AppendItem(nRootId, data[i].pLayer->GetName(), 1); switch(eType) { case enumGISFeatureDataset: { wxGISFeatureDataset* pDataset = wxDynamicCast(data[i].pLayer->GetDataset(), wxGISFeatureDataset); m_pTreeCtrl->SetItemData(nLayerId, new wxIdentifyTreeItemData(pDataset)); //wxTreeItemId nFirstFeatureId = nLayerId; wxGISSpatialTreeCursor::const_iterator iter; for(iter = data[i].Cursor.begin(); iter != data[i].Cursor.end(); ++iter) { wxGISSpatialTreeData *current = *iter; if(current) { wxTreeItemId nFeatureId = m_pTreeCtrl->AppendItem(nLayerId, wxString::Format(wxT("%ld"), current->GetFID()), 2); m_pTreeCtrl->SetItemData(nFeatureId, new wxIdentifyTreeItemData(pDataset, current->GetFID(), current->GetGeometry())); // if(iter == data[i].Cursor.begin()) // nFirstFeatureId = nFeatureId; } } } break; default: break; }; m_pTreeCtrl->ExpandAllChildren(nLayerId); } // m_pTreeCtrl->SelectItem(nFirstFeatureId); }
virtual ~MyClass() { #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for ( size_t i=0; i<gs_myClassInstances.size(); i++ ) { if ( gs_myClassInstances[i] == this ) { gs_myClassInstances.erase(gs_myClassInstances.begin()+i); } } }
void ShowMessageDialog(wxWindow* pWnd, const wxVector<MESSAGE>& msgs) { wxMessageDialog dlg(pWnd, _("During export there were several warnings."), _("Warning"), wxOK | wxCENTRE | wxICON_WARNING); wxString extMsg; for (size_t i = 0; i < msgs.size(); ++i) { if (msgs[i].sMessage.IsEmpty()) continue; if (msgs[i].eType == enumGISMessageErr) extMsg += _("Error") + wxT(": "); else if (msgs[i].eType == enumGISMessageWarning) extMsg += _("Warning") + wxT(": "); extMsg += msgs[i].sMessage; extMsg += wxT("\n\n"); } dlg.SetExtendedMessage(extMsg); dlg.ShowModal(); wxLogError(extMsg); }
void wxGLAPI::glEnd() { #if wxUSE_OPENGL_EMULATION bool formerColors = SetState( GL_COLOR_ARRAY, s_colorsUsed ); bool formerNormals = SetState( GL_NORMAL_ARRAY, s_normalsUsed ); bool formerTexCoords = SetState( GL_TEXTURE_COORD_ARRAY, s_texCoordsUsed ); bool formerVertex = glIsEnabled(GL_VERTEX_ARRAY); if( !formerVertex ) glEnableClientState(GL_VERTEX_ARRAY); if ( s_colorsUsed ) glColorPointer( 4, GL_FLOAT, 0, &s_colors[0] ); if ( s_normalsUsed ) glNormalPointer( GL_FLOAT, 0, &s_normals[0] ); if ( s_texCoordsUsed ) glTexCoordPointer( 2, GL_FLOAT, 0, &s_texCoords[0] ); glVertexPointer(3, GL_FLOAT, 0, &s_vertices[0]); glDrawArrays( s_mode, 0, s_vertices.size() / 3 ); if ( s_colorsUsed != formerColors ) RestoreState( GL_COLOR_ARRAY, formerColors ); if ( s_normalsUsed != formerNormals ) RestoreState( GL_NORMAL_ARRAY, formerColors ); if ( s_texCoordsUsed != formerTexCoords ) RestoreState( GL_TEXTURE_COORD_ARRAY, formerColors ); if( !formerVertex ) glDisableClientState(GL_VERTEX_ARRAY); s_mode = 0xFF; #else ::glEnd(); #endif }
void GLPolygons::GenerateGLBufferVertices(wxVector<PMSPolygon> &polygons, wxVector<GLfloat> &vertices) { unsigned int polygonsCount = polygons.size(); unsigned int i, j; // Trim down polygons' count. if (polygonsCount > MAX_POLYGONS_COUNT) { polygonsCount = MAX_POLYGONS_COUNT; } for (i = 0; i < polygonsCount; ++i) { for (j = 0; j < 3; ++j) { vertices.push_back((GLfloat)polygons[i].vertices[j].x); vertices.push_back((GLfloat)polygons[i].vertices[j].y); vertices.push_back((GLfloat)polygons[i].vertices[j].z); vertices.push_back((GLfloat)polygons[i].vertices[j].color.red / 255.0); vertices.push_back((GLfloat)polygons[i].vertices[j].color.green / 255.0); vertices.push_back((GLfloat)polygons[i].vertices[j].color.blue / 255.0); vertices.push_back((GLfloat)polygons[i].vertices[j].color.alpha / 255.0); vertices.push_back((GLfloat)polygons[i].vertices[j].textureS); vertices.push_back((GLfloat)polygons[i].vertices[j].textureT); } } // Initialization of unused polygons. for (i = 0; i < MAX_POLYGONS_COUNT - polygonsCount; ++i) { for (j = 0; j < 3; ++j) { for (unsigned int k = 0; k < GL_POLYGON_VERTEX_SIZE; ++k) { vertices.push_back(0.0f); } } } }
bool TestExec(const wxVector<wxFileName>& programs, long timeout) { size_t i; wxVector<MonitorData*> data; // run all programs specified as command line parameters wxArrayLong procID; for (i=0; i<programs.size(); i++) { MonitorData *dt = new MonitorData(programs[i].GetFullPath()); long pid = wxExecute(programs[i].GetFullPath(), wxEXEC_ASYNC, &dt->process); if (pid == 0) { wxLogError("could not run the program '%s'", programs[i].GetFullPath()); } else { wxLogMessage("started program '%s' (pid %d)...", programs[i].GetFullPath(), pid); wxASSERT(dt->process.GetPid() == pid); data.push_back(dt); } } // sleep some moments wxSleep(timeout); // check if all processes are still running bool allok = true; for (i=0; i<data.size(); i++) { MonitoredProcess& proc = data[i]->process; const wxString& prog = data[i]->program; if (wxProcess::Exists(proc.GetPid())) proc.Kill(); else { // this typically never happens, at least when running wx-programs // built with debug builds of wx (see MonitoredProcess::OnTerminate; // even if an asserts fail the app doesn't automatically close!): wxLogMessage("program '%s' (pid %d) is NOT running anymore...", prog, proc.GetPid()); allok = false; } if (data[i]->process.Crashed()) { allok = false; wxLogMessage("program '%s' (pid %d) crashed...", prog, proc.GetPid()); } else wxLogMessage("program '%s' (pid %d) ended with exit code %d...", prog, proc.GetPid(), proc.GetExitCode()); } return allok; }
void ExportMultipleDatasetsSelect(wxWindow* pWnd, wxVector<IGxDataset*> &paDatasets) { wxCHECK_RET(paDatasets.size() > 1, wxT("The input dataset array is empty")); wxGxContainerDialog dlg(pWnd, wxID_ANY, _("Select output")); dlg.SetAllFilters(false); dlg.ShowExportFormats(true); wxGxObject* pGxSrcObj = dynamic_cast<wxGxObject*>(paDatasets[0]); wxGISEnumDatasetType eType = paDatasets[0]->GetType(); int eSubType = paDatasets[0]->GetSubType(); bool bDefaultSet = false; int eDefaulSubType = 0; if (eType == enumGISFeatureDataset) { for (size_t i = enumVecUnknown + 1; i < enumVecMAX; ++i) { wxGISEnumVectorDatasetType eCurrentSubType = (wxGISEnumVectorDatasetType)i; if (eCurrentSubType != eSubType && IsFileDataset(enumGISFeatureDataset, eCurrentSubType)) { if (bDefaultSet) { dlg.AddFilter(new wxGxFeatureDatasetFilter(eCurrentSubType), false); } else { dlg.AddFilter(new wxGxFeatureDatasetFilter(eCurrentSubType), true); bDefaultSet = true; eDefaulSubType = eCurrentSubType; } } } if (eSubType != enumVecPostGIS) { dlg.AddFilter(new wxGxFeatureDatasetFilter(enumVecPostGIS), false); } } else if (eType == enumGISRasterDataset) { //for (size_t i = enumRasterUnknown + 1; i < enumRasterMAX; ++i) //{ // wxGISEnumRasterDatasetType eCurrentSubType = (wxGISEnumRasterDatasetType)i; // if (eCurrentSubType != eSubType && IsFileDataset(enumGISRasterDataset, eCurrentSubType)) // { // if (bDefaultSet) // { // dlg.AddFilter(new wxGxRasterDatasetFilter(eCurrentSubType), false); // } // else // { // dlg.AddFilter(new wxGxRasterDatasetFilter(eCurrentSubType), true); // bDefaultSet = true; // eDefaulSubType = eCurrentSubType; // } // } //} //if (eSubType != enumRasterPostGIS) //{ // dlg.AddFilter(new wxGxRasterDatasetFilter(enumRasterPostGIS), false); //} } else if (eType == enumGISTableDataset) { for (size_t i = enumTableUnknown + 1; i < enumTableMAX; ++i) { wxGISEnumTableDatasetType eCurrentSubType = (wxGISEnumTableDatasetType)i; if (eCurrentSubType != eSubType && IsFileDataset(enumGISTableDataset, eCurrentSubType)) { if (bDefaultSet) { dlg.AddFilter(new wxGxTableDatasetFilter(eCurrentSubType), false); } else { dlg.AddFilter(new wxGxTableDatasetFilter(eCurrentSubType), true); bDefaultSet = true; eDefaulSubType = eCurrentSubType; } } } if (eSubType != enumTablePostgres) { dlg.AddFilter(new wxGxTableDatasetFilter(enumTablePostgres), false); } } dlg.AddShowFilter(new wxGxFolderFilter()); dlg.AddShowFilter(new wxGxRemoteDBSchemaFilter()); dlg.ShowCreateButton(true); wxGxObject* pGxParentObj = pGxSrcObj->GetParent(); wxString sStartLoc; if (pGxParentObj) { while (NULL != pGxParentObj) { wxGxObjectContainer* pGxCont = wxDynamicCast(pGxParentObj, wxGxObjectContainer); if (NULL != pGxCont && pGxCont->CanCreate(enumGISFeatureDataset, eDefaulSubType)) { break; } else { pGxParentObj = pGxParentObj->GetParent(); } } if (pGxParentObj) { sStartLoc = pGxParentObj->GetFullName(); } } wxGISAppConfig oConfig = GetConfig(); if (oConfig.IsOk()) { if (eType == enumGISFeatureDataset) { sStartLoc = oConfig.Read(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/expm_vector_ds/path"), sStartLoc); } else if (eType == enumGISRasterDataset) { sStartLoc = oConfig.Read(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/expm_raster_ds/path"), sStartLoc); } else if (eType == enumGISTableDataset) { sStartLoc = oConfig.Read(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/expm_table_ds/path"), sStartLoc); } } if (!sStartLoc.IsEmpty()) dlg.SetStartingLocation(sStartLoc); if (dlg.ShowModal() == wxID_OK) { wxGxObjectFilter* pFilter = dlg.GetCurrentFilter(); if (NULL == pFilter) { wxMessageBox(_("Unexpected error"), _("Error"), wxCENTRE | wxOK | wxICON_ERROR, pWnd); wxLogError(_("Null wxGxObjectFilter returned")); return; } CPLString sPath = dlg.GetPath(); wxString sCatalogPath = dlg.GetLocation()->GetFullName(); if (oConfig.IsOk()) { if (eType == enumGISFeatureDataset) { oConfig.Write(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/expm_vector_ds/path"), sCatalogPath); } else if (eType == enumGISRasterDataset) { oConfig.Write(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/expm_raster_ds/path"), sCatalogPath); } else if (eType == enumGISTableDataset) { oConfig.Write(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/expm_table_ds/path"), sCatalogPath); } } //TODO: Now we create the copies (new names) instead of overwrite, but should show table with exist names and new names. If user set the same name - overwrite // |----------------|------------------| // | dataset1 | dataset1 (1) | // | dataset2 | dataset2 (1) | // | dataset3 | dataset3 (2) | // |----------------|------------------| wxVector<EXPORTED_DATASET> paExportDatasets; for (size_t i = 0; i < paDatasets.size(); ++i) { wxGxObject* pGxSrcDatasetObj = dynamic_cast<wxGxObject*>(paDatasets[i]); if (NULL == pGxSrcDatasetObj) { continue; } wxString sNewName = CheckUniqName(sPath, pGxSrcDatasetObj->GetBaseName(), pFilter->GetExt()); EXPORTED_DATASET ds = { sNewName, paDatasets[i] }; paExportDatasets.push_back(ds); } if (eType == enumGISFeatureDataset) { ExportMultipleVectorDatasets(pWnd, sPath, pFilter, paExportDatasets); } else if (eType == enumGISRasterDataset) { ExportMultipleRasterDatasets(pWnd, sPath, pFilter, paExportDatasets); } else if (eType == enumGISTableDataset) { ExportMultipleTableDatasets(pWnd, sPath, pFilter, paExportDatasets); } } }
bool wxSound::IsPlaying() { return s_soundsPlaying.size() > 0; }
void ExportMultipleVectorDatasets(wxWindow* pWnd, const CPLString &sPath, wxGxObjectFilter* const pFilter, wxVector<EXPORTED_DATASET> &paDatasets) { wxCHECK_RET(pWnd && pFilter && paDatasets.size() > 1, wxT("The input pointer is NULL or datasets array is empty")); wxGISProgressDlg ProgressDlg(_("Exporting..."), _("Begin operation..."), 100, pWnd); ProgressDlg.SetAddPercentToMessage(false); ProgressDlg.ShowProgress(true); for (size_t i = 0; i < paDatasets.size(); ++i) { ProgressDlg.SetTitle(wxString::Format(_("Proceed %ld of %ld..."), i + 1, paDatasets.size())); wxGISDataset* pDataset = paDatasets[i].pDSet->GetDataset(false, &ProgressDlg); wxVector<wxGISFeatureDataset*> apFeatureDatasets; if (pDataset->GetSubsetsCount() == 0) { wxGISFeatureDataset* pFeatureDataset = wxDynamicCast(pDataset, wxGISFeatureDataset); if (NULL != pFeatureDataset) { pFeatureDataset->Reference(); apFeatureDatasets.push_back(pFeatureDataset); } } else { for (size_t j = 0; j < pDataset->GetSubsetsCount(); ++j) { wxGISFeatureDataset* pFeatureDataset = wxDynamicCast(pDataset->GetSubset(j), wxGISFeatureDataset); if (NULL != pFeatureDataset) { pFeatureDataset->Reference(); apFeatureDatasets.push_back(pFeatureDataset); } } } if (apFeatureDatasets.size() == 0) { wxMessageBox(_("The dataset is empty"), _("Error"), wxCENTRE | wxICON_ERROR | wxOK, pWnd); wxLogError(_("wxGISFeatureDataset pointer is null returned")); return; } for (size_t j = 0; j < apFeatureDatasets.size(); ++j) { if(!ProgressDlg.Continue()) break; if (!apFeatureDatasets[j]->IsOpened()) { if (!apFeatureDatasets[j]->Open(0, TRUE, false, &ProgressDlg)) { wxMessageBox(ProgressDlg.GetLastMessage(), _("Error"), wxCENTRE | wxICON_ERROR | wxOK, pWnd); wxLogError(ProgressDlg.GetLastMessage()); wsDELETE(apFeatureDatasets[j]); continue; } } if (!ExportFormat(apFeatureDatasets[j], sPath, paDatasets[i].sName, pFilter, wxGISNullSpatialFilter, NULL, NULL, true, static_cast<ITrackCancel*>(&ProgressDlg))) { wxMessageBox(ProgressDlg.GetLastMessage(), _("Error"), wxCENTRE | wxICON_ERROR | wxOK, pWnd); wxLogError(ProgressDlg.GetLastMessage()); wsDELETE(apFeatureDatasets[j]); continue; } wsDELETE(apFeatureDatasets[j]); } } if (ProgressDlg.GetWarningCount() > 0 && ProgressDlg.Continue()) { ShowMessageDialog(pWnd, ProgressDlg.GetWarnings()); } }