Changes in / [6940bb:573ca5]


Ignore:
Files:
107 added
18 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • configure.ac

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

    r6940bb r573ca5  
    3131#include <boost/optional.hpp>
    3232#include <boost/program_options.hpp>
     33#include <boost/filesystem.hpp>
    3334
    3435#include <iostream>
     
    190191  BV.zz = boost::lexical_cast<double>(components.at(5));
    191192  v = boost::any(BoxValue(BV));
     193}
     194
     195void 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));
    192209}
    193210
     
    367384  TypeMap["fill-void"] = &typeid(std::string);
    368385  TypeMap["fragment-mol"] = &typeid(std::string);
    369   TypeMap["input"] = &typeid(std::string);
     386  TypeMap["input"] = &typeid(boost::filesystem::path);
    370387  TypeMap["linear-interpolate"] = &typeid(std::string);
    371388  TypeMap["molecular-volume"] = &typeid(molecule);
     
    446463  TypeEnumMap[&typeid(bool)] = Boolean;
    447464  TypeEnumMap[&typeid(int)] = Integer;
     465  TypeEnumMap[&typeid(boost::filesystem::path)] = File;
    448466  TypeEnumMap[&typeid(std::vector<int>)] = ListOfIntegers;
    449467  TypeEnumMap[&typeid(double)] = Double;
     
    825843}
    826844
     845void 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
    827861
    828862void MapOfActions::setCurrentValue(const char * name, class atom * &_T)
     
    927961      stream << (*iter)->getId() << " ";
    928962    }
     963    CurrentValue[name] = stream.str();
     964  } else
     965    throw IllegalTypeException(__FILE__,__LINE__);
     966}
     967
     968void 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();
    929973    CurrentValue[name] = stream.str();
    930974  } else
     
    10511095              ;
    10521096            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;
    10531104          case Integer:
    10541105            ListRunner->second->add_options()
  • src/Actions/MapOfActions.hpp

    r6940bb r573ca5  
    99#define MAPOFACTIONS_HPP_
    1010
     11#include <boost/filesystem.hpp>
     12#include <boost/lexical_cast.hpp>
    1113#include <boost/program_options.hpp>
    12 #include <boost/lexical_cast.hpp>
    1314
    1415#include <map>
     
    3132
    3233namespace po = boost::program_options;
     34namespace fs = boost::filesystem;
    3335
    3436using boost::lexical_cast;
     
    136138  friend class MapOfActionsTest;
    137139public:
    138   enum OptionTypes { None, Boolean, Integer, ListOfIntegers, Double, ListOfDoubles, String, ListOfStrings, Vector, ListOfVectors, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };
     140  enum OptionTypes { None, Boolean, Integer, File, ListOfIntegers, Double, ListOfDoubles, String, ListOfStrings, Vector, ListOfVectors, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };
    139141
    140142  // getter for the action descriptions and short forms
     
    173175  void queryCurrentValue(const char * name, std::vector<const element *>&_T);
    174176  void queryCurrentValue(const char * name, std::vector<molecule *>&_T);
     177  void queryCurrentValue(const char * name, fs::path&_T);
    175178  template<typename T> void queryCurrentValue(const char * name, T &_T)
    176179  {
     
    208211  void setCurrentValue(const char * name, std::vector<const element *>&_T);
    209212  void setCurrentValue(const char * name, std::vector<molecule *>&_T);
     213  void setCurrentValue(const char * name, fs::path&_T);
    210214  template<class T> void setCurrentValue(const char * name, T &_T)
    211215  {
  • src/Actions/WorldAction/InputAction.cpp

    r6940bb r573ca5  
    3030#include <string>
    3131
     32#include <boost/filesystem/fstream.hpp>
     33
    3234using namespace std;
    3335
     
    3941/** =========== define the function ====================== */
    4042Action::state_ptr WorldInputAction::performCall() {
    41   MoleculeListClass *molecules = World::getInstance().getMolecules();
    42   molecule *mol = NULL;
    43   std::ifstream test;
     43//  MoleculeListClass *molecules = World::getInstance().getMolecules();
     44//  molecule *mol = NULL;
     45  boost::filesystem::ifstream test;
    4446
    4547  // obtain information
    4648  getParametersfromValueStorage();
    4749
    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());
     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();
    5258    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     }
    6159    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());
    7660  } else {
    7761    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());
    7881  }
    7982  return Action::success;
  • src/Actions/WorldAction/InputAction.def

    r6940bb r573ca5  
    77
    88// all includes and forward declarations necessary for non-integral types below
    9 
     9#include <boost/filesystem.hpp>
    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 (std::string)
     14#define paramtypes (boost::filesystem::path)
    1515#define paramtokens (WorldInputAction::NAME)
    1616#define paramreferences (filename)
  • src/Makefile.am

    r6940bb r573ca5  
    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/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
     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
    139172             
    140 QTUIHEADER = ${QTUIMOC_HEADER} UIElements/QT4/QTUIFactory.hpp
     173QTUIHEADER = \
     174  ${QTUIMOC_HEADER} \
     175  UIElements/Qt4/Pipe/QtQueryListPipe.hpp \
     176  UIElements/Qt4/QtUIFactory.hpp
    141177
    142178QTUI_DEFS =
     
    289325
    290326
    291 BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB)
     327BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB)
    292328GUI_LIBS = ${QT_LDADD} ${QT_LIB_GUI} -lQtOpenGL ${GLU_LIBS}
    293329INCLUDES = -I$(top_srcdir)/src/unittests -I$(top_srcdir)/src/Actions -I$(top_srcdir)/src/UIElements
     
    315351        Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
    316352        Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
    317         $(BOOST_LIB) \
    318         ${BOOST_THREAD_LIB} \
    319         ${BOOST_PROGRAM_OPTIONS_LIB}
    320 
    321 
    322 #Stuff for building the GUI using QT
     353        $(BOOST_LIB)
     354
     355#Stuff for building the GUI using Qt
    323356molecuildergui_SOURCES = ${QTUISOURCE} builder.cpp
    324357molecuildergui_CXXFLAGS = ${QT_CXXFLAGS} ${GLU_CXXFLAGS} -DUSE_GUI_QT
     
    326359
    327360unity_SOURCES = unity.cpp
    328 unity_LDADD = $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
     361unity_LDADD = $(BOOST_LIB)
    329362
    330363molecuildergui_LDADD = \
     
    337370        Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
    338371        $(BOOST_LIB) \
    339         ${BOOST_THREAD_LIB} \
    340         ${BOOST_PROGRAM_OPTIONS_LIB} \
    341372        ${GUI_LIBS}
    342373
     
    350381        Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
    351382        Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
    352         $(BOOST_LIB) \
    353         ${BOOST_THREAD_LIB} \
    354         ${BOOST_PROGRAM_OPTIONS_LIB}
     383        $(BOOST_LIB)
    355384
    356385analyzer_SOURCES = analyzer.cpp datacreator.cpp periodentafel.hpp datacreator.hpp
     
    363392        Exceptions/libMolecuilderExceptions-@MOLECUILDER_API_VERSION@.la \
    364393        Helpers/libMolecuilderHelpers-@MOLECUILDER_API_VERSION@.la \
    365         $(BOOST_LIB) \
    366         ${BOOST_THREAD_LIB} \
    367         ${BOOST_PROGRAM_OPTIONS_LIB}
    368 
    369 #Rules needed for QT4
     394        $(BOOST_LIB)
     395
     396#Rules needed for Qt4
    370397# UI-Files are scattered throughout several subdirectories
    371398# Therfore `%'-rules do not seem to work
  • src/Parser/MpqcParser.cpp

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

    r6940bb r573ca5  
    355355  // 3. parse the molecule in
    356356  molecule *mol = World::getInstance().createMolecule();
    357   MoleculeListClass *molecules = World::getInstance().getMolecules();
    358   molecules->insert(mol);
     357  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);
    359360  LoadMolecule(mol, FileBuffer, World::getInstance().getPeriode(), FastParsing);
    360   //mol->SetNameFromFilename(filename);
    361   mol->ActiveFlag = true;
    362   //MolList->insert(mol);
    363361
    364362  // 4. dissect the molecule into connected subgraphs
  • src/Parser/PdbParser.cpp

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

    r6940bb r573ca5  
    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);
    9497  while (file->good()) {
    9598    std::getline(*file, line, '\n');
  • src/UIElements/CommandLineUI/CommandLineDialog.cpp

    r6940bb r573ca5  
    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>
    2922#include "CommandLineUI/CommandLineDialog.hpp"
    3023
    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"
    4824
    4925using namespace std;
     
    127103}
    128104
    129 /************************** Query Infrastructure ************************/
    130 
    131 CommandLineDialog::EmptyCommandLineQuery::EmptyCommandLineQuery(string title, string _description) :
    132     Dialog::EmptyQuery(title, _description)
    133 {}
    134 
    135 CommandLineDialog::EmptyCommandLineQuery::~EmptyCommandLineQuery() {}
    136 
    137 bool CommandLineDialog::EmptyCommandLineQuery::handle() {
    138   cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n";
    139   return true;
     105void CommandLineDialog::queryFile(const char* title, string _description){
     106  registerQuery(new FileCommandLineQuery(title, _description));
    140107}
    141108
    142 CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title, string _description) :
    143     Dialog::IntQuery(title, _description)
    144 {}
    145 
    146 CommandLineDialog::IntCommandLineQuery::~IntCommandLineQuery() {}
    147 
    148 bool 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 
    158 CommandLineDialog::IntsCommandLineQuery::IntsCommandLineQuery(string title, string _description) :
    159     Dialog::IntsQuery(title, _description)
    160 {}
    161 
    162 CommandLineDialog::IntsCommandLineQuery::~IntsCommandLineQuery() {}
    163 
    164 bool 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 
    174 CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title, string _description) :
    175     Dialog::BooleanQuery(title, _description)
    176 {}
    177 
    178 CommandLineDialog::BooleanCommandLineQuery::~BooleanCommandLineQuery() {}
    179 
    180 bool 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 
    190 CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title, string _description) :
    191     Dialog::StringQuery(title, _description)
    192 {}
    193 
    194 CommandLineDialog::StringCommandLineQuery::~StringCommandLineQuery() {}
    195 
    196 bool 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 
    206 CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title, string _description) :
    207     Dialog::StringsQuery(title, _description)
    208 {}
    209 
    210 CommandLineDialog::StringsCommandLineQuery::~StringsCommandLineQuery() {}
    211 
    212 bool 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 
    222 CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title, string _description) :
    223     Dialog::DoubleQuery(title, _description)
    224 {}
    225 
    226 CommandLineDialog::DoubleCommandLineQuery::~DoubleCommandLineQuery() {}
    227 
    228 bool 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 
    238 CommandLineDialog::DoublesCommandLineQuery::DoublesCommandLineQuery(string title, string _description) :
    239     Dialog::DoublesQuery(title, _description)
    240 {}
    241 
    242 CommandLineDialog::DoublesCommandLineQuery::~DoublesCommandLineQuery() {}
    243 
    244 bool 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 
    254 CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, string _description) :
    255     Dialog::AtomQuery(title, _description)
    256 {}
    257 
    258 CommandLineDialog::AtomCommandLineQuery::~AtomCommandLineQuery() {}
    259 
    260 bool 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 
    272 CommandLineDialog::AtomsCommandLineQuery::AtomsCommandLineQuery(string title, string _description) :
    273     Dialog::AtomsQuery(title, _description)
    274 {}
    275 
    276 CommandLineDialog::AtomsCommandLineQuery::~AtomsCommandLineQuery() {}
    277 
    278 bool 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 
    294 CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, string _description) :
    295     Dialog::MoleculeQuery(title, _description)
    296 {}
    297 
    298 CommandLineDialog::MoleculeCommandLineQuery::~MoleculeCommandLineQuery() {}
    299 
    300 bool 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 
    312 CommandLineDialog::MoleculesCommandLineQuery::MoleculesCommandLineQuery(string title, string _description) :
    313     Dialog::MoleculesQuery(title, _description)
    314 {}
    315 
    316 CommandLineDialog::MoleculesCommandLineQuery::~MoleculesCommandLineQuery() {}
    317 
    318 bool 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 
    334 CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, bool _check, string _description) :
    335     Dialog::VectorQuery(title,_check, _description)
    336 {}
    337 
    338 CommandLineDialog::VectorCommandLineQuery::~VectorCommandLineQuery()
    339 {}
    340 
    341 bool 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 
    359 CommandLineDialog::VectorsCommandLineQuery::VectorsCommandLineQuery(string title, bool _check, string _description) :
    360     Dialog::VectorsQuery(title,_check, _description)
    361 {}
    362 
    363 CommandLineDialog::VectorsCommandLineQuery::~VectorsCommandLineQuery()
    364 {}
    365 
    366 bool 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 
    386 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) :
    387     Dialog::BoxQuery(title, _description)
    388 {}
    389 
    390 CommandLineDialog::BoxCommandLineQuery::~BoxCommandLineQuery()
    391 {}
    392 
    393 bool 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 
    415 CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, string _description) :
    416     Dialog::ElementQuery(title, _description)
    417 {}
    418 
    419 CommandLineDialog::ElementCommandLineQuery::~ElementCommandLineQuery()
    420 {}
    421 
    422 bool 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 
    436 CommandLineDialog::ElementsCommandLineQuery::ElementsCommandLineQuery(string title, string _description) :
    437     Dialog::ElementsQuery(title, _description)
    438 {}
    439 
    440 CommandLineDialog::ElementsCommandLineQuery::~ElementsCommandLineQuery()
    441 {}
    442 
    443 bool 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 }
     109/************************** Query Infrastructure ************************/
     110/*       ---> shifted to folder Query                                   */
     111/************************************************************************/
  • src/UIElements/CommandLineUI/CommandLineDialog.hpp

    r6940bb r573ca5  
    4444  virtual void queryElement(const char*, std::string = "");
    4545  virtual void queryElements(const char*, std::string = "");
     46  virtual void queryFile(const char*, std::string = "");
    4647
    4748protected:
     
    165166    virtual bool handle();
    166167  };
     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  };
    167175};
    168176
  • src/UIElements/Dialog.cpp

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

    r6940bb r573ca5  
    1313#include<vector>
    1414
     15#include <boost/filesystem.hpp>
     16
    1517#include "Box.hpp"
    1618#include "LinearAlgebra/Vector.hpp"
     
    2426/** Dialog is one of the two main classes of the UIFactory base class.
    2527 *
    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.
     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.
    2830 *
    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.
     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.
    3335 */
    3436class Dialog
     
    5759  virtual void queryElement(const char*, std::string = "")=0;
    5860  virtual void queryElements(const char*, std::string = "")=0;
     61  virtual void queryFile(const char*, std::string = "")=0;
    5962
    6063  virtual bool display();
     
    7679  //due to lack of common code for query types as well as GUI-Types (all subtypes differ a lot)
    7780
    78   //base class for all queries
     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   */
    79107  class Query {
    80108    friend class Dialog;
     
    271299  };
    272300
     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
    273311void registerQuery(Query* query);
    274312
  • src/UIElements/Makefile.am

    r6940bb r573ca5  
    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 \
    4362  Dialog.cpp \
    4463  MainWindow.cpp
     
    5473
    5574TEXTUISOURCE = \
     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 \
    5693  TextUI/TextDialog.cpp \
    5794  TextUI/TextStatusIndicator.cpp \
     
    65102
    66103COMMANDLINEUISOURCE = \
     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 \
    67122  CommandLineUI/CommandLineDialog.cpp \
    68123  CommandLineUI/CommandLineStatusIndicator.cpp \
  • src/UIElements/TextUI/TextDialog.cpp

    r6940bb r573ca5  
    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>
    2922#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>
    4423
    4524using namespace std;
     
    125104}
    126105
    127 /************************** Query Infrastructure ************************/
    128 
    129 TextDialog::EmptyTextQuery::EmptyTextQuery(string title, std::string _description) :
    130     Dialog::EmptyQuery(title,_description)
    131 {}
    132 
    133 TextDialog::EmptyTextQuery::~EmptyTextQuery() {}
    134 
    135 bool TextDialog::EmptyTextQuery::handle() {
    136   cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n";
    137   return true;
     106void TextDialog::queryFile(const char* title, std::string description){
     107  registerQuery(new FileTextQuery(title,description));
    138108}
    139109
    140 TextDialog::IntTextQuery::IntTextQuery(string title, std::string _description) :
    141     Dialog::IntQuery(title,_description)
    142 {}
     110/************************** Query Infrastructure ************************/
     111/*       ---> shifted to folder Query                                   */
     112/************************************************************************/
    143113
    144 TextDialog::IntTextQuery::~IntTextQuery() {}
    145 
    146 bool 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 
    164 TextDialog::IntsTextQuery::IntsTextQuery(string title, std::string _description) :
    165     Dialog::IntsQuery(title,_description)
    166 {}
    167 
    168 TextDialog::IntsTextQuery::~IntsTextQuery() {}
    169 
    170 bool 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 
    193 TextDialog::BooleanTextQuery::BooleanTextQuery(string title, std::string _description) :
    194     Dialog::BooleanQuery(title,_description)
    195 {}
    196 
    197 TextDialog::BooleanTextQuery::~BooleanTextQuery() {}
    198 
    199 bool 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 
    222 TextDialog::StringTextQuery::StringTextQuery(string title, std::string _description) :
    223     Dialog::StringQuery(title,_description)
    224 {}
    225 
    226 TextDialog::StringTextQuery::~StringTextQuery() {}
    227 
    228 bool TextDialog::StringTextQuery::handle() {
    229   Log() << Verbose(0) << getTitle();
    230   getline(cin,tmp);
    231   return true;
    232 }
    233 
    234 TextDialog::StringsTextQuery::StringsTextQuery(string title, std::string _description) :
    235     Dialog::StringsQuery(title,_description)
    236 {}
    237 
    238 TextDialog::StringsTextQuery::~StringsTextQuery() {}
    239 
    240 bool 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 
    257 TextDialog::DoubleTextQuery::DoubleTextQuery(string title, std::string _description) :
    258     Dialog::DoubleQuery(title,_description)
    259 {}
    260 
    261 TextDialog::DoubleTextQuery::~DoubleTextQuery() {}
    262 
    263 bool 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 
    281 TextDialog::DoublesTextQuery::DoublesTextQuery(string title, std::string _description) :
    282     Dialog::DoublesQuery(title,_description)
    283 {}
    284 
    285 TextDialog::DoublesTextQuery::~DoublesTextQuery() {}
    286 
    287 bool 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 
    310 TextDialog::AtomTextQuery::AtomTextQuery(string title, std::string _description) :
    311     Dialog::AtomQuery(title,_description)
    312 {}
    313 
    314 TextDialog::AtomTextQuery::~AtomTextQuery() {}
    315 
    316 bool 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 
    343 TextDialog::AtomsTextQuery::AtomsTextQuery(string title, std::string _description) :
    344     Dialog::AtomsQuery(title,_description)
    345 {}
    346 
    347 TextDialog::AtomsTextQuery::~AtomsTextQuery() {}
    348 
    349 bool 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 
    382 TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, std::string _description) :
    383     Dialog::MoleculeQuery(title,_description)
    384 {}
    385 
    386 TextDialog::MoleculeTextQuery::~MoleculeTextQuery() {}
    387 
    388 bool 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 
    415 TextDialog::MoleculesTextQuery::MoleculesTextQuery(string title, std::string _description) :
    416     Dialog::MoleculesQuery(title,_description)
    417 {}
    418 
    419 TextDialog::MoleculesTextQuery::~MoleculesTextQuery() {}
    420 
    421 bool 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 
    454 TextDialog::VectorTextQuery::VectorTextQuery(std::string title, bool _check, std::string _description) :
    455     Dialog::VectorQuery(title,_check,_description)
    456 {}
    457 
    458 TextDialog::VectorTextQuery::~VectorTextQuery()
    459 {}
    460 
    461 bool 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 
    493 TextDialog::VectorsTextQuery::VectorsTextQuery(std::string title, bool _check, std::string _description) :
    494     Dialog::VectorsQuery(title,_check,_description)
    495 {}
    496 
    497 TextDialog::VectorsTextQuery::~VectorsTextQuery()
    498 {}
    499 
    500 bool 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 
    542 TextDialog::BoxTextQuery::BoxTextQuery(std::string title, std::string _description) :
    543     Dialog::BoxQuery(title,_description)
    544 {}
    545 
    546 TextDialog::BoxTextQuery::~BoxTextQuery()
    547 {}
    548 
    549 bool 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 
    572 TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::string _description) :
    573     Dialog::ElementQuery(title,_description)
    574 {}
    575 
    576 TextDialog::ElementTextQuery::~ElementTextQuery()
    577 {}
    578 
    579 bool 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 
    636 TextDialog::ElementsTextQuery::ElementsTextQuery(std::string title, std::string _description) :
    637     Dialog::ElementsQuery(title,_description)
    638 {}
    639 
    640 TextDialog::ElementsTextQuery::~ElementsTextQuery()
    641 {}
    642 
    643 bool 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

    r6940bb r573ca5  
    4141  virtual void queryElement(const char*, std::string = "");
    4242  virtual void queryElements(const char*, std::string = "");
     43  virtual void queryFile(const char*, std::string = "");
    4344
    4445protected:
     
    162163    virtual bool handle();
    163164  };
     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  };
    164172};
    165173
  • src/builder.cpp

    r6940bb r573ca5  
    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

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

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

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