Ignore:
Timestamp:
Apr 7, 2010, 3:45:38 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:
72e7fa
Parents:
f9352d
Message:

Made data internal data-structure of vector class private

  • Replaced occurences of access to internals with operator
  • moved Vector-class into LinAlg-Module
  • Reworked Vector to allow clean modularization
  • Added Plane class to describe arbitrary planes in 3d space
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Legacy/oldmenu.cpp

    rf9352d r0a4f7f  
    2424#include "molecule.hpp"
    2525#include "periodentafel.hpp"
     26#include "vector_ops.hpp"
     27#include "Plane.hpp"
    2628
    2729#include "UIElements/UIFactory.hpp"
     
    7779      break;
    7880      case 'a': // absolute coordinates of atom
    79         Log() << Verbose(0) << "Enter absolute coordinates." << endl;
     81      {
    8082        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
    84         break;
     83        Dialog *dialog = UIFactory::getInstance().makeDialog();
     84        dialog->queryVector("Enter absolute coordinates.",&first->x,mol->cell_size, false);
     85        dialog->queryElement("Choose element for this atom",&first->type);
     86        if(dialog->display()){
     87          mol->AddAtom(first);  // add to molecule
     88        }
     89        else{
     90          // dialog was canceled... destroy the atom that was used
     91          World::getInstance().destroyAtom(first);
     92        }
     93        delete dialog;
     94      }
     95      break;
    8596
    8697      case 'b': // relative coordinates of atom wrt to reference point
     
    8899        valid = true;
    89100        do {
     101          Dialog *dialog = UIFactory::getInstance().makeDialog();
    90102          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)));
     103          dialog->queryVector("Enter reference coordinates.",&x,mol->cell_size,true);
     104          dialog->queryVector("Enter relative coordinates.",&first->x,mol->cell_size,false);
     105          first->x.AddVector(&x);
     106          dialog->display();
     107          delete dialog;
     108        } while (!(valid = mol->CheckBounds(&first->x)));
    98109        first->type = periode->AskElement();  // give type
    99110        mol->AddAtom(first);  // add to molecule
     
    101112
    102113      case 'c': // relative coordinates of atom wrt to already placed atom
     114      {
    103115        first = World::getInstance().createAtom();
    104116        valid = true;
     
    106118          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
    107119          second = mol->AskAtom("Enter atom number: ");
    108           Log() << Verbose(0) << "Enter relative coordinates." << endl;
    109           first->x.AskPosition(mol->cell_size, false);
     120          Dialog *dialog = UIFactory::getInstance().makeDialog();
     121          dialog->queryVector("Enter relative coordinates.",&first->x,mol->cell_size,false);
     122          dialog->display();
    110123          for (int i=NDIM;i--;) {
    111             first->x.x[i] += second->x.x[i];
     124            first->x[i] += second->x[i];
    112125          }
    113126        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    114127        first->type = periode->AskElement();  // give type
    115128        mol->AddAtom(first);  // add to molecule
    116         break;
     129      }
     130      break;
    117131
    118132    case 'd': // two atoms, two angles and a distance
     
    157171          x.SubtractVector(&third->x);
    158172          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;
     173          Log() << Verbose(0) << "x: " << x << endl;
     174          z = Plane(second->x,third->x,fourth->x).getNormal();
     175          Log() << Verbose(0) << "z: " << z << endl;
     176          y = Plane(x,z,0).getNormal();
     177          Log() << Verbose(0) << "y: " << y << endl;
    170178
    171179          // rotate vector around first angle
    172180          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;
     181          first->x = RotateVector(first->x,z,b - M_PI);
     182          Log() << Verbose(0) << "Rotated vector: " << first->x << endl,
    177183          // remove the projection onto the rotation plane of the second angle
    178184          n.CopyVector(&y);
    179185          n.Scale(first->x.ScalarProduct(&y));
    180           Log() << Verbose(0) << "N1: ",
    181           n.Output();
    182           Log() << Verbose(0) << endl;
     186          Log() << Verbose(0) << "N1: " << n << endl;
    183187          first->x.SubtractVector(&n);
    184           Log() << Verbose(0) << "Subtracted vector: ",
    185           first->x.Output();
    186           Log() << Verbose(0) << endl;
     188          Log() << Verbose(0) << "Subtracted vector: " << first->x << endl;
    187189          n.CopyVector(&z);
    188190          n.Scale(first->x.ScalarProduct(&z));
    189           Log() << Verbose(0) << "N2: ",
    190           n.Output();
    191           Log() << Verbose(0) << endl;
     191          Log() << Verbose(0) << "N2: " << n << endl;
    192192          first->x.SubtractVector(&n);
    193           Log() << Verbose(0) << "2nd subtracted vector: ",
    194           first->x.Output();
    195           Log() << Verbose(0) << endl;
     193          Log() << Verbose(0) << "2nd subtracted vector: " << first->x << endl;
    196194
    197195          // rotate another vector around second angle
    198196          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;
     197          n = RotateVector(n,x,c - M_PI);
     198          Log() << Verbose(0) << "2nd Rotated vector: " << n << endl;
    203199
    204200          // add the two linear independent vectors
     
    208204          first->x.AddVector(&second->x);
    209205
    210           Log() << Verbose(0) << "resulting coordinates: ";
    211           first->x.Output();
    212           Log() << Verbose(0) << endl;
     206          Log() << Verbose(0) << "resulting coordinates: " << first->x << endl;
    213207        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    214208        first->type = periode->AskElement();  // give type
     
    233227        } while ((j != -1) && (i<128));
    234228        if (i >= 2) {
    235           first->x.LSQdistance((const Vector **)atoms, i);
    236 
    237           first->x.Output();
     229          LSQdistance(first->x,(const Vector **)atoms, i);
     230
     231          Log() << Verbose(0) << first->x;
    238232          first->type = periode->AskElement();  // give type
    239233          mol->AddAtom(first);  // add to molecule
     
    280274      for (int i=0;i<NDIM;i++) {
    281275        Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
    282         cin >> y.x[i];
     276        cin >> y[i];
    283277      }
    284278      mol->CenterEdge(&x);  // make every coordinate positive
     
    293287      for (int i=0;i<NDIM;i++) {
    294288        Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
    295         cin >> x.x[i];
     289        cin >> x[i];
    296290      }
    297291      // update Box of atoms by boundary
     
    330324      third = mol->AskAtom("Enter third atom: ");
    331325
    332       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
     326      n = Plane(first->x,second->x,third->x).getNormal();
    333327      break;
    334328    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);
     329    {
     330      Dialog *dialog = UIFactory::getInstance().makeDialog();
     331      dialog->queryVector("Enter normal vector of mirror plane.",&n,mol->cell_size,false);
     332      dialog->display();
     333      delete dialog;
    337334      n.Normalize();
    338       break;
     335    }
     336    break;
     337
    339338    case 'c': // three atoms defining mirror plane
    340339      first = mol->AskAtom("Enter first atom: ");
     
    356355      mol->GetAlignvector(&param);
    357356      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);
     357        x[i] = gsl_vector_get(param.x,i);
     358        n[i] = gsl_vector_get(param.x,i+NDIM);
    360359      }
    361360      gsl_vector_free(param.x);
    362       Log() << Verbose(0) << "Offset vector: ";
    363       x.Output();
    364       Log() << Verbose(0) << endl;
     361      Log() << Verbose(0) << "Offset vector: " << x << endl;
    365362      n.Normalize();
    366363      break;
    367364  };
    368   Log() << Verbose(0) << "Alignment vector: ";
    369   n.Output();
    370   Log() << Verbose(0) << endl;
     365  Log() << Verbose(0) << "Alignment vector: " << n << endl;
    371366  mol->Align(&n);
    372367};
     
    397392      third = mol->AskAtom("Enter third atom: ");
    398393
    399       n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
     394      n = Plane(first->x,second->x,third->x).getNormal();
    400395      break;
    401396    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);
     397    {
     398      Dialog *dialog = UIFactory::getInstance().makeDialog();
     399      dialog->queryVector("Enter normal vector of mirror plane.",&n,mol->cell_size,false);
     400      dialog->display();
     401      delete dialog;
    404402      n.Normalize();
    405       break;
     403    }
     404    break;
     405
    406406    case 'c': // three atoms defining mirror plane
    407407      first = mol->AskAtom("Enter first atom: ");
     
    413413      break;
    414414  };
    415   Log() << Verbose(0) << "Normal vector: ";
    416   n.Output();
    417   Log() << Verbose(0) << endl;
     415  Log() << Verbose(0) << "Normal vector: " << n << endl;
    418416  mol->Mirror((const Vector *)&n);
    419417};
     
    471469        first = second;
    472470        second = first->next;
    473         if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
     471        if ((first->x[axis] < tmp1) || (first->x[axis] > tmp2)) {// out of boundary ...
    474472          //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    475473          mol->RemoveAtom(first);
     
    541539      x.SubtractVector((const Vector *)&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
     
    676673        minBond = 0.;
    677674        for (int i=NDIM;i--;)
    678           minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
     675          minBond += (first->x[i]-second->x[i])*(first->x[i] - second->x[i]);
    679676        minBond = sqrt(minBond);
    680677        Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
     
    682679        cin >> bond;
    683680        for (int i=NDIM;i--;) {
    684           second->x.x[i] -= (second->x.x[i]-first->x.x[i])/minBond*(minBond-bond);
     681          second->x[i] -= (second->x[i]-first->x[i])/minBond*(minBond-bond);
    685682        }
    686683        //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
     
    778775      x.Zero();
    779776      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
     777      y[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
    781778      for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    782779        x.AddVector(&y); // per factor one cell width further
     
    893890        mol = *ListRunner;
    894891        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);
     892        Dialog *dialog = UIFactory::getInstance().makeDialog();
     893        dialog->queryVector("Enter translation vector.",&x,mol->cell_size,false);
     894        dialog->display();
     895        delete dialog;
    897896        mol->Center.AddVector((const Vector *)&x);
    898897     }
Note: See TracChangeset for help on using the changeset viewer.