Changeset e6317b for src/UIElements


Ignore:
Timestamp:
Jun 16, 2010, 12:24:21 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
492279
Parents:
f8e486 (diff), 980dd6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Broken: Merge commit 'Gitosis/stable' into stable

Conflicts:

molecuilder/src/Actions/AnalysisAction/PairCorrelationToPointAction.cpp
molecuilder/src/Actions/AnalysisAction/PairCorrelationToSurfaceAction.cpp
molecuilder/src/Makefile.am

Location:
src/UIElements
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/CommandLineUI/CommandLineDialog.cpp

    rf8e486 re6317b  
    88#include "Helpers/MemDebug.hpp"
    99
    10 #include <cassert>
    1110#include <iostream>
     11#include <vector>
    1212
    1313#include <Descriptors/AtomDescriptor.hpp>
     
    1616#include <Descriptors/MoleculeIdDescriptor.hpp>
    1717#include "CommandLineUI/CommandLineDialog.hpp"
     18
     19#include "Actions/Values.hpp"
    1820
    1921#include "element.hpp"
     
    7981}
    8082
    81 void CommandLineDialog::queryElement(const char* title, const element **target, string _description){
     83void CommandLineDialog::queryElement(const char* title, std::vector<element *> *target, string _description){
    8284  registerQuery(new ElementCommandLineQuery(title,target, _description));
    8385}
     
    106108    tmp = CommandLineParser::getInstance().vm[getTitle()].as<int>();
    107109    return true;
    108   } else
    109     return false;
     110  } else {
     111    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integer for " << getTitle() << "." << endl);
     112    return false;
     113  }
    110114}
    111115
     
    117121
    118122bool CommandLineDialog::BooleanCommandLineQuery::handle() {
    119   bool badInput = false;
    120   char input = ' ';
    121   do{
    122     badInput = false;
    123     Log() << Verbose(0) << getTitle();
    124     cin >> input;
    125     if ((input == 'y' ) || (input == 'Y')) {
    126       tmp = true;
    127     } else if ((input == 'n' ) || (input == 'N')) {
    128       tmp = false;
    129     } else {
    130       badInput=true;
    131       cin.clear();
    132       cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    133       Log() << Verbose(0) << "Input was not of [yYnN]!" << endl;
    134     }
    135   } while(badInput);
    136   // clear the input buffer of anything still in the line
    137   cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    138   return true;
     123  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     124    tmp = CommandLineParser::getInstance().vm[getTitle()].as<bool>();
     125    return true;
     126  } else {
     127    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing boolean for " << getTitle() << "." << endl);
     128    return false;
     129  }
    139130}
    140131
     
    149140    tmp = CommandLineParser::getInstance().vm[getTitle()].as<string>();
    150141    return true;
    151   } else
    152     return false;
     142  } else {
     143    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl);
     144    return false;
     145  }
    153146}
    154147
     
    163156    tmp = CommandLineParser::getInstance().vm[getTitle()].as<double>();
    164157    return true;
    165   } else
    166     return false;
     158  } else {
     159    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing double for " << getTitle() << "." << endl);
     160    return false;
     161  }
    167162}
    168163
     
    179174    tmp = World::getInstance().getAtom(AtomById(IdxOfAtom));
    180175    return true;
    181   } else
    182     return false;
     176  } else {
     177    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atom for " << getTitle() << "." << endl);
     178    return false;
     179  }
    183180}
    184181
     
    199196      tmp = NULL;
    200197    return true;
    201   } else
    202     return false;
     198  } else {
     199    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecule for " << getTitle() << "." << endl);
     200    return false;
     201  }
    203202}
    204203
     
    211210
    212211bool CommandLineDialog::VectorCommandLineQuery::handle() {
    213   vector<double> temp;
    214   if (CommandLineParser::getInstance().vm.count(getTitle())) {
    215     temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >();
    216     assert((temp.size() == 3) && "Vector from command line does not have three components.");
    217     for (int i=0;i<NDIM;i++)
    218       tmp->at(i) = temp[i];
    219     return true;
    220   } else
    221     return false;
     212  VectorValue temp;
     213  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     214    temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
     215    tmp->at(0) = temp.x;
     216    tmp->at(1) = temp.y;
     217    tmp->at(2) = temp.z;
     218    return true;
     219  } else {
     220    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vector for " << getTitle() << "." << endl);
     221    return false;
     222  }
    222223}
    223224
     
    231232
    232233bool CommandLineDialog::BoxCommandLineQuery::handle() {
    233   vector<double> temp;
    234   if (CommandLineParser::getInstance().vm.count(getTitle())) {
    235     temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >();
    236     assert((temp.size() == 6) && "Symmetric box matrix from command line does not have six components.");
    237     for (int i=0;i<6;i++) {
    238       tmp[i] = temp[i];
    239     }
    240     return true;
    241   } else
    242     return false;
    243 }
    244 
    245 CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, const element **target, string _description) :
     234  BoxValue temp;
     235  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     236    temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >();
     237    tmp[0] = temp.xx;
     238    tmp[1] = temp.xy;
     239    tmp[2] = temp.xz;
     240    tmp[3] = temp.yy;
     241    tmp[4] = temp.yz;
     242    tmp[5] = temp.zz;
     243    return true;
     244  } else {
     245    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing symmetric box matrix for " << getTitle() << "." << endl);
     246    return false;
     247  }
     248}
     249
     250CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, std::vector<element *> *target, string _description) :
    246251    Dialog::ElementQuery(title,target, _description)
    247252{}
     
    252257bool CommandLineDialog::ElementCommandLineQuery::handle() {
    253258  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
    254   int Z;
     259  periodentafel *periode = World::getInstance().getPeriode();
     260  element *elemental = NULL;
    255261  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    256262    vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
    257     vector<int>::iterator ElementRunner = AllElements.begin();
    258     Z = *ElementRunner;
    259     // TODO: So far, this does not really erase the element in the parsed list.
    260     AllElements.erase(ElementRunner);
    261     tmp = World::getInstance().getPeriode()->FindElement(Z);
    262     return true;
    263   } else
    264     return false;
    265 }
     263    for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) {
     264      elemental = periode->FindElement(*ZRunner);
     265      ASSERT(elemental != NULL, "Invalid element specified in ElementCommandLineQuery");
     266      elements.push_back(elemental);
     267    }
     268    return true;
     269  } else {
     270    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);
     271    return false;
     272  }
     273}
  • src/UIElements/CommandLineUI/CommandLineDialog.hpp

    rf8e486 re6317b  
    3636  virtual void queryVector(const char*,Vector *,const double * const,bool, std::string = "");
    3737  virtual void queryBox(const char*,double ** const, std::string = "");
    38   virtual void queryElement(const char*,const element **, std::string = "");
     38  virtual void queryElement(const char*, std::vector<element *> *, std::string = "");
    3939
    4040protected:
     
    105105  class ElementCommandLineQuery : public Dialog::ElementQuery {
    106106  public:
    107     ElementCommandLineQuery(std::string title, const element **_target, std::string _description = "");
     107    ElementCommandLineQuery(std::string title, std::vector<element *> *_target, std::string _description = "");
    108108    virtual ~ElementCommandLineQuery();
    109109    virtual bool handle();
  • src/UIElements/CommandLineUI/CommandLineWindow.cpp

    rf8e486 re6317b  
    1414
    1515#include "Actions/ActionRegistry.hpp"
     16#include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
    1617#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
    17 #include "Actions/AnalysisAction/PairCorrelationToPointAction.hpp"
    18 #include "Actions/AnalysisAction/PairCorrelationToSurfaceAction.hpp"
     18#include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
    1919#include "Actions/AtomAction/AddAction.hpp"
    2020#include "Actions/AtomAction/ChangeElementAction.hpp"
     
    2828#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
    2929#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
     30#include "Actions/FragmentationAction/FragmentationAction.hpp"
    3031#include "Actions/MoleculeAction/BondFileAction.hpp"
    3132#include "Actions/MoleculeAction/ChangeNameAction.hpp"
     
    3536#include "Actions/MoleculeAction/SaveBondsAction.hpp"
    3637#include "Actions/MoleculeAction/SaveTemperatureAction.hpp"
     38#include "Actions/MoleculeAction/TranslateAction.hpp"
    3739#include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
    3840#include "Actions/ParserAction/LoadXyzAction.hpp"
     
    7577CommandLineWindow::~CommandLineWindow()
    7678{
    77 //  // go through all possible actions
    78 //  for(std::map<const std::string,Action*>::iterator ActionRunner = ActionRegistry::getInstance().getBeginIter(); ActionRegistry::getInstance().getBeginIter() != ActionRegistry::getInstance().getEndIter(); ActionRunner = ActionRegistry::getInstance().getBeginIter()) {
    79 //    ActionRegistry::getInstance().unregisterAction(ActionRunner->second);
    80 //    delete(ActionRunner->second);
    81 //  }
    82 
    8379  delete statusIndicator;
    8480}
     
    8682void CommandLineWindow::display() {
    8783  // go through all possible actions
    88   for(std::map<const std::string,Action*>::iterator ActionRunner = ActionRegistry::getInstance().getBeginIter(); ActionRunner != ActionRegistry::getInstance().getEndIter(); ActionRunner++) {
    89     // check whether action is present in command line
    90     if (CommandLineParser::getInstance().vm.count(ActionRunner->first)) {
    91       ActionRunner->second->call();
    92     }
     84  for (std::list<std::string>::iterator CommandRunner = CommandLineParser::getInstance().SequenceOfActions.begin(); CommandRunner != CommandLineParser::getInstance().SequenceOfActions.end(); ++CommandRunner) {
     85    cout << "Checking presence of " << *CommandRunner << endl;
     86    if (ActionRegistry::getInstance().isActionByNamePresent(*CommandRunner))
     87      ActionRegistry::getInstance().getActionByName(*CommandRunner)->call();
    9388  }
    9489}
     
    9691void CommandLineWindow::populateAnalysisActions()
    9792{
     93  new AnalysisMolecularVolumeAction();
    9894  new AnalysisPairCorrelationAction();
    99   new AnalysisPairCorrelationToPointAction();
    100   new AnalysisPairCorrelationToSurfaceAction();
     95  new AnalysisPrincipalAxisSystemAction();
    10196}
    10297
     
    121116{
    122117  new FragmentationDepthFirstSearchAction();
     118  new FragmentationFragmentationAction();
     119  new FragmentationSubgraphDissectionAction();
    123120}
    124121
     
    132129  new MoleculeSaveBondsAction();
    133130  new MoleculeSaveTemperatureAction();
     131  new MoleculeTranslateAction();
    134132  new MoleculeVerletIntegrationAction();
    135133}
  • src/UIElements/Dialog.cpp

    rf8e486 re6317b  
    4141    retval &= (*iter)->handle();
    4242    // if any query fails (is canceled), we can end the handling process
    43     if(!retval)
     43    if(!retval) {
     44      DoeLog(1) && (eLog() << Verbose(1) << "The following query failed: " << (**iter).getTitle() << "." << endl);
    4445      break;
     46    }
    4547  }
    4648  if (retval){
     
    201203
    202204// Element Queries
    203 Dialog::ElementQuery::ElementQuery(std::string title, const element **_target, std::string _description) :
     205Dialog::ElementQuery::ElementQuery(std::string title, std::vector<element *> *_target, std::string _description) :
    204206  Query(title, _description),
    205   tmp(0),
    206207  target(_target)
    207208  {}
     
    210211
    211212void Dialog::ElementQuery::setResult(){
    212   *target=tmp;
    213 }
     213  *target=elements;
     214}
  • src/UIElements/Dialog.hpp

    rf8e486 re6317b  
    1111#include<string>
    1212#include<list>
     13#include<vector>
    1314
    1415class atom;
     
    3233  virtual void queryVector(const char*,Vector *,const double *const,bool, std::string = "")=0;
    3334  virtual void queryBox(const char*,double ** const, std::string = "")=0;
    34   virtual void queryElement(const char*,const element **, std::string = "")=0;
     35  virtual void queryElement(const char*, std::vector<element *> *, std::string = "")=0;
    3536
    3637  virtual bool display();
     
    4950  //base class for all queries
    5051  class Query {
     52    friend class Dialog;
    5153  public:
    5254    Query(std::string _title, std::string _description = "");
     
    172174  class ElementQuery : public Query {
    173175  public:
    174     ElementQuery(std::string title, const element**_target, std::string _description = "");
     176    ElementQuery(std::string title, std::vector<element *> *_target, std::string _description = "");
    175177    virtual ~ElementQuery();
    176178    virtual bool handle()=0;
    177179    virtual void setResult();
    178180  protected:
    179     const element *tmp;
     181    std::vector<element *> elements;
    180182  private:
    181     const element **target;
     183    std::vector<element *> * const target;
    182184  };
    183185
  • src/UIElements/TextUI/TextDialog.cpp

    rf8e486 re6317b  
    7474}
    7575
    76 void TextDialog::queryElement(const char* title, const element **target, string description){
     76void TextDialog::queryElement(const char* title, std::vector<element *> *target, string description){
    7777  registerQuery(new ElementTextQuery(title,target,description));
    7878}
     
    283283}
    284284
    285 TextDialog::ElementTextQuery::ElementTextQuery(std::string title, const element **target, std::string _description) :
    286     Dialog::ElementQuery(title,target,_description)
     285TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::vector<element *> *_target, std::string _description) :
     286    Dialog::ElementQuery(title,_target,_description)
    287287{}
    288288
     
    293293  bool badInput=false;
    294294  bool aborted = false;
     295  element * tmp = NULL;
    295296  do{
    296297    badInput = false;
     
    309310          Log() << Verbose(0) << "No element with this atomic number!" << endl;
    310311          badInput = true;
     312        } else {
     313          elements.push_back(tmp);
    311314        }
    312315      }
     
    331334          Log() << Verbose(0) << "No element with this shorthand!" << endl;
    332335          badInput = true;
     336        } else {
     337          elements.push_back(tmp);
    333338        }
    334339      }
  • src/UIElements/TextUI/TextDialog.hpp

    rf8e486 re6317b  
    3333  virtual void queryVector(const char*,Vector *,const double * const,bool, std::string = "");
    3434  virtual void queryBox(const char*,double ** const, std::string = "");
    35   virtual void queryElement(const char*,const element **, std::string = "");
     35  virtual void queryElement(const char*, std::vector<element *> *, std::string = "");
    3636
    3737protected:
     
    102102  class ElementTextQuery : public Dialog::ElementQuery {
    103103  public:
    104     ElementTextQuery(std::string title, const element **_target, std::string _description = NULL);
     104    ElementTextQuery(std::string title, std::vector<element *> *_target, std::string _description = NULL);
    105105    virtual ~ElementTextQuery();
    106106    virtual bool handle();
Note: See TracChangeset for help on using the changeset viewer.