Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/WorldAction/ScaleBoxAction.cpp

    r623e89 r047878  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "Actions/WorldAction/ScaleBoxAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    912#include "atom.hpp"
    1013#include "log.hpp"
     
    1215#include "verbose.hpp"
    1316#include "World.hpp"
     17#include "Box.hpp"
     18#include "Matrix.hpp"
    1419
    1520#include <iostream>
     
    2025#include "UIElements/UIFactory.hpp"
    2126#include "UIElements/Dialog.hpp"
    22 #include "Actions/MapOfActions.hpp"
     27#include "UIElements/ValueStorage.hpp"
    2328
    2429const char WorldScaleBoxAction::NAME[] = "scale-box";
     
    3136{}
    3237
     38void WorldScaleBox(Vector &Scaler) {
     39  ValueStorage::getInstance().setCurrentValue(WorldScaleBoxAction::NAME, Scaler);
     40  ActionRegistry::getInstance().getActionByName(WorldScaleBoxAction::NAME)->call(Action::NonInteractive);
     41};
     42
     43Dialog* WorldScaleBoxAction::fillDialog(Dialog *dialog) {
     44  ASSERT(dialog,"No Dialog given when filling action dialog");
     45
     46  dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME));
     47
     48  return dialog;
     49}
     50
    3351Action::state_ptr WorldScaleBoxAction::performCall() {
    34   Dialog *dialog = UIFactory::getInstance().makeDialog();
    3552  Vector Scaler;
    3653  double x[NDIM];
    37   int j=0;
    3854
    39   dialog->queryVector(NAME, &Scaler, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));
     55  ValueStorage::getInstance().queryCurrentValue(NAME, Scaler);
    4056
    41   if(dialog->display()) {
    42     DoLog(1) && (Log() << Verbose(1) << "Scaling all atomic positions by factor." << endl);
    43     for (int i=0;i<NDIM;i++)
    44       x[i] = Scaler[i];
    45     vector<atom*> AllAtoms = World::getInstance().getAllAtoms();
    46     for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) {
    47       (*AtomRunner)->x.ScaleAll(x);
    48     }
    49     j = -1;
    50     double * const cell_size = World::getInstance().getDomain();
    51     for (int i=0;i<NDIM;i++) {
    52       j += i+1;
    53       cell_size[j]*=x[i];
    54     }
     57  DoLog(1) && (Log() << Verbose(1) << "Scaling all atomic positions by factor." << endl);
     58  for (int i=0;i<NDIM;i++)
     59    x[i] = Scaler[i];
     60  vector<atom*> AllAtoms = World::getInstance().getAllAtoms();
     61  for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) {
     62    (*AtomRunner)->x.ScaleAll(x);
     63  }
    5564
    56     delete dialog;
    57     return Action::success;
    58   } else {
    59     delete dialog;
    60     return Action::failure;
     65  Matrix M = World::getInstance().getDomain().getM();
     66  Matrix scale;
     67
     68  for (int i=0;i<NDIM;i++) {
     69    scale.at(i,i) = x[i];
    6170  }
     71  M *= scale;
     72  World::getInstance().setDomain(M);
     73
     74  return Action::success;
    6275}
    6376
Note: See TracChangeset for help on using the changeset viewer.