FaToDFA::FaToDFA(modes _mode, AlgorithmWidget* _algorithm_widget, FA_widget* _not_dfa_widget, FA_widget* _dfa_widget, QLabel* _var_widget, QObject* parrent) : Algorithm(parrent), mode(_mode), algorithm_widget(_algorithm_widget), not_dfa_widget(_not_dfa_widget), dfa_widget(_dfa_widget), var_widget(_var_widget) { actInstruction = HEADER; prewInstruction = HEADER; instruction_count = WHILE_NEW+1; initInstructions(); initBreakpoints(instruction_count); this->setColumnCount(1); this->setRowCount(instructions.count()); var_widget->setText(""); for(int i = 0; i < instructions.count();i++) { QModelIndex index = this->index(i,0,QModelIndex()); setData(index,instructions[i],Qt::EditRole); setData(index,true,Algorithm::HasBreakpoint_Role); setData(index,false,Algorithm::Breakpoint_Role); switch(i) { case HEADER: setData(index,false,Algorithm::HasBreakpoint_Role); break; } } // // Connect algorithm buttons. // connect(this->algorithm_widget,SIGNAL(playPressed(int)),this,SLOT(runAlgorithm(int))); connect(this->algorithm_widget,SIGNAL(stopPressed()),this,SLOT(stop())); connect(this->algorithm_widget,SIGNAL(prewPressed()),this,SLOT(prevStep())); connect(this->algorithm_widget,SIGNAL(nextPressed()),this,SLOT(nextStep())); connect(this->algorithm_widget, SIGNAL(checkSolutionPressed()), this, SLOT(checkSolution())); connect(this->algorithm_widget, SIGNAL(showCorrectSolutionPressed()), this, SLOT(showCorrectSolution())); connect(this->algorithm_widget, SIGNAL(showUserSolutionPressed()), this, SLOT(showUserSolution())); connect(this->algorithm_widget, SIGNAL(beginPressed()), this, SLOT(toBegin())); connect(this->algorithm_widget, SIGNAL(endPressed()), this, SLOT(toEnd())); // // Connect timers. // connect(play_timer, SIGNAL(timeout()), this, SLOT(nextStep())); connect(check_step_timer, SIGNAL(timeout()), this, SLOT(checkSolution())); // Connect Finite Automata widgets connect(not_dfa_widget,SIGNAL(FA_changed(FiniteAutomata*)),this,SLOT(setFA(FiniteAutomata*))); connect(dfa_widget,SIGNAL(FA_changed(FiniteAutomata*)),this,SLOT(setDFA(FiniteAutomata*))); not_dfa_widget->setFA(new FiniteAutomata()); algorithm_widget->enableShowButton(); }
CAlgorithmWidget::CAlgorithmWidget(QWidget *parent) : QWidget(parent), m_mode(AlgorithmModes::NONE), ui(new Ui::AlgorithmWidget) { ui->setupUi(this); showSolution = true; connect(this->ui->nextButton,SIGNAL(clicked()),this,SIGNAL(nextPressed())); connect(this->ui->prewButton,SIGNAL(clicked()),this,SIGNAL(prewPressed())); connect(this->ui->playButton,SIGNAL(clicked()),this,SLOT(emitPlay())); connect(this->ui->stopButton,SIGNAL(clicked()),this,SIGNAL(stopPressed())); connect(this->ui->checkButton,SIGNAL(clicked()),this,SIGNAL(checkSolutionPressed())); connect(this->ui->beginButton,SIGNAL(clicked()), this, SIGNAL(beginPressed())); connect(this->ui->endButton,SIGNAL(clicked()),this, SIGNAL(endPressed())); SetMode(m_mode); ui->Formal->removeTab(1); }