new Graphic feature - floatingAxisType: Free, TraceX/Y

qpicalculator moved to PIEvaluator
This commit is contained in:
2020-08-26 23:44:50 +03:00
parent 9130496887
commit 7f820c8f67
7 changed files with 150 additions and 45 deletions

View File

@@ -7,7 +7,7 @@ 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_application(${PROJECT_NAME} "Gui;Widgets" "qad_utils;qad_widgets;qad_graphic;pip;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)

View File

@@ -1,4 +1,5 @@
#include "mainwindow.h"
#include "piqt.h"
MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow() {
@@ -62,7 +63,7 @@ void MainWindow::redrawGraphics() {
graphic->setGraphicName(ti->text(1), i);
pol.clear();
if (ti->checkState(0) == Qt::Checked) {
if (evaluator.check(ti->text(1))) {
if (evaluator.check(Q2PIString(ti->text(1)))) {
cx = sx;
while (cx < fx) {
evaluator.setVariable(vi, complexd(cx, 0.));
@@ -140,19 +141,19 @@ void MainWindow::saving(QPIConfig & conf) {
void MainWindow::on_lineInput_textChanged(QString text) {
if (evaluator.check(text)) lineInput->setPalette(npal);
if (evaluator.check(Q2PIString(text))) lineInput->setPalette(npal);
else lineInput->setPalette(epal);
labelParsed->setText(evaluator.expression());
labelError->setText(evaluator.error());
labelParsed->setText(PI2QString(evaluator.expression()));
labelError->setText(PI2QString(evaluator.error()));
}
void MainWindow::on_lineInput_returnPressed() {
bool ret = evaluator.check(lineInput->text());
bool ret = evaluator.check(Q2PIString(lineInput->text()));
if (ret) lineInput->setPalette(npal);
else lineInput->setPalette(epal);
labelParsed->setText(evaluator.expression());
labelError->setText(evaluator.error());
labelParsed->setText(PI2QString(evaluator.expression()));
labelError->setText(PI2QString(evaluator.error()));
if (!ret) return;
complexd val = evaluator.evaluate();
evaluator.setVariable(ans, val);
@@ -182,6 +183,16 @@ void MainWindow::on_lineInput_returnPressed() {
}
void MainWindow::on_treeGraphics_itemSelectionChanged() {
buttonGraphicDel->setDisabled(treeGraphics->selectedItems().isEmpty());
if (treeGraphics->currentItem()) {
int ind = treeGraphics->indexOfTopLevelItem(treeGraphics->currentItem());
if (ind < 0 || ind >= graphic->graphicsCount()) return;
graphic->setCurrentGraphic(ind);
}
}
void MainWindow::on_treeGraphics_itemDoubleClicked(QTreeWidgetItem * item, int column) {
Qt::ItemFlags f = item->flags();
if (column != 1) f &= ~Qt::ItemIsEditable;
@@ -254,7 +265,7 @@ void MainWindow::on_tabWidget_currentChanged(int index) {
vn = treeVariables->topLevelItem(i)->text(0);
vv = treeVariables->topLevelItem(i)->text(1);
eval.check(vv);
evaluator.setVariable(vn, eval.evaluate());
evaluator.setVariable(Q2PIString(vn), eval.evaluate());
}
if (index == 0) on_lineInput_returnPressed();
if (index == 2) redrawGraphics();

View File

@@ -8,7 +8,7 @@
#include <QScrollBar>
#include <QColorDialog>
#include "ui_mainwindow.h"
#include "qpievaluator.h"
#include "pievaluator.h"
#include "session_manager.h"
@@ -26,7 +26,7 @@ private:
void updateGraphics();
void redrawGraphics();
QPIEvaluator evaluator;
PIEvaluator evaluator;
QPalette npal, epal;
SessionManager session;
int ans;
@@ -39,7 +39,7 @@ private slots:
void on_lineInput_returnPressed();
void on_treeHistory_itemDoubleClicked(QTreeWidgetItem * item, int column) {lineInput->setText(item->text(0));}
void on_treeVariables_itemSelectionChanged() {buttonVarDel->setDisabled(treeVariables->selectedItems().isEmpty());}
void on_treeGraphics_itemSelectionChanged() {buttonGraphicDel->setDisabled(treeGraphics->selectedItems().isEmpty());}
void on_treeGraphics_itemSelectionChanged();
void on_treeGraphics_itemChanged(QTreeWidgetItem * , int col) { if (active_) redrawGraphics();}
void on_treeGraphics_itemDoubleClicked(QTreeWidgetItem * item, int column);
void on_buttonVarAdd_clicked();