Esempio n. 1
0
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();
}
Esempio n. 2
0
void ChaserRunner::switchFunctions(MasterTimer* timer)
{
    if (m_currentFunction != NULL)
    {
        m_currentFunction->stop();
        /** @todo this is a dirty hack to re-use the same scene for all the steps */

        if (m_chaser->isSequence())
            m_currentFunction->postRun(timer, NULL);

    }

    ChaserStep step(m_chaser->steps().at(m_currentStep));
    m_currentFunction = m_doc->function(step.fid);
    qDebug() << Q_FUNC_INFO << "Step #" << m_currentStep << ", function ID: " << step.fid;
    if (m_currentFunction != NULL && m_currentFunction->stopped() == true)
    {
        if (m_chaser->isSequence())
        {
            Scene *s = qobject_cast<Scene*>(m_currentFunction);
            qDebug() << Q_FUNC_INFO << "Current step #" << m_currentStep << " has values: " << step.values.count();
            if (m_currentStep == 0)
            {
                for (int i = 0; i < step.values.count(); i++)
                    s->setValue(step.values.at(i));
            }
            else
            {
                ChaserStep prevStep(m_chaser->steps().at(m_currentStep - 1));
                qDebug() << Q_FUNC_INFO << "Previous step has values: " << prevStep.values.count();
                for (int i = 0; i < step.values.count(); i++)
                {
                    SceneValue stepValue = step.values.at(i);
                    SceneValue prevStepValue = prevStep.values.at(i);
                    if (stepValue == prevStepValue && stepValue.value != prevStepValue.value)
                        s->setValue(stepValue);
                }
            }
        }

        // Set intensity before starting the function. Otherwise the intensity
        // might momentarily jump too high.
        m_currentFunction->adjustIntensity(m_intensity);

        // Start function using step-specific or global speed settings
        // Don't override duration because that would mess up everything when
        // a chaser/cuelist starts another chaser. Overriding the duration with
        // the current chaser's duration would mean that only the first step is
        // run from the sub-chaser. If the subfunction is an RGBMatrix or EFX,
        // the step duration probably isb not the wanted subfunction speed, either
        m_currentFunction->start(timer, true, currentFadeIn(), currentFadeOut());
    }

    m_roundTime->restart();
}
Esempio n. 3
0
MainWindow::MainWindow(QWidget *parent){
    nulls = 0;
    addMode = false;
    QLabel* lbl1 = new QLabel("Map Colors");
    QLabel* lbl2 = new QLabel("Object Colors");
    spinBox1 = new QSpinBox;
    spinBox2 = new QSpinBox;
    spinBox3 = new QSpinBox;
    spinBox4 = new QSpinBox;
    spinBox5 = new QSpinBox;
    spinBox6 = new QSpinBox;
    spinBox1->setMaximum(10); spinBox1->setMinimum(0); spinBox1->setValue(0);
    spinBox2->setMaximum(10); spinBox2->setMinimum(0);spinBox2->setValue(3);
    spinBox3->setMaximum(10); spinBox3->setMinimum(0);spinBox3->setValue(10);
    spinBox4->setMaximum(10); spinBox4->setMinimum(0);spinBox4->setValue(0);
    spinBox5->setMaximum(10); spinBox5->setMinimum(0);spinBox5->setValue(8);
    spinBox6->setMaximum(10); spinBox6->setMinimum(0);spinBox6->setValue(8);

    scene = new Scene;

    QHBoxLayout* layout1 = new QHBoxLayout;
    QVBoxLayout* layout2 = new QVBoxLayout;
    QHBoxLayout* layout3 = new QHBoxLayout;
    QVBoxLayout* layout4 = new QVBoxLayout;
    QHBoxLayout* layout5 = new QHBoxLayout;
    QHBoxLayout* layout6 = new QHBoxLayout;

    pbtn1 = new QPushButton("Start"); pbtn1->setFixedSize(40,25);
    pbtn2 = new QPushButton("Prev");  pbtn2->setFixedSize(40,25);
    pbtn3 = new QPushButton("Next");  pbtn3->setFixedSize(40,25);
    pbtn4 = new QPushButton("Stop");  pbtn4->setFixedSize(40,25); pbtn4->setEnabled(false);
    pbtn6 = new QPushButton("Map+");pbtn6->setFixedSize(40,25);
    pbtn7 = new QPushButton("Map-");pbtn7->setFixedSize(40,25);
    pbtn8 = new QPushButton("+");    pbtn8->setFixedSize(40,25);
    pbtn9 = new QPushButton("-");    pbtn9->setFixedSize(40,25);
    pbtn11 = new QPushButton("Set");    pbtn11->setFixedSize(40,25);
    pbtn12 = new QPushButton("View");    pbtn12->setFixedSize(40,25); pbtn12->setEnabled(false);
    pbtn10 = new QPushButton("Clear");  pbtn10->setFixedSize(40,25);

    layout3->addWidget(pbtn1);
    layout3->addWidget(pbtn2);
    layout3->addWidget(pbtn3);
    layout3->addWidget(pbtn4);
    layout3->addWidget(pbtn6);
    layout3->addWidget(pbtn7);
    layout3->addWidget(pbtn9);
    layout3->addWidget(pbtn8);
    layout3->addWidget(pbtn11);
    layout3->addWidget(pbtn12);
    layout3->addWidget(pbtn10);
    layout3->addStretch();
    layout5->addWidget(lbl1);
    layout5->addWidget(spinBox1);
    layout5->addWidget(spinBox2);
    layout5->addWidget(spinBox3);
    layout6->addWidget(lbl2);
    layout6->addWidget(spinBox4);
    layout6->addWidget(spinBox5);
    layout6->addWidget(spinBox6);
    layout4->addLayout(layout5);
    layout4->addLayout(layout6);
    layout2->addWidget(scene);
    layout2->addLayout(layout3);
    layout1->addLayout(layout2);
    layout1->addLayout(layout4);

    setLayout(layout1);

    connect(pbtn1,SIGNAL(clicked()),this,SLOT(startGame()));
    connect(pbtn3,SIGNAL(clicked()),this,SLOT(nextStep()));
    connect(pbtn4,SIGNAL(clicked()),this,SLOT(stopGame()));
    connect(pbtn6,SIGNAL(clicked()),this,SLOT(mapPlus()));
    connect(pbtn7,SIGNAL(clicked()),this,SLOT(mapMinus()));
    connect(pbtn8,SIGNAL(clicked()),this,SLOT(increaseSize()));
    connect(pbtn9,SIGNAL(clicked()),this,SLOT(reduceSize()));
    connect(pbtn10,SIGNAL(clicked()),this,SLOT(clearMap()));
    connect(pbtn11,SIGNAL(clicked()),this,SLOT(setTrueAddMode()));
    connect(pbtn12,SIGNAL(clicked()),this,SLOT(setFalseAddMode()));
    connect(pbtn2, SIGNAL(clicked()),this, SLOT(prevStep()));

    QTimer *timer = new QTimer(this);
    timer->setInterval(42);
    connect(timer, SIGNAL(timeout()), this, SLOT(view()));
    timer->start();
}
Esempio n. 4
0
LDViewMainWindow::LDViewMainWindow(QApplication *a)
	:QMainWindow(),Ui::LDView(),
	fileSeparatorIndex(-1),
	toolbarMaxStep(new QLabel),
	toolbarCurrentStep(new QLabel),
	toolbarStepLabel(new QLabel("Step :")),
	toolbarViewAngle(NULL),
	toolbarWireframeMenu(new QMenu(this)),
	edgeMenu(new QMenu(this)),
	bfcMenu(new QMenu(this)),
	primitiveMenu(new QMenu(this))
{
    setupUi(this);
	toolbar->insertWidget(toolbarFirstStep,toolbarStepLabel);
	toolbar->insertWidget(toolbarFirstStep,toolbarCurrentStep);
	toolbar->insertWidget(toolbarFirstStep,toolbarMaxStep);
    if (modelViewer) modelViewer->setMainWindow(this);
    connect( fileOpenAction, SIGNAL( triggered() ), this, SLOT( fileOpen() ) );
    connect( fileSaveSettingsAction, SIGNAL( triggered() ), this, SLOT( fileSaveSettings() ) );
    connect( fileExportAction, SIGNAL( triggered() ), this, SLOT( fileExport() ) );
    connect( fileExportOptionAction, SIGNAL( triggered() ), this, SLOT( fileExportOption() ) );
	connect( file3DSExportOptionAction, SIGNAL( triggered() ), this, SLOT( file3DSExportOption() ) );
    connect( fileJPEGOptionsAction, SIGNAL( triggered() ), this, SLOT( fileJPEGOptions() ) );
    connect( fileSaveAction, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
    connect( filePrintAction, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
    connect( fileExitAction, SIGNAL( triggered() ), this, SLOT( fileExit() ) );
    connect( helpContentsAction, SIGNAL( triggered() ), this, SLOT( helpContents() ) );
    connect( helpAboutAction, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
    connect( helpAboutQtAction, SIGNAL( triggered() ), this, SLOT( helpAboutQt() ) );
    connect( editPreferencesAction, SIGNAL( triggered() ), this, SLOT( editPreferences() ) );
    connect( viewToolBarAction, SIGNAL( toggled(bool) ), this, SLOT( viewToolBar(bool) ) );
    connect( toolbarWireframeAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarWireframe(bool) ) );
    connect( toolbarEdgeAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarEdge(bool) ) );
    connect( toolbarPrimitiveSubstitutionAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarPrimitiveSubstitution(bool) ) );
    connect( toolbarLightingAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarLighting(bool) ) );
    connect( toolbarBFCAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarBFC(bool) ) );
    connect( toolbarAxesAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarAxes(bool) ) );
    connect( toolbarSeamsAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarSeams(bool) ) );
    connect( viewStatusBarAction, SIGNAL( toggled(bool) ), this, SLOT( viewStatusBar(bool) ) );
    connect( viewLatitudeRotationAction, SIGNAL( toggled(bool) ), this, SLOT( latitudeRotation(bool) ) );
    connect( viewKeepRightSideUpAction, SIGNAL( toggled(bool) ), this, SLOT( keepRightSideUp(bool) ) );
    connect( viewFullScreenAction, SIGNAL( triggered() ), this, SLOT( viewFullScreen() ) );
    connect( viewResetViewAction, SIGNAL( triggered() ), this, SLOT( viewResetView() ) );
    connect( helpOpenGLDriverInfoAction, SIGNAL( triggered() ), this, SLOT( helpOpenGLDriverInfo() ) );
    connect( fileLDrawDirAction, SIGNAL( triggered() ), this, SLOT( fileLDrawDir() ) );
    connect( fileExtraDirAction, SIGNAL( triggered() ), this, SLOT( fileExtraDir() ) );
    connect( fileCheckForUpdatesAction, SIGNAL( triggered() ), this, SLOT( fileCheckForUpdates() ) );
    connect( fileReloadAction, SIGNAL( triggered() ), this, SLOT( fileReload() ) );
    connect( viewShowErrorsAction, SIGNAL( triggered() ), this, SLOT( viewShowErrors() ) );
    connect( pollActionGroup, SIGNAL( triggered(QAction*) ), this, SLOT( pollChanged(QAction*) ) );
    connect( viewZoomToFitAction, SIGNAL( triggered() ), this, SLOT( viewZoomToFit() ) );
	connect( viewRightSideUpAction, SIGNAL( triggered() ), this, SLOT( viewRightSideUp() ) );
    connect( viewModeActionGroup, SIGNAL( triggered(QAction*) ), this, SLOT( viewModeChanged(QAction*) ) );
    connect( frontViewAngleAction, SIGNAL( triggered() ), this, SLOT( frontViewAngle() ) );
    connect( backViewAngleAction, SIGNAL( triggered() ), this, SLOT( backViewAngle() ) );
    connect( leftViewAngleAction, SIGNAL( triggered() ), this, SLOT( leftViewAngle() ) );
    connect( rightViewAngleAction, SIGNAL( triggered() ), this, SLOT( rightViewAngle() ) );
    connect( topViewAngleAction, SIGNAL( triggered() ), this, SLOT( topViewAngle() ) );
    connect( bottomViewAngleAction, SIGNAL( triggered() ), this, SLOT( bottomViewAngle() ) );
    connect( latLongViewAngleAction, SIGNAL( triggered() ), this, SLOT( latLongViewAngle() ) );
    connect( isoViewAngleAction, SIGNAL( triggered() ), this, SLOT( isoViewAngle() ) );
    connect( saveDefaultViewAngleAction, SIGNAL( triggered() ), this, SLOT( saveDefaultViewAngle() ) );
    connect( fileCancelLoadAction, SIGNAL( triggered() ), this, SLOT( fileCancelLoad() ) );
    connect( showViewInfoAction, SIGNAL( triggered() ), this, SLOT( showViewInfo() ) );
    connect( showPovCameraAction, SIGNAL( triggered() ), this, SLOT( showPovCamera() ) );
    connect( showPovAspectRatioAction, SIGNAL( toggled(bool) ), this, SLOT( showPovAspectRatio(bool) ) );
    connect( toolsPartListAction, SIGNAL( triggered() ), this, SLOT( toolsPartList() ) );
    connect( toolbarPrevStep, SIGNAL( triggered() ), this, SLOT( prevStep() ) );
    connect( toolbarNextStep, SIGNAL( triggered() ), this, SLOT( nextStep() ) );
    connect( toolbarFirstStep, SIGNAL( triggered() ), this, SLOT( firstStep() ) );
    connect( toolbarLastStep, SIGNAL( triggered() ), this, SLOT( lastStep() ) );
    connect( stepGoto, SIGNAL( triggered() ), this, SLOT( gotoStep() ) );
    connect( toolsModelTreeAction, SIGNAL( triggered() ), this, SLOT( toolsModelTree() ) );
    connect( toolsBoundingBoxAction, SIGNAL( triggered() ), this, SLOT( toolsBoundingBox() ) );
    connect( toolsMpdModelSelectionAction, SIGNAL( triggered() ), this, SLOT( toolsMpdModelSelection() ) );

    connect(fileMenu, SIGNAL(aboutToShow()), this, SLOT(doFileMenuAboutToShow()));
    connect(editMenu, SIGNAL(aboutToShow()), this, SLOT(doEditMenuAboutToShow()));
    connect(viewMenu, SIGNAL(aboutToShow()), this, SLOT(doViewMenuAboutToShow()));
    connect(toolsMenu,SIGNAL(aboutToShow()), this, SLOT(doToolsMenuAboutToShow()));
    connect(helpMenu, SIGNAL(aboutToShow()), this, SLOT(doHelpMenuAboutToShow()));

	int cnt,i;
	QAction *item;
    for ( cnt = i = 0; ; i++)
    {
        item = fileMenu->actions()[i];
        if (item->isSeparator())
        {
            if (++cnt == 2)
                break;
        }
    }
    fileSeparatorIndex = i;
#ifdef __APPLE__
    fileMenu->removeItemAt(fileSeparatorIndex);
    fileSeparatorIndex = -1;
    openRecentMenu = new QMenu(this, "openRecentMenu");
    fileMenu->insertItem("Open Recent", openRecentMenu, -1, 1);
#endif // __APPLE__
    if (!recentFiles)
    {
        recentFiles = new TCStringArray(10);
        populateRecentFiles();
    }
    populateRecentFileMenuItems();
	setupStandardSizes();
#ifdef __APPLE__
        // Since Preferences is the only item in the edit menu, we need to
        // delete the edit menu on the Mac, since the item is going to get
        // magically moved to the LDView menu.  The problem is, if we delete
        // the edit menu, the magic stops working, since it's apparently all
        // done on the fly.  So, we're going to create a new fully-functional
        // Preferences menu item at the top of the File menu, and THEN delete
        // the edit menu.  This newly created menu item won't be visible to the
        // user, but it will make the other one continue to function after the
        // deletion of the edit menu.
        fileMenu->insertItem("Preferences", this, SLOT(doPreferences()),
            0, -1, 0);
        // Remove the (empty without Preferences) edit menu.
        menuBar->removeItem(menuBar->idAt(1));
#endif //__APPLE__
	toolbarViewAngle = new QToolButton(toolbar);
	toolbarViewAngle->setMenu(viewingAnglePopupMenu);
	toolbarViewAngle->setPopupMode(QToolButton::InstantPopup);
	toolbarViewAngle->setIcon(QPixmap( ":/images/images/toolbar_view.png"));
	toolbarViewAngle->setEnabled(false);
	toolbar->insertWidget(editPreferencesAction,toolbarViewAngle);
	connect( wireframeFogAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarWireframeFog(bool) ) );
	connect( wireframeRemoveHiddenLinesAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarWireframeRemoveHiddenLines(bool) ) );
	toolbarWireframeMenu->addAction(wireframeFogAction);
	toolbarWireframeMenu->addAction(wireframeRemoveHiddenLinesAction);
	QToolButton *toolbarWireframe =
		(QToolButton *)toolbar->widgetForAction(toolbarWireframeAction);	
	if (toolbarWireframe != NULL)
	{
		toolbarWireframe->setMenu(toolbarWireframeMenu);
		toolbarWireframe->setPopupMode(QToolButton::MenuButtonPopup);
	}
	connect( textureStudAction, SIGNAL( toggled(bool) ), this, SLOT( textureStud(bool) ) );
	primitiveMenu->addAction(textureStudAction);
	QToolButton *toolbarPrimitives =
		(QToolButton *)toolbar->widgetForAction(toolbarPrimitiveSubstitutionAction);
	if (toolbarPrimitives)
	{
		toolbarPrimitives->setMenu(primitiveMenu);
		toolbarPrimitives->setPopupMode(QToolButton::MenuButtonPopup);
	}
	connect( edgeShowEdgeOnlyAction, SIGNAL( toggled(bool) ), this, SLOT( edgeShowEdgeOnly(bool) ) );
	connect( edgeConditionalLineAction, SIGNAL( toggled(bool) ), this, SLOT( edgeConditionalLine(bool) ) );
	connect( edgeHighQualityAction, SIGNAL( toggled(bool) ), this, SLOT( edgeHighQuality(bool) ) );
	connect( edgeAlwaysBlackAction, SIGNAL( toggled(bool) ), this, SLOT( edgeAlwaysBlack(bool) ) );
	edgeMenu->addAction(edgeShowEdgeOnlyAction);
	edgeMenu->addAction(edgeConditionalLineAction);
	edgeMenu->addAction(edgeHighQualityAction);
	edgeMenu->addAction(edgeAlwaysBlackAction);
	QToolButton *toolbarEdge =
		(QToolButton *)toolbar->widgetForAction(toolbarEdgeAction);
	if (toolbarEdge)
	{
		toolbarEdge->setMenu(edgeMenu);
		toolbarEdge->setPopupMode(QToolButton::MenuButtonPopup);
	}
	connect( bfcRedBackFacesAction, SIGNAL( toggled(bool) ), this, SLOT( bfcRedBackFaces(bool) ) );
	connect( bfcGreenFrontFacesAction, SIGNAL( toggled(bool) ), this, SLOT( bfcGreenFrontFaces(bool) ) );
	connect( bfcBlueNeutralFacesAction, SIGNAL( toggled(bool) ), this, SLOT( bfcBlueNeutralFaces(bool) ) );
	bfcMenu->addAction(bfcRedBackFacesAction);
	bfcMenu->addAction(bfcGreenFrontFacesAction);
	bfcMenu->addAction(bfcBlueNeutralFacesAction);
	QToolButton *toolbarBfc =
		(QToolButton *)toolbar->widgetForAction(toolbarBFCAction);
	if (toolbarBfc)
	{
		toolbarBfc->setMenu(bfcMenu);
		toolbarBfc->setPopupMode(QToolButton::MenuButtonPopup);
	}
    modelViewer->setApplication(a);
}