当前位置: 首页>>代码示例>>C++>>正文


C++ Formula::printFormula方法代码示例

本文整理汇总了C++中Formula::printFormula方法的典型用法代码示例。如果您正苦于以下问题:C++ Formula::printFormula方法的具体用法?C++ Formula::printFormula怎么用?C++ Formula::printFormula使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Formula的用法示例。


在下文中一共展示了Formula::printFormula方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: notEClicked

void MainWindow::notEClicked()
{

    QList<QGraphicsItem *> selected_list = scene->selectedItems();
    Node* selected = (Node*)(selected_list.at(0));

    selected->setRule("notE");
    selected->update();

    bool ok;
    QString tekst = QInputDialog::getText(this, tr("QInputDialog::getText()"),
                                             tr("Unesite formulu:"), QLineEdit::Normal,
                                             "", &ok);
    if (ok && !tekst.isEmpty()){
            qDebug() << "radi";
    }


    std::string formula = tekst.toUtf8().constData();
    formula += " ;";
    std::ostringstream stream;
    qDebug() << QString::fromStdString(formula);
    YY_BUFFER_STATE buffer = yy_scan_string(formula.c_str());

            if(yyparse() == 1){
        qDebug() << "Pa to ti ne radi";
    }


    std::ostringstream stream1;
    parsed_formula->printFormula(stream1);
    qreal rect_width =  stream1.str().length()*PARAMETER;
    qreal rect_height = 20;

    int rect_x = selected->getx() -20  - depth/2;
    int rect_y = selected->gety() - 20 - depth/2;
    QVector<Formula> assumptions = selected->getAssumptions();
    Node* item1 = new Node( parsed_formula, rect_width, rect_height, rect_x, rect_y, selected_list.at(0), assumptions);
    scene->addNode(item1);

    Formula f2 = Formula(new Not(parsed_formula));

    rect_x = selected->getx() + 25  + depth/2;
    rect_y = selected->gety() - 20 - depth/2;
    f2->printFormula(stream1);
    rect_width = stream1.str().length()*PARAMETER;
    Node* item2 = new Node( f2, rect_width, rect_height, rect_x, rect_y, selected_list.at(0), assumptions);
    scene->addNode(item2);

}
开发者ID:Shoocky,项目名称:Interaktivni-dokazivac,代码行数:50,代码来源:mainwindow.cpp

示例2: orEClicked

void MainWindow::orEClicked()
{

    QList<QGraphicsItem *> selected_list = scene->selectedItems();
    Node* selected = (Node*)(selected_list.at(0));
    selected->setRule("orE");
    selected->update();
    int rect_x;
    int rect_y;

    bool ok;
    while(1){
             QString tekst = QInputDialog::getText(this, tr("QInputDialog::getText()"),
                                             tr("Unesite formulu:"), QLineEdit::Normal,
                                             QDir::home().dirName(), &ok);
             if (ok && !tekst.isEmpty()){
                qDebug() << "radi";
             }


            std::string formula = tekst.toUtf8().constData();
            formula += " ;";
            std::ostringstream stream;
            qDebug() << QString::fromStdString(formula);
            YY_BUFFER_STATE buffer = yy_scan_string(formula.c_str());

            if(yyparse() == 1){
                qDebug() << "Pa to ti ne radi";
             }

            if(parsed_formula->getType() == BaseFormula::T_OR){
                break;
            }
    }

    std::ostringstream stream;
    parsed_formula->printFormula(stream);
    qreal rect_width =  stream.str().length()*PARAMETER;
    qreal rect_height = 20;

    rect_x = selected->getx() - 20 - depth/2;
    rect_y = selected->gety() - 20 - depth/2;

    QVector<Formula> assumptions = selected->getAssumptions();
    assumptions.push_back(parsed_formula);

    Node* item3 = new Node( parsed_formula, rect_width, rect_height, rect_x, rect_y, selected_list.at(0), assumptions);
    scene->addNode(item3);

    Formula op1 = ((Or*)parsed_formula.get())->getOperand1();
    Formula op2 = ((Or*)parsed_formula.get())->getOperand2();

    rect_x = selected->getx() + 25 + depth/2;
    rect_y = selected->gety() - 20 - depth/2;


    assumptions.push_back(op1);
    assumptions.push_back(op2);
    op1->printFormula(stream);
    rect_width = stream.str().length()*PARAMETER;
    Node* item1 = new Node( selected->getFormula(), rect_width, rect_height, rect_x, rect_y, selected_list.at(0), assumptions);
    scene->addNode(item1);

    rect_x = selected->getx() + 50 + depth/2;
    rect_y = selected->gety() - 20 - depth/2;

    op2->printFormula(stream);
    rect_width = stream.str().length()*PARAMETER;
    Node* item2 = new Node(selected->getFormula(), rect_width, rect_height, rect_x, rect_y, selected_list.at(0), assumptions);
    scene->addNode(item2);



}
开发者ID:Shoocky,项目名称:Interaktivni-dokazivac,代码行数:74,代码来源:mainwindow.cpp


注:本文中的Formula::printFormula方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。