QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
RMathLineEdit.h
Go to the documentation of this file.
1
20#ifndef RMATHLINEEDIT_H_
21#define RMATHLINEEDIT_H_
22
23#include "gui_global.h"
24
25#include <QMetaType>
26#include <QLineEdit>
27
28#include "RMath.h"
29
34class QCADGUI_EXPORT RMathLineEdit: public QLineEdit {
35
36Q_OBJECT
37
38// keep extra ';' in place for the benefit of ecmagenerator:
39Q_PROPERTY(bool angle READ isAngle WRITE setAngle);
40Q_PROPERTY(bool scale READ isScale WRITE setScale);
41Q_PROPERTY(bool integer READ isInteger WRITE setInteger);
42//Q_PROPERTY(double defaultValue READ getDefaultValue WRITE setDefaultValue);
43//Q_PROPERTY(int defaultUnit READ getDefaultUnit WRITE setDefaultUnit);
44//Q_PROPERTY(RS::Unit defaultUnit READ getDefaultUnit WRITE setDefaultUnit);
45//Q_ENUMS(RS::Unit);
46
47public:
48 RMathLineEdit(QWidget* parent = NULL);
49
50 bool isAngle() const {
51 return angle;
52 }
53 void setAngle(bool on) {
54 angle = on;
55 }
56
57 bool isScale() const {
58 return scale;
59 }
60 void setScale(bool on) {
61 scale = on;
62 }
63
64 bool isInteger() const {
65 return integer;
66 }
67 void setInteger(bool on) {
68 integer = on;
69 }
70
71 void setValue(double v, int precision=6);
72 double getValue();
73 QString getError();
74 void clearError();
75
76 bool isValid() {
77 return !RMath::isNaN(value);
78 }
79
80 bool isSane() {
81 return RMath::isSane(value);
82 }
83
84 void setToolTip(const QString& toolTip);
85
86 QColor getNormalTextColor() const;
87 void setTextColor(bool error);
88
89 /*
90 double getDefaultValue() {
91 return defaultValue;
92 }
93 void setDefaultValue(double v) {
94 defaultValue = v;
95 }
96 */
97
98 //void setDefaultUnit(int defaultUnit);
99 //int getDefaultUnit();
100
101protected:
102 virtual void keyPressEvent(QKeyEvent* event);
103 virtual void keyReleaseEvent(QKeyEvent* event);
104// virtual bool eventFilter(QObject* obj, QEvent* event);
105
106public slots:
107 void slotTextChanged(const QString& text);
108 void slotTextEdited(const QString& text);
109
110signals:
111 void valueChanged(double value, const QString& error);
114
115private:
116 QPalette oriPalette;
117 bool angle;
118 bool scale;
119 bool integer;
120 double value;
121 //RS::Unit defaultUnit;
122 QString error;
124 bool noEmit;
126 //double defaultValue;
127};
128
130
131#endif
Q_DECLARE_METATYPE(RMath *)
static bool isSane(double v)
Definition RMath.cpp:157
static bool isNaN(double v)
Definition RMath.cpp:134
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RMathLineEdit.h:34
bool isValid()
Definition RMathLineEdit.h:76
void upKeyPressed()
QString error
Definition RMathLineEdit.h:122
void setScale(bool on)
Definition RMathLineEdit.h:60
double value
Definition RMathLineEdit.h:120
void setAngle(bool on)
Definition RMathLineEdit.h:53
QPalette oriPalette
Definition RMathLineEdit.h:116
bool isScale() const
Definition RMathLineEdit.h:57
bool isAngle() const
Definition RMathLineEdit.h:50
bool isSane()
Definition RMathLineEdit.h:80
void valueChanged(double value, const QString &error)
bool isInteger() const
Definition RMathLineEdit.h:64
bool noEmit
Definition RMathLineEdit.h:124
bool noResultInToolTip
Definition RMathLineEdit.h:125
QString originalToolTip
Definition RMathLineEdit.h:123
void setInteger(bool on)
Definition RMathLineEdit.h:67
void downKeyPressed()
void scale(void e, void factor, void focusPoint)
Scales the given entity or shape by the given factor with the given focus point.
Definition simple_modify.js:15
#define QCADGUI_EXPORT
Definition gui_global.h:10
#define NULL
Definition opennurbs_system.h:256