Changeset d61161 for src/Actions


Ignore:
Timestamp:
Nov 19, 2012, 10:27:51 AM (12 years ago)
Author:
Frederik Heber <heber@…>
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:
d5307b
Parents:
286a967 (diff), 315351 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'michi-list-query-validator' into stable

Location:
src/Actions
Files:
25 added
10 deleted
2 edited
5 moved

Legend:

Unmodified
Added
Removed
  • src/Actions/FillAction/FillSurfaceAction.cpp

    r286a967 rd61161  
    2222
    2323/*
    24  * FillSphericalSurfaceAction.cpp
     24 * FillSurfaceAction.cpp
    2525 *
    2626 *  Created on: Mar 29, 2012
     
    4848#include "molecule.hpp"
    4949#include "Shapes/BaseShapes.hpp"
     50#include "Shapes/ShapeRegistry.hpp"
    5051#include "World.hpp"
    5152
     
    5859#include <vector>
    5960
    60 #include "Actions/FillAction/FillSphericalSurfaceAction.hpp"
     61#include "Actions/FillAction/FillSurfaceAction.hpp"
    6162
    6263using namespace MoleCuilder;
    6364
    6465// and construct the stuff
    65 #include "FillSphericalSurfaceAction.def"
     66#include "FillSurfaceAction.def"
    6667#include "Action_impl_pre.hpp"
    6768/** =========== define the function ====================== */
    68 Action::state_ptr FillSphericalSurfaceAction::performCall() {
     69Action::state_ptr FillSurfaceAction::performCall() {
    6970  // get the filler molecule
    7071  const std::vector< molecule *> molecules = World::getInstance().getSelectedMolecules();
     
    99100
    100101  // create predicate, mesh, and filler
    101   FillSphericalSurfaceState *UndoState = NULL;
     102  FillSurfaceState *UndoState = NULL;
    102103  bool successflag = false;
    103104  {
     
    107108            )
    108109        );
    109     Shape s = Sphere(params.center.get(), params.radius.get());
     110
     111
     112    std::vector<Shape*> selectedShapes = ShapeRegistry::getInstance().getSelectedShapes();
     113    if (selectedShapes.size() != 1){
     114      ELOG(1, "FillSurfaceAction::performCall(): there has to be exactly 1 selected shape.");
     115      return Action::failure;
     116    }
     117
    110118    boost::function<const NodeSet ()> func =
    111         boost::bind(&Shape::getHomogeneousPointsOnSurface, boost::ref(s), params.N.get());
     119        boost::bind(&Shape::getHomogeneousPointsOnSurface, boost::ref(*selectedShapes[0]), params.N.get());
    112120    Mesh *mesh = new MeshAdaptor(func);
    113121    Inserter *inserter = new Inserter(
    114         Inserter::impl_ptr(new SurfaceInserter(s, params.AlignedAxis.get())));
     122        Inserter::impl_ptr(new SurfaceInserter(*selectedShapes[0], params.AlignedAxis.get())));
    115123
    116124    // fill
     
    150158        std::transform(filler->begin(), filler->end(), MovedToVector.begin(),
    151159            boost::bind(&AtomInfo::getPosition, _1) );
    152         UndoState = new FillSphericalSurfaceState(clonedatominfos,clonedbonds,movedatoms,MovedToVector,params);
     160        UndoState = new FillSurfaceState(clonedatominfos,clonedbonds,movedatoms,MovedToVector,params);
    153161      }
    154162    }
     
    166174}
    167175
    168 Action::state_ptr FillSphericalSurfaceAction::performUndo(Action::state_ptr _state) {
    169   FillSphericalSurfaceState *state = assert_cast<FillSphericalSurfaceState*>(_state.get());
     176Action::state_ptr FillSurfaceAction::performUndo(Action::state_ptr _state) {
     177  FillSurfaceState *state = assert_cast<FillSurfaceState*>(_state.get());
    170178
    171179  // remove all created atoms
     
    177185}
    178186
    179 Action::state_ptr FillSphericalSurfaceAction::performRedo(Action::state_ptr _state){
    180   FillSphericalSurfaceState *state = assert_cast<FillSphericalSurfaceState*>(_state.get());
     187Action::state_ptr FillSurfaceAction::performRedo(Action::state_ptr _state){
     188  FillSurfaceState *state = assert_cast<FillSurfaceState*>(_state.get());
    181189
    182190  // place filler cluster again at new spot
     
    194202}
    195203
    196 bool FillSphericalSurfaceAction::canUndo() {
     204bool FillSurfaceAction::canUndo() {
    197205  return true;
    198206}
    199207
    200 bool FillSphericalSurfaceAction::shouldUndo() {
     208bool FillSurfaceAction::shouldUndo() {
    201209  return true;
    202210}
  • src/Actions/FillAction/FillSurfaceAction.def

    r286a967 rd61161  
    11/*
    2  * FillRegularGridAction.def
     2 * FillSurfaceAction.def
    33 *
    44 *  Created on: Mar 29, 2012
     
    2020// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    2121// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    22 #define paramtypes (Vector)(double)(unsigned int)(double)(Vector)
    23 #define paramtokens ("center")("radius")("count")("min-distance")("Alignment-Axis")
    24 #define paramdescriptions ("center of the sphere")("sphere size")("number of instances to be added, changed according to geometric needs")("minimum distance between added instances")("The filler molecule is rotated relative to this alignment axis")
    25 #define paramdefaults (PARAM_DEFAULT(Vector(0.,0.,0.)))(NOPARAM_DEFAULT)(PARAM_DEFAULT(12))(PARAM_DEFAULT(1.))(NOPARAM_DEFAULT)
    26 #define paramreferences (center)(radius)(N)(mindistance)(AlignedAxis)
     22#define paramtypes (unsigned int)(double)(Vector)
     23#define paramtokens ("count")("min-distance")("Alignment-Axis")
     24#define paramdescriptions ("number of instances to be added, changed according to geometric needs")("minimum distance between added instances")("The filler molecule is rotated relative to this alignment axis")
     25#define paramdefaults (PARAM_DEFAULT(12))(PARAM_DEFAULT(1.))(NOPARAM_DEFAULT)
     26#define paramreferences (N)(mindistance)(AlignedAxis)
    2727#define paramvalids \
    28 (BoxVectorValidator()) \
    29 (BoxLengthValidator()) \
    3028(DummyValidator< unsigned int >()) \
    3129(BoxLengthValidator()) \
     
    3937#define MENUNAME "fill"
    4038#define MENUPOSITION 1
    41 #define ACTIONNAME SphericalSurface
    42 #define TOKEN "fill-spherical-surface"
     39#define ACTIONNAME Surface
     40#define TOKEN "fill-surface"
    4341
    4442
    4543// finally the information stored in the ActionTrait specialization
    4644#define DESCRIPTION "\
    47 fill homogenous points on a sphere surface with instances of the selected molecule."
     45fill homogenous points on a shape's surface with instances of the selected molecule."
    4846#undef SHORTFORM
  • src/Actions/FillAction/FillSurfaceAction.hpp

    r286a967 rd61161  
    11/*
    2  * FillSphericalSurfaceAction.hpp
     2 * FillSurfaceAction.hpp
    33 *
    44 *  Created on: Mar 29, 2012
     
    66 */
    77
    8 #ifndef FILLSPHERICALSURFACEACTION_HPP
    9 #define FILLSPHERICALSURFACEACTION_HPP
     8#ifndef FILLSURFACEACTION_HPP
     9#define FILLSURFACEACTION_HPP
    1010
    1111// include config.h
     
    1717#include "Actions/Action.hpp"
    1818
    19 #include "FillSphericalSurfaceAction.def"
     19#include "FillSurfaceAction.def"
    2020#include "Action_impl_header.hpp"
    2121
    22 #endif // FILLSPHERICALSURFACEACTION_HPP
     22#endif // FILLSURFACEACTION_HPP
  • src/Actions/GlobalListOfActions.hpp

    r286a967 rd61161  
    101101  (SelectionNotAtomById) \
    102102  (SelectionNotAtomByOrder) \
    103   (SelectionAllAtomsInsideCuboid) \
    104103  (SelectionAllAtoms) \
    105104  (SelectionClearAllAtoms) \
     
    107106  (SelectionNotAllAtoms) \
    108107  (SelectionNotAtomByElement) \
    109   (SelectionAllAtomsInsideSphere) \
     108  (SelectionAllAtomsInsideVolume) \
    110109  (SelectionAllAtomsOfMolecule) \
    111   (SelectionNotAllAtomsInsideSphere) \
     110  (SelectionNotAllAtomsInsideVolume) \
    112111  (SelectionAtomByElement) \
    113112  (SelectionNotAllAtomsOfMolecule) \
    114   (SelectionNotAllAtomsInsideCuboid) \
    115113  (SelectionAtomById) \
    116114  (SelectionAtomByOrder) \
     115  (SelectionAllShapes) \
     116  (SelectionShapeByName) \
     117  (SelectionNotAllShapes) \
     118  (SelectionNotShapeByName) \
    117119  (FragmentationFragmentation) \
    118120  (FillRegularGrid) \
    119   (FillSphericalSurface)
     121  (FillSurface) \
     122  (ShapeCombineShapes) \
     123  (ShapeCreateShape) \
     124  (ShapeRemoveShape)
    120125
    121126// we need to append the automation action in case we have the JobMarket
  • src/Actions/Makefile.am

    r286a967 rd61161  
    6060  ${SELECTIONATOMACTIONSOURCE} \
    6161  ${SELECTIONMOLECULEACTIONSOURCE} \
     62  ${SELECTIONSHAPEACTIONSOURCE} \
     63  ${SHAPEACTIONSOURCE} \
    6264  ${TESSELATIONACTIONSOURCE} \
    6365  $(UNDOACTIONSOURCE) \
     
    7678  ${SELECTIONATOMACTIONHEADER} \
    7779  ${SELECTIONMOLECULEACTIONHEADER} \
     80  ${SELECTIONSHAPEACTIONHEADER} \
     81  ${SHAPEACTIONHEADER} \
    7882  ${TESSELATIONACTIONHEADER} \
    7983  $(UNDOACTIONHEADER) \
     
    9296  ${SELECTIONATOMACTIONDEFS} \
    9397  ${SELECTIONMOLECULEACTIONDEFS} \
     98  ${SELECTIONSHAPEACTIONDEFS} \
     99  ${SHAPEACTIONDEFS} \
    94100  ${TESSELATIONACTIONDEFS} \
    95101  $(UNDOACTIONDEFS) \
     
    182188FILLACTIONSOURCE = \
    183189        Actions/FillAction/FillRegularGridAction.cpp \
    184         Actions/FillAction/FillSphericalSurfaceAction.cpp
     190        Actions/FillAction/FillSurfaceAction.cpp
    185191FILLACTIONHEADER = \
    186192        Actions/FillAction/FillRegularGridAction.hpp \
    187         Actions/FillAction/FillSphericalSurfaceAction.hpp
     193        Actions/FillAction/FillSurfaceAction.hpp
    188194FILLACTIONDEFS = \
    189195        Actions/FillAction/FillRegularGridAction.def \
    190         Actions/FillAction/FillSphericalSurfaceAction.def
     196        Actions/FillAction/FillSurfaceAction.def
    191197
    192198
     
    303309SELECTIONATOMACTIONSOURCE = \
    304310  Actions/SelectionAction/Atoms/AllAtomsAction.cpp \
    305   Actions/SelectionAction/Atoms/AllAtomsInsideCuboidAction.cpp \
    306   Actions/SelectionAction/Atoms/AllAtomsInsideSphereAction.cpp \
     311  Actions/SelectionAction/Atoms/AllAtomsInsideVolumeAction.cpp \
    307312  Actions/SelectionAction/Atoms/AllAtomsOfMoleculeAction.cpp \
    308313  Actions/SelectionAction/Atoms/AtomByElementAction.cpp \
     
    312317  Actions/SelectionAction/Atoms/InvertAtomsAction.cpp \
    313318  Actions/SelectionAction/Atoms/NotAllAtomsAction.cpp \
    314   Actions/SelectionAction/Atoms/NotAllAtomsInsideCuboidAction.cpp \
    315   Actions/SelectionAction/Atoms/NotAllAtomsInsideSphereAction.cpp \
     319  Actions/SelectionAction/Atoms/NotAllAtomsInsideVolumeAction.cpp \
    316320  Actions/SelectionAction/Atoms/NotAllAtomsOfMoleculeAction.cpp \
    317321  Actions/SelectionAction/Atoms/NotAtomByElementAction.cpp \
     
    320324SELECTIONATOMACTIONHEADER = \
    321325  Actions/SelectionAction/Atoms/AllAtomsAction.hpp \
    322   Actions/SelectionAction/Atoms/AllAtomsInsideCuboidAction.hpp \
    323   Actions/SelectionAction/Atoms/AllAtomsInsideSphereAction.hpp \
     326  Actions/SelectionAction/Atoms/AllAtomsInsideVolumeAction.hpp \
    324327  Actions/SelectionAction/Atoms/AllAtomsOfMoleculeAction.hpp \
    325328  Actions/SelectionAction/Atoms/AtomByElementAction.hpp \
     
    329332  Actions/SelectionAction/Atoms/InvertAtomsAction.hpp \
    330333  Actions/SelectionAction/Atoms/NotAllAtomsAction.hpp \
    331   Actions/SelectionAction/Atoms/NotAllAtomsInsideCuboidAction.hpp \
    332   Actions/SelectionAction/Atoms/NotAllAtomsInsideSphereAction.hpp \
     334  Actions/SelectionAction/Atoms/NotAllAtomsInsideVolumeAction.hpp \
    333335  Actions/SelectionAction/Atoms/NotAllAtomsOfMoleculeAction.hpp \
    334336  Actions/SelectionAction/Atoms/NotAtomByElementAction.hpp \
     
    337339SELECTIONATOMACTIONDEFS = \
    338340  Actions/SelectionAction/Atoms/AllAtomsAction.def \
    339   Actions/SelectionAction/Atoms/AllAtomsInsideCuboidAction.def \
    340   Actions/SelectionAction/Atoms/AllAtomsInsideSphereAction.def \
     341  Actions/SelectionAction/Atoms/AllAtomsInsideVolumeAction.def \
    341342  Actions/SelectionAction/Atoms/AllAtomsOfMoleculeAction.def \
    342343  Actions/SelectionAction/Atoms/AtomByElementAction.def \
     
    346347  Actions/SelectionAction/Atoms/InvertAtomsAction.def \
    347348  Actions/SelectionAction/Atoms/NotAllAtomsAction.def \
    348   Actions/SelectionAction/Atoms/NotAllAtomsInsideCuboidAction.def \
    349   Actions/SelectionAction/Atoms/NotAllAtomsInsideSphereAction.def \
     349  Actions/SelectionAction/Atoms/NotAllAtomsInsideVolumeAction.def \
    350350  Actions/SelectionAction/Atoms/NotAllAtomsOfMoleculeAction.def \
    351351  Actions/SelectionAction/Atoms/NotAtomByElementAction.def \
     
    398398  Actions/SelectionAction/Molecules/NotMoleculeByOrderAction.def \
    399399  Actions/SelectionAction/Molecules/NotMoleculeOfAtomAction.def
     400                 
     401SELECTIONSHAPEACTIONSOURCE = \
     402  Actions/SelectionAction/Shapes/AllShapesAction.cpp \
     403  Actions/SelectionAction/Shapes/ShapeByNameAction.cpp \
     404  Actions/SelectionAction/Shapes/NotAllShapesAction.cpp \
     405  Actions/SelectionAction/Shapes/NotShapeByNameAction.cpp
     406SELECTIONSHAPEACTIONHEADER = \
     407  Actions/SelectionAction/Shapes/AllShapesAction.hpp \
     408  Actions/SelectionAction/Shapes/ShapeByNameAction.hpp \
     409  Actions/SelectionAction/Shapes/NotAllShapesAction.hpp \
     410  Actions/SelectionAction/Shapes/NotShapeByNameAction.hpp
     411SELECTIONSHAPEACTIONDEFS = \
     412  Actions/SelectionAction/Shapes/AllShapesAction.def \
     413  Actions/SelectionAction/Shapes/ShapeByNameAction.def \
     414  Actions/SelectionAction/Shapes/NotAllShapesAction.def \
     415  Actions/SelectionAction/Shapes/NotShapeByNameAction.def
     416       
     417SHAPEACTIONSOURCE = \
     418  Actions/ShapeAction/CombineShapesAction.cpp \
     419  Actions/ShapeAction/CreateShapeAction.cpp \
     420  Actions/ShapeAction/RemoveShapeAction.cpp
     421SHAPEACTIONHEADER = \
     422  Actions/ShapeAction/CombineShapesAction.hpp \
     423  Actions/ShapeAction/CreateShapeAction.hpp \
     424  Actions/ShapeAction/RemoveShapeAction.hpp
     425SHAPEACTIONDEFS = \
     426  Actions/ShapeAction/CombineShapesAction.def \
     427  Actions/ShapeAction/CreateShapeAction.def \
     428  Actions/ShapeAction/RemoveShapeAction.def
    400429       
    401430TESSELATIONACTIONSOURCE = \
    402431  Actions/TesselationAction/ConvexEnvelopeAction.cpp \
    403   Actions/TesselationAction/NonConvexEnvelopeAction.cpp               
     432  Actions/TesselationAction/NonConvexEnvelopeAction.cpp
    404433TESSELATIONACTIONHEADER = \
    405434  Actions/TesselationAction/ConvexEnvelopeAction.hpp \
  • src/Actions/SelectionAction/Atoms/AllAtomsInsideVolumeAction.cpp

    r286a967 rd61161  
    2222
    2323/*
    24  * AllAtomsInsideSphereAction.cpp
     24 * AllAtomsInsideVolumeAction.cpp
    2525 *
    2626 *  Created on: Aug 9, 2010
    27  *      Author: heber
     27 *      Author: heber, ankele
    2828 */
    2929
     
    4141#include "CodePatterns/Verbose.hpp"
    4242#include "LinearAlgebra/Vector.hpp"
    43 #include "Shapes/BaseShapes.hpp"
    44 #include "Shapes/Shape.hpp"
    45 #include "Shapes/ShapeOps.hpp"
     43#include "Shapes/ShapeRegistry.hpp"
    4644#include "World.hpp"
    4745
     
    5048#include <string>
    5149
    52 #include "AllAtomsInsideSphereAction.hpp"
     50#include "AllAtomsInsideVolumeAction.hpp"
    5351
    5452using namespace MoleCuilder;
    5553
    5654// and construct the stuff
    57 #include "AllAtomsInsideSphereAction.def"
     55#include "AllAtomsInsideVolumeAction.def"
    5856#include "Action_impl_pre.hpp"
    5957/** =========== define the function ====================== */
    60 Action::state_ptr SelectionAllAtomsInsideSphereAction::performCall() {
    61   LOG(1, "Selecting all atoms inside a sphere at " << params.position.get() << " with radius " << params.radius.get() << ".");
    62   Shape s = translate(resize(Sphere(),params.radius.get()),params.position.get());
    63   std::vector<atom *> selectedAtoms = World::getInstance().getAllAtoms(AtomsBySelection() && AtomsByShape(s));
    64   World::getInstance().selectAllAtoms(AtomsByShape(s));
     58Action::state_ptr SelectionAllAtomsInsideVolumeAction::performCall() {
     59  LOG(1, "Selecting all atoms inside a volume.");
     60  std::vector<Shape*> selectedShapes = ShapeRegistry::getInstance().getSelectedShapes();
     61  if (selectedShapes.size() != 1){
     62    ELOG(1, "SelectionAllAtomsInsideVolumeAction::performCall(): there has to be exactly 1 selected shape.");
     63    return Action::failure;
     64  }
     65  std::vector<atom *> selectedAtoms = World::getInstance().getAllAtoms(AtomsBySelection() && AtomsByShape(*selectedShapes[0]));
     66  World::getInstance().selectAllAtoms(AtomsByShape(*selectedShapes[0]));
    6567  LOG(0, World::getInstance().countSelectedAtoms() << " atoms selected.");
    66   return Action::state_ptr(new SelectionAllAtomsInsideSphereState(selectedAtoms, s, params));
     68  return Action::state_ptr(new SelectionAllAtomsInsideVolumeState(selectedAtoms, params));
    6769}
    6870
    69 Action::state_ptr SelectionAllAtomsInsideSphereAction::performUndo(Action::state_ptr _state) {
    70   SelectionAllAtomsInsideSphereState *state = assert_cast<SelectionAllAtomsInsideSphereState*>(_state.get());
     71Action::state_ptr SelectionAllAtomsInsideVolumeAction::performUndo(Action::state_ptr _state) {
     72  SelectionAllAtomsInsideVolumeState *state = assert_cast<SelectionAllAtomsInsideVolumeState*>(_state.get());
    7173
    72   World::getInstance().unselectAllAtoms(AtomsByShape(state->s));
     74  std::vector<Shape*> selectedShapes = ShapeRegistry::getInstance().getSelectedShapes();
     75  if (selectedShapes.size() != 1)
     76    return Action::failure;
     77  World::getInstance().unselectAllAtoms(AtomsByShape(*selectedShapes[0]));
    7378  BOOST_FOREACH(atom *_atom, state->selectedAtoms)
    7479    World::getInstance().selectAtom(_atom);
     
    7782}
    7883
    79 Action::state_ptr SelectionAllAtomsInsideSphereAction::performRedo(Action::state_ptr _state){
    80   SelectionAllAtomsInsideSphereState *state = assert_cast<SelectionAllAtomsInsideSphereState*>(_state.get());
     84Action::state_ptr SelectionAllAtomsInsideVolumeAction::performRedo(Action::state_ptr _state){
     85  //SelectionAllAtomsInsideVolumeState *state = assert_cast<SelectionAllAtomsInsideVolumeState*>(_state.get());
    8186
    82   World::getInstance().selectAllAtoms(AtomsByShape(state->s));
     87  std::vector<Shape*> selectedShapes = ShapeRegistry::getInstance().getSelectedShapes();
     88  if (selectedShapes.size() != 1)
     89    return Action::failure;
     90  World::getInstance().selectAllAtoms(AtomsByShape(*selectedShapes[0]));
    8391
    8492  return Action::state_ptr(_state);
    8593}
    8694
    87 bool SelectionAllAtomsInsideSphereAction::canUndo() {
     95bool SelectionAllAtomsInsideVolumeAction::canUndo() {
    8896  return true;
    8997}
    9098
    91 bool SelectionAllAtomsInsideSphereAction::shouldUndo() {
     99bool SelectionAllAtomsInsideVolumeAction::shouldUndo() {
    92100  return true;
    93101}
  • src/Actions/SelectionAction/Atoms/NotAllAtomsInsideVolumeAction.cpp

    r286a967 rd61161  
    2222
    2323/*
    24  * NotAllAtomsInsideSphereAction.cpp
     24 * NotAllAtomsInsideVolumeAction.cpp
    2525 *
    2626 *  Created on: Aug 9, 2010
     
    4141#include "CodePatterns/Verbose.hpp"
    4242#include "LinearAlgebra/Vector.hpp"
    43 #include "Shapes/BaseShapes.hpp"
    44 #include "Shapes/Shape.hpp"
    45 #include "Shapes/ShapeOps.hpp"
     43#include "Shapes/ShapeRegistry.hpp"
    4644#include "World.hpp"
    4745
     
    5048#include <string>
    5149
    52 #include "NotAllAtomsInsideSphereAction.hpp"
     50#include "NotAllAtomsInsideVolumeAction.hpp"
    5351
    5452using namespace MoleCuilder;
    5553
    5654// and construct the stuff
    57 #include "NotAllAtomsInsideSphereAction.def"
     55#include "NotAllAtomsInsideVolumeAction.def"
    5856#include "Action_impl_pre.hpp"
    5957/** =========== define the function ====================== */
    60 Action::state_ptr SelectionNotAllAtomsInsideSphereAction::performCall() {
    61   LOG(1, "Unselecting all atoms inside a sphere at " << params.position.get() << " with radius " << params.radius.get() << ".");
    62   Shape s = translate(resize(Sphere(),params.radius.get()),params.position.get());
    63   std::vector<atom *> unselectedAtoms = World::getInstance().getAllAtoms((!AtomsBySelection()) && AtomsByShape(s));
    64   World::getInstance().unselectAllAtoms(AtomsByShape(s));
     58Action::state_ptr SelectionNotAllAtomsInsideVolumeAction::performCall() {
     59  LOG(1, "Unselecting all atoms inside a volume.");
     60  std::vector<Shape*> selectedShapes = ShapeRegistry::getInstance().getSelectedShapes();
     61  if (selectedShapes.size() != 1){
     62    ELOG(1, "SelectionNotAllAtomsInsideVolumeAction::performCall(): there has to be exactly 1 selected shape.");
     63    return Action::failure;
     64  }
     65  std::vector<atom *> unselectedAtoms = World::getInstance().getAllAtoms((!AtomsBySelection()) && AtomsByShape(*selectedShapes[0]));
     66  World::getInstance().unselectAllAtoms(AtomsByShape(*selectedShapes[0]));
    6567  LOG(0, World::getInstance().countSelectedAtoms() << " atoms remain selected.");
    66   return Action::state_ptr(new SelectionNotAllAtomsInsideSphereState(unselectedAtoms, s, params));
     68  return Action::state_ptr(new SelectionNotAllAtomsInsideVolumeState(unselectedAtoms, params));
    6769}
    6870
    69 Action::state_ptr SelectionNotAllAtomsInsideSphereAction::performUndo(Action::state_ptr _state) {
    70   SelectionNotAllAtomsInsideSphereState *state = assert_cast<SelectionNotAllAtomsInsideSphereState*>(_state.get());
     71Action::state_ptr SelectionNotAllAtomsInsideVolumeAction::performUndo(Action::state_ptr _state) {
     72  SelectionNotAllAtomsInsideVolumeState *state = assert_cast<SelectionNotAllAtomsInsideVolumeState*>(_state.get());
    7173
    72   World::getInstance().selectAllAtoms(AtomsByShape(state->s));
     74  std::vector<Shape*> selectedShapes = ShapeRegistry::getInstance().getSelectedShapes();
     75  if (selectedShapes.size() != 1)
     76    return Action::failure;
     77  World::getInstance().selectAllAtoms(AtomsByShape(*selectedShapes[0]));
    7378  BOOST_FOREACH(atom *_atom, state->unselectedAtoms)
    7479    World::getInstance().unselectAtom(_atom);
     
    7782}
    7883
    79 Action::state_ptr SelectionNotAllAtomsInsideSphereAction::performRedo(Action::state_ptr _state){
    80   SelectionNotAllAtomsInsideSphereState *state = assert_cast<SelectionNotAllAtomsInsideSphereState*>(_state.get());
     84Action::state_ptr SelectionNotAllAtomsInsideVolumeAction::performRedo(Action::state_ptr _state){
     85  //SelectionNotAllAtomsInsideVolumeState *state = assert_cast<SelectionNotAllAtomsInsideVolumeState*>(_state.get());
    8186
    82   World::getInstance().unselectAllAtoms(AtomsByShape(state->s));
     87  std::vector<Shape*> selectedShapes = ShapeRegistry::getInstance().getSelectedShapes();
     88  if (selectedShapes.size() != 1)
     89    return Action::failure;
     90  World::getInstance().unselectAllAtoms(AtomsByShape(*selectedShapes[0]));
    8391
    8492  return Action::state_ptr(_state);
    8593}
    8694
    87 bool SelectionNotAllAtomsInsideSphereAction::canUndo() {
     95bool SelectionNotAllAtomsInsideVolumeAction::canUndo() {
    8896  return true;
    8997}
    9098
    91 bool SelectionNotAllAtomsInsideSphereAction::shouldUndo() {
     99bool SelectionNotAllAtomsInsideVolumeAction::shouldUndo() {
    92100  return true;
    93101}
Note: See TracChangeset for help on using the changeset viewer.