Warning, file /office/calligra/filters/karbon/xfig/XFigDocument.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the Calligra project, made within the KDE community. 0002 0003 SPDX-FileCopyrightText: 2012 Friedrich W. H. Kossebau <kossebau@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "XFigDocument.h" 0009 0010 0011 void 0012 XFigBoxObject::setPoints(const QVector<XFigPoint>& points) 0013 { 0014 if (points.count()!=5) { 0015 return; 0016 } 0017 0018 // format does not specify in which order the corner points are given, 0019 // so just get the box from all points 0020 const XFigPoint firstPoint = points.at(0); 0021 qint32 minX = firstPoint.x(); 0022 qint32 maxX = firstPoint.x(); 0023 qint32 minY = firstPoint.y(); 0024 qint32 maxY = firstPoint.y(); 0025 for (int i = 1; i < 5; ++i) { 0026 const XFigPoint point = points.at(i); 0027 0028 const qint32 x = point.x(); 0029 if (x < minX) { 0030 minX = x; 0031 } else if (maxX < x) { 0032 maxX = x; 0033 } 0034 0035 const qint32 y = point.y(); 0036 if (y < minY) { 0037 minY = y; 0038 } else if (maxY < y) { 0039 maxY = y; 0040 } 0041 } 0042 0043 m_UpperLeftCorner = XFigPoint(minX, minY); 0044 m_Width = (maxX - minX + 1); 0045 m_Height = (maxY - minY + 1); 0046 } 0047 0048 static void 0049 fillColorTable( QHash<int, QColor>& colorTable ) 0050 { 0051 static const unsigned int colorValues[24] = { 0052 // four shades of blue (dark to lighter) 0053 0x000090, 0x0000b0, 0x0000d0, 0x87ceff, 0054 // three shades of green (dark to lighter) 0055 0x009000, 0x00b000, 0x00d000, 0x009090, 0056 // three shades of cyan (dark to lighter) 0057 0x00b0b0, 0x00d0d0, 0x900000, 0xb00000, 0058 // three shades of red (dark to lighter) 0059 0xd00000, 0x900090, 0xb000b0, 0xd000d0, 0060 // three shades of magenta (dark to lighter) 0061 0x803000, 0xa04000, 0xc06000, 0xff8080, 0062 // three shades of brown (dark to lighter) 0063 0xffa0a0, 0xffc0c0, 0xffe0e0, 0064 // gold 0065 0xffd700 0066 }; 0067 0068 colorTable.insert(0, QColor(Qt::black)); 0069 colorTable.insert(1, QColor(Qt::blue)); 0070 colorTable.insert(2, QColor(Qt::green)); 0071 colorTable.insert(3, QColor(Qt::cyan)); 0072 colorTable.insert(4, QColor(Qt::red)); 0073 colorTable.insert(5, QColor(Qt::magenta)); 0074 colorTable.insert(6, QColor(Qt::yellow)); 0075 colorTable.insert(7, QColor(Qt::white)); 0076 0077 for (int i = 8; i < 32; i++) 0078 colorTable.insert(i, QColor(colorValues[i-8])); 0079 } 0080 0081 0082 XFigDocument::XFigDocument() 0083 : m_PageOrientation(XFigPageOrientationUnknown) 0084 , m_CoordSystemOriginType(XFigCoordSystemOriginTypeUnknown) 0085 , m_UnitType(XFigUnitTypeUnknown) 0086 , m_PageSizeType(XFigPageSizeUnknown) 0087 , m_Resolution(1200) 0088 { 0089 fillColorTable( m_ColorTable ); 0090 } 0091 0092 const QColor* 0093 XFigDocument::color(int id) const 0094 { 0095 QHash<int, QColor>::ConstIterator it = m_ColorTable.constFind(id); 0096 0097 return (it!=m_ColorTable.constEnd()) ? &it.value() : 0; 0098 }