source: src/UIElements/TextUI/TextWindow.cpp@ 112b09

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
Last change on this file since 112b09 was 112b09, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Added #include "Helpers/MemDebug.hpp" to all .cpp files

  • Property mode set to 100644
File size: 6.1 KB
Line 
1/*
2 * TextWindow.cpp
3 *
4 * Created on: Jan 7, 2010
5 * Author: crueger
6 */
7
8#include "Helpers/MemDebug.hpp"
9
10#include "TextUI/TextWindow.hpp"
11
12#include <boost/bind.hpp>
13
14
15// TODO: When done with refactoring most of these wont be needed anymore
16#include "analysis_correlation.hpp"
17#include "atom.hpp"
18#include "bond.hpp"
19#include "bondgraph.hpp"
20#include "boundary.hpp"
21#include "config.hpp"
22#include "element.hpp"
23#include "ellipsoid.hpp"
24#include "helpers.hpp"
25#include "leastsquaremin.hpp"
26#include "linkedcell.hpp"
27#include "log.hpp"
28#include "memoryusageobserver.hpp"
29#include "molecule.hpp"
30#include "periodentafel.hpp"
31#include "World.hpp"
32
33#include "Legacy/oldmenu.hpp"
34
35#include "Menu/Menu.hpp"
36#include "Menu/TextMenu.hpp"
37#include "Menu/ActionMenuItem.hpp"
38#include "Menu/SeperatorItem.hpp"
39#include "Menu/DisplayMenuItem.hpp"
40#include "Menu/SubMenuItem.hpp"
41#include "TextUI/TextStatusIndicator.hpp"
42#include "Actions/MethodAction.hpp"
43#include "Actions/MoleculeAction/ChangeNameAction.hpp"
44#include "Actions/ErrorAction.hpp"
45#include "Actions/ActionRegistry.hpp"
46#include "Views/StreamStringView.hpp"
47#include "Views/MethodStringView.hpp"
48
49#include <iostream>
50
51using namespace std;
52
53// TODO: see what code can be moved to a base class for Graphic and Text Windows
54TextWindow::TextWindow()
55{
56 MoleculeListClass *molecules = World::getInstance().getMolecules();
57 config *configuration = World::getInstance().getConfig();
58 periodentafel *periode = World::getInstance().getPeriode();
59 char *ConfigFileName = NULL;
60 old_menu = new oldmenu;
61
62 // build the main menu
63 main_menu = new TextMenu(Log() << Verbose(0), "Main Menu");
64
65 moleculeView = new StreamStringView(boost::bind(&MoleculeListClass::Enumerate,molecules,_1));
66 new DisplayMenuItem(main_menu,moleculeView,"Molecule List");
67
68 new SeperatorItem(main_menu);
69
70 Action* undoAction = ActionRegistry::getInstance().getActionByName("Undo");
71 new ActionMenuItem('u',"Undo last operation",main_menu,undoAction);
72
73 Action* redoAction = ActionRegistry::getInstance().getActionByName("Redo");
74 new ActionMenuItem('r',"Redo last operation",main_menu,redoAction);
75
76 new SeperatorItem(main_menu);
77
78 Action *setMoleculeAction = new MethodAction("setMoleculeAction",boost::bind(&MoleculeListClass::flipChosen,molecules));
79 new ActionMenuItem('a',"set molecule (in)active",main_menu,setMoleculeAction);
80
81 TextMenu *editMoleculesMenu = new TextMenu(Log() << Verbose(0), "Edit Molecules");
82 new SubMenuItem('e',"edit molecules (load, parse, save)",main_menu,editMoleculesMenu);
83
84 Action *manipulateMoleculeAction = new MethodAction("manipulateMoleculeAction",boost::bind(&oldmenu::ManipulateMolecules,old_menu,periode, molecules, configuration));
85 new ActionMenuItem('g',"globally manipulate atoms in molecule",main_menu,manipulateMoleculeAction);
86
87 Action *mergeMoleculeAction = new MethodAction("mergeMoleculeAction",boost::bind(&oldmenu::MergeMolecules,old_menu,periode, molecules));
88 new ActionMenuItem('M',"Merge molecules",main_menu,mergeMoleculeAction);
89
90 Action *manipulateAtomsAction = new MethodAction("manipulateAtomsAction",boost::bind(&oldmenu::ManipulateAtoms,old_menu,periode, molecules, configuration));
91 new ActionMenuItem('m',"manipulate atoms",main_menu,manipulateAtomsAction);
92
93 new SeperatorItem(main_menu);
94
95 Action *editConfigAction = new MethodAction("editConfigAction",boost::bind(&config::Edit,configuration));
96 new ActionMenuItem('c',"edit the current configuration",main_menu,editConfigAction);
97
98 new SeperatorItem(main_menu);
99
100 Action *saveConfigAction = new MethodAction("saveConfigAction",boost::bind(&config::SaveAll,configuration, ConfigFileName, periode, molecules));
101 new ActionMenuItem('s',"save current setup to config file",main_menu,saveConfigAction);
102
103 Action *doTestAction = new MethodAction("doTestAction",boost::bind(&oldmenu::testroutine,old_menu,molecules));
104 new ActionMenuItem('T',"call the current test routine",main_menu,doTestAction);
105
106 quitAction = new MethodAction("quitAction",boost::bind(&TextMenu::doQuit,main_menu),false);
107 new ActionMenuItem('q',"quit",main_menu,quitAction);
108
109 // call all functions used to build the submenus
110
111 populateEditMoleculesMenu(editMoleculesMenu);
112
113 Action *returnFromEditMoleculeAction = new TextMenu::LeaveAction(editMoleculesMenu);
114 MenuItem *returnItem = new ActionMenuItem('q',"return to Main menu",editMoleculesMenu,returnFromEditMoleculeAction);
115
116 editMoleculesMenu->addDefault(returnItem);
117
118 // Add status indicators etc...
119
120 statusIndicator = new TextStatusIndicator();
121}
122
123TextWindow::~TextWindow()
124{
125 delete old_menu;
126 delete quitAction;
127 delete moleculeView;
128 delete statusIndicator;
129 delete main_menu;
130}
131
132void TextWindow::display() {
133 main_menu->display();
134}
135
136void TextWindow::populateEditMoleculesMenu(Menu* editMoleculesMenu)
137{
138 MoleculeListClass *molecules = World::getInstance().getMolecules();
139 periodentafel *periode = World::getInstance().getPeriode();
140
141 // build the EditMoleculesMenu
142 Action *createMoleculeAction = new MethodAction("createMoleculeAction",boost::bind(&MoleculeListClass::createNewMolecule,molecules,periode));
143 new ActionMenuItem('c',"create new molecule",editMoleculesMenu,createMoleculeAction);
144
145 Action *loadMoleculeAction = new MethodAction("loadMoleculeAction",boost::bind(&MoleculeListClass::loadFromXYZ,molecules,periode));
146 new ActionMenuItem('l',"load molecule from xyz file",editMoleculesMenu,loadMoleculeAction);
147
148 Action *changeFilenameAction = new MoleculeChangeNameAction();
149 new ActionMenuItem('n',"change molecule's name",editMoleculesMenu,changeFilenameAction);
150
151 Action *giveFilenameAction = new MethodAction("giveFilenameAction",boost::bind(&MoleculeListClass::setMoleculeFilename,molecules));
152 new ActionMenuItem('N',"give molecules filename",editMoleculesMenu,giveFilenameAction);
153
154 Action *parseAtomsAction = new MethodAction("parseAtomsAction",boost::bind(&MoleculeListClass::parseXYZIntoMolecule,molecules));
155 new ActionMenuItem('p',"parse atoms in xyz file into molecule",editMoleculesMenu,parseAtomsAction);
156
157 Action *eraseMoleculeAction = new MethodAction("eraseMoleculeAction",boost::bind(&MoleculeListClass::eraseMolecule,molecules));
158 new ActionMenuItem('r',"remove a molecule",editMoleculesMenu,eraseMoleculeAction);
159
160}
Note: See TracBrowser for help on using the repository browser.