void CSetting::write() { QSettings settings(getFilePath(), getFileFormat()) ; settings.beginGroup("Global") ; settings.setValue(kKeyMapOpenDir, getMapOpenDir()) ; settings.endGroup() ; settings.beginGroup("MainWindow") ; settings.setValue(kKeyGeometry, getMainWindowGeometry()) ; settings.setValue(kKeyState, getMainWindowState()) ; settings.endGroup() ; settings.beginGroup("Splitter") ; settings.value(kKeyGeometry, getSplitterGeometry()) ; settings.setValue(kKeyState, getSplitterState()) ; settings.endGroup() ; settings.beginGroup("GameView") ; settings.setValue(kKeyGeometry, getGameViewGeometry()) ; settings.endGroup() ; settings.beginGroup("GameViewSplitter") ; settings.setValue(kKeyGeometry, getGameSplitterGeometry()) ; settings.setValue(kKeyState, getGameSplitterState()) ; settings.endGroup() ; }
void CSetting::read() { QSettings settings(getFilePath(), getFileFormat()) ; settings.beginGroup("Global") ; setMapOpenDir(settings.value(kKeyMapOpenDir).toString()) ; settings.endGroup() ; settings.beginGroup("MainWindow") ; setMainWindowGeometry(settings.value(kKeyGeometry).toByteArray()) ; setMainWindowState(settings.value(kKeyState).toByteArray()) ; settings.endGroup() ; settings.beginGroup("Splitter") ; setSplitterGeometry(settings.value(kKeyGeometry).toByteArray()) ; setSplitterState(settings.value(kKeyState).toByteArray()) ; settings.endGroup() ; settings.beginGroup("GameView") ; setGameViewGeometry(settings.value(kKeyGeometry).toByteArray()) ; settings.endGroup() ; settings.beginGroup("GameViewSplitter") ; setGameSplitterGeometry(settings.value(kKeyGeometry).toByteArray()) ; setGameSplitterState(settings.value(kKeyState).toByteArray()) ; settings.endGroup() ; }
// Has image extension ..................................................... bool FileName::hasMetadataExtension() const { String ext = getFileFormat(); return (ext == "sel" || ext == "xmd" || ext == "doc" || ext == "ctfdat" || ext == "ctfparam" || ext == "pos" || ext == "sqlite" || ext == "xml" || ext == "star"); }
// Has image extension ..................................................... bool FileName::hasStackExtension() const { String ext = getFileFormat(); return (ext=="stk" || ext=="spi" || ext=="xmp" || ext=="mrcs" || ext=="mrc" || ext=="img" || ext=="hed" || ext=="pif" || ext=="tif" || ext=="dm3" || ext=="ser" || ext=="st" || ext=="dm4"); }
bool IoDisk::save(Image & image, JSON & data) { // ---------------------------------------- // The naming convention that will be used // for the image. std::string pathToImage = getFileFormat(); // ------------------------------------------ // Stringify data object: build image path // with data information. static const std::string kTypeNames[] = { "Null", "False", "True", "Object", "Array", "String", "Number" }; for (JSONValue::ConstMemberIterator itr = data.MemberBegin(); itr != data.MemberEnd(); ++itr) { std::string name = itr->name.GetString(); std::string type = kTypeNames[itr->value.GetType()]; if(type == "String") { std::string value = itr->value.GetString(); kerberos::helper::replace(pathToImage, name, value); } else if(type == "Number") { std::string value = kerberos::helper::to_string(itr->value.GetInt()); kerberos::helper::replace(pathToImage, name, value); } else if(type == "Array") { std::string arrayString = ""; for (JSONValue::ConstValueIterator itr2 = itr->value.Begin(); itr2 != itr->value.End(); ++itr2) { type = kTypeNames[itr2->GetType()]; if(type == "String") { arrayString += itr2->GetString(); } else if(type == "Number") { arrayString += kerberos::helper::to_string(itr2->GetInt()); } arrayString += "-"; } kerberos::helper::replace(pathToImage, name, arrayString.substr(0, arrayString.size()-1)); } } /// --------------------- // Replace variables pathToImage = buildPath(pathToImage); // --------------------------------------------------------------------- // Save original version & generate unique timestamp for current image return m_fileManager.save(image, pathToImage); }
bool IoDisk::save(Image & image) { // ---------------------------------------- // The naming convention that will be used // for the image. std::string pathToImage = getFileFormat(); // --------------------- // Replace variables pathToImage = buildPath(pathToImage); std::string timestamp = kerberos::helper::getTimestamp(); kerberos::helper::replace(pathToImage, "timestamp", timestamp); drawDateOnImage(image, timestamp); std::string microseconds = kerberos::helper::getMicroseconds(); std::string size = kerberos::helper::to_string((int)microseconds.length()); kerberos::helper::replace(pathToImage, "microseconds", size + "-" + microseconds); std::string token = kerberos::helper::to_string(rand()%1000); kerberos::helper::replace(pathToImage, "token", token); // --------------------------------------------------------------------- // Save original version & generate unique timestamp for current image return m_fileManager.save(image, pathToImage); }
// Has image extension ..................................................... bool FileName::hasImageExtension() const { String ext = getFileFormat(); return (ext=="img" || ext=="hed" || ext=="inf" || ext=="raw" || ext=="mrc" || ext=="map" || ext=="spi" || ext=="xmp" || ext=="tif" || ext=="dm3" || ext=="spe" || ext=="em" || ext=="pif" || ext=="ser" || ext=="stk" || ext=="mrcs"|| ext=="jpg" || ext=="dm4"); }
std::string Encoder::getOutputFileExtension() const { switch (getFileFormat()) { case FILEFORMAT_OTF: case FILEFORMAT_TTF: return ".xtb"; default: return ".xtb"; } }
int Jpeg2000::inputFormat(const char *filename) const { FILE *reader; const char *s, *magic_s; int ext_format, magic_format; unsigned char buf[12]; OPJ_SIZE_T l_nb_read; reader = fopen(filename, "rb"); if (reader == NULL) { return -2; } memset(buf, 0, 12); l_nb_read = fread(buf, 1, 12, reader); fclose(reader); if (l_nb_read != 12) { return -1; } ext_format = getFileFormat(filename); if (ext_format == JPT_CFMT) { return JPT_CFMT; } if (memcmp(buf, JP2_RFC3745_MAGIC, 12) == 0 || memcmp(buf, JP2_MAGIC, 4) == 0) { magic_format = JP2_CFMT; magic_s = ".jp2"; } else if (memcmp(buf, J2K_CODESTREAM_MAGIC, 4) == 0) { magic_format = J2K_CFMT; magic_s = ".j2k or .jpc or .j2c"; } else { return -1; } if (magic_format == ext_format) { return ext_format; } s = filename + strlen(filename) - 4; LOG4CPP_ERROR_S ((*mainCat)) << "Jpeg2000::inputFormat" << "The extension of this file is incorrect. Found " << s << ". Should be " << magic_s; return magic_format; }
bool IoDisk::save(Image & image) { // ---------------------------------------- // The naming convention that will be used // for the image. std::string pathToImage = getFileFormat(); // --------------------- // Replace variables pathToImage = buildPath(pathToImage); // --------------------------------------------------------------------- // Save original version & generate unique timestamp for current image return m_fileManager.save(image, pathToImage); }
void CSetting::writeSetting() { qDebug() << "write settings" << qApp->applicationDirPath() << "/settnig.ini" ; QSettings settings(getFilePath(), getFileFormat()) ; settings.beginGroup("Global"); settings.setValue(kKeyFileOpenDir, m_fileOpenDir) ; settings.setValue(kKeyFileSaveDir, m_fileSaveDir) ; settings.setValue(kKeyJsonFileSaveDir, m_jsonFileSaveDir) ; settings.setValue(kKeyImageGridSize, m_imgGridSize) ; settings.setValue(kKeyMapGridSize, m_mapGridSize) ; settings.setValue(kKeyViewMode, m_viewMode) ; settings.endGroup(); settings.beginGroup("MainWindow") ; settings.setValue(kKeyWindowGeometry, m_MainWindowGeometry) ; settings.setValue(kKeyWindowState, m_MainWindowState) ; settings.endGroup(); settings.beginGroup("SplitterMap") ; settings.setValue(kKeyWindowGeometry, m_SplitterMapGeometry) ; settings.setValue(kKeyWindowState, m_SplitterMapState) ; settings.endGroup(); settings.beginGroup("LabelImage") ; settings.setValue(kKeyWindowGeometry, m_LabelImageGeometry) ; settings.setValue(kKeyWindowState, m_LabelImageState) ; settings.endGroup(); settings.beginGroup("FrameMap") ; settings.setValue(kKeyWindowSize, m_frameMapSize) ; settings.endGroup(); settings.beginGroup("FrameTree") ; settings.setValue(kKeyWindowSize, m_frameTreeSize) ; settings.endGroup(); settings.beginGroup("FrameImage") ; settings.setValue(kKeyWindowSize, m_frameImageSize) ; settings.endGroup(); }
CSetting::CSetting() { QSettings settings(getFilePath(), getFileFormat()) ; settings.beginGroup("Global"); m_fileOpenDir = settings.value(kKeyFileOpenDir, "./").toString() ; m_fileSaveDir = settings.value(kKeyFileSaveDir, "./").toString() ; m_jsonFileSaveDir = settings.value(kKeyJsonFileSaveDir, "./").toString() ; m_imgGridSize = settings.value(kKeyImageGridSize, QSize(16, 16)).toSize() ; m_mapGridSize = settings.value(kKeyMapGridSize, QSize(90, 90)).toSize() ; m_viewMode = settings.value(kKeyViewMode, 0).toInt() ; settings.endGroup(); settings.beginGroup("MainWindow") ; m_MainWindowGeometry = settings.value(kKeyWindowGeometry).toByteArray() ; m_MainWindowState = settings.value(kKeyWindowState).toByteArray() ; settings.endGroup(); settings.beginGroup("SplitterMap") ; m_SplitterMapGeometry = settings.value(kKeyWindowGeometry).toByteArray() ; m_SplitterMapState = settings.value(kKeyWindowState).toByteArray() ; settings.endGroup(); settings.beginGroup("LabelImage") ; m_LabelImageGeometry = settings.value(kKeyWindowGeometry).toByteArray() ; m_LabelImageState = settings.value(kKeyWindowState).toByteArray() ; settings.endGroup(); settings.beginGroup("FrameMap") ; m_frameMapSize = settings.value(kKeyWindowSize, QSize(406, 451)) ; settings.endGroup(); settings.beginGroup("FrameTree") ; m_frameTreeSize = settings.value(kKeyWindowSize, QSize(121, 441)) ; settings.endGroup(); settings.beginGroup("FrameImage") ; m_frameImageSize = settings.value(kKeyWindowSize) ; settings.endGroup(); }
bool IoDisk::save(Image & image, JSON & data) { // ---------------------------------------- // The naming convention that will be used // for the image. std::string pathToImage = getFileFormat(); // ------------------------------------------ // Stringify data object: build image path // with data information. static const std::string kTypeNames[] = { "Null", "False", "True", "Object", "Array", "String", "Number" }; for (JSONValue::ConstMemberIterator itr = data.MemberBegin(); itr != data.MemberEnd(); ++itr) { std::string name = itr->name.GetString(); std::string type = kTypeNames[itr->value.GetType()]; if(type == "String") { std::string value = itr->value.GetString(); kerberos::helper::replace(pathToImage, name, value); } else if(type == "Number") { std::string value = kerberos::helper::to_string(itr->value.GetInt()); kerberos::helper::replace(pathToImage, name, value); } else if(type == "Array") { std::string arrayString = ""; for (JSONValue::ConstValueIterator itr2 = itr->value.Begin(); itr2 != itr->value.End(); ++itr2) { type = kTypeNames[itr2->GetType()]; if(type == "String") { arrayString += itr2->GetString(); } else if(type == "Number") { arrayString += kerberos::helper::to_string(itr2->GetInt()); } arrayString += "-"; } kerberos::helper::replace(pathToImage, name, arrayString.substr(0, arrayString.size()-1)); } } /// --------------------- // Replace variables pathToImage = buildPath(pathToImage); // ------------------------------------------------------- // Add path to JSON object, so other IO devices can use it JSONValue path; JSON::AllocatorType& allocator = data.GetAllocator(); path.SetString(pathToImage.c_str(), allocator); data.AddMember("pathToImage", path, allocator); // ------------------ // Draw date on image drawDateOnImage(image, data["timestamp"].GetString()); // ------------------------- // Save original version BINFO << "IoDisk: saving image " + pathToImage; return m_fileManager.save(image, pathToImage); }
void Database::getStats( OperationContext* opCtx, BSONObjBuilder* output, double scale ) { bool empty = isEmpty() || getExtentManager()->numFiles() == 0; list<string> collections; if ( !empty ) _dbEntry->getCollectionNamespaces( &collections ); long long ncollections = 0; long long objects = 0; long long size = 0; long long storageSize = 0; long long numExtents = 0; long long indexes = 0; long long indexSize = 0; for (list<string>::const_iterator it = collections.begin(); it != collections.end(); ++it) { const string ns = *it; Collection* collection = getCollection( opCtx, ns ); if ( !collection ) continue; ncollections += 1; objects += collection->numRecords(); size += collection->dataSize(); BSONObjBuilder temp; storageSize += collection->getRecordStore()->storageSize( &temp ); numExtents += temp.obj()["numExtents"].numberInt(); // XXX indexes += collection->getIndexCatalog()->numIndexesTotal(); indexSize += getIndexSizeForCollection(opCtx, collection); } output->append ( "db" , _name ); output->appendNumber( "collections" , ncollections ); output->appendNumber( "objects" , objects ); output->append ( "avgObjSize" , objects == 0 ? 0 : double(size) / double(objects) ); output->appendNumber( "dataSize" , size / scale ); output->appendNumber( "storageSize" , storageSize / scale); output->appendNumber( "numExtents" , numExtents ); output->appendNumber( "indexes" , indexes ); output->appendNumber( "indexSize" , indexSize / scale ); if ( !empty ) { output->appendNumber( "fileSize" , fileSize() / scale ); output->appendNumber( "nsSizeMB", (int)_dbEntry->namespaceIndex().fileLength() / 1024 / 1024 ); } else { output->appendNumber( "fileSize" , 0 ); } BSONObjBuilder dataFileVersion( output->subobjStart( "dataFileVersion" ) ); if ( !empty ) { int major, minor; getFileFormat( opCtx, &major, &minor ); dataFileVersion.append( "major", major ); dataFileVersion.append( "minor", minor ); } dataFileVersion.done(); if ( !empty ){ int freeListSize = 0; int64_t freeListSpace = 0; getExtentManager()->freeListStats( &freeListSize, &freeListSpace ); BSONObjBuilder extentFreeList( output->subobjStart( "extentFreeList" ) ); extentFreeList.append( "num", freeListSize ); extentFreeList.appendNumber( "totalSize", static_cast<long long>( freeListSpace / scale ) ); extentFreeList.done(); } }
/* entry */ int main(int argc, char** argv) { char *selectFile, *inFile, *outFile, *dropFile; optionInit(&argc, argv, optionSpecs); if (argc != 4) usage("wrong # args"); selectFile = argv[1]; inFile = argv[2]; outFile = argv[3]; /* select file options */ if (optionExists("selectFmt") && optionExists("selectCoordCols")) errAbort("can't specify both -selectFmt and -selectCoordCols"); if (optionExists("selectFmt")) selectFmt = parseFormatSpec(optionVal("selectFmt", NULL)); else if (optionExists("selectCoordCols")) { selectCoordCols = coordColsParseSpec("selectCoordCols", optionVal("selectCoordCols", NULL)); selectFmt = COORD_COLS_FMT; } else selectFmt = getFileFormat(selectFile); if (optionExists("selectCds")) selectCaOpts |= chromAnnCds; if (optionExists("selectRange")) selectCaOpts |= chromAnnRange; if ((selectFmt == PSLQ_FMT) || (selectFmt == CHAINQ_FMT)) selectCaOpts |= chromAnnUseQSide; /* in file options */ if (optionExists("inFmt") && optionExists("inCoordCols")) errAbort("can't specify both -inFmt and -inCoordCols"); if (optionExists("inFmt")) inFmt = parseFormatSpec(optionVal("inFmt", NULL)); else if (optionExists("inCoordCols")) { inCoordCols = coordColsParseSpec("inCoordCols", optionVal("inCoordCols", NULL)); inFmt = COORD_COLS_FMT; } else inFmt = getFileFormat(inFile); inCaOpts = chromAnnSaveLines; // need lines for output if (optionExists("inCds")) inCaOpts |= chromAnnCds; if (optionExists("inRange")) inCaOpts |= chromAnnRange; if ((inFmt == PSLQ_FMT) || (inFmt == CHAINQ_FMT)) inCaOpts |= chromAnnUseQSide; /* select options */ useAggregate = optionExists("aggregate"); nonOverlapping = optionExists("nonOverlapping"); if (optionExists("strand") && optionExists("oppositeStrand")) errAbort("can only specify one of -strand and -oppositeStrand"); if (optionExists("strand")) selectOpts |= selStrand; if (optionExists("oppositeStrand")) selectOpts |= selOppositeStrand; if (optionExists("excludeSelf") && (optionExists("idMatch"))) errAbort("can't specify both -excludeSelf and -idMatch"); if (optionExists("excludeSelf")) selectOpts |= selExcludeSelf; if (optionExists("idMatch")) selectOpts |= selIdMatch; criteria.threshold = optionFloat("overlapThreshold", 0.0); criteria.thresholdCeil = optionFloat("overlapThresholdCeil", 1.1); criteria.similarity = optionFloat("overlapSimilarity", 0.0); criteria.similarityCeil = optionFloat("overlapSimilarityCeil", 1.1); criteria.bases = optionInt("overlapBases", -1); /* output options */ mergeOutput = optionExists("mergeOutput"); idOutput = optionExists("idOutput"); statsOutput = optionExists("statsOutput") || optionExists("statsOutputAll") || optionExists("statsOutputBoth"); if ((mergeOutput + idOutput + statsOutput) > 1) errAbort("can only specify one of -mergeOutput, -idOutput, -statsOutput, -statsOutputAll, or -statsOutputBoth"); outputAll = optionExists("statsOutputAll"); outputBoth = optionExists("statsOutputBoth"); if (outputBoth) outputAll = TRUE; if (mergeOutput) { if (nonOverlapping) errAbort("can't use -mergeOutput with -nonOverlapping"); if (useAggregate) errAbort("can't use -mergeOutput with -aggregate"); if ((selectFmt == CHAIN_FMT) || (selectFmt == CHAINQ_FMT) || (inFmt == CHAIN_FMT) || (inFmt == CHAINQ_FMT)) if (useAggregate) errAbort("can't use -mergeOutput with chains"); selectCaOpts |= chromAnnSaveLines; } dropFile = optionVal("dropped", NULL); /* check for options incompatible with aggregate mode */ if (useAggregate) { int i; for (i = 0; aggIncompatible[i] != NULL; i++) { if (optionExists(aggIncompatible[i])) errAbort("-%s is not allowed -aggregate", aggIncompatible[i]); } } overlapSelect(selectFile, inFile, outFile, dropFile); return 0; }
void climate_openFile() // // Input: none // Output: none // Purpose: opens a climate file and reads in first set of values. // { int i, m, y; // --- open the file if ( (Fclimate.file = fopen(Fclimate.name, "rt")) == NULL ) { report_writeErrorMsg(ERR_CLIMATE_FILE_OPEN, Fclimate.name); return; } // --- initialize values of file's climate variables // (Temp.ta was previously initialized in project.c) FileValue[TMIN] = Temp.ta; FileValue[TMAX] = Temp.ta; FileValue[EVAP] = 0.0; FileValue[WIND] = 0.0; // --- find climate file's format FileFormat = getFileFormat(); if ( FileFormat == UNKNOWN_FORMAT ) { report_writeErrorMsg(ERR_CLIMATE_FILE_READ, Fclimate.name); return; } // --- position file to begin reading climate file at either user-specified // month/year or at start of simulation period. rewind(Fclimate.file); strcpy(FileLine, ""); if ( Temp.fileStartDate == NO_DATE ) datetime_decodeDate(StartDate, &FileYear, &FileMonth, &FileDay); else datetime_decodeDate(Temp.fileStartDate, &FileYear, &FileMonth, &FileDay); while ( !feof(Fclimate.file) ) { strcpy(FileLine, ""); readFileLine(&y, &m); if ( y == FileYear && m == FileMonth ) break; } if ( feof(Fclimate.file) ) { report_writeErrorMsg(ERR_CLIMATE_END_OF_FILE, Fclimate.name); return; } // --- initialize file dates and current climate variable values if ( !ErrorCode ) { FileElapsedDays = 0; FileLastDay = datetime_daysPerMonth(FileYear, FileMonth); readFileValues(); for (i=TMIN; i<=WIND; i++) { if ( FileData[i][FileDay] == MISSING ) continue; FileValue[i] = FileData[i][FileDay]; } } }
// Has image extension ..................................................... bool FileName::hasVolumeExtension() const { String ext = getFileFormat(); return (ext=="vol" || ext=="spi" || ext=="xmp" || ext=="mrc" || ext=="map" || ext=="em" || ext=="pif" || ext=="inf" || ext=="raw"); }