RBDtoWeatherDialog::RBDtoWeatherDialog(QWidget *parent) : QDialog(parent), ui(new Ui::RBDtoWeatherDialog) { ui->setupUi(this); connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(doCalc())); }
weatherToNoaaDialog::weatherToNoaaDialog(QWidget *parent) : QDialog(parent), ui(new Ui::weatherToNoaaDialog) { ui->setupUi(this); connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(doCalc())); connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close())); }
int main(int argc, char *argv[]) { static int key = 9973; static char mbuf[1024000]; char *p; p = malloc(1024); doCalc(key); exit(EXIT_SUCCESS); }
stData CTLAbstractAlgorithm::calculate(const unsigned long long &ullTFIndex, const long double &ldblTimeFrame, const long double &ldblStartTime, const long double &ldblTimeStep, const long double &ldblEndTime, const QVector<stData> &x, const QVector<stData> &y) { if (!m_prepared) prepare(ldblStartTime, ldblTimeStep, ldblEndTime); return doCalc(ullTFIndex, ldblTimeFrame, x, y); }
int main(int argc, char *argv[]) /* Allocated in frame for main() */ { static int key = 9973; /* Initialized data segment */ static char mbuf[10240000]; /* Uninitialized data segment */ char *p; /* Allocated in frame for main() */ p = malloc(1024); /* Points to memory in heap segment */ doCalc(key); exit(EXIT_SUCCESS); }
processByMonths::processByMonths(QWidget *parent) : QWidget(parent), ui(new Ui::processByMonths), positionModel(new QSqlTableModel), aspectsModel(new QSqlTableModel), quadrantsModel(new QSqlTableModel), signsModel(new QSqlTableModel), housesModel(new QSqlTableModel), weatherModel(new QSqlTableModel), resultModel(new QSqlQueryModel), noaaModel(new QSqlTableModel) { ui->setupUi(this); connect(ui->filterButton, SIGNAL(clicked()), this, SLOT(doCalc())); connect(ui->dayResultTableView, SIGNAL(clicked(QModelIndex)), this, SLOT(dayChange(QModelIndex))); connect(ui->noaaResultTableView, SIGNAL(clicked(QModelIndex)), this, SLOT(dayChange(QModelIndex))); connect(ui->monthResultTableView, SIGNAL(clicked(QModelIndex)), this, SLOT(weatherChange(QModelIndex))); ui->positionTableView->setModel(positionModel); ui->quadrantsTableView->setModel(quadrantsModel); ui->AspectsTableView->setModel(aspectsModel); ui->signsTableView->setModel(signsModel); ui->housesTableView->setModel(housesModel); ui->monthResultTableView->setModel(resultModel); ui->noaaResultTableView->setModel(noaaModel); ui->dayResultTableView->setModel(weatherModel); positionModel->setTable("view_posiciones"); aspectsModel->setTable("view_aspectaiums"); quadrantsModel->setTable("view_cuadrantes"); signsModel->setTable("view_signos"); housesModel->setTable("view_casas"); weatherModel->setTable("view_estadotiempos"); noaaModel->setTable("estadotiempos_diarios"); ui->mesSpinBox->setValue(MainWindow::instance()->getWorkingDate().date().month()); ui->monthResultTableView->setContextMenuPolicy(Qt::CustomContextMenu); ui->dayResultTableView->setContextMenuPolicy(Qt::CustomContextMenu); ui->noaaResultTableView->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->monthResultTableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(monthMenu(QPoint))); connect(ui->dayResultTableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(dayMenu(QPoint))); connect(ui->noaaResultTableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(noaaMenu(QPoint))); }
processByAspectWidget::processByAspectWidget(QWidget *parent) : QWidget(parent), ui(new Ui::processByAspectWidget), information(new dataProcessor) { ui->setupUi(this); setWindowTitle("Procesar por Aspectos"); QSqlQuery query; query.exec("CREATE TEMPORARY TABLE IF NOT EXISTS pedro (fecha DATESTAMP NOT NULL," "planeta1 SHORT NOT NULL," "signo1 SHORT NOT NULL," "planeta2 SHORT NOT NULL," "signo2 SHORT NOT NULL" ");"); qDebug() << query.lastQuery() << query.lastError(); query.exec("DELETE FROM pedro WHERE 1 = 1"); qDebug() << query.lastQuery() << query.lastError(); astroModel = new QSqlTableModel(); dairyModel = new QSqlTableModel(); signModel = new QSqlTableModel(); ui->dairyTableView->setModel(dairyModel); ui->astroTableView->setModel(astroModel); ui->occurenciasTableView->setModel(signModel); dairyModel->setTable("estadotiempos_diarios"); astroModel->setTable("view_estadotiempos"); signModel->setTable("pedro"); refreshResult(); connect(ui->addlButton, SIGNAL(clicked()), this, SLOT(add())); connect(ui->dellButton, SIGNAL(clicked()), this, SLOT(del())); connect(ui->filterButton, SIGNAL(clicked()), this, SLOT(doCalc())); ui->dairyTableView->setContextMenuPolicy(Qt::CustomContextMenu); ui->astroTableView->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->dairyTableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(noaaMenu(QPoint))); connect(ui->astroTableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(daysMenu(QPoint))); }
ResultSet BoolQuery::calcRPN(Expression exp) { stack<ReverseTable> tableStack; ReverseTable opA, opB; for (string token : exp) { if (isOp(token)) { opA = tableStack.top(); tableStack.pop(); if (token != "NOT") { opB = tableStack.top(); tableStack.pop(); } tableStack.push(doCalc(token, opA, opB)); } else { ReverseTable tmp = getReverseTable(token); tableStack.push(tmp); } } return tableStack.top(); }
processByDignityWidget::processByDignityWidget(QWidget *parent) : QWidget(parent), ui(new Ui::processByDignityWidget), fechaModel(new QSqlTableModel), resultModel(new QSqlTableModel), noaaResultModel(new QSqlTableModel), information(new dataProcessor) { ui->setupUi(this); QStringList items; connect(ui->filterButton, SIGNAL(clicked()), this, SLOT(doCalc())); connect(ui->dignityFilterButton, SIGNAL(clicked()), this, SLOT(calcDignity())); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(add())); connect(ui->delButton, SIGNAL(clicked()), this, SLOT(del())); items << "Normal" << "Luna llena" << "Luna nueva" << "Equinoccios" << "Solsticios"; ui->tipoComboBox->addItems(items); fechaModel->setTable("view_estadotiempos"); fechaModel->select(); //resultModel->setTable("validweather"); resultModel->setTable("view_estadotiempos"); noaaResultModel->setTable("estadotiempos_diarios"); ui->tableView->setModel(resultModel); ui->noaaTableView->setModel(noaaResultModel); ui->fechaComboBox->setModel(fechaModel); ui->fechaComboBox->setModelColumn(0); dateTypeChanged("Normal"); setWindowTitle("Procesar por Dignidades"); connect(ui->tipoComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(dateTypeChanged(QString))); ui->noaaTableView->setContextMenuPolicy(Qt::CustomContextMenu); ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->noaaTableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(noaaMenu(QPoint))); connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(dailyMenu(QPoint))); }
processByCyclesWidget::processByCyclesWidget(QWidget *parent) : QWidget(parent), ui(new Ui::processByCyclesWidget), fechaModel(new QSqlTableModel), phase19Model(new QSqlTableModel), phase37Model(new QSqlTableModel), phase96Model(new QSqlTableModel), nPhaseModel(new QSqlTableModel), monthlyModel(new QSqlTableModel), dailyModel(new QSqlTableModel), astralDailyModel(new QSqlTableModel) { ui->setupUi(this); connect(ui->filterButton, SIGNAL(clicked()), this, SLOT(doCalc())); connect(ui->phase19ListView, SIGNAL(clicked(QModelIndex)), this, SLOT(phaseSelected(QModelIndex))); connect(ui->phase37ListView, SIGNAL(clicked(QModelIndex)), this, SLOT(phaseSelected(QModelIndex))); connect(ui->phase96ListView, SIGNAL(clicked(QModelIndex)), this, SLOT(phaseSelected(QModelIndex))); connect(ui->nMonthListView, SIGNAL(clicked(QModelIndex)), this, SLOT(phaseSelected(QModelIndex))); connect(ui->phase19ListView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(phaseMenu(QPoint))); connect(ui->phase37ListView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(phaseMenu(QPoint))); connect(ui->phase96ListView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(phaseMenu(QPoint))); connect(ui->nMonthListView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(phaseMenu(QPoint))); QStringList items; items << "Normal" << "Luna llena" << "Luna nueva" << "Equinoccios" << "Solsticios"; ui->tipoFechaComboBox->addItems(items); fechaModel->setTable("estadotiempos"); phase19Model->setTable("estadotiempos_diarios"); phase19Model->setSort(0, Qt::AscendingOrder); phase37Model->setTable("estadotiempos_diarios"); phase37Model->setSort(0, Qt::AscendingOrder); phase96Model->setTable("estadotiempos_diarios"); phase96Model->setSort(0, Qt::AscendingOrder); nPhaseModel->setTable("estadotiempos_diarios"); nPhaseModel->setSort(0, Qt::AscendingOrder); monthlyModel->setTable("estadotiempos_mensuales"); dailyModel->setTable("estadotiempos_diarios"); astralDailyModel->setTable("view_estadotiempos"); ui->phase19ListView->setModel(phase19Model); //ui->phase19ListView->setModelColumn(1); ui->phase37ListView->setModel(phase37Model); //ui->phase37ListView->setModelColumn(1); ui->phase96ListView->setModel(phase96Model); //ui->phase96ListView->setModelColumn(1); ui->nMonthListView->setModel(nPhaseModel); ui->astrologycalDaysTableView->setModel(astralDailyModel); ui->daysTableView->setModel(dailyModel); ui->monthTableView->setModel(monthlyModel); phase19Model->select(); phase37Model->select(); phase96Model->select(); nPhaseModel->select(); ui->diaComboBox->setModel(fechaModel); ui->diaComboBox->setModelColumn(1); typeChanged("Normal"); setWindowTitle("Proceso por Ciclos Lunares"); ui->astrologycalDaysTableView->setContextMenuPolicy(Qt::CustomContextMenu); ui->daysTableView->setContextMenuPolicy(Qt::CustomContextMenu); ui->monthTableView->setContextMenuPolicy(Qt::CustomContextMenu); ui->phase19ListView->setContextMenuPolicy(Qt::CustomContextMenu); ui->phase37ListView->setContextMenuPolicy(Qt::CustomContextMenu); ui->phase96ListView->setContextMenuPolicy(Qt::CustomContextMenu); ui->nMonthListView->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->astrologycalDaysTableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(astralMenu(QPoint))); connect(ui->daysTableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(noaaMenu(QPoint))); connect(ui->monthTableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(monthMenu(QPoint))); connect(ui->tipoFechaComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(typeChanged(QString))); }
MainWindow::MainWindow(QApplication &app, ElementDatabase& db) : QMainWindow(), Ui::MainWindow(), mApp(&app), mCompleter(NULL), mLangPath(":/lang"), mInputData(db), mDB(&db), mDataVisualizer(this, db) { mApp->installTranslator(&mTranslator); #ifdef DEBUG if ( ! mLangPath.exists() ) std::cerr << "Unable to determine language directory !" << std::endl; #endif setupUi(this); mFormulaDefaultPalette = ntrFormula->palette(); tblResult->setModel(&mModel); // action setup (menu bar) menuFile = new QMenu(menubar); menuTools = new QMenu(menubar); menuLang = new QMenu(menubar); menuHelp = new QMenu(menubar); addActions(); connect(actionQuit, SIGNAL(triggered()), &app, SLOT(quit())); connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); connect(actionAbout_Qt, SIGNAL(triggered()), &app, SLOT(aboutQt())); connect(actionAbout, SIGNAL(triggered()), this, SLOT(about())); connect(actionVisualizeData, SIGNAL(triggered()), &mDataVisualizer, SLOT(show())); connect(actionUseSystemLocale, SIGNAL(triggered()), this, SLOT(useSystemLocaleTriggered())); selectDefaultLang(); actionUseSystemLocale->trigger(); // action setup result table connect(actionExpandAll, SIGNAL(triggered()), this, SLOT(expandAll())); connect(actionCollapseAll, SIGNAL(triggered()), this, SLOT(collapseAll())); connect(actionSelectAll, SIGNAL(triggered()), tblResult, SLOT(selectAll())); connect(actionCopySelection, SIGNAL(triggered()), this, SLOT(copyResultTableSelection())); connect(tblResult, SIGNAL(expanded(const QModelIndex&)), this, SLOT(expandItem(const QModelIndex&))); connect(tblResult, SIGNAL(collapsed(const QModelIndex&)), this, SLOT(expandItem(const QModelIndex&))); // populate list of all known GUI input fields mFormEntries.append(FormEntry(ntrFormula, "currentText", lblFormula)); mFormEntries.append(FormEntry(ntrDensity, "value", lblDensity)); mFormEntries.append(FormEntry(ntrXrayEn, "value", lblXrayEn)); mFormEntries.append(FormEntry(ntrNeutronWl, "value", lblNeutronWl)); saveInitialInput(); // button connectors connect(btnClear, SIGNAL(clicked()), this, SLOT(resetInput())); connect(btnAddAlias, SIGNAL(clicked()), this, SLOT(addAlias())); connect(btnCalc, SIGNAL(clicked()), this, SLOT(doCalc())); if (ntrFormula->lineEdit()) { mCompleter = new FormulaCompleter(db, ntrFormula->lineEdit(), btnCalc); connect(ntrFormula->lineEdit(), SIGNAL(returnPressed()), btnCalc, SLOT(animateClick())); } connect(ntrDensity, SIGNAL(editingFinished()), btnCalc, SLOT(animateClick())); connect(ntrXrayEn, SIGNAL(editingFinished()), btnCalc, SLOT(animateClick())); connect(ntrNeutronWl, SIGNAL(editingFinished()), btnCalc, SLOT(animateClick())); connect(lblFormattedFormula, SIGNAL(linkActivated(const QString&)), this, SLOT(showElementData(const QString&))); connect(&mDataVisualizer, SIGNAL(elementLinkActivated(const QString&)), this, SLOT(showElementData(const QString&))); }
static long process(acalcoutRecord *pcalc) { rpvtStruct *prpvt = (rpvtStruct *)pcalc->rpvt; long i; double *pnew, *pprev; if (aCalcoutRecordDebug) printf("acalcoutRecord(%s):process: pact=%d, cact=%d, dlya=%d\n", pcalc->name, pcalc->pact, pcalc->cact, pcalc->dlya); /* Make sure. Autosave is capable of setting NUSE to an illegal value. */ if ((pcalc->nuse < 0) || (pcalc->nuse > pcalc->nelm)) { pcalc->nuse = pcalc->nelm; db_post_events(pcalc,&pcalc->nuse, DBE_VALUE|DBE_LOG); } /* If we're getting processed, we can no longer put off allocating memory */ if (pcalc->aval == NULL) pcalc->aval = (double *)calloc(pcalc->nelm, sizeof(double)); if (pcalc->oav == NULL) pcalc->oav = (double *)calloc(pcalc->nelm, sizeof(double)); if (!pcalc->pact) { pcalc->pact = TRUE; /* record scalar-field values so we can tell which ones aCalcPerform wrote to. */ for (i=0, pnew=&pcalc->a, pprev=&pcalc->pa; i<MAX_FIELDS; i++, pnew++, pprev++) { *pprev = *pnew; } /* if some links are CA, check connections */ if (prpvt->caLinkStat != NO_CA_LINKS) checkLinks(pcalc); if (fetch_values(pcalc)==0) { long stat; if (aCalcoutRecordDebug >= 5) printf("acalcoutRecord(%s):process: queueing aCalcPerform\n", pcalc->name); pcalc->cact = 0; stat = doCalc(pcalc); if (stat) printf("%s:process: doCalc failed.\n", pcalc->name); if (stat == 0 && pcalc->cact == 1) { pcalc->pact = 1; /* we'll get processed again when the calculation is done */ return(0); } else { if (afterCalc(pcalc) == ASYNC) return(0); } } } else { /* pact == TRUE */ /* Who invoked us ? */ if (pcalc->cact) { pcalc->cact = 0; if (afterCalc(pcalc) == ASYNC) return(0); } else if (pcalc->dlya) { /* callbackRequestProcessCallbackDelayed() called us */ pcalc->dlya = 0; db_post_events(pcalc,&pcalc->dlya,DBE_VALUE); /* Must set pact 0 so that asynchronous device support works */ pcalc->pact = 0; execOutput(pcalc); if (pcalc->pact) return(0); pcalc->pact = TRUE; } else { /* We must have been called by asynchronous device support */ writeValue(pcalc); } } /*checkAlarms(pcalc); This is too late; IVOA might have vetoed output */ recGblGetTimeStamp(pcalc); if (aCalcoutRecordDebug >= 5) { printf("acalcoutRecord(%s):process:calling monitor \n", pcalc->name); } monitor(pcalc); recGblFwdLink(pcalc); pcalc->pact = FALSE; if (aCalcoutRecordDebug >= 5) { printf("acalcoutRecord(%s):process-done\n", pcalc->name); } if (aCalcoutRecordDebug) printf("acalcoutRecord(%s):process: exit, pact==0\n", pcalc->name); return(0); }
uint32_t calc(int argc, char* argv[]) { calcErrFlag = 0; int now = 0; for(int i = 1; i < argc; ++i) for(int j = 0; argv[i][j]; ++j) buf[now++] = argv[i][j]; buf[now] = 0; cprintf("%s : ", buf); now = 0; for(int i = 0; buf[i]; ++i) { int flag = 0; for(int j = 0; j < NOPERATORS; ++j) { if(buf[i] == operator[j].symbol[0]) { flag = 1; calcBuf[now++] = buf[i]; if(buf[i + 1] == '<' || buf[i + 1] == '>' ) break; calcBuf[now++] = ' '; break; } } if(flag) continue; if('0' <= buf[i] && buf[i] <= '9') { while( buf[i] == 'x' || '0' <= buf[i] && buf[i] <= '9' || 'a' <= buf[i] && buf[i] <= 'f' || 'A' <= buf[i] && buf[i] <= 'F' ) { calcBuf[now++] = buf[i++]; } calcBuf[now++] = ' '; i --; continue; } flag = *strfind(reservedChars, buf[i]); if(flag) { cprintf("Invalid character: %c\n", buf[i]); calcErrFlag = -1; return -1; } while(1) { flag = *strfind(reservedChars, buf[i]); if(!flag && buf[i]) calcBuf[now++] = buf[i++]; else { calcBuf[now++] = ' ', i--; break; } } } calcBuf[now] = 0; // cprintf("%s\n", calcBuf); char** calcComp = split(calcBuf); stackn = 0; valuen = 0; int m = 0; for(int i = 0; calcComp[i]; ++i) { m = i; int j; if((j = findOpt(calcComp[i])) != -1) { if(operator[j].type == OPT_LBRACE || operator[j].type == OPT_RBRACE) calcMark[i] = operator[j].type; else if(i == 0 || calcMark[i-1] == OPT_UNO || calcMark[i-1] == OPT_BINARY || calcMark[i-1] == OPT_LBRACE) calcMark[i] = OPT_UNO; else calcMark[i] = OPT_BINARY; continue; } if('0' <= calcComp[i][0] && calcComp[i][0] <= '9') { calcMark[i] = OPT_VALUE; continue; } calcMark[i] = OPT_SYMBOL; } /* for(int i = 0; i <= m; ++i) cprintf("%d ", calcMark[i]); cprintf("\n"); */ for(int i = m; i >= 0; --i) { //printCalcStack(); int j; struct DebugInfo* p; switch(calcMark[i]) { case OPT_UNO: j = findSpecOpt(calcComp[i], OPT_UNO); if(j == -1) { cprintf("Invalid expression!\n"); calcErrFlag = -1; return -1; } calcStack[++stackn] = operator[j]; doCalc(); break; case OPT_BINARY: j = findSpecOpt(calcComp[i], OPT_BINARY); if(j == -1) { cprintf("Invalid expression!\n"); calcErrFlag = -1; return -1; } while( stackn > 0 && calcStack[stackn].type == OPT_BINARY && calcStack[stackn].priority > operator[j].priority) doCalc(); calcStack[++stackn] = operator[j]; break; case OPT_LBRACE: while(calcStack[stackn].type != OPT_RBRACE) doCalc(); stackn--; break; case OPT_RBRACE: calcStack[++stackn].type = OPT_RBRACE; break; case OPT_VALUE: calcValue[++valuen] = strToInt(calcComp[i]); break; case OPT_SYMBOL: p = findSymbol(pinfo.pc, calcComp[i]); if(p == 0) { cprintf("Cannot find symbol: %s\n", calcComp[i]); calcErrFlag = -1; return -1; } uint32_t vaddr = p->vaddr; int type = 0; if(p->type != N_GSYM) type = 1; subArgv[0] = vaddr; subArgv[1] = buf; subArgv[2] = type; subArgv[3] = 0; int result = doSysDebug(DEBUG_PRINT, subArgv); if(result < 0) { cprintf("%s", subArgv[1]); calcErrFlag = -1; return -1; } calcValue[++valuen] = strToInt(subArgv[1]); break; } } while(stackn) { //printCalcStack(); doCalc(); } cprintf("%d\n", calcValue[1]); return calcValue[1]; }
main(int argc, char *argv[]) { int listenFd, connFd; struct sockaddr_in servAddr, cliAddr; int len; int resultLen; int n; /* a simple command line argument processing */ if (argc != 1) err_quit("Usage: %s"); /* open a socket */ if ((listenFd = socket(AF_INET, SOCK_STREAM, 0)) < 0) err_sys("socket error"); /* setup the server address and bind it */ bzero(&servAddr, sizeof(servAddr)); servAddr.sin_family = AF_INET; servAddr.sin_addr.s_addr = htonl(INADDR_ANY); servAddr.sin_port = htons(NETCALC_SERV_PORT); if (bind(listenFd, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0) err_sys("bind error"); if (listen(listenFd, 16) < 0) /* use a small queue limit */ err_sys("listen error"); /* loop forever */ for (;;) { len = sizeof(cliAddr); /* wait for the connection */ if ((connFd = accept(listenFd, (struct sockaddr *) &cliAddr, &len)) < 0) err_sys("accept error"); /* read input here */ while ((n = read(connFd, reqBuf, BUF_SIZE)) > 0) { DUMP_BUF(reqBuf, n); /* for debugging purpose */ if (doCalc(reqBuf, n, resBuf, &resultLen) == SUCCESS) { if (write(connFd, resBuf, resultLen) < 0) err_sys("write error"); } else { printf("!!%s: doCalc failed\n", __FUNCTION__); DUMP_BUF(reqBuf, n); } } close(connFd); } close(listenFd); }
bool Calculator::tokenizer() { try { std::stack<std::string> workspace; //作業用スタック for (auto& it : tokens) { if (!std::regex_match(it, sym_ptn)) { //トークンが数値のとき this->re_porand.push_back(it); continue; } else if (it == ")") { //)括弧のとき while (!workspace.empty() && workspace.top() != "(") { this->re_porand.push_back(workspace.top()); workspace.pop(); } if (workspace.empty()) { std::cout << "左右括弧の数が合いません" << std::endl; return false; } else { workspace.pop(); continue; } } else if (it == "(") { //(括弧のとき workspace.push(it); continue; } else { while (!workspace.empty()) { //スタックが空でないとき if (getPriority(it) <= getPriority(workspace.top())) { this->re_porand.push_back(workspace.top()); workspace.pop(); continue; } else { break; } } //スタックが空のとき workspace.push(it); continue; } } while (!workspace.empty()) { //スタックの中身をバッファに流す this->re_porand.push_back(workspace.top()); workspace.pop(); } //トークンの描写(テスト時) // UTI::printVec(this->tokens); // std::cout << std::endl; // UTI::printVec(this->re_porand); //計算処理 for (unsigned int idx = 0; idx < this->re_porand.size(); ++idx) { doCalc(re_porand.at(idx), idx); } pre_ans = answer; answer = std::stold(re_porand.at(0)); std::cout << "Ans = " << answer << std::endl; } catch (std::invalid_argument& e) { std::cout << "std::invalid_argument" << std::endl; return false; } catch (std::out_of_range& e){ std::cout << "std::out_of_range" << std::endl; return false; } return true; }
//摇头测试结束,开始计算结果 void YawAnalyser::finish(){ this->progressTimer->stop(); this->updateSliderTimer->stop(); QObject::disconnect(webcamCapture,SIGNAL(newImageCaptured(cv::Mat)),this,SLOT(receiveNewFrame(cv::Mat))); //解绑接收摄像头事件 QObject::disconnect(this,SIGNAL(doCalcOpticalFlow(cv::Mat)),this->opticalFlowCalculater,SLOT(doCalc(cv::Mat))); //解绑光流计算事件 QObject::disconnect(opticalFlowCalculater,SIGNAL(calcCompete(bool,cv::Mat)),this,SLOT(receiveNewOpticalFlow(bool,cv::Mat))); //解绑接受光流事件 //cv::destroyAllWindows(); std::cout << "YawAnalyser Time out!"<<std::endl; ///////////////////// std::cout << "捕获到光流总帧数:" <<this->leftBackgroundNormalVector.size() <<std::endl; std::cout << "左模" << Utils::calculatePearsonCorrelation(this->faceNormalVector,this->leftBackgroundNormalVector) <<std::endl; std::cout << "右模"<< Utils::calculatePearsonCorrelation(this->faceNormalVector,this->rightBackgroundNormalVector) <<std::endl; std::cout << "左相位"<< Utils::calculatePearsonCorrelation(this->facePhaseVector,this->leftBackgroundPhaseVector) <<std::endl; std::cout << "右相位"<< Utils::calculatePearsonCorrelation(this->facePhaseVector,this->rightBackgroundPhaseVector) <<std::endl; emit this->done(true); }
//构造函数 YawAnalyser::YawAnalyser():totalProgressTimeMS(5000),isCurrentAlignmentValid(false),isOpticalFlowCalculaterBusy(false),sliderPhase(0),isProgressTimeout(false) { this->webcamCapture = WebcamCapture::getInstance(); this->faceDetector = new FaceDetector(); //faceDetector对象 faceAligner = FaceAligner::getInstance(); QObject::connect(this,SIGNAL(doAlignment(cv::Mat,BoundingBox)),faceAligner,SLOT(doAlignment(cv::Mat,BoundingBox))); QObject::connect(faceAligner,SIGNAL(alignmentCompete(cv::Mat_<double>)),this,SLOT(receiveNewAlignment(cv::Mat_<double>))); this->opticalFlowCalculater = OpticalFlowCalculater::getInstance(); QObject::connect(this,SIGNAL(doCalcOpticalFlow(cv::Mat)),this->opticalFlowCalculater,SLOT(doCalc(cv::Mat))); QObject::connect(opticalFlowCalculater,SIGNAL(calcCompete(bool,cv::Mat)),this,SLOT(receiveNewOpticalFlow(bool,cv::Mat))); this->norm = cv::Mat(600,800, CV_32FC1);//声明光流模的矩阵 this->phaseAngle = cv::Mat(600,800, CV_32FC1); this->zoneMap = cv::Mat(600,800,CV_8UC1); }