source: src/UIElements/Qt4/QtMainWindow.cpp@ 7e6a1b

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

drop unused references to ValueStorage

  • Property mode set to 100644
File size: 4.3 KB
RevLine 
[bcf653]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
[0aa122]4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
[bcf653]5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
[3027f8]8/*
[4cf323d]9 * QtMainWindow.cpp
[3027f8]10 *
11 * Created on: Jan 14, 2010
12 * Author: crueger
13 */
14
[bf3817]15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
[bbbad5]19
[4cf323d]20#include "QtMainWindow.hpp"
[3027f8]21
[8f67e2]22#include<Qt/qapplication.h>
[fa27ed]23#include<Qt/qlabel.h>
24#include<Qt/qstring.h>
25#include<Qt/qmenubar.h>
[cef1d7]26#include<Qt/qsplitter.h>
[7641d4]27#include<Qt/qtoolbar.h>
[b82101]28#include<Qt/qsettings.h>
[22d01e]29#include<Qt/qmessagebox.h>
30#include<Qt/qevent.h>
[8f67e2]31
[3027f8]32#include<iostream>
[b2531f]33#include<map>
34
[fa27ed]35#include<boost/bind.hpp>
36
[a08d3c0]37#include "Menu/Qt4/QtMenu.hpp"
[0eb7bf3]38#include "Views/Qt4/QtMoleculeList.hpp"
[0e6156]39#include "Views/Qt4/QtElementList.hpp"
[3c53fa]40#include "Views/Qt4/QtInfoBox.hpp"
[a08d3c0]41#include "Views/Qt4/QtStatusBar.hpp"
[7641d4]42#include "Views/Qt4/QtToolBar.hpp"
[04f017]43#include "Views/Qt4/Qt3D/GLWorldView.hpp"
[a08d3c0]44
[ad011c]45#include "CodePatterns/MemDebug.hpp"
[bbbad5]46
[6f0841]47#include "Atom/atom.hpp"
[fa27ed]48#include "molecule.hpp"
[ad011c]49#include "CodePatterns/Verbose.hpp"
[b2531f]50#include "Actions/Action.hpp"
51#include "Actions/ActionRegistry.hpp"
[22d01e]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;
[3027f8]58
[4cf323d]59QtMainWindow::QtMainWindow(QApplication *_theApp) :
[8f67e2]60 theApp(_theApp)
[fa27ed]61{
[b82101]62 QCoreApplication::setOrganizationName("ins");
63 QCoreApplication::setOrganizationDomain("ins.uni-bonn.de");
64 QCoreApplication::setApplicationName("MoleCuilder");
[cef1d7]65 QSplitter *splitter1 = new QSplitter (Qt::Horizontal, this );
66 QSplitter *splitter2 = new QSplitter (Qt::Vertical, splitter1 );
[244f81]67 QTabWidget *worldTab = new QTabWidget(splitter2);
[cef1d7]68
[0eb7bf3]69 moleculeList = new QtMoleculeList(worldTab);
[0e6156]70 elementList = new QtElementList(worldTab);
[cef1d7]71
[3c53fa]72 infoBox = new QtInfoBox();
[0eb7bf3]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));
[cef1d7]78
[b59da6]79 MainMenu = new QtMenu<QMenuBar>(menuBar(), "");
80 MainMenu->init();
[b80021]81
[7641d4]82 toolbar = new QtToolBar(this);
[0eb7bf3]83 glWorldView->addToolBarActions(toolbar);
[7641d4]84 addToolBar(toolbar);
85
[cef1d7]86 setCentralWidget(splitter1);
87 splitter1->addWidget(splitter2);
[3c53fa]88 splitter1->addWidget(infoBox);
[0eb7bf3]89 splitter2->addWidget(glWorldView);
[244f81]90 splitter2->addWidget(worldTab);
[0eb7bf3]91 worldTab->addTab(moleculeList, "Molecules");
[0e6156]92 worldTab->addTab(elementList, "All Elements");
[cef1d7]93
[4cf323d]94 statusBar = new QtStatusBar(this);
[326a43b]95 setStatusBar(statusBar);
[fa27ed]96
[b82101]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
[3c53fa]105 connect(glWorldView,SIGNAL(hoverChanged(const atom*)), infoBox,SLOT(atomHover(const atom*)));
[fa27ed]106}
[3027f8]107
[4cf323d]108QtMainWindow::~QtMainWindow()
[992fd7]109{
[b82101]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
[992fd7]117 menuBar()->clear();
[da8f97]118 delete MainMenu;
[992fd7]119}
[3027f8]120
[4cf323d]121void QtMainWindow::display() {
[8f67e2]122 this->show();
123 theApp->exec();
[3027f8]124}
[b2531f]125
[5125f6]126void QtMainWindow::closeEvent(QCloseEvent *event)
127{
[22d01e]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 }
[5125f6]152 QMainWindow::closeEvent(event);
153}
154
Note: See TracBrowser for help on using the repository browser.