source: src/UIElements/Qt4/QtMainWindow.cpp@ eb0d77

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 eb0d77 was b2a7cc, checked in by Michael Ankele <ankele@…>, 12 years ago

drop unused references to ValueStorage

  • Property mode set to 100644
File size: 4.3 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 * QtMainWindow.cpp
10 *
11 * Created on: Jan 14, 2010
12 * Author: crueger
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "QtMainWindow.hpp"
21
22#include<Qt/qapplication.h>
23#include<Qt/qlabel.h>
24#include<Qt/qstring.h>
25#include<Qt/qmenubar.h>
26#include<Qt/qsplitter.h>
27#include<Qt/qtoolbar.h>
28#include<Qt/qsettings.h>
29#include<Qt/qmessagebox.h>
30#include<Qt/qevent.h>
31
32#include<iostream>
33#include<map>
34
35#include<boost/bind.hpp>
36
37#include "Menu/Qt4/QtMenu.hpp"
38#include "Views/Qt4/QtMoleculeList.hpp"
39#include "Views/Qt4/QtElementList.hpp"
40#include "Views/Qt4/QtInfoBox.hpp"
41#include "Views/Qt4/QtStatusBar.hpp"
42#include "Views/Qt4/QtToolBar.hpp"
43#include "Views/Qt4/Qt3D/GLWorldView.hpp"
44
45#include "CodePatterns/MemDebug.hpp"
46
47#include "Atom/atom.hpp"
48#include "molecule.hpp"
49#include "CodePatterns/Verbose.hpp"
50#include "Actions/Action.hpp"
51#include "Actions/ActionRegistry.hpp"
52#include "Parser/ChangeTracker.hpp"
53#include "Parser/FormatParserStorage.hpp"
54#include "Actions/WorldAction/OutputAction.hpp"
55#include "Actions/WorldAction/OutputAsAction.hpp"
56
57using namespace MoleCuilder;
58
59QtMainWindow::QtMainWindow(QApplication *_theApp) :
60 theApp(_theApp)
61{
62 QCoreApplication::setOrganizationName("ins");
63 QCoreApplication::setOrganizationDomain("ins.uni-bonn.de");
64 QCoreApplication::setApplicationName("MoleCuilder");
65 QSplitter *splitter1 = new QSplitter (Qt::Horizontal, this );
66 QSplitter *splitter2 = new QSplitter (Qt::Vertical, splitter1 );
67 QTabWidget *worldTab = new QTabWidget(splitter2);
68
69 moleculeList = new QtMoleculeList(worldTab);
70 elementList = new QtElementList(worldTab);
71
72 infoBox = new QtInfoBox();
73 glWorldView = new GLWorldView(this);
74// glWorldView->setSizePolicy( QSizePolicy::Minimum,QSizePolicy::Minimum);
75 glWorldView->setMinimumSize( QSize(640,480) );
76// glWorldView->setFocus();
77 glWorldView->camera()->setEye( QVector3D(0,3,10));
78
79 MainMenu = new QtMenu<QMenuBar>(menuBar(), "");
80 MainMenu->init();
81
82 toolbar = new QtToolBar(this);
83 glWorldView->addToolBarActions(toolbar);
84 addToolBar(toolbar);
85
86 setCentralWidget(splitter1);
87 splitter1->addWidget(splitter2);
88 splitter1->addWidget(infoBox);
89 splitter2->addWidget(glWorldView);
90 splitter2->addWidget(worldTab);
91 worldTab->addTab(moleculeList, "Molecules");
92 worldTab->addTab(elementList, "All Elements");
93
94 statusBar = new QtStatusBar(this);
95 setStatusBar(statusBar);
96
97 QSettings settings;
98 settings.beginGroup("MainWindow");
99 resize(settings.value("size", QSize(400, 400)).toSize());
100 move(settings.value("position", QPoint(200, 200)).toPoint());
101 if (settings.value("maximized", false).toBool())
102 showMaximized();
103 settings.endGroup();
104
105 connect(glWorldView,SIGNAL(hoverChanged(const atom*)), infoBox,SLOT(atomHover(const atom*)));
106}
107
108QtMainWindow::~QtMainWindow()
109{
110 QSettings settings;
111 settings.beginGroup("MainWindow");
112 settings.setValue("size", size());
113 settings.setValue("position", pos());
114 settings.setValue("maximized", isMaximized());
115 settings.endGroup();
116
117 menuBar()->clear();
118 delete MainMenu;
119}
120
121void QtMainWindow::display() {
122 this->show();
123 theApp->exec();
124}
125
126void QtMainWindow::closeEvent(QCloseEvent *event)
127{
128 if (ChangeTracker::getInstance().hasChanged()){
129 int ret = QMessageBox::question(this, tr("MoleCuilder"),
130 tr("The world has been modified.\n"
131 "Do you want to save your changes?"),
132 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
133 QMessageBox::Save);
134 switch(ret){
135 case QMessageBox::Cancel:
136 event->ignore();
137 return;
138 case QMessageBox::Save:
139 if (FormatParserStorage::getInstance().isAbleToSave())
140 MoleCuilder::WorldOutput();
141 else{
142 Action* action = ActionRegistry::getInstance().getActionByName("output-as");
143 try{
144 action->call();
145 }catch(...){
146 ELOG(1, "Action failed or cancelled");
147 }
148 }
149 break;
150 }
151 }
152 QMainWindow::closeEvent(event);
153}
154
Note: See TracBrowser for help on using the repository browser.