Loading isis/src/base/apps/copylabel/main.cpp +36 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ using namespace std; using namespace Isis; bool copyGroup(Pvl * source, Pvl * mergeTo, QString name); bool copyObject(Pvl * source, Pvl * mergeTo, QString name); bool copyBlob(Cube * from, Cube * to, QString type, QString name, QString fname); void IsisMain() { Loading Loading @@ -95,7 +96,7 @@ void IsisMain() { // Can't copy Instrument group if the the scale factors don't match string msg = "Cannot copy Instruments group when the sample scaling" " factor and line scaling factor do not match"; throw IException(IException::User, msg, _FILEINFO_); // throw IException(IException::User, msg, _FILEINFO_); } bool success = copyGroup(source, mergeTo, "Instrument"); results += PvlKeyword("Instrument", success ? "true" : "false"); Loading @@ -108,7 +109,7 @@ void IsisMain() { if (inOut.bandCount() != sourceCube.bandCount()) { string msg = "Cannot copy BandBin group when the number of bands does" " not match"; throw IException(IException::User, msg, _FILEINFO_); // throw IException(IException::User, msg, _FILEINFO_); } } bool success = copyGroup(source, mergeTo, "Bandbin"); Loading Loading @@ -147,7 +148,7 @@ void IsisMain() { // Can't copy Mapping group if the the scale factors don't match string msg = "Cannot copy Mapping group when the sample scaling" " factor and line scaling factor do not match"; throw IException(IException::User, msg, _FILEINFO_); // throw IException(IException::User, msg, _FILEINFO_); } bool success = copyGroup(source, mergeTo, "Mapping"); results += PvlKeyword("Mapping", success ? "true" : "false"); Loading Loading @@ -194,6 +195,19 @@ void IsisMain() { } } // Any other requested groups if (ui.WasEntered("Objects")) { QString grps = QString(ui.GetString("Objects")).remove(" "); QStringList list = grps.split(","); QString grp; foreach (grp, list) { if (grp.size() != 0) { bool success = copyObject(source, mergeTo, grp); results += PvlKeyword(grp, success ? "true" : "false"); } } } // Any other requested blobs // Expected format is: <Object name>:<Name keyword> if (ui.WasEntered("Blobs")) { Loading @@ -206,7 +220,7 @@ void IsisMain() { if (brk.size() != 2) { string msg = "The blob name [" + blob.toStdString() + "] is" " improperly formatted"; throw IException(IException::User, msg, _FILEINFO_); // throw IException(IException::User, msg, _FILEINFO_); } bool success = copyBlob(&sourceCube, &inOut, brk[1], brk[0], sourceFileName); Loading Loading @@ -255,6 +269,24 @@ bool copyGroup(Pvl * source, Pvl * mergeTo, QString name) { } } bool copyObject(Pvl *source, Pvl *mergeTo, QString name) { try { // The call we're looking to get an exception on is the one just below. PvlObject & toCopy = source->findObject(name, Pvl::Traverse); // PvlObject & isiscube = mergeTo->findObject("IsisCube"); Pvl* isiscube = mergeTo; if (isiscube->hasObject(name)) { isiscube->deleteObject(name); } isiscube->addObject(toCopy); return true; } catch (IException &) { return false; } } bool copyBlob(Cube * from, Cube * to, QString name, QString type, QString fname) { try { Blob blob(name, type, fname); Loading Loading
isis/src/base/apps/copylabel/main.cpp +36 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ using namespace std; using namespace Isis; bool copyGroup(Pvl * source, Pvl * mergeTo, QString name); bool copyObject(Pvl * source, Pvl * mergeTo, QString name); bool copyBlob(Cube * from, Cube * to, QString type, QString name, QString fname); void IsisMain() { Loading Loading @@ -95,7 +96,7 @@ void IsisMain() { // Can't copy Instrument group if the the scale factors don't match string msg = "Cannot copy Instruments group when the sample scaling" " factor and line scaling factor do not match"; throw IException(IException::User, msg, _FILEINFO_); // throw IException(IException::User, msg, _FILEINFO_); } bool success = copyGroup(source, mergeTo, "Instrument"); results += PvlKeyword("Instrument", success ? "true" : "false"); Loading @@ -108,7 +109,7 @@ void IsisMain() { if (inOut.bandCount() != sourceCube.bandCount()) { string msg = "Cannot copy BandBin group when the number of bands does" " not match"; throw IException(IException::User, msg, _FILEINFO_); // throw IException(IException::User, msg, _FILEINFO_); } } bool success = copyGroup(source, mergeTo, "Bandbin"); Loading Loading @@ -147,7 +148,7 @@ void IsisMain() { // Can't copy Mapping group if the the scale factors don't match string msg = "Cannot copy Mapping group when the sample scaling" " factor and line scaling factor do not match"; throw IException(IException::User, msg, _FILEINFO_); // throw IException(IException::User, msg, _FILEINFO_); } bool success = copyGroup(source, mergeTo, "Mapping"); results += PvlKeyword("Mapping", success ? "true" : "false"); Loading Loading @@ -194,6 +195,19 @@ void IsisMain() { } } // Any other requested groups if (ui.WasEntered("Objects")) { QString grps = QString(ui.GetString("Objects")).remove(" "); QStringList list = grps.split(","); QString grp; foreach (grp, list) { if (grp.size() != 0) { bool success = copyObject(source, mergeTo, grp); results += PvlKeyword(grp, success ? "true" : "false"); } } } // Any other requested blobs // Expected format is: <Object name>:<Name keyword> if (ui.WasEntered("Blobs")) { Loading @@ -206,7 +220,7 @@ void IsisMain() { if (brk.size() != 2) { string msg = "The blob name [" + blob.toStdString() + "] is" " improperly formatted"; throw IException(IException::User, msg, _FILEINFO_); // throw IException(IException::User, msg, _FILEINFO_); } bool success = copyBlob(&sourceCube, &inOut, brk[1], brk[0], sourceFileName); Loading Loading @@ -255,6 +269,24 @@ bool copyGroup(Pvl * source, Pvl * mergeTo, QString name) { } } bool copyObject(Pvl *source, Pvl *mergeTo, QString name) { try { // The call we're looking to get an exception on is the one just below. PvlObject & toCopy = source->findObject(name, Pvl::Traverse); // PvlObject & isiscube = mergeTo->findObject("IsisCube"); Pvl* isiscube = mergeTo; if (isiscube->hasObject(name)) { isiscube->deleteObject(name); } isiscube->addObject(toCopy); return true; } catch (IException &) { return false; } } bool copyBlob(Cube * from, Cube * to, QString name, QString type, QString fname) { try { Blob blob(name, type, fname); Loading