[a56275] | 1 | /*
|
---|
| 2 | * TextWindow.cpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Jan 7, 2010
|
---|
| 5 | * Author: crueger
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "UIElements/TextWindow.hpp"
|
---|
[12b845] | 9 |
|
---|
| 10 | #include <boost/bind.hpp>
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | // TODO: When done with refactoring most of these wont be needed anymore
|
---|
| 14 | #include "analysis_correlation.hpp"
|
---|
| 15 | #include "atom.hpp"
|
---|
| 16 | #include "bond.hpp"
|
---|
| 17 | #include "bondgraph.hpp"
|
---|
| 18 | #include "boundary.hpp"
|
---|
| 19 | #include "config.hpp"
|
---|
| 20 | #include "element.hpp"
|
---|
| 21 | #include "ellipsoid.hpp"
|
---|
| 22 | #include "helpers.hpp"
|
---|
| 23 | #include "leastsquaremin.hpp"
|
---|
| 24 | #include "linkedcell.hpp"
|
---|
| 25 | #include "log.hpp"
|
---|
| 26 | #include "memoryusageobserverunittest.hpp"
|
---|
| 27 | #include "molecule.hpp"
|
---|
| 28 | #include "periodentafel.hpp"
|
---|
| 29 |
|
---|
[442218] | 30 | #include "Legacy/oldmenu.hpp"
|
---|
[a56275] | 31 |
|
---|
[12b845] | 32 | #include "Menu/Menu.hpp"
|
---|
| 33 | #include "Menu/TextMenu.hpp"
|
---|
| 34 | #include "Menu/ActionMenuItem.hpp"
|
---|
| 35 | #include "Menu/SeperatorItem.hpp"
|
---|
| 36 | #include "Menu/DisplayMenuItem.hpp"
|
---|
| 37 | #include "Menu/SubMenuItem.hpp"
|
---|
[0188ea] | 38 | #include "UIElements/TextStatusIndicator.hpp"
|
---|
[12b845] | 39 | #include "Actions/MethodAction.hpp"
|
---|
| 40 | #include "Actions/ErrorAction.hpp"
|
---|
[f6bbc6] | 41 | #include "Actions/ActionRegistry.hpp"
|
---|
[12b845] | 42 | #include "Views/StreamStringView.hpp"
|
---|
| 43 | #include "Views/MethodStringView.hpp"
|
---|
| 44 |
|
---|
[cc04b7] | 45 | #include <iostream>
|
---|
| 46 |
|
---|
| 47 | using namespace std;
|
---|
| 48 |
|
---|
[12b845] | 49 | // TODO: see what code can be moved to a base class for Graphic and Text Windows
|
---|
| 50 | TextWindow::TextWindow(menuPopulaters populaters,MoleculeListClass *molecules, config *configuration, periodentafel *periode, char *ConfigFileName)
|
---|
[a56275] | 51 | {
|
---|
[12b845] | 52 | old_menu = new oldmenu;
|
---|
| 53 |
|
---|
| 54 | // build the main menu
|
---|
| 55 | main_menu = new TextMenu(Log() << Verbose(0), "Main Menu");
|
---|
| 56 |
|
---|
| 57 | moleculeView = new StreamStringView(boost::bind(&MoleculeListClass::Enumerate,molecules,_1));
|
---|
| 58 | new DisplayMenuItem(main_menu,moleculeView,"Molecule List");
|
---|
| 59 |
|
---|
| 60 | new SeperatorItem(main_menu);
|
---|
| 61 |
|
---|
[f6bbc6] | 62 | Action* undoAction = ActionRegistry::getInstance().getActionByName("Undo");
|
---|
| 63 | new ActionMenuItem('u',"Undo last operation",main_menu,undoAction);
|
---|
| 64 |
|
---|
| 65 | Action* redoAction = ActionRegistry::getInstance().getActionByName("Redo");
|
---|
| 66 | new ActionMenuItem('r',"Redo last operation",main_menu,redoAction);
|
---|
| 67 |
|
---|
| 68 | new SeperatorItem(main_menu);
|
---|
| 69 |
|
---|
[12b845] | 70 | Action *setMoleculeAction = new MethodAction("setMoleculeAction",boost::bind(&MoleculeListClass::flipChosen,molecules));
|
---|
| 71 | new ActionMenuItem('a',"set molecule (in)active",main_menu,setMoleculeAction);
|
---|
| 72 |
|
---|
| 73 | TextMenu *editMoleculesMenu = new TextMenu(Log() << Verbose(0), "Edit Molecules");
|
---|
| 74 | new SubMenuItem('e',"edit molecules (load, parse, save)",main_menu,editMoleculesMenu);
|
---|
| 75 |
|
---|
| 76 | Action *manipulateMoleculeAction = new MethodAction("manipulateMoleculeAction",boost::bind(&oldmenu::ManipulateMolecules,old_menu,periode, molecules, configuration));
|
---|
| 77 | new ActionMenuItem('g',"globally manipulate atoms in molecule",main_menu,manipulateMoleculeAction);
|
---|
| 78 |
|
---|
| 79 | Action *mergeMoleculeAction = new MethodAction("mergeMoleculeAction",boost::bind(&oldmenu::MergeMolecules,old_menu,periode, molecules));
|
---|
| 80 | new ActionMenuItem('M',"Merge molecules",main_menu,mergeMoleculeAction);
|
---|
[a56275] | 81 |
|
---|
[12b845] | 82 | Action *manipulateAtomsAction = new MethodAction("manipulateAtomsAction",boost::bind(&oldmenu::ManipulateAtoms,old_menu,periode, molecules, configuration));
|
---|
| 83 | new ActionMenuItem('m',"manipulate atoms",main_menu,manipulateAtomsAction);
|
---|
| 84 |
|
---|
| 85 | new SeperatorItem(main_menu);
|
---|
| 86 |
|
---|
| 87 | Action *editConfigAction = new MethodAction("editConfigAction",boost::bind(&config::Edit,configuration));
|
---|
| 88 | new ActionMenuItem('c',"edit the current configuration",main_menu,editConfigAction);
|
---|
| 89 |
|
---|
| 90 | new SeperatorItem(main_menu);
|
---|
| 91 |
|
---|
| 92 | Action *saveConfigAction = new MethodAction("saveConfigAction",boost::bind(&config::SaveAll,configuration, ConfigFileName, periode, molecules));
|
---|
| 93 | new ActionMenuItem('s',"save current setup to config file",main_menu,saveConfigAction);
|
---|
| 94 |
|
---|
| 95 | Action *doTestAction = new MethodAction("doTestAction",boost::bind(&oldmenu::testroutine,old_menu,molecules));
|
---|
| 96 | new ActionMenuItem('T',"call the current test routine",main_menu,doTestAction);
|
---|
| 97 |
|
---|
| 98 | quitAction = new MethodAction("quitAction",boost::bind(&TextMenu::doQuit,main_menu),false);
|
---|
| 99 | new ActionMenuItem('q',"quit",main_menu,quitAction);
|
---|
| 100 |
|
---|
| 101 | // call all functions used to build the submenus
|
---|
| 102 |
|
---|
| 103 | populaters.MakeEditMoleculesMenu(editMoleculesMenu,molecules,configuration,periode);
|
---|
| 104 |
|
---|
[d56640] | 105 | Action *returnFromEditMoleculeAction = new TextMenu::LeaveAction(editMoleculesMenu);
|
---|
[12b845] | 106 | MenuItem *returnItem = new ActionMenuItem('q',"return to Main menu",editMoleculesMenu,returnFromEditMoleculeAction);
|
---|
| 107 |
|
---|
| 108 | editMoleculesMenu->addDefault(returnItem);
|
---|
[0188ea] | 109 |
|
---|
| 110 | // Add status indicators etc...
|
---|
| 111 |
|
---|
| 112 | statusIndicator = new TextStatusIndicator();
|
---|
[a56275] | 113 | }
|
---|
| 114 |
|
---|
| 115 | TextWindow::~TextWindow()
|
---|
| 116 | {
|
---|
[12b845] | 117 | delete old_menu;
|
---|
| 118 | delete quitAction;
|
---|
| 119 | delete moleculeView;
|
---|
[0188ea] | 120 | delete statusIndicator;
|
---|
[12b845] | 121 | delete main_menu;
|
---|
[a56275] | 122 | }
|
---|
| 123 |
|
---|
[12b845] | 124 | void TextWindow::display() {
|
---|
| 125 | main_menu->display();
|
---|
[a56275] | 126 | }
|
---|