- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp
re2b47c r047878 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "Descriptors/AtomDescriptor.hpp" 9 13 #include "atom.hpp" 10 #include "Descriptors/AtomDescriptor.hpp"11 14 #include "log.hpp" 12 15 #include "molecule.hpp" … … 22 25 #include "UIElements/UIFactory.hpp" 23 26 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 25 28 26 29 const char WorldRemoveSphereOfAtomsAction::NAME[] = "remove-sphere"; … … 33 36 {} 34 37 38 void WorldRemoveSphereOfAtoms(double radius, Vector &point) { 39 ValueStorage::getInstance().setCurrentValue(WorldRemoveSphereOfAtomsAction::NAME, radius); 40 ValueStorage::getInstance().setCurrentValue("position", point); 41 ActionRegistry::getInstance().getActionByName(WorldRemoveSphereOfAtomsAction::NAME)->call(Action::NonInteractive); 42 }; 43 44 Dialog* WorldRemoveSphereOfAtomsAction::fillDialog(Dialog *dialog) { 45 ASSERT(dialog,"No Dialog given when filling action dialog"); 46 47 dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME)); 48 dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position")); 49 50 return dialog; 51 } 52 35 53 Action::state_ptr WorldRemoveSphereOfAtomsAction::performCall() { 36 Dialog *dialog = UIFactory::getInstance().makeDialog();37 54 double radius = 0.; 38 55 Vector point; 39 56 40 dialog->queryDouble(NAME, &radius, MapOfActions::getInstance().getDescription(NAME));41 dialog->queryVector("position", &point, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("position"));57 ValueStorage::getInstance().queryCurrentValue(NAME, radius); 58 ValueStorage::getInstance().queryCurrentValue("position", point); 42 59 43 if(dialog->display()) { 44 delete dialog; 45 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl); 46 vector<atom*> AllAtoms = World::getInstance().getAllAtoms(); 47 vector<molecule *> molecules = World::getInstance().getAllMolecules(); 48 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { 49 if (point.DistanceSquared((*AtomRunner)->x) > radius*radius) { // distance to first above radius ... 50 // TODO: This is not necessary anymore when atoms are completely handled by World (create/destroy and load/save) 51 for (vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end();++iter) 52 (*iter)->erase(*AtomRunner); 53 World::getInstance().destroyAtom(*AtomRunner); 54 } 60 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl); 61 vector<atom*> AllAtoms = World::getInstance().getAllAtoms(); 62 vector<molecule *> molecules = World::getInstance().getAllMolecules(); 63 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { 64 if (point.DistanceSquared((*AtomRunner)->x) > radius*radius) { // distance to first above radius ... 65 // TODO: This is not necessary anymore when atoms are completely handled by World (create/destroy and load/save) 66 for (vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end();++iter) 67 (*iter)->erase(*AtomRunner); 68 World::getInstance().destroyAtom(*AtomRunner); 55 69 } 56 return Action::success;57 } else {58 delete dialog;59 return Action::failure;60 70 } 61 71 return Action::success; 62 72 } 63 73
Note:
See TracChangeset
for help on using the changeset viewer.