Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

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

Some UI tweaks:

* Improved appearance of PipelineTreeWidget
* Fixed IntPropertyWidget and FloatPropertyWidget recursively setting the widgets value, when the change event comes from the widget itself
parent 15174e5a
......@@ -44,6 +44,10 @@ namespace campvis {
setValueImpl(value);
}
int DoubleAdjusterWidget::decimals() const {
return _spinBox->decimals();
}
void DoubleAdjusterWidget::setDecimals(int prec) {
_spinBox->setDecimals(prec);
setSliderProperties(_spinBox->singleStep(), _spinBox->minimum(), _spinBox->maximum());
......@@ -94,5 +98,4 @@ namespace campvis {
setSingleStepImpl(value);
}
}
......@@ -45,6 +45,11 @@ namespace campvis {
*/
DoubleAdjusterWidget(QWidget* parent = 0);
/**
* Returns how many decimals the adjuster will use for displaying and doubleerpreting doubles.
*/
int decimals() const;
/**
* Set how many decimals the adjuster will use for displaying and doubleerpreting doubles.
* \param prec number of decimals the adjuster will use
......
......@@ -146,6 +146,7 @@ namespace campvis {
qRegisterMetaType< std::vector<DataContainer*> >("std::vector<DataContainer*>");
qRegisterMetaType< std::vector<AbstractPipeline*> >("std::vector<AbstractPipeline*>");
qRegisterMetaType< std::map<AbstractProperty*, QWidget*>::iterator >("PropertyWidgetMapIterator");
connect(
this, SIGNAL(updatePipelineWidget(const std::vector<DataContainer*>&, const std::vector<AbstractPipeline*>&)),
_pipelineWidget, SLOT(update(const std::vector<DataContainer*>&, const std::vector<AbstractPipeline*>&)));
......
......@@ -25,6 +25,7 @@
#include "pipelinetreewidget.h"
#include "cgt/assert.h"
#include <QApplication>
#include <QHeaderView>
#include <QScrollBar>
#include <QStringList>
......@@ -35,7 +36,6 @@ namespace campvis {
const int COLUMN_NAME = 0;
const int COLUMN_ENABLED_STATE = 1;
const int COLUMN_CLOCK_STATE = 2;
const int COLUMN_DESCRIPTION = 3;
}
// = TreeModel items ==============================================================================
......@@ -58,6 +58,8 @@ namespace campvis {
return QVariant();
case Qt::UserRole:
return QVariant();
case Qt::BackgroundRole:
return QVariant(QApplication::palette().alternateBase());
default:
return QVariant();
}
......@@ -91,6 +93,13 @@ namespace campvis {
return _pipeline->getEnabled() ? QVariant(Qt::Checked) : QVariant(Qt::Unchecked);
else
return QVariant();
case Qt::SizeHintRole:
if (column == COLUMN_ENABLED_STATE || column == COLUMN_CLOCK_STATE)
return QVariant(QSize());
else
return QVariant();
case Qt::BackgroundRole:
return QVariant(QApplication::palette().alternateBase());
case Qt::UserRole:
return qVariantFromValue(static_cast<void*>(_pipeline));
default:
......@@ -125,8 +134,6 @@ namespace campvis {
case Qt::DisplayRole:
if (column == COLUMN_NAME)
return QVariant(QString::fromStdString(_processor->getName()));
else if (column == COLUMN_DESCRIPTION)
return QVariant(QString::fromStdString(_processor->getDescription()));
else
return QVariant();
case Qt::CheckStateRole:
......@@ -138,6 +145,8 @@ namespace campvis {
return QVariant();
case Qt::UserRole:
return qVariantFromValue(static_cast<void*>(_processor));
case Qt::ToolTipRole:
return QVariant(QString::fromStdString(_processor->getDescription()));
default:
return QVariant();
}
......@@ -170,12 +179,18 @@ namespace campvis {
if (role == Qt::DisplayRole) {
if (column == COLUMN_NAME)
return QVariant(QString("Pipeline/Processor"));
else if (column == COLUMN_DESCRIPTION)
return QVariant(QString("Description"));
else if (column == COLUMN_ENABLED_STATE)
return QVariant(QString("E"));
else if (column == COLUMN_CLOCK_STATE)
return QVariant(QString("P"));
}
else if (role == Qt::ToolTipRole) {
if (column == COLUMN_NAME)
return QVariant(QString("Name of Pipeline/Processor"));
else if (column == COLUMN_ENABLED_STATE)
return QVariant(QString("Enabled"));
else if (column == COLUMN_CLOCK_STATE)
return QVariant(QString("Clock"));
return QVariant(QString("Profile Processor's execution time"));
}
return QVariant();
......@@ -218,8 +233,6 @@ namespace campvis {
return 0;
switch (index.column()) {
case COLUMN_DESCRIPTION:
return QAbstractItemModel::flags(index) | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
case COLUMN_NAME:
return QAbstractItemModel::flags(index) | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
case COLUMN_ENABLED_STATE:
......@@ -283,7 +296,7 @@ namespace campvis {
}
int PipelineTreeModel::columnCount(const QModelIndex &parent /*= QModelIndex()*/) const {
return 4;
return 3;
}
void PipelineTreeModel::setData(const std::vector<DataContainer*>& dataContainers, const std::vector<AbstractPipeline*>& pipelines) {
......@@ -349,7 +362,7 @@ namespace campvis {
height += 2 * header()->sizeHint().height();
height += 2 * frameWidth();
return QSize(QTreeView::sizeHint().width(), height);
return QSize(QTreeView::sizeHint().width(), std::max(height, 200));
}
void PipelineTreeWidget::update(const std::vector<DataContainer*>& dataContainers, const std::vector<AbstractPipeline*>& pipelines) {
......@@ -360,6 +373,7 @@ namespace campvis {
expandAll();
resizeColumnToContents(0);
resizeColumnToContents(1);
resizeColumnToContents(2);
// The widget's size hint might have changed, notify the layout
updateGeometry();
......
......@@ -55,11 +55,16 @@ namespace campvis {
void FloatPropertyWidget::updateWidgetFromProperty() {
FloatProperty* prop = static_cast<FloatProperty*>(_property);
_adjuster->blockSignals(true);
_adjuster->setValue(prop->getValue());
_adjuster->setMinimum(prop->getMinValue());
_adjuster->setMaximum(prop->getMaxValue());
_adjuster->setSingleStep(prop->getStepValue());
_adjuster->setDecimals(prop->getDecimals());
if (static_cast<float>(_adjuster->value()) != prop->getValue())
_adjuster->setValue(prop->getValue());
if (static_cast<float>(_adjuster->minimum()) != prop->getMinValue())
_adjuster->setMinimum(prop->getMinValue());
if (static_cast<float>(_adjuster->maximum()) != prop->getMaxValue())
_adjuster->setMaximum(prop->getMaxValue());
if (static_cast<float>(_adjuster->singleStep()) != prop->getStepValue())
_adjuster->setSingleStep(prop->getStepValue());
if (_adjuster->decimals() != prop->getDecimals())
_adjuster->setDecimals(prop->getDecimals());
_adjuster->blockSignals(false);
}
......
......@@ -86,7 +86,8 @@ namespace campvis {
void IntPropertyWidget::updateWidgetFromProperty() {
IntProperty* prop = static_cast<IntProperty*>(_property);
_adjuster->blockSignals(true);
_adjuster->setValue(prop->getValue());
if (_adjuster->value() != prop->getValue())
_adjuster->setValue(prop->getValue());
_adjuster->blockSignals(false);
}
......@@ -100,8 +101,10 @@ namespace campvis {
void IntPropertyWidget::onPropertyMinMaxChanged(const AbstractProperty* property) {
if (_ignorePropertyUpdates == 0) {
IntProperty* prop = static_cast<IntProperty*>(_property);
_adjuster->setMinimum(prop->getMinValue());
_adjuster->setMaximum(prop->getMaxValue());
if (_adjuster->minimum() != prop->getMinValue())
_adjuster->setMinimum(prop->getMinValue());
if (_adjuster->maximum() != prop->getMaxValue())
_adjuster->setMaximum(prop->getMaxValue());
}
}
......
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