Merge branch 'feature/struct-menu-20241023' of http://1.92.128.200:3000/YXS/AppFlow into feature/struct-menu-20241023

feature/struct-menu-20241023
mzh 3 days ago
commit 0ccbc96825

@ -11,17 +11,17 @@ class CUIConfig;
class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataSolverComputingControlManager : public CFDStructDataManagerBase {
Q_OBJECT
public:
explicit CFDStructDataSolverComputingControlManager(QObject *parent = nullptr);
explicit CFDStructDataSolverComputingControlManager(QObject* parent = nullptr);
~CFDStructDataSolverComputingControlManager();
CUIConfig *getParamUIConfig();
void saveDataToDom(rapidjson::Document &dom);
CUIConfig* getParamUIConfig();
void saveDataToDom(rapidjson::Document& dom);
void readDataFromDom(rapidjson::Document &dom);
void readDataFromDom(rapidjson::Document& dom);
private:
// 生成界面配置
CUIConfig *genUIConfig();
CUIConfig* genUIConfig();
signals:
private:

@ -8,26 +8,25 @@
#include "CFDStructDataManager_global.h"
class CUIConfig;
class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataSolverInitializationManager : public CFDStructDataManagerBase
{
class CFDSTRUCTDATAMANAGER_EXPORT CFDStructDataSolverInitializationManager : public CFDStructDataManagerBase {
Q_OBJECT
public:
explicit CFDStructDataSolverInitializationManager(QObject *parent = nullptr);
public:
explicit CFDStructDataSolverInitializationManager(QObject* parent = nullptr);
~CFDStructDataSolverInitializationManager();
CUIConfig *getParamUIConfig();
void saveDataToDom(rapidjson::Document &dom);
void readDataFromDom(rapidjson::Document &dom);
CUIConfig* getParamUIConfig();
void saveDataToDom(rapidjson::Document& dom);
void readDataFromDom(rapidjson::Document& dom);
private:
private:
// 生成界面配置 柱坐标系
CUIConfig *genCylindricalUIConfig();
CUIConfig* genCylindricalUIConfig();
// 生成界面配置 笛卡尔坐标系
CUIConfig *genCartesianUIConfig();
signals:
CUIConfig* genCartesianUIConfig();
signals:
private:
private:
// 参考值取自
int m_ReferenceValuesFrom = 0; // Reference Values From

@ -54,6 +54,8 @@ void CUIComponentLineEdit::initUI(QVector<CUIPropertyWidget *> &subCUI) {
// 设置格式校验
this->setValidator();
this->setInputTips();
// 显示值
m_lineEdit->setText(m_conf->getOriginValueString());
connect(m_lineEdit, &QLineEdit::textEdited, this,
&CUIComponentLineEdit::onTextChanged);
}
@ -64,9 +66,10 @@ void CUIComponentLineEdit::setValidator() {
case CUI_DATA_TYPE_DOUBLE: {
qDebug() << m_rangeMin.toInt() << ' ' << m_rangeMax.toInt();
m_lineEdit->setValidator(new QDoubleValidator(m_rangeMin.toDouble(),
m_rangeMax.toDouble(), 10));
m_rangeMax.toDouble(), 10));
break;
}
case CUI_DATA_TYPE_INT: {
qDebug() << m_rangeMin.toInt() << ' ' << m_rangeMax.toInt();
m_lineEdit->setValidator(
@ -81,14 +84,17 @@ void CUIComponentLineEdit::setValidator() {
*/
void CUIComponentLineEdit::setInputTips() {
QString msg = "";
if (m_checkRange) {
msg += m_inclusiveMin ? "[" : "(";
msg += this->getRangeMinString() + "," + this->getRangeMaxString();
msg += m_inclusiveMax ? "]" : ")";
}
if (m_required) {
msg += "\t" + tr("(required)");
}
m_lineEdit->setPlaceholderText(msg);
}
@ -98,11 +104,14 @@ void CUIComponentLineEdit::setInputTips() {
void CUIComponentLineEdit::showRangeError() {
if (m_checkRange) {
QPalette palette = m_lineEdit->palette();
if (this->inRange(this->getQVFrom(m_lineEdit->text()))) {
palette.setColor(QPalette::Text, Qt::black);
} else {
palette.setColor(QPalette::Text, Qt::red);
}
m_lineEdit->setPalette(palette);
}
}
@ -115,10 +124,9 @@ void CUIComponentLineEdit::showRangeError() {
*
* @param text
*/
void CUIComponentLineEdit::onTextChanged(const QString &text) {
void CUIComponentLineEdit::onTextChanged(const QString& text) {
this->showRangeError();
// 如果在范围内,
if (this->inRange(m_lineEdit->text())) {
// switch (m_dataType) {
// case CUI_DATA_TYPE_DOUBLE: {

@ -73,7 +73,7 @@ CUIConfig::CUIConfig(QMap<QString, QVariant> property) {
* @param property
* @param sub
*/
CUIConfig::CUIConfig(QMap<QString, QVariant> property, QVector<CUIConfig *> sub) {
CUIConfig::CUIConfig(QMap<QString, QVariant> property, QVector<CUIConfig*> sub) {
setDefault();
this->property = property;
this->sub = sub;
@ -84,38 +84,69 @@ CUIConfig::CUIConfig(QMap<QString, QVariant> property, QVector<CUIConfig *> sub)
* @brief CUIConfig::printConfig
*/
void CUIConfig::printConfig() {
// qDebug() << "{";
// for(auto it = property.begin(); it != property.end(); it++) {
// qDebug() << it.key() << ' ' << it.value();
// }
// for(auto it : sub) {
// it->printConfig();
// }
// qDebug() << "}";
// qDebug() << "{";
// for(auto it = property.begin(); it != property.end(); it++) {
// qDebug() << it.key() << ' ' << it.value();
// }
// for(auto it : sub) {
// it->printConfig();
// }
// qDebug() << "}";
}
QString CUIConfig::getOriginValueString() {
QVariant pValue = property["value_origin"];
// 如果没有设置原始值
if (pValue == QVariant::Invalid) {
return QString("");
}
if (property["value_type"] == CUI_DATA_TYPE_INT) {
int* ptr = qvariant_cast<int*>(pValue);
return QString::number(*ptr);
} else if (property["value_type"] == CUI_DATA_TYPE_DOUBLE) {
double* ptr = qvariant_cast<double*>(pValue);
return QString::number(*ptr);
} else if (property["value_type"] == CUI_DATA_TYPE_STRING) {
QString* ptr = qvariant_cast<QString*>(pValue);
return *ptr;
}
return QString("");
}
void CUIConfig::setValue(QVariant value) {
bool changed = false;
QVariant pValue = property["value_origin"];
if (property["value_type"] == CUI_DATA_TYPE_INT) {
int *ptr = qvariant_cast<int *>(pValue);
int* ptr = qvariant_cast<int*>(pValue);
if (*ptr != value.toInt()) {
*ptr = value.toInt();
changed = true;
}
} else if (property["value_type"] == CUI_DATA_TYPE_DOUBLE) {
double *ptr = qvariant_cast<double *>(pValue);
double* ptr = qvariant_cast<double*>(pValue);
if (*ptr != value.toDouble()) {
*ptr = value.toDouble();
changed = true;
}
} else if (property["value_type"] == CUI_DATA_TYPE_STRING) {
double *ptr = qvariant_cast<double *>(pValue);
if (*ptr != value.toDouble()) {
*ptr = value.toDouble();
QString* ptr = qvariant_cast<QString*>(pValue);
if (*ptr != value.toString()) {
*ptr = value.toString();
changed = true;
}
}
// 如果需要通知,则通知参数值发生修改
if (changed && this->getPropertyOriginValue("semaphore") != QVariant::Invalid) {
QTimer::singleShot(50, m_sigsCenter, [=]() {
@ -134,6 +165,7 @@ QString CUIConfig::getPropertyValue(QString key) {
if (property.contains(key)) {
return qvariant_cast<QString>(property[key]);
}
return QString();
}
@ -146,10 +178,11 @@ QVariant CUIConfig::getPropertyOriginValue(QString key) {
if (property.contains(key)) {
return property[key];
}
return QVariant::Invalid;
}
QVector<CUIConfig *> CUIConfig::getSub() {
QVector<CUIConfig*> CUIConfig::getSub() {
return this->sub;
}
@ -158,25 +191,30 @@ QVector<CUIConfig *> CUIConfig::getSub() {
*/
void CUIConfig::setDefault() {
QString type = qvariant_cast<QString>(property["type"]);
if (type == "LineEdit") {
setDefault("name", "");
setDefault("data_type", "string"); // 数据类型
setDefault("initial_value_", ""); // 初始值
setDefault("check_range_", false); // 是否检查范围
setDefault("range_min_", ""); // 最小值
setDefault("range_max_", ""); // 最大值
setDefault("inclusive_min", true); // 左范围是否包括
setDefault("inclusive_max", true); // 右范围是否包括
setDefault("required_", true); // 是否为必选
setDefault("data_type", "string"); // 数据类型
setDefault("initial_value_", ""); // 初始值
setDefault("check_range_", false); // 是否检查范围
setDefault("range_min_", ""); // 最小值
setDefault("range_max_", ""); // 最大值
setDefault("inclusive_min", true); // 左范围是否包括
setDefault("inclusive_max", true); // 右范围是否包括
setDefault("required_", true); // 是否为必选
} else if (type == "Widget") {
setDefault("layout", "QVBoxLayout");
setDefault("name", "");
} else if (type == "GroupBox") {
setDefault("name", "");
setDefault("layout", "QVBoxLayout");
} else if (type == "TabWidget") {
} else if (type == "ComboBox") {
setDefault("name", "");
} else if (type == "Item") {
setDefault("name", "");
setDefault("data_type", "string");

@ -17,8 +17,8 @@ class CUIPropertyAPI CUIConfig {
void setValue(QVariant);
QString getPropertyValue(QString);
QVariant getPropertyOriginValue(QString);
QVector<CUIConfig *> getSub();
QVector<CUIConfig*> getSub();
QString getOriginValueString();
private:
void setDefault();
void setDefault(QString key, QVariant val);

Loading…
Cancel
Save