Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 5abc76a8 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Added s_propertyAdded and s_propertyRemoved signals to PropertyCollection...

Added s_propertyAdded and s_propertyRemoved signals to PropertyCollection signaling changes to the property list. PropertyCollectionWidget listens to them and updates the GUI on the fly.
parent d9e7da62
......@@ -46,6 +46,7 @@ namespace campvis {
/**
* Creates a new PropertyWidget for the property \a property.
* \param property The property the widget shall handle
* \param dc DataContainer this property uses to populate the combo box (may be 0).
* \param parent Parent Qt widget
*/
DataNamePropertyWidget(DataNameProperty* property, DataContainer* dc, QWidget* parent = 0);
......
......@@ -38,6 +38,7 @@ namespace campvis {
PropertyCollectionWidget::PropertyCollectionWidget(QWidget* parent /*= 0*/)
: QWidget(parent)
, _propCollection(0)
, _dataContainer(0)
, _layout(0)
{
setupWidget();
......@@ -51,18 +52,17 @@ namespace campvis {
// remove and delete all widgets of the previous PropertyCollection
clearWidgetMap();
_propCollection = propertyCollection;
_dataContainer = dc;
// create widgets for the new PropertyCollection
if (propertyCollection != 0) {
for (std::vector<AbstractProperty*>::const_iterator it = propertyCollection->getProperties().begin(); it != propertyCollection->getProperties().end(); ++it) {
QWidget* propWidget = PropertyWidgetFactory::createWidget(*it, dc);
if (propWidget == 0)
propWidget = new QPushButton(QString::fromStdString((*it)->getTitle()));
_widgetMap.insert(std::make_pair(*it, propWidget));
_layout->addWidget(propWidget);
propWidget->setVisible((*it)->isVisible());
(*it)->s_visibilityChanged.connect(this, &PropertyCollectionWidget::onPropertyVisibilityChanged);
}
addProperty(*it);
}
propertyCollection->s_propertyAdded.connect(this, &PropertyCollectionWidget::onPropCollectionPropAdded);
propertyCollection->s_propertyRemoved.connect(this, &PropertyCollectionWidget::onPropCollectionPropRemoved);
}
}
......@@ -72,16 +72,21 @@ namespace campvis {
_layout->setMargin(0);
setLayout(_layout);
connect(this, SIGNAL(s_widgetVisibilityChanged(QWidget*, bool)), this, SLOT(onWidgetVisibilityChanged(QWidget*, bool)));
connect(this, SIGNAL(propertyAdded(AbstractProperty*)), this, SLOT(addProperty(AbstractProperty*)));
connect(this, SIGNAL(propertyRemoved(std::map<AbstractProperty*, QWidget*>::iterator)), this, SLOT(removeProperty(std::map<AbstractProperty*, QWidget*>::iterator)));
}
void PropertyCollectionWidget::clearWidgetMap() {
for (std::map<AbstractProperty*, QWidget*>::iterator it = _widgetMap.begin(); it != _widgetMap.end(); ++it) {
it->first->s_visibilityChanged.disconnect(this);
_layout->removeWidget(it->second);
delete it->second;
removeProperty(it);
}
_widgetMap.clear();
if (_propCollection != 0) {
_propCollection->s_propertyAdded.disconnect(this);
_propCollection->s_propertyRemoved.disconnect(this);
}
}
void PropertyCollectionWidget::onPropertyVisibilityChanged(const AbstractProperty* prop) {
......@@ -95,4 +100,31 @@ namespace campvis {
widget->setVisible(visibility);
}
void PropertyCollectionWidget::onPropCollectionPropAdded(AbstractProperty* prop) {
emit propertyAdded(prop);
}
void PropertyCollectionWidget::onPropCollectionPropRemoved(AbstractProperty* prop) {
std::map<AbstractProperty*, QWidget*>::iterator it = _widgetMap.find(prop);
if (it != _widgetMap.end())
emit propertyRemoved(it);
}
void PropertyCollectionWidget::addProperty(AbstractProperty* prop) {
QWidget* propWidget = PropertyWidgetFactory::createWidget(prop, _dataContainer);
if (propWidget == 0)
propWidget = new QPushButton(QString::fromStdString(prop->getTitle()));
_widgetMap.insert(std::make_pair(prop, propWidget));
_layout->addWidget(propWidget);
propWidget->setVisible(prop->isVisible());
prop->s_visibilityChanged.connect(this, &PropertyCollectionWidget::onPropertyVisibilityChanged);
}
void PropertyCollectionWidget::removeProperty(std::map<AbstractProperty*, QWidget*>::iterator it) {
it->first->s_visibilityChanged.disconnect(this);
_layout->removeWidget(it->second);
delete it->second;
}
}
\ No newline at end of file
......@@ -63,7 +63,7 @@ namespace campvis {
void updatePropCollection(HasPropertyCollection* propertyCollection, DataContainer* dc);
/**
* Slot to be called when one of the propertie's visibility has changed.
* Slot to be called when one of the properties' visibility has changed.
* \param prop Property that emitted the signal
*/
void onPropertyVisibilityChanged(const AbstractProperty* prop);
......@@ -74,9 +74,24 @@ namespace campvis {
*/
virtual void onWidgetVisibilityChanged(QWidget* widget, bool visibility);
/**
* Creates the property widget for \a prop, connects all neccesary signals, etc.
* \param prop Property to add
*/
void addProperty(AbstractProperty* prop);
/**
* Removes the property widget for \a prop, disconnects all neccesary signals, etc.
* \param prop Iterator to widget map for the property to remove.
*/
void removeProperty(std::map<AbstractProperty*, QWidget*>::iterator prop);
signals:
void s_widgetVisibilityChanged(QWidget* widget, bool visibility);
void propertyAdded(AbstractProperty* prop);
void propertyRemoved(std::map<AbstractProperty*, QWidget*>::iterator prop);
private:
/**
* Sets up this widget
......@@ -88,11 +103,23 @@ namespace campvis {
*/
void clearWidgetMap();
HasPropertyCollection* _propCollection; ///< The HasPropertyCollection instance this widget is currently working on.
/**
* Slot called from PropertyCollection a property was added.
*/
void onPropCollectionPropAdded(AbstractProperty* prop);
/**
* Slot called from PropertyCollection a property was removed.
*/
void onPropCollectionPropRemoved(AbstractProperty* prop);
HasPropertyCollection* _propCollection; ///< The HasPropertyCollection instance this widget is currently working on.
DataContainer* _dataContainer; ///< The DataContainer the properties shall work on
QVBoxLayout* _layout;
std::map<AbstractProperty*, QWidget*> _widgetMap;
//QList<QWidget*> _widgetList;
};
}
#endif // PROPERTYCOLLECTIONWIDGET_H__
......@@ -41,7 +41,7 @@ namespace campvis {
* \todo Add PropertyWidgets, add clone()?
* Think about a reasonable locking mechanism and implement that
*/
class AbstractProperty : public sigslot::has_slots<> {
class AbstractProperty {
public:
/**
* Creates a new AbstractProperty
......
......@@ -40,12 +40,14 @@ namespace campvis {
PropertyCollection::iterator it = findProperty(prop->getName());
if (it != _properties.end()) {
(*it)->s_changed.disconnect(this);
s_propertyRemoved(*it);
*it = prop;
}
else {
_properties.push_back(prop);
}
prop->s_changed.connect(this, &HasPropertyCollection::onPropertyChanged);
s_propertyAdded(prop);
}
void HasPropertyCollection::removeProperty(AbstractProperty* prop) {
......@@ -54,6 +56,7 @@ namespace campvis {
if (it != _properties.end()) {
(*it)->s_changed.disconnect(this);
_properties.erase(it);
s_propertyRemoved(prop);
}
}
......
......@@ -120,6 +120,12 @@ namespace campvis {
*/
virtual void onPropertyChanged(const AbstractProperty* prop);
/// Signal emitted when a property was added to the collection.
sigslot::signal1<AbstractProperty*> s_propertyAdded;
/// Signal emitted when a property was removed from the collection.
sigslot::signal1<AbstractProperty*> s_propertyRemoved;
protected:
/**
* Searches _properties for a property named \a name.
......
......@@ -36,7 +36,7 @@ namespace campvis {
/**
* \todo Implement correct behavior if the TF changes during locked property state.
*/
class TransferFunctionProperty : public AbstractProperty {
class TransferFunctionProperty : public AbstractProperty , public sigslot::has_slots<> {
public:
typedef ConcurrentGenericHistogramND<float, 1> IntensityHistogramType;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment