Changeset 9ee38b for src/UIElements


Ignore:
Timestamp:
Aug 28, 2010, 12:52:58 AM (15 years ago)
Author:
Frederik Heber <heber@…>
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:
b4fa106
Parents:
0b2ce9
git-author:
Frederik Heber <heber@…> (08/25/10 17:20:37)
git-committer:
Frederik Heber <heber@…> (08/28/10 00:52:58)
Message:

Extended macro framework.

Extensions:

  • all central definitions reside in .def files
    • This if file is necessary because we need the definitions at two places: hpp and cpp
    • And as we always use the same define names, we have to undefine them at the end of both (otherwise we get compiler warnings and are prone to dumb mistakes of forgotten defines seeming present)
  • the .hpp is just a very tiny header, that should be possible to batch- construct inside Makefile as well
  • .cpp includes some Action_...hpp files and implements the function

For later (i.e. when ActionRegistry becomes prototype copier)

  • instead of waiting for clone(), for now we simply call the prototype.
  • in the action command we must not yet prefix paramreferences with "params."

Changes:

  • Dialog::query<> is a template which is specialized for every present query...() function. We need it to automatize fillDialog()
  • all AnalysisAction's are now converted, i.e. framework is functional with parameters and queries (MolecularVolume had none).
Location:
src/UIElements
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Dialog.cpp

    r0b2ce9 r9ee38b  
    2525#include "Helpers/Verbose.hpp"
    2626#include "atom.hpp"
     27#include "Box.hpp"
    2728#include "element.hpp"
    2829#include "molecule.hpp"
    2930#include "LinearAlgebra/Vector.hpp"
    3031#include "LinearAlgebra/Matrix.hpp"
    31 #include "Box.hpp"
    3232
    3333using namespace std;
     
    8484}
    8585
     86template <> void Dialog::query<void *>(const char *token, std::string description)
     87{
     88  queryEmpty(token, description);
     89}
     90
     91template <> void Dialog::query<bool>(const char *token, std::string description)
     92{
     93  queryBoolean(token, description);
     94}
     95
     96template <> void Dialog::query<int>(const char *token, std::string description)
     97{
     98  queryInt(token, description);
     99}
     100
     101template <> void Dialog::query< std::vector<int> >(const char *token, std::string description)
     102{
     103  queryInts(token, description);
     104}
     105
     106template <> void Dialog::query<double>(const char *token, std::string description)
     107{
     108  queryDouble(token, description);
     109}
     110
     111template <> void Dialog::query< std::vector<double> >(const char *token, std::string description)
     112{
     113  queryDoubles(token, description);
     114}
     115
     116template <> void Dialog::query<std::string>(const char *token, std::string description)
     117{
     118  queryString(token, description);
     119}
     120
     121template <> void Dialog::query< std::vector<std::string> >(const char *token, std::string description)
     122{
     123  queryStrings(token, description);
     124}
     125
     126template <> void Dialog::query<atom *>(const char *token, std::string description)
     127{
     128  queryAtom(token, description);
     129}
     130
     131template <> void Dialog::query< std::vector<atom *> >(const char *token, std::string description)
     132{
     133  queryAtoms(token, description);
     134}
     135
     136template <> void Dialog::query<molecule *>(const char *token, std::string description)
     137{
     138  queryMolecule(token, description);
     139}
     140
     141template <> void Dialog::query< std::vector<molecule *> >(const char *token, std::string description)
     142{
     143  queryMolecules(token, description);
     144}
     145
     146template <> void Dialog::query<Vector>(const char *token, std::string description)
     147{
     148  queryVector(token, false, description);
     149}
     150
     151template <> void Dialog::query< std::vector<Vector> >(const char *token, std::string description)
     152{
     153  queryVectors(token, false, description);
     154}
     155
     156template <> void Dialog::query<Box>(const char *token, std::string description)
     157{
     158  queryBox(token, description);
     159}
     160
     161template <> void Dialog::query<const element *>(const char *token, std::string description)
     162{
     163  queryElement(token, description);
     164}
     165
     166template <> void Dialog::query< std::vector<const element *> >(const char *token, std::string description)
     167{
     168  queryElements(token, description);
     169}
     170
    86171/****************** Query types Infrastructure **************************/
    87172
  • src/UIElements/Dialog.hpp

    r0b2ce9 r9ee38b  
    3737  Dialog();
    3838  virtual ~Dialog();
     39
     40  template <class T> void query(const char *, std::string = "");
    3941
    4042  virtual void queryEmpty(const char *, std::string = "")=0;
  • src/UIElements/QT4/QTDialog.cpp

    r0b2ce9 r9ee38b  
    9898/************************** Query Infrastructure ************************/
    9999
    100 void QTDialog::queryEmpty(char const*, string){
     100void QTDialog::queryEmpty(const char*, std::string){
    101101  // TODO
    102102  ASSERT(false, "Not implemented yet");
    103103}
    104104
    105 void QTDialog::queryBoolean(char const*,string){
     105void QTDialog::queryBoolean(const char*,string){
    106106  // TODO
    107107  ASSERT(false, "Not implemented yet");
    108108}
    109109
    110 void QTDialog::queryAtom(char const*, string){
     110void QTDialog::queryAtom(const char*, std::string){
    111111  // TODO
    112112  ASSERT(false, "Not implemented yet");
    113113}
    114114
    115 void QTDialog::queryAtoms(char const*, string){
     115void QTDialog::queryAtoms(const char*, std::string){
    116116  // TODO
    117117  ASSERT(false, "Not implemented yet");
    118118}
    119119
    120 void QTDialog::queryBox(char const*, string){
     120void QTDialog::queryBox(const char*, std::string){
    121121  // TODO
    122122  ASSERT(false, "Not implemented yet");
     
    172172}
    173173
    174 void QTDialog::queryElement(const char* title, string){
     174void QTDialog::queryElement(const char* title, std::string){
    175175  registerQuery(new ElementQTQuery(title,inputLayout,this));
    176176}
    177177
    178 void QTDialog::queryElements(const char* title, string){
     178void QTDialog::queryElements(const char* title, std::string){
    179179  // TODO
    180180  ASSERT(false, "Not implemented yet");
     
    353353}
    354354
    355 // All values besides the empty string are valid
     355// All values besides the empty std::string are valid
    356356bool QTDialog::StringQTQuery::handle()
    357357{
     
    400400}
    401401
    402 // All values besides the empty string are valid
     402// All values besides the empty std::string are valid
    403403bool QTDialog::StringsQTQuery::handle()
    404404{
    405405  // dissect by ","
    406   string::iterator olditer = temp.begin();
     406  std::string::iterator olditer = temp.begin();
    407407  for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) {
    408408    if (*iter == ' ') {
     
    429429      iter != molecules.end();
    430430      ++iter) {
    431     stringstream sstr;
     431    std::stringstream sstr;
    432432    sstr << (*iter)->IndexNr << "\t" << (*iter)->getName();
    433433    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr));
     
    465465      iter != molecules.end();
    466466      ++iter) {
    467     stringstream sstr;
     467    std::stringstream sstr;
    468468    sstr << (*iter)->IndexNr << "\t" << (*iter)->getName();
    469469    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr));
     
    565565      ++iter)
    566566  {
    567     stringstream sstr;
     567    std::stringstream sstr;
    568568    sstr << (*iter).first << "\t" << (*iter).second->getName();
    569569    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
     
    600600      ++iter)
    601601  {
    602     stringstream sstr;
     602    std::stringstream sstr;
    603603    sstr << (*iter).first << "\t" << (*iter).second->getName();
    604604    inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
  • src/UIElements/TextUI/TextDialog.cpp

    r0b2ce9 r9ee38b  
    5757}
    5858
    59 
    60 void TextDialog::queryEmpty(const char* title, string description){
     59void TextDialog::queryEmpty(const char* title, std::string description){
    6160  registerQuery(new EmptyTextQuery(title,description));
    6261}
    6362
    64 void TextDialog::queryBoolean(const char* title, string description){
     63void TextDialog::queryBoolean(const char* title, std::string description){
    6564  registerQuery(new BooleanTextQuery(title,description));
    6665}
    6766
    68 void TextDialog::queryInt(const char* title, string description){
     67void TextDialog::queryInt(const char* title, std::string description){
    6968  registerQuery(new IntTextQuery(title,description));
    7069}
    7170
    72 void TextDialog::queryInts(const char* title, string description){
     71void TextDialog::queryInts(const char* title, std::string description){
    7372  registerQuery(new IntsTextQuery(title,description));
    7473}
    7574
    76 void TextDialog::queryDouble(const char* title, string description){
     75void TextDialog::queryDouble(const char* title, std::string description){
    7776  registerQuery(new DoubleTextQuery(title,description));
    7877}
    7978
    80 void TextDialog::queryDoubles(const char* title, string description){
     79void TextDialog::queryDoubles(const char* title, std::string description){
    8180  registerQuery(new DoublesTextQuery(title,description));
    8281}
    8382
    84 void TextDialog::queryString(const char* title, string description){
     83void TextDialog::queryString(const char* title, std::string description){
    8584  registerQuery(new StringTextQuery(title,description));
    8685}
    8786
    88 void TextDialog::queryStrings(const char* title, string description){
     87void TextDialog::queryStrings(const char* title, std::string description){
    8988  registerQuery(new StringsTextQuery(title,description));
    9089}
    9190
    92 void TextDialog::queryAtom(const char* title, string description) {
     91void TextDialog::queryAtom(const char* title, std::string description) {
    9392  registerQuery(new AtomTextQuery(title,description));
    9493}
    9594
    96 void TextDialog::queryAtoms(const char* title, string description) {
     95void TextDialog::queryAtoms(const char* title, std::string description) {
    9796  registerQuery(new AtomsTextQuery(title,description));
    9897}
    9998
    100 void TextDialog::queryMolecule(const char* title, string description) {
     99void TextDialog::queryMolecule(const char* title, std::string description) {
    101100  registerQuery(new MoleculeTextQuery(title,description));
    102101}
    103102
    104 void TextDialog::queryMolecules(const char* title, string description) {
     103void TextDialog::queryMolecules(const char* title, std::string description) {
    105104  registerQuery(new MoleculesTextQuery(title,description));
    106105}
    107106
    108 void TextDialog::queryVector(const char* title, bool check, string description) {
     107void TextDialog::queryVector(const char* title, bool check, std::string description) {
    109108  registerQuery(new VectorTextQuery(title,check,description));
    110109}
    111110
    112 void TextDialog::queryVectors(const char* title, bool check, string description) {
     111void TextDialog::queryVectors(const char* title, bool check, std::string description) {
    113112  registerQuery(new VectorsTextQuery(title,check,description));
    114113}
    115114
    116 void TextDialog::queryBox(const char* title, string description) {
     115void TextDialog::queryBox(const char* title, std::string description) {
    117116  registerQuery(new BoxTextQuery(title,description));
    118117}
    119118
    120 void TextDialog::queryElement(const char* title, string description){
     119void TextDialog::queryElement(const char* title, std::string description){
    121120  registerQuery(new ElementTextQuery(title,description));
    122121}
    123122
    124 void TextDialog::queryElements(const char* title, string description){
     123void TextDialog::queryElements(const char* title, std::string description){
    125124  registerQuery(new ElementsTextQuery(title,description));
    126125}
     
    174173  getline(cin,line);
    175174  // dissect by " "
    176   string::iterator olditer = line.begin();
     175  std::string::iterator olditer = line.begin();
    177176  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
    178177    if (*iter == ' ') {
     
    243242  getline(cin,temp);
    244243  // dissect by " "
    245   string::iterator olditer = temp.begin();
     244  std::string::iterator olditer = temp.begin();
    246245  for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) {
    247246    if (*iter == ' ') {
     
    291290  getline(cin,line);
    292291  // dissect by " "
    293   string::iterator olditer = line.begin();
     292  std::string::iterator olditer = line.begin();
    294293  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
    295294    if (*iter == ' ') {
     
    354353  getline(cin,line);
    355354  // dissect by " "
    356   string::iterator olditer = line.begin();
     355  std::string::iterator olditer = line.begin();
    357356  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
    358357    if (*iter == ' ') {
     
    426425  getline(cin,line);
    427426  // dissect by " "
    428   string::iterator olditer = line.begin();
     427  std::string::iterator olditer = line.begin();
    429428  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
    430429    if (*iter == ' ') {
     
    473472  double coord = 0.;
    474473  int counter = 0;
    475   string::iterator olditer = line.begin();
     474  std::string::iterator olditer = line.begin();
    476475  for(string::iterator iter = line.begin(); (iter != line.end()) && (counter != 3); ++iter) {
    477476    if (*iter == ',') {
     
    511510  // dissect by ","
    512511  double coord = 0.;
    513   string::iterator olditerspace = line.begin();
    514   string::iterator olditercomma = line.begin();
     512  std::string::iterator olditerspace = line.begin();
     513  std::string::iterator olditercomma = line.begin();
    515514  int counter = 0;
    516515  for(string::iterator vectoriter = line.begin(); vectoriter != line.end(); ++vectoriter) {
     
    608607    // Try to read as shorthand
    609608    // the last buffer content was not removed, so we read the
    610     // same thing again, this time as a string
    611     string shorthand;
     609    // same thing again, this time as a std::string
     610    std::string shorthand;
    612611    cin >> shorthand;
    613612    if(!cin.fail()){
     
    649648  getline(cin,line);
    650649  // dissect by " "
    651   string::iterator olditer = line.begin();
     650  std::string::iterator olditer = line.begin();
    652651  for(string::iterator iter = line.begin(); iter != line.end(); ++iter) {
    653652    if (*iter == ' ') {
Note: See TracChangeset for help on using the changeset viewer.