Released version 6.1.3
This commit is contained in:
		
				commit
				
					
						a94503cb82
					
				
			
		
					 1885 changed files with 276310 additions and 0 deletions
				
			
		
							
								
								
									
										13
									
								
								playground/timescale/main.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								playground/timescale/main.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
#include <qapplication.h>
 | 
			
		||||
#include "mainwindow.h"
 | 
			
		||||
 | 
			
		||||
int main( int argc, char **argv )
 | 
			
		||||
{
 | 
			
		||||
    QApplication a( argc, argv );
 | 
			
		||||
 | 
			
		||||
    MainWindow window;
 | 
			
		||||
    window.resize( 800, 600 );
 | 
			
		||||
    window.show();
 | 
			
		||||
 | 
			
		||||
    return a.exec();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										58
									
								
								playground/timescale/mainwindow.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								playground/timescale/mainwindow.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,58 @@
 | 
			
		|||
#include "plot.h"
 | 
			
		||||
#include "panel.h"
 | 
			
		||||
#include "mainwindow.h"
 | 
			
		||||
#include <qwt_date.h>
 | 
			
		||||
#include <qwt_scale_widget.h>
 | 
			
		||||
#include <qlayout.h>
 | 
			
		||||
 | 
			
		||||
MainWindow::MainWindow( QWidget *parent ):
 | 
			
		||||
    QMainWindow( parent )
 | 
			
		||||
{
 | 
			
		||||
    Settings settings;
 | 
			
		||||
#if 1
 | 
			
		||||
    settings.startDateTime = QDateTime( QDate( 2012, 10, 27 ), QTime( 18, 5, 0, 0 ) );
 | 
			
		||||
    settings.endDateTime = QDateTime( QDate( 2012, 10, 28 ), QTime( 12, 12, 0, 0 ) );
 | 
			
		||||
#else
 | 
			
		||||
    settings.startDateTime = QDateTime( QDate( 2011, 5, 3 ), QTime( 0, 6, 0, 0 ) );
 | 
			
		||||
    settings.endDateTime = QDateTime( QDate( 2012, 3, 10 ), QTime( 0, 5, 0, 0 ) );
 | 
			
		||||
#endif
 | 
			
		||||
    settings.maxMajorSteps = 10;
 | 
			
		||||
    settings.maxMinorSteps = 8;
 | 
			
		||||
    settings.maxWeeks = -1;
 | 
			
		||||
 | 
			
		||||
    d_plot = new Plot();
 | 
			
		||||
    d_panel = new Panel();
 | 
			
		||||
    d_panel->setSettings( settings );
 | 
			
		||||
 | 
			
		||||
    QWidget *box = new QWidget( this );
 | 
			
		||||
 | 
			
		||||
    QHBoxLayout *layout = new QHBoxLayout( box );
 | 
			
		||||
    layout->addWidget( d_plot, 10 );
 | 
			
		||||
    layout->addWidget( d_panel );
 | 
			
		||||
 | 
			
		||||
    setCentralWidget( box );
 | 
			
		||||
 | 
			
		||||
    updatePlot();
 | 
			
		||||
 | 
			
		||||
    connect( d_panel, SIGNAL( edited() ), SLOT( updatePlot() ) );
 | 
			
		||||
    connect( d_plot->axisWidget( QwtPlot::yLeft ), 
 | 
			
		||||
        SIGNAL( scaleDivChanged() ), SLOT( updatePanel() ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::updatePlot()
 | 
			
		||||
{
 | 
			
		||||
    d_plot->blockSignals( true );
 | 
			
		||||
    d_plot->applySettings( d_panel->settings() );
 | 
			
		||||
    d_plot->blockSignals( false );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::updatePanel()
 | 
			
		||||
{
 | 
			
		||||
    const QwtScaleDiv scaleDiv = d_plot->axisScaleDiv( QwtPlot::yLeft );
 | 
			
		||||
 | 
			
		||||
    Settings settings = d_panel->settings();
 | 
			
		||||
    settings.startDateTime = QwtDate::toDateTime( scaleDiv.lowerBound(), Qt::LocalTime );
 | 
			
		||||
    settings.endDateTime = QwtDate::toDateTime( scaleDiv.upperBound(), Qt::LocalTime );
 | 
			
		||||
 | 
			
		||||
    d_panel->setSettings( settings );
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										20
									
								
								playground/timescale/mainwindow.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								playground/timescale/mainwindow.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,20 @@
 | 
			
		|||
#include <qmainwindow.h>
 | 
			
		||||
 | 
			
		||||
class Plot;
 | 
			
		||||
class Panel;
 | 
			
		||||
 | 
			
		||||
class MainWindow : public QMainWindow
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    MainWindow( QWidget *parent = 0 );
 | 
			
		||||
 | 
			
		||||
private Q_SLOTS:
 | 
			
		||||
    void updatePlot();
 | 
			
		||||
    void updatePanel();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    Plot *d_plot;
 | 
			
		||||
    Panel *d_panel;
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										95
									
								
								playground/timescale/panel.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								playground/timescale/panel.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,95 @@
 | 
			
		|||
#include "panel.h"
 | 
			
		||||
#include "settings.h"
 | 
			
		||||
#include <qwt_date.h>
 | 
			
		||||
#include <qdatetimeedit.h>
 | 
			
		||||
#include <qspinbox.h>
 | 
			
		||||
#include <qlayout.h>
 | 
			
		||||
#include <qlabel.h>
 | 
			
		||||
 | 
			
		||||
Panel::Panel( QWidget *parent ):
 | 
			
		||||
    QWidget( parent )
 | 
			
		||||
{
 | 
			
		||||
    // create widgets
 | 
			
		||||
 | 
			
		||||
    d_startDateTime = new QDateTimeEdit();
 | 
			
		||||
    d_startDateTime->setDisplayFormat( "M/d/yyyy h:mm AP :zzz" );
 | 
			
		||||
    d_startDateTime->setCalendarPopup( true );
 | 
			
		||||
 | 
			
		||||
    d_endDateTime = new QDateTimeEdit();
 | 
			
		||||
    d_endDateTime->setDisplayFormat( "M/d/yyyy h:mm AP :zzz" );
 | 
			
		||||
    d_endDateTime->setCalendarPopup( true );
 | 
			
		||||
    
 | 
			
		||||
    d_maxMajorSteps = new QSpinBox();
 | 
			
		||||
    d_maxMajorSteps->setRange( 0, 50 );
 | 
			
		||||
 | 
			
		||||
    d_maxMinorSteps = new QSpinBox();
 | 
			
		||||
    d_maxMinorSteps->setRange( 0, 50 );
 | 
			
		||||
 | 
			
		||||
    d_maxWeeks = new QSpinBox();
 | 
			
		||||
    d_maxWeeks->setRange( -1, 100 );
 | 
			
		||||
    d_maxWeeks->setSpecialValueText( "Disabled" );
 | 
			
		||||
 | 
			
		||||
    // layout
 | 
			
		||||
 | 
			
		||||
    QGridLayout *layout = new QGridLayout( this );
 | 
			
		||||
    layout->setAlignment( Qt::AlignLeft | Qt::AlignTop );
 | 
			
		||||
 | 
			
		||||
    int row = 0;
 | 
			
		||||
    layout->addWidget( new QLabel( "From" ), row, 0 );
 | 
			
		||||
    layout->addWidget( d_startDateTime, row, 1 );
 | 
			
		||||
 | 
			
		||||
    row++;
 | 
			
		||||
    layout->addWidget( new QLabel( "To" ), row, 0 );
 | 
			
		||||
    layout->addWidget( d_endDateTime, row, 1 );
 | 
			
		||||
 | 
			
		||||
    row++;
 | 
			
		||||
    layout->addWidget( new QLabel( "Max. Major Steps" ), row, 0 );
 | 
			
		||||
    layout->addWidget( d_maxMajorSteps, row, 1 );
 | 
			
		||||
 | 
			
		||||
    row++;
 | 
			
		||||
    layout->addWidget( new QLabel( "Max. Minor Steps" ), row, 0 );
 | 
			
		||||
    layout->addWidget( d_maxMinorSteps, row, 1 );
 | 
			
		||||
 | 
			
		||||
    row++;
 | 
			
		||||
    layout->addWidget( new QLabel( "Max Weeks" ), row, 0 );
 | 
			
		||||
    layout->addWidget( d_maxWeeks, row, 1 );
 | 
			
		||||
 | 
			
		||||
    connect( d_startDateTime,
 | 
			
		||||
        SIGNAL( dateTimeChanged( const QDateTime & ) ), SIGNAL( edited() ) );
 | 
			
		||||
    connect( d_endDateTime,
 | 
			
		||||
        SIGNAL( dateTimeChanged( const QDateTime & ) ), SIGNAL( edited() ) );
 | 
			
		||||
    connect( d_maxMajorSteps,
 | 
			
		||||
        SIGNAL( valueChanged( int ) ), SIGNAL( edited() ) );
 | 
			
		||||
    connect( d_maxMinorSteps,
 | 
			
		||||
        SIGNAL( valueChanged( int ) ), SIGNAL( edited() ) );
 | 
			
		||||
    connect( d_maxWeeks,
 | 
			
		||||
        SIGNAL( valueChanged( int ) ), SIGNAL( edited() ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Panel::setSettings( const Settings &settings )
 | 
			
		||||
{
 | 
			
		||||
    blockSignals( true );
 | 
			
		||||
 | 
			
		||||
    d_startDateTime->setDateTime( settings.startDateTime );
 | 
			
		||||
    d_endDateTime->setDateTime( settings.endDateTime );
 | 
			
		||||
 | 
			
		||||
    d_maxMajorSteps->setValue( settings.maxMajorSteps );
 | 
			
		||||
    d_maxMinorSteps->setValue( settings.maxMinorSteps );
 | 
			
		||||
    d_maxWeeks->setValue( settings.maxWeeks );
 | 
			
		||||
        
 | 
			
		||||
    blockSignals( false );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Settings Panel::settings() const
 | 
			
		||||
{
 | 
			
		||||
    Settings settings;
 | 
			
		||||
 | 
			
		||||
    settings.startDateTime = d_startDateTime->dateTime();
 | 
			
		||||
    settings.endDateTime = d_endDateTime->dateTime();
 | 
			
		||||
 | 
			
		||||
    settings.maxMajorSteps = d_maxMajorSteps->value();
 | 
			
		||||
    settings.maxMinorSteps = d_maxMinorSteps->value();
 | 
			
		||||
    settings.maxWeeks = d_maxWeeks->value();
 | 
			
		||||
 | 
			
		||||
    return settings;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										32
									
								
								playground/timescale/panel.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								playground/timescale/panel.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,32 @@
 | 
			
		|||
#ifndef _PANEL_
 | 
			
		||||
#define _PANEL_
 | 
			
		||||
 | 
			
		||||
#include "settings.h"
 | 
			
		||||
#include <qwidget.h>
 | 
			
		||||
 | 
			
		||||
class QDateTimeEdit;
 | 
			
		||||
class QSpinBox;
 | 
			
		||||
 | 
			
		||||
class Panel: public QWidget
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    Panel( QWidget *parent = NULL );
 | 
			
		||||
 | 
			
		||||
    void setSettings( const Settings &);
 | 
			
		||||
    Settings settings() const;
 | 
			
		||||
    
 | 
			
		||||
Q_SIGNALS:
 | 
			
		||||
    void edited();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    QDateTimeEdit* d_startDateTime;
 | 
			
		||||
    QDateTimeEdit* d_endDateTime;
 | 
			
		||||
 | 
			
		||||
    QSpinBox *d_maxMajorSteps;
 | 
			
		||||
    QSpinBox *d_maxMinorSteps;
 | 
			
		||||
    QSpinBox *d_maxWeeks;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										90
									
								
								playground/timescale/plot.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								playground/timescale/plot.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,90 @@
 | 
			
		|||
#include "plot.h"
 | 
			
		||||
#include "settings.h"
 | 
			
		||||
#include <qwt_date.h>
 | 
			
		||||
#include <qwt_date_scale_draw.h>
 | 
			
		||||
#include <qwt_date_scale_engine.h>
 | 
			
		||||
#include <qwt_plot_panner.h>
 | 
			
		||||
#include <qwt_plot_magnifier.h>
 | 
			
		||||
#include <qwt_plot_grid.h>
 | 
			
		||||
#include <qwt_plot_layout.h>
 | 
			
		||||
 | 
			
		||||
Plot::Plot( QWidget *parent ):
 | 
			
		||||
    QwtPlot( parent )
 | 
			
		||||
{
 | 
			
		||||
    setAutoFillBackground( true );
 | 
			
		||||
    setPalette( Qt::darkGray );
 | 
			
		||||
    setCanvasBackground( Qt::white );
 | 
			
		||||
 | 
			
		||||
    plotLayout()->setAlignCanvasToScales( true );
 | 
			
		||||
 | 
			
		||||
    initAxis( QwtPlot::yLeft, "Local Time", Qt::LocalTime );
 | 
			
		||||
    initAxis( QwtPlot::yRight, 
 | 
			
		||||
        "Coordinated Universal Time ( UTC )", Qt::UTC );
 | 
			
		||||
 | 
			
		||||
    QwtPlotPanner *panner = new QwtPlotPanner( canvas() );
 | 
			
		||||
    QwtPlotMagnifier *magnifier = new QwtPlotMagnifier( canvas() );
 | 
			
		||||
 | 
			
		||||
    for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
 | 
			
		||||
    {
 | 
			
		||||
        const bool on = axis == QwtPlot::yLeft ||
 | 
			
		||||
            axis == QwtPlot::yRight;
 | 
			
		||||
 | 
			
		||||
        enableAxis( axis, on );
 | 
			
		||||
        panner->setAxisEnabled( axis, on );
 | 
			
		||||
        magnifier->setAxisEnabled( axis, on );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QwtPlotGrid *grid = new QwtPlotGrid();
 | 
			
		||||
    grid->setMajorPen( Qt::black, 0, Qt::SolidLine );
 | 
			
		||||
    grid->setMinorPen( Qt::gray, 0 , Qt::SolidLine );
 | 
			
		||||
    grid->enableX( false );
 | 
			
		||||
    grid->enableXMin( false );
 | 
			
		||||
    grid->enableY( true );
 | 
			
		||||
    grid->enableYMin( true );
 | 
			
		||||
 | 
			
		||||
    grid->attach( this );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Plot::initAxis( int axis, 
 | 
			
		||||
    const QString& title, Qt::TimeSpec timeSpec )
 | 
			
		||||
{
 | 
			
		||||
    setAxisTitle( axis, title );
 | 
			
		||||
 | 
			
		||||
    QwtDateScaleDraw *scaleDraw = new QwtDateScaleDraw( timeSpec );
 | 
			
		||||
    QwtDateScaleEngine *scaleEngine = new QwtDateScaleEngine( timeSpec );
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
    if ( timeSpec == Qt::LocalTime )
 | 
			
		||||
    {
 | 
			
		||||
        scaleDraw->setTimeSpec( Qt::OffsetFromUTC );
 | 
			
		||||
        scaleDraw->setUtcOffset( 10 );
 | 
			
		||||
 | 
			
		||||
        scaleEngine->setTimeSpec( Qt::OffsetFromUTC );
 | 
			
		||||
        scaleEngine->setUtcOffset( 10 );
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
    setAxisScaleDraw( axis, scaleDraw );
 | 
			
		||||
    setAxisScaleEngine( axis, scaleEngine );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Plot::applySettings( const Settings &settings )
 | 
			
		||||
{
 | 
			
		||||
    applyAxisSettings( QwtPlot::yLeft, settings );
 | 
			
		||||
    applyAxisSettings( QwtPlot::yRight, settings );
 | 
			
		||||
 | 
			
		||||
    replot();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Plot::applyAxisSettings( int axis, const Settings &settings )
 | 
			
		||||
{
 | 
			
		||||
    QwtDateScaleEngine *scaleEngine = 
 | 
			
		||||
        static_cast<QwtDateScaleEngine *>( axisScaleEngine( axis ) );
 | 
			
		||||
 | 
			
		||||
    scaleEngine->setMaxWeeks( settings.maxWeeks );
 | 
			
		||||
    setAxisMaxMinor( axis, settings.maxMinorSteps );
 | 
			
		||||
    setAxisMaxMajor( axis, settings.maxMajorSteps );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    setAxisScale( axis, QwtDate::toDouble( settings.startDateTime ), 
 | 
			
		||||
        QwtDate::toDouble( settings.endDateTime ) );
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										23
									
								
								playground/timescale/plot.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								playground/timescale/plot.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,23 @@
 | 
			
		|||
#ifndef _PLOT_H_
 | 
			
		||||
#define _PLOT_H_
 | 
			
		||||
 | 
			
		||||
#include <qwt_plot.h>
 | 
			
		||||
 | 
			
		||||
class Settings;
 | 
			
		||||
 | 
			
		||||
class Plot: public QwtPlot
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT 
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    Plot( QWidget *parent = NULL );
 | 
			
		||||
 | 
			
		||||
public Q_SLOTS:
 | 
			
		||||
    void applySettings( const Settings & );
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    void initAxis( int axis, const QString& title, Qt::TimeSpec );
 | 
			
		||||
    void applyAxisSettings( int axis, const Settings & );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										25
									
								
								playground/timescale/settings.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								playground/timescale/settings.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,25 @@
 | 
			
		|||
#ifndef _SETTINGS_H_
 | 
			
		||||
#define _SETTINGS_H_ 1
 | 
			
		||||
 | 
			
		||||
#include <qdatetime.h>
 | 
			
		||||
 | 
			
		||||
class Settings
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    Settings():
 | 
			
		||||
        maxMajorSteps( 10 ),
 | 
			
		||||
        maxMinorSteps( 5 ),
 | 
			
		||||
        maxWeeks( -1 )
 | 
			
		||||
    {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    QDateTime startDateTime;
 | 
			
		||||
    QDateTime endDateTime;
 | 
			
		||||
 | 
			
		||||
    int maxMajorSteps;
 | 
			
		||||
    int maxMinorSteps;
 | 
			
		||||
 | 
			
		||||
    int maxWeeks;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										24
									
								
								playground/timescale/timescale.pro
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								playground/timescale/timescale.pro
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,24 @@
 | 
			
		|||
################################################################
 | 
			
		||||
# Qwt Widget Library
 | 
			
		||||
# 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}/../playground.pri )
 | 
			
		||||
 | 
			
		||||
TARGET       = timescale
 | 
			
		||||
 | 
			
		||||
HEADERS = \
 | 
			
		||||
    panel.h \
 | 
			
		||||
    plot.h \
 | 
			
		||||
    mainwindow.h
 | 
			
		||||
 | 
			
		||||
SOURCES = \
 | 
			
		||||
    panel.cpp \
 | 
			
		||||
    plot.cpp \
 | 
			
		||||
    mainwindow.cpp \
 | 
			
		||||
    main.cpp
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue