Skip to content

Commit

Permalink
Codestyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitozz committed Jan 23, 2019
1 parent 0a5b6dc commit e74eb7e
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 121 deletions.
42 changes: 21 additions & 21 deletions core/misescalcelast.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* misescalcelast.cpp
* Copyright (C) 2018 Vitaly Tonkacheyev
* Copyright (C) 2018-2019 Vitaly Tonkacheyev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -26,25 +26,25 @@
#endif

MisesCalcElast::MisesCalcElast()
:iterations_(ZERO),
startAngle_(ZERO),
youngModule_(ZERO),
trussLength_(ZERO),
csArea_(ZERO),
forceAngle_(ZERO),
supportStfns_(ZERO),
hwM_(ZERO),
Afcal_(ZERO),
tgA_(ZERO),
tgB_(ZERO),
sinA_(ZERO),
cosA_(ZERO),
scale_(ZERO),
extremum_(QPointF()),
curveFx_(QVector<QPointF>()),
allkeM_(QVector<QPointF>()),
extremums_(QVector<QPointF>()),
angles_(QVector<QString>())
:iterations_(ZERO),
startAngle_(ZERO),
youngModule_(ZERO),
trussLength_(ZERO),
csArea_(ZERO),
forceAngle_(ZERO),
supportStfns_(ZERO),
hwM_(ZERO),
Afcal_(ZERO),
tgA_(ZERO),
tgB_(ZERO),
sinA_(ZERO),
cosA_(ZERO),
scale_(ZERO),
extremum_(QPointF()),
curveFx_(QVector<QPointF>()),
allkeM_(QVector<QPointF>()),
extremums_(QVector<QPointF>()),
angles_(QVector<QString>())
{
}

Expand Down Expand Up @@ -160,7 +160,7 @@ void MisesCalcElast::obtainForcesVectors(const double &angle)
++i;
}
#ifdef IS_DEBUG
qDebug() << allkeM_;
qDebug() << allkeM_;
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion core/misescalcelast.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* misescalcelast.h
* Copyright (C) 2018 Vitaly Tonkacheyev
* Copyright (C) 2018-2019 Vitaly Tonkacheyev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
10 changes: 5 additions & 5 deletions core/misescalcnelast.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* misescalcnelast.cpp
* Copyright (C) 2018 Vitaly Tonkacheyev
* Copyright (C) 2018-2019 Vitaly Tonkacheyev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -48,8 +48,8 @@ MisesCalcNonElast::MisesCalcNonElast():
double MisesCalcNonElast::getForce(const double &value) const
{
const double A = fZeroCheck(csArea_) || fZeroCheck(youngModule_)
? ZERO
: value*trussLength_*supportStfns_/(youngModule_*csArea_);
? ZERO
: value*trussLength_*supportStfns_/(youngModule_*csArea_);
const double var1 = fZeroCheck(tgA_) ? ZERO : 1.0/tgA_ - value;
const double var12 = pow2(var1);
const double var4 = 1.0-value*tgB_;
Expand Down Expand Up @@ -79,8 +79,8 @@ double MisesCalcNonElast::getDfDx(const double &value) const
const double dC = (-1.0)/sqrt(var32+var22);
const double dD = (-1.0)*var2*(-2*tgB_*var3-2*var2)/(2*sqrt(var5));
const double dE = fZeroCheck(csArea_) || fZeroCheck(youngModule_)
? ZERO
: trussLength_*supportStfns_/(csArea_*youngModule_);
? ZERO
: trussLength_*supportStfns_/(csArea_*youngModule_);
return dA+dB+dC+dD+dE + 2*sinA_;
}

Expand Down
2 changes: 1 addition & 1 deletion core/misescalcnelast.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* misescalcnelast.h
* Copyright (C) 2018 Vitaly Tonkacheyev
* Copyright (C) 2018-2019 Vitaly Tonkacheyev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define ORGANIZATION "thesomeprojects"
#define APPNAME "qmisestruss"
#define APPVERISON "0.0.4"
#define APPVERISON "0.0.5"

#define NumIter "ITERATIONS"
#define NumStartAngle "START_ANGLE"
Expand Down
59 changes: 29 additions & 30 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* mainwindow.cpp
* Copyright (C) 2015-2018 Vitaly Tonkacheyev
* Copyright (C) 2015-2019 Vitaly Tonkacheyev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -45,16 +45,16 @@
#include <qwt_legend.h>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
misesNE_(MisesCalcNonElast::Ptr(new MisesCalcNonElast())),
misesE_(MisesCalcElast::Ptr(new MisesCalcElast())),
grid_(new QwtPlotGrid()),
buffer_(QString()),
lastDir_(QDir::home().absolutePath()),
log_(QString()),
popupMenu_(new QMenu(this)),
copyAction_(new QAction(tr("&Copy Data"), popupMenu_))
QMainWindow(parent),
ui(new Ui::MainWindow),
misesNE_(MisesCalcNonElast::Ptr(new MisesCalcNonElast())),
misesE_(MisesCalcElast::Ptr(new MisesCalcElast())),
grid_(new QwtPlotGrid()),
buffer_(QString()),
lastDir_(QDir::home().absolutePath()),
log_(QString()),
popupMenu_(new QMenu(this)),
copyAction_(new QAction(tr("&Copy Data"), popupMenu_))
{
ui->setupUi(this);
QSettings settings(this);
Expand Down Expand Up @@ -207,11 +207,11 @@ void MainWindow::onExit()
void MainWindow::onAbout()
{
const QString message(tr("<!DOCTYPE html><html><body>"
"<p><b>Calculation of von Mises truss parameters</b></p>"
"<p>Written using Qt</p>"
"<p>2015-2018 (c) Vitaly Tonkacheyev <address><a href=\"mailto:thetvg@gmail.com\">&lt;EMail&gt;</a></address></p>"
"<a href=\"http://sites.google.com/site/thesomeprojects/\">Program WebSite</a>"
"<p>version: <b>%1</b></p></body></html>").arg(APPVERISON));
"<p><b>Calculation of von Mises truss parameters</b></p>"
"<p>Written using Qt</p>"
"<p>2015-2019 (c) Vitaly Tonkacheyev <address><a href=\"mailto:thetvg@gmail.com\">&lt;EMail&gt;</a></address></p>"
"<a href=\"http://sites.google.com/site/thesomeprojects/\">Program WebSite</a>"
"<p>version: <b>%1</b></p></body></html>").arg(APPVERISON));
const QString appLogo = ":/icons/f(x)48.png";
QMessageBox about;
about.setIconPixmap(QPixmap(appLogo));
Expand Down Expand Up @@ -281,11 +281,11 @@ void MainWindow::calculate()
ui->progressBar->setValue(index+1);
}
log_ = tr("Number of items in curve: %1\n").arg(QString::number(curveFx_.count()))
+tr("Number of iderivatives: %1\n").arg(QString::number(curvedFx_.count()))
+tr("Number of KeM: %1\n").arg(QString::number(kems.count()))
+tr("Number of item in elastic calculation: %1\n").arg(QString::number(elastCurve.count()))
+tr("GCS Plot Scale: %1\n").arg(QString::number(misesNE_->scale()))
+tr("S. Bilyk Plot Scale: %1\n").arg(QString::number(misesE_->scale()));
+tr("Number of iderivatives: %1\n").arg(QString::number(curvedFx_.count()))
+tr("Number of KeM: %1\n").arg(QString::number(kems.count()))
+tr("Number of item in elastic calculation: %1\n").arg(QString::number(elastCurve.count()))
+tr("GCS Plot Scale: %1\n").arg(QString::number(misesNE_->scale()))
+tr("S. Bilyk Plot Scale: %1\n").arg(QString::number(misesE_->scale()));

ui->cLog->setText(log_);
ui->tableWidget->setColumnWidth(0, 150);
Expand Down Expand Up @@ -452,10 +452,9 @@ void MainWindow::copyToClipboard()

void MainWindow::saveSelection()
{
QStringList lines;
lines << QString("%1\t%2\t%3\n").arg("alpha_0")
.arg(ui->extremums->horizontalHeaderItem(1)->text())
.arg(ui->extremums->horizontalHeaderItem(2)->text());
QStringList lines({QString("%1\t%2\t%3\n").arg("alpha_0")
.arg(ui->extremums->horizontalHeaderItem(1)->text())
.arg(ui->extremums->horizontalHeaderItem(2)->text())});
for (int row =0; row < ui->extremums->rowCount(); ++row) {
QStringList line;
for (int column = 0; column < ui->extremums->columnCount(); ++column) {
Expand All @@ -465,11 +464,11 @@ void MainWindow::saveSelection()
}
QString result = lines.join("");
QString filename = QFileDialog::getSaveFileName(this,
tr("Save file"),
lastDir_,
tr("CSV Table (*.csv)"),
nullptr,
nullptr);
tr("Save file"),
lastDir_,
tr("CSV Table (*.csv)"),
nullptr,
nullptr);
if (!filename.isEmpty()) {
int dotIndex = filename.lastIndexOf(".");
if (dotIndex < 0) {
Expand Down
76 changes: 38 additions & 38 deletions gui/mainwindow.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* mainwindow.h
* Copyright (C) 2015-2018 Vitaly Tonkacheyev
* Copyright (C) 2015-2019 Vitaly Tonkacheyev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -34,67 +34,67 @@ class MainWindow;

class MainWindow : public QMainWindow
{
Q_OBJECT
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
~MainWindow();

protected slots:
//DoubleSpinbox slots
void startAnlgeChanged(const double &value);
void youngModuleChanged(const double &value);
void trussLengthChanged(const double &value);
void csAreaChnged(const double &value);
void forceAngleChanged(const double &value);
void supportStfnsChanged(const double &value);
void iterationChanged(const double &value);
//DoubleSpinbox slots
void startAnlgeChanged(const double &value);
void youngModuleChanged(const double &value);
void trussLengthChanged(const double &value);
void csAreaChnged(const double &value);
void forceAngleChanged(const double &value);
void supportStfnsChanged(const double &value);
void iterationChanged(const double &value);
void hwChanged(const double &value);
void AfcalChanged(const double &value);
//Buttons
void onCountBtn();
void onCountExtremums();
void onSaveBtn();
//Buttons
void onCountBtn();
void onCountExtremums();
void onSaveBtn();
void calculateKv();
void onPlus();
void onSubst();
//Table1
void onTableSelectionChanged();
void onPopup(const QPoint& point);
void onCopy(bool);
//TabWidget
void onTabChanged(int index);
//Menu
void onExit();
void onAbout();
//Table1
void onTableSelectionChanged();
void onPopup(const QPoint& point);
void onCopy(bool);
//TabWidget
void onTabChanged(int index);
//Menu
void onExit();
void onAbout();

protected:
void closeEvent(QCloseEvent *e);
void closeEvent(QCloseEvent *e);

private:
void calculate();
void calculateExtremums();
void checkVars();
void keyPressEvent(QKeyEvent * event);
void copyToClipboard();
void saveSelection();
void saveSettings();
void calculate();
void calculateExtremums();
void checkVars();
void keyPressEvent(QKeyEvent * event);
void copyToClipboard();
void saveSelection();
void saveSettings();
void showDoneDialog(const QString &text);
bool fZeroCheck(const double &a) const { return (qAbs(a-ZERO) < EPSILON_);}
double TextToDouble(const QString &text) const;
QString DoubleToText(const double &value, const int &size) const;
void enableButtons(bool enabled);

private:
Ui::MainWindow *ui;
Ui::MainWindow *ui;
MisesCalcNonElast::Ptr misesNE_;
MisesCalcElast::Ptr misesE_;
QSharedPointer<QwtPlotGrid> grid_;
QString buffer_;
QString lastDir_;
QSharedPointer<QwtPlotGrid> grid_;
QString buffer_;
QString lastDir_;
QString log_;
QMenu *popupMenu_;
QAction *copyAction_;
QMenu *popupMenu_;
QAction *copyAction_;
};

#endif // MAINWINDOW_H
47 changes: 23 additions & 24 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* main.cpp
* Copyright (C) 2015-2018 Vitaly Tonkacheyev
* Copyright (C) 2015-2019 Vitaly Tonkacheyev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -23,28 +23,27 @@

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setOrganizationName(QString(ORGANIZATION));
a.setApplicationName(QString(APPNAME));
a.setApplicationVersion(QString(APPVERISON));
QTranslator translator;
const QStringList localeDirs = QStringList()
<< qApp->applicationDirPath()
<< QString("%1/langs").arg(QDir::currentPath())
<< QString("%1/langs").arg(qApp->applicationDirPath())
<< QString("../share/%1/langs").arg(APPNAME)
<< QString("/usr/share/%1/langs").arg(QString(APPNAME))
<< QString("/usr/local/share/%1/langs").arg(QString(APPNAME))
<< QString("%1/.local/share/%2/langs").arg(QDir::home().absolutePath(),QString(APPNAME));
const QString langFile(APPNAME);
foreach(const QString &dir, localeDirs){
if (translator.load(QLocale::system(),langFile, "_", dir )) {
qApp->installTranslator(&translator);
break;
}
}
MainWindow w;
w.show();
QApplication a(argc, argv);
a.setOrganizationName(QString(ORGANIZATION));
a.setApplicationName(QString(APPNAME));
a.setApplicationVersion(QString(APPVERISON));
QTranslator translator;
const QStringList localeDirs({qApp->applicationDirPath(),
QString("%1/langs").arg(QDir::currentPath()),
QString("%1/langs").arg(qApp->applicationDirPath()),
QString("../share/%1/langs").arg(APPNAME),
QString("/usr/share/%1/langs").arg(QString(APPNAME)),
QString("/usr/local/share/%1/langs").arg(QString(APPNAME)),
QString("%1/.local/share/%2/langs").arg(QDir::home().absolutePath(),QString(APPNAME))});
const QString langFile(APPNAME);
foreach(const QString &dir, localeDirs){
if (translator.load(QLocale::system(),langFile, "_", dir )) {
qApp->installTranslator(&translator);
break;
}
}
MainWindow w;
w.show();

return a.exec();
return a.exec();
}

0 comments on commit e74eb7e

Please sign in to comment.