Windows works

This commit is contained in:
2020-09-06 21:46:06 +03:00
parent 32707fbd4d
commit b1536eb16a
12 changed files with 81 additions and 63 deletions

View File

@@ -45,7 +45,7 @@ macro(qad_plugin NAME _MODULES _LIBS)
shstk_qt_plugin(qad_${NAME} "${_MODULES}" "qad_${NAME};${_LIBS}") shstk_qt_plugin(qad_${NAME} "${_MODULES}" "qad_${NAME};${_LIBS}")
endmacro() endmacro()
shstk_install(qad FALSE "" "${QAD_VERSION_FILE}") shstk_install(qad FALSE "" "${qad_VERSION_FILE}")
if (NOT LOCAL) if (NOT LOCAL)
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in") file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in")
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules) install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
@@ -60,7 +60,13 @@ message("----------QAD----------")
message(" Build for ${QtVersions}") message(" Build for ${QtVersions}")
message(" Linkage: ${qad_LIB_TYPE_MSG}") message(" Linkage: ${qad_LIB_TYPE_MSG}")
message(" Type : ${qad_BUILD_TYPE}") message(" Type : ${qad_BUILD_TYPE}")
if (NOT LOCAL)
message(" Install: \"${CMAKE_INSTALL_PREFIX}\"") message(" Install: \"${CMAKE_INSTALL_PREFIX}\"")
else()
if(NOT PIP_FREERTOS)
message(" Install: local \"bin\", \"lib\" and \"include\"")
endif()
endif()
message("") message("")
print_list("${_qt_libs}" " Libraries:" " * ") print_list("${_qt_libs}" " Libraries:" " * ")
if (NOT "x${_qt_plugs}" STREQUAL "x") if (NOT "x${_qt_plugs}" STREQUAL "x")

View File

@@ -104,7 +104,7 @@ else()
add_library(QAD::${_m}${_v} UNKNOWN IMPORTED) add_library(QAD::${_m}${_v} UNKNOWN IMPORTED)
set(_deps) set(_deps)
foreach (_d ${__deps_${_l}}) foreach (_d ${__deps_${_l}})
if (${_d} MATCHES "QAD::*") if (${_d} MATCHES "QAD::.*")
list(APPEND _deps ${_d}${_v}) list(APPEND _deps ${_d}${_v})
else() else()
list(APPEND _deps ${_d}) list(APPEND _deps ${_d})

View File

@@ -217,7 +217,7 @@ macro(find_qt)
#if (Qt5_FOUND) #if (Qt5_FOUND)
# set(_MSG 0) # set(_MSG 0)
#endif() #endif()
find_package(Qt5 COMPONENTS Core LinguistTools UiPlugin Widgets ${_QCOMP} ${_QUIET}) find_package(Qt5 COMPONENTS Core LinguistTools UiPlugin Widgets ${_QCOMP} QUIET)
if (DEFINED ANDROID_PLATFORM) if (DEFINED ANDROID_PLATFORM)
set(CMAKE_SHARED_MODULE_SUFFIX_CXX ".so") set(CMAKE_SHARED_MODULE_SUFFIX_CXX ".so")
set(CMAKE_SHARED_LIBRARY_SUFFIX_CXX ".so") set(CMAKE_SHARED_LIBRARY_SUFFIX_CXX ".so")

View File

@@ -21,6 +21,8 @@
# endif # endif
#endif #endif
const double deg2rad_qpie = atan(1.) / 45.;
const double rad2deg_qpie = 45. / atan(1.);
__GraphicRegistrator__ __graphic_registrator__; __GraphicRegistrator__ __graphic_registrator__;

View File

@@ -1,8 +1,10 @@
if (((DEFINED QGLVIEW) AND QGLVIEW) OR (NOT DEFINED QGLVIEW))
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
shstk_qt_project(qglview FALSE "qad" "Gui;OpenGL;Xml" "qad_widgets;qad_utils;${OPENGL_LIBRARIES}") shstk_qt_project(qglview FALSE "qad" "Gui;OpenGL;Xml" "qad_widgets;qad_utils;${OPENGL_LIBRARIES}")
shstk_qt_install("qad" FALSE qglview "out_HDR" "out_QM") shstk_qt_install("qad" FALSE qglview "${out_HDR}" "${out_QM}")
qt_sources(test_SRC DIR "qglview_test") qt_sources(test_SRC DIR "qglview_test")
qt_wrap(${test_SRC} CPPS test_CPP) qt_wrap(${test_SRC} CPPS test_CPP)
qt_add_executable(qglview_test test_CPP) qt_add_executable(qglview_test test_CPP)
qt_target_link_libraries(qglview_test qglview) qt_target_link_libraries(qglview_test qglview)
endif()

View File

@@ -8,12 +8,14 @@
#include <QStyle> #include <QStyle>
#include <QStyleOptionSpinBox> #include <QStyleOptionSpinBox>
#include "qad_types.h" #include "qad_types.h"
#include "qpievaluator_p.h"
EvalSpinBox::EvalSpinBox(QWidget * parent): QAbstractSpinBox(parent) { EvalSpinBox::EvalSpinBox(QWidget * parent): QAbstractSpinBox(parent) {
status = new QWidget(lineEdit()); status = new QWidget(lineEdit());
cw = new QWidget(lineEdit()); cw = new QWidget(lineEdit());
label = new QLabel(lineEdit()); label = new QLabel(lineEdit());
eval = new QPIEvaluator();
precision_ = -1; precision_ = -1;
// label->hide(); // label->hide();
clear_im.load(":/icons/edit-clear-locationbar-rtl.png"); clear_im.load(":/icons/edit-clear-locationbar-rtl.png");
@@ -40,9 +42,10 @@ EvalSpinBox::EvalSpinBox(QWidget * parent): QAbstractSpinBox(parent) {
EvalSpinBox::~EvalSpinBox() { EvalSpinBox::~EvalSpinBox() {
delete eval;
delete label;
delete cw; delete cw;
delete status; delete status;
delete label;
} }
@@ -124,9 +127,9 @@ void EvalSpinBox::textChanged_(const QString & text) {
td = true; td = true;
t.chop(1); t.chop(1);
} }
bool ok = eval.check(t); bool ok = eval->check(t);
if (ok) { if (ok) {
eval.evaluate(); eval->evaluate();
if (td) { if (td) {
icon = icon_calc; icon = icon_calc;
status->setToolTip("Enter to calc -> "+QString::number(value(), 'G', 10)); status->setToolTip("Enter to calc -> "+QString::number(value(), 'G', 10));
@@ -138,7 +141,7 @@ void EvalSpinBox::textChanged_(const QString & text) {
if (pv != value()) emit valueChanged(value()); if (pv != value()) emit valueChanged(value());
} else { } else {
icon = icon_fail; icon = icon_fail;
status->setToolTip(eval.error()); status->setToolTip(eval->error());
} }
resizeIcons(); resizeIcons();
} }
@@ -152,16 +155,16 @@ void EvalSpinBox::setExpression_() {
td = true; td = true;
t.chop(1); t.chop(1);
} }
if (eval.check(t)) { if (eval->check(t)) {
/*if (eval.expression() == "0") lineEdit()->clear(); /*if (eval.expression() == "0") lineEdit()->clear();
else*/ lineEdit()->setText(eval.expression()); else*/ lineEdit()->setText(eval->expression());
eval.evaluate(); eval->evaluate();
if (td) lineEdit()->setText(QString::number(value(), 'G', precision_ > 0 ? precision_ : 16)); if (td) lineEdit()->setText(QString::number(value(), 'G', precision_ > 0 ? precision_ : 16));
status->setToolTip("OK -> " + QString::number(value(), 'G', 10)); status->setToolTip("OK -> " + QString::number(value(), 'G', 10));
icon = icon_ok; icon = icon_ok;
} else { } else {
icon = icon_fail; icon = icon_fail;
status->setToolTip(eval.error()); status->setToolTip(eval->error());
// qDebug() << eval.expression(); // qDebug() << eval.expression();
} }
if (!label->isHidden()) { if (!label->isHidden()) {
@@ -169,12 +172,12 @@ void EvalSpinBox::setExpression_() {
// label->setText("<html><head/><body><p>" + eval.expression() + " <span style=\"color:#005500;\">-&gt; " + QString::number(value(), 'G', 10) + "</span></p></body></html>"); // label->setText("<html><head/><body><p>" + eval.expression() + " <span style=\"color:#005500;\">-&gt; " + QString::number(value(), 'G', 10) + "</span></p></body></html>");
// else // else
// label->setText(eval.expression()); // label->setText(eval.expression());
if (eval.expression() != QString::number(value(), 'G', 10) && eval.expression() != QString::number(value(), 'G', 11) && eval.isCorrect()) if (eval->expression() != QString::number(value(), 'G', 10) && eval->expression() != QString::number(value(), 'G', 11) && eval->isCorrect())
label->setText("<html><head/><body><p><span style=\"color:#005500;\">-&gt; " + QString::number(value(), 'G', 10) + "</span></p></body></html>"); label->setText("<html><head/><body><p><span style=\"color:#005500;\">-&gt; " + QString::number(value(), 'G', 10) + "</span></p></body></html>");
else else
label->setText(""); label->setText("");
lineEdit()->blockSignals(true); lineEdit()->blockSignals(true);
if (!eval.isCorrect()) { if (!eval->isCorrect()) {
lineEdit()->setStyleSheet("color: darkred;"); lineEdit()->setStyleSheet("color: darkred;");
status->show(); status->show();
} else { } else {
@@ -222,20 +225,20 @@ void EvalSpinBox::clear() {
double EvalSpinBox::value() const { double EvalSpinBox::value() const {
if (eval.isCorrect()) { if (eval->isCorrect()) {
return eval.lastResult().real(); return eval->lastResult().real();
} }
return 0.; return 0.;
} }
const QString & EvalSpinBox::expression() const { const QString & EvalSpinBox::expression() const {
return eval.expression(); return eval->expression();
} }
bool EvalSpinBox::isCleared() const { bool EvalSpinBox::isCleared() const {
return (dt == eval.expression() || (value() == 0 && dt.isEmpty())); return (dt == eval->expression() || (value() == 0 && dt.isEmpty()));
} }
@@ -257,7 +260,7 @@ void EvalSpinBox::focusInEvent(QFocusEvent * event) {
status->show(); status->show();
lineEdit()->blockSignals(true); lineEdit()->blockSignals(true);
lineEdit()->setStyleSheet(""); lineEdit()->setStyleSheet("");
if (eval.expression() == "0") lineEdit()->clear(); if (eval->expression() == "0") lineEdit()->clear();
lineEdit()->blockSignals(false); lineEdit()->blockSignals(false);
QAbstractSpinBox::focusInEvent(event); QAbstractSpinBox::focusInEvent(event);
resizeIcons(); resizeIcons();
@@ -271,13 +274,13 @@ void EvalSpinBox::focusOutEvent(QFocusEvent * event) {
// label->setText("<html><head/><body><p>" + eval.expression() + " <span style=\"color:#005500;\">-&gt; " + QString::number(value(), 'G', 10) + "</span></p></body></html>"); // label->setText("<html><head/><body><p>" + eval.expression() + " <span style=\"color:#005500;\">-&gt; " + QString::number(value(), 'G', 10) + "</span></p></body></html>");
// else // else
// label->setText(eval.expression()); // label->setText(eval.expression());
if (eval.expression() != QString::number(value(), 'G', 10) && eval.expression() != QString::number(value(), 'G', 11) && eval.isCorrect()) if (eval->expression() != QString::number(value(), 'G', 10) && eval->expression() != QString::number(value(), 'G', 11) && eval->isCorrect())
label->setText("<html><head/><body><p><span style=\"color:#005500;\">-&gt; " + QString::number(value(), 'G', 10) + "</span></p></body></html>"); label->setText("<html><head/><body><p><span style=\"color:#005500;\">-&gt; " + QString::number(value(), 'G', 10) + "</span></p></body></html>");
else else
label->setText(""); label->setText("");
label->show(); label->show();
lineEdit()->blockSignals(true); lineEdit()->blockSignals(true);
if (!eval.isCorrect()) lineEdit()->setStyleSheet("color: darkred;"); if (!eval->isCorrect()) lineEdit()->setStyleSheet("color: darkred;");
else status->hide(); else status->hide();
// lineEdit()->setText(eval.expression() + " -> " + QString::number(value(), 'G', 10)); // lineEdit()->setText(eval.expression() + " -> " + QString::number(value(), 'G', 10));
//lineEdit()->clear(); //lineEdit()->clear();
@@ -298,8 +301,8 @@ void EvalSpinBox::stepByDouble(double steps) {
//qDebug() << "step" << steps; //qDebug() << "step" << steps;
if (isReadOnly()) return; if (isReadOnly()) return;
QString t = text(); QString t = text();
if (eval.check(t)) { if (eval->check(t)) {
t = eval.expression(); t = eval->expression();
//QRegExp re("(\\-?\\d+)"); //QRegExp re("(\\-?\\d+)");
QRegExp re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)"); QRegExp re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)");
int pos = 0; int pos = 0;
@@ -312,8 +315,8 @@ void EvalSpinBox::stepByDouble(double steps) {
double v = steps; double v = steps;
t = QString::number(v) + t; t = QString::number(v) + t;
} }
eval.check(t); eval->check(t);
lineEdit()->setText(eval.expression()); lineEdit()->setText(eval->expression());
} }
} }
@@ -326,13 +329,13 @@ void EvalSpinBox::setDefaultText(const QString & t) {
// setExpression_(); // setExpression_();
// } // }
//if (t == eval.expression() || (value() == 0 && t.isEmpty())) clear(); //if (t == eval.expression() || (value() == 0 && t.isEmpty())) clear();
cw->setVisible((eval.expression() != dt || (dt.isEmpty() && eval.expression() == "0")) && cw_visible); cw->setVisible((eval->expression() != dt || (dt.isEmpty() && eval->expression() == "0")) && cw_visible);
resizeIcons(); resizeIcons();
} }
void EvalSpinBox::setClearButtonVisible(bool visible) { void EvalSpinBox::setClearButtonVisible(bool visible) {
cw_visible = visible; cw_visible = visible;
cw->setVisible((eval.expression() != dt || (dt.isEmpty() && eval.expression() == "0")) && cw_visible); cw->setVisible((eval->expression() != dt || (dt.isEmpty() && eval->expression() == "0")) && cw_visible);
resizeIcons(); resizeIcons();
} }

View File

@@ -22,9 +22,10 @@
#include <QAbstractSpinBox> #include <QAbstractSpinBox>
#include <QMouseEvent> #include <QMouseEvent>
#include "qpievaluator.h"
#include "qad_widgets_export.h" #include "qad_widgets_export.h"
class QPIEvaluator;
class QLabel; class QLabel;
@@ -64,7 +65,7 @@ protected:
QWidget * status; QWidget * status;
QWidget * cw; QWidget * cw;
QPIEvaluator eval; QPIEvaluator * eval;
QLabel * label; QLabel * label;
QImage icon_ok; QImage icon_ok;
QImage icon_fail; QImage icon_fail;

View File

@@ -1,5 +1,5 @@
#include "qpiconfigvaluewidget.h" #include "qpiconfigvaluewidget.h"
#include "qpievaluator.h" #include "qpievaluator_p.h"
ConfigValueWidget::ConfigValueWidget(QWidget * parent): QWidget(parent), lay(QBoxLayout::Down, this) { ConfigValueWidget::ConfigValueWidget(QWidget * parent): QWidget(parent), lay(QBoxLayout::Down, this) {

View File

@@ -1,4 +1,4 @@
#include "qpievaluator.h" #include "qpievaluator_p.h"
QPIEvaluatorContent::QPIEvaluatorContent() { QPIEvaluatorContent::QPIEvaluatorContent() {

View File

@@ -17,8 +17,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef QPIEVALUATOR_H #ifndef QPIEVALUATOR_P_H
#define QPIEVALUATOR_H #define QPIEVALUATOR_P_H
#include <QStringList> #include <QStringList>
#include <QVector> #include <QVector>
@@ -26,7 +26,6 @@
#include <QDebug> #include <QDebug>
#include <cmath> #include <cmath>
#include <complex> #include <complex>
#include "qad_utils_export.h"
#ifndef PIP_MATH_COMPLEX #ifndef PIP_MATH_COMPLEX
@@ -67,7 +66,7 @@ namespace QPIEvaluatorTypes {
bfIm, bfRe, bfArg, bfLen, bfConj, bfIm, bfRe, bfArg, bfLen, bfConj,
bfRad, bfDeg}; bfRad, bfDeg};
struct QAD_UTILS_EXPORT Instruction { struct Instruction {
Instruction() {;} Instruction() {;}
Instruction(Operation oper, QVector<int> opers, int out_ind, int func = -1) { Instruction(Operation oper, QVector<int> opers, int out_ind, int func = -1) {
operation = oper; operators = opers; out = out_ind; function = func;} operation = oper; operators = opers; out = out_ind; function = func;}
@@ -75,20 +74,20 @@ namespace QPIEvaluatorTypes {
QVector<int> operators; QVector<int> operators;
int out; int out;
int function;}; int function;};
struct QAD_UTILS_EXPORT Element { struct Element {
Element() {;} Element() {;}
Element(eType new_type, int new_num, int new_var_num = -1) {set(new_type, new_num, new_var_num);} Element(eType new_type, int new_num, int new_var_num = -1) {set(new_type, new_num, new_var_num);}
void set(eType new_type, int new_num, int new_var_num = -1) {type = new_type; num = new_num; var_num = new_var_num;} void set(eType new_type, int new_num, int new_var_num = -1) {type = new_type; num = new_num; var_num = new_var_num;}
eType type; eType type;
int num; int num;
int var_num;}; int var_num;};
struct QAD_UTILS_EXPORT Function { struct Function {
Function() {arguments = 0; type = bfUnknown;} Function() {arguments = 0; type = bfUnknown;}
Function(const QString & name, int args, BaseFunctions ftype) {identifier = name; arguments = args; type = ftype;} Function(const QString & name, int args, BaseFunctions ftype) {identifier = name; arguments = args; type = ftype;}
QString identifier; QString identifier;
BaseFunctions type; BaseFunctions type;
int arguments;}; int arguments;};
struct QAD_UTILS_EXPORT Variable { struct Variable {
Variable() {value = 0.;} Variable() {value = 0.;}
Variable(const QString & var_name, complexd val) {name = var_name; value = val;} Variable(const QString & var_name, complexd val) {name = var_name; value = val;}
QString name; QString name;
@@ -108,7 +107,7 @@ namespace QPIEvaluatorTypes {
& &
| |
*/ */
class QAD_UTILS_EXPORT QPIEvaluatorContent class QPIEvaluatorContent
{ {
friend class QPIEvaluator; friend class QPIEvaluator;
public: public:
@@ -146,7 +145,7 @@ private:
}; };
class QAD_UTILS_EXPORT QPIEvaluator class QPIEvaluator
{ {
public: public:
QPIEvaluator() {correct = false ;} QPIEvaluator() {correct = false ;}
@@ -206,4 +205,4 @@ private:
inline bool operator ==(QPIEvaluatorTypes::Element e1, QPIEvaluatorTypes::Element e2) {return (e1.type == e2.type && e1.num == e2.num);} inline bool operator ==(QPIEvaluatorTypes::Element e1, QPIEvaluatorTypes::Element e2) {return (e1.type == e2.type && e1.num == e2.num);}
inline bool operator !=(QPIEvaluatorTypes::Element e1, QPIEvaluatorTypes::Element e2) {return (e1.type != e2.type || e1.num != e2.num);} inline bool operator !=(QPIEvaluatorTypes::Element e1, QPIEvaluatorTypes::Element e2) {return (e1.type != e2.type || e1.num != e2.num);}
#endif // QPIEVALUATOR_H #endif // QPIEVALUATOR_P_H

View File

@@ -1,3 +1,6 @@
find_package(PIP)
if (PIP_FOUND)
project(qpicalc) project(qpicalc)
if(APPLE) if(APPLE)
set(APP_ICON "") set(APP_ICON "")
@@ -7,8 +10,10 @@ else()
set(APP_ICON "icons/qpicalculator.png") set(APP_ICON "icons/qpicalculator.png")
endif() endif()
set(APP_INFO "Small calculator ang grapher") set(APP_INFO "Small calculator ang grapher")
qad_application(${PROJECT_NAME} "Gui;Widgets" "qad_utils;qad_widgets;qad_graphic;qad_piqt;pip") qad_application(${PROJECT_NAME} "Gui;Widgets" "qad_graphic;qad_piqt")
if (Qt5_FOUND) if (Qt5_FOUND)
import_version(${PROJ_NAME}5 ${PROJECT_NAME}) import_version(${PROJ_NAME}5 ${PROJECT_NAME})
deploy_target(${PROJECT_NAME}5 DEPLOY_DIR ${CMAKE_CURRENT_BINARY_DIR} DESTINATION ${ROOT_DIR}/release) deploy_target(${PROJECT_NAME}5 DEPLOY_DIR ${CMAKE_CURRENT_BINARY_DIR} DESTINATION ${ROOT_DIR}/release)
endif() endif()
endif()

View File

@@ -258,13 +258,13 @@ void MainWindow::on_buttonGraphicClear_clicked() {
void MainWindow::on_tabWidget_currentChanged(int index) { void MainWindow::on_tabWidget_currentChanged(int index) {
QPIEvaluator eval; PIEvaluator eval;
evaluator.clearCustomVariables(); evaluator.clearCustomVariables();
for (int i = 0; i < treeVariables->topLevelItemCount(); ++i) { for (int i = 0; i < treeVariables->topLevelItemCount(); ++i) {
QString vn, vv; QString vn, vv;
vn = treeVariables->topLevelItem(i)->text(0); vn = treeVariables->topLevelItem(i)->text(0);
vv = treeVariables->topLevelItem(i)->text(1); vv = treeVariables->topLevelItem(i)->text(1);
eval.check(vv); eval.check(Q2PIString(vv));
evaluator.setVariable(Q2PIString(vn), eval.evaluate()); evaluator.setVariable(Q2PIString(vn), eval.evaluate());
} }
if (index == 0) on_lineInput_returnPressed(); if (index == 0) on_lineInput_returnPressed();