Пример #1
0
void NGLScene::keyPressEvent(QKeyEvent *_event)
{
  // this method is called every time the main window recives a key event.
  // we then switch on the key value and set the camera in the GLWindow
  switch (_event->key())
  {
  // escape key to quite
  case Qt::Key_Escape : QGuiApplication::exit(EXIT_SUCCESS); break;
  // show full screen
  case Qt::Key_F : showFullScreen(); break;
  // show windowed
  case Qt::Key_N : showNormal(); break;
  case Qt::Key_Q : changeWeight(Weights::POSE1,Direction::DOWN); break;
  case Qt::Key_W : changeWeight(Weights::POSE1,Direction::UP); break;

  case Qt::Key_A : changeWeight(Weights::POSE2,Direction::DOWN); break;
  case Qt::Key_S : changeWeight(Weights::POSE2,Direction::UP); break;
  case Qt::Key_Space : toggleAnimation(); break;
  case Qt::Key_Z : punchLeft(); break;
  case Qt::Key_X : punchRight(); break;

  default : break;
  }
  // finally update the GLWindow and re-draw
    update();
}
Пример #2
0
unsigned int
One::runWeighted()
{    
    trace_msg( weakconstraints, 1, "Starting algorithm ONE" );
    
    preprocessingWeights();
    changeWeight();
    computeAssumptionsStratified();        
    
    initInUnsatCore();

    solver.setComputeUnsatCores( true );
    solver.turnOffSimplifications();

    while( true )
    {
        if( solver.solve( assumptions ) != INCOHERENT )
        {
            solver.unrollToZero();
            solver.clearConflictStatus();
            if( !changeWeight() )
                break;
        }
        else if( !foundUnsat() )
            return INCOHERENT;
        
        assumptions.clear();
        computeAssumptionsStratified();
        if( lb() == ub() )
            break;
    }

    assert_msg( lb() == ub(), lb() << " != " << ub() );    
    
    return OPTIMUM_FOUND;
}
Пример #3
0
void GraphView::executeContextMenu(const QPoint& menuPosition)
{
    QMenu menu;

    GraphNode* node = dynamic_cast<GraphNode*>(selectedItem);
    GraphEdge* edge = dynamic_cast<GraphEdge*>(selectedItem);

    if (node) {
        QAction *changeLabelAction = menu.addAction("Change label");
        QAction *deleteAction = menu.addAction("Delete vertex");
        QAction *selectedAction = menu.exec(menuPosition);

        if (selectedAction == changeLabelAction)
          changeLabel(node);
        else if (selectedAction == deleteAction)
          removeItemCommand(node);
    }
    else if (edge){
        QAction *changeWeightAction(NULL);

        if (weightedGraph)
            changeWeightAction = menu.addAction("Change weight");

        QAction *changeDirectionSDAction(NULL);
        QAction *changeDirectionDSAction(NULL);
        QAction *changeUndirectedAction(NULL);

        if (!undirectedGraph) {
            QMenu *changeDirectionMenu = new QMenu("Change direction");
            menu.addMenu(changeDirectionMenu);
            QString sourceLabel = edge->getSourceNode()->getLabel();
            if (sourceLabel.isEmpty())
                sourceLabel = "no_label";
            QString destinationLabel = edge->getDestinationNode()->getLabel();
            if (destinationLabel.isEmpty())
                destinationLabel = "no_label";

            changeDirectionSDAction = changeDirectionMenu->addAction(sourceLabel + " -> " + destinationLabel);
            changeDirectionDSAction = changeDirectionMenu->addAction(destinationLabel + " -> " + sourceLabel);
            changeUndirectedAction = changeDirectionMenu->addAction("Change to undirected");

            if (edge->isUndirected())
                changeUndirectedAction->setEnabled(false);
            else
                changeDirectionSDAction->setEnabled(false);
        }

        QAction *deleteAction = menu.addAction("Delete edge");
        QAction *selectedAction = menu.exec(menuPosition);

        if (selectedAction) {
            if (selectedAction == deleteAction)
                removeItemCommand(edge);
            else if (selectedAction == changeWeightAction)
                changeWeight(edge);
            else if (selectedAction == changeDirectionSDAction)
                undoStack->push(new ChangeEdgeDirectionCommand(edge, false, false));
            else if (selectedAction == changeDirectionDSAction)
                undoStack->push(new ChangeEdgeDirectionCommand(edge, true, false));
            else if (selectedAction == changeUndirectedAction)
                undoStack->push(new ChangeEdgeDirectionCommand(edge, false, true));
        }
    }
}