Add files from zip
This commit is contained in:
176
examples/controls/DialBox.cpp
Normal file
176
examples/controls/DialBox.cpp
Normal file
@@ -0,0 +1,176 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "DialBox.h"
|
||||
|
||||
#include <QwtDial>
|
||||
#include <QwtDialNeedle>
|
||||
#include <QwtScaleEngine>
|
||||
#include <QwtTransform>
|
||||
#include <QwtRoundScaleDraw>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
|
||||
DialBox::DialBox( QWidget* parent, int type )
|
||||
: QWidget( parent )
|
||||
{
|
||||
m_dial = createDial( type );
|
||||
|
||||
m_label = new QLabel( this );
|
||||
m_label->setAlignment( Qt::AlignCenter );
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout( this );;
|
||||
layout->setSpacing( 0 );
|
||||
layout->addWidget( m_dial, 10 );
|
||||
layout->addWidget( m_label );
|
||||
|
||||
connect( m_dial, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(setNum(double)) );
|
||||
|
||||
setNum( m_dial->value() );
|
||||
}
|
||||
|
||||
QwtDial* DialBox::createDial( int type ) const
|
||||
{
|
||||
QwtDial* dial = new QwtDial();
|
||||
dial->setTracking( true );
|
||||
dial->setFocusPolicy( Qt::StrongFocus );
|
||||
dial->setObjectName( QString( "Dial %1" ).arg( type + 1 ) );
|
||||
|
||||
QColor needleColor( Qt::red );
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
dial->setOrigin( 135.0 );
|
||||
dial->setScaleArc( 0.0, 270.0 );
|
||||
dial->setScaleMaxMinor( 4 );
|
||||
dial->setScaleMaxMajor( 10 );
|
||||
dial->setScale( -100.0, 100.0 );
|
||||
|
||||
needleColor = QColor( "Goldenrod" );
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
dial->setOrigin( 135.0 );
|
||||
dial->setScaleArc( 0.0, 270.0 );
|
||||
dial->setScaleMaxMinor( 10 );
|
||||
dial->setScaleMaxMajor( 10 );
|
||||
dial->setScale( 10.0, 0.0 );
|
||||
|
||||
QwtRoundScaleDraw* scaleDraw = new QwtRoundScaleDraw();
|
||||
scaleDraw->setSpacing( 8 );
|
||||
scaleDraw->enableComponent(
|
||||
QwtAbstractScaleDraw::Backbone, false );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MinorTick, 2 );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MediumTick, 4 );
|
||||
scaleDraw->setTickLength( QwtScaleDiv::MajorTick, 8 );
|
||||
dial->setScaleDraw( scaleDraw );
|
||||
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
dial->setOrigin( 150.0 );
|
||||
dial->setScaleArc( 0.0, 240.0 );
|
||||
|
||||
QwtLinearScaleEngine* scaleEngine = new QwtLinearScaleEngine( 2 );
|
||||
scaleEngine->setTransformation( new QwtPowerTransform( 2 ) );
|
||||
dial->setScaleEngine( scaleEngine );
|
||||
|
||||
QList< double > ticks[ QwtScaleDiv::NTickTypes ];
|
||||
ticks[ QwtScaleDiv::MajorTick ] << 0 << 4
|
||||
<< 16 << 32 << 64 << 96 << 128;
|
||||
ticks[ QwtScaleDiv::MediumTick ] << 24 << 48 << 80 << 112;
|
||||
ticks[ QwtScaleDiv::MinorTick ]
|
||||
<< 0.5 << 1 << 2
|
||||
<< 7 << 10 << 13
|
||||
<< 20 << 28
|
||||
<< 40 << 56
|
||||
<< 72 << 88
|
||||
<< 104 << 120;
|
||||
|
||||
dial->setScale( QwtScaleDiv( 0, 128, ticks ) );
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
dial->setOrigin( 135.0 );
|
||||
dial->setScaleArc( 0.0, 270.0 );
|
||||
dial->setScaleMaxMinor( 9 );
|
||||
dial->setScaleEngine( new QwtLogScaleEngine );
|
||||
dial->setScale( 1.0e-2, 1.0e2 );
|
||||
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
dial->setOrigin( 225.0 );
|
||||
dial->setScaleArc( 0.0, 360.0 );
|
||||
dial->setScaleMaxMinor( 5 );
|
||||
dial->setScaleStepSize( 20 );
|
||||
dial->setScale( 100.0, -100.0 );
|
||||
dial->setWrapping( true );
|
||||
dial->setTotalSteps( 40 );
|
||||
dial->setMode( QwtDial::RotateScale );
|
||||
dial->setValue( 70.0 );
|
||||
|
||||
needleColor = QColor( "DarkSlateBlue" );
|
||||
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
dial->setOrigin( 45.0 );
|
||||
dial->setScaleArc( 0.0, 225.0 );
|
||||
dial->setScaleMaxMinor( 5 );
|
||||
dial->setScaleMaxMajor( 10 );
|
||||
dial->setScale( 0.0, 10.0 );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QwtDialSimpleNeedle* needle = new QwtDialSimpleNeedle(
|
||||
QwtDialSimpleNeedle::Arrow, true, needleColor,
|
||||
QColor( Qt::gray ).lighter( 130 ) );
|
||||
dial->setNeedle( needle );
|
||||
|
||||
//const QColor base( QColor( "DimGray" ) );
|
||||
const QColor base( QColor( Qt::darkGray ).darker( 150 ) );
|
||||
|
||||
QPalette palette;
|
||||
palette.setColor( QPalette::Base, base );
|
||||
palette.setColor( QPalette::Window, base.darker( 150 ) );
|
||||
palette.setColor( QPalette::Mid, base.darker( 110 ) );
|
||||
palette.setColor( QPalette::Light, base.lighter( 170 ) );
|
||||
palette.setColor( QPalette::Dark, base.darker( 170 ) );
|
||||
palette.setColor( QPalette::Text, base.darker( 200 ).lighter( 800 ) );
|
||||
palette.setColor( QPalette::WindowText, base.darker( 200 ) );
|
||||
|
||||
dial->setPalette( palette );
|
||||
dial->setLineWidth( 4 );
|
||||
dial->setFrameShadow( QwtDial::Sunken );
|
||||
|
||||
return dial;
|
||||
}
|
||||
|
||||
void DialBox::setNum( double v )
|
||||
{
|
||||
QString text;
|
||||
text.setNum( v, 'f', 2 );
|
||||
|
||||
m_label->setText( text );
|
||||
}
|
||||
|
||||
#include "moc_DialBox.cpp"
|
||||
31
examples/controls/DialBox.h
Normal file
31
examples/controls/DialBox.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QwtDial;
|
||||
|
||||
class DialBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DialBox( QWidget* parent, int type );
|
||||
|
||||
private Q_SLOTS:
|
||||
void setNum( double v );
|
||||
|
||||
private:
|
||||
QwtDial* createDial( int type ) const;
|
||||
|
||||
QwtDial* m_dial;
|
||||
QLabel* m_label;
|
||||
};
|
||||
27
examples/controls/DialTab.cpp
Normal file
27
examples/controls/DialTab.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "DialTab.h"
|
||||
#include "DialBox.h"
|
||||
|
||||
#include <QLayout>
|
||||
|
||||
DialTab::DialTab( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
QGridLayout* layout = new QGridLayout( this );
|
||||
|
||||
const int numRows = 3;
|
||||
for ( int i = 0; i < 2 * numRows; i++ )
|
||||
{
|
||||
DialBox* dialBox = new DialBox( this, i );
|
||||
layout->addWidget( dialBox, i / numRows, i % numRows );
|
||||
}
|
||||
}
|
||||
|
||||
18
examples/controls/DialTab.h
Normal file
18
examples/controls/DialTab.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class DialTab : public QWidget
|
||||
{
|
||||
public:
|
||||
DialTab( QWidget* parent = NULL );
|
||||
};
|
||||
132
examples/controls/KnobBox.cpp
Normal file
132
examples/controls/KnobBox.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "KnobBox.h"
|
||||
|
||||
#include <QwtKnob>
|
||||
#include <QwtScaleEngine>
|
||||
#include <QwtTransform>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
|
||||
KnobBox::KnobBox( QWidget* parent, int knobType )
|
||||
: QWidget( parent )
|
||||
{
|
||||
m_knob = createKnob( knobType );
|
||||
m_knob->setKnobWidth( 100 );
|
||||
|
||||
m_label = new QLabel( this );
|
||||
m_label->setAlignment( Qt::AlignCenter );
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout( this );;
|
||||
layout->setSpacing( 0 );
|
||||
layout->addWidget( m_knob, 10 );
|
||||
layout->addWidget( m_label );
|
||||
layout->addStretch( 10 );
|
||||
|
||||
connect( m_knob, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(setNum(double)) );
|
||||
|
||||
setNum( m_knob->value() );
|
||||
}
|
||||
|
||||
QwtKnob* KnobBox::createKnob( int knobType ) const
|
||||
{
|
||||
QwtKnob* knob = new QwtKnob();
|
||||
knob->setTracking( true );
|
||||
|
||||
switch( knobType )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
knob->setKnobStyle( QwtKnob::Sunken );
|
||||
knob->setMarkerStyle( QwtKnob::Nub );
|
||||
knob->setWrapping( true );
|
||||
knob->setNumTurns( 4 );
|
||||
knob->setScaleStepSize( 10.0 );
|
||||
knob->setScale( 0, 400 );
|
||||
knob->setTotalSteps( 400 );
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
knob->setKnobStyle( QwtKnob::Sunken );
|
||||
knob->setMarkerStyle( QwtKnob::Dot );
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
knob->setKnobStyle( QwtKnob::Sunken );
|
||||
knob->setMarkerStyle( QwtKnob::Tick );
|
||||
|
||||
QwtLinearScaleEngine* scaleEngine = new QwtLinearScaleEngine( 2 );
|
||||
scaleEngine->setTransformation( new QwtPowerTransform( 2 ) );
|
||||
knob->setScaleEngine( scaleEngine );
|
||||
|
||||
QList< double > ticks[ QwtScaleDiv::NTickTypes ];
|
||||
ticks[ QwtScaleDiv::MajorTick ] << 0 << 4
|
||||
<< 16 << 32 << 64 << 96 << 128;
|
||||
ticks[ QwtScaleDiv::MediumTick ] << 24 << 48 << 80 << 112;
|
||||
ticks[ QwtScaleDiv::MinorTick ]
|
||||
<< 0.5 << 1 << 2
|
||||
<< 7 << 10 << 13
|
||||
<< 20 << 28
|
||||
<< 40 << 56
|
||||
<< 72 << 88
|
||||
<< 104 << 120;
|
||||
|
||||
knob->setScale( QwtScaleDiv( 0, 128, ticks ) );
|
||||
|
||||
knob->setTotalSteps( 100 );
|
||||
knob->setStepAlignment( false );
|
||||
knob->setSingleSteps( 1 );
|
||||
knob->setPageSteps( 5 );
|
||||
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
knob->setKnobStyle( QwtKnob::Flat );
|
||||
knob->setMarkerStyle( QwtKnob::Notch );
|
||||
knob->setScaleEngine( new QwtLogScaleEngine() );
|
||||
knob->setScaleStepSize( 1.0 );
|
||||
knob->setScale( 0.1, 1000.0 );
|
||||
knob->setScaleMaxMinor( 10 );
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
knob->setKnobStyle( QwtKnob::Raised );
|
||||
knob->setMarkerStyle( QwtKnob::Dot );
|
||||
knob->setWrapping( true );
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
knob->setKnobStyle( QwtKnob::Styled );
|
||||
knob->setMarkerStyle( QwtKnob::Triangle );
|
||||
knob->setTotalAngle( 180.0 );
|
||||
knob->setScale( 100, -100 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return knob;
|
||||
}
|
||||
|
||||
void KnobBox::setNum( double v )
|
||||
{
|
||||
QString text;
|
||||
text.setNum( v, 'f', 2 );
|
||||
|
||||
m_label->setText( text );
|
||||
}
|
||||
|
||||
#include "moc_KnobBox.cpp"
|
||||
32
examples/controls/KnobBox.h
Normal file
32
examples/controls/KnobBox.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QwtKnob;
|
||||
|
||||
class KnobBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KnobBox( QWidget* parent, int knobType );
|
||||
|
||||
private Q_SLOTS:
|
||||
void setNum( double v );
|
||||
|
||||
private:
|
||||
QwtKnob* createKnob( int knobType ) const;
|
||||
|
||||
QwtKnob* m_knob;
|
||||
QLabel* m_label;
|
||||
};
|
||||
27
examples/controls/KnobTab.cpp
Normal file
27
examples/controls/KnobTab.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "KnobTab.h"
|
||||
#include "KnobBox.h"
|
||||
|
||||
#include <QLayout>
|
||||
|
||||
KnobTab::KnobTab( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
QGridLayout* layout = new QGridLayout( this );
|
||||
|
||||
const int numRows = 3;
|
||||
for ( int i = 0; i < 2 * numRows; i++ )
|
||||
{
|
||||
KnobBox* knobBox = new KnobBox( this, i );
|
||||
layout->addWidget( knobBox, i / numRows, i % numRows );
|
||||
}
|
||||
}
|
||||
|
||||
18
examples/controls/KnobTab.h
Normal file
18
examples/controls/KnobTab.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class KnobTab : public QWidget
|
||||
{
|
||||
public:
|
||||
KnobTab( QWidget* parent = NULL );
|
||||
};
|
||||
189
examples/controls/SliderBox.cpp
Normal file
189
examples/controls/SliderBox.cpp
Normal file
@@ -0,0 +1,189 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SliderBox.h"
|
||||
|
||||
#include <QwtSlider>
|
||||
#include <QwtScaleEngine>
|
||||
#include <QwtTransform>
|
||||
#include <QwtPainter>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
|
||||
SliderBox::SliderBox( int sliderType, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
m_slider = createSlider( sliderType );
|
||||
|
||||
QFlags< Qt::AlignmentFlag > alignment;
|
||||
|
||||
if ( m_slider->orientation() == Qt::Horizontal )
|
||||
{
|
||||
if ( m_slider->scalePosition() == QwtSlider::TrailingScale )
|
||||
alignment = Qt::AlignBottom;
|
||||
else
|
||||
alignment = Qt::AlignTop;
|
||||
|
||||
alignment |= Qt::AlignHCenter;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_slider->scalePosition() == QwtSlider::TrailingScale )
|
||||
alignment = Qt::AlignRight;
|
||||
else
|
||||
alignment = Qt::AlignLeft;
|
||||
|
||||
alignment |= Qt::AlignVCenter;
|
||||
}
|
||||
|
||||
m_label = new QLabel( this );
|
||||
m_label->setAlignment( alignment );
|
||||
|
||||
const int labelWidth = QwtPainter::horizontalAdvance(
|
||||
m_label->fontMetrics(), "10000.9" );
|
||||
m_label->setFixedWidth( labelWidth );
|
||||
|
||||
connect( m_slider, SIGNAL(valueChanged(double)), SLOT(setNum(double)) );
|
||||
|
||||
QBoxLayout* layout;
|
||||
if ( m_slider->orientation() == Qt::Horizontal )
|
||||
layout = new QHBoxLayout( this );
|
||||
else
|
||||
layout = new QVBoxLayout( this );
|
||||
|
||||
layout->addWidget( m_slider );
|
||||
layout->addWidget( m_label );
|
||||
|
||||
setNum( m_slider->value() );
|
||||
}
|
||||
|
||||
QwtSlider* SliderBox::createSlider( int sliderType ) const
|
||||
{
|
||||
QwtSlider* slider = new QwtSlider();
|
||||
|
||||
switch( sliderType )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
slider->setOrientation( Qt::Horizontal );
|
||||
slider->setScalePosition( QwtSlider::TrailingScale );
|
||||
slider->setTrough( true );
|
||||
slider->setGroove( false );
|
||||
slider->setSpacing( 0 );
|
||||
slider->setHandleSize( QSize( 30, 16 ) );
|
||||
slider->setScale( 10.0, -10.0 );
|
||||
slider->setTotalSteps( 8 );
|
||||
slider->setSingleSteps( 1 );
|
||||
slider->setPageSteps( 1 );
|
||||
slider->setWrapping( true );
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
slider->setOrientation( Qt::Horizontal );
|
||||
slider->setScalePosition( QwtSlider::NoScale );
|
||||
slider->setTrough( true );
|
||||
slider->setGroove( true );
|
||||
slider->setScale( 0.0, 1.0 );
|
||||
slider->setTotalSteps( 100 );
|
||||
slider->setSingleSteps( 1 );
|
||||
slider->setPageSteps( 5 );
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
slider->setOrientation( Qt::Horizontal );
|
||||
slider->setScalePosition( QwtSlider::LeadingScale );
|
||||
slider->setTrough( false );
|
||||
slider->setGroove( true );
|
||||
slider->setHandleSize( QSize( 12, 25 ) );
|
||||
slider->setScale( 1000.0, 3000.0 );
|
||||
slider->setTotalSteps( 200.0 );
|
||||
slider->setSingleSteps( 2 );
|
||||
slider->setPageSteps( 10 );
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
slider->setOrientation( Qt::Horizontal );
|
||||
slider->setScalePosition( QwtSlider::TrailingScale );
|
||||
slider->setTrough( true );
|
||||
slider->setGroove( true );
|
||||
|
||||
QwtLinearScaleEngine* scaleEngine = new QwtLinearScaleEngine( 2 );
|
||||
scaleEngine->setTransformation( new QwtPowerTransform( 2 ) );
|
||||
slider->setScaleEngine( scaleEngine );
|
||||
slider->setScale( 0.0, 128.0 );
|
||||
slider->setTotalSteps( 100 );
|
||||
slider->setStepAlignment( false );
|
||||
slider->setSingleSteps( 1 );
|
||||
slider->setPageSteps( 5 );
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
slider->setOrientation( Qt::Vertical );
|
||||
slider->setScalePosition( QwtSlider::TrailingScale );
|
||||
slider->setTrough( false );
|
||||
slider->setGroove( true );
|
||||
slider->setScale( 100.0, 0.0 );
|
||||
slider->setInvertedControls( true );
|
||||
slider->setTotalSteps( 100 );
|
||||
slider->setPageSteps( 5 );
|
||||
slider->setScaleMaxMinor( 5 );
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
slider->setOrientation( Qt::Vertical );
|
||||
slider->setScalePosition( QwtSlider::NoScale );
|
||||
slider->setTrough( true );
|
||||
slider->setGroove( false );
|
||||
slider->setScale( 0.0, 100.0 );
|
||||
slider->setTotalSteps( 100 );
|
||||
slider->setPageSteps( 10 );
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
slider->setOrientation( Qt::Vertical );
|
||||
slider->setScalePosition( QwtSlider::LeadingScale );
|
||||
slider->setTrough( true );
|
||||
slider->setGroove( true );
|
||||
slider->setScaleEngine( new QwtLogScaleEngine );
|
||||
slider->setStepAlignment( false );
|
||||
slider->setHandleSize( QSize( 20, 32 ) );
|
||||
slider->setBorderWidth( 1 );
|
||||
slider->setScale( 1.0, 1.0e4 );
|
||||
slider->setTotalSteps( 100 );
|
||||
slider->setPageSteps( 10 );
|
||||
slider->setScaleMaxMinor( 9 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( slider )
|
||||
{
|
||||
QString name( "Slider %1" );
|
||||
slider->setObjectName( name.arg( sliderType ) );
|
||||
}
|
||||
|
||||
return slider;
|
||||
}
|
||||
|
||||
void SliderBox::setNum( double v )
|
||||
{
|
||||
QString text;
|
||||
text.setNum( v, 'f', 2 );
|
||||
|
||||
m_label->setText( text );
|
||||
}
|
||||
|
||||
#include "moc_SliderBox.cpp"
|
||||
31
examples/controls/SliderBox.h
Normal file
31
examples/controls/SliderBox.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QwtSlider;
|
||||
|
||||
class SliderBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SliderBox( int sliderType, QWidget* parent = NULL );
|
||||
|
||||
private Q_SLOTS:
|
||||
void setNum( double v );
|
||||
|
||||
private:
|
||||
QwtSlider* createSlider( int sliderType ) const;
|
||||
|
||||
QwtSlider* m_slider;
|
||||
QLabel* m_label;
|
||||
};
|
||||
47
examples/controls/SliderTab.cpp
Normal file
47
examples/controls/SliderTab.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SliderTab.h"
|
||||
#include "SliderBox.h"
|
||||
|
||||
#include <QLayout>
|
||||
|
||||
SliderTab::SliderTab( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
int i;
|
||||
|
||||
QBoxLayout* hLayout = createLayout( Qt::Vertical );
|
||||
for ( i = 0; i < 4; i++ )
|
||||
hLayout->addWidget( new SliderBox( i ) );
|
||||
hLayout->addStretch();
|
||||
|
||||
QBoxLayout* vLayout = createLayout( Qt::Horizontal );
|
||||
for ( ; i < 7; i++ )
|
||||
vLayout->addWidget( new SliderBox( i ) );
|
||||
|
||||
QBoxLayout* mainLayout = createLayout( Qt::Horizontal, this );
|
||||
mainLayout->addLayout( vLayout );
|
||||
mainLayout->addLayout( hLayout, 10 );
|
||||
}
|
||||
|
||||
QBoxLayout* SliderTab::createLayout(
|
||||
Qt::Orientation orientation, QWidget* widget )
|
||||
{
|
||||
QBoxLayout* layout =
|
||||
new QBoxLayout( QBoxLayout::LeftToRight, widget );
|
||||
|
||||
if ( orientation == Qt::Vertical )
|
||||
layout->setDirection( QBoxLayout::TopToBottom );
|
||||
|
||||
layout->setSpacing( 20 );
|
||||
layout->setContentsMargins( QMargins() );
|
||||
|
||||
return layout;
|
||||
}
|
||||
24
examples/controls/SliderTab.h
Normal file
24
examples/controls/SliderTab.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QBoxLayout;
|
||||
|
||||
class SliderTab : public QWidget
|
||||
{
|
||||
public:
|
||||
SliderTab( QWidget* parent = NULL );
|
||||
|
||||
private:
|
||||
QBoxLayout* createLayout( Qt::Orientation,
|
||||
QWidget* widget = NULL );
|
||||
};
|
||||
199
examples/controls/WheelBox.cpp
Normal file
199
examples/controls/WheelBox.cpp
Normal file
@@ -0,0 +1,199 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "WheelBox.h"
|
||||
|
||||
#include <QwtWheel>
|
||||
#include <QwtThermo>
|
||||
#include <QwtScaleEngine>
|
||||
#include <QwtTransform>
|
||||
#include <QwtColorMap>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
|
||||
WheelBox::WheelBox( Qt::Orientation orientation, int type, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
QWidget* box = createBox( orientation, type );
|
||||
m_label = new QLabel( this );
|
||||
m_label->setAlignment( Qt::AlignHCenter | Qt::AlignTop );
|
||||
|
||||
QBoxLayout* layout = new QVBoxLayout( this );
|
||||
layout->addWidget( box );
|
||||
layout->addWidget( m_label );
|
||||
|
||||
setNum( m_wheel->value() );
|
||||
|
||||
connect( m_wheel, SIGNAL(valueChanged(double)),
|
||||
this, SLOT(setNum(double)) );
|
||||
}
|
||||
|
||||
QWidget* WheelBox::createBox( Qt::Orientation orientation, int type )
|
||||
{
|
||||
m_wheel = new QwtWheel();
|
||||
m_wheel->setValue( 80 );
|
||||
m_wheel->setWheelWidth( 20 );
|
||||
m_wheel->setMass( 1.0 );
|
||||
|
||||
m_thermo = new QwtThermo();
|
||||
m_thermo->setOrientation( orientation );
|
||||
|
||||
if ( orientation == Qt::Horizontal )
|
||||
{
|
||||
m_thermo->setScalePosition( QwtThermo::LeadingScale );
|
||||
m_wheel->setOrientation( Qt::Vertical );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_thermo->setScalePosition( QwtThermo::TrailingScale );
|
||||
m_wheel->setOrientation( Qt::Horizontal );
|
||||
}
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
QwtLinearColorMap* colorMap = new QwtLinearColorMap();
|
||||
colorMap->setColorInterval( Qt::blue, Qt::red );
|
||||
m_thermo->setColorMap( colorMap );
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
QwtLinearColorMap* colorMap = new QwtLinearColorMap();
|
||||
colorMap->setMode( QwtLinearColorMap::FixedColors );
|
||||
|
||||
int idx = 4;
|
||||
|
||||
colorMap->setColorInterval( Qt::GlobalColor( idx ),
|
||||
Qt::GlobalColor( idx + 10 ) );
|
||||
for ( int i = 1; i < 10; i++ )
|
||||
{
|
||||
colorMap->addColorStop( i / 10.0,
|
||||
Qt::GlobalColor( idx + i ) );
|
||||
}
|
||||
|
||||
m_thermo->setColorMap( colorMap );
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
m_wheel->setRange( 10, 1000 );
|
||||
m_wheel->setSingleStep( 1.0 );
|
||||
|
||||
m_thermo->setScaleEngine( new QwtLogScaleEngine );
|
||||
m_thermo->setScaleMaxMinor( 10 );
|
||||
|
||||
m_thermo->setFillBrush( Qt::darkCyan );
|
||||
m_thermo->setAlarmBrush( Qt::magenta );
|
||||
m_thermo->setAlarmLevel( 500.0 );
|
||||
|
||||
m_wheel->setValue( 800 );
|
||||
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
m_wheel->setRange( -1000, 1000 );
|
||||
m_wheel->setSingleStep( 1.0 );
|
||||
m_wheel->setPalette( QColor( "Tan" ) );
|
||||
|
||||
QwtLinearScaleEngine* scaleEngine = new QwtLinearScaleEngine();
|
||||
scaleEngine->setTransformation( new QwtPowerTransform( 2 ) );
|
||||
|
||||
m_thermo->setScaleMaxMinor( 5 );
|
||||
m_thermo->setScaleEngine( scaleEngine );
|
||||
|
||||
QPalette pal = palette();
|
||||
pal.setColor( QPalette::Base, Qt::darkGray );
|
||||
pal.setColor( QPalette::ButtonText, QColor( "darkKhaki" ) );
|
||||
|
||||
m_thermo->setPalette( pal );
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
m_wheel->setRange( -100, 300 );
|
||||
m_wheel->setInverted( true );
|
||||
|
||||
QwtLinearColorMap* colorMap = new QwtLinearColorMap();
|
||||
colorMap->setColorInterval( Qt::darkCyan, Qt::yellow );
|
||||
m_thermo->setColorMap( colorMap );
|
||||
|
||||
m_wheel->setValue( 243 );
|
||||
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
m_thermo->setFillBrush( Qt::darkCyan );
|
||||
m_thermo->setAlarmBrush( Qt::magenta );
|
||||
m_thermo->setAlarmLevel( 60.0 );
|
||||
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
m_thermo->setOriginMode( QwtThermo::OriginMinimum );
|
||||
m_thermo->setFillBrush( QBrush( "DarkSlateBlue" ) );
|
||||
m_thermo->setAlarmBrush( QBrush( "DarkOrange" ) );
|
||||
m_thermo->setAlarmLevel( 60.0 );
|
||||
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
m_wheel->setRange( -100, 100 );
|
||||
|
||||
m_thermo->setOriginMode( QwtThermo::OriginCustom );
|
||||
m_thermo->setOrigin( 0.0 );
|
||||
m_thermo->setFillBrush( Qt::darkBlue );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double min = m_wheel->minimum();
|
||||
double max = m_wheel->maximum();
|
||||
|
||||
if ( m_wheel->isInverted() )
|
||||
qSwap( min, max );
|
||||
|
||||
m_thermo->setScale( min, max );
|
||||
m_thermo->setValue( m_wheel->value() );
|
||||
|
||||
connect( m_wheel, SIGNAL(valueChanged(double)),
|
||||
m_thermo, SLOT(setValue(double)) );
|
||||
|
||||
QWidget* box = new QWidget();
|
||||
|
||||
QBoxLayout* layout;
|
||||
|
||||
if ( orientation == Qt::Horizontal )
|
||||
layout = new QHBoxLayout( box );
|
||||
else
|
||||
layout = new QVBoxLayout( box );
|
||||
|
||||
layout->addWidget( m_thermo, Qt::AlignCenter );
|
||||
layout->addWidget( m_wheel );
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
void WheelBox::setNum( double v )
|
||||
{
|
||||
QString text;
|
||||
text.setNum( v, 'f', 2 );
|
||||
|
||||
m_label->setText( text );
|
||||
}
|
||||
|
||||
#include "moc_WheelBox.cpp"
|
||||
35
examples/controls/WheelBox.h
Normal file
35
examples/controls/WheelBox.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QwtThermo;
|
||||
class QwtWheel;
|
||||
|
||||
class WheelBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
WheelBox( Qt::Orientation,
|
||||
int type, QWidget* parent = NULL );
|
||||
|
||||
private Q_SLOTS:
|
||||
void setNum( double v );
|
||||
|
||||
private:
|
||||
QWidget* createBox( Qt::Orientation, int type );
|
||||
|
||||
private:
|
||||
QwtWheel* m_wheel;
|
||||
QwtThermo* m_thermo;
|
||||
QLabel* m_label;
|
||||
};
|
||||
38
examples/controls/WheelTab.cpp
Normal file
38
examples/controls/WheelTab.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "WheelTab.h"
|
||||
#include "WheelBox.h"
|
||||
|
||||
#include <QLayout>
|
||||
|
||||
WheelTab::WheelTab( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
const int numBoxes = 4;
|
||||
|
||||
QGridLayout* layout1 = new QGridLayout();
|
||||
for ( int i = 0; i < numBoxes; i++ )
|
||||
{
|
||||
WheelBox* box = new WheelBox( Qt::Vertical, i );
|
||||
layout1->addWidget( box, i / 2, i % 2 );
|
||||
}
|
||||
|
||||
QGridLayout* layout2 = new QGridLayout();
|
||||
for ( int i = 0; i < numBoxes; i++ )
|
||||
{
|
||||
WheelBox* box = new WheelBox( Qt::Horizontal, i + numBoxes );
|
||||
layout2->addWidget( box, i / 2, i % 2 );
|
||||
}
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout( this );
|
||||
layout->addLayout( layout1, 2 );
|
||||
layout->addLayout( layout2, 5 );
|
||||
}
|
||||
|
||||
18
examples/controls/WheelTab.h
Normal file
18
examples/controls/WheelTab.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class WheelTab : public QWidget
|
||||
{
|
||||
public:
|
||||
WheelTab( QWidget* parent = NULL );
|
||||
};
|
||||
34
examples/controls/controls.pro
Normal file
34
examples/controls/controls.pro
Normal file
@@ -0,0 +1,34 @@
|
||||
################################################################
|
||||
# Qwt Examples
|
||||
# Copyright (C) 1997 Josef Wilgen
|
||||
# Copyright (C) 2002 Uwe Rathmann
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the Qwt License, Version 1.0
|
||||
################################################################
|
||||
|
||||
include( $${PWD}/../examples.pri )
|
||||
|
||||
TARGET = controls
|
||||
|
||||
HEADERS = \
|
||||
SliderBox.h \
|
||||
SliderTab.h \
|
||||
WheelBox.h \
|
||||
WheelTab.h \
|
||||
KnobBox.h \
|
||||
KnobTab.h \
|
||||
DialBox.h \
|
||||
DialTab.h
|
||||
|
||||
SOURCES = \
|
||||
SliderBox.cpp \
|
||||
SliderTab.cpp \
|
||||
WheelBox.cpp \
|
||||
WheelTab.cpp \
|
||||
KnobBox.cpp \
|
||||
KnobTab.cpp \
|
||||
DialBox.cpp \
|
||||
DialTab.cpp \
|
||||
main.cpp
|
||||
|
||||
60
examples/controls/main.cpp
Normal file
60
examples/controls/main.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/*****************************************************************************
|
||||
* Qwt Examples
|
||||
* Copyright (C) 1997 Josef Wilgen
|
||||
* Copyright (C) 2002 Uwe Rathmann
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the Qwt License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SliderTab.h"
|
||||
#include "WheelTab.h"
|
||||
#include "KnobTab.h"
|
||||
#include "DialTab.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QTabWidget>
|
||||
|
||||
namespace
|
||||
{
|
||||
class TabWidget : public QTabWidget
|
||||
{
|
||||
public:
|
||||
TabWidget()
|
||||
{
|
||||
SliderTab* sliderTab = new SliderTab();
|
||||
sliderTab->setAutoFillBackground( true );
|
||||
sliderTab->setPalette( QColor( "DimGray" ) );
|
||||
|
||||
WheelTab* wheelTab = new WheelTab();
|
||||
wheelTab->setAutoFillBackground( true );
|
||||
wheelTab->setPalette( QColor( "Silver" ) );
|
||||
|
||||
KnobTab* knobTab = new KnobTab();
|
||||
knobTab->setAutoFillBackground( true );
|
||||
knobTab->setPalette( Qt::darkGray );
|
||||
|
||||
DialTab* dialTab = new DialTab();
|
||||
dialTab->setAutoFillBackground( true );
|
||||
dialTab->setPalette( Qt::darkGray );
|
||||
|
||||
addTab( sliderTab, "Slider" );
|
||||
addTab( wheelTab, "Wheel/Thermo" );
|
||||
addTab( knobTab, "Knob" );
|
||||
addTab( dialTab, "Dial" );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
|
||||
TabWidget tabWidget;
|
||||
|
||||
tabWidget.resize( 800, 600 );
|
||||
tabWidget.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user