Skip to content

Commit 37ab498

Browse files
author
AnotherStudent
committed
fucked hack
1 parent 3db6943 commit 37ab498

10 files changed

+54
-49
lines changed

Core/EquationThread.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ void EquationThread::run()
1616
double ans;
1717

1818
switch (mode) {
19-
case ModeEqDich:
20-
ans = HalfDiv(QStrToCStr(func), a, b, e, &iterations);
21-
break;
22-
case ModeEqChord:
23-
ans = Chord(QStrToCStr(func), a, b, e, &iterations);
24-
break;
25-
default:;
19+
case ModeEqHalfDiv:
20+
ans = EqHalfDiv(QStrToCStr(func), a, b, e, &iterations);
21+
break;
22+
23+
case ModeEqChord:
24+
ans = EqChord(QStrToCStr(func), a, b, e, &iterations);
25+
break;
26+
27+
default:
28+
ans = 0;
2629
}
2730

2831
if(IsErrorCalc())

Core/EquationThread.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
#include "XCore.h"
55

6-
#define ModeEqDich 0
7-
#define ModeEqChord 1
6+
#define ModeEqHalfDiv 1
7+
#define ModeEqChord 2
88

99
typedef int ModeEq;
1010

Frames/integralConstStepFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
IntegralConstStepFrame::IntegralConstStepFrame(QWidget *parent) : FrameThreadHelper(parent), ui(new Ui::IntegralConstStepFrame)
77
{
88
ui->setupUi(this);
9-
change();
9+
//change();
1010
}
1111

1212
IntegralConstStepFrame::~IntegralConstStepFrame()

Frames/integralFloatingStepFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ IntegralFloatingStepFrame::IntegralFloatingStepFrame(QWidget *parent) : FrameThr
88
ui->setupUi(this);
99
validatorSetup();
1010
setTimeOutUse(true);
11-
change();
11+
//change();
1212
}
1313

1414
IntegralFloatingStepFrame::~IntegralFloatingStepFrame()

Frames/integralMultipleFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ IntegralMultipleFrame::IntegralMultipleFrame(QWidget *parent) :
99
{
1010
ui->setupUi(this);
1111
setTimeOutUse(true);
12-
change();
12+
//change();
1313
}
1414

1515
IntegralMultipleFrame::~IntegralMultipleFrame()

Frames/nonlinearEquationsFrame.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ NonlinearEquationsFrame::NonlinearEquationsFrame(QWidget *parent, ModeEq mode) :
1111
this->mode = mode;
1212
validatorSetup();
1313
setTimeOutUse(true);
14-
change();
14+
//change();
1515
}
1616

1717
NonlinearEquationsFrame::~NonlinearEquationsFrame()
@@ -26,44 +26,44 @@ void NonlinearEquationsFrame::change()
2626

2727
cancel();
2828

29-
// a = Expression(QStrToCStr(ui->limitAEdit->text()));
30-
// if(IsNan(a))
31-
// {
32-
// showAnswer("Неверный параметр a");
33-
// return;
34-
// }
29+
a = Expression(QStrToCStr(ui->limitAEdit->text()));
30+
if(IsNan(a))
31+
{
32+
showAnswer("Неверный параметр a");
33+
return;
34+
}
3535

36-
// b = Expression(QStrToCStr(ui->limitBEdit->text()));
37-
// if(IsNan(b))
38-
// {
39-
// showAnswer("Неверный параметр b");
40-
// return;
41-
// }
36+
b = Expression(QStrToCStr(ui->limitBEdit->text()));
37+
if(IsNan(b))
38+
{
39+
showAnswer("Неверный параметр b");
40+
return;
41+
}
4242

43-
// if(a >= b)
44-
// {
45-
// showAnswer("b должн быть больше a");
46-
// return;
47-
// }
43+
if(a >= b)
44+
{
45+
showAnswer("b должн быть больше a");
46+
return;
47+
}
4848

49-
// e = ui->epsilonEdit->text().toDouble();
49+
e = ui->epsilonEdit->text().toDouble();
5050

51-
// if(e >= 1 || e <= 1e-99)
52-
// {
53-
// showAnswer("Точность должна быть в пределах (1..1e-99)");
54-
// return;
55-
// }
51+
if(e >= 1 || e <= 1e-99)
52+
{
53+
showAnswer("Точность должна быть в пределах (1..1e-99)");
54+
return;
55+
}
5656

57-
// func = ui->equationEdit->text();
57+
func = ui->equationEdit->text();
5858

59-
// setThread(new EquationThread(func, a, b, e, mode));
59+
setThread(new EquationThread(func, a, b, e, mode));
6060

61-
// connect(getThread(), SIGNAL(sendResultSignal(double, int)), SLOT(onResult(double,int)));
62-
// connect(getThread(), SIGNAL(sendErrorSignal(int)), SLOT(onError(int)));
61+
connect(getThread(), SIGNAL(sendResultSignal(double, int)), SLOT(onResult(double,int)));
62+
connect(getThread(), SIGNAL(sendErrorSignal(int)), SLOT(onError(int)));
6363

64-
// start();
64+
start();
6565

66-
// showAnswer(sCalculating);
66+
showAnswer(sCalculating);
6767
}
6868

6969
void NonlinearEquationsFrame::showAnswer(QString ans)

Frames/nonlinearEquationsFrame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class NonlinearEquationsFrame : public FrameThreadHelper
1818
void validatorSetup();
1919

2020
public:
21-
explicit NonlinearEquationsFrame(QWidget *parent = 0, ModeEq mode = ModeEqDich);
21+
explicit NonlinearEquationsFrame(QWidget *parent, ModeEq mode);
2222
~NonlinearEquationsFrame();
2323

2424
private slots:

MathCore/Algorithms/Equation.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "../MathParser.h"
33
#include "../MathUtils.h"
44

5-
int Sign(double v)
5+
static int Sign(double v)
66
{
77
if(v < 0)
88
return -1;
@@ -11,7 +11,7 @@ int Sign(double v)
1111
else return 0;
1212
}
1313

14-
double HalfDiv(char* func, double a, double b, double epsilon, int* countRef)
14+
double EqHalfDiv(char* func, double a, double b, double epsilon, int* countRef)
1515
{
1616
double c = 0;
1717
int count;
@@ -53,7 +53,7 @@ double HalfDiv(char* func, double a, double b, double epsilon, int* countRef)
5353
return c;
5454
}
5555

56-
double Chord(char* func, double a, double b, double epsilon, int* countRef)
56+
double EqChord(char* func, double a, double b, double epsilon, int* countRef)
5757
{
5858
double t, aOld;
5959
int count;

MathCore/Algorithms/Equation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef equation_h
22
#define equation_h
33

4-
double HalfDiv(char* func, double a, double b, double epsilon, int* countRef);
5-
double Chord(char* func, double a, double b, double epsilon, int* countRef);
4+
double EqHalfDiv(char* func, double a, double b, double epsilon, int* countRef);
5+
double EqChord(char* func, double a, double b, double epsilon, int* countRef);
66

77
#endif /* equation_h */

mainwindow.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "ui_mainwindow.h"
33
#include "QLabel"
44
#include "QTreeWidget"
5+
#include "Core/CalcThread.h"
56

67
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
78
{
@@ -41,7 +42,7 @@ void MainWindow::createMenu()
4142
const int nolinearItemsCount = 2;
4243
TMember nolinearItems[nolinearItemsCount] =
4344
{
44-
{"Метод Дихотомии", new NonlinearEquationsFrame(this, ModeEqDich)},
45+
{"Метод Дихотомии", new NonlinearEquationsFrame(this, ModeEqHalfDiv)},
4546
{"Метод хорд", new NonlinearEquationsFrame(this, ModeEqChord)}
4647
};
4748

@@ -143,6 +144,7 @@ void MainWindow::on_menu_itemClicked(QTreeWidgetItem *item, int column)
143144
{
144145
ui->stackedWidget->setCurrentWidget(currentWidgetIterator.value());
145146
ui->frameName->setText(item->parent()->text(0) + ": " + item->text(0));
147+
static_cast<FrameThreadHelper*>(currentWidgetIterator.value())->change();
146148
}
147149
}
148150

0 commit comments

Comments
 (0)