Exemplo n.º 1
0
 bool equalTo( const Formula & f) const
 {
   return f->getType() == this->getType() &&
     _op1->equalTo(((BinaryConjective *)f.get())->getOperand1())
     &&
     _op2->equalTo(((BinaryConjective *)f.get())->getOperand2());
 }
Exemplo n.º 2
0
void MainWindow::impIClicked()
{

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

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

    Formula f = selected->getFormula();
    Formula op1 = ((Imp*)f.get())->getOperand1();
    Formula op2 = ((Imp*)f.get())->getOperand2();


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

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

    QVector<Formula> assumptions = selected->getAssumptions();
    assumptions.push_back(op1);
    Node* item = new Node( op2, rect_width, rect_height, rect_x, rect_y, selected_list.at(0), assumptions);
    scene->addNode(item);

}
Exemplo n.º 3
0
  bool equalTo(const Formula & f) const
  {
    if(f->getType() != T_ATOM)
      return false;

    if(_p != ((Atom *) f.get())->getSymbol())
      return false;

    const vector<Term> & f_ops = ((Atom *) f.get())->getOperands();

    if(_ops.size() != f_ops.size())
      return false;

    for(unsigned i = 0; i < _ops.size(); i++)
      if(!_ops[i]->equalTo(f_ops[i]))
        return false;

      return true;
  }
Exemplo n.º 4
0
 bool equalTo(const Formula & f) const
 {
   return f->getType() == getType() &&
     ((Quantifier *) f.get())->getVariable() == _v &&
     ((Quantifier *) f.get())->getOperand()->equalTo(_op);
 }
Exemplo n.º 5
0
 bool equalTo(const Formula & f) const
 {
   return f->getType() == this->getType() &&
     _op->equalTo(((UnaryConjective *)f.get())->getOperand());
 }
Exemplo n.º 6
0
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);



}