Changeset d5f216


Ignore:
Timestamp:
Feb 2, 2010, 12:00:19 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
bfce50
Parents:
63c1f6
git-author:
Tillmann Crueger <crueger@…> (01/21/10 14:01:16)
git-committer:
Tillmann Crueger <crueger@…> (02/02/10 12:00:19)
Message:

Added a view that displays all molecules using a QTableWidget

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Makefile.am

    r63c1f6 rd5f216  
    2222UISOURCE = ${ACTIONSSOURCE} ${VIEWSOURCE} ${MENUSOURCE} UIElements/UIFactory.cpp UIElements/TextUIFactory.cpp UIElements/MainWindow.cpp UIElements/TextWindow.cpp UIElements/Dialog.cpp UIElements/TextDialog.cpp
    2323UIHEADER = ${ACTIONSHEADER} ${VIEWHEADER} ${MENUHEADER} UIElements/UIFactory.hpp UIElements/TextUIFactory.hpp UIElements/MainWindow.hpp UIElements/TextWindow.hpp UIElements/Dialog.hpp UIElements/TextDialog.hpp
    24 
    2524
    2625SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} ${PATTERNSOURCE} ${UISOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp menu.cpp
  • src/Patterns/Observer.hpp

    r63c1f6 rd5f216  
    3232class Observer
    3333{
     34  friend class Observable;
    3435public:
    3536  Observer();
    3637  virtual ~Observer();
    3738
     39protected:
    3840  virtual void update(Observable *publisher)=0;
    3941  virtual void subjectKilled(Observable *publisher)=0;
     
    4850  virtual void signOff(Observer *target);
    4951
     52protected:
    5053  virtual void update(Observable *publisher);
    5154  virtual void subjectKilled(Observable *publisher);
    5255
    53 private:
    5456  virtual void notifyAll();
    5557protected:
    56 // Observer mechanismen is done from a static central place
     58// Observer mechanism is done from a static central place
    5759  /**
    5860   * Internal method.
  • src/molecule.hpp

    r63c1f6 rd5f216  
    3030#include "stackclass.hpp"
    3131#include "tesselation.hpp"
     32#include "Patterns/Observer.hpp"
    3233
    3334/****************************************** forward declarations *****************************/
     
    310311/** A list of \a molecule classes.
    311312 */
    312 class MoleculeListClass {
     313class MoleculeListClass : public Observable {
    313314  public:
    314315    MoleculeList ListOfMolecules; //!< List of the contained molecules
  • src/moleculelist.cpp

    r63c1f6 rd5f216  
    889889
    890890void MoleculeListClass::createNewMolecule(periodentafel *periode) {
     891  START_OBSERVER;
    891892  molecule *mol = NULL;
    892893  mol = new molecule(periode);
    893894  insert(mol);
     895  FINISH_OBSERVER;
    894896};
    895897
  • src/unittests/ObserverTest.cpp

    r63c1f6 rd5f216  
    8686
    8787void ObserverTest::setUp() {
    88   simpleObservable = new  SimpleObservable();
     88  simpleObservable1 = new SimpleObservable();
     89  simpleObservable2 = new SimpleObservable();
    8990  callObservable = new CallObservable();
    9091  superObservable = new SuperObservable();
     
    9394  observer2 = new UpdateCountObserver();
    9495  observer3 = new UpdateCountObserver();
     96  observer4 = new UpdateCountObserver();
    9597}
    9698
    9799void ObserverTest::tearDown() {
    98   delete simpleObservable;
     100  delete simpleObservable1;
     101  delete simpleObservable2;
    99102  delete callObservable;
    100103  delete superObservable;
     
    103106  delete observer2;
    104107  delete observer3;
     108  delete observer4;
    105109}
    106110
    107111void ObserverTest::doesUpdateTest()
    108112{
    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();
    114120  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
    115121  CPPUNIT_ASSERT_EQUAL( 1, observer2->updates );
    116122  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();
    121128  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
    122129  CPPUNIT_ASSERT_EQUAL( 2, observer2->updates );
    123130  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 );
    124138}
    125139
     
    155169  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;
    156170
    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;
    158172
    159173  // 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);
    162184  // when we reach this line, although we broke the DAG assumption the circle check works fine
    163185  CPPUNIT_ASSERT(true);
  • src/unittests/ObserverTest.hpp

    r63c1f6 rd5f216  
    4040  UpdateCountObserver *observer2;
    4141  UpdateCountObserver *observer3;
     42  UpdateCountObserver *observer4;
    4243
    43   SimpleObservable *simpleObservable;
     44  SimpleObservable *simpleObservable1;
     45  SimpleObservable *simpleObservable2;
    4446  CallObservable *callObservable;
    4547  SuperObservable *superObservable;
Note: See TracChangeset for help on using the changeset viewer.