source: src/UIElements/Views/QT4/QTStatusBar.cpp@ 61ea5b

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 61ea5b was b47bfc, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Added forgotten files in previous commit

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