00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef OMGUI_H
00022 #define OMGUI_H
00023 #include "omgmodellerplugininterface.h"
00024 #include "omgscraperplugininterface.h"
00025 class QString;
00026 class QColor;
00027 class QDomDocument;
00028 class QDomElement;
00029 class OmgLocality;
00030 class OmgLayerSet;
00031 #include <QHash>
00032 #include <QPair>
00033 #include <QImage>
00039 class OMG_LIB_EXPORT Omgui
00040 {
00041 public:
00050 static const QString userSettingsDirPath();
00059 static const QString userAlgorithmProfilesDirPath();
00060
00069 static const QString fileSelectorCachePath();
00078 static const QString userLayersetDirPath();
00083 static const QString pluginDirPath();
00084
00085
00091 static const QString getModelOutputDir();
00092
00097 typedef QMap<QString,OmgLayerSet> LayerSetMap;
00101 static Omgui::LayerSetMap getAvailableLayerSets();
00102
00108 static QStringList sortList(QStringList theList);
00109
00114 static QStringList uniqueList(QStringList theList);
00115
00122 static QString getLayers(QString theBaseDir);
00123
00128 static QStringList getExperimentsList();
00129
00136 static QHash<QString,QString> getOutputFormats();
00144 static QHash<QString,QPair<double,double> > getOutputFormatRanges();
00145
00153 static QHash<QString,float> getOutputFormatNoData();
00154
00160 static QHash<QString,QString> getOutputFormatNotes();
00161
00165 static QString getOutputFormatExtension();
00166
00172 static bool createTextFile(QString theFileName, QString theData);
00173
00178 static QString readTextFile(QString theFileName);
00179
00185 static QString xmlEncodeAmpersands(QString theString);
00191 static QString xmlEncode(QString theString);
00192
00197 static void xmlEncodeInPlace(QString &theString);
00198
00204 static QString xmlDecode(QString theString);
00205
00210 static void xmlDecodeInPlace(QString &theString);
00211
00215 static QColor randomColour();
00219 static QString defaultStyleSheet();
00223 static QString getHtmlHeader();
00227 static QString getHtmlFooter();
00234 static bool deleteShapeFile(QString theFileBase);
00241 static bool localitiesToShapefile(QString theShapefileName,OmgLocalities const &theLocalities);
00245 static QString i18nPath();
00248 static QStringList i18nList();
00249
00253 enum TimeForm {longTimeForm,shortTimeForm} ;
00254
00259 static QString version();
00260
00261 static void createThumbnail(QString theTopLabel,
00262 QString theBottomLabel,
00263 QString theSourceImageFileName,
00264 QString theOutputFileName);
00265
00285 template <class T>
00286 static QString secondsToString(T theSeconds, Omgui::TimeForm theForm=Omgui::shortTimeForm)
00287 {
00288 QString myString;
00289
00290
00291 int mySecsPerHour = 3600;
00292 int mySecsPerMinute = 60;
00293 int myHours = static_cast<int> (theSeconds / mySecsPerHour);
00294 int myRemainder = static_cast<int> (theSeconds % mySecsPerHour);
00295 int myMinutes = static_cast<int> (myRemainder / mySecsPerMinute);
00296 int mySeconds = static_cast<int> (myRemainder % mySecsPerMinute);
00297 if (theForm == Omgui::shortTimeForm)
00298 {
00299 if (myHours > 0)
00300 {
00301 myString += QString::number(myHours) + " " + QObject::tr("h") + " ";
00302 }
00303 if (myMinutes > 0)
00304 {
00305 myString += QString::number(myMinutes) + " " + QObject::tr("m") + " ";
00306 }
00307 if (mySeconds > 0)
00308 {
00309 myString += QString::number(mySeconds) + " " + QObject::tr("s") + " ";
00310 }
00311 }
00312 else
00313 {
00314 if (myHours > 0)
00315 {
00316 myString += QString::number(myHours) + " " + QObject::tr("Hours") + " ";
00317 }
00318 if (myMinutes > 0)
00319 {
00320 myString += QString::number(myMinutes) + " " + QObject::tr("Minutes") + " ";
00321 }
00322 if (mySeconds > 0)
00323 {
00324 myString += QString::number(mySeconds) + " " + QObject::tr("Seconds") + " ";
00325 }
00326
00327 }
00328 return myString;
00329 }
00330
00331 private:
00339 static void traverseDirectories(const QString theDirName, QDomDocument &theDocument, QDomElement &theParentElement);
00340
00341 };
00342
00343
00344 #endif