void QueryFinishWizardPage::initializePage() { m_result->clear(); ui.progressBar->setValue(0); Framework* fw = framework(); setCurrentAction(tr("Collecting information...")); quint32 storeId = field("store").value<quint32>(); const QString queryStr = field("query").toString(); setCurrentAction(tr("Looking for store...")); const DataStore* dataStore = fw->dataStoreById(storeId); if(dataStore == NULL) return; setCurrentAction(tr("Store found...")); setCurrentAction(tr("Parsing query...")); CGSQL_NS::RootNode *root = CGSQL_NS::QueryParser::parse(queryStr.toStdString()); if (root == NULL) { setCurrentAction("Error while parting query."); return; } pgn::GameCollection loadedGames; setCurrentAction(tr("Retrieving games from %1...").arg(dataStore->name().toLower())); bool loadResult = dataStore->load(root, loadedGames); if(!loadResult) { setCurrentAction(tr("Can not load games from %1...").arg(dataStore->name().toLower())); return; } setCurrentAction(tr("Loaded %1 games. Looking for concepts in its...").arg(loadedGames.size())); QProgressDialog* progressDialog = new QProgressDialog("Searching for concepts", "Cancel", 0, loadedGames.size()); progressDialog->setWindowModality(Qt::WindowModal); progressDialog->setValue(0); int progress = 0; for(pgn::GameCollection::iterator it = loadedGames.begin(); it != loadedGames.end(); ++it) { progressDialog->show(); m_result->data().addGame(&(*it)); if(root->body()->accept(&(m_result->data()))) m_result->games().insert(*it); progressDialog->setValue(progress); ++progress; } progressDialog->setValue(100); progressDialog->setAutoClose(true); progressDialog->reset(); progressDialog->show(); progressDialog->deleteLater(); ui.progressBar->setValue(100); }
void ColorChooser::loadHistograms(const QImage* imageOriginal) { qApp->processEvents(); // process events just once to fill gray box left over from dropped down menu int discretizeMethods = 5; int runTime = imageOriginal->width() * discretizeMethods; QProgressDialog* dlg = new QProgressDialog(QString(tr("Loading histograms")), "Cancel", 0, runTime, m_parent); CHECK_PTR_ENGAUGE(dlg); dlg->setCaption(tr("Progress")); dlg->show(); loadForegroundPixmap(m_rgbBg); intensityHistogram.setAutoDelete(true); foregroundHistogram.setAutoDelete(true); hueHistogram.setAutoDelete(true); saturationHistogram.setAutoDelete(true); valueHistogram.setAutoDelete(true); loadHistogram(imageOriginal, DiscretizeIntensity, DiscretizeIntensityMax, &intensityHistogram, m_rgbBg, dlg); loadHistogram(imageOriginal, DiscretizeForeground, DiscretizeForegroundMax, &foregroundHistogram, m_rgbBg, dlg); loadHistogram(imageOriginal, DiscretizeHue, DiscretizeHueMax, &hueHistogram, m_rgbBg, dlg); loadHistogram(imageOriginal, DiscretizeSaturation, DiscretizeSaturationMax, &saturationHistogram, m_rgbBg, dlg); loadHistogram(imageOriginal, DiscretizeValue, DiscretizeValueMax, &valueHistogram, m_rgbBg, dlg); showCurrentHistogram(); chooserCanvas->update(); ASSERT_ENGAUGE(dlg != 0); delete dlg; qApp->processEvents(); // process events just once to fill gray box left over from previous window }
void Main_Window::on_sweep_clicked() { QProgressDialog *dlg = new QProgressDialog(this); dlg->setWindowModality(Qt::WindowModal); dlg->setLabelText("Frequency Sweep"); dlg->setCancelButtonText("Cancel"); dlg->setMaximum(100); dlg->show(); double start = ui.sweep_start->value(); double stop = ui.sweep_stop->value(); double step = ui.sweep_step->value(); for (double f = start; f <= stop && !dlg->wasCanceled(); f += step) { dlg->setValue((int)((f - start) * 100.0 / (stop - start))); QCoreApplication::processEvents(); ui.freq->setValue(f); on_idle_clicked(); update_freq(); send_freq(); on_cal_clicked(); on_tx_clicked(); usleep(100 * 1000); } delete dlg; }
void ProgressDialog::showProgressDialog(QOpenGLWidget *parent) { progressDialog = new QProgressDialog(parent); progressDialog->setWindowTitle("Image rendering progress"); progressDialog->setMinimumSize(300, 40); progressDialog->setCancelButton(NULL); progressDialog->show(); }
void FileTransferLogDialog::onExportExcelButton() { QString filePath = QFileDialog::getSaveFileName(this, tr("请选择要导出的excel文件路径"), "", tr("Excel 文件(*.xls)")); if(filePath == "") return; ExportExcelObject exportExcelObject(filePath, tr("文件传送日志"), ui->m_LogTable); exportExcelObject.addField(0, tr("客户端"), "varchar(100)"); exportExcelObject.addField(1, tr("文件名"), "varchar(100)"); exportExcelObject.addField(2, tr("文件大小KB"),"int"); exportExcelObject.addField(3, tr("传送结束时间"),"varchar(100)"); QProgressDialog progressDialog; progressDialog.setRange(0, m_Model->rowCount()); connect(&exportExcelObject, SIGNAL(exportedRowCount(int)), &progressDialog, SLOT(setValue(int))); progressDialog.show(); int ret = exportExcelObject.export2Excel(); if(ret > 0) { QMessageBox::information(this, tr("消息"), tr("恭喜您,Excel文档导出成功!")); } else { QMessageBox::critical(this, tr("错误"), tr("非常抱歉,Excel文档导出失败!")); } }
void FilesystemWidget::ExtractDirectory(const DiscIO::Partition& partition, const QString& path, const QString& out) { const DiscIO::FileSystem* filesystem = m_volume->GetFileSystem(partition); if (!filesystem) return; std::unique_ptr<DiscIO::FileInfo> info = filesystem->FindFileInfo(path.toStdString()); u32 size = info->GetTotalChildren(); QProgressDialog* dialog = new QProgressDialog(this); dialog->setMinimum(0); dialog->setMaximum(size); dialog->show(); bool all = path.isEmpty(); DiscIO::ExportDirectory( *m_volume, partition, *info, true, path.toStdString(), out.toStdString(), [all, dialog](const std::string& current) { dialog->setLabelText( (all ? QObject::tr("Extracting All Files...") : QObject::tr("Extracting Directory...")) .append(QStringLiteral(" %1").arg(QString::fromStdString(current)))); dialog->setValue(dialog->value() + 1); QCoreApplication::processEvents(); return dialog->wasCanceled(); }); dialog->close(); }
void FilesystemWidget::CheckIntegrity(const DiscIO::Partition& partition) { QProgressDialog* dialog = new QProgressDialog(this); std::future<bool> is_valid = std::async( std::launch::async, [this, partition] { return m_volume->CheckIntegrity(partition); }); dialog->setLabelText(tr("Verifying integrity of partition...")); dialog->setWindowFlags(dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint); dialog->setWindowTitle(tr("Verifying partition")); dialog->setMinimum(0); dialog->setMaximum(0); dialog->show(); while (is_valid.wait_for(std::chrono::milliseconds(50)) != std::future_status::ready) QCoreApplication::processEvents(); dialog->close(); if (is_valid.get()) QMessageBox::information(nullptr, tr("Success"), tr("Integrity check completed. No errors have been found.")); else QMessageBox::critical(nullptr, tr("Error"), tr("Integrity check for partition failed. The disc image is most " "likely corrupted or has been patched incorrectly.")); }
void UnnormalClientStatisticDialog::onExportExcelButton() { QString filePath = QFileDialog::getSaveFileName(this, tr("请选择要导出的excel文件路径"), "", tr("Excel 文件(*.xls)")); if(filePath == "") return; ExportExcelObject exportExcelObject(filePath, tr("异常状态统计信息"), m_Table); exportExcelObject.addField(0, tr("客户组名称"), "varchar(100)"); exportExcelObject.addField(1, tr("客户端数目"), "int"); exportExcelObject.addField(2, tr("温度异常数目"),"int"); exportExcelObject.addField(3,tr("湿度异常数目"),"int"); exportExcelObject.addField(4, tr("开关一异常数目"),"int"); exportExcelObject.addField(5, tr("门磁异常数目"),"int"); exportExcelObject.addField(6,tr("开关二异常数目"),"int"); exportExcelObject.addField(7,tr("开关三屏异常数目"),"int"); exportExcelObject.addField(8, tr("总异常数目"),"int"); QProgressDialog progressDialog; progressDialog.setRange(0, m_Table->rowCount()); connect(&exportExcelObject, SIGNAL(exportedRowCount(int)), &progressDialog, SLOT(setValue(int))); progressDialog.show(); int ret = exportExcelObject.export2Excel(); if(ret > 0) { QMessageBox::information(this, tr("消息"), tr("恭喜您,Excel文档导出成功!")); } else { QMessageBox::critical(this, tr("错误"), tr("非常抱歉,Excel文档导出失败!")); } }
void NetworkStatusStatement::onExportExcelButton() { QString filePath = QFileDialog::getSaveFileName(this, tr("请选择要导出的excel文件路径"), "", tr("Excel 文件(*.xls)")); if(filePath == "") return; ExportExcelObject exportExcelObject(filePath, tr("网络日志"), ui->m_EventTable); exportExcelObject.addField(0, tr("事件时间"), "varchar(100)"); exportExcelObject.addField(1, tr("客户端"), "varchar(100)"); exportExcelObject.addField(2, tr("事件种类"),"varchar(20)"); exportExcelObject.addField(3, tr("IP地址"),"varchar(50)"); exportExcelObject.addField(4, tr("端口号"),"varchar(20)"); QProgressDialog progressDialog; progressDialog.setRange(0, ui->m_EventTable->rowCount()); connect(&exportExcelObject, SIGNAL(exportedRowCount(int)), &progressDialog, SLOT(setValue(int))); progressDialog.show(); int ret = exportExcelObject.export2Excel(); if(ret > 0) { QMessageBox::information(this, tr("消息"), tr("恭喜您,Excel文档导出成功!")); } else { QMessageBox::critical(this, tr("错误"), tr("非常抱歉,Excel文档导出失败!")); } }
void Thread::Execute(bool WaitTilDone) { //starts the thread, waits til complete; clock_t startTime, finishTime; startTime = clock(); QProgressDialog progress; progress.setModal(true); if (pCancelFlag) *pCancelFlag = false; //haven't canceled before we started! start(); if (WantProgress) progress.show(); if (WantProgress || WantTimed || WaitTilDone){ //if we want to stick around until the thread is finished... while (isRunning()){ if (WantProgress){ progress.setLabelText(QString((*pCurMessage).c_str())); progress.setRange(0, *pCurMaxTick); progress.setValue(*pCurTick); QApplication::processEvents(); if (progress.wasCanceled()){ *pCancelFlag = true; wait(); return; //returns } } msleep(50); } } finishTime = clock(); double duration = (double)(finishTime - startTime) / CLOCKS_PER_SEC; std::ostringstream os; os << "Elapsed time: " << duration << " Sec"; if (WantTimed) QMessageBox::warning(NULL, "Warning", (os.str()).c_str()); }
void MainWindow::on_actionVista_Previa_triggered() { QProgressDialog* pDlg = new QProgressDialog(this); pDlg->setMaximum(0); pDlg->setValue(0); pDlg->show(); QPrinter * printer = new QPrinter(); QPrintDialog dlg(printer,this); // bool error; QDomDocument doc = paper.preview(); render = new ReportRenderer(); render->setPrinter(printer); render->setDocIn(doc); QMap<QString,QString> c; c["Empresa.cab_fac"] = "id = 1"; c["Empresa.lin_fac"] = "id_cab = 1"; render->setQueryClausules(c); QtConcurrent::run(render, &ReportRenderer::PreRender); connect(render,SIGNAL(end()),pDlg,SLOT(deleteLater())); connect(render,SIGNAL(end()),this,SLOT(previewReady())); }
int DicomImageSet::parseFolder(QString folderName) { QStringList fileList = getAllFiles(folderName); HRESULT hr = CoInitialize(NULL); if (!SUCCEEDED(hr)) { return NULL; } hr = S_OK; IXMLDOMDocument *pXMLDom = NULL; IXMLDOMElement *pRoot = NULL; BSTR bstrXML = NULL; VARIANT varFileName; VariantInit(&varFileName); QProgressDialog progress (QString("Parsing all files in %1").arg(folderName), QString("Cancel"), 0, fileList.count()); CHK_HR(CreateAndInitDOM(&pXMLDom)); // Create a processing instruction element. CHK_HR(CreateAndAddPINode(pXMLDom, L"xml", L"version='1.0'")); // Create the root element. CHK_HR(CreateElement(pXMLDom, L"root", &pRoot)); // Create an attribute for the <root> element, with name "created" and value "using dom". CHK_HR(CreateAndAddAttributeNode(pXMLDom, L"path", folderName.toStdWString().c_str(), pRoot)); // Add NEWLINE for identation before </root>. CHK_HR(CreateAndAddTextNode(pXMLDom, L"\n", pRoot)); // add <root> to document CHK_HR(AppendChildToParent(pRoot, pXMLDom)); progress.show(); for (int i=0; i<fileList.count(); ++i) { insertFileItem(pXMLDom, pRoot, folderName, fileList[i]); progress.setValue(i); } CHK_HR(VariantFromString(QDir(folderName).filePath(DATASET_FILE_NAME).toStdWString().c_str(), varFileName)); CHK_HR(pXMLDom->save(varFileName)); CleanUp: SAFE_RELEASE(pRoot); SysFreeString(bstrXML); VariantClear(&varFileName); CoUninitialize(); if (FAILED(hr)) { SAFE_RELEASE(pXMLDom); return 0; } return 1; }
void MainWindow::on_actionFind_all_text_string_16_bit_triggered() { HexEditorWidget* v = dynamic_cast<HexEditorWidget*>(ui->twHex->currentWidget()); if (v==NULL)return; QByteArray br = v->data(); QByteArray akk; int lastAdr=0; QProgressDialog * progress = new QProgressDialog(tr("Search..."), tr("Cancel"), 0, br.size(), this); progress->setWindowModality(Qt::WindowModal); progress->show(); for(int i=0;i<=br.count()-1;i=i+2) { if (i % 1000 == 0 ) { progress->setValue(i); QCoreApplication::processEvents (); if (progress->wasCanceled()) break; } unsigned char c = br[i]; unsigned char d = br[i+1]; bool mached = false; if( d >= 0x20 && d <= 0x7E && c == 0x00) { if(akk.count()==0)lastAdr=i; akk.append(d); mached = true; } if( d >= 0x20 && d <= 0x7E && c >= 0x20 && c <= 0x7E) { if(akk.count()==0)lastAdr=i; akk.append(d); akk.append(c); mached = true; } if(!mached) { if (akk.length()>3) { QString s; s.setNum(lastAdr,16); ui->consoleView->appendPlainText(s.toUpper() + " : \""+akk+"\""); } akk.clear(); } } progress->close(); delete progress; }
/*========================================================================= doFileSearch =========================================================================*/ void MainWindow::doFileSearch (const QString &path, const QString &text, KFileList *fileList) { QProgressDialog progress (tr("Searching..."), tr("Stop"), 0, 100, this); progress.setWindowModality (Qt::WindowModal); progress.setMinimumDuration (0); progress.show(); _doFileSearch (path, "", text, fileList, progress); progress.setValue (100); }
bool downloadTracksFromOSM(QWidget* Main, const QString& aWeb, const QString& aUser, const QString& aPassword, const CoordBox& aBox , Document* theDocument) { Downloader theDownloader(aUser, aPassword); QList<TrackLayer*> theTracklayers; //TrackMapLayer* trackLayer = new TrackMapLayer(QApplication::translate("Downloader","Downloaded tracks")); //theDocument->add(trackLayer); IProgressWindow* aProgressWindow = dynamic_cast<IProgressWindow*>(Main); if (!aProgressWindow) return false; QProgressDialog* dlg = aProgressWindow->getProgressDialog(); dlg->setWindowTitle(QApplication::translate("Downloader","Parsing...")); QProgressBar* Bar = aProgressWindow->getProgressBar(); Bar->setTextVisible(false); Bar->setMaximum(11); QLabel* Lbl = aProgressWindow->getProgressLabel(); Lbl->setText(QApplication::translate("Downloader","Parsing XML")); if (dlg) dlg->show(); theDownloader.setAnimator(dlg,Lbl,Bar,true); for (int Page=0; ;++Page) { Lbl->setText(QApplication::translate("Downloader","Downloading trackpoints %1-%2").arg(Page*5000+1).arg(Page*5000+5000)); QString URL = theDownloader.getURLToTrackPoints(); URL = URL.arg(aBox.bottomLeft().x()). arg(aBox.bottomLeft().y()). arg(aBox.topRight().x()). arg(aBox.topRight().y()). arg(Page); QUrl theUrl(aWeb+URL); if (!theDownloader.go(theUrl)) return false; if (theDownloader.resultCode() != 200) return false; int Before = theTracklayers.size(); QByteArray Ar(theDownloader.content()); bool OK = importGPX(Main, Ar, theDocument, theTracklayers, true); if (!OK) return false; if (Before == theTracklayers.size()) break; theTracklayers[theTracklayers.size()-1]->setName(QApplication::translate("Downloader", "Downloaded track - nodes %1-%2").arg(Page*5000+1).arg(Page*5000+5000)); } return true; }
bool NXMAccessManager::loggedIn() const { if (m_LoginState == LOGIN_CHECKING) { QProgressDialog progress; progress.setLabelText(tr("Verifying Nexus login")); progress.show(); while (m_LoginState == LOGIN_CHECKING) { QCoreApplication::processEvents(); QThread::msleep(100); } progress.hide(); } return m_LoginState == LOGIN_VALID; }
void Demo::OpenDialog() { QProgressDialog* dialog = new QProgressDialog(this); dialog->setLabelText("Nyan nyan nyan nyan"); dialog->setWindowTitle("Nyan nyan nyan nyan"); dialog->setCancelButtonText("Nooooooooo!"); dialog->setMinimumWidth(350); QTimer* timer = new QTimer(dialog); timer->setInterval(100); connect(timer, SIGNAL(timeout()), SLOT(DialogTimerFired())); connect(dialog, SIGNAL(canceled()), dialog, SLOT(deleteLater())); dialog->show(); timer->start(); }
void BatchTranslationDialog::startTranslation() { int translatedcount = 0; QCursor oldCursor = cursor(); setCursor(Qt::BusyCursor); int messageCount = m_dataModel->messageCount(); QProgressDialog *dlgProgress; dlgProgress = new QProgressDialog(tr("Searching, please wait..."), tr("&Cancel"), 0, messageCount, this); dlgProgress->show(); int msgidx = 0; const bool translateTranslated = m_ui.ckTranslateTranslated->isChecked(); const bool translateFinished = m_ui.ckTranslateFinished->isChecked(); for (MultiDataModelIterator it(m_dataModel, m_modelIndex); it.isValid(); ++it) { if (MessageItem *m = it.current()) { if (!m->isObsolete() && (translateTranslated || m->translation().isEmpty()) && (translateFinished || !m->isFinished())) { // Go through them in the order the user specified in the phrasebookList for (int b = 0; b < m_model.rowCount(); ++b) { QModelIndex idx(m_model.index(b, 0)); QVariant checkState = m_model.data(idx, Qt::CheckStateRole); if (checkState == Qt::Checked) { PhraseBook *pb = m_phrasebooks[m_model.data(idx, Qt::UserRole).toInt()]; foreach (const Phrase *ph, pb->phrases()) { if (ph->source() == m->text()) { m_dataModel->setTranslation(it, ph->target()); m_dataModel->setFinished(it, m_ui.ckMarkFinished->isChecked()); ++translatedcount; goto done; // break 2; } } } } } } done: ++msgidx; if (!(msgidx & 15)) dlgProgress->setValue(msgidx); qApp->processEvents(); if (dlgProgress->wasCanceled()) break; }
void TomahawkApp::onShutdownDelayed() { QProgressDialog* d = new QProgressDialog( tr( "Tomahawk is updating the database. Please wait, this may take a minute!" ), QString(), 0, 0, 0, Qt::Tool | Qt::WindowTitleHint | Qt::CustomizeWindowHint ); d->setModal( true ); d->setAutoClose( false ); d->setAutoReset( false ); d->setWindowTitle( tr( "Tomahawk" ) ); #ifdef Q_OS_MAC d->setAttribute( Qt::WA_MacAlwaysShowToolWindow ); #endif d->show(); }
void MainWindow::syncStarted(int count) { ui->actionSync->setEnabled(false); if (loaded) return; QProgressDialog* progress = new QProgressDialog("Syncing Notes...", "Abort Sync", 0, count, this); progress->setAutoReset(false); progress->setAutoClose(false); connect( EdamProtocol::GetInstance(), SIGNAL(syncProgress(int)), progress, SLOT(setValue(int))); connect(progress, SIGNAL(canceled()), EdamProtocol::GetInstance(), SLOT(cancelSync())); connect(progress, SIGNAL(canceled()), progress, SLOT(deleteLater())); connect(EdamProtocol::GetInstance(), SIGNAL(syncFinished()), progress, SLOT(close())); connect(EdamProtocol::GetInstance(), SIGNAL(syncRangeChange(int)), progress, SLOT(setMaximum(int))); progress->show(); ui->statusbar->showMessage("Sync Started!", 5000); }
bool Omr::readPdf() { QProgressDialog *progress = new QProgressDialog(QWidget::tr("Reading PDF..."), QWidget::tr("Cancel"), 0, 100, 0, Qt::FramelessWindowHint); progress->setWindowModality(Qt::ApplicationModal); progress->show(); progress->setRange(0, ACTION_NUM); #ifdef OCR if (_ocr == 0) _ocr = new Ocr; _ocr->init(); #endif int ID = READ_PDF; int page = 0; bool val; while (ID < ACTION_NUM) { if(ID != INIT_PAGE && ID != SYSTEM_IDENTIFICATION) { page = 0; progress->setLabelText(QWidget::tr("%1 at Page %2").arg(ActionNames.at(ID+1)).arg(1)); val = omrActions(ID, page); } else { progress->setLabelText(QWidget::tr("%1 at Page %2").arg(ActionNames.at(ID)).arg(page+1)); val = omrActions(ID, page); page++; } if (!val || progress->wasCanceled()) { progress->close(); return false; } else { if (ID < ACTION_NUM) progress->setValue(ID); else progress->setValue(ACTION_NUM - 1); qApp->processEvents(); } } progress->close(); delete progress; return true; }
void MVCrossCorrelogramsWidget::updateWidget() { if (d->m_path.isEmpty()) return; int k0=d->m_base_unit_num; DiskReadMda X; X.setPath(d->m_path); QProgressDialog dlg; dlg.show(); dlg.setLabelText("Loading cross correlograms..."); dlg.repaint(); qApp->processEvents(); QList<FloatList> data0=get_cross_correlogram_datas_2(X,k0); int K=data0.count()-1; int num_rows=(int)sqrt(K); if (num_rows<1) num_rows=1; int num_cols=(K+num_rows-1)/num_rows; d->m_num_columns=num_cols; QWidget *W=this; W->setAttribute(Qt::WA_DeleteOnClose); QGridLayout *GL=new QGridLayout; GL->setHorizontalSpacing(20); GL->setVerticalSpacing(0); GL->setMargin(0); W->setLayout(GL); for (int k1=1; k1<=K; k1++) { HistogramView *HV=new HistogramView; HV->setData(data0[k1]); HV->autoSetBins(50); int k2=k1; if (k0>=1) k2=k0; QString title0=QString("%1/%2").arg(k1).arg(k2); HV->setTitle(title0); GL->addWidget(HV,(k1-1)/num_cols,(k1-1)%num_cols); HV->setProperty("unit_number",k1); connect(HV,SIGNAL(clicked()),this,SLOT(slot_histogram_view_clicked())); connect(HV,SIGNAL(activated()),this,SLOT(slot_histogram_view_activated())); d->m_histogram_views << HV; } }
void MountainViewWidgetPrivate::update_clips_view(SSTimeSeriesWidget *W,SSTimeSeriesView *V,int label) { QProgressDialog dlg; dlg.setWindowTitle(QString("Extracting clips for template %1").arg(label)); dlg.setRange(0,100); dlg.show(); dlg.setLabelText(QString("Extracting clips for template %1...").arg(label)); dlg.setValue(0); dlg.repaint(); qApp->processEvents(); Mda clips=extract_clips(m_raw,m_times,m_labels,label); dlg.setLabelText("Formatting clips..."); dlg.setValue(50); dlg.repaint(); qApp->processEvents(); Mda clips2=format_clips(clips,m_template_view_padding); DiskArrayModel *MM=new DiskArrayModel; MM->setFromMda(clips2); dlg.setLabelText("Initializing..."); dlg.setValue(75); dlg.repaint(); qApp->processEvents(); V->setData(MM,true); V->initialize(); W->setClipData(clips); W->setWindowTitle(QString("Spike Clips -- template %1 -- %2 spikes").arg(label).arg(clips.N3())); }
void ShortestPathComputer::init(ccMesh *mesh, QWidget *parentWidget/* = NULL*/) { mMesh = mesh; ccGenericPointCloud *cloud = mesh->getAssociatedCloud(); const unsigned vertexNum = cloud->size(); const unsigned triangleNum = mesh->size(); const unsigned edgeNum = triangleNum * 3; //半边 Edge *edges = new Edge[edgeNum]; float *edgeWeights = new float[edgeNum]; const unsigned triangleEdgeVertexIndexs[3][2] = { 0, 1, 1, 2, 2, 0 }; unsigned edgeIndexBase, edgeIndex; mesh->placeIteratorAtBegining(); for (unsigned i = 0; i < triangleNum; i++) { CCLib::TriangleSummitsIndexes* indexs = mesh->getNextTriangleIndexes(); assert(indexs->i[0] < vertexNum && indexs->i[1] < vertexNum && indexs->i[2] < vertexNum); const CCVector3 *triangleVertices[3] = { cloud->getPoint(indexs->i[0]), cloud->getPoint(indexs->i[1]), cloud->getPoint(indexs->i[2]) }; edgeIndexBase = i * 3; for (unsigned j = 0; j < 3; j++) { edgeIndex = edgeIndexBase + j; edges[edgeIndex].first = indexs->i[triangleEdgeVertexIndexs[j][0]]; edges[edgeIndex].second = indexs->i[triangleEdgeVertexIndexs[j][1]]; edgeWeights[edgeIndex] = CCVector3::vdistance(triangleVertices[triangleEdgeVertexIndexs[j][0]]->u, triangleVertices[triangleEdgeVertexIndexs[j][1]]->u); } } //开启新线程初始化BGL图并显示进度条 BoostGraphInitThread thread; thread.setGraphData(&mGraph, edges, edgeNum, edgeWeights, vertexNum); thread.start(); QProgressDialog progress; if (parentWidget) { progress.setParent(parentWidget); } progress.setWindowModality(Qt::WindowModal); progress.setWindowFlags(Qt::SubWindow | Qt::Popup); progress.setMinimumWidth(200); progress.setCancelButton(0); progress.setWindowTitle(QString::fromAscii("BGL图初始化")); progress.setLabelText(QString::fromAscii("BGL图初始化中,请稍后...")); progress.setRange(0, 0); progress.show(); while (thread.isRunning()) { QApplication::processEvents(); } progress.close(); //mGraph = MyGraph(edges, edges + edgeNum, edgeWeights, vertexNum); }
void Polar::setPolarName(QString fname) { isCsv=true; loaded=false; clearPolar(); if(this->mainWindow->getSelectedBoat() && this->mainWindow->getSelectedBoat()->get_boatType()==BOAT_REAL) coeffPolar=Settings::getSetting("polarEfficiency",100).toInt()/100.0; else coeffPolar=1.0; //qWarning() << "Opening polar" << fname<<"with coeff"<<coeffPolar; name=fname; QString nameF = appFolder.value("polar")+fname+".csv"; QFile file(nameF); if (fname.endsWith(".csv",Qt::CaseInsensitive) || fname.endsWith(".pol",Qt::CaseInsensitive)) { nameF=appFolder.value("polar")+fname; file.setFileName(nameF); if (!file.open(QIODevice::ReadOnly | QIODevice::Text )) { QMessageBox::warning(0,QObject::tr("Lecture de polaire"), QString(QObject::tr("Impossible d'ouvrir le fichier %1")).arg(name)); return; } isCsv=fname.endsWith("csv",Qt::CaseInsensitive); } else { if (!file.open(QIODevice::ReadOnly | QIODevice::Text )) { isCsv=false; nameF = appFolder.value("polar")+fname+".pol"; file.setFileName(nameF); if (!file.open(QIODevice::ReadOnly | QIODevice::Text )) { QMessageBox::warning(0,QObject::tr("Lecture de polaire"), QString(QObject::tr("Impossible d'ouvrir le fichier %1 (ni en .csv ni en .pol)")).arg(name)); return; } } } QTextStream stream(&file); QString line; QStringList list; /* read first line to see line length */ line=stream.readLine(); line.remove("\""); if(line.isNull()) { QMessageBox::warning(0,QObject::tr("Lecture de polaire"), QString(QObject::tr("Fichier %1 vide")).arg(fname)); file.close(); return; } if(isCsv) list = line.split(';'); else list = line.split('\t'); if(list[0].toUpper() != "TWA\\TWS" && list[0].toUpper() != "TWA/TWS" && list[0].toUpper() != "TWA") { QMessageBox::warning(0,QObject::tr("Lecture de polaire"), QString(QObject::tr("Fichier %1 invalide (doit commencer par TWA\\TWS et non '%2')")) .arg(fname) .arg(list[0])); file.close(); return; } int i; for(i=1;i<list.count();++i) { if(!tws.isEmpty() && list[i].toDouble()<=tws.last()) break; tws.append(list[i].toDouble()); } bool missingTws0=false; if(tws.first()!=0.0) { missingTws0=true; } bool firstTWA=true; while(true) { line=stream.readLine(); if(line.isNull()) break; line.remove("\""); if (isCsv) list = line.split(";"); else list = line.split("\t"); if(firstTWA) { firstTWA=false; if(list.first().toDouble()!=0.0) { for(int t=0;t<tws.count();++t) { polar_data.append(0); } if(missingTws0) polar_data.append(0); twa.append(0.0); } } twa.append(list[0].toDouble()); if(missingTws0) polar_data.append(0); for(i=1;i<list.count();++i) { if(i>tws.count()) break; polar_data.append(list[i].toDouble()*this->coeffPolar); } while(i<=tws.count()) polar_data.append(0); } if(missingTws0) tws.prepend(0.0); #if 0 qWarning()<<"polar data for"<<nameF; QString debug="xxx.x "; foreach(double dd,tws) debug+=QString().sprintf("%04.1f ",dd); qWarning()<<debug; QListIterator<double> i1(polar_data); QListIterator<double> i2(twa); while(i2.hasNext()) { debug=QString().sprintf("%05.1f ",i2.next()); for(int nn=0;nn<tws.count();++nn) debug+=QString().sprintf("%04.1f ",i1.next()); qWarning()<<debug; } #endif mid_twa=qRound(twa.count()/2.0); mid_tws=qRound(tws.count()/2.0); /* polaire chargee */ /* pre-calculate B-VMG for every tws at 0.1 precision with a twa step of 1 and then .1 */ double ws=0.0; double wa=0.0; double bvmg,bvmg_d,bvmg_u,wa_u,wa_d,wa_limit; maxSpeed=0.0; do { wa_u=0.0; wa_d=180.0; bvmg_u=bvmg_d=0; double speed; do { speed=myGetSpeed(ws,wa,true); if(speed>maxSpeed) maxSpeed=speed; bvmg=speed*cos(degToRad(wa)); if(bvmg_u<bvmg) //bvmg is positive here { bvmg_u=bvmg; wa_u=wa; } if(bvmg_d>bvmg) //bvmg is negative here { bvmg_d=bvmg; wa_d=wa; } wa=qRound(wa+1); } while(wa<181.00); wa=wa_u-1; wa_limit=wa_u+1; if(wa<0) wa=0.0; if(wa_limit<1) wa_limit=1.0; if(wa_limit>180) wa_limit=180.0; bvmg_u=0.0; do { speed=myGetSpeed(ws,wa,true); if(speed>maxSpeed) maxSpeed=speed; bvmg=speed*cos(degToRad(wa)); if(bvmg_u<bvmg) { bvmg_u=bvmg; wa_u=wa; } wa=wa+0.1; } while(wa<(wa_limit+0.1000)); wa=wa_d-1; wa_limit=wa_d+1; if(wa<0) wa=0.0; if(wa_limit<1) wa_limit=1.0; if(wa_limit>180) wa_limit=180.0; bvmg_d=0.0; do { speed=myGetSpeed(ws,wa,true); if(speed>maxSpeed) maxSpeed=speed; bvmg=speed*cos(degToRad(wa)); if(bvmg_d>bvmg) { bvmg_d=bvmg; wa_d=wa; } wa=wa+0.1; }while(wa<wa_limit+0.1); best_vmg_up.append(wa_u); best_vmg_down.append(wa_d); wa=0.0; ws=ws+.1; }while(ws<60.1); loaded=true; QFileInfo fi(file.fileName()); QString nameFVmg = appFolder.value("polar")+fi.baseName()+".vmg"; fileVMG.setFileName(nameFVmg); if (fileVMG.open(QIODevice::ReadOnly | QIODevice::Text )) { if(fileVMG.size()<4329500 || fileVMG.size()>4329700) fileVMG.remove(); else { QFileInfo info1(fileVMG); QFileInfo info2(file); if(this->mainWindow->isStartingUp && info1.lastModified()<info2.lastModified()) fileVMG.remove(); else { file.close(); return; } } } file.close(); //precalculate regular VMGs //qWarning() << "Start computing vmg"; fileVMG.open(QIODevice::WriteOnly | QIODevice::Text ); double vmg=0; QTextStream sVmg(&fileVMG); QString ssVmg; QProgressDialog * progress; progress=new QProgressDialog((QWidget*)mainWindow); progress->setWindowModality(Qt::ApplicationModal); progress->setLabelText(tr("Pre-calcul des valeurs de VMG pour ")+fname); progress->setMaximum(600); progress->setMinimum(0); progress->setCancelButton(NULL); progress->setMaximumHeight(100); progress->show(); for (int tws=0;tws<601;tws++) { progress->setValue(tws); for (int twa=0;twa<1801;twa++) { bvmgWind((double) twa/10.0,(double) tws/10.0,&vmg); ssVmg.sprintf("%.4d",qRound(A360(vmg)*10.0)); sVmg<<ssVmg; } } fileVMG.close(); if(!fileVMG.open(QIODevice::ReadOnly | QIODevice::Text )) qWarning()<<"fileVMG could not be re-opened!"; progress->close(); delete progress; }
void Segments::makeSegments(QImage &imageProcessed, SegmentSettings seg) { segments.clear(); // autoDelete is on // statistics that show up in debug spew int madeLines = 0; int shortLines = 0; // lines rejected since their segments are too short int foldedLines = 0; // lines rejected since they could be into other lines // debugging with modal progress dialog box is problematic so make switchable const bool useDlg = true; // for each new column of pixels, loop through the runs. a run is defined as // one or more colored pixels that are all touching, with one uncolored pixel or the // image boundary at each end of the set. for each set in the current column, count // the number of runs it touches in the adjacent (left and right) columns. here is // the pseudocode: // if ((L > 1) || (R > 1)) // "this run is at a branch point so ignore the set" // else // if (L == 0) // "this run is the start of a new segment" // else // "this run is appended to the segment on the left int width = imageProcessed.width(); int height = imageProcessed.height(); QProgressDialog* dlg; if (useDlg) { dlg = new QProgressDialog("Scanning segments in image", "Cancel", 0, width); CHECK_PTR_ENGAUGE(dlg); dlg->setCaption(QString("Progress")); dlg->show(); } bool* lastBool = new bool [height]; CHECK_PTR_ENGAUGE(lastBool); bool* currBool = new bool [height]; CHECK_PTR_ENGAUGE(currBool); bool* nextBool = new bool [height]; CHECK_PTR_ENGAUGE(nextBool); Segment** lastSegment = new Segment* [height]; CHECK_PTR_ENGAUGE(lastSegment); Segment** currSegment = new Segment* [height]; CHECK_PTR_ENGAUGE(currSegment); Discretize discretize; loadBool(&discretize, lastBool, &imageProcessed, -1); loadBool(&discretize, currBool, &imageProcessed, 0); loadBool(&discretize, nextBool, &imageProcessed, 1); loadSegment(lastSegment, height); for (int x = 0; x < width; x++) { if (useDlg) { // update progress bar dlg->setValue(x); qApp->processEvents(); if (dlg->wasCanceled()) // quit scanning. only existing segments will be available break; } matchRunsToSegments(x, height, lastBool, lastSegment, currBool, currSegment, nextBool, seg, &madeLines, &foldedLines, &shortLines); // get ready for next column scrollBool(lastBool, currBool, height); scrollBool(currBool, nextBool, height); if (x + 1 < width) loadBool(&discretize, nextBool, &imageProcessed, x + 1); scrollSegment(lastSegment, currSegment, height); } if (useDlg) { dlg->setValue(width); delete dlg; } DigitDebug::scanning(QString("segment lines created ") + QString::number(madeLines) + QString(", too short so removed ") + QString::number(shortLines) + QString(", folded together ") + QString::number(foldedLines)); delete[] lastBool; delete[] currBool; delete[] nextBool; delete[] lastSegment; delete[] currSegment; }
int QgsGml::getFeatures( const QString &uri, QgsWkbTypes::Type *wkbType, QgsRectangle *extent, const QString &userName, const QString &password, const QString &authcfg ) { //start with empty extent mExtent.setMinimal(); QNetworkRequest request( uri ); if ( !authcfg.isEmpty() ) { if ( !QgsApplication::authManager()->updateNetworkRequest( request, authcfg ) ) { QgsMessageLog::logMessage( tr( "GML Getfeature network request update failed for authcfg %1" ).arg( authcfg ), tr( "Network" ), Qgis::Critical ); return 1; } } else if ( !userName.isNull() || !password.isNull() ) { request.setRawHeader( "Authorization", "Basic " + QStringLiteral( "%1:%2" ).arg( userName, password ).toLatin1().toBase64() ); } QNetworkReply *reply = QgsNetworkAccessManager::instance()->get( request ); if ( !authcfg.isEmpty() ) { if ( !QgsApplication::authManager()->updateNetworkReply( reply, authcfg ) ) { reply->deleteLater(); QgsMessageLog::logMessage( tr( "GML Getfeature network reply update failed for authcfg %1" ).arg( authcfg ), tr( "Network" ), Qgis::Critical ); return 1; } } connect( reply, &QNetworkReply::finished, this, &QgsGml::setFinished ); connect( reply, &QNetworkReply::downloadProgress, this, &QgsGml::handleProgressEvent ); //find out if there is a QGIS main window. If yes, display a progress dialog QProgressDialog *progressDialog = nullptr; QWidget *mainWindow = nullptr; QWidgetList topLevelWidgets = qApp->topLevelWidgets(); for ( QWidgetList::const_iterator it = topLevelWidgets.constBegin(); it != topLevelWidgets.constEnd(); ++it ) { if ( ( *it )->objectName() == QLatin1String( "QgisApp" ) ) { mainWindow = *it; break; } } if ( mainWindow ) { progressDialog = new QProgressDialog( tr( "Loading GML data\n%1" ).arg( mTypeName ), tr( "Abort" ), 0, 0, mainWindow ); progressDialog->setWindowModality( Qt::ApplicationModal ); connect( this, &QgsGml::dataReadProgress, progressDialog, &QProgressDialog::setValue ); connect( this, &QgsGml::totalStepsUpdate, progressDialog, &QProgressDialog::setMaximum ); connect( progressDialog, &QProgressDialog::canceled, this, &QgsGml::setFinished ); progressDialog->show(); } int atEnd = 0; while ( !atEnd ) { if ( mFinished ) { atEnd = 1; } QByteArray readData = reply->readAll(); if ( !readData.isEmpty() ) { QString errorMsg; if ( !mParser.processData( readData, atEnd, errorMsg ) ) QgsMessageLog::logMessage( errorMsg, QObject::tr( "WFS" ) ); } QCoreApplication::processEvents(); } fillMapsFromParser(); QNetworkReply::NetworkError replyError = reply->error(); QString replyErrorString = reply->errorString(); delete reply; delete progressDialog; if ( replyError ) { QgsMessageLog::logMessage( tr( "GML Getfeature network request failed with error: %1" ).arg( replyErrorString ), tr( "Network" ), Qgis::Critical ); return 1; } *wkbType = mParser.wkbType(); if ( *wkbType != QgsWkbTypes::Unknown ) { if ( mExtent.isEmpty() ) { //reading of bbox from the server failed, so we calculate it less efficiently by evaluating the features calculateExtentFromFeatures(); } } if ( extent ) *extent = mExtent; return 0; }
void SegmentFactory::makeSegments (const QImage &imageFiltered, const DocumentModelSegments &modelSegments, QList<Segment*> &segments) { LOG4CPP_INFO_S ((*mainCat)) << "SegmentFactory::makeSegments"; // Statistics that show up in debug spew int madeLines = 0; int shortLines = 0; // Lines rejected since their segments are too short int foldedLines = 0; // Lines rejected since they could be into other lines // debugging with modal progress dialog box is problematic so make switchable const bool useDlg = true; // For each new column of pixels, loop through the runs. a run is defined as // one or more colored pixels that are all touching, with one uncolored pixel or the // image boundary at each end of the set. for each set in the current column, count // the number of runs it touches in the adjacent (left and right) columns. here is // the pseudocode: // if ((L > 1) || (R > 1)) // "this run is at a branch point so ignore the set" // else // if (L == 0) // "this run is the start of a new segment" // else // "this run is appended to the segment on the left int width = imageFiltered.width(); int height = imageFiltered.height(); QProgressDialog* dlg; if (useDlg) { dlg = new QProgressDialog("Scanning segments in image", "Cancel", 0, width); ENGAUGE_CHECK_PTR (dlg); dlg->show(); } bool* lastBool = new bool [height]; ENGAUGE_CHECK_PTR(lastBool); bool* currBool = new bool [height]; ENGAUGE_CHECK_PTR(currBool); bool* nextBool = new bool [height]; ENGAUGE_CHECK_PTR(nextBool); SegmentVector lastSegment (height); SegmentVector currSegment (height); ColorFilter filter; loadBool(filter, lastBool, imageFiltered, -1); loadBool(filter, currBool, imageFiltered, 0); loadBool(filter, nextBool, imageFiltered, 1); loadSegment(lastSegment, height); for (int x = 0; x < width; x++) { if (useDlg) { // Update progress bar dlg->setValue(x); qApp->processEvents(); if (dlg->wasCanceled()) { // Quit scanning. only existing segments will be available break; } } matchRunsToSegments(x, height, lastBool, lastSegment, currBool, currSegment, nextBool, modelSegments, &madeLines, &foldedLines, &shortLines, segments); // Get ready for next column scrollBool(lastBool, currBool, height); scrollBool(currBool, nextBool, height); if (x + 1 < width) { loadBool(filter, nextBool, imageFiltered, x + 1); } scrollSegment(lastSegment, currSegment, height); } if (useDlg) { dlg->setValue(width); delete dlg; } removeEmptySegments (segments); LOG4CPP_INFO_S ((*mainCat)) << "SegmentFactory::makeSegments" << " linesCreated=" << madeLines << " linesTooShortSoRemoved=" << shortLines << " linesFoldedTogether=" << foldedLines; delete[] lastBool; delete[] currBool; delete[] nextBool; }
void MainWindow::launchInstance(InstancePtr instance, AuthSessionPtr session, BaseProfilerFactory *profiler) { Q_ASSERT_X(instance != NULL, "launchInstance", "instance is NULL"); Q_ASSERT_X(session.get() != nullptr, "launchInstance", "session is NULL"); QString launchScript; if(!instance->prepareForLaunch(session, launchScript)) return; MinecraftProcess *proc = new MinecraftProcess(instance); proc->setLaunchScript(launchScript); proc->setWorkdir(instance->minecraftRoot()); this->hide(); console = new ConsoleWindow(proc); connect(console, SIGNAL(isClosing()), this, SLOT(instanceEnded())); proc->setLogin(session); proc->arm(); if (profiler) { QString error; if (!profiler->check(&error)) { QMessageBox::critical(this, tr("Error"), tr("Couldn't start profiler: %1").arg(error)); proc->abort(); return; } BaseProfiler *profilerInstance = profiler->createProfiler(instance, this); QProgressDialog dialog; dialog.setMinimum(0); dialog.setMaximum(0); dialog.setValue(0); dialog.setLabelText(tr("Waiting for profiler...")); connect(&dialog, &QProgressDialog::canceled, profilerInstance, &BaseProfiler::abortProfiling); dialog.show(); connect(profilerInstance, &BaseProfiler::readyToLaunch, [&dialog, this, proc](const QString &message) { dialog.accept(); QMessageBox msg; msg.setText(tr("The launch of Minecraft itself is delayed until you press the " "button. This is the right time to setup the profiler, as the " "profiler server is running now.\n\n%1").arg(message)); msg.setWindowTitle(tr("Waiting")); msg.setIcon(QMessageBox::Information); msg.addButton(tr("Launch"), QMessageBox::AcceptRole); msg.exec(); proc->launch(); }); connect(profilerInstance, &BaseProfiler::abortLaunch, [&dialog, this, proc](const QString &message) { dialog.accept(); QMessageBox msg; msg.setText(tr("Couldn't start the profiler: %1").arg(message)); msg.setWindowTitle(tr("Error")); msg.setIcon(QMessageBox::Critical); msg.addButton(QMessageBox::Ok); msg.exec(); proc->abort(); }); profilerInstance->beginProfiling(proc); dialog.exec(); } else { proc->launch(); } }
bool QgsShapeFile::scanGeometries() { QProgressDialog *sg = new QProgressDialog(); sg->setMinimum( 0 ); sg->setMaximum( 0 ); QString label = tr( "Scanning " ); label += fileName; sg->setLabel( new QLabel( label ) ); sg->show(); qApp->processEvents(); OGRFeatureH feat; OGRwkbGeometryType currentType = wkbUnknown; bool multi = false; while (( feat = OGR_L_GetNextFeature( ogrLayer ) ) ) { qApp->processEvents(); // feat->DumpReadable(NULL); OGRGeometryH geom = OGR_F_GetGeometryRef( feat ); if ( geom ) { QString gml = OGR_G_ExportToGML( geom ); // QgsDebugMsg(gml); if ( gml.indexOf( "gml:Multi" ) > -1 ) { // QgsDebugMsg("MULTI Part Feature detected"); multi = true; } OGRFeatureDefnH fDef = OGR_F_GetDefnRef( feat ); OGRwkbGeometryType gType = OGR_FD_GetGeomType( fDef ); // QgsDebugMsg(gType); if ( gType > currentType ) { currentType = gType; } if ( gType < currentType ) { QgsDebugMsg( QString( "Encountered inconsistent geometry type %1" ).arg( gType ) ); } } } // a hack to support 2.5D geometries (their wkb is equivalent to 2D variants // except that the highest bit is set also). For now we will ignore 3rd coordinate. hasMoreDimensions = false; if ( currentType & wkb25DBit ) { QgsDebugMsg( "Got a shapefile with 2.5D geometry." ); currentType = wkbFlatten( currentType ); hasMoreDimensions = true; } OGR_L_ResetReading( ogrLayer ); geom_type = geometries[currentType]; if ( multi && ( geom_type.indexOf( "MULTI" ) == -1 ) ) { geom_type = "MULTI" + geom_type; } delete sg; // QgsDebugMsg(QString("Geometry type is %1 (%2)").arg(currentType).arg(geometries[currentType])); return multi; }