Notice: If you are member of any public project or group, please make sure that your GitLab username is not the same as the LRZ identifier/Kennung (see https://gitlab.lrz.de/profile/account). Please change your username if necessary. For more information see the section "Public projects / Öffentliche Projekte" at https://doku.lrz.de/display/PUBLIC/GitLab . Thank you!

Commit ce6e4a7e authored by Jakob Weiss's avatar Jakob Weiss

Various fixes and updates

* increased overall font size
* introduced debugging diagnostic to detect when derived processors do not call AbstractProcessor::[de]init()
* fixed processors not adhering to this
* fixed some tab vs spaces problems
parent 03041535
......@@ -173,25 +173,25 @@ namespace campvis {
}
}
// Set Qt color palette to dark - adapted from https://gist.github.com/QuantumCD/6245215
QApplication::setStyle(QStyleFactory::create("Fusion"));
QPalette darkPalette;
darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
darkPalette.setColor(QPalette::WindowText, Qt::white);
darkPalette.setColor(QPalette::Base, QColor(25, 25, 25));
darkPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
darkPalette.setColor(QPalette::Text, Qt::white);
darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
darkPalette.setColor(QPalette::ButtonText, Qt::white);
darkPalette.setColor(QPalette::BrightText, Qt::red);
darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
darkPalette.setColor(QPalette::HighlightedText, Qt::black);
setPalette(darkPalette);
setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
// Set Qt color palette to dark - adapted from https://gist.github.com/QuantumCD/6245215
QApplication::setStyle(QStyleFactory::create("Fusion"));
QPalette darkPalette;
darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
darkPalette.setColor(QPalette::WindowText, Qt::white);
darkPalette.setColor(QPalette::Base, QColor(25, 25, 25));
darkPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
darkPalette.setColor(QPalette::Text, Qt::white);
darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
darkPalette.setColor(QPalette::ButtonText, Qt::white);
darkPalette.setColor(QPalette::BrightText, Qt::red);
darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
darkPalette.setColor(QPalette::HighlightedText, Qt::black);
setPalette(darkPalette);
setStyleSheet("QMainWindow * {font: 12pt;} QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
_initialized = true;
......
......@@ -122,6 +122,7 @@ namespace campvis {
getEventHandler()->addEventListenerToFront(this);
_geometryRenderer.init();
_tcp.init();
}
void DataContainerInspectorCanvas::deinit() {
......@@ -132,6 +133,7 @@ namespace campvis {
}
_geometryRenderer.deinit();
_tcp.deinit();
_handles.clear();
_localDataContainer.clear();
......
......@@ -30,24 +30,47 @@
namespace campvis {
AbstractPropertyWidget::AbstractPropertyWidget(AbstractProperty* property, bool displayBoxed /*= false*/,
DataContainer* dataContainer /*= nullptr*/, QWidget* parent /*= 0*/)
DataContainer* dataContainer /*= nullptr*/, QWidget* parent /*= 0*/, bool boxCheckable /*= false*/)
: QWidget(parent)
, _property(property)
, _dataContainer(dataContainer)
, _layout(0)
, _layout(nullptr)
, _groupBox(nullptr)
, _groupBoxInner(nullptr)
{
_ignorePropertyUpdates = 0;
if (displayBoxed) {
// For the boxed case, we have the following qt object tree:
// [ this ]
// -- [ outerLayout ] to hold and stretch the group box
// --[ groupBox ] to get the title, border and checkbox
// -- [ innerLayout ]
// -- [ _groupBoxInner ] to show and hide all widgets at once
// -- [ _layout ]
// -- PropertyWidget 1
// -- PropertyWidget 2
// ...
QBoxLayout* outerLayout = new QBoxLayout(QBoxLayout::LeftToRight, this);
QGroupBox* groupBox = new QGroupBox(QString::fromStdString(_property->getTitle()));
_groupBox = new QGroupBox(QString::fromStdString(_property->getTitle()));
outerLayout->setMargin(4);
outerLayout->addWidget(groupBox);
outerLayout->addWidget(_groupBox);
QBoxLayout* innerLayout = new QBoxLayout(QBoxLayout::LeftToRight, _groupBox);
_groupBoxInner = new QWidget();
innerLayout->addWidget(_groupBoxInner);
_layout = new QBoxLayout(QBoxLayout::TopToBottom, groupBox);
_layout = new QBoxLayout(QBoxLayout::TopToBottom, _groupBoxInner);
_layout->setSpacing(1);
_layout->setMargin(3);
if (boxCheckable) {
_groupBox->setCheckable(true);
_groupBox->setChecked(true);
connect(_groupBox, &QGroupBox::toggled, this, &AbstractPropertyWidget::onGroupBoxToggled);
}
}
else {
_titleLabel = new QLabel(QString::fromStdString(_property->getTitle() + ":"), this);
......@@ -59,14 +82,14 @@ namespace campvis {
}
_property->s_changed.connect(this, &AbstractPropertyWidget::onPropertyChanged);
connect(this, SIGNAL(s_propertyChanged(const AbstractProperty*)), this, SLOT(updateWidgetFromProperty()));
connect(this, &AbstractPropertyWidget::s_propertyChanged, this, &AbstractPropertyWidget::updateWidgetFromProperty);
}
AbstractPropertyWidget::~AbstractPropertyWidget() {
_property->s_changed.disconnect(this);
}
void AbstractPropertyWidget::setLabelVisibile(bool isVisible) {
void AbstractPropertyWidget::setLabelVisible(bool isVisible) {
if (_titleLabel)
_titleLabel->setVisible(isVisible);
}
......
......@@ -34,6 +34,8 @@
#include <QLabel>
#include <QWidget>
class QGroupBox;
namespace campvis {
class AbstractProperty;
class DataContainer;
......@@ -54,8 +56,10 @@ namespace campvis {
* \param displayBoxed Should the widget be displayed in a group box?
* \param dataContainer DataContainer to use (optional), defaults to nullptr. However, some derived classed might need a valid pointer here!
* \param parent Parent Qt widget, defaults to nullptr.
* \param boxCheckable If \a displayBoxed is true, indicates whether a checkbox should be displayed next to the name. If so,
* derived classes can re-implement the onGroupBoxToggled slot to get notified and react accordingly
*/
AbstractPropertyWidget(AbstractProperty* property, bool displayBoxed = false, DataContainer* dataContainer = nullptr, QWidget* parent = nullptr);
AbstractPropertyWidget(AbstractProperty* property, bool displayBoxed = false, DataContainer* dataContainer = nullptr, QWidget* parent = nullptr, bool boxCheckable = false);
/**
* Destructor
......@@ -65,9 +69,9 @@ namespace campvis {
/**
* Shows or hides the label that appears on the left hand side of the widget.
*
* \param isVisible Wether the label should be shown or not
* \param isVisible Whether the label should be shown or not
*/
void setLabelVisibile(bool isVisible);
void setLabelVisible(bool isVisible);
protected:
/**
......@@ -78,6 +82,9 @@ namespace campvis {
AbstractProperty* _property; ///< The property this widget handles
DataContainer* _dataContainer; ///< DataContainer to use (e.g. to populate GUI), may be 0!
QGroupBox *_groupBox; ///< The group box when \a displayBoxed was true in the constructor, otherwise this is a nullptr
QWidget *_groupBoxInner; ///< the content of the \a _groupBox
/// Semaphore acts as flag whether the widget shall ignore incoming signals from properties being updated.
tbb::atomic<int> _ignorePropertyUpdates;
......@@ -87,6 +94,11 @@ namespace campvis {
*/
virtual void updateWidgetFromProperty() {};
/**
* Gets called when the widget is displayed boxed and the group checkbox has been clicked
*/
virtual void onGroupBoxToggled(bool on) {};
signals:
/**
* Internal signal used to update the property widget in a thread-safe way.
......@@ -103,8 +115,8 @@ namespace campvis {
/// Slot getting called when the property has changed, so that the widget can be updated.
virtual void onPropertyChanged(const AbstractProperty* property);
QBoxLayout* _layout;
QLabel* _titleLabel;
QBoxLayout *_layout;
QLabel *_titleLabel;
};
}
......
......@@ -31,7 +31,7 @@ namespace campvis {
: AbstractPropertyWidget(property, false, dataContainer, parent)
, _button(0)
{
setLabelVisibile(false);
setLabelVisible(false);
_button = new QPushButton(QString::fromStdString(property->getTitle()), this);
connect(_button, SIGNAL(clicked(bool)), this, SLOT(onButtonClicked(bool)));
......
......@@ -25,9 +25,11 @@
#include "cgt/assert.h"
#include "metapropertywidget.h"
#include <QGroupBox>
namespace campvis {
MetaPropertyWidget::MetaPropertyWidget(MetaProperty* property, DataContainer* dc, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, true, dc, parent)
: AbstractPropertyWidget(property, true, dc, parent, true)
, _pcw(0)
{
//cgtAssert(_dataContainer != 0, "Pointer to DataContainer must not be 0.");
......@@ -35,13 +37,33 @@ namespace campvis {
_pcw = new PropertyCollectionWidget(this);
_pcw->updatePropCollection(property, _dataContainer);
addWidget(_pcw);
updateWidgetFromProperty();
}
MetaPropertyWidget::~MetaPropertyWidget() {
}
void MetaPropertyWidget::updateWidgetFromProperty() {
_groupBox->setChecked(!static_cast<MetaProperty*>(_property)->getFolded());
}
void MetaPropertyWidget::onGroupBoxToggled(bool on)
{
// Check if the toggle comes from user interaction
if (on != !static_cast<MetaProperty*>(_property)->getFolded()) {
// If so, we update the property
static_cast<MetaProperty*>(_property)->setFolded(!on);
}
// prevent unnecessary updates (may lead to endless invalidations)
if (_groupBox && on != _groupBox->isChecked())
_groupBox->setChecked(on);
// update the widget accordingly
if (_groupBoxInner) {
_groupBoxInner->setVisible(on);
_groupBox->setStyleSheet(on ? "" : "border:0;padding:0;");
}
}
}
\ No newline at end of file
......@@ -62,6 +62,9 @@ namespace campvis {
*/
virtual void updateWidgetFromProperty();
protected slots:
/// \see AbstractPropertyWidget::onGroupBoxToggled
void onGroupBoxToggled(bool on) override;
private:
PropertyCollectionWidget* _pcw;
......
......@@ -35,6 +35,10 @@ namespace campvis {
AbstractProcessor::AbstractProcessor()
: HasPropertyCollection()
#ifdef _DEBUG
, _baseInitWasCalled(false)
, _baseDeinitWasCalled(false)
#endif
{
_enabled = true;
_clockExecutionTime = false;
......@@ -44,19 +48,27 @@ namespace campvis {
}
AbstractProcessor::~AbstractProcessor() {
#ifdef _DEBUG
cgtAssert(_baseInitWasCalled, (std::string("AbstractProcessor::init() was never called for class ") + _instanceName + ". Most likely you forgot to add this call in your overridden init()!").c_str());
cgtAssert(_baseDeinitWasCalled, (std::string("AbstractProcessor::deinit() was never called for class ") + _instanceName + ". Most likely you forgot to add this call in your overridden deinit()!").c_str());
#endif
}
void AbstractProcessor::init() {
_instanceName = this->getName();
initAllProperties();
#ifdef _DEBUG
_baseInitWasCalled = true;
#endif
}
void AbstractProcessor::deinit() {
deinitAllProperties();
#ifdef _DEBUG
_baseDeinitWasCalled = true;
#endif
}
void AbstractProcessor::lockProcessor() {
// hopefully, it does not take too long.
while (_locked.compare_and_swap(true, false) == true)
......
......@@ -404,6 +404,11 @@ namespace campvis {
std::string _instanceName; ///< instance name displayed in the GUI
#ifdef _DEBUG
bool _baseInitWasCalled; ///< This is used for debug checks to make sure subclasses call init/deinit
bool _baseDeinitWasCalled; ///< This is used for debug checks to make sure subclasses call init/deinit
#endif
static const std::string loggerCat_;
};
......
......@@ -28,8 +28,9 @@ namespace campvis {
const std::string MetaProperty::loggerCat_ = "CAMPVis.core.datastructures.MetaProperty";
MetaProperty::MetaProperty(const std::string& name, const std::string& title)
MetaProperty::MetaProperty(const std::string& name, const std::string& title, bool folded)
: AbstractProperty(name, title)
, _folded(folded)
{
}
......@@ -53,5 +54,17 @@ namespace campvis {
}
}
void MetaProperty::setFolded(bool folded)
{
if (_folded != folded) {
_folded = folded;
s_changed.emitSignal(this);
}
}
bool MetaProperty::getFolded()
{
return _folded;
}
}
......@@ -45,8 +45,9 @@ namespace campvis {
* Creates a new MetaProperty
* \param name Property name (unchangable!)
* \param title Property title (e.g. used for GUI)
* \param folded whether the gui group is initially folded, displaying only the title
*/
MetaProperty(const std::string& name, const std::string& title);
MetaProperty(const std::string& name, const std::string& title, bool folded = false);
/**
* Virtual Destructor
......@@ -65,8 +66,20 @@ namespace campvis {
*/
void addPropertyCollection(HasPropertyCollection& pc);
/**
* Sets whether the meta group is displayed folded or not
*/
void setFolded(bool folded);
/**
* Returns whether the meta group is displayed folded or not
*/
bool getFolded();
protected:
bool _folded; ///< whether the property is folded or not
static const std::string loggerCat_;
};
......
......@@ -63,8 +63,8 @@ QtCanvas::QtCanvas(const std::string& title,
doubleBuffered_ = doubleBuffer();
stereoViewing_ = format().stereo();
connect(this, SIGNAL(s_sizeChangedExternally(int, int)), this, SLOT(sizeChangedExternally(int, int)));
connect(this, SIGNAL(fullScreenChanged(bool)), this, SLOT(changeFullScreen(bool)));
connect(this, &QtCanvas::s_sizeChangedExternally, this, &QtCanvas::sizeChangedExternally);
connect(this, &QtCanvas::fullScreenChanged, this, &QtCanvas::changeFullScreen);
}
QtCanvas::QtCanvas(QWidget* parent, bool shared, Qt::WindowFlags f, char* /*name*/)
......@@ -609,4 +609,14 @@ void QtCanvas::sizeChangedExternally(int w, int h) {
QWidget::resize(w, h);
}
void QtCanvas::changeFullScreen(bool fullscreen) {
fullscreen_ = fullscreen;
if (fullscreen) {
showFullScreen();
}
else {
showNormal();
}
}
} // namespace
......@@ -157,10 +157,9 @@ signals:
protected slots:
void sizeChangedExternally(int w, int h);
void changeFullScreen(bool fullscreen);
protected:
static QGLWidget* shareWidget_; ///< widget that this canvas shares the OpenGL context with
signals:
......
......@@ -74,6 +74,8 @@ namespace campvis {
}
void TrackballCameraProvider::init() {
AbstractProcessor::init();
onRenderTargetSizeChanged(_canvasSize);
}
......@@ -82,6 +84,8 @@ namespace campvis {
_canvasSize->s_changed.disconnect(this);
delete _trackball;
AbstractProcessor::deinit();
}
void TrackballCameraProvider::onEvent(cgt::Event* e) {
......
......@@ -87,7 +87,7 @@ namespace campvis {
}
void GenericImageReader::init() {
AbstractProcessor::init();
}
void GenericImageReader::deinit() {
......@@ -101,6 +101,7 @@ namespace campvis {
it->first->deinit();
}
}
AbstractProcessor::deinit();
}
void GenericImageReader::updateResult(DataContainer& data) {
......@@ -126,6 +127,8 @@ namespace campvis {
}
void GenericImageReader::addReader(AbstractImageReader* reader) {
reader->init();
MetaProperty* meta = new MetaProperty(reader->getName() + "MetaProp", reader->getName());
meta->addPropertyCollection(*reader);
meta->setVisible(false);
......
......@@ -53,7 +53,7 @@ namespace campvis {
, p_enableScribbling("EnableScribbling", "Enable Scribbling in Slice Views", false)
, p_seProperties("SliceExtractorProperties", "Slice Extractor Properties")
, p_vrProperties("VolumeRendererProperties", "Volume Renderer Properties")
, p_tcpProperties("CameraProviderProperties", "Camera Properties")
, p_tcpProperties("CameraProviderProperties", "Camera Properties", true)
, _shader(nullptr)
, _quad(nullptr)
, _tcp(viewportSizeProp)
......
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