Changes in / [7067bd6:677e13]
- Files:
-
- 27 added
- 3 deleted
- 142 edited
Legend:
- Unmodified
- Added
- Removed
-
configure.ac
r7067bd6 r677e13 8 8 AC_CONFIG_HEADER([config.h]) 9 9 10 AM_INIT_AUTOMAKE(dist-bzip2 )10 AM_INIT_AUTOMAKE(dist-bzip2 parallel-tests) 11 11 12 12 # Checks for programs. -
src/Actions/Action.cpp
r7067bd6 r677e13 13 13 #include "Actions/ActionRegistry.hpp" 14 14 #include "Actions/ActionHistory.hpp" 15 #include "Exceptions/MissingValueException.hpp" 16 #include "UIElements/Dialog.hpp" 15 17 #include "Helpers/MemDebug.hpp" 18 19 #include "log.hpp" 20 #include "verbose.hpp" 16 21 17 22 using namespace std; … … 40 45 } 41 46 42 void Action::call( ){47 void Action::call(enum QueryOptions flag){ 43 48 if(!isActive()){ 44 49 return; 45 50 } 46 51 // forward to private virtual 47 state_ptr state = performCall(); 52 if (flag == Interactive) { 53 Dialog* dialog = createDialog(); 54 if (dialog != NULL) { 55 dialog->display(); 56 delete(dialog); 57 } 58 } 59 state_ptr state = Action::failure; 60 // try { 61 state = performCall(); 62 // } catch(MissingValueException&) { 63 // DoeLog(0) && (eLog() << Verbose(0) << "There is a value missing for action " << getName() << endl); 64 // }; 65 48 66 if(shouldUndo() && state != failure){ 49 67 if(canUndo()){ -
src/Actions/Action.hpp
r7067bd6 r677e13 16 16 class ActionState; 17 17 class ActionSequence; 18 class Dialog; 18 19 19 20 /** … … 44 45 * hasRedo() method respectively. 45 46 * 47 * Note that an Action always has two functions createDialog() and performCall(). The former 48 * returns a Dialog filled with query...() functions for all information that we need from the 49 * user. The latter must not contain any interaction but just uses these values (which are 50 * temporarily stored by class ValueStorage) to perform the Action. 51 * 52 * Furthermore, there is a global action function that makes the action callable with already 53 * present parameters (i.e. without user interaction and for internal use within the code only). 54 * This function is basically just a macro, that puts the parameters into the ValueStorage and 55 * calls Action::call(Action::NonInteractive). 56 * 46 57 * Actions can be set to be active or inactive. If an action is set to inactive it is signaling, that 47 58 * some condition necessary for this action to be executed is not currently met. For example the … … 78 89 * Building actions is fairly easy. Simply derive from the abstract Action base class and implement 79 90 * the virtual methods. The main code that needs to be executed upon call() should be implemented in 80 * the performCall() method. You should also indicate whether the action supports undo by implementing 91 * the performCall() method. Any user interaction should be placed into the dialog returned by 92 * createDialog(). You should also indicate whether the action supports undo by implementing 81 93 * the shouldUndo() and canUndo() methods to return the appropriate flags. 94 * 95 * Also, create the global function to allow for easy calling of your function internally (i.e. 96 * without user interaction). It should have the name of the Action class without the suffix Action. 82 97 * 83 98 * The constructor of your derived class also needs to call the Base constructor, passing it the … … 122 137 * <li/> derive YourAction from Action 123 138 * <li/> pass name and flag for registry to the base constructor 124 * <li/> implement performCall(), performUndo(), performRedo() 139 * <li/> implement createDialog(), performCall(), performUndo(), performRedo() 140 * <li/> implement the global function call/macro. 125 141 * <li/> implement the functions that return the flags for the undo mechanism 126 142 * <li/> Derive YourActionState from ActionState as necessary … … 130 146 * 131 147 * <ul> 148 * <li/> createDialog(): 149 * <ul> 150 * <li/> Call makeDialog() from the UIFactory. 151 * <li/> Call any needed Dialog->Query...() for the values you need with specific keywords. 152 * <li/> if the action needs to save a state return a custom state object 153 * <li/> otherwise return Action::success 154 * </ul> 132 155 * <li/> performCall(): 133 156 * <ul> 157 * <li/> obtain parameters you need by ValueStorage::getCurrentValue, matching 158 * key words from createDialog(). 134 159 * <li/> do whatever is needed to make the action work 135 160 * <li/> if the action was abborted return Action::failure … … 256 281 public: 257 282 283 enum QueryOptions {Interactive, NonInteractive}; 284 258 285 /** 259 286 * This type is used to store pointers to ActionStates while allowing multiple ownership … … 278 305 * If the call needs to undone you have to use the History, to avoid destroying 279 306 * invariants used by the History. 280 */ 281 void call(); 307 * 308 * Note that this call can be Interactive (i.e. a dialog will ask the user for 309 * necessary information) and NonInteractive (i.e. the information will have to 310 * be present already within the ValueStorage class or else a MissingArgumentException 311 * is thrown) 312 */ 313 void call(enum QueryOptions state = Interactive); 282 314 283 315 /** … … 339 371 private: 340 372 /** 341 * This is called internally when the call is being done. Implement this method to do the actuall 373 * This creates the dialog requesting the information needed for this action from the user 374 * via means of the user interface. 375 */ 376 virtual Dialog * createDialog()=0; 377 378 /** 379 * This is called internally when the call is being done. Implement this method to do the actual 342 380 * work of the Action. Implement this in your Derived classes. Needs to return a state that can be 343 381 * used to undo the action. -
src/Actions/ActionHistory.cpp
r7067bd6 r677e13 86 86 } 87 87 88 Dialog* ActionHistory::UndoAction::createDialog(){ 89 return NULL; 90 } 91 88 92 Action::state_ptr ActionHistory::UndoAction::performCall(){ 89 93 hist->undoLast(); … … 120 124 } 121 125 126 Dialog* ActionHistory::RedoAction::createDialog(){ 127 return NULL; 128 } 129 122 130 Action::state_ptr ActionHistory::RedoAction::performCall(){ 123 131 hist->redoLast(); -
src/Actions/ActionHistory.hpp
r7067bd6 r677e13 40 40 41 41 private: 42 virtual Dialog * createDialog(); 42 43 virtual Action::state_ptr performCall(); 43 44 virtual Action::state_ptr performUndo(Action::state_ptr); … … 58 59 59 60 private: 61 virtual Dialog * createDialog(); 60 62 virtual Action::state_ptr performCall(); 61 63 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/ActionSequence.cpp
r7067bd6 r677e13 10 10 #include "Actions/ActionSequence.hpp" 11 11 #include "Actions/Action.hpp" 12 #include "UIElements/Dialog.hpp" 12 13 13 14 #include "Helpers/Assert.hpp" … … 36 37 return theAction; 37 38 } 39 } 40 41 // this method is used outside the ActionModule 42 // Each action registers itself with the history 43 void ActionSequence::callAllDialogs(){ 44 for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){ 45 // we want to have a global bookkeeping for all actions in the sequence, so 46 // we bypass the normal call 47 Dialog * dialog = (*it)->createDialog(); 48 if (dialog != NULL) { 49 dialog->display(); 50 delete(dialog); 51 } 52 } 53 } 54 55 // This method is used internally when MakroActions are constructed. 56 // In this case only the makro Action should be registered and 57 // handle the states 58 ActionSequence::stateSet ActionSequence::callAllDialogs(bool){ 59 stateSet states; 60 for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){ 61 // we want to have a global bookkeeping for all actions in the sequence, so 62 // we bypass the normal call 63 (*it)->createDialog()->display(); 64 } 65 return states; 38 66 } 39 67 -
src/Actions/ActionSequence.hpp
r7067bd6 r677e13 30 30 31 31 void callAll(); 32 void callAllDialogs(); 32 33 33 34 bool canUndo(); … … 36 37 protected: 37 38 stateSet callAll(bool); // Dummy parameter to allow overloading 39 stateSet callAllDialogs(bool); // Dummy parameter to allow overloading 38 40 stateSet undoAll(stateSet); 39 41 stateSet redoAll(stateSet); -
src/Actions/AnalysisAction/MolecularVolumeAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/AnalysisAction/MolecularVolumeAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "boundary.hpp" 12 13 #include "config.hpp" … … 24 25 #include "UIElements/UIFactory.hpp" 25 26 #include "UIElements/Dialog.hpp" 26 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 27 28 28 29 const char AnalysisMolecularVolumeAction::NAME[] = "molecular-volume"; … … 35 36 {} 36 37 38 void AnalysisMolecularVolume() { 39 ActionRegistry::getInstance().getActionByName(AnalysisMolecularVolumeAction::NAME)->call(Action::NonInteractive); 40 }; 41 42 Dialog * AnalysisMolecularVolumeAction::createDialog() { 43 Dialog *dialog = UIFactory::getInstance().makeDialog(); 44 45 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 46 47 return dialog; 48 } 49 37 50 Action::state_ptr AnalysisMolecularVolumeAction::performCall() { 38 Dialog *dialog = UIFactory::getInstance().makeDialog(); 39 molecule *mol = NULL; 51 int molID = -1; 52 // obtain information 53 ValueStorage::getInstance().queryCurrentValue(NAME, molID); 40 54 41 dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));42 43 if(dialog->display()) {55 // execute action 56 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 57 molecule *mol = iter->second; 44 58 class Tesselation *TesselStruct = NULL; 45 59 const LinkedCell *LCList = NULL; … … 57 71 delete(TesselStruct); 58 72 delete(LCList); 59 delete dialog;60 return Action::success;61 } else {62 delete dialog;63 return Action::failure;64 73 } 74 return Action::success; 65 75 } 66 76 67 77 Action::state_ptr AnalysisMolecularVolumeAction::performUndo(Action::state_ptr _state) { 68 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 69 70 return Action::failure; 71 // string newName = state->mol->getName(); 72 // state->mol->setName(state->lastName); 73 // 74 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 78 return Action::success; 75 79 } 76 80 77 81 Action::state_ptr AnalysisMolecularVolumeAction::performRedo(Action::state_ptr _state){ 78 return Action:: failure;82 return Action::success; 79 83 } 80 84 81 85 bool AnalysisMolecularVolumeAction::canUndo() { 82 return false;86 return true; 83 87 } 84 88 85 89 bool AnalysisMolecularVolumeAction::shouldUndo() { 86 return false;90 return true; 87 91 } 88 92 -
src/Actions/AnalysisAction/MolecularVolumeAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void AnalysisMolecularVolume(); 14 13 15 class AnalysisMolecularVolumeAction : public Action { 16 friend void AnalysisMolecularVolume(); 14 17 public: 15 18 AnalysisMolecularVolumeAction(); … … 21 24 virtual const std::string getName(); 22 25 private: 26 virtual Dialog * createDialog(); 23 27 virtual Action::state_ptr performCall(); 24 28 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/AnalysisAction/PairCorrelationAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/AnalysisAction/PairCorrelationAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "analysis_correlation.hpp" 12 13 #include "boundary.hpp" … … 27 28 #include "UIElements/UIFactory.hpp" 28 29 #include "UIElements/Dialog.hpp" 29 #include " Actions/MapOfActions.hpp"30 #include "UIElements/ValueStorage.hpp" 30 31 31 32 const char AnalysisPairCorrelationAction::NAME[] = "pair-correlation"; … … 38 39 {} 39 40 41 void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, string &outputname, string &binoutputname, bool periodic) { 42 ValueStorage::getInstance().setCurrentValue("elements", elements); 43 ValueStorage::getInstance().setCurrentValue("bin-start", BinStart); 44 ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth); 45 ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd); 46 ValueStorage::getInstance().setCurrentValue("output-file", outputname); 47 ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname); 48 ValueStorage::getInstance().setCurrentValue("periodic", periodic); 49 ActionRegistry::getInstance().getActionByName(AnalysisPairCorrelationAction::NAME)->call(Action::NonInteractive); 50 }; 51 52 53 Dialog* AnalysisPairCorrelationAction::createDialog() { 54 Dialog *dialog = UIFactory::getInstance().makeDialog(); 55 56 dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements")); 57 dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start")); 58 dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width")); 59 dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end")); 60 dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file")); 61 dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file")); 62 dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic")); 63 64 return dialog; 65 } 66 40 67 Action::state_ptr AnalysisPairCorrelationAction::performCall() { 41 Dialog *dialog = UIFactory::getInstance().makeDialog();42 68 int ranges[3] = {1, 1, 1}; 43 69 double BinEnd = 0.; … … 54 80 Vector Point; 55 81 BinPairMap *binmap = NULL; 56 MoleculeListClass *molecules = World::getInstance().getMolecules();57 82 58 // first dialog: Obtain which type of correlation59 dialog->queryString(NAME, &type, MapOfActions::getInstance().getDescription(NAME));60 if(dialog->display()) {61 delete dialog;62 } else {63 delete dialog;64 return Action::failure;65 }83 // obtain information 84 ValueStorage::getInstance().queryCurrentValue("elements", elements); 85 ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart); 86 ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth); 87 ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd); 88 ValueStorage::getInstance().queryCurrentValue("output-file", outputname); 89 ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname); 90 ValueStorage::getInstance().queryCurrentValue("periodic", periodic); 66 91 67 // second dialog: Obtain parameters specific to this type 68 dialog = UIFactory::getInstance().makeDialog(); 69 if (type == "P") 70 dialog->queryVector("position", &Point, false, MapOfActions::getInstance().getDescription("position")); 71 if (type == "S") 72 dialog->queryMolecule("molecule-by-id", &Boundary, MapOfActions::getInstance().getDescription("molecule-by-id")); 73 dialog->queryElement("elements", &elements, MapOfActions::getInstance().getDescription("elements")); 74 dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start")); 75 dialog->queryDouble("bin-width", &BinWidth, MapOfActions::getInstance().getDescription("bin-width")); 76 dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end")); 77 dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file")); 78 dialog->queryString("bin-output-file", &binoutputname, MapOfActions::getInstance().getDescription("bin-output-file")); 79 dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic")); 80 81 if(dialog->display()) { 82 output.open(outputname.c_str()); 83 binoutput.open(binoutputname.c_str()); 84 if (type == "E") { 85 PairCorrelationMap *correlationmap = NULL; 86 if (periodic) 87 correlationmap = PeriodicPairCorrelation(World::getInstance().getMolecules(), elements, ranges); 88 else 89 correlationmap = PairCorrelation(World::getInstance().getMolecules(), elements); 90 OutputPairCorrelation(&output, correlationmap); 91 binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd ); 92 OutputCorrelation ( &binoutput, binmap ); 93 delete(binmap); 94 delete(correlationmap); 95 } else if (type == "P") { 96 cout << "Point to correlate to is " << Point << endl; 97 CorrelationToPointMap *correlationmap = NULL; 98 if (periodic) 99 correlationmap = PeriodicCorrelationToPoint(molecules, elements, &Point, ranges); 100 else 101 correlationmap = CorrelationToPoint(molecules, elements, &Point); 102 OutputCorrelationToPoint(&output, correlationmap); 103 binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd ); 104 OutputCorrelation ( &binoutput, binmap ); 105 delete(binmap); 106 delete(correlationmap); 107 } else if (type == "S") { 108 ASSERT(Boundary != NULL, "No molecule specified for SurfaceCorrelation."); 109 const double radius = 4.; 110 double LCWidth = 20.; 111 if (BinEnd > 0) { 112 if (BinEnd > 2.*radius) 113 LCWidth = BinEnd; 114 else 115 LCWidth = 2.*radius; 116 } 117 118 // get the boundary 119 class Tesselation *TesselStruct = NULL; 120 const LinkedCell *LCList = NULL; 121 // find biggest molecule 122 int counter = molecules->ListOfMolecules.size(); 123 bool *Actives = new bool[counter]; 124 counter = 0; 125 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 126 Actives[counter++] = (*BigFinder)->ActiveFlag; 127 (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true; 128 } 129 LCList = new LinkedCell(Boundary, LCWidth); 130 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL); 131 CorrelationToSurfaceMap *surfacemap = NULL; 132 if (periodic) 133 surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges); 134 else 135 surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList); 136 delete LCList; 137 OutputCorrelationToSurface(&output, surfacemap); 138 // re-set ActiveFlag 139 counter = 0; 140 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) { 141 (*BigFinder)->ActiveFlag = Actives[counter++]; 142 } 143 delete[] Actives; 144 // check whether radius was appropriate 145 { 146 double start; double end; 147 GetMinMax( surfacemap, start, end); 148 if (LCWidth < end) 149 DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl); 150 } 151 binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd ); 152 OutputCorrelation ( &binoutput, binmap ); 153 delete TesselStruct; // surfacemap contains refs to triangles! delete here, not earlier! 154 delete(binmap); 155 delete(surfacemap); 156 } else { 157 return Action::failure; 158 } 159 output.close(); 160 binoutput.close(); 161 delete dialog; 162 return Action::success; 163 } else { 164 delete dialog; 165 return Action::failure; 166 } 92 // execute action 93 output.open(outputname.c_str()); 94 binoutput.open(binoutputname.c_str()); 95 PairCorrelationMap *correlationmap = NULL; 96 std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules(); 97 if (periodic) 98 correlationmap = PeriodicPairCorrelation(molecules, elements, ranges); 99 else 100 correlationmap = PairCorrelation(molecules, elements); 101 OutputPairCorrelation(&output, correlationmap); 102 binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd ); 103 OutputCorrelation ( &binoutput, binmap ); 104 delete(binmap); 105 delete(correlationmap); 106 output.close(); 107 binoutput.close(); 108 return Action::success; 167 109 } 168 110 169 111 Action::state_ptr AnalysisPairCorrelationAction::performUndo(Action::state_ptr _state) { 170 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 171 172 return Action::failure; 173 // string newName = state->mol->getName(); 174 // state->mol->setName(state->lastName); 175 // 176 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 112 return Action::success; 177 113 } 178 114 179 115 Action::state_ptr AnalysisPairCorrelationAction::performRedo(Action::state_ptr _state){ 180 return Action:: failure;116 return Action::success; 181 117 } 182 118 183 119 bool AnalysisPairCorrelationAction::canUndo() { 184 return false;120 return true; 185 121 } 186 122 187 123 bool AnalysisPairCorrelationAction::shouldUndo() { 188 return false;124 return true; 189 125 } 190 126 -
src/Actions/AnalysisAction/PairCorrelationAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 class element; 14 15 void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic); 16 13 17 class AnalysisPairCorrelationAction : public Action { 18 friend void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic); 14 19 public: 15 20 AnalysisPairCorrelationAction(); … … 20 25 21 26 virtual const std::string getName(); 27 22 28 private: 29 virtual Dialog * createDialog(); 23 30 virtual Action::state_ptr performCall(); 24 31 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "molecule.hpp" 12 13 #include "log.hpp" … … 20 21 #include "UIElements/UIFactory.hpp" 21 22 #include "UIElements/Dialog.hpp" 22 #include " Actions/MapOfActions.hpp"23 #include "UIElements/ValueStorage.hpp" 23 24 24 25 const char AnalysisPrincipalAxisSystemAction::NAME[] = "principal-axis-system"; … … 31 32 {} 32 33 34 void AnalysisPrincipalAxisSystem() { 35 ActionRegistry::getInstance().getActionByName(AnalysisPrincipalAxisSystemAction::NAME)->call(Action::NonInteractive); 36 }; 37 38 Dialog* AnalysisPrincipalAxisSystemAction::createDialog() { 39 Dialog *dialog = UIFactory::getInstance().makeDialog(); 40 41 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 42 43 return dialog; 44 } 45 33 46 Action::state_ptr AnalysisPrincipalAxisSystemAction::performCall() { 34 Dialog *dialog = UIFactory::getInstance().makeDialog();35 47 molecule *mol = NULL; 36 48 37 dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME));38 39 if(dialog->display()) {40 DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);49 ValueStorage::getInstance().queryCurrentValue(NAME, mol); 50 DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl); 51 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 52 molecule *mol = iter->second; 41 53 mol->PrincipalAxisSystem(false); 42 delete dialog;43 return Action::success;44 } else {45 delete dialog;46 return Action::failure;47 54 } 55 return Action::success; 48 56 } 49 57 50 58 Action::state_ptr AnalysisPrincipalAxisSystemAction::performUndo(Action::state_ptr _state) { 51 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 52 53 return Action::failure; 54 // string newName = state->mol->getName(); 55 // state->mol->setName(state->lastName); 56 // 57 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 59 return Action::success; 58 60 } 59 61 60 62 Action::state_ptr AnalysisPrincipalAxisSystemAction::performRedo(Action::state_ptr _state){ 61 return Action:: failure;63 return Action::success; 62 64 } 63 65 64 66 bool AnalysisPrincipalAxisSystemAction::canUndo() { 65 return false;67 return true; 66 68 } 67 69 68 70 bool AnalysisPrincipalAxisSystemAction::shouldUndo() { 69 return false;71 return true; 70 72 } 71 73 -
src/Actions/AnalysisAction/PrincipalAxisSystemAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void AnalysisPrincipalAxisSystem(); 14 13 15 class AnalysisPrincipalAxisSystemAction : public Action { 16 friend void AnalysisPrincipalAxisSystem(); 17 14 18 public: 15 19 AnalysisPrincipalAxisSystemAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/AtomAction/AddAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/AtomAction/AddAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "element.hpp" … … 24 25 #include "UIElements/UIFactory.hpp" 25 26 #include "UIElements/Dialog.hpp" 26 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 27 28 28 29 const char AtomAddAction::NAME[] = "add-atom"; … … 35 36 {} 36 37 38 void AtomAdd(element *elemental, Vector &position) { 39 ValueStorage::getInstance().setCurrentValue(AtomAddAction::NAME, elemental); 40 ValueStorage::getInstance().setCurrentValue("position", elemental); 41 ActionRegistry::getInstance().getActionByName(AtomAddAction::NAME)->call(Action::NonInteractive); 42 }; 43 44 Dialog * AtomAddAction::createDialog() { 45 Dialog *dialog = UIFactory::getInstance().makeDialog(); 46 47 dialog->queryElement(NAME, ValueStorage::getInstance().getDescription(NAME)); 48 dialog->queryVector("position", true, ValueStorage::getInstance().getDescription("position")); 49 50 return dialog; 51 } 52 37 53 Action::state_ptr AtomAddAction::performCall() { 38 Dialog *dialog = UIFactory::getInstance().makeDialog(); 39 std::vector<element *> elements; 54 element * elemental = NULL; 40 55 Vector position; 41 56 42 dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME));43 dialog->queryVector("position", &position, true, MapOfActions::getInstance().getDescription("position"));44 cout << "pre-dialog" << endl;57 // obtain information 58 ValueStorage::getInstance().queryCurrentValue(NAME, elemental); 59 ValueStorage::getInstance().queryCurrentValue("position", position); 45 60 46 if(dialog->display()) { 47 cout << "post-dialog" << endl; 48 delete dialog; 49 if (elements.size() == 1) { 50 atom * first = World::getInstance().createAtom(); 51 first->type = *(elements.begin()); 52 first->x = position; 53 DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->type->name << " at " << (first->x) << "." << endl); 54 // TODO: remove when all of World's atoms are stored. 55 std::vector<molecule *> molecules = World::getInstance().getAllMolecules(); 56 if (!molecules.empty()) { 57 std::vector<molecule *>::iterator iter = molecules.begin(); 58 (*iter)->AddAtom(first); 59 } 60 return Action::success; 61 } else { 62 DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl); 63 return Action::failure; 64 } 65 } else { 66 delete dialog; 67 return Action::failure; 61 // execute action 62 atom * first = World::getInstance().createAtom(); 63 first->type = elemental; 64 first->x = position; 65 DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->type->name << " at " << (first->x) << "." << endl); 66 // TODO: remove when all of World's atoms are stored. 67 std::vector<molecule *> molecules = World::getInstance().getAllMolecules(); 68 if (!molecules.empty()) { 69 std::vector<molecule *>::iterator iter = molecules.begin(); 70 (*iter)->AddAtom(first); 68 71 } 69 72 return Action::success; 70 73 } 71 74 -
src/Actions/AtomAction/AddAction.hpp
r7067bd6 r677e13 10 10 11 11 #include "Actions/Action.hpp" 12 #include "vector.hpp" 13 14 class element; 15 16 void AtomAdd(element *elemental, Vector &position); 12 17 13 18 class AtomAddAction : public Action { 19 friend void AtomAdd(element *elemental, Vector &position); 20 14 21 public: 15 22 AtomAddAction(); … … 21 28 virtual const std::string getName(); 22 29 private: 30 virtual Dialog * createDialog(); 23 31 virtual Action::state_ptr performCall(); 24 32 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/AtomAction/ChangeElementAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/AtomAction/ChangeElementAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 13 #include "element.hpp" 12 14 #include "log.hpp" 13 15 #include "vector.hpp" … … 22 24 #include "UIElements/UIFactory.hpp" 23 25 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"26 #include "UIElements/ValueStorage.hpp" 25 27 26 28 const char AtomChangeElementAction::NAME[] = "change-element"; … … 33 35 {} 34 36 37 void AtomChangeElement(element *elemental) { 38 ValueStorage::getInstance().setCurrentValue(AtomChangeElementAction::NAME, elemental); 39 ActionRegistry::getInstance().getActionByName(AtomChangeElementAction::NAME)->call(Action::NonInteractive); 40 }; 41 42 Dialog* AtomChangeElementAction::createDialog() { 43 Dialog *dialog = UIFactory::getInstance().makeDialog(); 44 45 dialog->queryElement(NAME, ValueStorage::getInstance().getDescription(NAME)); 46 47 return dialog; 48 } 49 35 50 Action::state_ptr AtomChangeElementAction::performCall() { 36 Dialog *dialog = UIFactory::getInstance().makeDialog();37 51 atom *first = NULL; 38 std::vector<element *> elements;52 element *elemental = NULL; 39 53 40 dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME)); 41 dialog->queryAtom("atom-by-id", &first, MapOfActions::getInstance().getDescription("atom-by-id")); 54 ValueStorage::getInstance().queryCurrentValue(NAME, elemental); 42 55 43 if(dialog->display()) { 44 delete dialog; 45 ASSERT(elements.size() == 1, "Unequal to one element specified when changing an atom's element"); 46 ASSERT(first != NULL, "No valid atom specified"); 47 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << elements.at(0) << "." << endl); 48 if (elements.at(0) != NULL) { 49 first->type = elements.at(0); 50 return Action::success; 51 } else 52 return Action::failure; 53 } else { 54 delete dialog; 55 return Action::failure; 56 for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) { 57 first = iter->second; 58 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << *first << " to element " << elemental->symbol << "." << endl); 59 first->type = elemental; 56 60 } 57 61 return Action::success; 58 62 } 59 63 -
src/Actions/AtomAction/ChangeElementAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 class element; 14 15 void AtomChangeElement(element *elemental); 16 13 17 class AtomChangeElementAction : public Action { 18 friend void AtomChangeElement(element *elemental); 19 14 20 public: 15 21 AtomChangeElementAction(); … … 21 27 virtual const std::string getName(); 22 28 private: 29 virtual Dialog * createDialog(); 23 30 virtual Action::state_ptr performCall(); 24 31 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/AtomAction/RemoveAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/AtomAction/RemoveAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "Descriptors/AtomDescriptor.hpp" … … 23 24 #include "UIElements/UIFactory.hpp" 24 25 #include "UIElements/Dialog.hpp" 25 #include " Actions/MapOfActions.hpp"26 #include "UIElements/ValueStorage.hpp" 26 27 27 28 const char AtomRemoveAction::NAME[] = "remove-atom"; … … 34 35 {} 35 36 37 void AtomRemove() { 38 ActionRegistry::getInstance().getActionByName(AtomRemoveAction::NAME)->call(Action::NonInteractive); 39 }; 40 41 Dialog* AtomRemoveAction::createDialog() { 42 Dialog *dialog = UIFactory::getInstance().makeDialog(); 43 44 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 45 46 return dialog; 47 } 48 36 49 Action::state_ptr AtomRemoveAction::performCall() { 37 Dialog *dialog = UIFactory::getInstance().makeDialog();38 50 atom *first = NULL; 39 51 40 dialog->queryAtom(NAME, &first, MapOfActions::getInstance().getDescription(NAME)); 41 42 if(dialog->display()) { 43 delete dialog; 52 std::vector<molecule *> molecules = World::getInstance().getAllMolecules(); 53 for (World::AtomSelectionIterator iter = World::getInstance().beginAtomSelection(); iter != World::getInstance().endAtomSelection(); ++iter) { 54 first = iter->second; 44 55 DoLog(1) && (Log() << Verbose(1) << "Removing atom " << first->getId() << "." << endl); 45 56 // TODO: this is not necessary when atoms and their storing to file are handled by the World 46 57 // simply try to erase in every molecule found 47 std::vector<molecule *> molecules = World::getInstance().getAllMolecules();48 58 for (std::vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end(); ++iter) { 49 59 (*iter)->erase(first); 50 60 } 51 61 World::getInstance().destroyAtom(first); 52 return Action::success;53 } else {54 delete dialog;55 return Action::failure;56 62 } 57 63 return Action::success; 58 64 } 59 65 -
src/Actions/AtomAction/RemoveAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void AtomRemove(); 14 13 15 class AtomRemoveAction : public Action { 16 friend void AtomRemove(); 17 14 18 public: 15 19 AtomRemoveAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/Calculation.hpp
r7067bd6 r677e13 64 64 virtual T* doCalc()=0; 65 65 private: 66 virtual Dialog* createDialog(); 66 67 virtual Action::state_ptr performCall(); 67 68 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/Calculation_impl.hpp
r7067bd6 r677e13 27 27 28 28 // methods inherited from Action 29 30 template<typename T> 31 Dialog* Calculation<T>::createDialog(){ 32 return NULL; 33 } 29 34 30 35 template<typename T> -
src/Actions/CmdAction/BondLengthTableAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/CmdAction/BondLengthTableAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "bondgraph.hpp" 12 13 #include "config.hpp" … … 22 23 #include "UIElements/UIFactory.hpp" 23 24 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 25 26 26 27 const char CommandLineBondLengthTableAction::NAME[] = "bond-table"; … … 33 34 {} 34 35 36 void CommandBondLengthTable(std::string &BondGraphFileName) { 37 ValueStorage::getInstance().setCurrentValue(CommandLineBondLengthTableAction::NAME, BondGraphFileName); 38 ActionRegistry::getInstance().getActionByName(CommandLineBondLengthTableAction::NAME)->call(Action::NonInteractive); 39 }; 40 41 Dialog* CommandLineBondLengthTableAction::createDialog() { 42 Dialog *dialog = UIFactory::getInstance().makeDialog(); 43 44 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 45 46 return dialog; 47 } 48 35 49 Action::state_ptr CommandLineBondLengthTableAction::performCall() { 36 50 ostringstream usage; 37 51 string BondGraphFileName; 38 Dialog *dialog = UIFactory::getInstance().makeDialog();39 52 53 ValueStorage::getInstance().queryCurrentValue(NAME, BondGraphFileName); 54 DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl); 40 55 config *configuration = World::getInstance().getConfig(); 41 dialog->queryString(NAME, &BondGraphFileName, MapOfActions::getInstance().getDescription(NAME));42 43 if(dialog->display()) {44 DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);45 delete dialog;46 } else {47 delete dialog;48 return Action::failure;49 }50 51 56 if (configuration->BG == NULL) { 52 57 configuration->BG = new BondGraph(configuration->GetIsAngstroem()); -
src/Actions/CmdAction/BondLengthTableAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandBondLengthTable(std::string &BondGraphFileName); 14 13 15 class CommandLineBondLengthTableAction : public Action { 16 friend void CommandBondLengthTable(std::string &BondGraphFileName); 17 14 18 public: 15 19 CommandLineBondLengthTableAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/CmdAction/ElementDbAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/CmdAction/ElementDbAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "config.hpp" 12 13 #include "log.hpp" … … 22 23 #include "UIElements/UIFactory.hpp" 23 24 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 25 26 26 27 const char CommandLineElementDbAction::NAME[] = "element-db"; … … 33 34 {} 34 35 36 void CommandElementDb(std::string &databasepath) { 37 ValueStorage::getInstance().setCurrentValue(CommandLineElementDbAction::NAME, databasepath); 38 ActionRegistry::getInstance().getActionByName(CommandLineElementDbAction::NAME)->call(Action::NonInteractive); 39 }; 40 41 Dialog* CommandLineElementDbAction::createDialog() { 42 Dialog *dialog = UIFactory::getInstance().makeDialog(); 43 44 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 45 46 return dialog; 47 } 48 35 49 Action::state_ptr CommandLineElementDbAction::performCall() { 36 50 ostringstream usage; 37 51 string databasepath; 38 Dialog *dialog = UIFactory::getInstance().makeDialog();39 52 40 53 // get the path 41 54 // TODO: Make databasepath a std::string 42 55 config *configuration = World::getInstance().getConfig(); 43 dialog->queryString(NAME, &databasepath, MapOfActions::getInstance().getDescription(NAME)); 44 45 if(dialog->display()) { 46 strcpy(configuration->databasepath, databasepath.c_str()); 47 delete dialog; 48 } else { 49 delete dialog; 50 return Action::failure; 51 } 56 ValueStorage::getInstance().queryCurrentValue(NAME, databasepath); 57 strcpy(configuration->databasepath, databasepath.c_str()); 52 58 53 59 // load table -
src/Actions/CmdAction/ElementDbAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandElementDb(std::string &databasepath); 14 13 15 class CommandLineElementDbAction : public Action { 16 friend void CommandElementDb(std::string &databasepath); 17 14 18 public: 15 19 CommandLineElementDbAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/CmdAction/FastParsingAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/CmdAction/FastParsingAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "config.hpp" 12 13 #include "log.hpp" … … 21 22 #include "UIElements/UIFactory.hpp" 22 23 #include "UIElements/Dialog.hpp" 23 #include "Actions/MapOfActions.hpp" 24 #include "UIElements/ValueStorage.hpp" 25 26 // memento to remember the state when undoing 27 28 class CommandLineFastParsingState : public ActionState { 29 public: 30 CommandLineFastParsingState(bool _bool) : 31 boolean(_bool) 32 {} 33 bool boolean; 34 }; 35 24 36 25 37 const char CommandLineFastParsingAction::NAME[] = "fastparsing"; … … 32 44 {} 33 45 34 Action::state_ptr CommandLineFastParsingAction::performCall() { 46 void CommandFastParsing(bool fastparsing) { 47 ValueStorage::getInstance().setCurrentValue(CommandLineFastParsingAction::NAME, fastparsing); 48 ActionRegistry::getInstance().getActionByName(CommandLineFastParsingAction::NAME)->call(Action::NonInteractive); 49 }; 50 51 Dialog* CommandLineFastParsingAction::createDialog() { 35 52 Dialog *dialog = UIFactory::getInstance().makeDialog(); 36 53 54 dialog->queryBoolean(NAME, MapOfActions::getInstance().getDescription(NAME)); 55 56 return dialog; 57 } 58 59 Action::state_ptr CommandLineFastParsingAction::performCall() { 60 37 61 config *configuration = World::getInstance().getConfig(); 38 dialog->queryBoolean(NAME, &configuration->FastParsing, MapOfActions::getInstance().getDescription(NAME)); 39 40 if(dialog->display()) { 41 if (configuration->FastParsing) 42 DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl); 43 else 44 DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl); 45 delete dialog; 46 return Action::success; 47 } else { 48 delete dialog; 49 return Action::failure; 50 } 62 ValueStorage::getInstance().queryCurrentValue(NAME, configuration->FastParsing); 63 if (configuration->FastParsing) 64 DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl); 65 else 66 DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl); 67 return Action::success; 51 68 } 52 69 53 70 Action::state_ptr CommandLineFastParsingAction::performUndo(Action::state_ptr _state) { 54 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());71 CommandLineFastParsingState *state = assert_cast<CommandLineFastParsingState*>(_state.get()); 55 72 56 return Action::failure; 57 // string newName = state->mol->getName(); 58 // state->mol->setName(state->lastName); 59 // 60 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 73 config *configuration = World::getInstance().getConfig(); 74 configuration->FastParsing = state->boolean; 75 76 return Action::state_ptr(new CommandLineFastParsingState(!state->boolean)); 61 77 } 62 78 63 79 Action::state_ptr CommandLineFastParsingAction::performRedo(Action::state_ptr _state){ 64 return Action::failure;80 performUndo(_state); 65 81 } 66 82 67 83 bool CommandLineFastParsingAction::canUndo() { 68 return false;84 return true; 69 85 } 70 86 71 87 bool CommandLineFastParsingAction::shouldUndo() { 72 return false;88 return true; 73 89 } 74 90 -
src/Actions/CmdAction/FastParsingAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandFastParsing(bool fastparsing); 14 13 15 class CommandLineFastParsingAction : public Action { 16 friend void CommandFastParsing(bool fastparsing); 17 14 18 public: 15 19 CommandLineFastParsingAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/CmdAction/HelpAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/CmdAction/HelpAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "CommandLineParser.hpp" 12 13 … … 29 30 {} 30 31 31 Action::state_ptr CommandLineHelpAction::performCall() { 32 ostringstream usage; 32 void CommandHelp() { 33 ActionRegistry::getInstance().getActionByName(CommandLineHelpAction::NAME)->call(Action::NonInteractive); 34 }; 35 36 Dialog* CommandLineHelpAction::createDialog() { 33 37 Dialog *dialog = UIFactory::getInstance().makeDialog(); 34 38 39 ostringstream usage; 35 40 usage << CommandLineParser::getInstance().visible << endl; 36 41 dialog->queryEmpty(NAME, usage.str()); 37 42 38 if(dialog->display()) { 39 delete dialog; 40 return Action::success; 41 } else { 42 delete dialog; 43 return Action::failure; 44 } 43 return dialog; 44 } 45 46 Action::state_ptr CommandLineHelpAction::performCall() { 47 return Action::success; 45 48 } 46 49 47 50 Action::state_ptr CommandLineHelpAction::performUndo(Action::state_ptr _state) { 48 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 49 50 return Action::failure; 51 // string newName = state->mol->getName(); 52 // state->mol->setName(state->lastName); 53 // 54 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 51 return Action::success; 55 52 } 56 53 57 54 Action::state_ptr CommandLineHelpAction::performRedo(Action::state_ptr _state){ 58 return Action:: failure;55 return Action::success; 59 56 } 60 57 61 58 bool CommandLineHelpAction::canUndo() { 62 return false;59 return true; 63 60 } 64 61 65 62 bool CommandLineHelpAction::shouldUndo() { 66 return false;63 return true; 67 64 } 68 65 -
src/Actions/CmdAction/HelpAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandHelp(); 14 13 15 class CommandLineHelpAction : public Action { 16 friend void CommandHelp(); 17 14 18 public: 15 19 CommandLineHelpAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/CmdAction/VerboseAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/CmdAction/VerboseAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "log.hpp" 12 13 #include "verbose.hpp" … … 19 20 #include "UIElements/UIFactory.hpp" 20 21 #include "UIElements/Dialog.hpp" 21 #include "Actions/MapOfActions.hpp" 22 #include "UIElements/ValueStorage.hpp" 23 24 // memento to remember the state when undoing 25 26 class CommandLineVerboseState : public ActionState { 27 public: 28 CommandLineVerboseState(int _verbosity) : 29 verbosity(_verbosity) 30 {} 31 int verbosity; 32 }; 33 22 34 23 35 const char CommandLineVerboseAction::NAME[] = "verbose"; … … 30 42 {} 31 43 44 void CommandVerbose(int verbosity) { 45 ValueStorage::getInstance().setCurrentValue(CommandLineVerboseAction::NAME, verbosity); 46 ActionRegistry::getInstance().getActionByName(CommandLineVerboseAction::NAME)->call(Action::NonInteractive); 47 }; 48 49 Dialog* CommandLineVerboseAction::createDialog() { 50 Dialog *dialog = UIFactory::getInstance().makeDialog(); 51 52 dialog->queryInt(NAME, ValueStorage::getInstance().getDescription(NAME)); 53 54 return dialog; 55 } 56 32 57 Action::state_ptr CommandLineVerboseAction::performCall() { 33 Dialog *dialog = UIFactory::getInstance().makeDialog();34 58 int verbosity = 2; 35 59 36 dialog->queryInt(NAME, &verbosity, MapOfActions::getInstance().getDescription(NAME));60 ValueStorage::getInstance().queryCurrentValue(NAME, verbosity); 37 61 38 if(dialog->display()) { 39 setVerbosity(verbosity); 40 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl); 41 delete dialog; 42 return Action::success; 43 } else { 44 delete dialog; 45 return Action::failure; 46 } 62 setVerbosity(verbosity); 63 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl); 64 return Action::success; 47 65 } 48 66 49 67 Action::state_ptr CommandLineVerboseAction::performUndo(Action::state_ptr _state) { 50 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());68 CommandLineVerboseState *state = assert_cast<CommandLineVerboseState*>(_state.get()); 51 69 52 return Action::failure;53 // string newName = state->mol->getName();54 // state->mol->setName(state->lastName); 55 // 56 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));70 int verbosity = 2; 71 ValueStorage::getInstance().queryCurrentValue(NAME, verbosity); 72 73 setVerbosity(state->verbosity); 74 return Action::state_ptr(new CommandLineVerboseState(verbosity)); 57 75 } 58 76 59 77 Action::state_ptr CommandLineVerboseAction::performRedo(Action::state_ptr _state){ 60 return Action::failure;78 performUndo(_state); 61 79 } 62 80 63 81 bool CommandLineVerboseAction::canUndo() { 64 return false;82 return true; 65 83 } 66 84 67 85 bool CommandLineVerboseAction::shouldUndo() { 68 return false;86 return true; 69 87 } 70 88 -
src/Actions/CmdAction/VerboseAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandVerbose(int verbosity); 14 13 15 class CommandLineVerboseAction : public Action { 16 friend void CommandVerbose(int verbosity); 17 14 18 public: 15 19 CommandLineVerboseAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/CmdAction/VersionAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/CmdAction/VersionAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 12 13 #include <iostream> … … 17 18 #include "UIElements/UIFactory.hpp" 18 19 #include "UIElements/Dialog.hpp" 19 #include " Actions/MapOfActions.hpp"20 #include "UIElements/ValueStorage.hpp" 20 21 21 22 const char CommandLineVersionAction::NAME[] = "version"; … … 28 29 {} 29 30 30 Action::state_ptr CommandLineVersionAction::performCall() { 31 void CommandVersion() { 32 ActionRegistry::getInstance().getActionByName(CommandLineVersionAction::NAME)->call(Action::NonInteractive); 33 }; 34 35 Dialog* CommandLineVersionAction::createDialog() { 31 36 Dialog *dialog = UIFactory::getInstance().makeDialog(); 32 37 33 38 dialog->queryEmpty(NAME, ESPACKVersion); 34 39 35 if(dialog->display()) { 36 delete dialog; 37 return Action::success; 38 } else { 39 delete dialog; 40 return Action::failure; 41 } 40 return dialog; 41 } 42 43 Action::state_ptr CommandLineVersionAction::performCall() { 44 return Action::success; 42 45 } 43 46 44 47 Action::state_ptr CommandLineVersionAction::performUndo(Action::state_ptr _state) { 45 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 46 47 return Action::failure; 48 // string newName = state->mol->getName(); 49 // state->mol->setName(state->lastName); 50 // 51 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 48 return Action::success; 52 49 } 53 50 54 51 Action::state_ptr CommandLineVersionAction::performRedo(Action::state_ptr _state){ 55 return Action:: failure;52 return Action::success; 56 53 } 57 54 58 55 bool CommandLineVersionAction::canUndo() { 59 return false;56 return true; 60 57 } 61 58 62 59 bool CommandLineVersionAction::shouldUndo() { 63 return false;60 return true; 64 61 } 65 62 -
src/Actions/CmdAction/VersionAction.hpp
r7067bd6 r677e13 12 12 #include "version.h" 13 13 14 void CommandVersion(); 15 14 16 class CommandLineVersionAction : public Action { 17 friend void CommandVersion(); 18 15 19 public: 16 20 CommandLineVersionAction(); … … 22 26 virtual const std::string getName(); 23 27 private: 28 virtual Dialog * createDialog(); 24 29 virtual Action::state_ptr performCall(); 25 30 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/ErrorAction.cpp
r7067bd6 r677e13 27 27 } 28 28 29 Dialog* ErrorAction::createDialog() { 30 return NULL; 31 } 32 29 33 Action::state_ptr ErrorAction::performCall() { 30 34 Log() << Verbose(0) << errorMsg << endl; -
src/Actions/ErrorAction.hpp
r7067bd6 r677e13 22 22 23 23 private: 24 24 virtual Dialog * createDialog(); 25 25 virtual Action::state_ptr performCall(); 26 26 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/FragmentationAction/DepthFirstSearchAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "bondgraph.hpp" … … 27 28 #include "UIElements/UIFactory.hpp" 28 29 #include "UIElements/Dialog.hpp" 29 #include " Actions/MapOfActions.hpp"30 #include "UIElements/ValueStorage.hpp" 30 31 31 32 const char FragmentationDepthFirstSearchAction::NAME[] = "depth-first-search"; … … 38 39 {} 39 40 41 void FragmentationDepthFirstSearch(double distance) { 42 ValueStorage::getInstance().setCurrentValue(FragmentationDepthFirstSearchAction::NAME, distance); 43 ActionRegistry::getInstance().getActionByName(FragmentationDepthFirstSearchAction::NAME)->call(Action::NonInteractive); 44 }; 45 46 Dialog* FragmentationDepthFirstSearchAction::createDialog() { 47 Dialog *dialog = UIFactory::getInstance().makeDialog(); 48 49 dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME)); 50 51 return dialog; 52 } 53 40 54 Action::state_ptr FragmentationDepthFirstSearchAction::performCall() { 41 Dialog *dialog = UIFactory::getInstance().makeDialog();42 55 double distance; 43 56 44 dialog->queryDouble(NAME, &distance, MapOfActions::getInstance().getDescription(NAME));57 ValueStorage::getInstance().queryCurrentValue(NAME, distance); 45 58 46 if(dialog->display()) { 47 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl); 48 molecule * const mol = World::getInstance().getMolecule(MoleculeById(0)); 49 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 50 int *MinimumRingSize = new int[mol->getAtomCount()]; 51 atom **ListOfAtoms = NULL; 52 class StackClass<bond *> *BackEdgeStack = NULL; 53 class StackClass<bond *> *LocalBackEdgeStack = NULL; 54 mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 55 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack); 56 if (Subgraphs != NULL) { 57 int FragmentCounter = 0; 58 while (Subgraphs->next != NULL) { 59 Subgraphs = Subgraphs->next; 60 ListOfAtoms = NULL; 61 Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false); // we want to keep the created ListOfLocalAtoms 62 LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount); 63 Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack); 64 Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize); 65 delete(LocalBackEdgeStack); 66 delete(Subgraphs->previous); 67 delete[](ListOfAtoms); // and here we remove it 68 FragmentCounter++; 69 } 70 delete(Subgraphs); 59 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl); 60 molecule * const mol = World::getInstance().getMolecule(MoleculeById(0)); 61 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis 62 int *MinimumRingSize = new int[mol->getAtomCount()]; 63 atom **ListOfAtoms = NULL; 64 class StackClass<bond *> *BackEdgeStack = NULL; 65 class StackClass<bond *> *LocalBackEdgeStack = NULL; 66 mol->CreateAdjacencyList(distance, World::getInstance().getConfig()->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 67 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack); 68 if (Subgraphs != NULL) { 69 int FragmentCounter = 0; 70 while (Subgraphs->next != NULL) { 71 Subgraphs = Subgraphs->next; 72 ListOfAtoms = NULL; 73 Subgraphs->FillBondStructureFromReference(mol, ListOfAtoms, false); // we want to keep the created ListOfLocalAtoms 74 LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount); 75 Subgraphs->Leaf->PickLocalBackEdges(ListOfAtoms, BackEdgeStack, LocalBackEdgeStack); 76 Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize); 77 delete(LocalBackEdgeStack); 78 delete(Subgraphs->previous); 79 delete[](ListOfAtoms); // and here we remove it 80 FragmentCounter++; 71 81 } 72 delete(BackEdgeStack); 73 delete[](MinimumRingSize); 74 delete dialog; 75 return Action::success; 76 } else { 77 delete dialog; 78 return Action::failure; 82 delete(Subgraphs); 79 83 } 84 delete(BackEdgeStack); 85 delete[](MinimumRingSize); 86 return Action::success; 80 87 } 81 88 82 89 Action::state_ptr FragmentationDepthFirstSearchAction::performUndo(Action::state_ptr _state) { 83 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 84 85 return Action::failure; 86 // string newName = state->mol->getName(); 87 // state->mol->setName(state->lastName); 88 // 89 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 90 return Action::success; 90 91 } 91 92 92 93 Action::state_ptr FragmentationDepthFirstSearchAction::performRedo(Action::state_ptr _state){ 93 return Action:: failure;94 return Action::success; 94 95 } 95 96 96 97 bool FragmentationDepthFirstSearchAction::canUndo() { 97 return false;98 return true; 98 99 } 99 100 100 101 bool FragmentationDepthFirstSearchAction::shouldUndo() { 101 return false;102 return true; 102 103 } 103 104 -
src/Actions/FragmentationAction/DepthFirstSearchAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void FragmentationDepthFirstSearch(double distance); 14 13 15 class FragmentationDepthFirstSearchAction : public Action { 16 friend void FragmentationDepthFirstSearch(double distance); 17 14 18 public: 15 19 FragmentationDepthFirstSearchAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/FragmentationAction/FragmentationAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/FragmentationAction/FragmentationAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "bondgraph.hpp" … … 25 26 #include "UIElements/UIFactory.hpp" 26 27 #include "UIElements/Dialog.hpp" 27 #include " Actions/MapOfActions.hpp"28 #include "UIElements/ValueStorage.hpp" 28 29 29 30 const char FragmentationFragmentationAction::NAME[] = "fragment-mol"; … … 36 37 {} 37 38 39 void FragmentationFragmentation(std::string &path, double distance, int order) { 40 ValueStorage::getInstance().setCurrentValue(FragmentationFragmentationAction::NAME, path); 41 ValueStorage::getInstance().setCurrentValue("distance", distance); 42 ValueStorage::getInstance().setCurrentValue("order", order); 43 ActionRegistry::getInstance().getActionByName(FragmentationFragmentationAction::NAME)->call(Action::NonInteractive); 44 }; 45 46 Dialog* FragmentationFragmentationAction::createDialog() { 47 Dialog *dialog = UIFactory::getInstance().makeDialog(); 48 49 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 50 dialog->queryDouble("distance", ValueStorage::getInstance().getDescription("distance")); 51 dialog->queryInt("order", ValueStorage::getInstance().getDescription("order")); 52 53 return dialog; 54 } 55 38 56 Action::state_ptr FragmentationFragmentationAction::performCall() { 39 Dialog *dialog = UIFactory::getInstance().makeDialog();40 57 clock_t start,end; 41 58 molecule *mol = NULL; … … 46 63 int ExitFlag = 0; 47 64 48 cout << "pre-dialog"<< endl; 49 dialog->queryString(NAME, &path, MapOfActions::getInstance().getDescription(NAME)); 50 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 51 dialog->queryDouble("distance", &distance, MapOfActions::getInstance().getDescription("distance")); 52 dialog->queryInt("order", &order, MapOfActions::getInstance().getDescription("order")); 65 ValueStorage::getInstance().queryCurrentValue(NAME, path); 66 ValueStorage::getInstance().queryCurrentValue("distance", distance); 67 ValueStorage::getInstance().queryCurrentValue("order", order); 53 68 54 if(dialog->display()) {55 cout << "POST-dialog"<< endl;69 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 70 mol = iter->second; 56 71 ASSERT(mol != NULL, "No molecule has been picked for fragmentation."); 57 72 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << distance << " angstroem, order of " << order << "." << endl); … … 66 81 end = clock(); 67 82 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl); 68 delete dialog;69 return Action::success;70 } else {71 delete dialog;72 return Action::failure;73 83 } 84 return Action::success; 74 85 } 75 86 76 87 Action::state_ptr FragmentationFragmentationAction::performUndo(Action::state_ptr _state) { 77 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 78 79 return Action::failure; 80 // string newName = state->mol->getName(); 81 // state->mol->setName(state->lastName); 82 // 83 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 88 return Action::success; 84 89 } 85 90 86 91 Action::state_ptr FragmentationFragmentationAction::performRedo(Action::state_ptr _state){ 87 return Action:: failure;92 return Action::success; 88 93 } 89 94 90 95 bool FragmentationFragmentationAction::canUndo() { 91 return false;96 return true; 92 97 } 93 98 94 99 bool FragmentationFragmentationAction::shouldUndo() { 95 return false;100 return true; 96 101 } 97 102 -
src/Actions/FragmentationAction/FragmentationAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void FragmentationFragmentation(std::string &path, double distance, int order); 14 13 15 class FragmentationFragmentationAction : public Action { 16 friend void FragmentationFragmentation(std::string &path, double distance, int order); 17 14 18 public: 15 19 FragmentationFragmentationAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/FragmentationAction/SubgraphDissectionAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "config.hpp" … … 24 25 #include "UIElements/UIFactory.hpp" 25 26 #include "UIElements/Dialog.hpp" 26 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 27 28 28 29 const char FragmentationSubgraphDissectionAction::NAME[] = "subgraph-dissect"; … … 35 36 {} 36 37 37 Action::state_ptr FragmentationSubgraphDissectionAction::performCall() { 38 void FragmentationSubgraphDissection() { 39 ActionRegistry::getInstance().getActionByName(FragmentationSubgraphDissectionAction::NAME)->call(Action::NonInteractive); 40 }; 41 42 Dialog* FragmentationSubgraphDissectionAction::createDialog() { 38 43 Dialog *dialog = UIFactory::getInstance().makeDialog(); 39 44 40 45 dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME)); 41 46 42 if(dialog->display()) { 43 DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl); 44 // @TODO rather do the dissection afterwards 45 MoleculeListClass *molecules = World::getInstance().getMolecules(); 46 molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig()); 47 delete dialog; 48 return Action::success; 49 } else { 50 delete dialog; 51 return Action::failure; 52 } 47 return dialog; 48 } 49 50 51 Action::state_ptr FragmentationSubgraphDissectionAction::performCall() { 52 DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl); 53 // @TODO rather do the dissection afterwards 54 MoleculeListClass *molecules = World::getInstance().getMolecules(); 55 molecules->DissectMoleculeIntoConnectedSubgraphs(World::getInstance().getPeriode(), World::getInstance().getConfig()); 56 return Action::success; 53 57 } 54 58 -
src/Actions/FragmentationAction/SubgraphDissectionAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void FragmentationSubgraphDissection(); 14 13 15 class FragmentationSubgraphDissectionAction : public Action { 16 friend void FragmentationSubgraphDissection(); 17 14 18 public: 15 19 FragmentationSubgraphDissectionAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/Makefile.am
r7067bd6 r677e13 17 17 ${MOLECULEACTIONSOURCE} \ 18 18 ${PARSERACTIONSOURCE} \ 19 ${SELECTIONACTIONSOURCE} \ 19 20 ${TESSELATIONACTIONSOURCE} \ 20 21 ${WORLDACTIONSOURCE} \ … … 28 29 ${MOLECULEACTIONHEADER} \ 29 30 ${PARSERACTIONHEADER} \ 31 ${SELECTIONACTIONHEADER} \ 30 32 ${TESSELATIONACTIONHEADER} \ 31 33 ${WORLDACTIONHEADER} \ … … 36 38 AnalysisAction/MolecularVolumeAction.cpp \ 37 39 AnalysisAction/PairCorrelationAction.cpp \ 38 AnalysisAction/PrincipalAxisSystemAction.cpp 40 AnalysisAction/PointCorrelationAction.cpp \ 41 AnalysisAction/PrincipalAxisSystemAction.cpp \ 42 AnalysisAction/SurfaceCorrelationAction.cpp 39 43 ANALYSISACTIONHEADER = \ 40 44 AnalysisAction/MolecularVolumeAction.hpp \ 41 45 AnalysisAction/PairCorrelationAction.hpp \ 42 AnalysisAction/PrincipalAxisSystemAction.hpp 46 AnalysisAction/PointCorrelationAction.hpp \ 47 AnalysisAction/PrincipalAxisSystemAction.hpp \ 48 AnalysisAction/SurfaceCorrelationAction.hpp 43 49 44 50 ATOMACTIONSOURCE = \ … … 107 113 ParserAction/SaveXyzAction.hpp 108 114 115 SELECTIONACTIONSOURCE = \ 116 SelectionAction/AllAtomsAction.cpp \ 117 SelectionAction/AllMoleculesAction.cpp \ 118 SelectionAction/AtomByIdAction.cpp \ 119 SelectionAction/MoleculeByIdAction.cpp \ 120 SelectionAction/NotAllAtomsAction.cpp \ 121 SelectionAction/NotAllMoleculesAction.cpp \ 122 SelectionAction/NotAtomByIdAction.cpp \ 123 SelectionAction/NotMoleculeByIdAction.cpp 124 SELECTIONACTIONHEADER = \ 125 SelectionAction/AllAtomsAction.hpp \ 126 SelectionAction/AllMoleculesAction.hpp \ 127 SelectionAction/AtomByIdAction.hpp \ 128 SelectionAction/MoleculeByIdAction.hpp \ 129 SelectionAction/NotAllAtomsAction.hpp \ 130 SelectionAction/NotAllMoleculesAction.hpp \ 131 SelectionAction/NotAtomByIdAction.hpp \ 132 SelectionAction/NotMoleculeByIdAction.hpp 133 109 134 TESSELATIONACTIONSOURCE = \ 110 135 TesselationAction/ConvexEnvelopeAction.cpp \ -
src/Actions/MakroAction.cpp
r7067bd6 r677e13 44 44 } 45 45 46 Dialog* MakroAction::createDialog() { 47 actions->callAllDialogs(); 48 } 46 49 47 50 Action::state_ptr MakroAction::performCall(){ -
src/Actions/MakroAction.hpp
r7067bd6 r677e13 30 30 31 31 private: 32 virtual Dialog * createDialog(); 32 33 virtual Action::state_ptr performCall(); 33 34 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/ManipulateAtomsProcess.cpp
r7067bd6 r677e13 26 26 ManipulateAtomsProcess::~ManipulateAtomsProcess() 27 27 {} 28 29 Dialog* ManipulateAtomsProcess::createDialog(){ 30 return NULL; 31 } 28 32 29 33 Action::state_ptr ManipulateAtomsProcess::performCall(){ -
src/Actions/ManipulateAtomsProcess.hpp
r7067bd6 r677e13 29 29 private: 30 30 31 virtual Dialog* createDialog(); 31 32 virtual Action::state_ptr performCall(); 32 33 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/MapOfActions.cpp
r7067bd6 r677e13 10 10 using namespace std; 11 11 12 #include "Actions/MapOfActions.hpp" 13 #include "Descriptors/AtomIdDescriptor.hpp" 14 #include "Descriptors/MoleculeIdDescriptor.hpp" 15 #include "Helpers/Assert.hpp" 12 16 #include "Patterns/Singleton_impl.hpp" 13 #include "Actions/MapOfActions.hpp"14 #include "Helpers/Assert.hpp"15 17 16 18 #include <boost/lexical_cast.hpp> … … 20 22 #include <iostream> 21 23 24 #include "atom.hpp" 25 #include "Box.hpp" 22 26 #include "CommandLineParser.hpp" 27 #include "element.hpp" 23 28 #include "log.hpp" 29 #include "Matrix.hpp" 30 #include "molecule.hpp" 31 #include "periodentafel.hpp" 32 #include "vector.hpp" 24 33 #include "verbose.hpp" 25 34 … … 27 36 #include "Actions/AnalysisAction/MolecularVolumeAction.hpp" 28 37 #include "Actions/AnalysisAction/PairCorrelationAction.hpp" 38 #include "Actions/AnalysisAction/PointCorrelationAction.hpp" 29 39 #include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp" 40 #include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp" 30 41 #include "Actions/AtomAction/AddAction.hpp" 31 42 #include "Actions/AtomAction/ChangeElementAction.hpp" … … 53 64 #include "Actions/ParserAction/LoadXyzAction.hpp" 54 65 #include "Actions/ParserAction/SaveXyzAction.hpp" 66 #include "Actions/SelectionAction/AllAtomsAction.hpp" 67 #include "Actions/SelectionAction/AllMoleculesAction.hpp" 68 #include "Actions/SelectionAction/AtomByIdAction.hpp" 69 #include "Actions/SelectionAction/MoleculeByIdAction.hpp" 70 #include "Actions/SelectionAction/NotAllAtomsAction.hpp" 71 #include "Actions/SelectionAction/NotAllMoleculesAction.hpp" 72 #include "Actions/SelectionAction/NotAtomByIdAction.hpp" 73 #include "Actions/SelectionAction/NotMoleculeByIdAction.hpp" 55 74 #include "Actions/TesselationAction/ConvexEnvelopeAction.hpp" 56 75 #include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp" … … 133 152 } 134 153 BV.xx = boost::lexical_cast<double>(components.at(0)); 135 BV. xy= boost::lexical_cast<double>(components.at(1));136 BV. xz= boost::lexical_cast<double>(components.at(2));137 BV. yy= boost::lexical_cast<double>(components.at(3));138 BV. yz= boost::lexical_cast<double>(components.at(4));154 BV.yx = boost::lexical_cast<double>(components.at(1)); 155 BV.yy = boost::lexical_cast<double>(components.at(2)); 156 BV.zx = boost::lexical_cast<double>(components.at(3)); 157 BV.zy = boost::lexical_cast<double>(components.at(4)); 139 158 BV.zz = boost::lexical_cast<double>(components.at(5)); 140 159 v = boost::any(BoxValue(BV)); … … 177 196 DescriptionMap["output"] = "write output files"; 178 197 DescriptionMap["set-output"] = "specify output formats"; 179 DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements , element and point or element and surface";198 DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements"; 180 199 DescriptionMap["parse-xyz"] = "parse xyz file into World"; 200 DescriptionMap["point-correlation"] = "pair correlation analysis between element and point"; 181 201 DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule"; 182 202 DescriptionMap["remove-atom"] = "remove a specified atom"; … … 189 209 DescriptionMap["SaveXyz"] = "save world as xyz file"; 190 210 DescriptionMap["scale-box"] = "scale box and atomic positions inside"; 211 DescriptionMap["select-all-atoms"] = "select all atoms"; 212 DescriptionMap["select-all-molecules"] = "select all molecules"; 213 DescriptionMap["select-atom-by-id"] = "select an atom by index"; 214 DescriptionMap["select-molecule-by-id"] = "select a molecule by index"; 191 215 DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC"; 192 216 DescriptionMap["set-output"] = "specify output formats"; 193 217 DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs"; 218 DescriptionMap["surface-correlation"] = "pair correlation analysis between element and surface"; 194 219 DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified"; 195 220 DescriptionMap["translate-mol"] = "translate molecule by given vector"; 221 DescriptionMap["unselect-all-atoms"] = "unselect all atoms"; 222 DescriptionMap["unselect-all-molecules"] = "unselect all molecules"; 223 DescriptionMap["unselect-atom-by-id"] = "unselect an atom by index"; 224 DescriptionMap["unselect-molecule-by-id"] = "unselect a molecule by index"; 196 225 DescriptionMap["verbose"] = "set verbosity level"; 197 226 DescriptionMap["verlet-integrate"] = "perform verlet integration of a given force file"; 198 227 DescriptionMap["version"] = "show version"; 199 228 // keys for values 200 DescriptionMap["atom-by-id"] = "index of an atom";201 229 DescriptionMap["bin-output-file"] = "name of the bin output file"; 202 230 DescriptionMap["bin-end"] = "start of the last bin"; … … 216 244 DescriptionMap["MaxDistance"] = "maximum distance in space"; 217 245 DescriptionMap["molecule-by-id"] = "index of a molecule"; 218 DescriptionMap["molecule-by-name"] = "name of a molecule";219 246 DescriptionMap["nonconvex-file"] = "filename of the non-convex envelope"; 220 247 DescriptionMap["order"] = "order of a discretization, dissection, ..."; … … 222 249 DescriptionMap["periodic"] = "system is constraint to periodic boundary conditions (y/n)"; 223 250 DescriptionMap["position"] = "position in R^3 space"; 224 DescriptionMap["sphere-radius"] = "radius of tesselation sphere";225 251 DescriptionMap["start-step"] = "first or start step"; 226 252 … … 246 272 ShortFormMap["nonconvex-envelope"] = "N"; 247 273 // ShortFormMap["output"] = "o"; 248 ShortFormMap["pair-correlation"] = "C";274 // ShortFormMap["pair-correlation"] = "C"; 249 275 ShortFormMap["parse-xyz"] = "p"; 250 276 ShortFormMap["remove-atom"] = "r"; … … 266 292 267 293 // value types for the actions 268 TypeMap["add-atom"] = Element; 269 TypeMap["bond-file"] = String; 270 TypeMap["bond-table"] = String; 271 TypeMap["boundary"] = Vector; 272 TypeMap["center-in-box"] = Box; 273 TypeMap["change-box"] = Box; 274 TypeMap["change-element"] = Element; 275 TypeMap["change-molname"] = String; 276 TypeMap["convex-envelope"] = Molecule; 277 TypeMap["default-molname"] = String; 278 TypeMap["depth-first-search"] = Double; 279 TypeMap["element-db"] = String; 280 TypeMap["fastparsing"] = Boolean; 281 TypeMap["fill-molecule"] = String; 282 TypeMap["fragment-mol"] = String; 283 TypeMap["input"] = String; 284 TypeMap["linear-interpolate"] = String; 285 TypeMap["molecular-volume"] = Molecule; 286 TypeMap["nonconvex-envelope"] = Molecule; 287 TypeMap["output"] = None; 288 TypeMap["parse-xyz"] = String; 289 TypeMap["pair-correlation"] = String; 290 TypeMap["principal-axis-system"] = Molecule; 291 TypeMap["remove-atom"] = Atom; 292 TypeMap["remove-sphere"] = Double; 293 TypeMap["repeat-box"] = Vector; 294 TypeMap["rotate-to-pas"] = Molecule; 295 TypeMap["save-adjacency"] = String; 296 TypeMap["save-bonds"] = String; 297 TypeMap["save-temperature"] = String; 298 TypeMap["scale-box"] = Vector; 299 TypeMap["set-basis"] = String; 300 TypeMap["set-output"] = ListOfString; 301 TypeMap["subgraph-dissect"] = None; 302 TypeMap["suspend-in-water"] = Double; 303 TypeMap["translate-mol"] = Vector; 304 TypeMap["verlet-integrate"] = String; 305 TypeMap["verbose"] = Integer; 294 TypeMap["add-atom"] = &typeid(element); 295 TypeMap["bond-file"] = &typeid(std::string); 296 TypeMap["bond-table"] = &typeid(std::string); 297 TypeMap["boundary"] = &typeid(VectorValue); 298 TypeMap["center-in-box"] = &typeid(BoxValue); 299 TypeMap["change-box"] = &typeid(BoxValue); 300 TypeMap["change-element"] = &typeid(element); 301 TypeMap["change-molname"] = &typeid(std::string); 302 TypeMap["convex-envelope"] = &typeid(void); 303 TypeMap["default-molname"] = &typeid(std::string); 304 TypeMap["depth-first-search"] = &typeid(double); 305 TypeMap["element-db"] = &typeid(std::string); 306 TypeMap["fastparsing"] = &typeid(bool); 307 TypeMap["fill-molecule"] = &typeid(std::string); 308 TypeMap["fragment-mol"] = &typeid(std::string); 309 TypeMap["input"] = &typeid(std::string); 310 TypeMap["linear-interpolate"] = &typeid(std::string); 311 TypeMap["molecular-volume"] = &typeid(molecule); 312 TypeMap["nonconvex-envelope"] = &typeid(double); 313 TypeMap["output"] = &typeid(void); 314 TypeMap["parse-xyz"] = &typeid(std::string); 315 TypeMap["pair-correlation"] = &typeid(void); 316 TypeMap["point-correlation"] = &typeid(void); 317 TypeMap["principal-axis-system"] = &typeid(void); 318 TypeMap["remove-atom"] = &typeid(void); 319 TypeMap["remove-sphere"] = &typeid(double); 320 TypeMap["repeat-box"] = &typeid(VectorValue); 321 TypeMap["rotate-to-pas"] = &typeid(molecule); 322 TypeMap["save-adjacency"] = &typeid(std::string); 323 TypeMap["save-bonds"] = &typeid(std::string); 324 TypeMap["save-temperature"] = &typeid(std::string); 325 TypeMap["scale-box"] = &typeid(VectorValue); 326 TypeMap["set-basis"] = &typeid(std::string); 327 TypeMap["set-output"] = &typeid(std::vector<std::string>); 328 TypeMap["subgraph-dissect"] = &typeid(void); 329 TypeMap["surface-correlation"] = &typeid(void); 330 TypeMap["suspend-in-water"] = &typeid(double); 331 TypeMap["translate-mol"] = &typeid(VectorValue); 332 TypeMap["verlet-integrate"] = &typeid(std::string); 333 TypeMap["verbose"] = &typeid(int); 306 334 307 335 // value types for the values 308 TypeMap["atom-by-id"] = Atom; 309 TypeMap["bin-output-file"] = String; 310 TypeMap["bin-end"] = Double; 311 TypeMap["bin-start"] = Double; 312 TypeMap["bin-width"] = Double; 313 TypeMap["convex-file"] = String; 314 TypeMap["distance"] = Double; 315 TypeMap["distances"] = Vector; 316 TypeMap["DoRotate"] = Boolean; 317 TypeMap["element"] = Element; 318 TypeMap["elements"] = ListOfElements; 319 TypeMap["end-step"] = Integer; 320 TypeMap["id-mapping"] = Boolean; 321 TypeMap["length"] = Double; 322 TypeMap["lengths"] = Vector; 323 TypeMap["MaxDistance"] = Double; 324 TypeMap["molecule-by-id"] = Molecule; 325 TypeMap["molecule-by-name"] = String; 326 TypeMap["nonconvex-file"] = String; 327 TypeMap["order"] = Integer; 328 TypeMap["output-file"] = String; 329 TypeMap["periodic"] = Boolean; 330 TypeMap["position"] = Vector; 331 TypeMap["sphere-radius"] = Double; 332 TypeMap["start-step"] = Integer; 336 TypeMap["bin-output-file"] = &typeid(std::string); 337 TypeMap["bin-end"] = &typeid(double); 338 TypeMap["bin-start"] = &typeid(double); 339 TypeMap["bin-width"] = &typeid(double); 340 TypeMap["convex-file"] = &typeid(std::string); 341 TypeMap["distance"] = &typeid(double); 342 TypeMap["distances"] = &typeid(VectorValue); 343 TypeMap["DoRotate"] = &typeid(bool); 344 TypeMap["element"] = &typeid(element); 345 TypeMap["elements"] = &typeid(std::vector<element *>); 346 TypeMap["end-step"] = &typeid(int); 347 TypeMap["id-mapping"] = &typeid(bool); 348 TypeMap["length"] = &typeid(double); 349 TypeMap["lengths"] = &typeid(VectorValue); 350 TypeMap["MaxDistance"] = &typeid(double); 351 TypeMap["molecule-by-id"] = &typeid(molecule); 352 TypeMap["nonconvex-file"] = &typeid(std::string); 353 TypeMap["order"] = &typeid(int); 354 TypeMap["output-file"] = &typeid(std::string); 355 TypeMap["periodic"] = &typeid(bool); 356 TypeMap["position"] = &typeid(VectorValue); 357 TypeMap["select-all-atoms"] = &typeid(void); 358 TypeMap["select-all-molecules"] = &typeid(void); 359 TypeMap["select-atom-by-id"] = &typeid(atom); 360 TypeMap["select-molecule-by-id"] = &typeid(molecule); 361 TypeMap["start-step"] = &typeid(int); 362 TypeMap["unselect-all-atoms"] = &typeid(void); 363 TypeMap["unselect-all-molecules"] = &typeid(void); 364 TypeMap["unselect-atom-by-id"] = &typeid(atom); 365 TypeMap["unselect-molecule-by-id"] = &typeid(molecule); 366 367 TypeEnumMap[&typeid(void)] = None; 368 TypeEnumMap[&typeid(bool)] = Boolean; 369 TypeEnumMap[&typeid(int)] = Integer; 370 TypeEnumMap[&typeid(std::vector<int>)] = ListOfIntegers; 371 TypeEnumMap[&typeid(double)] = Double; 372 TypeEnumMap[&typeid(std::vector<double>)] = ListOfDoubles; 373 TypeEnumMap[&typeid(std::string)] = String; 374 TypeEnumMap[&typeid(std::vector<std::string>)] = ListOfStrings; 375 TypeEnumMap[&typeid(VectorValue)] = Vector; 376 TypeEnumMap[&typeid(std::vector<VectorValue>)] = ListOfVectors; 377 TypeEnumMap[&typeid(BoxValue)] = Box; 378 TypeEnumMap[&typeid(molecule)] = Molecule; 379 TypeEnumMap[&typeid(std::vector<molecule *>)] = ListOfMolecules; 380 TypeEnumMap[&typeid(atom)] = Atom; 381 TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms; 382 TypeEnumMap[&typeid(element)] = Element; 383 TypeEnumMap[&typeid(std::vector<element *>)] = ListOfElements; 333 384 334 385 // default values for any action that needs one (always string!) 335 DefaultValue["bin-width"] = "0.5"; 336 DefaultValue["fastparsing"] = "0"; 337 DefaultValue["atom-by-id"] = "-1"; 338 DefaultValue["molecule-by-id"] = "-1"; 339 DefaultValue["periodic"] = "0"; 386 CurrentValue["bin-width"] = "0.5"; 387 CurrentValue["fastparsing"] = "0"; 388 CurrentValue["periodic"] = "0"; 340 389 341 390 // put action into each menu category 342 391 MenuDescription["analysis"] = pair<std::string,std::string>("Analysis (pair correlation, volume)", "Analysis"); 343 MenuDescription["atom"] = pair<std::string,std::string>("Edit atoms", " Edit atoms");344 MenuDescription["command"] = pair<std::string,std::string>("Configuration", " Configuration");392 MenuDescription["atom"] = pair<std::string,std::string>("Edit atoms", "Atoms"); 393 MenuDescription["command"] = pair<std::string,std::string>("Configuration", "configuration options"); 345 394 MenuDescription["fragmentation"] = pair<std::string,std::string>("Fragmentation", "Fragmentation"); 346 MenuDescription["molecule"] = pair<std::string,std::string>("Parse files into system", "Parse files"); 347 MenuDescription["parser"] = pair<std::string,std::string>("Edit molecules (load, parse, save)", "Edit molecules"); 348 MenuDescription["tesselation"] = pair<std::string,std::string>("Tesselate molecules", "Tesselate molecules"); 349 MenuDescription["world"] = pair<std::string,std::string>("Edit world", "Edit world"); 395 MenuDescription["molecule"] = pair<std::string,std::string>("Parse files into system", "Molecules"); 396 MenuDescription["parser"] = pair<std::string,std::string>("Edit molecules (load, parse, save)", "Input/Output"); 397 MenuDescription["selection"] = pair<std::string,std::string>("Select atoms/molecules", "Selection"); 398 MenuDescription["tesselation"] = pair<std::string,std::string>("Tesselate molecules", "Tesselation"); 399 MenuDescription["world"] = pair<std::string,std::string>("Edit world", "Globals"); 350 400 351 401 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "molecular-volume") ); 352 402 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "pair-correlation") ); 403 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "point-correlation") ); 404 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "surface-correlation") ); 353 405 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "principal-axis-system") ); 354 406 … … 381 433 MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "parse-xyz") ); 382 434 MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "SaveXyz") ); 435 436 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-id") ); 437 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-by-id") ); 438 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-id") ); 439 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-id") ); 383 440 384 441 MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "convex-envelope") ); … … 425 482 generic.insert("pair-correlation"); 426 483 generic.insert("parse-xyz"); 484 generic.insert("point-correlation"); 427 485 // generic.insert("principal-axis-system"); 428 486 generic.insert("remove-atom"); … … 434 492 generic.insert("save-temperature"); 435 493 generic.insert("scale-box"); 494 generic.insert("select-all-atoms"); 495 generic.insert("select-all-molecules"); 496 generic.insert("select-atom-by-id"); 497 generic.insert("select-molecule-by-id"); 436 498 generic.insert("set-basis"); 437 499 generic.insert("set-output"); 438 500 generic.insert("subgraph-dissect"); 501 generic.insert("surface-correlation"); 439 502 generic.insert("suspend-in-water"); 440 503 generic.insert("translate-mol"); 504 generic.insert("unselect-all-atoms"); 505 generic.insert("unselect-all-molecules"); 506 generic.insert("unselect-atom-by-id"); 507 generic.insert("unselect-molecule-by-id"); 441 508 generic.insert("verbose"); 442 509 generic.insert("verlet-integrate"); … … 445 512 // positional arguments 446 513 generic.insert("input"); 447 inputfile.insert("input");448 514 449 515 // hidden arguments 450 generic.insert("atom-by-id"); 451 generic.insert("bin-end"); 452 generic.insert("bin-output-file"); 453 generic.insert("bin-start"); 454 generic.insert("bin-width"); 455 generic.insert("convex-file"); 456 generic.insert("distance"); 457 generic.insert("DoRotate"); 458 generic.insert("distances"); 459 generic.insert("element"); 460 generic.insert("elements"); 461 generic.insert("end-step"); 462 generic.insert("id-mapping"); 463 generic.insert("lengths"); 464 generic.insert("MaxDistance"); 465 generic.insert("molecule-by-id"); 466 generic.insert("molecule-by-name"); 467 generic.insert("nonconvex-file"); 468 generic.insert("order"); 469 generic.insert("output-file"); 470 generic.insert("periodic"); 471 generic.insert("position"); 472 generic.insert("sphere-radius"); 473 generic.insert("start-step"); 516 hidden.insert("bin-end"); 517 hidden.insert("bin-output-file"); 518 hidden.insert("bin-start"); 519 hidden.insert("bin-width"); 520 hidden.insert("convex-file"); 521 hidden.insert("distance"); 522 hidden.insert("DoRotate"); 523 hidden.insert("distances"); 524 hidden.insert("element"); 525 hidden.insert("elements"); 526 hidden.insert("end-step"); 527 hidden.insert("id-mapping"); 528 hidden.insert("lengths"); 529 hidden.insert("MaxDistance"); 530 hidden.insert("molecule-by-id"); 531 hidden.insert("nonconvex-file"); 532 hidden.insert("order"); 533 hidden.insert("output-file"); 534 hidden.insert("periodic"); 535 hidden.insert("position"); 536 hidden.insert("start-step"); 474 537 } 475 538 … … 482 545 } 483 546 547 void MapOfActions::queryCurrentValue(const char * name, class atom * &_T) 548 { 549 int atomID = -1; 550 if (typeid( atom ) == *TypeMap[name]) { 551 if (CurrentValue.find(name) == CurrentValue.end()) 552 throw MissingValueException(__FILE__, __LINE__); 553 atomID = lexical_cast<int>(CurrentValue[name].c_str()); 554 CurrentValue.erase(name); 555 } else 556 throw IllegalTypeException(__FILE__,__LINE__); 557 _T = World::getInstance().getAtom(AtomById(atomID)); 558 } 559 560 void MapOfActions::queryCurrentValue(const char * name, class element * &_T) { 561 int Z = -1; 562 if (typeid( element ) == *TypeMap[name]) { 563 if (CurrentValue.find(name) == CurrentValue.end()) 564 throw MissingValueException(__FILE__, __LINE__); 565 Z = lexical_cast<int>(CurrentValue[name].c_str()); 566 CurrentValue.erase(name); 567 } else 568 throw IllegalTypeException(__FILE__,__LINE__); 569 _T = World::getInstance().getPeriode()->FindElement(Z); 570 } 571 572 void MapOfActions::queryCurrentValue(const char * name, class molecule * &_T) { 573 int molID = -1; 574 if (typeid( molecule ) == *TypeMap[name]) { 575 if (CurrentValue.find(name) == CurrentValue.end()) 576 throw MissingValueException(__FILE__, __LINE__); 577 molID = lexical_cast<int>(CurrentValue[name].c_str()); 578 CurrentValue.erase(name); 579 } else 580 throw IllegalTypeException(__FILE__,__LINE__); 581 _T = World::getInstance().getMolecule(MoleculeById(molID)); 582 } 583 584 void MapOfActions::queryCurrentValue(const char * name, class Box &_T) { 585 Matrix M; 586 double tmp; 587 if (typeid( BoxValue ) == *TypeMap[name]) { 588 if (CurrentValue.find(name) == CurrentValue.end()) 589 throw MissingValueException(__FILE__, __LINE__); 590 std::istringstream stream(CurrentValue[name]); 591 stream >> tmp; 592 M.set(0,0,tmp); 593 stream >> tmp; 594 M.set(0,1,tmp); 595 M.set(1,0,tmp); 596 stream >> tmp; 597 M.set(0,2,tmp); 598 M.set(2,0,tmp); 599 stream >> tmp; 600 M.set(1,1,tmp); 601 stream >> tmp; 602 M.set(1,2,tmp); 603 M.set(2,1,tmp); 604 stream >> tmp; 605 M.set(2,2,tmp); 606 _T = M; 607 CurrentValue.erase(name); 608 } else 609 throw IllegalTypeException(__FILE__,__LINE__); 610 } 611 612 void MapOfActions::queryCurrentValue(const char * name, class Vector &_T) { 613 if (typeid( VectorValue ) == *TypeMap[name]) { 614 std::istringstream stream(CurrentValue[name]); 615 CurrentValue.erase(name); 616 stream >> _T[0]; 617 stream >> _T[1]; 618 stream >> _T[2]; 619 } else 620 throw IllegalTypeException(__FILE__,__LINE__); 621 } 622 623 void MapOfActions::queryCurrentValue(const char * name, std::vector<atom *>&_T) 624 { 625 int atomID = -1; 626 atom *Walker = NULL; 627 if (typeid( std::vector<atom *> ) == *TypeMap[name]) { 628 if (CurrentValue.find(name) == CurrentValue.end()) 629 throw MissingValueException(__FILE__, __LINE__); 630 std::istringstream stream(CurrentValue[name]); 631 CurrentValue.erase(name); 632 while (!stream.fail()) { 633 stream >> atomID >> ws; 634 Walker = World::getInstance().getAtom(AtomById(atomID)); 635 if (Walker != NULL) 636 _T.push_back(Walker); 637 atomID = -1; 638 Walker = NULL; 639 } 640 } else 641 throw IllegalTypeException(__FILE__,__LINE__); 642 } 643 644 void MapOfActions::queryCurrentValue(const char * name, std::vector<element *>&_T) 645 { 646 int Z = -1; 647 element *elemental = NULL; 648 if (typeid( std::vector<element *> ) == *TypeMap[name]) { 649 if (CurrentValue.find(name) == CurrentValue.end()) 650 throw MissingValueException(__FILE__, __LINE__); 651 std::istringstream stream(CurrentValue[name]); 652 CurrentValue.erase(name); 653 while (!stream.fail()) { 654 stream >> Z >> ws; 655 elemental = World::getInstance().getPeriode()->FindElement(Z); 656 if (elemental != NULL) 657 _T.push_back(elemental); 658 Z = -1; 659 } 660 } else 661 throw IllegalTypeException(__FILE__,__LINE__); 662 } 663 664 void MapOfActions::queryCurrentValue(const char * name, std::vector<molecule *>&_T) 665 { 666 int molID = -1; 667 molecule *mol = NULL; 668 if (typeid( std::vector<molecule *> ) == *TypeMap[name]) { 669 if (CurrentValue.find(name) == CurrentValue.end()) 670 throw MissingValueException(__FILE__, __LINE__); 671 std::istringstream stream(CurrentValue[name]); 672 CurrentValue.erase(name); 673 while (!stream.fail()) { 674 stream >> molID >> ws; 675 mol = World::getInstance().getMolecule(MoleculeById(molID)); 676 if (mol != NULL) 677 _T.push_back(mol); 678 molID = -1; 679 mol = NULL; 680 } 681 } else 682 throw IllegalTypeException(__FILE__,__LINE__); 683 } 684 685 686 void MapOfActions::setCurrentValue(const char * name, class atom * &_T) 687 { 688 if (typeid( atom ) == *TypeMap[name]) { 689 std::ostringstream stream; 690 stream << _T->getId(); 691 CurrentValue[name] = stream.str(); 692 } else 693 throw IllegalTypeException(__FILE__,__LINE__); 694 } 695 696 void MapOfActions::setCurrentValue(const char * name, class element * &_T) 697 { 698 if (typeid( element ) == *TypeMap[name]) { 699 std::ostringstream stream; 700 stream << _T->Z; 701 CurrentValue[name] = stream.str(); 702 } else 703 throw IllegalTypeException(__FILE__,__LINE__); 704 } 705 706 void MapOfActions::setCurrentValue(const char * name, class molecule * &_T) 707 { 708 if (typeid( molecule ) == *TypeMap[name]) { 709 std::ostringstream stream; 710 stream << _T->getId(); 711 CurrentValue[name] = stream.str(); 712 } else 713 throw IllegalTypeException(__FILE__,__LINE__); 714 } 715 716 void MapOfActions::setCurrentValue(const char * name, class Box &_T) 717 { 718 const Matrix &M = _T.getM(); 719 if (typeid( BoxValue ) == *TypeMap[name]) { 720 std::ostringstream stream; 721 stream << M.at(0,0) << " "; 722 stream << M.at(0,1) << " "; 723 stream << M.at(0,2) << " "; 724 stream << M.at(1,1) << " "; 725 stream << M.at(1,2) << " "; 726 stream << M.at(2,2) << " "; 727 CurrentValue[name] = stream.str(); 728 } else 729 throw IllegalTypeException(__FILE__,__LINE__); 730 } 731 732 void MapOfActions::setCurrentValue(const char * name, class Vector &_T) 733 { 734 if (typeid( VectorValue ) == *TypeMap[name]){ 735 std::ostringstream stream; 736 stream << _T[0] << " "; 737 stream << _T[1] << " "; 738 stream << _T[2] << " "; 739 CurrentValue[name] = stream.str(); 740 } else 741 throw IllegalTypeException(__FILE__,__LINE__); 742 } 743 744 void MapOfActions::setCurrentValue(const char * name, std::vector<atom *>&_T) 745 { 746 if (typeid( std::vector<atom *> ) == *TypeMap[name]) { 747 std::ostringstream stream; 748 for (std::vector<atom *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 749 stream << (*iter)->getId() << " "; 750 } 751 CurrentValue[name] = stream.str(); 752 } else 753 throw IllegalTypeException(__FILE__,__LINE__); 754 } 755 756 void MapOfActions::setCurrentValue(const char * name, std::vector<element *>&_T) 757 { 758 if (typeid( std::vector<element *> ) == *TypeMap[name]) { 759 std::ostringstream stream; 760 for (std::vector<element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 761 stream << (*iter)->Z << " "; 762 } 763 CurrentValue[name] = stream.str(); 764 } else 765 throw IllegalTypeException(__FILE__,__LINE__); 766 } 767 768 void MapOfActions::setCurrentValue(const char * name, std::vector<molecule *>&_T) 769 { 770 if (typeid( std::vector<molecule *> ) == *TypeMap[name]) { 771 std::ostringstream stream; 772 for (std::vector<molecule *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 773 stream << (*iter)->getId() << " "; 774 } 775 CurrentValue[name] = stream.str(); 776 } else 777 throw IllegalTypeException(__FILE__,__LINE__); 778 } 779 780 484 781 485 782 void MapOfActions::populateActions() … … 487 784 new AnalysisMolecularVolumeAction(); 488 785 new AnalysisPairCorrelationAction(); 786 new AnalysisPointCorrelationAction(); 489 787 new AnalysisPrincipalAxisSystemAction(); 788 new AnalysisSurfaceCorrelationAction(); 490 789 491 790 new AtomAddAction(); … … 518 817 new ParserLoadXyzAction(); 519 818 new ParserSaveXyzAction(); 819 820 new SelectionAllAtomsAction(); 821 new SelectionAllMoleculesAction(); 822 new SelectionAtomByIdAction(); 823 new SelectionMoleculeByIdAction(); 824 new SelectionNotAllAtomsAction(); 825 new SelectionNotAllMoleculesAction(); 826 new SelectionNotAtomByIdAction(); 827 new SelectionNotMoleculeByIdAction(); 520 828 521 829 new TesselationConvexEnvelopeAction(); … … 537 845 } 538 846 539 540 847 /** Adds all options to the CommandLineParser. 541 848 * … … 547 854 for (set<string>::iterator OptionRunner = ListRunner->first->begin(); OptionRunner != ListRunner->first->end(); ++OptionRunner) { 548 855 if (hasValue(*OptionRunner)) { 549 DoLog( 0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner]<< " to CommandLineParser." << endl);550 switch( (enum OptionTypes) TypeMap[*OptionRunner]) {856 DoLog(1) && (Log() << Verbose(1) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner]->name() << " to CommandLineParser." << endl); 857 switch(TypeEnumMap[TypeMap[*OptionRunner]]) { 551 858 default: 552 859 case None: … … 558 865 ListRunner->second->add_options() 559 866 (getKeyAndShortForm(*OptionRunner).c_str(), 560 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?561 po::value< bool >()->default_value( atoi(DefaultValue[*OptionRunner].c_str())) :867 CurrentValue.find(*OptionRunner) != CurrentValue.end() ? 868 po::value< bool >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) : 562 869 po::value< bool >(), 563 870 getDescription(*OptionRunner).c_str()) … … 567 874 ListRunner->second->add_options() 568 875 (getKeyAndShortForm(*OptionRunner).c_str(), 569 po::value<BoxValue>() ->multitoken(),876 po::value<BoxValue>(), 570 877 getDescription(*OptionRunner).c_str()) 571 878 ; … … 574 881 ListRunner->second->add_options() 575 882 (getKeyAndShortForm(*OptionRunner).c_str(), 576 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?577 po::value< int >()->default_value( atoi(DefaultValue[*OptionRunner].c_str())) :883 CurrentValue.find(*OptionRunner) != CurrentValue.end() ? 884 po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) : 578 885 po::value< int >(), 579 886 getDescription(*OptionRunner).c_str()) 580 887 ; 581 888 break; 582 case ListOfInt s:889 case ListOfIntegers: 583 890 ListRunner->second->add_options() 584 891 (getKeyAndShortForm(*OptionRunner).c_str(), … … 590 897 ListRunner->second->add_options() 591 898 (getKeyAndShortForm(*OptionRunner).c_str(), 592 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?593 po::value< double >()->default_value( atof(DefaultValue[*OptionRunner].c_str())) :899 CurrentValue.find(*OptionRunner) != CurrentValue.end() ? 900 po::value< double >()->default_value(lexical_cast<double>(CurrentValue[*OptionRunner].c_str())) : 594 901 po::value< double >(), 595 902 getDescription(*OptionRunner).c_str()) … … 606 913 ListRunner->second->add_options() 607 914 (getKeyAndShortForm(*OptionRunner).c_str(), 608 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?609 po::value< std::string >()->default_value( DefaultValue[*OptionRunner]) :915 CurrentValue.find(*OptionRunner) != CurrentValue.end() ? 916 po::value< std::string >()->default_value(CurrentValue[*OptionRunner]) : 610 917 po::value< std::string >(), 611 918 getDescription(*OptionRunner).c_str()) 612 919 ; 613 920 break; 614 case ListOfString :921 case ListOfStrings: 615 922 ListRunner->second->add_options() 616 923 (getKeyAndShortForm(*OptionRunner).c_str(), … … 619 926 ; 620 927 break; 621 case Axis: 622 ListRunner->second->add_options() 623 (getKeyAndShortForm(*OptionRunner).c_str(), 624 DefaultValue.find(*OptionRunner) != DefaultValue.end() ? 625 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) : 928 case Vector: 929 ListRunner->second->add_options() 930 (getKeyAndShortForm(*OptionRunner).c_str(), 931 po::value<VectorValue>(), 932 getDescription(*OptionRunner).c_str()) 933 ; 934 break; 935 case ListOfVectors: 936 ListRunner->second->add_options() 937 (getKeyAndShortForm(*OptionRunner).c_str(), 938 po::value< vector<VectorValue> >()->multitoken(), 939 getDescription(*OptionRunner).c_str()) 940 ; 941 break; 942 case Molecule: 943 ListRunner->second->add_options() 944 (getKeyAndShortForm(*OptionRunner).c_str(), 945 CurrentValue.find(*OptionRunner) != CurrentValue.end() ? 946 po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) : 626 947 po::value< int >(), 627 948 getDescription(*OptionRunner).c_str()) 628 949 ; 629 950 break; 630 case Vector:631 ListRunner->second->add_options() 632 (getKeyAndShortForm(*OptionRunner).c_str(), 633 po::value< VectorValue>(),634 getDescription(*OptionRunner).c_str()) 635 ; 636 break; 637 case Molecule:638 ListRunner->second->add_options() 639 (getKeyAndShortForm(*OptionRunner).c_str(), 640 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?641 po::value< int >()->default_value( atoi(DefaultValue[*OptionRunner].c_str())) :951 case ListOfMolecules: 952 ListRunner->second->add_options() 953 (getKeyAndShortForm(*OptionRunner).c_str(), 954 po::value< vector<int> >()->multitoken(), 955 getDescription(*OptionRunner).c_str()) 956 ; 957 break; 958 case Atom: 959 ListRunner->second->add_options() 960 (getKeyAndShortForm(*OptionRunner).c_str(), 961 CurrentValue.find(*OptionRunner) != CurrentValue.end() ? 962 po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) : 642 963 po::value< int >(), 643 964 getDescription(*OptionRunner).c_str()) 644 965 ; 645 966 break; 646 case ListOf Molecules:967 case ListOfAtoms: 647 968 ListRunner->second->add_options() 648 969 (getKeyAndShortForm(*OptionRunner).c_str(), … … 651 972 ; 652 973 break; 653 case Atom:654 ListRunner->second->add_options()655 (getKeyAndShortForm(*OptionRunner).c_str(),656 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?657 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :658 po::value< int >(),659 getDescription(*OptionRunner).c_str())660 ;661 break;662 case ListOfAtoms:663 ListRunner->second->add_options()664 (getKeyAndShortForm(*OptionRunner).c_str(),665 po::value< vector<int> >()->multitoken(),666 getDescription(*OptionRunner).c_str())667 ;668 break;669 974 case Element: 670 975 ListRunner->second->add_options() 671 976 (getKeyAndShortForm(*OptionRunner).c_str(), 672 po::value< vector<int>>(),977 po::value< int >(), 673 978 getDescription(*OptionRunner).c_str()) 674 979 ; … … 683 988 } 684 989 } else { 685 DoLog( 0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);990 DoLog(3) && (Log() << Verbose(3) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl); 686 991 ListRunner->second->add_options() 687 992 (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str()) … … 690 995 } 691 996 } 692 // add positional arguments693 for (set<string>::iterator OptionRunner = inputfile.begin(); OptionRunner != inputfile.end(); ++OptionRunner) {694 DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to positional CommandLineParser." << endl);695 CommandLineParser::getInstance().inputfile.add((*OptionRunner).c_str(), -1);696 }697 cout << "Name for position 1: " << CommandLineParser::getInstance().inputfile.name_for_position(1) << endl;698 997 } 699 998 … … 751 1050 * \return type of the action 752 1051 */ 753 enum MapOfActions::OptionTypesMapOfActions::getValueType(string actionname)754 { 755 return TypeMap[actionname] ;1052 std::string MapOfActions::getValueType(string actionname) 1053 { 1054 return TypeMap[actionname]->name(); 756 1055 } 757 1056 -
src/Actions/MapOfActions.hpp
r7067bd6 r677e13 9 9 #define MAPOFACTIONS_HPP_ 10 10 11 #include "Helpers/Assert.hpp"12 11 #include <boost/program_options.hpp> 13 12 14 13 #include <map> 15 14 #include <set> 15 #include <vector> 16 #include <typeinfo> 17 18 #include "Exceptions/IllegalTypeException.hpp" 19 #include "Exceptions/MissingValueException.hpp" 20 #include "Helpers/Assert.hpp" 21 #include "Patterns/Singleton.hpp" 16 22 17 23 class MapOfActionsTest; 18 24 19 #include "Patterns/Singleton.hpp" 25 class Box; 26 class atom; 27 class element; 28 class molecule; 29 class Vector; 20 30 21 31 namespace po = boost::program_options; 32 33 using boost::lexical_cast; 22 34 23 35 /** Central class for adding functionality to the code. … … 123 135 friend class MapOfActionsTest; 124 136 public: 125 enum OptionTypes { None, Boolean, Integer, ListOfInt s, Double, ListOfDoubles, String, ListOfString, Axis, Vector, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };137 enum OptionTypes { None, Boolean, Integer, ListOfIntegers, Double, ListOfDoubles, String, ListOfStrings, Vector, ListOfVectors, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements }; 126 138 127 139 // getter for the action descriptions and short forms … … 136 148 bool hasValue(std::string actionname); 137 149 bool isShortFormPresent(std::string shortform); 138 enum OptionTypesgetValueType(std::string actionname);150 std::string getValueType(std::string actionname); 139 151 140 152 std::set<std::string> generic; … … 150 162 void populateActions(); 151 163 164 void queryCurrentValue(const char * name, class atom * &_T); 165 void queryCurrentValue(const char * name, class element * &_T); 166 void queryCurrentValue(const char * name, class molecule * &_T); 167 void queryCurrentValue(const char * name, class Box &_T); 168 void queryCurrentValue(const char * name, class Vector &_T); 169 void queryCurrentValue(const char * name, std::vector<atom *>&_T); 170 void queryCurrentValue(const char * name, std::vector<element *>&_T); 171 void queryCurrentValue(const char * name, std::vector<molecule *>&_T); 172 template<typename T> void queryCurrentValue(const char * name, T &_T) 173 { 174 if (typeid( T ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr 175 if (CurrentValue.find(name) == CurrentValue.end()) 176 throw MissingValueException(__FILE__, __LINE__); 177 _T = lexical_cast<T>(CurrentValue[name].c_str()); 178 CurrentValue.erase(name); 179 } else 180 throw IllegalTypeException(__FILE__,__LINE__); 181 } 182 template<typename T> void queryCurrentValue(const char * name, std::vector<T> &_T) 183 { 184 T temp; 185 if (typeid( std::vector<T> ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr 186 if (CurrentValue.find(name) == CurrentValue.end()) 187 throw MissingValueException(__FILE__, __LINE__); 188 std::istringstream stream(CurrentValue[name]); 189 CurrentValue.erase(name); 190 while (!stream.fail()) { 191 stream >> temp >> std::ws; 192 _T.push_back(temp); 193 } 194 } else 195 throw IllegalTypeException(__FILE__,__LINE__); 196 } 197 198 void setCurrentValue(const char * name, class atom * &_T); 199 void setCurrentValue(const char * name, class element * &_T); 200 void setCurrentValue(const char * name, class molecule * &_T); 201 void setCurrentValue(const char * name, class Box &_T); 202 void setCurrentValue(const char * name, class Vector &_T); 203 void setCurrentValue(const char * name, std::vector<atom *>&_T); 204 void setCurrentValue(const char * name, std::vector<element *>&_T); 205 void setCurrentValue(const char * name, std::vector<molecule *>&_T); 206 template<class T> void setCurrentValue(const char * name, T &_T) 207 { 208 std::ostringstream stream; 209 if (typeid( T ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr 210 stream << _T; 211 CurrentValue[name] = stream.str(); 212 } else 213 throw IllegalTypeException(__FILE__,__LINE__); 214 } 215 template<class T> void setCurrentValue(const char * name, std::vector<T> &_T) 216 { 217 std::ostringstream stream; 218 if (typeid( std::vector<T> ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr 219 std::ostringstream stream; 220 for (typename std::vector<T>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 221 stream << (*iter) << " "; 222 } 223 CurrentValue[name] = stream.str(); 224 } else 225 throw IllegalTypeException(__FILE__,__LINE__); 226 } 227 228 152 229 private: 153 230 // private constructor and destructor … … 159 236 160 237 // map of the action names and their description 161 std::map<std::string, std::string> DefaultValue;238 std::map<std::string, std::string> CurrentValue; 162 239 std::map<std::string, std::string> DescriptionMap; 163 240 std::map<std::string, std::string> ShortFormMap; 164 std::map<std::string, enum OptionTypes > TypeMap; 241 std::map<std::string, const std::type_info * > TypeMap; 242 std::map<const std::type_info *, enum OptionTypes > TypeEnumMap; 165 243 }; 166 244 -
src/Actions/MethodAction.cpp
r7067bd6 r677e13 26 26 {} 27 27 28 Dialog* MethodAction::createDialog() { 29 return NULL; 30 } 31 28 32 29 33 Action::state_ptr MethodAction::performCall() { -
src/Actions/MethodAction.hpp
r7067bd6 r677e13 26 26 27 27 private: 28 virtual Dialog * createDialog(); 28 29 virtual Action::state_ptr performCall(); 29 30 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/MoleculeAction/BondFileAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/MoleculeAction/BondFileAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "log.hpp" 13 #include "molecule.hpp" 14 #include "verbose.hpp" 15 #include "World.hpp" 11 16 12 17 #include <iostream> … … 18 23 #include "UIElements/UIFactory.hpp" 19 24 #include "UIElements/Dialog.hpp" 20 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 21 26 22 #include "atom.hpp"23 #include "bondgraph.hpp"24 #include "config.hpp"25 #include "defs.hpp"26 #include "verbose.hpp"27 #include "log.hpp"28 #include "molecule.hpp"29 #include "vector.hpp"30 #include "World.hpp"31 27 32 28 /****** MoleculeBondFileAction *****/ … … 53 49 {} 54 50 51 void MoleculeBondFile(std::string &bondfile) { 52 ValueStorage::getInstance().setCurrentValue(MoleculeBondFileAction::NAME, bondfile); 53 ActionRegistry::getInstance().getActionByName(MoleculeBondFileAction::NAME)->call(Action::NonInteractive); 54 }; 55 56 Dialog* MoleculeBondFileAction::createDialog() { 57 Dialog *dialog = UIFactory::getInstance().makeDialog(); 58 59 dialog->queryString(NAME, MapOfActions::getInstance().getDescription(NAME)); 60 61 return dialog; 62 } 63 55 64 Action::state_ptr MoleculeBondFileAction::performCall() { 56 65 string filename; 57 Dialog *dialog = UIFactory::getInstance().makeDialog();58 66 molecule *mol = NULL; 59 67 60 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 61 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 68 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 62 69 63 if(dialog->display()) { 70 if(World::getInstance().countSelectedMolecules() == 1) { 71 mol = World::getInstance().beginMoleculeSelection()->second; 64 72 DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << filename << "." << endl); 65 73 ifstream input(filename.c_str()); 66 74 mol->CreateAdjacencyListFromDbondFile(&input); 67 75 input.close(); 68 delete dialog;69 76 return Action::success; 70 } 71 delete dialog; 72 return Action::failure; 77 } else 78 return Action::failure; 73 79 } 74 80 -
src/Actions/MoleculeAction/BondFileAction.hpp
r7067bd6 r677e13 14 14 class MoleculeListClass; 15 15 16 void MoleculeBondFile(std::string &bondfile); 17 16 18 class MoleculeBondFileAction : public Action { 19 friend void MoleculeBondFile(std::string &bondfile); 20 17 21 public: 18 22 MoleculeBondFileAction(); … … 24 28 virtual const std::string getName(); 25 29 private: 30 virtual Dialog * createDialog(); 26 31 virtual Action::state_ptr performCall(); 27 32 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/MoleculeAction/ChangeNameAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/MoleculeAction/ChangeNameAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "atom.hpp" 13 #include "molecule.hpp" 11 14 12 15 #include <iostream> … … 17 20 #include "UIElements/UIFactory.hpp" 18 21 #include "UIElements/Dialog.hpp" 19 #include "Actions/MapOfActions.hpp" 20 21 #include "atom.hpp" 22 #include "molecule.hpp" 22 #include "UIElements/ValueStorage.hpp" 23 23 24 24 /****** MoleculeChangeNameAction *****/ … … 45 45 {} 46 46 47 void MoleculeChangeName(std::string &name) { 48 ValueStorage::getInstance().setCurrentValue(MoleculeChangeNameAction::NAME, name); 49 ActionRegistry::getInstance().getActionByName(MoleculeChangeNameAction::NAME)->call(Action::NonInteractive); 50 }; 51 52 Dialog* MoleculeChangeNameAction::createDialog() { 53 Dialog *dialog = UIFactory::getInstance().makeDialog(); 54 55 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 56 57 return dialog; 58 } 59 47 60 Action::state_ptr MoleculeChangeNameAction::performCall() { 48 61 string filename; 49 62 molecule *mol = NULL; 50 Dialog *dialog = UIFactory::getInstance().makeDialog();51 63 52 dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME)); 53 dialog->queryString("Enter name: ",&filename); 64 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 54 65 55 if(dialog->display()) { 66 if (World::getInstance().countSelectedMolecules() == 1) { 67 mol = World::getInstance().beginMoleculeSelection()->second; 56 68 string oldName = mol->getName(); 57 69 mol->setName(filename); 58 delete dialog;59 70 return Action::state_ptr(new MoleculeChangeNameState(mol,oldName)); 60 } 61 delete dialog; 62 return Action::failure; 71 } else 72 return Action::failure; 63 73 } 64 74 -
src/Actions/MoleculeAction/ChangeNameAction.hpp
r7067bd6 r677e13 14 14 class MoleculeListClass; 15 15 16 void MoleculeChangeName(std::string &name); 17 16 18 class MoleculeChangeNameAction : public Action { 19 friend void MoleculeChangeName(std::string &name); 20 17 21 public: 18 22 MoleculeChangeNameAction(); … … 24 28 virtual const std::string getName(); 25 29 private: 30 virtual Dialog * createDialog(); 26 31 virtual Action::state_ptr performCall(); 27 32 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/MoleculeAction/FillWithMoleculeAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/MoleculeAction/FillWithMoleculeAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "atom.hpp" 13 #include "bondgraph.hpp" 14 #include "boundary.hpp" 15 #include "config.hpp" 16 #include "molecule.hpp" 17 #include "verbose.hpp" 18 #include "World.hpp" 19 11 20 12 21 #include <iostream> … … 17 26 #include "UIElements/UIFactory.hpp" 18 27 #include "UIElements/Dialog.hpp" 19 #include "Actions/MapOfActions.hpp" 20 21 #include "atom.hpp" 22 #include "bondgraph.hpp" 23 #include "boundary.hpp" 24 #include "config.hpp" 25 #include "defs.hpp" 26 #include "molecule.hpp" 27 #include "periodentafel.hpp" 28 #include "vector.hpp" 29 #include "verbose.hpp" 30 #include "World.hpp" 28 #include "UIElements/ValueStorage.hpp" 31 29 32 30 /****** MoleculeFillWithMoleculeAction *****/ … … 53 51 {} 54 52 53 void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate) { 54 ValueStorage::getInstance().setCurrentValue(MoleculeFillWithMoleculeAction::NAME, fillername); 55 ValueStorage::getInstance().setCurrentValue("distances", distances); 56 ValueStorage::getInstance().setCurrentValue("lengths", lengths); 57 ValueStorage::getInstance().setCurrentValue("DoRotate", MaxDistance); 58 ValueStorage::getInstance().setCurrentValue("MaxDistance", DoRotate); 59 ActionRegistry::getInstance().getActionByName(MoleculeFillWithMoleculeAction::NAME)->call(Action::NonInteractive); 60 }; 61 62 Dialog* MoleculeFillWithMoleculeAction::createDialog() { 63 Dialog *dialog = UIFactory::getInstance().makeDialog(); 64 65 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 66 dialog->queryVector("distances", false, ValueStorage::getInstance().getDescription("distances")); 67 dialog->queryVector("lengths", false, ValueStorage::getInstance().getDescription("lengths")); 68 dialog->queryBoolean("DoRotate", ValueStorage::getInstance().getDescription("DoRotate")); 69 dialog->queryDouble("MaxDistance", ValueStorage::getInstance().getDescription("MaxDistance")); 70 71 return dialog; 72 } 73 55 74 Action::state_ptr MoleculeFillWithMoleculeAction::performCall() { 56 75 string filename; 57 Dialog *dialog = UIFactory::getInstance().makeDialog();58 76 Vector distances; 59 77 Vector lengths; … … 61 79 bool DoRotate = false; 62 80 63 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));64 dialog->queryVector("distances", &distances, false, MapOfActions::getInstance().getDescription("distances"));65 dialog->queryVector("lengths", &lengths, false, MapOfActions::getInstance().getDescription("lengths"));66 dialog->queryBoolean("DoRotate", &DoRotate, MapOfActions::getInstance().getDescription("DoRotate"));67 dialog->queryDouble("MaxDistance", &MaxDistance, MapOfActions::getInstance().getDescription("MaxDistance"));81 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 82 ValueStorage::getInstance().queryCurrentValue("distances", distances); 83 ValueStorage::getInstance().queryCurrentValue("lengths", lengths); 84 ValueStorage::getInstance().queryCurrentValue("DoRotate", DoRotate); 85 ValueStorage::getInstance().queryCurrentValue("MaxDistance", MaxDistance); 68 86 69 if(dialog->display()) { 70 DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << lengths[0] << "," << lengths[1] << "," << lengths[2] << "), distances (" << distances[0] << "," << distances[1] << "," << distances[2] << "), MaxDistance " << MaxDistance << ", DoRotate " << DoRotate << "." << endl); 71 // construct water molecule 72 molecule *filler = World::getInstance().createMolecule(); 73 if (!filler->AddXYZFile(filename)) { 74 DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << filename << "." << endl); 75 } 76 filler->SetNameFromFilename(filename.c_str()); 77 molecule *Filling = NULL; 87 DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules, lengths(" << lengths[0] << "," << lengths[1] << "," << lengths[2] << "), distances (" << distances[0] << "," << distances[1] << "," << distances[2] << "), MaxDistance " << MaxDistance << ", DoRotate " << DoRotate << "." << endl); 88 // construct water molecule 89 molecule *filler = World::getInstance().createMolecule(); 90 if (!filler->AddXYZFile(filename)) { 91 DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << filename << "." << endl); 92 } 93 filler->SetNameFromFilename(filename.c_str()); 94 molecule *Filling = NULL; 78 95 // atom *first = NULL, *second = NULL, *third = NULL; 79 96 // first = World::getInstance().createAtom(); … … 91 108 // filler->AddBond(first, third, 1); 92 109 // filler->AddBond(second, third, 1); 93 110 World::getInstance().getConfig()->BG->ConstructBondGraph(filler); 94 111 // filler->SetNameFromFilename("water"); 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 112 // call routine 113 double distance[NDIM]; 114 for (int i=0;i<NDIM;i++) 115 distance[i] = distances[i]; 116 Filling = FillBoxWithMolecule(World::getInstance().getMolecules(), filler, *(World::getInstance().getConfig()), MaxDistance, distance, lengths[0], lengths[1], lengths[2], DoRotate); 117 if (Filling != NULL) { 118 Filling->ActiveFlag = false; 119 World::getInstance().getMolecules()->insert(Filling); 120 } 121 for (molecule::iterator iter = filler->begin(); !filler->empty(); iter = filler->begin()) { 122 atom *Walker = *iter; 123 filler->erase(iter); 124 World::getInstance().destroyAtom(Walker); 125 } 126 World::getInstance().destroyMolecule(filler); 110 127 111 delete dialog; 112 return Action::success; 113 } 114 delete dialog; 115 return Action::failure; 128 return Action::success; 116 129 } 117 130 -
src/Actions/MoleculeAction/FillWithMoleculeAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 #include "Actions/Process.hpp" 13 #include "vector.hpp" 13 14 14 15 class MoleculeListClass; 15 16 17 void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate); 18 16 19 class MoleculeFillWithMoleculeAction : public Action { 20 friend void MoleculeFillWithMolecule(std::string &fillername, Vector &distances, Vector &lengths, double MaxDistance, bool DoRotate); 21 17 22 public: 18 23 MoleculeFillWithMoleculeAction(); … … 24 29 virtual const std::string getName(); 25 30 private: 31 virtual Dialog * createDialog(); 26 32 virtual Action::state_ptr performCall(); 27 33 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "atom.hpp" 13 #include "defs.hpp" 14 #include "log.hpp" 15 #include "molecule.hpp" 16 #include "verbose.hpp" 17 #include "World.hpp" 11 18 12 19 #include <iostream> … … 18 25 #include "UIElements/UIFactory.hpp" 19 26 #include "UIElements/Dialog.hpp" 20 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 21 28 22 #include "atom.hpp"23 #include "defs.hpp"24 #include "log.hpp"25 #include "molecule.hpp"26 #include "verbose.hpp"27 #include "World.hpp"28 29 29 30 /****** MoleculeLinearInterpolationofTrajectoriesAction *****/ … … 50 51 {} 51 52 53 void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping) { 54 ValueStorage::getInstance().setCurrentValue(MoleculeLinearInterpolationofTrajectoriesAction::NAME, filename); 55 ValueStorage::getInstance().setCurrentValue("start-step", start); 56 ValueStorage::getInstance().setCurrentValue("end-step", end); 57 ValueStorage::getInstance().setCurrentValue("id-mapping", IdMapping); 58 ActionRegistry::getInstance().getActionByName(MoleculeLinearInterpolationofTrajectoriesAction::NAME)->call(Action::NonInteractive); 59 }; 60 61 Dialog* MoleculeLinearInterpolationofTrajectoriesAction::createDialog() { 62 Dialog *dialog = UIFactory::getInstance().makeDialog(); 63 64 dialog->queryString(NAME, MapOfActions::getInstance().getDescription(NAME)); 65 dialog->queryInt("start-step", MapOfActions::getInstance().getDescription("start-step")); 66 dialog->queryInt("end-step", MapOfActions::getInstance().getDescription("end-step")); 67 dialog->queryBoolean("id-mapping", MapOfActions::getInstance().getDescription("id-mapping")); 68 69 return dialog; 70 } 71 52 72 Action::state_ptr MoleculeLinearInterpolationofTrajectoriesAction::performCall() { 53 73 string filename; 54 Dialog *dialog = UIFactory::getInstance().makeDialog();55 74 molecule *mol = NULL; 56 75 int start = -1; … … 58 77 bool IdMapping = true; 59 78 79 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 80 ValueStorage::getInstance().queryCurrentValue("start-step", start); 81 ValueStorage::getInstance().queryCurrentValue("end-step", end); 82 ValueStorage::getInstance().queryCurrentValue("id-mapping", IdMapping); 60 83 61 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 62 dialog->queryInt("start-step", &start, MapOfActions::getInstance().getDescription("start-step")); 63 dialog->queryInt("end-step", &end, MapOfActions::getInstance().getDescription("end-step")); 64 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 65 dialog->queryBoolean("id-mapping", &IdMapping, MapOfActions::getInstance().getDescription("id-mapping")); 66 67 if(dialog->display()) { 84 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 85 mol = iter->second; 68 86 DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << start << " and " << end << "." << endl); 69 87 if (IdMapping) … … 73 91 else 74 92 DoLog(2) && (Log() << Verbose(2) << "Steps created and " << filename << " files stored." << endl); 75 delete dialog;76 return Action::success;77 93 } 78 delete dialog; 79 return Action::failure; 94 return Action::success; 80 95 } 81 96 -
src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp
r7067bd6 r677e13 14 14 class MoleculeListClass; 15 15 16 void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping); 17 16 18 class MoleculeLinearInterpolationofTrajectoriesAction : public Action { 19 friend void MoleculeLinearInterpolationofTrajectories(std::string &filename, int start, int end, bool IdMapping); 20 17 21 public: 18 22 MoleculeLinearInterpolationofTrajectoriesAction(); … … 24 28 virtual const std::string getName(); 25 29 private: 30 virtual Dialog * createDialog(); 26 31 virtual Action::state_ptr performCall(); 27 32 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "log.hpp" 13 #include "molecule.hpp" 14 #include "verbose.hpp" 15 11 16 12 17 #include <iostream> … … 18 23 #include "UIElements/UIFactory.hpp" 19 24 #include "UIElements/Dialog.hpp" 20 #include "Actions/MapOfActions.hpp" 21 22 #include "log.hpp" 23 #include "molecule.hpp" 24 #include "verbose.hpp" 25 #include "UIElements/ValueStorage.hpp" 25 26 26 27 /****** MoleculeRotateToPrincipalAxisSystemAction *****/ … … 47 48 {} 48 49 50 void MoleculeRotateToPrincipalAxisSystem() { 51 ActionRegistry::getInstance().getActionByName(MoleculeRotateToPrincipalAxisSystemAction::NAME)->call(Action::NonInteractive); 52 }; 53 54 Dialog* MoleculeRotateToPrincipalAxisSystemAction::createDialog() { 55 Dialog *dialog = UIFactory::getInstance().makeDialog(); 56 57 dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME)); 58 59 return dialog; 60 } 61 49 62 Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performCall() { 50 Dialog *dialog = UIFactory::getInstance().makeDialog();51 63 molecule *mol = NULL; 52 64 53 dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME)); 54 55 if(dialog->display()) { 65 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 66 mol = iter->second; 56 67 DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl); 57 68 mol->PrincipalAxisSystem(true); 58 delete dialog;59 return Action::success;60 69 } 61 delete dialog; 62 return Action::failure; 70 return Action::success; 63 71 } 64 72 -
src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp
r7067bd6 r677e13 14 14 class MoleculeListClass; 15 15 16 void MoleculeRotateToPrincipalAxisSystem(); 17 16 18 class MoleculeRotateToPrincipalAxisSystemAction : public Action { 19 friend void MoleculeRotateToPrincipalAxisSystem(); 20 17 21 public: 18 22 MoleculeRotateToPrincipalAxisSystemAction(); … … 24 28 virtual const std::string getName(); 25 29 private: 30 virtual Dialog * createDialog(); 26 31 virtual Action::state_ptr performCall(); 27 32 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/MoleculeAction/SaveAdjacencyAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "bondgraph.hpp" 13 #include "config.hpp" 14 #include "log.hpp" 15 #include "molecule.hpp" 16 #include "verbose.hpp" 17 #include "World.hpp" 18 11 19 12 20 #include <iostream> … … 18 26 #include "UIElements/UIFactory.hpp" 19 27 #include "UIElements/Dialog.hpp" 20 #include "Actions/MapOfActions.hpp" 21 22 #include "atom.hpp" 23 #include "bondgraph.hpp" 24 #include "config.hpp" 25 #include "defs.hpp" 26 #include "log.hpp" 27 #include "molecule.hpp" 28 #include "vector.hpp" 29 #include "verbose.hpp" 30 #include "World.hpp" 28 #include "UIElements/ValueStorage.hpp" 31 29 32 30 /****** MoleculeSaveAdjacencyAction *****/ … … 53 51 {} 54 52 53 void MoleculeSaveAdjacency(std::string &adjacencyfile) { 54 ValueStorage::getInstance().setCurrentValue(MoleculeSaveAdjacencyAction::NAME, adjacencyfile); 55 ActionRegistry::getInstance().getActionByName(MoleculeSaveAdjacencyAction::NAME)->call(Action::NonInteractive); 56 }; 57 58 Dialog* MoleculeSaveAdjacencyAction::createDialog() { 59 Dialog *dialog = UIFactory::getInstance().makeDialog(); 60 61 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 62 63 return dialog; 64 } 65 55 66 Action::state_ptr MoleculeSaveAdjacencyAction::performCall() { 56 67 string filename; 57 Dialog *dialog = UIFactory::getInstance().makeDialog();58 68 molecule *mol = NULL; 59 69 60 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 61 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 70 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 62 71 63 if(dialog->display()) { 72 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 73 mol = iter->second; 64 74 DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << filename << "." << endl); 65 75 World::getInstance().getConfig()->BG->ConstructBondGraph(mol); 66 76 // TODO: sollte stream nicht filename benutzen, besser fuer unit test 67 77 mol->StoreAdjacencyToFile(filename); 68 delete dialog;69 return Action::success;70 78 } 71 delete dialog; 72 return Action::failure; 79 return Action::success; 73 80 } 74 81 -
src/Actions/MoleculeAction/SaveAdjacencyAction.hpp
r7067bd6 r677e13 14 14 class MoleculeListClass; 15 15 16 void MoleculeSaveAdjacency(std::string &adjacencyfile); 17 16 18 class MoleculeSaveAdjacencyAction : public Action { 19 friend void MoleculeSaveAdjacency(std::string &adjacencyfile); 20 17 21 public: 18 22 MoleculeSaveAdjacencyAction(); … … 24 28 virtual const std::string getName(); 25 29 private: 30 virtual Dialog * createDialog(); 26 31 virtual Action::state_ptr performCall(); 27 32 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/MoleculeAction/SaveBondsAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/MoleculeAction/SaveBondsAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "bondgraph.hpp" 13 #include "config.hpp" 14 #include "log.hpp" 15 #include "molecule.hpp" 16 #include "verbose.hpp" 17 #include "World.hpp" 18 11 19 12 20 #include <iostream> … … 18 26 #include "UIElements/UIFactory.hpp" 19 27 #include "UIElements/Dialog.hpp" 20 #include "Actions/MapOfActions.hpp" 21 22 #include "atom.hpp" 23 #include "bondgraph.hpp" 24 #include "config.hpp" 25 #include "defs.hpp" 26 #include "log.hpp" 27 #include "molecule.hpp" 28 #include "vector.hpp" 29 #include "verbose.hpp" 30 #include "World.hpp" 28 #include "UIElements/ValueStorage.hpp" 31 29 32 30 /****** MoleculeSaveBondsAction *****/ … … 53 51 {} 54 52 53 void MoleculeSaveBonds(std::string &bondsfile) { 54 ValueStorage::getInstance().setCurrentValue(MoleculeSaveBondsAction::NAME, bondsfile); 55 ActionRegistry::getInstance().getActionByName(MoleculeSaveBondsAction::NAME)->call(Action::NonInteractive); 56 }; 57 58 Dialog* MoleculeSaveBondsAction::createDialog() { 59 Dialog *dialog = UIFactory::getInstance().makeDialog(); 60 61 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 62 63 return dialog; 64 } 65 55 66 Action::state_ptr MoleculeSaveBondsAction::performCall() { 56 67 string filename; 57 Dialog *dialog = UIFactory::getInstance().makeDialog();58 68 molecule *mol = NULL; 59 69 60 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 61 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 70 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 62 71 63 if(dialog->display()) { 72 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 73 mol = iter->second; 64 74 DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << filename << "." << endl); 65 75 World::getInstance().getConfig()->BG->ConstructBondGraph(mol); 66 76 // TODO: sollte stream, nicht filenamen direkt nutzen, besser fuer unit tests 67 77 mol->StoreBondsToFile(filename); 68 delete dialog;69 return Action::success;70 78 } 71 delete dialog; 72 return Action::failure; 79 return Action::success; 73 80 } 74 81 -
src/Actions/MoleculeAction/SaveBondsAction.hpp
r7067bd6 r677e13 14 14 class MoleculeListClass; 15 15 16 void MoleculeSaveBonds(std::string &bondsfile); 17 16 18 class MoleculeSaveBondsAction : public Action { 19 friend void MoleculeSaveBonds(std::string &bondsfile); 20 17 21 public: 18 22 MoleculeSaveBondsAction(); … … 24 28 virtual const std::string getName(); 25 29 private: 30 virtual Dialog * createDialog(); 26 31 virtual Action::state_ptr performCall(); 27 32 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/MoleculeAction/SaveTemperatureAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/MoleculeAction/SaveTemperatureAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "log.hpp" 13 #include "molecule.hpp" 14 #include "verbose.hpp" 15 #include "World.hpp" 11 16 12 17 #include <iostream> … … 18 23 #include "UIElements/UIFactory.hpp" 19 24 #include "UIElements/Dialog.hpp" 20 #include "Actions/MapOfActions.hpp" 21 22 #include "atom.hpp" 23 #include "log.hpp" 24 #include "molecule.hpp" 25 #include "verbose.hpp" 26 #include "World.hpp" 25 #include "UIElements/ValueStorage.hpp" 27 26 28 27 /****** MoleculeSaveTemperatureAction *****/ … … 49 48 {} 50 49 50 void MoleculeSaveTemperature(std::string &temperaturefile) { 51 ValueStorage::getInstance().setCurrentValue(MoleculeSaveTemperatureAction::NAME, temperaturefile); 52 ActionRegistry::getInstance().getActionByName(MoleculeSaveTemperatureAction::NAME)->call(Action::NonInteractive); 53 }; 54 55 Dialog* MoleculeSaveTemperatureAction::createDialog() { 56 Dialog *dialog = UIFactory::getInstance().makeDialog(); 57 58 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 59 60 return dialog; 61 } 62 51 63 Action::state_ptr MoleculeSaveTemperatureAction::performCall() { 52 64 string filename; 53 Dialog *dialog = UIFactory::getInstance().makeDialog();54 65 molecule *mol = NULL; 55 66 56 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 57 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 67 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 58 68 59 if(dialog->display()) { 69 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 70 mol = iter->second; 60 71 DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl); 61 72 ofstream output; … … 66 77 DoLog(2) && (Log() << Verbose(2) << "File stored." << endl); 67 78 output.close(); 68 delete dialog;69 return Action::success;70 79 } 71 delete dialog; 72 return Action::failure; 80 return Action::success; 73 81 } 74 82 -
src/Actions/MoleculeAction/SaveTemperatureAction.hpp
r7067bd6 r677e13 14 14 class MoleculeListClass; 15 15 16 void MoleculeSaveTemperature(std::string &temperaturefile); 17 16 18 class MoleculeSaveTemperatureAction : public Action { 19 friend void MoleculeSaveTemperature(std::string &temperaturefile); 20 17 21 public: 18 22 MoleculeSaveTemperatureAction(); … … 24 28 virtual const std::string getName(); 25 29 private: 30 virtual Dialog * createDialog(); 26 31 virtual Action::state_ptr performCall(); 27 32 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/MoleculeAction/SuspendInWaterAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/MoleculeAction/SuspendInWaterAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "boundary.hpp" 13 #include "config.hpp" 14 #include "log.hpp" 15 #include "verbose.hpp" 16 #include "World.hpp" 11 17 12 18 #include <iostream> … … 17 23 #include "UIElements/UIFactory.hpp" 18 24 #include "UIElements/Dialog.hpp" 19 #include "Actions/MapOfActions.hpp" 20 21 #include "atom.hpp" 22 #include "boundary.hpp" 23 #include "config.hpp" 24 #include "verbose.hpp" 25 #include "log.hpp" 26 #include "config.hpp" 27 #include "World.hpp" 25 #include "UIElements/ValueStorage.hpp" 28 26 29 27 /****** MoleculeSuspendInWaterAction *****/ … … 50 48 {} 51 49 50 void MoleculeSuspendInWater(double density) { 51 ValueStorage::getInstance().setCurrentValue(MoleculeSuspendInWaterAction::NAME, density); 52 ActionRegistry::getInstance().getActionByName(MoleculeSuspendInWaterAction::NAME)->call(Action::NonInteractive); 53 }; 54 55 Dialog* MoleculeSuspendInWaterAction::createDialog() { 56 Dialog *dialog = UIFactory::getInstance().makeDialog(); 57 58 dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME)); 59 60 return dialog; 61 } 62 52 63 Action::state_ptr MoleculeSuspendInWaterAction::performCall() { 53 64 molecule *mol = NULL; 54 Dialog *dialog = UIFactory::getInstance().makeDialog();55 65 double density; 56 66 double volume = 0.; 57 67 58 dialog->queryDouble(NAME, &density, MapOfActions::getInstance().getDescription(NAME)); 59 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 68 ValueStorage::getInstance().queryCurrentValue(NAME, density); 60 69 61 if(dialog->display()) { 70 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 71 mol = iter->second; 62 72 DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water."); 63 73 if (density < 1.0) { … … 65 75 } else { 66 76 PrepareClustersinWater(World::getInstance().getConfig(), mol, volume, density); // if volume == 0, will calculate from ConvexEnvelope 67 delete dialog;68 return Action::success;69 77 } 70 78 } 71 delete dialog; 72 return Action::failure; 79 return Action::success; 73 80 } 74 81 -
src/Actions/MoleculeAction/SuspendInWaterAction.hpp
r7067bd6 r677e13 14 14 class MoleculeListClass; 15 15 16 void MoleculeSuspendInWater(double density); 17 16 18 class MoleculeSuspendInWaterAction : public Action { 19 friend void MoleculeSuspendInWater(double density); 20 17 21 public: 18 22 MoleculeSuspendInWaterAction(); … … 24 28 virtual const std::string getName(); 25 29 private: 30 virtual Dialog * createDialog(); 26 31 virtual Action::state_ptr performCall(); 27 32 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/MoleculeAction/TranslateAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/MoleculeAction/TranslateAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "log.hpp" 13 #include "molecule.hpp" 14 #include "vector.hpp" 15 #include "verbose.hpp" 16 #include "World.hpp" 11 17 12 18 #include <iostream> … … 18 24 #include "UIElements/UIFactory.hpp" 19 25 #include "UIElements/Dialog.hpp" 20 #include "Actions/MapOfActions.hpp" 21 22 #include "atom.hpp" 23 #include "log.hpp" 24 #include "molecule.hpp" 25 #include "verbose.hpp" 26 #include "World.hpp" 26 #include "UIElements/ValueStorage.hpp" 27 27 28 28 /****** MoleculeTranslateAction *****/ … … 49 49 {} 50 50 51 void MoleculeTranslate(Vector &x, bool periodic) { 52 ValueStorage::getInstance().setCurrentValue(MoleculeTranslateAction::NAME, x); 53 ValueStorage::getInstance().setCurrentValue("periodic", periodic); 54 ActionRegistry::getInstance().getActionByName(MoleculeTranslateAction::NAME)->call(Action::NonInteractive); 55 }; 56 57 Dialog* MoleculeTranslateAction::createDialog() { 58 Dialog *dialog = UIFactory::getInstance().makeDialog(); 59 60 dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME)); 61 dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic")); 62 63 return dialog; 64 } 65 51 66 Action::state_ptr MoleculeTranslateAction::performCall() { 52 Dialog *dialog = UIFactory::getInstance().makeDialog();53 67 molecule *mol = NULL; 54 68 Vector x; 55 69 bool periodic = false; 56 70 57 dialog->queryVector(NAME, &x, false, MapOfActions::getInstance().getDescription(NAME)); 58 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 59 dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic")); 60 cout << "pre-dialog" << endl; 71 ValueStorage::getInstance().queryCurrentValue(NAME, x); 72 ValueStorage::getInstance().queryCurrentValue("periodic", periodic); 61 73 62 if(dialog->display()) {63 cout << "post-dialog" << endl;74 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 75 mol = iter->second; 64 76 DoLog(1) && (Log() << Verbose(1) << "Translating all ions by given vector." << endl); 65 77 if (periodic) … … 67 79 else 68 80 mol->Translate((const Vector *)&x); 69 delete dialog;70 return Action::success;71 81 } 72 delete dialog; 73 return Action::failure; 82 return Action::success; 74 83 } 75 84 -
src/Actions/MoleculeAction/TranslateAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 #include "Actions/Process.hpp" 13 #include "vector.hpp" 13 14 14 15 class MoleculeListClass; 15 16 17 void MoleculeTranslate(Vector &x, bool periodic); 18 16 19 class MoleculeTranslateAction : public Action { 20 friend void MoleculeTranslate(Vector &x, bool periodic); 21 17 22 public: 18 23 MoleculeTranslateAction(); … … 24 29 virtual const std::string getName(); 25 30 private: 31 virtual Dialog * createDialog(); 26 32 virtual Action::state_ptr performCall(); 27 33 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/MoleculeAction/VerletIntegrationAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/MoleculeAction/VerletIntegrationAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "log.hpp" 13 #include "molecule.hpp" 14 #include "verbose.hpp" 15 #include "World.hpp" 11 16 12 17 #include <iostream> … … 18 23 #include "UIElements/UIFactory.hpp" 19 24 #include "UIElements/Dialog.hpp" 20 #include "Actions/MapOfActions.hpp" 21 22 #include "atom.hpp" 23 #include "log.hpp" 24 #include "molecule.hpp" 25 #include "verbose.hpp" 26 #include "World.hpp" 25 #include "UIElements/ValueStorage.hpp" 27 26 28 27 /****** MoleculeVerletIntegrationAction *****/ … … 49 48 {} 50 49 50 void MoleculeVerletIntegration(std::string &forcesfile) { 51 ValueStorage::getInstance().setCurrentValue(MoleculeVerletIntegrationAction::NAME, forcesfile); 52 ActionRegistry::getInstance().getActionByName(MoleculeVerletIntegrationAction::NAME)->call(Action::NonInteractive); 53 }; 54 55 Dialog* MoleculeVerletIntegrationAction::createDialog() { 56 Dialog *dialog = UIFactory::getInstance().makeDialog(); 57 58 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 59 60 return dialog; 61 } 62 51 63 Action::state_ptr MoleculeVerletIntegrationAction::performCall() { 52 64 string filename; 53 Dialog *dialog = UIFactory::getInstance().makeDialog();54 65 molecule *mol = NULL; 55 66 56 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME)); 57 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 67 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 58 68 59 if(dialog->display()) { 69 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 70 mol = iter->second; 60 71 DoLog(1) && (Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl); 61 72 // TODO: sollte besser stream nutzen, nicht filename direkt (es sei denn, ist prefix), besser fuer unit test … … 66 77 else 67 78 DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl); 68 69 delete dialog;70 return Action::success;71 79 } 72 delete dialog; 73 return Action::failure; 80 return Action::success; 74 81 } 75 82 -
src/Actions/MoleculeAction/VerletIntegrationAction.hpp
r7067bd6 r677e13 14 14 class MoleculeListClass; 15 15 16 void MoleculeVerletIntegration(std::string &forcesfile); 17 16 18 class MoleculeVerletIntegrationAction : public Action { 19 friend void MoleculeVerletIntegration(std::string &forcesfile); 20 17 21 public: 18 22 MoleculeVerletIntegrationAction(); … … 24 28 virtual const std::string getName(); 25 29 private: 30 virtual Dialog * createDialog(); 26 31 virtual Action::state_ptr performCall(); 27 32 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/ParserAction/LoadXyzAction.cpp
r7067bd6 r677e13 11 11 12 12 #include "Actions/ParserAction/LoadXyzAction.hpp" 13 #include "Actions/ActionRegistry.hpp" 13 14 #include "Parser/XyzParser.hpp" 15 #include "atom.hpp" 16 #include "log.hpp" 17 #include "molecule.hpp" 18 #include "verbose.hpp" 19 #include "World.hpp" 14 20 15 21 #include <iostream> … … 18 24 #include <vector> 19 25 20 21 26 #include "UIElements/UIFactory.hpp" 22 27 #include "UIElements/Dialog.hpp" 23 #include "Actions/MapOfActions.hpp" 24 25 #include "atom.hpp" 26 #include "log.hpp" 27 #include "molecule.hpp" 28 #include "verbose.hpp" 29 #include "World.hpp" 28 #include "UIElements/ValueStorage.hpp" 30 29 31 30 /****** ParserLoadXyzAction *****/ … … 52 51 {} 53 52 53 void ParserLoadXyz(std::string &filename) { 54 ValueStorage::getInstance().setCurrentValue(ParserLoadXyzAction::NAME, filename); 55 ActionRegistry::getInstance().getActionByName(ParserLoadXyzAction::NAME)->call(Action::NonInteractive); 56 }; 57 58 Dialog* ParserLoadXyzAction::createDialog() { 59 Dialog *dialog = UIFactory::getInstance().makeDialog(); 60 61 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 62 63 return dialog; 64 } 65 54 66 Action::state_ptr ParserLoadXyzAction::performCall() { 55 67 string filename; 56 Dialog *dialog = UIFactory::getInstance().makeDialog();57 68 58 dialog->queryString(NAME,&filename, NAME);69 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 59 70 60 if(dialog->display()) { 61 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl); 62 // parse xyz file 63 ifstream input; 64 input.open(filename.c_str()); 65 if (!input.fail()) { 66 // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include 67 set <atom*> UniqueList; 68 { 69 vector<atom *> ListBefore = World::getInstance().getAllAtoms(); 70 for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner) 71 UniqueList.insert(*runner); 71 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl); 72 // parse xyz file 73 ifstream input; 74 input.open(filename.c_str()); 75 if (!input.fail()) { 76 // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include 77 set <atom*> UniqueList; 78 { 79 vector<atom *> ListBefore = World::getInstance().getAllAtoms(); 80 for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner) 81 UniqueList.insert(*runner); 82 } 83 XyzParser parser; // briefly instantiate a parser which is removed at end of focus 84 parser.load(&input); 85 { 86 vector<atom *> ListAfter = World::getInstance().getAllAtoms(); 87 pair< set<atom *>::iterator, bool > Inserter; 88 if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed 89 MoleculeListClass *molecules = World::getInstance().getMolecules(); 90 molecule *mol = World::getInstance().createMolecule(); 91 molecules->insert(mol); 92 for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) { 93 Inserter = UniqueList.insert(*runner); 94 if (Inserter.second) { // if not present, then new (just parsed) atom, add ... 95 cout << "Adding new atom " << **runner << " to new mol." << endl; 96 mol->AddAtom(*runner); 97 } 98 } 99 mol->doCountAtoms(); 100 } else { 101 cout << "No atoms parsed?" << endl; 72 102 } 73 XyzParser parser; // briefly instantiate a parser which is removed at end of focus74 parser.load(&input);75 {76 vector<atom *> ListAfter = World::getInstance().getAllAtoms();77 pair< set<atom *>::iterator, bool > Inserter;78 if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed79 MoleculeListClass *molecules = World::getInstance().getMolecules();80 molecule *mol = World::getInstance().createMolecule();81 molecules->insert(mol);82 for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) {83 Inserter = UniqueList.insert(*runner);84 if (Inserter.second) { // if not present, then new (just parsed) atom, add ...85 cout << "Adding new atom " << **runner << " to new mol." << endl;86 mol->AddAtom(*runner);87 }88 }89 mol->doCountAtoms();90 } else {91 cout << "No atoms parsed?" << endl;92 }93 }94 } else {95 DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);96 103 } 97 input.close(); 104 } else { 105 DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl); 98 106 } 99 delete dialog;100 return Action:: failure;107 input.close(); 108 return Action::success; 101 109 } 102 110 -
src/Actions/ParserAction/LoadXyzAction.hpp
r7067bd6 r677e13 12 12 #include "Actions/Process.hpp" 13 13 14 void ParserLoadXyz(std::string &filename); 15 14 16 class ParserLoadXyzAction : public Action { 17 friend void ParserLoadXyz(std::string &filename); 18 15 19 public: 16 20 ParserLoadXyzAction(); … … 22 26 virtual const std::string getName(); 23 27 private: 28 virtual Dialog * createDialog(); 24 29 virtual Action::state_ptr performCall(); 25 30 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/ParserAction/SaveXyzAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/ParserAction/SaveXyzAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "Parser/XyzParser.hpp" 13 #include "atom.hpp" 14 #include "molecule.hpp" 12 15 13 16 #include <iostream> … … 18 21 #include "UIElements/UIFactory.hpp" 19 22 #include "UIElements/Dialog.hpp" 20 #include " Actions/MapOfActions.hpp"23 #include "UIElements/ValueStorage.hpp" 21 24 22 #include "atom.hpp"23 #include "molecule.hpp"24 25 25 26 /****** ParserSaveXyzAction *****/ … … 46 47 {} 47 48 49 void ParserSaveXyz(std::string &filename) { 50 ValueStorage::getInstance().setCurrentValue(ParserSaveXyzAction::NAME, filename); 51 ActionRegistry::getInstance().getActionByName(ParserSaveXyzAction::NAME)->call(Action::NonInteractive); 52 }; 53 54 Dialog* ParserSaveXyzAction::createDialog() { 55 Dialog *dialog = UIFactory::getInstance().makeDialog(); 56 57 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 58 59 return dialog; 60 } 61 48 62 Action::state_ptr ParserSaveXyzAction::performCall() { 49 63 string filename; 50 64 XyzParser parser; 51 Dialog *dialog = UIFactory::getInstance().makeDialog();52 65 53 dialog->queryString("filename",&filename, "Filename of the xyz file");66 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 54 67 55 if(dialog->display()) { 56 // store xyz file 57 ofstream output; 58 output.open(filename.c_str()); 59 if (!output.fail()) 60 parser.save(&output); 61 output.close(); 62 } 63 delete dialog; 68 // store xyz file 69 ofstream output; 70 output.open(filename.c_str()); 71 if (!output.fail()) 72 parser.save(&output); 73 output.close(); 64 74 return Action::failure; 65 75 } -
src/Actions/ParserAction/SaveXyzAction.hpp
r7067bd6 r677e13 12 12 #include "Actions/Process.hpp" 13 13 14 void ParserSaveXyz(std::string &filename); 15 14 16 class ParserSaveXyzAction : public Action { 17 friend void ParserSaveXyz(std::string &filename); 18 15 19 public: 16 20 ParserSaveXyzAction(); … … 22 26 virtual const std::string getName(); 23 27 private: 28 virtual Dialog * createDialog(); 24 29 virtual Action::state_ptr performCall(); 25 30 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/TesselationAction/ConvexEnvelopeAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/TesselationAction/ConvexEnvelopeAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "boundary.hpp" 13 #include "config.hpp" 14 #include "linkedcell.hpp" 15 #include "log.hpp" 16 #include "molecule.hpp" 17 #include "verbose.hpp" 18 #include "World.hpp" 11 19 12 20 #include <iostream> … … 17 25 #include "UIElements/UIFactory.hpp" 18 26 #include "UIElements/Dialog.hpp" 19 #include "Actions/MapOfActions.hpp" 20 21 #include "atom.hpp" 22 #include "boundary.hpp" 23 #include "config.hpp" 24 #include "linkedcell.hpp" 25 #include "log.hpp" 26 #include "molecule.hpp" 27 #include "verbose.hpp" 28 #include "World.hpp" 27 #include "UIElements/ValueStorage.hpp" 29 28 30 29 /****** TesselationConvexEnvelopeAction *****/ … … 51 50 {} 52 51 52 void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex) { 53 ValueStorage::getInstance().setCurrentValue("convex-file", filenameConvex); 54 ValueStorage::getInstance().setCurrentValue("nonconvex-file", filenameConvex); 55 ActionRegistry::getInstance().getActionByName(TesselationConvexEnvelopeAction::NAME)->call(Action::NonInteractive); 56 }; 57 58 Dialog* TesselationConvexEnvelopeAction::createDialog() { 59 Dialog *dialog = UIFactory::getInstance().makeDialog(); 60 61 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 62 dialog->queryString("convex-file", ValueStorage::getInstance().getDescription("convex-file")); 63 dialog->queryString("nonconvex-file", ValueStorage::getInstance().getDescription("nonconvex-file")); 64 65 return dialog; 66 } 67 53 68 Action::state_ptr TesselationConvexEnvelopeAction::performCall() { 54 69 string filenameConvex; 55 70 string filenameNonConvex; 56 Dialog *dialog = UIFactory::getInstance().makeDialog();57 71 molecule * mol = NULL; 58 bool Success = false;72 bool Success = true; 59 73 config *configuration = World::getInstance().getConfig(); 60 74 61 dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME)); 62 dialog->queryString("convex-file", &filenameConvex, MapOfActions::getInstance().getDescription("convex-file")); 63 dialog->queryString("nonconvex-file", &filenameNonConvex, MapOfActions::getInstance().getDescription("nonconvex-file")); 75 ValueStorage::getInstance().queryCurrentValue("convex-file", filenameConvex); 76 ValueStorage::getInstance().queryCurrentValue("nonconvex-file", filenameNonConvex); 64 77 65 if(dialog->display()) { 78 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 79 mol = iter->second; 66 80 class Tesselation *TesselStruct = NULL; 67 81 const LinkedCell *LCList = NULL; … … 81 95 delete(TesselStruct); 82 96 delete(LCList); 83 delete dialog;84 if (Success)85 return Action::success;86 else87 return Action::failure;88 97 } 89 delete dialog; 90 return Action::failure; 98 if (Success) 99 return Action::success; 100 else 101 return Action::failure; 91 102 } 92 103 -
src/Actions/TesselationAction/ConvexEnvelopeAction.hpp
r7067bd6 r677e13 14 14 class TesselationListClass; 15 15 16 void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex); 17 16 18 class TesselationConvexEnvelopeAction : public Action { 19 friend void TesselationConvexEnvelope(std::string &filenameConvex, std::string &filenameNonConvex); 20 17 21 public: 18 22 TesselationConvexEnvelopeAction(); … … 24 28 virtual const std::string getName(); 25 29 private: 30 virtual Dialog * createDialog(); 26 31 virtual Action::state_ptr performCall(); 27 32 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/TesselationAction/NonConvexEnvelopeAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "boundary.hpp" 13 #include "linkedcell.hpp" 14 #include "log.hpp" 15 #include "molecule.hpp" 16 #include "verbose.hpp" 17 #include "World.hpp" 11 18 12 19 #include <iostream> … … 17 24 #include "UIElements/UIFactory.hpp" 18 25 #include "UIElements/Dialog.hpp" 19 #include "Actions/MapOfActions.hpp" 20 21 #include "atom.hpp" 22 #include "boundary.hpp" 23 #include "linkedcell.hpp" 24 #include "log.hpp" 25 #include "molecule.hpp" 26 #include "verbose.hpp" 27 #include "World.hpp" 26 #include "UIElements/ValueStorage.hpp" 28 27 29 28 /****** TesselationNonConvexEnvelopeAction *****/ … … 50 49 {} 51 50 51 void TesselationNonConvexEnvelope(double radius, std::string &filename) { 52 ValueStorage::getInstance().setCurrentValue(TesselationNonConvexEnvelopeAction::NAME, radius); 53 ValueStorage::getInstance().setCurrentValue("nonconvex-file", filename); 54 ActionRegistry::getInstance().getActionByName(TesselationNonConvexEnvelopeAction::NAME)->call(Action::NonInteractive); 55 }; 56 57 Dialog* TesselationNonConvexEnvelopeAction::createDialog() { 58 Dialog *dialog = UIFactory::getInstance().makeDialog(); 59 60 dialog->queryDouble(NAME, MapOfActions::getInstance().getDescription(NAME)); 61 dialog->queryString("nonconvex-file", MapOfActions::getInstance().getDescription("nonconvex-file")); 62 63 return dialog; 64 } 65 52 66 Action::state_ptr TesselationNonConvexEnvelopeAction::performCall() { 53 67 string filename; 54 Dialog *dialog = UIFactory::getInstance().makeDialog();55 68 molecule * Boundary = NULL; 56 69 double SphereRadius = 0; … … 58 71 clock_t start,end; 59 72 60 dialog->queryMolecule(NAME, &Boundary, MapOfActions::getInstance().getDescription(NAME)); 61 dialog->queryString("nonconvex-file", &filename, MapOfActions::getInstance().getDescription("nonconvex-file")); 62 dialog->queryDouble("sphere-radius", &SphereRadius, MapOfActions::getInstance().getDescription("sphere-radius")); 73 ValueStorage::getInstance().queryCurrentValue(NAME, SphereRadius); 74 ValueStorage::getInstance().queryCurrentValue("nonconvex-file", filename); 63 75 64 if(dialog->display()) { 76 for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) { 77 Boundary = iter->second; 65 78 class Tesselation *T = NULL; 66 79 const LinkedCell *LCList = NULL; … … 76 89 delete(LCList); 77 90 delete(T); 78 delete dialog;79 if (Success)80 return Action::success;81 else82 return Action::failure;83 91 } 84 delete dialog; 85 return Action::failure; 92 if (Success) 93 return Action::success; 94 else 95 return Action::failure; 86 96 } 87 97 -
src/Actions/TesselationAction/NonConvexEnvelopeAction.hpp
r7067bd6 r677e13 14 14 class TesselationListClass; 15 15 16 void TesselationNonConvexEnvelope(double radius, std::string &filename); 17 16 18 class TesselationNonConvexEnvelopeAction : public Action { 19 friend void TesselationNonConvexEnvelope(double radius, std::string &filename); 20 17 21 public: 18 22 TesselationNonConvexEnvelopeAction(); … … 24 28 virtual const std::string getName(); 25 29 private: 30 virtual Dialog * createDialog(); 26 31 virtual Action::state_ptr performCall(); 27 32 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/Values.hpp
r7067bd6 r677e13 19 19 { 20 20 double xx; 21 double xy; 22 double xz; 21 double yx; 23 22 double yy; 24 double yz; 23 double zx; 24 double zy; 25 25 double zz; 26 26 }; -
src/Actions/WorldAction/AddEmptyBoundaryAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/WorldAction/AddEmptyBoundaryAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "log.hpp" … … 22 23 #include "UIElements/UIFactory.hpp" 23 24 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 25 26 #include "Helpers/Assert.hpp" 26 27 … … 34 35 {} 35 36 37 void WorldAddEmptyBoundary(Vector &boundary) { 38 ValueStorage::getInstance().setCurrentValue(WorldAddEmptyBoundaryAction::NAME, boundary); 39 ActionRegistry::getInstance().getActionByName(WorldAddEmptyBoundaryAction::NAME)->call(Action::NonInteractive); 40 }; 41 42 Dialog* WorldAddEmptyBoundaryAction::createDialog() { 43 Dialog *dialog = UIFactory::getInstance().makeDialog(); 44 45 dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME)); 46 47 return dialog; 48 } 49 36 50 Action::state_ptr WorldAddEmptyBoundaryAction::performCall() { 37 Dialog *dialog = UIFactory::getInstance().makeDialog();38 51 Vector boundary; 39 52 Vector Min; … … 41 54 int j=0; 42 55 43 dialog->queryVector(NAME, &boundary, false, MapOfActions::getInstance().getDescription(NAME));56 ValueStorage::getInstance().queryCurrentValue(NAME, boundary); 44 57 45 if(dialog->display()) { 46 // get maximum and minimum 47 vector<atom *> AllAtoms = World::getInstance().getAllAtoms(); 48 ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary."); 49 vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 50 Min = (*AtomRunner)->x; 51 Max = (*AtomRunner)->x; 52 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { 53 for (int i=0;i<NDIM;i++) { 54 if ((*AtomRunner)->x[i] > Max[i]) 55 Max[i] = (*AtomRunner)->x[i]; 56 if ((*AtomRunner)->x[i] < Min[i]) 57 Min[i] = (*AtomRunner)->x[i]; 58 } 58 // get maximum and minimum 59 vector<atom *> AllAtoms = World::getInstance().getAllAtoms(); 60 ASSERT(AllAtoms.size() > 0, "There must be atoms present for AddingEmptyBoundary."); 61 vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 62 Min = (*AtomRunner)->x; 63 Max = (*AtomRunner)->x; 64 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { 65 for (int i=0;i<NDIM;i++) { 66 if ((*AtomRunner)->x[i] > Max[i]) 67 Max[i] = (*AtomRunner)->x[i]; 68 if ((*AtomRunner)->x[i] < Min[i]) 69 Min[i] = (*AtomRunner)->x[i]; 59 70 } 60 // set new box size61 double * const cell_size = new double[6];62 for (j=0;j<6;j++)63 cell_size[j] = 0.;64 j=-1;65 for (int i=0;i<NDIM;i++) {66 j += i+1;67 cell_size[j] = (Max[i]-Min[i]+2.*boundary[i]);68 }69 World::getInstance().setDomain(cell_size);70 delete[] cell_size;71 // translate all atoms, such that Min is aty (0,0,0)72 AtomRunner = AllAtoms.begin();73 for (; AtomRunner != AllAtoms.end(); ++AtomRunner)74 (*AtomRunner)->x -= Min - boundary;75 delete dialog;76 return Action::success;77 } else {78 delete dialog;79 return Action::failure;80 71 } 72 // set new box size 73 double * const cell_size = new double[6]; 74 for (j=0;j<6;j++) 75 cell_size[j] = 0.; 76 j=-1; 77 for (int i=0;i<NDIM;i++) { 78 j += i+1; 79 cell_size[j] = (Max[i]-Min[i]+2.*boundary[i]); 80 } 81 World::getInstance().setDomain(cell_size); 82 delete[] cell_size; 83 // translate all atoms, such that Min is aty (0,0,0) 84 AtomRunner = AllAtoms.begin(); 85 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) 86 (*AtomRunner)->x -= Min - boundary; 87 return Action::success; 81 88 } 82 89 -
src/Actions/WorldAction/AddEmptyBoundaryAction.hpp
r7067bd6 r677e13 10 10 11 11 #include "Actions/Action.hpp" 12 #include "vector.hpp" 13 14 void WorldAddEmptyBoundary(Vector &boundary); 12 15 13 16 class WorldAddEmptyBoundaryAction : public Action { 17 friend void WorldAddEmptyBoundary(Vector &boundary); 18 14 19 public: 15 20 WorldAddEmptyBoundaryAction(); … … 21 26 virtual const std::string getName(); 22 27 private: 28 virtual Dialog * createDialog(); 23 29 virtual Action::state_ptr performCall(); 24 30 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/WorldAction/BoundInBoxAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/WorldAction/BoundInBoxAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "log.hpp" 12 13 #include "molecule.hpp" … … 21 22 #include "UIElements/UIFactory.hpp" 22 23 #include "UIElements/Dialog.hpp" 23 #include " Actions/MapOfActions.hpp"24 #include "UIElements/ValueStorage.hpp" 24 25 25 26 const char WorldBoundInBoxAction::NAME[] = "bound-in-box"; … … 32 33 {} 33 34 34 Action::state_ptr WorldBoundInBoxAction::performCall() { 35 void WorldBoundInBox() { 36 ActionRegistry::getInstance().getActionByName(WorldBoundInBoxAction::NAME)->call(Action::NonInteractive); 37 }; 38 39 Dialog* WorldBoundInBoxAction::createDialog() { 35 40 Dialog *dialog = UIFactory::getInstance().makeDialog(); 36 41 37 dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));42 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 38 43 39 if(dialog->display()) { 40 // center 41 vector<molecule*> AllMolecules = World::getInstance().getAllMolecules(); 42 for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 43 (*MolRunner)->BoundInBox(); 44 } 45 delete dialog; 46 return Action::success; 47 } else { 48 delete dialog; 49 return Action::failure; 44 return dialog; 45 } 46 47 Action::state_ptr WorldBoundInBoxAction::performCall() { 48 49 // center 50 vector<molecule*> AllMolecules = World::getInstance().getAllMolecules(); 51 for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 52 (*MolRunner)->BoundInBox(); 50 53 } 54 return Action::success; 51 55 } 52 56 -
src/Actions/WorldAction/BoundInBoxAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void WorldBoundInBox(); 14 13 15 class WorldBoundInBoxAction : public Action { 16 friend void WorldBoundInBox(); 17 14 18 public: 15 19 WorldBoundInBoxAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/WorldAction/CenterInBoxAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/WorldAction/CenterInBoxAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "Box.hpp" 11 13 #include "log.hpp" 12 14 #include "molecule.hpp" … … 20 22 #include "UIElements/UIFactory.hpp" 21 23 #include "UIElements/Dialog.hpp" 22 #include " Actions/MapOfActions.hpp"24 #include "UIElements/ValueStorage.hpp" 23 25 24 26 const char WorldCenterInBoxAction::NAME[] = "center-in-box"; … … 31 33 {} 32 34 33 Action::state_ptr WorldCenterInBoxAction::performCall() { 35 void WorldCenterInBox(Box &_box) { 36 ValueStorage::getInstance().setCurrentValue(WorldCenterInBoxAction::NAME, _box); 37 ActionRegistry::getInstance().getActionByName(WorldCenterInBoxAction::NAME)->call(Action::NonInteractive); 38 }; 39 40 Dialog* WorldCenterInBoxAction::createDialog() { 34 41 Dialog *dialog = UIFactory::getInstance().makeDialog(); 35 42 43 dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME)); 44 45 return dialog; 46 } 47 48 Action::state_ptr WorldCenterInBoxAction::performCall() { 49 36 50 Box& cell_size = World::getInstance().getDomain(); 37 dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME)); 51 ValueStorage::getInstance().queryCurrentValue(NAME, cell_size); 52 World::getInstance().setDomain(cell_size.getM()); 38 53 39 if(dialog->display()) { 40 // center 41 vector<molecule *> AllMolecules = World::getInstance().getAllMolecules(); 42 for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 43 (*MolRunner)->CenterInBox(); 44 } 45 delete dialog; 46 return Action::success; 47 } else { 48 delete dialog; 49 return Action::failure; 54 // center 55 vector<molecule *> AllMolecules = World::getInstance().getAllMolecules(); 56 for (vector<molecule*>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 57 (*MolRunner)->CenterInBox(); 50 58 } 59 return Action::success; 51 60 } 52 61 -
src/Actions/WorldAction/CenterInBoxAction.hpp
r7067bd6 r677e13 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Box.hpp" 13 14 void WorldCenterInBox(Box &_box); 12 15 13 16 class WorldCenterInBoxAction : public Action { 17 friend void WorldCenterInBox(Box &_box); 18 14 19 public: 15 20 WorldCenterInBoxAction(); … … 21 26 virtual const std::string getName(); 22 27 private: 28 virtual Dialog * createDialog(); 23 29 virtual Action::state_ptr performCall(); 24 30 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/WorldAction/CenterOnEdgeAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/WorldAction/CenterOnEdgeAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "log.hpp" … … 22 23 #include "UIElements/UIFactory.hpp" 23 24 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 25 26 #include "Helpers/Assert.hpp" 26 27 … … 34 35 {} 35 36 37 void WorldCenterOnEdge() { 38 ActionRegistry::getInstance().getActionByName(WorldCenterOnEdgeAction::NAME)->call(Action::NonInteractive); 39 }; 40 41 Dialog* WorldCenterOnEdgeAction::createDialog() { 42 Dialog *dialog = UIFactory::getInstance().makeDialog(); 43 44 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 45 46 return dialog; 47 } 48 36 49 Action::state_ptr WorldCenterOnEdgeAction::performCall() { 37 Dialog *dialog = UIFactory::getInstance().makeDialog();38 50 Vector Min; 39 51 Vector Max; 40 52 41 dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME)); 53 // get maximum and minimum 54 vector<atom *> AllAtoms = World::getInstance().getAllAtoms(); 55 ASSERT(AllAtoms.size() > 0, "For CenteronEdge atoms must be present."); 56 vector<atom *>::iterator AtomRunner = AllAtoms.begin(); 57 Min = (*AtomRunner)->x; 58 Max = (*AtomRunner)->x; 59 for (; AtomRunner != AllAtoms.end(); ++AtomRunner) { 60 for (int i=0;i<NDIM;i++) { 61 if ((*AtomRunner)->x[i] > Max[i]) 62 Max[i] = (*AtomRunner)->x[i]; 63 if ((*AtomRunner)->x[i] < Min[i]) 64 Min[i] = (*AtomRunner)->x[i]; 65 } 66 } 67 // set new box size 68 Matrix domain; 69 for (int i=0;i<NDIM;i++) { 70 double tmp = Max[i]-Min[i]; 71 tmp = fabs(tmp)>=1. ? tmp : 1.0; 72 domain.at(i,i) = tmp; 73 } 74 World::getInstance().setDomain(domain); 75 // translate all atoms, such that Min is aty (0,0,0) 76 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) 77 (*AtomRunner)->x -= Min; 42 78 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 } 79 return Action::success; 75 80 } 76 81 -
src/Actions/WorldAction/CenterOnEdgeAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void WorldCenterOnEdge(); 14 13 15 class WorldCenterOnEdgeAction : public Action { 16 friend void WorldCenterOnEdge(); 17 14 18 public: 15 19 WorldCenterOnEdgeAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/WorldAction/ChangeBoxAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/WorldAction/ChangeBoxAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "log.hpp" 12 13 #include "verbose.hpp" … … 22 23 #include "UIElements/UIFactory.hpp" 23 24 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 25 26 26 27 const char WorldChangeBoxAction::NAME[] = "change-box"; … … 33 34 {} 34 35 35 Action::state_ptr WorldChangeBoxAction::performCall() { 36 void WorldChangeBox(Box &_box) { 37 ValueStorage::getInstance().setCurrentValue(WorldChangeBoxAction::NAME, _box); 38 ActionRegistry::getInstance().getActionByName(WorldChangeBoxAction::NAME)->call(Action::NonInteractive); 39 }; 40 41 Dialog* WorldChangeBoxAction::createDialog() { 36 42 Dialog *dialog = UIFactory::getInstance().makeDialog(); 37 43 38 Box& cell_size = World::getInstance().getDomain(); 39 dialog->queryBox(NAME, &cell_size, MapOfActions::getInstance().getDescription(NAME)); 44 dialog->queryBox(NAME, ValueStorage::getInstance().getDescription(NAME)); 40 45 41 if(dialog->display()) { 42 DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << cell_size.getM() << endl); 43 World::getInstance().setDomain(cell_size.getM()); 44 delete dialog; 45 return Action::success; 46 } else { 47 delete dialog; 48 return Action::failure; 49 } 46 return dialog; 47 } 48 49 Action::state_ptr WorldChangeBoxAction::performCall() { 50 51 Box cell_size; 52 ValueStorage::getInstance().queryCurrentValue(NAME, cell_size); 53 World::getInstance().setDomain(cell_size.getM()); // this is needed as only this function is OBSERVEd. 54 55 DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << World::getInstance().getDomain().getM() << endl); 56 return Action::success; 50 57 } 51 58 -
src/Actions/WorldAction/ChangeBoxAction.hpp
r7067bd6 r677e13 10 10 11 11 #include "Actions/Action.hpp" 12 #include "Box.hpp" 13 14 void WorldChangeBox(Box &_box); 12 15 13 16 class WorldChangeBoxAction : public Action { 17 friend void WorldChangeBox(Box &_box); 18 14 19 public: 15 20 WorldChangeBoxAction(); … … 21 26 virtual const std::string getName(); 22 27 private: 28 virtual Dialog * createDialog(); 23 29 virtual Action::state_ptr performCall(); 24 30 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/WorldAction/InputAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/WorldAction/InputAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "log.hpp" 12 13 #include "molecule.hpp" … … 23 24 #include "UIElements/UIFactory.hpp" 24 25 #include "UIElements/Dialog.hpp" 25 #include " Actions/MapOfActions.hpp"26 #include "UIElements/ValueStorage.hpp" 26 27 27 28 const char WorldInputAction::NAME[] = "input"; … … 34 35 {} 35 36 37 void WorldInput(std::string &filename) { 38 ValueStorage::getInstance().setCurrentValue(WorldInputAction::NAME, filename); 39 ActionRegistry::getInstance().getActionByName(WorldInputAction::NAME)->call(Action::NonInteractive); 40 }; 41 42 Dialog* WorldInputAction::createDialog() { 43 Dialog *dialog = UIFactory::getInstance().makeDialog(); 44 45 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 46 47 return dialog; 48 } 49 36 50 Action::state_ptr WorldInputAction::performCall() { 37 Dialog *dialog = UIFactory::getInstance().makeDialog();38 51 MoleculeListClass *molecules = World::getInstance().getMolecules(); 39 52 molecule *mol = NULL; … … 41 54 std::ifstream test; 42 55 43 dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));56 ValueStorage::getInstance().queryCurrentValue(NAME, filename); 44 57 45 if(dialog->display()) { 46 DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl); 47 if (filename.find('.') != string::npos) { 48 std::string FilenamePrefix = filename.substr(0,filename.find_last_of('.')); 49 std::string FilenameSuffix = filename.substr(filename.find_last_of('.')+1, filename.length()); 50 DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << FilenamePrefix << "." << endl); 51 test.open(filename.c_str()); 52 if (test == NULL) { 53 DoLog(1) && (Log() << Verbose(1) << "Specified config file " << filename << " not found." << endl); 54 } else { 55 DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... "); 56 FormatParserStorage::getInstance().get((std::istream &)test, FilenameSuffix); 57 test.close(); 58 } 59 FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix); 60 // set mol to first active molecule 61 if (molecules->ListOfMolecules.size() != 0) { 62 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 63 if ((*ListRunner)->ActiveFlag) { 64 mol = *ListRunner; 65 break; 66 } 67 } 68 if (mol == NULL) { 69 mol = World::getInstance().createMolecule(); 70 mol->ActiveFlag = true; 71 molecules->insert(mol); 72 } 73 mol->SetNameFromFilename(filename.substr(0,filename.find('.')).c_str()); 58 DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl); 59 if (filename.find('.') != string::npos) { 60 std::string FilenamePrefix = filename.substr(0,filename.find_last_of('.')); 61 std::string FilenameSuffix = filename.substr(filename.find_last_of('.')+1, filename.length()); 62 DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << FilenamePrefix << "." << endl); 63 test.open(filename.c_str()); 64 if (test == NULL) { 65 DoLog(1) && (Log() << Verbose(1) << "Specified config file " << filename << " not found." << endl); 74 66 } else { 75 DoeLog(1) && (eLog() << Verbose(1) << "Input file does not have a suffix, cannot recognize format." << endl); 67 DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... "); 68 FormatParserStorage::getInstance().get((std::istream &)test, FilenameSuffix); 69 test.close(); 76 70 } 77 delete dialog; 78 return Action::success; 71 FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix); 72 // set mol to first active molecule 73 if (molecules->ListOfMolecules.size() != 0) { 74 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 75 if ((*ListRunner)->ActiveFlag) { 76 mol = *ListRunner; 77 break; 78 } 79 } 80 if (mol == NULL) { 81 mol = World::getInstance().createMolecule(); 82 mol->ActiveFlag = true; 83 molecules->insert(mol); 84 } 85 mol->SetNameFromFilename(filename.substr(0,filename.find('.')).c_str()); 79 86 } else { 80 delete dialog; 81 return Action::failure; 87 DoeLog(1) && (eLog() << Verbose(1) << "Input file does not have a suffix, cannot recognize format." << endl); 82 88 } 89 return Action::success; 83 90 } 84 91 -
src/Actions/WorldAction/InputAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void WorldInput(std::string &filename); 14 13 15 class WorldInputAction : public Action { 16 friend void WorldInput(std::string &filename); 17 14 18 public: 15 19 WorldInputAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/WorldAction/OutputAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/WorldAction/OutputAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "Parser/ChangeTracker.hpp" 12 13 #include "log.hpp" … … 21 22 #include "UIElements/UIFactory.hpp" 22 23 #include "UIElements/Dialog.hpp" 23 #include " Actions/MapOfActions.hpp"24 #include "UIElements/ValueStorage.hpp" 24 25 25 26 const char WorldOutputAction::NAME[] = "output"; … … 32 33 {} 33 34 34 Action::state_ptr WorldOutputAction::performCall() { 35 void WorldOutput() { 36 ActionRegistry::getInstance().getActionByName(WorldOutputAction::NAME)->call(Action::NonInteractive); 37 }; 38 39 Dialog* WorldOutputAction::createDialog() { 35 40 Dialog *dialog = UIFactory::getInstance().makeDialog(); 36 41 37 dialog->queryEmpty(NAME, MapOfActions::getInstance().getDescription(NAME));42 dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME)); 38 43 39 if(dialog->display()) { 40 DoLog(0) && (Log() << Verbose(0) << "Saving world to files." << endl); 41 ChangeTracker::getInstance().saveStatus(); 42 delete dialog; 43 return Action::success; 44 } else { 45 delete dialog; 46 return Action::failure; 47 } 44 return dialog; 45 } 46 47 Action::state_ptr WorldOutputAction::performCall() { 48 49 DoLog(0) && (Log() << Verbose(0) << "Saving world to files." << endl); 50 ChangeTracker::getInstance().saveStatus(); 51 return Action::success; 48 52 } 49 53 -
src/Actions/WorldAction/OutputAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void WorldOutput(); 14 13 15 class WorldOutputAction : public Action { 16 friend void WorldOutput(); 17 14 18 public: 15 19 WorldOutputAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 12 #include "Descriptors/AtomDescriptor.hpp" 11 13 #include "atom.hpp" 12 #include "Descriptors/AtomDescriptor.hpp"13 14 #include "log.hpp" 14 15 #include "molecule.hpp" … … 24 25 #include "UIElements/UIFactory.hpp" 25 26 #include "UIElements/Dialog.hpp" 26 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 27 28 28 29 const char WorldRemoveSphereOfAtomsAction::NAME[] = "remove-sphere"; … … 35 36 {} 36 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::createDialog() { 45 Dialog *dialog = UIFactory::getInstance().makeDialog(); 46 47 dialog->queryDouble(NAME, ValueStorage::getInstance().getDescription(NAME)); 48 dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position")); 49 50 return dialog; 51 } 52 37 53 Action::state_ptr WorldRemoveSphereOfAtomsAction::performCall() { 38 Dialog *dialog = UIFactory::getInstance().makeDialog();39 54 double radius = 0.; 40 55 Vector point; 41 56 42 dialog->queryDouble(NAME, &radius, MapOfActions::getInstance().getDescription(NAME));43 dialog->queryVector("position", &point, false, MapOfActions::getInstance().getDescription("position"));57 ValueStorage::getInstance().queryCurrentValue(NAME, radius); 58 ValueStorage::getInstance().queryCurrentValue("position", point); 44 59 45 if(dialog->display()) { 46 delete dialog; 47 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl); 48 vector<atom*> AllAtoms = World::getInstance().getAllAtoms(); 49 vector<molecule *> molecules = World::getInstance().getAllMolecules(); 50 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { 51 if (point.DistanceSquared((*AtomRunner)->x) > radius*radius) { // distance to first above radius ... 52 // TODO: This is not necessary anymore when atoms are completely handled by World (create/destroy and load/save) 53 for (vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end();++iter) 54 (*iter)->erase(*AtomRunner); 55 World::getInstance().destroyAtom(*AtomRunner); 56 } 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); 57 69 } 58 return Action::success;59 } else {60 delete dialog;61 return Action::failure;62 70 } 63 71 return Action::success; 64 72 } 65 73 -
src/Actions/WorldAction/RemoveSphereOfAtomsAction.hpp
r7067bd6 r677e13 10 10 11 11 #include "Actions/Action.hpp" 12 #include "vector.hpp" 13 14 15 void WorldRemoveSphereOfAtoms(double radius, Vector &point); 12 16 13 17 class WorldRemoveSphereOfAtomsAction : public Action { 18 friend void WorldRemoveSphereOfAtoms(double radius, Vector &point); 19 14 20 public: 15 21 WorldRemoveSphereOfAtomsAction(); … … 21 27 virtual const std::string getName(); 22 28 private: 29 virtual Dialog * createDialog(); 23 30 virtual Action::state_ptr performCall(); 24 31 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/WorldAction/RepeatBoxAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/WorldAction/RepeatBoxAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "log.hpp" … … 25 26 #include "UIElements/UIFactory.hpp" 26 27 #include "UIElements/Dialog.hpp" 27 #include " Actions/MapOfActions.hpp"28 #include "UIElements/ValueStorage.hpp" 28 29 #include "Descriptors/MoleculeDescriptor.hpp" 29 30 #include "Descriptors/MoleculePtrDescriptor.hpp" … … 38 39 {} 39 40 41 void WorldRepeatBox(Vector &Repeater) { 42 ValueStorage::getInstance().setCurrentValue(WorldRepeatBoxAction::NAME, Repeater); 43 ActionRegistry::getInstance().getActionByName(WorldRepeatBoxAction::NAME)->call(Action::NonInteractive); 44 }; 45 46 Dialog * WorldRepeatBoxAction::createDialog() { 47 Dialog *dialog = UIFactory::getInstance().makeDialog(); 48 49 dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME)); 50 51 return dialog; 52 } 53 40 54 Action::state_ptr WorldRepeatBoxAction::performCall() { 41 Dialog *dialog = UIFactory::getInstance().makeDialog();42 55 Vector Repeater; 43 56 int count; … … 48 61 MoleculeListClass *molecules = World::getInstance().getMolecules(); 49 62 50 dialog->queryVector(NAME, &Repeater, false, MapOfActions::getInstance().getDescription(NAME));51 //dialog->queryMolecule("molecule-by-id", &mol,MapOfActions::getInstance().getDescription("molecule-by-id")); 63 ValueStorage::getInstance().queryCurrentValue(NAME, Repeater); 64 52 65 vector<molecule *> AllMolecules; 53 66 if (mol != NULL) { … … 59 72 } 60 73 61 if(dialog->display()) { 62 (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl); 63 Matrix M = World::getInstance().getDomain().getM(); 64 Matrix newM = M; 65 Vector x,y; 66 int n[NDIM]; 67 Matrix repMat; 68 for (int axis = 0; axis < NDIM; axis++) { 69 Repeater[axis] = floor(Repeater[axis]); 70 if (Repeater[axis] < 1) { 71 DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor must be greater than 1!" << endl); 72 Repeater[axis] = 1; 73 } 74 repMat.at(axis,axis) = Repeater[axis]; 74 (cout << "Repeating box " << Repeater << " times for (x,y,z) axis." << endl); 75 Matrix M = World::getInstance().getDomain().getM(); 76 Matrix newM = M; 77 Vector x,y; 78 int n[NDIM]; 79 Matrix repMat; 80 for (int axis = 0; axis < NDIM; axis++) { 81 Repeater[axis] = floor(Repeater[axis]); 82 if (Repeater[axis] < 1) { 83 DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor must be greater than 1!" << endl); 84 Repeater[axis] = 1; 75 85 } 76 newM *= repMat; 77 World::getInstance().setDomain(newM); 86 repMat.at(axis,axis) = Repeater[axis]; 87 } 88 newM *= repMat; 89 World::getInstance().setDomain(newM); 78 90 79 molecule *newmol = NULL; 80 Vector ** vectors = NULL; 81 for (n[0] = 0; n[0] < Repeater[0]; n[0]++) { 82 y[0] = n[0]; 83 for (n[1] = 0; n[1] < Repeater[1]; n[1]++) { 84 y[1] = n[1]; 85 for (n[2] = 0; n[2] < Repeater[2]; n[2]++) { 86 y[2] = n[2]; 87 if ((n[0] == 0) && (n[1] == 0) && (n[2] == 0)) 88 continue; 89 for (vector<molecule *>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 90 mol = *MolRunner; 91 DoLog(1) && (Log() << Verbose(1) << "Current mol is " << mol->name << "." << endl); 92 count = mol->getAtomCount(); // is changed becausing of adding, thus has to be stored away beforehand 93 if (count != 0) { // if there is more than none 94 Elements = new const element *[count]; 95 vectors = new Vector *[count]; 96 j = 0; 97 for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) { 98 Elements[j] = (*AtomRunner)->type; 99 vectors[j] = &(*AtomRunner)->x; 100 j++; 101 } 102 if (count != j) 103 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 104 x = y; 105 x *= M; 106 newmol = World::getInstance().createMolecule(); 107 molecules->insert(newmol); 108 for (int k=count;k--;) { // go through every atom of the original cell 109 Walker = World::getInstance().createAtom(); // create a new body 110 Walker->x = (*vectors[k]) + x; 111 Walker->type = Elements[k]; // insert original element 112 cout << "new atom is " << *Walker << endl; 113 newmol->AddAtom(Walker); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 114 } 115 // free memory 116 delete[](Elements); 117 delete[](vectors); 118 } else { 119 DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl); 91 molecule *newmol = NULL; 92 Vector ** vectors = NULL; 93 for (n[0] = 0; n[0] < Repeater[0]; n[0]++) { 94 y[0] = n[0]; 95 for (n[1] = 0; n[1] < Repeater[1]; n[1]++) { 96 y[1] = n[1]; 97 for (n[2] = 0; n[2] < Repeater[2]; n[2]++) { 98 y[2] = n[2]; 99 if ((n[0] == 0) && (n[1] == 0) && (n[2] == 0)) 100 continue; 101 for (vector<molecule *>::iterator MolRunner = AllMolecules.begin(); MolRunner != AllMolecules.end(); ++MolRunner) { 102 mol = *MolRunner; 103 DoLog(1) && (Log() << Verbose(1) << "Current mol is " << mol->name << "." << endl); 104 count = mol->getAtomCount(); // is changed becausing of adding, thus has to be stored away beforehand 105 if (count != 0) { // if there is more than none 106 Elements = new const element *[count]; 107 vectors = new Vector *[count]; 108 j = 0; 109 for(molecule::iterator AtomRunner = mol->begin(); AtomRunner != mol->end(); ++AtomRunner) { 110 Elements[j] = (*AtomRunner)->type; 111 vectors[j] = &(*AtomRunner)->x; 112 j++; 120 113 } 114 if (count != j) 115 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 116 x = y; 117 x *= M; 118 newmol = World::getInstance().createMolecule(); 119 molecules->insert(newmol); 120 for (int k=count;k--;) { // go through every atom of the original cell 121 Walker = World::getInstance().createAtom(); // create a new body 122 Walker->x = (*vectors[k]) + x; 123 Walker->type = Elements[k]; // insert original element 124 cout << "new atom is " << *Walker << endl; 125 newmol->AddAtom(Walker); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 126 } 127 // free memory 128 delete[](Elements); 129 delete[](vectors); 130 } else { 131 DoLog(1) && (Log() << Verbose(1) << "\t ... is empty." << endl); 121 132 } 122 133 } 123 134 } 124 135 } 125 delete dialog;126 return Action::success;127 } else {128 delete dialog;129 return Action::failure;130 136 } 137 return Action::success; 131 138 } 132 139 -
src/Actions/WorldAction/RepeatBoxAction.hpp
r7067bd6 r677e13 10 10 11 11 #include "Actions/Action.hpp" 12 #include "vector.hpp" 13 14 void WorldRepeatBox(Vector &Repeater); 12 15 13 16 class WorldRepeatBoxAction : public Action { 17 friend void WorldRepeatBox(Vector &Repeater); 18 14 19 public: 15 20 WorldRepeatBoxAction(); … … 21 26 virtual const std::string getName(); 22 27 private: 28 virtual Dialog * createDialog(); 23 29 virtual Action::state_ptr performCall(); 24 30 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/WorldAction/ScaleBoxAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/WorldAction/ScaleBoxAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "atom.hpp" 12 13 #include "log.hpp" … … 24 25 #include "UIElements/UIFactory.hpp" 25 26 #include "UIElements/Dialog.hpp" 26 #include " Actions/MapOfActions.hpp"27 #include "UIElements/ValueStorage.hpp" 27 28 28 29 const char WorldScaleBoxAction::NAME[] = "scale-box"; … … 35 36 {} 36 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::createDialog() { 44 Dialog *dialog = UIFactory::getInstance().makeDialog(); 45 46 dialog->queryVector(NAME, false, ValueStorage::getInstance().getDescription(NAME)); 47 48 return dialog; 49 } 50 37 51 Action::state_ptr WorldScaleBoxAction::performCall() { 38 Dialog *dialog = UIFactory::getInstance().makeDialog();39 52 Vector Scaler; 40 53 double x[NDIM]; 41 54 42 dialog->queryVector(NAME, &Scaler, false, MapOfActions::getInstance().getDescription(NAME));55 ValueStorage::getInstance().queryCurrentValue(NAME, Scaler); 43 56 44 if(dialog->display()) { 45 DoLog(1) && (Log() << Verbose(1) << "Scaling all atomic positions by factor." << endl); 46 for (int i=0;i<NDIM;i++) 47 x[i] = Scaler[i]; 48 vector<atom*> AllAtoms = World::getInstance().getAllAtoms(); 49 for(vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { 50 (*AtomRunner)->x.ScaleAll(x); 51 } 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 } 52 64 53 54 65 Matrix M = World::getInstance().getDomain().getM(); 66 Matrix scale; 55 67 56 57 58 59 60 68 for (int i=0;i<NDIM;i++) { 69 scale.at(i,i) = x[i]; 70 } 71 M *= scale; 72 World::getInstance().setDomain(M); 61 73 62 delete dialog; 63 return Action::success; 64 } else { 65 delete dialog; 66 return Action::failure; 67 } 74 return Action::success; 68 75 } 69 76 -
src/Actions/WorldAction/ScaleBoxAction.hpp
r7067bd6 r677e13 10 10 11 11 #include "Actions/Action.hpp" 12 #include "vector.hpp" 13 14 void WorldScaleBox(Vector &Scaler); 12 15 13 16 class WorldScaleBoxAction : public Action { 17 friend void WorldScaleBox(Vector &Scaler); 18 14 19 public: 15 20 WorldScaleBoxAction(); … … 21 26 virtual const std::string getName(); 22 27 private: 28 virtual Dialog * createDialog(); 23 29 virtual Action::state_ptr performCall(); 24 30 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/WorldAction/SetDefaultNameAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/WorldAction/SetDefaultNameAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "log.hpp" 12 13 #include "verbose.hpp" … … 20 21 #include "UIElements/UIFactory.hpp" 21 22 #include "UIElements/Dialog.hpp" 22 #include "Actions/MapOfActions.hpp" 23 #include "UIElements/ValueStorage.hpp" 24 25 26 // memento to remember the state when undoing 27 28 class WorldSetDefaultNameState : public ActionState { 29 public: 30 WorldSetDefaultNameState(std::string _lastName) : 31 lastName(_lastName) 32 {} 33 std::string lastName; 34 }; 23 35 24 36 const char WorldSetDefaultNameAction::NAME[] = "default-molname"; … … 31 43 {} 32 44 45 void WorldSetDefaultName(std::string &defaultname) { 46 ValueStorage::getInstance().setCurrentValue(WorldSetDefaultNameAction::NAME, defaultname); 47 ActionRegistry::getInstance().getActionByName(WorldSetDefaultNameAction::NAME)->call(Action::NonInteractive); 48 }; 49 50 Dialog* WorldSetDefaultNameAction::createDialog() { 51 Dialog *dialog = UIFactory::getInstance().makeDialog(); 52 53 string defaultname = World::getInstance().getDefaultName(); 54 ValueStorage::getInstance().setCurrentValue(NAME, defaultname); 55 dialog->queryString(NAME, MapOfActions::getInstance().getDescription(NAME)); 56 57 return dialog; 58 } 59 33 60 Action::state_ptr WorldSetDefaultNameAction::performCall() { 34 Dialog *dialog = UIFactory::getInstance().makeDialog();35 61 string defaultname; 36 62 37 63 defaultname = World::getInstance().getDefaultName(); 38 dialog->queryString(NAME, &defaultname, MapOfActions::getInstance().getDescription(NAME));64 ValueStorage::getInstance().queryCurrentValue(NAME, defaultname); 39 65 40 if(dialog->display()) { 41 World::getInstance().setDefaultName(defaultname); 42 DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << World::getInstance().getDefaultName() << "." << endl); 43 delete dialog; 44 return Action::success; 45 } else { 46 delete dialog; 47 return Action::failure; 48 } 66 World::getInstance().setDefaultName(defaultname); 67 DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << World::getInstance().getDefaultName() << "." << endl); 68 return Action::success; 49 69 } 50 70 51 71 Action::state_ptr WorldSetDefaultNameAction::performUndo(Action::state_ptr _state) { 52 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());72 WorldSetDefaultNameState *state = assert_cast<WorldSetDefaultNameState*>(_state.get()); 53 73 54 return Action::failure; 55 // string newName = state->mol->getName(); 56 // state->mol->setName(state->lastName); 57 // 58 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 74 string newName = World::getInstance().getDefaultName(); 75 World::getInstance().setDefaultName(state->lastName); 76 77 return Action::state_ptr(new WorldSetDefaultNameState(newName)); 59 78 } 60 79 61 80 Action::state_ptr WorldSetDefaultNameAction::performRedo(Action::state_ptr _state){ 62 return Action::failure;81 performUndo(_state); 63 82 } 64 83 65 84 bool WorldSetDefaultNameAction::canUndo() { 66 return false;85 return true; 67 86 } 68 87 69 88 bool WorldSetDefaultNameAction::shouldUndo() { 70 return false;89 return true; 71 90 } 72 91 -
src/Actions/WorldAction/SetDefaultNameAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void WorldSetDefaultName(std::string &defaultname); 14 13 15 class WorldSetDefaultNameAction : public Action { 16 friend void WorldSetDefaultName(std::string &defaultname); 17 14 18 public: 15 19 WorldSetDefaultNameAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/WorldAction/SetGaussianBasisAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/WorldAction/SetGaussianBasisAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "config.hpp" 12 13 #include "log.hpp" … … 21 22 #include "UIElements/UIFactory.hpp" 22 23 #include "UIElements/Dialog.hpp" 23 #include "Actions/MapOfActions.hpp" 24 #include "UIElements/ValueStorage.hpp" 25 26 27 // memento to remember the state when undoing 28 29 class WorldSetGaussianBasisState : public ActionState { 30 public: 31 WorldSetGaussianBasisState(std::string _lastName) : 32 lastName(_lastName) 33 {} 34 std::string lastName; 35 }; 36 24 37 25 38 const char WorldSetGaussianBasisAction::NAME[] = "set-basis"; … … 32 45 {} 33 46 47 void WorldSetGaussianBasis(std::string &basisname) { 48 ValueStorage::getInstance().setCurrentValue(WorldSetGaussianBasisAction::NAME, basisname); 49 ActionRegistry::getInstance().getActionByName(WorldSetGaussianBasisAction::NAME)->call(Action::NonInteractive); 50 }; 51 52 Dialog* WorldSetGaussianBasisAction::createDialog() { 53 Dialog *dialog = UIFactory::getInstance().makeDialog(); 54 55 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 56 57 return dialog; 58 } 59 34 60 Action::state_ptr WorldSetGaussianBasisAction::performCall() { 35 Dialog *dialog = UIFactory::getInstance().makeDialog();36 61 config *configuration = World::getInstance().getConfig(); 37 dialog->queryString(NAME, &(configuration->basis), MapOfActions::getInstance().getDescription(NAME));38 62 39 if(dialog->display()) { 40 DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration->basis << "." << endl); 41 delete dialog; 42 return Action::success; 43 } else { 44 delete dialog; 45 return Action::failure; 46 } 63 string lastname = configuration->basis; 64 ValueStorage::getInstance().queryCurrentValue(NAME, configuration->basis); 65 66 DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration->basis << "." << endl); 67 return Action::success; 47 68 } 48 69 49 70 Action::state_ptr WorldSetGaussianBasisAction::performUndo(Action::state_ptr _state) { 50 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());71 WorldSetGaussianBasisState *state = assert_cast<WorldSetGaussianBasisState*>(_state.get()); 51 72 52 return Action::failure;53 // string newName = state->mol->getName();54 // state->mol->setName(state->lastName);55 // 56 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));73 config *configuration = World::getInstance().getConfig(); 74 string newName = configuration->basis; 75 configuration->basis = state->lastName; 76 77 return Action::state_ptr(new WorldSetGaussianBasisState(newName)); 57 78 } 58 79 59 80 Action::state_ptr WorldSetGaussianBasisAction::performRedo(Action::state_ptr _state){ 60 return Action::failure;81 performUndo(_state); 61 82 } 62 83 63 84 bool WorldSetGaussianBasisAction::canUndo() { 64 return false;85 return true; 65 86 } 66 87 67 88 bool WorldSetGaussianBasisAction::shouldUndo() { 68 return false;89 return true; 69 90 } 70 91 -
src/Actions/WorldAction/SetGaussianBasisAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 void WorldSetGaussianBasis(std::string &basisname); 14 13 15 class WorldSetGaussianBasisAction : public Action { 16 friend void WorldSetGaussianBasis(std::string &basisname); 17 14 18 public: 15 19 WorldSetGaussianBasisAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/WorldAction/SetOutputFormatsAction.cpp
r7067bd6 r677e13 9 9 10 10 #include "Actions/WorldAction/SetOutputFormatsAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "Parser/ChangeTracker.hpp" 12 13 #include "Parser/FormatParserStorage.hpp" … … 22 23 #include "UIElements/UIFactory.hpp" 23 24 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 25 26 26 27 const char WorldSetOutputFormatsAction::NAME[] = "set-output"; … … 33 34 {} 34 35 36 void WorldSetOutputFormats(vector<std::string> &FormatList) { 37 ValueStorage::getInstance().setCurrentValue(WorldSetOutputFormatsAction::NAME, FormatList); 38 ActionRegistry::getInstance().getActionByName(WorldSetOutputFormatsAction::NAME)->call(Action::NonInteractive); 39 }; 40 41 Dialog* WorldSetOutputFormatsAction::createDialog() { 42 Dialog *dialog = UIFactory::getInstance().makeDialog(); 43 44 dialog->queryStrings(NAME, ValueStorage::getInstance().getDescription(NAME)); 45 46 return dialog; 47 } 48 35 49 Action::state_ptr WorldSetOutputFormatsAction::performCall() { 36 Dialog *dialog = UIFactory::getInstance().makeDialog();37 50 vector<std::string> FormatList; 38 51 39 dialog->queryStrings(NAME, &FormatList, MapOfActions::getInstance().getDescription(NAME));52 ValueStorage::getInstance().queryCurrentValue(NAME, FormatList); 40 53 41 if(dialog->display()) { 42 for (vector<std::string>::iterator iter = FormatList.begin(); iter != FormatList.end(); ++iter) { 43 if (*iter == "mpqc") { 44 FormatParserStorage::getInstance().addMpqc(); 45 DoLog(0) && (Log() << Verbose(0) << "Adding mpqc type to output." << endl); 46 } else if (*iter == "pcp") { 47 FormatParserStorage::getInstance().addPcp(); 48 DoLog(0) && (Log() << Verbose(0) << "Adding pcp type to output." << endl); 49 } else if (*iter == "tremolo") { 50 FormatParserStorage::getInstance().addTremolo(); 51 DoLog(0) && (Log() << Verbose(0) << "Adding tremolo type to output." << endl); 52 } else if (*iter == "xyz") { 53 FormatParserStorage::getInstance().addXyz(); 54 DoLog(0) && (Log() << Verbose(0) << "Adding xyz type to output." << endl); 55 } else { 56 DoeLog(1) && (eLog() << Verbose(1) << "Unknown format." << endl); 57 } 54 for (vector<std::string>::iterator iter = FormatList.begin(); iter != FormatList.end(); ++iter) { 55 if (*iter == "mpqc") { 56 FormatParserStorage::getInstance().addMpqc(); 57 DoLog(0) && (Log() << Verbose(0) << "Adding mpqc type to output." << endl); 58 } else if (*iter == "pcp") { 59 FormatParserStorage::getInstance().addPcp(); 60 DoLog(0) && (Log() << Verbose(0) << "Adding pcp type to output." << endl); 61 } else if (*iter == "tremolo") { 62 FormatParserStorage::getInstance().addTremolo(); 63 DoLog(0) && (Log() << Verbose(0) << "Adding tremolo type to output." << endl); 64 } else if (*iter == "xyz") { 65 FormatParserStorage::getInstance().addXyz(); 66 DoLog(0) && (Log() << Verbose(0) << "Adding xyz type to output." << endl); 67 } else { 68 DoeLog(1) && (eLog() << Verbose(1) << "Unknown format:" << *iter << endl); 58 69 } 59 ChangeTracker::getInstance().saveStatus();60 delete dialog;61 return Action::success;62 } else {63 delete dialog;64 return Action::failure;65 70 } 71 ChangeTracker::getInstance().saveStatus(); 72 return Action::success; 66 73 } 67 74 -
src/Actions/WorldAction/SetOutputFormatsAction.hpp
r7067bd6 r677e13 11 11 #include "Actions/Action.hpp" 12 12 13 #include <vector> 14 15 void WorldSetOutputFormats(std::vector<std::string> &FormatList); 16 13 17 class WorldSetOutputFormatsAction : public Action { 18 friend void WorldSetOutputFormats(std::vector<std::string> &FormatList); 19 14 20 public: 15 21 WorldSetOutputFormatsAction(); … … 21 27 virtual const std::string getName(); 22 28 private: 29 virtual Dialog * createDialog(); 23 30 virtual Action::state_ptr performCall(); 24 31 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Box.cpp
r7067bd6 r677e13 68 68 return translateIn(helper); 69 69 } 70 71 bool Box::isInside(const Vector &point) const 72 { 73 bool result = true; 74 Vector tester = (*Minv) * point; 75 76 for(int i=0;i<NDIM;i++) 77 result = result && ((tester[i] >= -MYEPSILON) && ((tester[i] - 1.) < MYEPSILON)); 78 79 return result; 80 } 81 70 82 71 83 VECTORSET(std::list) Box::explode(const Vector &point,int n) const{ -
src/Box.hpp
r7067bd6 r677e13 64 64 65 65 /** 66 * Checks whether a given vector is inside the box. 67 */ 68 bool isInside(const Vector &point) const; 69 70 /** 66 71 * Produce corresponding points in several adjacent boxes. 67 72 * -
src/CommandLineParser.cpp
r7067bd6 r677e13 41 41 void CommandLineParser::Parse() 42 42 { 43 po::store(po::command_line_parser(argc,argv).options(cmdline_options). options(visible).run(), vm);43 po::store(po::command_line_parser(argc,argv).options(cmdline_options).run(), vm); 44 44 ifstream input; 45 45 input.open("example.cfg"); -
src/Makefile.am
r7067bd6 r677e13 79 79 EXCEPTIONSOURCE = \ 80 80 Exceptions/CustomException.cpp \ 81 Exceptions/IllegalTypeException.cpp \ 81 82 Exceptions/LinearDependenceException.cpp \ 82 83 Exceptions/MathException.cpp \ 84 Exceptions/MissingValueException.cpp \ 83 85 Exceptions/NotInvertibleException.cpp \ 84 86 Exceptions/ParseError.cpp \ … … 88 90 EXCEPTIONHEADER = \ 89 91 Exceptions/CustomException.hpp \ 92 Exceptions/IllegalTypeException.hpp \ 90 93 Exceptions/LinearDependenceException.hpp \ 91 94 Exceptions/MathException.hpp \ 95 Exceptions/MissingValueException.hpp \ 92 96 Exceptions/NotInvertibleException.hpp \ 93 97 Exceptions/ParseError.hpp \ … … 131 135 132 136 QTUIMOC_HEADER = UIElements/QT4/QTDialog.hpp \ 133 134 135 136 137 138 137 UIElements/QT4/QTMainWindow.hpp \ 138 UIElements/Menu/QT4/QTMenu.hpp \ 139 UIElements/Views/QT4/QTWorldView.hpp \ 140 UIElements/Views/QT4/GLMoleculeView.hpp \ 141 UIElements/Views/QT4/QTMoleculeView.hpp \ 142 UIElements/Views/QT4/QTStatusBar.hpp 139 143 140 144 QTUIMOC_TARGETS = QTMainWindow.moc.cpp \ 141 142 143 144 145 146 145 QTMenu.moc.cpp\ 146 QTDialog.moc.cpp \ 147 QTWorldView.moc.cpp \ 148 GLMoleculeView.moc.cpp \ 149 QTMoleculeView.moc.cpp \ 150 QTStatusBar.moc.cpp 147 151 148 152 DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp \ … … 170 174 171 175 QTUISOURCE = ${QTUIMOC_TARGETS} \ 172 173 174 175 176 177 178 179 176 UIElements/QT4/QTMainWindow.cpp \ 177 UIElements/QT4/QTDialog.cpp \ 178 UIElements/QT4/QTUIFactory.cpp \ 179 UIElements/Menu/QT4/QTMenu.cpp \ 180 UIElements/Views/QT4/QTWorldView.cpp \ 181 UIElements/Views/QT4/GLMoleculeView.cpp \ 182 UIElements/Views/QT4/QTMoleculeView.cpp \ 183 UIElements/Views/QT4/QTStatusBar.cpp 180 184 181 185 QTUIHEADER = ${QTUIMOC_HEADER} UIElements/QT4/QTUIFactory.hpp -
src/UIElements/CommandLineUI/CommandLineDialog.cpp
r7067bd6 r677e13 24 24 #include "defs.hpp" 25 25 #include "log.hpp" 26 #include "Matrix.hpp" 26 27 #include "periodentafel.hpp" 27 28 #include "verbose.hpp" … … 50 51 } 51 52 52 void CommandLineDialog::queryInt(const char* title, int* target, string _description){ 53 registerQuery(new IntCommandLineQuery(title,target, _description)); 54 } 55 56 void CommandLineDialog::queryBoolean(const char* title, bool* target, string _description){ 57 registerQuery(new BooleanCommandLineQuery(title,target, _description)); 58 } 59 60 void CommandLineDialog::queryDouble(const char* title, double* target, string _description){ 61 registerQuery(new DoubleCommandLineQuery(title,target, _description)); 62 } 63 64 void CommandLineDialog::queryString(const char* title, string* target, string _description){ 65 registerQuery(new StringCommandLineQuery(title,target, _description)); 66 } 67 68 void CommandLineDialog::queryStrings(const char* title, vector<string> * target, string _description){ 69 registerQuery(new StringsCommandLineQuery(title,target, _description)); 70 } 71 72 void CommandLineDialog::queryAtom(const char* title, atom **target, string _description) { 73 registerQuery(new AtomCommandLineQuery(title,target, _description)); 74 } 75 76 void CommandLineDialog::queryMolecule(const char* title, molecule **target, string _description) { 77 registerQuery(new MoleculeCommandLineQuery(title,target, _description)); 78 } 79 80 void CommandLineDialog::queryVector(const char* title, Vector *target, bool check, string _description) { 81 registerQuery(new VectorCommandLineQuery(title,target,check, _description)); 82 } 83 84 void CommandLineDialog::queryBox(const char* title, Box* cellSize, string _description) { 85 registerQuery(new BoxCommandLineQuery(title,cellSize,_description)); 86 } 87 88 void CommandLineDialog::queryElement(const char* title, std::vector<element *> *target, string _description){ 89 registerQuery(new ElementCommandLineQuery(title,target, _description)); 53 void CommandLineDialog::queryInt(const char* title, string _description){ 54 registerQuery(new IntCommandLineQuery(title, _description)); 55 } 56 57 void CommandLineDialog::queryInts(const char* title, string _description){ 58 registerQuery(new IntsCommandLineQuery(title, _description)); 59 } 60 61 void CommandLineDialog::queryBoolean(const char* title, string _description){ 62 registerQuery(new BooleanCommandLineQuery(title, _description)); 63 } 64 65 void CommandLineDialog::queryDouble(const char* title, string _description){ 66 registerQuery(new DoubleCommandLineQuery(title, _description)); 67 } 68 69 void CommandLineDialog::queryDoubles(const char* title, string _description){ 70 registerQuery(new DoublesCommandLineQuery(title, _description)); 71 } 72 73 void CommandLineDialog::queryString(const char* title, string _description){ 74 registerQuery(new StringCommandLineQuery(title, _description)); 75 } 76 77 void CommandLineDialog::queryStrings(const char* title, string _description){ 78 registerQuery(new StringsCommandLineQuery(title, _description)); 79 } 80 81 void CommandLineDialog::queryAtom(const char* title, string _description) { 82 registerQuery(new AtomCommandLineQuery(title, _description)); 83 } 84 85 void CommandLineDialog::queryAtoms(const char* title, string _description) { 86 registerQuery(new AtomsCommandLineQuery(title, _description)); 87 } 88 89 void CommandLineDialog::queryMolecule(const char* title, string _description) { 90 registerQuery(new MoleculeCommandLineQuery(title, _description)); 91 } 92 93 void CommandLineDialog::queryMolecules(const char* title, string _description) { 94 registerQuery(new MoleculesCommandLineQuery(title, _description)); 95 } 96 97 void CommandLineDialog::queryVector(const char* title, bool check, string _description) { 98 registerQuery(new VectorCommandLineQuery(title,check, _description)); 99 } 100 101 void CommandLineDialog::queryVectors(const char* title, bool check, string _description) { 102 registerQuery(new VectorsCommandLineQuery(title,check, _description)); 103 } 104 105 void CommandLineDialog::queryBox(const char* title, string _description) { 106 registerQuery(new BoxCommandLineQuery(title,_description)); 107 } 108 109 void CommandLineDialog::queryElement(const char* title, string _description){ 110 registerQuery(new ElementCommandLineQuery(title, _description)); 111 } 112 113 void CommandLineDialog::queryElements(const char* title, string _description){ 114 registerQuery(new ElementsCommandLineQuery(title, _description)); 90 115 } 91 116 … … 103 128 } 104 129 105 CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title, int *_target,string _description) :106 Dialog::IntQuery(title, _target,_description)130 CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title, string _description) : 131 Dialog::IntQuery(title, _description) 107 132 {} 108 133 … … 119 144 } 120 145 121 CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title,bool *_target, string _description) : 122 Dialog::BooleanQuery(title,_target, _description) 146 CommandLineDialog::IntsCommandLineQuery::IntsCommandLineQuery(string title, string _description) : 147 Dialog::IntsQuery(title, _description) 148 {} 149 150 CommandLineDialog::IntsCommandLineQuery::~IntsCommandLineQuery() {} 151 152 bool CommandLineDialog::IntsCommandLineQuery::handle() { 153 if (CommandLineParser::getInstance().vm.count(getTitle())) { 154 tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >(); 155 return true; 156 } else { 157 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integers for " << getTitle() << "." << endl); 158 return false; 159 } 160 } 161 162 CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title, string _description) : 163 Dialog::BooleanQuery(title, _description) 123 164 {} 124 165 … … 135 176 } 136 177 137 CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title, string *_target,string _description) :138 Dialog::StringQuery(title, _target,_description)178 CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title, string _description) : 179 Dialog::StringQuery(title, _description) 139 180 {} 140 181 … … 151 192 } 152 193 153 CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title, vector<string> *_target,string _description) :154 Dialog::StringsQuery(title, _target,_description)194 CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title, string _description) : 195 Dialog::StringsQuery(title, _description) 155 196 {} 156 197 … … 162 203 return true; 163 204 } else { 164 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl);165 return false; 166 } 167 } 168 169 CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title, double *_target,string _description) :170 Dialog::DoubleQuery(title, _target,_description)205 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing strings for " << getTitle() << "." << endl); 206 return false; 207 } 208 } 209 210 CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title, string _description) : 211 Dialog::DoubleQuery(title, _description) 171 212 {} 172 213 … … 183 224 } 184 225 185 CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, atom **_target, string _description) : 186 Dialog::AtomQuery(title,_target, _description) 226 CommandLineDialog::DoublesCommandLineQuery::DoublesCommandLineQuery(string title, string _description) : 227 Dialog::DoublesQuery(title, _description) 228 {} 229 230 CommandLineDialog::DoublesCommandLineQuery::~DoublesCommandLineQuery() {} 231 232 bool CommandLineDialog::DoublesCommandLineQuery::handle() { 233 if (CommandLineParser::getInstance().vm.count(getTitle())) { 234 tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<double> >(); 235 return true; 236 } else { 237 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing doubles for " << getTitle() << "." << endl); 238 return false; 239 } 240 } 241 242 CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, string _description) : 243 Dialog::AtomQuery(title, _description) 187 244 {} 188 245 … … 201 258 } 202 259 203 CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, string _description) : 204 Dialog::MoleculeQuery(title,_target, _description) 260 CommandLineDialog::AtomsCommandLineQuery::AtomsCommandLineQuery(string title, string _description) : 261 Dialog::AtomsQuery(title, _description) 262 {} 263 264 CommandLineDialog::AtomsCommandLineQuery::~AtomsCommandLineQuery() {} 265 266 bool CommandLineDialog::AtomsCommandLineQuery::handle() { 267 std::vector<int> IdxOfAtom; 268 if (CommandLineParser::getInstance().vm.count(getTitle())) { 269 IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >(); 270 for (std::vector<int>::iterator iter = IdxOfAtom.begin(); iter != IdxOfAtom.end(); ++iter) { 271 temp = World::getInstance().getAtom(AtomById(*iter)); 272 if (temp) 273 tmp.push_back(temp); 274 } 275 return true; 276 } else { 277 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atoms for " << getTitle() << "." << endl); 278 return false; 279 } 280 } 281 282 CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, string _description) : 283 Dialog::MoleculeQuery(title, _description) 205 284 {} 206 285 … … 211 290 if (CommandLineParser::getInstance().vm.count(getTitle())) { 212 291 IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>(); 213 cout << "IdxOfMol " << IdxOfMol << endl; 214 if (IdxOfMol >= 0) 215 tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol)); 216 else 217 tmp = NULL; 292 tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol)); 218 293 return true; 219 294 } else { … … 223 298 } 224 299 225 CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, Vector *_target, bool _check, string _description) : 226 Dialog::VectorQuery(title,_target,_check, _description) 300 CommandLineDialog::MoleculesCommandLineQuery::MoleculesCommandLineQuery(string title, string _description) : 301 Dialog::MoleculesQuery(title, _description) 302 {} 303 304 CommandLineDialog::MoleculesCommandLineQuery::~MoleculesCommandLineQuery() {} 305 306 bool CommandLineDialog::MoleculesCommandLineQuery::handle() { 307 std::vector<int> IdxOfMol; 308 if (CommandLineParser::getInstance().vm.count(getTitle())) { 309 IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >(); 310 for (std::vector<int>::iterator iter = IdxOfMol.begin(); iter != IdxOfMol.end(); ++iter) { 311 temp = World::getInstance().getMolecule(MoleculeById(*iter)); 312 if (temp) 313 tmp.push_back(temp); 314 } 315 return true; 316 } else { 317 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecules for " << getTitle() << "." << endl); 318 return false; 319 } 320 } 321 322 CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, bool _check, string _description) : 323 Dialog::VectorQuery(title,_check, _description) 227 324 {} 228 325 … … 234 331 if (CommandLineParser::getInstance().vm.count(getTitle())) { 235 332 temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >(); 236 tmp->at(0) = temp.x; 237 tmp->at(1) = temp.y; 238 tmp->at(2) = temp.z; 333 tmp[0] = temp.x; 334 tmp[1] = temp.y; 335 tmp[2] = temp.z; 336 if ((check) && (!World::getInstance().getDomain().isInside(tmp))) { 337 DoeLog(1) && (eLog() << Verbose(1) << "Vector " << tmp << " would be outside of box domain." << endl); 338 return false; 339 } 239 340 return true; 240 341 } else { … … 244 345 } 245 346 246 247 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, Box* _cellSize, string _description) : 248 Dialog::BoxQuery(title,_cellSize, _description) 347 CommandLineDialog::VectorsCommandLineQuery::VectorsCommandLineQuery(string title, bool _check, string _description) : 348 Dialog::VectorsQuery(title,_check, _description) 349 {} 350 351 CommandLineDialog::VectorsCommandLineQuery::~VectorsCommandLineQuery() 352 {} 353 354 bool CommandLineDialog::VectorsCommandLineQuery::handle() { 355 std::vector<VectorValue> temporary; 356 if (CommandLineParser::getInstance().vm.count(getTitle())) { 357 temporary = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<VectorValue> >(); 358 for(std::vector<VectorValue>::iterator iter = temporary.begin(); iter != temporary.end(); ++iter) { 359 temp[0] = (*iter).x; 360 temp[1] = (*iter).y; 361 temp[2] = (*iter).z; 362 if ((!check) || (World::getInstance().getDomain().isInside(temp))) 363 tmp.push_back(temp); 364 else 365 DoeLog(1) && (eLog() << Verbose(1) << "Vector " << temp << " would be outside of box domain." << endl); 366 } 367 return true; 368 } else { 369 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vectors for " << getTitle() << "." << endl); 370 return false; 371 } 372 } 373 374 CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) : 375 Dialog::BoxQuery(title, _description) 249 376 {} 250 377 … … 256 383 if (CommandLineParser::getInstance().vm.count(getTitle())) { 257 384 temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >(); 258 tmp[0] = temp.xx; 259 tmp[1] = temp.xy; 260 tmp[2] = temp.xz; 261 tmp[3] = temp.yy; 262 tmp[4] = temp.yz; 263 tmp[5] = temp.zz; 385 Matrix M; 386 M.set(0,0, temp.xx); 387 M.set(0,1, temp.yx); 388 M.set(0,2, temp.zx); 389 M.set(1,0, temp.yx); 390 M.set(1,1, temp.yy); 391 M.set(1,2, temp.zy); 392 M.set(2,0, temp.zx); 393 M.set(2,1, temp.zy); 394 M.set(2,2, temp.zz); 395 tmp.setM(M); 264 396 return true; 265 397 } else { … … 269 401 } 270 402 271 CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, st d::vector<element *> *target, string _description) :272 Dialog::ElementQuery(title, target,_description)403 CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, string _description) : 404 Dialog::ElementQuery(title, _description) 273 405 {} 274 406 … … 279 411 // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector? 280 412 periodentafel *periode = World::getInstance().getPeriode(); 281 element *elemental = NULL; 413 if (CommandLineParser::getInstance().vm.count(getTitle())) { 414 int Z = CommandLineParser::getInstance().vm[getTitle()].as< int >(); 415 tmp = periode->FindElement(Z); 416 ASSERT(tmp != NULL, "Invalid element specified in ElementCommandLineQuery"); 417 return true; 418 } else { 419 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl); 420 return false; 421 } 422 } 423 424 CommandLineDialog::ElementsCommandLineQuery::ElementsCommandLineQuery(string title, string _description) : 425 Dialog::ElementsQuery(title, _description) 426 {} 427 428 CommandLineDialog::ElementsCommandLineQuery::~ElementsCommandLineQuery() 429 {} 430 431 bool CommandLineDialog::ElementsCommandLineQuery::handle() { 432 // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector? 433 periodentafel *periode = World::getInstance().getPeriode(); 282 434 if (CommandLineParser::getInstance().vm.count(getTitle())) { 283 435 vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >(); 284 436 for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) { 285 elemental= periode->FindElement(*ZRunner);286 ASSERT( elemental!= NULL, "Invalid element specified in ElementCommandLineQuery");287 elements.push_back(elemental);437 temp = periode->FindElement(*ZRunner); 438 ASSERT(temp != NULL, "Invalid element specified in ElementCommandLineQuery"); 439 tmp.push_back(temp); 288 440 } 289 441 return true; 290 442 } else { 291 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);292 return false; 293 } 294 } 443 DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing elements for " << getTitle() << "." << endl); 444 return false; 445 } 446 } -
src/UIElements/CommandLineUI/CommandLineDialog.hpp
r7067bd6 r677e13 28 28 29 29 virtual void queryEmpty(const char *, std::string = ""); 30 virtual void queryInt(const char *, int *, std::string = ""); 31 virtual void queryBoolean(const char *, bool *, std::string = ""); 32 virtual void queryString(const char*, std::string *, std::string = ""); 33 virtual void queryStrings(const char*, std::vector<std::string> *, std::string = ""); 34 virtual void queryDouble(const char*, double*, std::string = ""); 35 virtual void queryAtom(const char*,atom**, std::string = ""); 36 virtual void queryMolecule(const char*,molecule**,std::string = ""); 37 virtual void queryVector(const char*,Vector *,bool, std::string = ""); 38 virtual void queryBox(const char*,Box *, std::string = ""); 39 virtual void queryElement(const char*, std::vector<element *> *, std::string = ""); 30 virtual void queryInt(const char *, std::string = ""); 31 virtual void queryInts(const char *, std::string = ""); 32 virtual void queryBoolean(const char *, std::string = ""); 33 virtual void queryString(const char*, std::string = ""); 34 virtual void queryStrings(const char*, std::string = ""); 35 virtual void queryDouble(const char*, std::string = ""); 36 virtual void queryDoubles(const char*, std::string = ""); 37 virtual void queryAtom(const char*, std::string = ""); 38 virtual void queryAtoms(const char*, std::string = ""); 39 virtual void queryMolecule(const char*, std::string = ""); 40 virtual void queryMolecules(const char*, std::string = ""); 41 virtual void queryVector(const char*, bool, std::string = ""); 42 virtual void queryVectors(const char*, bool, std::string = ""); 43 virtual void queryBox(const char*, std::string = ""); 44 virtual void queryElement(const char*, std::string = ""); 45 virtual void queryElements(const char*, std::string = ""); 40 46 41 47 protected: … … 50 56 class IntCommandLineQuery : public Dialog::IntQuery { 51 57 public: 52 IntCommandLineQuery(std::string title, int *_target,std::string _description = "");58 IntCommandLineQuery(std::string title, std::string _description = ""); 53 59 virtual ~IntCommandLineQuery(); 60 virtual bool handle(); 61 }; 62 63 class IntsCommandLineQuery : public Dialog::IntsQuery { 64 public: 65 IntsCommandLineQuery(std::string title, std::string _description = ""); 66 virtual ~IntsCommandLineQuery(); 54 67 virtual bool handle(); 55 68 }; … … 57 70 class BooleanCommandLineQuery : public Dialog::BooleanQuery { 58 71 public: 59 BooleanCommandLineQuery(std::string title, bool *_target,std::string _description = "");72 BooleanCommandLineQuery(std::string title, std::string _description = ""); 60 73 virtual ~BooleanCommandLineQuery(); 61 74 virtual bool handle(); … … 64 77 class DoubleCommandLineQuery : public Dialog::DoubleQuery { 65 78 public: 66 DoubleCommandLineQuery(std::string title, double *_target,std::string _description = "");79 DoubleCommandLineQuery(std::string title, std::string _description = ""); 67 80 virtual ~DoubleCommandLineQuery(); 81 virtual bool handle(); 82 }; 83 84 class DoublesCommandLineQuery : public Dialog::DoublesQuery { 85 public: 86 DoublesCommandLineQuery(std::string title, std::string _description = ""); 87 virtual ~DoublesCommandLineQuery(); 68 88 virtual bool handle(); 69 89 }; … … 71 91 class StringCommandLineQuery : public Dialog::StringQuery { 72 92 public: 73 StringCommandLineQuery(std::string title, std::string *_target, std::string_description = "");93 StringCommandLineQuery(std::string title, std::string _description = ""); 74 94 virtual ~StringCommandLineQuery(); 75 95 virtual bool handle(); … … 78 98 class StringsCommandLineQuery : public Dialog::StringsQuery { 79 99 public: 80 StringsCommandLineQuery(std::string title, std:: vector<std::string> *_target, std::string _description = "");100 StringsCommandLineQuery(std::string title, std::string _description = ""); 81 101 virtual ~StringsCommandLineQuery(); 82 102 virtual bool handle(); … … 85 105 class AtomCommandLineQuery : public Dialog::AtomQuery { 86 106 public: 87 AtomCommandLineQuery(std::string title, atom **_target,std::string _description = "");107 AtomCommandLineQuery(std::string title, std::string _description = ""); 88 108 virtual ~AtomCommandLineQuery(); 109 virtual bool handle(); 110 }; 111 112 class AtomsCommandLineQuery : public Dialog::AtomsQuery { 113 public: 114 AtomsCommandLineQuery(std::string title, std::string _description = ""); 115 virtual ~AtomsCommandLineQuery(); 89 116 virtual bool handle(); 90 117 }; … … 92 119 class MoleculeCommandLineQuery : public Dialog::MoleculeQuery { 93 120 public: 94 MoleculeCommandLineQuery(std::string title, molecule **_target,std::string _description = "");121 MoleculeCommandLineQuery(std::string title, std::string _description = ""); 95 122 virtual ~MoleculeCommandLineQuery(); 123 virtual bool handle(); 124 }; 125 126 class MoleculesCommandLineQuery : public Dialog::MoleculesQuery { 127 public: 128 MoleculesCommandLineQuery(std::string title, std::string _description = ""); 129 virtual ~MoleculesCommandLineQuery(); 96 130 virtual bool handle(); 97 131 }; … … 99 133 class VectorCommandLineQuery : public Dialog::VectorQuery { 100 134 public: 101 VectorCommandLineQuery(std::string title, Vector *_target,bool _check, std::string _description = "");135 VectorCommandLineQuery(std::string title,bool _check, std::string _description = ""); 102 136 virtual ~VectorCommandLineQuery(); 137 virtual bool handle(); 138 }; 139 140 class VectorsCommandLineQuery : public Dialog::VectorsQuery { 141 public: 142 VectorsCommandLineQuery(std::string title,bool _check, std::string _description = ""); 143 virtual ~VectorsCommandLineQuery(); 103 144 virtual bool handle(); 104 145 }; … … 106 147 class BoxCommandLineQuery : public Dialog::BoxQuery { 107 148 public: 108 BoxCommandLineQuery(std::string title, Box* _cellSize,std::string _description = "");149 BoxCommandLineQuery(std::string title, std::string _description = ""); 109 150 virtual ~BoxCommandLineQuery(); 110 151 virtual bool handle(); … … 113 154 class ElementCommandLineQuery : public Dialog::ElementQuery { 114 155 public: 115 ElementCommandLineQuery(std::string title, std:: vector<element *> *_target, std::string _description = "");156 ElementCommandLineQuery(std::string title, std::string _description = ""); 116 157 virtual ~ElementCommandLineQuery(); 158 virtual bool handle(); 159 }; 160 161 class ElementsCommandLineQuery : public Dialog::ElementsQuery { 162 public: 163 ElementsCommandLineQuery(std::string title, std::string _description = ""); 164 virtual ~ElementsCommandLineQuery(); 117 165 virtual bool handle(); 118 166 }; -
src/UIElements/Dialog.cpp
r7067bd6 r677e13 9 9 10 10 #include "Dialog.hpp" 11 #include "ValueStorage.hpp" 11 12 12 13 #include "verbose.hpp" … … 97 98 // Int Queries 98 99 99 Dialog::IntQuery::IntQuery(string title, int *_target,std::string description) :100 Query(title, description) , target(_target)100 Dialog::IntQuery::IntQuery(string title, std::string description) : 101 Query(title, description) 101 102 {} 102 103 … … 104 105 105 106 void Dialog::IntQuery::setResult() { 106 *target = tmp; 107 } 108 109 // Int Queries 110 111 Dialog::BooleanQuery::BooleanQuery(string title,bool *_target, std::string description) : 112 Query(title, description), target(_target) 107 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 108 } 109 110 // Ints Queries 111 112 Dialog::IntsQuery::IntsQuery(string title, std::string description) : 113 Query(title, description) 114 {} 115 116 Dialog::IntsQuery::~IntsQuery() {} 117 118 void Dialog::IntsQuery::setResult() { 119 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 120 } 121 122 // Bool Queries 123 124 Dialog::BooleanQuery::BooleanQuery(string title,std::string description) : 125 Query(title, description) 113 126 {} 114 127 … … 116 129 117 130 void Dialog::BooleanQuery::setResult() { 118 *target = tmp;131 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 119 132 } 120 133 121 134 // String Queries 122 135 123 Dialog::StringQuery::StringQuery(string title,st ring *_target, std::string _description) :124 Query(title, _description) , target(_target)136 Dialog::StringQuery::StringQuery(string title,std::string _description) : 137 Query(title, _description) 125 138 {} 126 139 … … 128 141 129 142 void Dialog::StringQuery::setResult() { 130 *target = tmp;143 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 131 144 } 132 145 133 146 // Strings Queries 134 147 135 Dialog::StringsQuery::StringsQuery(string title, vector<string> *_target,std::string _description) :136 Query(title, _description) , target(_target)148 Dialog::StringsQuery::StringsQuery(string title,std::string _description) : 149 Query(title, _description) 137 150 {} 138 151 … … 140 153 141 154 void Dialog::StringsQuery::setResult() { 142 *target = tmp;155 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 143 156 } 144 157 145 158 // Double Queries 146 159 147 Dialog::DoubleQuery::DoubleQuery(string title, double *_target,std::string _description) :148 Query(title, _description) , target(_target)160 Dialog::DoubleQuery::DoubleQuery(string title, std::string _description) : 161 Query(title, _description) 149 162 {} 150 163 … … 152 165 153 166 void Dialog::DoubleQuery::setResult() { 154 *target = tmp; 167 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 168 } 169 170 // Doubles Queries 171 172 Dialog::DoublesQuery::DoublesQuery(string title, std::string _description) : 173 Query(title, _description) 174 {} 175 176 Dialog::DoublesQuery::~DoublesQuery() {}; 177 178 void Dialog::DoublesQuery::setResult() { 179 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 155 180 } 156 181 … … 158 183 // Atom Queries 159 184 160 Dialog::AtomQuery::AtomQuery(string title, atom **_target, std::string _description) : 161 Query(title, _description), 162 tmp(0), 163 target(_target) 164 185 Dialog::AtomQuery::AtomQuery(string title, std::string _description) : 186 Query(title, _description), 187 tmp(0) 165 188 {} 166 189 … … 168 191 169 192 void Dialog::AtomQuery::setResult() { 170 *target = tmp; 193 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 194 } 195 196 // Atoms Queries 197 198 Dialog::AtomsQuery::AtomsQuery(string title, std::string _description) : 199 Query(title, _description), 200 tmp(0) 201 {} 202 203 Dialog::AtomsQuery::~AtomsQuery() {} 204 205 void Dialog::AtomsQuery::setResult() { 206 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 171 207 } 172 208 173 209 // Molecule Queries 174 210 175 Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, std::string _description) : 176 Query(title, _description), 177 tmp(0), 178 target(_target) 179 211 Dialog::MoleculeQuery::MoleculeQuery(string title, std::string _description) : 212 Query(title, _description), 213 tmp(0) 180 214 {} 181 215 … … 183 217 184 218 void Dialog::MoleculeQuery::setResult() { 185 *target = tmp; 219 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 220 } 221 222 // Molecules Queries 223 224 Dialog::MoleculesQuery::MoleculesQuery(string title, std::string _description) : 225 Query(title, _description), 226 tmp(0) 227 {} 228 229 Dialog::MoleculesQuery::~MoleculesQuery() {} 230 231 void Dialog::MoleculesQuery::setResult() { 232 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 186 233 } 187 234 188 235 // Vector Queries 189 236 190 Dialog::VectorQuery::VectorQuery(std::string title, Vector *_target,bool _check, std::string _description) :237 Dialog::VectorQuery::VectorQuery(std::string title,bool _check, std::string _description) : 191 238 Query(title, _description), 192 check(_check), 193 target(_target) 194 { 195 tmp = new Vector(); 196 } 239 check(_check) 240 {} 197 241 198 242 Dialog::VectorQuery::~VectorQuery() 199 { 200 delete tmp; 201 } 243 {} 202 244 203 245 void Dialog::VectorQuery::setResult() { 204 *target = *tmp; 246 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 247 } 248 249 // Vectors Queries 250 251 Dialog::VectorsQuery::VectorsQuery(std::string title,bool _check, std::string _description) : 252 Query(title, _description), 253 check(_check) 254 {} 255 256 Dialog::VectorsQuery::~VectorsQuery() 257 {} 258 259 void Dialog::VectorsQuery::setResult() { 260 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 205 261 } 206 262 207 263 // Box Queries 208 264 209 Dialog::BoxQuery::BoxQuery(std::string title, Box* _cellSize, std::string _description) : 210 Query(title, _description), 211 target(_cellSize) 212 { 213 tmp = new double[6]; 214 } 265 Dialog::BoxQuery::BoxQuery(std::string title, std::string _description) : 266 Query(title, _description) 267 {} 215 268 216 269 Dialog::BoxQuery::~BoxQuery() 217 { 218 delete[] tmp; 219 } 270 {} 220 271 221 272 void Dialog::BoxQuery::setResult() { 222 (*target)= ReturnFullMatrixforSymmetric(tmp);273 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 223 274 } 224 275 225 276 // Element Queries 226 Dialog::ElementQuery::ElementQuery(std::string title, std::vector<element *> *_target, std::string _description) : 227 Query(title, _description), 228 target(_target) 277 Dialog::ElementQuery::ElementQuery(std::string title, std::string _description) : 278 Query(title, _description) 229 279 {} 230 280 … … 232 282 233 283 void Dialog::ElementQuery::setResult(){ 234 *target=elements; 235 } 284 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 285 } 286 287 // Elements Queries 288 Dialog::ElementsQuery::ElementsQuery(std::string title, std::string _description) : 289 Query(title, _description) 290 {} 291 292 Dialog::ElementsQuery::~ElementsQuery(){} 293 294 void Dialog::ElementsQuery::setResult(){ 295 ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); 296 } -
src/UIElements/Dialog.hpp
r7067bd6 r677e13 13 13 #include<vector> 14 14 15 #include "Box.hpp" 16 #include "vector.hpp" 17 15 18 class atom; 16 19 class Box; 17 20 class element; 18 21 class molecule; 19 class Vector;20 22 21 23 … … 37 39 38 40 virtual void queryEmpty(const char *, std::string = "")=0; 39 virtual void queryBoolean(const char *, bool *, std::string = "")=0; 40 virtual void queryInt(const char *, int *, std::string = "")=0; 41 virtual void queryDouble(const char*,double *, std::string = "")=0; 42 virtual void queryString(const char*, std::string *, std::string = "")=0; 43 virtual void queryStrings(const char*, std::vector<std::string> *, std::string = "")=0; 44 virtual void queryAtom(const char*,atom**,std::string = "")=0; 45 virtual void queryMolecule(const char*,molecule**, std::string = "")=0; 46 virtual void queryVector(const char*,Vector *,bool, std::string = "")=0; 47 virtual void queryBox(const char*,Box*, std::string = "")=0; 48 virtual void queryElement(const char*, std::vector<element *> *, std::string = "")=0; 41 virtual void queryBoolean(const char *, std::string = "")=0; 42 virtual void queryInt(const char *, std::string = "")=0; 43 virtual void queryInts(const char *, std::string = "")=0; 44 virtual void queryDouble(const char*, std::string = "")=0; 45 virtual void queryDoubles(const char*, std::string = "")=0; 46 virtual void queryString(const char*, std::string = "")=0; 47 virtual void queryStrings(const char*, std::string = "")=0; 48 virtual void queryAtom(const char*,std::string = "")=0; 49 virtual void queryAtoms(const char*,std::string = "")=0; 50 virtual void queryMolecule(const char*, std::string = "")=0; 51 virtual void queryMolecules(const char*, std::string = "")=0; 52 virtual void queryVector(const char*,bool, std::string = "")=0; 53 virtual void queryVectors(const char*,bool, std::string = "")=0; 54 virtual void queryBox(const char*, std::string = "")=0; 55 virtual void queryElement(const char*, std::string = "")=0; 56 virtual void queryElements(const char*, std::string = "")=0; 49 57 50 58 virtual bool display(); … … 92 100 class BooleanQuery : public Query { 93 101 public: 94 BooleanQuery(std::string title, bool *_target,std::string _description = "");102 BooleanQuery(std::string title, std::string _description = ""); 95 103 virtual ~BooleanQuery(); 96 104 virtual bool handle()=0; … … 98 106 protected: 99 107 bool tmp; 100 private:101 bool *target;102 108 }; 103 109 104 110 class IntQuery : public Query { 105 111 public: 106 IntQuery(std::string title, int *_target,std::string _description = "");112 IntQuery(std::string title, std::string _description = ""); 107 113 virtual ~IntQuery(); 108 114 virtual bool handle()=0; … … 110 116 protected: 111 117 int tmp; 112 private: 113 int *target; 118 }; 119 120 class IntsQuery : public Query { 121 public: 122 IntsQuery(std::string title, std::string _description = ""); 123 virtual ~IntsQuery(); 124 virtual bool handle()=0; 125 virtual void setResult(); 126 protected: 127 int temp; 128 std::vector<int> tmp; 114 129 }; 115 130 116 131 class DoubleQuery : public Query { 117 132 public: 118 DoubleQuery(std::string title, double *_target,std::string _description = "");133 DoubleQuery(std::string title, std::string _description = ""); 119 134 virtual ~DoubleQuery(); 120 135 virtual bool handle()=0; … … 122 137 protected: 123 138 double tmp; 124 private: 125 double *target; 139 }; 140 141 class DoublesQuery : public Query { 142 public: 143 DoublesQuery(std::string title, std::string _description = ""); 144 virtual ~DoublesQuery(); 145 virtual bool handle()=0; 146 virtual void setResult(); 147 protected: 148 double temp; 149 std::vector<double> tmp; 126 150 }; 127 151 128 152 class StringQuery : public Query { 129 153 public: 130 StringQuery(std::string title, std::string *_target,std::string _description = "");154 StringQuery(std::string title, std::string _description = ""); 131 155 virtual ~StringQuery(); 132 156 virtual bool handle()=0; … … 134 158 protected: 135 159 std::string tmp; 136 private:137 std::string *target;138 160 }; 139 161 140 162 class StringsQuery : public Query { 141 163 public: 142 StringsQuery(std::string title, std::vector<std::string> *_target,std::string _description = "");164 StringsQuery(std::string title, std::string _description = ""); 143 165 virtual ~StringsQuery(); 144 166 virtual bool handle()=0; … … 147 169 std::string temp; 148 170 std::vector<std::string> tmp; 149 private:150 std::vector<std::string> *target;151 171 }; 152 172 153 173 class MoleculeQuery : public Query { 154 174 public: 155 MoleculeQuery(std::string title, molecule **_target,std::string _description = "");175 MoleculeQuery(std::string title, std::string _description = ""); 156 176 virtual ~MoleculeQuery(); 157 177 virtual bool handle()=0; … … 159 179 protected: 160 180 molecule *tmp; 161 private: 162 molecule **target; 181 }; 182 183 class MoleculesQuery : public Query { 184 public: 185 MoleculesQuery(std::string title, std::string _description = ""); 186 virtual ~MoleculesQuery(); 187 virtual bool handle()=0; 188 virtual void setResult(); 189 protected: 190 molecule * temp; 191 std::vector<molecule *> tmp; 163 192 }; 164 193 165 194 class AtomQuery : public Query { 166 195 public: 167 AtomQuery(std::string title, atom **_target,std::string _description = "");196 AtomQuery(std::string title, std::string _description = ""); 168 197 virtual ~AtomQuery(); 169 198 virtual bool handle()=0; … … 171 200 protected: 172 201 atom *tmp; 173 private: 174 atom **target; 202 }; 203 204 class AtomsQuery : public Query { 205 public: 206 AtomsQuery(std::string title, std::string _description = ""); 207 virtual ~AtomsQuery(); 208 virtual bool handle()=0; 209 virtual void setResult(); 210 protected: 211 atom *temp; 212 std::vector<atom *> tmp; 175 213 }; 176 214 177 215 class VectorQuery : public Query { 178 216 public: 179 VectorQuery(std::string title, Vector *_target,bool _check, std::string _description = "");217 VectorQuery(std::string title,bool _check, std::string _description = ""); 180 218 virtual ~VectorQuery(); 181 219 virtual bool handle()=0; 182 220 virtual void setResult(); 183 221 protected: 184 Vector *tmp;222 Vector tmp; 185 223 bool check; 186 private: 187 Vector *target; 224 }; 225 226 class VectorsQuery : public Query { 227 public: 228 VectorsQuery(std::string title,bool _check, std::string _description = ""); 229 virtual ~VectorsQuery(); 230 virtual bool handle()=0; 231 virtual void setResult(); 232 protected: 233 Vector temp; 234 std::vector<Vector> tmp; 235 bool check; 188 236 }; 189 237 190 238 class BoxQuery : public Query { 191 239 public: 192 BoxQuery(std::string title, Box *_cellSize,std::string _description = "");240 BoxQuery(std::string title, std::string _description = ""); 193 241 virtual ~BoxQuery(); 194 242 virtual bool handle()=0; 195 243 virtual void setResult(); 196 244 protected: 197 double* tmp; 198 private: 199 Box* target; 245 Box tmp; 200 246 }; 201 247 202 248 class ElementQuery : public Query { 203 249 public: 204 ElementQuery(std::string title, std:: vector<element *> *_target, std::string _description = "");250 ElementQuery(std::string title, std::string _description = ""); 205 251 virtual ~ElementQuery(); 206 252 virtual bool handle()=0; 207 253 virtual void setResult(); 208 254 protected: 209 std::vector<element *> elements; 210 private: 211 std::vector<element *> * const target; 255 element * tmp; 256 }; 257 258 class ElementsQuery : public Query { 259 public: 260 ElementsQuery(std::string title, std::string _description = ""); 261 virtual ~ElementsQuery(); 262 virtual bool handle()=0; 263 virtual void setResult(); 264 protected: 265 element *temp; 266 std::vector<element *> tmp; 212 267 }; 213 268 -
src/UIElements/Makefile.am
r7067bd6 r677e13 46 46 Dialog.cpp \ 47 47 MainWindow.cpp \ 48 UIFactory.cpp 48 UIFactory.cpp \ 49 ValueStorage.cpp 49 50 50 51 UIHEADER = \ … … 56 57 Dialog.hpp \ 57 58 MainWindow.hpp \ 58 UIFactory.hpp 59 UIFactory.hpp \ 60 ValueStorage.hpp 59 61 60 62 TEXTUISOURCE = \ -
src/UIElements/Menu/TextMenu.cpp
r7067bd6 r677e13 127 127 } 128 128 129 Dialog* TextMenu::LeaveAction::createDialog(){ 130 } 131 132 129 133 Action::state_ptr TextMenu::LeaveAction::performCall(){ 130 134 menu->doQuit(); -
src/UIElements/Menu/TextMenu.hpp
r7067bd6 r677e13 36 36 37 37 private: 38 virtual Dialog* createDialog(); 38 39 virtual Action::state_ptr performCall(); 39 40 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/UIElements/QT4/QTDialog.cpp
r7067bd6 r677e13 17 17 #include <QtGui/QDoubleSpinBox> 18 18 #include <Qt/qlineedit.h> 19 #include <Qt/qlistwidget.h> 19 20 #include <Qt/qdialogbuttonbox.h> 20 21 #include <Qt/qpushbutton.h> … … 28 29 #include "element.hpp" 29 30 #include "molecule.hpp" 31 #include "Descriptors/AtomIdDescriptor.hpp" 30 32 #include "Descriptors/MoleculeIdDescriptor.hpp" 31 33 #include "Matrix.hpp" … … 85 87 } 86 88 87 void QTDialog::queryBoolean(char const*, bool*,string){89 void QTDialog::queryBoolean(char const*,string){ 88 90 // TODO 89 91 ASSERT(false, "Not implemented yet"); 90 92 } 91 93 92 void QTDialog::queryAtom(char const*, atom**,string){94 void QTDialog::queryAtom(char const*, string){ 93 95 // TODO 94 96 ASSERT(false, "Not implemented yet"); 95 97 } 96 98 97 void QTDialog::query Box(char const*, Box*, string){99 void QTDialog::queryAtoms(char const*, string){ 98 100 // TODO 99 101 ASSERT(false, "Not implemented yet"); 100 102 } 101 103 102 103 void QTDialog::queryInt(const char *title, int *target,string) 104 { 105 registerQuery(new IntQTQuery(title,target,inputLayout,this)); 106 } 107 108 void QTDialog::queryDouble(const char* title, double* target,string){ 109 registerQuery(new DoubleQTQuery(title,target,inputLayout,this)); 110 } 111 112 void QTDialog::queryString(const char* title, std::string *target,string) 113 { 114 registerQuery(new StringQTQuery(title,target,inputLayout,this)); 115 } 116 117 void QTDialog::queryStrings(const char* title, std::vector<std::string> *target,string) 118 { 119 registerQuery(new StringsQTQuery(title,target,inputLayout,this)); 120 } 121 122 void QTDialog::queryMolecule(const char *title,molecule **target,string) 123 { 124 registerQuery(new MoleculeQTQuery(title,target,inputLayout,this)); 125 } 126 127 void QTDialog::queryVector(const char* title, Vector *target, bool check,string) { 128 registerQuery(new VectorQTQuery(title,target,check,inputLayout,this)); 129 } 130 131 void QTDialog::queryElement(const char* title, std::vector<element *> *target,string){ 132 registerQuery(new ElementQTQuery(title,target,inputLayout,this)); 104 void QTDialog::queryBox(char const*, string){ 105 // TODO 106 ASSERT(false, "Not implemented yet"); 107 } 108 109 110 void QTDialog::queryInt(const char *title,string) 111 { 112 registerQuery(new IntQTQuery(title,inputLayout,this)); 113 } 114 115 void QTDialog::queryInts(const char *title,string) 116 { 117 registerQuery(new IntsQTQuery(title,inputLayout,this)); 118 } 119 120 void QTDialog::queryDouble(const char* title,string){ 121 registerQuery(new DoubleQTQuery(title,inputLayout,this)); 122 } 123 124 void QTDialog::queryDoubles(const char* title,string){ 125 registerQuery(new DoublesQTQuery(title,inputLayout,this)); 126 } 127 128 void QTDialog::queryString(const char* title,string) 129 { 130 registerQuery(new StringQTQuery(title,inputLayout,this)); 131 } 132 133 void QTDialog::queryStrings(const char* title,string) 134 { 135 registerQuery(new StringsQTQuery(title,inputLayout,this)); 136 } 137 138 void QTDialog::queryMolecule(const char *title,string) 139 { 140 registerQuery(new MoleculeQTQuery(title,inputLayout,this)); 141 } 142 143 void QTDialog::queryMolecules(const char *title,string) 144 { 145 // TODO 146 ASSERT(false, "Not implemented yet"); 147 } 148 149 void QTDialog::queryVector(const char* title, bool check,string) { 150 registerQuery(new VectorQTQuery(title,check,inputLayout,this)); 151 } 152 153 void QTDialog::queryVectors(const char* title, bool check,string) { 154 // TODO 155 ASSERT(false, "Not implemented yet"); 156 } 157 158 void QTDialog::queryElement(const char* title, string){ 159 registerQuery(new ElementQTQuery(title,inputLayout,this)); 160 } 161 162 void QTDialog::queryElements(const char* title, string){ 163 // TODO 164 ASSERT(false, "Not implemented yet"); 133 165 } 134 166 135 167 /************************** Query Objects *******************************/ 136 168 137 QTDialog::IntQTQuery::IntQTQuery(string _title, int *_target,QBoxLayout *_parent,QTDialog *_dialog) :138 Dialog::IntQuery(_title ,_target),169 QTDialog::IntQTQuery::IntQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) : 170 Dialog::IntQuery(_title), 139 171 parent(_parent) 140 172 { … … 157 189 } 158 190 159 // Handling is easy since the GUI makes it impossible to enter invalid values 160 bool QTDialog::IntQTQuery::handle() 161 { 162 return true; 163 } 164 165 QTDialog::DoubleQTQuery::DoubleQTQuery(string title,double *_target,QBoxLayout *_parent,QTDialog *_dialog) : 166 Dialog::DoubleQuery(title,_target), 191 bool QTDialog::IntQTQuery::handle() { 192 return true; 193 } 194 195 196 QTDialog::IntsQTQuery::IntsQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) : 197 Dialog::IntsQuery(_title), 198 parent(_parent) 199 { 200 QHBoxLayout * thisHLayout = new QHBoxLayout(); 201 QVBoxLayout * thisV1Layout = new QVBoxLayout(); 202 QVBoxLayout * thisV2Layout = new QVBoxLayout(); 203 204 QLabel *titleLabel = new QLabel(QString(getTitle().c_str())); 205 QLabel *inputLabel = new QLabel("Enter to add"); 206 QListWidget* inputList = new QListWidget(); 207 inputList->setSelectionMode(QAbstractItemView::ExtendedSelection); 208 QLineEdit* inputBox = new QLineEdit(); 209 inputLabel->setBuddy(inputBox); 210 titleLabel->setBuddy(inputList); 211 QPushButton* AddButton = new QPushButton("Add"); 212 AddButton->setEnabled(false); 213 QPushButton* RemoveButton = new QPushButton("Remove"); 214 RemoveButton->setEnabled(false); 215 216 thisV1Layout->addWidget(titleLabel); 217 thisV1Layout->addWidget(inputList); 218 thisV2Layout->addWidget(inputLabel); 219 thisV2Layout->addWidget(inputBox); 220 thisV2Layout->addWidget(AddButton); 221 thisV2Layout->addWidget(RemoveButton); 222 parent->addLayout(thisHLayout); 223 thisHLayout->addLayout(thisV1Layout); 224 thisHLayout->addLayout(thisV2Layout); 225 226 pipe = new QTQueryListPipe<int>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton); 227 connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&))); 228 connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected())); 229 connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue())); 230 connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow())); 231 } 232 233 QTDialog::IntsQTQuery::~IntsQTQuery() 234 { 235 delete pipe; 236 } 237 238 bool QTDialog::IntsQTQuery::handle() { 239 return true; 240 } 241 242 243 QTDialog::DoubleQTQuery::DoubleQTQuery(string title,QBoxLayout *_parent,QTDialog *_dialog) : 244 Dialog::DoubleQuery(title), 167 245 parent(_parent) 168 246 { … … 192 270 193 271 194 QTDialog::StringQTQuery::StringQTQuery(string _title,string *_target,QBoxLayout *_parent,QTDialog *_dialog) : 195 Dialog::StringQuery(_title,_target), 272 QTDialog::DoublesQTQuery::DoublesQTQuery(string title,QBoxLayout *_parent,QTDialog *_dialog) : 273 Dialog::DoublesQuery(title), 274 parent(_parent) 275 { 276 QHBoxLayout * thisHLayout = new QHBoxLayout(); 277 QVBoxLayout * thisV1Layout = new QVBoxLayout(); 278 QVBoxLayout * thisV2Layout = new QVBoxLayout(); 279 280 QLabel *titleLabel = new QLabel(QString(getTitle().c_str())); 281 QLabel *inputLabel = new QLabel("Enter to add"); 282 QListWidget* inputList = new QListWidget(); 283 inputList->setSelectionMode(QAbstractItemView::ExtendedSelection); 284 QLineEdit* inputBox = new QLineEdit(); 285 inputLabel->setBuddy(inputBox); 286 titleLabel->setBuddy(inputList); 287 QPushButton* AddButton = new QPushButton("Add"); 288 AddButton->setEnabled(false); 289 QPushButton* RemoveButton = new QPushButton("Remove"); 290 RemoveButton->setEnabled(false); 291 292 thisV1Layout->addWidget(titleLabel); 293 thisV1Layout->addWidget(inputList); 294 thisV2Layout->addWidget(inputLabel); 295 thisV2Layout->addWidget(inputBox); 296 thisV2Layout->addWidget(AddButton); 297 thisV2Layout->addWidget(RemoveButton); 298 parent->addLayout(thisHLayout); 299 thisHLayout->addLayout(thisV1Layout); 300 thisHLayout->addLayout(thisV2Layout); 301 302 pipe = new QTQueryListPipe<double>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton); 303 connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&))); 304 connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected())); 305 connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue())); 306 connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));} 307 308 QTDialog::DoublesQTQuery::~DoublesQTQuery() 309 { 310 delete pipe; 311 } 312 313 bool QTDialog::DoublesQTQuery::handle() { 314 return true; 315 } 316 317 318 QTDialog::StringQTQuery::StringQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) : 319 Dialog::StringQuery(_title), 196 320 parent(_parent) 197 321 { … … 219 343 } 220 344 221 QTDialog::StringsQTQuery::StringsQTQuery(string _title,vector<string> *_target,QBoxLayout *_parent,QTDialog *_dialog) : 222 Dialog::StringsQuery(_title,_target), 223 parent(_parent) 224 { 225 thisLayout = new QHBoxLayout(); 226 titleLabel = new QLabel(QString(getTitle().c_str())); 227 inputBox = new QLineEdit(); 228 parent->addLayout(thisLayout); 229 thisLayout->addWidget(titleLabel); 230 thisLayout->addWidget(inputBox); 231 232 pipe = new StringQTQueryPipe(&temp,_dialog); 233 pipe->update(inputBox->text()); 234 connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(update(const QString&))); 235 } 345 QTDialog::StringsQTQuery::StringsQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) : 346 Dialog::StringsQuery(_title), 347 parent(_parent) 348 { 349 QHBoxLayout * thisHLayout = new QHBoxLayout(); 350 QVBoxLayout * thisV1Layout = new QVBoxLayout(); 351 QVBoxLayout * thisV2Layout = new QVBoxLayout(); 352 353 QLabel *titleLabel = new QLabel(QString(getTitle().c_str())); 354 QLabel *inputLabel = new QLabel("Enter to add"); 355 QListWidget* inputList = new QListWidget(); 356 inputList->setSelectionMode(QAbstractItemView::ExtendedSelection); 357 QLineEdit* inputBox = new QLineEdit(); 358 inputLabel->setBuddy(inputBox); 359 titleLabel->setBuddy(inputList); 360 QPushButton* AddButton = new QPushButton("Add"); 361 AddButton->setEnabled(false); 362 QPushButton* RemoveButton = new QPushButton("Remove"); 363 RemoveButton->setEnabled(false); 364 365 thisV1Layout->addWidget(titleLabel); 366 thisV1Layout->addWidget(inputList); 367 thisV2Layout->addWidget(inputLabel); 368 thisV2Layout->addWidget(inputBox); 369 thisV2Layout->addWidget(AddButton); 370 thisV2Layout->addWidget(RemoveButton); 371 parent->addLayout(thisHLayout); 372 thisHLayout->addLayout(thisV1Layout); 373 thisHLayout->addLayout(thisV2Layout); 374 375 pipe = new QTQueryListPipe<std::string>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton); 376 connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&))); 377 connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected())); 378 connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue())); 379 connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));} 236 380 237 381 QTDialog::StringsQTQuery::~StringsQTQuery() … … 257 401 } 258 402 259 QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, molecule **_target,QBoxLayout *_parent,QTDialog *_dialog) :260 Dialog::MoleculeQuery(_title ,_target),403 QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, QBoxLayout *_parent,QTDialog *_dialog) : 404 Dialog::MoleculeQuery(_title), 261 405 parent(_parent) 262 406 { … … 293 437 } 294 438 295 QTDialog::VectorQTQuery::VectorQTQuery(std::string title, Vector *_target, bool _check,QBoxLayout *_parent,QTDialog *_dialog) : 296 Dialog::VectorQuery(title,_target,_check), 439 QTDialog::MoleculesQTQuery::MoleculesQTQuery(string _title, QBoxLayout *_parent,QTDialog *_dialog) : 440 Dialog::MoleculesQuery(_title), 441 parent(_parent) 442 { 443 thisLayout = new QHBoxLayout(); 444 titleLabel = new QLabel(QString(getTitle().c_str())); 445 inputBox = new QComboBox(); 446 // add all molecules to the combo box 447 vector<molecule*> molecules = World::getInstance().getAllMolecules(); 448 for(vector<molecule*>::iterator iter = molecules.begin(); 449 iter != molecules.end(); 450 ++iter) { 451 stringstream sstr; 452 sstr << (*iter)->IndexNr << "\t" << (*iter)->getName(); 453 inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr)); 454 } 455 parent->addLayout(thisLayout); 456 thisLayout->addWidget(titleLabel); 457 thisLayout->addWidget(inputBox); 458 459 pipe = new MoleculesQTQueryPipe(&tmp,_dialog,inputBox); 460 pipe->update(inputBox->currentIndex()); 461 connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); 462 } 463 464 QTDialog::MoleculesQTQuery::~MoleculesQTQuery() 465 { 466 delete pipe; 467 } 468 469 // Handling is easy, since the GUI makes it impossible to select invalid values 470 bool QTDialog::MoleculesQTQuery::handle() 471 { 472 return true; 473 } 474 475 QTDialog::VectorQTQuery::VectorQTQuery(std::string title, bool _check,QBoxLayout *_parent,QTDialog *_dialog) : 476 Dialog::VectorQuery(title,_check), 297 477 parent(_parent) 298 478 { … … 304 484 subLayout = new QVBoxLayout(); 305 485 mainLayout->addLayout(subLayout); 306 for(int i=0; i<3; i++) { 307 coordLayout[i] = new QHBoxLayout(); 308 subLayout->addLayout(coordLayout[i]); 309 coordLabel[i] = new QLabel(QString(coords[i])); 310 coordLayout[i]->addWidget(coordLabel[i]); 311 coordInput[i] = new QDoubleSpinBox(); 312 coordInput[i]->setRange(0,M.at(i,i)); 313 coordInput[i]->setDecimals(3); 314 coordLayout[i]->addWidget(coordInput[i]); 315 pipe[i] = new DoubleQTQueryPipe(&((*tmp)[i]),_dialog); 316 pipe[i]->update(coordInput[i]->value()); 317 connect(coordInput[i],SIGNAL(valueChanged(double)),pipe[i],SLOT(update(double))); 318 319 } 486 QComboBox* inputBox = new QComboBox(); 487 coordLayout = new QHBoxLayout(); 488 subLayout->addLayout(coordLayout); 489 coordLabel = new QLabel(QString("x,y,z")); 490 coordLayout->addWidget(coordLabel); 491 coordInput = new QDoubleSpinBox(); 492 // coordInput->setRange(0,M.at(i,i)); 493 coordInput->setDecimals(3); 494 coordLayout->addWidget(coordInput); 495 pipe = new VectorQTQueryPipe(&(tmp),_dialog,inputBox); 496 //pipe->update(coordInput->value()); 497 connect(coordInput,SIGNAL(valueChanged(double)),pipe,SLOT(update(double))); 320 498 parent->addLayout(mainLayout); 321 499 } … … 329 507 330 508 331 QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, vector<element *> *_target, QBoxLayout *_parent, QTDialog *_dialog) : 332 Dialog::ElementQuery(_title,_target), 509 QTDialog::VectorsQTQuery::VectorsQTQuery(std::string title, bool _check,QBoxLayout *_parent,QTDialog *_dialog) : 510 Dialog::VectorsQuery(title,_check), 511 parent(_parent) 512 { 513 const Matrix& M = World::getInstance().getDomain().getM(); 514 const char *coords[3] = {"x:","y:","z:"}; 515 mainLayout= new QHBoxLayout(); 516 titleLabel = new QLabel(QString(getTitle().c_str())); 517 mainLayout->addWidget(titleLabel); 518 subLayout = new QVBoxLayout(); 519 mainLayout->addLayout(subLayout); 520 QComboBox* inputBox = new QComboBox(); 521 coordLayout = new QHBoxLayout(); 522 subLayout->addLayout(coordLayout); 523 coordLabel = new QLabel(QString("x,y,z")); 524 coordLayout->addWidget(coordLabel); 525 coordInput = new QDoubleSpinBox(); 526 // coordInput->setRange(0,M.at(i,i)); 527 coordInput->setDecimals(3); 528 coordLayout->addWidget(coordInput); 529 pipe = new VectorsQTQueryPipe(&(tmp),_dialog,inputBox); 530 //pipe->update(coordInput->value()); 531 connect(coordInput,SIGNAL(valueChanged(double)),pipe,SLOT(update(double))); 532 parent->addLayout(mainLayout); 533 } 534 535 QTDialog::VectorsQTQuery::~VectorsQTQuery() 536 {} 537 538 bool QTDialog::VectorsQTQuery::handle() { 539 return true; 540 } 541 542 543 QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog) : 544 Dialog::ElementQuery(_title), 333 545 parent(_parent) 334 546 { … … 349 561 thisLayout->addWidget(inputBox); 350 562 351 pipe = new ElementQTQueryPipe(& elements,_dialog,inputBox);563 pipe = new ElementQTQueryPipe(&tmp,_dialog,inputBox); 352 564 pipe->update(inputBox->currentIndex()); 353 565 connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); … … 363 575 } 364 576 577 578 QTDialog::ElementsQTQuery::ElementsQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog) : 579 Dialog::ElementsQuery(_title), 580 parent(_parent) 581 { 582 periodentafel *periode = World::getInstance().getPeriode(); 583 thisLayout = new QHBoxLayout(); 584 titleLabel = new QLabel(QString(getTitle().c_str())); 585 inputBox = new QComboBox(); 586 for(periodentafel::const_iterator iter = periode->begin(); 587 iter!=periode->end(); 588 ++iter) 589 { 590 stringstream sstr; 591 sstr << (*iter).first << "\t" << (*iter).second->name; 592 inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first)); 593 } 594 parent->addLayout(thisLayout); 595 thisLayout->addWidget(titleLabel); 596 thisLayout->addWidget(inputBox); 597 598 pipe = new ElementsQTQueryPipe(&tmp,_dialog,inputBox); 599 pipe->update(inputBox->currentIndex()); 600 connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); 601 } 602 603 QTDialog::ElementsQTQuery::~ElementsQTQuery() 604 { 605 delete pipe; 606 } 607 608 bool QTDialog::ElementsQTQuery::handle(){ 609 return true; 610 } 611 365 612 /*************************** Plumbing *******************************/ 613 614 615 template<typename T> QTQueryListPipe<T>::QTQueryListPipe(std::vector<T> *_content, QTDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton) : 616 content(_content), 617 dialog(_dialog), 618 inputBox(_inputBox), 619 inputList(_inputList), 620 AddButton(_AddButton), 621 RemoveButton(_RemoveButton) 622 {} 623 624 template<typename T> QTQueryListPipe<T>::~QTQueryListPipe() 625 {} 626 627 template<typename T> void QTQueryListPipe<T>::IntegerEntered(const QString&) 628 { 629 AddButton->setEnabled(true); 630 } 631 632 template<typename T> void QTQueryListPipe<T>::IntegerSelected() 633 { 634 if (inputList->selectedItems().empty()) 635 RemoveButton->setEnabled(false); 636 else 637 RemoveButton->setEnabled(true); 638 } 639 640 template<typename T> void QTQueryListPipe<T>::AddInteger() { 641 // type-check 642 std::string text = inputBox->text().toStdString(); 643 int number = 0; 644 try { 645 number = boost::lexical_cast<int>(text); 646 } catch (boost::bad_lexical_cast&) { 647 return; 648 }; 649 // add item to both 650 inputList->addItem(QString(number)); 651 AddValue(number); 652 } 653 654 template<typename T> void QTQueryListPipe<T>::AddValue(T item) { 655 content->push_back(item); 656 657 dialog->update(); 658 } 659 660 template<typename T> void QTQueryListPipe<T>::RemoveInteger() { 661 QList<QListWidgetItem *> items = inputList->selectedItems(); 662 for (QList<QListWidgetItem *>::iterator iter = items.begin(); !items.empty(); iter = items.begin()) { 663 // obtain which position item has (by making it current item) 664 inputList->setCurrentItem(*iter); 665 // remove 666 QTQueryListPipe<T>::RemoteRow(inputList->currentRow()); // template parameters needs to be known, such that compiler knows which to call 667 inputList->removeItemWidget(*iter); 668 } 669 } 670 671 template<typename T> void QTQueryListPipe<T>::RemoveRow(int row) { 672 int counter = 0; 673 typename std::vector<T>::iterator iter = content->begin(); 674 for (; iter != content->end(); ++iter) 675 if (counter++ == row) 676 break; 677 if (iter != content->end()) 678 content->erase(iter); 679 } 680 366 681 367 682 StringQTQueryPipe::StringQTQueryPipe(string *_content, QTDialog *_dialog) : … … 403 718 dialog->update(); 404 719 } 720 721 VectorQTQueryPipe::VectorQTQueryPipe(Vector *_content, QTDialog *_dialog, QComboBox *_theBox) : 722 content(_content), 723 dialog(_dialog), 724 theBox(_theBox) 725 {} 726 727 VectorQTQueryPipe::~VectorQTQueryPipe() 728 {} 729 730 void VectorQTQueryPipe::update() { 731 dialog->update(); 732 } 733 734 VectorsQTQueryPipe::VectorsQTQueryPipe(std::vector<Vector> *_content, QTDialog *_dialog, QComboBox *_theBox) : 735 content(_content), 736 dialog(_dialog), 737 theBox(_theBox) 738 {} 739 740 VectorsQTQueryPipe::~VectorsQTQueryPipe() 741 {} 742 743 void VectorsQTQueryPipe::update() { 744 dialog->update(); 745 } 746 747 AtomQTQueryPipe::AtomQTQueryPipe(atom **_content, QTDialog *_dialog, QComboBox *_theBox) : 748 content(_content), 749 dialog(_dialog), 750 theBox(_theBox) 751 {} 752 753 AtomQTQueryPipe::~AtomQTQueryPipe() 754 {} 755 756 void AtomQTQueryPipe::update(int newIndex) { 757 QVariant data = theBox->itemData(newIndex); 758 int idx = data.toInt(); 759 (*content) = World::getInstance().getAtom(AtomById(idx)); 760 dialog->update(); 761 } 762 763 764 AtomsQTQueryPipe::AtomsQTQueryPipe(std::vector<atom *>*_content, QTDialog *_dialog, QComboBox *_theBox) : 765 content(_content), 766 dialog(_dialog), 767 theBox(_theBox) 768 {} 769 770 AtomsQTQueryPipe::~AtomsQTQueryPipe() 771 {} 772 773 void AtomsQTQueryPipe::update(int newIndex) { 774 QVariant data = theBox->itemData(newIndex); 775 int idx = data.toInt(); 776 atom *Walker = World::getInstance().getAtom(AtomById(idx)); 777 if (Walker) 778 (*content).push_back(Walker) ; 779 dialog->update(); 780 } 781 405 782 406 783 MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox) : … … 420 797 } 421 798 422 ElementQTQueryPipe::ElementQTQueryPipe(std::vector<element *> *_content, QTDialog *_dialog, QComboBox *_theBox) : 799 800 MoleculesQTQueryPipe::MoleculesQTQueryPipe(std::vector<molecule *>*_content, QTDialog *_dialog, QComboBox *_theBox) : 423 801 content(_content), 424 802 dialog(_dialog), 425 803 theBox(_theBox) 426 { 427 content->resize(1); 428 } 804 {} 805 806 MoleculesQTQueryPipe::~MoleculesQTQueryPipe() 807 {} 808 809 void MoleculesQTQueryPipe::update(int newIndex) { 810 QVariant data = theBox->itemData(newIndex); 811 int idx = data.toInt(); 812 molecule *mol = World::getInstance().getMolecule(MoleculeById(idx)); 813 if (mol) 814 (*content).push_back(mol); 815 dialog->update(); 816 } 817 818 ElementQTQueryPipe::ElementQTQueryPipe(element **_content, QTDialog *_dialog, QComboBox *_theBox) : 819 content(_content), 820 dialog(_dialog), 821 theBox(_theBox) 822 {} 429 823 430 824 ElementQTQueryPipe::~ElementQTQueryPipe() … … 434 828 QVariant data = theBox->itemData(newIndex); 435 829 int idx = data.toInt(); 436 (*content)[0] = World::getInstance().getPeriode()->FindElement(idx); 437 dialog->update(); 438 } 439 830 *content = World::getInstance().getPeriode()->FindElement(idx); 831 dialog->update(); 832 } 833 834 ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox) : 835 content(_content), 836 dialog(_dialog), 837 theBox(_theBox) 838 {} 839 840 ElementsQTQueryPipe::~ElementsQTQueryPipe() 841 {} 842 843 void ElementsQTQueryPipe::update(int newIndex) { 844 QVariant data = theBox->itemData(newIndex); 845 int idx = data.toInt(); 846 element *elemental = World::getInstance().getPeriode()->FindElement(idx); 847 if(elemental) 848 (*content).push_back(elemental); 849 dialog->update(); 850 } 851 852 -
src/UIElements/QT4/QTDialog.hpp
r7067bd6 r677e13 17 17 class QDoubleSpinBox; 18 18 class QLineEdit; 19 class QListWidget; 19 20 class QComboBox; 20 21 class QDialogButtonBox; … … 22 23 23 24 // Forward declarations for plumbing 25 template<typename T> class QTQueryListPipe; 24 26 class StringQTQueryPipe; 27 class StringsQTQueryPipe; 25 28 class IntQTQueryPipe; 26 29 class DoubleQTQueryPipe; 30 class DoublesQTQueryPipe; 31 class AtomQTQueryPipe; 32 class AtomsQTQueryPipe; 27 33 class MoleculeQTQueryPipe; 34 class MoleculesQTQueryPipe; 28 35 class ElementQTQueryPipe; 36 class ElementsQTQueryPipe; 37 class VectorQTQueryPipe; 38 class VectorsQTQueryPipe; 29 39 30 40 class QTDialog : public QDialog, public Dialog … … 36 46 37 47 virtual void queryEmpty(const char*, std::string); 38 virtual void queryBoolean(const char *, bool *, std::string = ""); 39 virtual void queryInt(const char *, int *,std::string = ""); 40 virtual void queryDouble(const char*,double *,std::string = ""); 41 virtual void queryString(const char*, std::string *,std::string = ""); 42 virtual void queryStrings(const char*, std::vector<std::string> *,std::string = ""); 43 virtual void queryAtom(const char*,atom**,std::string = ""); 44 virtual void queryMolecule(const char*,molecule**,std::string = ""); 45 virtual void queryVector(const char*,Vector *,bool,std::string = ""); 46 virtual void queryBox(const char*,Box*, std::string = ""); 47 virtual void queryElement(const char*,std::vector<element *> *_target,std::string = ""); 48 virtual void queryBoolean(const char *, std::string = ""); 49 virtual void queryInt(const char *,std::string = ""); 50 virtual void queryInts(const char *,std::string = ""); 51 virtual void queryDouble(const char*,std::string = ""); 52 virtual void queryDoubles(const char*,std::string = ""); 53 virtual void queryString(const char*,std::string = ""); 54 virtual void queryStrings(const char*,std::string = ""); 55 virtual void queryAtom(const char*,std::string = ""); 56 virtual void queryAtoms(const char*,std::string = ""); 57 virtual void queryMolecule(const char*,std::string = ""); 58 virtual void queryMolecules(const char*,std::string = ""); 59 virtual void queryVector(const char*,bool,std::string = ""); 60 virtual void queryVectors(const char*,bool,std::string = ""); 61 virtual void queryBox(const char*, std::string = ""); 62 virtual void queryElement(const char*,std::string = ""); 63 virtual void queryElements(const char*,std::string = ""); 48 64 49 65 virtual bool display(); … … 54 70 class IntQTQuery : public Dialog::IntQuery { 55 71 public: 56 IntQTQuery(std::string _title, int *_target,QBoxLayout *_parent,QTDialog *_dialog);72 IntQTQuery(std::string _title,QBoxLayout *_parent,QTDialog *_dialog); 57 73 virtual ~IntQTQuery(); 58 74 virtual bool handle(); … … 66 82 }; 67 83 84 class IntsQTQuery : public Dialog::IntsQuery { 85 public: 86 IntsQTQuery(std::string _title,QBoxLayout *_parent,QTDialog *_dialog); 87 virtual ~IntsQTQuery(); 88 virtual bool handle(); 89 void IntegerEntered(const QString&); 90 void IntegerSelected(); 91 void AddInteger(); 92 void RemoveInteger(); 93 private: 94 QBoxLayout *parent; 95 QBoxLayout *thisLayout; 96 QLabel *titleLabel; 97 98 QTQueryListPipe<int> *pipe; 99 }; 100 68 101 class DoubleQTQuery : public Dialog::DoubleQuery { 69 102 public: 70 DoubleQTQuery(std::string title, double *_target,QBoxLayout *_parent,QTDialog *_dialog);103 DoubleQTQuery(std::string title,QBoxLayout *_parent,QTDialog *_dialog); 71 104 virtual ~DoubleQTQuery(); 72 105 virtual bool handle(); … … 80 113 }; 81 114 115 class DoublesQTQuery : public Dialog::DoublesQuery { 116 public: 117 DoublesQTQuery(std::string title,QBoxLayout *_parent,QTDialog *_dialog); 118 virtual ~DoublesQTQuery(); 119 virtual bool handle(); 120 private: 121 QBoxLayout *parent; 122 QBoxLayout *thisLayout; 123 QLabel *titleLabel; 124 QDoubleSpinBox *inputBox; 125 126 QTQueryListPipe<double> *pipe; 127 }; 128 82 129 class StringQTQuery : public Dialog::StringQuery { 83 130 public: 84 StringQTQuery(std::string _title, std::string *_target,QBoxLayout *_parent,QTDialog *_dialog);131 StringQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog); 85 132 virtual ~StringQTQuery(); 86 133 virtual bool handle(); … … 96 143 class StringsQTQuery : public Dialog::StringsQuery { 97 144 public: 98 StringsQTQuery(std::string _title, std::vector<std::string> *_target,QBoxLayout *_parent,QTDialog *_dialog);145 StringsQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog); 99 146 virtual ~StringsQTQuery(); 100 147 virtual bool handle(); … … 105 152 QLineEdit *inputBox; 106 153 107 StringQTQueryPipe *pipe; 154 QTQueryListPipe<std::string> *pipe; 155 }; 156 157 class AtomQTQuery : public Dialog::AtomQuery { 158 public: 159 AtomQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog); 160 virtual ~AtomQTQuery(); 161 virtual bool handle(); 162 private: 163 QBoxLayout *parent; 164 QBoxLayout *thisLayout; 165 QLabel *titleLabel; 166 QComboBox *inputBox; 167 168 AtomQTQueryPipe *pipe; 169 }; 170 171 class AtomsQTQuery : public Dialog::AtomsQuery { 172 public: 173 AtomsQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog); 174 virtual ~AtomsQTQuery(); 175 virtual bool handle(); 176 private: 177 QBoxLayout *parent; 178 QBoxLayout *thisLayout; 179 QLabel *titleLabel; 180 QComboBox *inputBox; 181 182 AtomsQTQueryPipe *pipe; 108 183 }; 109 184 110 185 class MoleculeQTQuery : public Dialog::MoleculeQuery { 111 186 public: 112 MoleculeQTQuery(std::string _title, molecule **_target,QBoxLayout *_parent,QTDialog *_dialog);187 MoleculeQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog); 113 188 virtual ~MoleculeQTQuery(); 114 189 virtual bool handle(); … … 122 197 }; 123 198 199 class MoleculesQTQuery : public Dialog::MoleculesQuery { 200 public: 201 MoleculesQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog); 202 virtual ~MoleculesQTQuery(); 203 virtual bool handle(); 204 private: 205 QBoxLayout *parent; 206 QBoxLayout *thisLayout; 207 QLabel *titleLabel; 208 QComboBox *inputBox; 209 210 MoleculesQTQueryPipe *pipe; 211 }; 212 124 213 class VectorQTQuery : public Dialog::VectorQuery { 125 214 public: 126 VectorQTQuery(std::string title, Vector *_target,bool _check,QBoxLayout *,QTDialog *);215 VectorQTQuery(std::string title,bool _check,QBoxLayout *,QTDialog *); 127 216 virtual ~VectorQTQuery(); 128 217 virtual bool handle(); … … 132 221 QLabel *titleLabel; 133 222 QBoxLayout *subLayout; 134 QBoxLayout *coordLayout[3]; 135 QLabel *coordLabel[3]; 136 QDoubleSpinBox *coordInput[3]; 137 138 DoubleQTQueryPipe *pipe[3]; 223 QBoxLayout *coordLayout; 224 QLabel *coordLabel; 225 QDoubleSpinBox *coordInput; 226 227 VectorQTQueryPipe *pipe; 228 }; 229 230 class VectorsQTQuery : public Dialog::VectorsQuery { 231 public: 232 VectorsQTQuery(std::string title,bool _check,QBoxLayout *,QTDialog *); 233 virtual ~VectorsQTQuery(); 234 virtual bool handle(); 235 private: 236 QBoxLayout *parent; 237 QBoxLayout *mainLayout; 238 QLabel *titleLabel; 239 QBoxLayout *subLayout; 240 QBoxLayout *coordLayout; 241 QLabel *coordLabel; 242 QDoubleSpinBox *coordInput; 243 244 VectorsQTQueryPipe *pipe; 139 245 }; 140 246 141 247 class ElementQTQuery : public Dialog::ElementQuery { 142 248 public: 143 ElementQTQuery(std::string _title, std::vector<element *> *_target,QBoxLayout *_parent, QTDialog *_dialog);249 ElementQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog); 144 250 virtual ~ElementQTQuery(); 145 251 virtual bool handle(); … … 151 257 152 258 ElementQTQueryPipe *pipe; 259 }; 260 261 class ElementsQTQuery : public Dialog::ElementsQuery { 262 public: 263 ElementsQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog); 264 virtual ~ElementsQTQuery(); 265 virtual bool handle(); 266 private: 267 QBoxLayout *parent; 268 QBoxLayout *thisLayout; 269 QLabel *titleLabel; 270 QComboBox *inputBox; 271 272 ElementsQTQueryPipe *pipe; 153 273 }; 154 274 … … 164 284 // since MOC doesn't like nested classes 165 285 286 287 template<typename T> class QTQueryListPipe : public QWidget { 288 public: 289 QTQueryListPipe(std::vector<T> *_content, QTDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton); 290 virtual ~QTQueryListPipe(); 291 void AddInteger(); 292 void RemoveInteger(); 293 void IntegerSelected(); 294 void IntegerEntered(const QString&); 295 296 private: 297 void AddValue(T item); 298 void RemoveRow(int row); 299 300 std::vector<T> *content; 301 QTDialog *dialog; 302 QLineEdit *inputBox; 303 QListWidget *inputList; 304 QPushButton *AddButton; 305 QPushButton *RemoveButton; 306 }; 307 308 166 309 class StringQTQueryPipe : public QWidget { 167 310 Q_OBJECT … … 194 337 }; 195 338 339 196 340 class DoubleQTQueryPipe : public QWidget { 197 341 Q_OBJECT … … 209 353 }; 210 354 355 class AtomQTQueryPipe : public QWidget { 356 Q_OBJECT 357 public: 358 AtomQTQueryPipe(atom **_content, QTDialog *_dialog, QComboBox *_theBox); 359 virtual ~AtomQTQueryPipe(); 360 361 public slots: 362 void update(int); 363 364 private: 365 atom **content; 366 QTDialog *dialog; 367 QComboBox *theBox; 368 369 }; 370 371 372 class AtomsQTQueryPipe : public QWidget { 373 Q_OBJECT 374 public: 375 AtomsQTQueryPipe(std::vector<atom *>*_content, QTDialog *_dialog, QComboBox *_theBox); 376 virtual ~AtomsQTQueryPipe(); 377 378 public slots: 379 void update(int); 380 381 private: 382 std::vector<atom *>*content; 383 QTDialog *dialog; 384 QComboBox *theBox; 385 386 }; 387 211 388 class MoleculeQTQueryPipe : public QWidget { 212 389 Q_OBJECT … … 225 402 }; 226 403 404 class MoleculesQTQueryPipe : public QWidget { 405 Q_OBJECT 406 public: 407 MoleculesQTQueryPipe(std::vector<molecule *>*_content, QTDialog *_dialog, QComboBox *_theBox); 408 virtual ~MoleculesQTQueryPipe(); 409 410 public slots: 411 void update(int); 412 413 private: 414 std::vector<molecule *>*content; 415 QTDialog *dialog; 416 QComboBox *theBox; 417 418 }; 419 420 class VectorQTQueryPipe : public QWidget { 421 Q_OBJECT 422 public: 423 VectorQTQueryPipe(Vector *_content, QTDialog *_dialog, QComboBox *_theBox); 424 virtual ~VectorQTQueryPipe(); 425 426 public slots: 427 void update(); 428 429 private: 430 Vector *content; 431 QTDialog *dialog; 432 QComboBox *theBox; 433 }; 434 435 class VectorsQTQueryPipe : public QWidget { 436 Q_OBJECT 437 public: 438 VectorsQTQueryPipe(std::vector<Vector>*_content, QTDialog *_dialog, QComboBox *_theBox); 439 virtual ~VectorsQTQueryPipe(); 440 441 public slots: 442 void update(); 443 444 private: 445 std::vector<Vector> *content; 446 QTDialog *dialog; 447 QComboBox *theBox; 448 }; 449 227 450 class ElementQTQueryPipe : public QWidget { 228 451 Q_OBJECT 229 452 public: 230 ElementQTQueryPipe( std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox);453 ElementQTQueryPipe(element **_content, QTDialog *_dialog, QComboBox *_theBox); 231 454 virtual ~ElementQTQueryPipe(); 232 455 … … 235 458 236 459 private: 237 std::vector<element *> *content; 460 element **content; 461 QTDialog *dialog; 462 QComboBox *theBox; 463 }; 464 465 class ElementsQTQueryPipe : public QWidget { 466 Q_OBJECT 467 public: 468 ElementsQTQueryPipe(std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox); 469 virtual ~ElementsQTQueryPipe(); 470 471 public slots: 472 void update(int); 473 474 private: 475 std::vector<element *>*content; 238 476 QTDialog *dialog; 239 477 QComboBox *theBox; -
src/UIElements/TextUI/TextDialog.cpp
r7067bd6 r677e13 30 30 using namespace std; 31 31 32 using boost::lexical_cast; 33 using boost::bad_lexical_cast; 34 32 35 33 36 TextDialog::TextDialog() … … 44 47 } 45 48 46 void TextDialog::queryBoolean(const char* title, bool* target, string description){ 47 registerQuery(new BooleanTextQuery(title,target,description)); 48 } 49 50 void TextDialog::queryInt(const char* title, int* target, string description){ 51 registerQuery(new IntTextQuery(title,target,description)); 52 } 53 54 void TextDialog::queryDouble(const char* title, double* target, string description){ 55 registerQuery(new DoubleTextQuery(title,target,description)); 56 } 57 58 void TextDialog::queryString(const char* title, string* target, string description){ 59 registerQuery(new StringTextQuery(title,target,description)); 60 } 61 62 void TextDialog::queryStrings(const char* title, vector<string>* target, string description){ 63 registerQuery(new StringsTextQuery(title,target,description)); 64 } 65 66 void TextDialog::queryAtom(const char* title, atom **target, string description) { 67 registerQuery(new AtomTextQuery(title,target,description)); 68 } 69 70 void TextDialog::queryMolecule(const char* title, molecule **target, string description) { 71 registerQuery(new MoleculeTextQuery(title,target,description)); 72 } 73 74 void TextDialog::queryVector(const char* title, Vector *target, bool check, string description) { 75 registerQuery(new VectorTextQuery(title,target,check,description)); 76 } 77 78 void TextDialog::queryBox(const char* title,Box* cellSize, string description) { 79 registerQuery(new BoxTextQuery(title,cellSize,description)); 80 } 81 82 void TextDialog::queryElement(const char* title, std::vector<element *> *target, string description){ 83 registerQuery(new ElementTextQuery(title,target,description)); 49 void TextDialog::queryBoolean(const char* title, string description){ 50 registerQuery(new BooleanTextQuery(title,description)); 51 } 52 53 void TextDialog::queryInt(const char* title, string description){ 54 registerQuery(new IntTextQuery(title,description)); 55 } 56 57 void TextDialog::queryInts(const char* title, string description){ 58 registerQuery(new IntsTextQuery(title,description)); 59 } 60 61 void TextDialog::queryDouble(const char* title, string description){ 62 registerQuery(new DoubleTextQuery(title,description)); 63 } 64 65 void TextDialog::queryDoubles(const char* title, string description){ 66 registerQuery(new DoublesTextQuery(title,description)); 67 } 68 69 void TextDialog::queryString(const char* title, string description){ 70 registerQuery(new StringTextQuery(title,description)); 71 } 72 73 void TextDialog::queryStrings(const char* title, string description){ 74 registerQuery(new StringsTextQuery(title,description)); 75 } 76 77 void TextDialog::queryAtom(const char* title, string description) { 78 registerQuery(new AtomTextQuery(title,description)); 79 } 80 81 void TextDialog::queryAtoms(const char* title, string description) { 82 registerQuery(new AtomsTextQuery(title,description)); 83 } 84 85 void TextDialog::queryMolecule(const char* title, string description) { 86 registerQuery(new MoleculeTextQuery(title,description)); 87 } 88 89 void TextDialog::queryMolecules(const char* title, string description) { 90 registerQuery(new MoleculesTextQuery(title,description)); 91 } 92 93 void TextDialog::queryVector(const char* title, bool check, string description) { 94 registerQuery(new VectorTextQuery(title,check,description)); 95 } 96 97 void TextDialog::queryVectors(const char* title, bool check, string description) { 98 registerQuery(new VectorsTextQuery(title,check,description)); 99 } 100 101 void TextDialog::queryBox(const char* title, string description) { 102 registerQuery(new BoxTextQuery(title,description)); 103 } 104 105 void TextDialog::queryElement(const char* title, string description){ 106 registerQuery(new ElementTextQuery(title,description)); 107 } 108 109 void TextDialog::queryElements(const char* title, string description){ 110 registerQuery(new ElementsTextQuery(title,description)); 84 111 } 85 112 … … 97 124 } 98 125 99 TextDialog::IntTextQuery::IntTextQuery(string title, int * _target,std::string _description) :100 Dialog::IntQuery(title,_ target,_description)126 TextDialog::IntTextQuery::IntTextQuery(string title, std::string _description) : 127 Dialog::IntQuery(title,_description) 101 128 {} 102 129 … … 121 148 } 122 149 123 TextDialog::BooleanTextQuery::BooleanTextQuery(string title, bool * _target, std::string _description) : 124 Dialog::BooleanQuery(title,_target,_description) 150 TextDialog::IntsTextQuery::IntsTextQuery(string title, std::string _description) : 151 Dialog::IntsQuery(title,_description) 152 {} 153 154 TextDialog::IntsTextQuery::~IntsTextQuery() {} 155 156 bool TextDialog::IntsTextQuery::handle() { 157 Log() << Verbose(0) << getTitle(); 158 std::string line; 159 getline(cin,line); 160 // dissect by " " 161 string::iterator olditer = line.begin(); 162 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) { 163 if (*iter == ' ') { 164 std::istringstream stream(string(iter, olditer)); 165 stream >> temp; 166 tmp.push_back(temp); 167 olditer = iter; 168 } 169 } 170 if (olditer != line.begin()) { // insert last part also 171 std::istringstream stream(string(olditer, line.end())); 172 stream >> temp; 173 tmp.push_back(temp); 174 } 175 176 return true; 177 } 178 179 TextDialog::BooleanTextQuery::BooleanTextQuery(string title, std::string _description) : 180 Dialog::BooleanQuery(title,_description) 125 181 {} 126 182 … … 150 206 } 151 207 152 TextDialog::StringTextQuery::StringTextQuery(string title, string *_target,std::string _description) :153 Dialog::StringQuery(title,_ target,_description)208 TextDialog::StringTextQuery::StringTextQuery(string title, std::string _description) : 209 Dialog::StringQuery(title,_description) 154 210 {} 155 211 … … 162 218 } 163 219 164 TextDialog::StringsTextQuery::StringsTextQuery(string title, vector<string> *_target,std::string _description) :165 Dialog::StringsQuery(title,_ target,_description)220 TextDialog::StringsTextQuery::StringsTextQuery(string title, std::string _description) : 221 Dialog::StringsQuery(title,_description) 166 222 {} 167 223 … … 171 227 Log() << Verbose(0) << getTitle(); 172 228 getline(cin,temp); 173 // dissect by " ,"229 // dissect by " " 174 230 string::iterator olditer = temp.begin(); 175 231 for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) { … … 185 241 } 186 242 187 TextDialog::DoubleTextQuery::DoubleTextQuery(string title, double *_target,std::string _description) :188 Dialog::DoubleQuery(title,_ target,_description)243 TextDialog::DoubleTextQuery::DoubleTextQuery(string title, std::string _description) : 244 Dialog::DoubleQuery(title,_description) 189 245 {} 190 246 … … 208 264 } 209 265 210 TextDialog::AtomTextQuery::AtomTextQuery(string title, atom **_target, std::string _description) : 211 Dialog::AtomQuery(title,_target,_description) 266 267 TextDialog::DoublesTextQuery::DoublesTextQuery(string title, std::string _description) : 268 Dialog::DoublesQuery(title,_description) 269 {} 270 271 TextDialog::DoublesTextQuery::~DoublesTextQuery() {} 272 273 bool TextDialog::DoublesTextQuery::handle() { 274 Log() << Verbose(0) << getTitle(); 275 std::string line; 276 getline(cin,line); 277 // dissect by " " 278 string::iterator olditer = line.begin(); 279 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) { 280 if (*iter == ' ') { 281 std::istringstream stream(string(iter, olditer)); 282 stream >> temp; 283 tmp.push_back(temp); 284 olditer = iter; 285 } 286 } 287 if (olditer != line.begin()) { // insert last part also 288 std::istringstream stream(string(olditer, line.end())); 289 stream >> temp; 290 tmp.push_back(temp); 291 } 292 293 return true; 294 } 295 296 TextDialog::AtomTextQuery::AtomTextQuery(string title, std::string _description) : 297 Dialog::AtomQuery(title,_description) 212 298 {} 213 299 … … 215 301 216 302 bool TextDialog::AtomTextQuery::handle() { 217 int idxOfAtom= 0;303 int idxOfAtom=-1; 218 304 bool badInput = false; 219 305 do{ … … 231 317 tmp = World::getInstance().getAtom(AtomById(idxOfAtom)); 232 318 if(!tmp && idxOfAtom!=-1){ 233 Log() << Verbose(0) << "Invalid Atom Index" << endl;319 Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl; 234 320 badInput = true; 235 321 } … … 240 326 } 241 327 242 TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, molecule **_target, std::string _description) : 243 Dialog::MoleculeQuery(title,_target,_description) 328 329 TextDialog::AtomsTextQuery::AtomsTextQuery(string title, std::string _description) : 330 Dialog::AtomsQuery(title,_description) 331 {} 332 333 TextDialog::AtomsTextQuery::~AtomsTextQuery() {} 334 335 bool TextDialog::AtomsTextQuery::handle() { 336 int idxOfAtom=-1; 337 Log() << Verbose(0) << getTitle(); 338 std::string line; 339 getline(cin,line); 340 // dissect by " " 341 string::iterator olditer = line.begin(); 342 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) { 343 if (*iter == ' ') { 344 std::istringstream stream(string(iter, olditer)); 345 stream >> idxOfAtom; 346 temp = World::getInstance().getAtom(AtomById(idxOfAtom)); 347 if(!temp && idxOfAtom!=-1){ 348 Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl; 349 break; 350 } 351 tmp.push_back(temp); 352 olditer = iter; 353 } 354 } 355 if (olditer != line.begin()) { // insert last part also 356 std::istringstream stream(string(olditer, line.end())); 357 stream >> idxOfAtom; 358 temp = World::getInstance().getAtom(AtomById(idxOfAtom)); 359 if(!temp && idxOfAtom!=-1) { 360 Log() << Verbose(0) << "Invalid Atom Index" << idxOfAtom << endl; 361 tmp.push_back(temp); 362 } 363 } 364 365 return (idxOfAtom!=-1); 366 } 367 368 TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, std::string _description) : 369 Dialog::MoleculeQuery(title,_description) 244 370 {} 245 371 … … 272 398 } 273 399 274 TextDialog::VectorTextQuery::VectorTextQuery(std::string title, Vector *_target, bool _check, std::string _description) : 275 Dialog::VectorQuery(title,_target,_check,_description) 400 401 TextDialog::MoleculesTextQuery::MoleculesTextQuery(string title, std::string _description) : 402 Dialog::MoleculesQuery(title,_description) 403 {} 404 405 TextDialog::MoleculesTextQuery::~MoleculesTextQuery() {} 406 407 bool TextDialog::MoleculesTextQuery::handle() { 408 int idxOfMol=-1; 409 Log() << Verbose(0) << getTitle(); 410 std::string line; 411 getline(cin,line); 412 // dissect by " " 413 string::iterator olditer = line.begin(); 414 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) { 415 if (*iter == ' ') { 416 std::istringstream stream(string(iter, olditer)); 417 stream >> idxOfMol; 418 temp = World::getInstance().getMolecule(MoleculeById(idxOfMol)); 419 if(!temp && idxOfMol!=-1){ 420 Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl; 421 break; 422 } 423 tmp.push_back(temp); 424 olditer = iter; 425 } 426 } 427 if (olditer != line.begin()) { // insert last part also 428 std::istringstream stream(string(olditer, line.end())); 429 stream >> idxOfMol; 430 temp = World::getInstance().getMolecule(MoleculeById(idxOfMol)); 431 if(!temp && idxOfMol!=-1){ 432 Log() << Verbose(0) << "Invalid Molecule Index" << idxOfMol << endl; 433 tmp.push_back(temp); 434 } 435 } 436 437 return (idxOfMol!=-1); 438 } 439 440 TextDialog::VectorTextQuery::VectorTextQuery(std::string title, bool _check, std::string _description) : 441 Dialog::VectorQuery(title,_check,_description) 276 442 {} 277 443 … … 280 446 281 447 bool TextDialog::VectorTextQuery::handle() { 282 Log() << Verbose(0) << getTitle(); 283 448 std::cout << getTitle(); 284 449 const Matrix &M = World::getInstance().getDomain().getM(); 285 char coords[3] = {'x','y','z'}; 286 for (int i=0;i<3;i++) { 287 do { 288 Log() << Verbose(0) << coords[i] << "[0.." << M.at(i,i) << "]: "; 289 cin >> (*tmp)[i]; 290 } while ((((*tmp)[i] < 0) || ((*tmp)[i] >= M.at(i,i))) && (check)); 291 } 292 return true; 293 } 294 295 TextDialog::BoxTextQuery::BoxTextQuery(std::string title, Box* _cellSize, std::string _description) : 296 Dialog::BoxQuery(title,_cellSize,_description) 450 char coords[3] = {'x', 'y', 'z'}; 451 for (int i=0;i<3;i++) 452 std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: "); 453 454 std::string line; 455 getline(cin,line); 456 457 // dissect by "," 458 double coord = 0.; 459 int counter = 0; 460 string::iterator olditer = line.begin(); 461 for(string::iterator iter = line.begin(); (iter != line.end()) && (counter != 3); ++iter) { 462 if (*iter == ',') { 463 std::istringstream stream(string(iter, olditer)); 464 stream >> coord; 465 tmp[counter++] = coord; 466 olditer = iter; 467 } 468 } 469 if ((olditer != line.begin()) && (counter != 3)) { // insert last part also 470 std::istringstream stream(string(olditer, line.end())); 471 stream >> coord; 472 tmp[counter++] = coord; 473 } 474 475 // check vector 476 return World::getInstance().getDomain().isInside(tmp); 477 } 478 479 TextDialog::VectorsTextQuery::VectorsTextQuery(std::string title, bool _check, std::string _description) : 480 Dialog::VectorsQuery(title,_check,_description) 481 {} 482 483 TextDialog::VectorsTextQuery::~VectorsTextQuery() 484 {} 485 486 bool TextDialog::VectorsTextQuery::handle() { 487 std::cout << getTitle(); 488 char coords[3] = {'x', 'y', 'z'}; 489 const Matrix &M = World::getInstance().getDomain().getM(); 490 for (int i=0;i<3;i++) 491 std::cout << coords[i] << "[0.." << M.at(i,i) << ( (i!=2) ? "], " : "]: "); 492 493 std::string line; 494 getline(cin,line); 495 496 // dissect by "," 497 double coord = 0.; 498 string::iterator olditerspace = line.begin(); 499 string::iterator olditercomma = line.begin(); 500 int counter = 0; 501 for(string::iterator vectoriter = line.begin(); vectoriter != line.end(); ++vectoriter) { 502 if (*vectoriter == ',') 503 counter++; 504 if ((*vectoriter == ' ') && (counter == 2)) { 505 counter = 0; 506 for(string::iterator componentiter = olditerspace; (componentiter != vectoriter) && (counter !=3); ++componentiter) { 507 if (*componentiter == ',') { 508 std::istringstream stream(string(componentiter, olditercomma)); 509 stream >> coord; 510 temp[counter++] = coord; 511 olditercomma = componentiter; 512 } 513 } 514 if ((olditercomma != line.begin()) && (counter != 3)) { // insert last part also 515 std::istringstream stream(string(olditercomma, vectoriter)); 516 stream >> coord; 517 temp[counter++] = coord; 518 } 519 if (World::getInstance().getDomain().isInside(temp)) 520 tmp.push_back(temp); 521 olditerspace = vectoriter; 522 } 523 } 524 } 525 526 TextDialog::BoxTextQuery::BoxTextQuery(std::string title, std::string _description) : 527 Dialog::BoxQuery(title,_description) 297 528 {} 298 529 … … 303 534 Log() << Verbose(0) << getTitle(); 304 535 305 std::string coords[6] = {"xx","xy","xz", "yy", "yz", "zz"}; 536 double temp[6]; 537 std::string coords[6] = {"xx","yx","yy", "zx", "zy", "zz"}; 306 538 for (int i=0;i<6;i++) { 307 539 Log() << Verbose(0) << coords[i] << ": "; 308 cin >> tmp[i]; 309 } 310 return true; 311 } 312 313 TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::vector<element *> *_target, std::string _description) : 314 Dialog::ElementQuery(title,_target,_description) 540 cin >> temp[i]; 541 } 542 Matrix M; 543 M.set(0,0, temp[0]); 544 M.set(0,1, temp[1]); 545 M.set(0,2, temp[2]); 546 M.set(1,0, temp[1]); 547 M.set(1,1, temp[3]); 548 M.set(1,2, temp[4]); 549 M.set(2,0, temp[2]); 550 M.set(2,1, temp[4]); 551 M.set(2,2, temp[5]); 552 tmp.setM(M); 553 return true; 554 } 555 556 TextDialog::ElementTextQuery::ElementTextQuery(std::string title, std::string _description) : 557 Dialog::ElementQuery(title,_description) 315 558 {} 316 559 … … 321 564 bool badInput=false; 322 565 bool aborted = false; 323 element * t mp = NULL;566 element * temp = NULL; 324 567 do{ 325 568 badInput = false; … … 334 577 } 335 578 else{ 336 t mp = World::getInstance().getPeriode()->FindElement(Z);337 if(!t mp){579 temp = World::getInstance().getPeriode()->FindElement(Z); 580 if(!temp){ 338 581 Log() << Verbose(0) << "No element with this atomic number!" << endl; 339 582 badInput = true; 340 } else {341 elements.push_back(tmp);342 583 } 343 584 } … … 358 599 } 359 600 else{ 360 t mp = World::getInstance().getPeriode()->FindElement(shorthand.c_str());361 if(!t mp){601 temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str()); 602 if(!temp){ 362 603 Log() << Verbose(0) << "No element with this shorthand!" << endl; 363 604 badInput = true; 364 } else {365 elements.push_back(tmp);366 605 } 367 606 } … … 378 617 return !aborted; 379 618 } 619 620 TextDialog::ElementsTextQuery::ElementsTextQuery(std::string title, std::string _description) : 621 Dialog::ElementsQuery(title,_description) 622 {} 623 624 TextDialog::ElementsTextQuery::~ElementsTextQuery() 625 {} 626 627 bool TextDialog::ElementsTextQuery::handle() { 628 std::string shorthand; 629 int Z=-1; 630 Log() << Verbose(0) << getTitle(); 631 std::string line; 632 getline(cin,line); 633 // dissect by " " 634 string::iterator olditer = line.begin(); 635 for(string::iterator iter = line.begin(); iter != line.end(); ++iter) { 636 if (*iter == ' ') { 637 std::istringstream stream(string(iter, olditer)); 638 stream >> shorthand; 639 try { 640 Z = lexical_cast<int>(shorthand); 641 temp = World::getInstance().getPeriode()->FindElement(Z); 642 } catch (bad_lexical_cast) { 643 temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str()); 644 }; 645 if(!temp && Z!=-1){ 646 Log() << Verbose(0) << "Invalid Element" << shorthand << endl; 647 break; 648 } 649 tmp.push_back(temp); 650 olditer = iter; 651 } 652 } 653 if (olditer != line.begin()) { // insert last part also 654 std::istringstream stream(string(olditer, line.end())); 655 stream >> shorthand; 656 try { 657 Z = lexical_cast<int>(shorthand); 658 temp = World::getInstance().getPeriode()->FindElement(Z); 659 } catch (bad_lexical_cast) { 660 temp = World::getInstance().getPeriode()->FindElement(shorthand.c_str()); 661 }; 662 if(!temp && Z!=-1) { 663 Log() << Verbose(0) << "Invalid Element" << shorthand << endl; 664 tmp.push_back(temp); 665 } 666 } 667 668 return (Z!=-1); 669 } -
src/UIElements/TextUI/TextDialog.hpp
r7067bd6 r677e13 25 25 26 26 virtual void queryEmpty(const char *, std::string = ""); 27 virtual void queryBoolean(const char *, bool *, std::string = ""); 28 virtual void queryInt(const char *, int *, std::string = ""); 29 virtual void queryString(const char*, std::string *, std::string = ""); 30 virtual void queryStrings(const char*, std::vector<std::string> *, std::string = ""); 31 virtual void queryDouble(const char*, double*, std::string = ""); 32 virtual void queryAtom(const char*,atom**,std::string = ""); 33 virtual void queryMolecule(const char*,molecule**,std::string = ""); 34 virtual void queryVector(const char*,Vector *,bool, std::string = ""); 35 virtual void queryBox(const char*,Box*, std::string = ""); 36 virtual void queryElement(const char*, std::vector<element *> *, std::string = ""); 27 virtual void queryBoolean(const char *, std::string = ""); 28 virtual void queryInt(const char *, std::string = ""); 29 virtual void queryInts(const char *, std::string = ""); 30 virtual void queryString(const char*, std::string = ""); 31 virtual void queryStrings(const char*, std::string = ""); 32 virtual void queryDouble(const char*, std::string = ""); 33 virtual void queryDoubles(const char*, std::string = ""); 34 virtual void queryAtom(const char*,std::string = ""); 35 virtual void queryAtoms(const char*,std::string = ""); 36 virtual void queryMolecule(const char*,std::string = ""); 37 virtual void queryMolecules(const char*,std::string = ""); 38 virtual void queryVector(const char*,bool, std::string = ""); 39 virtual void queryVectors(const char*,bool, std::string = ""); 40 virtual void queryBox(const char*, std::string = ""); 41 virtual void queryElement(const char*, std::string = ""); 42 virtual void queryElements(const char*, std::string = ""); 37 43 38 44 protected: … … 47 53 class BooleanTextQuery : public Dialog::BooleanQuery { 48 54 public: 49 BooleanTextQuery(std::string title, bool *_target,std::string _description = NULL);55 BooleanTextQuery(std::string title, std::string _description = NULL); 50 56 virtual ~BooleanTextQuery(); 51 57 virtual bool handle(); … … 54 60 class IntTextQuery : public Dialog::IntQuery { 55 61 public: 56 IntTextQuery(std::string title, int *_target,std::string _description = NULL);62 IntTextQuery(std::string title, std::string _description = NULL); 57 63 virtual ~IntTextQuery(); 64 virtual bool handle(); 65 }; 66 67 class IntsTextQuery : public Dialog::IntsQuery { 68 public: 69 IntsTextQuery(std::string title, std::string _description = NULL); 70 virtual ~IntsTextQuery(); 58 71 virtual bool handle(); 59 72 }; … … 61 74 class DoubleTextQuery : public Dialog::DoubleQuery { 62 75 public: 63 DoubleTextQuery(std::string title, double *_target,std::string _description = NULL);76 DoubleTextQuery(std::string title, std::string _description = NULL); 64 77 virtual ~DoubleTextQuery(); 78 virtual bool handle(); 79 }; 80 81 class DoublesTextQuery : public Dialog::DoublesQuery { 82 public: 83 DoublesTextQuery(std::string title, std::string _description = NULL); 84 virtual ~DoublesTextQuery(); 65 85 virtual bool handle(); 66 86 }; … … 68 88 class StringTextQuery : public Dialog::StringQuery { 69 89 public: 70 StringTextQuery(std::string title, std::string *_target, std::string_description = NULL);90 StringTextQuery(std::string title, std::string _description = NULL); 71 91 virtual ~StringTextQuery(); 72 92 virtual bool handle(); … … 75 95 class StringsTextQuery : public Dialog::StringsQuery { 76 96 public: 77 StringsTextQuery(std::string title, std:: vector<std::string> *_target, std::string _description = NULL);97 StringsTextQuery(std::string title, std::string _description = NULL); 78 98 virtual ~StringsTextQuery(); 79 99 virtual bool handle(); … … 82 102 class AtomTextQuery : public Dialog::AtomQuery { 83 103 public: 84 AtomTextQuery(std::string title, atom **_target,std::string _description = NULL);104 AtomTextQuery(std::string title, std::string _description = NULL); 85 105 virtual ~AtomTextQuery(); 106 virtual bool handle(); 107 }; 108 109 class AtomsTextQuery : public Dialog::AtomsQuery { 110 public: 111 AtomsTextQuery(std::string title, std::string _description = NULL); 112 virtual ~AtomsTextQuery(); 86 113 virtual bool handle(); 87 114 }; … … 89 116 class MoleculeTextQuery : public Dialog::MoleculeQuery { 90 117 public: 91 MoleculeTextQuery(std::string title, molecule **_target,std::string _description = NULL);118 MoleculeTextQuery(std::string title, std::string _description = NULL); 92 119 virtual ~MoleculeTextQuery(); 120 virtual bool handle(); 121 }; 122 123 class MoleculesTextQuery : public Dialog::MoleculesQuery { 124 public: 125 MoleculesTextQuery(std::string title, std::string _description = NULL); 126 virtual ~MoleculesTextQuery(); 93 127 virtual bool handle(); 94 128 }; … … 96 130 class VectorTextQuery : public Dialog::VectorQuery { 97 131 public: 98 VectorTextQuery(std::string title, Vector *_target,bool _check, std::string _description = NULL);132 VectorTextQuery(std::string title,bool _check, std::string _description = NULL); 99 133 virtual ~VectorTextQuery(); 134 virtual bool handle(); 135 }; 136 137 class VectorsTextQuery : public Dialog::VectorsQuery { 138 public: 139 VectorsTextQuery(std::string title,bool _check, std::string _description = NULL); 140 virtual ~VectorsTextQuery(); 100 141 virtual bool handle(); 101 142 }; … … 103 144 class BoxTextQuery : public Dialog::BoxQuery { 104 145 public: 105 BoxTextQuery(std::string title, Box* _cellSize,std::string _description = NULL);146 BoxTextQuery(std::string title, std::string _description = NULL); 106 147 virtual ~BoxTextQuery(); 107 148 virtual bool handle(); … … 110 151 class ElementTextQuery : public Dialog::ElementQuery { 111 152 public: 112 ElementTextQuery(std::string title, std:: vector<element *> *_target, std::string _description = NULL);153 ElementTextQuery(std::string title, std::string _description = NULL); 113 154 virtual ~ElementTextQuery(); 155 virtual bool handle(); 156 }; 157 158 class ElementsTextQuery : public Dialog::ElementsQuery { 159 public: 160 ElementsTextQuery(std::string title, std::string _description = NULL); 161 virtual ~ElementsTextQuery(); 114 162 virtual bool handle(); 115 163 }; -
src/World.cpp
r7067bd6 r677e13 558 558 } 559 559 560 size_t World::countSelectedAtoms() const { 561 size_t count = 0; 562 for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter) 563 count++; 564 return count; 565 } 566 567 bool World::isSelected(atom *atom) const { 568 return selectedAtoms.find(atom->getId()) != selectedAtoms.end(); 569 } 570 571 const std::vector<atom *> World::getSelectedAtoms() const { 572 std::vector<atom *> returnAtoms; 573 returnAtoms.resize(countSelectedAtoms()); 574 int count = 0; 575 for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter) 576 returnAtoms[count++] = iter->second; 577 return returnAtoms; 578 } 579 580 560 581 // Molecules 561 582 … … 574 595 } 575 596 576 void World::selectAllMolecules s(MoleculeDescriptor descr){597 void World::selectAllMolecules(MoleculeDescriptor descr){ 577 598 internal_MoleculeIterator begin = getMoleculeIter_internal(descr); 578 599 internal_MoleculeIterator end = moleculeEnd_internal(); … … 605 626 } 606 627 607 void World::unselectAllMolecules s(MoleculeDescriptor descr){628 void World::unselectAllMolecules(MoleculeDescriptor descr){ 608 629 internal_MoleculeIterator begin = getMoleculeIter_internal(descr); 609 630 internal_MoleculeIterator end = moleculeEnd_internal(); … … 624 645 ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\ 625 646 unselectMoleculeOfAtom(atoms[id]); 647 } 648 649 size_t World::countSelectedMolecules() const { 650 size_t count = 0; 651 for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter) 652 count++; 653 return count; 654 } 655 656 bool World::isSelected(molecule *mol) const { 657 return selectedMolecules.find(mol->getId()) != selectedMolecules.end(); 658 } 659 660 const std::vector<molecule *> World::getSelectedMolecules() const { 661 std::vector<molecule *> returnMolecules; 662 returnMolecules.resize(countSelectedMolecules()); 663 int count = 0; 664 for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter) 665 returnMolecules[count++] = iter->second; 666 return returnMolecules; 626 667 } 627 668 -
src/World.hpp
r7067bd6 r677e13 265 265 void unselectAtomsOfMolecule(molecule*); 266 266 void unselectAtomsOfMolecule(moleculeId_t); 267 size_t countSelectedAtoms() const; 268 bool isSelected(atom *_atom) const; 269 const std::vector<atom *> getSelectedAtoms() const; 267 270 268 271 void clearMoleculeSelection(); 269 272 void selectMolecule(molecule*); 270 273 void selectMolecule(moleculeId_t); 271 void selectAllMolecules s(MoleculeDescriptor);274 void selectAllMolecules(MoleculeDescriptor); 272 275 void selectMoleculeOfAtom(atom*); 273 276 void selectMoleculeOfAtom(atomId_t); 274 277 void unselectMolecule(molecule*); 275 278 void unselectMolecule(moleculeId_t); 276 void unselectAllMolecules s(MoleculeDescriptor);279 void unselectAllMolecules(MoleculeDescriptor); 277 280 void unselectMoleculeOfAtom(atom*); 278 281 void unselectMoleculeOfAtom(atomId_t); 282 size_t countSelectedMolecules() const; 283 bool isSelected(molecule *_mol) const; 284 const std::vector<molecule *> getSelectedMolecules() const; 279 285 280 286 /******************** Iterators to selections *****************/ -
src/analysis_correlation.cpp
r7067bd6 r677e13 28 28 /** Calculates the pair correlation between given elements. 29 29 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si)) 30 * \param *molecules list of molecules structure30 * \param *molecules vector of molecules 31 31 * \param &elements vector of elements to correlate 32 32 * \return Map of doubles with values the pair of the two atoms. 33 33 */ 34 PairCorrelationMap *PairCorrelation( MoleculeListClass * const&molecules, const std::vector<element *> &elements)34 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements) 35 35 { 36 36 Info FunctionInfo(__func__); … … 39 39 Box &domain = World::getInstance().getDomain(); 40 40 41 if (molecules ->ListOfMolecules.empty()) {41 if (molecules.empty()) { 42 42 DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl); 43 43 return outmap; 44 44 } 45 for ( MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)45 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) 46 46 (*MolWalker)->doCountAtoms(); 47 47 … … 64 64 65 65 outmap = new PairCorrelationMap; 66 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){ 67 if ((*MolWalker)->ActiveFlag) { 68 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 69 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 70 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 71 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 72 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){ 73 if ((*MolOtherWalker)->ActiveFlag) { 74 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 75 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 76 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 77 if ((*iter)->getId() < (*runner)->getId()){ 78 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 79 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 80 distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node); 81 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 82 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 83 } 66 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){ 67 DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 68 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 69 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 70 for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){ 71 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 72 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 73 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 74 if ((*iter)->getId() < (*runner)->getId()){ 75 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 76 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 77 distance = domain.periodicDistance(*(*iter)->node,*(*runner)->node); 78 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 79 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 84 80 } 85 }86 81 } 87 82 } … … 99 94 * \return Map of doubles with values the pair of the two atoms. 100 95 */ 101 PairCorrelationMap *PeriodicPairCorrelation( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const int ranges[NDIM] )96 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const int ranges[NDIM] ) 102 97 { 103 98 Info FunctionInfo(__func__); … … 111 106 Vector periodicOtherX; 112 107 113 if (molecules ->ListOfMolecules.empty()) {108 if (molecules.empty()) { 114 109 DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl); 115 110 return outmap; 116 111 } 117 for ( MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)112 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) 118 113 (*MolWalker)->doCountAtoms(); 119 114 … … 136 131 137 132 outmap = new PairCorrelationMap; 138 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){ 139 if ((*MolWalker)->ActiveFlag) { 140 Matrix FullMatrix = World::getInstance().getDomain().getM(); 141 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 142 DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 143 eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl; 144 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 145 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 146 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 147 // go through every range in xyz and get distance 148 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 149 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 150 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 151 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 152 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){ 153 if ((*MolOtherWalker)->ActiveFlag) { 154 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 155 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 156 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 157 if ((*iter)->getId() < (*runner)->getId()){ 158 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 159 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 160 periodicOtherX = FullInverseMatrix * (*(*runner)->node); // x now in [0,1)^3 161 // go through every range in xyz and get distance 162 for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++) 163 for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++) 164 for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) { 165 checkOtherX = FullMatrix * (Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX); 166 distance = checkX.distance(checkOtherX); 167 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 168 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 169 } 170 } 133 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++){ 134 Matrix FullMatrix = World::getInstance().getDomain().getM(); 135 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 136 DoLog(2) && (Log()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 137 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 138 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 139 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 140 // go through every range in xyz and get distance 141 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 142 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 143 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 144 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 145 for (std::vector<molecule *>::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules.end(); MolOtherWalker++){ 146 DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl); 147 for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) { 148 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl); 149 if ((*iter)->getId() < (*runner)->getId()){ 150 for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner) 151 if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) { 152 periodicOtherX = FullInverseMatrix * (*(*runner)->node); // x now in [0,1)^3 153 // go through every range in xyz and get distance 154 for (Othern[0]=-ranges[0]; Othern[0] <= ranges[0]; Othern[0]++) 155 for (Othern[1]=-ranges[1]; Othern[1] <= ranges[1]; Othern[1]++) 156 for (Othern[2]=-ranges[2]; Othern[2] <= ranges[2]; Othern[2]++) { 157 checkOtherX = FullMatrix * (Vector(Othern[0], Othern[1], Othern[2]) + periodicOtherX); 158 distance = checkX.distance(checkOtherX); 159 //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl; 160 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) ); 161 } 162 } 171 163 } 172 164 } 173 165 } 174 }175 }176 166 } 177 167 } … … 187 177 * \return Map of dobules with values as pairs of atom and the vector 188 178 */ 189 CorrelationToPointMap *CorrelationToPoint( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Vector *point )179 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point ) 190 180 { 191 181 Info FunctionInfo(__func__); … … 194 184 Box &domain = World::getInstance().getDomain(); 195 185 196 if (molecules ->ListOfMolecules.empty()) {186 if (molecules.empty()) { 197 187 DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl); 198 188 return outmap; 199 189 } 200 for ( MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)190 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) 201 191 (*MolWalker)->doCountAtoms(); 202 192 outmap = new CorrelationToPointMap; 203 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 204 if ((*MolWalker)->ActiveFlag) { 205 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 206 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 207 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 208 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 209 if ((*type == NULL) || ((*iter)->type == *type)) { 210 distance = domain.periodicDistance(*(*iter)->node,*point); 211 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 212 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) ); 213 } 214 } 215 } 193 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { 194 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 195 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 196 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 197 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 198 if ((*type == NULL) || ((*iter)->type == *type)) { 199 distance = domain.periodicDistance(*(*iter)->node,*point); 200 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 201 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) ); 202 } 203 } 204 } 216 205 217 206 return outmap; … … 225 214 * \return Map of dobules with values as pairs of atom and the vector 226 215 */ 227 CorrelationToPointMap *PeriodicCorrelationToPoint( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )216 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] ) 228 217 { 229 218 Info FunctionInfo(__func__); … … 234 223 Vector checkX; 235 224 236 if (molecules ->ListOfMolecules.empty()) {225 if (molecules.empty()) { 237 226 DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl); 238 227 return outmap; 239 228 } 240 for ( MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)229 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) 241 230 (*MolWalker)->doCountAtoms(); 242 231 outmap = new CorrelationToPointMap; 243 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 244 if ((*MolWalker)->ActiveFlag) { 245 Matrix FullMatrix = World::getInstance().getDomain().getM(); 246 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 247 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 248 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 249 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 250 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 251 if ((*type == NULL) || ((*iter)->type == *type)) { 252 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 253 // go through every range in xyz and get distance 254 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 255 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 256 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 257 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 258 distance = checkX.distance(*point); 259 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 260 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) ); 261 } 262 } 263 } 264 } 232 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { 233 Matrix FullMatrix = World::getInstance().getDomain().getM(); 234 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 235 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 236 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 237 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 238 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 239 if ((*type == NULL) || ((*iter)->type == *type)) { 240 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 241 // go through every range in xyz and get distance 242 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 243 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 244 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 245 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 246 distance = checkX.distance(*point); 247 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl); 248 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) ); 249 } 250 } 251 } 252 } 265 253 266 254 return outmap; … … 274 262 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 275 263 */ 276 CorrelationToSurfaceMap *CorrelationToSurface( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )264 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC ) 277 265 { 278 266 Info FunctionInfo(__func__); … … 282 270 Vector centroid; 283 271 284 if ((Surface == NULL) || (LC == NULL) || (molecules ->ListOfMolecules.empty())) {272 if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) { 285 273 DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl); 286 274 return outmap; 287 275 } 288 for ( MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)276 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) 289 277 (*MolWalker)->doCountAtoms(); 290 278 outmap = new CorrelationToSurfaceMap; 291 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 292 if ((*MolWalker)->ActiveFlag) { 293 DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl); 294 if ((*MolWalker)->empty()) 295 DoLog(1) && (1) && (Log() << Verbose(1) << "\t is empty." << endl); 296 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 297 DoLog(1) && (Log() << Verbose(1) << "\tCurrent atom is " << *(*iter) << "." << endl); 298 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 299 if ((*type == NULL) || ((*iter)->type == *type)) { 300 TriangleIntersectionList Intersections((*iter)->node,Surface,LC); 301 distance = Intersections.GetSmallestDistance(); 302 triangle = Intersections.GetClosestTriangle(); 303 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) ); 304 } 305 } 306 } else { 307 DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl); 308 } 279 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { 280 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << (*MolWalker)->name << "." << endl); 281 if ((*MolWalker)->empty()) 282 DoLog(2) && (2) && (Log() << Verbose(2) << "\t is empty." << endl); 283 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 284 DoLog(3) && (Log() << Verbose(3) << "\tCurrent atom is " << *(*iter) << "." << endl); 285 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 286 if ((*type == NULL) || ((*iter)->type == *type)) { 287 TriangleIntersectionList Intersections((*iter)->node,Surface,LC); 288 distance = Intersections.GetSmallestDistance(); 289 triangle = Intersections.GetClosestTriangle(); 290 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) ); 291 } 292 } 293 } 309 294 310 295 return outmap; … … 323 308 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest 324 309 */ 325 CorrelationToSurfaceMap *PeriodicCorrelationToSurface( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )310 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ) 326 311 { 327 312 Info FunctionInfo(__func__); … … 334 319 Vector checkX; 335 320 336 if ((Surface == NULL) || (LC == NULL) || (molecules ->ListOfMolecules.empty())) {321 if ((Surface == NULL) || (LC == NULL) || (molecules.empty())) { 337 322 DoLog(1) && (Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl); 338 323 return outmap; 339 324 } 340 for ( MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)325 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) 341 326 (*MolWalker)->doCountAtoms(); 342 327 outmap = new CorrelationToSurfaceMap; 343 328 double ShortestDistance = 0.; 344 329 BoundaryTriangleSet *ShortestTriangle = NULL; 345 for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++) 346 if ((*MolWalker)->ActiveFlag) { 347 Matrix FullMatrix = World::getInstance().getDomain().getM(); 348 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 349 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 350 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 351 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 352 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 353 if ((*type == NULL) || ((*iter)->type == *type)) { 354 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 355 // go through every range in xyz and get distance 356 ShortestDistance = -1.; 357 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 358 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 359 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 360 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 361 TriangleIntersectionList Intersections(&checkX,Surface,LC); 362 distance = Intersections.GetSmallestDistance(); 363 triangle = Intersections.GetClosestTriangle(); 364 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) { 365 ShortestDistance = distance; 366 ShortestTriangle = triangle; 367 } 330 for (std::vector<molecule *>::const_iterator MolWalker = molecules.begin(); MolWalker != molecules.end(); MolWalker++) { 331 Matrix FullMatrix = World::getInstance().getDomain().getM(); 332 Matrix FullInverseMatrix = World::getInstance().getDomain().getMinv(); 333 DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl); 334 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 335 DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl); 336 for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type) 337 if ((*type == NULL) || ((*iter)->type == *type)) { 338 periodicX = FullInverseMatrix * (*(*iter)->node); // x now in [0,1)^3 339 // go through every range in xyz and get distance 340 ShortestDistance = -1.; 341 for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++) 342 for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++) 343 for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) { 344 checkX = FullMatrix * (Vector(n[0], n[1], n[2]) + periodicX); 345 TriangleIntersectionList Intersections(&checkX,Surface,LC); 346 distance = Intersections.GetSmallestDistance(); 347 triangle = Intersections.GetClosestTriangle(); 348 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) { 349 ShortestDistance = distance; 350 ShortestTriangle = triangle; 368 351 } 369 // insert 370 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) ); 371 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; 372 } 373 } 374 } 352 } 353 // insert 354 outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) ); 355 //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl; 356 } 357 } 358 } 375 359 376 360 return outmap; -
src/analysis_correlation.hpp
r7067bd6 r677e13 22 22 // STL headers 23 23 #include <map> 24 #include <vector> 24 25 25 26 #include "defs.hpp" … … 33 34 class element; 34 35 class LinkedCell; 35 class MoleculeListClass;36 36 class Tesselation; 37 37 class Vector; … … 46 46 /********************************************** declarations *******************************/ 47 47 48 PairCorrelationMap *PairCorrelation( MoleculeListClass * const&molecules, const std::vector<element *> &elements);49 CorrelationToPointMap *CorrelationToPoint( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Vector *point );50 CorrelationToSurfaceMap *CorrelationToSurface( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );51 PairCorrelationMap *PeriodicPairCorrelation( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const int ranges[NDIM] );52 CorrelationToPointMap *PeriodicCorrelationToPoint( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] );53 CorrelationToSurfaceMap *PeriodicCorrelationToSurface( MoleculeListClass * const&molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );48 PairCorrelationMap *PairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements); 49 CorrelationToPointMap *CorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point ); 50 CorrelationToSurfaceMap *CorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC ); 51 PairCorrelationMap *PeriodicPairCorrelation(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const int ranges[NDIM] ); 52 CorrelationToPointMap *PeriodicCorrelationToPoint(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] ); 53 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(std::vector<molecule *> &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ); 54 54 int GetBin ( const double value, const double BinWidth, const double BinStart ); 55 55 void OutputCorrelation( ofstream * const file, const BinPairMap * const map ); -
src/unittests/ActionSequenceTest.cpp
r7067bd6 r677e13 33 33 virtual ~canUndoActionStub(){} 34 34 35 virtual Dialog* createDialog(){ 36 return NULL; 37 } 38 35 39 virtual Action::state_ptr performCall(){ 36 40 return Action::success; … … 55 59 cannotUndoActionStub() : Action("cannotUndoActionStub",false){} 56 60 virtual ~cannotUndoActionStub(){} 61 62 virtual Dialog* createDialog(){ 63 return NULL; 64 } 57 65 58 66 virtual Action::state_ptr performCall(){ … … 82 90 virtual ~wasCalledActionStub(){} 83 91 92 virtual Dialog* createDialog(){ 93 return NULL; 94 } 84 95 virtual Action::state_ptr performCall(){ 85 96 called = true; -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
r7067bd6 r677e13 16 16 #include "analysis_correlation.hpp" 17 17 #include "AnalysisCorrelationToPointUnitTest.hpp" 18 19 #include "Descriptors/MoleculeDescriptor.hpp" 18 20 19 21 #include "atom.hpp" … … 38 40 39 41 // init private all pointers to zero 40 TestList = NULL;41 42 TestMolecule = NULL; 42 43 pointmap = NULL; … … 71 72 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 72 73 73 TestList = World::getInstance().getMolecules();74 TestList->insert(TestMolecule);75 74 TestMolecule->ActiveFlag = true; 76 75 … … 79 78 80 79 // init maps 81 pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, elements, (const Vector *)point ); 80 World::getInstance().selectAllMolecules(AllMolecules()); 81 allMolecules = World::getInstance().getSelectedMolecules(); 82 CPPUNIT_ASSERT_EQUAL( (size_t) 1, allMolecules.size()); 83 pointmap = CorrelationToPoint( allMolecules, elements, (const Vector *)point ); 82 84 binmap = NULL; 83 85 -
src/unittests/AnalysisCorrelationToPointUnitTest.hpp
r7067bd6 r677e13 35 35 private: 36 36 37 MoleculeListClass *TestList;37 std::vector<molecule *> allMolecules; 38 38 molecule *TestMolecule; 39 39 element *hydrogen; -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
r7067bd6 r677e13 16 16 #include "analysis_correlation.hpp" 17 17 #include "AnalysisCorrelationToSurfaceUnitTest.hpp" 18 19 #include "Descriptors/MoleculeDescriptor.hpp" 18 20 19 21 #include "atom.hpp" … … 45 47 46 48 // init private all pointers to zero 47 TestList = NULL;48 49 TestSurfaceMolecule = NULL; 49 50 surfacemap = NULL; … … 83 84 CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 ); 84 85 85 TestList = World::getInstance().getMolecules();86 86 TestSurfaceMolecule->ActiveFlag = true; 87 TestList->insert(TestSurfaceMolecule);88 87 89 88 // init tesselation and linked cell … … 116 115 TestSurfaceMolecule->AddAtom(Walker); 117 116 118 TestSurfaceMolecule->ActiveFlag = true; 119 TestList->insert(TestSurfaceMolecule); 117 World::getInstance().selectAllMolecules(AllMolecules()); 118 allMolecules = World::getInstance().getSelectedMolecules(); 119 CPPUNIT_ASSERT_EQUAL( (size_t) 2, allMolecules.size()); 120 120 121 121 // init maps … … 146 146 { 147 147 CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() ); 148 CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );148 CPPUNIT_ASSERT_EQUAL( (size_t)2, allMolecules.size() ); 149 149 CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() ); 150 150 CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() ); … … 156 156 // do the pair correlation 157 157 elements.push_back(hydrogen); 158 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );158 surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC ); 159 159 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 160 160 CPPUNIT_ASSERT( surfacemap != NULL ); … … 166 166 BinPairMap::iterator tester; 167 167 elements.push_back(hydrogen); 168 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );168 surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC ); 169 169 // put pair correlation into bins and check with no range 170 170 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); … … 182 182 BinPairMap::iterator tester; 183 183 elements.push_back(hydrogen); 184 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );184 surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC ); 185 185 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 186 186 // ... and check with [0., 2.] range … … 201 201 BinPairMap::iterator tester; 202 202 elements.push_back(carbon); 203 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );203 surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC ); 204 204 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 205 205 // put pair correlation into bins and check with no range … … 221 221 BinPairMap::iterator tester; 222 222 elements.push_back(carbon); 223 surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );223 surfacemap = CorrelationToSurface( allMolecules, elements, Surface, LC ); 224 224 // OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap ); 225 225 // ... and check with [0., 2.] range -
src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp
r7067bd6 r677e13 43 43 private: 44 44 45 MoleculeListClass *TestList;45 std::vector<molecule *> allMolecules; 46 46 molecule *TestSurfaceMolecule; 47 47 element *hydrogen; -
src/unittests/AnalysisPairCorrelationUnitTest.cpp
r7067bd6 r677e13 16 16 #include "analysis_correlation.hpp" 17 17 #include "AnalysisPairCorrelationUnitTest.hpp" 18 19 #include "Descriptors/MoleculeDescriptor.hpp" 18 20 19 21 #include "World.hpp" … … 42 44 43 45 // init private all pointers to zero 44 TestList = NULL;45 46 TestMolecule = NULL; 46 47 correlationmap = NULL; … … 76 77 CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 ); 77 78 78 TestList = World::getInstance().getMolecules();79 TestMolecule->ActiveFlag = true;80 TestList->insert(TestMolecule);81 82 79 // init maps 83 correlationmap = PairCorrelation( TestList, elements); 80 World::getInstance().selectAllMolecules(AllMolecules()); 81 allMolecules = World::getInstance().getSelectedMolecules(); 82 CPPUNIT_ASSERT_EQUAL( (size_t) 1, allMolecules.size()); 83 correlationmap = PairCorrelation( allMolecules, elements); 84 84 binmap = NULL; 85 85 -
src/unittests/AnalysisPairCorrelationUnitTest.hpp
r7067bd6 r677e13 35 35 private: 36 36 37 MoleculeListClass *TestList;37 std::vector<molecule *> allMolecules; 38 38 molecule *TestMolecule; 39 39 element *hydrogen; -
test_all.sh
r7067bd6 r677e13 21 21 outfile="test.log"; 22 22 logfile="full.log"; 23 noprocs=1; 23 24 docheck=0; 24 25 docheck_mem=0; … … 40 41 echo " -o <outfile> Outfile to use for test results"; 41 42 echo " -f <logfile> File to use for output from commands"; 43 echo " -j <no_proc> Parallel compiling and tests"; 42 44 echo " -s Short tests (no memcheck)"; 43 45 echo " -c Only configure and compile (implies -s)"; 44 46 echo " -O <opt-level> Only compile this optimization level"; 45 47 echo " -t <tmpDir> Use tmpDir as temporary directory"; 46 echo " -p <prefix> Prefix to use for directory names (standar tMolecuilderTest)";47 } 48 49 while getopts âho:f: scO:t:p:â OPTION48 echo " -p <prefix> Prefix to use for directory names (standard MolecuilderTest)"; 49 } 50 51 while getopts âho:f:j:scO:t:p:â OPTION 50 52 do 51 53 case $OPTION in … … 60 62 logfile="$OPTARG"; 61 63 ;; 64 j) 65 noprocs=("$OPTARG"); 66 ;; 62 67 s) 63 68 docheck_mem=1; … … 105 110 function compile(){ 106 111 echo "Making"; 107 make all install >>$logfile 2>&1; 112 if [ $noprocs -gt 1 ]; then 113 make -j$noprocs all install >>$logfile 2>&1; 114 else 115 make all install >>$logfile 2>&1; 116 fi 108 117 } 109 118 110 119 function check(){ 111 120 echo "Checking"; 112 make check >> $logfile 2>&1; 121 if [ $noprocs -gt 1 ]; then 122 make -j$noprocs check >> $logfile 2>&1; 123 else 124 make check >> $logfile 2>&1; 125 fi 113 126 } 114 127 -
tests/Tesselations/defs.in
r7067bd6 r677e13 54 54 #echo "Current dir is `pwd`, calling $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME." 55 55 if [ -e $mol.dbond ]; then 56 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond - N 0 --sphere-radius$RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?56 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$? 57 57 else 58 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz - N 0 --sphere-radius$RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?58 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz --select-molecule-by-id 0 -N $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$? 59 59 fi 60 60 #echo "Molecuilder done with exitcode $exitcode." -
tests/Tesselations/heptan/1.5/NonConvexEnvelope-heptan.dat
r7067bd6 r677e13 8 8 1.2492 0.921941 -0.849545 18.7222 9 9 1.2492 0.921941 0.930455 18.7222 10 -2.4985 -1.22006 -0.849545 27.472710 -2.4985 -1.22006 -0.849545 19.9769 11 11 -2.4985 -1.22006 0.930455 19.9769 12 12 2.4985 -1.22006 0.930455 27.4727 13 2.4985 -1.22006 -0.849545 19.976913 2.4985 -1.22006 -0.849545 27.4727 14 14 -4.6377 -0.336759 0.0404545 21.541 15 15 -3.7477 0.921941 0.930455 18.8853 … … 21 21 -1.2492 0.292641 0.0404545 23.0167 22 22 1.2492 0.292641 0.0404545 23.0172 23 -2.4985 -0.590759 0.0404545 18.979824 2.4985 -0.590759 0.0404545 1 8.979823 -2.4985 -0.590759 0.0404545 21.8516 24 2.4985 -0.590759 0.0404545 16.0669 25 25 -3.7477 0.292641 0.0404545 39.5267 26 26 3.7477 0.292641 0.0404545 20.5497 … … 80 80 1 2 17 81 81 1 2 17 82 217 2183 2 10 2182 10 17 21 83 2 10 17 84 84 1 17 20 85 85 1 8 20 … … 88 88 8 11 20 89 89 7 11 20 90 717 2091 2 7 1790 2 17 20 91 2 7 20 -
tests/regression/testsuite-analysis.at
r7067bd6 r677e13 4 4 AT_KEYWORDS([analysis]) 5 5 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/1/pre/test.conf .], 0) 6 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 - C E--elements 1 8 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])6 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr]) 7 7 AT_CHECK([fgrep "Begin of PairCorrelation" stdout], 0, [ignore], [ignore]) 8 8 #AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/1/post/$file], 0, [ignore], [ignore]) … … 14 14 AT_KEYWORDS([analysis]) 15 15 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/pre/test.conf .], 0) 16 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 - C E--elements 1 8 --output-file output-5.csv --bin-output-file bin_output-5.csv --bin-start 0 --bin-end 5], 0, [stdout], [stderr])16 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-5.csv --bin-output-file bin_output-5.csv --bin-start 0 --bin-end 5], 0, [stdout], [stderr]) 17 17 #AT_CHECK([file=output-5.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore]) 18 18 AT_CHECK([file=bin_output-5.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore]) 19 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 - C E--elements 1 8 --output-file output-10.csv --bin-output-file bin_output-10.csv --bin-start 5 --bin-end 10], 0, [stdout], [stderr])19 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-10.csv --bin-output-file bin_output-10.csv --bin-start 5 --bin-end 10], 0, [stdout], [stderr]) 20 20 #AT_CHECK([file=output-10.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore]) 21 21 AT_CHECK([file=bin_output-10.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore]) 22 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 - C E--elements 1 8 --output-file output-20.csv --bin-output-file bin_output-20.csv --bin-start 10 --bin-end 20], 0, [stdout], [stderr])22 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-all-molecules --pair-correlation --elements 1 8 --output-file output-20.csv --bin-output-file bin_output-20.csv --bin-start 10 --bin-end 20], 0, [stdout], [stderr]) 23 23 #AT_CHECK([file=output-20.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore]) 24 24 AT_CHECK([file=bin_output-20.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/2/post/$file], 0, [ignore], [ignore]) … … 29 29 AT_KEYWORDS([analysis]) 30 30 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/3/pre/test.conf .], 0) 31 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 7 - C P--elements 1 --position "10., 10., 10." --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr])31 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 7 --select-all-molecules --point-correlation --elements 1 --position "10., 10., 10." --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-end 20], 0, [stdout], [stderr]) 32 32 AT_CHECK([fgrep "Begin of CorrelationToPoint" stdout], 0, [ignore], [ignore]) 33 33 #AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/3/post/$file], 0, [ignore], [ignore]) … … 39 39 AT_KEYWORDS([analysis]) 40 40 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/4/pre/test.conf .], 0) 41 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I - C S--elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 207], 0, [stdout], [stderr])41 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 -I --select-all-molecules --unselect-molecule-by-id 207 --surface-correlation --elements 1 --output-file output.csv --bin-output-file bin_output.csv --bin-start 0 --bin-width 1. --bin-end 20 --molecule-by-id 207], 0, [stdout], [stderr]) 42 42 AT_CHECK([fgrep "Begin of CorrelationToSurface" stdout], 0, [ignore], [ignore]) 43 43 #AT_CHECK([file=output.csv; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Analysis/4/post/$file], 0, [ignore], [ignore]) -
tests/regression/testsuite-filling.at
r7067bd6 r677e13 18 18 AT_KEYWORDS([filling]) 19 19 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/2/pre/test.conf .], 0) 20 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 - u 1.3 --molecule-by-id 0], 0, [stdout], [stderr])20 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 3 --select-molecule-by-id 0 -u 1.3], 0, [stdout], [stderr]) 21 21 #AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Filling/2/post/$file], 0, [ignore], [ignore]) 22 22 AT_CLEANUP -
tests/regression/testsuite-fragmentation.at
r7067bd6 r677e13 12 12 AT_SETUP([Fragmentation - Fragmentation]) 13 13 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/2/pre/test.conf .], 0) 14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 - f ./BondFragment --molecule-by-id 0--distance 1.55 --order 2], 0, [ignore], [ignore])14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], 0, [ignore], [ignore]) 15 15 AT_CHECK([ls -l BondFragment*.conf | wc -l], 0, [5 16 16 ], [ignore]) … … 21 21 AT_SETUP([Fragmentation - BROKEN: Fragmentation is at MaxOrder]) 22 22 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/3/pre/test.conf .], 0) 23 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 - f ./BondFragment --molecule-by-id 0--distance 1.55 --order 2], 0, [ignore], [ignore])24 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 - f ./BondFragment --molecule-by-id 0--distance 1.55 --order 2], [ignore], [ignore], [ignore])23 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], 0, [ignore], [ignore]) 24 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -f ./BondFragment --distance 1.55 --order 2], [ignore], [ignore], [ignore]) 25 25 AT_CLEANUP -
tests/regression/testsuite-molecules.at
r7067bd6 r677e13 4 4 AT_KEYWORDS([Molecules]) 5 5 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/1/pre/test.* .], 0) 6 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 4 - A test.dbond --molecule-by-id 0], 0, [stdout], [stderr])6 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 4 --select-molecule-by-id 0 -A test.dbond], 0, [stdout], [stderr]) 7 7 AT_CHECK([fgrep "Looking for atoms 2 and 9." stdout], 0, [ignore], [ignore]) 8 8 AT_CLEANUP … … 12 12 AT_KEYWORDS([Molecules]) 13 13 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/pre/test.conf .], 0) 14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 - j test.dbond --molecule-by-id 0], 0, [stdout], [stderr])14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -j test.dbond], 0, [stdout], [stderr]) 15 15 AT_CHECK([file=test.dbond; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/post/$file], 0, [ignore], [ignore]) 16 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 - J test.adj --molecule-by-id 0], 0, [stdout], [stderr])16 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -v 1 --select-molecule-by-id 0 -J test.adj], 0, [stdout], [stderr]) 17 17 AT_CHECK([file=test.adj; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/2/post/$file], 0, [ignore], [ignore]) 18 18 AT_CLEANUP … … 22 22 AT_KEYWORDS([Molecules]) 23 23 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/3/pre/test.conf .], 0) 24 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ - S test.ekin --molecule-by-id 0], 0, [stdout], [stderr])24 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -S test.ekin], 0, [stdout], [stderr]) 25 25 AT_CHECK([file=test.ekin; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/3/post/$file], 0, [ignore], [ignore]) 26 26 AT_CLEANUP … … 30 30 AT_KEYWORDS([Molecules]) 31 31 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/4/pre/test.conf .], 0) 32 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ - L teststep --start-step 0 --end-step 1 --molecule-by-id 0--id-mapping 1], 0, [stdout], [stderr])32 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -L teststep --start-step 0 --end-step 1 --id-mapping 1], 0, [stdout], [stderr]) 33 33 AT_CLEANUP 34 34 … … 37 37 AT_KEYWORDS([Molecules]) 38 38 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/5/pre/test.* .], 0) 39 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ - P test.forces --molecule-by-id 0], 0, [stdout], [stderr])39 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -P test.forces], 0, [stdout], [stderr]) 40 40 #AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/5/post/$file], 0, [ignore], [ignore]) 41 41 AT_CLEANUP … … 45 45 AT_KEYWORDS([Molecules]) 46 46 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/pre/test.* .], 0) 47 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ - t "1., 1., 1." --molecule-by-id 0--periodic 0], 0, [stdout], [stderr])47 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -t "1., 1., 1." --periodic 0], 0, [stdout], [stderr]) 48 48 AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/post/$file], 0, [ignore], [ignore]) 49 49 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/pre/test2.* .], 0) 50 AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ - t "-1., -1., -1." --molecule-by-id 0--periodic 0], 0, [stdout], [stderr])50 AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -t "-1., -1., -1." --periodic 0], 0, [stdout], [stderr]) 51 51 AT_CHECK([file=test2.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/6/post/$file], 0, [ignore], [ignore]) 52 52 AT_CLEANUP … … 56 56 AT_KEYWORDS([Molecules]) 57 57 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/7/pre/test.* .], 0) 58 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ - t "12., 12., 12." --molecule-by-id 0--periodic 1], 0, [stdout], [stderr])58 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -t "12., 12., 12." --periodic 1], 0, [stdout], [stderr]) 59 59 AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/7/post/$file], 0, [ignore], [ignore]) 60 60 AT_CLEANUP … … 64 64 AT_KEYWORDS([Molecules]) 65 65 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/pre/test.* .], 0) 66 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ - m 0], 0, [stdout], [stderr])66 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -m 0], 0, [stdout], [stderr]) 67 67 #AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Molecules/8/post/$file], 0, [ignore], [ignore]) 68 68 AT_CLEANUP -
tests/regression/testsuite-simple_configuration.at
r7067bd6 r677e13 29 29 AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore]) 30 30 AT_CHECK([file=test.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore]) 31 AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -a 1 --position "0., 0., -1."], 0, [ignore], [ignore]) 32 AT_CHECK([file=test2.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore]) 33 AT_CHECK([file=test2.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore]) 34 AT_CHECK([file=test2.xyz; diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/3/post/$file], 0, [ignore], [ignore]) 31 AT_CHECK([../../molecuilder -i test2.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz -a 1 --position "0., 0., -1."], 134, [ignore], [ignore]) 35 32 AT_CLEANUP 36 33 … … 39 36 AT_KEYWORDS([configuration]) 40 37 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/pre/test.xyz test.xyz], 0) 41 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ - E 6 --atom-by-id 0], 0, [ignore], [ignore])38 AT_CHECK([../../molecuilder -i test.xyz -e ${abs_top_srcdir}/src/ --select-atom-by-id 0 -E 6 ], 0, [ignore], [ignore]) 42 39 AT_CHECK([file=test.xyz; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/4/post/$file], 0, [ignore], [ignore]) 43 40 AT_CLEANUP … … 47 44 AT_KEYWORDS([configuration]) 48 45 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/pre/test.conf .], 0) 49 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz - r 0], 0, [ignore], [ignore])46 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -o mpqc pcp xyz --select-atom-by-id 0 -r], 0, [ignore], [ignore]) 50 47 AT_CHECK([file=test.conf; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore]) 51 48 AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/5/post/$file], 0, [ignore], [ignore]) -
tests/regression/testsuite-tesselation.at
r7067bd6 r677e13 4 4 AT_KEYWORDS([Tesselation]) 5 5 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/pre/* .], 0) 6 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ - N 0 --sphere-radius4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])6 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -N 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr]) 7 7 AT_CHECK([file=NonConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/post/$file], 0, [ignore], [ignore]) 8 8 #AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/1/post/$file], 0, [ignore], [ignore]) … … 12 12 AT_SETUP([Tesselation - Convex Envelope]) 13 13 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/pre/* .], 0) 14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -- convex-envelope 0--convex-file ConvexEnvelope --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])14 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 --convex-envelope --convex-file ConvexEnvelope --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr]) 15 15 AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/post/$file], 0, [ignore], [ignore]) 16 16 #AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/2/post/$file], 0, [ignore], [ignore]) … … 22 22 AT_SETUP([Tesselation - Big non-Convex Envelope]) 23 23 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/pre/* .], 0) 24 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ - N 0 --sphere-radius4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr])24 AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 -N 4. --nonconvex-file NonConvexEnvelope], 0, [stdout], [stderr]) 25 25 AT_CHECK([file=NonConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/post/$file], 0, [ignore], [ignore]) 26 26 #AT_CHECK([file=NonConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/3/post/$file], 0, [ignore], [ignore]) … … 30 30 #AT_SETUP([Tesselation - big convex Envelope]) 31 31 #AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/pre/* .], 0) 32 #AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ -- convex-envelope ConvexEnvelope NonConvexEnvelope], 0, [stdout], [stderr])32 #AT_CHECK([../../molecuilder -i test.conf -e ${abs_top_srcdir}/src/ --select-molecule-by-id 0 --convex-envelope ConvexEnvelope NonConvexEnvelope], 0, [stdout], [stderr]) 33 33 #AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/post/$file], 0, [ignore], [ignore]) 34 34 #AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Tesselation/4/post/$file], 0, [ignore], [ignore])
Note:
See TracChangeset
for help on using the changeset viewer.