Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuelemaz authored Dec 23, 2022
1 parent 043318c commit 8303c75
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 96 deletions.
33 changes: 32 additions & 1 deletion diagview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ DiagView::DiagView(Context &ctx, QWidget *parent) :
std::pair<std::vector<double>,std::vector<double>> xyH = ctx.getHpair();
std::pair<std::vector<double>,std::vector<double>> xyT = ctx.getTpair();
std::pair<std::vector<double>,std::vector<double>> xyM = ctx.getMpair();

yHmin = *std::min_element(xyH.second.begin(), xyH.second.end());
yHmax = *std::max_element(xyH.second.begin(), xyH.second.end());
yTmin = *std::min_element(xyT.second.begin(), xyT.second.end());
yTmax = *std::max_element(xyT.second.begin(), xyT.second.end());
yMmin = *std::min_element(xyM.second.begin(), xyM.second.end());
yMmax = *std::max_element(xyM.second.begin(), xyM.second.end());

std::pair<std::vector<double>,std::vector<double>> beamPoints = std::make_pair(std::vector<double>{0,ctx.beam.length}, std::vector<double>{0,0});

ui->diagHPlot->addGraph();
Expand All @@ -29,7 +37,7 @@ DiagView::DiagView(Context &ctx, QWidget *parent) :
ui->diagHPlot->graph(1)->setData(QVector<double>(xyH.first.begin(),xyH.first.end()), QVector<double>(xyH.second.begin(),xyH.second.end()));
ui->diagHPlot->graph(0)->setPen(QPen(QColor(102,161,130), 2));
ui->diagHPlot->replot();
ui->diagHPlot->rescaleAxes(true);
ui->diagTPlot->rescaleAxes(true);
ui->diagHPlot->xAxis->setLabel("Beam");
ui->diagHPlot->yAxis->setLabel("Axial force");
ui->diagHPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
Expand Down Expand Up @@ -69,3 +77,26 @@ void DiagView::on_doubleSpinBox_valueChanged(double x)
ui->momentIn->setText(QString::fromStdString(std::to_string(lCtx.pointM(x)*(-1))));
}


void DiagView::on_saveH_clicked()
{
ui->diagHPlot->xAxis->setRange(-lCtx.beam.length*0.2, lCtx.beam.length*1.2);
ui->diagHPlot->yAxis->setRange(1.2 * yHmin, 1.2 * yHmax );
ui->diagHPlot->savePdf("axial.pdf", 600, 600, QCP::epNoCosmetic);
}

void DiagView::on_saveT_clicked()
{
ui->diagTPlot->xAxis->setRange(-lCtx.beam.length*0.2, lCtx.beam.length*1.2);
ui->diagTPlot->yAxis->setRange(1.2 * yTmin, 1.2 * yTmax );
ui->diagTPlot->savePdf("shear.pdf", 600, 600, QCP::epNoCosmetic);

}

void DiagView::on_saveM_clicked()
{
ui->diagMPlot->xAxis->setRange(-lCtx.beam.length*0.2, lCtx.beam.length*1.2);
ui->diagMPlot->yAxis->setRange(1.2 * yMmin, 1.2 * yMmax );
ui->diagMPlot->savePdf("moment.pdf", 600, 600, QCP::epNoCosmetic);
}

7 changes: 7 additions & 0 deletions diagview.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ class DiagView : public QDialog
private slots:
void on_doubleSpinBox_valueChanged(double arg1);

void on_saveH_clicked();

void on_saveT_clicked();

void on_saveM_clicked();

private:
Ui::DiagView *ui;
double yHmin, yHmax, yTmin, yTmax, yMmin, yMmax;
};

#endif // DIAGVIEW_H
31 changes: 28 additions & 3 deletions diagview.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<property name="windowTitle">
<string>Diagrams</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
Expand Down Expand Up @@ -51,7 +51,32 @@
</item>
</layout>
</item>
<item row="1" column="0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="saveH">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="saveT">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="saveM">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
Expand Down
2 changes: 1 addition & 1 deletion easydiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ double Context::pointH(double x) {
if (x == beam.length) {
hValue -= hl.value;
}
else if (hl.distance<x) {
else if (hl.distance<=x) {
hValue -= hl.value;
}
}
Expand Down
38 changes: 36 additions & 2 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ void MainWindow::on_diagBtn_clicked()
}


void MainWindow::on_beamSpinBox_valueChanged(double arg1)
void MainWindow::on_beamSpinBox_valueChanged(double bl)
{
if (ui->beamSpinBox->value() == 0) {
QMessageBox::warning(this, "Warning", "The length of the beam must be greater than 0.", QMessageBox::Ok);
} else {
b.length = ui->beamSpinBox->value();
b.length = bl;
ui->pointLoadBtn->setEnabled(true);
ui->distributedLoadBtn->setEnabled(true);
ui->pointMomentBtn->setEnabled(true);
Expand Down Expand Up @@ -163,3 +163,37 @@ void MainWindow::on_clrPm_clicked()
ui->pointMomentsTbl->setRowCount(0);
}

void MainWindow::on_clrPlSel_clicked()
{
if (ui->pointLoadsTbl->selectedItems().empty()) {return;}

int selectedPl = ui->pointLoadsTbl->selectedItems()[0]->row();

if (ui->pointLoadsTbl->item(selectedPl, 2)->text() == "Horizontal") {
horizontalForces.erase(horizontalForces.begin() + selectedPl);
} else {
verticalForces.erase(verticalForces.begin() + selectedPl);
}

ui->pointLoadsTbl->removeRow(selectedPl);
}

void MainWindow::on_clrDlSel_clicked()
{
if (ui->distributedLoadsTbl->selectedItems().empty()) {return;}
int selectedPl = ui->distributedLoadsTbl->selectedItems()[0]->row();
distributedLoads.erase(distributedLoads.begin() + selectedPl);
ui->distributedLoadsTbl->removeRow(selectedPl);
}




void MainWindow::on_clrPmSel_clicked()
{
if (ui->pointMomentsTbl->selectedItems().empty()) {return;}
int selectedPl = ui->pointMomentsTbl->selectedItems()[0]->row();
pointMoments.erase(pointMoments.begin() + selectedPl);
ui->pointMomentsTbl->removeRow(selectedPl);
}

6 changes: 6 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ private slots:

void on_clrPm_clicked();

void on_clrPlSel_clicked();

void on_clrDlSel_clicked();

void on_clrPmSel_clicked();

private:
Ui::MainWindow *ui;
PointLoadDialog *pldialog;
Expand Down
Loading

0 comments on commit 8303c75

Please sign in to comment.