- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/WorldAction/ScaleBoxAction.cpp
r623e89 r047878 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "Actions/WorldAction/ScaleBoxAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 9 12 #include "atom.hpp" 10 13 #include "log.hpp" … … 12 15 #include "verbose.hpp" 13 16 #include "World.hpp" 17 #include "Box.hpp" 18 #include "Matrix.hpp" 14 19 15 20 #include <iostream> … … 20 25 #include "UIElements/UIFactory.hpp" 21 26 #include "UIElements/Dialog.hpp" 22 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 23 28 24 29 const char WorldScaleBoxAction::NAME[] = "scale-box"; … … 31 36 {} 32 37 38 void WorldScaleBox(Vector &Scaler) { 39 ValueStorage::getInstance().setCurrentValue(WorldScaleBoxAction::NAME, Scaler); 40 ActionRegistry::getInstance().getActionByName(WorldScaleBoxAction::NAME)->call(Action::NonInteractive); 41 }; 42 43 Dialog* 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 33 51 Action::state_ptr WorldScaleBoxAction::performCall() { 34 Dialog *dialog = UIFactory::getInstance().makeDialog();35 52 Vector Scaler; 36 53 double x[NDIM]; 37 int j=0;38 54 39 dialog->queryVector(NAME, &Scaler, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription(NAME));55 ValueStorage::getInstance().queryCurrentValue(NAME, Scaler); 40 56 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 } 55 64 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]; 61 70 } 71 M *= scale; 72 World::getInstance().setDomain(M); 73 74 return Action::success; 62 75 } 63 76
Note:
See TracChangeset
for help on using the changeset viewer.