source: src/UIElements/Views/Qt4/QtStatusBar.cpp@ d103d3

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 d103d3 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.1 KB
RevLine 
[bcf653]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
[d103d3]4 * Copyright (C) 2010-2011 University of Bonn. All rights reserved.
[bcf653]5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
[b47bfc]8/*
[4cf323d]9 * QtStatusBar.cpp
[b47bfc]10 *
11 * Created on: Feb 17, 2010
12 * Author: crueger
13 */
14
[bf3817]15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
[bbbad5]19
[b47bfc]20#include <sstream>
21
22#include <QtGui/QLabel>
23#include <QtGui/QBoxLayout>
24#include <QtGui/QProgressBar>
25
[4cf323d]26#include "QtStatusBar.hpp"
[bbbad5]27
[ad011c]28#include "CodePatterns/MemDebug.hpp"
[bbbad5]29
[b47bfc]30#include "World.hpp"
31#include "Actions/Process.hpp"
32
[5605793]33#define PLURAL_S(v) (((v)==1)?"":"s")
34
[ce7fdc]35using namespace MoleCuilder;
[b47bfc]36
[4cf323d]37QtStatusBar::QtStatusBar(QWidget *_parent) :
[b47bfc]38 QStatusBar(_parent),
[4cf323d]39 Observer("QtStatusBar"),
[b47bfc]40 atomCount(World::getInstance().numAtoms()),
[fc7504]41 moleculeCount(World::getInstance().numMolecules()),
42 parent(_parent)
[b47bfc]43{
44 World::getInstance().signOn(this);
45 Process::AddObserver(this);
46 statusLabel = new QLabel(this);
47 statusLabel->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
48 addPermanentWidget(statusLabel);
49 redrawStatus();
50}
51
[4cf323d]52QtStatusBar::~QtStatusBar()
[b47bfc]53{
54 Process::RemoveObserver(this);
55 World::getInstance().signOff(this);
56}
57
[4cf323d]58void QtStatusBar::update(Observable *subject){
[b47bfc]59 if (subject==World::getPointer()){
60 atomCount = World::getInstance().numAtoms();
61 moleculeCount = World::getInstance().numMolecules();
62 redrawStatus();
63 }
64 else {
65 // we probably have some process
66 Process *proc;
67 if((proc=dynamic_cast<Process*>(subject))){
68 redrawProcess(proc);
69 }
70 }
71}
72
[4cf323d]73void QtStatusBar::subjectKilled(Observable *subject){
[b47bfc]74 // Processes don't notify when they are killed
75 atomCount = World::getInstance().numAtoms();
76 moleculeCount = World::getInstance().numMolecules();
77 World::getInstance().signOn(this);
78 redrawStatus();
79}
80
[4cf323d]81void QtStatusBar::redrawStatus(){
[b47bfc]82 stringstream sstr;
83 sstr << "You have " << atomCount << " atom" << PLURAL_S(atomCount)
84 <<" in " << moleculeCount << " molecule" << PLURAL_S(moleculeCount);
85 statusLabel->setText(QString(sstr.str().c_str()));
86}
87
[4cf323d]88void QtStatusBar::redrawProcess(Process *proc){
[b47bfc]89 progressIndicator *ind=0;
90 // see what we have to do with the process
91 if(proc->doesStart()){
92 ind = new progressIndicator(proc->getName());
93 ind->bar->setMaximum(proc->getMaxSteps());
94 progressBars.insert(pair<Process*,progressIndicator*>(proc,ind));
95 }
96 else {
97 ind = progressBars[proc];
98 }
99 if(activeProcess!=proc){
100 addWidget(ind->container);
101 activeProcess = proc;
102 }
103 ind->bar->setValue(proc->getCurrStep());
104 parent->repaint();
105 if(proc->doesStop()){
106 removeWidget(ind->container);
107 activeProcess = 0;
108 progressBars.erase(proc);
109 delete ind;
110 }
111}
112
113
114
[4cf323d]115QtStatusBar::progressIndicator::progressIndicator(string name){
[b47bfc]116 stringstream sstr;
117 sstr << "Busy (" << name << ")";
118 container = new QWidget();
119 layout = new QHBoxLayout(container);
120 label = new QLabel(QString(sstr.str().c_str()));
121 bar = new QProgressBar();
122
123 layout->addWidget(label);
124 layout->addWidget(bar);
125 container->setLayout(layout);
126}
127
[4cf323d]128QtStatusBar::progressIndicator::~progressIndicator(){
[b47bfc]129 delete container;
130}
Note: See TracBrowser for help on using the repository browser.