PaniniParameters
::PaniniParameters( QWidget *parent
) : QWidget(0) // else get black hole in parent window {
ppar = parent;
genCtl( "upPitch", "pitch", -90, 90, 0,
tr
("pitch to world vertical, degrees"),
QString());
genCtl( "upRoll", "roll", -90, 90, 0,
tr
("roll to world vertical, degrees"),
QString());
genCtl( "camZoom", "zoom", 0, 100, 0,
tr("lens zoom, % of range"),
... <10 more like those> ...
// connect signals to our slots
}
void PaniniParameters
::genCtl( const QString &name,
double lo, double hi, double def,
{
PaniniSlide * ps = new PaniniSlide( this, label, lo, hi, def, tip, chkLbl );
ps->setObjectName( name );
names_addrs.insert( name, ps );
}
PaniniParameters::PaniniParameters( QWidget *parent )
: QWidget(0) // else get black hole in parent window
{
ppar = parent;
genCtl( "upPitch", "pitch", -90, 90, 0,
tr("pitch to world vertical, degrees"), QString());
genCtl( "upRoll", "roll", -90, 90, 0,
tr("roll to world vertical, degrees"), QString());
genCtl( "camZoom", "zoom", 0, 100, 0,
tr("lens zoom, % of range"),
QString("photo"));
... <10 more like those> ...
// connect signals to our slots
QMetaObject::connectSlotsByName( this );
}
void PaniniParameters::genCtl( const QString &name,
const QString &label,
double lo, double hi, double def,
const QString &tip,
const QString &chkLbl )
{
PaniniSlide * ps = new PaniniSlide( this, label, lo, hi, def, tip, chkLbl );
ps->setObjectName( name );
names_addrs.insert( name, ps );
}
To copy to clipboard, switch view to plain text mode
PaniniSlide
::PaniniSlide( QWidget * parent,
float lo, float hi,
float initv,
bool vert,
int minlen, int maxlen
)
{
if(minlen < 1) minlen = 121;
if(maxlen < minlen ) maxlen = 1001;
// set checkbox text, hide it if none
checkbox.setText( checkText );
checkbox.setVisible( !checkText.isEmpty() );
// set control data
setLabel( lblv );
setRange(lo, hi, initv );
// set control characteristics
label.setAlignment(Qt::AlignHCenter);
slider.setTickInterval(10);
slider.
setTickPosition(QSlider::TicksLeft);
// lay out the controls
if( vert ) {
slider.setOrientation ( Qt::Vertical );
slider.setMinimumHeight( minlen );
slider.setMaximumHeight( maxlen );
} else {
slider.setOrientation ( Qt::Horizontal );
slider.setMinimumWidth( minlen );
slider.setMaximumWidth( maxlen );
}
label.setFixedWidth( minW );
spinbox.setFixedWidth( minW );
lay->addWidget(&slider);
lay->addWidget(&label);
lay->addWidget(&spinbox);
lay->addWidget(&checkbox );
setLayout( lay );
// minimum widget size
setMinimumSize( lay->minimumSize() );
resize( minimumSize() );
// add tool tips
label.setToolTip( tip );
spinbox.setToolTip( tip );
slider.setToolTip(tr("\
Drag sliders or type numbers.\n\
Fine adjust: click number and\n\
use up and down arrow keys.\n\
Reset: left-dbl-click label.\n\
Options: right-dbl-click label.\
"));
//wire signals
connect( &slider, SIGNAL(valueChanged(int)),
this, SLOT(on_slider_valueChanged(int)));
connect( &spinbox, SIGNAL(valueChanged(double)),
this, SLOT(on_spinbox_valueChanged(double)));
connect( &checkbox, SIGNAL(stateChanged(int)),
this, SLOT(on_checkbox_stateChanged(int)));
// enable widget signals
slider.blockSignals(false);
spinbox.blockSignals(false);
checkbox.blockSignals(false);
}
PaniniSlide::PaniniSlide( QWidget * parent,
const QString & lblv,
float lo, float hi,
float initv,
const QString & tip,
const QString & checkText,
bool vert,
int minlen, int maxlen
)
: QWidget( parent )
{
if(minlen < 1) minlen = 121;
if(maxlen < minlen ) maxlen = 1001;
// set checkbox text, hide it if none
checkbox.setText( checkText );
checkbox.setVisible( !checkText.isEmpty() );
// set control data
setLabel( lblv );
setRange(lo, hi, initv );
// set control characteristics
label.setAlignment(Qt::AlignHCenter);
spinbox.setButtonSymbols(QAbstractSpinBox::NoButtons);
slider.setTickInterval(10);
slider.setTickPosition(QSlider::TicksLeft);
// lay out the controls
if( vert ) {
slider.setOrientation ( Qt::Vertical );
slider.setMinimumHeight( minlen );
slider.setMaximumHeight( maxlen );
slider.setSizePolicy( QSizePolicy::Fixed,
QSizePolicy::MinimumExpanding );
} else {
slider.setOrientation ( Qt::Horizontal );
slider.setMinimumWidth( minlen );
slider.setMaximumWidth( maxlen );
slider.setSizePolicy( QSizePolicy::MinimumExpanding,
QSizePolicy::Fixed );
}
label.setFixedWidth( minW );
spinbox.setFixedWidth( minW );
QBoxLayout::Direction d = vert ? QBoxLayout::TopToBottom
: QBoxLayout::RightToLeft;
QBoxLayout * lay = new QBoxLayout( d, this );
lay->addWidget(&slider);
lay->addWidget(&label);
lay->addWidget(&spinbox);
lay->addWidget(&checkbox );
setLayout( lay );
// minimum widget size
setMinimumSize( lay->minimumSize() );
resize( minimumSize() );
// add tool tips
label.setToolTip( tip );
spinbox.setToolTip( tip );
slider.setToolTip(tr("\
Drag sliders or type numbers.\n\
Fine adjust: click number and\n\
use up and down arrow keys.\n\
Reset: left-dbl-click label.\n\
Options: right-dbl-click label.\
"));
//wire signals
connect( &slider, SIGNAL(valueChanged(int)),
this, SLOT(on_slider_valueChanged(int)));
connect( &spinbox, SIGNAL(valueChanged(double)),
this, SLOT(on_spinbox_valueChanged(double)));
connect( &checkbox, SIGNAL(stateChanged(int)),
this, SLOT(on_checkbox_stateChanged(int)));
// enable widget signals
slider.blockSignals(false);
spinbox.blockSignals(false);
checkbox.blockSignals(false);
}
To copy to clipboard, switch view to plain text mode
Bookmarks