source: src/builder.cpp@ 670cd1

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 670cd1 was b59da6, checked in by Frederik Heber <heber@…>, 14 years ago

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.
  • Property mode set to 100755
File size: 7.7 KB
RevLine 
[bcf653]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8 /** \file builder.cpp
[a8bcea6]9 *
[a356f2]10 * date: Jan 1, 2007
11 * author: heber
[a8bcea6]12 *
[14de469]13 */
14
[bcf653]15/*! \page Copyright notice
16 *
17 * MoleCuilder - to create and alter molecular systems
[490038]18 * Copyright (C) 2010 University Bonn. All rights reserved.
[bcf653]19 *
20 */
21
[a356f2]22/*! \mainpage MoleCuilder - a molecular set builder
[a8bcea6]23 *
[a356f2]24 * This introductory shall briefly make acquainted with the program, helping in installing and a first run.
[a8bcea6]25 *
[14de469]26 * \section about About the Program
[a8bcea6]27 *
[a356f2]28 * MoleCuilder is a program, written entirely in C++, that enables the construction of a coordinate set for the
29 * atoms making up an molecule. It allows for both building of simple molecules by adding atom-wise giving bond
30 * angles and distances or absolute coordinates, but also using them as templates. Regions can be specified and
31 * ordered to be filled with a molecule in a certain manner. Greater conglomerations of molecules can be tesselated
32 * and recognized as a region themselves to be subsequently surrounded by other (surface solvated) molecules.
33 * In the end, MoleCuilder allows the construction of arbitrary nano structures, whether they be crystalline or
34 * amorphic in nature.
[a8bcea6]35 *
36 *
[14de469]37 * \section install Installation
[a8bcea6]38 *
[042f82]39 * Installation should without problems succeed as follows:
40 * -# ./configure (or: mkdir build;mkdir run;cd build; ../configure --bindir=../run)
41 * -# make
42 * -# make install
[a8bcea6]43 *
[042f82]44 * Further useful commands are
45 * -# make clean uninstall: deletes .o-files and removes executable from the given binary directory\n
46 * -# make doxygen-doc: Creates these html pages out of the documented source
[a356f2]47 * -# make check: Runs an extensive set of unit tests and a testsuite which also gives a good overview on the set of
48 * functions.
[a8bcea6]49 *
[14de469]50 * \section run Running
[a8bcea6]51 *
[042f82]52 * The program can be executed by running: ./molecuilder
[a8bcea6]53 *
[a356f2]54 * MoleCuilder has three interfaces at your disposal:
55 * -# Textmenu: A simple interactive console-based menu, where awaits your choices and inputs in order to set atoms
56 * as you like
57 * -# CommandLineUI: Every command can also be chained up as a sequence of actions on the command line to be executed
58 * with any user interaction.
59 * -# GraphicalUI: A graphical user interface that also display the molecular structure being built and lots of other
60 * informations to ease the construction of bigger geometries.
[a8bcea6]61 *
[a356f2]62 * The supported output formats right now are:
63 * -# mpqc: Configuration files of the Massively Parallel Quantum Chemistry package (Sandia labs)
64 * -# pcp: Configuration files of the Parallel Car-Parrinello program (Institute for Numerical Simulation)
65 * -# tremolo: Configuration files of TREMOLO (Institute for Numerical Simulation)
66 * -# xyz: the most basic format for the 3d arrangement of atoms consisting of a list of element and 3 coordinates.
[a8bcea6]67 *
[14de469]68 */
69
[bf3817]70// include config.h
71#ifdef HAVE_CONFIG_H
72#include <config.h>
73#endif
74
[112b09]75#include "Helpers/MemDebug.hpp"
[14de469]76
[b70721]77#include "bondgraph.hpp"
[f66195]78#include "config.hpp"
[952f38]79#include "Helpers/Log.hpp"
[cee0b57]80#include "molecule.hpp"
[f66195]81#include "periodentafel.hpp"
[bfd839]82#include "tesselationhelpers.hpp"
[cc04b7]83#include "UIElements/UIFactory.hpp"
[5f5a7b]84#include "UIElements/TextUI/TextUIFactory.hpp"
85#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
[e4afb4]86#include "UIElements/CommandLineUI/CommandLineParser.hpp"
[82b71a]87#ifdef USE_GUI_QT
[4cf323d]88#include "UIElements/Qt4/QtUIFactory.hpp"
[82b71a]89#endif
[cc04b7]90#include "UIElements/MainWindow.hpp"
[45f5d6]91#include "UIElements/Dialog.hpp"
[b59da6]92//#include "Menu/ActionMenuItem.hpp"
[952f38]93#include "Helpers/Verbose.hpp"
[a356f2]94#include "World.hpp"
95
[12b845]96#include "Actions/ActionRegistry.hpp"
[d56640]97#include "Actions/ActionHistory.hpp"
[042f82]98
[a356f2]99#include "Parser/ChangeTracker.hpp"
100#include "Parser/FormatParserStorage.hpp"
[1907a7]101
[a356f2]102#include "UIElements/UIFactory.hpp"
103#include "UIElements/TextUI/TextUIFactory.hpp"
104#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
105#include "UIElements/MainWindow.hpp"
106#include "UIElements/Dialog.hpp"
[1f1b23]107
[a356f2]108#include "version.h"
[1f1b23]109
[ca2b83]110
111/********************************************** Main routine **************************************/
[14de469]112
[148d8f0]113void cleanUp(){
[35b698]114 FormatParserStorage::purgeInstance();
[a1e929]115 ChangeTracker::purgeInstance();
[23b547]116 World::purgeInstance();
[354859]117 logger::purgeInstance();
118 errorLogger::purgeInstance();
[97ebf8]119 UIFactory::purgeInstance();
[e4afb4]120 ValueStorage::purgeInstance();
[c6efc1]121 CommandLineParser::purgeInstance();
[e73a8a2]122 ActionRegistry::purgeInstance();
[76cec6]123 OptionRegistry::purgeInstance();
[632bc3]124 ActionHistory::purgeInstance();
[cd5047]125#ifdef LOG_OBSERVER
126 cout << observerLog().getLog();
127#endif
[68f03d]128 Memory::getState();
[354859]129}
130
[097902]131void dumpMemory(){
132 ofstream ost("molecuilder.memdump");
133 Memory::dumpMemory(ost);
134}
135
[ca2b83]136int main(int argc, char **argv)
137{
[a356f2]138 // while we are non interactive, we want to abort from asserts
[097902]139 ASSERT_DO(Assert::Abort);
140 ASSERT_HOOK(dumpMemory);
[a356f2]141 string line;
142 char **Arguments = NULL;
143 int ArgcSize = 0;
144 int ExitFlag = 0;
145 bool ArgumentsCopied = false;
146 std::string BondGraphFileName("\n");
147
[bcf653]148 // print version check and copyright notice
[5f8660a]149 cout << MOLECUILDERVERSION << endl;
[bcf653]150 cout << "MoleCuilder comes with ABSOLUTELY NO WARRANTY; for details type" << endl;
[7230be]151 cout << "`molecuilder --warranty'." << endl;
[490038]152 cout << "`MoleCuilder - to create and alter molecular systems." << endl;
153 cout << "Copyright (C) 2010 University Bonn. All rights reserved." << endl;
[a356f2]154
155 setVerbosity(0);
156 // need to init the history before any action is created
157 ActionHistory::init();
158
159 // from this moment on, we need to be sure to deeinitialize in the correct order
160 // this is handled by the cleanup function
161 atexit(cleanUp);
162
163 // Parse command line options and if present create respective UI
164 {
165 // construct bond graph
166 if (World::getInstance().getConfig()->BG == NULL) {
167 World::getInstance().getConfig()->BG = new BondGraph(World::getInstance().getConfig()->GetIsAngstroem());
168 if (World::getInstance().getConfig()->BG->LoadBondLengthTable(BondGraphFileName)) {
169 DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
[97ebf8]170 } else {
[a356f2]171 DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
[97ebf8]172 }
[c6efc1]173 }
[a356f2]174 // handle remaining arguments by CommandLineParser
[326bbe]175 if (argc>1) {
[e4afb4]176 CommandLineParser::getInstance().InitializeCommandArguments();
177 CommandLineParser::getInstance().Run(argc,argv);
[a356f2]178 DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl);
179 UIFactory::registerFactory(new CommandLineUIFactory::description());
180 UIFactory::makeUserInterface("CommandLine");
181 } else {
[007839]182 // In the interactive mode, we can leave the user the choice in case of error
183 ASSERT_DO(Assert::Ask);
[04488a]184 #ifdef USE_GUI_QT
[4cf323d]185 DoLog(0) && (Log() << Verbose(0) << "Setting UI to Qt4." << endl);
186 UIFactory::registerFactory(new QtUIFactory::description());
187 UIFactory::makeUserInterface("Qt4");
[04488a]188 #else
189 DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl);
[5f8660a]190 cout << MOLECUILDERVERSION << endl;
[04488a]191 UIFactory::registerFactory(new TextUIFactory::description());
192 UIFactory::makeUserInterface("Text");
193 #endif
[12b845]194 }
[a356f2]195 }
196
197 {
198 MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow();
199 mainWindow->display();
200 delete mainWindow;
201 }
[6ac7ee]202
[a356f2]203 FormatParserStorage::getInstance().SaveAll();
204 ChangeTracker::getInstance().saveStatus();
[042f82]205
[97ebf8]206 // free the new argv
207 if (ArgumentsCopied) {
208 for (int i=0; i<ArgcSize;i++)
[920c70]209 delete[](Arguments[i]);
210 delete[](Arguments);
[97ebf8]211 }
[4f7f34e]212 //delete[](ConfigFileName);
[632bc3]213
[e4b5de]214 ExitFlag = World::getInstance().getExitFlag();
[99fcaf]215 return (ExitFlag == 1 ? 0 : ExitFlag);
[14de469]216}
217
218/********************************************** E N D **************************************************/
Note: See TracBrowser for help on using the repository browser.