diff --git a/src/Tools/ImageTools/ImageConv/CmdLine.cpp b/src/Tools/ImageTools/ImageConv/CmdLine.cpp deleted file mode 100644 index 009d45e960..0000000000 --- a/src/Tools/ImageTools/ImageConv/CmdLine.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/*------------------------------------------------------ - CCmdLine - - A utility for parsing command lines. - - Copyright (C) 1999 Chris Losinger, Smaller Animals Software. - http://www.smalleranimals.com - - This software is provided 'as-is', without any express - or implied warranty. In no event will the authors be - held liable for any damages arising from the use of this software. - - Permission is granted to anyone to use this software - for any purpose, including commercial applications, and - to alter it and redistribute it freely, subject to the - following restrictions: - - 1. The origin of this software must not be misrepresented; - you must not claim that you wrote the original software. - If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, - and must not be misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. - - See SACmds.h for more info. -------------------------------------------------------*/ - -// if you're using MFC, you'll need to un-comment this line -// #include "stdafx.h" - -#include "CmdLine.h" -#ifdef Q_WS_WIN -# include "crtdbg.h" -#endif - -/*------------------------------------------------------ - int CCmdLine::SplitLine(int argc, char **argv) - - parse the command line into switches and arguments - - returns number of switches found -------------------------------------------------------*/ -int CCmdLine::SplitLine(int argc, char **argv) -{ - clear(); - - StringType curParam; // current argv[x] - - // skip the exe name (start with i = 1) - for (int i = 1; i < argc; i++) - { - // if it's a switch, start a new CCmdLine - if (IsSwitch(argv[i])) - { - curParam = argv[i]; - - StringType arg; - - // look at next input string to see if it's a switch or an argument - if (i + 1 < argc) - { - if (!IsSwitch(argv[i + 1])) - { - // it's an argument, not a switch - arg = argv[i + 1]; - - // skip to next - i++; - } - else - { - arg = ""; - } - } - - // add it - CCmdParam cmd; - - // only add non-empty args - if (arg != "") - { - cmd.m_strings.push_back(arg); - } - - // add the CCmdParam to 'this' - pair res = insert(CCmdLine::value_type(curParam, cmd)); - - } - else - { - // it's not a new switch, so it must be more stuff for the last switch - - // ...let's add it - CCmdLine::iterator theIterator; - - // get an iterator for the current param - theIterator = find(curParam); - if (theIterator!=end()) - { - (*theIterator).second.m_strings.push_back(argv[i]); - } - else - { - // ?? - } - } - } - - return size(); -} - -/*------------------------------------------------------ - - protected member function - test a parameter to see if it's a switch : - - switches are of the form : -x - where 'x' is one or more characters. - the first character of a switch must be non-numeric! - -------------------------------------------------------*/ - -bool CCmdLine::IsSwitch(const char *pParam) -{ - if (pParam==NULL) - return false; - - // switches must non-empty - // must have at least one character after the '-' - int len = strlen(pParam); - if (len <= 1) - { - return false; - } - - // switches always start with '-' - if (pParam[0]=='-') - { - // allow negative numbers as arguments. - // ie., don't count them as switches -#ifdef Q_WS_WIN - return (!isdigit(pParam[1])); -#else - return true; -#endif - } - else - { - return false; - } -} - -/*------------------------------------------------------ - bool CCmdLine::HasSwitch(const char *pSwitch) - - was the switch found on the command line ? - - ex. if the command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.HasSwitch("-a") true - cmdLine.HasSwitch("-z") false -------------------------------------------------------*/ - -bool CCmdLine::HasSwitch(const char *pSwitch) -{ - CCmdLine::iterator theIterator; - theIterator = find(pSwitch); - return (theIterator!=end()); -} - -/*------------------------------------------------------ - - StringType CCmdLine::GetSafeArgument(const char *pSwitch, int iIdx, const char *pDefault) - - fetch an argument associated with a switch . if the parameter at - index iIdx is not found, this will return the default that you - provide. - - example : - - command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.GetSafeArgument("-a", 0, "zz") p1 - cmdLine.GetSafeArgument("-a", 1, "zz") p2 - cmdLine.GetSafeArgument("-b", 0, "zz") p4 - cmdLine.GetSafeArgument("-b", 1, "zz") zz - -------------------------------------------------------*/ - -StringType CCmdLine::GetSafeArgument(const char *pSwitch, int iIdx, const char *pDefault) -{ - StringType sRet; - - if (pDefault!=NULL) - sRet = pDefault; - - try - { - sRet = GetArgument(pSwitch, iIdx); - } - catch (...) - { - } - - return sRet; -} - -/*------------------------------------------------------ - - StringType CCmdLine::GetArgument(const char *pSwitch, int iIdx) - - fetch a argument associated with a switch. throws an exception - of (int)0, if the parameter at index iIdx is not found. - - example : - - command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.GetArgument("-a", 0) p1 - cmdLine.GetArgument("-b", 1) throws (int)0, returns an empty string - -------------------------------------------------------*/ - -StringType CCmdLine::GetArgument(const char *pSwitch, int iIdx) -{ - if (HasSwitch(pSwitch)) - { - CCmdLine::iterator theIterator; - - theIterator = find(pSwitch); - if (theIterator!=end()) - { - if ((*theIterator).second.m_strings.size() > (unsigned)iIdx) - { - return (*theIterator).second.m_strings[iIdx]; - } - } - } - - throw (int)0; - - return ""; -} - -/*------------------------------------------------------ - int CCmdLine::GetArgumentCount(const char *pSwitch) - - returns the number of arguments found for a given switch. - - returns -1 if the switch was not found - -------------------------------------------------------*/ - -int CCmdLine::GetArgumentCount(const char *pSwitch) -{ - int iArgumentCount = -1; - - if (HasSwitch(pSwitch)) - { - CCmdLine::iterator theIterator; - - theIterator = find(pSwitch); - if (theIterator!=end()) - { - iArgumentCount = (*theIterator).second.m_strings.size(); - } - } - - return iArgumentCount; -} diff --git a/src/Tools/ImageTools/ImageConv/CmdLine.h b/src/Tools/ImageTools/ImageConv/CmdLine.h deleted file mode 100644 index 88a965a70b..0000000000 --- a/src/Tools/ImageTools/ImageConv/CmdLine.h +++ /dev/null @@ -1,235 +0,0 @@ -/*------------------------------------------------------ - CCmdLine - - A utility for parsing command lines. - - Copyright (C) 1999 Chris Losinger, Smaller Animals Software. - http://www.smalleranimals.com - - This software is provided 'as-is', without any express - or implied warranty. In no event will the authors be - held liable for any damages arising from the use of this software. - - Permission is granted to anyone to use this software - for any purpose, including commercial applications, and - to alter it and redistribute it freely, subject to the - following restrictions: - - 1. The origin of this software must not be misrepresented; - you must not claim that you wrote the original software. - If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, - and must not be misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. - - ------------------------- - - Example : - - Our example application uses a command line that has two - required switches and two optional switches. The app should abort - if the required switches are not present and continue with default - values if the optional switches are not present. - - Sample command line : - MyApp.exe -p1 text1 text2 -p2 "this is a big argument" -opt1 -55 -opt2 - - Switches -p1 and -p2 are required. - p1 has two arguments and p2 has one. - - Switches -opt1 and -opt2 are optional. - opt1 requires a numeric argument. - opt2 has no arguments. - - Also, assume that the app displays a 'help' screen if the '-h' switch - is present on the command line. - - #include "CmdLine.h" - - void main(int argc, char **argv) - { - // our cmd line parser object - CCmdLine cmdLine; - - // parse argc,argv - if (cmdLine.SplitLine(argc, argv) < 1) - { - // no switches were given on the command line, abort - ASSERT(0); - exit(-1); - } - - // test for the 'help' case - if (cmdLine.HasSwitch("-h")) - { - show_help(); - exit(0); - } - - // get the required arguments - StringType p1_1, p1_2, p2_1; - try - { - // if any of these fail, we'll end up in the catch() block - p1_1 = cmdLine.GetArgument("-p1", 0); - p1_2 = cmdLine.GetArgument("-p1", 1); - p2_1 = cmdLine.GetArgument("-p2", 0); - - } - catch (...) - { - // one of the required arguments was missing, abort - ASSERT(0); - exit(-1); - } - - // get the optional parameters - - // convert to an int, default to '100' - int iOpt1Val = atoi(cmdLine.GetSafeArgument("-opt1", 0, 100)); - - // since opt2 has no arguments, just test for the presence of - // the '-opt2' switch - bool bOptVal2 = cmdLine.HasSwitch("-opt2"); - - .... and so on.... - - } - - If this class is used in an MFC application, StringType is CString, else - it uses the STL 'string' type. - - If this is an MFC app, you can use the __argc and __argv macros from - you CYourWinApp::InitInstance() function in place of the standard argc - and argv variables. - -------------------------------------------------------*/ -#ifndef SACMDSH -#define SACMDSH - - -#ifdef __AFX_H__ -// if we're using MFC, use CStrings -#define StringType CString -#else -// if we're not using MFC, use STL strings -#define StringType string -#endif - -// tell the compiler to shut up -#pragma warning(disable:4786) - -//#include // you may need this -#include -#include -#include -using namespace std ; - -// handy little container for our argument vector -struct CCmdParam -{ - vector m_strings; -}; - -// this class is actually a map of strings to vectors -using _CCmdLine = map; - -// the command line parser class -class CCmdLine : public _CCmdLine -{ - -public: - /*------------------------------------------------------ - int CCmdLine::SplitLine(int argc, char **argv) - - parse the command line into switches and arguments. - - returns number of switches found - ------------------------------------------------------*/ - int SplitLine(int argc, char **argv); - - /*------------------------------------------------------ - bool CCmdLine::HasSwitch(const char *pSwitch) - - was the switch found on the command line ? - - ex. if the command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.HasSwitch("-a") true - cmdLine.HasSwitch("-z") false - ------------------------------------------------------*/ - bool HasSwitch(const char *pSwitch); - - /*------------------------------------------------------ - - StringType CCmdLine::GetSafeArgument(const char *pSwitch, int iIdx, const char *pDefault) - - fetch an argument associated with a switch . if the parameter at - index iIdx is not found, this will return the default that you - provide. - - example : - - command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.GetSafeArgument("-a", 0, "zz") p1 - cmdLine.GetSafeArgument("-a", 1, "zz") p2 - cmdLine.GetSafeArgument("-b", 0, "zz") p4 - cmdLine.GetSafeArgument("-b", 1, "zz") zz - - ------------------------------------------------------*/ - - StringType GetSafeArgument(const char *pSwitch, int iIdx, const char *pDefault); - - /*------------------------------------------------------ - - StringType CCmdLine::GetArgument(const char *pSwitch, int iIdx) - - fetch a argument associated with a switch. throws an exception - of (int)0, if the parameter at index iIdx is not found. - - example : - - command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.GetArgument("-a", 0) p1 - cmdLine.GetArgument("-b", 1) throws (int)0, returns an empty string - - ------------------------------------------------------*/ - StringType GetArgument(const char *pSwitch, int iIdx); - - /*------------------------------------------------------ - int CCmdLine::GetArgumentCount(const char *pSwitch) - - returns the number of arguments found for a given switch. - - returns -1 if the switch was not found - - ------------------------------------------------------*/ - int GetArgumentCount(const char *pSwitch); - -protected: - /*------------------------------------------------------ - - protected member function - test a parameter to see if it's a switch : - - switches are of the form : -x - where 'x' is one or more characters. - the first character of a switch must be non-numeric! - - ------------------------------------------------------*/ - bool IsSwitch(const char *pParam); -}; - -#endif diff --git a/src/Tools/ImageTools/ImageConv/ImageConv.pro b/src/Tools/ImageTools/ImageConv/ImageConv.pro deleted file mode 100644 index b702f57074..0000000000 --- a/src/Tools/ImageTools/ImageConv/ImageConv.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = app -CONFIG += debug console -TARGET += -DEPENDPATH += . -INCLUDEPATH += . - -# Input -HEADERS += CmdLine.h imageconv.h -SOURCES += CmdLine.cpp imageconv.cpp main.cpp diff --git a/src/Tools/ImageTools/ImageConv/cmdline.htm b/src/Tools/ImageTools/ImageConv/cmdline.htm deleted file mode 100644 index 25a8363264..0000000000 --- a/src/Tools/ImageTools/ImageConv/cmdline.htm +++ /dev/null @@ -1,146 +0,0 @@ - - -

-CCmdLine - a class for parsing command line with or without MFC -


- - -This article was contributed by Chris Losinger. - - -

Environment: All - - -

- - -CCmdLine is a simple way to parse a command line into switches and arguments. -Ex : -
-

    -MyApp.exe -sw1 arg1 arg2 -sw2 arg3 -sw3 -sw4 -
-
-When using CCmdLine, "-sw1", "-sw2", "-sw3" and "-sw4" are switches and "arg1", "arg2" and "arg3" are arguments. -

-Parsing command lines with the standard C string functions (strlen, strcpy, etc.) or even -with the CString operators is a nightmare. But, CCmdLine makes it effortless. -

-CCmdLine was written for use with console apps, but can be easily used in -any application which requires command-line parsing. -

-CCmdLine uses STL for its collection classes, so it works in MFC -and non-MFC apps. If you are using this in an MFC app, the switches -and arguments will be returned as CStrings. If you are using this in a -non-MFC app, they will be returned as STL 'string's. -

-


-Example : - -Assume the application we're writing uses a command line that has two -required switches and two optional switches. The app should abort -if the required switches are not present and continue with default -values if the optional switches are not present. -
    -Sample command line : -
    -
    -  MyApp.exe -p1 text1 text2 -p2 "this is a big argument" -opt1 -55 -opt2
    -
    -Switches -p1 and -p2 are required. -
    -p1 has two arguments and p2 has one. -
    -
    -Switches -opt1 and -opt2 are optional. -
    -opt1 requires a numeric argument. -
    -opt2 has no arguments. -
    -
    -Also, assume that the app displays a 'help' screen if the '-h' switch -is present on the command line. -
-Here's how you can use CCmdLine to handle this : -
- -

-// if this is an MFC app, uncomment this line
-// #include "stdafx.h"
-
-#include "CmdLine.h"
-
-void main(int argc, char **argv)
-{
-  // our cmd line parser object
-  CCmdLine cmdLine;
-
-  // parse the command line
-  // use __argc and __argv, in MFC apps
-  if (cmdLine.SplitLine(argc, argv) < 1)
-  {
-     // no switches were given on the command line, abort
-     ASSERT(0);
-     exit(-1);
-  }
-
-  // test for the 'help' case
-  if (cmdLine.HasSwitch("-h"))
-  {
-     show_help();
-     exit(0);
-  }
-
-  // StringType is CString when using MFC, else STL's 'string'
-  StringType p1_1, p1_2, p2_1;
-
-  // get the required arguments
-  try
-  {  
-     // if any of these GetArgument calls fail, 
-     // we'll end up in the catch() block
-
-     // get the first -p1 argument
-     p1_1 = cmdLine.GetArgument("-p1", 0);
-
-     // get the second -p1 argument
-     p1_2 = cmdLine.GetArgument("-p1", 1);
-
-     // get the first -p2 argument
-     p2_1 = cmdLine.GetArgument("-p2", 0);
-
-  }
-  catch (...)
-  {
-     // one of the required arguments was missing, abort
-     ASSERT(0);
-     exit(-1);
-  }
-
-  // get the optional parameters
-
-  // GetSafeArgument does not throw exceptions, and allows for 
-  // the use of a default value, in case the switch is not found
-  // convert to an int, default to '100'
-  int iOpt1Val =    atoi( cmdLine.GetSafeArgument( "-opt1", 0, 100 ) );
-
-  // since opt2 has no arguments, just test for the presence of
-  // the '-opt2' switch
-  bool bOptSwitch2 =   cmdLine.HasSwitch("-opt2");
-
-  .... and so on....
-
-}
-
-
- - - -

Download source - 5 Kb - - - -

Date Posted: June 16, 1999 - - \ No newline at end of file diff --git a/src/Tools/ImageTools/ImageConv/imageconv.cpp b/src/Tools/ImageTools/ImageConv/imageconv.cpp deleted file mode 100644 index 99dc7df42c..0000000000 --- a/src/Tools/ImageTools/ImageConv/imageconv.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/*************************************************************************** - imageconv.cpp - description - ------------------- - begin : Die Apr 23 21:02:14 CEST 2002 - copyright : (C) 2002 by Werner Mayer - email : - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Library General Public License as * - * published by the Free Software Foundation; either version 2 of the * - * License, or (at your option) any later version. * - * Werner Mayer 2002 * - * * - ***************************************************************************/ - -#include "imageconv.h" -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -CCmdLineParser::CCmdLineParser(int argc, char** argv) -{ - SplitLine(argc, argv); -} - -CCmdParam CCmdLineParser::GetArgumentList(const char* pSwitch) -{ - if (HasSwitch(pSwitch)) - { - CCmdLineParser::iterator theIterator; - - theIterator = find(pSwitch); - if (theIterator!=end()) - { - return (*theIterator).second; - } - } - - CCmdParam param; - return param; -} - -// ------------------------------------------------------------ - -QString CImageConvApp::m_Executable = "ImageConv"; -QString CImageConvApp::m_BmpFactory = "BmpFactoryIcons.cpp"; - -CImageConvApp::CImageConvApp(const QString& sFile) -{ - m_bUpdate = false; - m_Output = sFile; - QString filter = "*.png;*.bmp;*.xbm;*.pnm;*.jpg;*.jpeg;*.mng;*.gif"; // not "*.xpm"! - m_Dir.setNameFilters(filter.split(';')); -} - -void CImageConvApp::SetOutputFile(const QString& sFile) -{ - m_Output = sFile; -} - -void CImageConvApp::SetNameFilters(const QStringList& nameFilter) -{ - m_Dir.setNameFilters(nameFilter); -} - -bool CImageConvApp::Save(const QString& fn) -{ - int iPos = fn.indexOf("."); - - QString ext = fn.mid(iPos+1); // extension of filename - QString name = fn.mid(0,iPos); // filename without extension - - if (!m_clPixmap.isNull()) - { - if (!fn.isEmpty()) - { - return m_clPixmap.save(fn, ext.toUpper().toLatin1()); - } - } - - return false; -} - -bool CImageConvApp::Load(const QString& fn) -{ - QByteArray ext = QImageReader::imageFormat(fn); - - if (!fn.isEmpty()) - return m_clPixmap.load( fn, ext); - - return false; -} - -const QPixmap& CImageConvApp::GetPixmap() const -{ - return m_clPixmap; -} - -bool CImageConvApp::ConvertToXPM(bool bAppendToFile) -{ - QStringList list = m_Dir.entryList(); - - // print to the console - cout << "Try converting to XPM..." << endl; - if (list.count() == 0) - { - cout << "Cannot find " << (const char*)m_Dir.nameFilters().join(" ").toLatin1() << endl; - return false; - } - - for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) - { - QByteArray ext = QImageReader::imageFormat(*it); - if (ext.isEmpty()) - continue; // no image format - - if (m_Output == *it) - continue; // if the file is the output file itself - - cout << "Converting " << (const char*)(*it).toLatin1() << " ..."; - - if (Load(*it) == true) - { - QString name(*it); - name.replace(name.indexOf(".")+1, 4, "xpm"); - - bool ok; - - QFileInfo fi(*it); - if (bAppendToFile) - ok = AppendToFile(fi.baseName()); - else - ok = Save(name); - - if (ok) - cout << "Done" << endl; - else - cout << "failed" << endl; - } - else - { - cout << "failed" << endl; - } - } - - return true; -} - -void CImageConvApp::CreateBmpFactory() -{ - // empty file - // - QFileInfo fi(m_BmpFactory); - - // already exists - if (fi.exists() && fi.isFile()) - return; - - QFile fw(m_BmpFactory); - QTextStream tw (&fw); - if (!fw.open(QIODevice::Text | QIODevice::Unbuffered | QIODevice::WriteOnly)) - return; - - // write header stuff - tw << "\n"; - tw << "void RegisterIcons()\n"; - tw << "{\n"; - tw << " Gui::BitmapFactoryInst& rclBmpFactory = Gui::BitmapFactory();\n"; - tw << "}\n"; - fw.close(); -} - -bool CImageConvApp::AppendToFile(const QString& file) -{ - CreateBmpFactory(); - - QString ohead("static char"); - QString nhead("static const char"); - - // save as XPM into tmp. buffer - QByteArray str; - QBuffer buf(&str); - buf.open (QIODevice::WriteOnly); - QImageWriter iio(&buf, "XPM"); - QImage im; - im = m_clPixmap.toImage(); - iio.write(im); - buf.close(); - - // convert to string and make changes - QString txt = str; - txt.replace(ohead, nhead); - txt.replace(QString("dummy"), file); - - // open file - bool found = false; - QFile fw(m_Output); - if (fw.open(QIODevice::ReadOnly)) - { - QTextStream tr (&fw); - QString line; - do - { - line = tr.readLine(); - if ((line.indexOf(file)) != -1) // icon already registered - { - found = true; - } - } while (!tr.atEnd() && !found); - - fw.close(); - } - - // register new icon - if (!found) - { - if (!fw.open(QIODevice::Text | QIODevice::Unbuffered | QIODevice::ReadWrite | QIODevice::Append)) - return false; - - // write into file now - QTextStream tw (&fw); - tw << txt << "\n"; - fw.close(); - - if (m_bUpdate) - { - QFile bmp(m_BmpFactory); - QTextStream ts (&bmp); - if (!bmp.open(QIODevice::Text | QIODevice::Unbuffered | QIODevice::WriteOnly)) - return false; - - bmp.seek(bmp.size()-3); - ts << " rclBmpFactory.addXPM(\"" << file << "\", " << file << ");\n"; - ts << "}\n"; - bmp.close(); - } - } - - return true; -} - -void CImageConvApp::Error() -{ - cerr << "Usage: " << (const char*)m_Executable.toLatin1() << " [OPTION(S)] -i input file(s) {-o output file}" << endl; - cerr << "Try '" << (const char*)m_Executable.toLatin1() << " --help' for more information." << endl; - - exit(0); -} - -void CImageConvApp::Version() -{ - cerr << (const char*)m_Executable.toLatin1() << " 1.0.0 " << endl; - exit(0); -} - -void CImageConvApp::Usage() -{ - cerr << "Usage: " << (const char*)m_Executable.toLatin1() << " [OPTION(S)] -i input file(s) {-o output file}\n" << endl; - cerr << "Options:" << endl; - - cerr << " -i \tSpecify the input file(s).\n" - " \tSeveral filenames must be separated by a blank.\n" - " \tIf you want to select all files of a format\n" - " \tyou also can write \"*.[FORMAT]\" (e.g. *.png).\n" - " \tSpecifying several files only makes sense in\n" - " \taddition with -a or -x." << endl; - - cerr << " -o \tSpecify the output file." << endl; - - cerr << " -x, --xpm\tConvert all specified image files to XPM.\n" - " \tFor each specified image file a corresponding\n" - " \tXPM file will be created.\n" - " \tWith -i you can specify the input files." << endl; - - cerr << " -a, --append\tConvert all specified image files to XPM and\n" - " \tappend the result to the file specified with -o.\n" - " \tWith -i you can specify the input files.\n" << endl; - - - cerr << " -u, --update\tUpdate the file \"BmpFactoryIcons.cpp\"\n" - " \tThis is a special mode to add icons to the FreeCAD's\n" - " \tbitmap factory automatically.\n" - " \tThis switch is only available in addition with -a.\n" << endl; - - cerr << " -v, --version\tPrint the version and exit." << endl; - - cerr << " -h, --help\tPrint this message and exit.\n" << endl; - - cerr << "This program supports the following image formats:\n" - " BMP, GIF, JPEG, MNG, PNG, PNM, XBM and XPM\n\n" - << (const char*)m_Executable.toLatin1() << " uses Qt Version " << qVersion() << "\n" - "Qt can be downloaded at http://www.trolltech.com." << endl; - - exit(0); -} diff --git a/src/Tools/ImageTools/ImageConv/imageconv.h b/src/Tools/ImageTools/ImageConv/imageconv.h deleted file mode 100644 index d90d51183e..0000000000 --- a/src/Tools/ImageTools/ImageConv/imageconv.h +++ /dev/null @@ -1,98 +0,0 @@ -/*************************************************************************** - imageconv.h - description - ------------------- - begin : Die Apr 23 21:02:14 CEST 2002 - copyright : (C) 2002 by Werner Mayer - email : - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Library General Public License as * - * published by the Free Software Foundation; either version 2 of the * - * License, or (at your option) any later version. * - * Werner Mayer 2002 * - * * - ***************************************************************************/ - -#ifndef IMAGECONV_H -#define IMAGECONV_H - -// includes -#include "CmdLine.h" -#include -#include -#include -#include - -#include -#include - -// defines -#define TString std::string -#define TVector std::vector -#define TMap std::map -#define TPair std::pair - - -// the command line parser class -class CCmdLineParser : public CCmdLine -{ -public: - CCmdLineParser (int argc, char** argv); - ~CCmdLineParser () {} - - CCmdParam GetArgumentList(const char* pSwitch); -}; - -// ------------------------------------------------------------ - -class CICException -{ -public: - CICException(const QString& text) - : msg(text) {} - CICException(const CICException& e) - { *this = e; } - ~CICException() - { } - QString what() const - { return msg; } - -private: - QString msg; -}; - -// ------------------------------------------------------------ - -class CImageConvApp -{ -public: - CImageConvApp(const QString& sFile = "Images.cpp"); - void SetOutputFile(const QString& sFile); - void SetNameFilters(const QStringList& nameFilter); - bool Save(const QString& fn); - bool Load(const QString& fn); - bool ConvertToXPM(bool bAppendToFile = false); - bool AppendToFile(const QString& file); - void SetUpdateBmpFactory(bool b) - { m_bUpdate = b; } - void CreateBmpFactory(); - - const QPixmap& GetPixmap() const; - - static void Usage(); - static void Error(); - static void Version(); - -private: - bool m_bUpdate; - static QString m_Executable; - static QString m_BmpFactory; - QPixmap m_clPixmap; // pixmap - QString m_Output; // specified output file - QDir m_Dir; // directory -}; - -#endif // IMAGECONV_H diff --git a/src/Tools/ImageTools/ImageConv/main.cpp b/src/Tools/ImageTools/ImageConv/main.cpp deleted file mode 100644 index f3a740ff26..0000000000 --- a/src/Tools/ImageTools/ImageConv/main.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/*************************************************************************** - main.cpp - description - ------------------- - begin : Die Apr 23 21:02:14 CEST 2002 - copyright : (C) 2002 by Werner Mayer - email : - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Library General Public License as * - * published by the Free Software Foundation; either version 2 of the * - * License, or (at your option) any later version. * - * Werner Mayer 2002 * - * * - ***************************************************************************/ - -#include -#include -#include "imageconv.h" - -using namespace std; - -int main( int argc, char **argv ) -{ - QApplication app( argc, argv ); - CImageConvApp cICApp; - CCmdLineParser cCmdP(argc, argv); - - try - { - // look for the specified switches and arguments - // - // - // show help message and exit - if (cCmdP.HasSwitch("-h") || cCmdP.HasSwitch("--help")) - { - CImageConvApp::Usage(); - } - // show version and exit - else if (cCmdP.HasSwitch("-v") || cCmdP.HasSwitch("--version")) - { - CImageConvApp::Version(); - } - - // convert all given/found image files to XPM - if (cCmdP.HasSwitch("-x") || cCmdP.HasSwitch("--xpm")) - { - // search for input files - if (cCmdP.GetArgumentCount("-i") > 0) - { - QStringList nameFilters; - CCmdParam para = cCmdP.GetArgumentList("-i"); - for (TVector::iterator it = para.m_strings.begin(); it != para.m_strings.end(); it++) - { - cout << "Search for " << it->c_str() << endl; - nameFilters.append(it->c_str()); - } - - cICApp.SetNameFilters(nameFilters); - cICApp.ConvertToXPM(false); - } - else - throw CICException("No input file specified."); - } - - // convert all given/found image files to XPM and write the result into a text file - else if (cCmdP.HasSwitch("-a") || cCmdP.HasSwitch("--append")) - { - // search for input fĂ­les - if (cCmdP.GetArgumentCount("-i") > 0) - { - cICApp.SetUpdateBmpFactory(cCmdP.HasSwitch("-a") || cCmdP.HasSwitch("--update")); - QStringList nameFilters; - CCmdParam para = cCmdP.GetArgumentList("-i"); - for (TVector::iterator it = para.m_strings.begin(); it != para.m_strings.end(); it++) - { - cout << "Search for " << it->c_str() << endl; - nameFilters.append(it->c_str()); - } - - cICApp.SetNameFilters(nameFilters); - } - else - throw CICException("No input files specified."); - - // search for output file - if (cCmdP.GetArgumentCount("-o") > 0) - { - cICApp.SetOutputFile(QString(cCmdP.GetArgument("-o", 0).c_str())); - cICApp.ConvertToXPM(true); - } - else - throw CICException("No output file specified."); - } - - // convert one image file to another image file - else if (cCmdP.HasSwitch("-i") && cCmdP.HasSwitch("-o")) - { - // input and output file specified - CCmdParam p1 = cCmdP.GetArgumentList("-i"); - CCmdParam p2 = cCmdP.GetArgumentList("-o"); - - if (p1.m_strings.size() > 1) - throw CICException("Too much input files specified."); - if (p1.m_strings.size() < 1) - throw CICException("No input file specified."); - if (p2.m_strings.size() > 1) - throw CICException("Too much output files specified."); - if (p2.m_strings.size() < 1) - throw CICException("No output file specified."); - - TString fil1(*p1.m_strings.begin()); - TString fil2(*p2.m_strings.begin()); - - if (cICApp.Load(QString(fil1.c_str())) == false) - { - cout << "Loading of " << fil1.c_str() << " failed!" << endl; - cout << "Perhaps the file does not exist or QT does not support this format." << endl; - return -1; - } - if (cICApp.Save(QString(fil2.c_str())) == false) - { - cout << "Saving of " << fil2.c_str() << " failed!" << endl; - cout << "Perhaps QT does not support this format." << endl; - } - else - { - cout << "Converted successfully!" << endl; - } - } - // no/wrong arguments - else - throw CICException("Wrong arguments."); - } - catch(const CICException& e) - { - cerr << (const char*)e.what().toLatin1() << endl; - CImageConvApp::Error(); - } - catch(...) - { - cerr << "An unknown exception has occurred!!!" << endl; - } - - return 0; -}