Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Commit [r44] Maximize Restore History

queue finished, ConsoleManager

mlusteck 2009-09-02

added /trunk/ConsoleManager.cpp
changed /trunk/CalcQueue.h
changed /trunk/ArgumentParser.cpp
changed /trunk/EnlargerDialog.cpp
changed /trunk/ImageEnlarger.pro
changed /trunk/ArgumentParser.h
changed /trunk/EnlargerDialog.h
changed /trunk/main.cpp
changed /trunk/CalcQueue.cpp
changed /trunk/EnlargerThread.cpp
changed /trunk/enlargerdialog.ui
copied /trunk/CommandLineOut.h -> /trunk/ConsoleManager.h
/trunk/ConsoleManager.cpp Diff Switch to side-by-side view
Loading...
/trunk/CalcQueue.h Diff Switch to side-by-side view
Loading...
/trunk/ArgumentParser.cpp Diff Switch to side-by-side view
Loading...
/trunk/EnlargerDialog.cpp Diff Switch to side-by-side view
Loading...
/trunk/ImageEnlarger.pro Diff Switch to side-by-side view
Loading...
/trunk/ArgumentParser.h Diff Switch to side-by-side view
Loading...
/trunk/EnlargerDialog.h Diff Switch to side-by-side view
Loading...
/trunk/main.cpp Diff Switch to side-by-side view
Loading...
/trunk/CalcQueue.cpp Diff Switch to side-by-side view
Loading...
/trunk/EnlargerThread.cpp Diff Switch to side-by-side view
Loading...
/trunk/enlargerdialog.ui Diff Switch to side-by-side view
Loading...
/trunk/CommandLineOut.h to /trunk/ConsoleManager.h
--- a/trunk/CommandLineOut.h
+++ b/trunk/ConsoleManager.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------
 
 SmillaEnlarger  -  resize, especially magnify bitmaps in high quality
-    CommandLineOut.h: QObject for accepting signals from EnlargerThread for command line output
+    ConsoleManager.h: command line functionality
 
 Copyright (C) 2009 Mischa Lusteck
 
@@ -20,31 +20,73 @@
 along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 ---------------------------------------------------------------------- */
-#ifndef COMMANDLINEOUT_H
-#define COMMANDLINEOUT_H
+#ifndef CONSOLEMANAGER_H
+#define CONSOLEMANAGER_H
 
 #include <QString>
 #include <QObject>
+#include <QImage>
 #include <iostream>
+
+#include "ArgumentParser.h"
+#include "ImageEnlargerCode/EnlargeParam.h"
 
 using namespace std;
 
+class EnlargerThread;
+class EnlargerDialog;
+
+// QObject for console output
 class EnlargerOut : public QObject {
    Q_OBJECT
 
    QString dstName;
+   bool ended;
 public:
-   EnlargerOut( const QString &  dstNam  ) : QObject(), dstName(dstNam)
-      { cout<<"Calculating "<<dstName.toStdString()<<": ["<<flush; }
+   EnlargerOut( void ) : QObject() { ended=false;}
    ~EnlargerOut( void ) {}
+   void SetName( const QString & name ) { dstName = name; }
+   void StartMessage( void ) { cout<<"Calculating '"<<dstName.toStdString()<<"' - "<<flush; }
 
 public slots:
-    void PrintProgress( int  p ) { cout<<"."<<flush; if( p>=100 ) cout<<"]"<<flush; }
+    void PrintProgress( int  p ) {
+       if( !ended ) {  cout<<"\rCalculating '"<<dstName.toStdString()<<"' - [ "<<p<<"% ]   "<<flush; } }
     void badAlloc( void )
-       { cout<<" ERROR ]\nCould not allocate enough memory for '"<<dstName.toStdString()<<"'./n"<<flush; }
+       { cout<<"\n[ ERROR ]\nCould not allocate enough memory for '"<<dstName.toStdString()<<"'.\n"<<flush; ended=true; }
     void imageNotSaved( void )
-       { cout<<" \n[ ERROR ] - Could not save image '"<<dstName.toStdString()<<"'./n"<<flush; }
-    void imageSaved( void ) { }
+       { cout<<" \n[ ERROR ] - Could not save image '"<<dstName.toStdString()<<"'.\n"<<flush; ended=true;  }
+    void imageSaved( void ) { cout<<" OK.\n"<<flush; ended=true; }
  };
 
-#endif // COMMANDLINEOUT_H
+class ConsoleManager : public QObject {
+   Q_OBJECT
+
+   bool parseError;
+   ArgumentParser myParser;
+   IntegerOption oZoom;
+   IntegerOption oWidth,   oHeight;
+
+   IntegerOption oSharp,   oFlat;
+   IntegerOption oDeNoise, oPreSharp;
+   IntegerOption oDither,  oFNoise;
+
+   StringOption oOutput;
+   BasicOption  oHelp, oInteractive;
+
+   EnlargerOut myEnOut;
+
+   QString dstName;
+
+public:
+   ConsoleManager( int argc, char *argv[] );
+   ~ConsoleManager( void ) {}
+   bool UseGUI( void );
+   void SetupEnlargerDialog ( EnlargerDialog & theDialog );
+   bool StartConsoleEnlarge  ( EnlargerThread & myThread );
+   bool TryOpenSource( QString filename, QImage & srcImage );
+   void PrintHelp( void );
+
+};
+
+
+#endif // CONSOLEMANAGER_H