void CoreConnection::syncToCore(const Protocol::SessionState &sessionState) { setProgressText(tr("Receiving network states")); updateProgress(0, 100); // create identities foreach(const QVariant &vid, sessionState.identities) { Client::instance()->coreIdentityCreated(vid.value<Identity>()); } // create buffers // FIXME: get rid of this crap -- why? NetworkModel *networkModel = Client::networkModel(); Q_ASSERT(networkModel); foreach(const QVariant &vinfo, sessionState.bufferInfos) networkModel->bufferUpdated(vinfo.value<BufferInfo>()); // create BufferItems // prepare sync progress thingys... // FIXME: Care about removal of networks _numNetsToSync = sessionState.networkIds.count(); updateProgress(0, _numNetsToSync); // create network objects foreach(const QVariant &networkid, sessionState.networkIds) { NetworkId netid = networkid.value<NetworkId>(); if (Client::network(netid)) continue; Network *net = new Network(netid, Client::instance()); _netsToSync.insert(net); connect(net, SIGNAL(initDone()), SLOT(networkInitDone())); connect(net, SIGNAL(destroyed()), SLOT(networkInitDone())); Client::addNetwork(net); } checkSyncState(); }
void SceneModeler::calculateClasses(){ setProgressText("calculate classes"); this->means = new vector<double>; double min = 0; double max = 0; for(unsigned int i = 0; i < this->sceneLimits->size();i++){ int next = (i != this->sceneLimits->size()-1) ? (*this->sceneLimits)[i+1]-1 : Ub(this->m_ptrData->getTrace()); this->means->push_back(_double(this->m_ptrData->getMeanSlice((*this->sceneLimits)[i],next))); min = ((*this->means)[i] < min || min == 0) ? (*this->means)[i] : min; max = ((*this->means)[i] > max) ? (*this->means)[i] : max; setProgressValue(26 + (int)( (double)( 10.0 / this->sceneLimits->size()) * i)); } this->numClasses = (int) floor((max - min) / _double(this->m_ptrData->getStandardDeviation())); double step = ((double)max - (double)min) / this->numClasses; this->classes = new vector< vector<int> >(this->numClasses); for(unsigned int i = 0; i < this->means->size();i++){ if((*this->means)[i] != max){ (*this->classes)[(int) floor(((*this->means)[i] - (double)min) / step)].push_back(i); } else{ (*this->classes)[(int) floor(((*this->means)[i] - (double)min) / step)-1].push_back(i); } setProgressValue(36 + (int)( (double) ( 15.0 / this->means->size()) * i)); } }
void CoreConnection::checkSyncState() { if (_netsToSync.isEmpty() && state() >= Synchronizing) { setState(Synchronized); setProgressText(tr("Synchronized to %1").arg(currentAccount().accountName())); setProgressMaximum(-1); emit synchronized(); } }
SSMProcess* SceneModeler::compute(){ setProgressText("starting computation"); setProgressMax(100); setProgressValue(1); this->captureSceneLimits(); this->calculateClasses(); this->computeIndexSequence(); for(int i = Lb(*this->transitionDataStates); i <= Ub(*this->transitionDataStates); i++){ (*this->transitionDataStates)[i] += 1; } intvector rv(Lb(*this->transitionDataStates) , Ub(*this->transitionDataStates) ); for(int i = Lb(rv) ; i <= Ub(rv) ; i++){ rv[i] = (*this->transitionDataStates)[i]; } setProgressText("creating model"); return modelFromIndexSequence(rv); }
OSStatus dialogHandler(EventHandlerCallRef handler, EventRef event, void *userdata) { OSStatus result = eventNotHandledErr; OSStatus err; UInt32 evtClass = GetEventClass(event); UInt32 evtKind = GetEventKind(event); if((evtClass == kEventClassCommand) && (evtKind == kEventCommandProcess)) { HICommand cmd; err = GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(cmd), NULL, &cmd); if(err == noErr) { switch(cmd.commandID) { case kHICommandCancel: gCancelled = true; // QuitAppModalLoopForWindow(gWindow); result = noErr; break; } } } else if((evtClass == kEventClassCustom) && (evtKind == kEventCustomProgress)) { // Request to update the progress dialog long cur = 0; long max = 0; CFStringRef text = NULL; (void) GetEventParameter(event, kEventParamCustomCurValue, typeLongInteger, NULL, sizeof(cur), NULL, &cur); (void) GetEventParameter(event, kEventParamCustomMaxValue, typeLongInteger, NULL, sizeof(max), NULL, &max); (void) GetEventParameter(event, kEventParamCustomText, typeCFStringRef, NULL, sizeof(text), NULL, &text); err = setProgress(cur, max); if(err == noErr) { if(text != NULL) { setProgressText(text); } } result = noErr; } else if((evtClass == kEventClassCustom) && (evtKind == kEventCustomDone)) { // We're done. Exit the modal loop. QuitAppModalLoopForWindow(gWindow); result = noErr; } return(result); }
/****************************************************************************** * Performs the actual analysis. This method is executed in a worker thread. ******************************************************************************/ void CreateBondsModifier::BondsEngine::perform() { setProgressText(tr("Generating bonds")); // Determine maximum cutoff. FloatType maxCutoff = _uniformCutoff; if(_particleTypes) { OVITO_ASSERT(_particleTypes->size() == _positions->size()); for(const auto& innerList : _pairCutoffs) for(const auto& cutoff : innerList) if(cutoff > maxCutoff) maxCutoff = cutoff; } // Prepare the neighbor list. CutoffNeighborFinder neighborFinder; if(!neighborFinder.prepare(maxCutoff, _positions.data(), _simCell, this)) return; // Generate (half) bonds. size_t particleCount = _positions->size(); setProgressRange(particleCount); if(!_particleTypes) { for(size_t particleIndex = 0; particleIndex < particleCount; particleIndex++) { for(CutoffNeighborFinder::Query neighborQuery(neighborFinder, particleIndex); !neighborQuery.atEnd(); neighborQuery.next()) { _bonds->push_back({ neighborQuery.unwrappedPbcShift(), (unsigned int)particleIndex, (unsigned int)neighborQuery.current() }); } // Update progress indicator. if((particleIndex % 4096) == 0) { setProgressValue(particleIndex); if(isCanceled()) return; } } } else { for(size_t particleIndex = 0; particleIndex < particleCount; particleIndex++) { for(CutoffNeighborFinder::Query neighborQuery(neighborFinder, particleIndex); !neighborQuery.atEnd(); neighborQuery.next()) { int type1 = _particleTypes->getInt(particleIndex); int type2 = _particleTypes->getInt(neighborQuery.current()); if(type1 >= 0 && type1 < (int)_pairCutoffs.size() && type2 >= 0 && type2 < (int)_pairCutoffs[type1].size()) { if(neighborQuery.distanceSquared() <= _pairCutoffs[type1][type2]) _bonds->push_back({ neighborQuery.unwrappedPbcShift(), (unsigned int)particleIndex, (unsigned int)neighborQuery.current() }); } } // Update progress indicator. if((particleIndex % 4096) == 0) { setProgressValue(particleIndex); if(isCanceled()) return; } } } setProgressValue(particleCount); }
void CoreConnection::onLoginSuccessful(const CoreAccount &account) { updateProgress(0, 0); // save current account data accountModel()->createOrUpdateAccount(account); accountModel()->save(); _reconnectTimer.stop(); setProgressText(tr("Receiving session state")); setState(Synchronizing); emit connectionMsg(tr("Synchronizing to %1...").arg(account.accountName())); }
/*! \fn FutureProgress::FutureProgress(QWidget *parent) \internal */ FutureProgress::FutureProgress(QWidget *parent) : QWidget(parent), d(new FutureProgressPrivate(this)) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); layout->addWidget(d->m_progress); layout->setMargin(0); layout->setSpacing(0); layout->addLayout(d->m_widgetLayout); d->m_widgetLayout->setContentsMargins(7, 0, 7, 2); d->m_widgetLayout->setSpacing(0); connect(&d->m_watcher, SIGNAL(started()), this, SLOT(setStarted())); connect(&d->m_watcher, SIGNAL(finished()), this, SLOT(setFinished())); connect(&d->m_watcher, SIGNAL(canceled()), this, SIGNAL(canceled())); connect(&d->m_watcher, SIGNAL(progressRangeChanged(int,int)), this, SLOT(setProgressRange(int,int))); connect(&d->m_watcher, SIGNAL(progressValueChanged(int)), this, SLOT(setProgressValue(int))); connect(&d->m_watcher, SIGNAL(progressTextChanged(QString)), this, SLOT(setProgressText(QString))); connect(d->m_progress, SIGNAL(clicked()), this, SLOT(cancel())); }
void SceneModeler::captureSceneLimits(){ this->sceneLimits = new vector<int>; this->sceneLimits->push_back(0); vector<real> vk; rvector trace = m_ptrData->getTrace(); SetLb(trace,0); setProgressText("caputre scenelimits"); for(int i = 0;i <= Ub(trace);i++){ vk.push_back(this->m_ptrData->getVariationCoefficientSlice(this->sceneLimits->back(),i)); int last = this->sceneLimits->back(); if( (i-last) >= 1 ){ if(((i-last+1) * abs(vk[i] - vk[i-1])) > this->threshold){ this->sceneLimits->push_back(i); vk[i] = this->m_ptrData->getVariationCoefficientSlice(this->sceneLimits->back(),i); } } setProgressValue( 1+ (int)( (double) (25.0 / Ub(trace) )) * i ); } }
void LoadingState::loadModuleData() { const int SCREEN_WIDTH = _gameEngine->getUIManager()->getScreenWidth(); const int SCREEN_HEIGHT = _gameEngine->getUIManager()->getScreenHeight(); setProgressText("Tidying some space...", 0); //Make sure all data is cleared first game_quit_module(); setProgressText("Calculating some math...", 10); BillboardSystem::get().reset(); //initialize math objects make_turntosin(); // Linking system setProgressText("Initializing module linking... ", 20); if (!link_build_vfs( "mp_data/link.txt", LinkList)) Log::get().warn("Failed to initialize module linking\n"); // initialize the collision system setProgressText("Beautifying graphics...", 40); // Reset all loaded "profiles" in the "profile system". ProfileSystem::get().reset(); // do some graphics initialization gfx_system_make_enviro(); //Load players if needed if(!_playersToLoad.empty()) { setProgressText("Loading players...", 50); if(!loadPlayers()) { Log::get().warn("Failed to load players!\n"); endState(); return; } } // try to start a new module setProgressText("Loading module data...", 60); if(!game_begin_module(_loadModule)) { Log::get().warn("Failed to load module!\n"); endState(); return; } _currentModule->setImportPlayers(_playersToLoad); setProgressText("Almost done...", 90); // set up the cameras *after* game_begin_module() or the player devices will not be initialized // and camera_system_begin() will not set up thte correct view std::shared_ptr<CameraSystem> cameraSystem = CameraSystem::request(local_stats.player_count); // Fade out music when finished loading AudioSystem::get().stopMusic(); // make sure the per-module configuration settings are correct config_synch(&egoboo_config_t::get(), true, false); // Complete! setProgressText("Finished!", 100); // Hit that gong AudioSystem::get().playSoundFull(AudioSystem::get().getGlobalSound(GSND_GAME_READY)); //1 second delay to let music finish, this prevents a frame lag on module startup std::this_thread::sleep_for(std::chrono::seconds(2)); //Add the start button once we are finished loading std::shared_ptr<Button> startButton = std::make_shared<Button>("Press Space to begin", SDLK_SPACE); startButton->setSize(400, 30); startButton->setPosition(SCREEN_WIDTH/2 - startButton->getWidth()/2, SCREEN_HEIGHT-50); startButton->setOnClickFunction( [cameraSystem]{ //Have to do this function in the OpenGL context thread or else it will fail Ego::Graphics::TextureAtlasManager::get().loadTileSet(); //Hush gong AudioSystem::get().fadeAllSounds(); _gameEngine->setGameState(std::make_shared<PlayingState>(cameraSystem)); }); addComponent(startButton); //Hide the progress bar _progressBar->setVisible(false); }
void SceneModeler::computeIndexSequence(){ setProgressText("compute index sequence"); rvector rawData(m_ptrData->getTrace()); int menge = 0; for(unsigned int i = 0;i < this->classes->size(); i++){ if((*this->classes)[i].size() != 0){ menge += 1; } } this->classTraces = new vector< Trace* >; this->classData = new vector< vector <double>* >(menge); this->transitionDataClasses = new vector< int >(Ub(this->m_ptrData->getTrace())+1); this->numStates = new int[this->numClasses]; this->classMap = new int[this->numClasses]; unsigned int count = 0; /*creating vectors containing: -a map that compensates the empty classes(this->classMap) -the specific class for each datapoint(this->transitionDataClasses)*/ for(unsigned int i = 0;i < this->classes->size(); i++){ if((*this->classes)[i].size() != 0){ this->classMap[i] = i-count; (*this->classData)[this->classMap[i]] = new vector<double>; for(unsigned int n = 0; n < (*this->classes)[i].size(); n++){ int ende = ((unsigned int) (*this->classes)[i][n] != this->sceneLimits->size()-1) ? ((int) (*this->sceneLimits)[((int) (*this->classes)[i][n])+1]) -1 : Ub(this->m_ptrData->getTrace());; for(int x = (*this->sceneLimits)[(*this->classes)[i][n]]; x <= ende; x++){ (*this->classData)[this->classMap[i]]->push_back(_double(rawData[x])); (*this->transitionDataClasses)[x] = i; } } double max = 0; double min = 0; for(unsigned int n = 0; n < (*this->classData)[this->classMap[i]]->size();n++){ min = (n == 0 || min > (*(*this->classData)[this->classMap[i]])[n]) ? (*(*this->classData)[this->classMap[i]])[n] : min; max = (max < (*(*this->classData)[this->classMap[i]])[n]) ? (*(*this->classData)[this->classMap[i]])[n] : max; } rvector dump(0,(*this->classData)[this->classMap[i]]->size()-1); for(unsigned int n=0;n< (*this->classData)[this->classMap[i]]->size();n++){ dump[n] = (*(*this->classData)[this->classMap[i]])[n]; } this->classTraces->push_back(new Trace(dump)); if( _double(this->classTraces->back()->getStandardDeviation()) == 0 ){ this->numStates[i] = 1; } else{ this->numStates[i] = (int) floor((max - min) / _double(this->classTraces->back()->getStandardDeviation())); } } else{ this->numStates[i] = 0; this->classMap[i] = -1; count++; } setProgressValue(41+ (int)( (double) (20.0 / this->classes->size()) * i)); } /*creating vector containing empty states*/ this->strippedStates = new vector< vector <int>* >(this->classes->size()); for(unsigned int i=0; i < this->classes->size();i++){ (*this->strippedStates)[i] = new vector<int>; if(this->classMap[i] != -1){ intvector intvec(0,Ub((*this->classTraces)[this->classMap[i]]->getTrace())); for(int c=0;c <= Ub(intvec);c++){ intvec[c] = this->getStateFromTrace((*(*this->classTraces)[this->classMap[i]]),(*this->classTraces)[this->classMap[i]]->getTrace()[c]); } rmatrix* tmp = new rmatrix(AbstractDiscreteSSMPModeler::computeTransition(intvec)); for(int n=0;n < this->numStates[i];n++){ real sum=0; for(int x=0;x < this->numStates[i];x++){ sum += (*tmp)[cxsc::Row(n)][x]; } if(((int) cxsc::_double(sum)) != 1){ (*this->strippedStates)[this->classMap[i]]->push_back(n); } } delete tmp; } setProgressValue(61 + (int)( (double) (20.0 / this->classes->size()) * i)); } /*creating intvector containing states for each datapoint*/ this->transitionDataStates = new intvector(0,Ub(m_ptrData->getTrace())); for(int i=0; i <= Ub(m_ptrData->getTrace());i++){ int stateBuff=0; for(int n=0;n < (*this->transitionDataClasses)[i];n++){ stateBuff += this->numStates[n]-(*this->strippedStates)[n]->size(); } (*this->transitionDataStates)[i] = (stateBuff+ this->getStateFromTrace( ((*(*this->classTraces)[this->classMap[(*this->transitionDataClasses)[i]]])) , m_ptrData->getTrace()[i] ) ); setProgressValue(81 + (int)( (double) ( 15.0 / Ub( m_ptrData->getTrace() )) * i)); } }