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
RevLine 
[f4d063]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
[d103d3]4 * Copyright (C) 2010-2011 University of Bonn. All rights reserved.
[f4d063]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
[ad011c]20#include "CodePatterns/MemDebug.hpp"
[f4d063]21
[862b6a]22#include <iomanip>
[4e855e]23#include <iostream>
24
[f4d063]25#include "Actions/ActionHistory.hpp"
[949953]26#include "Actions/ActionExceptions.hpp"
27
28#include "builder_init.hpp"
29#include "cleanUp.hpp"
[f4d063]30
[862b6a]31#include "CodePatterns/Log.hpp"
[949953]32
[862b6a]33#include "Graph/BondGraph.hpp"
[949953]34
[862b6a]35#include "Parser/ChangeTracker.hpp"
36#include "Parser/FormatParserStorage.hpp"
[949953]37
38#include "UIElements/UIFactory.hpp"
[862b6a]39#include "UIElements/CommandLineUI/CommandLineParser.hpp"
[949953]40#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
[862b6a]41#ifdef USE_GUI_QT
42#include "UIElements/Qt4/QtUIFactory.hpp"
43#endif
44#include "UIElements/TextUI/TextUIFactory.hpp"
[949953]45#include "UIElements/MainWindow.hpp"
[f4d063]46
47#include "version.h"
48
[949953]49#include "World.hpp"
50
[f4d063]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;
[ad7270]63 cout << endl;
[f4d063]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
[ad7270]77 setVerbosity(1);
[f4d063]78 // need to init the history before any action is created
[ce7fdc]79 MoleCuilder::ActionHistory::init();
[f4d063]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
[f71baf]96 if (boost::filesystem::exists(BondGraphFileName)) {
97 std::ifstream input(BondGraphFileName.c_str());
98 if ((input.good()) && (World::getInstance().getBondGraph()->LoadBondLengthTable(input))) {
[47d041]99 LOG(0, "Bond length table loaded successfully.");
[f71baf]100 } else {
[47d041]101 ELOG(1, "Bond length table loading failed.");
[f4d063]102 }
[f71baf]103 input.close();
[f4d063]104 }
105 // handle remaining arguments by CommandLineParser
106 if (argc>1) {
[47d041]107 LOG(0, "Setting UI to CommandLine.");
[f4d063]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
[47d041]116 LOG(0, "Setting UI to Qt4.");
[f4d063]117 UIFactory::registerFactory(new QtUIFactory::description());
118 UIFactory::makeUserInterface("Qt4");
119 #else
[47d041]120 LOG(0, "Setting UI to Text.");
[f4d063]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();
[e69c87]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 }
[f4d063]140 delete mainWindow;
141}
142
Note: See TracBrowser for help on using the repository browser.