Пример #1
1
/**
 * Replaces tilesets in \a map by similar tilesets in this map when possible,
 * and adds tilesets to \a missingTilesets whenever there is a tileset without
 * replacement in this map.
 *
 * \warning This method assumes that the tilesets in \a map are managed by
 *          the TilesetManager!
 */
void MapDocument::unifyTilesets(Map *map, QVector<SharedTileset> &missingTilesets)
{
    QVector<SharedTileset> availableTilesets = mMap->tilesets();
    for (const SharedTileset &tileset : qAsConst(missingTilesets))
        if (!availableTilesets.contains(tileset))
            availableTilesets.append(tileset);

    TilesetManager *tilesetManager = TilesetManager::instance();

    // Iterate over a copy because map->replaceTileset may invalidate iterator
    const QVector<SharedTileset> tilesets = map->tilesets();
    for (const SharedTileset &tileset : tilesets) {
        // tileset already added
        if (availableTilesets.contains(tileset))
            continue;

        SharedTileset replacement = tileset->findSimilarTileset(availableTilesets);

        // tileset not present and no replacement tileset found
        if (!replacement) {
            missingTilesets.append(tileset);
            availableTilesets.append(tileset);
            continue;
        }

        // replacement tileset found, change given map
        if (map->replaceTileset(tileset, replacement))
            tilesetManager->addReference(replacement);
        tilesetManager->removeReference(tileset);
    }
}
Пример #2
1
//
//	Creates recursively the dotted line points
//
QVector<Point3f> vectSub(int part, Point3f p1, Point3f p2)
{
	if(part==2)
	{
		QVector<Point3f> toRet(3);
		toRet[0]=p1;
		toRet[1]=(p1+p2)/2;
		toRet[2]=p2;
		return toRet;
	}
	else
	{
		QVector<Point3f> L;
		QVector<Point3f> R;

		int np=(int)(part/2);

		L = vectSub(np, p1, (p1+p2)/2);
		R = vectSub(np, (p1+p2)/2, p2);
		
		QVector<Point3f> toRet;
		for(int i=0; i<L.size(); i++)
			if(!toRet.contains(L.at(i)))
				toRet.push_back(L.at(i));
		for(int i=0; i<R.size(); i++)
			if(!toRet.contains(R.at(i)))
				toRet.push_back(R.at(i));

		return toRet;
	}
}
Пример #3
1
QVector<QPointF> jpsRoom::get_vertices() const
{
    QVector<QPointF> vertices;

    for (int i=0; i<item_list.size(); i++)
    {
        if (vertices.contains(item_list[i]->get_line()->line().p1())==false)
        {
            vertices.push_back(item_list[i]->get_line()->line().p1());
        }
        if (vertices.contains(item_list[i]->get_line()->line().p2())==false)
        {
            vertices.push_back(item_list[i]->get_line()->line().p2());
        }
    }
    for (jpsCrossing* crossing:_doorList)
    {
        if (vertices.contains(crossing->get_cLine()->get_line()->line().p1())==false)
        {
            vertices.push_back(crossing->get_cLine()->get_line()->line().p1());
        }

        if (vertices.contains(crossing->get_cLine()->get_line()->line().p1())==false)
        {
            vertices.push_back(crossing->get_cLine()->get_line()->line().p1());
        }

    }

    return vertices;
}
    void shouldNotifyWhenTabPropertiesChange()
    {
        qRegisterMetaType<QVector<int> >();
        QSignalSpy spy(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
        QQuickItem* tab = createTab();
        model->add(tab);

        QQmlProperty(tab, "url").write(QUrl("http://ubuntu.com"));
        QCOMPARE(spy.count(), 1);
        QList<QVariant> args = spy.takeFirst();
        QCOMPARE(args.at(0).toModelIndex().row(), 0);
        QCOMPARE(args.at(1).toModelIndex().row(), 0);
        QVector<int> roles = args.at(2).value<QVector<int> >();
        QCOMPARE(roles.size(), 1);
        QVERIFY(roles.contains(TabsModel::Url));

        QQmlProperty(tab, "title").write(QString("Lorem Ipsum"));
        QCOMPARE(spy.count(), 1);
        args = spy.takeFirst();
        QCOMPARE(args.at(0).toModelIndex().row(), 0);
        QCOMPARE(args.at(1).toModelIndex().row(), 0);
        roles = args.at(2).value<QVector<int> >();
        QCOMPARE(roles.size(), 1);
        QVERIFY(roles.contains(TabsModel::Title));

        QQmlProperty(tab, "icon").write(QUrl("image://webicon/123"));
        QCOMPARE(spy.count(), 1);
        args = spy.takeFirst();
        QCOMPARE(args.at(0).toModelIndex().row(), 0);
        QCOMPARE(args.at(1).toModelIndex().row(), 0);
        roles = args.at(2).value<QVector<int> >();
        QCOMPARE(roles.size(), 1);
        QVERIFY(roles.contains(TabsModel::Icon));
    }
Пример #5
0
TEST( tBridge, RemoveSeveralPreset )
{
    tDisplayId id1 = { QUuid::createUuid() };
    tDisplayId id2 = { QUuid::createUuid() };
    tPosition position1 = { QPoint( 1, 2 ) };
    tPosition position2 = { QPoint( 3, 4 ) };
    tBridge bridge;
    bridge.SetDisplay( id1, position1 );
    bridge.SetDisplay( id2, position2 );

    tPage page1 = { ePanelLayoutRowLower, QVector<PanelID>() << DATA, 0, 0 };
    tPage page2 = { ePanelLayoutRowLower, QVector<PanelID>() << POSITION, 0, 0 };
    tPreset preset1;
    preset1.SetDisplay( id1, page1 );
    tPreset preset2;
    preset2.SetDisplay( id2, page2 );
    tPreset preset3;
    preset3.SetDisplay( id1, page2 );

    bridge.AddPreset( preset1 );
    bridge.AddPreset( preset2 );
    bridge.AddPreset( preset3 );

    bridge.RemovePreset( preset2 );
    QVector<tPreset> presets = bridge.Presets();
    EXPECT_EQ( 2, presets.size() );
    EXPECT_TRUE( presets.contains( preset1 ) );
    EXPECT_TRUE( presets.contains( preset3 ) );
    bridge.RemovePreset( preset1 );
    presets = bridge.Presets();
    EXPECT_EQ( 1, presets.size() );
    EXPECT_TRUE( presets.contains( preset3 ) );
}
Пример #6
0
static QVector<unsigned short> getDeviceModeFramerates(int fd, unsigned w, unsigned h,
                                                       uint32_t pixelFormat)
{
    QVector<unsigned short> rates;
    v4l2_frmivalenum vfve{};
    vfve.pixel_format = pixelFormat;
    vfve.height = h;
    vfve.width = w;

    while (!ioctl(fd, VIDIOC_ENUM_FRAMEINTERVALS, &vfve)) {
        int rate;
        switch (vfve.type) {
        case V4L2_FRMSIZE_TYPE_DISCRETE:
            rate = vfve.discrete.denominator / vfve.discrete.numerator;
            if (!rates.contains(rate))
                rates.append(rate);
            break;
        case V4L2_FRMSIZE_TYPE_CONTINUOUS:
        case V4L2_FRMSIZE_TYPE_STEPWISE:
            rate = vfve.stepwise.min.denominator / vfve.stepwise.min.numerator;
            if (!rates.contains(rate))
                rates.append(rate);
        }
        vfve.index++;
    }

    return rates;
}
void Application::notifyTransfersChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
{
    // Display notifications if one of the following happens:
    // - the device name is known (receiving only)
    // - transfer fails or succeeds
    for(int row = topLeft.row(); row <= bottomRight.row(); ++row) {

        QModelIndex index = mTransferModel.index(row, 0);
        if(roles.contains(TransferModel::DeviceNameRole)) {

            mIcon->showMessage(tr("Receiving transfer from %1.").arg(
                index.data(TransferModel::DeviceNameRole).toString()
            ));
        } else if(roles.contains(TransferModel::StateRole)) {

            switch(index.data(TransferModel::StateRole).toInt()) {
            case TransferModel::Failed:
                mIcon->showMessage(tr("Transfer with %1 failed.").arg(
                    index.data(TransferModel::DeviceNameRole).toString()
                ));
                break;
            case TransferModel::Succeeded:
                mIcon->showMessage(tr("Transfer with %1 succeeded.").arg(
                    index.data(TransferModel::DeviceNameRole).toString()
                ));
                break;
            }
        }
    }
}
Пример #8
0
void TestBuddies::testDUChainBuddyVote()
{
    /*
     * Test that the DUChain buddy system finds the buddy file with the most
     * common declarations/definitions
     */

    enableBuddies();
    enableOpenAfterCurrent();

    QTemporaryDir dirA;

    TestFile header("void func1();\nvoid func2();\nvoid func3();\n", "h", nullptr, dirA.path());
    TestFile source1(
        QString("#include \"%1\"\nvoid func1() {}\n").arg(header.url().toUrl().fileName()),
        "cpp", nullptr, dirA.path()
    );
    TestFile source2(
        QString("#include \"%1\"\nvoid func2() {}\nvoid func3() {}\n").arg(header.url().toUrl().fileName()),
        "cpp", nullptr, dirA.path()
    );

    // -> buddy(header) should resolve to source2

    header.parseAndWait();
    source1.parseAndWait();
    source2.parseAndWait();

    // Test IBuddyDocumentFinder::getPotentialBuddies()
    QMimeDatabase db;
    IBuddyDocumentFinder* sourceBuddyFinder = IBuddyDocumentFinder::finderForMimeType(db.mimeTypeForUrl(source1.url().toUrl()).name());
    QVector< QUrl > sourceBuddies = sourceBuddyFinder->getPotentialBuddies(source1.url().toUrl());
    if (!sourceBuddies.contains(header.url().toUrl())) {
        qDebug() << "got source buddies: " << sourceBuddies;
        qDebug() << "expected: " << header.url().toUrl();
        QFAIL("Failed to find buddy for source file");
    }

    IBuddyDocumentFinder* source2BuddyFinder = IBuddyDocumentFinder::finderForMimeType(db.mimeTypeForUrl(source2.url().toUrl()).name());
    QVector< QUrl > source2Buddies = source2BuddyFinder->getPotentialBuddies(source2.url().toUrl());
    if (!source2Buddies.contains(header.url().toUrl())) {
        qDebug() << "got source2 buddies: " << source2Buddies;
        qDebug() << "expected: " << header.url().toUrl();
        QFAIL("Failed to find buddy for source2 file");
    }

    IBuddyDocumentFinder* headerBuddyFinder = IBuddyDocumentFinder::finderForMimeType(db.mimeTypeForUrl(header.url().toUrl()).name());
    QVector< QUrl > headerBuddies = headerBuddyFinder->getPotentialBuddies(header.url().toUrl());
    if (!headerBuddies.contains(source2.url().toUrl())) {
        qDebug() << "got header buddies: " << headerBuddies;
        qDebug() << "expected: " << source2.url().toUrl();
        QFAIL("Failed to find buddy for header file");
    }
    QVERIFY2(!headerBuddies.contains(source1.url().toUrl()), "header buddy list contains weaker file");
}
Пример #9
0
void CategorizedView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
{
//	if (m_updatesDisabled)
//	{
//		return;
//	}

	QListView::dataChanged(topLeft, bottomRight, roles);

	if (roles.contains(CategorizedViewRoles::CategoryRole) || roles.contains(Qt::DisplayRole))
	{
		updateGeometries();
		update();
	}
}
Пример #10
0
void Puzzle::createGivens()
{
    // Initialize givens
    QList<QPoint> cells;
    for ( int r = 0; r < 9; ++r ) {
        for ( int c = 0; c < 9; ++c ) {
            m_givens[c][r] = m_solution[c][r];
            cells.append ( QPoint ( c, r ) );
        }
    }
    std::random_shuffle ( cells.begin(), cells.end() );

    // Remove as many givens as possible
    QVector<int> values ( m_pattern->count() );
    int count = values.count();
    QList<QPoint> positions;
    foreach ( const QPoint& cell, cells ) {
        positions = m_pattern->pattern ( cell );
        for ( int i = 0; i < count; ++i ) {
            QPoint pos = positions.at ( i );
            values[i] = m_givens[pos.x() ][pos.y() ];
        }
        if ( !values.contains ( 0 ) ) {
            for ( int i = 0; i < count; ++i ) {
                const QPoint& pos = positions.at ( i );
                m_givens[pos.x() ][pos.y() ] = 0;
            }
            if ( !isUnique() ) {
                for ( int i = 0; i < count; ++i ) {
                    const QPoint& pos = positions.at ( i );
                    m_givens[pos.x() ][pos.y() ] = values.at ( i );
                }
            }
        }
    }
/**
 * Goes through all of the different names in the current data type to populate
 * a selection list to be used for graphing.
 */
void Summary::processChoices(std::vector<std::vector<std::string> > &results){
    std::vector< std::vector<std::string> >::iterator resultIter;
    std::vector<std::string>::iterator fieldIter;
    QVector<QString> names;
    QVector<QString> years;
    resultIter = results.begin();
    ui->nameBox->clear();
    ui->nameBox->addItem("All Names");
    ui->dateSelector->clear();
    while(resultIter != results.end())
    {
      fieldIter = resultIter->begin();
      QString name = QString::fromStdString(*(fieldIter));
      QString year = QString::fromStdString(*(fieldIter + 1));

      if(QString::compare(name,"") != 0 && names.contains(name) == false)
          names.push_back(name);

      if(QString::compare(year,"") != 0)
          years.push_back(year);

      resultIter++;
    }

    names = sortNames(names);
    for(int i=0;i<names.size();i++){
        ui->nameBox->addItem(names[i]);
    }

    years = cleanDates(years);
    for(int i=0;i<years.size();i++){
        ui->dateSelector->addItem(years[i]);
    }
}
Пример #12
0
void DemandListModel::removeSelectedTuples(const QModelIndexList &selecteds){

	if(selecteds.empty()){
		return; //nothing to do.
	}

	QVector<int> rows;

	for(QModelIndex selected: selecteds) {
		if(!rows.contains(selected.row())){
			rows.push_back(selected.row());
		}
	}

	std::sort(rows.begin(), rows.end());

	for(int i = 0; i < rows.size(); i++){

		beginRemoveRows(QModelIndex(), rows[i]-i, rows[i]-i);
		_usedIndexes.remove(_tuples[rows[i]-i].index);
		_tuples.removeAt(rows[i]-i);
		endRemoveRows();
	}

	emit(changedDatas());

}
Пример #13
0
void Field::generate(int x, int y)
{

    Cell *banned = cellAt(x, y);
    QVector<Cell*> bannedCells = banned->getNeighbors();
    bannedCells.append(banned);



    int minesToPlace = m_numberOfMines;

    while (minesToPlace > 0) {
        Cell *cell = m_cells.at(qrand() % m_cells.count());

        if (cell->haveMine()) {
            continue;
        }
        if (bannedCells.contains(cell)){
            continue;
        }

        cell->setHaveMine(true);
        --minesToPlace;
    }
    m_generated = true;

}
Пример #14
0
QVector< QUrl > getPotentialBuddies(const QUrl &url, bool checkDUChain)
{
    auto type = basePathAndTypeForUrl(url);
    // Don't do anything for types we don't know
    if (type.second == Unknown) {
        return {};
    }

    // Depending on the buddy's file type we either generate source extensions (for headers)
    // or header extensions (for sources)
    const auto& extensions = ( type.second == Header ? ClangHelpers::sourceExtensions() : ClangHelpers::headerExtensions() );
    QVector< QUrl > buddies;
    for(const QString& extension : extensions) {
        if (!extension.contains(QLatin1Char('.'))) {
            buddies.append(QUrl::fromLocalFile(type.first + QLatin1Char('.') + extension));
        } else {
            buddies.append(QUrl::fromLocalFile(type.first + extension));
        }
    }

    if (checkDUChain) {
        // Also ask DUChain for a guess
        QUrl bestBuddy = duchainBuddyFile(url, type.second);
        if (!buddies.contains(bestBuddy)) {
            buddies.append(bestBuddy);
        }
    }

    return buddies;
}
Пример #15
0
void UIWizardNewVDPage1::addFormatButton(QWidget *pParent, QVBoxLayout *pFormatLayout, CMediumFormat medFormat)
{
    /* Check that medium format supports creation: */
    ULONG uFormatCapabilities = 0;
    QVector<KMediumFormatCapabilities> capabilities;
    capabilities = medFormat.GetCapabilities();
    for (int i = 0; i < capabilities.size(); i++)
        uFormatCapabilities |= capabilities[i];

    if (!(uFormatCapabilities & MediumFormatCapabilities_CreateFixed ||
          uFormatCapabilities & MediumFormatCapabilities_CreateDynamic))
        return;

    /* Check that medium format supports creation of virtual hard-disks: */
    QVector<QString> fileExtensions;
    QVector<KDeviceType> deviceTypes;
    medFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    if (!deviceTypes.contains(KDeviceType_HardDisk))
        return;

    /* Create/add corresponding radio-button: */
    QRadioButton *pFormatButton = new QRadioButton(pParent);
    pFormatLayout->addWidget(pFormatButton);
    m_formats << medFormat;
    m_formatNames << medFormat.GetName();
    m_pFormatButtonGroup->addButton(pFormatButton, m_formatNames.size() - 1);
}
Пример #16
0
void Action::handleArbitraryActionsStateChanged(const QVector<int> &identifiers)
{
	if (identifiers.contains(m_identifier))
	{
		updateState();
	}
}
Пример #17
0
/**
 * @brief AddRecord add record about tool in history.
 * @param id object id in container
 * @param toolType tool type
 * @param doc dom document container
 */
void VAbstractTool::AddRecord(const quint32 id, const Tool &toolType, VPattern *doc)
{
    QVector<VToolRecord> *history = doc->getHistory();
    VToolRecord record = VToolRecord(id, toolType, doc->GetNameActivPP());
    if (history->contains(record))
    {
        return;
    }

    quint32 cursor = doc->getCursor();
    if (cursor <= 0)
    {
        history->append(record);
    }
    else
    {
        qint32 index = 0;
        for (qint32 i = 0; i<history->size(); ++i)
        {
            VToolRecord rec = history->at(i);
            if (rec.getId() == cursor)
            {
                index = i;
                break;
            }
        }
        history->insert(index+1, record);
    }
}
Пример #18
0
void Action::handleCategorizedActionsStateChanged(const QVector<int> &categories)
{
	if (categories.contains(getDefinition().category))
	{
		updateState();
	}
}
Пример #19
0
void PlayConfigWindow::addCharacter() {
	QVector<Character*> inParty = _project->getStartEvent()->getParty();
	if (inParty.size() == g_maxPartysize) {
		QMessageBox::information(this, "Party is full", "All available slots for the party are taken.");
		return;
	}

	QVector<Character*> characters = _project->getCharacters()->getCharacters();
	QStringList items;
	for (int i = 0; i < characters.size(); i++) {
		Character *it = characters.at(i);
		if (!inParty.contains(it))
			items << it->getName();
	}

	if (items.size() == 0) {
		QMessageBox::information(this, "No more characters available", "There are no more characters to choose from.");
		return;
	}

	bool accepted;
	QString item = QInputDialog::getItem(this, "Select character", "Select a character to add to the party.", items, 0, false, &accepted);
	if (accepted) {
		Character *newMember = _project->getCharacters()->getCharacter(item);
		if (!!newMember) {
			try {
				_project->getStartEvent()->addCharacter(newMember);
			} catch (ProjectException &e) {
				QMessageBox::critical(this, "An unexpected error has occurred", e.what());
				return;
			}
			loadPartyTab();
		}
	}
}
void QuickInspectorWidget::itemModelDataChanged(const QModelIndex &topLeft,
                                                const QModelIndex &bottomRight,
                                                const QVector<int> &roles)
{
    if (!roles.contains(QuickItemModelRole::ItemEvent))
        return;

    for (int i = topLeft.row(); i <= bottomRight.row(); i++) {
        const QModelIndex index = ui->itemTreeView->model()->index(i, 0, topLeft.parent());
        const auto state = index.data(RemoteModelRole::LoadingState).value<RemoteModelNodeState::NodeStates>();
        if (state & RemoteModelNodeState::Empty || ~state & RemoteModelNodeState::Outdated)
            continue;

        QVariantAnimation *colorAnimation = new QVariantAnimation(this);
        QPersistentModelIndex persistentIndex(index);
        connect(colorAnimation, &QVariantAnimation::valueChanged,
                ui->itemTreeView->itemDelegate(), [persistentIndex, this](const QVariant &value) {
            qobject_cast<QuickItemDelegate *>(ui->itemTreeView->itemDelegate())->setTextColor(value,
                                                                                              persistentIndex);
        });
        colorAnimation->setStartValue(QColor(129, 0, 129));
        colorAnimation->setEndValue(QColor(129, 0, 129, 0));
        colorAnimation->setDuration(2000);
        colorAnimation->start(QAbstractAnimation::DeleteWhenStopped);
    }
}
 QVector<QString> GraphHelper::sumResultsType(double* barAmount, std::vector<std::vector<std::string>> &results)
 {
     std::vector< std::vector<std::string> >::iterator resultIter;
     std::vector<std::string>::iterator fieldIter;
     resultIter = results.begin();
     QVector<QString> found;
     while(resultIter != results.end())
     {
       fieldIter = resultIter->begin();
       std::string date = *(fieldIter +0);
       std::string amount = *(fieldIter + graphChoice);

       if(date.find(std::to_string(dateChoice)) != std::string::npos)
       {
           if(amount.compare("") == 0)
               amount = "Type Missing";

           if(found.contains(QString::fromStdString(amount)) == false)
               found.push_back(QString::fromStdString(amount));

            //Add amount to date
              barAmount[found.indexOf(QString::fromStdString(amount))] += 1;
       }

       resultIter++;
     }
     return found;
 }
Пример #22
0
QRectF Visualizer::putWord(QString word, float x, float y, bool isOnTop, int pos, QMap<int, QVector<int> > map) {
    QGraphicsTextItem *wordItem = new QGraphicsTextItem(QString(word));
    if(selWordRef.isActive()) {
        if(selWordRef.isOnTop() == isOnTop) {
            if(selWordRef.getPos() == pos) {
                wordItem->setDefaultTextColor(QColor("red"));
            }
        } else {
            QMapIterator<int, QVector<int> > i(map);
            while(i.hasNext()) {
                i.next();
                qDebug() << i.key() << " --- " << selWordRef.getPos() - 1;
            }
            QVector<int> targets = map[selWordRef.getPos() - 1];
            if(targets.contains(pos)) {
                wordItem->setDefaultTextColor(QColor("orange"));
            }
        }
    }
    wordItem->setFont(font);
    wordItem->setPos(x, y);
    wordItem->setData(IS_ON_TOP_KEY, QVariant(isOnTop));
    wordItem->setData(POS_KEY, QVariant(pos));
    QRectF rect = wordItem->boundingRect();
    scene->addItem(wordItem);
    return rect;
}
Пример #23
0
Файл: job.cpp Проект: JoelB/BITS
void Job::makeTaskIDs()
{
	/* find maximum taskID */
	int highest = 0;
	bool convertOK;
	Task *tempTask;
	QVector<int> needTaskID; // holds indexes of tasks that need an ID
	QVector<int> currentTaskIDs; // holds used IDs
	for (int i = 0; i < taskCount(); i++)
	{
		tempTask = getTask(i);
		int tempID = tempTask->getAttributeValue("TaskID").toInt(&convertOK);
		if (convertOK && tempID > 0 && !currentTaskIDs.contains(tempID))
		{
			currentTaskIDs.append(tempID);
			if (tempID > highest)
				highest = tempID;				
		}
		else
			needTaskID.append(i);
	}
	highest++;
	
	for (int i=0; i < needTaskID.size(); i++)
		getTask(needTaskID.at(i))->changeAttributeValue("TaskID",highest++);		
}
Пример #24
0
    void Mesh::smoothMesh( double deltaX)
    {
        double deltaT = sqrt(2* (deltaX* deltaX));
        QVector<Geometry::Point3D> tabPts;
        for(int i = 0 ; i < m_tabPoint.size() ; i++ )
        {
            tabPts.clear();
            //std::cout << "tourne i " << i << endl;
            Geometry::Point3D ptLocal = m_tabPoint[i];
            for (int j = 0 ; j < m_tabPoint.size(); j ++)
            {
                double dist = ptLocal.distanceXYTo(m_tabPoint[j]);
                if (tabPts.contains(m_tabPoint[j]) )
                { /* Do nothing ) */ }
                else if ( dist < deltaT*1.1 )
                    tabPts.push_back(m_tabPoint[j]);
            }

            if ( tabPts.size() > 5)
            {
                double z = 0;
                for ( int k = 0 ; k < tabPts.size() ; k ++ )
                {
                    z += tabPts[k].getZ(); //( ptLocal.getZ() + (tabPts[k].getZ()/tabPts.size()) ) / 2.0 ;
                }
                z = z/ tabPts.size();
                m_tabPoint[i].setZ(z);
            }
        }
    }
Пример #25
0
TEST( tBridge, RemoveDisplayNotUsedInPreset )
{
    tDisplayId id1 = { QUuid::createUuid() };
    tDisplayId id2 = { QUuid::createUuid() };
    tDisplayId id3 = { QUuid::createUuid() };
    tPosition position1 = { QPoint( 1, 2 ) };
    tPosition position2 = { QPoint( 3, 4 ) };
    tPosition position3 = { QPoint( 5, 6 ) };
    tBridge bridge;
    bridge.SetDisplay( id1, position1 );
    bridge.SetDisplay( id2, position2 );
    bridge.SetDisplay( id3, position3 );
    tPage page1 = { ePanelLayoutRowLower, QVector<PanelID>() << DATA, 0, 0 };
    tPage page2 = { ePanelLayoutRowLower, QVector<PanelID>() << POSITION, 0, 0 };
    tPreset preset1;
    preset1.SetDisplay( id1, page1 );
    preset1.SetDisplay( id2, page2 );
    bridge.AddPreset( preset1 );

    // removing display id3 should work; it should just remove id3 from the bridge but not change
    // any items since it is not part of any
    EXPECT_TRUE( bridge.RemoveDisplay( id3 ) );
    QVector<tPreset> presets = bridge.Presets();
    ASSERT_EQ( 1, presets.size() );
    QVector<tPresetItem> items = presets[0].Items();
    ASSERT_EQ( 2, items.size() );
    tPresetItem item1 = { id1, page1 };
    tPresetItem item2 = { id2, page2 };
    EXPECT_TRUE( items.contains( item1 ) );
    EXPECT_TRUE( items.contains( item2 ) );
}
Пример #26
0
TEST( tBridge, RemoveDisplayUsedInPreset )
{
    tDisplayId id1 = { QUuid::createUuid() };
    tDisplayId id2 = { QUuid::createUuid() };
    tPosition position1 = { QPoint( 1, 2 ) };
    tPosition position2 = { QPoint( 3, 4 ) };
    tBridge bridge;
    bridge.SetDisplay( id1, position1 );
    bridge.SetDisplay( id2, position2 );
    tPage page1 = { ePanelLayoutRowLower, QVector<PanelID>() << DATA, 0, 0 };
    tPage page2 = { ePanelLayoutRowLower, QVector<PanelID>() << POSITION, 0, 0 };
    tPreset preset1;
    preset1.SetDisplay( id1, page1 );
    preset1.SetDisplay( id2, page2 );
    bridge.AddPreset( preset1 );

    // removing display id1 should work; it should update preset1 by removing the item containing id1
    EXPECT_TRUE( bridge.RemoveDisplay( id1 ) );
    QVector<tPreset> presets = bridge.Presets();
    ASSERT_EQ( 1, presets.size() );
    QVector<tPresetItem> items = presets[0].Items();
    EXPECT_EQ( 1, items.size() );
    tPresetItem item = { id2, page2 };
    EXPECT_TRUE( items.contains( item ) );
}
Пример #27
0
TEST( tBridge, AddSimilarPreset )
{
    tDisplayId id1 = { QUuid::createUuid() };
    tDisplayId id2 = { QUuid::createUuid() };
    tPosition position1 = { QPoint( 1, 2 ) };
    tPosition position2 = { QPoint( 3, 4 ) };
    tBridge bridge;
    bridge.SetDisplay( id1, position1 );
    bridge.SetDisplay( id2, position2 );

    tPage page1 = { ePanelLayoutRowLower, QVector<PanelID>() << DATA, 0, 0 };
    tPage page2 = { ePanelLayoutRowLower, QVector<PanelID>() << POSITION, 0, 0 };
    tPreset preset1;
    preset1.SetDisplay( id1, page1 );
    preset1.SetDisplay( id2, page2 );
    tPreset preset2;
    preset2.SetDisplay( id2, page2 ); // similar as preset1, just not the same order
    preset2.SetDisplay( id1, page1 );

    bridge.AddPreset( preset1 );
    bool result = bridge.AddPreset( preset2 );
    EXPECT_TRUE( result );
    QVector<tPreset> presets = bridge.Presets();
    EXPECT_EQ( 2, presets.size() );
    EXPECT_TRUE( presets.contains( preset1 ) );
    EXPECT_TRUE( presets.contains( preset2 ) );
}
Пример #28
0
QVector<int> getIntersect(QVector<int> S1, QVector<int> S2, bool sorted)
{
    QVector<int> result;
    for(int i=0; i<S1.count(); i++)
        if(S2.contains(S1.at(i))) result.append(S1.at(i));
    if(sorted) qStableSort(result);
    return result;
}
Пример #29
0
QVector<int> getUnion(QVector<int> S1, QVector<int> S2, bool sorted)
{
    QVector<int> result = S1;
    for(int i=0; i<S2.count(); i++)
        if(!S1.contains(S2.at(i))) result.append(S2.at(i));

    if(sorted) qStableSort(result);
    return result;
}
Пример #30
0
QVector<QPoint> ImageProcessor::intersection(QVector<QPoint> a, QVector<QPoint> b) {
    QVector<QPoint> returnMe;
    foreach(QPoint check, a) {
        if(b.contains(check)) {
            returnMe.append(check);
        }
    }
    return returnMe;
}