source: src/UIElements/Views/QT4/QTStatusBar.cpp@ 9cd807

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 9cd807 was bf3817, checked in by Frederik Heber <heber@…>, 14 years ago

Added ifdef HAVE_CONFIG and config.h include to each and every cpp file.

  • is now topmost in front of MemDebug.hpp (and any other).
  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 * QTStatusBar.cpp
3 *
4 * Created on: Feb 17, 2010
5 * Author: crueger
6 */
7
8// include config.h
9#ifdef HAVE_CONFIG_H
10#include <config.h>
11#endif
12
13#include <sstream>
14
15#include <QtGui/QLabel>
16#include <QtGui/QBoxLayout>
17#include <QtGui/QProgressBar>
18
19#include "QTStatusBar.hpp"
20
21#include "Helpers/MemDebug.hpp"
22
23#include "World.hpp"
24#include "Helpers/helpers.hpp"
25#include "Actions/Process.hpp"
26
27
28QTStatusBar::QTStatusBar(QWidget *_parent) :
29 QStatusBar(_parent),
30 Observer("QTStatusBar"),
31 atomCount(World::getInstance().numAtoms()),
32 moleculeCount(World::getInstance().numMolecules()),
33 parent(_parent)
34{
35 World::getInstance().signOn(this);
36 Process::AddObserver(this);
37 statusLabel = new QLabel(this);
38 statusLabel->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
39 addPermanentWidget(statusLabel);
40 redrawStatus();
41}
42
43QTStatusBar::~QTStatusBar()
44{
45 Process::RemoveObserver(this);
46 World::getInstance().signOff(this);
47}
48
49void QTStatusBar::update(Observable *subject){
50 if (subject==World::getPointer()){
51 atomCount = World::getInstance().numAtoms();
52 moleculeCount = World::getInstance().numMolecules();
53 redrawStatus();
54 }
55 else {
56 // we probably have some process
57 Process *proc;
58 if((proc=dynamic_cast<Process*>(subject))){
59 redrawProcess(proc);
60 }
61 }
62}
63
64void QTStatusBar::subjectKilled(Observable *subject){
65 // Processes don't notify when they are killed
66 atomCount = World::getInstance().numAtoms();
67 moleculeCount = World::getInstance().numMolecules();
68 World::getInstance().signOn(this);
69 redrawStatus();
70}
71
72void QTStatusBar::redrawStatus(){
73 stringstream sstr;
74 sstr << "You have " << atomCount << " atom" << PLURAL_S(atomCount)
75 <<" in " << moleculeCount << " molecule" << PLURAL_S(moleculeCount);
76 statusLabel->setText(QString(sstr.str().c_str()));
77}
78
79void QTStatusBar::redrawProcess(Process *proc){
80 progressIndicator *ind=0;
81 // see what we have to do with the process
82 if(proc->doesStart()){
83 ind = new progressIndicator(proc->getName());
84 ind->bar->setMaximum(proc->getMaxSteps());
85 progressBars.insert(pair<Process*,progressIndicator*>(proc,ind));
86 }
87 else {
88 ind = progressBars[proc];
89 }
90 if(activeProcess!=proc){
91 addWidget(ind->container);
92 activeProcess = proc;
93 }
94 ind->bar->setValue(proc->getCurrStep());
95 parent->repaint();
96 if(proc->doesStop()){
97 removeWidget(ind->container);
98 activeProcess = 0;
99 progressBars.erase(proc);
100 delete ind;
101 }
102}
103
104
105
106QTStatusBar::progressIndicator::progressIndicator(string name){
107 stringstream sstr;
108 sstr << "Busy (" << name << ")";
109 container = new QWidget();
110 layout = new QHBoxLayout(container);
111 label = new QLabel(QString(sstr.str().c_str()));
112 bar = new QProgressBar();
113
114 layout->addWidget(label);
115 layout->addWidget(bar);
116 container->setLayout(layout);
117}
118
119QTStatusBar::progressIndicator::~progressIndicator(){
120 delete container;
121}
Note: See TracBrowser for help on using the repository browser.