Changeset 426c84 for src


Ignore:
Timestamp:
Sep 29, 2013, 11:40:48 AM (11 years ago)
Author:
Frederik Heber <heber@…>
Branches:
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
Children:
8481f5
Parents:
c48ac12
git-author:
Frederik Heber <heber@…> (08/29/13 09:23:47)
git-committer:
Frederik Heber <heber@…> (09/29/13 11:40:48)
Message:

QtStatusBar::updateProcess() replaced by signal/slot mechanism.

  • updateProcess() added QProgessBar() widgets which can only take place in main thread, but notify comes from ActionQueue's thread. Hence, we relay the information via signal/slot redrawProgressBar()/updateProgressBar() to main thread and instantiate there.
Location:
src/UIElements/Views/Qt4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/QtStatusBar.cpp

    rc48ac12 r426c84  
    3737#include <QtGui/QLabel>
    3838#include <QtGui/QBoxLayout>
     39#include <QtCore/QMetaType>
    3940#include <QtGui/QProgressBar>
    4041
     
    5556  atomCount(World::getInstance().numAtoms()),
    5657  moleculeCount(World::getInstance().numMolecules()),
    57   parent(_parent)
     58  parent(_parent),
     59  activeProcess("")
    5860{
    5961  World::getInstance().signOn(this);
     
    6365  addPermanentWidget(statusLabel);
    6466  redrawStatus();
     67
     68  qRegisterMetaType<std::string>("std::string");
     69  connect(
     70      this, SIGNAL(redrawProgressBar(const std::string, const unsigned int, const unsigned int, const bool)),
     71      this, SLOT(updateProgressBar(const std::string, const unsigned int, const unsigned int, const bool)));
    6572}
    6673
     
    7986  else {
    8087    // we probably have some process
     88    // as notify comes from ActionQueue's thread, we have to use signal/slots
     89    // to inform ourselves but within the main() thread to be able to add
     90    // the progressbar widget.
    8191    Process *proc;
    8292    if((proc=dynamic_cast<Process*>(subject))){
    83       redrawProcess(proc);
     93      const bool StopStatus = proc->doesStop();
     94      emit redrawProgressBar(proc->getName(), proc->getMaxSteps(), proc->getCurrStep(), StopStatus);
    8495    }
    8596  }
     
    101112}
    102113
    103 void QtStatusBar::redrawProcess(Process *proc){
     114void QtStatusBar::updateProgressBar(
     115    const std::string name,
     116    const unsigned int maxsteps,
     117    const unsigned int currentstep,
     118    const bool StopStatus)
     119{
    104120  progressIndicator *ind=0;
     121  progressBars_t::iterator iter = progressBars.find(name);
    105122  // see what we have to do with the process
    106   if(proc->doesStart()){
    107     ind = new progressIndicator(proc->getName());
    108     ind->bar->setMaximum(proc->getMaxSteps());
    109     progressBars.insert(pair<Process*,progressIndicator*>(proc,ind));
     123  if (iter == progressBars.end()) {
     124    ind = new progressIndicator(name);
     125    ind->bar->setMaximum(maxsteps);
     126    progressBars.insert( std::make_pair(name,ind) );
     127  } else {
     128    ind = iter->second;
    110129  }
    111   else {
    112     ind = progressBars[proc];
     130  if (activeProcess != name) {
     131    addWidget(ind->container);
     132    activeProcess = name;
    113133  }
    114   if(activeProcess!=proc){
    115     addWidget(ind->container);
    116     activeProcess = proc;
    117   }
    118   ind->bar->setValue(proc->getCurrStep());
     134  ind->bar->setValue(currentstep);
    119135  parent->repaint();
    120   if(proc->doesStop()){
     136  if ((iter != progressBars.end()) && StopStatus) {
    121137    removeWidget(ind->container);
    122     activeProcess = 0;
    123     progressBars.erase(proc);
     138    activeProcess = std::string("");
     139    progressBars.erase(name);
    124140    delete ind;
    125141  }
     
    128144
    129145
    130 QtStatusBar::progressIndicator::progressIndicator(std::string name){
     146QtStatusBar::progressIndicator::progressIndicator(const std::string &name){
    131147  stringstream sstr;
    132148  sstr << "Busy (" << name << ")";
  • src/UIElements/Views/Qt4/QtStatusBar.hpp

    rc48ac12 r426c84  
    3535
    3636  struct progressIndicator{
    37     progressIndicator(std::string);
     37    progressIndicator(const std::string &name);
    3838    ~progressIndicator();
    3939    QLabel *label;
     
    4949  void subjectKilled(Observable *subject);
    5050
     51private slots:
     52  void updateProgressBar(
     53      const std::string name,
     54      const unsigned int maxsteps,
     55      const unsigned int currentstep,
     56      const bool StopStatus);
     57
     58signals:
     59  void redrawProgressBar(
     60      const std::string name,
     61      const unsigned int maxsteps,
     62      const unsigned int currentstep,
     63      const bool StopStatus);
     64
    5165private:
    5266  void redrawStatus();
    53   void redrawProcess(MoleCuilder::Process *proc);
    5467
    5568  int atomCount;
     
    5871  QLabel *statusLabel;
    5972  QWidget *parent;
    60   std::map<MoleCuilder::Process*,progressIndicator*> progressBars;
    61   MoleCuilder::Process* activeProcess;
     73  typedef std::map<std::string,progressIndicator*> progressBars_t;
     74  progressBars_t progressBars;
     75  std::string activeProcess;
    6276};
    6377
Note: See TracChangeset for help on using the changeset viewer.