Changeset 57ee0d
- Timestamp:
- Jan 21, 2010, 2:01:16 PM (15 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 6adb96
- Parents:
- f8879d
- Location:
- src
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Makefile.am
rf8879d r57ee0d 20 20 UIHEADER = ${ACTIONSHEADER} ${VIEWHEADER} ${MENUHEADER} UIElements/UIFactory.hpp UIElements/TextUIFactory.hpp UIElements/MainWindow.hpp UIElements/TextWindow.hpp UIElements/Dialog.hpp UIElements/TextDialog.hpp 21 21 22 QTUIMOC_HEADER = UIElements/QT4/QTMainWindow.hpp UIElements/QT4/QTDialog.hpp Menu/QT4/QTMenu.hpp 23 QTUIMOC_TARGETS = QTMainWindow.moc.cpp QTMenu.moc.cpp QTDialog.moc.cpp 22 QTUIMOC_HEADER = UIElements/QT4/QTMainWindow.hpp UIElements/QT4/QTDialog.hpp Menu/QT4/QTMenu.hpp Views/QT4/QTMoleculesView.hpp 23 QTUIMOC_TARGETS = QTMainWindow.moc.cpp QTMenu.moc.cpp QTDialog.moc.cpp QTMoleculesView.moc.cpp 24 24 25 QTUISOURCE = ${QTUIMOC_TARGETS} UIElements/QT4/QTMainWindow.cpp UIElements/QT4/QTDialog.cpp UIElements/QT4/QTUIFactory.cpp Menu/QT4/QTMenu.cpp 25 QTUISOURCE = ${QTUIMOC_TARGETS} UIElements/QT4/QTMainWindow.cpp UIElements/QT4/QTDialog.cpp UIElements/QT4/QTUIFactory.cpp Menu/QT4/QTMenu.cpp Views/QT4/QTMoleculesView.cpp 26 26 QTUIHEADER = ${QTUIMOC_HEADER} UIElements/QT4/QTUIFactory.hpp 27 27 -
src/Patterns/Observer.hpp
rf8879d r57ee0d 32 32 class Observer 33 33 { 34 friend class Observable; 34 35 public: 35 36 Observer(); 36 37 virtual ~Observer(); 37 38 39 protected: 38 40 virtual void update(Observable *publisher)=0; 39 41 virtual void subjectKilled(Observable *publisher)=0; … … 48 50 virtual void signOff(Observer *target); 49 51 52 protected: 50 53 virtual void update(Observable *publisher); 51 54 virtual void subjectKilled(Observable *publisher); 52 55 53 private:54 56 virtual void notifyAll(); 55 57 protected: 56 // Observer mechanism enis done from a static central place58 // Observer mechanism is done from a static central place 57 59 /** 58 60 * Internal method. -
src/UIElements/QT4/QTMainWindow.cpp
rf8879d r57ee0d 19 19 #include "molecule.hpp" 20 20 #include "Menu/QT4/QTMenu.hpp" 21 #include "Views/ StreamStringView.hpp"21 #include "Views/QT4/QTMoleculesView.hpp" 22 22 23 23 … … 27 27 theApp(_theApp) 28 28 { 29 moleculeView = new StreamStringView(boost::bind(&MoleculeListClass::Enumerate,molecules,_1)); 30 moleculeDisplay = new QLabel(QString(moleculeView->toString().c_str())); 29 moleculeDisplay = new QTMoleculesView(molecules,this); 31 30 setCentralWidget(moleculeDisplay); 32 31 -
src/UIElements/QT4/QTMainWindow.hpp
rf8879d r57ee0d 12 12 #include <Qt/qmainwindow.h> 13 13 14 class Q Label;14 class QTMoleculesView; 15 15 class StringView; 16 16 class QTMenu; … … 30 30 // All kinds of QTStuff used in this window 31 31 QApplication *theApp; 32 Q Label*moleculeDisplay;32 QTMoleculesView *moleculeDisplay; 33 33 QTMenu *editMoleculesMenu; 34 35 // All kinds of internal stuff that is bridged to QT36 StringView *moleculeView;37 34 38 35 }; -
src/molecule.hpp
rf8879d r57ee0d 30 30 #include "stackclass.hpp" 31 31 #include "tesselation.hpp" 32 #include "Patterns/Observer.hpp" 32 33 33 34 /****************************************** forward declarations *****************************/ … … 308 309 /** A list of \a molecule classes. 309 310 */ 310 class MoleculeListClass {311 class MoleculeListClass : public Observable { 311 312 public: 312 313 MoleculeList ListOfMolecules; //!< List of the contained molecules -
src/moleculelist.cpp
rf8879d r57ee0d 852 852 853 853 void MoleculeListClass::createNewMolecule(periodentafel *periode) { 854 START_OBSERVER; 854 855 molecule *mol = NULL; 855 856 mol = new molecule(periode); 856 857 insert(mol); 858 FINISH_OBSERVER; 857 859 }; 858 860 -
src/unittests/ObserverTest.cpp
rf8879d r57ee0d 86 86 87 87 void ObserverTest::setUp() { 88 simpleObservable = new SimpleObservable(); 88 simpleObservable1 = new SimpleObservable(); 89 simpleObservable2 = new SimpleObservable(); 89 90 callObservable = new CallObservable(); 90 91 superObservable = new SuperObservable(); … … 93 94 observer2 = new UpdateCountObserver(); 94 95 observer3 = new UpdateCountObserver(); 96 observer4 = new UpdateCountObserver(); 95 97 } 96 98 97 99 void ObserverTest::tearDown() { 98 delete simpleObservable; 100 delete simpleObservable1; 101 delete simpleObservable2; 99 102 delete callObservable; 100 103 delete superObservable; … … 103 106 delete observer2; 104 107 delete observer3; 108 delete observer4; 105 109 } 106 110 107 111 void ObserverTest::doesUpdateTest() 108 112 { 109 simpleObservable->signOn(observer1); 110 simpleObservable->signOn(observer2); 111 simpleObservable->signOn(observer3); 112 113 simpleObservable->changeMethod(); 113 simpleObservable1->signOn(observer1); 114 simpleObservable1->signOn(observer2); 115 simpleObservable1->signOn(observer3); 116 simpleObservable2->signOn(observer2); 117 simpleObservable2->signOn(observer4); 118 119 simpleObservable1->changeMethod(); 114 120 CPPUNIT_ASSERT_EQUAL( 1, observer1->updates ); 115 121 CPPUNIT_ASSERT_EQUAL( 1, observer2->updates ); 116 122 CPPUNIT_ASSERT_EQUAL( 1, observer3->updates ); 117 118 simpleObservable->signOff(observer3); 119 120 simpleObservable->changeMethod(); 123 CPPUNIT_ASSERT_EQUAL( 0, observer4->updates ); 124 125 simpleObservable1->signOff(observer3); 126 127 simpleObservable1->changeMethod(); 121 128 CPPUNIT_ASSERT_EQUAL( 2, observer1->updates ); 122 129 CPPUNIT_ASSERT_EQUAL( 2, observer2->updates ); 123 130 CPPUNIT_ASSERT_EQUAL( 1, observer3->updates ); 131 CPPUNIT_ASSERT_EQUAL( 0, observer4->updates ); 132 133 simpleObservable2->changeMethod(); 134 CPPUNIT_ASSERT_EQUAL( 2, observer1->updates ); 135 CPPUNIT_ASSERT_EQUAL( 3, observer2->updates ); 136 CPPUNIT_ASSERT_EQUAL( 1, observer3->updates ); 137 CPPUNIT_ASSERT_EQUAL( 1, observer4->updates ); 124 138 } 125 139 … … 155 169 cout << "If this test does not complete in a few seconds, kill the test-suite and fix the Error in the circle detection mechanism" << endl; 156 170 157 cout << endl << endl << "The following error displayed by the observer framwork can be ignored" << endl;171 cout << endl << endl << "The following errors displayed by the observer framework can be ignored" << endl; 158 172 159 173 // make this Observable its own subject. NEVER DO THIS IN ACTUAL CODE 160 simpleObservable->signOn(simpleObservable); 161 simpleObservable->changeMethod(); 174 simpleObservable1->signOn(simpleObservable1); 175 simpleObservable1->changeMethod(); 176 177 // more complex test 178 simpleObservable1->signOff(simpleObservable1); 179 simpleObservable1->signOn(simpleObservable2); 180 simpleObservable2->signOn(simpleObservable1); 181 simpleObservable1->changeMethod(); 182 simpleObservable1->signOff(simpleObservable2); 183 simpleObservable2->signOff(simpleObservable1); 162 184 // when we reach this line, although we broke the DAG assumption the circle check works fine 163 185 CPPUNIT_ASSERT(true); -
src/unittests/ObserverTest.hpp
rf8879d r57ee0d 40 40 UpdateCountObserver *observer2; 41 41 UpdateCountObserver *observer3; 42 UpdateCountObserver *observer4; 42 43 43 SimpleObservable *simpleObservable; 44 SimpleObservable *simpleObservable1; 45 SimpleObservable *simpleObservable2; 44 46 CallObservable *callObservable; 45 47 SuperObservable *superObservable;
Note:
See TracChangeset
for help on using the changeset viewer.