25 QHBoxLayout* layout =
new QHBoxLayout(
this);
30 layout->addWidget(mLabel);
35 layout->addWidget(mTimerWidget);
37 mProgressBar =
new QProgressBar;
39 layout->addWidget(mProgressBar);
44 std::set<cx::TimedAlgorithmPtr>::iterator iter;
45 for(iter=threads.begin(); iter!=threads.end(); ++iter)
51 std::set<cx::TimedAlgorithmPtr>::iterator iter;
52 for(iter=threads.begin(); iter!=threads.end(); ++iter)
58 if (mAlgorithm.count(algorithm))
63 connect(algorithm.get(), SIGNAL(started(
int)),
this, SLOT(algorithmStartedSlot(
int)));
64 connect(algorithm.get(), SIGNAL(finished()),
this, SLOT(algorithmFinishedSlot()));
65 connect(algorithm.get(), SIGNAL(productChanged()),
this, SLOT(productChangedSlot()));
68 mAlgorithm.insert(algorithm);
73 if (!mAlgorithm.count(algorithm))
78 disconnect(algorithm.get(), SIGNAL(started(
int)),
this, SLOT(algorithmStartedSlot(
int)));
79 disconnect(algorithm.get(), SIGNAL(finished()),
this, SLOT(algorithmFinishedSlot()));
80 disconnect(algorithm.get(), SIGNAL(productChanged()),
this, SLOT(productChangedSlot()));
81 this->algorithmFinished(algorithm.get());
84 mAlgorithm.erase(algorithm);
87 void TimedAlgorithmProgressBar::productChangedSlot()
90 QString product =
"algorithm";
94 mLabel->setText(product);
100 if (mLabel->isVisible())
101 mLabel->setVisible(on);
104 void TimedAlgorithmProgressBar::algorithmStartedSlot(
int maxSteps)
107 QString product =
"algorithm";
111 mLabel->setText(product);
112 mLabel->setVisible(mShowTextLabel);
113 mStartedAlgos.insert(algo);
115 mTimerWidget->show();
116 mTimerWidget->
start();
118 mProgressBar->setRange(0, maxSteps);
119 mProgressBar->setValue(0);
120 mProgressBar->show();
123 void TimedAlgorithmProgressBar::algorithmFinishedSlot()
126 this->algorithmFinished(algo);
131 QString product =
"algorithm";
135 mStartedAlgos.erase(algo);
136 if (!mStartedAlgos.empty())
139 mProgressBar->setValue(0);
140 mProgressBar->hide();
143 mTimerWidget->hide();
144 mTimerWidget->
stop();
Base class for algorithms that wants to time their execution.
void detach(TimedAlgorithmPtr algorithm)
boost::shared_ptr< class TimedBaseAlgorithm > TimedAlgorithmPtr
virtual QString getProduct() const
TimedAlgorithmProgressBar(QWidget *parent=NULL)
void attach(TimedAlgorithmPtr algorithm)
void setShowTextLabel(bool on)
Namespace for all CustusX production code.