Example #1
0
/*
 * Note this is NOT thread-safe, lockSources() should be called around any calls
 * to this.
 */
void gravManager::moveToTop( std::vector<RectangleBase*>::iterator i,
                                bool checkGrouping )
{
    RectangleBase* temp = (*i);
    RectangleBase* orig = temp;

    // find highest group in the chain, to move up group members from the top
    // of the chain
    while ( checkGrouping && temp->isGrouped() )
        temp = temp->getGroup();

    // do this to properly find iterator position, since i != temp now
    if ( temp != orig )
        moveToTop( temp, checkGrouping );
    else
    {
        drawnObjects->erase( i );
        drawnObjects->push_back( temp );

        if ( temp->isGroup() )
        {
            Group* g = (Group*)temp;
            for ( int i = 0; i < g->numObjects(); i++ )
                moveToTop( (*g)[i], false );
        }
    }
}
Example #2
0
ConstraintTrees
ConstraintTree::countNormalize (const LogVarSet& Ys)
{
  assert (logVarSet_.contains (Ys));
  LogVarSet Zs = logVarSet_ - Ys;
  if (Ys.empty() || Zs.empty()) {
    return { new ConstraintTree (*this) };
  }
  moveToTop (Zs.elements());
  ConstraintTrees cts;
  unordered_map<unsigned, ConstraintTree*> countMap;
  unsigned stopLevel = getLevel (Zs.back());
  const CTChilds& childs = root_->childs();

  for (CTChilds::const_iterator chIt = childs.begin();
       chIt != childs.end(); ++ chIt) {
    const vector<pair<CTNode*, unsigned>>& res =
        countNormalize (*chIt, stopLevel);
    for (size_t j = 0; j < res.size(); j++) {
      unordered_map<unsigned, ConstraintTree*>::iterator it
          = countMap.find (res[j].second);
      if (it == countMap.end()) {
        ConstraintTree* newCt = new ConstraintTree (logVars_);
        it = countMap.insert (make_pair (res[j].second, newCt)).first;
        cts.push_back (newCt);
      }
      it->second->root_->mergeSubtree (res[j].first);
    }
  }
  return cts;
}
Example #3
0
task main()
{
	StartTask(listenToBluetooth);

	moveToTop();
	moveToOrigin();
	wait1Msec(500);

	while(true){wait10Msec(100);}
}
Example #4
0
void
ConstraintTree::join (ConstraintTree* ct, bool oneTwoOne)
{
  if (logVarSet_.empty()) {
    CTNode::deleteSubtree (root_);
    root_      = CTNode::copySubtree (ct->root());
    logVars_   = ct->logVars();
    logVarSet_ = ct->logVarSet();
    return;
  }
  if (oneTwoOne) {
    if (logVarSet_.contains (ct->logVarSet())) {
      return;
    }
    if (ct->logVarSet().contains (logVarSet_)) {
      CTNode::deleteSubtree (root_);
      root_      = CTNode::copySubtree (ct->root());
      logVars_   = ct->logVars();
      logVarSet_ = ct->logVarSet();
      return;
    }
  }
  LogVarSet intersect = logVarSet_ & ct->logVarSet_;
  if (intersect.empty()) {
    // cartesian product
    appendOnBottom (root_, ct->root()->childs());
    Util::addToVector (logVars_, ct->logVars_);
    logVarSet_ |= ct->logVarSet_;
  } else {
    moveToTop (intersect.elements());
    ct->moveToTop (intersect.elements());
    
    Tuples tuples;
    CTNodes appendNodes;
    getTuples (ct->root(), Tuples(), intersect.size(),
        tuples, appendNodes);

    CTNodes::const_iterator appendIt = appendNodes.begin();
    for (size_t i = 0; i < tuples.size(); ++ i, ++ appendIt) {
      bool tupleFounded = join (root_, tuples[i], 0, *appendIt);
      if (oneTwoOne && tupleFounded == false) {
        assert (false);
      }
    }

    LogVars newLvs (ct->logVars().begin() + intersect.size(), 
                    ct->logVars().end());
    Util::addToVector (logVars_, newLvs);
    logVarSet_ |= LogVarSet (newLvs);
  }
}
Example #5
0
ConstraintTrees
ConstraintTree::ground (LogVar X)
{
  moveToTop ({X});
  ConstraintTrees cts;
  const CTChilds& nodes = root_->childs();
  for (CTChilds::const_iterator it = nodes.begin();
       it != nodes.end(); ++ it) {
    CTNode* copy = CTNode::copySubtree (*it);
    copy->setSymbol ((*it)->symbol());
    ConstraintTree* newCt = new ConstraintTree (logVars_);
    newCt->root()->mergeSubtree (copy);
    cts.push_back (newCt);
  }
  return cts;
}
Example #6
0
/*
 * Note this is NOT thread-safe, lockSources() should be called around any calls
 * to this.
 */
void gravManager::moveToTop( RectangleBase* object, bool checkGrouping )
{
    if ( object == NULL )
    {
        gravUtil::logError( "gravManager::moveToTop: object %s is NULL\n",
                            object->getName().c_str() );
        return;
    }

    std::vector<RectangleBase*>::iterator i = drawnObjects->begin();
    while ( i != drawnObjects->end() && (*i) != object ) ++i;
    if ( i == drawnObjects->end() )
    {
        gravUtil::logError( "gravManager::moveToTop: object %s not found in "
                            "draw list\n", object->getName().c_str() );
        return;
    }
    moveToTop( i, checkGrouping );
}
Example #7
0
TinySet<unsigned>
ConstraintTree::getConditionalCounts (const LogVarSet& Ys)
{
  TinySet<unsigned> counts;
  assert (logVarSet_.contains (Ys));
  if (Ys.empty()) {
    counts.insert (1);
  } else if (Ys.size() == logVars_.size()) {
    assert (LogVarSet (logVars_) == LogVarSet (Ys));
    counts.insert (countTuples (root_));
  } else {
    LogVarSet Zs = logVarSet_ - LogVarSet (Ys);
    moveToTop (Zs.elements());
    CTNodes nodes = getNodesAtLevel (Zs.size());
    for (CTNodes::const_iterator it = nodes.begin();
         it != nodes.end(); ++ it) {
      counts.insert (countTuples (*it));
    }
  }
  return counts;
}
Example #8
0
unsigned 
ConstraintTree::getConditionalCount (const LogVarSet& Ys)
{
  assert (isCountNormalized (Ys));
  if (Ys.empty()) {
    return 1;
  }
  if (Ys.size() == logVars_.size()) {
    assert (LogVarSet (Ys) == LogVarSet (logVars_));
    return countTuples (root_);
  }
  LogVarSet Zs = logVarSet_ - Ys;
  moveToTop (Zs.elements());
  CTNode* n = root_;
  unsigned l = 0;
  while (l != Zs.size()) {
    n = *(n->childs().begin());
    l ++;
  }
  return countTuples (n);
}
Example #9
0
bool
ConstraintTree::isCartesianProduct (const LogVarSet& Xs)
{
  assert (logVarSet_.contains (Xs));
  if (Xs.size() <= 1) {
    return true;
  }
  moveToTop (Xs.elements());
  for (size_t i = 1; i < Xs.size(); i++) {
    CTNodes nodes = getNodesAtLevel (i);
    for (size_t j = 1; j < nodes.size(); j++) {
      if (nodes[j-1]->nrChilds() != nodes[ j ]->nrChilds()) {
        return false;
      }
      if (nodes[j-1]->childSymbols() != nodes[ j ]->childSymbols()) {
        return false;
      }
    }
  }
  return true;
}
Example #10
0
bool
ConstraintTree::isCountNormalized (const LogVarSet& Ys)
{
  assert (logVarSet_.contains (Ys));
  if (Ys.empty()) {
    return true;
  }
  if (Ys.size() == logVars_.size()) {
    assert (LogVarSet (logVars_) == LogVarSet (Ys));
    return true;
  }
  LogVarSet Zs = logVarSet_ - LogVarSet (Ys);
  moveToTop (Zs.elements());
  CTNodes nodes = getNodesAtLevel (Zs.size());
  unsigned count = countTuples (*nodes.begin());
  for (CTNodes::const_iterator it = nodes.begin();
       it != nodes.end(); ++ it) {
    if (countTuples (*it) != count) {
      return false;
    }
  }  
  return true;
}
ProjectBuildSetWidget::ProjectBuildSetWidget( QWidget* parent )
    : QWidget( parent ), m_view( 0 ),
     m_ui( new Ui::ProjectBuildSetWidget )
{
    m_ui->setupUi( this );
    
    m_ui->addItemButton->setIcon( KIcon( "list-add" ) );
    connect( m_ui->addItemButton, SIGNAL( clicked() ),
             this, SLOT( addItems() ) );

    m_ui->removeItemButton->setIcon( KIcon( "list-remove" ) );
    connect( m_ui->removeItemButton, SIGNAL( clicked() ),
             this, SLOT( removeItems() ) );

    m_ui->upButton->setIcon( KIcon( "go-up" ) );
    connect( m_ui->upButton, SIGNAL( clicked() ),
             SLOT( moveUp() ) );
    
    m_ui->downButton->setIcon( KIcon( "go-down" ) );
    connect( m_ui->downButton, SIGNAL( clicked() ),
             SLOT( moveDown() ) );
    
    m_ui->topButton->setIcon( KIcon( "go-top" ) );
    connect( m_ui->topButton, SIGNAL( clicked() ),
             SLOT( moveToTop() ) );
    
    m_ui->bottomButton->setIcon( KIcon( "go-bottom" ) );
    connect( m_ui->bottomButton, SIGNAL( clicked() ),
             SLOT( moveToBottom() ) );
    
    m_ui->itemView->horizontalHeader()->setStretchLastSection(true);
    m_ui->itemView->verticalHeader()->setVisible(false);
    m_ui->itemView->setContextMenuPolicy( Qt::CustomContextMenu );
    connect( m_ui->itemView, SIGNAL( customContextMenuRequested( const QPoint& ) ),
             SLOT(showContextMenu(const QPoint&) ) );
    layout()->setMargin(0);
}
Example #12
0
TupleSet
ConstraintTree::tupleSet (const LogVars& originalLvs)
{
  LogVars uniqueLvs;
  for (size_t i = 0; i < originalLvs.size(); i++) {
    if (Util::contains (uniqueLvs, originalLvs[i]) == false) {
      uniqueLvs.push_back (originalLvs[i]);
    }
  }

  Tuples tuples;
  moveToTop (uniqueLvs);
  unsigned stopLevel = uniqueLvs.size();
  getTuples (root_, Tuples(), stopLevel, tuples, CTNodes() = {});

  if (originalLvs.size() != uniqueLvs.size()) {
    vector<size_t> indexes;
    indexes.reserve (originalLvs.size());
    for (size_t i = 0; i < originalLvs.size(); i++) {
      indexes.push_back (Util::indexOf (uniqueLvs, originalLvs[i]));
    }
    Tuples tuples2;
    tuples2.reserve (tuples.size());
    for (size_t i = 0; i < tuples.size(); i++) {
      Tuple t;
      t.reserve (originalLvs.size());
      for (size_t j = 0; j < originalLvs.size(); j++) {
        t.push_back (tuples[i][indexes[j]]);
      }
      tuples2.push_back (t);
    }
    return TupleSet (tuples2);
  }

  return TupleSet (tuples);
}
Example #13
0
    void WorldEditor::mouseReleased(gcn::MouseEvent& mouseEvent)
    {
        if (mDrawingNewRoom 
            && mNewRoomWidth != 0 
            && mNewRoomHeight != 0
            && !mNewRoomDialogWindow->isVisible())
        {
            mDrawingNewRoom = false;

            if (mNewRoomWidth < 0)
            {
                int oldNewRoomX = mNewRoomX;
                mNewRoomX = mNewRoomX + mNewRoomWidth;
                mNewRoomWidth = -mNewRoomWidth; 
            }
            
            if (mNewRoomHeight < 0)
            {
                int oldNewRoomY = mNewRoomY;
                mNewRoomY = mNewRoomY + mNewRoomHeight;
                mNewRoomHeight = -mNewRoomHeight; 
            }

            mNewRoomDialogWidthLabel->setCaption("Width " + toString(mNewRoomWidth));
            mNewRoomDialogWidthLabel->adjustSize();
            mNewRoomDialogHeightLabel->setCaption("Height " + toString(mNewRoomHeight));
            mNewRoomDialogHeightLabel->adjustSize();
            mNewRoomDialogNameTextField->setText("");
            mNewRoomDialogWindow->setVisible(true);
            moveToTop(mNewRoomDialogWindow);
        }
        else
        {
            mDrawingNewRoom = false;
        }
    }
Example #14
0
MainWindow::MainWindow()
{
    // User interface ----------------------------------------------------------
    if (tr("LTR") == "RTL") {
        qApp->setLayoutDirection(Qt::RightToLeft);
    }
    setupUi(this);
    network_access_manager = new QNetworkAccessManager(this);
    default_printer = NULL;
#ifdef Q_OS_MAC
    this->setUnifiedTitleAndToolBarOnMac(true);
#endif
    progressBar = new QProgressBar(this);
    progressBar->setTextVisible(false);
    progressBar->resize(QSize(30, 10));
    statusBar()->addPermanentWidget(progressBar, 0);
    statusBar()->setFixedHeight(20);
    progressBar->setFixedWidth(150);
    progressBar->setFixedHeight(15);
    progressBar->setVisible(false);
    LQCategoryComboBox->setVisible(false);
    SQStatisticsLabel->setVisible(false);
    currentSvgChanged();
    btnApply = SQButtonBox->button(QDialogButtonBox::Apply);
    btnApply->setText(tr("Apply"));
    btnApply->setStatusTip(tr("Apply any changes you have made to the question"));
    btnApply->setIcon(QIcon(QString::fromUtf8(":/images/images/button_ok.png")));
    btnDiscard = SQButtonBox->button(QDialogButtonBox::Discard);
    btnDiscard->setText(tr("Discard"));
    btnDiscard->setStatusTip(tr("Discard any changes you have made to the question"));
    btnDiscard->setIcon(QIcon(QString::fromUtf8(":/images/images/button_cancel.png")));
    SQQuestionTextEdit->setTitle(tr("Question:"));
    SQQuestionTextEdit->textEdit()->setStatusTip(tr("Text of the selected question"));
    ECTextEdit->setTitle(tr("Comments:"));
    ECTextEdit->textEdit()->setStatusTip(tr("Use this field for your comments, notes, reminders..."));
    EFTreeWidget->setMouseTracking(true);
    EFTreeWidget->header()->setSectionResizeMode(0, QHeaderView::Fixed);
    EFTreeWidget->header()->setSectionResizeMode(1, QHeaderView::Stretch);
    EFTreeWidget->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
    EFButtonBox->button(QDialogButtonBox::Apply)->setText(tr("Apply"));
    EFButtonBox->button(QDialogButtonBox::Apply)->setStatusTip(tr("Apply any changes you have made to the categories"));
    EFButtonBox->button(QDialogButtonBox::Apply)->setIcon(QIcon(QString::fromUtf8(":/images/images/button_ok.png")));
    EFButtonBox->button(QDialogButtonBox::Discard)->setText(tr("Discard"));
    EFButtonBox->button(QDialogButtonBox::Discard)->setStatusTip(tr("Discard any changes you have made to the categories"));
    EFButtonBox->button(QDialogButtonBox::Discard)->setIcon(QIcon(QString::fromUtf8(":/images/images/button_cancel.png")));
    // Initialize variables ----------------------------------------------------
    // URLs
    docs_url = tr("http://itest.sourceforge.net/documentation/%1/en/").arg("1.4");
    // i18n
    QTranslator translator; translator.load(":/i18n/iTest-i18n.qm");
    itest_i18n.insert("English", "en");
    itest_i18n.insert(translator.translate("LanguageNames", "Slovak"), "sk");
    itest_i18n.insert(translator.translate("LanguageNames", "Russian"), "ru");
    itest_i18n.insert(translator.translate("LanguageNames", "Turkish"), "tr");
    itest_i18n.insert(translator.translate("LanguageNames", "Portuguese"), "pt");
    itest_i18n.insert(translator.translate("LanguageNames", "Spanish"), "es");
    itest_i18n.insert(translator.translate("LanguageNames", "Italian"), "it");
    itest_i18n.insert(translator.translate("LanguageNames", "Latvian"), "lv");
    itest_i18n.insert(translator.translate("LanguageNames", "Ukrainian"), "uk");
    itest_i18n.insert(translator.translate("LanguageNames", "Czech"), "cs");
    itest_i18n.insert(translator.translate("LanguageNames", "Hungarian"), "hu");
    itest_i18n.insert(translator.translate("LanguageNames", "German"), "de");
    // CURRENT_DB
    current_db_open = false;
    current_db_session = NULL;
    current_db_class = NULL;
    current_db_categories.resize(20);
    current_db_categories_enabled.resize(20);
    // Connect slots -----------------------------------------------------------
    tbtnAddQuestion->setDefaultAction(actionAdd);
    tbtnDuplicateQuestion->setDefaultAction(actionDuplicate);
    tbtnDeleteQuestion->setDefaultAction(actionDelete);
    QObject::connect(actionAdd, SIGNAL(triggered()), this, SLOT(addQuestion()));
    QObject::connect(actionDelete, SIGNAL(triggered()), this, SLOT(deleteQuestion()));
    QObject::connect(actionDuplicate, SIGNAL(triggered()), this, SLOT(duplicateQuestion()));
    QObject::connect(btnApply, SIGNAL(released()), this, SLOT(applyQuestionChanges()));
    QObject::connect(actionApply, SIGNAL(triggered()), this, SLOT(applyQuestionChanges()));
    QObject::connect(btnDiscard, SIGNAL(released()), this, SLOT(discardQuestionChanges()));
    QObject::connect(actionDiscard, SIGNAL(triggered()), this, SLOT(discardQuestionChanges()));

    QObject::connect(actionNew, SIGNAL(triggered()), this, SLOT(newDB()));
    QObject::connect(btnNew, SIGNAL(released()), this, SLOT(newDB()));
    QObject::connect(actionOpen, SIGNAL(triggered()), this, SLOT(open()));
    QObject::connect(btnOpenOther, SIGNAL(released()), this, SLOT(open()));
    QObject::connect(btnOpenSelected, SIGNAL(released()), this, SLOT(openRecent()));
    QObject::connect(actionSave, SIGNAL(triggered()), this, SLOT(save()));
    QObject::connect(actionSave_as, SIGNAL(triggered()), this, SLOT(saveAs()));
    QObject::connect(actionSave_a_copy, SIGNAL(triggered()), this, SLOT(saveCopy()));
    QObject::connect(actionExport_CSV, SIGNAL(triggered()), this, SLOT(exportCSV()));
    QObject::connect(actionClose, SIGNAL(triggered()), this, SLOT(closeDB()));
    QObject::connect(actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
    QObject::connect(actionAbout, SIGNAL(triggered()), this, SLOT(about()));

    QObject::connect(recentDBsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(openRecent(QListWidgetItem *)));
    QObject::connect(LQListWidget, SIGNAL(currentTextChanged(QString)), this, SLOT(setCurrentQuestion()));

    QObject::connect(actionFrom_A_to_Z, SIGNAL(triggered()), this, SLOT(sortQuestionsAscending()));
    QObject::connect(actionFrom_Z_to_A, SIGNAL(triggered()), this, SLOT(sortQuestionsDescending()));
    QObject::connect(actionBy_category, SIGNAL(triggered()), this, SLOT(sortQuestionsByCategory()));

    tbtnAddSVG->setDefaultAction(actionAdd_SVG);
    tbtnRemoveSVG->setDefaultAction(actionRemove_SVG);
    tbtnEditSVG->setDefaultAction(actionEdit_SVG);
    tbtnExportSVG->setDefaultAction(actionExport_SVG);
    QObject::connect(actionAdd_SVG, SIGNAL(triggered()), this, SLOT(addSvg()));
    QObject::connect(actionRemove_SVG, SIGNAL(triggered()), this, SLOT(removeSvg()));
    QObject::connect(actionEdit_SVG, SIGNAL(triggered()), this, SLOT(editSvg()));
    QObject::connect(actionExport_SVG, SIGNAL(triggered()), this, SLOT(exportSvg()));
    QObject::connect(SQSVGListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(previewSvg(QListWidgetItem *)));
    QObject::connect(SQSVGListWidget, SIGNAL(currentTextChanged(QString)), this, SLOT(currentSvgChanged()));

    tbtnMoveUp->setDefaultAction(actionMove_up);
    tbtnMoveDown->setDefaultAction(actionMove_down);
    QObject::connect(actionMove_up, SIGNAL(triggered()), this, SLOT(moveUp()));
    QObject::connect(actionMove_down, SIGNAL(triggered()), this, SLOT(moveDown()));
    QObject::connect(actionMove_to_top, SIGNAL(triggered()), this, SLOT(moveToTop()));
    QObject::connect(actionMove_to_bottom, SIGNAL(triggered()), this, SLOT(moveToBottom()));
    QObject::connect(actionHide, SIGNAL(triggered()), this, SLOT(hideQuestion()));
    QObject::connect(actionShow_hidden, SIGNAL(triggered()), this, SLOT(filterLQSearch()));

    rbtngrpFilterLQ = new QButtonGroup(this);
    rbtngrpFilterLQ->addButton(LQAllRadioButton);
    rbtngrpFilterLQ->addButton(LQEasyRadioButton);
    rbtngrpFilterLQ->addButton(LQMediumRadioButton);
    rbtngrpFilterLQ->addButton(LQDifficultRadioButton);
    rbtngrpFilterLQ->addButton(LQCategoryRadioButton);

    actgrpFilterLQ = new QActionGroup(this);
    actgrpFilterLQ->addAction(actionShow_all);
    actgrpFilterLQ->addAction(actionShow_easy);
    actgrpFilterLQ->addAction(actionShow_medium);
    actgrpFilterLQ->addAction(actionShow_difficult);
    actgrpFilterLQ->addAction(actionShow_category);

    QObject::connect(rbtngrpFilterLQ, SIGNAL(buttonReleased(QAbstractButton *)), this, SLOT(filterLQ(QAbstractButton *)));
    QObject::connect(actgrpFilterLQ, SIGNAL(triggered(QAction *)), this, SLOT(filterLQAction(QAction *)));
    QObject::connect(LQCategoryComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterLQCategoryChanged()));
    QObject::connect(LQSearchLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterLQSearch()));
    QObject::connect(tbtnSearchByGroup, SIGNAL(released()), this, SLOT(searchByGroup()));

    actgrpPage = new QActionGroup(this);
    actgrpPage->addAction(actionEdit_questions);
    actgrpPage->addAction(actionEdit_comments);
    actgrpPage->addAction(actionEdit_categories);
    actgrpPage->addAction(actionEdit_test);
    actgrpPage->addAction(actionSaved_sessions);
    actgrpPage->addAction(actionEdit_classes);

    QObject::connect(actgrpPage, SIGNAL(triggered(QAction *)), this, SLOT(setPage(QAction *)));

    //QObject::connect(btnApply, SIGNAL(released()), this, SLOT(setDatabaseModified()));
    //QObject::connect(actionApply, SIGNAL(triggered()), this, SLOT(setDatabaseModified()));
    QObject::connect(ECTextEdit, SIGNAL(textChanged()), this, SLOT(setDatabaseModified()));

    QObject::connect(actionCheck_for_updates, SIGNAL(triggered()), this, SLOT(checkForUpdates()));
    QObject::connect(network_access_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(httpRequestFinished(QNetworkReply *)));
    QObject::connect(actionDocumentation, SIGNAL(triggered()), this, SLOT(openDocumentation()));
    QObject::connect(SQStatisticsLabel, SIGNAL(linkActivated(QString)), this, SLOT(adjustQuestionDifficulty()));
    QObject::connect(actionPrint_questions, SIGNAL(triggered()), this, SLOT(showPrintQuestionsDialogue()));
    QObject::connect(actionOverall_statistics, SIGNAL(triggered()), this, SLOT(overallStatistics()));
    QObject::connect(actionChange_language, SIGNAL(triggered()), this, SLOT(changeLanguage()));

    QObject::connect(mainStackedWidget, SIGNAL(currentChanged(int)), this, SLOT(currentPageChanged(int)));
    // Disable all -------------------------------------------------------------
    setAllEnabled(false);
    // Categories -------------------------------------------------------------------
    setupCategoriesPage();
    // Server ------------------------------------------------------------------
    setupServer();
    // Session viewer ----------------------------------------------------------
    setupSessionViewer();
    // Class viewer ------------------------------------------------------------
    setupClassViewer();
    // -------------------------------------------------------------------------
#ifdef Q_OS_MAC
    show();
#endif
    // Load settings -----------------------------------------------------------
    loadSettings();
    // Ready -------------------------------------------------------------------
    statusBar()->showMessage(tr("Ready"), 10000);
    // Check app args ----------------------------------------------------------
    if (qApp->arguments().count() > 1) {
        openFile(qApp->arguments().at(1));
    }
    // -------------------------------------------------------------------------
#ifndef Q_OS_MAC
    show();
#endif
}
Example #15
0
unsigned
ConstraintTree::nrSymbols (LogVar X)
{
  moveToTop ({X});
  return root_->childs().size();
}
Example #16
0
void gravManager::draw()
{
    // don't draw if either of these objects haven't been initialized yet
    if ( !earth || !input ) return;

    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    cam->animateValues();
    cam->doGLLookat();

    // audio test drawing
    /*if ( audioAvailable() )
    {
        GLUquadric* sphereQuad = gluNewQuadric();
        if ( true ) //drawCounter % 2 == 0 )
        {
            float avg = audio->getLevelAvg();
            if ( avg > 0.0001f )
                overalllevel = avg;
        }
        gluSphere( sphereQuad, overalllevel * 30.0f + 0.5f, 50, 50 );
    }*/

    // set it to update names only every 30 frames
    bool updateNames = false;
    if ( drawCounter == 0 )
    {
        updateNames = true;
        if ( audioAvailable() )
            audio->updateNames();
    }

    // polygon offset to fix z-fighting of coplanar polygons (videos)
    // disabled, since making the depth buffer read-only in some area takes
    // care of this issue
    //glEnable( GL_POLYGON_OFFSET_FILL );
    //glPolygonOffset( 0.1, 1.0 );

    //glPolygonMode( GL_FRONT, GL_FILL );
    //float pOffset = 0.1;

    std::vector<RectangleBase*>::const_iterator si;

    lockSources();

    // periodically automatically rearrange if on automatic - take last object
    // and put it in center
    if ( autoCounter == 0 && getMovableObjects().size() > 0 && autoFocusRotate )
    {
        outerObjs = getMovableObjects();
        innerObjs = std::vector<RectangleBase*>( outerObjs.begin(),
                                                    outerObjs.begin()+1 );
        outerObjs.erase( outerObjs.begin() );

        std::map<std::string, std::vector<RectangleBase*> > data = \
            std::map<std::string, std::vector<RectangleBase*> >();
        data["inners"] = innerObjs;
        data["outers"] = outerObjs;
        layouts->arrange( "aspectFocus", getScreenRect(), RectangleBase(),
                            data );

        moveToTop( innerObjs[0] );

        outerObjs.clear();
        innerObjs.clear();
    }

    // add objects to tree that need to be added - similar to delete, tree is
    // modified on the main thread (in other WX places) so
    if ( objectsToAddToTree->size() > 0 && tree != NULL )
    {
        for ( unsigned int i = 0; i < objectsToAddToTree->size(); i++ )
        {
            tree->addObject( (*objectsToAddToTree)[i] );
        }
        objectsToAddToTree->clear();
    }
    // same for remove
    if ( objectsToRemoveFromTree->size() > 0 && tree != NULL )
    {
        for ( unsigned int i = 0; i < objectsToRemoveFromTree->size(); i++ )
        {
            tree->removeObject( (*objectsToRemoveFromTree)[i] );
        }
        objectsToRemoveFromTree->clear();
    }
    // delete sources that need to be deleted - see deleteSource for the reason
    doDelayedDelete();

    // draw point on geographical position, selected ones on top (and bigger)
    for ( si = drawnObjects->begin(); si != drawnObjects->end(); si++ )
    {
        RGBAColor col = (*si)->getColor();
        glColor4f( col.R, col.G, col.B, col.A );
        if ( !(*si)->isGrouped() && !(*si)->isSelected() )
        {
            //drawCurvedEarthLine( (*si)->getLat(), (*si)->getLon(),
            //                    (*si)->getX(), (*si)->getY(), (*si)->getZ() );
            drawEarthPoint( (*si)->getLat(), (*si)->getLon(), 3.0f );
        }
    }
    for ( si = selectedObjects->begin(); si != selectedObjects->end(); si++ )
    {
        RGBAColor col = (*si)->getColor();
        glColor4f( col.R, col.G, col.B, col.A );
        if ( !(*si)->isGrouped() )
        {
            //drawCurvedEarthLine( (*si)->getLat(), (*si)->getLon(),
            //                    (*si)->getX(), (*si)->getY(), (*si)->getZ() );
            drawEarthPoint( (*si)->getLat(), (*si)->getLon(), 6.0f );
        }
    }

    earth->draw();

    // this makes the depth buffer read-only for this bit - this prevents
    // z-fighting on the videos which are coplanar
    glDepthMask( GL_FALSE );

    // iterate through all objects to be drawn, and draw
    for ( si = drawnObjects->begin(); si != drawnObjects->end(); si++ )
    {
        // do things we only want to do every X frames,
        // like updating the name
        if ( updateNames )
        {
            // only bother updating it on the tree if it actually
            // changes - to suppress "" from getting shown
            if ( (*si)->updateName() && tree )
                tree->updateObjectName( (*si) );
        }

        // only draw if not grouped - groups are responsible for
        // drawing their members
        if ( !(*si)->isGrouped() )
        {
            // set the audio effect level on the drawcounter, if audio is
            // enabled, and if it's selectable (excludes runway)
            // TODO maybe change this if meaning of selectable changes
            if ( audioAvailable() && drawCounter == 0 && (*si)->isSelectable() )
            {
                // had a really bizarre bug here - if uninitialized, would hit
                // > 0.01f check and succeed later if object was selected. what?
                float level = 0.0f;
                // if source has siteID, send that (and tell audiomanager to
                // only check siteIDs), if not, use cname if available
                if ( (*si)->getSiteID().compare("") != 0 )
                {
                    level = audio->getLevel( (*si)->getSiteID(), true, false );
                }
                else if ( (*si)->getAltName().compare("") != 0 )
                {
                    level = audio->getLevel( (*si)->getAltName(), true, true );
                }

                if ( level > 0.01f )
                {
                    innerObjs.push_back( (*si) );
                    audioFocusTrigger = true;
                }
                else
                {
                    outerObjs.push_back( (*si) );
                }
            }
            (*si)->draw();
        }
        else
        {
            // object is grouped, so group will draw it itself
        }
    }

    // do the audio focus if it triggered
    if ( audioAvailable() )
    {
        if ( audioFocusTrigger )
        {
            std::map<std::string, std::vector<RectangleBase*> > data = \
                std::map<std::string, std::vector<RectangleBase*> >();
            data["inners"] = innerObjs;
            data["outers"] = outerObjs;
            layouts->arrange( "aspectFocus", getScreenRect(), RectangleBase(),
                                data );
            audioFocusTrigger = false;
        }

        outerObjs.clear();
        innerObjs.clear();
    }

    // check runway members for potential removal if outside
    if ( intersectCounter == 0 && runway->numObjects() > 0 &&
            runway->getColor().A > 0.01f )
        runway->handleOutsideMembers();

    if ( input->haveValidMousePos() )
    {
        bool sessionMouseover = input->getMouseX() > sessionManager->getLBound()
                && input->getMouseX() < sessionManager->getRBound()
                && input->getMouseY() < sessionManager->getUBound()
                && input->getMouseY() > sessionManager->getDBound();
        if ( sessionMouseover && !sessionManager->isShown() )
        {
            sessionManager->show( true );
            moveToTop( sessionManager );
        }
        else if ( !sessionMouseover && sessionManager->isShown() )
        {
            sessionManager->show( false );
        }
    }

    unlockSources();

    // check session manager for moved session entry objects & shift if
    // necessary - this needs to be outside the lock() since a shift might
    // trigger a session disable, which may delete a video which needs to lock
    // on its own (ie, we're not doing reentrant mutexes)
    if ( intersectCounter == 0 && sessionManager->getColor().A > 0.01f )
        sessionManager->checkGUISessionShift();

    // draw the click-and-drag selection box
    if ( holdCounter > 1 && drawSelectionBox )
    {
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

        // the main box
        glBegin(GL_QUADS);

        glColor4f( 0.1f, 0.2f, 1.0f, holdCounter/25.0f * 0.25f );

        glVertex3f(input->getDragStartX(), input->getDragStartY(), 0.0f);
        glVertex3f(input->getDragEndX(), input->getDragStartY(), 0.0f);
        glVertex3f(input->getDragEndX(), input->getDragEndY(), 0.0f);
        glVertex3f(input->getDragStartX(), input->getDragEndY(), 0.0f);

        glEnd();

        // the outline
        glBegin(GL_LINE_LOOP);

        glColor4f( 0.5f, 0.6f, 1.0f, holdCounter/25.0f * 0.25f );

        glVertex3f(input->getDragStartX(), input->getDragStartY(), 0.0f);
        glVertex3f(input->getDragEndX(), input->getDragStartY(), 0.0f);
        glVertex3f(input->getDragEndX(), input->getDragEndY(), 0.0f);
        glVertex3f(input->getDragStartX(), input->getDragEndY(), 0.0f);

        glEnd();

        glDisable(GL_BLEND);
    }

    // header text drawing
    if ( useHeader )
    {
        glPushMatrix();

        glEnable( GL_BLEND );
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glColor4f( 0.953f, 0.431f, 0.129f, 0.5f );
        float textXPos = screenRectFull.getLBound() + textOffset;
        float textYPos = screenRectFull.getUBound() -
                ( ( headerTextBox.Upper().Yf() - headerTextBox.Lower().Yf() )
                        * textScale ) - textOffset;
        glTranslatef( textXPos, textYPos, 0.0f );
        glScalef( textScale, textScale, textScale );
        const char* text = headerString.c_str();
        GLUtil::getInstance()->getMainFont()->Render( text );
        glDisable( GL_BLEND );

        glPopMatrix();
    }

    // graphics debug drawing
    if ( graphicsDebugView )
    {
        glPushMatrix();

        GLCanvas* canvas = GLUtil::getInstance()->getCanvas();

        long drawTime = canvas->getDrawTime();
        float color = (33.0f - (float)drawTime) / 17.0f;
        glColor4f( 1.0f, color, color, 0.8f );
        glTranslatef( 0.0f, screenRectFull.getUBound() * 0.9f, 0.0f );
        float debugScale = textScale / 2.5f;
        glScalef( debugScale, debugScale, debugScale );
        char text[100];
        sprintf( text,
                "Draw time: %3ld  Non-draw time: %3ld  Pixel count: %8ld "
                "FPS: %2.2f",
                canvas->getDrawTime(), canvas->getNonDrawTime(),
                videoListener->getPixelCount(), canvas->getFPS() );
        GLUtil::getInstance()->getMainFont()->Render( text );

        glPopMatrix();
    }

    // back to writeable z-buffer for proper earth/line rendering
    glDepthMask( GL_TRUE );

    glFlush();

    // hold counter is a bit different than the others since alpha values
    // directly depend on it, as above
    if ( !input->isLeftButtonHeld() && holdCounter > 0 )
        holdCounter-=2;
    else if ( holdCounter < 24 )
        holdCounter++;

    drawCounter = ( drawCounter + 1 ) % 30;
    intersectCounter = ( intersectCounter + 1 ) % 20;
    autoCounter = ( autoCounter + 1 ) % 900;
}
Example #17
0
void snap( sf::Font& font )
{
	sf::RenderWindow window( sf::VideoMode( getScreenSize().x, getScreenSize().y ), "QuickSnap - Snap", sf::Style::None );
	window.setFramerateLimit( 30 );
	setTransparent( window, 128 );
	moveToPos( window, getScreenPos() );
	
	sf::CircleShape circ;
	circ.setRadius( 4 );
	circ.setFillColor( sf::Color::Black );
	circ.setOrigin( 4, 4 );
	
	sf::RectangleShape rect;
	rect.setOutlineColor( sf::Color::Black );
	rect.setOutlineThickness( 3 );
	rect.setFillColor( sf::Color( 255, 255, 255, 64 ) );
	
	bool didFirstClick = false;
	bool didFirstRelease = false;
	
	bool isRunning = true;
	while ( isRunning )
	{
		moveToTop( window );
		focus( window );
		
		sf::Event event;
		while ( window.pollEvent( event ) )
		{
			if ( event.type == sf::Event::KeyPressed )
			{
				if ( event.key.code == sf::Keyboard::Return )
				{
					window.close();
					takeSnapshot( rect );
					isRunning = false;
				}
				else if ( event.key.code == sf::Keyboard::Escape )
				{
					isRunning = false;
				}
			}
			else if ( event.type == sf::Event::MouseButtonPressed )
			{
				if ( event.mouseButton.button == sf::Mouse::Left )
				{
					didFirstClick = true;
					didFirstRelease = false;
					rect.setPosition( event.mouseButton.x, event.mouseButton.y );
				}
			}
			else if ( event.type == sf::Event::MouseButtonReleased )
			{
				if ( event.mouseButton.button == sf::Mouse::Left )
				{
					didFirstRelease = true;
					fixRect( window, rect );
				}
			}
		}
		
		fixCircle( window, circ );
		if ( !didFirstRelease )
		{
			fixRect( window, rect );
		}
		
		window.clear( sf::Color( 255, 255, 255, 64 ) );
		if ( didFirstClick )
		{
			window.draw( rect );
		}
		window.draw( circ );
		window.display();
	}
}