Files
grbl-sender/terje/measure_view_model.h
T

43 lines
968 B
C++
Raw Normal View History

#pragma once
#include <string>
#include "grbl.h"
namespace iosender {
class MeasureViewModel {
public:
bool _isMetric = true;
const double MM_PER_INCH = 25.4;
bool IsMetric() const { return _isMetric; }
void IsMetric(bool value) {
if (value != _isMetric) {
_isMetric = value;
// trigger OnPropertyChanged()
}
}
std::string Unit() const { return _isMetric ? "mm" : "in"; }
std::string FeedrateUnit() const { return _isMetric ? "mm/min" : "in/min"; }
double UnitFactor() const { return _isMetric ? 1.0 : 25.4; }
std::string Format() const { return _isMetric ? GrblConstants::FORMAT_METRIC : GrblConstants::FORMAT_IMPERIAL; }
std::string FormatSigned() const { return "-" + Format(); }
int Precision() const { return _isMetric ? 3 : 4; }
double ConvertMM2Current(double value) const {
if (!_isMetric)
value /= 25.4;
return value;
}
};
}