Changes in / [0ac85c3:7b38d3]
- Files:
-
- 2 added
- 81 deleted
- 67 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/userguide/userguide.xml
r0ac85c3 r7b38d3 629 629 </programlisting> 630 630 </listitem> 631 632 <listitem>633 <para>Push/Pop the current selection to/from a stack to store634 it momentarily and allow modifications in MakroActions.</para>635 <programlisting>636 ... --push-atom-selection637 </programlisting>638 <programlisting>639 ... --pop-atom-selection640 </programlisting>641 </listitem>642 631 </itemizedlist> 643 632 </listitem> … … 720 709 <programlisting> 721 710 ... --unselect-atoms-molecules 722 </programlisting>723 </listitem>724 725 <listitem>726 <para>Push/Pop the current selection to/from a stack to store727 it momentarily and allow modifications in MakroActions.</para>728 <programlisting>729 ... --push-molecule-selection730 </programlisting>731 <programlisting>732 ... --pop-molecule-selection733 711 </programlisting> 734 712 </listitem> … … 1269 1247 (without suffix) as its name.</para> 1270 1248 </note> 1271 </section>1272 1273 <section xml:id='molecule.remove-molecule'>1274 <title xml:id='molecule.remove-molecule.title'>Remove molecules1275 </title>1276 1277 <para>This removes one or multiple selected molecules.</para>1278 1279 <programlisting>... -remove-molecule</programlisting>1280 1281 <para>This essentially just removes all of the molecules' atoms1282 which in turn also causes the removal of the molecule.</para>1283 </section>1284 1285 <section xml:id='molecule.translate-molecules'>1286 <title xml:id='molecule.translate-molecules.title'>Translate molecules1287 </title>1288 1289 <para>This translates one or multiple selected molecules by a1290 specific offset..</para>1291 1292 <programlisting>... -translate-molecules</programlisting>1293 1294 <para>This essentially translates all of the molecules' atoms.</para>1295 1249 </section> 1296 1250 -
src/Actions/Action.cpp
r0ac85c3 r7b38d3 146 146 endTimer(); 147 147 148 if (shouldUndo() && state != Action::failure){149 if (canUndo()){148 if(shouldUndo() && state != failure){ 149 if(canUndo()){ 150 150 ActionQueue::getInstance().addElement(this,state); 151 151 } 152 //else{153 //ActionQueue::getInstance().clear();154 //}152 else{ 153 ActionQueue::getInstance().clear(); 154 } 155 155 } 156 156 -
src/Actions/ActionQueue.cpp
r0ac85c3 r7b38d3 44 44 #include <boost/date_time/posix_time/posix_time.hpp> 45 45 #include <boost/version.hpp> 46 #include <iterator>47 46 #include <string> 48 47 #include <sstream> … … 62 61 AR(new ActionRegistry()), 63 62 history(new ActionHistory), 63 CurrentAction(0), 64 64 #ifndef HAVE_ACTION_THREAD 65 65 lastActionOk(true) 66 66 #else 67 CurrentAction(0),68 67 lastActionOk(true), 69 68 run_thread(boost::bind(&ActionQueue::run, this)), … … 83 82 #ifdef HAVE_ACTION_THREAD 84 83 stop(); 85 86 clearTempQueue();87 84 #endif 88 85 … … 114 111 std::cerr << "Action " << *boost::get_error_info<ActionNameString>(e) << " has failed." << std::endl; 115 112 World::getInstance().setExitFlag(5); 116 clearQueue( actionqueue.size()-1);113 clearQueue(); 117 114 lastActionOk = false; 118 std::cerr << " Remaining Actions cleared from queue." << std::endl;115 std::cerr << "ActionQueue cleared." << std::endl; 119 116 } catch (std::exception &e) { 120 117 pushStatus("FAIL: General exception caught, aborting."); 121 118 World::getInstance().setExitFlag(134); 122 clearQueue( actionqueue.size()-1);119 clearQueue(); 123 120 lastActionOk = false; 124 std::cerr << " Remaining Actions cleared from queue." << std::endl;121 std::cerr << "ActionQueue cleared." << std::endl; 125 122 } 126 123 if (lastActionOk) { … … 130 127 } 131 128 #else 132 setRunThreadIdle(CurrentAction == actionqueue.size()); 129 { 130 boost::lock_guard<boost::mutex> lock(mtx_idle); 131 run_thread_isIdle = (CurrentAction == actionqueue.size()); 132 } 133 133 mtx_queue.unlock(); 134 134 #endif … … 144 144 mtx_queue.lock(); 145 145 tempqueue.push_back( newaction ); 146 setRunThreadIdle( !((CurrentAction != actionqueue.size()) || !tempqueue.empty()) ); 146 { 147 boost::lock_guard<boost::mutex> lock(mtx_idle); 148 run_thread_isIdle = !((CurrentAction != actionqueue.size()) || !tempqueue.empty()); 149 } 147 150 mtx_queue.unlock(); 148 151 #endif … … 181 184 pushStatus("FAIL: Action "+*boost::get_error_info<ActionNameString>(e)+" has failed."); 182 185 World::getInstance().setExitFlag(5); 183 clearQueue(CurrentAction); 184 clearTempQueue(); 186 clearQueue(); 185 187 lastActionOk = false; 186 std::cerr << "Remaining Actions cleared from queue." << std::endl; 188 std::cerr << "ActionQueue cleared." << std::endl; 189 CurrentAction = (size_t)-1; 187 190 } catch (std::exception &e) { 188 191 pushStatus("FAIL: General exception caught, aborting."); 189 192 World::getInstance().setExitFlag(134); 190 clearQueue( CurrentAction);191 clearTempQueue();192 std::cerr << "Remaining Actions cleared from queue." << std::endl;193 clearQueue(); 194 std::cerr << "ActionQueue cleared." << std::endl; 195 CurrentAction = (size_t)-1; 193 196 } 194 197 if (lastActionOk) { … … 196 199 NOTIFY(ActionQueued); 197 200 _lastchangedaction = actionqueue[CurrentAction]; 198 mtx_queue.lock();199 CurrentAction++;200 mtx_queue.unlock();201 201 } 202 202 // access actionqueue, hence using mutex 203 203 mtx_queue.lock(); 204 // step on to next action and check for end 205 CurrentAction++; 204 206 // insert new actions (before [CurrentAction]) if they have been spawned 205 207 // we must have an extra vector for this, as we cannot change actionqueue … … 209 211 mtx_queue.unlock(); 210 212 } 211 setRunThreadIdle( !((CurrentAction != actionqueue.size()) || !tempqueue.empty()) ); 213 { 214 boost::lock_guard<boost::mutex> lock(mtx_idle); 215 run_thread_isIdle = !((CurrentAction != actionqueue.size()) || !tempqueue.empty()); 216 } 212 217 cond_idle.notify_one(); 213 218 // LOG(1, "DEBUG: End of ActionQueue's run() loop."); 214 219 } while (!Interrupted); 215 220 } 221 #endif 216 222 217 223 void ActionQueue::insertTempQueue() … … 225 231 } 226 232 233 #ifdef HAVE_ACTION_THREAD 227 234 void ActionQueue::wait() 228 235 { … … 309 316 } 310 317 311 void ActionQueue::clearQueue(const size_t _fromAction) 312 { 313 #ifdef HAVE_ACTION_THREAD 314 mtx_queue.lock(); 315 #endif 316 LOG(1, "Removing all Actions from position " << _fromAction << " onward."); 317 // free all actions still to be called contained in actionqueue 318 ActionQueue_t::iterator inititer = actionqueue.begin(); 319 std::advance(inititer, _fromAction); 320 for (ActionQueue_t::iterator iter = inititer; iter != actionqueue.end(); ++iter) 318 void ActionQueue::clearQueue() 319 { 320 // free all actions contained in actionqueue 321 for (ActionQueue_t::iterator iter = actionqueue.begin(); 322 !actionqueue.empty(); iter = actionqueue.begin()) { 321 323 delete *iter; 322 actionqueue.erase(inititer, actionqueue.end()); 323 LOG(1, "There are " << actionqueue.size() << " remaining Actions."); 324 #ifdef HAVE_ACTION_THREAD 325 CurrentAction = actionqueue.size(); 326 mtx_queue.unlock(); 327 #endif 328 } 329 330 #ifdef HAVE_ACTION_THREAD 331 void ActionQueue::clearTempQueue() 332 { 324 actionqueue.erase(iter); 325 } 333 326 // free all actions contained in tempqueue 334 327 for (ActionQueue_t::iterator iter = tempqueue.begin(); … … 337 330 tempqueue.erase(iter); 338 331 } 339 } 340 341 void ActionQueue::setRunThreadIdle(const bool _flag) 342 { 332 #ifdef HAVE_ACTION_THREAD 343 333 { 344 334 boost::unique_lock<boost::mutex> lock(mtx_idle); 345 run_thread_isIdle = _flag;346 } 347 } 348 #endif 335 run_thread_isIdle = true; 336 } 337 #endif 338 } 349 339 350 340 const ActionQueue::ActionTokens_t ActionQueue::getListOfActions() const … … 365 355 } 366 356 367 bool ActionQueue::canUndo() const368 {369 return history->hasUndo();370 }371 372 357 void ActionQueue::redoLast() 373 358 { … … 375 360 } 376 361 377 bool ActionQueue::canRedo() const378 {379 return history->hasRedo();380 }381 382 362 383 363 CONSTRUCT_SINGLETON(ActionQueue) -
src/Actions/ActionQueue.hpp
r0ac85c3 r7b38d3 145 145 void redoLast(); 146 146 147 /** Checks whether there is one completed Action stored in ActionHistory in the past.148 *149 * @return true - at least one Action to undo present, false - else150 */151 bool canUndo() const;152 153 /** Checks whether there is one completed Action stored in ActionHistory in the future.154 *155 * @return true - at least one Action to redo present, false - else156 */157 bool canRedo() const;158 159 147 /** Return status of last executed action. 160 148 * … … 202 190 void clear(); 203 191 204 /** Clears all actions present in the actionqueues from \a _fromAction. 205 * 206 * @param _fromAction 0 if all Actions to clear or else 207 */ 208 void clearQueue(const size_t _fromAction = 0); 209 210 #ifdef HAVE_ACTION_THREAD 211 212 /** Clears the temporary queue. 213 * 214 */ 215 void clearTempQueue(); 216 217 /** Sets the run_thread_isIdle flag. 218 * 219 * @param _flag state to set to 220 */ 221 void setRunThreadIdle(const bool _flag); 222 192 /** Clears all actions currently present in the actionqueues. 193 * 194 */ 195 void clearQueue(); 196 197 #ifdef HAVE_ACTION_THREAD 223 198 /** Runs the ActionQueue. 224 199 * … … 239 214 */ 240 215 void wait(); 241 242 /** Moves all action from tempqueue into real queue.243 *244 */245 void insertTempQueue();246 247 216 #endif 248 217 … … 255 224 void insertAction(Action *_action, enum Action::QueryOptions state); 256 225 226 /** Moves all action from tempqueue into real queue. 227 * 228 */ 229 void insertTempQueue(); 230 257 231 private: 258 232 /** Private cstor for ActionQueue. … … 281 255 ActionQueue_t actionqueue; 282 256 257 //!> point to current action in actionqueue 258 size_t CurrentAction; 259 260 //!> internal temporary actionqueue of actions used by insertAction() 261 ActionQueue_t tempqueue; 262 283 263 //!> indicates that the last action has failed 284 264 bool lastActionOk; 285 265 286 266 #ifdef HAVE_ACTION_THREAD 287 //!> point to current action in actionqueue288 size_t CurrentAction;289 290 //!> internal temporary actionqueue of actions used by insertAction()291 ActionQueue_t tempqueue;292 293 267 //!> internal thread to call Actions 294 268 boost::thread run_thread; -
src/Actions/ActionRegistry.cpp
r0ac85c3 r7b38d3 91 91 MakroAction * presentAction = 92 92 dynamic_cast<MakroAction *>(getActionByName("subgraph-dissection")); 93 ASSERT( presentAction != NULL,94 "ActionRegistry::fillRegistry() - makro action has not been registered.");95 presentAction->unprepare(*this);96 }97 {98 MakroAction * presentAction =99 dynamic_cast<MakroAction *>(getActionByName("translate-molecules"));100 93 ASSERT( presentAction != NULL, 101 94 "ActionRegistry::fillRegistry() - makro action has not been registered."); … … 143 136 MakroAction * presentAction = 144 137 dynamic_cast<MakroAction *>(getActionByName("optimize-structure")); 145 ASSERT( presentAction != NULL,146 "ActionRegistry::fillRegistry() - makro action has not been registered.");147 presentAction->prepare(*this);148 }149 {150 MakroAction * presentAction =151 dynamic_cast<MakroAction *>(getActionByName("translate-molecules"));152 138 ASSERT( presentAction != NULL, 153 139 "ActionRegistry::fillRegistry() - makro action has not been registered."); -
src/Actions/AtomAction/TranslateAction.def
r0ac85c3 r7b38d3 16 16 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 17 17 #define paramtypes (Vector)(bool) 18 #define paramtokens (" position")("periodic")18 #define paramtokens ("translate-atoms")("periodic") 19 19 #define paramdescriptions ("translation vector")("system is constraint to periodic boundary conditions") 20 20 #define paramreferences (x)(periodic) -
src/Actions/FillAction/SuspendInMoleculeAction.cpp
r0ac85c3 r7b38d3 129 129 filler->CenterEdge(); 130 130 131 /// first we need to calculate some volumes and masses 131 132 std::vector<molecule *> molecules = World::getInstance().getAllMolecules(); 132 if (molecules.size() < 2) {133 STATUS("There must be at least two molecules: filler and to be suspended.");134 return Action::failure;135 }136 137 /// first we need to calculate some volumes and masses138 133 double totalmass = 0.; 139 134 const bool IsAngstroem = true; … … 144 139 iter != molecules.end(); ++iter) 145 140 { 146 // skip the filler147 if (*iter == filler)148 continue;149 141 molecule & mol = **iter; 150 142 const double mass = calculateMass(mol); … … 160 152 LOG(1, "INFO: The average density is " << setprecision(10) 161 153 << totalmass / clustervolume << " atomicmassunit/" 162 << (IsAngstroem ? " angstrom" : " atomiclength") << "^3."); 163 if ( ((totalmass / clustervolume < 1.) && (params.density.get() > 1.)) 164 || ((totalmass / clustervolume > 1.) && (params.density.get() < 1.))) { 165 STATUS("Desired and present molecular densities must both be either in [0,1) or in (1, inf)."); 166 return Action::failure; 167 } 154 << (IsAngstroem ? "angstrom" : "atomiclength") << "^3."); 168 155 169 156 // calculate maximum solvent density 170 157 std::vector<double> fillerdiameters(NDIM, 0.); 171 const double fillervolume = calculateEnvelopeVolume(*filler, fillerdiameters); 172 const double fillermass = calculateMass(*filler); 173 LOG(1, "INFO: The filler's mass is " << setprecision(10) 174 << fillermass << " atomicmassunit, and it's volume is " 175 << fillervolume << (IsAngstroem ? " angstrom" : " atomiclength") << "^3."); 176 const double solventdensity = fillermass / fillervolume; 158 const double solventdensity = 159 calculateMass(*filler) / calculateEnvelopeVolume(*filler, fillerdiameters); 160 161 std::vector<unsigned int> counts(3, 0); 162 Vector offset(.5,.5,.5); 177 163 178 164 /// solve cubic polynomial 179 165 double cellvolume = 0.; 180 166 LOG(1, "Solving equidistant suspension in water problem ..."); 181 // s = solvent, f = filler, 0 = initial molecules/cluster 182 // v_s = v_0 + v_f, m_s = m_0 + rho_f * v_f --> rho_s = m_s/v_s ==> v_f = (m_0 - rho_s * v_o) / (rho_s - rho_f) 183 cellvolume = (totalmass - params.density.get() * clustervolume) / (params.density.get() - 1.) + clustervolume; 167 cellvolume = (totalmass / solventdensity 168 - (totalmass / clustervolume)) / (params.density.get() - 1.); 184 169 LOG(1, "Cellvolume needed for a density of " << params.density.get() 185 170 << " g/cm^3 is " << cellvolume << " angstroem^3."); … … 188 173 (GreatestDiameter[0] * GreatestDiameter[1] * GreatestDiameter[2]); 189 174 LOG(1, "Minimum volume of the convex envelope contained in a rectangular box is " 190 << minimumvolume << " 175 << minimumvolume << "angstrom^3."); 191 176 192 177 if (minimumvolume > cellvolume) { … … 202 187 + GreatestDiameter[1] * GreatestDiameter[2]; 203 188 BoxLengths[2] = minimumvolume - cellvolume; 204 std::vector<double> x(3, 0.); 189 double x0 = 0.; 190 double x1 = 0.; 191 double x2 = 0.; 205 192 // for cubic polynomial there are either 1 or 3 unique solutions 206 if (gsl_poly_solve_cubic(BoxLengths[0], BoxLengths[1], BoxLengths[2], &x[0], &x[1], &x[2]) == 1) { 207 x[1] = x[0]; 208 x[2] = x[0]; 209 } else { 210 std::swap(x[0], x[2]); // sorted in ascending order 211 } 212 LOG(0, "RESULT: The resulting spacing is: " << x << " ."); 193 if (gsl_poly_solve_cubic(BoxLengths[0], BoxLengths[1], BoxLengths[2], &x0, &x1, &x2) == 1) 194 LOG(0, "RESULT: The resulting spacing is: " << x0 << " ."); 195 else { 196 LOG(0, "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ."); 197 std::swap(x0, x2); // sorted in ascending order 198 } 213 199 214 200 cellvolume = 1.; 215 201 for (size_t i = 0; i < NDIM; ++i) { 216 BoxLengths[i] = x [i]+ GreatestDiameter[i];202 BoxLengths[i] = x0 + GreatestDiameter[i]; 217 203 cellvolume *= BoxLengths[i]; 218 204 } 219 } 220 221 // TODO: Determine counts from resulting mass correctly (hard problem due to integers) 222 std::vector<unsigned int> counts(3, 0); 223 const unsigned int totalcounts = round(params.density.get() * cellvolume - totalmass) / fillermass; 224 if (totalcounts > 0) { 225 counts[0] = ceil(BoxLengths[0]/3.1); 226 counts[1] = ceil(BoxLengths[1]/3.1); 227 counts[2] = ceil(BoxLengths[2]/3.1); 205 206 // set new box dimensions 207 LOG(0, "Translating to box with these boundaries."); 208 { 209 RealSpaceMatrix domain; 210 for(size_t i =0; i<NDIM;++i) 211 domain.at(i,i) = BoxLengths[i]; 212 World::getInstance().setDomain(domain); 213 } 214 // mol->CenterInBox(); 228 215 } 229 216 … … 244 231 params.RandMoleculeDisplacement.get(), 245 232 params.DoRotate.get()); 246 Vector offset(.5,.5,.5);247 233 filler_preparator.addCubeMesh( 248 234 counts, -
src/Actions/FillAction/SuspendInMoleculeAction.def
r0ac85c3 r7b38d3 17 17 #include "Parameters/Validators/RangeValidator.hpp" 18 18 #include "Parameters/Validators/STLVectorValidator.hpp" 19 #include "Parameters/Validators/Ops_Validator.hpp"20 19 #include "Parameters/Validators/Specific/BoxLengthValidator.hpp" 21 20 #include "Parameters/Validators/Specific/VectorZeroOneComponentsValidator.hpp" … … 26 25 #define paramtypes (double)(double)(double)(double)(bool) 27 26 #define paramtokens ("density")("min-distance")("random-atom-displacement")("random-molecule-displacement")("DoRotate") 28 #define paramdescriptions ("desired density for the total domain , unequal 1.")("minimum distance of water molecules to present atoms")("magnitude of random atom displacement")("magnitude of random molecule displacement")("whether to rotate or not")27 #define paramdescriptions ("desired density for the total domain")("minimum distance of water molecules to present atoms")("magnitude of random atom displacement")("magnitude of random molecule displacement")("whether to rotate or not") 29 28 #define paramdefaults (PARAM_DEFAULT(1.))(PARAM_DEFAULT(1.))(PARAM_DEFAULT(0.))(PARAM_DEFAULT(0.))(PARAM_DEFAULT(false)) 30 29 #define paramreferences (density)(mindistance)(RandAtomDisplacement)(RandMoleculeDisplacement)(DoRotate) 31 30 #define paramvalids \ 32 (RangeValidator< double >(0., 1. - std::numeric_limits<double>::epsilon()) || RangeValidator< double >(1. + std::numeric_limits<double>::epsilon(),std::numeric_limits<double>::max())) \31 (RangeValidator< double >(0., std::numeric_limits<double>::max())) \ 33 32 (BoxLengthValidator()) \ 34 33 (BoxLengthValidator()) \ -
src/Actions/GlobalListOfActions.hpp
r0ac85c3 r7b38d3 76 76 (MoleculeLinearInterpolationofTrajectories) \ 77 77 (MoleculeLoad) \ 78 (MoleculeRemove) \79 78 (MoleculeRotateAroundSelfByAngle) \ 80 79 (MoleculeRotateToPrincipalAxisSystem) \ … … 84 83 (MoleculeSaveTemperature) \ 85 84 (MoleculeStretchBond) \ 86 (MoleculeTranslate) \87 85 (MoleculeVerletIntegration) \ 88 86 (PotentialFitParticleCharges) \ … … 128 126 (SelectionNotMoleculeByOrder) \ 129 127 (SelectionNotShapeByName) \ 130 (SelectionPopAtoms) \131 (SelectionPushAtoms) \132 (SelectionPopMolecules) \133 (SelectionPushMolecules) \134 128 (SelectionShapeByName) \ 135 129 (ShapeCombineShapes) \ -
src/Actions/GraphAction/SubgraphDissectionAction.cpp
r0ac85c3 r7b38d3 42 42 #include "Actions/GraphAction/UpdateMoleculesAction.hpp" 43 43 #include "Actions/GraphAction/SubgraphDissectionAction.hpp" 44 #include "Actions/SelectionAction/Atoms/PushAtomsAction.hpp"45 #include "Actions/SelectionAction/Atoms/PopAtomsAction.hpp"46 #include "Actions/SelectionAction/Atoms/AllAtomsAction.hpp"47 44 #include "Actions/ActionQueue.hpp" 48 45 #include "Actions/ActionRegistry.hpp" … … 63 60 void GraphSubgraphDissectionAction::prepare(ActionRegistry &AR) 64 61 { 65 actions.addAction(AR.getActionByName(std::string("push-atom-selection")));66 62 actions.addAction(AR.getActionByName(std::string("select-all-atoms"))); 67 63 actions.addAction(AR.getActionByName(std::string("destroy-adjacency"))); 68 64 actions.addAction(AR.getActionByName(std::string("create-adjacency"))); 69 65 actions.addAction(AR.getActionByName(std::string("update-molecules"))); 70 actions.addAction(AR.getActionByName(std::string("pop-atom-selection")));71 66 isPrepared = true; 72 67 } … … 79 74 } 80 75 76 void reselectAtoms(const std::vector<atom *> &selected_atoms) 77 { 78 World::getInstance().clearAtomSelection(); 79 for (std::vector<atom *>::const_iterator iter = selected_atoms.begin(); 80 iter != selected_atoms.end(); 81 ++iter) 82 World::getInstance().selectAtom(*iter); 83 } 84 81 85 ActionState::ptr GraphSubgraphDissectionAction::performCall(){ 86 // we need to "emulate" that all atoms have been selected without destroying 87 // current selection 88 const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms(); 82 89 ActionState::ptr state(MakroAction::performCall()); 90 reselectAtoms(selected_atoms); 83 91 84 92 return state; … … 86 94 87 95 ActionState::ptr GraphSubgraphDissectionAction::performUndo(ActionState::ptr _state) { 96 // we need to "emulate" that all atoms have been selected without destroying 97 // current selection 98 const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms(); 88 99 ActionState::ptr state(MakroAction::performUndo(_state)); 100 reselectAtoms(selected_atoms); 89 101 90 102 return state; … … 92 104 93 105 ActionState::ptr GraphSubgraphDissectionAction::performRedo(ActionState::ptr _state){ 106 // we need to "emulate" that all atoms have been selected without destroying 107 // current selection 108 const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms(); 94 109 ActionState::ptr state(MakroAction::performRedo(_state)); 110 reselectAtoms(selected_atoms); 95 111 96 112 return state; -
src/Actions/Makefile.am
r0ac85c3 r7b38d3 297 297 Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp \ 298 298 Actions/MoleculeAction/LoadAction.cpp \ 299 Actions/MoleculeAction/RemoveAction.cpp \300 299 Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp \ 301 300 Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp \ … … 305 304 Actions/MoleculeAction/SaveTemperatureAction.cpp \ 306 305 Actions/MoleculeAction/StretchBondAction.cpp \ 307 Actions/MoleculeAction/TranslateAction.cpp \308 306 Actions/MoleculeAction/VerletIntegrationAction.cpp 309 307 MOLECULEACTIONHEADER = \ … … 315 313 Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp \ 316 314 Actions/MoleculeAction/LoadAction.hpp \ 317 Actions/MoleculeAction/RemoveAction.hpp \318 315 Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp \ 319 316 Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp \ … … 323 320 Actions/MoleculeAction/SaveTemperatureAction.hpp \ 324 321 Actions/MoleculeAction/StretchBondAction.hpp \ 325 Actions/MoleculeAction/TranslateAction.hpp \326 322 Actions/MoleculeAction/VerletIntegrationAction.hpp 327 323 MOLECULEACTIONDEFS = \ … … 333 329 Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.def \ 334 330 Actions/MoleculeAction/LoadAction.def \ 335 Actions/MoleculeAction/RemoveAction.def \336 331 Actions/MoleculeAction/RotateAroundSelfByAngleAction.def \ 337 332 Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.def \ … … 341 336 Actions/MoleculeAction/SaveTemperatureAction.def \ 342 337 Actions/MoleculeAction/StretchBondAction.def \ 343 Actions/MoleculeAction/TranslateAction.def \344 338 Actions/MoleculeAction/VerletIntegrationAction.def 345 339 … … 418 412 Actions/SelectionAction/Atoms/NotAtomByElementAction.cpp \ 419 413 Actions/SelectionAction/Atoms/NotAtomByIdAction.cpp \ 420 Actions/SelectionAction/Atoms/NotAtomByOrderAction.cpp \ 421 Actions/SelectionAction/Atoms/PopAtomsAction.cpp \ 422 Actions/SelectionAction/Atoms/PushAtomsAction.cpp 414 Actions/SelectionAction/Atoms/NotAtomByOrderAction.cpp 423 415 SELECTIONATOMACTIONHEADER = \ 424 416 Actions/SelectionAction/Atoms/AllAtomsAction.hpp \ … … 435 427 Actions/SelectionAction/Atoms/NotAtomByElementAction.hpp \ 436 428 Actions/SelectionAction/Atoms/NotAtomByIdAction.hpp \ 437 Actions/SelectionAction/Atoms/NotAtomByOrderAction.hpp \ 438 Actions/SelectionAction/Atoms/PopAtomsAction.hpp \ 439 Actions/SelectionAction/Atoms/PushAtomsAction.hpp 429 Actions/SelectionAction/Atoms/NotAtomByOrderAction.hpp 440 430 SELECTIONATOMACTIONDEFS = \ 441 431 Actions/SelectionAction/Atoms/AllAtomsAction.def \ … … 452 442 Actions/SelectionAction/Atoms/NotAtomByElementAction.def \ 453 443 Actions/SelectionAction/Atoms/NotAtomByIdAction.def \ 454 Actions/SelectionAction/Atoms/NotAtomByOrderAction.def \ 455 Actions/SelectionAction/Atoms/PopAtomsAction.def \ 456 Actions/SelectionAction/Atoms/PushAtomsAction.def 444 Actions/SelectionAction/Atoms/NotAtomByOrderAction.def 457 445 458 446 SELECTIONMOLECULEACTIONSOURCE = \ … … 470 458 Actions/SelectionAction/Molecules/NotMoleculeByNameAction.cpp \ 471 459 Actions/SelectionAction/Molecules/NotMoleculeByOrderAction.cpp \ 472 Actions/SelectionAction/Molecules/NotMoleculeOfAtomAction.cpp \ 473 Actions/SelectionAction/Molecules/PopMoleculesAction.cpp \ 474 Actions/SelectionAction/Molecules/PushMoleculesAction.cpp 460 Actions/SelectionAction/Molecules/NotMoleculeOfAtomAction.cpp 475 461 SELECTIONMOLECULEACTIONHEADER = \ 476 462 Actions/SelectionAction/Molecules/AllMoleculesAction.hpp \ … … 487 473 Actions/SelectionAction/Molecules/NotMoleculeByNameAction.hpp \ 488 474 Actions/SelectionAction/Molecules/NotMoleculeByOrderAction.hpp \ 489 Actions/SelectionAction/Molecules/NotMoleculeOfAtomAction.hpp \ 490 Actions/SelectionAction/Molecules/PopMoleculesAction.hpp \ 491 Actions/SelectionAction/Molecules/PushMoleculesAction.hpp 475 Actions/SelectionAction/Molecules/NotMoleculeOfAtomAction.hpp 492 476 SELECTIONMOLECULEACTIONDEFS = \ 493 477 Actions/SelectionAction/Molecules/AllMoleculesAction.def \ … … 504 488 Actions/SelectionAction/Molecules/NotMoleculeByNameAction.def \ 505 489 Actions/SelectionAction/Molecules/NotMoleculeByOrderAction.def \ 506 Actions/SelectionAction/Molecules/NotMoleculeOfAtomAction.def \ 507 Actions/SelectionAction/Molecules/PopMoleculesAction.def \ 508 Actions/SelectionAction/Molecules/PushMoleculesAction.def 490 Actions/SelectionAction/Molecules/NotMoleculeOfAtomAction.def 509 491 510 492 SELECTIONSHAPEACTIONSOURCE = \ -
src/Actions/SelectionAction/Atoms/NotAtomByIdAction.def
r0ac85c3 r7b38d3 26 26 (STLVectorValidator< std::vector<atomId_t> >(AtomIdValidator())) 27 27 28 28 29 #define statetypes (atomids_t) 29 30 #define statereferences (undoatomids) -
src/Actions/SelectionAction/Molecules/MoleculeByIdAction.cpp
r0ac85c3 r7b38d3 53 53 /** =========== define the function ====================== */ 54 54 ActionState::ptr SelectionMoleculeByIdAction::performCall() { 55 56 enum Sucess { 57 NoStatus, 58 AllMoleculesUnselected, 59 MoleculesSelected, 60 MoleculeMissing 61 } status = NoStatus; 62 63 const molids_t molids = params.molids.get(); 64 molids_t undomolids; 65 undomolids.reserve(molids.size()); 66 for (molids_t::const_iterator iter = molids.begin(); iter != molids.end(); ++iter) { 67 const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter)); 68 if (Walker != NULL) { 69 if (!World::getInstance().isSelected(Walker)) { 70 LOG(1, "Selecting mol " << Walker->getName()); 71 World::getInstance().selectMolecule(Walker); 72 undomolids.push_back(*iter); 73 if (status < MoleculeMissing) 74 status = MoleculesSelected; 75 } else { 76 if (status == NoStatus) 77 status = AllMoleculesUnselected; 78 } 55 const molecule *mol = World::getInstance().getMolecule(MoleculeById(params.molindex.get())); 56 if (mol != NULL) { 57 if (!World::getInstance().isSelected(mol)) { 58 LOG(1, "Selecting molecule " << mol->name); 59 World::getInstance().selectAllMolecules(MoleculeById(params.molindex.get())); 60 LOG(0, World::getInstance().countSelectedMolecules() << " molecules selected."); 61 return ActionState::ptr(new SelectionMoleculeByIdState(params)); 79 62 } else { 80 status = MoleculeMissing;63 return Action::success; 81 64 } 65 } else { 66 STATUS("Cannot find molecule by given index "+toString(params.molindex.get())+"."); 67 return Action::failure; 82 68 } 83 LOG(0, World::getInstance().countSelectedMolecules() << " mols selected.");84 85 switch (status) {86 case MoleculeMissing:87 STATUS("Cannot find all mols with given ids.");88 return Action::failure;89 break;90 case AllMoleculesUnselected:91 case MoleculesSelected:92 return ActionState::ptr(new SelectionMoleculeByIdState(undomolids, params));93 break;94 default:95 STATUS("No mols have been selected.");96 return Action::failure;97 break;98 }99 return Action::failure;100 69 } 101 70 … … 103 72 SelectionMoleculeByIdState *state = assert_cast<SelectionMoleculeByIdState*>(_state.get()); 104 73 105 for (molids_t::const_iterator iter = state->undomolids.begin(); 106 iter != state->undomolids.end(); ++iter) { 107 const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter)); 108 World::getInstance().unselectMolecule(Walker); 109 } 74 World::getInstance().unselectAllMolecules(MoleculeById(state->params.molindex.get())); 110 75 111 76 return ActionState::ptr(_state); … … 115 80 SelectionMoleculeByIdState *state = assert_cast<SelectionMoleculeByIdState*>(_state.get()); 116 81 117 for (molids_t::const_iterator iter = state->undomolids.begin(); 118 iter != state->undomolids.end(); ++iter) { 119 const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter)); 120 World::getInstance().selectMolecule(Walker); 121 } 82 World::getInstance().selectAllMolecules(MoleculeById(state->params.molindex.get())); 122 83 123 84 return ActionState::ptr(_state); -
src/Actions/SelectionAction/Molecules/MoleculeByIdAction.def
r0ac85c3 r7b38d3 7 7 8 8 // all includes and forward declarations necessary for non-integral types below 9 #include <vector>10 9 #include "types.hpp" 11 10 12 typedef std::vector<moleculeId_t> molids_t;13 14 #include "Parameters/Validators/STLVectorValidator.hpp"15 11 #include "Parameters/Validators/Specific/MoleculeIdValidator.hpp" 16 12 … … 18 14 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 19 15 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 20 #define paramtypes (mol ids_t)16 #define paramtypes (moleculeId_t) 21 17 #define paramtokens ("select-molecule-by-id") 22 #define paramdescriptions ("molecule ind ices to select")18 #define paramdescriptions ("molecule index") 23 19 #undef paramdefaults 24 #define paramreferences (moli ds)20 #define paramreferences (molindex) 25 21 #define paramvalids \ 26 ( STLVectorValidator< std::vector<moleculeId_t> >(MoleculeIdValidator()))22 (MoleculeIdValidator()) 27 23 28 # define statetypes (molids_t)29 # define statereferences (undomolids)24 #undef statetypes 25 #undef statereferences 30 26 31 27 // some defines for all the names, you may use ACTION, STATE and PARAMS -
src/Actions/SelectionAction/Molecules/NotMoleculeByIdAction.cpp
r0ac85c3 r7b38d3 53 53 /** =========== define the function ====================== */ 54 54 ActionState::ptr SelectionNotMoleculeByIdAction::performCall() { 55 enum Sucess { 56 NoStatus, 57 AllMoleculesSelected, 58 MoleculesUnselected, 59 MoleculeMissing 60 } status = NoStatus; 61 62 const molids_t molids = params.molids.get(); 63 molids_t undomolids; 64 undomolids.reserve(molids.size()); 65 for (molids_t::const_iterator iter = molids.begin(); iter != molids.end(); ++iter) { 66 const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter)); 67 if (Walker != NULL) { 68 if (World::getInstance().isSelected(Walker)) { 69 LOG(1, "Unselecting mol " << Walker->getName()); 70 World::getInstance().unselectMolecule(Walker); 71 undomolids.push_back(*iter); 72 if (status < MoleculeMissing) 73 status = MoleculesUnselected; 74 } else { 75 if (status == NoStatus) 76 status = AllMoleculesSelected; 77 } 55 const molecule *mol = World::getInstance().getMolecule(MoleculeById(params.molindex.get())); 56 if (mol != NULL) { 57 if (World::getInstance().isSelected(mol)) { 58 LOG(1, "Unselecting molecule " << mol->name); 59 World::getInstance().unselectAllMolecules(MoleculeById(params.molindex.get())); 60 LOG(0, World::getInstance().countSelectedMolecules() << " molecules remain selected."); 61 return ActionState::ptr(new SelectionNotMoleculeByIdState(params)); 78 62 } else { 79 status = MoleculeMissing;63 return Action::success; 80 64 } 65 } else { 66 STATUS("Cannot find molecule by given index "+toString(params.molindex.get())+"."); 67 return Action::failure; 81 68 } 82 LOG(0, World::getInstance().countSelectedMolecules() << " mols remain selected.");83 84 switch (status) {85 case MoleculeMissing:86 STATUS("Cannot find all mols by given ids.");87 return Action::failure;88 break;89 case AllMoleculesSelected:90 case MoleculesUnselected:91 return ActionState::ptr(new SelectionNotMoleculeByIdState(undomolids, params));92 break;93 default:94 STATUS("No mols have been selected.");95 return Action::failure;96 break;97 }98 return Action::failure;99 69 } 100 70 … … 102 72 SelectionNotMoleculeByIdState *state = assert_cast<SelectionNotMoleculeByIdState*>(_state.get()); 103 73 104 for (molids_t::const_iterator iter = state->undomolids.begin(); 105 iter != state->undomolids.end(); ++iter) { 106 const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter)); 107 World::getInstance().selectMolecule(Walker); 108 } 74 World::getInstance().selectAllMolecules(MoleculeById(state->params.molindex.get())); 109 75 110 76 return ActionState::ptr(_state); … … 114 80 SelectionNotMoleculeByIdState *state = assert_cast<SelectionNotMoleculeByIdState*>(_state.get()); 115 81 116 for (molids_t::const_iterator iter = state->undomolids.begin(); 117 iter != state->undomolids.end(); ++iter) { 118 const molecule *Walker = World::getInstance().getMolecule(MoleculeById(*iter)); 119 World::getInstance().unselectMolecule(Walker); 120 } 82 World::getInstance().unselectAllMolecules(MoleculeById(state->params.molindex.get())); 121 83 122 84 return ActionState::ptr(_state); -
src/Actions/SelectionAction/Molecules/NotMoleculeByIdAction.def
r0ac85c3 r7b38d3 7 7 8 8 // all includes and forward declarations necessary for non-integral types below 9 #include <vector>10 9 #include "types.hpp" 11 10 12 typedef std::vector<moleculeId_t> molids_t;13 14 #include "Parameters/Validators/STLVectorValidator.hpp"15 11 #include "Parameters/Validators/Specific/MoleculeIdValidator.hpp" 16 12 … … 18 14 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 19 15 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 20 #define paramtypes (mol ids_t)16 #define paramtypes (moleculeId_t) 21 17 #define paramtokens ("unselect-molecule-by-id") 22 #define paramdescriptions ("molecule ind ices to unselect")18 #define paramdescriptions ("molecule index") 23 19 #undef paramdefaults 24 #define paramreferences (moli ds)20 #define paramreferences (molindex) 25 21 #define paramvalids \ 26 ( STLVectorValidator< std::vector<moleculeId_t> >(MoleculeIdValidator()))22 (MoleculeIdValidator()) 27 23 28 # define statetypes (molids_t)29 # define statereferences (undomolids)24 #undef statetypes 25 #undef statereferences 30 26 31 27 // some defines for all the names, you may use ACTION, STATE and PARAMS -
src/Actions/UndoRedoHelpers.cpp
r0ac85c3 r7b38d3 52 52 #include "WorldTime.hpp" 53 53 54 bool MoleCuilder::AddAtomsFromAtomicInfo( conststd::vector<AtomicInfo> &atoms)54 bool MoleCuilder::AddAtomsFromAtomicInfo(std::vector<AtomicInfo> &atoms) 55 55 { 56 56 size_t i=0; … … 69 69 for (size_t j=0;j<i;++j) 70 70 World::getInstance().destroyAtom(atoms[j].getId()); 71 // and announce the failure72 return false;73 }74 return true;75 }76 77 bool MoleCuilder::AddMoleculesFromAtomicInfo(std::map< moleculeId_t, std::vector<AtomicInfo> > &mol_atoms)78 {79 bool status = true;80 for (std::map< moleculeId_t, std::vector<AtomicInfo> >::const_iterator iter = mol_atoms.begin();81 iter != mol_atoms.end(); ++iter) {82 // re-create the atom83 LOG(3, "DEBUG: Re-adding molecule " << iter->first << ".");84 molecule *mol_Walker = World::getInstance().createMolecule();85 86 // reset the mol id87 bool status = true;88 if (mol_Walker->getId() != iter->first)89 status &= mol_Walker->changeId(iter->first);90 91 // add all its atoms92 status &= AddAtomsFromAtomicInfo(iter->second);93 }94 if (!status) {95 // remove all molecules again96 for (std::map< moleculeId_t, std::vector<AtomicInfo> >::const_iterator iter = mol_atoms.begin();97 iter != mol_atoms.end(); ++iter) {98 molecule * mol = World::getInstance().getMolecule(MoleculeById(iter->first));99 if (mol != NULL)100 removeAtomsinMolecule(mol);101 }102 71 // and announce the failure 103 72 return false; … … 204 173 for (std::vector<moleculeId_t>::const_iterator iter = ids.begin(); 205 174 iter != ids.end(); ++iter) { 206 molecule * mol = World::getInstance().getMolecule(MoleculeById(*iter));175 molecule * const mol = World::getInstance().getMolecule(MoleculeById(*iter)); 207 176 if (mol != NULL) { 208 removeAtomsinMolecule(mol);209 // molecules are automatically removed when empty177 mol->removeAtomsinMolecule(); 178 World::getInstance().destroyMolecule(mol); 210 179 } 211 180 } -
src/Actions/UndoRedoHelpers.hpp
r0ac85c3 r7b38d3 27 27 * @return restoral was successful, at least atom could not be restored. 28 28 */ 29 bool AddAtomsFromAtomicInfo(const std::vector<AtomicInfo> &atoms); 30 31 /** Adds removed molecules with their atoms back to the world. 32 * 33 * @param mol_atoms map of molecules with ids and their atoms as AtomicInfo 34 * \return true - restoral was successful, at least one atom or molecule could not be restored 35 */ 36 bool AddMoleculesFromAtomicInfo(std::map< moleculeId_t, std::vector<AtomicInfo> > &mol_atoms); 29 bool AddAtomsFromAtomicInfo(std::vector<AtomicInfo> &atoms); 37 30 38 31 /** Removes atoms whose state information is stored as AtomicInfo. -
src/Actions/WorldAction/RepeatBoxAction.cpp
r0ac85c3 r7b38d3 147 147 iter != allmolecules.end(); 148 148 ++iter) { 149 if (state->oldmolecules.find(*iter) == state->oldmolecules.end()) 150 removeAtomsinMolecule(*iter); 149 if (state->oldmolecules.find(*iter) == state->oldmolecules.end()) { 150 (*iter)->removeAtomsinMolecule(); 151 // TODO: Remove this when World don't has deprecated MoleculeListClass anymore 152 molecules->erase(*iter); 153 World::getInstance().destroyMolecule(*iter); 154 } 151 155 } 152 156 -
src/Atom/atom.cpp
r0ac85c3 r7b38d3 270 270 removeFromMolecule(); 271 271 mol = _mol; 272 if ((mol) && (!mol->containsAtom(this))) { 273 signOn(mol, AtomObservable::PositionChanged); 272 if ((mol) && (!mol->containsAtom(this))) 274 273 mol->insert(this); 275 }276 274 } 277 275 … … 281 279 ASSERT(!mol->containsAtom(this), 282 280 "atom::unsetMolecule() - old molecule "+toString(mol)+" still contains us!"); 283 signOff(mol, AtomObservable::PositionChanged);284 281 mol = NULL; 285 282 } … … 292 289 if(mol){ 293 290 if(mol->containsAtom(this)){ 294 signOff(mol, AtomObservable::PositionChanged);295 291 mol->erase(this); 296 292 } -
src/Fragmentation/Exporters/ExportGraph.cpp
r0ac85c3 r7b38d3 80 80 // remove copied atoms and molecule again 81 81 molecule *mol = *iter; 82 mol->removeAtomsinMolecule(); 83 World::getInstance().destroyMolecule(mol); 82 84 BondFragments.ListOfMolecules.erase(iter); 83 removeAtomsinMolecule(mol);84 85 } 85 86 } -
src/Graph/DepthFirstSearchAnalysis.cpp
r0ac85c3 r7b38d3 431 431 World::getInstance().getMoleculeIter() != World::getInstance().moleculeEnd(); 432 432 iter = World::getInstance().getMoleculeIter()) { 433 // TODO: remove when deprecated MoleculeListClass is gone434 433 World::getInstance().getMolecules()->erase(*iter); 435 434 World::getInstance().destroyMolecule(*iter); -
src/Graph/unittests/AdjacencyListUnitTest.cpp
r0ac85c3 r7b38d3 153 153 154 154 // destroy molecule and contained atoms 155 removeAtomsinMolecule(TestMolecule); 155 TestMolecule->removeAtomsinMolecule(); 156 World::getInstance().destroyMolecule(TestMolecule); 156 157 // destroy World 157 158 World::purgeInstance(); -
src/MoleculeLeafClass.cpp
r0ac85c3 r7b38d3 85 85 // } 86 86 // remove the leaf itself 87 if (Leaf != NULL) 88 removeAtomsinMolecule(Leaf); 87 if (Leaf != NULL) { 88 Leaf->removeAtomsinMolecule(); 89 World::getInstance().destroyMolecule(Leaf); 90 Leaf = NULL; 91 } 89 92 // remove this Leaf from level list 90 93 if (previous != NULL) -
src/UIElements/CommandLineUI/CommandLineParser.cpp
r0ac85c3 r7b38d3 443 443 // force action queue to stop thread 444 444 ActionQueue::getInstance().stop(); 445 ActionQueue::getInstance().clearTempQueue();446 445 #endif 447 446 ActionQueue::getInstance().clearQueue(); -
src/UIElements/Qt4/QtMainWindow.cpp
r0ac85c3 r7b38d3 146 146 settings.endGroup(); 147 147 148 qRegisterMetaType<moleculeId_t>("moleculeId_t"); 149 150 connect(glWorldView,SIGNAL(hoverChanged(const atom&)), infoBox,SLOT(atomHover(const atom&))); 151 connect(glWorldView,SIGNAL(hoverChanged(const molecule&, int)), infoBox,SLOT(moleculeHover(const molecule&))); 152 connect(moleculeList,SIGNAL(moleculesVisibilityChanged(const moleculeId_t,bool)), glWorldView, SIGNAL(moleculesVisibilityChanged(const moleculeId_t,bool))); 148 connect(glWorldView,SIGNAL(hoverChanged(const atom*)), infoBox,SLOT(atomHover(const atom*))); 153 149 } 154 150 -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.cpp
r0ac85c3 r7b38d3 62 62 QGLMaterial *GLMoleculeObject::m_selectionBoxMaterial = NULL; 63 63 64 QGLSceneNode *GLMoleculeObject::meshEmpty[GLMoleculeObject::DETAILTYPES_MAX];65 QGLSceneNode *GLMoleculeObject::meshSphere[GLMoleculeObject::DETAILTYPES_MAX];66 QGLSceneNode *GLMoleculeObject::meshCylinder[GLMoleculeObject::DETAILTYPES_MAX];67 64 68 65 double GLMoleculeObject::detailMinDistance[GLMoleculeObject::DETAILTYPES_MAX] = {0, 15, 30, 42}; … … 72 69 { 73 70 //mesh->setParent(this); 74 for (int i=0;i<DETAILTYPES_MAX;i++) 75 m_mesh[i] = mesh[i]; 76 MeshFreeType = free_none; 77 m_scaleX = 1.0f; 78 m_scaleY = 1.0f; 79 m_scaleZ = 1.0f; 80 m_rotationAngle = 0.0f; 81 m_effect = 0; 82 m_objectId = -1; 83 m_hovering = false; 84 m_selected = false; 85 m_visible = true; 86 m_material = 0; 87 initStaticMaterials(); 88 } 89 90 GLMoleculeObject::GLMoleculeObject(QGLSceneNode *mesh, QObject *parent) 91 : QObject(parent) 92 { 93 //mesh->setParent(this); 94 for (int i=0;i<DETAILTYPES_MAX;i++) 95 m_mesh[i] = mesh; 96 MeshFreeType = free_none; 71 for (int i=0;i<DETAILTYPES_MAX;i++) 72 m_mesh[i] = mesh[i]; 97 73 m_scaleX = 1.0f; 98 74 m_scaleY = 1.0f; … … 107 83 } 108 84 109 GLMoleculeObject::GLMoleculeObject(QGL AbstractScene *scene, QObject *parent)85 GLMoleculeObject::GLMoleculeObject(QGLSceneNode *mesh, QObject *parent) 110 86 : QObject(parent) 111 87 { 112 for (int i=0;i<DETAILTYPES_MAX;i++)113 m_mesh[i] = scene->mainNode();114 MeshFreeType = free_none;88 //mesh->setParent(this); 89 for (int i=0;i<DETAILTYPES_MAX;i++) 90 m_mesh[i] = mesh; 115 91 m_scaleX = 1.0f; 116 92 m_scaleY = 1.0f; … … 125 101 } 126 102 103 GLMoleculeObject::GLMoleculeObject(QGLAbstractScene *scene, QObject *parent) 104 : QObject(parent) 105 { 106 scene->setParent(this); 107 for (int i=0;i<DETAILTYPES_MAX;i++) 108 m_mesh[i] = scene->mainNode(); 109 m_scaleX = 1.0f; 110 m_scaleY = 1.0f; 111 m_scaleZ = 1.0f; 112 m_rotationAngle = 0.0f; 113 m_effect = 0; 114 m_objectId = -1; 115 m_hovering = false; 116 m_selected = false; 117 m_material = 0; 118 initStaticMaterials(); 119 } 120 127 121 GLMoleculeObject::~GLMoleculeObject() 128 122 { … … 169 163 painter->modelViewMatrix().push(); 170 164 painter->modelViewMatrix().translate(m_position); 171 if ((m_scaleX != 1.0f) || (m_scaleY != 1.0f) || (m_scaleZ != 1.0f))172 painter->modelViewMatrix().scale(m_scaleX, m_scaleY, m_scaleZ);173 165 if (m_rotationAngle != 0.0f) 174 166 painter->modelViewMatrix().rotate(m_rotationAngle, m_rotationVector); 167 painter->modelViewMatrix().scale(m_scaleX, m_scaleY, m_scaleZ); 175 168 176 169 // Apply the material and effect to the painter. … … 332 325 } 333 326 } 334 335 void GLMoleculeObject::setVisible(bool value)336 {337 if (value != m_visible){338 m_visible = value;339 emit changed();340 }341 }342 343 void GLMoleculeObject::updateMesh(QGLSceneNode *mesh)344 {345 if (m_mesh[0] != NULL) {346 switch(MeshFreeType) {347 case free_all:348 for (int i=0;i<DETAILTYPES_MAX;i++)349 delete m_mesh[i];350 break;351 case free_single:352 delete m_mesh[0];353 break;354 default:355 case free_none:356 break;357 }358 }359 MeshFreeType = free_single;360 for (int i=0;i<DETAILTYPES_MAX;i++)361 m_mesh[i] = mesh;362 } -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.hpp
r0ac85c3 r7b38d3 74 74 void setSelected(bool value); 75 75 76 bool visible() const { return m_visible; }77 virtual void setVisible(bool value);78 79 76 void initStaticMaterials(); 80 v irtual void initialize(QGLView *view, QGLPainter *painter);77 void initialize(QGLView *view, QGLPainter *painter); 81 78 virtual void draw(QGLPainter *painter, const QVector4D &cameraPlane); 82 79 void drawSelectionBox(QGLPainter *painter); … … 97 94 static void cleanMaterialMap(); 98 95 99 void updateMesh(QGLSceneNode *scene);100 101 96 typedef std::map< size_t, QGLMaterial *> ElementMaterialMap; 102 97 static ElementMaterialMap ElementNoMaterialMap; … … 105 100 enum{DETAIL_HIGHEST, DETAIL_HIGH, DETAIL_MEDIUM, DETAIL_LOW, DETAILTYPES_MAX} DetailType; 106 101 107 static QGLSceneNode *meshEmpty[DETAILTYPES_MAX];108 static QGLSceneNode *meshSphere[DETAILTYPES_MAX];109 static QGLSceneNode *meshCylinder[DETAILTYPES_MAX];110 111 102 protected: 112 103 … … 114 105 115 106 QGLSceneNode *m_mesh[DETAILTYPES_MAX]; 116 enum enum_MeshFreeType {117 free_all,118 free_single,119 free_none120 } MeshFreeType;121 107 QGLAbstractScene *m_scene; 122 108 QVector3D m_position; … … 134 120 bool m_hovering; 135 121 bool m_selected; 136 bool m_visible;137 122 }; 138 123 -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
r0ac85c3 r7b38d3 56 56 GLMoleculeObject(mesh, parent), 57 57 Observer(std::string("GLMoleculeObject_atom")+toString(_id)), 58 atomicid(_id), 59 uptodatePosition(false), 60 uptodateElement(false) 58 atomicid(_id) 61 59 { 62 60 // sign on as observer (obtain non-const instance before) … … 110 108 ELOG(2, "Atom with id "+toString(atomicid)+" is already gone."); 111 109 } 112 uptodatePosition = true;113 110 } 114 111 … … 144 141 } 145 142 setScale( radius / 4. ); 146 147 uptodateElement = true;148 143 } 149 144 … … 170 165 // selected? 171 166 setSelected(World::getInstance().isAtomSelected(atomicid)); 172 }173 174 void GLMoleculeObject_atom::draw(QGLPainter *painter, const QVector4D &cameraPlane)175 {176 // hook to update prior to painting177 if (!uptodatePosition)178 resetPosition();179 if (!uptodateElement)180 resetElement();181 182 // call old hook to do the actual paining183 GLMoleculeObject::draw(painter, cameraPlane);184 167 } 185 168 … … 202 185 switch (notification->getChannelNo()) { 203 186 case AtomObservable::ElementChanged: 204 uptodateElement = false; 187 resetElement(); 188 emit changed(); 205 189 break; 206 190 case AtomObservable::IndexChanged: … … 208 192 break; 209 193 case AtomObservable::PositionChanged: 210 uptodatePosition = false; 194 resetPosition(); 195 emit changed(); 211 196 break; 212 197 case AtomObservable::BondsAdded: … … 214 199 const atom *_atom = World::getInstance().getAtom(AtomById(atomicid)); 215 200 if (_atom != NULL) { 216 // make sure position is up-to-date217 if (!uptodatePosition)218 resetPosition();219 201 ASSERT(!_atom->getListOfBonds().empty(), 220 202 "GLMoleculeObject_atom::recieveNotification() - received BondsAdded but ListOfBonds is empty."); -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp
r0ac85c3 r7b38d3 31 31 virtual ~GLMoleculeObject_atom(); 32 32 33 void draw(QGLPainter *painter, const QVector4D &cameraPlane);34 35 33 // Observer functions 36 34 void update(Observable *publisher); … … 47 45 48 46 private: 49 //!> grant GL MoleculeObject_molecule acess to reset functions50 friend class GL MoleculeObject_molecule;47 //!> grant GLWorldScene acess to reset functions 48 friend class GLWorldScene; 51 49 52 50 void resetPosition(); … … 58 56 59 57 const atomId_t atomicid; 60 61 bool uptodatePosition;62 bool uptodateElement;63 58 }; 64 59 -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp
r0ac85c3 r7b38d3 43 43 44 44 private: 45 //!> grant GLMoleculeObject_molecule acess to reset functions46 friend class GL MoleculeObject_molecule;45 //!> grant WorldScene access to reset functions 46 friend class GLWorldScene; 47 47 48 48 /** Recalculates the position of the cylinder representing the bond. -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp
r0ac85c3 r7b38d3 41 41 42 42 #include <Qt3D/qglscenenode.h> 43 #include <Qt3D/qglbuilder.h>44 43 45 44 #include "CodePatterns/MemDebug.hpp" … … 55 54 #include "Element/element.hpp" 56 55 #include "LinearAlgebra/Vector.hpp" 57 #include "LinkedCell/PointCloudAdaptor.hpp"58 #include "LinkedCell/linkedcell.hpp"59 #include "Tesselation/tesselation.hpp"60 #include "Tesselation/BoundaryLineSet.hpp"61 #include "Tesselation/BoundaryTriangleSet.hpp"62 #include "Tesselation/CandidateForTesselation.hpp"63 #include "Atom/TesselPoint.hpp"64 56 #include "World.hpp" 65 57 66 #include "GLMoleculeObject_atom.hpp" 67 68 static QGLSceneNode *createMoleculeMesh(const molecule *molref, QObject *parent) 69 { 70 // Shape shape = molref->getBoundingSphere(); 71 double minradius = 2.; // TODO: set to maximum bond length value 72 LOG(3, "DEBUG: Molecule fits into sphere of radius " << minradius); 73 if (minradius < 1.) 74 minradius = 1.; 75 76 QGeometryData geo; 77 // we need at least three points for tesselation 78 if (molref->getAtomCount() >= 3) { 79 // Tesselate the points. 80 Tesselation T; 81 PointCloudAdaptor<molecule> cloud(const_cast<molecule *>(molref), molref->getName()); 82 T(cloud, minradius); 83 84 // Fill the points into a Qt geometry. 85 LinkedCell_deprecated LinkedList(cloud, minradius); 86 std::map<int, int> indices; 87 std::map<int, Vector> normals; 88 int index = 0; 89 for (PointMap::const_iterator piter = T.PointsOnBoundary.begin(); 90 piter != T.PointsOnBoundary.end(); ++piter) { 91 const Vector &point = piter->second->getPosition(); 92 // add data to the primitive 93 geo.appendVertex(QVector3D(point[0], point[1], point[2])); 94 Vector normalvector; 95 for (LineMap::const_iterator lineiter = piter->second->lines.begin(); 96 lineiter != piter->second->lines.end(); ++lineiter) 97 for (TriangleMap::const_iterator triangleiter = lineiter->second->triangles.begin(); 98 triangleiter != lineiter->second->triangles.end(); ++triangleiter) 99 normalvector += 100 triangleiter->second->NormalVector; 101 normalvector.Normalize(); 102 geo.appendNormal(QVector3D(normalvector[0], normalvector[1], normalvector[2])); 103 geo.appendColor(QColor(1, 1, 1, 1)); 104 geo.appendTexCoord(QVector2D(0, 0)); 105 indices.insert( std::make_pair( piter->second->getNr(), index++)); 106 } 107 108 // Fill the tesselated triangles into the geometry. 109 for (TriangleMap::const_iterator runner = T.TrianglesOnBoundary.begin(); 110 runner != T.TrianglesOnBoundary.end(); runner++) { 111 int v[3]; 112 for (size_t i=0; i<3; ++i) 113 v[i] = runner->second->endpoints[i]->getNr(); 114 115 // Sort the vertices so the triangle is clockwise (relative to the normal vector). 116 Vector cross = T.PointsOnBoundary[v[1]]->getPosition() - T.PointsOnBoundary[v[0]]->getPosition(); 117 cross.VectorProduct(T.PointsOnBoundary[v[2]]->getPosition() - T.PointsOnBoundary[v[0]]->getPosition()); 118 if (cross.ScalarProduct(runner->second->NormalVector) > 0) 119 geo.appendIndices(indices[v[0]], indices[v[1]], indices[v[2]]); 120 else 121 geo.appendIndices(indices[v[0]], indices[v[2]], indices[v[1]]); 122 } 123 } 124 125 // Build a mesh from the geometry. 126 QGLBuilder builder; 127 builder.addTriangles(geo); 128 QGLSceneNode *mesh = builder.finalizedSceneNode(); 129 return mesh; 130 } 131 132 GLMoleculeObject_molecule::GLMoleculeObject_molecule(QObject *parent, const molecule *molref) : 133 GLMoleculeObject(createMoleculeMesh(molref, parent), parent), 58 GLMoleculeObject_molecule::GLMoleculeObject_molecule(QGLSceneNode *mesh[], QObject *parent, const molecule *molref) : 59 GLMoleculeObject(mesh, parent), 134 60 Observer(std::string("GLMoleculeObject_molecule")+toString(molref->getId())), 135 isBoundingBoxUptodate(true), 136 isSignedOn(false), 137 _molecule(molref), 138 TesselationHullUptodate(true), 139 hoverAtom(NULL) 61 _molecule(molref) 140 62 { 141 63 // sign on as observer (obtain non-const instance before) 142 _molecule->signOn(this, molecule::AtomInserted);143 _molecule->signOn(this, molecule::AtomRemoved);144 _molecule->signOn(this, molecule::AtomMoved);145 isSignedOn = true;146 64 /*molref->signOn(this, AtomObservable::IndexChanged); 147 65 molref->signOn(this, AtomObservable::PositionChanged); … … 151 69 World::getInstance().signOn(this, World::SelectionChanged); 152 70 updateBoundingBox(); 153 154 // initially, atoms and bonds should be visible155 m_visible = false;156 157 init();158 159 connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));160 connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));161 162 connect( this, SIGNAL(clicked()), this, SLOT(wasClicked()));163 }164 165 GLMoleculeObject_molecule::GLMoleculeObject_molecule(QGLSceneNode *mesh[], QObject *parent, const molecule *molref) :166 GLMoleculeObject(mesh, parent),167 Observer(std::string("GLMoleculeObject_molecule")+toString(molref->getId())),168 isBoundingBoxUptodate(true),169 isSignedOn(false),170 _molecule(molref),171 TesselationHullUptodate(true),172 hoverAtom(NULL)173 {174 // sign on as observer (obtain non-const instance before)175 _molecule->signOn(this, molecule::AtomInserted);176 _molecule->signOn(this, molecule::AtomRemoved);177 _molecule->signOn(this, molecule::AtomMoved);178 isSignedOn = true;179 /*molref->signOn(this, AtomObservable::IndexChanged);180 molref->signOn(this, AtomObservable::PositionChanged);181 molref->signOn(this, AtomObservable::ElementChanged);182 molref->signOn(this, AtomObservable::BondsAdded);*/183 setMaterial(getMaterial(1));184 World::getInstance().signOn(this, World::SelectionChanged);185 updateBoundingBox();186 187 // initially, atoms and bonds should be visible188 m_visible = false;189 190 init();191 192 connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));193 connect (this, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));194 195 connect( this, SIGNAL(clicked()), this, SLOT(wasClicked()));196 71 } 197 72 198 73 GLMoleculeObject_molecule::~GLMoleculeObject_molecule() 199 74 { 200 if (isSignedOn) {201 _molecule->signOff(this, molecule::AtomInserted);202 _molecule->signOff(this, molecule::AtomRemoved);203 _molecule->signOff(this, molecule::AtomMoved);204 }205 75 /*_atom->signOff(this, AtomObservable::IndexChanged); 206 76 _atom->signOff(this, AtomObservable::PositionChanged); … … 210 80 } 211 81 212 /** Initialise the WorldScene with molecules and atoms from World.213 *214 */215 void GLMoleculeObject_molecule::init()216 {217 if (_molecule->begin() != _molecule->end()) {218 int atomicid = -1;219 for (molecule::const_iterator atomiter = _molecule->begin();220 atomiter != _molecule->end();221 atomiter++) {222 // create atom objects in scene223 atomicid = (*atomiter)->getId();224 atomInserted(atomicid);225 226 // create bond objects in scene227 const BondList &bondlist = (*atomiter)->getListOfBonds();228 for (BondList::const_iterator bonditer = bondlist.begin();229 bonditer != bondlist.end();230 ++bonditer) {231 const bond::ptr _bond = *bonditer;232 const GLMoleculeObject_bond::SideOfBond side = (_bond->leftatom == *atomiter) ?233 GLMoleculeObject_bond::left : GLMoleculeObject_bond::right;234 bondInserted(_bond, side);235 }236 }237 // set id to one of the atom's as either mol or atoms is present at the same time238 setObjectId(atomicid);239 }240 }241 242 void GLMoleculeObject_molecule::addAtomBonds(243 const bond::ptr &_bond,244 const GLMoleculeObject_bond::SideOfBond _side245 )246 {247 bool bond_present = false;248 const BondIds ids = getBondIds(_bond, _side);249 // check whether bond is not present already250 bond_present = BondsinSceneMap.count(ids);251 if (!bond_present)252 bondInserted(_bond, _side);253 else {254 BondsinSceneMap[ids]->resetPosition();255 BondsinSceneMap[ids]->resetWidth();256 }257 }258 259 void GLMoleculeObject_molecule::addAtomBonds(260 const atom *_atom)261 {262 const bool atom_present = AtomsinSceneMap.count(_atom->getId());263 const BondList &bondlist = _atom->getListOfBonds();264 for (BondList::const_iterator bonditer = bondlist.begin();265 (bonditer != bondlist.end()) && atom_present;266 ++bonditer) {267 const bond::ptr _bond = *bonditer;268 // check if OtherAtom's sphere is already present269 const atom *OtherAtom = _bond->GetOtherAtom(_atom);270 const bool otheratom_present = AtomsinSceneMap.count(OtherAtom->getId());271 if (otheratom_present && atom_present) {272 const GLMoleculeObject_bond::SideOfBond side = (_bond->leftatom == _atom) ?273 GLMoleculeObject_bond::left : GLMoleculeObject_bond::right;274 const GLMoleculeObject_bond::SideOfBond otherside = (_bond->leftatom == _atom) ?275 GLMoleculeObject_bond::right : GLMoleculeObject_bond::left;276 addAtomBonds(_bond, side);277 addAtomBonds(_bond, otherside);278 }279 }280 }281 282 void GLMoleculeObject_molecule::reinit()283 {284 if (_molecule->getAtomCount() > 0) {285 for (molecule::const_iterator atomiter = _molecule->begin();286 atomiter != _molecule->end();287 atomiter++) {288 // check whether atom already exists289 const atomId_t atomid = (*atomiter)->getId();290 const bool atom_present = AtomsinSceneMap.count(atomid);291 if (!atom_present)292 atomInserted((*atomiter)->getId());293 else294 AtomsinSceneMap[atomid]->resetPosition();295 296 297 // create bond objects in scene298 addAtomBonds(*atomiter);299 }300 }301 }302 303 82 void GLMoleculeObject_molecule::updateBoundingBox() 304 83 { 305 isBoundingBoxUptodate = true;306 84 Shape shape = _molecule->getBoundingSphere(); 307 85 Vector v = shape.getCenter(); … … 319 97 320 98 void GLMoleculeObject_molecule::subjectKilled(Observable *publisher) 321 { 322 isSignedOn = false; 323 } 99 {} 324 100 325 101 void GLMoleculeObject_molecule::recieveNotification(Observable *publisher, Notification_ptr notification) … … 332 108 << notification->getChannelNo() << "."; 333 109 #endif 334 switch (notification->getChannelNo()) {335 case molecule::AtomInserted:336 {337 const atomId_t _id = _molecule->lastChanged()->getId();338 #ifdef LOG_OBSERVER339 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted.";340 #endif341 TesselationHullUptodate = false;342 isBoundingBoxUptodate = false;343 atomInserted(_id);344 break;345 }346 case World::AtomRemoved:347 {348 const atomId_t _id = _molecule->lastChanged()->getId();349 #ifdef LOG_OBSERVER350 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been removed.";351 #endif352 TesselationHullUptodate = false;353 isBoundingBoxUptodate = false;354 atomRemoved(_id);355 break;356 }357 case molecule::AtomMoved:358 {359 #ifdef LOG_OBSERVER360 const atomId_t _id = _molecule->lastChanged()->getId();361 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted.";362 #endif363 TesselationHullUptodate = false;364 isBoundingBoxUptodate = false;365 break;366 }367 default:368 break;369 }370 110 }else{ 371 111 // notification from world … … 385 125 } 386 126 387 void GLMoleculeObject_molecule::initialize(QGLView *view, QGLPainter *painter)388 {389 // Initialize all of the mesh objects that we have as children.390 if (m_visible) {391 GLMoleculeObject::initialize(view, painter);392 } else {393 foreach (QObject *obj, children()) {394 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);395 if (meshobj)396 meshobj->initialize(view, painter);397 }398 }399 }400 401 void GLMoleculeObject_molecule::draw(QGLPainter *painter, const QVector4D &cameraPlane)402 {403 // draw either molecule's mesh or all atoms and bonds404 if (m_visible) {405 updateTesselationHull();406 407 painter->modelViewMatrix().push();408 409 // Apply the material and effect to the painter.410 QGLMaterial *material;411 if (m_hovering)412 material = m_hoverMaterial;413 else if (m_selected)414 material = m_selectionMaterial;415 else416 material = m_material;417 418 ASSERT(material, "GLMoleculeObject::draw: chosen material is NULL");419 420 painter->setColor(material->diffuseColor());421 painter->setFaceMaterial(QGL::AllFaces, material);422 if (m_effect)423 painter->setUserEffect(m_effect);424 else425 painter->setStandardEffect(QGL::LitMaterial);426 427 // Mark the object for object picking purposes.428 int prevObjectId = painter->objectPickId();429 if (m_objectId != -1)430 painter->setObjectPickId(m_objectId);431 432 m_mesh[0]->draw(painter);433 434 // Turn off the user effect, if present.435 if (m_effect)436 painter->setStandardEffect(QGL::LitMaterial);437 438 // Revert to the previous object identifier.439 painter->setObjectPickId(prevObjectId);440 441 // Restore the modelview matrix.442 painter->modelViewMatrix().pop();443 444 // GLMoleculeObject::draw(painter, cameraPlane);445 } else {446 // Draw all of the mesh objects that we have as children.447 foreach (QObject *obj, children()) {448 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);449 if (meshobj)450 meshobj->draw(painter, cameraPlane);451 }452 453 // update bounding box prior to selection454 if (!isBoundingBoxUptodate)455 updateBoundingBox();456 457 painter->modelViewMatrix().push();458 painter->modelViewMatrix().translate(m_position);459 if ((m_scaleX != 1.0f) || (m_scaleY != 1.0f) || (m_scaleZ != 1.0f))460 painter->modelViewMatrix().scale(m_scaleX, m_scaleY, m_scaleZ);461 if (m_rotationAngle != 0.0f)462 painter->modelViewMatrix().rotate(m_rotationAngle, m_rotationVector);463 464 // Draw a box around the mesh, if selected.465 if (m_selected)466 drawSelectionBox(painter);467 468 // Restore the modelview matrix.469 painter->modelViewMatrix().pop();470 }471 }472 473 /** Adds an atom of this molecule to the scene.474 *475 * @param _atom atom to add476 */477 void GLMoleculeObject_molecule::atomInserted(const atomicNumber_t _id)478 {479 LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_id)+".");480 GLMoleculeObject_atom *atomObject = new GLMoleculeObject_atom(GLMoleculeObject::meshSphere, this, _id);481 AtomNodeMap::iterator iter = AtomsinSceneMap.find(_id);482 ASSERT(iter == AtomsinSceneMap.end(),483 "GLWorldScene::atomAdded() - same atom with id "+toString(_id)+" added again.");484 AtomsinSceneMap.insert( make_pair(_id, atomObject) );485 486 qRegisterMetaType<atomId_t>("atomId_t");487 qRegisterMetaType<bond::ptr>("bond::ptr");488 qRegisterMetaType<GLMoleculeObject_bond::SideOfBond>("GLMoleculeObject_bond::SideOfBond");489 connect (atomObject, SIGNAL(clicked(atomId_t)), this, SIGNAL(atomClicked(atomId_t)));490 connect (atomObject, SIGNAL(changed()), this, SIGNAL(changed()));491 connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed()));492 connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *)));493 connect (atomObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));494 connect (atomObject, SIGNAL(BondsInserted(const bond::ptr , const GLMoleculeObject_bond::SideOfBond)), this, SLOT(bondInserted(const bond::ptr , const GLMoleculeObject_bond::SideOfBond)));495 connect (atomObject, SIGNAL(indexChanged(GLMoleculeObject_atom*, int, int)), this, SIGNAL(changeAtomId(GLMoleculeObject_atom*, int, int)));496 497 isBoundingBoxUptodate = false;498 499 if (m_objectId == -1)500 setObjectId(_id);501 502 // add all bonds503 const atom *Walker = World::getInstance().getAtom(AtomById(_id));504 addAtomBonds(Walker);505 506 emit changeOccured();507 }508 509 /** Removes an atom of this molecule from the scene.510 *511 * We just the id as the atom might have already been destroyed.512 *513 * @param _id id of atom to remove514 */515 void GLMoleculeObject_molecule::atomRemoved(const atomicNumber_t _id)516 {517 LOG(3, "INFO: GLWorldScene: Received signal atomRemoved for atom "+toString(_id)+".");518 // bonds are removed by signal coming from ~bond519 520 if (m_objectId == _id)521 setObjectId(-1);522 523 // remove atoms524 AtomNodeMap::iterator iter = AtomsinSceneMap.find(_id);525 ASSERT(iter != AtomsinSceneMap.end(),526 "GLWorldScene::atomRemoved() - atom "+toString(_id)+" not on display.");527 GLMoleculeObject_atom *atomObject = iter->second;528 atomObject->disconnect();529 AtomsinSceneMap.erase(iter);530 delete atomObject;531 532 isBoundingBoxUptodate = false;533 534 emit changeOccured();535 }536 537 void GLMoleculeObject_molecule::hoverChangedSignalled(GLMoleculeObject *ob)538 {539 // Find the atom, ob corresponds to.540 hoverAtom = NULL;541 GLMoleculeObject_atom *atomObject = dynamic_cast<GLMoleculeObject_atom *>(ob);542 if (atomObject){543 for (AtomNodeMap::iterator iter = AtomsinSceneMap.begin();iter != AtomsinSceneMap.end(); ++ iter){544 if (iter->second == atomObject)545 hoverAtom = World::getInstance().getAtom(AtomById(iter->first));546 }547 548 // Propagate signal.549 emit hoverChanged(*hoverAtom);550 } else {551 // Find the atom, ob corresponds to.552 GLMoleculeObject_molecule *moleculeObject = dynamic_cast<GLMoleculeObject_molecule *>(ob);553 if (moleculeObject == this){554 // Propagate signal.555 emit hoverChanged(*_molecule, 0);556 }557 }558 }559 560 561 /** Helper function to get bond ids in the correct order for BondNodeMap.562 *563 * \return pair of ids in correct order.564 */565 GLMoleculeObject_molecule::BondIds GLMoleculeObject_molecule::getBondIds(566 const bond::ptr _bond,567 const enum GLMoleculeObject_bond::SideOfBond _side)568 {569 BondIds ids;570 switch (_side) {571 case GLMoleculeObject_bond::left:572 ids = std::make_pair(_bond->leftatom->getId(), _bond->rightatom->getId());573 break;574 case GLMoleculeObject_bond::right:575 ids = std::make_pair(_bond->rightatom->getId(), _bond->leftatom->getId());576 break;577 }578 return ids;579 }580 581 /** Adds a bond to the scene.582 *583 * @param _bond bond to add584 * @param side which side of the bond (left or right)585 */586 void GLMoleculeObject_molecule::bondInserted(const bond::ptr _bond, const enum GLMoleculeObject_bond::SideOfBond _side)587 {588 LOG(3, "INFO: GLWorldScene::bondInserted() - Adding bond "+toString(*_bond)+".");589 //LOG(4, "INFO: Currently present bonds " << BondsinSceneMap << ".");590 591 const BondIds ids = getBondIds(_bond, _side);592 BondNodeMap::iterator iter = BondsinSceneMap.find(ids);593 if (iter == BondsinSceneMap.end()) {594 GLMoleculeObject_bond * bondObject =595 new GLMoleculeObject_bond(GLMoleculeObject::meshCylinder, this, _bond, _side);596 connect (597 bondObject, SIGNAL(BondRemoved(const atomId_t, const atomId_t)),598 this, SLOT(bondRemoved(const atomId_t, const atomId_t)));599 connect (bondObject, SIGNAL(changed()), this, SIGNAL(changed()));600 BondsinSceneMap.insert( make_pair(ids, bondObject) );601 // BondIdsinSceneMap.insert( Leftids );602 } else {603 iter->second->resetPosition();604 iter->second->resetWidth();605 }606 emit changeOccured();607 }608 609 /** Removes a bond from the scene.610 *611 * @param _bond bond to remove612 */613 void GLMoleculeObject_molecule::bondRemoved(const atomId_t leftnr, const atomId_t rightnr)614 {615 LOG(3, "INFO: GLWorldScene::bondRemoved() - Removing bond between "+toString(leftnr)+" and "+toString(rightnr)+".");616 {617 // left bond618 const BondIds Leftids( make_pair(leftnr, rightnr) );619 BondNodeMap::iterator leftiter = BondsinSceneMap.find( Leftids );620 ASSERT(leftiter != BondsinSceneMap.end(),621 "GLWorldScene::bondRemoved() - bond "+toString(leftnr)+"-"622 +toString(rightnr)+" not on display.");623 GLMoleculeObject_bond *bondObject = leftiter->second;624 bondObject->disconnect();625 BondsinSceneMap.erase(leftiter);626 delete bondObject; // is done by signal from bond itself627 //LOG(4, "INFO: Still present bonds " << BondsinSceneMap << ".");628 }629 630 emit changeOccured();631 }632 633 void GLMoleculeObject_molecule::setVisible(bool value)634 {635 // first update the mesh if we are going to be visible now636 if (value)637 updateTesselationHull();638 // then emit onward639 GLMoleculeObject::setVisible(value);640 }641 642 void GLMoleculeObject_molecule::updateTesselationHull()643 {644 if (!TesselationHullUptodate) {645 updateMesh(createMoleculeMesh(_molecule, parent()));646 TesselationHullUptodate = true;647 }648 }649 650 std::ostream &operator<<(std::ostream &ost, const GLMoleculeObject_molecule::BondIds &t)651 {652 ost << t.first << "," << t.second;653 return ost;654 }655 656 void GLMoleculeObject_molecule::wasClicked()657 {658 LOG(4, "INFO: GLMoleculeObject_molecule: atom " << _molecule->getId() << " has been clicked");659 emit moleculeClicked(_molecule->getId());660 } -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp
r0ac85c3 r7b38d3 22 22 class atom; 23 23 class bond; 24 class GLMoleculeObject_atom;25 class GLWorldScene;26 24 class molecule; 27 25 … … 30 28 Q_OBJECT 31 29 public: 32 GLMoleculeObject_molecule(QObject *parent, const molecule *molref);33 30 GLMoleculeObject_molecule(QGLSceneNode *mesh[], QObject *parent, const molecule *molref); 34 31 virtual ~GLMoleculeObject_molecule(); … … 41 38 void recieveNotification(Observable *publisher, Notification_ptr notification); 42 39 43 void initialize(QGLView *view, QGLPainter *painter);44 void draw(QGLPainter *painter, const QVector4D &cameraPlane);45 46 typedef std::pair< atomId_t, atomId_t> BondIds;47 friend std::ostream &operator<<(std::ostream &ost, const BondIds &t);48 49 static BondIds getBondIds(50 const bond::ptr _bond,51 const enum GLMoleculeObject_bond::SideOfBond side);52 53 void selected(const bool _isSelected)54 { isSelected = _isSelected; }55 56 signals:57 void changed();58 void changeOccured();59 void hoverChanged(const atom&);60 void hoverChanged(const molecule&, int);61 void atomClicked(atomId_t no);62 void moleculeClicked(moleculeId_t no);63 void changeAtomId(GLMoleculeObject_atom *, int, int);64 65 private slots:66 //!> grant GLWorldScene access to private slots67 friend class GLWorldScene;68 69 void wasClicked();70 void atomInserted(const atomicNumber_t _id);71 void atomRemoved(const atomicNumber_t _id);72 void bondInserted(const bond::ptr _bond, const GLMoleculeObject_bond::SideOfBond side);73 void bondRemoved(const atomId_t leftnr, const atomId_t rightnr);74 void hoverChangedSignalled(GLMoleculeObject *ob);75 76 void setVisible(bool value);77 78 40 private: 79 void init();80 void reinit();81 82 void addAtomBonds(83 const bond::ptr &_bond,84 const GLMoleculeObject_bond::SideOfBond _side85 );86 void addAtomBonds(const atom *_atom);87 88 void updateTesselationHull();89 90 //!> states whether selection box is additionally drawn or not91 bool isSelected;92 bool isBoundingBoxUptodate;93 94 //!> whether we are signed on to the associated molecule95 bool isSignedOn;96 41 97 42 const molecule *_molecule; 98 99 bool TesselationHullUptodate;100 101 typedef std::map< atomId_t, GLMoleculeObject_atom* > AtomNodeMap;102 typedef std::map< BondIds , GLMoleculeObject_bond* > BondNodeMap;103 AtomNodeMap AtomsinSceneMap;104 BondNodeMap BondsinSceneMap;105 106 const atom *hoverAtom;107 43 }; 108 44 109 std::ostream &operator<<(std::ostream &ost, const GLMoleculeObject_molecule::BondIds &t);110 45 111 46 -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_shape.cpp
r0ac85c3 r7b38d3 63 63 typedef QGLSceneNode *MeshList[GLMoleculeObject::DETAILTYPES_MAX]; 64 64 65 staticQGLSceneNode *createShapeMesh(Shape &shape, QObject *parent)65 QGLSceneNode *createShapeMesh(Shape &shape, QObject *parent) 66 66 { 67 67 size_t NumPointsonSurface = 200; -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
r0ac85c3 r7b38d3 60 60 #include "Bond/bond.hpp" 61 61 #include "Descriptors/AtomIdDescriptor.hpp" 62 #include "Descriptors/MoleculeIdDescriptor.hpp"63 62 #include "Helpers/helpers.hpp" 64 63 #include "Shapes/ShapeRegistry.hpp" … … 70 69 using namespace MoleCuilder; 71 70 71 std::ostream &operator<<(std::ostream &ost, const GLWorldScene::BondIds &t) 72 { 73 ost << t.first << "," << t.second; 74 return ost; 75 } 76 72 77 GLWorldScene::GLWorldScene(QObject *parent) 73 : QObject(parent) 78 : QObject(parent), 79 hoverAtom(NULL) 74 80 { 75 81 int sphereDetails[] = {5, 3, 2, 0}; … … 77 83 for (int i=0;i<GLMoleculeObject::DETAILTYPES_MAX;i++){ 78 84 QGLBuilder emptyBuilder; 79 GLMoleculeObject::meshEmpty[i] = emptyBuilder.finalizedSceneNode();85 meshEmpty[i] = emptyBuilder.finalizedSceneNode(); 80 86 QGLBuilder sphereBuilder; 81 87 sphereBuilder << QGLSphere(2.0, sphereDetails[i]); 82 GLMoleculeObject::meshSphere[i] = sphereBuilder.finalizedSceneNode();83 GLMoleculeObject::meshSphere[i]->setOption(QGLSceneNode::CullBoundingBox, true);88 meshSphere[i] = sphereBuilder.finalizedSceneNode(); 89 meshSphere[i]->setOption(QGLSceneNode::CullBoundingBox, true); 84 90 QGLBuilder cylinderBuilder; 85 91 cylinderBuilder << QGLCylinder(.25,.25,1.0,cylinderDetails[i]); 86 GLMoleculeObject::meshCylinder[i] = cylinderBuilder.finalizedSceneNode();87 GLMoleculeObject::meshCylinder[i]->setOption(QGLSceneNode::CullBoundingBox, true);92 meshCylinder[i] = cylinderBuilder.finalizedSceneNode(); 93 meshCylinder[i]->setOption(QGLSceneNode::CullBoundingBox, true); 88 94 } 89 95 90 96 connect(this, SIGNAL(updated()), this, SLOT(update())); 91 92 97 93 98 setSelectionMode(SelectAtom); … … 107 112 void GLWorldScene::init() 108 113 { 109 const std::vector<molecule *> &molecules = World::getInstance().getAllMolecules(); 110 111 for (std::vector<molecule*>::const_iterator moliter = molecules.begin(); 112 moliter != molecules.end(); 113 moliter++) { 114 // create molecule objects in scene 115 moleculeInserted(*moliter); 114 const std::vector<atom*> &atoms = World::getInstance().getAllAtoms(); 115 116 if (atoms.size() > 0) { 117 for (std::vector<atom*>::const_iterator atomiter = atoms.begin(); 118 atomiter != atoms.end(); 119 atomiter++) { 120 // create atom objects in scene 121 atomInserted((*atomiter)->getId()); 122 123 // create bond objects in scene 124 const BondList &bondlist = (*atomiter)->getListOfBonds(); 125 for (BondList::const_iterator bonditer = bondlist.begin(); 126 bonditer != bondlist.end(); 127 ++bonditer) { 128 const bond::ptr _bond = *bonditer; 129 const GLMoleculeObject_bond::SideOfBond side = (_bond->leftatom == *atomiter) ? 130 GLMoleculeObject_bond::left : GLMoleculeObject_bond::right; 131 bondInserted(_bond, side); 132 } 133 } 116 134 } 117 135 } … … 125 143 void GLWorldScene::update() 126 144 { 127 const std::vector<molecule *> &molecules = World::getInstance().getAllMolecules(); 128 129 for (std::vector<molecule*>::const_iterator moliter = molecules.begin(); 130 moliter != molecules.end(); 131 moliter++) { 132 // check whether molecule already exists 133 const moleculeId_t molid = (*moliter)->getId(); 134 const bool mol_present = MoleculesinSceneMap.count(molid); 135 if (!mol_present) 136 moleculeInserted(*moliter); 137 } 145 const std::vector<atom*> &atoms = World::getInstance().getAllAtoms(); 146 147 if (atoms.size() > 0) { 148 for (std::vector<atom*>::const_iterator atomiter = atoms.begin(); 149 atomiter != atoms.end(); 150 atomiter++) { 151 // check whether atom already exists 152 const atomId_t atomid = (*atomiter)->getId(); 153 const bool atom_present = AtomsinSceneMap.count(atomid); 154 if (!atom_present) 155 atomInserted((*atomiter)->getId()); 156 else 157 AtomsinSceneMap[atomid]->resetPosition(); 158 159 160 // create bond objects in scene 161 const BondList &bondlist = (*atomiter)->getListOfBonds(); 162 for (BondList::const_iterator bonditer = bondlist.begin(); 163 bonditer != bondlist.end(); 164 ++bonditer) { 165 const bond::ptr _bond = *bonditer; 166 const GLMoleculeObject_bond::SideOfBond side = (_bond->leftatom == *atomiter) ? 167 GLMoleculeObject_bond::left : GLMoleculeObject_bond::right; 168 bool bond_present = false; 169 const BondIds ids = getBondIds(_bond,side); 170 if (atom_present) { 171 // check whether bond is not present already 172 bond_present = BondsinSceneMap.count(ids); 173 } 174 if (!bond_present) 175 bondInserted(_bond, side); 176 else { 177 BondsinSceneMap[ids]->resetPosition(); 178 BondsinSceneMap[ids]->resetWidth(); 179 } 180 } 181 } 182 } 183 } 184 185 /** Adds an atom to the scene. 186 * 187 * @param _atom atom to add 188 */ 189 void GLWorldScene::atomInserted(const atomicNumber_t _id) 190 { 191 LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_id)+"."); 192 GLMoleculeObject_atom *atomObject = new GLMoleculeObject_atom(meshSphere, this, _id); 193 AtomNodeMap::iterator iter = AtomsinSceneMap.find(_id); 194 ASSERT(iter == AtomsinSceneMap.end(), 195 "GLWorldScene::atomAdded() - same atom with id "+toString(_id)+" added again."); 196 AtomsinSceneMap.insert( make_pair(_id, atomObject) ); 197 198 qRegisterMetaType<atomId_t>("atomId_t"); 199 qRegisterMetaType<bond::ptr>("bond::ptr"); 200 qRegisterMetaType<GLMoleculeObject_bond::SideOfBond>("GLMoleculeObject_bond::SideOfBond"); 201 connect (atomObject, SIGNAL(clicked(atomId_t)), this, SLOT(atomClicked(atomId_t))); 202 connect (atomObject, SIGNAL(changed()), this, SIGNAL(changed())); 203 connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SIGNAL(changed())); 204 connect (atomObject, SIGNAL(hoverChanged(GLMoleculeObject *)), this, SLOT(hoverChangedSignalled(GLMoleculeObject *))); 205 connect (atomObject, SIGNAL(selectionChanged()), this, SIGNAL(changed())); 206 connect (atomObject, SIGNAL(BondsInserted(const bond::ptr , const GLMoleculeObject_bond::SideOfBond)), this, SLOT(bondInserted(const bond::ptr , const GLMoleculeObject_bond::SideOfBond))); 207 connect (atomObject, SIGNAL(indexChanged(GLMoleculeObject_atom*, int, int)), this, SLOT(changeAtomId(GLMoleculeObject_atom*, int, int))); 208 //bondsChanged(_atom); 209 emit changeOccured(); 210 } 211 212 /** Removes an atom from the scene. 213 * 214 * We just the id as the atom might have already been destroyed. 215 * 216 * @param _id id of atom to remove 217 */ 218 void GLWorldScene::atomRemoved(const atomicNumber_t _id) 219 { 220 LOG(3, "INFO: GLWorldScene: Received signal atomRemoved for atom "+toString(_id)+"."); 221 // bonds are removed by signal coming from ~bond 222 // remove atoms 223 AtomNodeMap::iterator iter = AtomsinSceneMap.find(_id); 224 ASSERT(iter != AtomsinSceneMap.end(), 225 "GLWorldScene::atomRemoved() - atom "+toString(_id)+" not on display."); 226 GLMoleculeObject_atom *atomObject = iter->second; 227 atomObject->disconnect(); 228 AtomsinSceneMap.erase(iter); 229 delete atomObject; 230 emit changeOccured(); 231 } 232 233 /** .... 234 * 235 */ 236 void GLWorldScene::worldSelectionChanged() 237 { 238 LOG(3, "INFO: GLWorldScene: Received signal selectionChanged."); 239 240 const std::vector<molecule*> &molecules = World::getInstance().getAllMolecules(); 241 242 if (molecules.size() > 0) { 243 for (std::vector<molecule*>::const_iterator Runner = molecules.begin(); 244 Runner != molecules.end(); 245 Runner++) { 246 247 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find((*Runner)->getId()); 248 bool isSelected = World::getInstance().isSelected(*Runner); 249 250 // molecule selected but not in scene? 251 if (isSelected && (iter == MoleculesinSceneMap.end())){ 252 // -> create new mesh 253 GLMoleculeObject_molecule *molObject = new GLMoleculeObject_molecule(meshEmpty, this, *Runner); 254 MoleculesinSceneMap.insert( make_pair((*Runner)->getId(), molObject) ); 255 connect (molObject, SIGNAL(changed()), this, SIGNAL(changed())); 256 connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed())); 257 connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed())); 258 emit changed(); 259 emit changeOccured(); 260 } 261 262 // molecule not selected but in scene? 263 if (!isSelected && (iter != MoleculesinSceneMap.end())){ 264 // -> remove from scene 265 moleculeRemoved(*Runner); 266 } 267 268 } 269 } 270 } 271 272 /** Removes a molecule from the scene. 273 * 274 * @param _molecule molecule to remove 275 */ 276 void GLWorldScene::moleculeRemoved(const molecule *_molecule) 277 { 278 LOG(3, "INFO: GLWorldScene: Received signal moleculeRemoved for molecule "+toString(_molecule->getId())+"."); 279 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molecule->getId()); 280 281 // only remove if the molecule is in the scene 282 // (= is selected) 283 if (iter != MoleculesinSceneMap.end()){ 284 GLMoleculeObject_molecule *molObject = iter->second; 285 molObject->disconnect(); 286 MoleculesinSceneMap.erase(iter); 287 delete molObject; 288 emit changed(); 289 emit changeOccured(); 290 } 291 } 292 293 /** Helper function to get bond ids in the correct order for BondNodeMap. 294 * 295 * \return pair of ids in correct order. 296 */ 297 GLWorldScene::BondIds GLWorldScene::getBondIds( 298 const bond::ptr _bond, 299 const enum GLMoleculeObject_bond::SideOfBond _side) const 300 { 301 BondIds ids; 302 switch (_side) { 303 case GLMoleculeObject_bond::left: 304 ids = std::make_pair(_bond->leftatom->getId(), _bond->rightatom->getId()); 305 break; 306 case GLMoleculeObject_bond::right: 307 ids = std::make_pair(_bond->rightatom->getId(), _bond->leftatom->getId()); 308 break; 309 } 310 return ids; 311 } 312 313 /** Adds a bond to the scene. 314 * 315 * @param _bond bond to add 316 * @param side which side of the bond (left or right) 317 */ 318 void GLWorldScene::bondInserted(const bond::ptr _bond, const enum GLMoleculeObject_bond::SideOfBond _side) 319 { 320 LOG(3, "INFO: GLWorldScene::bondInserted() - Adding bond "+toString(*_bond)+"."); 321 //LOG(4, "INFO: Currently present bonds " << BondsinSceneMap << "."); 322 323 const BondIds ids = getBondIds(_bond, _side); 324 BondNodeMap::iterator iter = BondsinSceneMap.find(ids); 325 if (iter == BondsinSceneMap.end()) { 326 GLMoleculeObject_bond * bondObject = 327 new GLMoleculeObject_bond(meshCylinder, this, _bond, _side); 328 connect ( 329 bondObject, SIGNAL(BondRemoved(const atomId_t, const atomId_t)), 330 this, SLOT(bondRemoved(const atomId_t, const atomId_t))); 331 connect (bondObject, SIGNAL(changed()), this, SIGNAL(changed())); 332 BondsinSceneMap.insert( make_pair(ids, bondObject) ); 333 // BondIdsinSceneMap.insert( Leftids ); 334 } else { 335 iter->second->resetPosition(); 336 iter->second->resetWidth(); 337 } 338 emit changeOccured(); 339 } 340 341 /** Removes a bond from the scene. 342 * 343 * @param _bond bond to remove 344 */ 345 void GLWorldScene::bondRemoved(const atomId_t leftnr, const atomId_t rightnr) 346 { 347 LOG(3, "INFO: GLWorldScene::bondRemoved() - Removing bond between "+toString(leftnr)+" and "+toString(rightnr)+"."); 348 { 349 // left bond 350 const BondIds Leftids( make_pair(leftnr, rightnr) ); 351 BondNodeMap::iterator leftiter = BondsinSceneMap.find( Leftids ); 352 ASSERT(leftiter != BondsinSceneMap.end(), 353 "GLWorldScene::bondRemoved() - bond "+toString(leftnr)+"-" 354 +toString(rightnr)+" not on display."); 355 GLMoleculeObject_bond *bondObject = leftiter->second; 356 BondsinSceneMap.erase(leftiter); 357 delete bondObject; // is done by signal from bond itself 358 //LOG(4, "INFO: Still present bonds " << BondsinSceneMap << "."); 359 } 360 361 emit changeOccured(); 362 } 363 364 /** Adds a shape to the scene. 365 * 366 * uses ShapeRegistry::lastChanged() 367 * 368 */ 369 void GLWorldScene::addShape() 370 { 371 Shape &shape = *ShapeRegistry::getInstance().lastChanged(); 372 GLMoleculeObject_shape *shapeObject = new GLMoleculeObject_shape(shape, this); 373 ShapeNodeMap::iterator iter = ShapesinSceneMap.find(shape.getName()); 374 ASSERT(iter == ShapesinSceneMap.end(), 375 "GLWorldScene::addShape() - same shape "+shape.getName()+" added again."); 376 ShapesinSceneMap.insert( make_pair(shape.getName(), shapeObject) ); 377 } 378 379 void GLWorldScene::removeShape() 380 { 381 Shape &shape = *ShapeRegistry::getInstance().lastChanged(); 382 ShapeNodeMap::iterator iter = ShapesinSceneMap.find(shape.getName()); 383 ASSERT(iter != ShapesinSceneMap.end(), 384 "GLWorldScene::removeShape() - shape "+shape.getName()+" not in scene."); 385 ShapesinSceneMap.erase(iter); 386 delete(iter->second); 387 } 388 389 void GLWorldScene::updateSelectedShapes() 390 { 391 foreach (QObject *obj, children()) { 392 GLMoleculeObject_shape *shapeobj = qobject_cast<GLMoleculeObject_shape *>(obj); 393 if (shapeobj){ 394 shapeobj->enable(ShapeRegistry::getInstance().isSelected(shapeobj->getShape())); 395 } 396 } 397 } 398 399 void GLWorldScene::initialize(QGLView *view, QGLPainter *painter) const 400 { 401 // Initialize all of the mesh objects that we have as children. 402 foreach (QObject *obj, children()) { 403 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj); 404 if (meshobj) 405 meshobj->initialize(view, painter); 406 } 407 } 408 409 void GLWorldScene::draw(QGLPainter *painter, const QVector4D &cameraPlane) const 410 { 411 // Draw all of the mesh objects that we have as children. 412 foreach (QObject *obj, children()) { 413 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj); 414 if (meshobj) 415 meshobj->draw(painter, cameraPlane); 416 } 138 417 } 139 418 140 419 void GLWorldScene::atomClicked(atomId_t no) 141 420 { 142 LOG(3, "INFO: GL MoleculeObject_molecule - atom " << no << " has been clicked.");421 LOG(3, "INFO: GLWorldScene - atom " << no << " has been clicked."); 143 422 const atom *Walker = World::getInstance().getAtom(AtomById(no)); 144 423 if (selectionMode == SelectAtom){ … … 150 429 const molecule *mol = Walker->getMolecule(); 151 430 ASSERT(mol, "Atom without molecule has been clicked."); 152 molids_t ids(1, mol->getId());153 431 if (!World::getInstance().isSelected(mol)) 154 SelectionMoleculeById( ids);432 SelectionMoleculeById(mol->getId()); 155 433 else 156 SelectionNotMoleculeById( ids);434 SelectionNotMoleculeById(mol->getId()); 157 435 } 158 436 emit clicked(no); 159 437 } 160 438 161 void GLWorldScene::moleculeClicked(moleculeId_t no)162 {163 LOG(3, "INFO: GLMoleculeObject_molecule - mol " << no << " has been clicked.");164 const molecule *mol= World::getInstance().getMolecule(MoleculeById(no));165 ASSERT(mol, "Atom without molecule has been clicked.");166 molids_t ids(1, mol->getId());167 if (!World::getInstance().isSelected(mol))168 SelectionMoleculeById(ids);169 else170 SelectionNotMoleculeById(ids);171 emit clicked(no);172 }173 174 175 /** Adds an atom to the scene.176 *177 * @param _atom atom to add178 */179 void GLWorldScene::atomInserted(const atomId_t _id)180 {181 LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_id)+".");182 // find associated molecule183 const moleculeId_t molid = World::getInstance().getAtom(AtomById(_id))->getMolecule()->getId();184 MoleculeNodeMap::const_iterator moliter = MoleculesinSceneMap.find(molid );185 ASSERT(moliter != MoleculesinSceneMap.end(),186 "GLWorldScene::atomAdded() - molecule with id of "+toString(molid)187 +" atom with id "+toString(_id)+" is unknown.");188 GLMoleculeObject_molecule *molObject = moliter->second;189 190 // add atom to internal list191 #ifndef NDEBUG192 AtomMoleculeMap::const_iterator atomiter = AtomsinSceneMap.find(_id);193 ASSERT(atomiter == AtomsinSceneMap.end(),194 "GLWorldScene::atomRemoved() - atom "+toString(_id)+" already known.");195 #endif196 AtomsinSceneMap.insert( std::make_pair( _id, molObject ));197 198 // inform its GlMoleculeObject_molecule.199 molObject->atomInserted(_id);200 201 // emit change202 emit changeOccured();203 }204 205 /** Removes an atom from the scene.206 *207 * We just the id as the atom might have already been destroyed.208 *209 * @param _id id of atom to remove210 */211 void GLWorldScene::atomRemoved(const atomId_t _id)212 {213 LOG(3, "INFO: GLWorldScene: Received signal atomRemoved for atom "+toString(_id)+".");214 // find associated molecule215 AtomMoleculeMap::iterator iter = AtomsinSceneMap.find(_id);216 ASSERT(iter != AtomsinSceneMap.end(),217 "GLWorldScene::atomRemoved() - atom "+toString(_id)+" not on display.");218 GLMoleculeObject_molecule *molObject = iter->second;219 220 // remove from internal list221 AtomsinSceneMap.erase(iter);222 223 // inform its GlMoleculeObject_molecule.224 molObject->atomRemoved(_id);225 226 // emit change227 emit changeOccured();228 }229 230 /** ....231 *232 */233 void GLWorldScene::worldSelectionChanged()234 {235 LOG(3, "INFO: GLWorldScene: Received signal selectionChanged.");236 237 const std::vector<molecule*> &molecules = World::getInstance().getAllMolecules();238 239 if (molecules.size() > 0) {240 for (std::vector<molecule*>::const_iterator Runner = molecules.begin();241 Runner != molecules.end();242 Runner++) {243 244 // molecule selected but not in scene?245 const bool isSelected = World::getInstance().isSelected(*Runner);246 if (isSelected){247 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find((*Runner)->getId());248 ASSERT( iter != MoleculesinSceneMap.end(),249 "GLWorldScene::worldSelectionChanged() - selected molecule is unknown.");250 GLMoleculeObject_molecule *molObject = iter->second;251 // inform molecule object252 molObject->selected(isSelected);253 }254 }255 }256 }257 258 /** Inserts a molecule into the scene.259 *260 * @param _mol molecule to insert261 */262 void GLWorldScene::moleculeInserted(const molecule * _mol)263 {264 LOG(3, "INFO: GLWorldScene: Received signal moleculeRemoved for molecule "+toString(_mol->getId())+".");265 MoleculeNodeMap::const_iterator iter = MoleculesinSceneMap.find(_mol->getId());266 ASSERT( iter == MoleculesinSceneMap.end(),267 "GLWorldScene::moleculeInserted() - molecule's id "+toString(_mol->getId())+" already present.");268 269 // add new object270 GLMoleculeObject_molecule *molObject = new GLMoleculeObject_molecule(GLMoleculeObject::meshEmpty, this, _mol);271 MoleculesinSceneMap.insert( make_pair(_mol->getId(), molObject) );272 connect (molObject, SIGNAL(changed()), this, SIGNAL(changed()));273 connect (molObject, SIGNAL(changeOccured()), this, SIGNAL(changeOccured()));274 connect (molObject, SIGNAL(atomClicked(atomId_t)), this, SLOT(atomClicked(atomId_t)));275 connect (molObject, SIGNAL(moleculeClicked(moleculeId_t)), this, SLOT(moleculeClicked(moleculeId_t)));276 connect (molObject, SIGNAL(changeAtomId(GLMoleculeObject_atom *, int, int)), this, SLOT(changeAtomId(GLMoleculeObject_atom *, int, int)));277 connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));278 connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));279 connect (molObject, SIGNAL(hoverChanged(const atom &)), this, SIGNAL(hoverChanged(const atom &)));280 connect (molObject, SIGNAL(hoverChanged(const molecule &, int)), this, SIGNAL(hoverChanged(const molecule &, int)));281 emit changed();282 emit changeOccured();283 }284 285 /** Removes a molecule from the scene.286 *287 * @param _id id of molecule to remove288 */289 void GLWorldScene::moleculeRemoved(const moleculeId_t _id)290 {291 LOG(3, "INFO: GLWorldScene: Received signal moleculeRemoved for molecule "+toString(_id)+".");292 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);293 ASSERT( iter != MoleculesinSceneMap.end(),294 "GLWorldScene::moleculeInserted() - molecule's id "+toString(_id)+" is unknown.");295 296 GLMoleculeObject_molecule *molObject = iter->second;297 molObject->disconnect();298 MoleculesinSceneMap.erase(iter);299 delete molObject;300 emit changed();301 emit changeOccured();302 }303 304 void GLWorldScene::moleculesVisibilityChanged(const moleculeId_t _id, bool _visible)305 {306 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);307 ASSERT( iter != MoleculesinSceneMap.end(),308 "GLWorldScene::moleculeInserted() - molecule's id "+toString(_id)+" is unknown.");309 310 GLMoleculeObject_molecule *molObject = iter->second;311 molObject->setVisible(_visible);312 313 emit changed();314 emit changeOccured();315 }316 317 /** Adds a bond to the scene.318 *319 * @param _bond bond to add320 * @param side which side of the bond (left or right)321 */322 void GLWorldScene::bondInserted(const bond::ptr _bond, const enum GLMoleculeObject_bond::SideOfBond _side)323 {324 LOG(3, "INFO: GLWorldScene::bondInserted() - Adding bond "+toString(*_bond)+".");325 //LOG(4, "INFO: Currently present bonds " << BondsinSceneMap << ".");326 // bond partners must both belong to same atom327 ASSERT( _bond->leftatom->getMolecule() == _bond->rightatom->getMolecule(),328 "GLWorldScene::bondInserted() - bond partners do not belong to same molecule.");329 330 // find associated molecule object331 const moleculeId_t molid = _bond->leftatom->getMolecule()->getId();332 MoleculeNodeMap::const_iterator moliter = MoleculesinSceneMap.find(molid );333 ASSERT(moliter != MoleculesinSceneMap.end(),334 "GLWorldScene::bondInserted() - molecule with id of "+toString(molid)335 +" atom with id "+toString(_bond->leftatom->getId())+" is unknown.");336 GLMoleculeObject_molecule *molObject = moliter->second;337 338 // add to internal list339 const GLMoleculeObject_molecule::BondIds ids =340 GLMoleculeObject_molecule::getBondIds(_bond, _side);341 BondMoleculeMap::const_iterator iter = BondsinSceneMap.find(ids);342 ASSERT(iter == BondsinSceneMap.end(),343 "GLWorldScene::bondInserted() - bond with ids "+toString(ids.first)344 +","+toString(ids.second)+" already present.");345 BondsinSceneMap.insert( std::make_pair( ids, molObject ));346 347 // inform its GlMoleculeObject_molecule.348 molObject->bondInserted(_bond, _side);349 350 // emit change351 emit changeOccured();352 }353 354 /** Removes a bond from the scene.355 *356 * @param _bond bond to remove357 */358 void GLWorldScene::bondRemoved(const atomId_t leftnr, const atomId_t rightnr)359 {360 LOG(3, "INFO: GLWorldScene::bondRemoved() - Removing bond between "+toString(leftnr)+" and "+toString(rightnr)+".");361 {362 // left bond363 const GLMoleculeObject_molecule::BondIds Leftids( make_pair(leftnr, rightnr) );364 BondMoleculeMap::iterator leftiter = BondsinSceneMap.find( Leftids );365 ASSERT(leftiter != BondsinSceneMap.end(),366 "GLWorldScene::bondRemoved() - bond "+toString(leftnr)+"-"367 +toString(rightnr)+" not on display.");368 GLMoleculeObject_molecule *molObject = leftiter->second;369 370 // remove from internal list371 BondsinSceneMap.erase(leftiter);372 373 // inform its GlMoleculeObject_molecule.374 molObject->bondRemoved( leftnr, rightnr );375 }376 377 // emit change378 emit changeOccured();379 }380 381 /** Adds a shape to the scene.382 *383 * uses ShapeRegistry::lastChanged()384 *385 */386 void GLWorldScene::addShape()387 {388 Shape &shape = *ShapeRegistry::getInstance().lastChanged();389 GLMoleculeObject_shape *shapeObject = new GLMoleculeObject_shape(shape, this);390 ShapeNodeMap::iterator iter = ShapesinSceneMap.find(shape.getName());391 ASSERT(iter == ShapesinSceneMap.end(),392 "GLWorldScene::addShape() - same shape "+shape.getName()+" added again.");393 ShapesinSceneMap.insert( make_pair(shape.getName(), shapeObject) );394 }395 396 void GLWorldScene::removeShape()397 {398 Shape &shape = *ShapeRegistry::getInstance().lastChanged();399 ShapeNodeMap::iterator iter = ShapesinSceneMap.find(shape.getName());400 ASSERT(iter != ShapesinSceneMap.end(),401 "GLWorldScene::removeShape() - shape "+shape.getName()+" not in scene.");402 ShapesinSceneMap.erase(iter);403 delete(iter->second);404 }405 406 void GLWorldScene::updateSelectedShapes()407 {408 foreach (QObject *obj, children()) {409 GLMoleculeObject_shape *shapeobj = qobject_cast<GLMoleculeObject_shape *>(obj);410 if (shapeobj){411 shapeobj->enable(ShapeRegistry::getInstance().isSelected(shapeobj->getShape()));412 }413 }414 }415 416 void GLWorldScene::initialize(QGLView *view, QGLPainter *painter) const417 {418 // Initialize all of the mesh objects that we have as children.419 foreach (QObject *obj, children()) {420 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);421 if (meshobj)422 meshobj->initialize(view, painter);423 }424 }425 426 void GLWorldScene::draw(QGLPainter *painter, const QVector4D &cameraPlane) const427 {428 // Draw all of the mesh objects that we have as children.429 foreach (QObject *obj, children()) {430 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);431 if (meshobj)432 meshobj->draw(painter, cameraPlane);433 }434 }435 436 439 void GLWorldScene::setSelectionMode(SelectionModeType mode) 437 440 { … … 450 453 } 451 454 455 void GLWorldScene::hoverChangedSignalled(GLMoleculeObject *ob) 456 { 457 // Find the atom, ob corresponds to. 458 hoverAtom = NULL; 459 GLMoleculeObject_atom *atomObject = dynamic_cast<GLMoleculeObject_atom *>(ob); 460 if (atomObject){ 461 for (AtomNodeMap::iterator iter = AtomsinSceneMap.begin();iter != AtomsinSceneMap.end(); ++ iter){ 462 if (iter->second == atomObject) 463 hoverAtom = World::getInstance().getAtom(AtomById(iter->first)); 464 } 465 } 466 467 // Propagate signal. 468 emit hoverChanged(hoverAtom); 469 } 470 452 471 void GLWorldScene::changeAtomId(GLMoleculeObject_atom *ob, int oldId, int newId) 453 472 { 454 473 LOG(3, "INFO: GLWorldScene - change atom id " << oldId << " to " << newId << "."); 455 474 // Remove from map. 456 Atom MoleculeMap::iterator iter = AtomsinSceneMap.find(oldId);475 AtomNodeMap::iterator iter = AtomsinSceneMap.find(oldId); 457 476 ASSERT(iter != AtomsinSceneMap.end(), 458 "GLWorldScene::changeAtomId() - atom with old id "+toString(oldId)+" not on display."); 459 GLMoleculeObject_molecule *molObject = iter->second; 460 461 // erase by signalling removal 462 molObject->atomRemoved(oldId); 463 464 // remove from internal list 477 "GLWorldScene::objectIdChangedSignalled() - atom with id "+toString(oldId)+" not on display."); 478 GLMoleculeObject_atom *atomObject = iter->second; 465 479 AtomsinSceneMap.erase(iter); 466 480 467 481 // Reinsert with new id. 468 { 469 AtomMoleculeMap::iterator iter = AtomsinSceneMap.find(newId); 470 ASSERT(iter == AtomsinSceneMap.end(), 471 "GLWorldScene::changeAtomId() - atom with new id "+toString(newId)+" already known."); 472 } 473 AtomsinSceneMap.insert( make_pair(newId, molObject) ); 474 475 // inform molecule object 476 molObject->atomInserted(oldId); 477 } 482 AtomsinSceneMap.insert( make_pair(newId, atomObject) ); 483 } 484 -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp
r0ac85c3 r7b38d3 75 75 void clicked(atomId_t); 76 76 void doubleClicked(); 77 void hoverChanged(const atom &); 78 void hoverChanged(const molecule &, int); 77 void hoverChanged(const atom*); 79 78 80 79 private slots: 81 80 void atomClicked(atomId_t no); 82 void atomInserted(const atomId_t _id); 83 void atomRemoved(const atomId_t _id); 84 void moleculeClicked(moleculeId_t no); 85 void moleculeRemoved(const moleculeId_t _id); 86 void moleculeInserted(const molecule * _mol); 81 void atomInserted(const atomicNumber_t _id); 82 void atomRemoved(const atomicNumber_t _id); 83 void moleculeRemoved(const molecule *_molecule); 87 84 void worldSelectionChanged(); 88 85 void bondInserted(const bond::ptr _bond, const GLMoleculeObject_bond::SideOfBond side); … … 90 87 void setSelectionModeAtom(); 91 88 void setSelectionModeMolecule(); 89 void hoverChangedSignalled(GLMoleculeObject *ob); 92 90 void changeAtomId(GLMoleculeObject_atom *ob, int oldId, int newOd); 93 91 void addShape(); 94 92 void removeShape(); 95 93 void update(); 96 void moleculesVisibilityChanged(const moleculeId_t _id, bool _visible);97 94 98 95 public: … … 103 100 104 101 private: 102 typedef std::pair< atomId_t, atomId_t> BondIds; 103 friend std::ostream &operator<<(std::ostream &ost, const BondIds &t); 105 104 106 typedef std::map< atomId_t, GLMoleculeObject_molecule* > AtomMoleculeMap; 107 typedef std::map< GLMoleculeObject_molecule::BondIds , GLMoleculeObject_molecule* > BondMoleculeMap; 105 BondIds getBondIds( 106 const bond::ptr _bond, 107 const enum GLMoleculeObject_bond::SideOfBond side) const; 108 109 typedef std::map< atomId_t, GLMoleculeObject_atom* > AtomNodeMap; 110 typedef std::map< BondIds , GLMoleculeObject_bond* > BondNodeMap; 108 111 typedef std::map< moleculeId_t , GLMoleculeObject_molecule* > MoleculeNodeMap; 109 112 typedef std::map< std::string , GLMoleculeObject_shape* > ShapeNodeMap; 110 Atom MoleculeMap AtomsinSceneMap;111 Bond MoleculeMap BondsinSceneMap;113 AtomNodeMap AtomsinSceneMap; 114 BondNodeMap BondsinSceneMap; 112 115 MoleculeNodeMap MoleculesinSceneMap; 113 116 ShapeNodeMap ShapesinSceneMap; 114 117 118 QGLSceneNode *meshEmpty[GLMoleculeObject::DETAILTYPES_MAX]; 119 QGLSceneNode *meshSphere[GLMoleculeObject::DETAILTYPES_MAX]; 120 QGLSceneNode *meshCylinder[GLMoleculeObject::DETAILTYPES_MAX]; 121 115 122 SelectionModeType selectionMode; 123 const atom *hoverAtom; 116 124 }; 117 125 126 std::ostream &operator<<(std::ostream &ost, const GLWorldScene::BondIds &t); 127 118 128 #endif /* GLWORLDSCENE_HPP_ */ -
src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp
r0ac85c3 r7b38d3 71 71 setOption(QGLView::ObjectPicking, true); 72 72 setOption(QGLView::CameraNavigation, false); 73 setFocusPolicy(Qt::StrongFocus);74 73 setCameraControlMode(Rotate); 75 74 defaultEyeSeparation = 4.0; … … 79 78 //changeMaterials(false); 80 79 81 qRegisterMetaType<atomId_t>("atomId_t"); 82 qRegisterMetaType<moleculeId_t>("moleculeId_t"); 80 qRegisterMetaType<atomicNumber_t>("atomicNumber_t"); 83 81 84 82 connect(this, SIGNAL(ShapeAdded()), worldscene, SLOT(addShape())); … … 87 85 connect(worldscene, SIGNAL(changeOccured()), this, SLOT(changeSignalled())); 88 86 connect(worldscene, SIGNAL(changed()), this, SIGNAL(changed())); 89 connect(worldscene, SIGNAL(hoverChanged(const atom &)), this, SLOT(sceneHoverSignalled(const atom &))); 90 connect(worldscene, SIGNAL(hoverChanged(const molecule &, int)), this, SLOT(sceneHoverSignalled(const molecule &, int))); 87 connect(worldscene, SIGNAL(hoverChanged(const atom *)), this, SLOT(sceneHoverSignalled(const atom *))); 88 connect(this, SIGNAL(atomInserted(const atomicNumber_t)), worldscene, SLOT(atomInserted(const atomicNumber_t))); 89 connect(this, SIGNAL(atomRemoved(const atomicNumber_t)), worldscene, SLOT(atomRemoved(const atomicNumber_t))); 91 90 connect(this, SIGNAL(worldSelectionChanged()), worldscene, SLOT(worldSelectionChanged())); 92 connect(this, SIGNAL(moleculeRemoved(const molecule Id_t)), worldscene, SLOT(moleculeRemoved(const moleculeId_t)));93 connect(this, SIGNAL(moleculeInserted(const molecule *)), worldscene, SLOT(moleculeInserted(const molecule *)));91 connect(this, SIGNAL(moleculeRemoved(const molecule *)), worldscene, SLOT(moleculeRemoved(const molecule *))); 92 //connect(this, SIGNAL(moleculeInserted(const molecule *)), worldscene, SLOT(moleculeInserted(const molecule *))); 94 93 //connect(this, SIGNAL(changed()), this, SLOT(updateGL())); 95 94 connect(this, SIGNAL(changed()), this, SLOT(sceneChangeSignalled())); 96 connect(this, SIGNAL(moleculesVisibilityChanged(const moleculeId_t,bool)), worldscene, SLOT(moleculesVisibilityChanged(const moleculeId_t,bool)));97 95 98 96 // sign on to changes in the world 99 97 World::getInstance().signOn(this); 98 World::getInstance().signOn(this, World::AtomInserted); 99 World::getInstance().signOn(this, World::AtomRemoved); 100 100 World::getInstance().signOn(this, World::MoleculeInserted); 101 101 World::getInstance().signOn(this, World::MoleculeRemoved); … … 338 338 if (static_cast<World *>(publisher) == World::getPointer()) { 339 339 switch (notification->getChannelNo()) { 340 case World::AtomInserted: 341 { 342 const atomicNumber_t _id = World::getInstance().lastChanged<atom>()->getId(); 343 #ifdef LOG_OBSERVER 344 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted."; 345 #endif 346 emit atomInserted(_id); 347 break; 348 } 349 case World::AtomRemoved: 350 { 351 const atomicNumber_t _id = World::getInstance().lastChanged<atom>()->getId(); 352 #ifdef LOG_OBSERVER 353 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been removed."; 354 #endif 355 emit atomRemoved(_id); 356 break; 357 } 340 358 case World::SelectionChanged: 341 359 { … … 348 366 case World::MoleculeInserted: 349 367 { 350 const molecule * _mol= World::getInstance().lastChanged<molecule>();368 const molecule *_molecule = World::getInstance().lastChanged<molecule>(); 351 369 #ifdef LOG_OBSERVER 352 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_mol ->getId())+" has been removed.";370 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_molecule->getId())+" has been removed."; 353 371 #endif 354 emit moleculeInserted(_mol );372 emit moleculeInserted(_molecule); 355 373 break; 356 374 } 357 375 case World::MoleculeRemoved: 358 376 { 359 const molecule Id_t _id = World::getInstance().lastChanged<molecule>()->getId();377 const molecule *_molecule = World::getInstance().lastChanged<molecule>(); 360 378 #ifdef LOG_OBSERVER 361 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_ id)+" has been removed.";379 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_molecule->getId())+" has been removed."; 362 380 #endif 363 emit moleculeRemoved(_ id);381 emit moleculeRemoved(_molecule); 364 382 break; 365 383 } … … 500 518 void GLWorldView::keyPressEvent(QKeyEvent *e) 501 519 { 502 // Find the distance between the eye and focus point.503 QVector3D d = camera()->eye() - camera()->center();504 // LOG(1, "Distance vector eye and center is "505 // << d.x() << "," << d.y() << "," << d.z());506 // scale the move unit by the eye <-> domain center distance507 const double key_move_unit = 0.04*(d.length()/50.);508 509 520 if (e->key() == Qt::Key_Tab) { 510 521 // The Tab key turns the ShowPicking option on and off, … … 512 523 setOption(QGLView::ShowPicking, ((options() & QGLView::ShowPicking) == 0)); 513 524 updateGL(); 514 } else if ((e->key() == Qt::Key_Minus) || (e->key() == Qt::Key_Plus)) {515 // Scale the distance.516 if (e->key() == Qt::Key_Minus)517 d *= 1.2;518 else if (e->key() == Qt::Key_Plus)519 d /= 1.2;520 // Set new eye position.521 camera()->setEye(camera()->center() + d);522 } else if ((e->key() == Qt::Key_Left) || (e->key() == Qt::Key_Right)) {523 // Translate the camera.524 const double d = (e->key() == Qt::Key_Left) ? -key_move_unit : key_move_unit;525 camera()->translateCenter( d, 0., 0);526 camera()->translateEye( d, 0., 0);527 } else if ((e->key() == Qt::Key_Up) || (e->key() == Qt::Key_Down)) {528 // Translate the camera.529 const double d = (e->key() == Qt::Key_Up) ? -key_move_unit : key_move_unit;530 camera()->translateCenter( 0., d, 0);531 camera()->translateEye( 0., d, 0);532 } else if ((e->key() == Qt::Key_PageUp) || (e->key() == Qt::Key_PageDown)) {533 // Translate the camera.534 const double d = (e->key() == Qt::Key_PageUp) ? -key_move_unit : key_move_unit;535 camera()->translateCenter( 0., 0., d);536 camera()->translateEye( 0., 0., d);537 525 } 538 526 QGLView::keyPressEvent(e); … … 762 750 } 763 751 764 void GLWorldView::sceneHoverSignalled(const atom &_atom)752 void GLWorldView::sceneHoverSignalled(const atom *_atom) 765 753 { 766 754 emit hoverChanged(_atom); 767 755 } 768 769 void GLWorldView::sceneHoverSignalled(const molecule &_mol, int _i)770 {771 emit hoverChanged(_mol, _i);772 } -
src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp
r0ac85c3 r7b38d3 51 51 void checkChanges(); 52 52 void sceneChangeSignalled(); 53 void sceneHoverSignalled(const atom &_atom); 54 void sceneHoverSignalled(const molecule &_mol, int); 53 void sceneHoverSignalled(const atom *_atom); 55 54 void changeDreiBein(); 56 55 void changeDomain(); … … 59 58 void changed(); 60 59 void TimeChanged(); 61 void moleculeInserted(const molecule * _mol); 62 void moleculeRemoved(const moleculeId_t _id); 60 void atomInserted(const atomicNumber_t _id); 61 void atomRemoved(const atomicNumber_t _id); 62 void moleculeInserted(const molecule *_molecule); 63 void moleculeRemoved(const molecule *_molecule); 63 64 void worldSelectionChanged(); 64 void hoverChanged(const atom &_atom); 65 void hoverChanged(const molecule &_mol, int); 65 void hoverChanged(const atom *_atom); 66 66 void ShapeAdded(); 67 67 void ShapeRemoved(); 68 void moleculesVisibilityChanged(const moleculeId_t,bool);69 68 70 69 protected: -
src/UIElements/Views/Qt4/QtInfoBox.cpp
r0ac85c3 r7b38d3 50 50 QTabWidget(), 51 51 curAtom(NULL), nextAtom(NULL), 52 curMolecule(NULL), nextMolecule(NULL),53 52 page_mol(NULL), page_atom(NULL) 54 53 { … … 68 67 } 69 68 70 void QtInfoBox::atomHover(const atom &_atom) 71 { 72 nextAtom = &_atom; 73 timer->start(500); 74 } 75 76 void QtInfoBox::moleculeHover(const molecule &_mol) 77 { 78 nextMolecule = &_mol; 69 void QtInfoBox::atomHover(const atom *_atom) 70 { 71 nextAtom = _atom; 79 72 timer->start(500); 80 73 } … … 84 77 if (nextAtom) 85 78 showAtom(nextAtom); 86 if (nextMolecule)87 showMolecule(nextMolecule);88 79 } 89 80 … … 110 101 111 102 curAtom = _atom; 112 nextAtom = NULL;113 nextMolecule = NULL;114 103 115 104 // Show new tabs. … … 127 116 setCurrentIndex(currentPage); 128 117 } 129 }130 }131 132 void QtInfoBox::showMolecule(const molecule *_mol)133 {134 currentPage = currentIndex();135 136 // Remove old tabs.137 clearTabs();138 139 curMolecule = _mol;140 nextAtom = NULL;141 nextMolecule = NULL;142 143 // Show new tabs.144 if (curMolecule){145 page_mol = new QtMoleculeInfoPage(curMolecule, this);146 addTab(page_mol, "Molecule");147 connect(page_mol, SIGNAL(moleculeKilled()), this, SLOT(clearTabs()));148 149 if (currentPage > 0)150 setCurrentIndex(currentPage);151 118 } 152 119 } -
src/UIElements/Views/Qt4/QtInfoBox.hpp
r0ac85c3 r7b38d3 36 36 37 37 void showAtom(const atom *_atom); 38 void showMolecule(const molecule *_mol);39 38 40 39 public slots: 41 void atomHover(const atom &_atom); 42 void moleculeHover(const molecule &_mol); 40 void atomHover(const atom *_atom); 43 41 void timerTimeout(); 44 42 … … 48 46 const atom *curAtom; 49 47 const atom *nextAtom; 50 const molecule *curMolecule;51 const molecule *nextMolecule;52 48 QtMoleculeInfoPage *page_mol; 53 49 QtAtomInfoPage *page_atom; -
src/UIElements/Views/Qt4/QtMoleculeList.cpp
r0ac85c3 r7b38d3 55 55 // these attributes are skipped so far 56 56 const int QtMoleculeList::COLUMNCOUNT = COLUMNTYPES_MAX; 57 const char *QtMoleculeList::COLUMNNAMES[QtMoleculeList::COLUMNCOUNT]={"Name"," Visibility", "Atoms","Formula","Occurrence"/*,"Size"*/};57 const char *QtMoleculeList::COLUMNNAMES[QtMoleculeList::COLUMNCOUNT]={"Name","Atoms","Formula","Occurrence"/*,"Size"*/}; 58 58 59 59 QtMoleculeList::QtMoleculeList(QWidget * _parent) : … … 69 69 setHeaderLabels(header); 70 70 71 World::getInstance().signOn(this , World::MoleculeInserted);72 World::getInstance().signOn(this, World::MoleculeRemoved);71 World::getInstance().signOn(this);//, World::MoleculeInserted); 72 //World::getInstance().signOn(this, World::MoleculeRemoved); 73 73 74 74 … … 76 76 clearing = false; 77 77 selecting = false; 78 ChangingChildrensVisibility = false;79 78 refill(); 80 79 … … 82 81 //connect(this,SIGNAL(cellChanged(int,int)),this,SLOT(moleculeChanged(int,int))); 83 82 connect(selectionModel(),SIGNAL(selectionChanged(QItemSelection, QItemSelection)),this,SLOT(rowsSelected(QItemSelection, QItemSelection))); 84 connect(this, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(visibilityChanged(QTreeWidgetItem*, int))); 83 85 84 } 86 85 87 86 QtMoleculeList::~QtMoleculeList() 88 87 { 89 World::getInstance().signOff(this , World::MoleculeInserted);90 World::getInstance().signOff(this, World::MoleculeRemoved);88 World::getInstance().signOff(this);//, World::MoleculeInserted); 89 //World::getInstance().signOff(this, World::MoleculeRemoved); 91 90 } 92 91 93 92 void QtMoleculeList::update(Observable *publisher) { 94 ASSERT(0,95 "QtMoleculeList::update() - we did not sign up for any global updates.");96 }97 98 void QtMoleculeList::recieveNotification(Observable *publisher, Notification_ptr notification) {99 93 100 94 if (selecting) … … 102 96 103 97 dirty = true; 104 } 105 98 99 // force an update from Qt... 100 clearing = true; 101 clear(); 102 clearing = false; 103 } 106 104 107 105 void QtMoleculeList::refill() { … … 110 108 111 109 clear(); 112 formula.clear(); 113 FormulaVisibilityCountMap.clear(); 110 111 // list of (unique) formulas in the world 112 std::vector<Formula> formula; 114 113 115 114 for (std::vector<molecule*>::const_iterator iter = molecules.begin(); … … 119 118 // find group if already in list 120 119 QTreeWidgetItem *groupItem = NULL; 121 const std::string &molecule_formula = (*iter)->getFormula().toString(); 122 FormulaTreeItemMap_t::const_iterator formulaiter = 123 formula.find(molecule_formula); 120 for (unsigned int j=0;j<formula.size();j++) 121 if ((*iter)->getFormula() == formula[j]){ 122 groupItem = topLevelItem(j); 123 break; 124 } 124 125 125 126 // new molecule type -> create new group 126 if (formulaiter == formula.end()){ 127 // insert new formula entry into visibility 128 #ifndef NDEBUG 129 std::pair< FormulaVisibilityCountMap_t::iterator, bool> visibilityinserter = 130 #endif 131 FormulaVisibilityCountMap.insert( 132 std::make_pair( molecule_formula, (unsigned int)0) ); 133 ASSERT( visibilityinserter.second, 134 "QtMoleculeList::refill() - molecule with formula " 135 +molecule_formula+" already in FormulaVisibilityCountMap."); 136 137 // create item and place into Map with formula as key 127 if (!groupItem){ 128 formula.push_back((*iter)->getFormula()); 138 129 groupItem = new QTreeWidgetItem(this); 139 formula.insert( std::make_pair(molecule_formula, groupItem) ); 140 // fill item 141 groupItem->setText(NAME, QString("default")); 142 groupItem->setFlags((groupItem->flags() | Qt::ItemIsUserCheckable) ^ Qt::ItemIsSelectable); 143 groupItem->setCheckState(VISIBILITY, Qt::Unchecked); 144 groupItem->setText(ATOMCOUNT, QString::number(0)); 145 groupItem->setText(FORMULA, QString("")); 146 groupItem->setText(OCCURRENCE, "0"); 130 groupItem->setText(0, QString("default")); 131 groupItem->setText(1, QString::number(0)); 132 groupItem->setText(2, QString("")); 133 groupItem->setText(3, "0"); 147 134 groupItem->setData(0, Qt::UserRole, QVariant(-1)); 148 } else {149 groupItem = formulaiter->second;150 135 } 151 136 152 137 // add molecule 153 138 QTreeWidgetItem *molItem = new QTreeWidgetItem(groupItem); 154 molItem->setText(NAME, QString((*iter)->getName().c_str())); 155 molItem->setFlags(molItem->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable); 156 molItem->setCheckState(VISIBILITY, Qt::Unchecked); 157 molItem->setText(ATOMCOUNT, QString::number((*iter)->getAtomCount())); 158 molItem->setText(FORMULA, QString(molecule_formula.c_str())); 139 molItem->setText(0, QString((*iter)->getName().c_str())); 140 molItem->setText(1, QString::number((*iter)->getAtomCount())); 141 molItem->setText(2, QString((*iter)->getFormula().toString().c_str())); 159 142 const int index = (*iter)->getId(); 160 143 molItem->setData(0, Qt::UserRole, QVariant(index)); 161 144 molItem->setSelected(World::getInstance().isSelected(*iter)); 162 145 146 163 147 // increase group occurrence 164 int count = groupItem->text( OCCURRENCE).toInt() + 1;165 groupItem->setText( OCCURRENCE, QString::number(count));148 int count = groupItem->text(3).toInt() + 1; 149 groupItem->setText(3, QString::number(count)); 166 150 } 167 151 dirty = false; … … 177 161 178 162 void QtMoleculeList::subjectKilled(Observable *publisher) { 179 }180 181 void QtMoleculeList::visibilityChanged(QTreeWidgetItem* item, int column)182 {183 if ((!clearing) && (!ChangingChildrensVisibility))184 if (column == VISIBILITY) {185 const moleculeId_t molid = item->data(0, Qt::UserRole).toInt();186 const bool visible = item->checkState(VISIBILITY);187 if (molid != (unsigned int)-1) { // molecule item188 const molecule * const _molecule =189 World::getInstance().getMolecule(MoleculeById(molid));190 ASSERT( _molecule != NULL,191 "QtMoleculeList::visibilityChanged() - molecule with id "192 +toString(molid)+" is not known to World.");193 const std::string &molecule_formula = _molecule->getFormula().toString();194 ASSERT( FormulaVisibilityCountMap.count(molecule_formula) != 0,195 "QtMoleculeList::visibilityChanged() - molecule with formula " +molecule_formula196 +" is not present in FormulaVisibilityCountMap.");197 198 // get parent199 QTreeWidgetItem *groupItem = item->parent();200 ASSERT( groupItem != NULL,201 "QtMoleculeList::visibilityChanged() - item with id "+toString(molid)202 +" has not parent?");203 // check whether we have to set the group item204 205 ChangingChildrensVisibility = true;206 if (visible) {207 ++(FormulaVisibilityCountMap[molecule_formula]);208 // compare with occurence/total number of molecules209 if (FormulaVisibilityCountMap[molecule_formula] ==210 (unsigned int)(groupItem->text(OCCURRENCE).toInt()))211 groupItem->setCheckState(VISIBILITY, Qt::Checked);212 } else {213 --(FormulaVisibilityCountMap[molecule_formula]);214 // none selected anymore?215 if (FormulaVisibilityCountMap[molecule_formula] == 0)216 groupItem->setCheckState(VISIBILITY, Qt::Unchecked);217 }218 ChangingChildrensVisibility = false;219 220 emit moleculesVisibilityChanged(molid, visible);221 222 } else { // group item223 224 // go through all children, but don't enter for groupItem once more225 ChangingChildrensVisibility = true;226 for (int i=0;i<item->childCount();++i) {227 QTreeWidgetItem *molItem = item->child(i);228 const moleculeId_t molid = molItem->data(0, Qt::UserRole).toInt();229 ASSERT( molid != (unsigned int)-1,230 "QtMoleculeList::visibilityChanged() - to child with index"231 +toString(i)+" there is no molecule?");232 molItem->setCheckState(VISIBILITY, visible ? Qt::Checked : Qt::Unchecked);233 234 // emit signal235 emit moleculesVisibilityChanged(molid, visible);236 }237 // set current number of visible children238 const std::string molecule_formula =239 item->text(FORMULA).toStdString();240 FormulaVisibilityCountMap[molecule_formula] =241 visible ? item->text(OCCURRENCE).toInt() : 0;242 243 ChangingChildrensVisibility = false;244 }245 }246 163 } 247 164 … … 268 185 // Select all molecules which belong to newly selected rows. 269 186 QModelIndex index; 270 { 271 QModelIndexList items = selected.indexes(); 272 molids_t ids; 273 ids.reserve(items.size()); 274 foreach (index, items) 275 if (index.column() == 0){ 276 int mol_id = model()->data(index, Qt::UserRole).toInt(); 277 if (mol_id < 0) 278 continue; 279 ids.push_back(mol_id); 280 //std::cout << "select molecule" << std::endl; 281 } 282 MoleCuilder::SelectionMoleculeById(ids); 283 } 187 QModelIndexList items = selected.indexes(); 188 foreach (index, items) 189 if (index.column() == 0){ 190 int mol_id = model()->data(index, Qt::UserRole).toInt(); 191 if (mol_id < 0) 192 continue; 193 //std::cout << "select molecule" << std::endl; 194 MoleCuilder::SelectionMoleculeById(mol_id); 195 } 284 196 285 197 // Unselect all molecules which belong to newly unselected rows. 286 { 287 QModelIndexList items = deselected.indexes(); 288 molids_t ids; 289 ids.reserve(items.size()); 290 foreach (index, items) 291 if (index.column() == 0){ 292 int mol_id = model()->data(index, Qt::UserRole).toInt(); 293 if (mol_id < 0) 294 continue; 295 //std::cout << "unselect molecule" << std::endl; 296 ids.push_back(mol_id); 297 } 298 MoleCuilder::SelectionNotMoleculeById(ids); 299 } 198 items = deselected.indexes(); 199 foreach (index, items) 200 if (index.column() == 0){ 201 int mol_id = model()->data(index, Qt::UserRole).toInt(); 202 if (mol_id < 0) 203 continue; 204 //std::cout << "unselect molecule" << std::endl; 205 MoleCuilder::SelectionNotMoleculeById(mol_id); 206 } 300 207 301 208 selecting = false; -
src/UIElements/Views/Qt4/QtMoleculeList.hpp
r0ac85c3 r7b38d3 14 14 #endif 15 15 16 16 17 #include <QtGui/QTreeWidget> 17 18 #include <map>19 #include <string>20 21 18 #include "CodePatterns/Observer/Observer.hpp" 22 23 #include "types.hpp"24 19 25 20 class molecule; … … 36 31 protected: 37 32 virtual void update(Observable *publisher); 38 virtual void recieveNotification(Observable *publisher, Notification_ptr notification);39 33 virtual void subjectKilled(Observable *publisher); 40 34 virtual void paintEvent(QPaintEvent * event); … … 42 36 43 37 static const int COLUMNCOUNT; 44 enum {NAME, VISIBILITY,ATOMCOUNT,FORMULA,OCCURRENCE,COLUMNTYPES_MAX} COLUMNTYPES;38 enum {NAME,ATOMCOUNT,FORMULA,OCCURRENCE,COLUMNTYPES_MAX} COLUMNTYPES; 45 39 static const char *COLUMNNAMES[]; 46 40 47 41 private slots: 48 42 void moleculeChanged(); 49 void visibilityChanged(QTreeWidgetItem*, int);50 43 51 44 void rowsSelected(const QItemSelection & selected, const QItemSelection & deselected); … … 54 47 void moleculeSelected(molecule*); 55 48 void moleculeUnSelected(molecule*); 56 void moleculesVisibilityChanged(const moleculeId_t, bool);57 49 58 50 private: … … 60 52 bool clearing; 61 53 bool selecting; 62 bool ChangingChildrensVisibility;63 64 typedef std::map<std::string, unsigned int> FormulaVisibilityCountMap_t;65 FormulaVisibilityCountMap_t FormulaVisibilityCountMap;66 67 typedef std::map<std::string, QTreeWidgetItem*> FormulaTreeItemMap_t;68 //!> map of (unique) formulas in the world69 FormulaTreeItemMap_t formula;70 54 }; 71 55 -
src/UIElements/Views/Qt4/QtToolBar.cpp
r0ac85c3 r7b38d3 28 28 */ 29 29 30 31 32 30 33 // include config.h 31 34 #ifdef HAVE_CONFIG_H … … 33 36 #endif 34 37 38 35 39 #include "QtToolBar.hpp" 36 40 37 41 #include "CodePatterns/MemDebug.hpp" 38 42 39 #include "CodePatterns/Observer/Notification.hpp"40 41 #include "Actions/ActionQueue.hpp"42 43 43 QtToolBar::QtToolBar(QWidget * _parent) : 44 QToolBar(_parent), 45 Observer("QToolBar"), 46 ActionQueue_observing(false), 47 undoaction(addActionItem("undo", "undo the last Action", "edit-undo")), 48 redoaction(addActionItem("redo", "redo the last Action", "edit-redo")) 44 QToolBar(_parent) 49 45 { 50 // gray out undo/redo buttons initially 51 undoaction->setEnabled(false); 52 redoaction->setEnabled(false); 53 54 // sign in 55 MoleCuilder::ActionQueue::getInstance().signOn(this, MoleCuilder::ActionQueue::ActionQueued); 56 ActionQueue_observing = true; 46 addActionItem("undo", "undo the last Action", "edit-undo"); 47 addActionItem("redo", "redo the last Action", "edit-redo"); 57 48 } 58 49 … … 60 51 QtToolBar::~QtToolBar() 61 52 { 62 // sign off63 if (ActionQueue_observing)64 MoleCuilder::ActionQueue::getInstance().signOff(this, MoleCuilder::ActionQueue::ActionQueued);65 53 } 66 54 67 55 68 QAction * QtToolBar::addActionItem( 69 const std::string &token, 70 const std::string &description, 71 const std::string &icon_name) 56 void QtToolBar::addActionItem(const std::string &token, const std::string &description, const std::string &icon_name) 72 57 { 73 58 QAction *action = addAction(QString(description.c_str())); … … 78 63 plumbing.push_back(pipe); 79 64 present_actions.insert( token ); 80 return action;81 65 } 82 66 … … 88 72 } 89 73 90 void QtToolBar::update(Observable *publisher)91 {92 ASSERT(0, "QtToolBar::update() - this should never be called, we are only subscribed to channels.");93 }94 95 void QtToolBar::subjectKilled(Observable *publisher)96 {97 ActionQueue_observing = false;98 }99 100 void QtToolBar::recieveNotification(Observable *publisher, Notification_ptr notification)101 {102 if (dynamic_cast<MoleCuilder::ActionQueue *>(publisher) != NULL) {103 switch(notification->getChannelNo()) {104 case MoleCuilder::ActionQueue::ActionQueued:105 undoaction->setEnabled(MoleCuilder::ActionQueue::getInstance().canUndo());106 redoaction->setEnabled(MoleCuilder::ActionQueue::getInstance().canRedo());107 break;108 default:109 ASSERT(0, "QtToolBar::recieveNotification() - cannot get here, not subscribed to channel "110 +toString(notification->getChannelNo()));111 break;112 }113 } else {114 ASSERT(0, "QtToolBar::recieveNotification() - cannot get here, we are only subscribed to ActionQueue.");115 }116 } -
src/UIElements/Views/Qt4/QtToolBar.hpp
r0ac85c3 r7b38d3 27 27 28 28 29 class QtToolBar : public QToolBar , public Observer29 class QtToolBar : public QToolBar 30 30 { 31 31 Q_OBJECT … … 39 39 * @param description description to appear as tooltip 40 40 * @param icon_name name of icon 41 * @return ref to newly created action42 41 */ 43 QAction * addActionItem( 44 const std::string &token, 45 const std::string &description, 46 const std::string &icon_name); 42 void addActionItem(const std::string &token, const std::string &description, const std::string &icon_name); 47 43 48 44 /** Function to add a set of favorite actions. … … 61 57 const present_actions_t & getPresentActions() const 62 58 { return present_actions; } 63 64 void update(Observable *publisher);65 void subjectKilled(Observable *publisher);66 void recieveNotification(Observable *publisher, Notification_ptr notification);67 59 68 60 private: … … 113 105 //!> set of already present action icons 114 106 present_actions_t present_actions; 115 116 //!> sign in to ActionQueue?117 bool ActionQueue_observing;118 //!> ref to undoaction to gray out119 QAction *undoaction;120 //!> ref to redoaction to gray out121 QAction *redoaction;122 107 }; 123 108 -
src/UIElements/Views/Qt4/QtToolBar_QtFavoriteActions.cpp
r0ac85c3 r7b38d3 46 46 #include "CodePatterns/Assert.hpp" 47 47 #include "CodePatterns/Log.hpp" 48 #include "CodePatterns/Observer/Observer.hpp" 48 49 49 50 #include "Actions/Action.hpp" -
src/World.cpp
r0ac85c3 r7b38d3 245 245 WorldTime::getInstance().setTime(_step); 246 246 247 // TODO: removed when BondGraph creates the adjacency 248 // 3. remove all of World's molecules 249 for (MoleculeIterator iter = getMoleculeIter(); 250 getMoleculeIter() != moleculeEnd(); 251 iter = getMoleculeIter()) { 252 getMolecules()->erase(*iter); 253 destroyMolecule(*iter); 254 } 255 247 256 // 4. scan for connected subgraphs => molecules 248 257 DepthFirstSearchAnalysis DFS; … … 295 304 296 305 void World::destroyMolecule(molecule* mol){ 306 OBSERVE; 297 307 ASSERT(mol,"Molecule that was meant to be destroyed did not exist"); 298 308 destroyMolecule(mol->getId()); … … 309 319 } 310 320 mol->signOff(this); 311 // TODO: removed when depcreated MoleculeListClass is gone312 molecules_deprecated->erase(mol);313 321 DeleteMolecule(mol); 314 322 if (isMoleculeSelected(id)) … … 357 365 NOTIFY(AtomRemoved); 358 366 } 359 // check if it's the last atom360 molecule *_mol = atom->getMolecule();361 if ((_mol == NULL) || (_mol->getAtomCount() > 1))362 _mol = NULL;363 367 DeleteAtom(atom); 364 368 if (isAtomSelected(id)) … … 366 370 atoms.erase(id); 367 371 atomIdPool.releaseId(id); 368 // remove molecule if empty369 if (_mol != NULL)370 destroyMolecule(_mol);371 372 } 372 373 … … 554 555 std::for_each(invertedSelection.begin(),invertedSelection.end(), 555 556 std::bind1st(std::mem_fun(selector),this)); // func is select... see above 556 }557 558 void World::popAtomSelection(){559 OBSERVE;560 NOTIFY(SelectionChanged);561 selectedAtoms = selectedAtoms_Stack.top();562 selectedAtoms_Stack.pop();563 }564 565 void World::pushAtomSelection(){566 OBSERVE;567 NOTIFY(SelectionChanged);568 selectedAtoms_Stack.push( selectedAtoms );569 selectedAtoms.clear();570 557 } 571 558 … … 698 685 std::for_each(invertedSelection.begin(),invertedSelection.end(), 699 686 std::bind1st(std::mem_fun(selector),this)); // func is select... see above 700 }701 702 void World::popMoleculeSelection(){703 OBSERVE;704 NOTIFY(SelectionChanged);705 selectedMolecules = selectedMolecules_Stack.top();706 selectedMolecules_Stack.pop();707 }708 709 void World::pushMoleculeSelection(){710 OBSERVE;711 NOTIFY(SelectionChanged);712 selectedMolecules_Stack.push( selectedMolecules );713 selectedMolecules.clear();714 687 } 715 688 -
src/World.hpp
r0ac85c3 r7b38d3 20 20 #include <vector> 21 21 #include <set> 22 #include <stack>23 22 #include <boost/thread.hpp> 24 23 #include <boost/shared_ptr.hpp> … … 374 373 void clearAtomSelection(); 375 374 void invertAtomSelection(); 376 void popAtomSelection();377 void pushAtomSelection();378 375 void selectAtom(const atom*); 379 376 void selectAtom(const atomId_t); … … 393 390 void clearMoleculeSelection(); 394 391 void invertMoleculeSelection(); 395 void popMoleculeSelection();396 void pushMoleculeSelection();397 392 void selectMolecule(const molecule*); 398 393 void selectMolecule(const moleculeId_t); … … 491 486 AtomSet atoms; 492 487 AtomSet selectedAtoms; 493 std::stack<AtomSet> selectedAtoms_Stack;494 488 /** 495 489 * stores the pool for all available AtomIds below currAtomId … … 501 495 MoleculeSet molecules; 502 496 MoleculeSet selectedMolecules; 503 std::stack<MoleculeSet> selectedMolecules_Stack;504 497 /** 505 498 * stores the pool for all available AtomIds below currAtomId -
src/molecule.cpp
r0ac85c3 r7b38d3 49 49 #include "CodePatterns/enumeration.hpp" 50 50 #include "CodePatterns/Log.hpp" 51 #include "CodePatterns/Observer/Notification.hpp"52 51 #include "config.hpp" 53 52 #include "Descriptors/AtomIdDescriptor.hpp" … … 147 146 OBSERVE; 148 147 if(atomIdPool.reserveId(newNr)){ 149 _lastchangedatom = target;150 148 NOTIFY(AtomNrChanged); 151 149 if (oldNr != -1) // -1 is reserved and indicates no number … … 209 207 { 210 208 OBSERVE; 209 NOTIFY(AtomRemoved); 211 210 const_iterator iter = loc; 212 211 ++iter; 213 212 atom * const _atom = const_cast<atom *>(*loc); 214 {215 _lastchangedatom = _atom;216 NOTIFY(AtomRemoved);217 }218 213 atomIds.erase( _atom->getId() ); 219 214 { … … 231 226 { 232 227 OBSERVE; 233 { 234 _lastchangedatom = key; 235 NOTIFY(AtomRemoved); 236 } 228 NOTIFY(AtomRemoved); 237 229 const_iterator iter = find(key); 238 230 if (iter != end()){ … … 255 247 OBSERVE; 256 248 NOTIFY(AtomInserted); 257 _lastchangedatom = key;258 249 std::pair<iterator,bool> res = atomIds.insert(key->getId()); 259 250 if (res.second) { // push atom if went well … … 646 637 /** Destroys all atoms inside this molecule. 647 638 */ 648 void removeAtomsinMolecule(molecule *&_mol)639 void molecule::removeAtomsinMolecule() 649 640 { 650 641 // remove each atom from world 651 for( molecule::iterator AtomRunner = _mol->begin(); !_mol->empty(); AtomRunner = _mol->begin())642 for(iterator AtomRunner = begin(); !empty(); AtomRunner = begin()) 652 643 World::getInstance().destroyAtom(*AtomRunner); 653 // make sure that pointer os not usable654 _mol = NULL;655 644 }; 656 645 … … 985 974 for(const_iterator iter = begin(); iter != end(); ++iter) 986 975 center += (*iter)->getPosition(); 987 if (begin() != end()) 988 center *= 1./(double)size(); 976 center *= 1./(double)size(); 989 977 for(const_iterator iter = begin(); iter != end(); ++iter) { 990 978 const Vector &position = (*iter)->getPosition(); … … 1007 995 } 1008 996 1009 void molecule::update(Observable *publisher)1010 {1011 ASSERT(0, "molecule::update() - did not sign on for any general updates.");1012 }1013 1014 void molecule::recieveNotification(Observable *publisher, Notification_ptr notification)1015 {1016 const atom * const _atom = dynamic_cast<atom *>(publisher);1017 if ((_atom != NULL) && containsAtom(_atom)) {1018 #ifdef LOG_OBSERVER1019 observerLog().addMessage() << "++ Update of Observer "<< observerLog().getName(static_cast<Observer *>(this))1020 << " received notification from atom " << _atom->getId() << " for channel "1021 << notification->getChannelNo() << ".";1022 #endif1023 switch (notification->getChannelNo()) {1024 case AtomObservable::PositionChanged:1025 {1026 // emit others about one of our atoms moved1027 _lastchangedatom = const_cast<atom *>(_atom);1028 OBSERVE;1029 NOTIFY(AtomMoved);1030 break;1031 }1032 default:1033 ASSERT( 0, "molecule::recieveNotification() - we did not sign up for channel "1034 +toString(notification->getChannelNo()));1035 break;1036 }1037 }1038 }1039 1040 void molecule::subjectKilled(Observable *publisher)1041 {1042 // do nothing, atom does it all1043 }1044 1045 1046 997 // construct idpool 1047 998 CONSTRUCT_IDPOOL(atomId_t, continuousId) -
src/molecule.hpp
r0ac85c3 r7b38d3 57 57 /************************************* Class definitions ****************************************/ 58 58 59 /** External function to remove all atoms since this will also delete the molecule60 *61 * \param _mol ref pointer to molecule to destroy62 */63 void removeAtomsinMolecule(molecule *&_mol);64 65 59 /** The complete molecule. 66 60 * Class incorporates number of types … … 111 105 AtomRemoved, 112 106 AtomNrChanged, 113 AtomMoved,114 107 MoleculeNameChanged, 115 108 NotificationType_MAX 116 109 }; 117 118 //>! access to last changed element (atom)119 const atom* lastChanged() const120 { return _lastchangedatom; }121 110 122 111 public: … … 268 257 bool UnlinkAtom(atom *pointer); 269 258 bool CleanupMolecule(); 259 void removeAtomsinMolecule(); 270 260 271 261 /// Add/remove atoms to/from molecule. … … 328 318 void flipActiveFlag(); 329 319 330 virtual void update(Observable *publisher);331 virtual void recieveNotification(Observable *publisher, Notification_ptr notification);332 virtual void subjectKilled(Observable *publisher);333 334 320 private: 335 friend const atom *detail::lastChanged<atom>();336 atom *_lastchangedatom;337 338 321 int last_atom; //!< number given to last atom 339 322 }; -
tests/regression/Atoms/Translation/testsuite-atoms-translation.at
r0ac85c3 r7b38d3 24 24 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Atoms/Translation/pre/test.xyz $file], 0) 25 25 AT_CHECK([chmod u+w $file], 0) 26 AT_CHECK([../../molecuilder -i $file --select-all-atoms - -translate-atoms --position"1,0,0"], 0, [stdout], [stderr])26 AT_CHECK([../../molecuilder -i $file --select-all-atoms -t "1,0,0"], 0, [stdout], [stderr]) 27 27 AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Atoms/Translation/post/test-shifted.xyz], 0, [ignore], [ignore]) 28 28 … … 36 36 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Atoms/Translation/pre/test.xyz $file], 0) 37 37 AT_CHECK([chmod u+w $file], 0) 38 AT_CHECK([../../molecuilder -i $file --select-all-atoms - -translate-atoms --position"1,0,0" --undo], 0, [stdout], [stderr])38 AT_CHECK([../../molecuilder -i $file --select-all-atoms -t "1,0,0" --undo], 0, [stdout], [stderr]) 39 39 AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Atoms/Translation/pre/test.xyz], 0, [ignore], [ignore]) 40 40 … … 48 48 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Atoms/Translation/pre/test.xyz $file], 0) 49 49 AT_CHECK([chmod u+w $file], 0) 50 AT_CHECK([../../molecuilder -i $file --select-all-atoms - -translate-atoms --position"1,0,0" --undo --redo], 0, [stdout], [stderr])50 AT_CHECK([../../molecuilder -i $file --select-all-atoms -t "1,0,0" --undo --redo], 0, [stdout], [stderr]) 51 51 AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Atoms/Translation/post/test-shifted.xyz], 0, [ignore], [ignore]) 52 52 -
tests/regression/Filling/SuspendInWater/pre/test.conf
r0ac85c3 r7b38d3 28 28 OutSrcStep 5 # Output "restart" data every ..th step 29 29 TargetTemp 0.000950045 # Target temperature 30 MaxPsiStep 3# number of Minimisation steps per state (0 - default)30 MaxPsiStep 0 # number of Minimisation steps per state (0 - default) 31 31 EpsWannier 1e-07 # tolerance value for spread minimisation of orbitals 32 32 … … 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 12# check every ..th steps38 MaxMinGapStopStep 1# check every ..th steps37 MaxMinStopStep 0 # check every ..th steps 38 MaxMinGapStopStep 0 # check every ..th steps 39 39 40 40 # Values specifying when to stop for INIT, otherwise same as above … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 12# check every ..th steps45 InitMaxMinGapStopStep 1# check every ..th steps44 InitMaxMinStopStep 0 # check every ..th steps 45 InitMaxMinGapStopStep 0 # check every ..th steps 46 46 47 47 BoxLength # (Length of a unit cell) … … 55 55 RiemannTensor 0 # (Use metric) 56 56 PsiType 0 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 MaxPsiDouble 12# here: specifying both maximum number of SpinUp- and -Down-states58 PsiMaxNoUp 12# here: specifying maximum number of SpinUp-states59 PsiMaxNoDown 12# here: specifying maximum number of SpinDown-states57 MaxPsiDouble 0 # here: specifying both maximum number of SpinUp- and -Down-states 58 PsiMaxNoUp 0 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 0 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 … … 64 64 IsAngstroem 1 # 0 - Bohr, 1 - Angstroem 65 65 RelativeCoord 0 # whether ion coordinates are relative (1) or absolute (0) 66 MaxTypes 3# maximum number of different ion types66 MaxTypes 2 # maximum number of different ion types 67 67 68 68 # Ion type data (PP = PseudoPotential, Z = atomic number) 69 69 #Ion_TypeNr. Amount Z RGauss L_Max(PP)L_Loc(PP)IonMass # chemical name, symbol 70 Ion_Type1 101 1.0 3 3 1.00800000000 Hydrogen H70 Ion_Type1 8 1 1.0 3 3 1.00800000000 Hydrogen H 71 71 Ion_Type2 3 6 1.0 3 3 12.01100000000 Carbon C 72 Ion_Type3 1 8 1.0 3 3 15.99900000000 Oxygen O73 72 #Ion_TypeNr._Nr.R[0] R[1] R[2] MoveType (0 MoveIon, 1 FixedIon) 74 Ion_Type1_1 9.782085945 2.645886050 2.645886050 0 # molecule nr 0 75 Ion_Type1_2 9.782085945 2.645886050 4.425886024 0 # molecule nr 1 76 Ion_Type1_3 10.672039608 3.904536878 3.535886037 0 # molecule nr 2 77 Ion_Type1_4 8.532785963 4.787886018 2.645886050 0 # molecule nr 3 78 Ion_Type1_5 8.532785963 4.787886018 4.425886024 0 # molecule nr 4 79 Ion_Type1_6 6.393632318 3.904536877 3.535886037 0 # molecule nr 5 80 Ion_Type1_7 7.283585982 2.645886050 2.645886050 0 # molecule nr 6 81 Ion_Type1_8 7.283585982 2.645886050 4.425886024 0 # molecule nr 7 82 Ion_Type2_1 9.782085945 3.275186040 3.535886037 0 # molecule nr 8 83 Ion_Type2_2 8.532785963 4.158586027 3.535886037 0 # molecule nr 9 84 Ion_Type2_3 7.283585982 3.275186040 3.535886037 0 # molecule nr 10 85 Ion_Type3_1 2.000000000 2.000000000 2.000000000 0 # molecule nr 11 86 Ion_Type1_9 2.758602000 2.000000000 2.504284000 0 # molecule nr 12 87 Ion_Type1_10 2.758602000 2.000000000 1.495716000 0 # molecule nr 13 73 Ion_Type2_1 9.782085945 3.275186040 3.535886037 0 # molecule nr 0 74 Ion_Type2_2 8.532785963 4.158586027 3.535886037 0 # molecule nr 1 75 Ion_Type2_3 7.283585982 3.275186040 3.535886037 0 # molecule nr 2 76 Ion_Type1_1 9.782085945 2.645886050 2.645886050 0 # molecule nr 3 77 Ion_Type1_2 9.782085945 2.645886050 4.425886024 0 # molecule nr 4 78 Ion_Type1_3 10.672039608 3.904536878 3.535886037 0 # molecule nr 5 79 Ion_Type1_4 8.532785963 4.787886018 2.645886050 0 # molecule nr 6 80 Ion_Type1_5 8.532785963 4.787886018 4.425886024 0 # molecule nr 7 81 Ion_Type1_6 6.393632318 3.904536877 3.535886037 0 # molecule nr 8 82 Ion_Type1_7 7.283585982 2.645886050 2.645886050 0 # molecule nr 9 83 Ion_Type1_8 7.283585982 2.645886050 4.425886024 0 # molecule nr 10 -
tests/regression/Filling/SuspendInWater/testsuite-suspend-in-water.at
r0ac85c3 r7b38d3 18 18 ### suspend in water with certain density 19 19 20 AT_SETUP([Filling - suspend in water fails with rho=1]) 20 AT_SETUP([Filling - suspend in water]) 21 AT_XFAIL_IF([/bin/true]) 21 22 AT_KEYWORDS([filling suspend-in-water]) 22 23 … … 24 25 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/pre/test.conf $file], 0) 25 26 AT_CHECK([chmod u+w $file], 0) 26 AT_CHECK([../../molecuilder -i $file -I -v 3 --select-molecule-by-id 0 -u --density 1.], 5, [stdout], [stderr]) 27 AT_CHECK([../../molecuilder -i $file -v 3 --select-molecule-by-id 0 -u 1.3], 0, [stdout], [stderr]) 28 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/post/test.conf], 0, [ignore], [ignore]) 27 29 28 30 AT_CLEANUP 29 31 30 AT_SETUP([Filling - suspend in water fails with just one molecule])31 AT_KEYWORDS([filling suspend-in-water])32 33 file=single_molecule.conf34 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/pre/$file $file], 0)35 AT_CHECK([chmod u+w $file], 0)36 AT_CHECK([../../molecuilder -i $file -I -v 3 --select-molecule-by-id 0 -u --density 1.], 5, [stdout], [stderr])37 AT_CHECK([grep "at least two molecules" stdout], 0, [ignore], [ignore])38 39 AT_CLEANUP40 41 # rho must be on same side of 1 as the present density42 AT_SETUP([Filling - suspend in water fails with wrong rho])43 AT_KEYWORDS([filling suspend-in-water])44 45 file=test.conf46 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/pre/$file $file], 0)47 AT_CHECK([chmod u+w $file], 0)48 AT_CHECK([../../molecuilder -i $file -I -v 3 --select-molecule-by-id 0 -u --density .5], 5, [stdout], [stderr])49 AT_CHECK([grep "Desired and present molecular densities must both be either" stdout], 0, [ignore], [ignore])50 51 AT_CLEANUP52 53 AT_SETUP([Filling - suspend in water])54 AT_XFAIL_IF([/bin/true])55 AT_KEYWORDS([filling suspend-in-water])56 57 file=test.conf58 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/pre/$file $file], 0)59 AT_CHECK([chmod u+w $file], 0)60 AT_CHECK([../../molecuilder -i $file -I -v 3 --select-molecule-by-id 0 -u --density 2.], 5, [stdout], [stderr])61 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/post/test.conf], 0, [ignore], [ignore])62 63 AT_CLEANUP64 32 65 33 AT_SETUP([Filling - suspend in water with Undo]) … … 70 38 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/pre/test.conf $file], 0) 71 39 AT_CHECK([chmod u+w $file], 0) 72 AT_CHECK([../../molecuilder -i $file -I -v 3 --select-molecule-by-id 0 -u --density 2.--undo], 0, [stdout], [stderr])40 AT_CHECK([../../molecuilder -i $file -v 3 --select-molecule-by-id 0 -u 1.3 --undo], 0, [stdout], [stderr]) 73 41 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/post/test.conf], 0, [ignore], [ignore]) 74 42 … … 83 51 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/pre/test.conf $file], 0) 84 52 AT_CHECK([chmod u+w $file], 0) 85 AT_CHECK([../../molecuilder -i $file -I -v 3 --select-molecule-by-id 0 -u --density 2.--undo --redo], 0, [stdout], [stderr])53 AT_CHECK([../../molecuilder -i $file -v 3 --select-molecule-by-id 0 -u 1.3 --undo --redo], 0, [stdout], [stderr]) 86 54 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Filling/SuspendInWater/post/test.conf], 0, [ignore], [ignore]) 87 55 -
tests/regression/Makefile.am
r0ac85c3 r7b38d3 98 98 $(srcdir)/Molecules/ForceAnnealing/testsuite-molecules-force-annealing.at \ 99 99 $(srcdir)/Molecules/LinearInterpolationofTrajectories/testsuite-molecules-linear-interpolation-of-trajectories.at \ 100 $(srcdir)/Molecules/Remove/testsuite-molecules-remove.at \101 100 $(srcdir)/Molecules/RotateAroundOrigin/testsuite-molecules-rotate-around-origin.at \ 102 101 $(srcdir)/Molecules/RotateAroundSelf/testsuite-molecules-rotate-around-self.at \ … … 202 201 $(srcdir)/Selection/Atoms/ClearAtoms/testsuite-selection-clear-atoms.at \ 203 202 $(srcdir)/Selection/Atoms/InvertAtoms/testsuite-selection-invert-atoms.at \ 204 $(srcdir)/Selection/Atoms/PopAtomSelection/testsuite-selection-pop-atom-selection.at \205 $(srcdir)/Selection/Atoms/PushAtomSelection/testsuite-selection-push-atom-selection.at \206 203 $(srcdir)/Selection/Molecules/testsuite-selection-molecules.at \ 207 204 $(srcdir)/Selection/Molecules/AllMolecules/testsuite-selection-select-all-molecules.at \ … … 221 218 $(srcdir)/Selection/Molecules/MoleculeOfAtom/testsuite-selection-select-atoms-molecules.at \ 222 219 $(srcdir)/Selection/Molecules/MoleculeOfAtom/testsuite-selection-unselect-atoms-molecules.at \ 223 $(srcdir)/Selection/Molecules/PopMoleculeSelection/testsuite-selection-pop-molecule-selection.at \224 $(srcdir)/Selection/Molecules/PushMoleculeSelection/testsuite-selection-push-molecule-selection.at \225 220 $(srcdir)/Tesselation/testsuite-tesselation.at \ 226 221 $(srcdir)/Tesselation/BigConvex/testsuite-tesselation-big-convex-envelope.at \ -
tests/regression/Molecules/Translation-Periodic/testsuite-molecules-translation-periodic.at
r0ac85c3 r7b38d3 1 1 # 2 2 # MoleCuilder - creates and alters molecular systems 3 # Copyright (C) 20 14 Frederik Heber3 # Copyright (C) 2008-2012 University of Bonn 4 4 # 5 5 # This program is free software: you can redistribute it and/or modify … … 19 19 20 20 AT_SETUP([Molecules - Translation with periodic boundaries]) 21 AT_KEYWORDS([molecules translate- molecules])21 AT_KEYWORDS([molecules translate-atoms]) 22 22 23 23 file=test.conf 24 24 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/Translation-Periodic/pre/test.conf $file], 0) 25 25 AT_CHECK([chmod u+w $file], 0) 26 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 -- translate-molecules --position"-8., -8., -8." --periodic 1], 0, [stdout], [stderr])26 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 --select-molecules-atoms -t "-8., -8., -8." --periodic 1], 0, [stdout], [stderr]) 27 27 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/Translation-Periodic/post/test.conf], 0, [ignore], [ignore]) 28 28 … … 31 31 32 32 AT_SETUP([Molecules - Translation with periodic boundaries with Undo]) 33 AT_KEYWORDS([molecules translate- molecules undo])33 AT_KEYWORDS([molecules translate-atoms undo]) 34 34 35 35 file=test.conf 36 36 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/Translation-Periodic/pre/test.conf $file], 0) 37 37 AT_CHECK([chmod u+w $file], 0) 38 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 -- translate-molecules --position"-8., -8., -8." --periodic 1 --undo], 0, [stdout], [stderr])38 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 --select-molecules-atoms -t "-8., -8., -8." --periodic 1 --undo], 0, [stdout], [stderr]) 39 39 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/Translation-Periodic/post/test-undo.conf], 0, [ignore], [ignore]) 40 40 … … 43 43 44 44 AT_SETUP([Molecules - Translation with periodic boundaries with Redo]) 45 AT_KEYWORDS([molecules translate- molecules redo])45 AT_KEYWORDS([molecules translate-atoms redo]) 46 46 47 47 file=test.conf 48 48 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/Translation-Periodic/pre/test.conf $file], 0) 49 49 AT_CHECK([chmod u+w $file], 0) 50 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 -- translate-molecules --position"-8., -8., -8." --periodic 1 --undo --redo], 0, [stdout], [stderr])50 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 --select-molecules-atoms -t "-8., -8., -8." --periodic 1 --undo --redo], 0, [stdout], [stderr]) 51 51 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/Translation-Periodic/post/test.conf], 0, [ignore], [ignore]) 52 52 -
tests/regression/Molecules/Translation/testsuite-molecules-translation.at
r0ac85c3 r7b38d3 1 1 # 2 2 # MoleCuilder - creates and alters molecular systems 3 # Copyright (C) 20 14 Frederik Heber3 # Copyright (C) 2008-2012 University of Bonn 4 4 # 5 5 # This program is free software: you can redistribute it and/or modify … … 19 19 20 20 AT_SETUP([Molecules - Translation]) 21 AT_KEYWORDS([molecules translate- molecules])21 AT_KEYWORDS([molecules translate-atoms]) 22 22 23 23 file=test.conf 24 24 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/Translation/pre/test.conf $file], 0) 25 25 AT_CHECK([chmod u+w $file], 0) 26 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 -- translate-molecules --position"1., 1., 1." --periodic 0], 0, [stdout], [stderr])26 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 --select-molecules-atoms -t "1., 1., 1." --periodic 0], 0, [stdout], [stderr]) 27 27 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/Translation/post/test.conf], 0, [ignore], [ignore]) 28 28 … … 30 30 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/Translation/pre/test2.conf $file], 0) 31 31 AT_CHECK([chmod u+w $file], 0) 32 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 -- translate-molecules --position"-1., -1., -1." --periodic 0], 0, [stdout], [stderr])32 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 --select-molecules-atoms -t "-1., -1., -1." --periodic 0], 0, [stdout], [stderr]) 33 33 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/Translation/post/test2.conf], 0, [ignore], [ignore]) 34 34 … … 37 37 38 38 AT_SETUP([Molecules - Translation with Undo]) 39 AT_KEYWORDS([molecules translate- molecules undo])39 AT_KEYWORDS([molecules translate-atoms undo]) 40 40 41 41 file=test.conf 42 42 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/Translation/pre/test.conf $file], 0) 43 43 AT_CHECK([chmod u+w $file], 0) 44 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 -- translate-molecules --position"1., 1., 1." --periodic 0 --undo], 0, [stdout], [stderr])44 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 --select-molecules-atoms -t "1., 1., 1." --periodic 0 --undo], 0, [stdout], [stderr]) 45 45 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/Translation/post/test-undo.conf], 0, [ignore], [ignore]) 46 46 … … 48 48 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/Translation/pre/test2.conf $file], 0) 49 49 AT_CHECK([chmod u+w $file], 0) 50 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 -- translate-molecules --position"-1., -1., -1." --periodic 0 --undo], 0, [stdout], [stderr])50 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 --select-molecules-atoms -t "-1., -1., -1." --periodic 0 --undo], 0, [stdout], [stderr]) 51 51 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/Translation/post/test2-undo.conf], 0, [ignore], [ignore]) 52 52 … … 55 55 56 56 AT_SETUP([Molecules - Translation with Redo]) 57 AT_KEYWORDS([molecules translate- molecules redo])57 AT_KEYWORDS([molecules translate-atoms redo]) 58 58 59 59 file=test.conf 60 60 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/Translation/pre/test.conf $file], 0) 61 61 AT_CHECK([chmod u+w $file], 0) 62 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 -- translate-molecules --position"1., 1., 1." --periodic 0 --undo --redo], 0, [stdout], [stderr])62 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 --select-molecules-atoms -t "1., 1., 1." --periodic 0 --undo --redo], 0, [stdout], [stderr]) 63 63 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/Translation/post/test.conf], 0, [ignore], [ignore]) 64 64 … … 66 66 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/Translation/pre/test2.conf $file], 0) 67 67 AT_CHECK([chmod u+w $file], 0) 68 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 -- translate-molecules --position"-1., -1., -1." --periodic 0 --undo --redo], 0, [stdout], [stderr])68 AT_CHECK([../../molecuilder -i $file --select-molecule-by-id 0 --select-molecules-atoms -t "-1., -1., -1." --periodic 0 --undo --redo], 0, [stdout], [stderr]) 69 69 AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/Translation/post/test2.conf], 0, [ignore], [ignore]) 70 70 -
tests/regression/Molecules/testsuite-molecules.at
r0ac85c3 r7b38d3 54 54 m4_include([Molecules/Translation-Periodic/testsuite-molecules-translation-periodic.at]) 55 55 56 # remove whole molecules57 m4_include([Molecules/Remove/testsuite-molecules-remove.at])58 59 56 # Rotate to Principal Axis System 60 57 m4_include([Molecules/RotateToPrincipalAxisSystem/testsuite-molecules-rotate-to-principal-axis-system.at]) -
tests/regression/Options/InvalidCommands/testsuite-options-invalid-commands.at
r0ac85c3 r7b38d3 24 24 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Options/InvalidCommands/pre/test.conf $file], 0) 25 25 AT_CHECK([chmod u+w $file], 0) 26 AT_CHECK([../../molecuilder -i $file -t], 134, [ignore], [stderr]) 26 27 AT_CHECK([../../molecuilder -i $file -s -b -E -c -b -a], 134, [ignore], [stderr]) 27 28 AT_CHECK([../../molecuilder -i $file -b -E -c -b -a], 134, [ignore], [stderr]) -
tests/regression/Parser/Mpqc/testsuite-parser-mpqc-load-multiply.at
r0ac85c3 r7b38d3 24 24 destfile=doublewater.in 25 25 AT_CHECK([../../molecuilder -i $destfile -o mpqc -l ${abs_top_srcdir}/tests/regression/Parser/Mpqc/pre/$srcfile], 0, [ignore], [ignore]) 26 AT_CHECK([../../molecuilder -i $destfile -l ${abs_top_srcdir}/tests/regression/Parser/Mpqc/pre/$srcfile --select-molecule-by-order -1 --select-molecules-atoms --translate-atoms --position"2,0,0"], 0, [ignore], [ignore])26 AT_CHECK([../../molecuilder -i $destfile -l ${abs_top_srcdir}/tests/regression/Parser/Mpqc/pre/$srcfile --select-molecule-by-order -1 --select-molecules-atoms --translate-atoms "2,0,0"], 0, [ignore], [ignore]) 27 27 AT_CHECK([diff -I '%.*' $destfile ${abs_top_srcdir}/tests/regression/Parser/Mpqc/post/$destfile], 0, [ignore], [ignore]) 28 28 -
tests/regression/Parser/Pcp/testsuite-parser-pcp-load-multiply.at
r0ac85c3 r7b38d3 24 24 destfile=doublewater.conf 25 25 AT_CHECK([../../molecuilder -i $destfile -o pcp -l ${abs_top_srcdir}/tests/regression/Parser/Pcp/pre/$srcfile], 0, [ignore], [ignore]) 26 AT_CHECK([../../molecuilder -i $destfile -l ${abs_top_srcdir}/tests/regression/Parser/Pcp/pre/$srcfile --select-molecule-by-order -1 --select-molecules-atoms --translate-atoms --position"2,0,0"], 0, [ignore], [ignore])26 AT_CHECK([../../molecuilder -i $destfile -l ${abs_top_srcdir}/tests/regression/Parser/Pcp/pre/$srcfile --select-molecule-by-order -1 --select-molecules-atoms --translate-atoms "2,0,0"], 0, [ignore], [ignore]) 27 27 AT_CHECK([diff $destfile ${abs_top_srcdir}/tests/regression/Parser/Pcp/post/$destfile], 0, [ignore], [ignore]) 28 28 -
tests/regression/Parser/Pdb/testsuite-parser-pdb-load-multiply.at
r0ac85c3 r7b38d3 24 24 destfile=doublewater.pdb 25 25 AT_CHECK([../../molecuilder -i $destfile -o pdb -l ${abs_top_srcdir}/tests/regression/Parser/Pdb/pre/$srcfile], 0, [ignore], [ignore]) 26 AT_CHECK([../../molecuilder -i $destfile -l ${abs_top_srcdir}/tests/regression/Parser/Pdb/pre/$srcfile --select-molecule-by-order -1 --select-molecules-atoms --translate-atoms --position"2,0,0"], 0, [ignore], [ignore])26 AT_CHECK([../../molecuilder -i $destfile -l ${abs_top_srcdir}/tests/regression/Parser/Pdb/pre/$srcfile --select-molecule-by-order -1 --select-molecules-atoms --translate-atoms "2,0,0"], 0, [ignore], [ignore]) 27 27 AT_CHECK([diff -I 'REMARK.*' $destfile ${abs_top_srcdir}/tests/regression/Parser/Pdb/post/$destfile], 0, [ignore], [ignore]) 28 28 -
tests/regression/Parser/Psi3/testsuite-parser-psi3-load-multiply.at
r0ac85c3 r7b38d3 24 24 destfile=doublewater.psi 25 25 AT_CHECK([../../molecuilder -i $destfile -o psi3 -l ${abs_top_srcdir}/tests/regression/Parser/Psi3/pre/$srcfile], 0, [ignore], [ignore]) 26 AT_CHECK([../../molecuilder -i $destfile -l ${abs_top_srcdir}/tests/regression/Parser/Psi3/pre/$srcfile --select-molecule-by-order -1 --select-molecules-atoms --translate-atoms --position"2,0,0"], 0, [ignore], [ignore])26 AT_CHECK([../../molecuilder -i $destfile -l ${abs_top_srcdir}/tests/regression/Parser/Psi3/pre/$srcfile --select-molecule-by-order -1 --select-molecules-atoms --translate-atoms "2,0,0"], 0, [ignore], [ignore]) 27 27 AT_CHECK([diff -w -I '%.*' $destfile ${abs_top_srcdir}/tests/regression/Parser/Psi3/post/$destfile], 0, [ignore], [ignore]) 28 28 -
tests/regression/Parser/Tremolo/testsuite-parser-tremolo-load-multiply.at
r0ac85c3 r7b38d3 25 25 destfile=doublewater.data 26 26 AT_CHECK([../../molecuilder -i $destfile -o tremolo -l ${abs_top_srcdir}/tests/regression/Parser/Tremolo/pre/$srcfile], 0, [ignore], [ignore]) 27 AT_CHECK([../../molecuilder -i $destfile -l ${abs_top_srcdir}/tests/regression/Parser/Tremolo/pre/$srcfile --select-molecule-by-order -1 --select-molecules-atoms --translate-atoms --position"2,0,0"], 0, [ignore], [ignore])27 AT_CHECK([../../molecuilder -i $destfile -l ${abs_top_srcdir}/tests/regression/Parser/Tremolo/pre/$srcfile --select-molecule-by-order -1 --select-molecules-atoms --translate-atoms "2,0,0"], 0, [ignore], [ignore]) 28 28 AT_CHECK([diff -w -I '#.*' $destfile ${abs_top_srcdir}/tests/regression/Parser/Tremolo/post/$destfile], 0, [ignore], [ignore]) 29 29 -
tests/regression/Parser/Xyz/testsuite-parser-xyz-load-multiply.at
r0ac85c3 r7b38d3 24 24 destfile=doublewater.xyz 25 25 AT_CHECK([../../molecuilder -i $destfile -o xyz -l ${abs_top_srcdir}/tests/regression/Parser/Xyz/pre/$srcfile], 0, [ignore], [ignore]) 26 AT_CHECK([../../molecuilder -i $destfile -l ${abs_top_srcdir}/tests/regression/Parser/Xyz/pre/$srcfile --select-molecule-by-order -1 --select-molecules-atoms --translate-atoms --position"2,0,0"], 0, [ignore], [ignore])26 AT_CHECK([../../molecuilder -i $destfile -l ${abs_top_srcdir}/tests/regression/Parser/Xyz/pre/$srcfile --select-molecule-by-order -1 --select-molecules-atoms --translate-atoms "2,0,0"], 0, [ignore], [ignore]) 27 27 AT_CHECK([diff -I '.*Created by molecuilder.*' $destfile ${abs_top_srcdir}/tests/regression/Parser/Xyz/post/$destfile], 0, [ignore], [ignore]) 28 28 -
tests/regression/Selection/Atoms/testsuite-selection-atoms.at
r0ac85c3 r7b38d3 59 59 m4_include(Selection/Atoms/InvertAtoms/testsuite-selection-invert-atoms.at) 60 60 61 # push atom selection62 m4_include(Selection/Atoms/PushAtomSelection/testsuite-selection-push-atom-selection.at)63 64 # pop atom selection65 m4_include(Selection/Atoms/PopAtomSelection/testsuite-selection-pop-atom-selection.at) -
tests/regression/Selection/Molecules/MoleculeById/testsuite-selection-select-molecule-by-id.at
r0ac85c3 r7b38d3 25 25 srcfile=box.xyz 26 26 testfile=test.xyz 27 targetfile=water_id 2_4.xyz27 targetfile=water_id4.xyz 28 28 AT_CHECK([cp -n ${regressionpath}/pre/$srcfile $testfile], 0) 29 AT_CHECK([../../molecuilder -i $testfile -I --select-molecule-by-id 24 -s $targetfile], 0, [stdout], [stderr])29 AT_CHECK([../../molecuilder -i $testfile -I --select-molecule-by-id 4 -s $targetfile], 0, [stdout], [stderr]) 30 30 AT_CHECK([diff -I '.*Created by molecuilder.*' $targetfile ${regressionpath}/post/$targetfile], 0, [ignore], [ignore]) 31 31 … … 41 41 targetfile=empty.xyz 42 42 AT_CHECK([cp -n ${regressionpath}/pre/$srcfile $testfile], 0) 43 AT_CHECK([../../molecuilder -i $testfile -I --select-molecule-by-id 24 --undo -s $targetfile], 0, [stdout], [stderr])43 AT_CHECK([../../molecuilder -i $testfile -I --select-molecule-by-id 4 --undo -s $targetfile], 0, [stdout], [stderr]) 44 44 AT_CHECK([diff -I '.*Created by molecuilder.*' $targetfile ${regressionpath}/post/$targetfile], 0, [ignore], [ignore]) 45 45 … … 53 53 srcfile=box.xyz 54 54 testfile=test.xyz 55 targetfile=water_id 2_4.xyz55 targetfile=water_id4.xyz 56 56 AT_CHECK([cp -n ${regressionpath}/pre/$srcfile $testfile], 0) 57 AT_CHECK([../../molecuilder -i $testfile -I --select-molecule-by-id 24 --undo --redo -s $targetfile], 0, [stdout], [stderr])57 AT_CHECK([../../molecuilder -i $testfile -I --select-molecule-by-id 4 --undo --redo -s $targetfile], 0, [stdout], [stderr]) 58 58 AT_CHECK([diff -I '.*Created by molecuilder.*' $targetfile ${regressionpath}/post/$targetfile], 0, [ignore], [ignore]) 59 59 -
tests/regression/Selection/Molecules/MoleculeById/testsuite-selection-unselect-molecule-by-id.at
r0ac85c3 r7b38d3 25 25 srcfile=box.xyz 26 26 testfile=test.xyz 27 targetfile=id 2_4_missing.xyz27 targetfile=id4_missing.xyz 28 28 AT_CHECK([cp -n ${regressionpath}/pre/$srcfile $testfile], 0) 29 AT_CHECK([../../molecuilder -i $testfile -I --select-all-molecules --unselect-molecule-by-id 24 -s $targetfile], 0, [stdout], [stderr])29 AT_CHECK([../../molecuilder -i $testfile -I --select-all-molecules --unselect-molecule-by-id 4 -s $targetfile], 0, [stdout], [stderr]) 30 30 AT_CHECK([diff -I '.*Created by molecuilder.*' $targetfile ${regressionpath}/post/$targetfile], 0, [ignore], [ignore]) 31 31 … … 41 41 targetfile=box.xyz 42 42 AT_CHECK([cp -n ${regressionpath}/pre/$srcfile $testfile], 0) 43 AT_CHECK([../../molecuilder -i $testfile -I --select-all-molecules --unselect-molecule-by-id 24 --undo -s $targetfile], 0, [stdout], [stderr])43 AT_CHECK([../../molecuilder -i $testfile -I --select-all-molecules --unselect-molecule-by-id 4 --undo -s $targetfile], 0, [stdout], [stderr]) 44 44 AT_CHECK([diff -I '.*Created by molecuilder.*' $targetfile ${regressionpath}/post/$targetfile], 0, [ignore], [ignore]) 45 45 … … 53 53 srcfile=box.xyz 54 54 testfile=test.xyz 55 targetfile=id 2_4_missing.xyz55 targetfile=id4_missing.xyz 56 56 AT_CHECK([cp -n ${regressionpath}/pre/$srcfile $testfile], 0) 57 AT_CHECK([../../molecuilder -i $testfile -I --select-all-molecules --unselect-molecule-by-id 24 --undo --redo -s $targetfile], 0, [stdout], [stderr])57 AT_CHECK([../../molecuilder -i $testfile -I --select-all-molecules --unselect-molecule-by-id 4 --undo --redo -s $targetfile], 0, [stdout], [stderr]) 58 58 AT_CHECK([diff -I '.*Created by molecuilder.*' $targetfile ${regressionpath}/post/$targetfile], 0, [ignore], [ignore]) 59 59 -
tests/regression/Selection/Molecules/testsuite-selection-molecules.at
r0ac85c3 r7b38d3 52 52 m4_include(Selection/Molecules/InvertMolecules/testsuite-selection-invert-molecules.at) 53 53 54 # push molecule selection55 m4_include(Selection/Molecules/PushMoleculeSelection/testsuite-selection-push-molecule-selection.at)56 57 # pop molecule selection58 m4_include(Selection/Molecules/PopMoleculeSelection/testsuite-selection-pop-molecule-selection.at)
Note:
See TracChangeset
for help on using the changeset viewer.