• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

C:/CVUT/diplomka/Automata_editor/sources/main.cpp

Go to the documentation of this file.
00001 #include "constants.h"
00002 
00003 #include "mainwindow.h"
00004 
00005 #include <QtPlugin>
00006 #include <QApplication>
00007 
00008 /*! \mainpage AutomataEditor
00009  *
00010  * \section intro_sec Introduction
00011  *
00012  * AutomataEditor is vector editor for drawing finite automata according to VauCanSon-G format (LaTeX package).
00013  * Editor supports export to several vector formats, e.g. EPS, VauCanSon-G, GraphML.
00014  * Then implements basic operations over finite automata, including simulation of DFA/NFA, basic algorithms
00015  * (determinization, minimalization, ...) and transition table export.
00016  *
00017  * \section subversion Subversion
00018  * 
00019  * Curretly on webdev (contact zdarekj@fel.cvut.cz for access):
00020  *     https://webdev.felk.cvut.cz/~zdarekj/svn/Automata_editor
00021  *    
00022  * Project is planned to be moved to sourceforge:
00023  *     http://sourceforge.net/projects/automataeditor
00024  *
00025  * \section install_sec Installation
00026  *
00027  * \subsection step1 Step 1: Install Qt 4.6.3 (supported and tested version)
00028  * \subsection step2 Step 2: Check Automata_Editor.pro and the other subproject files (*.pro)
00029  * \subsection step3 Step 3: Run qmake in application directory (contains Automata_editor.pro)
00030  * \subsection step4 Step 4: Run make (nmake) in application directory
00031  *
00032  * \section wrapper GraphViz wrapper
00033  * If don't wish to have GraphViz positioner, comment gvwrapper in Automata_editor.pro:
00034  * \code SUBDIRS += gvwrapper \endcode
00035  *
00036  * Widows: GraphViz version 2.26.3
00037  * Linux systems: GraphViz version 2.20.2-8 (for other version modification of gvwrapper could be needed)
00038  *
00039  * GraphViz version is checked in runtime and can be set globally in sources.pro:
00040  * \code DEFINES += GRAPHVIZ_VERSION=\\\"2.26.3\\\" \endcode
00041  * \note escaping \\ and \" is required for make define's value a string
00042  * or it's possible to change GraphViz supported libraries in constants.h:
00043  * \code GRAPHVIZ_VERSION    "2.26.3" \endcode
00044  *
00045  *
00046  * For other versions of some modifications in gvwrapper will be probably needed,
00047  * because GraphViz interface was changed somewhere between 2.20.x and 2.26.x
00048  *
00049  * It's possible to change GraphViz supported libraries in constants.h:
00050  * \code GRAPHVIZ_VERSION    "2.26.3"    // this is version which is required in runtime \endcode
00051  *
00052  * \section devel Developement IDE
00053  *
00054  * Possible to use QtCreator and load existing project Automata_editor.pro
00055  *
00056  * \subsection eclipse Eclipse
00057  *
00058  * Qt Eclipse Integration available - http://doc.qt.nokia.com/qt-eclipse-1.5/index.html
00059  *
00060  * \subsection visualstudio Visual Studio project
00061  *
00062  * Qt Visual Studio Add-in available - http://doc.qt.nokia.com/vs-add-in-1.0/index.html
00063  *
00064  * \subsubsection vs_issues Known issues
00065  * \li First try to compile gvwrapper fails, but try it again should solve it
00066  *
00067  * \section plugin Plugin HOWTO subproject
00068  *
00069  * Simple project which shows how to implement custom algorithm as external dynamically loaded plugin.
00070  * For build this project allow it in Automata_editor.pro:
00071  * \code SUBDIRS += plugin_howto \endcode
00072  *
00073  * \section features Features settings
00074  *
00075  * \subsection svg SVG support
00076  *
00077  * If don't wish SVG support, comment usage of Qt SVG Module in core project sources.pro
00078  * \code QT += svg \endcode
00079  *
00080  * \subsection opengl OpenGL support
00081  *
00082  * It's possible to experimentally turn on OpenGL drawing by allowing it in sources.pro
00083  * \code QT += opengl \endcode
00084  */
00085 
00086 
00087 // on windows release turn on logging to file
00088 #if defined(QT_NO_DEBUG) && defined(_WINDOWS)
00089 #   define LOGGING_ENABLED
00090 #endif
00091 
00092 #ifdef LOGGING_ENABLED
00093     #include <QFile>
00094     #include <QTextStream>
00095     #include <stdlib.h>
00096 
00097     QFile gLogFile("automataLog.txt");
00098 
00099 void automataMsgHandler(QtMsgType type, const char *msg)
00100 {
00101     gLogFile.open(QIODevice::Append);
00102     QTextStream log(&gLogFile);
00103     switch (type) 
00104     {                       
00105         case QtDebugMsg:
00106             log << "Debug: " << msg << endl;
00107             fprintf(stdout, "Debug: %s\n", msg);            
00108             break;
00109         case QtWarningMsg:
00110             log << "Warning: " << msg << endl;            
00111             fprintf(stderr, "Warning: %s\n", msg);
00112             break;
00113         case QtCriticalMsg:
00114             log << "Critical: " << msg << endl;            
00115             fprintf(stderr, "Critical: %s\n", msg);
00116             break;
00117         case QtFatalMsg:            
00118             log << "Fatal: " << msg << endl;            
00119             fprintf(stderr, "Fatal: %s\n", msg);
00120             abort();
00121     }
00122     gLogFile.close();
00123 }
00124 
00125 #endif
00126 
00127 void printHelp()
00128 {
00129     QTextStream out(stdout);
00130 
00131     if (out.status() == QTextStream::Ok)
00132     {
00133         out << "AutomataEditor v 2.0" << endl
00134             << "Usage:" << endl
00135             << "\tAutomataEditor filename" << endl
00136             << "\tAutomataEditor [opions] -f|--file filename" << endl
00137             << "Options:" << endl
00138             << "-h,--help\t\tthis help message" << endl
00139             << "-f,--file\t\topen specified file" << endl
00140             << endl
00141             << "Homepage: http://sourceforge.net/projects/automataeditor" << endl
00142             << "Milan Kriz" << endl
00143             << "\tmilan.kriz@centrum.cz" << endl
00144             << "\tkrizmil2@fel.cvut.cz" << endl
00145             << "Jan Zdarek" << endl
00146             << "\tzdarekj@fel.cvut.cz" << endl;
00147     }
00148     else
00149     {
00150         RELLOG("Cannot output standard output!!! (" << out.status() << ")");
00151     }
00152 }
00153 
00154 Q_IMPORT_PLUGIN(algorithms)
00155 
00156 int main(int argc, char **argv)
00157 {
00158     Q_INIT_RESOURCE(application);
00159     #ifdef LOGGING_ENABLED
00160         gLogFile.open(QIODevice::WriteOnly); // erase old log file
00161         gLogFile.close();
00162         qInstallMsgHandler(automataMsgHandler);
00163     #endif
00164 
00165     QString fileName;
00166     if (argc > 1)
00167     {
00168         QStringList args;
00169         for(int i=1; i<argc; ++i)
00170         {
00171             args << argv[i];
00172         }
00173 
00174         if (args.contains("-h") || args.contains("--help"))
00175         {
00176             printHelp();
00177             return 0;
00178         }
00179 
00180         if (args.count() == 1)
00181         {
00182             fileName = args[0];
00183         }
00184         else if (args.contains("-f") && args.length() > args.indexOf("-f"))
00185         {
00186             fileName = args[args.indexOf("-f")+1];
00187         }
00188         else if (args.contains("-file") && args.length() > args.indexOf("-file"))
00189         {
00190             fileName = args[args.indexOf("-file")+1];
00191         }
00192         else if(!args.isEmpty())
00193         {
00194             printHelp();
00195             return 1;
00196         }
00197     }
00198 
00199     QApplication app(argc, argv);
00200 
00201     MainWindow window(fileName);
00202     window.show();
00203     return app.exec();
00204 }

Generated on Tue Jan 4 2011 03:03:23 for Autoamata editor by  doxygen 1.7.0