51 #include <boost/bind.hpp> 52 #include <boost/shared_ptr.hpp> 53 #include <boost/shared_ptr.hpp> 60 BaseWidget(parent,
"algorithm_widgets_configurable_filter",
"All Filters"),
61 mWantedFilters(wantedFilters)
66 this->appendFilters(services);
68 this->setWindowTitleAndObjectNameBasedOnWantedFilters();
70 this->configureFilterSelector(options);
72 this->setupLayout(services, options);
74 this->filterChangedSlot();
79 return QString(
"<html>" 80 "<h3>Filter Widget.</h3>" 81 "<p>Select one type of filter.</p>" 82 "<p><i>Currently selected filter:</i></p>" 87 void FiltersWidget::filterChangedSlot()
89 for (
unsigned i=0; i<mFilters->size(); ++i)
91 if (mFilters->get(i)->getUid() == mFilterSelector->getValue())
93 mCurrentFilter = mFilters->get(i);
101 void FiltersWidget::toggleDetailsSlot()
107 void FiltersWidget::runFilterSlot()
113 reportWarning(QString(
"Last operation on %1 is not finished. Could not start filtering").arg(mThread->getFilter()->getName()));
118 connect(mThread.get(), SIGNAL(finished()),
this, SLOT(finishedSlot()));
119 mTimedAlgorithmProgressBar->
attach(mThread);
124 void FiltersWidget::finishedSlot()
126 mTimedAlgorithmProgressBar->
detach(mThread);
127 disconnect(mThread.get(), SIGNAL(finished()),
this, SLOT(finishedSlot()));
131 void FiltersWidget::onServiceAdded(
Filter* service)
136 void FiltersWidget::onServiceRemoved(
Filter *service)
138 mFilters->remove(service);
141 void FiltersWidget::appendFiltersThatAreNotServices(
VisServicesPtr services)
151 void FiltersWidget::appendFilterServices()
153 mServiceListener.reset(
156 boost::bind(&FiltersWidget::onServiceAdded,
this, _1),
157 boost::function<
void(
Filter*)>(),
158 boost::bind(&FiltersWidget::onServiceRemoved,
this, _1)));
159 mServiceListener->open();
164 this->appendFiltersThatAreNotServices(services);
165 this->appendFilterServices();
168 void FiltersWidget::appendFilterIfWanted(
FilterPtr filter)
170 if(mWantedFilters.empty() || mWantedFilters.contains(filter->getName()))
171 mFilters->append(filter);
174 void FiltersWidget::configureFilterSelector(
XmlOptionFile options)
176 QStringList availableFilters;
177 std::map<QString,QString> names;
178 for (
unsigned i=0; i<mFilters->size(); ++i)
180 availableFilters << mFilters->get(i)->getUid();
181 names[mFilters->get(i)->getUid()] = mFilters->get(i)->getName();
183 if(availableFilters.isEmpty())
185 availableFilters <<
"FILTER NOT FOUND";
189 "Select which filter to use.",
193 mFilterSelector->setDisplayNames(names);
197 void FiltersWidget::addDetailedButton(QHBoxLayout* filterLayout)
200 QIcon(
":/icons/open_icon_library/system-run-5.png"),
201 "Details",
"Toggle Details",
202 SLOT(toggleDetailsSlot()),
205 QToolButton* detailsButton =
new QToolButton();
206 detailsButton->setObjectName(
"DetailedButton");
207 detailsButton->setDefaultAction(detailsAction);
208 filterLayout->addWidget(detailsButton);
214 QIcon(
":/icons/open_icon_library/arrow-right-3.png"),
216 SLOT(runFilterSlot()),
220 button->setObjectName(
"RunFilterButton");
221 button->setDefaultAction(runAction);
222 filterLayout->addWidget(button);
225 QHBoxLayout * FiltersWidget::addFilterSelector(QVBoxLayout* topLayout)
227 QHBoxLayout* filterLayout =
new QHBoxLayout;
228 topLayout->addLayout(filterLayout);
231 filterLayout->addWidget(filterSelectorWidget);
236 void FiltersWidget::addProgressBar(QVBoxLayout* topLayout)
239 topLayout->addWidget(mTimedAlgorithmProgressBar);
245 topLayout->addWidget(mSetupWidget);
248 void FiltersWidget::setWindowTitleAndObjectNameBasedOnWantedFilters()
250 if(mWantedFilters.size() == 1)
252 this->setWindowTitle(mWantedFilters.first());
253 this->setObjectName(mWantedFilters.first()+
" Widget");
255 else if(mWantedFilters.empty())
257 this->setWindowTitle(
"All Filters");
258 this->setObjectName(
"algorithm_widgets_configurable_filter");
264 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
265 QHBoxLayout* filterLayout = addFilterSelector(topLayout);
266 this->addDetailedButton(filterLayout);
268 this->addProgressBar(topLayout);
269 this->addFilterWidget(options, services, topLayout);
270 topLayout->addStretch();
cxResource_EXPORT ProfilePtr profile()
boost::shared_ptr< class VisServices > VisServicesPtr
Show progress for a TimedBaseAlgorithm.
QDomElement getElement()
return the current element
void detach(TimedAlgorithmPtr algorithm)
boost::shared_ptr< class Filter > FilterPtr
void reportWarning(QString msg)
static LogicManager * getInstance()
void attach(TimedAlgorithmPtr algorithm)
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
Helper class for listening to services being added, modified and removed.
Helper class for xml files used to store ssc/cx data.
Namespace for all CustusX production code.