Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

omgui.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Tim Sutton   *
00003  *   tim@linfiniti.com   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
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       //division and modulus must be done with the same type as the template class 
00290       //otherwise a warning is generated
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       { //short form
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       { //long form
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

Generated on Mon Apr 28 15:09:20 2008 for openModellerDesktop by  doxygen 1.4.1-20050210