Scatter plots, a duct can be placed in a system, which runs in mainwindow
This commit is contained in:
parent
ff398f4602
commit
e261b5c009
@ -23,7 +23,7 @@ DECLARE_ENUM(PreviewShow,CSArea,Porosity,HydraulicRadius,SolidTemperatureFunctio
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
AddDuctDialog::AddDuctDialog(const us id,const std::string& name,QWidget* parent):
|
AddDuctDialog::AddDuctDialog(const std::string& name,QWidget* parent):
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
_dialog(new Ui::add_duct_dialog),
|
_dialog(new Ui::add_duct_dialog),
|
||||||
_duct(pb::Duct::default_instance())
|
_duct(pb::Duct::default_instance())
|
||||||
@ -32,7 +32,6 @@ AddDuctDialog::AddDuctDialog(const us id,const std::string& name,QWidget* parent
|
|||||||
_blocked = true;
|
_blocked = true;
|
||||||
_dialog->setupUi(this);
|
_dialog->setupUi(this);
|
||||||
|
|
||||||
_duct.set_id(id);
|
|
||||||
_duct.set_name(name);
|
_duct.set_name(name);
|
||||||
|
|
||||||
QString title = "Add/edit duct segment '";
|
QString title = "Add/edit duct segment '";
|
||||||
@ -93,11 +92,13 @@ AddDuctDialog::AddDuctDialog(const us id,const std::string& name,QWidget* parent
|
|||||||
_dialog->gridtype->setCurrentIndex(0);
|
_dialog->gridtype->setCurrentIndex(0);
|
||||||
|
|
||||||
// create a single graph in the QCP
|
// create a single graph in the QCP
|
||||||
|
QCPScatterStyle scatter;
|
||||||
|
scatter.setShape(QCPScatterStyle::ssDiamond);
|
||||||
_plot->addGraph();
|
_plot->addGraph();
|
||||||
|
_plot->graph(0)->setLineStyle(QCPGraph::lsLine);
|
||||||
|
_plot->graph(0)->setScatterStyle(scatter);
|
||||||
|
|
||||||
_duct.set_length(constants::default_L);
|
_duct.set_length(constants::default_L);
|
||||||
_duct.set_name("Unnamed");
|
|
||||||
_duct.set_dxb(0.01);
|
_duct.set_dxb(0.01);
|
||||||
_duct.set_dxmid(0.1);
|
_duct.set_dxmid(0.1);
|
||||||
_duct.set_gridtype(pb::Linear);
|
_duct.set_gridtype(pb::Linear);
|
||||||
|
@ -27,8 +27,12 @@ class AddDuctDialog: public QDialog {
|
|||||||
pb::Duct _duct;
|
pb::Duct _duct;
|
||||||
bool _blocked = false;
|
bool _blocked = false;
|
||||||
public:
|
public:
|
||||||
AddDuctDialog(const us id,const std::string& name,QWidget* parent = nullptr);
|
AddDuctDialog(const std::string& name,QWidget* parent = nullptr);
|
||||||
~AddDuctDialog();
|
~AddDuctDialog();
|
||||||
|
|
||||||
|
void set(const pb::Duct&);
|
||||||
|
const pb::Duct& get() const {return _duct; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void accept();
|
void accept();
|
||||||
void reject();
|
void reject();
|
||||||
@ -50,11 +54,10 @@ private slots:
|
|||||||
void on_stempmodel_currentIndexChanged(int) {changed();}
|
void on_stempmodel_currentIndexChanged(int) {changed();}
|
||||||
|
|
||||||
void on_previewshow_currentIndexChanged(int) {changed();}
|
void on_previewshow_currentIndexChanged(int) {changed();}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Called whenever the user changes a field
|
// Called whenever the user changes a field
|
||||||
void changed();
|
void changed();
|
||||||
void set(const pb::Duct&);
|
|
||||||
const pb::Duct& get() const {return _duct; }
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#include "tasmet_tracer.h"
|
#include "tasmet_tracer.h"
|
||||||
#include "add_duct_dialog.h"
|
#include "add_duct_dialog.h"
|
||||||
|
|
||||||
|
const QString default_name = "Unnamed segment";
|
||||||
|
|
||||||
TaSMETMainWindow::TaSMETMainWindow():
|
TaSMETMainWindow::TaSMETMainWindow():
|
||||||
window(new Ui::MainWindow())
|
window(new Ui::MainWindow())
|
||||||
{
|
{
|
||||||
@ -48,8 +50,7 @@ TaSMETMainWindow::TaSMETMainWindow():
|
|||||||
window->p0->setValidator(new QDoubleValidator(constants::min_p0,
|
window->p0->setValidator(new QDoubleValidator(constants::min_p0,
|
||||||
constants::max_p0,
|
constants::max_p0,
|
||||||
constants::field_decimals));
|
constants::field_decimals));
|
||||||
|
window->name->setText(default_name);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
TaSMETMainWindow::~TaSMETMainWindow(){
|
TaSMETMainWindow::~TaSMETMainWindow(){
|
||||||
@ -68,9 +69,44 @@ void TaSMETMainWindow::closeEvent(QCloseEvent *event) {
|
|||||||
}
|
}
|
||||||
void TaSMETMainWindow::on_addsegment_clicked() {
|
void TaSMETMainWindow::on_addsegment_clicked() {
|
||||||
|
|
||||||
AddDuctDialog dialog(0,"hola",this);
|
us id = window->segmentid_add->value();
|
||||||
|
string name = window->name->text().toStdString();
|
||||||
|
VARTRACE(15,name);
|
||||||
|
bool edit = false;
|
||||||
|
|
||||||
int rv = dialog.exec();
|
AddDuctDialog dialog(name,this);
|
||||||
|
|
||||||
|
auto& ductmap = *_system.mutable_ducts();
|
||||||
|
if(ductmap.find(id) != ductmap.end()) {
|
||||||
|
dialog.set(ductmap[id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int code = dialog.exec();
|
||||||
|
if(code == QDialog::Accepted) {
|
||||||
|
|
||||||
|
VARTRACE(15,dialog.get().name());
|
||||||
|
ductmap[id] = dialog.get();
|
||||||
|
window->segmentid_add->setValue(id+1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
void TaSMETMainWindow::on_segmentid_add_valueChanged(int id) {
|
||||||
|
|
||||||
|
auto& ductmap = *_system.mutable_ducts();
|
||||||
|
if(ductmap.find(id) != ductmap.end()) {
|
||||||
|
window->name->setText(QString::fromStdString(ductmap[id].name()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void TaSMETMainWindow::on_name_textEdited() {
|
||||||
|
|
||||||
|
auto& ductmap = *_system.mutable_ducts();
|
||||||
|
int id = window->segmentid_add->value();
|
||||||
|
|
||||||
|
if(ductmap.find(id) != ductmap.end()) {
|
||||||
|
ductmap[id].set_name(window->name->text().toStdString());
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
#include "tasmet_config.h"
|
#include "tasmet_config.h"
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include "protobuf/system.pb.h"
|
||||||
|
|
||||||
namespace Ui{
|
namespace Ui{
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
@ -18,12 +19,15 @@ namespace Ui{
|
|||||||
class TaSMETMainWindow: public QMainWindow {
|
class TaSMETMainWindow: public QMainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Ui::MainWindow *window;
|
Ui::MainWindow *window;
|
||||||
|
pb::System _system;
|
||||||
public:
|
public:
|
||||||
TaSMETMainWindow();
|
TaSMETMainWindow();
|
||||||
~TaSMETMainWindow();
|
~TaSMETMainWindow();
|
||||||
private slots:
|
private slots:
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
void on_addsegment_clicked();
|
void on_addsegment_clicked();
|
||||||
|
void on_segmentid_add_valueChanged(int i);
|
||||||
|
void on_name_textEdited();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@
|
|||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="name">
|
<widget class="QLineEdit" name="name">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Unnamed segment</string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -30,7 +30,6 @@ enum SolidTemperatureModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message Duct {
|
message Duct {
|
||||||
required uint32 id = 1;
|
|
||||||
required string name = 2;
|
required string name = 2;
|
||||||
required double length = 3 [default = 1];
|
required double length = 3 [default = 1];
|
||||||
optional uint32 ngp = 4 [default = 100];
|
optional uint32 ngp = 4 [default = 100];
|
||||||
|
@ -19,6 +19,6 @@ message System {
|
|||||||
required double p0 = 5;
|
required double p0 = 5;
|
||||||
required double T0 = 6;
|
required double T0 = 6;
|
||||||
|
|
||||||
repeated Duct ducts = 7;
|
map<uint32,Duct> ducts = 7;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user