Changeset 67c75b for src/Legacy


Ignore:
Timestamp:
Jun 2, 2010, 11:44:00 AM (16 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, Candidate_v1.7.0, Candidate_v1.7.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:
992fd7
Parents:
82b71a (diff), 190326 (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:

Merge branch 'MenuRefactoring' into QT4Refactoring

Conflicts:

molecuilder/src/Makefile.am
molecuilder/src/builder.cpp
molecuilder/src/unittests/Makefile.am
molecuilder/src/vector.cpp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Legacy/oldmenu.cpp

    r82b71a r67c75b  
    2424#include "molecule.hpp"
    2525#include "periodentafel.hpp"
     26#include "vector_ops.hpp"
     27#include "Plane.hpp"
     28#include "Line.hpp"
    2629
    2730#include "UIElements/UIFactory.hpp"
     
    5962  char choice;  // menu choice char
    6063  bool valid;
     64  bool aborted;
    6165
    6266  Log() << Verbose(0) << "===========ADD ATOM============================" << endl;
     
    7781      break;
    7882      case 'a': // absolute coordinates of atom
    79         Log() << Verbose(0) << "Enter absolute coordinates." << endl;
     83      {
     84        Dialog *dialog = UIFactory::getInstance().makeDialog();
    8085        first = World::getInstance().createAtom();
    81         first->x.AskPosition(mol->cell_size, false);
    82         first->type = periode->AskElement();  // give type
    83         mol->AddAtom(first);  // add to molecule
     86        dialog->queryVector("Please enter coordinates: ",&first->x,World::getInstance().getDomain(), false);
     87        dialog->queryElement("Please choose element: ",&first->type);
     88        if(dialog->display()){
     89          mol->AddAtom(first);  // add to molecule
     90        }
     91        else{
     92          World::getInstance().destroyAtom(first);
     93        }
     94      }
     95      break;
     96
     97      case 'b': // relative coordinates of atom wrt to reference point
     98        first = World::getInstance().createAtom();
     99        valid = true;
     100        aborted = false;
     101        do {
     102          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
     103          auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
     104          dialog->queryVector("Enter reference coordinates.",&x,World::getInstance().getDomain(), true);
     105          dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), false);
     106          if((aborted = !dialog->display())){
     107            continue;
     108          }
     109          first->x += x;
     110        } while (!aborted && !(valid = mol->CheckBounds((const Vector *)&first->x)));
     111        if(!aborted){
     112          first->type = periode->AskElement();  // give type
     113          mol->AddAtom(first);  // add to molecule
     114        }
     115        else{
     116          World::getInstance().destroyAtom(first);
     117        }
    84118        break;
    85119
    86       case 'b': // relative coordinates of atom wrt to reference point
     120      case 'c': // relative coordinates of atom wrt to already placed atom
     121      {
    87122        first = World::getInstance().createAtom();
    88123        valid = true;
    89124        do {
    90125          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
    91           Log() << Verbose(0) << "Enter reference coordinates." << endl;
    92           x.AskPosition(mol->cell_size, true);
    93           Log() << Verbose(0) << "Enter relative coordinates." << endl;
    94           first->x.AskPosition(mol->cell_size, false);
    95           first->x.AddVector((const Vector *)&x);
    96           Log() << Verbose(0) << "\n";
    97         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    98         first->type = periode->AskElement();  // give type
    99         mol->AddAtom(first);  // add to molecule
    100         break;
    101 
    102       case 'c': // relative coordinates of atom wrt to already placed atom
    103         first = World::getInstance().createAtom();
    104         valid = true;
    105         do {
    106           if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
     126          auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
    107127          second = mol->AskAtom("Enter atom number: ");
    108           Log() << Verbose(0) << "Enter relative coordinates." << endl;
    109           first->x.AskPosition(mol->cell_size, false);
     128          dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), false);
     129          dialog->display();
    110130          for (int i=NDIM;i--;) {
    111             first->x.x[i] += second->x.x[i];
     131            first->x[i] += second->x[i];
    112132          }
    113133        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    114134        first->type = periode->AskElement();  // give type
    115135        mol->AddAtom(first);  // add to molecule
    116         break;
     136      }
     137      break;
    117138
    118139    case 'd': // two atoms, two angles and a distance
     
    154175          */
    155176          // calc axis vector
    156           x.CopyVector(&second->x);
    157           x.SubtractVector(&third->x);
     177          x= second->x - third->x;
    158178          x.Normalize();
    159           Log() << Verbose(0) << "x: ",
    160           x.Output();
    161           Log() << Verbose(0) << endl;
    162           z.MakeNormalVector(&second->x,&third->x,&fourth->x);
    163           Log() << Verbose(0) << "z: ",
    164           z.Output();
    165           Log() << Verbose(0) << endl;
    166           y.MakeNormalVector(&x,&z);
    167           Log() << Verbose(0) << "y: ",
    168           y.Output();
    169           Log() << Verbose(0) << endl;
     179          Log() << Verbose(0) << "x: " << x << endl;
     180          z = Plane(second->x,third->x,fourth->x).getNormal();
     181          Log() << Verbose(0) << "z: " << z << endl;
     182          y = Plane(x,z,0).getNormal();
     183          Log() << Verbose(0) << "y: " << y << endl;
    170184
    171185          // rotate vector around first angle
    172           first->x.CopyVector(&x);
    173           first->x.RotateVector(&z,b - M_PI);
    174           Log() << Verbose(0) << "Rotated vector: ",
    175           first->x.Output();
    176           Log() << Verbose(0) << endl;
     186          first->x = x;
     187          first->x = Line(zeroVec,z).rotateVector(first->x,b - M_PI);
     188          Log() << Verbose(0) << "Rotated vector: " << first->x << endl,
    177189          // remove the projection onto the rotation plane of the second angle
    178           n.CopyVector(&y);
    179           n.Scale(first->x.ScalarProduct(&y));
    180           Log() << Verbose(0) << "N1: ",
    181           n.Output();
    182           Log() << Verbose(0) << endl;
    183           first->x.SubtractVector(&n);
    184           Log() << Verbose(0) << "Subtracted vector: ",
    185           first->x.Output();
    186           Log() << Verbose(0) << endl;
    187           n.CopyVector(&z);
    188           n.Scale(first->x.ScalarProduct(&z));
    189           Log() << Verbose(0) << "N2: ",
    190           n.Output();
    191           Log() << Verbose(0) << endl;
    192           first->x.SubtractVector(&n);
    193           Log() << Verbose(0) << "2nd subtracted vector: ",
    194           first->x.Output();
    195           Log() << Verbose(0) << endl;
     190          n = y;
     191          n.Scale(first->x.ScalarProduct(y));
     192          Log() << Verbose(0) << "N1: " << n << endl;
     193          first->x -= n;
     194          Log() << Verbose(0) << "Subtracted vector: " << first->x << endl;
     195          n = z;
     196          n.Scale(first->x.ScalarProduct(z));
     197          Log() << Verbose(0) << "N2: " << n << endl;
     198          first->x -= n;
     199          Log() << Verbose(0) << "2nd subtracted vector: " << first->x << endl;
    196200
    197201          // rotate another vector around second angle
    198           n.CopyVector(&y);
    199           n.RotateVector(&x,c - M_PI);
    200           Log() << Verbose(0) << "2nd Rotated vector: ",
    201           n.Output();
    202           Log() << Verbose(0) << endl;
     202          n = y;
     203          n = Line(zeroVec,x).rotateVector(n,c - M_PI);
     204          Log() << Verbose(0) << "2nd Rotated vector: " << n << endl;
    203205
    204206          // add the two linear independent vectors
    205           first->x.AddVector(&n);
     207          first->x += n;
    206208          first->x.Normalize();
    207209          first->x.Scale(a);
    208           first->x.AddVector(&second->x);
    209 
    210           Log() << Verbose(0) << "resulting coordinates: ";
    211           first->x.Output();
    212           Log() << Verbose(0) << endl;
     210          first->x += second->x;
     211
     212          Log() << Verbose(0) << "resulting coordinates: " << first->x << endl;
    213213        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    214214        first->type = periode->AskElement();  // give type
     
    233233        } while ((j != -1) && (i<128));
    234234        if (i >= 2) {
    235           first->x.LSQdistance((const Vector **)atoms, i);
    236 
    237           first->x.Output();
     235          LSQdistance(first->x,(const Vector **)atoms, i);
     236
     237          Log() << Verbose(0) << first->x;
    238238          first->type = periode->AskElement();  // give type
    239239          mol->AddAtom(first);  // add to molecule
     
    280280      for (int i=0;i<NDIM;i++) {
    281281        Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
    282         cin >> y.x[i];
     282        cin >> y[i];
    283283      }
    284284      mol->CenterEdge(&x);  // make every coordinate positive
    285       mol->Center.AddVector(&y); // translate by boundary
    286       helper.CopyVector(&y);
    287       helper.Scale(2.);
    288       helper.AddVector(&x);
     285      mol->Center += y; // translate by boundary
     286      helper = (2*y)+x;
    289287      mol->SetBoxDimension(&helper);  // update Box of atoms by boundary
    290288      break;
     
    293291      for (int i=0;i<NDIM;i++) {
    294292        Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
    295         cin >> x.x[i];
     293        cin >> x[i];
    296294      }
    297295      // update Box of atoms by boundary
     
    330328      third = mol->AskAtom("Enter third atom: ");
    331329
    332       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
     330      n = Plane(first->x,second->x,third->x).getNormal();
    333331      break;
    334332    case 'b': // normal vector of mirror plane
    335       Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    336       n.AskPosition(mol->cell_size,0);
     333    {
     334      Dialog *dialog = UIFactory::getInstance().makeDialog();
     335      dialog->queryVector("Enter normal vector of mirror plane.",&n,World::getInstance().getDomain(),false);
     336      dialog->display();
     337      delete dialog;
    337338      n.Normalize();
    338       break;
     339    }
     340    break;
     341
    339342    case 'c': // three atoms defining mirror plane
    340343      first = mol->AskAtom("Enter first atom: ");
    341344      second = mol->AskAtom("Enter second atom: ");
    342345
    343       n.CopyVector((const Vector *)&first->x);
    344       n.SubtractVector((const Vector *)&second->x);
     346      n = first->x - second->x;
    345347      n.Normalize();
    346348      break;
     
    356358      mol->GetAlignvector(&param);
    357359      for (int i=NDIM;i--;) {
    358         x.x[i] = gsl_vector_get(param.x,i);
    359         n.x[i] = gsl_vector_get(param.x,i+NDIM);
     360        x[i] = gsl_vector_get(param.x,i);
     361        n[i] = gsl_vector_get(param.x,i+NDIM);
    360362      }
    361363      gsl_vector_free(param.x);
    362       Log() << Verbose(0) << "Offset vector: ";
    363       x.Output();
    364       Log() << Verbose(0) << endl;
     364      Log() << Verbose(0) << "Offset vector: " << x << endl;
    365365      n.Normalize();
    366366      break;
    367367  };
    368   Log() << Verbose(0) << "Alignment vector: ";
    369   n.Output();
    370   Log() << Verbose(0) << endl;
     368  Log() << Verbose(0) << "Alignment vector: " << n << endl;
    371369  mol->Align(&n);
    372370};
     
    397395      third = mol->AskAtom("Enter third atom: ");
    398396
    399       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
     397      n = Plane(first->x,second->x,third->x).getNormal();
    400398      break;
    401399    case 'b': // normal vector of mirror plane
    402       Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    403       n.AskPosition(mol->cell_size,0);
     400    {
     401      Dialog *dialog = UIFactory::getInstance().makeDialog();
     402      dialog->queryVector("Enter normal vector of mirror plane.",&n,World::getInstance().getDomain(),false);
     403      dialog->display();
     404      delete dialog;
    404405      n.Normalize();
    405       break;
     406    }
     407    break;
     408
    406409    case 'c': // three atoms defining mirror plane
    407410      first = mol->AskAtom("Enter first atom: ");
    408411      second = mol->AskAtom("Enter second atom: ");
    409412
    410       n.CopyVector((const Vector *)&first->x);
    411       n.SubtractVector((const Vector *)&second->x);
     413      n = first->x - second->x;
    412414      n.Normalize();
    413415      break;
    414416  };
    415   Log() << Verbose(0) << "Normal vector: ";
    416   n.Output();
    417   Log() << Verbose(0) << endl;
     417  Log() << Verbose(0) << "Normal vector: " << n << endl;
    418418  mol->Mirror((const Vector *)&n);
    419419};
     
    455455        first = second;
    456456        second = first->next;
    457         if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
     457        if (first->x.DistanceSquared(second->x) > tmp1*tmp1) // distance to first above radius ...
    458458          mol->RemoveAtom(first);
    459459      }
     
    471471        first = second;
    472472        second = first->next;
    473         if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
     473        if ((first->x[axis] < tmp1) || (first->x[axis] > tmp2)) {// out of boundary ...
    474474          //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    475475          mol->RemoveAtom(first);
     
    522522        tmp1 = 0.;
    523523        if (first != second) {
    524           x.CopyVector((const Vector *)&first->x);
    525           x.SubtractVector((const Vector *)&second->x);
     524          x = first->x - second->x;
    526525          tmp1 = x.Norm();
    527526        }
     
    538537      for (int i=NDIM;i--;)
    539538        min[i] = 0.;
    540       x.CopyVector((const Vector *)&first->x);
    541       x.SubtractVector((const Vector *)&second->x);
     539      x = first->x - second->x;
    542540      tmp1 = x.Norm();
    543       Log() << Verbose(1) << "Distance vector is ";
    544       x.Output();
    545       Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl;
     541      Log() << Verbose(1) << "Distance vector is " << x << "." << "/n"
     542            << "Norm of distance is " << tmp1 << "." << endl;
    546543      break;
    547544
     
    552549      third  = mol->AskAtom("Enter last atom: ");
    553550      tmp1 = tmp2 = tmp3 = 0.;
    554       x.CopyVector((const Vector *)&first->x);
    555       x.SubtractVector((const Vector *)&second->x);
    556       y.CopyVector((const Vector *)&third->x);
    557       y.SubtractVector((const Vector *)&second->x);
     551      x = first->x - second->x;
     552      y = third->x - second->x;
    558553      Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
    559       Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
     554      Log() << Verbose(0) << (acos(x.ScalarProduct(y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
    560555      break;
    561556    case 'd':
     
    676671        minBond = 0.;
    677672        for (int i=NDIM;i--;)
    678           minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
     673          minBond += (first->x[i]-second->x[i])*(first->x[i] - second->x[i]);
    679674        minBond = sqrt(minBond);
    680675        Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
     
    682677        cin >> bond;
    683678        for (int i=NDIM;i--;) {
    684           second->x.x[i] -= (second->x.x[i]-first->x.x[i])/minBond*(minBond-bond);
     679          second->x[i] -= (second->x[i]-first->x[i])/minBond*(minBond-bond);
    685680        }
    686681        //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
     
    778773      x.Zero();
    779774      y.Zero();
    780       y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
     775      y[abs(axis)-1] = World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    781776      for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    782         x.AddVector(&y); // per factor one cell width further
     777        x += y; // per factor one cell width further
    783778        for (int k=count;k--;) { // go through every atom of the original cell
    784779          first = World::getInstance().createAtom(); // create a new body
    785           first->x.CopyVector(vectors[k]);  // use coordinate of original atom
    786           first->x.AddVector(&x);     // translate the coordinates
     780          first->x = (*vectors[k]) + x;  // use coordinate of original atom
    787781          first->type = Elements[k];  // insert original element
    788782          mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
     
    796790      // correct cell size
    797791      if (axis < 0) { // if sign was negative, we have to translate everything
    798         x.Zero();
    799         x.AddVector(&y);
     792        x = y;
    800793        x.Scale(-(faktor-1));
    801794        mol->Translate(&x);
    802795      }
    803       mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
     796      World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
    804797    }
    805798  }
     
    893886        mol = *ListRunner;
    894887        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    895         Log() << Verbose(0) << "Enter translation vector." << endl;
    896         x.AskPosition(mol->cell_size,0);
    897         mol->Center.AddVector((const Vector *)&x);
     888        Dialog *dialog = UIFactory::getInstance().makeDialog();
     889        dialog->queryVector("Enter translation vector.",&x,World::getInstance().getDomain(),false);
     890        if(dialog->display()){
     891          mol->Center += x;
     892        }
     893        delete dialog;
    898894     }
    899895     break;
Note: See TracChangeset for help on using the changeset viewer.