source: src/builder_init.cpp@ 30c753

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 30c753 was d103d3, checked in by Frederik Heber <heber@…>, 13 years ago

Added additional check in CodeCheck's project disclaimer for current year in copyright.

  • had to modify all .cpp files to update to 2011.
  • 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-2011 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
52/** Print some initial information output the program.
53 *
54 */
55void ProgramHeader()
56{
57 // print version check and copyright notice
58 cout << MOLECUILDERVERSION << endl;
59 cout << "MoleCuilder comes with ABSOLUTELY NO WARRANTY; for details type" << endl;
60 cout << "`molecuilder --warranty'." << endl;
61 cout << "`MoleCuilder - to create and alter molecular systems." << endl;
62 cout << "Copyright (C) 2010 University Bonn. All rights reserved." << endl;
63 cout << endl;
64}
65
66/** General stuff to intialize before UI.
67 *
68 */
69void initGeneral()
70{
71 // while we are non interactive, we want to abort from asserts
72 ASSERT_DO(Assert::Abort);
73 ASSERT_HOOK(dumpMemory);
74
75 ProgramHeader();
76
77 setVerbosity(1);
78 // need to init the history before any action is created
79 MoleCuilder::ActionHistory::init();
80
81 // from this moment on, we need to be sure to deeinitialize in the correct order
82 // this is handled by the cleanup function
83 atexit(cleanUp);
84}
85
86/** Initialize specific UIFactory.
87 *
88 * @param argc argument count
89 * @param argv argument array
90 */
91void initUI(int argc, char **argv)
92{
93 std::string BondGraphFileName("\n");
94 // Parse command line options and if present create respective UI
95 // construct bond graph
96 if (boost::filesystem::exists(BondGraphFileName)) {
97 std::ifstream input(BondGraphFileName.c_str());
98 if ((input.good()) && (World::getInstance().getBondGraph()->LoadBondLengthTable(input))) {
99 LOG(0, "Bond length table loaded successfully.");
100 } else {
101 ELOG(1, "Bond length table loading failed.");
102 }
103 input.close();
104 }
105 // handle remaining arguments by CommandLineParser
106 if (argc>1) {
107 LOG(0, "Setting UI to CommandLine.");
108 CommandLineParser::getInstance().InitializeCommandArguments();
109 CommandLineParser::getInstance().Run(argc,argv);
110 UIFactory::registerFactory(new CommandLineUIFactory::description());
111 UIFactory::makeUserInterface("CommandLine");
112 } else {
113 // In the interactive mode, we can leave the user the choice in case of error
114 ASSERT_DO(Assert::Ask);
115 #ifdef USE_GUI_QT
116 LOG(0, "Setting UI to Qt4.");
117 UIFactory::registerFactory(new QtUIFactory::description());
118 UIFactory::makeUserInterface("Qt4");
119 #else
120 LOG(0, "Setting UI to Text.");
121 cout << MOLECUILDERVERSION << endl;
122 UIFactory::registerFactory(new TextUIFactory::description());
123 UIFactory::makeUserInterface("Text");
124 #endif
125 }
126}
127
128/** Create MainWindow and displays.
129 * I.e. here all the Actions are parsed and done.
130 */
131void doUI()
132{
133 MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow();
134 try {
135 mainWindow->display();
136 } catch(ActionFailureException &e) {
137 std::cerr << "Action " << *boost::get_error_info<ActionNameString>(e) << " has failed." << std::endl;
138 World::getInstance().setExitFlag(5);
139 }
140 delete mainWindow;
141}
142
Note: See TracBrowser for help on using the repository browser.