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

View File

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

View File

@@ -217,7 +217,7 @@ macro(find_qt)
#if (Qt5_FOUND)
# set(_MSG 0)
#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)
set(CMAKE_SHARED_MODULE_SUFFIX_CXX ".so")
set(CMAKE_SHARED_LIBRARY_SUFFIX_CXX ".so")

View File

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

View File

@@ -1,8 +1,10 @@
find_package(OpenGL REQUIRED)
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")
if (((DEFINED QGLVIEW) AND QGLVIEW) OR (NOT DEFINED QGLVIEW))
find_package(OpenGL REQUIRED)
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}")
qt_sources(test_SRC DIR "qglview_test")
qt_wrap(${test_SRC} CPPS test_CPP)
qt_add_executable(qglview_test test_CPP)
qt_target_link_libraries(qglview_test qglview)
qt_sources(test_SRC DIR "qglview_test")
qt_wrap(${test_SRC} CPPS test_CPP)
qt_add_executable(qglview_test test_CPP)
qt_target_link_libraries(qglview_test qglview)
endif()

View File

@@ -8,12 +8,14 @@
#include <QStyle>
#include <QStyleOptionSpinBox>
#include "qad_types.h"
#include "qpievaluator_p.h"
EvalSpinBox::EvalSpinBox(QWidget * parent): QAbstractSpinBox(parent) {
status = new QWidget(lineEdit());
cw = new QWidget(lineEdit());
label = new QLabel(lineEdit());
eval = new QPIEvaluator();
precision_ = -1;
// label->hide();
clear_im.load(":/icons/edit-clear-locationbar-rtl.png");
@@ -40,9 +42,10 @@ EvalSpinBox::EvalSpinBox(QWidget * parent): QAbstractSpinBox(parent) {
EvalSpinBox::~EvalSpinBox() {
delete eval;
delete label;
delete cw;
delete status;
delete label;
}
@@ -124,9 +127,9 @@ void EvalSpinBox::textChanged_(const QString & text) {
td = true;
t.chop(1);
}
bool ok = eval.check(t);
bool ok = eval->check(t);
if (ok) {
eval.evaluate();
eval->evaluate();
if (td) {
icon = icon_calc;
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());
} else {
icon = icon_fail;
status->setToolTip(eval.error());
status->setToolTip(eval->error());
}
resizeIcons();
}
@@ -152,16 +155,16 @@ void EvalSpinBox::setExpression_() {
td = true;
t.chop(1);
}
if (eval.check(t)) {
if (eval->check(t)) {
/*if (eval.expression() == "0") lineEdit()->clear();
else*/ lineEdit()->setText(eval.expression());
eval.evaluate();
else*/ lineEdit()->setText(eval->expression());
eval->evaluate();
if (td) lineEdit()->setText(QString::number(value(), 'G', precision_ > 0 ? precision_ : 16));
status->setToolTip("OK -> " + QString::number(value(), 'G', 10));
icon = icon_ok;
} else {
icon = icon_fail;
status->setToolTip(eval.error());
status->setToolTip(eval->error());
// qDebug() << eval.expression();
}
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>");
// else
// 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>");
else
label->setText("");
lineEdit()->blockSignals(true);
if (!eval.isCorrect()) {
if (!eval->isCorrect()) {
lineEdit()->setStyleSheet("color: darkred;");
status->show();
} else {
@@ -222,20 +225,20 @@ void EvalSpinBox::clear() {
double EvalSpinBox::value() const {
if (eval.isCorrect()) {
return eval.lastResult().real();
if (eval->isCorrect()) {
return eval->lastResult().real();
}
return 0.;
}
const QString & EvalSpinBox::expression() const {
return eval.expression();
return eval->expression();
}
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();
lineEdit()->blockSignals(true);
lineEdit()->setStyleSheet("");
if (eval.expression() == "0") lineEdit()->clear();
if (eval->expression() == "0") lineEdit()->clear();
lineEdit()->blockSignals(false);
QAbstractSpinBox::focusInEvent(event);
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>");
// else
// 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>");
else
label->setText("");
label->show();
lineEdit()->blockSignals(true);
if (!eval.isCorrect()) lineEdit()->setStyleSheet("color: darkred;");
if (!eval->isCorrect()) lineEdit()->setStyleSheet("color: darkred;");
else status->hide();
// lineEdit()->setText(eval.expression() + " -> " + QString::number(value(), 'G', 10));
//lineEdit()->clear();
@@ -298,8 +301,8 @@ void EvalSpinBox::stepByDouble(double steps) {
//qDebug() << "step" << steps;
if (isReadOnly()) return;
QString t = text();
if (eval.check(t)) {
t = eval.expression();
if (eval->check(t)) {
t = eval->expression();
//QRegExp re("(\\-?\\d+)");
QRegExp re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)");
int pos = 0;
@@ -312,8 +315,8 @@ void EvalSpinBox::stepByDouble(double steps) {
double v = steps;
t = QString::number(v) + t;
}
eval.check(t);
lineEdit()->setText(eval.expression());
eval->check(t);
lineEdit()->setText(eval->expression());
}
}
@@ -326,13 +329,13 @@ void EvalSpinBox::setDefaultText(const QString & t) {
// setExpression_();
// }
//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();
}
void EvalSpinBox::setClearButtonVisible(bool 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();
}

View File

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

View File

@@ -1,5 +1,5 @@
#include "qpiconfigvaluewidget.h"
#include "qpievaluator.h"
#include "qpievaluator_p.h"
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() {

View File

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

View File

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

View File

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