//----------------------------------------------------------------------------- void VisibleBspLeavesSearch::run() { startSearching(); enumVisibleBspLeaves(); endSearching(); addBspEntityToRenderQueue(); }
int main(int argc, char* argv[]) { int recordsToRead; int fileDesc; if(argc != 5) { printf("Wrong number of arguments!\n"); printf("You have to pass: number of threads, filename, number of records, text to find.\n"); exit(EXIT_FAILURE); } numberOfThreads = atoi(argv[1]); recordsToRead = atoi(argv[3]); if((fileDesc = open(argv[2], O_RDONLY)) == -1) { printf("Error while opening the file!\n"); return EXIT_FAILURE; } threadsID = malloc(sizeof(pthread_t)*numberOfThreads); threadArgs args; args.fileDesc = fileDesc; args.recordsNumber = recordsToRead; args.text = argv[4]; startSearching(numberOfThreads, args); close(fileDesc); return EXIT_SUCCESS; }
void KGrEnemy::dieAndReappear() { bool looking; int i; if (nuggets > 0) { nuggets = 0; // Enemy died and could not drop nugget. emit lostNugget(); // NO SCORE for lost nugget. } emit killed (75); // Killed an enemy: score 75. if (reappearAtTop) { // Follow Traditional rules: enemies reappear at top. looking = TRUE; y = 2; // Randomly look for a free spot in row 2. Limit the number of tries. for (i = 1; ((i <= 3) && looking); i++) { x = (int)((FIELDWIDTH * (float) rand()) / RAND_MAX) + 1; switch ((*playfield)[x][2]->whatIam()) { case FREE: case HLADDER: looking = FALSE; break; default: break; } } // If unsuccessful, choose the first free spot in row 3 or below. while ((y<FIELDHEIGHT) && looking) { y++; x = 0; while ((x<FIELDWIDTH) && looking) { x++; switch ((*playfield)[x][y]->whatIam()) { case FREE: case HLADDER: looking = FALSE; break; default: break; } } } } else { // Follow KGoldrunner rules: enemies reappear where they started. x = birthX; y = birthY; } // Enemy reappears and starts searching for the hero. startSearching(); }
FindImageInstance::FindImageInstance(const ActionTools::ActionDefinition *definition, QObject *parent) : ActionTools::ActionInstance(definition, parent), mOpenCVAlgorithms(new ActionTools::OpenCVAlgorithms(this)), mMethod(CorrelationCoefficientMethod), mWindowRelativePosition(false), mConfidenceMinimum(0), mSource(ScreenshotSource), mMaximumMatches(1), mDownPyramidCount(0), mSearchExpansion(0) { connect(mOpenCVAlgorithms, SIGNAL(finished(ActionTools::MatchingPointList)), this, SLOT(searchFinished(ActionTools::MatchingPointList))); connect(&mWaitTimer, SIGNAL(timeout()), this, SLOT(startSearching())); mWaitTimer.setSingleShot(true); }
void FindImageInstance::startExecution() { bool ok = true; mSource = evaluateListElement<Source>(ok, sources, QStringLiteral("source")); mImageToFind = evaluateImage(ok, QStringLiteral("imageToFind")); mIfFound = evaluateIfAction(ok, QStringLiteral("ifFound")); mIfNotFound = evaluateIfAction(ok, QStringLiteral("ifNotFound")); mPositionVariableName = evaluateVariable(ok, QStringLiteral("position")); mMethod = evaluateListElement<Method>(ok, methods, QStringLiteral("method")); mWindowRelativePosition = evaluateBoolean(ok, QStringLiteral("windowRelativePosition")); mConfidenceMinimum = evaluateInteger(ok, QStringLiteral("confidenceMinimum")); mMaximumMatches = evaluateInteger(ok, QStringLiteral("maximumMatches")); mDownPyramidCount = evaluateInteger(ok, QStringLiteral("downPyramidCount")); mSearchExpansion = evaluateInteger(ok, QStringLiteral("searchExpansion")); mConfidenceVariableName = evaluateVariable(ok, QStringLiteral("confidence")); mSearchDelay = evaluateInteger(ok, QStringLiteral("searchDelay")); if(!ok) return; validateParameterRange(ok, mConfidenceMinimum, QStringLiteral("confidenceMinimum"), tr("minimum confidence"), 0, 100); validateParameterRange(ok, mMaximumMatches, QStringLiteral("maximumMatches"), tr("maximum matches"), 1); validateParameterRange(ok, mDownPyramidCount, QStringLiteral("downPyramidCount"), tr("downsampling"), 1); validateParameterRange(ok, mSearchExpansion, QStringLiteral("searchExpansion"), tr("search expansion"), 1); if(!ok) return; if(mImageToFind.isNull()) { emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid image to find")); return; } startSearching(); }
DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) : QWidget(parent), m_topLayout(0), m_urlNavigator(0), m_searchBox(0), m_view(0), m_filterBar(0), m_statusBar(0), m_statusBarTimer(0), m_statusBarTimestamp() { hide(); m_topLayout = new QVBoxLayout(this); m_topLayout->setSpacing(0); m_topLayout->setMargin(0); m_urlNavigator = new KUrlNavigator(DolphinSettings::instance().placesModel(), url, this); connect(m_urlNavigator, SIGNAL(urlsDropped(const KUrl&, QDropEvent*)), this, SLOT(dropUrls(const KUrl&, QDropEvent*))); connect(m_urlNavigator, SIGNAL(activated()), this, SLOT(activate())); connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)), this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion))); const GeneralSettings* settings = DolphinSettings::instance().generalSettings(); m_urlNavigator->setUrlEditable(settings->editableUrl()); m_urlNavigator->setShowFullPath(settings->showFullPath()); m_urlNavigator->setHomeUrl(KUrl(settings->homeUrl())); KUrlComboBox* editor = m_urlNavigator->editor(); editor->setCompletionMode(KGlobalSettings::Completion(settings->urlCompletionMode())); m_searchBox = new DolphinSearchBox(this); m_searchBox->hide(); connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox())); connect(m_searchBox, SIGNAL(search(QString)), this, SLOT(startSearching(QString))); connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus())); m_view = new DolphinView(url, this); connect(m_view, SIGNAL(urlChanged(const KUrl&)), m_urlNavigator, SLOT(setUrl(const KUrl&))); connect(m_view, SIGNAL(writeStateChanged(bool)), this, SIGNAL(writeStateChanged(bool))); connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(showItemInfo(KFileItem))); connect(m_view, SIGNAL(errorMessage(const QString&)), this, SLOT(showErrorMessage(const QString&))); connect(m_view, SIGNAL(infoMessage(const QString&)), this, SLOT(showInfoMessage(const QString&))); connect(m_view, SIGNAL(itemTriggered(KFileItem)), this, SLOT(slotItemTriggered(KFileItem))); connect(m_view, SIGNAL(redirection(KUrl, KUrl)), this, SLOT(redirect(KUrl, KUrl))); connect(m_view, SIGNAL(startedPathLoading(KUrl)), this, SLOT(slotStartedPathLoading())); connect(m_view, SIGNAL(finishedPathLoading(KUrl)), this, SLOT(slotFinishedPathLoading())); connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(delayedStatusBarUpdate())); connect(m_view, SIGNAL(pathLoadingProgress(int)), this, SLOT(updateProgress(int))); connect(m_view, SIGNAL(infoMessage(const QString&)), this, SLOT(showInfoMessage(const QString&))); connect(m_view, SIGNAL(errorMessage(const QString&)), this, SLOT(showErrorMessage(const QString&))); connect(m_view, SIGNAL(urlIsFileError(const KUrl&)), this, SLOT(openFile(const KUrl&))); connect(m_view, SIGNAL(selectionChanged(const KFileItemList&)), this, SLOT(delayedStatusBarUpdate())); connect(m_view, SIGNAL(operationCompletedMessage(const QString&)), this, SLOT(showOperationCompletedMessage(const QString&))); connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)), this, SLOT(slotUrlNavigatorLocationChanged(const KUrl&))); connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(const KUrl&)), this, SLOT(saveViewState())); connect(m_urlNavigator, SIGNAL(historyChanged()), this, SLOT(slotHistoryChanged())); // initialize status bar m_statusBar = new DolphinStatusBar(this, m_view); connect(m_statusBar, SIGNAL(stopPressed()), this, SLOT(stopLoading())); m_statusBarTimer = new QTimer(this); m_statusBarTimer->setSingleShot(true); m_statusBarTimer->setInterval(300); connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self(); connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)), this, SLOT(delayedStatusBarUpdate())); // initialize filter bar m_filterBar = new FilterBar(this); m_filterBar->setVisible(settings->filterBar()); connect(m_filterBar, SIGNAL(filterChanged(const QString&)), this, SLOT(setNameFilter(const QString&))); connect(m_filterBar, SIGNAL(closeRequest()), this, SLOT(closeFilterBar())); connect(m_view, SIGNAL(urlChanged(const KUrl&)), m_filterBar, SLOT(clear())); m_topLayout->addWidget(m_urlNavigator); m_topLayout->addWidget(m_searchBox); m_topLayout->addWidget(m_view); m_topLayout->addWidget(m_filterBar); m_topLayout->addWidget(m_statusBar); setSearchModeEnabled(isSearchUrl(url)); }