source: src/builder_init.cpp@ 52575c

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 52575c was 5ca6b5, checked in by Michael Ankele <ankele@…>, 12 years ago

drop deprecated references to ValueStorage

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * builder_init.cpp
10 *
11 * Created on: Dec 15, 2010
12 * Author: heber
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "CodePatterns/MemDebug.hpp"
21
22#include <iomanip>
23#include <iostream>
24
25#include "Actions/ActionHistory.hpp"
26#include "Actions/ActionExceptions.hpp"
27
28#include "builder_init.hpp"
29#include "cleanUp.hpp"
30
31#include "CodePatterns/Log.hpp"
32
33#include "Graph/BondGraph.hpp"
34
35#include "Parser/ChangeTracker.hpp"
36#include "Parser/FormatParserStorage.hpp"
37
38#include "UIElements/UIFactory.hpp"
39#include "UIElements/CommandLineUI/CommandLineParser.hpp"
40#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
41#ifdef USE_GUI_QT
42#include "UIElements/Qt4/QtUIFactory.hpp"
43#endif
44#include "UIElements/TextUI/TextUIFactory.hpp"
45#include "UIElements/MainWindow.hpp"
46
47#include "version.h"
48
49#include "World.hpp"
50
51#include <boost/filesystem.hpp>
52
53
54/** Print some initial information output the program.
55 *
56 */
57void ProgramHeader()
58{
59 // print version check and copyright notice
60 cout << MOLECUILDERVERSION << endl;
61 cout << "MoleCuilder comes with ABSOLUTELY NO WARRANTY; for details type" << endl;
62 cout << "`molecuilder --warranty'." << endl;
63 cout << "`MoleCuilder - to create and alter molecular systems." << endl;
64 cout << "Copyright (C) 2010 University Bonn. All rights reserved." << endl;
65 cout << endl;
66}
67
68/** General stuff to intialize before UI.
69 *
70 */
71void initGeneral()
72{
73 // while we are non interactive, we want to abort from asserts
74 ASSERT_DO(Assert::Abort);
75 ASSERT_HOOK(dumpMemory);
76
77 ProgramHeader();
78
79 setVerbosity(1);
80 // need to init the history before any action is created
81 MoleCuilder::ActionHistory::init();
82
83 // from this moment on, we need to be sure to deeinitialize in the correct order
84 // this is handled by the cleanup function
85 atexit(cleanUp);
86}
87
88/** Initialize specific UIFactory.
89 *
90 * @param argc argument count
91 * @param argv argument array
92 */
93void initUI(int argc, char **argv)
94{
95 std::string BondGraphFileName("\n");
96 // Parse command line options and if present create respective UI
97 // construct bond graph
98 if (boost::filesystem::exists(BondGraphFileName)) {
99 std::ifstream input(BondGraphFileName.c_str());
100 if ((input.good()) && (World::getInstance().getBondGraph()->LoadBondLengthTable(input))) {
101 LOG(0, "Bond length table loaded successfully.");
102 } else {
103 ELOG(1, "Bond length table loading failed.");
104 }
105 input.close();
106 }
107 // handle remaining arguments by CommandLineParser
108 if (argc>1) {
109 LOG(0, "Setting UI to CommandLine.");
110 CommandLineParser::getInstance().InitializeCommandArguments();
111 CommandLineParser::getInstance().Run(argc,argv);
112 UIFactory::registerFactory(new CommandLineUIFactory::description());
113 UIFactory::makeUserInterface("CommandLine");
114 } else {
115 // In the interactive mode, we can leave the user the choice in case of error
116 ASSERT_DO(Assert::Ask);
117 #ifdef USE_GUI_QT
118 LOG(0, "Setting UI to Qt4.");
119 UIFactory::registerFactory(new QtUIFactory::description());
120 UIFactory::makeUserInterface("Qt4");
121 #else
122 LOG(0, "Setting UI to Text.");
123 cout << MOLECUILDERVERSION << endl;
124 UIFactory::registerFactory(new TextUIFactory::description());
125 UIFactory::makeUserInterface("Text");
126 #endif
127 }
128}
129
130/** Create MainWindow and displays.
131 * I.e. here all the Actions are parsed and done.
132 */
133void doUI()
134{
135 MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow();
136 try {
137 mainWindow->display();
138 } catch(ActionFailureException &e) {
139 std::cerr << "Action " << *boost::get_error_info<ActionNameString>(e) << " has failed." << std::endl;
140 World::getInstance().setExitFlag(5);
141 }
142 delete mainWindow;
143}
144
Note: See TracBrowser for help on using the repository browser.