Add UnitsSchemaMmMin - izes are only in mm, speed in mm/munute.
This commit is contained in:
@@ -185,6 +185,8 @@ SET(FreeCADBase_UNITAPI_SRCS
|
||||
UnitsSchemaImperial1.cpp
|
||||
UnitsSchemaCentimeters.h
|
||||
UnitsSchemaCentimeters.cpp
|
||||
UnitsSchemaMmMin.h
|
||||
UnitsSchemaMmMin.cpp
|
||||
Quantity.h
|
||||
Quantity.cpp
|
||||
QuantityPyImp.cpp
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "UnitsSchemaImperial1.h"
|
||||
#include "UnitsSchemaMKS.h"
|
||||
#include "UnitsSchemaCentimeters.h"
|
||||
#include "UnitsSchemaMmMin.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
@@ -93,6 +94,7 @@ void UnitsApi::setSchema(UnitSystem s)
|
||||
case ImperialDecimal: UserPrefSystem = new UnitsSchemaImperialDecimal(); break;
|
||||
case Centimeters: UserPrefSystem = new UnitsSchemaCentimeters(); break;
|
||||
case ImperialBuilding: UserPrefSystem = new UnitsSchemaImperialBuilding(); break;
|
||||
case MmMin: UserPrefSystem = new UnitsSchemaMmMin(); break;
|
||||
default : UserPrefSystem = new UnitsSchemaInternal(); s = SI1; break;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ enum UnitSystem {
|
||||
Imperial1 = 2, /** the Imperial system (http://en.wikipedia.org/wiki/Imperial_units) */
|
||||
ImperialDecimal = 3, /** Imperial with length in inch only */
|
||||
Centimeters = 4, /** All lengths in centimeters, areas and volumes in square/cubic meters */
|
||||
ImperialBuilding = 5 /** All lengths in feet + inches + fractions */
|
||||
ImperialBuilding = 5, /** All lengths in feet + inches + fractions */
|
||||
MmMin = 6, /** All lengths in mm, Speed in mm/min. Usefull for small parts & CNN */
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
60
src/Base/UnitsSchemaMmMin.cpp
Normal file
60
src/Base/UnitsSchemaMmMin.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2009 Juergen Riegel (FreeCAD@juergen-riegel.net) *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifdef __GNUC__
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <QString>
|
||||
#include <QLocale>
|
||||
#include "Exception.h"
|
||||
#include "UnitsApi.h"
|
||||
#include "UnitsSchemaMmMin.h"
|
||||
#include <cmath>
|
||||
|
||||
|
||||
using namespace Base;
|
||||
|
||||
|
||||
QString UnitsSchemaMmMin::schemaTranslate(const Quantity &quant, double &factor, QString &unitString)
|
||||
{
|
||||
Unit unit = quant.getUnit();
|
||||
if (unit == Unit::Angle) {
|
||||
// TODO Cascade for the Areas
|
||||
// default action for all cases without special treatment:
|
||||
unitString = QString::fromUtf8("\xC2\xB0");
|
||||
factor = 1.0;
|
||||
}
|
||||
else if (unit == Unit::Velocity) {
|
||||
unitString = QString::fromLatin1("mm/min");
|
||||
factor = 1./60.;
|
||||
}
|
||||
else {
|
||||
// default action for all cases without special treatment:
|
||||
unitString = quant.getUnit().getString();
|
||||
factor = 1.0;
|
||||
}
|
||||
|
||||
return toLocale(quant, factor, unitString);
|
||||
}
|
||||
50
src/Base/UnitsSchemaMmMin.h
Normal file
50
src/Base/UnitsSchemaMmMin.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2009 Juergen Riegel (FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef BASE_UNITSSCHEMAMMMIN_H
|
||||
#define BASE_UNITSSCHEMAMMMIN_H
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <QString>
|
||||
#include "UnitsSchema.h"
|
||||
|
||||
namespace Base {
|
||||
|
||||
|
||||
/** The standard units schema
|
||||
* Here is defined what internal (base) units FreeCAD uses.
|
||||
* FreeCAD uses a mm/kg/deg scala.
|
||||
* Also it defines how the units get presented.
|
||||
*/
|
||||
class UnitsSchemaMmMin: public UnitsSchema
|
||||
{
|
||||
public:
|
||||
virtual QString schemaTranslate(const Base::Quantity& quant, double &factor, QString &unitString);
|
||||
};
|
||||
|
||||
|
||||
} // namespace Base
|
||||
|
||||
|
||||
#endif // BASE_UNITSSCHEMAMMMIN_H
|
||||
@@ -61,6 +61,11 @@
|
||||
<string>Building US (ft-in/sqft/cuft)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Metric small parts & CNC(mm, mm/min)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
Reference in New Issue
Block a user