Add files from zip

This commit is contained in:
2023-10-31 09:22:42 +01:00
parent 6bacdc5f6d
commit 4dae68036f
2788 changed files with 492537 additions and 0 deletions

103
playground/svgmap/Plot.cpp Normal file
View File

@@ -0,0 +1,103 @@
/*****************************************************************************
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
#include "Plot.h"
#include <QwtPlotGraphicItem>
#include <QwtPlotLayout>
#include <QwtPlotPanner>
#include <QwtPlotMagnifier>
#include <QwtGraphic>
#define DEBUG_SCALE 0
#if DEBUG_SCALE
#include <QwtPlotGrid>
#endif
#include <QSvgRenderer>
#include <QFileDialog>
Plot::Plot( QWidget* parent )
: QwtPlot( parent )
, m_mapItem( NULL )
, m_mapRect( 0.0, 0.0, 100.0, 100.0 ) // something
{
#if DEBUG_SCALE
QwtPlotGrid* grid = new QwtPlotGrid();
grid->attach( this );
#else
/*
m_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 axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ )
setAxisVisible( axisPos, false );
#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 );
setCanvasBackground( Qt::white );
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 ( m_mapItem == NULL )
{
m_mapItem = new QwtPlotGraphicItem();
m_mapItem->attach( this );
}
QwtGraphic graphic;
QSvgRenderer renderer;
if ( renderer.load( fileName ) )
{
QPainter p( &graphic );
renderer.render( &p );
}
m_mapItem->setGraphic( m_mapRect, graphic );
rescale();
replot();
}
void Plot::rescale()
{
setAxisScale( QwtAxis::XBottom, m_mapRect.left(), m_mapRect.right() );
setAxisScale( QwtAxis::YLeft, m_mapRect.top(), m_mapRect.bottom() );
}
#include "moc_Plot.cpp"

33
playground/svgmap/Plot.h Normal file
View File

@@ -0,0 +1,33 @@
/*****************************************************************************
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
#pragma once
#include <QwtPlot>
#include <QRect>
class QwtPlotGraphicItem;
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();
QwtPlotGraphicItem* m_mapItem;
const QRectF m_mapRect;
};

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 92 KiB

View File

@@ -0,0 +1,65 @@
/*****************************************************************************
* Qwt Examples - Copyright (C) 2002 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
#include "Plot.h"
#include <QApplication>
#include <QMainWindow>
#ifndef QT_NO_FILEDIALOG
#include <QToolBar>
#include <QToolButton>
#endif
namespace
{
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
QToolButton* btnLoad = new QToolButton();
btnLoad->setText( "Load SVG" );
btnLoad->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
QToolBar* toolBar = new QToolBar();
toolBar->addWidget( btnLoad );
addToolBar( toolBar );
connect( btnLoad, SIGNAL(clicked()), plot, SLOT(loadSVG()) );
#endif
}
};
}
int main( int argc, char* argv[] )
{
QApplication app( argc, argv );
QString fileName;
if ( argc > 1 )
{
fileName = argv[1];
}
else
{
// see: https://commons.wikimedia.org/wiki/File:Schlosspark_Nymphenburg.svg
fileName = ":/svg/Schlosspark_Nymphenburg.svg";
}
MainWindow window( fileName );
window.resize( 600, 600 );
window.show();
return app.exec();
}

View File

@@ -0,0 +1,25 @@
######################################################################
# Qwt Examples - Copyright (C) 2002 Uwe Rathmann
# This file may be used under the terms of the 3-clause BSD License
######################################################################
include( $${PWD}/../playground.pri )
greaterThan(QT_MAJOR_VERSION, 4) {
!qtHaveModule(svg) {
error("Qt has been built without SVG support !")
}
}
TARGET = svgmap
QT += svg
RESOURCES += \
svgmap.qrc
HEADERS = \
Plot.h
SOURCES = \
Plot.cpp \
main.cpp

View File

@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/svg">
<file>Schlosspark_Nymphenburg.svg</file>
</qresource>
</RCC>