Changes in / [573ca5:6940bb]


Ignore:
Files:
18 added
107 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • configure.ac

    r573ca5 r6940bb  
    3838AX_BOOST_BASE([1.40])
    3939AX_BOOST_PROGRAM_OPTIONS
     40#AX_BOOST_FOREACH
    4041AX_BOOST_FILESYSTEM
    4142AX_BOOST_THREAD
  • src/Actions/MapOfActions.cpp

    r573ca5 r6940bb  
    3131#include <boost/optional.hpp>
    3232#include <boost/program_options.hpp>
    33 #include <boost/filesystem.hpp>
    3433
    3534#include <iostream>
     
    191190  BV.zz = boost::lexical_cast<double>(components.at(5));
    192191  v = boost::any(BoxValue(BV));
    193 }
    194 
    195 void validate(boost::any& v, const std::vector<std::string>& values, boost::filesystem::path *, int)
    196 {
    197   boost::filesystem::path filename;
    198   std::vector<std::string> components;
    199 
    200   std::cout << "boost::filesystem::path validator used." << std::endl;
    201 
    202   // split comma-separated values
    203   if (values.size() != 1) {
    204     cerr <<  "Not one file but " << components.size() << " given " << endl;
    205     throw boost::program_options::validation_error("Unequal to one file given");
    206   }
    207   filename = values.at(0);
    208   v = boost::any(boost::filesystem::path(filename));
    209192}
    210193
     
    384367  TypeMap["fill-void"] = &typeid(std::string);
    385368  TypeMap["fragment-mol"] = &typeid(std::string);
    386   TypeMap["input"] = &typeid(boost::filesystem::path);
     369  TypeMap["input"] = &typeid(std::string);
    387370  TypeMap["linear-interpolate"] = &typeid(std::string);
    388371  TypeMap["molecular-volume"] = &typeid(molecule);
     
    463446  TypeEnumMap[&typeid(bool)] = Boolean;
    464447  TypeEnumMap[&typeid(int)] = Integer;
    465   TypeEnumMap[&typeid(boost::filesystem::path)] = File;
    466448  TypeEnumMap[&typeid(std::vector<int>)] = ListOfIntegers;
    467449  TypeEnumMap[&typeid(double)] = Double;
     
    843825}
    844826
    845 void MapOfActions::queryCurrentValue(const char * name, boost::filesystem::path&_T)
    846 {
    847   std::string tmp;
    848   if (typeid( boost::filesystem::path ) == *TypeMap[name]) {
    849     if (CurrentValue.find(name) == CurrentValue.end())
    850       throw MissingValueException(__FILE__, __LINE__);
    851     std::istringstream stream(CurrentValue[name]);
    852     CurrentValue.erase(name);
    853     if (!stream.fail()) {
    854       stream >> tmp >> ws;
    855       _T = tmp;
    856     }
    857   } else
    858     throw IllegalTypeException(__FILE__,__LINE__);
    859 }
    860 
    861827
    862828void MapOfActions::setCurrentValue(const char * name, class atom * &_T)
     
    961927      stream << (*iter)->getId() << " ";
    962928    }
    963     CurrentValue[name] = stream.str();
    964   } else
    965     throw IllegalTypeException(__FILE__,__LINE__);
    966 }
    967 
    968 void MapOfActions::setCurrentValue(const char * name, boost::filesystem::path &_T)
    969 {
    970   if (typeid( boost::filesystem::path ) == *TypeMap[name]) {
    971     std::ostringstream stream;
    972     stream << _T.string();
    973929    CurrentValue[name] = stream.str();
    974930  } else
     
    10951051              ;
    10961052            break;
    1097           case File:
    1098             ListRunner->second->add_options()
    1099               (getKeyAndShortForm(*OptionRunner).c_str(),
    1100                   po::value< boost::filesystem::path >(),
    1101                   getDescription(*OptionRunner).c_str())
    1102               ;
    1103             break;
    11041053          case Integer:
    11051054            ListRunner->second->add_options()
  • src/Actions/MapOfActions.hpp

    r573ca5 r6940bb  
    99#define MAPOFACTIONS_HPP_
    1010
    11 #include <boost/filesystem.hpp>
     11#include <boost/program_options.hpp>
    1212#include <boost/lexical_cast.hpp>
    13 #include <boost/program_options.hpp>
    1413
    1514#include <map>
     
    3231
    3332namespace po = boost::program_options;
    34 namespace fs = boost::filesystem;
    3533
    3634using boost::lexical_cast;
     
    138136  friend class MapOfActionsTest;
    139137public:
    140   enum OptionTypes { None, Boolean, Integer, File, ListOfIntegers, Double, ListOfDoubles, String, ListOfStrings, Vector, ListOfVectors, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };
     138  enum OptionTypes { None, Boolean, Integer, ListOfIntegers, Double, ListOfDoubles, String, ListOfStrings, Vector, ListOfVectors, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };
    141139
    142140  // getter for the action descriptions and short forms
     
    175173  void queryCurrentValue(const char * name, std::vector<const element *>&_T);
    176174  void queryCurrentValue(const char * name, std::vector<molecule *>&_T);
    177   void queryCurrentValue(const char * name, fs::path&_T);
    178175  template<typename T> void queryCurrentValue(const char * name, T &_T)
    179176  {
     
    211208  void setCurrentValue(const char * name, std::vector<const element *>&_T);
    212209  void setCurrentValue(const char * name, std::vector<molecule *>&_T);
    213   void setCurrentValue(const char * name, fs::path&_T);
    214210  template<class T> void setCurrentValue(const char * name, T &_T)
    215211  {
  • src/Actions/WorldAction/InputAction.cpp

    r573ca5 r6940bb  
    3030#include <string>
    3131
    32 #include <boost/filesystem/fstream.hpp>
    33 
    3432using namespace std;
    3533
     
    4139/** =========== define the function ====================== */
    4240Action::state_ptr WorldInputAction::performCall() {
    43 //  MoleculeListClass *molecules = World::getInstance().getMolecules();
    44 //  molecule *mol = NULL;
    45   boost::filesystem::ifstream test;
     41  MoleculeListClass *molecules = World::getInstance().getMolecules();
     42  molecule *mol = NULL;
     43  std::ifstream test;
    4644
    4745  // obtain information
    4846  getParametersfromValueStorage();
    4947
    50   DoLog(0) && (Log() << Verbose(0) << "Config file given " << params.filename << "." << endl);
    51   // using the filename as prefix for all parsers
    52   std::string FilenameSuffix;
    53   std::string FilenamePrefix;
    54   if (params.filename.has_filename()) {
    55     // get suffix
    56     FilenameSuffix = params.filename.extension().substr(1); // remove the prefixed "."
    57     FilenamePrefix = params.filename.stem();
     48  DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
     49  if (params.filename.find('.') != string::npos) {
     50    std::string FilenamePrefix = params.filename.substr(0,params.filename.find_last_of('.'));
     51    std::string FilenameSuffix = params.filename.substr(params.filename.find_last_of('.')+1, params.filename.length());
    5852    DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << FilenamePrefix << "." << endl);
     53    test.open(params.filename.c_str());
     54    if (test == NULL) {
     55      DoLog(1) && (Log() << Verbose(1) << "Specified config file " << params.filename << " not found." << endl);
     56    } else {
     57      DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
     58      FormatParserStorage::getInstance().get((std::istream &)test, FilenameSuffix);
     59      test.close();
     60    }
    5961    FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix);
     62    // set mol to first active molecule
     63    if (molecules->ListOfMolecules.size() != 0) {
     64      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     65        if ((*ListRunner)->ActiveFlag) {
     66          mol = *ListRunner;
     67          break;
     68        }
     69    }
     70    if (mol == NULL) {
     71      mol = World::getInstance().createMolecule();
     72      mol->ActiveFlag = true;
     73      molecules->insert(mol);
     74    }
     75    mol->SetNameFromFilename(params.filename.substr(0,params.filename.find('.')).c_str());
    6076  } else {
    6177    DoeLog(1) && (eLog() << Verbose(1) << "Input file does not have a suffix, cannot recognize format." << endl);
    62     return Action::failure;
    63   }
    64 
    65   // parsing file if present
    66   if (!boost::filesystem::exists(params.filename)) {
    67     DoLog(1) && (Log() << Verbose(1) << "Specified config file " << params.filename << " not found." << endl);
    68     // DONT FAIL: it's just empty and we use the name. // return Action::failure;
    69   } else {
    70     DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
    71 
    72     // parse the file
    73     test.open(params.filename);
    74     FormatParserStorage::getInstance().get(test, FilenameSuffix);
    75     test.close();
    76 
    77     // set file name of last molecule
    78     MoleculeList::const_iterator iter = World::getInstance().getMolecules()->ListOfMolecules.end();
    79     iter--;
    80     (*iter)->SetNameFromFilename(FilenamePrefix.c_str());
    8178  }
    8279  return Action::success;
  • src/Actions/WorldAction/InputAction.def

    r573ca5 r6940bb  
    77
    88// all includes and forward declarations necessary for non-integral types below
    9 #include <boost/filesystem.hpp>
     9
    1010
    1111// i.e. there is an integer with variable name Z that can be found in
    1212// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1313// "undefine" if no parameters are required
    14 #define paramtypes (boost::filesystem::path)
     14#define paramtypes (std::string)
    1515#define paramtokens (WorldInputAction::NAME)
    1616#define paramreferences (filename)
  • src/Makefile.am

    r573ca5 r6940bb  
    120120  Thermostats/Woodcock.hpp
    121121
    122 QTUIMOC_HEADER = UIElements/Qt4/QtDialog.hpp \
    123         UIElements/Qt4/QtMainWindow.hpp \
    124         UIElements/Menu/Qt4/QtMenu.hpp \
    125         UIElements/Views/Qt4/QtWorldView.hpp \
    126         UIElements/Views/Qt4/GLMoleculeView.hpp \
    127         UIElements/Views/Qt4/QtMoleculeView.hpp \
    128         UIElements/Views/Qt4/QtStatusBar.hpp
     122QTUIMOC_HEADER = UIElements/QT4/QTDialog.hpp \
     123        UIElements/QT4/QTMainWindow.hpp \
     124        UIElements/Menu/QT4/QTMenu.hpp \
     125        UIElements/Views/QT4/QTWorldView.hpp \
     126        UIElements/Views/QT4/GLMoleculeView.hpp \
     127        UIElements/Views/QT4/QTMoleculeView.hpp \
     128        UIElements/Views/QT4/QTStatusBar.hpp
    129129                                 
    130130QTUISOURCE = allmocs.moc.cpp \
    131   UIElements/Qt4/Pipe/AtomQtQueryPipe.cpp \
    132   UIElements/Qt4/Pipe/AtomsQtQueryPipe.cpp \
    133   UIElements/Qt4/Pipe/BooleanQtQueryPipe.cpp \
    134   UIElements/Qt4/Pipe/BoxQtQueryPipe.cpp \
    135   UIElements/Qt4/Pipe/DoubleQtQueryPipe.cpp \
    136   UIElements/Qt4/Pipe/ElementsQtQueryPipe.cpp \
    137   UIElements/Qt4/Pipe/EmptyQtQueryPipe.cpp \
    138   UIElements/Qt4/Pipe/ElementQtQueryPipe.cpp \
    139   UIElements/Qt4/Pipe/FileQtQueryPipe.cpp \
    140   UIElements/Qt4/Pipe/IntQtQueryPipe.cpp \
    141   UIElements/Qt4/Pipe/MoleculeQtQueryPipe.cpp \
    142   UIElements/Qt4/Pipe/MoleculesQtQueryPipe.cpp \
    143   UIElements/Qt4/Pipe/StringQtQueryPipe.cpp \
    144   UIElements/Qt4/Pipe/VectorQtQueryPipe.cpp \
    145   UIElements/Qt4/Pipe/VectorsQtQueryPipe.cpp \
    146   UIElements/Qt4/Query/AtomQtQuery.cpp \
    147   UIElements/Qt4/Query/AtomsQtQuery.cpp \
    148   UIElements/Qt4/Query/BooleanQtQuery.cpp \
    149   UIElements/Qt4/Query/BoxQtQuery.cpp \
    150   UIElements/Qt4/Query/DoubleQtQuery.cpp \
    151   UIElements/Qt4/Query/DoublesQtQuery.cpp \
    152   UIElements/Qt4/Query/ElementQtQuery.cpp \
    153   UIElements/Qt4/Query/ElementsQtQuery.cpp \
    154   UIElements/Qt4/Query/EmptyQtQuery.cpp \
    155   UIElements/Qt4/Query/FileQtQuery.cpp \
    156   UIElements/Qt4/Query/IntQtQuery.cpp \
    157   UIElements/Qt4/Query/IntsQtQuery.cpp \
    158   UIElements/Qt4/Query/MoleculeQtQuery.cpp \
    159   UIElements/Qt4/Query/MoleculesQtQuery.cpp \
    160   UIElements/Qt4/Query/StringQtQuery.cpp \
    161   UIElements/Qt4/Query/StringsQtQuery.cpp \
    162   UIElements/Qt4/Query/VectorQtQuery.cpp \
    163   UIElements/Qt4/Query/VectorsQtQuery.cpp \
    164         UIElements/Qt4/QtMainWindow.cpp \
    165         UIElements/Qt4/QtDialog.cpp \
    166         UIElements/Qt4/QtUIFactory.cpp \
    167         UIElements/Menu/Qt4/QtMenu.cpp \
    168         UIElements/Views/Qt4/QtWorldView.cpp \
    169         UIElements/Views/Qt4/GLMoleculeView.cpp \
    170         UIElements/Views/Qt4/QtMoleculeView.cpp \
    171         UIElements/Views/Qt4/QtStatusBar.cpp
     131        UIElements/QT4/QTMainWindow.cpp \
     132        UIElements/QT4/QTDialog.cpp \
     133        UIElements/QT4/QTUIFactory.cpp \
     134        UIElements/Menu/QT4/QTMenu.cpp \
     135        UIElements/Views/QT4/QTWorldView.cpp \
     136        UIElements/Views/QT4/GLMoleculeView.cpp \
     137        UIElements/Views/QT4/QTMoleculeView.cpp \
     138        UIElements/Views/QT4/QTStatusBar.cpp
    172139             
    173 QTUIHEADER = \
    174   ${QTUIMOC_HEADER} \
    175   UIElements/Qt4/Pipe/QtQueryListPipe.hpp \
    176   UIElements/Qt4/QtUIFactory.hpp
     140QTUIHEADER = ${QTUIMOC_HEADER} UIElements/QT4/QTUIFactory.hpp
    177141
    178142QTUI_DEFS =
     
    325289
    326290
    327 BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB)
     291BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB)
    328292GUI_LIBS = ${QT_LDADD} ${QT_LIB_GUI} -lQtOpenGL ${GLU_LIBS}
    329293INCLUDES = -I$(top_srcdir)/src/unittests -I$(top_srcdir)/src/Actions -I$(top_srcdir)/src/UIElements
     
    351315        Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
    352316        Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
    353         $(BOOST_LIB)
    354 
    355 #Stuff for building the GUI using Qt
     317        $(BOOST_LIB) \
     318        ${BOOST_THREAD_LIB} \
     319        ${BOOST_PROGRAM_OPTIONS_LIB}
     320
     321
     322#Stuff for building the GUI using QT
    356323molecuildergui_SOURCES = ${QTUISOURCE} builder.cpp
    357324molecuildergui_CXXFLAGS = ${QT_CXXFLAGS} ${GLU_CXXFLAGS} -DUSE_GUI_QT
     
    359326
    360327unity_SOURCES = unity.cpp
    361 unity_LDADD = $(BOOST_LIB)
     328unity_LDADD = $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
    362329
    363330molecuildergui_LDADD = \
     
    370337        Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
    371338        $(BOOST_LIB) \
     339        ${BOOST_THREAD_LIB} \
     340        ${BOOST_PROGRAM_OPTIONS_LIB} \
    372341        ${GUI_LIBS}
    373342
     
    381350        Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
    382351        Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
    383         $(BOOST_LIB)
     352        $(BOOST_LIB) \
     353        ${BOOST_THREAD_LIB} \
     354        ${BOOST_PROGRAM_OPTIONS_LIB}
    384355
    385356analyzer_SOURCES = analyzer.cpp datacreator.cpp periodentafel.hpp datacreator.hpp
     
    392363        Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
    393364        Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
    394         $(BOOST_LIB)
    395 
    396 #Rules needed for Qt4
     365        $(BOOST_LIB) \
     366        ${BOOST_THREAD_LIB} \
     367        ${BOOST_PROGRAM_OPTIONS_LIB}
     368
     369#Rules needed for QT4
    397370# UI-Files are scattered throughout several subdirectories
    398371# Therfore `%'-rules do not seem to work
  • src/Parser/MpqcParser.cpp

    r573ca5 r6940bb  
    4949void MpqcParser::load(istream *file)
    5050{
    51   // TODO: MpqcParser::load implementation
    52   ASSERT(false, "Not implemented yet");
     51  DoeLog(0) && (Log() << Verbose(0) << "Not yet implemented" << endl) ;
    5352}
    5453
  • src/Parser/PcpParser.cpp

    r573ca5 r6940bb  
    355355  // 3. parse the molecule in
    356356  molecule *mol = World::getInstance().createMolecule();
     357  MoleculeListClass *molecules = World::getInstance().getMolecules();
     358  molecules->insert(mol);
     359  LoadMolecule(mol, FileBuffer, World::getInstance().getPeriode(), FastParsing);
     360  //mol->SetNameFromFilename(filename);
    357361  mol->ActiveFlag = true;
    358   // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include
    359   World::getInstance().getMolecules()->insert(mol);
    360   LoadMolecule(mol, FileBuffer, World::getInstance().getPeriode(), FastParsing);
     362  //MolList->insert(mol);
    361363
    362364  // 4. dissect the molecule into connected subgraphs
  • src/Parser/PdbParser.cpp

    r573ca5 r6940bb  
    7474 */
    7575void PdbParser::load(istream* file) {
    76   // TODO: PdbParser::load implementation
    77   ASSERT(false, "Not implemented yet");
    7876//  string line;
    7977//  string::size_type location;
     
    134132      elementNo[Z] = (elementNo[Z]+1) % 100;   // confine to two digits
    135133      const molecule *mol = (*atomIt)->getMolecule();
    136       if (mol == NULL) {  // for homeless atoms, MolNo = -1 is reserved
    137         MolNo = -1;
     134      if (mol == NULL) {  // for homeless atoms, MolNo = 0 is reserved
     135        MolNo = 0;
    138136      } else {
    139137        MolNo = mol->getId();
  • src/Parser/TremoloParser.cpp

    r573ca5 r6940bb  
    9292  usedFields.clear();
    9393  molecule *newmol = World::getInstance().createMolecule();
    94   newmol->ActiveFlag = true;
    95   // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include
    96   World::getInstance().getMolecules()->insert(newmol);
    9794  while (file->good()) {
    9895    std::getline(*file, line, '\n');
  • src/UIElements/CommandLineUI/CommandLineDialog.cpp

    r573ca5 r6940bb  
    2020#include "Helpers/MemDebug.hpp"
    2121
     22#include <iostream>
     23#include <vector>
     24
     25#include <Descriptors/AtomDescriptor.hpp>
     26#include <Descriptors/AtomIdDescriptor.hpp>
     27#include <Descriptors/MoleculeDescriptor.hpp>
     28#include <Descriptors/MoleculeIdDescriptor.hpp>
    2229#include "CommandLineUI/CommandLineDialog.hpp"
    2330
     31#include "Actions/Values.hpp"
     32
     33#include "element.hpp"
     34#include "periodentafel.hpp"
     35#include "CommandLineParser.hpp"
     36#include "defs.hpp"
     37#include "Helpers/Log.hpp"
     38#include "LinearAlgebra/Matrix.hpp"
     39#include "periodentafel.hpp"
     40#include "Helpers/Verbose.hpp"
     41#include "World.hpp"
     42#include "Box.hpp"
     43
     44#include "atom.hpp"
     45#include "element.hpp"
     46#include "molecule.hpp"
     47#include "LinearAlgebra/Vector.hpp"
    2448
    2549using namespace std;
     
    103127}
    104128
    105 void CommandLineDialog::queryFile(const char* title, string _description){
    106   registerQuery(new FileCommandLineQuery(title, _description));
    107 }
    108 
    109129/************************** Query Infrastructure ************************/
    110 /*       ---> shifted to folder Query                                   */
    111 /************************************************************************/
     130
     131CommandLineDialog::EmptyCommandLineQuery::EmptyCommandLineQuery(string title, string _description) :
     132    Dialog::EmptyQuery(title, _description)
     133{}
     134
     135CommandLineDialog::EmptyCommandLineQuery::~EmptyCommandLineQuery() {}
     136
     137bool CommandLineDialog::EmptyCommandLineQuery::handle() {
     138  cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n";
     139  return true;
     140}
     141
     142CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title, string _description) :
     143    Dialog::IntQuery(title, _description)
     144{}
     145
     146CommandLineDialog::IntCommandLineQuery::~IntCommandLineQuery() {}
     147
     148bool CommandLineDialog::IntCommandLineQuery::handle() {
     149  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     150    tmp = CommandLineParser::getInstance().vm[getTitle()].as<int>();
     151    return true;
     152  } else {
     153    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integer for " << getTitle() << "." << endl);
     154    return false;
     155  }
     156}
     157
     158CommandLineDialog::IntsCommandLineQuery::IntsCommandLineQuery(string title, string _description) :
     159    Dialog::IntsQuery(title, _description)
     160{}
     161
     162CommandLineDialog::IntsCommandLineQuery::~IntsCommandLineQuery() {}
     163
     164bool CommandLineDialog::IntsCommandLineQuery::handle() {
     165  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     166    tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
     167    return true;
     168  } else {
     169    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integers for " << getTitle() << "." << endl);
     170    return false;
     171  }
     172}
     173
     174CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title, string _description) :
     175    Dialog::BooleanQuery(title, _description)
     176{}
     177
     178CommandLineDialog::BooleanCommandLineQuery::~BooleanCommandLineQuery() {}
     179
     180bool CommandLineDialog::BooleanCommandLineQuery::handle() {
     181  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     182    tmp = CommandLineParser::getInstance().vm[getTitle()].as<bool>();
     183    return true;
     184  } else {
     185    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing boolean for " << getTitle() << "." << endl);
     186    return false;
     187  }
     188}
     189
     190CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title, string _description) :
     191    Dialog::StringQuery(title, _description)
     192{}
     193
     194CommandLineDialog::StringCommandLineQuery::~StringCommandLineQuery() {}
     195
     196bool CommandLineDialog::StringCommandLineQuery::handle() {
     197  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     198    tmp = CommandLineParser::getInstance().vm[getTitle()].as<string>();
     199    return true;
     200  } else {
     201    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl);
     202    return false;
     203  }
     204}
     205
     206CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title, string _description) :
     207    Dialog::StringsQuery(title, _description)
     208{}
     209
     210CommandLineDialog::StringsCommandLineQuery::~StringsCommandLineQuery() {}
     211
     212bool CommandLineDialog::StringsCommandLineQuery::handle() {
     213  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     214    tmp = CommandLineParser::getInstance().vm[getTitle()].as< vector<string> >();
     215    return true;
     216  } else {
     217    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing strings for " << getTitle() << "." << endl);
     218    return false;
     219  }
     220}
     221
     222CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title, string _description) :
     223    Dialog::DoubleQuery(title, _description)
     224{}
     225
     226CommandLineDialog::DoubleCommandLineQuery::~DoubleCommandLineQuery() {}
     227
     228bool CommandLineDialog::DoubleCommandLineQuery::handle() {
     229  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     230    tmp = CommandLineParser::getInstance().vm[getTitle()].as<double>();
     231    return true;
     232  } else {
     233    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing double for " << getTitle() << "." << endl);
     234    return false;
     235  }
     236}
     237
     238CommandLineDialog::DoublesCommandLineQuery::DoublesCommandLineQuery(string title, string _description) :
     239    Dialog::DoublesQuery(title, _description)
     240{}
     241
     242CommandLineDialog::DoublesCommandLineQuery::~DoublesCommandLineQuery() {}
     243
     244bool CommandLineDialog::DoublesCommandLineQuery::handle() {
     245  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     246    tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<double> >();
     247    return true;
     248  } else {
     249    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing doubles for " << getTitle() << "." << endl);
     250    return false;
     251  }
     252}
     253
     254CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, string _description) :
     255    Dialog::AtomQuery(title, _description)
     256{}
     257
     258CommandLineDialog::AtomCommandLineQuery::~AtomCommandLineQuery() {}
     259
     260bool CommandLineDialog::AtomCommandLineQuery::handle() {
     261  int IdxOfAtom = -1;
     262  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     263    IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as<int>();
     264    tmp = World::getInstance().getAtom(AtomById(IdxOfAtom));
     265    return true;
     266  } else {
     267    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atom for " << getTitle() << "." << endl);
     268    return false;
     269  }
     270}
     271
     272CommandLineDialog::AtomsCommandLineQuery::AtomsCommandLineQuery(string title, string _description) :
     273    Dialog::AtomsQuery(title, _description)
     274{}
     275
     276CommandLineDialog::AtomsCommandLineQuery::~AtomsCommandLineQuery() {}
     277
     278bool CommandLineDialog::AtomsCommandLineQuery::handle() {
     279  std::vector<int> IdxOfAtom;
     280  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     281    IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
     282    for (std::vector<int>::iterator iter = IdxOfAtom.begin(); iter != IdxOfAtom.end(); ++iter) {
     283      temp = World::getInstance().getAtom(AtomById(*iter));
     284      if (temp)
     285        tmp.push_back(temp);
     286    }
     287    return true;
     288  } else {
     289    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atoms for " << getTitle() << "." << endl);
     290    return false;
     291  }
     292}
     293
     294CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, string _description) :
     295    Dialog::MoleculeQuery(title, _description)
     296{}
     297
     298CommandLineDialog::MoleculeCommandLineQuery::~MoleculeCommandLineQuery() {}
     299
     300bool CommandLineDialog::MoleculeCommandLineQuery::handle() {
     301  int IdxOfMol = -1;
     302  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     303    IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>();
     304    tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
     305    return true;
     306  } else {
     307    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecule for " << getTitle() << "." << endl);
     308    return false;
     309  }
     310}
     311
     312CommandLineDialog::MoleculesCommandLineQuery::MoleculesCommandLineQuery(string title, string _description) :
     313    Dialog::MoleculesQuery(title, _description)
     314{}
     315
     316CommandLineDialog::MoleculesCommandLineQuery::~MoleculesCommandLineQuery() {}
     317
     318bool CommandLineDialog::MoleculesCommandLineQuery::handle() {
     319  std::vector<int> IdxOfMol;
     320  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     321    IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
     322    for (std::vector<int>::iterator iter = IdxOfMol.begin(); iter != IdxOfMol.end(); ++iter) {
     323      temp = World::getInstance().getMolecule(MoleculeById(*iter));
     324      if (temp)
     325        tmp.push_back(temp);
     326    }
     327    return true;
     328  } else {
     329    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecules for " << getTitle() << "." << endl);
     330    return false;
     331  }
     332}
     333
     334CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, bool _check, string _description) :
     335    Dialog::VectorQuery(title,_check, _description)
     336{}
     337
     338CommandLineDialog::VectorCommandLineQuery::~VectorCommandLineQuery()
     339{}
     340
     341bool CommandLineDialog::VectorCommandLineQuery::handle() {
     342  VectorValue temp;
     343  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     344    temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
     345    tmp[0] = temp.x;
     346    tmp[1] = temp.y;
     347    tmp[2] = temp.z;
     348    if ((check) && (!World::getInstance().getDomain().isInside(tmp))) {
     349      DoeLog(1) && (eLog() << Verbose(1) << "Vector " << tmp << " would be outside of box domain." << endl);
     350      return false;
     351    }
     352    return true;
     353  } else {
     354    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vector for " << getTitle() << "." << endl);
     355    return false;
     356  }
     357}
     358
     359CommandLineDialog::VectorsCommandLineQuery::VectorsCommandLineQuery(string title, bool _check, string _description) :
     360    Dialog::VectorsQuery(title,_check, _description)
     361{}
     362
     363CommandLineDialog::VectorsCommandLineQuery::~VectorsCommandLineQuery()
     364{}
     365
     366bool CommandLineDialog::VectorsCommandLineQuery::handle() {
     367  std::vector<VectorValue> temporary;
     368  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     369    temporary = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<VectorValue> >();
     370    for(std::vector<VectorValue>::iterator iter = temporary.begin(); iter != temporary.end(); ++iter) {
     371      temp[0] = (*iter).x;
     372      temp[1] = (*iter).y;
     373      temp[2] = (*iter).z;
     374      if ((!check) || (World::getInstance().getDomain().isInside(temp)))
     375        tmp.push_back(temp);
     376      else
     377        DoeLog(1) && (eLog() << Verbose(1) << "Vector " << temp << " would be outside of box domain." << endl);
     378    }
     379    return true;
     380  } else {
     381    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vectors for " << getTitle() << "." << endl);
     382    return false;
     383  }
     384}
     385
     386CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) :
     387    Dialog::BoxQuery(title, _description)
     388{}
     389
     390CommandLineDialog::BoxCommandLineQuery::~BoxCommandLineQuery()
     391{}
     392
     393bool CommandLineDialog::BoxCommandLineQuery::handle() {
     394  BoxValue temp;
     395  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     396    temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >();
     397    Matrix M;
     398    M.set(0,0, temp.xx);
     399    M.set(0,1, temp.yx);
     400    M.set(0,2, temp.zx);
     401    M.set(1,0, temp.yx);
     402    M.set(1,1, temp.yy);
     403    M.set(1,2, temp.zy);
     404    M.set(2,0, temp.zx);
     405    M.set(2,1, temp.zy);
     406    M.set(2,2, temp.zz);
     407    tmp.setM(M);
     408    return true;
     409  } else {
     410    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing symmetric box matrix for " << getTitle() << "." << endl);
     411    return false;
     412  }
     413}
     414
     415CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, string _description) :
     416    Dialog::ElementQuery(title, _description)
     417{}
     418
     419CommandLineDialog::ElementCommandLineQuery::~ElementCommandLineQuery()
     420{}
     421
     422bool CommandLineDialog::ElementCommandLineQuery::handle() {
     423  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
     424  periodentafel *periode = World::getInstance().getPeriode();
     425  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     426    int Z = CommandLineParser::getInstance().vm[getTitle()].as< int >();
     427    tmp = periode->FindElement(Z);
     428    ASSERT(tmp != NULL, "Invalid element specified in ElementCommandLineQuery");
     429    return true;
     430  } else {
     431    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);
     432    return false;
     433  }
     434}
     435
     436CommandLineDialog::ElementsCommandLineQuery::ElementsCommandLineQuery(string title, string _description) :
     437    Dialog::ElementsQuery(title, _description)
     438{}
     439
     440CommandLineDialog::ElementsCommandLineQuery::~ElementsCommandLineQuery()
     441{}
     442
     443bool CommandLineDialog::ElementsCommandLineQuery::handle() {
     444  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
     445  periodentafel *periode = World::getInstance().getPeriode();
     446  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     447    vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
     448    for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) {
     449      temp = periode->FindElement(*ZRunner);
     450      ASSERT(temp != NULL, "Invalid element specified in ElementCommandLineQuery");
     451      tmp.push_back(temp);
     452    }
     453    return true;
     454  } else {
     455    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing elements for " << getTitle() << "." << endl);
     456    return false;
     457  }
     458}
  • src/UIElements/CommandLineUI/CommandLineDialog.hpp

    r573ca5 r6940bb  
    4444  virtual void queryElement(const char*, std::string = "");
    4545  virtual void queryElements(const char*, std::string = "");
    46   virtual void queryFile(const char*, std::string = "");
    4746
    4847protected:
     
    166165    virtual bool handle();
    167166  };
    168 
    169   class FileCommandLineQuery : public Dialog::FileQuery {
    170   public:
    171     FileCommandLineQuery(std::string title, std::string _description = "");
    172     virtual ~FileCommandLineQuery();
    173     virtual bool handle();
    174   };
    175167};
    176168
  • src/UIElements/Dialog.cpp

    r573ca5 r6940bb  
    2323#include "Actions/ValueStorage.hpp"
    2424
    25 #include "Helpers/Log.hpp"
    2625#include "Helpers/Verbose.hpp"
    27 
    28 class Atom;
    29 class Box;
    30 class element;
    31 class Matrix;
    32 class molecule;
    33 class Vector;
     26#include "atom.hpp"
     27#include "Box.hpp"
     28#include "element.hpp"
     29#include "molecule.hpp"
     30#include "LinearAlgebra/BoxVector.hpp"
     31#include "LinearAlgebra/Vector.hpp"
     32#include "LinearAlgebra/Matrix.hpp"
    3433
    3534using namespace std;
     
    181180}
    182181
    183 template <> void Dialog::query< boost::filesystem::path >(const char *token, std::string description)
    184 {
    185   queryFile(token, description);
    186 }
    187 
    188 /************************** Query Infrastructure ************************/
    189 /*       ---> shifted to folder Query                                   */
    190 /************************************************************************/
     182/****************** Query types Infrastructure **************************/
     183
     184// Base class
     185Dialog::Query::Query(string _title, string _description) :
     186    title(_title),
     187    description(_description)
     188{}
     189
     190Dialog::Query::~Query() {}
     191
     192const std::string Dialog::Query::getTitle() const{
     193  return title;
     194}
     195
     196const std::string Dialog::Query::getDescription() const{
     197  return description;
     198}
     199// empty Queries
     200
     201Dialog::EmptyQuery::EmptyQuery(string title, std::string description) :
     202    Query(title, description)
     203{}
     204
     205Dialog::EmptyQuery::~EmptyQuery() {}
     206
     207void Dialog::EmptyQuery::setResult() {
     208}
     209
     210// Int Queries
     211
     212Dialog::IntQuery::IntQuery(string title, std::string description) :
     213    Query(title, description)
     214{}
     215
     216Dialog::IntQuery::~IntQuery() {}
     217
     218void Dialog::IntQuery::setResult() {
     219  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     220}
     221
     222// Ints Queries
     223
     224Dialog::IntsQuery::IntsQuery(string title, std::string description) :
     225    Query(title, description)
     226{}
     227
     228Dialog::IntsQuery::~IntsQuery() {}
     229
     230void Dialog::IntsQuery::setResult() {
     231  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     232}
     233
     234// Bool Queries
     235
     236Dialog::BooleanQuery::BooleanQuery(string title,std::string description) :
     237    Query(title, description)
     238{}
     239
     240Dialog::BooleanQuery::~BooleanQuery() {}
     241
     242void Dialog::BooleanQuery::setResult() {
     243  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     244}
     245
     246// String Queries
     247
     248Dialog::StringQuery::StringQuery(string title,std::string _description) :
     249    Query(title, _description)
     250{}
     251
     252Dialog::StringQuery::~StringQuery() {};
     253
     254void Dialog::StringQuery::setResult() {
     255  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     256}
     257
     258// Strings Queries
     259
     260Dialog::StringsQuery::StringsQuery(string title,std::string _description) :
     261    Query(title, _description)
     262{}
     263
     264Dialog::StringsQuery::~StringsQuery() {};
     265
     266void Dialog::StringsQuery::setResult() {
     267  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     268}
     269
     270// Double Queries
     271
     272Dialog::DoubleQuery::DoubleQuery(string title, std::string _description) :
     273    Query(title, _description)
     274{}
     275
     276Dialog::DoubleQuery::~DoubleQuery() {};
     277
     278void Dialog::DoubleQuery::setResult() {
     279  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     280}
     281
     282// Doubles Queries
     283
     284Dialog::DoublesQuery::DoublesQuery(string title, std::string _description) :
     285    Query(title, _description)
     286{}
     287
     288Dialog::DoublesQuery::~DoublesQuery() {};
     289
     290void Dialog::DoublesQuery::setResult() {
     291  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     292}
     293
     294
     295// Atom Queries
     296
     297Dialog::AtomQuery::AtomQuery(string title, std::string _description) :
     298    Query(title, _description),
     299    tmp(0)
     300{}
     301
     302Dialog::AtomQuery::~AtomQuery() {}
     303
     304void Dialog::AtomQuery::setResult() {
     305  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     306}
     307
     308// Atoms Queries
     309
     310Dialog::AtomsQuery::AtomsQuery(string title, std::string _description) :
     311    Query(title, _description),
     312    tmp(0)
     313{}
     314
     315Dialog::AtomsQuery::~AtomsQuery() {}
     316
     317void Dialog::AtomsQuery::setResult() {
     318  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     319}
     320
     321// Molecule Queries
     322
     323Dialog::MoleculeQuery::MoleculeQuery(string title, std::string _description) :
     324    Query(title, _description),
     325    tmp(0)
     326{}
     327
     328Dialog::MoleculeQuery::~MoleculeQuery() {}
     329
     330void Dialog::MoleculeQuery::setResult() {
     331  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     332}
     333
     334// Molecules Queries
     335
     336Dialog::MoleculesQuery::MoleculesQuery(string title, std::string _description) :
     337    Query(title, _description),
     338    tmp(0)
     339{}
     340
     341Dialog::MoleculesQuery::~MoleculesQuery() {}
     342
     343void Dialog::MoleculesQuery::setResult() {
     344  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     345}
     346
     347// Vector Queries
     348
     349Dialog::VectorQuery::VectorQuery(std::string title,bool _check, std::string _description) :
     350  Query(title, _description),
     351  check(_check)
     352{}
     353
     354Dialog::VectorQuery::~VectorQuery()
     355{}
     356
     357void Dialog::VectorQuery::setResult() {
     358  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     359}
     360
     361// Vectors Queries
     362
     363Dialog::VectorsQuery::VectorsQuery(std::string title,bool _check, std::string _description) :
     364  Query(title, _description),
     365  check(_check)
     366{}
     367
     368Dialog::VectorsQuery::~VectorsQuery()
     369{}
     370
     371void Dialog::VectorsQuery::setResult() {
     372  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     373}
     374
     375// Box Queries
     376
     377Dialog::BoxQuery::BoxQuery(std::string title, std::string _description) :
     378  Query(title, _description)
     379{}
     380
     381Dialog::BoxQuery::~BoxQuery()
     382{}
     383
     384void Dialog::BoxQuery::setResult() {
     385  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     386}
     387
     388// Element Queries
     389Dialog::ElementQuery::ElementQuery(std::string title, std::string _description) :
     390  Query(title, _description)
     391  {}
     392
     393Dialog::ElementQuery::~ElementQuery(){}
     394
     395void Dialog::ElementQuery::setResult(){
     396  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     397}
     398
     399// Elements Queries
     400Dialog::ElementsQuery::ElementsQuery(std::string title, std::string _description) :
     401  Query(title, _description)
     402  {}
     403
     404Dialog::ElementsQuery::~ElementsQuery(){}
     405
     406void Dialog::ElementsQuery::setResult(){
     407  ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
     408}
  • src/UIElements/Dialog.hpp

    r573ca5 r6940bb  
    1313#include<vector>
    1414
    15 #include <boost/filesystem.hpp>
    16 
    1715#include "Box.hpp"
    1816#include "LinearAlgebra/Vector.hpp"
     
    2624/** Dialog is one of the two main classes of the UIFactory base class.
    2725 *
    28  * The Dialog is meant for asking the user for information needed to perform
    29  * actions he desires, such as asking for a position in space or a length.
     26 * The Dialog is meant for asking the user for information needed to perform actions he
     27 * desires, such as asking for a position in space or a length.
    3028 *
    31  * For this purpose there is the base class Query and numerous specializations
    32  * for each of the types to be asked. There are primitives integer, doubles and
    33  * string, but also advanced types such as element, molecule or Vector. There
    34  * is also an empty query for displaying text.
     29 * For this purpose there is the base class Query and numerous specializations for each
     30 * of the types to be asked. There are primitives integer, doubles and string, but also
     31 * advanced types such as element, molecule or Vector. There is also an empty query for
     32 * displaying text.
    3533 */
    3634class Dialog
     
    5957  virtual void queryElement(const char*, std::string = "")=0;
    6058  virtual void queryElements(const char*, std::string = "")=0;
    61   virtual void queryFile(const char*, std::string = "")=0;
    6259
    6360  virtual bool display();
     
    7976  //due to lack of common code for query types as well as GUI-Types (all subtypes differ a lot)
    8077
    81   /** Base class for all queries.
    82    *
    83    *
    84    * <h1>How to add another query?</h1>
    85    *
    86    * Let's say  we want to query for a type called \a Value.
    87    *
    88    * Then, we do the following:
    89    *  -# Add a class ValueQuery inside class Dialog, the class contains
    90    *    -# constructor/destructor (latter virtual! because of derived class)
    91    *    -# virtual bool handle() and virtual void setResult()
    92    *    -# a protected member tmp of type Value (NOTE: herein the result is stored)
    93    *    -# if temporaries for conversion are needed put them in here
    94    *  -# add a function queryValue
    95    *  -# now, for each of the GUIs we basically have to repeat the above, i.e.
    96    *     add the class and the function that implement the virtual ones above.
    97    *    -# QT: an extra class called ValueQtQueryPipe that actually handles
    98    *       showing dialogs to obtain the value and placing it into the \a tmp
    99    *       variable (via a given pointer to it as reference). handle() will
    100    *       simply return true. This is needed because of a restriction of Qt4:
    101    *       its meta-object-compiler does not like nested classes.
    102    *    -# CommandLine: nothing special, handle() imports value from \a
    103    *       CommandLineParser and sets the tmp variable.
    104    *    -# Text: nothing special, handle() queries the user and sets the tmp
    105    *       variable
    106    */
     78  //base class for all queries
    10779  class Query {
    10880    friend class Dialog;
     
    299271  };
    300272
    301   class FileQuery : public Query {
    302   public:
    303     FileQuery(std::string title, std::string _description = "");
    304     virtual ~FileQuery();
    305     virtual bool handle()=0;
    306     virtual void setResult();
    307   protected:
    308     boost::filesystem::path tmp;
    309   };
    310 
    311273void registerQuery(Query* query);
    312274
  • src/UIElements/Makefile.am

    r573ca5 r6940bb  
    4141  ${TEXTUISOURCE} \
    4242  ${VIEWSOURCE} \
    43   Query/AtomQuery.cpp \
    44   Query/AtomsQuery.cpp \
    45   Query/BooleanQuery.cpp \
    46   Query/BoxQuery.cpp \
    47   Query/DoubleQuery.cpp \
    48   Query/DoublesQuery.cpp \
    49   Query/ElementQuery.cpp \
    50   Query/ElementsQuery.cpp \
    51   Query/EmptyQuery.cpp \
    52   Query/FileQuery.cpp \
    53   Query/IntQuery.cpp \
    54   Query/IntsQuery.cpp \
    55   Query/MoleculeQuery.cpp \
    56   Query/MoleculesQuery.cpp \
    57   Query/Query.cpp \
    58   Query/StringQuery.cpp \
    59   Query/StringsQuery.cpp \
    60   Query/VectorQuery.cpp \
    61   Query/VectorsQuery.cpp \
    6243  Dialog.cpp \
    6344  MainWindow.cpp
     
    7354
    7455TEXTUISOURCE = \
    75   TextUI/Query/AtomsTextQuery.cpp \
    76   TextUI/Query/AtomTextQuery.cpp \
    77   TextUI/Query/BooleanTextQuery.cpp \
    78   TextUI/Query/BoxTextQuery.cpp \
    79   TextUI/Query/DoubleTextQuery.cpp \
    80   TextUI/Query/DoublesTextQuery.cpp \
    81   TextUI/Query/ElementTextQuery.cpp \
    82   TextUI/Query/ElementsTextQuery.cpp \
    83   TextUI/Query/EmptyTextQuery.cpp \
    84   TextUI/Query/FileTextQuery.cpp \
    85   TextUI/Query/IntTextQuery.cpp \
    86   TextUI/Query/IntsTextQuery.cpp \
    87   TextUI/Query/MoleculesTextQuery.cpp \
    88   TextUI/Query/MoleculeTextQuery.cpp \
    89   TextUI/Query/StringTextQuery.cpp \
    90   TextUI/Query/StringsTextQuery.cpp \
    91   TextUI/Query/VectorTextQuery.cpp \
    92   TextUI/Query/VectorsTextQuery.cpp \
    9356  TextUI/TextDialog.cpp \
    9457  TextUI/TextStatusIndicator.cpp \
     
    10265
    10366COMMANDLINEUISOURCE = \
    104   CommandLineUI/Query/AtomCommandLineQuery.cpp \
    105   CommandLineUI/Query/AtomsCommandLineQuery.cpp \
    106   CommandLineUI/Query/BooleanCommandLineQuery.cpp \
    107   CommandLineUI/Query/BoxCommandLineQuery.cpp \
    108   CommandLineUI/Query/DoubleCommandLineQuery.cpp \
    109   CommandLineUI/Query/DoublesCommandLineQuery.cpp \
    110   CommandLineUI/Query/ElementCommandLineQuery.cpp \
    111   CommandLineUI/Query/ElementsCommandLineQuery.cpp \
    112   CommandLineUI/Query/EmptyCommandLineQuery.cpp \
    113   CommandLineUI/Query/FileCommandLineQuery.cpp \
    114   CommandLineUI/Query/IntCommandLineQuery.cpp \
    115   CommandLineUI/Query/IntsCommandLineQuery.cpp \
    116   CommandLineUI/Query/MoleculeCommandLineQuery.cpp \
    117   CommandLineUI/Query/MoleculesCommandLineQuery.cpp \
    118   CommandLineUI/Query/StringCommandLineQuery.cpp \
    119   CommandLineUI/Query/StringsCommandLineQuery.cpp \
    120   CommandLineUI/Query/VectorCommandLineQuery.cpp \
    121   CommandLineUI/Query/VectorsCommandLineQuery.cpp \
    12267  CommandLineUI/CommandLineDialog.cpp \
    12368  CommandLineUI/CommandLineStatusIndicator.cpp \
  • src/UIElements/TextUI/TextDialog.cpp

    r573ca5 r6940bb  
    2020#include "Helpers/MemDebug.hpp"
    2121
     22#include <iostream>
     23
     24#include <Descriptors/AtomDescriptor.hpp>
     25#include <Descriptors/AtomIdDescriptor.hpp>
     26#include <Descriptors/MoleculeDescriptor.hpp>
     27#include <Descriptors/MoleculeIdDescriptor.hpp>
     28#include <boost/lexical_cast.hpp>
    2229#include "TextUI/TextDialog.hpp"
     30
     31#include "World.hpp"
     32#include "periodentafel.hpp"
     33#include "Helpers/Log.hpp"
     34#include "Helpers/Verbose.hpp"
     35
     36#include "atom.hpp"
     37#include "element.hpp"
     38#include "molecule.hpp"
     39#include "LinearAlgebra/Vector.hpp"
     40#include "LinearAlgebra/Matrix.hpp"
     41#include "Box.hpp"
     42
     43#include <boost/lexical_cast.hpp>
    2344
    2445using namespace std;
     
    104125}
    105126
    106 void TextDialog::queryFile(const char* title, std::string description){
    107   registerQuery(new FileTextQuery(title,description));
    108 }
    109 
    110127/************************** Query Infrastructure ************************/
    111 /*       ---> shifted to folder Query                                   */
    112 /************************************************************************/
    113 
     128
     129TextDialog::EmptyTextQuery::EmptyTextQuery(string title, std::string _description) :
     130    Dialog::EmptyQuery(title,_description)
     131{}
     132
     133TextDialog::EmptyTextQuery::~EmptyTextQuery() {}
     134
     135bool TextDialog::EmptyTextQuery::handle() {
     136  cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n";
     137  return true;
     138}
     139
     140TextDialog::IntTextQuery::IntTextQuery(string title, std::string _description) :
     141    Dialog::IntQuery(title,_description)
     142{}
     143
     144TextDialog::IntTextQuery::~IntTextQuery() {}
     145
     146bool TextDialog::IntTextQuery::handle() {
     147  bool badInput = false;
     148  do{
     149    badInput = false;
     150    Log() << Verbose(0) << getTitle();
     151    cin >> tmp;
     152    if(cin.fail()){
     153      badInput=true;
     154      cin.clear();
     155      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     156      Log() << Verbose(0) << "Input was not a number!" << endl;
     157    }
     158  } while(badInput);
     159  // clear the input buffer of anything still in the line
     160  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     161  return true;
     162}
     163
     164TextDialog::IntsTextQuery::IntsTextQuery(string title, std::string _description) :
     165    Dialog::IntsQuery(title,_description)
     166{}
     167
     168TextDialog::IntsTextQuery::~IntsTextQuery() {}
     169
     170bool TextDialog::IntsTextQuery::handle() {
     171  Log() << Verbose(0) << getTitle();
     172  std::string line;
     173  getline(cin,line);
     174  // dissect by " "
     175  std::string::iterator olditer = line.begin();
     176  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     177    if (*iter == ' ') {
     178      std::istringstream stream(string(iter, olditer));
     179      stream >> temp;
     180      tmp.push_back(temp);
     181      olditer = iter;
     182    }
     183  }
     184  if (olditer != line.begin()) { // insert last part also
     185    std::istringstream stream(string(olditer, line.end()));
     186    stream >> temp;
     187    tmp.push_back(temp);
     188  }
     189
     190  return true;
     191}
     192
     193TextDialog::BooleanTextQuery::BooleanTextQuery(string title, std::string _description) :
     194    Dialog::BooleanQuery(title,_description)
     195{}
     196
     197TextDialog::BooleanTextQuery::~BooleanTextQuery() {}
     198
     199bool TextDialog::BooleanTextQuery::handle() {
     200  bool badInput = false;
     201  char input = ' ';
     202  do{
     203    badInput = false;
     204    Log() << Verbose(0) << getTitle();
     205    cin >> input;
     206    if ((input == 'y' ) || (input == 'Y')) {
     207      tmp = true;
     208    } else if ((input == 'n' ) || (input == 'N')) {
     209      tmp = false;
     210    } else {
     211      badInput=true;
     212      cin.clear();
     213      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     214      Log() << Verbose(0) << "Input was not of [yYnN]!" << endl;
     215    }
     216  } while(badInput);
     217  // clear the input buffer of anything still in the line
     218  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     219  return true;
     220}
     221
     222TextDialog::StringTextQuery::StringTextQuery(string title, std::string _description) :
     223    Dialog::StringQuery(title,_description)
     224{}
     225
     226TextDialog::StringTextQuery::~StringTextQuery() {}
     227
     228bool TextDialog::StringTextQuery::handle() {
     229  Log() << Verbose(0) << getTitle();
     230  getline(cin,tmp);
     231  return true;
     232}
     233
     234TextDialog::StringsTextQuery::StringsTextQuery(string title, std::string _description) :
     235    Dialog::StringsQuery(title,_description)
     236{}
     237
     238TextDialog::StringsTextQuery::~StringsTextQuery() {}
     239
     240bool TextDialog::StringsTextQuery::handle() {
     241  Log() << Verbose(0) << getTitle();
     242  getline(cin,temp);
     243  // dissect by " "
     244  std::string::iterator olditer = temp.begin();
     245  for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) {
     246    if (*iter == ' ') {
     247      tmp.push_back(string(iter, olditer));
     248      olditer = iter;
     249    }
     250  }
     251  if (olditer != temp.begin())  // insert last part also
     252    tmp.push_back(string(olditer, temp.end()));
     253
     254  return true;
     255}
     256
     257TextDialog::DoubleTextQuery::DoubleTextQuery(string title, std::string _description) :
     258    Dialog::DoubleQuery(title,_description)
     259{}
     260
     261TextDialog::DoubleTextQuery::~DoubleTextQuery() {}
     262
     263bool TextDialog::DoubleTextQuery::handle() {
     264  bool badInput = false;
     265  do{
     266    badInput = false;
     267    Log() << Verbose(0) << getTitle();
     268    cin >> tmp;
     269    if(cin.fail()){
     270      badInput = true;
     271      cin.clear();
     272      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     273      Log() << Verbose(0) << "Input was not a number!" << endl;
     274    }
     275  }while(badInput);
     276  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     277  return true;
     278}
     279
     280
     281TextDialog::DoublesTextQuery::DoublesTextQuery(string title, std::string _description) :
     282    Dialog::DoublesQuery(title,_description)
     283{}
     284
     285TextDialog::DoublesTextQuery::~DoublesTextQuery() {}
     286
     287bool TextDialog::DoublesTextQuery::handle() {
     288  Log() << Verbose(0) << getTitle();
     289  std::string line;
     290  getline(cin,line);
     291  // dissect by " "
     292  std::string::iterator olditer = line.begin();
     293  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     294    if (*iter == ' ') {
     295      std::istringstream stream(string(iter, olditer));
     296      stream >> temp;
     297      tmp.push_back(temp);
     298      olditer = iter;
     299    }
     300  }
     301  if (olditer != line.begin()) { // insert last part also
     302    std::istringstream stream(string(olditer, line.end()));
     303    stream >> temp;
     304    tmp.push_back(temp);
     305  }
     306
     307  return true;
     308}
     309
     310TextDialog::AtomTextQuery::AtomTextQuery(string title, std::string _description) :
     311    Dialog::AtomQuery(title,_description)
     312{}
     313
     314TextDialog::AtomTextQuery::~AtomTextQuery() {}
     315
     316bool TextDialog::AtomTextQuery::handle() {
     317  int idxOfAtom=-1;
     318  bool badInput = false;
     319  do{
     320    badInput = false;
     321    Log() << Verbose(0) << getTitle();
     322    cin >> idxOfAtom;
     323    if(cin.fail()){
     324      badInput = true;
     325      cin.clear();
     326      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     327      Log() << Verbose(0) << "Input was not a number!" << endl;
     328      continue;
     329    }
     330
     331    tmp = World::getInstance().getAtom(AtomById(idxOfAtom));
     332    if(!tmp && idxOfAtom!=-1){
     333      Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
     334      badInput = true;
     335    }
     336
     337  } while(badInput);
     338  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     339  return (idxOfAtom!=-1);
     340}
     341
     342
     343TextDialog::AtomsTextQuery::AtomsTextQuery(string title, std::string _description) :
     344    Dialog::AtomsQuery(title,_description)
     345{}
     346
     347TextDialog::AtomsTextQuery::~AtomsTextQuery() {}
     348
     349bool TextDialog::AtomsTextQuery::handle() {
     350  int idxOfAtom=-1;
     351  Log() << Verbose(0) << getTitle();
     352  std::string line;
     353  getline(cin,line);
     354  // dissect by " "
     355  std::string::iterator olditer = line.begin();
     356  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     357    if (*iter == ' ') {
     358      std::istringstream stream(string(iter, olditer));
     359      stream >> idxOfAtom;
     360      temp = World::getInstance().getAtom(AtomById(idxOfAtom));
     361      if(!temp && idxOfAtom!=-1){
     362        Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
     363        break;
     364      }
     365      tmp.push_back(temp);
     366      olditer = iter;
     367    }
     368  }
     369  if (olditer != line.begin()) { // insert last part also
     370    std::istringstream stream(string(olditer, line.end()));
     371    stream >> idxOfAtom;
     372    temp = World::getInstance().getAtom(AtomById(idxOfAtom));
     373    if(!temp && idxOfAtom!=-1) {
     374      Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl;
     375      tmp.push_back(temp);
     376    }
     377  }
     378
     379  return (idxOfAtom!=-1);
     380}
     381
     382TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, std::string _description) :
     383    Dialog::MoleculeQuery(title,_description)
     384{}
     385
     386TextDialog::MoleculeTextQuery::~MoleculeTextQuery() {}
     387
     388bool TextDialog::MoleculeTextQuery::handle() {
     389  int idxOfMol=0;
     390  bool badInput = false;
     391  do{
     392    badInput = false;
     393    Log() << Verbose(0) << getTitle();
     394    cin >> idxOfMol;
     395    if(cin.fail()){
     396      badInput = true;
     397      cin.clear();
     398      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     399      Log() << Verbose(0) << "Input was not a number!" << endl;
     400      continue;
     401    }
     402
     403    tmp = World::getInstance().getMolecule(MoleculeById(idxOfMol));
     404    if(!tmp && idxOfMol!=-1){
     405      Log() << Verbose(0) << "Invalid Molecule Index" << endl;
     406      badInput = true;
     407    }
     408
     409  } while(badInput);
     410  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     411  return (idxOfMol!=-1);
     412}
     413
     414
     415TextDialog::MoleculesTextQuery::MoleculesTextQuery(string title, std::string _description) :
     416    Dialog::MoleculesQuery(title,_description)
     417{}
     418
     419TextDialog::MoleculesTextQuery::~MoleculesTextQuery() {}
     420
     421bool TextDialog::MoleculesTextQuery::handle() {
     422  int idxOfMol=-1;
     423  Log() << Verbose(0) << getTitle();
     424  std::string line;
     425  getline(cin,line);
     426  // dissect by " "
     427  std::string::iterator olditer = line.begin();
     428  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     429    if (*iter == ' ') {
     430      std::istringstream stream(string(iter, olditer));
     431      stream >> idxOfMol;
     432      temp = World::getInstance().getMolecule(MoleculeById(idxOfMol));
     433      if(!temp && idxOfMol!=-1){
     434        Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl;
     435        break;
     436      }
     437      tmp.push_back(temp);
     438      olditer = iter;
     439    }
     440  }
     441  if (olditer != line.begin()) { // insert last part also
     442    std::istringstream stream(string(olditer, line.end()));
     443    stream >> idxOfMol;
     444    temp = World::getInstance().getMolecule(MoleculeById(idxOfMol));
     445    if(!temp && idxOfMol!=-1){
     446      Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl;
     447      tmp.push_back(temp);
     448    }
     449  }
     450
     451  return (idxOfMol!=-1);
     452}
     453
     454TextDialog::VectorTextQuery::VectorTextQuery(std::string title, bool _check, std::string _description) :
     455    Dialog::VectorQuery(title,_check,_description)
     456{}
     457
     458TextDialog::VectorTextQuery::~VectorTextQuery()
     459{}
     460
     461bool TextDialog::VectorTextQuery::handle() {
     462  std::cout << getTitle();
     463  const Matrix &M = World::getInstance().getDomain().getM();
     464  char coords[3] = {'x', 'y', 'z'};
     465  for (int i=0;i<3;i++)
     466    std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: ");
     467
     468  std::string line;
     469  getline(cin,line);
     470
     471  // dissect by ","
     472  double coord = 0.;
     473  int counter = 0;
     474  std::string::iterator olditer = line.begin();
     475  for(string::iterator iter = line.begin(); (iter != line.end()) && (counter != 3); ++iter) {
     476    if (*iter == ',') {
     477      std::istringstream stream(string(iter, olditer));
     478      stream >> coord;
     479      tmp[counter++] = coord;
     480      olditer = iter;
     481    }
     482  }
     483  if ((olditer != line.begin()) && (counter != 3)) { // insert last part also
     484    std::istringstream stream(string(olditer, line.end()));
     485    stream >> coord;
     486    tmp[counter++] = coord;
     487  }
     488
     489  // check vector
     490  return World::getInstance().getDomain().isInside(tmp);
     491}
     492
     493TextDialog::VectorsTextQuery::VectorsTextQuery(std::string title, bool _check, std::string _description) :
     494    Dialog::VectorsQuery(title,_check,_description)
     495{}
     496
     497TextDialog::VectorsTextQuery::~VectorsTextQuery()
     498{}
     499
     500bool TextDialog::VectorsTextQuery::handle() {
     501  std::cout << getTitle();
     502  char coords[3] = {'x', 'y', 'z'};
     503  const Matrix &M = World::getInstance().getDomain().getM();
     504  for (int i=0;i<3;i++)
     505    std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: ");
     506
     507  std::string line;
     508  getline(cin,line);
     509
     510  // dissect by ","
     511  double coord = 0.;
     512  std::string::iterator olditerspace = line.begin();
     513  std::string::iterator olditercomma = line.begin();
     514  int counter = 0;
     515  for(string::iterator vectoriter = line.begin(); vectoriter != line.end(); ++vectoriter) {
     516    if (*vectoriter == ',')
     517      counter++;
     518    if ((*vectoriter == ' ') && (counter == 2)) {
     519      counter = 0;
     520      for(string::iterator componentiter = olditerspace; (componentiter != vectoriter) && (counter !=3); ++componentiter) {
     521        if (*componentiter == ',') {
     522          std::istringstream stream(string(componentiter, olditercomma));
     523          stream >> coord;
     524          temp[counter++] = coord;
     525          olditercomma = componentiter;
     526        }
     527      }
     528      if ((olditercomma != line.begin()) && (counter != 3)) { // insert last part also
     529        std::istringstream stream(string(olditercomma, vectoriter));
     530        stream >> coord;
     531        temp[counter++] = coord;
     532      }
     533      if (World::getInstance().getDomain().isInside(temp))
     534        tmp.push_back(temp);
     535      olditerspace = vectoriter;
     536    }
     537  }
     538
     539  return true;
     540}
     541
     542TextDialog::BoxTextQuery::BoxTextQuery(std::string title, std::string _description) :
     543    Dialog::BoxQuery(title,_description)
     544{}
     545
     546TextDialog::BoxTextQuery::~BoxTextQuery()
     547{}
     548
     549bool TextDialog::BoxTextQuery::handle() {
     550  Log() << Verbose(0) << getTitle();
     551
     552  double temp[6];
     553  std::string coords[6] = {"xx","yx","yy", "zx", "zy", "zz"};
     554  for (int i=0;i<6;i++) {
     555    Log() << Verbose(0) << coords[i] << ": ";
     556    cin >> temp[i];
     557  }
     558  Matrix M;
     559  M.set(0,0, temp[0]);
     560  M.set(0,1, temp[1]);
     561  M.set(0,2, temp[2]);
     562  M.set(1,0, temp[1]);
     563  M.set(1,1, temp[3]);
     564  M.set(1,2, temp[4]);
     565  M.set(2,0, temp[2]);
     566  M.set(2,1, temp[4]);
     567  M.set(2,2, temp[5]);
     568  tmp.setM(M);
     569  return true;
     570}
     571
     572TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::string _description) :
     573    Dialog::ElementQuery(title,_description)
     574{}
     575
     576TextDialog::ElementTextQuery::~ElementTextQuery()
     577{}
     578
     579bool TextDialog::ElementTextQuery::handle() {
     580  bool badInput=false;
     581  bool aborted = false;
     582  const element * temp = NULL;
     583  do{
     584    badInput = false;
     585    Log() << Verbose(0) << getTitle();
     586
     587    // try to read as Atomic number
     588    int Z;
     589    cin >> Z;
     590    if(!cin.fail()){
     591      if(Z==-1){
     592        aborted = true;
     593      }
     594      else{
     595        temp = World::getInstance().getPeriode()->FindElement(Z);
     596        if(!temp){
     597          Log() << Verbose(0) << "No element with this atomic number!" << endl;
     598          badInput = true;
     599        }
     600      }
     601      continue;
     602    }
     603    else{
     604      cin.clear();
     605    }
     606
     607    // Try to read as shorthand
     608    // the last buffer content was not removed, so we read the
     609    // same thing again, this time as a std::string
     610    std::string shorthand;
     611    cin >> shorthand;
     612    if(!cin.fail()){
     613      if(shorthand.empty()){
     614        aborted = true;
     615      }
     616      else{
     617        temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
     618        if(!temp){
     619          Log() << Verbose(0) << "No element with this shorthand!" << endl;
     620          badInput = true;
     621        }
     622      }
     623    }
     624    else{
     625      Log() << Verbose(0) << "Could not read input. Try Again." << endl;
     626      cin.clear();
     627      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     628      badInput = true;
     629    }
     630
     631  }while(badInput);
     632  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     633  return !aborted;
     634}
     635
     636TextDialog::ElementsTextQuery::ElementsTextQuery(std::string title, std::string _description) :
     637    Dialog::ElementsQuery(title,_description)
     638{}
     639
     640TextDialog::ElementsTextQuery::~ElementsTextQuery()
     641{}
     642
     643bool TextDialog::ElementsTextQuery::handle() {
     644  std::string shorthand;
     645  int Z=-1;
     646  Log() << Verbose(0) << getTitle();
     647  std::string line;
     648  getline(cin,line);
     649  // dissect by " "
     650  std::string::iterator olditer = line.begin();
     651  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
     652    if (*iter == ' ') {
     653      std::istringstream stream(string(iter, olditer));
     654      stream >> shorthand;
     655      try {
     656        Z = lexical_cast<int>(shorthand);
     657        temp = World::getInstance().getPeriode()->FindElement(Z);
     658      } catch (bad_lexical_cast) {
     659        temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
     660      };
     661      if(!temp && Z!=-1){
     662        Log() << Verbose(0) << "Invalid Element" << shorthand << endl;
     663        break;
     664      }
     665      tmp.push_back(temp);
     666      olditer = iter;
     667    }
     668  }
     669  if (olditer != line.begin()) { // insert last part also
     670    std::istringstream stream(string(olditer, line.end()));
     671    stream >> shorthand;
     672    try {
     673      Z = lexical_cast<int>(shorthand);
     674      temp = World::getInstance().getPeriode()->FindElement(Z);
     675    } catch (bad_lexical_cast) {
     676      temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());
     677    };
     678    if(!temp && Z!=-1) {
     679      Log() << Verbose(0) << "Invalid Element" << shorthand << endl;
     680      tmp.push_back(temp);
     681    }
     682  }
     683
     684  return (Z!=-1);
     685}
  • src/UIElements/TextUI/TextDialog.hpp

    r573ca5 r6940bb  
    4141  virtual void queryElement(const char*, std::string = "");
    4242  virtual void queryElements(const char*, std::string = "");
    43   virtual void queryFile(const char*, std::string = "");
    4443
    4544protected:
     
    163162    virtual bool handle();
    164163  };
    165 
    166   class FileTextQuery : public Dialog::FileQuery {
    167   public:
    168     FileTextQuery(std::string title, std::string _description = NULL);
    169     virtual ~FileTextQuery();
    170     virtual bool handle();
    171   };
    172164};
    173165
  • src/builder.cpp

    r573ca5 r6940bb  
    8686#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
    8787#ifdef USE_GUI_QT
    88 #include "UIElements/Qt4/QtUIFactory.hpp"
     88#include "UIElements/QT4/QTUIFactory.hpp"
    8989#endif
    9090#include "UIElements/MainWindow.hpp"
     
    184184      ASSERT_DO(Assert::Ask);
    185185      #ifdef USE_GUI_QT
    186         DoLog(0) && (Log() << Verbose(0) << "Setting UI to Qt4." << endl);
    187         UIFactory::registerFactory(new QtUIFactory::description());
    188         UIFactory::makeUserInterface("Qt4");
     186        DoLog(0) && (Log() << Verbose(0) << "Setting UI to QT4." << endl);
     187        UIFactory::registerFactory(new QTUIFactory::description());
     188        UIFactory::makeUserInterface("QT4");
    189189      #else
    190190        DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl);
  • src/unittests/DummyUI.hpp

    r573ca5 r6940bb  
    3535  virtual void queryElement(const char*, std::string = ""){}
    3636  virtual void queryElements(const char*, std::string = ""){}
    37   virtual void queryFile(const char*, std::string = ""){}
    3837};
    3938
  • src/unittests/Makefile.am

    r573ca5 r6940bb  
    4949noinst_PROGRAMS = $(TESTS) TestRunner
    5050
    51 BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB)
    5251GSLLIBS = \
    5352        ../LinearAlgebra/libMolecuilderLinearAlgebra-@MOLECUILDER_API_VERSION@.la \
    5453        ../Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
    5554        ../Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
    56         $(BOOST_LIB)
     55        $(BOOST_LIB) \
     56        ${BOOST_THREAD_LIB}
    5757ALLLIBS = \
    5858        ../UIElements/libMolecuilderUI-@MOLECUILDER_API_VERSION@.la \
     
    6060        ${PARSERLIBS} \
    6161        ../libMolecuilder-@MOLECUILDER_API_VERSION@.la \
    62         ${GSLLIBS}
    63 
     62        ${GSLLIBS} \
     63        ${BOOST_PROGRAM_OPTIONS_LIB}
    6464PARSERLIBS = ../Parser/libMolecuilderParser-@MOLECUILDER_API_VERSION@.la
    6565UILIBS = ../UIElements/libMolecuilderUI-@MOLECUILDER_API_VERSION@.la 
  • tests/regression/Simple_configuration/2/post/test.pdb

    r573ca5 r6940bb  
    11REMARK created by molecuilder on Fri Aug 27 12:18:33 2010
    2 ATOM      1  H01 non b   0        10.0    10.0    10.0   1.0   1.0         0 H 0
     2ATOM      1  H01 non b   1        10.0    10.0    10.0   1.0   1.0         0 H 0
    33END
Note: See TracChangeset for help on using the changeset viewer.