git-svn-id: svn://db.shs.com.ru/libs@334 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2017-11-30 09:13:49 +00:00
parent b46c65f826
commit 8cdbe203bf
20 changed files with 707 additions and 227 deletions

View File

@@ -13,34 +13,6 @@
__GraphicRegistrator__ __graphic_registrator__;
ELineEdit::ELineEdit(QWidget * parent): CLineEdit(parent) {
last_ret = complexd_0;
is_auto = false;
is_reset = true;
connect(this, SIGNAL(editingFinished()), this, SLOT(calculate()));
connect(this, SIGNAL(cleared()), this, SLOT(toDefaultClicked()));
}
void ELineEdit::wheelEvent(QWheelEvent * e) {
double mul = 1.1;
if (e->delta() < 0) mul = 0.9;
CLineEdit::setText(QString::number(last_ret.real() * mul).toUpper());
calculate();
}
void ELineEdit::calculate() {
evaluator.check(text().replace(",", "."));
if (!evaluator.isCorrect()) return;
is_reset = false;
last_ret = evaluator.evaluate();
CLineEdit::setText(QString::number(last_ret.real()).toUpper());
emit valueChanged(last_ret.real());
}
Graphic::Graphic(QWidget * parent): QFrame(parent), line_x_min(this), line_x_max(this), line_y_min(this), line_y_max(this) {
QTranslator * trans = new QTranslator();
trans->load(":/lang/qad_graphic_" + QLocale::system().name().left(2));
@@ -66,6 +38,10 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), line_x_min(this), line_x_max
LN2 = qLn(2.);
LN5 = qLn(5.);
LN10 = qLn(10.);
line_x_min.setClearButtonVisible(true);
line_x_max.setClearButtonVisible(true);
line_y_min.setClearButtonVisible(true);
line_y_max.setClearButtonVisible(true);
connect(&line_x_min, SIGNAL(valueChanged(double)), this, SLOT(lineXMinChanged(double)));
connect(&line_x_max, SIGNAL(valueChanged(double)), this, SLOT(lineXMaxChanged(double)));
connect(&line_y_min, SIGNAL(valueChanged(double)), this, SLOT(lineYMinChanged(double)));
@@ -1249,26 +1225,44 @@ void Graphic::swapToBuffer() {
void Graphic::setRectToLines() {
is_lines_update = true;
line_x_min.is_auto = line_x_max.is_auto = line_y_min.is_auto = line_y_max.is_auto = true;
//line_x_min.is_auto = line_x_max.is_auto = line_y_min.is_auto = line_y_max.is_auto = true;
//qDebug() << "set to lines" << selrect;
line_x_min.is_reset = line_x_max.is_reset = line_y_min.is_reset = line_y_max.is_reset = isFit;
if (!line_x_min.hasFocus()) line_x_min.setValue(selrect.left());
if (!line_x_max.hasFocus()) line_x_max.setValue(selrect.right());
if (!line_y_min.hasFocus()) line_y_min.setValue(selrect.bottom());
if (!line_y_max.hasFocus()) line_y_max.setValue(selrect.top());
if (!isFit) {
//line_x_min.is_reset = line_x_max.is_reset = line_y_min.is_reset = line_y_max.is_reset = isFit;
if (line_x_min.isVisible() && line_x_max.isVisible() && line_y_min.isVisible() && line_y_max.isVisible()) {
line_x_min.blockSignals(true); line_x_max.blockSignals(true); line_y_min.blockSignals(true); line_y_max.blockSignals(true);
if (!line_x_min.hasFocus()) {
if (isFit) line_x_min.setValue(grect.left());
else line_x_min.setValue(selrect.left());
}
if (!line_x_max.hasFocus()) {
if(isFit) line_x_max.setValue(grect.right());
else line_x_max.setValue(selrect.right());
}
if (!line_y_min.hasFocus()) {
if(isFit) line_y_min.setValue(grect.bottom());
else line_y_min.setValue(selrect.bottom());
}
if (!line_y_max.hasFocus()) {
if(isFit) line_y_max.setValue(grect.top());
else line_y_max.setValue(selrect.top());
}
line_x_min.setDefaultText(QString::number(grect.left()).toUpper());
line_x_max.setDefaultText(QString::number(grect.right()).toUpper());
line_y_min.setDefaultText(QString::number(grect.bottom()).toUpper());
line_y_max.setDefaultText(QString::number(grect.top()).toUpper());
line_x_min.blockSignals(false); line_x_max.blockSignals(false); line_y_min.blockSignals(false); line_y_max.blockSignals(false);
// if(isFit) {
// line_y_min.setValue(grect.left());
// line_y_max.setValue(grect.left());
// }
}
line_x_min.is_auto = line_x_max.is_auto = line_y_min.is_auto = line_y_max.is_auto = false;
//line_x_min.is_auto = line_x_max.is_auto = line_y_min.is_auto = line_y_max.is_auto = false;
is_lines_update = false;
}
void Graphic::checkLines() {
isFit = (line_x_min.isDefault() && line_x_max.isDefault() && line_y_min.isDefault() && line_y_max.isDefault());
isFit = (line_x_min.isCleared() && line_x_max.isCleared() && line_y_min.isCleared() && line_y_max.isCleared());
update(true);
}
@@ -1549,6 +1543,7 @@ void Graphic::setBorderInputsVisible(bool visible) {
ui->widgetLX->setVisible(visible);
ui->widgetLY->setVisible(visible);
ui->checkBorderInputs->setChecked(visible);
if (visible) setRectToLines();
}

View File

@@ -16,34 +16,12 @@
#include <qmath.h>
#include <float.h>
#include "graphic_conf.h"
#include "clineedit.h"
#include "qpievaluator.h"
#include "evalspinbox.h"
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class ELineEdit: public CLineEdit {
Q_OBJECT
public:
explicit ELineEdit(QWidget * parent = 0);
//void setText(const QString & v) {if (!is_auto) is_reset = false; CLineEdit::setText(v); setDefaultText(v, is_reset); last_ret = complexd(v.toDouble(), 0.); emit valueChanged(last_ret.real());}
void setValue(const int & v) {if (is_reset) setDefaultText(QString::number(v).toUpper(), is_reset); else setText(QString::number(v).toUpper()); last_ret = complexd(v, 0.); if (!is_auto) emit valueChanged(last_ret.real());}
void setValue(const double & v) {if (is_reset) setDefaultText(QString::number(v).toUpper(), is_reset); else setText(QString::number(v).toUpper()); last_ret = complexd(v, 0.); if (!is_auto) emit valueChanged(last_ret.real());}
double value() const {return last_ret.real();}
bool isDefault() const {return !cw->isVisible();}
bool is_reset, is_auto;
protected:
void wheelEvent(QWheelEvent * e);
QPIEvaluator evaluator;
complexd last_ret;
private slots:
void toDefaultClicked() {is_reset = true; calculate();}
void calculate();
signals:
void valueChanged(double value);
};
namespace Ui {
class Graphic;
@@ -381,7 +359,7 @@ protected:
Graphic::Buttons buttons_;
Graphic::Alignment align;
GraphicConf * conf;
ELineEdit line_x_min, line_x_max, line_y_min, line_y_max;
EvalSpinBox line_x_min, line_x_max, line_y_min, line_y_max;
QTime tm;
QIcon icon_exp_x, icon_exp_y, icon_exp_sx, icon_exp_sy;
QImage icon_pause_b, icon_pause_f;

View File

@@ -193,6 +193,9 @@
<property name="decimals">
<number>2</number>
</property>
<property name="maximum">
<double>999.990000000000009</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
@@ -265,22 +268,6 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="spinGridStepX">
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>0.001000000000000</double>
</property>
<property name="maximum">
<double>9999999.000000000000000</double>
</property>
<property name="value">
<double>50.000000000000000</double>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
@@ -295,22 +282,6 @@
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QDoubleSpinBox" name="spinGridStepY">
<property name="decimals">
<number>3</number>
</property>
<property name="minimum">
<double>0.001000000000000</double>
</property>
<property name="maximum">
<double>9999999.000000000000000</double>
</property>
<property name="value">
<double>30.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkGridAutoX">
<property name="text">
@@ -331,6 +302,32 @@
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="EvalSpinBox" name="spinGridStepY">
<property name="expression">
<string>30</string>
</property>
<property name="defaultText">
<string>30</string>
</property>
<property name="clearButtonVisible">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="EvalSpinBox" name="spinGridStepX">
<property name="expression">
<string>50</string>
</property>
<property name="defaultText">
<string>50</string>
</property>
<property name="clearButtonVisible">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -474,6 +471,11 @@
<signal>colorChanged(QColor)</signal>
</slots>
</customwidget>
<customwidget>
<class>EvalSpinBox</class>
<extends>QWidget</extends>
<header>evalspinbox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>checkAAlias</tabstop>