1 /****************************************************************************
2 ** $Id: rs_units.h 1877 2004-05-15 09:09:21Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the qcadlib Library project.
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
35 * Conversion methods for units
37 * @author Andrew Mustun
42 //static char* unit2sign(RS2::Unit unit);
44 //static RS2::Unit string2unit(const char* str, bool* ok=0);
45 //static char* unit2string(RS2::Unit unit);
47 static RS2::Unit dxfint2unit(int dxfint);
49 static QString unitToString(RS2::Unit u, bool t = true);
50 static RS2::Unit stringToUnit(const QString & u);
52 static bool isMetric(RS2::Unit u);
53 static double getFactorToMM(RS2::Unit u);
54 static double convert(double val, RS2::Unit src, RS2::Unit dest);
55 static Vector convert(const Vector val, RS2::Unit src, RS2::Unit dest);
57 static QString unitToSign(RS2::Unit u);
59 static QString formatLinear(double length, RS2::Unit unit,
60 RS2::LinearFormat format, int prec, bool showUnit = false);
61 static QString formatScientific(double length, RS2::Unit unit, int prec, bool showUnit = false);
62 static QString formatDecimal(double length, RS2::Unit unit, int prec, bool showUnit = false);
63 static QString formatEngineering(double length, RS2::Unit unit, int prec, bool showUnit = false);
64 static QString formatArchitectural(double length, RS2::Unit unit, int prec, bool showUnit = false);
65 static QString formatFractional(double length, RS2::Unit unit, int prec, bool showUnit = false);
67 static QString formatAngle(double angle, RS2::AngleFormat format, int prec);
69 static Vector paperFormatToSize(RS2::PaperFormat p);
70 static RS2::PaperFormat paperSizeToFormat(const Vector s);
72 static QString paperFormatToString(RS2::PaperFormat p);
73 static RS2::PaperFormat stringToPaperFormat(const QString & p);