Commit 107c7876 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED properly formatting CamiTK log message for translation

parent 1c3b1c70
......@@ -96,7 +96,7 @@ Action::ApplyStatus RegionGrowing::apply() {
// this call works only with a GUI (i.e. if theWidget exists)
if ((input == NULL) || (rgWidget == NULL)) {
CAMITK_WARNING("Cannot be called without a GUI (input data are required to be set manually. Action Aborted.")
CAMITK_WARNING(tr("Cannot be called without a GUI (input data are required to be set manually. Action Aborted."))
return ABORTED;
}
......
......@@ -66,7 +66,7 @@ DicomComponent::DicomComponent(DicomSerie* dicomSerie) throw(AbortException) : I
ippSorter.SetComputeZSpacing(true);
ippSorter.SetZSpacingTolerance(0.001);
if (!ippSorter.Sort(stdFileNames)) {
CAMITK_ERROR("IPPSorter sorting failed. Try to adjust Z spacing tolerance.")
CAMITK_ERROR(tr("IPPSorter sorting failed. Try to adjust Z spacing tolerance."))
files = stdFileNames;
zSpacing = DicomParser::getZSpacing(files);
}
......@@ -142,7 +142,7 @@ DicomComponent::DicomComponent(DicomSerie* dicomSerie) throw(AbortException) : I
updateLUT();
}
else {
CAMITK_WARNING("DicomComponent::DicomComponent(..): image LUT is null.");
CAMITK_WARNING(tr("Image LUT is null."))
}
}
......@@ -173,13 +173,13 @@ camitk::ImageOrientationHelper::PossibleImageOrientations DicomComponent::readDi
gdcm::Tag iopTag = gdcm::Tag(0x0020, 0x0037);
scanner.AddTag(iopTag);
// Scan should never failed, since DicomParser::parseDirectory() has already filter files.
CAMITK_ERROR_IF((!scanner.Scan(fileNames)),"Scan failed looking for tag (0x0020, 0x0037) Image Orientation Patient.")
CAMITK_ERROR_IF((!scanner.Scan(fileNames)),tr("Scan failed looking for tag (0x0020, 0x0037) Image Orientation Patient."))
// Check value tag exists
gdcm::Scanner::TagToValue const& ttv = scanner.GetMapping(fileNames[0].c_str());
gdcm::Scanner::TagToValue::const_iterator it = ttv.find(iopTag);
if (!(it != ttv.end())) {
CAMITK_WARNING("No tag (0x0020, 0x0037) Image Orientation Patient found on image \"" + QString::fromStdString(fileNames[0]) + "\"");
CAMITK_WARNING(tr("No tag (0x0020, 0x0037) Image Orientation Patient found on image \"%1\"").arg(QString::fromStdString(fileNames[0])))
return ImageOrientationHelper::UNKNOWN;
}
......@@ -287,7 +287,7 @@ camitk::ImageOrientationHelper::PossibleImageOrientations DicomComponent::readDi
}
// should never return UNKNOW
CAMITK_WARNING("DicomComponent::readDirectCosinesAngle(..): no orientation found for this image (direct cosines).")
CAMITK_WARNING(tr("No orientation found for this image (direct cosines)."))
return ImageOrientationHelper::UNKNOWN;
}
......
......@@ -37,8 +37,9 @@ DicomDialog::DicomDialog(QList<DicomDialogEntry*> elements): QDialog() {
ui.setupUi(this);
if (elements.isEmpty()) {
CAMITK_ERROR("No DICOM image files found");
throw camitk::AbortException("No DICOM image files found.");;
QString msg = tr("No DICOM image files found");
CAMITK_ERROR(msg)
throw camitk::AbortException(msg.toStdString());
}
// set table size
......
......@@ -52,7 +52,7 @@ QList<DicomSerie*> DicomParser::parseDirectory(const QString& directory) {
dicomImageScanner.AddTag(tagPixelData);
dicomImageScanner.Scan(fileNames);
CAMITK_BASIC_TRACE("DicomParser::parseDirectory(..): parsing files for DICOM image files");
CAMITK_BASIC_TRACE(QObject::tr("Parsing files for DICOM image files"))
foreach(std::string file, dicomImageScanner.GetFilenames()) {
// 1st check the file is a valid DICOM file
if (dicomImageScanner.IsKey(file.c_str())) {
......@@ -60,15 +60,15 @@ QList<DicomSerie*> DicomParser::parseDirectory(const QString& directory) {
gdcm::Scanner::TagToValue const& ttv = dicomImageScanner.GetMapping(file.c_str());
gdcm::Scanner::TagToValue::const_iterator it = ttv.find( tagPixelData );
if ( it != ttv.end() ) {
CAMITK_BASIC_TRACE("DicomParser::parseDirectory(..):" + QString::fromStdString(file) + " is a DICOM image file");
CAMITK_BASIC_TRACE(QObject::tr("%1 is a DICOM image file").arg(QString::fromStdString(file)))
imageFileNames.push_back(file);
}
else {
CAMITK_BASIC_TRACE("DicomParser::parseDirectory(..)" + QString::fromStdString(file) + " is a DICOM file WITHOUT PixelData information");
CAMITK_BASIC_TRACE(QObject::tr("%1 is a DICOM file WITHOUT PixelData information").arg(QString::fromStdString(file)))
}
}
else {
CAMITK_BASIC_TRACE("DicomParser::parseDirectory(..)" + QString::fromStdString(file) + " is not a valid DICOM file");
CAMITK_BASIC_TRACE(QObject::tr("%1 is not a valid DICOM file").arg(QString::fromStdString(file)))
}
}
......@@ -225,7 +225,7 @@ double DicomParser::getZSpacing(const std::vector<std::string>& serieFileNames)
std::string file = serieFileNames.at(0);
const char* value = scanner.GetValue(file.c_str(), zSpacingTag);
if (!value) {
CAMITK_BASIC_ERROR("No Z spacing found on image: " + QString::fromStdString(serieFileNames.at(0)));
CAMITK_BASIC_ERROR(QObject::tr("No Z spacing found on image: \"%1\"").arg(QString::fromStdString(serieFileNames.at(0))))
return 1.0;
}
return atof(value);
......
......@@ -33,6 +33,7 @@
#include <QMap>
#include <QList>
#include <QString>
#include <QCoreApplication>
// C++ includes
#include <stdlib.h>
......@@ -48,6 +49,8 @@
*
*/
class DicomParser {
Q_DECLARE_TR_FUNCTIONS(DicomParser)
public:
......
......@@ -130,7 +130,7 @@ Component* DicomItkComponentExtension::open(const QString& directoryName) throw
}
catch (AbortException e) {
CAMITK_ERROR(tr("DicomItkComponentExtension exception") + e.what())
CAMITK_ERROR(tr("Aborting with exception %1").arg(e.what()))
return NULL;
}
......
......@@ -117,7 +117,7 @@ vtkSmartPointer<vtkImageData> ItkImageComponent::readVolume(const QString& filen
catch (itk::ExceptionObject& err ) {
std::stringstream buffer;
err.Print(buffer);
CAMITK_ERROR(tr("ITK exception caught while reading the volume):\n") + err.what() + "\n" + QString(buffer.str().c_str()) + "\n")
CAMITK_ERROR(tr("ITK exception caught while reading the volume:\n%1\n%2").arg(err.what(),buffer.str().c_str()))
return NULL;
}
......
......@@ -72,7 +72,7 @@ Component* ItkImageComponentExtension::open(const QString& fileName) throw (Abor
res = new ItkImageComponent(fileName);
}
catch (const AbortException& e) {
CAMITK_ERROR(tr("CamiTK exception:") + e.what());
CAMITK_ERROR(tr("CamiTK exception: %1").arg(e.what()));
throw e;
}
return res;
......@@ -285,7 +285,7 @@ template<class ImageType> bool ItkImageComponentExtension::saveImage(ImageCompon
catch (const itk::ExceptionObject& err ) {
std::stringstream buffer;
err.Print(buffer);
CAMITK_BASIC_ERROR("ItkImageComponentExtension::saveImage(): saving Error: problem occurs while saving file:" + filename + ": ITK Exception: " + err.what() + "\n" + QString(buffer.str().c_str()) + "\n");
CAMITK_BASIC_ERROR(tr("Saving Error: problem occurs while saving file \"%1\", ITK Exception: %2\n%3").arg(filename,err.what(),buffer.str().c_str()))
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment