Changeset d893f79 for src


Ignore:
Timestamp:
May 8, 2010, 9:59:27 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
808fd3
Parents:
8e1f7af
Message:

removed menuPopulaters from MainWindow.

  • menuPopulaters is too specific to TextUIFactory.
  • for CommandLineUIFactory a different structure was needed.
  • the shift of struct menuPopulaters inside of class MainWindow makes it superflous.

Signed-off-by: Frederik Heber <heber@…>

Location:
src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/CommandLineUIFactory.cpp

    r8e1f7af rd893f79  
    2828}
    2929
    30 MainWindow* CommandLineUIFactory::makeMainWindow(menuPopulaters populaters) {
    31   return new CommandLineWindow(populaters);
     30MainWindow* CommandLineUIFactory::makeMainWindow() {
     31  return new CommandLineWindow();
    3232}
  • src/UIElements/CommandLineUIFactory.hpp

    r8e1f7af rd893f79  
    1919
    2020  virtual Dialog* makeDialog();
    21   virtual MainWindow* makeMainWindow(menuPopulaters);
     21  virtual MainWindow* makeMainWindow();
    2222
    2323protected:
  • src/UIElements/CommandLineWindow.cpp

    r8e1f7af rd893f79  
    1111#include "UIElements/CommandLineStatusIndicator.hpp"
    1212
     13#include "Actions/CmdAction/HelpAction.hpp"
     14#include "Actions/ParserAction/LoadXyzAction.hpp"
     15#include "Actions/ParserAction/SaveXyzAction.hpp"
     16
    1317#include <iostream>
    1418
     
    1620
    1721// TODO: see what code can be moved to a base class for Graphic and CommandLine Windows
    18 CommandLineWindow::CommandLineWindow(menuPopulaters populaters)
     22CommandLineWindow::CommandLineWindow()
    1923{
     24  // create and register all command line callable actions
     25  populateParserActions();
    2026
    2127  // Add status indicators etc...
    22 
    2328  statusIndicator = new CommandLineStatusIndicator();
    2429}
     
    3136void CommandLineWindow::display() {
    3237}
     38
     39void CommandLineWindow::populateParserActions()
     40{
     41  new ParserLoadXyzAction();
     42  new ParserSaveXyzAction();
     43}
     44
  • src/UIElements/CommandLineWindow.hpp

    r8e1f7af rd893f79  
    1616{
    1717public:
    18   CommandLineWindow(menuPopulaters);
     18  CommandLineWindow();
    1919  virtual ~CommandLineWindow();
    2020
     
    2222
    2323private:
     24  // populaters
     25  void populateParserActions();
    2426
    2527  CommandLineStatusIndicator *statusIndicator;
  • src/UIElements/MainWindow.hpp

    r8e1f7af rd893f79  
    2525};
    2626
    27 /**
    28  * The type of menuPopulators
    29  */
    30 typedef void (*MenuMaker)(Menu*);
    31 
    32 /**
    33  * This contains all Functions that are used to create the menus.
    34  * Needs a specific funtion for each menu. All populators will be called
    35  * by the UIFactory upon creation of the main menu. Thus the actuall construction
    36  * of the Menus can be kept independent of the concrete type of UI that is being
    37  * built.
    38  */
    39 struct menuPopulaters{
    40   MenuMaker MakeEditMoleculesMenu;
    41 };
    4227
    4328#endif /* MAINWINDOW_HPP_ */
  • src/UIElements/TextUIFactory.cpp

    r8e1f7af rd893f79  
    2727}
    2828
    29 MainWindow* TextUIFactory::makeMainWindow(menuPopulaters populaters) {
    30   return new TextWindow(populaters);
     29MainWindow* TextUIFactory::makeMainWindow() {
     30  return new TextWindow();
    3131}
    3232
  • src/UIElements/TextUIFactory.hpp

    r8e1f7af rd893f79  
    1919
    2020  virtual Dialog* makeDialog();
    21   virtual MainWindow* makeMainWindow(menuPopulaters);
     21  virtual MainWindow* makeMainWindow();
    2222
    2323protected:
  • src/UIElements/TextWindow.cpp

    r8e1f7af rd893f79  
    3939#include "UIElements/TextStatusIndicator.hpp"
    4040#include "Actions/MethodAction.hpp"
     41#include "Actions/MoleculeAction/ChangeNameAction.hpp"
    4142#include "Actions/ErrorAction.hpp"
    4243#include "Actions/ActionRegistry.hpp"
     
    4950
    5051// TODO: see what code can be moved to a base class for Graphic and Text Windows
    51 TextWindow::TextWindow(menuPopulaters populaters)
     52TextWindow::TextWindow()
    5253{
    5354  MoleculeListClass *molecules = World::getInstance().getMolecules();
     
    106107  // call all functions used to build the submenus
    107108
    108   populaters.MakeEditMoleculesMenu(editMoleculesMenu);
     109  populateEditMoleculesMenu(editMoleculesMenu);
    109110
    110111  Action *returnFromEditMoleculeAction = new TextMenu::LeaveAction(editMoleculesMenu);
     
    130131  main_menu->display();
    131132}
     133
     134void TextWindow::populateEditMoleculesMenu(Menu* editMoleculesMenu)
     135{
     136  MoleculeListClass *molecules = World::getInstance().getMolecules();
     137  periodentafel *periode = World::getInstance().getPeriode();
     138
     139  // build the EditMoleculesMenu
     140  Action *createMoleculeAction = new MethodAction("createMoleculeAction",boost::bind(&MoleculeListClass::createNewMolecule,molecules,periode));
     141  new ActionMenuItem('c',"create new molecule",editMoleculesMenu,createMoleculeAction);
     142
     143  Action *loadMoleculeAction = new MethodAction("loadMoleculeAction",boost::bind(&MoleculeListClass::loadFromXYZ,molecules,periode));
     144  new ActionMenuItem('l',"load molecule from xyz file",editMoleculesMenu,loadMoleculeAction);
     145
     146  Action *changeFilenameAction = new MoleculeChangeNameAction(molecules);
     147  new ActionMenuItem('n',"change molecule's name",editMoleculesMenu,changeFilenameAction);
     148
     149  Action *giveFilenameAction = new MethodAction("giveFilenameAction",boost::bind(&MoleculeListClass::setMoleculeFilename,molecules));
     150  new ActionMenuItem('N',"give molecules filename",editMoleculesMenu,giveFilenameAction);
     151
     152  Action *parseAtomsAction = new MethodAction("parseAtomsAction",boost::bind(&MoleculeListClass::parseXYZIntoMolecule,molecules));
     153  new ActionMenuItem('p',"parse atoms in xyz file into molecule",editMoleculesMenu,parseAtomsAction);
     154
     155  Action *eraseMoleculeAction = new MethodAction("eraseMoleculeAction",boost::bind(&MoleculeListClass::eraseMolecule,molecules));
     156  new ActionMenuItem('r',"remove a molecule",editMoleculesMenu,eraseMoleculeAction);
     157
     158}
  • src/UIElements/TextWindow.hpp

    r8e1f7af rd893f79  
    1717class TextStatusIndicator;
    1818
     19
    1920class TextWindow : public MainWindow
    2021{
    2122public:
    22   TextWindow(menuPopulaters);
     23  TextWindow();
    2324  virtual ~TextWindow();
    2425
    2526  virtual void display();
    2627private:
     28  // populaters
     29  void populateEditMoleculesMenu(Menu* editMoleculesMenu);
     30
    2731  TextMenu *main_menu;
    2832
  • src/UIElements/UIFactory.hpp

    r8e1f7af rd893f79  
    1212class Dialog;
    1313class DialogDescription;
    14 
    15 struct menuPopulaters;
    1614
    1715#include "Patterns/Singleton.hpp"
     
    3432   * Produce some kind of main window, of whichever type was chosen when the factory was created
    3533   */
    36   virtual MainWindow* makeMainWindow(menuPopulaters)=0;
     34  virtual MainWindow* makeMainWindow()=0;
    3735
    3836  /**
  • src/builder.cpp

    r8e1f7af rd893f79  
    25122512};
    25132513
    2514 /***************************************** Functions used to build all menus **********************/
    2515 
    2516 void populateEditMoleculesMenu(Menu* editMoleculesMenu){
    2517   MoleculeListClass *molecules = World::getInstance().getMolecules();
    2518   periodentafel *periode = World::getInstance().getPeriode();
    2519 
    2520   // build the EditMoleculesMenu
    2521   Action *createMoleculeAction = new MethodAction("createMoleculeAction",boost::bind(&MoleculeListClass::createNewMolecule,molecules,periode));
    2522   new ActionMenuItem('c',"create new molecule",editMoleculesMenu,createMoleculeAction);
    2523 
    2524   Action *loadMoleculeAction = new MethodAction("loadMoleculeAction",boost::bind(&MoleculeListClass::loadFromXYZ,molecules,periode));
    2525   new ActionMenuItem('l',"load molecule from xyz file",editMoleculesMenu,loadMoleculeAction);
    2526 
    2527   Action *changeFilenameAction = new MoleculeChangeNameAction(molecules);
    2528   new ActionMenuItem('n',"change molecule's name",editMoleculesMenu,changeFilenameAction);
    2529 
    2530   Action *giveFilenameAction = new MethodAction("giveFilenameAction",boost::bind(&MoleculeListClass::setMoleculeFilename,molecules));
    2531   new ActionMenuItem('N',"give molecules filename",editMoleculesMenu,giveFilenameAction);
    2532 
    2533   Action *parseAtomsAction = new MethodAction("parseAtomsAction",boost::bind(&MoleculeListClass::parseXYZIntoMolecule,molecules));
    2534   new ActionMenuItem('p',"parse atoms in xyz file into molecule",editMoleculesMenu,parseAtomsAction);
    2535 
    2536   Action *eraseMoleculeAction = new MethodAction("eraseMoleculeAction",boost::bind(&MoleculeListClass::eraseMolecule,molecules));
    2537   new ActionMenuItem('r',"remove a molecule",editMoleculesMenu,eraseMoleculeAction);
    2538 
    2539 }
    2540 
    2541 
    25422514/********************************************** Main routine **************************************/
    25432515
     
    25862558
    25872559    {
    2588       menuPopulaters populaters;
    2589       populaters.MakeEditMoleculesMenu = populateEditMoleculesMenu;
    2590 
    2591       MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow(populaters);
     2560      MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow();
    25922561      mainWindow->display();
    25932562      delete mainWindow;
Note: See TracChangeset for help on using the changeset viewer.