/* Executes program functions. */ int main() { setvbuf(stdout, NULL, _IONBF, 0); int row, col, r1, r2; int matrix1[ROW_SIZE][COL_SIZE]; int matrix2[ROW_SIZE][COL_SIZE]; int mat_trans[ROW_SIZE][COL_SIZE]; for (row = 0; row < ROW_SIZE; row++) { for (col = 0; col < COL_SIZE; col++) { r1 = rand() % 10; r2 = rand() % 10; matrix1[row][col] = r1; matrix2[row][col] = r2; } } printf("\nMatrix1:\n"); displayResults(matrix1); printf("\nMatrix2:\n"); displayResults(matrix2); memcpy(mat_trans, transpose(matrix2), sizeof(int) * ROW_SIZE * COL_SIZE); /* WARNING: passing argument 2 of 'memcpy' makes pointer from integer without a cast [enabled by default] */ multiplyMatrices(matrix1, mat_trans); multiplyMatrices(matrix1, matrix2); return 0; }
int main(void) { float retrDuration = getDuration(); float velocity = computeVelocity(retrDuration, dist); float estimatedDuration = duration(dist, velocity, wind); displayResults(estimatedDuration); return 0; }
void GFODlg::compliantEquilibriumOptimization(bool useDynamicDofForce) { Matrix tau(mHand->staticJointTorques(useDynamicDofForce)); int result = mHand->getGrasp()->computeQuasistaticForces(tau); displayResults(result); }
//----------------------------------------------------------------------- void OverlayProfileSessionListener::displayResults(const ProfileInstance& root, ulong maxTotalFrameTime) { Real newGuiHeight = mGuiHeight; int profileCount = 0; Real maxTimeMillisecs = (Real)maxTotalFrameTime / 1000.0f; ProfileBarList::const_iterator bIter = mProfileBars.begin(); ProfileInstance::ProfileChildren::const_iterator it = root.children.begin(), endit = root.children.end(); for(;it != endit; ++it) { ProfileInstance* child = it->second; displayResults(child, bIter, maxTimeMillisecs, newGuiHeight, profileCount); } // set the main display dimensions mProfileGui->setMetricsMode(GMM_PIXELS); mProfileGui->setHeight(newGuiHeight); mProfileGui->setWidth(mGuiWidth * 2 + 15); mProfileGui->setTop(5); mProfileGui->setLeft(5); // we hide all the remaining pre-created bars for (; bIter != mProfileBars.end(); ++bIter) { (*bIter)->hide(); } }
int main(int argc, char** argv) { initializeWindow(argc, argv, 800, 800); Line *LineHorArray = NULL; Line *LineVertArray = NULL; char filename[255]="input"; printf("Enter file name: \n"); scanf("%s", filename); readInputLines(filename, &LineHorArray, & LineVertArray); printf("Input file is read\n"); Edge * approximation1 = buildLowerBoundApproximationPart(LineHorArray, LineVertArray); Edge * approximation2 = buildLowerBoundApproximationPart(LineVertArray, LineHorArray); printf("Approximation is built\n"); OutSpanningTree spanning_tree = buildSpanningTree(LineHorArray, LineVertArray); printf("Spanning tree is built\n"); displayResults(LineHorArray, LineVertArray, approximation1, approximation2, spanning_tree); return 0; }
/** * This method performs the search and displays * the result to the screen. */ void Kiten::searchAndDisplay( const DictQuery &query ) { /* keep the user informed of what we are doing */ _statusBar->showMessage( i18n( "Searching..." ) ); /* This gorgeous incantation is all that's necessary to fill a DictQuery with a query and an Entrylist with all of the results form all of the requested dictionaries */ EntryList *results = _dictionaryManager.doSearch( query ); /* if there are no results */ if ( results->size() == 0 ) //TODO: check here if the user actually prefers this { //create a modifiable copy of the original query DictQuery newQuery( query ); bool tryAgain = false; do { //by default we don't try again tryAgain = false; //but if the matchtype is changed we try again if ( newQuery.getMatchType() == DictQuery::Exact ) { newQuery.setMatchType( DictQuery::Beginning ); tryAgain = true; } else if ( newQuery.getMatchType() == DictQuery::Beginning ) { newQuery.setMatchType( DictQuery::Anywhere ); tryAgain = true; } //try another search if ( tryAgain ) { delete results; results = _dictionaryManager.doSearch( newQuery ); //results means all is ok; don't try again if ( results->size() > 0 ) { tryAgain = false; } } } while ( tryAgain ); } /* synchronize the history (and store this pointer there) */ addHistory( results ); /* Add the current search to our drop down list */ _inputManager->setSearchQuery( results->getQuery() ); /* suppose it's about time to show the users the results. */ displayResults( results ); }
void GFODlg::tendonRouteOptimization() { if (!mHand->isA("McGrip")) { DBGA("Hand is not a McGrip!"); return; } /* //tendon route optimization Matrix l(6,1); int result = static_cast<McGripGrasp*>(mHand->getGrasp())->tendonRouteOptimization(&l); DBGA("l matrix:\n" << l); */ //tendon and construction optimization with new formulation Matrix p(8,1); double obj; int result = static_cast<McGripGrasp*>(mHand->getGrasp())->tendonAndHandOptimization(&p, obj); DBGA("p matrix:\n" << p); displayResults(result); /* Matrix *a, *B; static_cast<McGrip*>(mHand)->getRoutingMatrices(&B, &a); delete a; delete B; */ }
void BackgroundSuppressionShell::processNextStreamingFrame(Subject &subject, const std::string &signal, const boost::any &data) { AnimationFrame *pFrame = boost::any_cast<AnimationFrame*>(data); if(pFrame != NULL) { mCurrentFrame = pFrame->mFrameNumber; processFrame() && displayResults(); } }
void GFODlg::graspForceOptimization(int computation) { Matrix tau(Matrix::ZEROES<Matrix>(mHand->getNumJoints(),1)); int result = mHand->getGrasp()->computeQuasistaticForcesAndTorques(&tau, computation); if (!result) { DBGA("Optimal joint torques:\n" << tau); } displayResults(result); }
void GFODlg::mcgripEquilibrium() { if (!mHand->isA("McGrip")) { DBGA("Hand is not a McGrip!"); return; } int result = static_cast<McGrip*>(mHand)->jointTorqueEquilibrium(); displayResults(result); }
/** * Search in the previous results, identical to * searchAndDisplay except for the one call. */ void Kiten::searchInResults() { _statusBar->showMessage( i18n( "Searching..." ) ); DictQuery searchQuery = _inputManager->getSearchQuery(); EntryList *results = _dictionaryManager.doSearchInList( searchQuery ,_historyList.current() ); addHistory( results ); _inputManager->setSearchQuery( searchQuery ); displayResults( results ); }
int main() { struct Game *currentGame; currentGame = (struct Game *)malloc(sizeof(struct Game)); // initialize game attributes, set room values, and save rooms to file initGame(currentGame); // display congratulations, step count, and step history path to the user displayResults(currentGame); // exit with value 0 return 0; }
Sorts::Sorts() { // Fills array with random integers of size DATASET generateData(); // Do bubble sort runs for(int i = 0; i < DATARUNS; i++) { // Capture time clock_t t1 = clock(); // Perform bubble sort bubblesort(); //Capture time again clock_t t2 = clock(); // Add run time to result array bubbleSortTimes[i] = timediff(t1, t2); // Reset operating data to originaly generated random numbers to ensure we are // comparing the sorting speed on the exact same random numbers dataReset(); } // Repeat above process for other sorts // Do quick sort runs for(int i = 0; i < DATARUNS; i++) { clock_t t1 = clock(); quickSort(array, 0, DATASET-1); clock_t t2 = clock(); quickSortTimes[i] = timediff(t1, t2); dataReset(); } // Do merge sort runs for(int i = 0; i < DATARUNS; i++) { clock_t t1 = clock(); mergeSort(array, 0, DATASET-1); clock_t t2 = clock(); mergeSortTimes[i] = timediff(t1, t2); dataReset(); } // Display all the results displayResults(); }
int main() { // LOCAL DECLARATION int income; //the original income recieved from main float taxRate; //the taxrate recieved from main // EXECUTABLE STATEMENTS income = getIncome(); // calls the getIncome function taxRate = calcRate(income); //calls the calcRate function displayResults(income,taxRate); return(0); }
int main() { IloEnv env; try { IloModel model(env); setData(env); IloNumVarArray inside(env, nbProds); IloNumVarArray outside(env, nbProds); IloObjective obj = IloAdd(model, IloMinimize(env)); // Must meet demand for each product for(IloInt p = 0; p < nbProds; p++) { IloRange demRange = IloAdd(model, IloRange (env, demand[p], demand[p])); inside[p] = IloNumVar(obj(insideCost[p]) + demRange(1)); outside[p] = IloNumVar(obj(outsideCost[p]) + demRange(1)); } // Must respect capacity constraint for each resource for(IloInt r = 0; r < nbResources; r++) model.add(IloScalProd(consumption[r], inside) <= capacity[r]); IloCplex cplex(env); cplex.extract(model); cplex.solve(); if (cplex.getStatus() != IloAlgorithm::Optimal) cout << "No optimal solution" << endl; cout << "Solution status: " << cplex.getStatus() << endl; displayResults(cplex, inside, outside); cout << "----------------------------------------" << endl; } catch (IloException& ex) { cerr << "Error: " << ex << endl; } catch (...) { cerr << "Error" << endl; } env.end(); return 0; }
/* Multiplies two matrices. */ void multiplyMatrices(int matrix1[][COL_SIZE], int matrix2[][COL_SIZE]) { int row, col, k, sum = 0; int multMatrix[ROW_SIZE][COL_SIZE]; for (row = 0; row < ROW_SIZE; row++) { for (col = 0; col < COL_SIZE; col++) { for (k = 0; k < ROW_SIZE; k++) { sum = sum + matrix1[row][k] * matrix2[k][col]; } multMatrix[row][col] = sum; sum = 0; } } printf("\nProduct of matrices:\n"); displayResults(multMatrix); }
CustomMessageBox::CustomMessageBox(const unsigned short time, const unsigned short note, QWidget* parent) : QDialog(parent, Qt::FramelessWindowHint), _clickOnWindow(false), _type(Results) { this->setAttribute(Qt::WA_TranslucentBackground); _menu = new MinCloseMenu(this); _menu->setStyleSheet("QPushButton#Cross{background-image: url(none);}QPushButton#mini{margin-right: 5px;}QPushButton{background-color: rgba(255, 255, 255, 0);margin: 0px;padding: 0px;}QPushButton:pressed{color: rgb(255,169,50);}"); _label = new QLabel(this); _okBouton = new QPushButton("Ok", this); _okBouton->setAttribute(Qt::WA_TranslucentBackground); _okBouton->setObjectName("OkBouton"); _okBouton->setStyleSheet("QPushButton#OkBouton{background-color: rgba(255, 255, 255, 0);color: rgb(144,191,79);}"); displayResults(time, note); connect(_okBouton, SIGNAL(clicked()), this, SLOT(close())); }
void DCCollector::reconfig( void ) { use_nonblocking_update = param_boolean("NONBLOCKING_COLLECTOR_UPDATE",true); if( ! _addr ) { locate(); if( ! _is_configured ) { dprintf( D_FULLDEBUG, "COLLECTOR address not defined in " "config file, not doing updates\n" ); return; } } parseTCPInfo(); initDestinationStrings(); displayResults(); }
int main(void) { // seed random number function srand ( time(NULL) ); // initiate the weights initWeights(); // load in the data initData(); // train the network for(int j = 0;j <= numEpochs;j++) { for(int i = 0;i<numPatterns;i++) { //select a pattern at random patNum = rand()%numPatterns; //calculate the current network output //and error for this pattern calcNet(); //change network weights WeightChangesHO(); WeightChangesIH(); } //display the overall network error //after each epoch calcOverallError(); printf("epoch = %d RMS Error = %f\n",j,RMSerror); } //training has finished //display the results displayResults(); system("PAUSE"); return 0; }
int main(int argc, char *argv[]) { int parameters[NUM], comm_size, my_rank; long double piEst, approximation = 0.0, start = 0.0, end, a = 0.0, b = 1.0, local_min, local_max; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &comm_size); MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); if(my_rank == 0) { intro(); getParamaters(argv, parameters); start = MPI_Wtime(); } MPI_Bcast(parameters, NUM, MPI_INT, 0, MPI_COMM_WORLD); local_min = a + (b - a) / comm_size * my_rank; local_max = a + (b - a) / comm_size * (my_rank + 1); approximation = calcTrapezoid(local_min, local_max, parameters[0], parameters[1]); MPI_Reduce(&approximation, &piEst, 1, MPI_LONG_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); if(my_rank == 0) { end = MPI_Wtime(); displayResults(parameters[0], parameters[1], piEst, (end - start), comm_size); } MPI_Finalize(); return 0; }
//----------------------------------------------------------------------- void Profiler::displayResults(void) { // if its time to update the display if (!(mCurrentFrame % mUpdateDisplayFrequency)) { Real newGuiHeight = mGuiHeight; int profileCount = 0; Real maxTimeMillisecs = (Real)mMaxTotalFrameTime / 1000.0f; // ensure the root won't be culled mRoot.frame.calls = 1; ProfileBarList::iterator bIter = mProfileBars.begin(); ProfileChildren::iterator it = mRoot.children.begin(), endit = mRoot.children.end(); for(;it != endit; ++it) { ProfileInstance* child = it->second; displayResults(child, bIter, maxTimeMillisecs, newGuiHeight, profileCount); } // set the main display dimensions mProfileGui->setMetricsMode(GMM_PIXELS); mProfileGui->setHeight(newGuiHeight); mProfileGui->setWidth(mGuiWidth * 2 + 15); mProfileGui->setTop(5); mProfileGui->setLeft(5); // we hide all the remaining pre-created bars for (; bIter != mProfileBars.end(); ++bIter) { (*bIter)->hide(); } } ++mCurrentFrame; }
void ApplyMeasureNowDialog::runMeasure() { runmanager::ConfigOptions co(true); if (co.getTools().getAllByName("ruby").tools().size() == 0) { QMessageBox::information(this, "Missing Ruby", "Ruby could not be located.\nOpenStudio will scan for tools.", QMessageBox::Ok); co.findTools(true); openstudio::runmanager::RunManager rm; rm.setConfigOptions(co); rm.showConfigGui(); rm.getConfigOptions().saveQSettings(); emit toolsUpdated(); if (co.getTools().getAllByName("ruby").tools().size() == 0) { QMessageBox::information(this, "Missing Ruby", "Ruby was not located by tool search.\nPlease ensure Ruby correctly installed.\nSimulation aborted.", QMessageBox::Ok); m_mainPaneStackedWidget->setCurrentIndex(m_inputPageIdx); m_timer->stop(); this->okButton()->hide(); this->backButton()->hide(); return; } } m_mainPaneStackedWidget->setCurrentIndex(m_runningPageIdx); m_timer->start(50); this->okButton()->hide(); this->backButton()->hide(); OS_ASSERT(m_model); openstudio::OSAppBase * app = OSAppBase::instance(); m_workingDir = openstudio::toPath(app->currentDocument()->modelTempDir()) / openstudio::toPath("ApplyMeasureNow"); openstudio::path modelPath = m_workingDir / openstudio::toPath("modelClone.osm"); openstudio::path epwPath; // DLM: todo look at how this is done in the run tab removeWorkingDir(); // save cloned model to temp directory m_model->save(modelPath,true); // remove? this is shown only in debug (EW) QString path("Measure Output Location: "); path.append(toQString(m_workingDir)); m_jobPath->setText(path); analysis::RubyMeasure rubyMeasure = m_currentMeasureItem->measure(); // DLM: should be able to assert this bool hasIncompleteArguments = m_currentMeasureItem->hasIncompleteArguments(); OS_ASSERT(!hasIncompleteArguments); runmanager::RubyJobBuilder rjb(*m_bclMeasure, rubyMeasure.arguments()); openstudio::path p = getOpenStudioRubyIncludePath(); QString arg = "-I"; arg.append(toQString(p)); rjb.addToolArgument(arg.toStdString()); openstudio::runmanager::Workflow wf; rjb.addToWorkflow(wf); wf.add(co.getTools()); wf.setInputFiles(modelPath, openstudio::path()); m_job = wf.create(m_workingDir, modelPath); // DLM: you could make rm a class member then you would not have to call waitForFinished here runmanager::RunManager rm; bool queued = rm.enqueue(*m_job, true); OS_ASSERT(queued); std::vector<runmanager::Job> jobs = rm.getJobs(); OS_ASSERT(jobs.size() == 1); rm.waitForFinished (); QTimer::singleShot(0, this, SLOT(displayResults())); }
//----------------------------------------------------------------------- void Profiler::endProfile(const String& profileName, uint32 groupID) { // if the profiler received a request to be enabled or disabled // we reached the end of the frame so we can safely do this if (mEnableStateChangePending) { changeEnableState(); } // if the profiler is enabled if(!mEnabled) { return; } // mask groups if ((groupID & mProfileMask) == 0) { return; } // we only process this profile if isn't disabled DisabledProfileMap::iterator dIter; dIter = mDisabledProfiles.find(profileName); if ( dIter != mDisabledProfiles.end() ) { return; } // need a timer to profile! assert (mTimer && "Timer not set!"); // get the end time of this profile // we do this as close the beginning of this function as possible // to get more accurate timing results ulong endTime = mTimer->getMicroseconds(); // empty string is reserved for designating an empty parent assert ((profileName != "") && ("Profile name can't be an empty string")); // stack shouldn't be empty assert (!mProfiles.empty()); // get the start of this profile ProfileInstance bProfile; bProfile = mProfiles.back(); mProfiles.pop_back(); // calculate the elapsed time of this profile ulong timeElapsed = endTime - bProfile.currTime; // update parent's accumulator if it isn't the root if (bProfile.parent != "") { // find the parent ProfileStack::iterator iter; for(iter = mProfiles.begin(); iter != mProfiles.end(); ++iter) { if ((*iter).name == bProfile.parent) break; } // the parent should be found assert(iter != mProfiles.end()); // add this profile's time to the parent's accumlator (*iter).accum += timeElapsed; } // we find the profile in this frame ProfileFrameList::iterator iter; for (iter = mProfileFrame.begin(); iter != mProfileFrame.end(); ++iter) { if ((*iter).name == bProfile.name) break; } // nested profiles are cumulative (*iter).frameTime += timeElapsed; (*iter).calls++; // the stack is empty and all the profiles have been completed // we have reached the end of the frame so process the frame statistics if (mProfiles.empty()) { // we know that the time elapsed of the main loop is the total time the frame took mTotalFrameTime = timeElapsed; if (timeElapsed > mMaxTotalFrameTime) mMaxTotalFrameTime = timeElapsed; // we got all the information we need, so process the profiles // for this frame processFrameStats(); // clear the frame stats for next frame mProfileFrame.clear(); // we display everything to the screen displayResults(); } }
//----------------------------------------------------------------------- void Profiler::endProfile(const String& profileName, uint32 groupID) { if(!mEnabled) { // if the profiler received a request to be enabled or disabled if(mNewEnableState != mEnabled) { // note mNewEnableState == true to reach this. changeEnableState(); // NOTE we will be in an 'error' state until the next begin. ie endProfile will likely get invoked using a profileName that was never started. // even then, we can't be sure that the next beginProfile will be the true start of a new frame } return; } else { if(mNewEnableState != mEnabled) { // note mNewEnableState == false to reach this. changeEnableState(); // unwind the hierarchy, should be easy enough mCurrent = &mRoot; mLast = NULL; } if(&mRoot == mCurrent && mLast) { // profiler was enabled this frame, but the first subsequent beginProfile was NOT the beinging of a new frame as we had hoped. // we have a bogus ProfileInstance in our hierarchy, we will need to remove it, then update the overlays so as not to confuse ze user // we could use mRoot.children.find() instead of this, except we'd be compairing strings instead of a pointer. // the string way could be faster, but i don't believe it would. ProfileChildren::iterator it = mRoot.children.begin(), endit = mRoot.children.end(); for(;it != endit; ++it) { if(mLast == it->second) { mRoot.children.erase(it); break; } } // with mLast == NULL we won't reach this code, in case this isn't the end of the top level profile ProfileInstance* last = mLast; mLast = NULL; OGRE_DELETE last; processFrameStats(); displayResults(); } } if(&mRoot == mCurrent) return; // mask groups if ((groupID & mProfileMask) == 0) return; // need a timer to profile! assert (mTimer && "Timer not set!"); // get the end time of this profile // we do this as close the beginning of this function as possible // to get more accurate timing results const ulong endTime = mTimer->getMicroseconds(); // empty string is reserved for designating an empty parent assert ((profileName != "") && ("Profile name can't be an empty string")); // we only process this profile if isn't disabled // we check the current instance name against the provided profileName as a guard against disabling a profile name /after/ said profile began if(mCurrent->name != profileName && mDisabledProfiles.find(profileName) != mDisabledProfiles.end()) return; // calculate the elapsed time of this profile const ulong timeElapsed = endTime - mCurrent->currTime; // update parent's accumulator if it isn't the root if (&mRoot != mCurrent->parent) { // add this profile's time to the parent's accumlator mCurrent->parent->accum += timeElapsed; } mCurrent->frame.frameTime += timeElapsed; ++mCurrent->frame.calls; mLast = mCurrent; mCurrent = mCurrent->parent; if (&mRoot == mCurrent) { // the stack is empty and all the profiles have been completed // we have reached the end of the frame so process the frame statistics // we know that the time elapsed of the main loop is the total time the frame took mTotalFrameTime = timeElapsed; if(timeElapsed > mMaxTotalFrameTime) mMaxTotalFrameTime = timeElapsed; // we got all the information we need, so process the profiles // for this frame processFrameStats(); // we display everything to the screen displayResults(); } }
bool BackgroundSuppressionShell::execute(PlugInArgList *pInArgList, PlugInArgList *pOutArgList) { if(pInArgList == NULL) { return false; } mProgress = ProgressTracker(pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg()), "Suppressing background", "temporal", "{01F54B12-0323-4ac4-8C04-C89F1C45EAD9}"); mpRaster = pInArgList->getPlugInArgValue<RasterElement>(Executable::DataElementArg()); if(mpRaster == NULL) { mProgress.report("No raster element specified.", 0, ERRORS, true); return false; } mpView = pInArgList->getPlugInArgValue<SpatialDataView>(Executable::ViewArg()); RasterDataDescriptor *pDescriptor = static_cast<RasterDataDescriptor*>(mpRaster->getDataDescriptor()); VERIFY(pDescriptor != NULL); mIsStreaming = !isBatch(); if(!isBatch()) { BackgroundSuppressionDialog dlg; if(dlg.exec() == QDialog::Rejected) { mProgress.report("Suppression canceled by user.", 0, ABORT, true); return false; } mIsStreaming = dlg.isStreaming(); mpAnimation.reset(dlg.animation()); } unsigned int totalFrames = pDescriptor->getBandCount(); mCurrentFrame = 0; mProgressStep = 25.0 / (totalFrames - mCurrentFrame); mCurrentProgress = mProgressStep; if(!mIsStreaming) { for(InitializeReturnType rval = INIT_CONTINUE; rval == INIT_CONTINUE; mCurrentFrame++) { rval = initializeModel(); if(rval == INIT_ERROR) { return false; } } for(; mCurrentFrame < totalFrames; mCurrentFrame++) { if(isAborted()) { try { mProgress.abort(); } catch(const AlgorithmAbort&) { } cleanup(false); return false; } if(!processFrame()) { cleanup(false); return false; } } if(!displayResults()) { cleanup(false); mProgress.report("Unable to display results.", 0, ERRORS, true); return false; } cleanup(true); mProgress.report("Extraction complete", 100, NORMAL); mProgress.upALevel(); } else { for(InitializeReturnType rval = INIT_CONTINUE; rval == INIT_CONTINUE; mCurrentFrame++) { rval = initializeModel(); if(rval == INIT_ERROR) { return false; } } if(mpAnimation.get() == NULL) { mProgress.report("No animation specified, unable to perform streaming execution. Provide and animation or run in batch mode.", 0, ERRORS, true); return false; } mCurrentFrame = 0; const AnimationFrame *pFrame = mpAnimation->getCurrentFrame(); if(pFrame != NULL) { mCurrentFrame = pFrame->mFrameNumber; } if(!processFrame() || !displayResults()) { mProgress.report("Unable to initialize streaming mode.", 0, ERRORS, true); return false; } mProgress.report("Streaming mode setup complete.", 100, NORMAL); mProgress.upALevel(); mProgress.initialize(NULL, "Suppressing background", "temporal", "{01F54B12-0323-4ac4-8C04-C89F1C45EAD9}"); destroyAfterExecute(false); } return true; }
Multiwin::Multiwin(std::string arg) : QWidget(NULL) { //call on the parser engine = new SearchEng; NewParse* p = new NewParse(); this->parser(arg); engine->add_parse_from_index_file(newIndex, p); std::map<std::string, WebPage*> allPages = engine->getPages(); //setting the title this->setWindowTitle("GOOGLE II"); //fixing placement & width + height this->setGeometry(100,100, 600, 165); //Overall Layout overallLayout = new QVBoxLayout(); //Google Tu image image.load("GoogleTu.png"); imageContainer = new QLabel(); imageContainer->setPixmap(QPixmap::fromImage(image)); overallLayout->addWidget(imageContainer); //searchLayout radioLayout = new QHBoxLayout(); orRadio = new QRadioButton("OR", this); andRadio = new QRadioButton("AND ", this); singleRadio = new QRadioButton("Single", this); singleRadio->setChecked(true); radioLayout->addWidget(singleRadio); radioLayout->addWidget(orRadio); radioLayout->addWidget(andRadio); overallLayout->addLayout(radioLayout); searchLayout = new QHBoxLayout(); //search textbox textSearch = new QLineEdit(); searchLayout->addWidget(textSearch); //search Button searchButton = new QPushButton("Search"); searchLayout->addWidget(searchButton); overallLayout->addLayout(searchLayout); //resultsLayout resultsLayout = new QHBoxLayout(); //QTreeWidget to display the results tree = new QTreeWidget; tree->setColumnCount(4); //setting the header of the TreeWidget QStringList headerLabels; headerLabels.push_back("Filename"); headerLabels.push_back("In Links"); headerLabels.push_back("Out Links"); headerLabels.push_back("Page Rank"); tree->setHeaderLabels(headerLabels); //sorting list button options sortList = new QVBoxLayout(); sortLabel = new QLabel("Sort By: "); fileNameButton = new QPushButton("Filename"); inLinkButton = new QPushButton("InLinks"); outLinkButton = new QPushButton("OutLinks"); pageRankButton = new QPushButton("Page Rank"); sortList->addWidget(sortLabel); sortList->addWidget(pageRankButton); sortList->addWidget(fileNameButton); sortList->addWidget(inLinkButton); sortList->addWidget(outLinkButton); //The results list resultsLayout->addWidget(tree); resultsLayout->addLayout(sortList); //adding the layouts to overallLayout overallLayout->addLayout(resultsLayout); //set the overall layout setLayout(overallLayout); QVBoxLayout* mainLayout = new QVBoxLayout; overallLayout->addLayout(mainLayout); QVBoxLayout* otherLayout = new QVBoxLayout; otherWin = new QWidget; closeButton = new QPushButton("&Close Popup Window"); otherLayout->addWidget(closeButton); exitButton = new QPushButton("&Exit Program"); otherLayout->addWidget(exitButton); overallLayout->addLayout(otherLayout); //otherWin stuff otherWin->setWindowTitle(""); otherWin->setGeometry(300,200, 800, 600); popupLayout = new QVBoxLayout(); fileContent = new QTextEdit(""); popupLayout->addWidget(fileContent); //setting up bottom tier of the popup window; bottom = new QHBoxLayout(); inLayout = new QVBoxLayout(); outLayout = new QVBoxLayout(); sortButtons = new QVBoxLayout(); incomingLabel = new QLabel("Incoming"); inList = new QTreeWidget(); inLayout->addWidget(incomingLabel); QStringList headerLabelsIn; headerLabelsIn.push_back("Filename"); headerLabelsIn.push_back("In Links"); headerLabelsIn.push_back("Out Links"); inList->setHeaderLabels(headerLabelsIn); inLayout->addWidget(inList); sortByLabel = new QLabel("SORT BY:"); fSort = new QPushButton("filename"); iSort = new QPushButton("input files"); oSort = new QPushButton("output files"); sortButtons->addWidget(sortByLabel); sortButtons->addWidget(fSort); sortButtons->addWidget(iSort); sortButtons->addWidget(oSort); outgoingLabel = new QLabel("Outgoing"); outList = new QTreeWidget(); outLayout->addWidget(outgoingLabel); QStringList headerLabelsOut; headerLabelsOut.push_back("Filename"); headerLabelsOut.push_back("In Links"); headerLabelsOut.push_back("Out Links"); outList->setHeaderLabels(headerLabelsOut); outLayout->addWidget(outList); bottom->addLayout(inLayout); bottom->addLayout(sortButtons); bottom->addLayout(outLayout); popupLayout->addLayout(bottom); otherWin->setLayout(popupLayout); QObject::connect(searchButton, SIGNAL(clicked()), this, SLOT(displayResults())); QObject::connect(textSearch, SIGNAL(returnPressed()), this, SLOT(displayResults())); QObject::connect(closeButton, SIGNAL(clicked()), this, SLOT(otherButtonClicked())); QObject::connect(fileNameButton, SIGNAL(clicked()), this, SLOT(fileSort())); QObject::connect(inLinkButton, SIGNAL(clicked()), this, SLOT(inSort())); QObject::connect(outLinkButton, SIGNAL(clicked()), this, SLOT(outSort())); QObject::connect(pageRankButton, SIGNAL(clicked()), this, SLOT(prSort())); //pop up window QObject::connect(fSort, SIGNAL(clicked()), this, SLOT(popFSort())); QObject::connect(iSort, SIGNAL(clicked()), this, SLOT(popISort())); QObject::connect(oSort, SIGNAL(clicked()), this, SLOT(popOSort())); QObject::connect(inList, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(changeInLists(QTreeWidgetItem*))); QObject::connect(outList, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(changeOutLists(QTreeWidgetItem*))); QObject::connect(tree, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(mainButtonClicked())); QObject::connect(exitButton, SIGNAL(clicked()), this, SLOT(close())); }
/*! * \brief Processor::run */ void VideoProcessor::run() { QVector<int> lightPixelsNumbers; QVector<double> lightPixelsMeans; QVector<double> timeStamps; if(autodetection){ emit detection(); QRect rect = lightDetector->detectLight(filename, qMakePair(range.first, range.second)); if(stop){ stop = false; return; } imageProcessor->setBounds(rect); emit rectChanged(rect); } CaptureWrapper capture(filename); try{ capture.isOpened(); int frameNumber = int(capture.get(CV_CAP_PROP_FRAME_COUNT)); int fps = Utils::Video::getAVIFPS(filename.toStdString()); lightDetector->fixRange(range, fps, frameNumber); if(range.first >= range.second && range.first > std::numeric_limits<double>::epsilon() && range.second > std::numeric_limits<double>::epsilon()){ return; } int absIndex = 0; for(int i = 0; i < int(range.first * fps); ++i, ++absIndex){ capture.grab(); } cv::Mat frame; for(int i = int(range.first * fps); i < int(range.second * fps); i++){ if (stop) { stop = false; break; } capture >> frame; cv::Mat grayFrame; cv::cvtColor(frame, grayFrame, CV_BGR2GRAY, 1); cv::flip(grayFrame, grayFrame, 0); QPair<int, double> processingResult; if(imageProcessor){ imageProcessor->setH_size(QSize(640, 480)); processingResult = imageProcessor->process(grayFrame); }else{ QMessageBox::critical(0, "Error", "No image processor is set!\nContact with developer!"); processingResult = qMakePair(0, 0.0l); } lightPixelsNumbers.push_back(processingResult.first); lightPixelsMeans.push_back(processingResult.second); absIndex++; int relIndex = absIndex - int(range.first * fps); const int hundreds = int((range.second - range.first) * fps) / 100; if (hundreds && !(relIndex % (hundreds))) { emit progress(relIndex / (hundreds)); } double timestamp = absIndex / double(fps); timeStamps.push_back(timestamp); emit time(timestamp); QThread::currentThread()->usleep(50); } std::shared_ptr<Results> results(new Results); results->resultsNumbers = lightPixelsNumbers; results->resultMeans = lightPixelsMeans; results->timeStamps = timeStamps; emit displayResults(results); emit progress(100); } catch(CaptureError e){ QMessageBox::critical(0, "Error", e.getMessage()); return; } }
/* Pobiera tekst ze standardowego wejscia, justuje w dwoch kolumnach i wysyla na standardowe wejscie. Wymaga 4 parametrow: 1: dlugosc lewego marginesu, 2: dlugosc lewej kolumny (niezerowa), 3: dlugosc odstepu miedzy kolumnami, 4: dlugosc prawej kolumny (niezerowa). Suma wartosci parametrow nie moze byc wieksza niz ustawiona dlugosc wiersza konsoli (stala LineLength). Slowa musza miescic sie w przydzielonych im kolumnach. W przeciwnym razie wykonywanie programu zostaje przerwane. Wyrazy pobierane sa az do napotkania znaku konca pliku (EOF). */ int main (int argc, char *argv[]) { /* Lista wierszy. */ LinesHandler *Lines; int /* Zrzutowane wartosci parametrow programu. */ Margin, S1, Distance, S2, /* Wynik testu poprawnosci sprawdzanej liczby wierszy. */ LinesNoCorrectness, /* Okresla czy kolumny sie "spotkaly" (podczas wypelniania ich wyrazami). */ LinesMet = 0, /* Ostateczna liczba kolumn <= MaxLinesNo - warunek poprawnosci bedzie spr. dla l. wierszy = MaxLinesNo i mniejszych. */ MaxLinesNo = 0, Iterator; /* Lista wyrazow. */ WordsHandler *Words; /* Alokowanie pamieci na liste wyrazow. */ Words = (WordsHandler*) malloc (sizeof (WordsHandler)); if (Words == NULL) { printf ("Memory allocation error!\n"); return 0; } Words->First = NULL; Words->Last = NULL; /* Alokowanie pamieci na liste wierszy. */ Lines = (LinesHandler*) malloc (sizeof (LinesHandler)); if (Lines == NULL) { printf ("Memory allocation error!\n"); free (Words); return 0; } Lines->First = NULL; /* Sprawdzenie czy podano wymagana liczbe paramentrow. */ if (argc != 5) { printf ("Invalid number of parameters!\n"); return 0; } /* Przypisanie wartosci parametrcw do zmiennych. */ Margin = (int) atoi (argv [1]); S1 = (int) atoi (argv [2]); Distance = (int) atoi (argv [3]); S2 = (int) atoi (argv [4]); /* Sprawdzenie czy wartosci parametrow spelniaja przypisane im wymagania. */ if (S1 == 0 || S2 == 0) { printf ("Lines' length mustn't be egual to 0!\n"); return 0; } else if (Margin < 0 || S1 < 0 || Distance < 0 || S2 < 0) { printf ("None parameter can be less than 0!\n"); return 0; } else if (Margin + S1 + Distance + S2 > LineLength) { printf ("Margin + Col 1st length + Distance + Col 2nd length must be less or equal to %d!\n", LineLength); return 0; } /* Wczytuje slowa i sprawdza, czy mozliwe jest dla nich wykonanie kodu (slowa mieszcza sie w kolumnach etc.). */ if (!readWords (Words, S1, S2)) { freeMemory (Lines, Words); return 0; } /* Obsluga sytuacji gdy wprowadzony tekst to pojednyczy wyraz. */ if (Words->First->Next == NULL) { if (Words->First->Length <= S1) { for (Iterator = 0; Iterator < Margin; Iterator++) printf (" "); printf ("%s\n", Words->First->Content); } else printf ("The word is too long!"); freeMemory (Lines, Words); return 0; } /* Obliczanie gornego ograniczenia dla szukanej liczby wierszy. */ MaxLinesNo = calculateMaxLinesNo (Words, S1, S2); do { LinesNoCorrectness = checkColumnsCorrectness (Words, S1, S2, MaxLinesNo); switch (LinesNoCorrectness) { /* Dla podanych danych co najmniej jeden z wyrazow nie miesci sie w wyznaczonym miejscu. */ case -2: printf ("At least one of words was too long!\n"); freeMemory (Lines, Words); return 0; /* Nie istnieje rozwiazanie spelniajace podane zalozenia. */ case -1: printf ("Proper justification wasn't possible!\n"); freeMemory (Lines, Words); return 0; /* Podana liczba wierszy jest zbyt wysoka - nalezy sprawdzix nizsze wartosci. */ case 0: MaxLinesNo--; continue; /* Znaleziono szukano liczbe wierszy - przygotowanie kolumn i wyswietleniee wynikow. */ case 1: /* Czasem zachodzi sytuacja gdy funkcja sprawdzajaca daje poprawne wyniki dla wiecej niz 1 wartosci. Wtedy wybierana jest najmniejsza. */ while (checkColumnsCorrectness (Words, S1, S2, MaxLinesNo-1) == 1) MaxLinesNo--; if (makeColumns (Lines, Words, S1, S2, MaxLinesNo)) displayResults (Lines, Margin, Distance); else printf ("Memory allocation error!\n"); break; } } while (LinesNoCorrectness == 0); /* Poki liczba wierszy jest zbyt duza, nalezy ja zmniejszac. Znalezienie rozwiazania (lub stwierdzenie jego braku) przeywa petle. */ /* Zwalnia pamiec przed zakonczeniem programu. */ freeMemory (Lines, Words); return 0; }
//----------------------------------------------------------------------- void OverlayProfileSessionListener::displayResults(ProfileInstance* instance, ProfileBarList::const_iterator& bIter, Real& maxTimeMillisecs, Real& newGuiHeight, int& profileCount) { OverlayElement* g; // display the profile's name and the number of times it was called in a frame g = *bIter; ++bIter; g->show(); g->setCaption(String(instance->name + " (" + StringConverter::toString(instance->history.numCallsThisFrame) + ")")); g->setLeft(10 + instance->hierarchicalLvl * 15.0f); // display the main bar that show the percentage of the frame time that this // profile has taken g = *bIter; ++bIter; g->show(); // most of this junk has been set before, but we do this to get around a weird // Ogre gui issue (bug?) g->setMetricsMode(GMM_PIXELS); g->setHeight(mBarHeight); if (mDisplayMode == DISPLAY_PERCENTAGE) g->setWidth( (instance->history.currentTimePercent) * mGuiWidth); else g->setWidth( (instance->history.currentTimeMillisecs / maxTimeMillisecs) * mGuiWidth); g->setLeft(mGuiWidth); g->setTop(mGuiBorderWidth + profileCount * (mBarHeight + mBarSpacing)); // display line to indicate the minimum frame time for this profile g = *bIter; ++bIter; g->show(); if(mDisplayMode == DISPLAY_PERCENTAGE) g->setLeft(mBarIndent + instance->history.minTimePercent * mGuiWidth); else g->setLeft(mBarIndent + (instance->history.minTimeMillisecs / maxTimeMillisecs) * mGuiWidth); // display line to indicate the maximum frame time for this profile g = *bIter; ++bIter; g->show(); if(mDisplayMode == DISPLAY_PERCENTAGE) g->setLeft(mBarIndent + instance->history.maxTimePercent * mGuiWidth); else g->setLeft(mBarIndent + (instance->history.maxTimeMillisecs / maxTimeMillisecs) * mGuiWidth); // display line to indicate the average frame time for this profile g = *bIter; ++bIter; g->show(); if(instance->history.totalCalls != 0) { if (mDisplayMode == DISPLAY_PERCENTAGE) g->setLeft(mBarIndent + (instance->history.totalTimePercent / instance->history.totalCalls) * mGuiWidth); else g->setLeft(mBarIndent + ((instance->history.totalTimeMillisecs / instance->history.totalCalls) / maxTimeMillisecs) * mGuiWidth); } else g->setLeft(mBarIndent); // display text g = *bIter; ++bIter; g->show(); if (mDisplayMode == DISPLAY_PERCENTAGE) { g->setLeft(mBarIndent + instance->history.currentTimePercent * mGuiWidth + 2); g->setCaption(StringConverter::toString(instance->history.currentTimePercent * 100.0f, 3, 3) + "%"); } else { g->setLeft(mBarIndent + (instance->history.currentTimeMillisecs / maxTimeMillisecs) * mGuiWidth + 2); g->setCaption(StringConverter::toString(instance->history.currentTimeMillisecs, 3, 3) + "ms"); } // we set the height of the display with respect to the number of profiles displayed newGuiHeight += mBarHeight + mBarSpacing; ++profileCount; // display children ProfileInstance::ProfileChildren::const_iterator it = instance->children.begin(), endit = instance->children.end(); for(;it != endit; ++it) { ProfileInstance* child = it->second; displayResults(child, bIter, maxTimeMillisecs, newGuiHeight, profileCount); } }
int main() { int menu0ChosenOption = menu0(); while (menu0ChosenOption == 2) { long backupCount = 0; char** backupNames = getBackupList(&backupCount); if (backupCount != 0) { int backupSelected = selectBackup(backupNames, backupCount); char command[MAX_PATH]; sprintf(command,"xcopy /y \"%s\" pad00000.meta",backupNames[backupSelected]); system(command); } else { printf("No backup was found"); } printf("\n"); system("PAUSE"); menu0ChosenOption = menu0(); } if (menu0ChosenOption != EXIT) { int menu1ChosenOption = menu1(); regionSelected = menu1ChosenOption - 1; initProgram(); // This calls the Meta Injector, but it also calls the Meta Patcher inside it, so the whole program runs by this call runMetaInjector(); runMetaPatcher(); displayResults(); int menu2ChosenOption = menu2(); if (menu2ChosenOption == 1) { printf("\nCopying Files..."); copyFiles(FILES_TO_PATCH_FOLDER_NAME,bdoRootFolder); printf("\nDone.\n"); } else if (menu2ChosenOption == 2) { printf("\nMoving Files..."); moveFiles(FILES_TO_PATCH_FOLDER_NAME,bdoRootFolder); printf("\nDone.\n"); } if (menu2ChosenOption != EXIT) { printf("\n"); system("PAUSE"); } } return 0; }