本文整理汇总了C++中FileName::baseName方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::baseName方法的具体用法?C++ FileName::baseName怎么用?C++ FileName::baseName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName::baseName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsisMain
void IsisMain() {
//Get user parameters
UserInterface &ui = Application::GetUserInterface();
FileName inFile = ui.GetFileName("FROM");
int numberOfLines = ui.GetInteger("NL");
int lineOverlap = ui.GetInteger("OVERLAP");
//Throws exception if user is dumb
if(lineOverlap >= numberOfLines) {
throw IException(IException::User, "The Line Overlap (OVERLAP) must be less than the Number of Lines (LN).", _FILEINFO_);
}
//Opens the cube
Cube cube;
cube.open(inFile.expanded());
//Loops through, cropping as desired
int cropNum = 1;
int startLine = 1;
bool hasReachedEndOfCube = false;
while(startLine <= cube.lineCount() && not hasReachedEndOfCube) {
//! Sets up the proper paramaters for running the crop program
QString parameters = "FROM=" + inFile.expanded() +
" TO=" + inFile.path() + "/" + inFile.baseName() + ".segment" + toString(cropNum) + ".cub"
+ " LINE=" + toString(startLine) + " NLINES=";
if(startLine + numberOfLines > cube.lineCount()) {
parameters += toString(cube.lineCount() - (startLine - 1));
hasReachedEndOfCube = true;
}
else {
parameters += toString(numberOfLines);
}
ProgramLauncher::RunIsisProgram("crop", parameters);
//The starting line for next crop
startLine = 1 + cropNum * (numberOfLines - lineOverlap);
cropNum++;
}
}
示例2: createTempFile
FileName FileName::createTempFile(FileName templateFileName) {
QString preppedFileName = QString("%1/%2XXXXXX.%3").arg(templateFileName.path())
.arg(templateFileName.baseName()).arg(templateFileName.extension());
QTemporaryFile tempFile(preppedFileName);
tempFile.setAutoRemove(false);
if (!tempFile.open()) {
throw IException(IException::Io,
QObject::tr("Could not create a unique temporary file name based on [%1]")
.arg(templateFileName.original()),
_FILEINFO_);
}
// We want to set the 'original' path as correctly as possible. So let's use the input original
// path with the output temp file's file name in our result.
FileName result;
QString newTempFileNameStr = templateFileName.originalPath() + "/" +
QFileInfo(tempFile.fileName()).fileName();
result = FileName(newTempFileNameStr);
return result;
}
示例3: IsisMain
void IsisMain ()
{
ProcessImportPds p;
Pvl pdsLabel;
UserInterface &ui = Application::GetUserInterface();
FileName inFile = ui.GetFileName("FROM");
QString imageFile("");
if (ui.WasEntered("IMAGE")) {
imageFile = ui.GetFileName("IMAGE");
}
// Generate the housekeeping filenames
QString hkLabel("");
QString hkData("");
if (ui.WasEntered("HKFROM") ) {
hkLabel = ui.GetFileName("HKFROM");
}
else {
hkLabel = inFile.originalPath() + "/" + inFile.baseName() + "_HK.LBL";
// Determine the housekeeping file
FileName hkFile(hkLabel);
if (!hkFile.fileExists()) {
hkFile = hkLabel.replace("_1B_", "_1A_");
if (hkFile.fileExists()) hkLabel = hkFile.expanded();
}
}
if (ui.WasEntered("HKTABLE")) {
hkData = ui.GetFileName("HKTABLE");
}
QString instid;
QString missid;
try {
Pvl lab(inFile.expanded());
instid = (QString) lab.findKeyword ("CHANNEL_ID");
missid = (QString) lab.findKeyword ("INSTRUMENT_HOST_ID");
}
catch (IException &e) {
QString msg = "Unable to read [INSTRUMENT_ID] or [MISSION_ID] from input file [" +
inFile.expanded() + "]";
throw IException(e, IException::Io,msg, _FILEINFO_);
}
instid = instid.simplified().trimmed();
missid = missid.simplified().trimmed();
if (missid != "DAWN" && instid != "VIS" && instid != "IR") {
QString msg = "Input file [" + inFile.expanded() + "] does not appear to be a " +
"DAWN Visual and InfraRed Mapping Spectrometer (VIR) EDR or RDR file.";
throw IException(IException::Unknown, msg, _FILEINFO_);
}
QString target;
if (ui.WasEntered("TARGET")) {
target = ui.GetString("TARGET");
}
// p.SetPdsFile (inFile.expanded(),imageFile,pdsLabel);
// QString labelFile = ui.GetFileName("FROM");
p.SetPdsFile (inFile.expanded(),imageFile,pdsLabel);
p.SetOrganization(Isis::ProcessImport::BIP);
Cube *outcube = p.SetOutputCube ("TO");
// p.SaveFileHeader();
Pvl labelPvl (inFile.expanded());
p.StartProcess ();
// Get the directory where the DAWN translation tables are.
PvlGroup dataDir (Preference::Preferences().findGroup("DataDirectory"));
QString transDir = (QString) dataDir["Dawn"] + "/translations/";
// Create a PVL to store the translated labels in
Pvl outLabel;
// Translate the BandBin group
FileName transFile (transDir + "dawnvirBandBin.trn");
PvlTranslationManager bandBinXlater (labelPvl, transFile.expanded());
bandBinXlater.Auto(outLabel);
// Translate the Archive group
transFile = transDir + "dawnvirArchive.trn";
PvlTranslationManager archiveXlater (labelPvl, transFile.expanded());
archiveXlater.Auto(outLabel);
// Translate the Instrument group
transFile = transDir + "dawnvirInstrument.trn";
PvlTranslationManager instrumentXlater (labelPvl, transFile.expanded());
instrumentXlater.Auto(outLabel);
// Update target if user specifies it
if (!target.isEmpty()) {
PvlGroup &igrp = outLabel.findGroup("Instrument",Pvl::Traverse);
igrp["TargetName"] = target;
}
// Write the BandBin, Archive, and Instrument groups
//.........这里部分代码省略.........
示例4: IsisMain
void IsisMain() {
ProcessImportPds p;
Pvl pdsLabel;
UserInterface &ui = Application::GetUserInterface();
FileName inFile = ui.GetFileName("FROM");
QString instid;
QString missid;
try {
Pvl lab(inFile.expanded());
instid = (QString) lab.findKeyword("INSTRUMENT_ID");
missid = (QString) lab.findKeyword("MISSION_ID");
}
catch(IException &e) {
QString msg = "Unable to read [INSTRUMENT_ID] or [MISSION_ID] from input file [" +
inFile.expanded() + "]";
throw IException(IException::Io, msg, _FILEINFO_);
}
instid = instid.simplified().trimmed();
missid = missid.simplified().trimmed();
if(missid != "DAWN" && instid != "FC1" && instid != "FC2") {
QString msg = "Input file [" + inFile.expanded() + "] does not appear to be " +
"a DAWN Framing Camera (FC) EDR or RDR file.";
throw IException(IException::Io, msg, _FILEINFO_);
}
QString target;
if(ui.WasEntered("TARGET")) {
target = ui.GetString("TARGET");
}
p.SetPdsFile(inFile.expanded(), "", pdsLabel);
p.SetOrganization(Isis::ProcessImport::BSQ);
QString tmpName = "$TEMPORARY/" + inFile.baseName() + ".tmp.cub";
FileName tmpFile(tmpName);
CubeAttributeOutput outatt = CubeAttributeOutput("+Real");
p.SetOutputCube(tmpFile.expanded(), outatt);
p.SaveFileHeader();
Pvl labelPvl(inFile.expanded());
p.StartProcess();
p.EndProcess();
ProcessBySample p2;
CubeAttributeInput inatt;
p2.SetInputCube(tmpFile.expanded(), inatt);
Cube *outcube = p2.SetOutputCube("TO");
// Get the directory where the DAWN translation tables are.
PvlGroup dataDir(Preference::Preferences().findGroup("DataDirectory"));
QString transDir = (QString) dataDir["Dawn"] + "/translations/";
// Create a PVL to store the translated labels in
Pvl outLabel;
// Translate the BandBin group
FileName transFile(transDir + "dawnfcBandBin.trn");
PvlTranslationManager bandBinXlater(labelPvl, transFile.expanded());
bandBinXlater.Auto(outLabel);
// Translate the Archive group
transFile = transDir + "dawnfcArchive.trn";
PvlTranslationManager archiveXlater(labelPvl, transFile.expanded());
archiveXlater.Auto(outLabel);
// Translate the Instrument group
transFile = transDir + "dawnfcInstrument.trn";
PvlTranslationManager instrumentXlater(labelPvl, transFile.expanded());
instrumentXlater.Auto(outLabel);
// Update target if user specifies it
if (!target.isEmpty()) {
PvlGroup &igrp = outLabel.findGroup("Instrument",Pvl::Traverse);
igrp["TargetName"] = target;
}
// Write the BandBin, Archive, and Instrument groups
// to the output cube label
outcube->putGroup(outLabel.findGroup("BandBin", Pvl::Traverse));
outcube->putGroup(outLabel.findGroup("Archive", Pvl::Traverse));
outcube->putGroup(outLabel.findGroup("Instrument", Pvl::Traverse));
// Set the BandBin filter name, center, and width values based on the
// FilterNumber.
PvlGroup &bbGrp(outLabel.findGroup("BandBin", Pvl::Traverse));
int filtno = bbGrp["FilterNumber"];
int center;
int width;
QString filtname;
if(filtno == 1) {
center = 700;
width = 700;
filtname = "Clear_F1";
}
else if(filtno == 2) {
center = 555;
//.........这里部分代码省略.........
示例5: IsisMain
void IsisMain() {
const QString caminfo_program = "caminfo";
UserInterface &ui = Application::GetUserInterface();
QList< QPair<QString, QString> > *general = NULL, *camstats = NULL, *statistics = NULL;
BandGeometry *bandGeom = NULL;
// Get input filename
FileName in = ui.GetFileName("FROM");
// Get the format
QString sFormat = ui.GetAsString("FORMAT");
// if true then run spiceinit, xml default is FALSE
// spiceinit will use system kernels
if(ui.GetBoolean("SPICE")) {
QString parameters = "FROM=" + in.expanded();
ProgramLauncher::RunIsisProgram("spiceinit", parameters);
}
Process p;
Cube *incube = p.SetInputCube("FROM");
// General data gathering
general = new QList< QPair<QString, QString> >;
general->append(MakePair("Program", caminfo_program));
general->append(MakePair("IsisVersion", Application::Version()));
general->append(MakePair("RunDate", iTime::CurrentGMT()));
general->append(MakePair("IsisId", SerialNumber::Compose(*incube)));
general->append(MakePair("From", in.baseName() + ".cub"));
general->append(MakePair("Lines", toString(incube->lineCount())));
general->append(MakePair("Samples", toString(incube->sampleCount())));
general->append(MakePair("Bands", toString(incube->bandCount())));
// Run camstats on the entire image (all bands)
// another camstats will be run for each band and output
// for each band.
if(ui.GetBoolean("CAMSTATS")) {
camstats = new QList< QPair<QString, QString> >;
QString filename = ui.GetAsString("FROM");
int sinc = ui.GetInteger("SINC");
int linc = ui.GetInteger("LINC");
CameraStatistics stats(filename, sinc, linc);
Pvl camPvl = stats.toPvl();
PvlGroup cg = camPvl.findGroup("Latitude", Pvl::Traverse);
camstats->append(MakePair("MinimumLatitude", cg["latitudeminimum"][0]));
camstats->append(MakePair("MaximumLatitude", cg["latitudemaximum"][0]));
cg = camPvl.findGroup("Longitude", Pvl::Traverse);
camstats->append(MakePair("MinimumLongitude", cg["longitudeminimum"][0]));
camstats->append(MakePair("MaximumLongitude", cg["longitudemaximum"][0]));
cg = camPvl.findGroup("Resolution", Pvl::Traverse);
camstats->append(MakePair("MinimumResolution", cg["resolutionminimum"][0]));
camstats->append(MakePair("MaximumResolution", cg["resolutionmaximum"][0]));
cg = camPvl.findGroup("PhaseAngle", Pvl::Traverse);
camstats->append(MakePair("MinimumPhase", cg["phaseminimum"][0]));
camstats->append(MakePair("MaximumPhase", cg["phasemaximum"][0]));
cg = camPvl.findGroup("EmissionAngle", Pvl::Traverse);
camstats->append(MakePair("MinimumEmission", cg["emissionminimum"][0]));
camstats->append(MakePair("MaximumEmission", cg["emissionmaximum"][0]));
cg = camPvl.findGroup("IncidenceAngle", Pvl::Traverse);
camstats->append(MakePair("MinimumIncidence", cg["incidenceminimum"][0]));
camstats->append(MakePair("MaximumIncidence", cg["incidencemaximum"][0]));
cg = camPvl.findGroup("LocalSolarTime", Pvl::Traverse);
camstats->append(MakePair("LocalTimeMinimum", cg["localsolartimeMinimum"][0]));
camstats->append(MakePair("LocalTimeMaximum", cg["localsolartimeMaximum"][0]));
}
// Compute statistics for entire cube
if(ui.GetBoolean("STATISTICS")) {
statistics = new QList< QPair<QString, QString> >;
LineManager iline(*incube);
Statistics stats;
Progress progress;
progress.SetText("Statistics...");
progress.SetMaximumSteps(incube->lineCount()*incube->bandCount());
progress.CheckStatus();
iline.SetLine(1);
for(; !iline.end() ; iline.next()) {
incube->read(iline);
stats.AddData(iline.DoubleBuffer(), iline.size());
progress.CheckStatus();
}
// Compute stats of entire cube
double nPixels = stats.TotalPixels();
double nullpercent = (stats.NullPixels() / (nPixels)) * 100;
double hispercent = (stats.HisPixels() / (nPixels)) * 100;
double hrspercent = (stats.HrsPixels() / (nPixels)) * 100;
double lispercent = (stats.LisPixels() / (nPixels)) * 100;
double lrspercent = (stats.LrsPixels() / (nPixels)) * 100;
//.........这里部分代码省略.........
示例6: IsisMain
//***********************************************************************
// IsisMain()
//***********************************************************************
void IsisMain() {
UserInterface &ui = Application::GetUserInterface();
FileName in = ui.GetFileName("FROM");
FileName outIr = ui.GetFileName("IR");
FileName outVis = ui.GetFileName("VIS");
Pvl lab(in.expanded());
//Checks if in file is rdr
if(lab.hasObject("IMAGE_MAP_PROJECTION")) {
QString msg = "[" + in.name() + "] appears to be an rdr file.";
msg += " Use pds2isis.";
throw IException(IException::User, msg, _FILEINFO_);
}
//Make sure it is a vims cube
try {
PvlObject qube(lab.findObject("QUBE"));
QString id;
id = (QString)qube["INSTRUMENT_ID"];
id = id.simplified().trimmed();
if(id != "VIMS") {
QString msg = "Invalid INSTRUMENT_ID [" + id + "]";
throw IException(IException::Unknown, msg, _FILEINFO_);
}
}
catch(IException &e) {
QString msg = "Input file [" + in.expanded() +
"] does not appear to be " +
"in VIMS EDR/RDR format";
throw IException(IException::Io, msg, _FILEINFO_);
}
FileName tempname(in.baseName() + ".bsq.cub");
Pvl pdsLab(in.expanded());
// It's VIMS, let's figure out if it has the suffix data or not
if(toInt(lab.findObject("QUBE")["SUFFIX_ITEMS"][0]) == 0) {
// No suffix data, we can use processimportpds
ProcessImportPds p;
p.SetPdsFile(in.expanded(), "", pdsLab);
// Set up the temporary output cube
//The temporary cube is set to Real pixeltype, regardless of input pixel type
Isis::CubeAttributeOutput outatt = CubeAttributeOutput("+Real");
p.SetOutputCube(tempname.name(), outatt);
p.StartProcess();
p.EndProcess();
}
else {
// We do it the hard way
ReadVimsBIL(in.expanded(), lab.findObject("QUBE")["SUFFIX_ITEMS"], tempname.name());
}
// Create holder for original labels
OriginalLabel origLabel(pdsLab);
//Now separate the cubes
ProcessByLine l;
PvlGroup status("Results");
//VIS cube
const PvlObject &qube = lab.findObject("Qube");
if(qube["SAMPLING_MODE_ID"][1] != "N/A") {
CubeAttributeInput inattvis = CubeAttributeInput("+1-96");
l.SetInputCube(tempname.name(), inattvis);
Cube *oviscube = l.SetOutputCube("VIS");
oviscube->write(origLabel);
l.StartProcess(ProcessCube);
TranslateVimsLabels(pdsLab, oviscube, VIS);
l.EndProcess();
status += PvlKeyword("VisCreated", "true");
}
else {
status += PvlKeyword("VisCreated", "false");
}
//IR cube
if(qube["SAMPLING_MODE_ID"][0] != "N/A") {
CubeAttributeInput inattir = CubeAttributeInput("+97-352");
l.SetInputCube(tempname.name(), inattir);
Cube *oircube = l.SetOutputCube("IR");
oircube->write(origLabel);
l.StartProcess(ProcessCube);
TranslateVimsLabels(pdsLab, oircube, IR);
l.EndProcess();
status += PvlKeyword("IrCreated", "true");
}
else {
status += PvlKeyword("IrCreated", "false");
}
Application::Log(status);
//Clean up
//.........这里部分代码省略.........