192 lines
5.5 KiB
C++
192 lines
5.5 KiB
C++
#include "DistributedLoadSettingWidget.h"
|
|
#include "ui_DistributedLoadSettingWidget.h"
|
|
#include "PhysicalField.h"
|
|
|
|
#include <QMessageBox>
|
|
|
|
DistributedLoadSettingWidget::DistributedLoadSettingWidget(PhysicalField *physicalField, QWidget *parent) :
|
|
QWidget(parent),
|
|
m_physicalField(physicalField),
|
|
ui(new Ui::DistributedLoadSettingWidget)
|
|
{
|
|
ui->setupUi(this);
|
|
m_boundarySetting = m_physicalField->getBoundarySetting();
|
|
m_preProcessingService = ServiceRegistry<PreProcessingService>::instance().getService();
|
|
|
|
//显示模式
|
|
connect(ui->allShowRadio, &QRadioButton::toggled, this, &DistributedLoadSettingWidget::onShowModelRadioButtonToggled);
|
|
connect(ui->oneShowRadio, &QRadioButton::toggled, this, &DistributedLoadSettingWidget::onShowModelRadioButtonToggled);
|
|
connect(ui->twoShowRadio, &QRadioButton::toggled, this, &DistributedLoadSettingWidget::onShowModelRadioButtonToggled);
|
|
connect(ui->threeShowRadio, &QRadioButton::toggled, this, &DistributedLoadSettingWidget::onShowModelRadioButtonToggled);
|
|
|
|
// 点选开关
|
|
connect(ui->clickSelectionCheckBox, &QCheckBox::toggled, this, &DistributedLoadSettingWidget::onSelectModelToggled);
|
|
}
|
|
|
|
void DistributedLoadSettingWidget::showData(int id,bool enable[3],double value[3])
|
|
{
|
|
ui->IdLabel->setText(QString::number(id+1));
|
|
if(enable[0])
|
|
{
|
|
ui->oneLabel->setText(QStringLiteral("已设置"));
|
|
}
|
|
else
|
|
{
|
|
ui->oneLabel->setText(QStringLiteral("未设置"));
|
|
}
|
|
if(enable[1])
|
|
{
|
|
ui->twoLabel->setText(QStringLiteral("已设置"));
|
|
}
|
|
else
|
|
{
|
|
ui->twoLabel->setText(QStringLiteral("未设置"));
|
|
}
|
|
if(enable[2])
|
|
{
|
|
ui->threeLabel->setText(QStringLiteral("已设置"));
|
|
}
|
|
else
|
|
{
|
|
ui->threeLabel->setText(QStringLiteral("未设置"));
|
|
}
|
|
}
|
|
|
|
void DistributedLoadSettingWidget::onSelectModelToggled(bool checked)
|
|
{
|
|
if(checked)
|
|
{
|
|
m_boundarySetting->setBoundarySettingStatus(2);
|
|
}
|
|
else
|
|
{
|
|
m_boundarySetting->setBoundarySettingStatus(0);
|
|
}
|
|
}
|
|
|
|
//设置显示方式
|
|
void DistributedLoadSettingWidget::onShowModelRadioButtonToggled(bool checked)
|
|
{
|
|
if(!checked) return;
|
|
// Sender() 获取触发信号的对象
|
|
QRadioButton *button = qobject_cast<QRadioButton*>(sender());
|
|
|
|
if (button) {
|
|
if(button->text() == QStringLiteral("全部"))
|
|
{
|
|
m_boundarySetting->setFaceShowModel(0);
|
|
}
|
|
else if(button->text() == QStringLiteral("111"))
|
|
{
|
|
m_boundarySetting->setFaceShowModel(1);
|
|
}
|
|
else if(button->text() == QStringLiteral("222"))
|
|
{
|
|
m_boundarySetting->setFaceShowModel(2);
|
|
}
|
|
else if(button->text() == QStringLiteral("333"))
|
|
{
|
|
m_boundarySetting->setFaceShowModel(3);
|
|
}
|
|
}
|
|
}
|
|
|
|
DistributedLoadSettingWidget::~DistributedLoadSettingWidget()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void DistributedLoadSettingWidget::showEvent(QShowEvent *event)
|
|
{
|
|
if(m_preProcessingService->isHaveStructured() == false)
|
|
{
|
|
return;
|
|
}
|
|
|
|
qDebug()<<QStringLiteral("开始设置均布载荷");
|
|
|
|
|
|
//----------------------更新颜色
|
|
|
|
m_boundarySetting->setStructure(m_preProcessingService->getGridStructure(),m_preProcessingService->getPointStructure());
|
|
m_boundarySetting->setFaceToCell(m_preProcessingService->getFaceToCell());
|
|
m_boundarySetting->setCellToGridMap(m_preProcessingService->getCellIdToGridIdMap());
|
|
|
|
m_boundarySetting->setBoundarySettingStatus(2);
|
|
|
|
//3D 1 2D 2
|
|
m_boundarySetting->set3DType(m_preProcessingService->is3DType());
|
|
|
|
ui->comboBox->clear();
|
|
for(int i=1;i<m_preProcessingService->getFaceToCell().size();i++)
|
|
{
|
|
ui->comboBox->addItem(QString::number(i));
|
|
}
|
|
// connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onBoxIndexChanged(int)));
|
|
ui->allShowRadio->setChecked(true); // 再次选中
|
|
ui->allShowRadio->toggled(true);
|
|
|
|
ui->clickSelectionCheckBox->setChecked(true);
|
|
}
|
|
|
|
void DistributedLoadSettingWidget::hideEvent(QHideEvent *event)
|
|
{
|
|
if(m_preProcessingService->isHaveStructured() == false)
|
|
{
|
|
return;
|
|
}
|
|
|
|
qDebug()<<QStringLiteral("结束设置均布载荷");
|
|
|
|
//清除选中
|
|
m_boundarySetting->clearSelectedFace();
|
|
m_boundarySetting->setFaceShowModel(4);
|
|
m_boundarySetting->setBoundarySettingStatus(0);
|
|
}
|
|
|
|
void DistributedLoadSettingWidget::on_clearSelectedButton_clicked()
|
|
{
|
|
m_boundarySetting->clearSelectedFace();
|
|
}
|
|
|
|
|
|
void DistributedLoadSettingWidget::on_batchSelectButton_clicked()
|
|
{
|
|
m_boundarySetting->batchSelectFace(ui->comboBox->currentIndex()+1);
|
|
}
|
|
|
|
void DistributedLoadSettingWidget::on_setFaceData_clicked()
|
|
{
|
|
qDebug()<<"sss";
|
|
bool enable[3]={false};
|
|
double value[3];
|
|
if(ui->oneCheckBox->isChecked())
|
|
{
|
|
enable[0] = true;
|
|
value[0] = 0;
|
|
}
|
|
if(ui->twoCheckBox->isChecked())
|
|
{
|
|
enable[1] = true;
|
|
value[1] = 0;
|
|
}
|
|
if(ui->threeCheckBox->isChecked())
|
|
{
|
|
enable[2] = true;
|
|
value[2] = 0;
|
|
}
|
|
if(!enable[0]&&!enable[1]&&!enable[2])
|
|
{
|
|
QMessageBox::warning(nullptr, QStringLiteral("输入错误"), QStringLiteral("请选择有效的参数。"));
|
|
return;
|
|
}
|
|
m_boundarySetting->setFaceData(enable,value);
|
|
}
|
|
|
|
|
|
void DistributedLoadSettingWidget::on_deleteFaceData_clicked()
|
|
{
|
|
m_boundarySetting->deleteFaceData();
|
|
}
|
|
|