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

intpropertywidget.cpp 6.87 KB
Newer Older
1
2
// ================================================================================================
// 
schultezub's avatar
schultezub committed
3
// This file is part of the CAMPVis Software Framework.
4
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2015, all rights reserved,
schultezub's avatar
schultezub committed
6
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
7
//      Chair for Computer Aided Medical Procedures
8
9
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
10
// 
schultezub's avatar
schultezub committed
11
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
12
// 
13
14
15
16
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 
// except in compliance with the License. You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
17
// 
18
19
20
21
// Unless required by applicable law or agreed to in writing, software distributed under the 
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific language governing permissions 
// and limitations under the License.
22
23
24
// 
// ================================================================================================

schultezub's avatar
schultezub committed
25
26
#include "intpropertywidget.h"

27
28
29
#include <QCheckBox>
#include <QTimer>
#include <QGridLayout>
30
#include <QPushButton>
31
32
#include <QWidget>

schultezub's avatar
schultezub committed
33
namespace campvis {
34
35
    IntPropertyWidget::IntPropertyWidget(IntProperty* property, DataContainer* dataContainer, QWidget* parent /*= 0*/)
        : AbstractPropertyWidget(property, false, dataContainer, parent)
36
        , _adjuster(0)
37
        , _timer(0)
schultezub's avatar
schultezub committed
38
    {
39
40
41
42
43
        _timer = new QTimer(this);
        _timer->setSingleShot(false);

        QWidget* widget = new QWidget(this);
        QGridLayout* layout = new QGridLayout(widget);
44
45
        layout->setSpacing(2);
        layout->setMargin(0);
46
47
        widget->setLayout(layout);

48
49
50
        _adjuster = new IntAdjusterWidget;
        _adjuster->setMinimum(property->getMinValue());
        _adjuster->setMaximum(property->getMaxValue());
51
        _adjuster->setSingleStep(property->getStepValue());
52
53
        _adjuster->setValue(property->getValue());
        layout->addWidget(_adjuster, 0, 0, 1, 2);
54

55
56
57
58
        _btnShowHideTimer = new QPushButton(tr("S"));
        _btnShowHideTimer->setFixedWidth(16);
        layout->addWidget(_btnShowHideTimer, 0, 2);

59
        _cbEnableTimer = new QCheckBox("Enable Timer", widget);
60
        _cbEnableTimer->setVisible(false);
61
        layout->addWidget(_cbEnableTimer, 1, 0);
schultezub's avatar
schultezub committed
62

63
64
65
66
        _sbInterval = new QSpinBox(widget);
        _sbInterval->setMinimum(1);
        _sbInterval->setMaximum(2000);
        _sbInterval->setValue(50);
67
68
        _sbInterval->setVisible(false);
        layout->addWidget(_sbInterval, 1, 1, 1, 2);
69
70
71
72

        addWidget(widget);

        connect(_timer, SIGNAL(timeout()), this, SLOT(onTimer()));
73
        connect(_adjuster, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
74
75
        connect(_cbEnableTimer, SIGNAL(stateChanged(int)), this, SLOT(onEnableTimerChanged(int)));
        connect(_sbInterval, SIGNAL(valueChanged(int)), this, SLOT(onIntervalValueChanged(int)));
76
        connect(_btnShowHideTimer, SIGNAL(clicked()), this, SLOT(onBtnSHTClicked()));
schultezub's avatar
schultezub committed
77
        property->s_minMaxChanged.connect(this, &IntPropertyWidget::onPropertyMinMaxChanged);
78
        property->s_stepChanged.connect(this, &IntPropertyWidget::onPropertyStepChanged);
schultezub's avatar
schultezub committed
79
80
81
    }

    IntPropertyWidget::~IntPropertyWidget() {
schultezub's avatar
schultezub committed
82
        static_cast<IntProperty*>(_property)->s_minMaxChanged.disconnect(this);
83
        static_cast<IntProperty*>(_property)->s_stepChanged.disconnect(this);
schultezub's avatar
schultezub committed
84
85
86
87
    }

    void IntPropertyWidget::updateWidgetFromProperty() {
        IntProperty* prop = static_cast<IntProperty*>(_property);
88
        _adjuster->blockSignals(true);
Christian Schulte zu Berge's avatar
Christian Schulte zu Berge committed
89
90
        if (_adjuster->value() != prop->getValue())
            _adjuster->setValue(prop->getValue());
91
        _adjuster->blockSignals(false);
schultezub's avatar
schultezub committed
92
93
94
    }

    void IntPropertyWidget::onValueChanged(int value) {
schultezub's avatar
schultezub committed
95
        ++_ignorePropertyUpdates;
schultezub's avatar
schultezub committed
96
97
        IntProperty* prop = static_cast<IntProperty*>(_property);
        prop->setValue(value);
schultezub's avatar
schultezub committed
98
        --_ignorePropertyUpdates;
schultezub's avatar
schultezub committed
99
100
101
    }

    void IntPropertyWidget::onPropertyMinMaxChanged(const AbstractProperty* property) {
schultezub's avatar
schultezub committed
102
        if (_ignorePropertyUpdates == 0) {
schultezub's avatar
schultezub committed
103
            IntProperty* prop = static_cast<IntProperty*>(_property);
Christian Schulte zu Berge's avatar
Christian Schulte zu Berge committed
104
105
106
107
            if (_adjuster->minimum() != prop->getMinValue())
                _adjuster->setMinimum(prop->getMinValue());
            if (_adjuster->maximum() != prop->getMaxValue())
                _adjuster->setMaximum(prop->getMaxValue());
schultezub's avatar
schultezub committed
108
109
        }
    }
schultezub's avatar
schultezub committed
110

111
112
113
114
115
116
117
    void IntPropertyWidget::onPropertyStepChanged(const AbstractProperty* property) {
        if (_ignorePropertyUpdates == 0) {
            IntProperty* prop = static_cast<IntProperty*>(_property);
            _adjuster->setSingleStep(prop->getStepValue());
        }
    }

118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
    void IntPropertyWidget::onIntervalValueChanged(int value) {
        _timer->setInterval(value);
    }

    void IntPropertyWidget::onEnableTimerChanged(int state) {
        if (state == Qt::Checked) {
            _timer->setInterval(_sbInterval->value());
            _timer->start();
        }
        else if (state == Qt::Unchecked) {
            _timer->stop();
        }
    }

    void IntPropertyWidget::onTimer() {
        IntProperty* prop = static_cast<IntProperty*>(_property);
        if (prop->getValue() < prop->getMaxValue())
            prop->increment();
        else
            prop->setValue(prop->getMinValue());
    }

140
141
142
143
144
145
    void IntPropertyWidget::onBtnSHTClicked() {
        _cbEnableTimer->setVisible(! _cbEnableTimer->isVisible());
        _sbInterval->setVisible(! _sbInterval->isVisible());
        _btnShowHideTimer->setText(_sbInterval->isVisible() ? tr("H") : tr("S"));
    }

146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
    IVec2PropertyWidget::IVec2PropertyWidget(PropertyType* property, DataContainer* dataContainer /*= nullptr*/, QWidget* parent /*= 0*/) : IVecPropertyWidget<2>(property, dataContainer, parent) {
        for (size_t i = 0; i < size; ++i) {
            connect(_adjusters[i], SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
        }
    }

    IVec3PropertyWidget::IVec3PropertyWidget(PropertyType* property, DataContainer* dataContainer /*= nullptr*/, QWidget* parent /*= 0*/) : IVecPropertyWidget<3>(property, dataContainer, parent) {
        for (size_t i = 0; i < size; ++i) {
            connect(_adjusters[i], SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
        }
    }

    IVec4PropertyWidget::IVec4PropertyWidget(PropertyType* property, DataContainer* dataContainer /*= nullptr*/, QWidget* parent /*= 0*/) : IVecPropertyWidget<4>(property, dataContainer, parent) {
        for (size_t i = 0; i < size; ++i) {
            connect(_adjusters[i], SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
        }
    }

schultezub's avatar
schultezub committed
164
}