30 #include <boost/bind.hpp> 31 #include <boost/shared_ptr.hpp> 32 #include <boost/shared_ptr.hpp> 39 BaseWidget(parent,
"algorithm_widgets_configurable_filter",
"All Filters"),
40 mWantedFilters(wantedFilters)
45 this->appendFilters(services);
47 this->setWindowTitleAndObjectNameBasedOnWantedFilters();
49 this->configureFilterSelector(options);
51 this->setupLayout(services, options);
53 this->filterChangedSlot();
58 return QString(
"<html>" 59 "<h3>Filter Widget.</h3>" 60 "<p>Select one type of filter.</p>" 61 "<p><i>Currently selected filter:</i></p>" 66 void FiltersWidget::filterChangedSlot()
68 for (
unsigned i=0; i<mFilters->size(); ++i)
70 if (mFilters->get(i)->getUid() == mFilterSelector->getValue())
72 mCurrentFilter = mFilters->get(i);
80 void FiltersWidget::toggleDetailsSlot()
86 void FiltersWidget::runFilterSlot()
92 reportWarning(QString(
"Last operation on %1 is not finished. Could not start filtering").arg(mThread->getFilter()->getName()));
97 connect(mThread.get(), SIGNAL(finished()),
this, SLOT(finishedSlot()));
98 mTimedAlgorithmProgressBar->
attach(mThread);
103 void FiltersWidget::finishedSlot()
105 mTimedAlgorithmProgressBar->
detach(mThread);
106 disconnect(mThread.get(), SIGNAL(finished()),
this, SLOT(finishedSlot()));
110 void FiltersWidget::onServiceAdded(
Filter* service)
115 void FiltersWidget::onServiceRemoved(
Filter *service)
117 mFilters->remove(service);
120 void FiltersWidget::appendFiltersThatAreNotServices(
VisServicesPtr services)
130 void FiltersWidget::appendFilterServices()
132 mServiceListener.reset(
135 boost::bind(&FiltersWidget::onServiceAdded,
this, _1),
136 boost::function<
void(
Filter*)>(),
137 boost::bind(&FiltersWidget::onServiceRemoved,
this, _1)));
138 mServiceListener->open();
143 this->appendFiltersThatAreNotServices(services);
144 this->appendFilterServices();
147 void FiltersWidget::appendFilterIfWanted(
FilterPtr filter)
149 if(mWantedFilters.empty() || mWantedFilters.contains(filter->getName()))
150 mFilters->append(filter);
153 void FiltersWidget::configureFilterSelector(
XmlOptionFile options)
155 QStringList availableFilters;
156 std::map<QString,QString> names;
157 for (
unsigned i=0; i<mFilters->size(); ++i)
159 availableFilters << mFilters->get(i)->getUid();
160 names[mFilters->get(i)->getUid()] = mFilters->get(i)->getName();
162 if(availableFilters.isEmpty())
164 availableFilters <<
"FILTER NOT FOUND";
168 "Select which filter to use.",
172 mFilterSelector->setDisplayNames(names);
176 void FiltersWidget::addDetailedButton(QHBoxLayout* filterLayout)
179 QIcon(
":/icons/open_icon_library/system-run-5.png"),
180 "Details",
"Toggle Details",
181 SLOT(toggleDetailsSlot()),
184 QToolButton* detailsButton =
new QToolButton();
185 detailsButton->setObjectName(
"DetailedButton");
186 detailsButton->setDefaultAction(detailsAction);
187 filterLayout->addWidget(detailsButton);
193 QIcon(
":/icons/open_icon_library/arrow-right-3.png"),
195 SLOT(runFilterSlot()),
199 button->setObjectName(
"RunFilterButton");
200 button->setDefaultAction(runAction);
201 filterLayout->addWidget(button);
204 QHBoxLayout * FiltersWidget::addFilterSelector(QVBoxLayout* topLayout)
206 QHBoxLayout* filterLayout =
new QHBoxLayout;
207 topLayout->addLayout(filterLayout);
210 filterLayout->addWidget(filterSelectorWidget);
215 void FiltersWidget::addProgressBar(QVBoxLayout* topLayout)
218 topLayout->addWidget(mTimedAlgorithmProgressBar);
224 topLayout->addWidget(mSetupWidget);
227 void FiltersWidget::setWindowTitleAndObjectNameBasedOnWantedFilters()
229 if(mWantedFilters.size() == 1)
231 this->setWindowTitle(mWantedFilters.first());
232 this->setObjectName(mWantedFilters.first()+
" Widget");
234 else if(mWantedFilters.empty())
236 this->setWindowTitle(
"All Filters");
237 this->setObjectName(
"algorithm_widgets_configurable_filter");
243 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
244 QHBoxLayout* filterLayout = addFilterSelector(topLayout);
245 this->addDetailedButton(filterLayout);
247 this->addProgressBar(topLayout);
248 this->addFilterWidget(options, services, topLayout);
249 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.