PeriDyno 1.0.0
Loading...
Searching...
No Matches
PCustomWidgets.cpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2011, T. Kroes <t.kroes@tudelft.nl>
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
7 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 - Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
11 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12*/
13
14#include "PCustomWidgets.h"
15
16namespace dyno
17{
18 QDoubleSlider::QDoubleSlider(QWidget* pParent /*= NULL*/) :
19 QSlider(pParent),
20 m_Multiplier(10000.0)
21 {
22 connect(this, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
23
24 setSingleStep(1);
25
26 setOrientation(Qt::Horizontal);
27 setFocusPolicy(Qt::NoFocus);
28 }
29
31 {
32 emit valueChanged((double)Value / m_Multiplier);
33 }
34
35 void QDoubleSlider::setValue(double Value, bool BlockSignals)
36 {
37 QSlider::blockSignals(BlockSignals);
38
39 QSlider::setValue(Value * m_Multiplier);
40
41 if (!BlockSignals)
42 emit valueChanged(Value);
43
44 QSlider::blockSignals(false);
45 }
46
47 void QDoubleSlider::setRange(double Min, double Max)
48 {
49 QSlider::setRange(Min * m_Multiplier, Max * m_Multiplier);
50
51 emit rangeChanged(Min, Max);
52 }
53
55 {
56 QSlider::setMinimum(Min * m_Multiplier);
57
58 emit rangeChanged(minimum(), maximum());
59 }
60
62 {
63 return QSlider::minimum() / m_Multiplier;
64 }
65
67 {
68 QSlider::setMaximum(Max * m_Multiplier);
69
70 emit rangeChanged(minimum(), maximum());
71 }
72
74 {
75 return QSlider::maximum() / m_Multiplier;
76 }
77
78 double QDoubleSlider::value() const
79 {
80 int Value = QSlider::value();
81 return (double)Value / m_Multiplier;
82 }
83
85 {
86 return QSize(30, 20);
87 }
88
89 QDoubleSpinner::QDoubleSpinner(QWidget* pParent /*= NULL*/) :
90 QDoubleSpinBox(pParent)
91 {
92 }
93
94 void QDoubleSpinner::setValue(double Value, bool BlockSignals)
95 {
96 blockSignals(BlockSignals);
97
98 QDoubleSpinBox::setValue(Value);
99
100 blockSignals(false);
101 }
102}
103
double maximum() const
double minimum() const
void setRange(double Min, double Max)
void setMaximum(double Max)
QDoubleSlider(QWidget *pParent=NULL)
void rangeChanged(double Min, double Max)
void setMinimum(double Min)
void setValue(int value)
void valueChanged(double Value)
void setValue(double Value, bool BlockSignals=false)
QDoubleSpinner(QWidget *pParent=NULL)
virtual QSize sizeHint() const
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25