Released version 6.1.3
This commit is contained in:
		
				commit
				
					
						a94503cb82
					
				
			
		
					 1885 changed files with 276310 additions and 0 deletions
				
			
		
							
								
								
									
										49
									
								
								playground/svgmap/main.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								playground/svgmap/main.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,49 @@
 | 
			
		|||
#include <qapplication.h>
 | 
			
		||||
#include <qmainwindow.h>
 | 
			
		||||
#include <qtoolbar.h>
 | 
			
		||||
#include <qtoolbutton.h>
 | 
			
		||||
#include "plot.h"
 | 
			
		||||
 | 
			
		||||
class MainWindow: public QMainWindow
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    MainWindow( const QString &fileName )
 | 
			
		||||
    {
 | 
			
		||||
        Plot *plot = new Plot( this );
 | 
			
		||||
        if ( !fileName.isEmpty() )
 | 
			
		||||
            plot->loadSVG( fileName );
 | 
			
		||||
 | 
			
		||||
        setCentralWidget( plot );
 | 
			
		||||
 | 
			
		||||
#ifndef QT_NO_FILEDIALOG
 | 
			
		||||
 | 
			
		||||
        QToolBar *toolBar = new QToolBar( this );
 | 
			
		||||
 | 
			
		||||
        QToolButton *btnLoad = new QToolButton( toolBar );
 | 
			
		||||
 | 
			
		||||
        btnLoad->setText( "Load SVG" );
 | 
			
		||||
        btnLoad->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
 | 
			
		||||
        toolBar->addWidget( btnLoad );
 | 
			
		||||
 | 
			
		||||
        addToolBar( toolBar );
 | 
			
		||||
 | 
			
		||||
        connect( btnLoad, SIGNAL( clicked() ), plot, SLOT( loadSVG() ) );
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int main( int argc, char **argv )
 | 
			
		||||
{
 | 
			
		||||
    QApplication a( argc, argv );
 | 
			
		||||
 | 
			
		||||
    QString fileName;
 | 
			
		||||
    if ( argc > 1 )
 | 
			
		||||
        fileName = argv[1];
 | 
			
		||||
 | 
			
		||||
    MainWindow w( fileName );
 | 
			
		||||
    w.resize( 600, 400 );
 | 
			
		||||
    w.show();
 | 
			
		||||
 | 
			
		||||
    int rv = a.exec();
 | 
			
		||||
    return rv;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										79
									
								
								playground/svgmap/plot.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								playground/svgmap/plot.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,79 @@
 | 
			
		|||
#include <qfiledialog.h>
 | 
			
		||||
#include <qwt_plot_svgitem.h>
 | 
			
		||||
#include <qwt_plot_grid.h>
 | 
			
		||||
#include <qwt_plot_layout.h>
 | 
			
		||||
#include <qwt_plot_canvas.h>
 | 
			
		||||
#include <qwt_plot_panner.h>
 | 
			
		||||
#include <qwt_plot_magnifier.h>
 | 
			
		||||
#include "plot.h"
 | 
			
		||||
 | 
			
		||||
Plot::Plot( QWidget *parent ):
 | 
			
		||||
    QwtPlot( parent ),
 | 
			
		||||
    d_mapItem( NULL ),
 | 
			
		||||
    d_mapRect( 0.0, 0.0, 100.0, 100.0 ) // something
 | 
			
		||||
{
 | 
			
		||||
#if 1
 | 
			
		||||
    /*
 | 
			
		||||
       d_mapRect is only a reference for zooming, but
 | 
			
		||||
       the ranges are nothing useful for the user. So we
 | 
			
		||||
       hide the axes.
 | 
			
		||||
     */
 | 
			
		||||
    plotLayout()->setCanvasMargin( 0 );
 | 
			
		||||
    for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
 | 
			
		||||
        enableAxis( axis, false );
 | 
			
		||||
#else
 | 
			
		||||
    QwtPlotGrid *grid = new QwtPlotGrid();
 | 
			
		||||
    grid->attach( this );
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
      Navigation:
 | 
			
		||||
 | 
			
		||||
      Left Mouse Button: Panning
 | 
			
		||||
      Mouse Wheel:       Zooming In/Out
 | 
			
		||||
      Right Mouse Button: Reset to initial
 | 
			
		||||
    */
 | 
			
		||||
 | 
			
		||||
    ( void )new QwtPlotPanner( canvas() );
 | 
			
		||||
    ( void )new QwtPlotMagnifier( canvas() );
 | 
			
		||||
 | 
			
		||||
    canvas()->setFocusPolicy( Qt::WheelFocus );
 | 
			
		||||
    rescale();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifndef QT_NO_FILEDIALOG
 | 
			
		||||
 | 
			
		||||
void Plot::loadSVG()
 | 
			
		||||
{
 | 
			
		||||
    QString dir;
 | 
			
		||||
    const QString fileName = QFileDialog::getOpenFileName( NULL,
 | 
			
		||||
        "Load a Scaleable Vector Graphic (SVG) Map",
 | 
			
		||||
        dir, "SVG Files (*.svg)" );
 | 
			
		||||
 | 
			
		||||
    if ( !fileName.isEmpty() )
 | 
			
		||||
        loadSVG( fileName );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void Plot::loadSVG( const QString &fileName )
 | 
			
		||||
{
 | 
			
		||||
    if ( d_mapItem == NULL )
 | 
			
		||||
    {
 | 
			
		||||
        d_mapItem = new QwtPlotSvgItem();
 | 
			
		||||
        d_mapItem->attach( this );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    d_mapItem->loadFile( d_mapRect, fileName );
 | 
			
		||||
    rescale();
 | 
			
		||||
 | 
			
		||||
    replot();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Plot::rescale()
 | 
			
		||||
{
 | 
			
		||||
    setAxisScale( QwtPlot::xBottom,
 | 
			
		||||
        d_mapRect.left(), d_mapRect.right() );
 | 
			
		||||
    setAxisScale( QwtPlot::yLeft,
 | 
			
		||||
        d_mapRect.top(), d_mapRect.bottom() );
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										26
									
								
								playground/svgmap/plot.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								playground/svgmap/plot.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,26 @@
 | 
			
		|||
#include <qwt_plot.h>
 | 
			
		||||
#include <qrect.h>
 | 
			
		||||
 | 
			
		||||
class QwtPlotSvgItem;
 | 
			
		||||
 | 
			
		||||
class Plot: public QwtPlot
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    Plot( QWidget * = NULL );
 | 
			
		||||
 | 
			
		||||
public Q_SLOTS:
 | 
			
		||||
 | 
			
		||||
#ifndef QT_NO_FILEDIALOG
 | 
			
		||||
    void loadSVG();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    void loadSVG( const QString & );
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    void rescale();
 | 
			
		||||
 | 
			
		||||
    QwtPlotSvgItem *d_mapItem;
 | 
			
		||||
    const QRectF d_mapRect;
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										26
									
								
								playground/svgmap/svgmap.pro
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								playground/svgmap/svgmap.pro
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,26 @@
 | 
			
		|||
################################################################
 | 
			
		||||
# 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 )
 | 
			
		||||
 | 
			
		||||
!contains(QWT_CONFIG, QwtSvg) {
 | 
			
		||||
 | 
			
		||||
    message(Are you trying to build Qwt with the Qt Creator as Shadow Build ?)
 | 
			
		||||
    error(Qwt is configured without SVG support !)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TARGET   = svgmap
 | 
			
		||||
QT      += svg
 | 
			
		||||
 | 
			
		||||
HEADERS = \
 | 
			
		||||
    plot.h
 | 
			
		||||
 | 
			
		||||
SOURCES = \
 | 
			
		||||
    plot.cpp \
 | 
			
		||||
    main.cpp
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue