~showard314/ubuntu/utopic/qtiplot/utopic_1311721

« back to all changes in this revision

Viewing changes to 3rdparty/QTeXEngine/src/QTeXPaintDevice.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Howard
  • Date: 2011-05-07 17:00:26 UTC
  • mfrom: (1.1.9 upstream) (2.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20110507170026-77wvcv8uc6955fff
* moved debian/build.conf into debian/patches/03_build_conf.patch
  to track changes to build.conf between releases. Updated
  debian/rules accordingly.
* New upstream release. (Closes: #599450)
* Refreshed patches.
* debian/control B-D on libalglib-dev, libtamuanova-dev,
  libqtexengine-dev
* debian/rules allows for parallel builds
* Byte compile python modules with dh_python2, removed debian/*.post{rm,inst}
  dropped dependency on depricated python-central (Closes: #587669)
* Added shared-mime-info xml data in debian/qtiplot.sharedmimeinfo
  (LP: #184307)
* 04_qwtplot3d_static.patch added to build a modified static
  library of qwt3dplot
* 05_link_gl2ps.patch added to use Debian gl2ps library.
* Policy 3.9.2, no changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
    File                 : QTeXPaintDevice.cpp
3
 
    Project              : QTeXEngine GNU GPL v. 3.0
4
 
    --------------------------------------------------------------------
5
 
    Copyright            : (C) 2009 by Ion Vasilief
6
 
    Email (use @ for *)  : ion_vasilief*yahoo.fr
7
 
    Description          : Enables the export of QPainter grafics to .tex files
8
 
 ***************************************************************************/
9
 
 
10
 
/***************************************************************************
11
 
 *                                                                         *
12
 
 *  This program is free software; you can redistribute it and/or modify   *
13
 
 *  it under the terms of the GNU General Public License as published by   *
14
 
 *  the Free Software Foundation; either version 3 of the License, or      *
15
 
 *  (at your option) any later version.                                    *
16
 
 *                                                                         *
17
 
 *  This program is distributed in the hope that it will be useful,        *
18
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
19
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
20
 
 *  GNU General Public License for more details.                           *
21
 
 *                                                                         *
22
 
 *   You should have received a copy of the GNU General Public License     *
23
 
 *   along with this program; if not, write to the Free Software           *
24
 
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
25
 
 *   Boston, MA  02110-1301  USA                                           *
26
 
 *                                                                         *
27
 
 ***************************************************************************/
28
 
 
29
 
#include "QTeXEngine.h"
30
 
 
31
 
#include <QApplication>
32
 
#include <QDesktopWidget>
33
 
 
34
 
QTeXPaintDevice::QTeXPaintDevice(const QString& fileName, const QSize& s, Unit u)
35
 
: QPaintDevice()
36
 
{
37
 
        d_size = s;
38
 
 
39
 
        if (!d_size.isValid())
40
 
                d_size = QSize(500, 400);
41
 
 
42
 
        engine = new QTeXPaintEngine(fileName, u);
43
 
}
44
 
 
45
 
QTeXPaintDevice::~QTeXPaintDevice()
46
 
{
47
 
        delete engine;
48
 
}
49
 
 
50
 
QPaintEngine * QTeXPaintDevice::paintEngine () const
51
 
{
52
 
        return engine;
53
 
}
54
 
 
55
 
void QTeXPaintDevice::setColorMode(QPrinter::ColorMode mode)
56
 
{
57
 
        engine->setGrayScale(mode == QPrinter::GrayScale);
58
 
}
59
 
 
60
 
void QTeXPaintDevice::setOutputMode(OutputMode mode)
61
 
{
62
 
        engine->setOutputMode(mode);
63
 
}
64
 
 
65
 
void QTeXPaintDevice::setUnit(Unit u)
66
 
{
67
 
        engine->setUnit(u);
68
 
}
69
 
 
70
 
void QTeXPaintDevice::setDocumentMode(bool on)
71
 
{
72
 
        engine->setDocumentMode(on);
73
 
}
74
 
 
75
 
void QTeXPaintDevice::setEscapeTextMode(bool on)
76
 
{
77
 
        engine->setEscapeTextMode(on);
78
 
}
79
 
 
80
 
void QTeXPaintDevice::exportFontSizes(bool on)
81
 
{
82
 
        engine->exportFontSizes(on);
83
 
}
84
 
 
85
 
void QTeXPaintDevice::setTextHorizontalAlignment(Qt::Alignment alignment)
86
 
{
87
 
        engine->setTextHorizontalAlignment(alignment);
88
 
}
89
 
 
90
 
int QTeXPaintDevice::metric ( PaintDeviceMetric metric ) const
91
 
{
92
 
        QDesktopWidget *desktop = QApplication::desktop();
93
 
        int dpi_x = desktop->logicalDpiX();
94
 
        int dpi_y = desktop->logicalDpiY();
95
 
        switch (metric){
96
 
                case QPaintDevice::PdmWidth:
97
 
                        return d_size.width();
98
 
                case QPaintDevice::PdmHeight:
99
 
                        return d_size.height();
100
 
                case QPaintDevice::PdmWidthMM:
101
 
                        return int(25.4*d_size.width()/(double)dpi_x);
102
 
                case QPaintDevice::PdmHeightMM:
103
 
                        return int(25.4*d_size.height()/(double)dpi_y);
104
 
                case QPaintDevice::PdmNumColors:
105
 
                        return 65536;//should it be millions?
106
 
                case QPaintDevice::PdmDepth:
107
 
                        return 32;
108
 
                case QPaintDevice::PdmDpiX:
109
 
                case QPaintDevice::PdmPhysicalDpiX:
110
 
                        return dpi_x;
111
 
                case QPaintDevice::PdmDpiY:
112
 
                case QPaintDevice::PdmPhysicalDpiY:
113
 
                        return dpi_y;
114
 
                default:
115
 
                        qWarning ("QTeXPaintDevice::Unknown metric asked");
116
 
                        return 0;
117
 
        }
118
 
}