Ignore:
Timestamp:
Dec 4, 2010, 11:33:47 PM (14 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:
0af7ef
Parents:
5813ac
git-author:
Frederik Heber <heber@…> (11/08/10 09:36:45)
git-committer:
Frederik Heber <heber@…> (12/04/10 23:33:47)
Message:

Refactoring of Menu structure for Qt and Text UI done.

  • Menu is now the initialising class for the menu structure.
  • MenuInterface contains virtual declarations of all functions that Menu needs to call.
  • TextMenu and QtMenu are templated classes which contain both Menu and MenuInterface and implement the virtual functions.
  • class TxMenu and its ...MenuItems contain most of the old Menu code for the text-based system. Most of the stuff, such as triggers, are now hidden internally.
  • in ..MainWindow() we basically just construct the desired Menu and call init at the correct time.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • src/UIElements/Menu/TextMenu/TxMenu.cpp

    r5813ac rb59da6  
    77
    88/*
    9  * TextMenu.cpp
     9 * TxMenu.cpp
    1010 *
    1111 *  Created on: Dec 10, 2009
     
    2121
    2222#include <boost/bind.hpp>
     23#include <algorithm>
    2324#include <iostream>
    2425#include <cmath>
    25 #include "Menu/TextMenu.hpp"
    26 #include "Menu/MenuItem.hpp"
     26#include "Actions/Action.hpp"
     27#include "Actions/ActionTraits.hpp"
     28#include "Menu/TextMenu/TxMenu.hpp"
     29#include "Menu/TextMenu/MenuItem.hpp"
    2730#include "Helpers/Assert.hpp"
    2831
     
    3235 * The text will later be displayed using the stream passed to the constructor.
    3336 */
    34 TextMenu::TextMenu(ostream& _outputter, const string _title, char _spacer,int _length) :
     37TxMenu::TxMenu(std::ostream& _outputter, const std::string _title, char _spacer,int _length) :
    3538  defaultItem(0),
    3639  outputter(_outputter),
     
    4245}
    4346
    44 TextMenu::~TextMenu()
     47TxMenu::~TxMenu()
    4548{
    46   for(list<MenuItem*>::iterator it=items.begin(); it != items.end(); it++)
     49  for(std::list<MenuItem*>::iterator it=items.begin(); it != items.end(); it++)
    4750    delete (*it);
    4851}
    4952
    50 
    51 void TextMenu::addItem(MenuItem* item) {
     53void TxMenu::addItem(MenuItem* item) {
    5254  items.push_back(item);
    5355}
    5456
    55 void TextMenu::removeItem(MenuItem* item) {
     57void TxMenu::removeItem(MenuItem* item) {
    5658  items.remove(item);
    5759}
    5860
    59 void TextMenu::doQuit(){
     61void TxMenu::doQuit(){
    6062  quit = true;
    6163}
    6264
    63 bool TextMenu::hasQuit(){
     65bool TxMenu::hasQuit(){
    6466  return quit;
    6567}
    6668
    67 void TextMenu::showEntry(MenuItem* entry){
     69void TxMenu::showEntry(MenuItem* entry){
    6870  if(entry->isActive()==false){
    6971    outputter << "(";
     
    7678}
    7779
    78 void TextMenu::display() {
     80void TxMenu::display() {
    7981  char choice;
    8082  bool somethingChosen = false;
     
    8991          outputter << spacer;
    9092    outputter << '\n';
    91     for_each(items.begin(), items.end(), boost::bind(&TextMenu::showEntry,this,_1));
     93    for_each(items.begin(), items.end(), boost::bind(&TxMenu::showEntry,this,_1));
    9294    outputter.flush();
    9395
    94     cin >> choice;
     96    std::cin >> choice;
    9597
    96     list<MenuItem*>::iterator iter;
     98    std::list<MenuItem*>::iterator iter;
    9799    for(iter = items.begin(); iter!=items.end();iter++){
    98100      if((*iter)->isActive()){
     
    106108      }
    107109      else{
    108         outputter << "Invalid Choice!" <<  endl;
     110        outputter << "Invalid Choice!" <<  std::endl;
    109111      }
    110112    }
     
    112114}
    113115
    114 string TextMenu::getTitle(){
     116std::string TxMenu::getTitle(){
    115117  return title;
    116118}
    117119
    118 void TextMenu::addDefault(MenuItem* _defaultItem) {
     120std::ostream& TxMenu::getOutputter()
     121{
     122  return outputter;
     123}
     124
     125
     126void TxMenu::addDefault(MenuItem* _defaultItem) {
    119127  defaultItem = _defaultItem;
    120128}
     
    122130/****************************** Contained Actions ****************/
    123131
    124 TextMenu::LeaveAction::LeaveAction(TextMenu* _menu, const ActionTraits & LeaveActionTrait) :
    125   Action(LeaveActionTrait, false),
     132TxMenu::LeaveAction::LeaveAction(TxMenu* const _menu, const ActionTraits & LeaveActionTrait) :
     133  Action(LeaveActionTrait, true),
    126134  menu(_menu)
    127135{}
    128136
    129 TextMenu::LeaveAction::~LeaveAction(){}
     137TxMenu::LeaveAction::~LeaveAction(){}
    130138
    131 bool TextMenu::LeaveAction::canUndo(){
     139bool TxMenu::LeaveAction::canUndo(){
    132140  return false;
    133141}
    134142
    135 bool TextMenu::LeaveAction::shouldUndo(){
     143bool TxMenu::LeaveAction::shouldUndo(){
    136144  return false;
    137145}
    138146
    139 void TextMenu::LeaveAction::getParametersfromValueStorage()
     147void TxMenu::LeaveAction::getParametersfromValueStorage()
    140148{}
    141149
    142 Dialog* TextMenu::LeaveAction::fillDialog(Dialog *dialog){
     150Dialog* TxMenu::LeaveAction::fillDialog(Dialog *dialog){
    143151  ASSERT(dialog,"No Dialog given when filling action dialog");
    144152  return dialog;
     
    146154
    147155
    148 Action::state_ptr TextMenu::LeaveAction::performCall(){
     156Action::state_ptr TxMenu::LeaveAction::performCall(){
    149157  menu->doQuit();
    150158  return Action::success;
     
    152160
    153161
    154 Action::state_ptr TextMenu::LeaveAction::performUndo(Action::state_ptr){
     162Action::state_ptr TxMenu::LeaveAction::performUndo(Action::state_ptr){
    155163  ASSERT(0,"Cannot undo leaving a menu");
    156164  return Action::success;
    157165}
    158166
    159 Action::state_ptr TextMenu::LeaveAction::performRedo(Action::state_ptr){
     167Action::state_ptr TxMenu::LeaveAction::performRedo(Action::state_ptr){
    160168  ASSERT(0,"Cannot redo leaving a menu");
    161169  return Action::success;
Note: See TracChangeset for help on using the changeset viewer.