Changeset 1ba67d for src/Actions
- Timestamp:
- Jul 22, 2010, 9:06:09 PM (15 years ago)
- 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:
- 7882e9
- Parents:
- 8da96a
- Location:
- src/Actions/WorldAction
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/WorldAction/CenterOnEdgeAction.cpp
r8da96a r1ba67d 22 22 #include "UIElements/UIFactory.hpp" 23 23 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"24 #include "UIElements/ValueStorage.hpp" 25 25 #include "Helpers/Assert.hpp" 26 26 … … 34 34 {} 35 35 36 Dialog* WorldCenterOnEdgeAction::createDialog() { 37 Dialog *dialog = UIFactory::getInstance().makeDialog(); 38 39 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 40 41 return dialog; 42 } 43 36 44 Action::state_ptr WorldCenterOnEdgeAction::performCall() { 37 Dialog *dialog = UIFactory::getInstance().makeDialog();38 45 Vector Min; 39 46 Vector Max; 40 47 41 dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME)); 48 // get maximum and minimum 49 vector<atom *> AllAtoms = World::getInstance().getAllAtoms(); 50 ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present."); 51 vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 52 Min = (*AtomRunner)->x; 53 Max = (*AtomRunner)->x; 54 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { 55 for (int i=0;i<NDIM;i++) { 56 if ((*AtomRunner)->x[i] > Max[i]) 57 Max[i] = (*AtomRunner)->x[i]; 58 if ((*AtomRunner)->x[i] < Min[i]) 59 Min[i] = (*AtomRunner)->x[i]; 60 } 61 } 62 // set new box size 63 Matrix domain; 64 for (int i=0;i<NDIM;i++) { 65 double tmp = Max[i]-Min[i]; 66 tmp = fabs(tmp)>=1. ? tmp : 1.0; 67 domain.at(i,i) = tmp; 68 } 69 World::getInstance().setDomain(domain); 70 // translate all atoms, such that Min is aty (0,0,0) 71 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) 72 (*AtomRunner)->x -= Min; 42 73 43 if(dialog->display()) { 44 // get maximum and minimum 45 vector<atom *> AllAtoms = World::getInstance().getAllAtoms(); 46 ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present."); 47 vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 48 Min = (*AtomRunner)->x; 49 Max = (*AtomRunner)->x; 50 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { 51 for (int i=0;i<NDIM;i++) { 52 if ((*AtomRunner)->x[i] > Max[i]) 53 Max[i] = (*AtomRunner)->x[i]; 54 if ((*AtomRunner)->x[i] < Min[i]) 55 Min[i] = (*AtomRunner)->x[i]; 56 } 57 } 58 // set new box size 59 Matrix domain; 60 for (int i=0;i<NDIM;i++) { 61 double tmp = Max[i]-Min[i]; 62 tmp = fabs(tmp)>=1. ? tmp : 1.0; 63 domain.at(i,i) = tmp; 64 } 65 World::getInstance().setDomain(domain); 66 // translate all atoms, such that Min is aty (0,0,0) 67 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) 68 (*AtomRunner)->x -= Min; 69 delete dialog; 70 return Action::success; 71 } else { 72 delete dialog; 73 return Action::failure; 74 } 74 return Action::success; 75 75 } 76 76 -
src/Actions/WorldAction/CenterOnEdgeAction.hpp
r8da96a r1ba67d 21 21 virtual const std::string getName(); 22 22 private: 23 virtual Dialog * createDialog(); 23 24 virtual Action::state_ptr performCall(); 24 25 virtual Action::state_ptr performUndo(Action::state_ptr);
Note:
See TracChangeset
for help on using the changeset viewer.