• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • misc
unit.h
Go to the documentation of this file.
1 /*
2  This file is part of Kig, a KDE program for Interactive Geometry...
3  Copyright (C) 2006 Pino Toscano <toscano.pino@tiscali.it>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  02110-1301, USA.
19 */
20 
21 #ifndef KIG_MISC_UNIT_H
22 #define KIG_MISC_UNIT_H
23 
24 #include <qstringlist.h>
25 
30 class Unit
31 {
32 public:
36  enum MetricalUnit { pixel = 0, cm, in };
37  explicit Unit( double value = 0.0, Unit::MetricalUnit unit = cm, int dpi = 1 );
38  ~Unit();
39  void setValue( double value );
40  double value() const;
47  void setUnit( Unit::MetricalUnit unit );
54  void convertTo( Unit::MetricalUnit unit );
55  Unit::MetricalUnit unit() const;
56  double getValue( Unit::MetricalUnit unit ) const;
57  void setDpi( int dpi );
58  int dpi() const;
64  static double convert( double value, Unit::MetricalUnit from, Unit::MetricalUnit to, int dpi = 1 );
68  static QStringList unitList();
69  static Unit::MetricalUnit intToUnit( int index );
70 
74  static int precision( Unit::MetricalUnit unit );
75 
76  Unit& operator=( const Unit& u );
77 
78 private:
79  double mvalue;
80  Unit::MetricalUnit munit;
81  int mdpi;
82 };
83 
84 #endif
Unit::setUnit
void setUnit(Unit::MetricalUnit unit)
Set the unit of the current object to unit, but it doesn't convert the value to the new unit...
Definition: unit.cc:47
Unit::setDpi
void setDpi(int dpi)
Definition: unit.cc:68
Unit::MetricalUnit
MetricalUnit
The kinds of metrical units we support.
Definition: unit.h:36
Unit::cm
Definition: unit.h:36
Unit::unitList
static QStringList unitList()
Get a list of the supported metrical units.
Definition: unit.cc:118
Unit::getValue
double getValue(Unit::MetricalUnit unit) const
Definition: unit.cc:63
Unit::unit
Unit::MetricalUnit unit() const
Definition: unit.cc:58
Unit::convertTo
void convertTo(Unit::MetricalUnit unit)
Set the unit of the current object to unit and convert the value to the new unit using convert()...
Definition: unit.cc:52
Unit::pixel
Definition: unit.h:36
Unit::setValue
void setValue(double value)
Definition: unit.cc:37
Unit::convert
static double convert(double value, Unit::MetricalUnit from, Unit::MetricalUnit to, int dpi=1)
The most useful method of this class: convert the specified value from the unit from to the unit to...
Definition: unit.cc:86
Unit::Unit
Unit(double value=0.0, Unit::MetricalUnit unit=cm, int dpi=1)
Definition: unit.cc:26
Unit::dpi
int dpi() const
Definition: unit.cc:73
Unit::precision
static int precision(Unit::MetricalUnit unit)
How many decimals the unit have.
Definition: unit.cc:139
Unit::in
Definition: unit.h:36
Unit::intToUnit
static Unit::MetricalUnit intToUnit(int index)
Definition: unit.cc:127
Unit::operator=
Unit & operator=(const Unit &u)
Definition: unit.cc:78
Unit::~Unit
~Unit()
Definition: unit.cc:33
Unit::value
double value() const
Definition: unit.cc:42
Unit
This small class server as helper to perform conversions between metrical units.
Definition: unit.h:30
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

Skip menu "kig"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal