void ScorerManager::parseConstraintGroup() { ////////////////// emit( message("Parse constraint group starts: ") ); if ( this->otherPairs_.size() < 2) { emit( message("Parse pairs first!") ); return; } /////////////////////// groupRelations_.clear(); for ( int i = 0; i < this->actualInputGraphs_.size(); ++i) { Structure::Graph * g = Structure::Graph::actualGraph( this->actualInputGraphs_[i] ); GroupRelationDetector grd(g, i, this->normalizeCoef_, this->logLevel_); grd.detect(this->otherPairs_[i]); this->groupRelations_.push_back(grd.groupRelations_); if (this->logLevel_) { saveToFile("group_relation-" + QString::number(i) + ".txt", this->groupRelations_[i]); saveToFile("pair_relation-" + QString::number(i) + ".txt", this->otherPairs_[i]); } } emit( message("Parse constraint group end. ") ); }
void saveToFile(struct dirNode *root,FILE *fstore) { if(root!=NULL) { //fwrite(&(root->fileDesc),sizeof(FileDescriptor),1,fstore); saveToFile(root->rightSibling,fstore); saveToFile(root->firstChild,fstore); } }
void ofxPanel::setValue(float mx, float my, bool bCheck){ if( ofGetFrameNum() - currentFrame > 1 ){ bGrabbed = false; bGuiActive = false; return; } if( bCheck ){ if( b.inside(mx, my) ){ bGuiActive = true; if( my > b.y && my <= b.y + header ){ bGrabbed = true; grabPt.set(mx-b.x, my-b.y); } else{ bGrabbed = false; } if(loadBox.inside(mx - b.x, my - b.y)) { loadFromFile(filename); } if(saveBox.inside(mx - b.x, my - b.y)) { saveToFile(filename); } } } else if( bGrabbed ){ b.x = mx - grabPt.x; b.y = my - grabPt.y; } }
Notebook::Notebook(QWidget *parent) : QWidget(parent) { setupUi(this); titleLine->setReadOnly(true); contentText->setReadOnly(true); cancelButton->hide(); submitButton->hide(); nextButton->setEnabled(false); previousButton->setEnabled(false); editButton->setEnabled(false); removeButton->setEnabled(false); dialog = new FindDialog; connect(addButton, SIGNAL(clicked()), this, SLOT(addNote())); connect(submitButton, SIGNAL(clicked()), this, SLOT(submitNote())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); connect(nextButton, SIGNAL(clicked()), this, SLOT(next())); connect(previousButton, SIGNAL(clicked()), this, SLOT(previous())); connect(editButton, SIGNAL(clicked()), this, SLOT(editContent())); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeContent())); connect(findButton, SIGNAL(clicked()), this, SLOT(findTitle())); connect(saveButton, SIGNAL(clicked()), this, SLOT(saveToFile())); connect(loadButton, SIGNAL(clicked()), this, SLOT(loadFromFile())); }
void dsk::work() { std::cout << "======Begin dsk model======" << std::endl; double a = 0, b = 1, r; for(auto i = 0; i < bytes.size(); i++){ generator(a,b,r); r >= p ? bytes.at(i) = 0:1; } bl = makeBlocks(Blocks, BlockSize, bytes); pr = new protocol(bl,code); pr->work(dsk::ProtocolType, dsk::PacketSize); std::stringstream res; for(UINT i = 1; i <= dsk::PacketSize; i+=5){ pr->work(dsk::ProtocolType, i); res << pr->getResults() << "\n"; } saveToFile(res.str()); dsk::plot = pr->getPlot(); dsk::delProbPlot = pr->getDelProbPlot(); std::cout << "======End dsk model======" << std::endl; std::stringstream bits; for(auto value : bytes){ bits << value << " "; } std::string bitsName = "ErrorsStreamDSK.txt"; std::ofstream f; f.open(bitsName); f.write(bits.str().c_str(), sizeof(char)*bits.str().size()); f.close(); }
bool ofxPanel::setValue(float mx, float my, bool bCheck){ if( !isGuiDrawing() ){ bGrabbed = false; bGuiActive = false; return false; } if( bCheck ){ if( b.inside(mx, my) ){ bGuiActive = true; if( my > b.y && my <= b.y + header ){ bGrabbed = true; grabPt.set(mx-b.x, my-b.y); } else{ bGrabbed = false; } if(loadBox.inside(mx, my)) { loadFromFile(filename); ofNotifyEvent(loadPressedE,this); return true; } if(saveBox.inside(mx, my)) { saveToFile(filename); ofNotifyEvent(savePressedE,this); return true; } } } else if( bGrabbed ){ setPosition(mx - grabPt.x,my - grabPt.y); return true; } return false; }
void PolicyEditor::save(){ if (!_isModified) return; QString file_name; file_name = getSavingFileName(_filePath); saveToFile(file_name); }
void TlevelCreatorDlg::saveLevel() { if ( QMessageBox::question(this, tr("level not saved!"), tr("Level was changed and not saved!"), QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save ) { saveToFile(); } else levelSaved(); }
void DemoKeeper::notifyEndDialog(common::OpenSaveFileDialog* _sender, bool _result) { mFileDialog->setVisible(false); if (!_result) return; if (mFileDialogSave) { std::string filename = mFileDialog->getFileName(); size_t index = filename.find_first_of('.'); if (index == std::string::npos) filename += ".xml"; filename = mFileDialog->getCurrentFolder() + "/" + filename; saveToFile(filename); } else { ClearGraph(); std::string filename = mFileDialog->getFileName(); filename = mFileDialog->getCurrentFolder() + "/" + filename; loadFromFile(filename); } }
void PixelWidget::keyPressEvent(QKeyEvent *e) { switch (e->key()) { case Qt::Key_Plus: increaseZoom(); break; case Qt::Key_Minus: decreaseZoom(); break; case Qt::Key_PageUp: setGridSize(m_gridSize + 1); break; case Qt::Key_PageDown: setGridSize(m_gridSize - 1); break; case Qt::Key_G: toggleGrid(); break; case Qt::Key_C: if (e->modifiers() & Qt::ControlModifier) copyToClipboard(); break; case Qt::Key_S: if (e->modifiers() & Qt::ControlModifier) { releaseKeyboard(); saveToFile(); } break; case Qt::Key_Control: grabKeyboard(); break; } }
// encoder void Huffman::encode() { cout << "Begin encoding..." << endl; cout << "Open file..." << endl; inFile_.open(inFileName_.c_str(),ios::in); cout << "Calculating frequency of all ascii chars..." << endl; createNodeArray(); cout << "Done!" << endl; inFile_.close(); cout << "Creating Priority-Queue..." << endl; createPq(); cout << "Done!" << endl; cout << "Creating Huffman-Tree..." << endl; createHuffmanTree(); cout << "Done!" << endl; cout << "Calculating Huffman-Code..." << endl; calculateHuffmanCode(); cout << "Done!" << endl; cout << "Saving to outputfile..." << endl; saveToFile(); cout << "Done!" << endl; cout << "Ecoding finished!" << endl; }
octree_base<Container, PointT>::~octree_base () { root_->flushToDisk (); root_->saveIdx (false); saveToFile (); delete root_; }
void EventRecorder::timeout() { if (sessionTimer->isSynchronizing()) return; if (autoStopRecord >= 0) { if((eventData.getRemainingTime().toString("h:mm:ss") == "0:00:00" && eventData.getEventType() == LTPackets::PRACTICE_EVENT) || (eventData.getRemainingTime().toString("h:mm:ss") == "0:00:00" && eventData.getEventType() == LTPackets::QUALI_EVENT && eventData.getQualiPeriod() == 3) || ((eventData.getRemainingTime().toString("h:mm:ss") == "0:00:00" || eventData.getCompletedLaps() == eventData.getEventInfo().laps) && eventData.getEventType() == LTPackets::RACE_EVENT)) ++elapsedTimeToStop; if (elapsedTimeToStop >= (autoStopRecord * 60)) { emit recordingStopped(); stopRecording(); } } if (autoSaveRecord > -1) { --autoSaveCounter; if (autoSaveCounter <= 0) { saveToFile(""); autoSaveCounter = autoSaveRecord * 60; } } }
void MainWindow::on_saveButton_clicked() { int size = nc*3/4; char potentialFilename[]="out/potential-%1.txt"; char concFilename[]="out/ni_ne-%1.txt"; //Save potential QVector<double> r(size), potential(size); for (int i=0; i<size; ++i) { r[i] = r_array[i]; potential[i] = phi[i]; } saveToFile(r,potential,QString(potentialFilename).arg((t/dt))); //Save concentration of the electrons and ions QVector<double> /*r(size),*/ ne(size),ni(size); for (int i=0; i<size; ++i) { r[i] = r_array[i]; ne[i] = srho[0][i]; ni[i] = srho[1][i]; } saveToFile2(r,ne,ni, QString(concFilename).arg((t/dt))); }
void Highscores::add(Score s) { s.version = highscoreVersion; localScores.push_back(s); saveToFile(localScores, localPath); remoteScores.push_back(s); fileSharing.uploadHighscores(localPath); }
void MonteCarlo::monteCarloAlgorithm() { logg("start monteCarlo algorithm..."); Time st(boost::posix_time::microsec_clock::local_time()); calculateEnergy(); vector<cell*> listCells; for (int i = 0; i < 100; i++) { copySpaces(oldstate, cells); fillList(&listCells, cells); //cout<<listCells.size()<<endl; if(listCells.size()>0){ executeList(&listCells,cells,oldstate); } manager->run(); manager->join_all(); listCells.clear(); } Time end(boost::posix_time::microsec_clock::local_time()); TimeDuraction d = end - st; duraction = d.total_milliseconds(); loggTime("time execution montecarlo algorithm: ",duraction); saveToFile(); //drawSpace(); }
YieldAction EuclideanMenuSlice::handleConsoleResults() { std::list<std::string> line = console->getCurrCommand(); //No command means the Console killed itself. if (line.empty() || line.front().empty()) { return YieldAction(); } //Else, the first item in the line is the command. std::string cmd = line.front(); line.erase(line.begin()); //Switch on this command. if (cmd == "clear") { //For now, we treat this as an error. console->appendCommandErrorMessage("Error: \"clear\" is not yet implemented."); return YieldAction(YieldAction::Stack, console); } else if (cmd == "additem") { return addNewMenuItem(line); } else if (cmd == "save") { return saveToFile(line); } //Else, throw the command back to the terminal. std::stringstream msg; msg <<"Error, unexpected command: \"" <<cmd <<"\""; console->appendCommandErrorMessage(msg.str()); return YieldAction(YieldAction::Stack, console); }
PluginInfoCache::~PluginInfoCache() { if (m_saveToFileIdle.isScheduled()) { m_saveToFileIdle.cancel(); saveToFile(); } }
int DriverCosmetics::saveToFile(const char* filename) { FILE* file = fopen(filename, "wb"); if(!file) return -1; return saveToFile(file); };
int main() { char input; cout << "========= R E S T A U R A N T S I N C U P E R T I N O ========="; listHead *restaurants = new listHead(hashSize); readFile(restaurants); restaurants->getHashPtr()->printHashTableSequence(); // Display menu displayMenu(); // Get user's input input = getUserInput(); // While the user does not want to quit... while (input != 'q') { // Call appropriate operation operationManager(restaurants, input); // Get user's input input = getUserInput(); } saveToFile(restaurants); cout << "\n======================== T H A N K Y O U ========================="; }
OutofcoreOctreeBase<ContainerT, PointT>::~OutofcoreOctreeBase () { root_->flushToDiskRecursive (); saveToFile (); delete root_; }
void ASMModel::saveToFile(const string& filename) { ModelFileAscii mf; mf.openFile(filename.c_str(), "wb"); saveToFile(mf); mf.closeFile(); }
inline void saveScreenshot(const ssvufs::Path& mPath) const { sf::Texture t; t.update(renderWindow); auto img = t.copyToImage(); img.saveToFile(mPath); }
void accountsCache::addAccount(const QString& bareJid, const QString& passwd) { if(m_accountsDocument.documentElement().isNull()) { m_accountsDocument.appendChild(m_accountsDocument.createElement("accounts")); } QDomElement element = m_accountsDocument.documentElement().firstChildElement("account"); while(!element.isNull()) { if(element.firstChildElement("bareJid").text() == bareJid) { m_accountsDocument.documentElement().removeChild(element); break; } element = element.nextSiblingElement("account"); } QDomElement newElement = m_accountsDocument.createElement("account"); QDomElement newElementBareJid = m_accountsDocument.createElement("bareJid"); newElementBareJid.appendChild(m_accountsDocument.createTextNode(bareJid)); newElement.appendChild(newElementBareJid); QDomElement newElementPasswd = m_accountsDocument.createElement("password"); newElementPasswd.appendChild(m_accountsDocument.createTextNode( calculateXor(passwd.toUtf8(), bareJid.toUtf8()).toBase64())); newElement.appendChild(newElementPasswd); m_accountsDocument.documentElement().appendChild(newElement); saveToFile(); }
void DemoKeeper::notifyEndDialog(tools::Dialog* _dialog, bool _result) { if (_result) { if (mFileDialogSave) { std::string filename = mFileDialog->getFileName(); size_t index = filename.find_first_of('.'); if (index == std::string::npos) filename += ".xml"; filename = mFileDialog->getCurrentFolder() + "/" + filename; saveToFile(filename); } else { ClearGraph(); std::string filename = mFileDialog->getFileName(); filename = mFileDialog->getCurrentFolder() + "/" + filename; loadFromFile(filename); } } _dialog->endModal(); }
//**************************************************************************** ErrorCode MD5UtilCore::processDigest (const CommandLineOptions& options, std::string& output) { if (options.getHelpMode ()) { std::cout << MSG_DIGEST_HELP << std::endl; return ErrorCode::NONE; } if (options.getInputText ().length () == 0) { return ErrorCode::DIGEST_USAGE_ERROR; } output = hash (options.getInputText ()); if (options.getOutputFilename ().length () != 0) { if (!saveToFile (options.getOutputFilename (), output)) { return ErrorCode::FILE_WRITE_ERROR; } } return ErrorCode::NONE; }
void cScreenShot::capture() { TCHAR szCount[MAX_PATH]; _stprintf(szCount, _T("%d"), m_count); //m_count의 자리수를 구한다 int data = m_count; int p = 0; bool is = true; while (is) { int mod = data/10; if (mod == 0) break; data = mod; ++p; } p += 1; //최대 자릿수 int max_p = 4; int last_p = max_p - p; std_string str; str = cScreenShot::directoryName + _T("\\ScreenShot"); for (int i = 0; i < last_p; ++i) str += _T("0"); str += szCount; str += cScreenShot::getExpName(); saveToFile(str.c_str()); ++m_count; }
void SkDebuggerGUI::actionSaveAs() { QString filename = QFileDialog::getSaveFileName(this, "Save File", "", "Skia Picture (*skp)"); if (!filename.endsWith(".skp", Qt::CaseInsensitive)) { filename.append(".skp"); } saveToFile(SkString(filename.toAscii().data())); }
bool LayoutMemoryPersister::save(const QString& moduleName) { if( isRestoreSession() ) { QString relPath = moduleName + REL_SESSION_FILE_PATH; QFile file(KStandardDirs::locateLocal("data", relPath)); return saveToFile(file); } return false; }
void StatisticsSampler::sample(System &system, ofstream &file) { sampleKineticEnergy(system); samplePotentialEnergy(system); sampleTemperature(system); sampleDensity(system); sampleDiffusionConstant(system); saveToFile(system, file); }