From: Clifford Wolf Date: Tue, 2 Sep 2014 01:52:46 +0000 (+0200) Subject: Removed yosys-svgviewer X-Git-Tag: yosys-0.4~175 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ee29ae2206b913fbb8cd41782001eed24c53b39d;p=yosys.git Removed yosys-svgviewer --- diff --git a/Makefile b/Makefile index 49a387263..ce4a68c55 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,6 @@ CONFIG := clang # features (the more the better) ENABLE_TCL := 1 -ENABLE_QT4 := 1 ENABLE_ABC := 1 ENABLE_PLUGINS := 1 ENABLE_READLINE := 1 @@ -111,10 +110,6 @@ CXXFLAGS += -pg LDFLAGS += -pg endif -ifeq ($(ENABLE_QT4),1) -TARGETS += yosys-svgviewer -endif - ifeq ($(ENABLE_ABC),1) TARGETS += yosys-abc endif @@ -215,10 +210,6 @@ yosys-config: yosys-config.in -e 's,@BINDIR@,$(DESTDIR)/bin,;' -e 's,@DATDIR@,$(DESTDIR)/share/yosys,;' < yosys-config.in > yosys-config $(Q) chmod +x yosys-config -yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp - $(P) cd libs/svgviewer && $(QMAKE) && $(MAKE) $(S) - $(Q) cp `find libs/svgviewer -name svgviewer -type f` yosys-svgviewer - abc/abc-$(ABCREV): $(P) ifneq ($(ABCREV),default) @@ -288,7 +279,6 @@ clean: rm -f $(OBJS) $(GENFILES) $(TARGETS) $(EXTRA_TARGETS) rm -f kernel/version_*.o kernel/version_*.cc abc/abc-[0-9a-f]* rm -f libs/*/*.d frontends/*/*.d passes/*/*.d backends/*/*.d kernel/*.d techlibs/*/*.d - test ! -f libs/svgviewer/Makefile || make -C libs/svgviewer distclean clean-abc: make -C abc clean @@ -319,7 +309,6 @@ config-gcc-4.6: clean config-emcc: clean echo 'CONFIG := emcc' > Makefile.conf echo 'ENABLE_TCL := 0' >> Makefile.conf - echo 'ENABLE_QT4 := 0' >> Makefile.conf echo 'ENABLE_ABC := 0' >> Makefile.conf echo 'ENABLE_PLUGINS := 0' >> Makefile.conf echo 'ENABLE_READLINE := 0' >> Makefile.conf diff --git a/README b/README index 2c7703a15..7e8a42a86 100644 --- a/README +++ b/README @@ -50,15 +50,13 @@ Getting Started You need a C++ compiler with C++11 support (up-to-date CLANG or GCC is recommended) and some standard tools such as GNU Flex, GNU Bison, and GNU Make. -The Qt4 library is needed for the yosys SVG viewer, that is used to display -schematics, the minisat library is required for the SAT features in yosys -and TCL for the scripting functionality. The extensive test suite requires -Icarus Verilog. For example on Ubuntu Linux 12.04 LTS the following commands -will install all prerequisites for building yosys: - - $ yosys_deps="git g++ clang make bison flex libreadline-dev - tcl8.5-dev zlib1g-dev libqt4-dev libffi-dev - mercurial iverilog graphviz xdot" +TCL, readline and libffi are optional (see ENABLE_* settings in Makefile). +Xdot (graphviz) is used by the "show" command in yosys to display schematics. +For example on Ubuntu Linux 14.04 LTS the following commands will install all +prerequisites for building yosys: + + $ yosys_deps="build-essential clang bison flex libreadline-dev + tcl8.5-dev libffi-dev git mercurial graphviz xdot" $ sudo apt-get install $yosys_deps There are also pre-compiled packages for Yosys on Ubuntu. Visit the Yosys @@ -66,12 +64,10 @@ download page to learn more about this: http://www.clifford.at/yosys/download.html -To configure the build system to use a specific set of compiler and -build configuration, use one of +To configure the build system to use a specific compiler, use one of - $ make config-clang-debug - $ make config-gcc-debug - $ make config-release + $ make config-clang + $ make config-gcc For other compilers and build configurations it might be necessary to make some changes to the config section of the @@ -118,7 +114,7 @@ some simple optimizations: yosys> proc; opt -display design netlist using the yosys svg viewer: +display design netlist using xdot: yosys> show @@ -156,17 +152,20 @@ commands in the synthesis script: $ ./yosys -o synth.v tests/simple/fiedler-cooley.v synth.ys -The following synthesis script works reasonable for all designs: +The following very basic synthesis script should work well with all designs: # check design hierarchy hierarchy - # translate processes (always blocks) and memories (arrays) - proc; memory; opt + # translate processes (always blocks) + proc; opt # detect and optimize FSM encodings fsm; opt + # implement memories (arrays) + memory; opt + # convert to gate logic techmap; opt @@ -175,7 +174,7 @@ in the liberty file mycells.lib, the following synthesis script will synthesize for the given cell library: # the high-level stuff - hierarchy; proc; memory; opt; fsm; opt + hierarchy; proc; fsm; opt; memory; opt # mapping to internal cell library techmap; opt diff --git a/libs/svgviewer/.gitignore b/libs/svgviewer/.gitignore deleted file mode 100644 index b46f84a66..000000000 --- a/libs/svgviewer/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -Makefile -moc_mainwindow.cpp -moc_svgview.cpp -qrc_svgviewer.cpp -svgviewer -svgviewer.app diff --git a/libs/svgviewer/files/bubbles.svg b/libs/svgviewer/files/bubbles.svg deleted file mode 100644 index 51730124a..000000000 --- a/libs/svgviewer/files/bubbles.svg +++ /dev/null @@ -1,215 +0,0 @@ - - - - Spheres - Semi-transparent bubbles on a colored background. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/svgviewer/files/cubic.svg b/libs/svgviewer/files/cubic.svg deleted file mode 100644 index 492bb72b8..000000000 --- a/libs/svgviewer/files/cubic.svg +++ /dev/null @@ -1,77 +0,0 @@ - - - Example cubic02 - cubic Bezier commands in path data - Picture showing examples of "C" and "S" commands, - along with annotations showing the control points - and end points - - - - - - - - - - - - M100,200 C100,100 400,100 400,200 - - - - - - - - - - M100,500 C25,400 475,400 400,500 - - - - - - - - - - M100,800 C175,700 325,700 400,800 - - - - - - - - - - M600,200 C675,100 975,100 900,200 - - - - - - - - - - M600,500 C600,350 900,650 900,500 - - - - - - - - - - - - - - - M600,800 C625,700 725,700 750,800 - S875,900 900,800 - diff --git a/libs/svgviewer/files/spheres.svg b/libs/svgviewer/files/spheres.svg deleted file mode 100644 index b23164bce..000000000 --- a/libs/svgviewer/files/spheres.svg +++ /dev/null @@ -1,72 +0,0 @@ - - - Spheres - Gradient filled spheres with different colors. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/svgviewer/main.cpp b/libs/svgviewer/main.cpp deleted file mode 100644 index 34866f854..000000000 --- a/libs/svgviewer/main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#ifndef QT_NO_OPENGL -#include -#endif - -#include "mainwindow.h" - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(svgviewer); - - QApplication app(argc, argv); - - MainWindow window; - if (argc == 2) - window.openFile(argv[1]); - else - window.openFile(":/files/bubbles.svg"); -#if defined(Q_OS_SYMBIAN) - window.showMaximized(); -#else - window.show(); -#endif - return app.exec(); -} diff --git a/libs/svgviewer/mainwindow.cpp b/libs/svgviewer/mainwindow.cpp deleted file mode 100644 index 70da140eb..000000000 --- a/libs/svgviewer/mainwindow.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwindow.h" - -#include -#include -#include - -#include "svgview.h" - -MainWindow::MainWindow() - : QMainWindow() - , m_view(new SvgView) - , m_watcher(NULL) - , m_filehandle(NULL) -{ - QMenu *fileMenu = new QMenu(tr("&File"), this); - QAction *openAction = fileMenu->addAction(tr("&Open...")); - openAction->setShortcut(QKeySequence(tr("Ctrl+O"))); - QAction *quitAction = fileMenu->addAction(tr("E&xit")); - quitAction->setShortcuts(QKeySequence::Quit); - - menuBar()->addMenu(fileMenu); - - QMenu *viewMenu = new QMenu(tr("&View"), this); - - m_interactiveAction = viewMenu->addAction(tr("&Interactive")); - m_interactiveAction->setEnabled(false); - m_interactiveAction->setCheckable(true); - m_interactiveAction->setChecked(false); - connect(m_interactiveAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewInteractive(bool))); - - m_backgroundAction = viewMenu->addAction(tr("&Background")); - m_backgroundAction->setEnabled(false); - m_backgroundAction->setCheckable(true); - m_backgroundAction->setChecked(false); - m_backgroundAction->setVisible(false); - connect(m_backgroundAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewBackground(bool))); - - m_outlineAction = viewMenu->addAction(tr("&Outline")); - m_outlineAction->setEnabled(false); - m_outlineAction->setCheckable(true); - m_outlineAction->setChecked(true); - connect(m_outlineAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewOutline(bool))); - - menuBar()->addMenu(viewMenu); - - QMenu *rendererMenu = new QMenu(tr("&Renderer"), this); - m_nativeAction = rendererMenu->addAction(tr("&Native")); - m_nativeAction->setCheckable(true); - m_nativeAction->setChecked(true); -#ifndef QT_NO_OPENGL - m_glAction = rendererMenu->addAction(tr("&OpenGL")); - m_glAction->setCheckable(true); -#endif - m_imageAction = rendererMenu->addAction(tr("&Image")); - m_imageAction->setCheckable(true); - -#ifndef QT_NO_OPENGL - rendererMenu->addSeparator(); - m_highQualityAntialiasingAction = rendererMenu->addAction(tr("&High Quality Antialiasing")); - m_highQualityAntialiasingAction->setEnabled(false); - m_highQualityAntialiasingAction->setCheckable(true); - m_highQualityAntialiasingAction->setChecked(false); - connect(m_highQualityAntialiasingAction, SIGNAL(toggled(bool)), m_view, SLOT(setHighQualityAntialiasing(bool))); -#endif - - QActionGroup *rendererGroup = new QActionGroup(this); - rendererGroup->addAction(m_nativeAction); -#ifndef QT_NO_OPENGL - rendererGroup->addAction(m_glAction); -#endif - rendererGroup->addAction(m_imageAction); - - menuBar()->addMenu(rendererMenu); - - connect(openAction, SIGNAL(triggered()), this, SLOT(openFile())); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - connect(rendererGroup, SIGNAL(triggered(QAction*)), - this, SLOT(setRenderer(QAction*))); - - setCentralWidget(m_view); - setWindowTitle(tr("Yosys SVG Viewer")); -} - -void MainWindow::openFile(const QString &path, bool reload) -{ - QString fileName; - if (path.isNull()) - fileName = QFileDialog::getOpenFileName(this, tr("Open SVG File"), - m_currentPath, "SVG files (*.svg *.svgz *.svg.gz)"); - else - fileName = path; - - if (m_watcher) { - delete m_watcher; - m_watcher = NULL; - } - if (m_filehandle) { - fclose(m_filehandle); - m_filehandle = NULL; - } - - if (!fileName.isEmpty()) { - QFile file(fileName); - if (!file.exists()) { - QMessageBox::critical(this, tr("Open SVG File"), - QString("Could not open file '%1'.").arg(fileName)); - - m_interactiveAction->setEnabled(false); - m_outlineAction->setEnabled(false); - m_backgroundAction->setEnabled(false); - return; - } - - QTransform oldTransform = m_view->transform(); - m_view->openFile(file); - - if (!fileName.startsWith(":/")) - { - m_currentPath = fileName; - setWindowTitle(tr("%1 - Yosys SVG Viewer").arg(m_currentPath)); - - // just keep the file open so this process is found using 'fuser' - m_filehandle = fopen(fileName.toAscii(), "r"); - - m_watcher = new QFileSystemWatcher(this); - m_watcher->addPath(fileName); - connect(m_watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(reloadFile())); - } - - m_interactiveAction->setEnabled(true); - m_outlineAction->setEnabled(true); - m_backgroundAction->setEnabled(true); - - if (reload) - m_view->setTransform(oldTransform); - else - resize(m_view->sizeHint() + QSize(80, 80 + menuBar()->height())); - } -} - -void MainWindow::reloadFile() -{ - // give the writer ~100 ms to finish writing - usleep(100000); - openFile(m_currentPath, true); -} - -void MainWindow::setRenderer(QAction *action) -{ -#ifndef QT_NO_OPENGL - m_highQualityAntialiasingAction->setEnabled(false); -#endif - - if (action == m_nativeAction) - m_view->setRenderer(SvgView::Native); -#ifndef QT_NO_OPENGL - else if (action == m_glAction) { - m_highQualityAntialiasingAction->setEnabled(true); - m_view->setRenderer(SvgView::OpenGL); - } -#endif - else if (action == m_imageAction) { - m_view->setRenderer(SvgView::Image); - } -} diff --git a/libs/svgviewer/mainwindow.h b/libs/svgviewer/mainwindow.h deleted file mode 100644 index dfb5586d4..000000000 --- a/libs/svgviewer/mainwindow.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include - -class SvgView; - -QT_BEGIN_NAMESPACE -class QAction; -class QGraphicsView; -class QGraphicsScene; -class QGraphicsRectItem; -class QFileSystemWatcher; -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - -public slots: - void openFile(const QString &path = QString(), bool reload = false); - void setRenderer(QAction *action); - void reloadFile(); - -private: - QAction *m_nativeAction; - QAction *m_glAction; - QAction *m_imageAction; - QAction *m_highQualityAntialiasingAction; - QAction *m_interactiveAction; - QAction *m_backgroundAction; - QAction *m_outlineAction; - - SvgView *m_view; - - QString m_currentPath; - QFileSystemWatcher *m_watcher; - FILE *m_filehandle; -}; - -#endif diff --git a/libs/svgviewer/svgview.cpp b/libs/svgviewer/svgview.cpp deleted file mode 100644 index 5a1a5ab29..000000000 --- a/libs/svgviewer/svgview.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "svgview.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef QT_NO_OPENGL -#include -#endif - -SvgView::SvgView(QWidget *parent) - : QGraphicsView(parent) - , m_renderer(Native) - , m_svgItem(0) - , m_webview(0) - , m_backgroundItem(0) - , m_outlineItem(0) -{ - setScene(new QGraphicsScene(this)); - setTransformationAnchor(AnchorUnderMouse); - setDragMode(ScrollHandDrag); - setViewportUpdateMode(FullViewportUpdate); - - // Prepare background check-board pattern - QPixmap tilePixmap(64, 64); - tilePixmap.fill(Qt::white); - QPainter tilePainter(&tilePixmap); - QColor color(220, 220, 220); - tilePainter.fillRect(0, 0, 32, 32, color); - tilePainter.fillRect(32, 32, 32, 32, color); - tilePainter.end(); - - setBackgroundBrush(tilePixmap); -} - -void SvgView::drawBackground(QPainter *p, const QRectF &) -{ - p->save(); - p->resetTransform(); - p->drawTiledPixmap(viewport()->rect(), backgroundBrush().texture()); - p->restore(); -} - -void SvgView::openFile(const QFile &file) -{ - if (!file.exists()) - return; - - QGraphicsScene *s = scene(); - - fn = file.fileName(); - if (fn[0] != '/') { - char cwd_buffer[4096]; - if (getcwd(cwd_buffer, 4096) != NULL) - fn = cwd_buffer + ("/" + fn); - } - - bool drawBackground = (m_backgroundItem ? m_backgroundItem->isVisible() : false); - bool drawOutline = (m_outlineItem ? m_outlineItem->isVisible() : true); - bool useWebview = (m_webview ? m_webview->isVisible() : false); - - s->clear(); - resetTransform(); - - m_svgItem = new QGraphicsSvgItem(file.fileName()); - m_svgItem->setFlags(QGraphicsItem::ItemClipsToShape); - m_svgItem->setCacheMode(QGraphicsItem::NoCache); - m_svgItem->setVisible(!useWebview); - m_svgItem->setZValue(1); - s->addItem(m_svgItem); - - if (useWebview) { - m_webview = new QGraphicsWebView(); - m_webview->load(QUrl::fromLocalFile(fn)); - m_webview->setResizesToContents(true); - m_webview->setZoomFactor(0.75); - m_webview->setVisible(useWebview); - m_webview->setZValue(1); - s->addItem(m_webview); - } else - m_webview = NULL; - - m_backgroundItem = new QGraphicsRectItem(m_svgItem->boundingRect()); - m_backgroundItem->setBrush(Qt::white); - m_backgroundItem->setPen(Qt::NoPen); - m_backgroundItem->setVisible(drawBackground); - m_backgroundItem->setZValue(0); - s->addItem(m_backgroundItem); - - m_outlineItem = new QGraphicsRectItem(m_svgItem->boundingRect()); - QPen outline(Qt::black, 2, Qt::DashLine); - outline.setCosmetic(true); - m_outlineItem->setPen(outline); - m_outlineItem->setBrush(Qt::NoBrush); - m_outlineItem->setVisible(drawOutline); - m_outlineItem->setZValue(2); - s->addItem(m_outlineItem); - - s->setSceneRect(m_outlineItem->boundingRect().adjusted(-10, -10, 10, 10)); -} - -void SvgView::setRenderer(RendererType type) -{ - m_renderer = type; - - if (m_renderer == OpenGL) { -#ifndef QT_NO_OPENGL - setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); -#endif - } else { - setViewport(new QWidget); - } -} - -void SvgView::setHighQualityAntialiasing(bool highQualityAntialiasing) -{ -#ifndef QT_NO_OPENGL - setRenderHint(QPainter::HighQualityAntialiasing, highQualityAntialiasing); -#else - Q_UNUSED(highQualityAntialiasing); -#endif -} - -void SvgView::setViewInteractive(bool enable) -{ - if (!m_svgItem) - return; - if (!m_webview) { - m_webview = new QGraphicsWebView(); - m_webview->load(QUrl::fromLocalFile(fn)); - m_webview->setResizesToContents(true); - m_webview->setZoomFactor(0.75); - m_webview->setVisible(false); - m_webview->setZValue(1); - m_svgItem->scene()->addItem(m_webview); - } - m_svgItem->setVisible(!enable); - m_webview->setVisible(enable); -} - -void SvgView::setViewBackground(bool enable) -{ - if (!m_backgroundItem) - return; - - m_backgroundItem->setVisible(enable); -} - -void SvgView::setViewOutline(bool enable) -{ - if (!m_outlineItem) - return; - - m_outlineItem->setVisible(enable); -} - -void SvgView::paintEvent(QPaintEvent *event) -{ - if (m_renderer == Image) { - if (m_image.size() != viewport()->size()) { - m_image = QImage(viewport()->size(), QImage::Format_ARGB32_Premultiplied); - } - - QPainter imagePainter(&m_image); - QGraphicsView::render(&imagePainter); - imagePainter.end(); - - QPainter p(viewport()); - p.drawImage(0, 0, m_image); - - } else { - QGraphicsView::paintEvent(event); - } -} - -void SvgView::wheelEvent(QWheelEvent *event) -{ - qreal factor = qPow(1.2, event->delta() / 240.0); - scale(factor, factor); - event->accept(); -} - diff --git a/libs/svgviewer/svgview.h b/libs/svgviewer/svgview.h deleted file mode 100644 index 833bb52e0..000000000 --- a/libs/svgviewer/svgview.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SVGVIEW_H -#define SVGVIEW_H - -#include -#include - -QT_BEGIN_NAMESPACE -class QWheelEvent; -class QPaintEvent; -class QFile; -QT_END_NAMESPACE - -class SvgView : public QGraphicsView -{ - Q_OBJECT - -public: - enum RendererType { Native, OpenGL, Image }; - - SvgView(QWidget *parent = 0); - - void openFile(const QFile &file); - void setRenderer(RendererType type = Native); - void drawBackground(QPainter *p, const QRectF &rect); - -public slots: - void setHighQualityAntialiasing(bool highQualityAntialiasing); - void setViewInteractive(bool enable); - void setViewBackground(bool enable); - void setViewOutline(bool enable); - -protected: - void wheelEvent(QWheelEvent *event); - void paintEvent(QPaintEvent *event); - -private: - RendererType m_renderer; - - QString fn; - QGraphicsItem *m_svgItem; - QGraphicsWebView *m_webview; - QGraphicsRectItem *m_backgroundItem; - QGraphicsRectItem *m_outlineItem; - - QImage m_image; -}; -#endif // SVGVIEW_H diff --git a/libs/svgviewer/svgviewer.desktop b/libs/svgviewer/svgviewer.desktop deleted file mode 100644 index 477ef789d..000000000 --- a/libs/svgviewer/svgviewer.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=SVG Viewer -Exec=/opt/usr/bin/svgviewer -Icon=svgviewer -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/libs/svgviewer/svgviewer.pro b/libs/svgviewer/svgviewer.pro deleted file mode 100644 index 488c62fd5..000000000 --- a/libs/svgviewer/svgviewer.pro +++ /dev/null @@ -1,33 +0,0 @@ -HEADERS = mainwindow.h \ - svgview.h -RESOURCES = svgviewer.qrc -SOURCES = main.cpp \ - mainwindow.cpp \ - svgview.cpp -QT += webkit svg xml - -contains(QT_CONFIG, opengl): QT += opengl - -CONFIG += console - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/painting/svgviewer -sources.files = $$SOURCES $$HEADERS $$RESOURCES svgviewer.pro files -sources.path = $$[QT_INSTALL_EXAMPLES]/painting/svgviewer -INSTALLS += target sources - -wince*: { - addFiles.files = files\\*.svg - addFiles.path = "\\My Documents" - DEPLOYMENT += addFiles -} - -symbian: { - TARGET.UID3 = 0xA000A64E - include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - addFiles.files = files\\*.svg - addFiles.path = . - DEPLOYMENT += addFiles -} -maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri) - diff --git a/libs/svgviewer/svgviewer.qrc b/libs/svgviewer/svgviewer.qrc deleted file mode 100644 index db611f51f..000000000 --- a/libs/svgviewer/svgviewer.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - files/bubbles.svg - - -