解释结论道,油气结论,分段点深度、备注等属性功能实现。
This commit is contained in:
parent
ea34409a5f
commit
69ee917963
|
|
@ -1205,3 +1205,14 @@ QByteArray UTF8ToGBK(const QString& utf8Str) {
|
|||
return gbkCodec->fromUnicode(utf8Str);
|
||||
}
|
||||
|
||||
int extractNumbers(QString strExp, const QString& input) {
|
||||
QRegularExpression re(strExp);
|
||||
QRegularExpressionMatch match = re.match(input);
|
||||
|
||||
int number = -1;
|
||||
if (match.hasMatch()) {
|
||||
QString numberStr = match.captured(1); // 获取括号内匹配的内容
|
||||
number = numberStr.toInt();
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,6 +239,7 @@ int GetLineWidth(QPainter * painter,int flWidth);
|
|||
|
||||
QString GBKToUTF8(const QByteArray& gbkData);
|
||||
QByteArray UTF8ToGBK(const QString& utf8Str);
|
||||
int extractNumbers(QString strExp, const QString& input);
|
||||
|
||||
struct WellHead
|
||||
{
|
||||
|
|
|
|||
|
|
@ -499,8 +499,31 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
|
|||
double lower = variant.value<double>();
|
||||
m_tdJieshi->setDragRect(1, -lower);
|
||||
}
|
||||
else if ("油气结论" == m_propertyData[pProperty])
|
||||
else
|
||||
{
|
||||
QString strProperty = m_propertyData[pProperty];
|
||||
if (strProperty == "油气结论")
|
||||
{
|
||||
m_tdJieshi->setDragResult(0, variant.toString());
|
||||
return;
|
||||
}
|
||||
int nidx = strProperty.indexOf("油气结论");
|
||||
if (nidx >= 0)
|
||||
{
|
||||
int nret = extractNumbers("油气结论(\\d+)", strProperty);
|
||||
m_tdJieshi->setDragResult(nret, variant.toString());
|
||||
return;
|
||||
}
|
||||
nidx = strProperty.indexOf("分段点");
|
||||
if (nidx >= 0)
|
||||
{
|
||||
int nret = extractNumbers("分段点(\\d+)深度", strProperty);
|
||||
m_tdJieshi->setDragDepth(nret, variant.toDouble());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1488,7 +1511,7 @@ void PropertyWidget::ChangFillProperty()
|
|||
|
||||
}
|
||||
|
||||
void PropertyWidget::_CreateVariantPropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue, int propertyType)
|
||||
QtVariantProperty* PropertyWidget::_CreateVariantPropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue, int propertyType)
|
||||
{
|
||||
QtProperty *pGroupItem =NULL;
|
||||
{
|
||||
|
|
@ -1508,6 +1531,7 @@ void PropertyWidget::_CreateVariantPropertyItem(QString strGroup, QString strPro
|
|||
item->setValue(vtPropertyValue);
|
||||
m_propertyData[item] = strPropertyCaption;
|
||||
pGroupItem->addSubProperty(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
void PropertyWidget::_CreateVariantPropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue, int propertyType, double dMin, double dMax)
|
||||
|
|
@ -2059,15 +2083,23 @@ void PropertyWidget::initJieshiItemProperty(TransparentGroupResult* tdJieshi, do
|
|||
_CreateVariantPropertyItem("当前项", "顶深(m)", -upper, QVariant::Double);
|
||||
_CreateVariantPropertyItem("当前项", "底深(m)", -lower, QVariant::Double);
|
||||
_CreateVariantPropertyItem("当前项", "解释层号", tdJieshi->getTitle(), QVariant::String);
|
||||
_CreateVariantPropertyItem("当前项", "油气结论", strResult, VariantManager::filePathTypeId());
|
||||
_CreateVariantPropertyItem("当前项", "备注", "", QVariant::String);
|
||||
QtVariantProperty* pItem = _CreateVariantPropertyItem("当前项", "油气结论", tdJieshi->getOilGasConclusion(0), VariantManager::filePathTypeId());
|
||||
m_pVariantManager->setAttribute(pItem, "filepath", GetOilSymbolDir());
|
||||
m_pVariantManager->setAttribute(pItem, "filter", "图片(*.png *.svg)");
|
||||
|
||||
_CreateVariantPropertyItem("当前项", "备注", tdJieshi->getRemark(), QVariant::String);
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
_CreateVariantPropertyItem("当前项", QString("油气结论%1").arg(i), strResult, VariantManager::filePathTypeId());
|
||||
QString s = tdJieshi->getOilGasConclusion(i);
|
||||
QtVariantProperty* pItem = _CreateVariantPropertyItem("当前项", QString("油气结论%1").arg(i), s, VariantManager::filePathTypeId());
|
||||
//pItem->setAttribute("FilePath", "123542");
|
||||
m_pVariantManager->setAttribute(pItem, "filepath", GetOilSymbolDir());
|
||||
m_pVariantManager->setAttribute(pItem, "filter", "图片(*.png *.svg)");
|
||||
}
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
_CreateVariantPropertyItem("当前项", QString("分段点%1深度").arg(i), strResult, VariantManager::filePathTypeId());
|
||||
QString s = tdJieshi->getOilGasDepth(i);
|
||||
_CreateVariantPropertyItem("当前项", QString("分段点%1深度").arg(i), s, QVariant::Double);
|
||||
}
|
||||
//当前属性类型
|
||||
m_strCurrentProperty = JieshiItem_Property;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ public:
|
|||
public:
|
||||
QWidget* GetPropertyWidget();
|
||||
|
||||
void _CreateVariantPropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue, int propertyType);
|
||||
QtVariantProperty* _CreateVariantPropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue, int propertyType);
|
||||
void _CreateVariantPropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue, int propertyType, double dMin, double dMax);
|
||||
void _CreateEnumPropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue, QStringList listValue);
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ void TransparentDraggableResult::drawResult(double left_Low, double right_Hight,
|
|||
}
|
||||
|
||||
// 设置矩形范围
|
||||
void TransparentDraggableResult::setRange(double left_Low, double right_Hight)
|
||||
void TransparentDraggableResult::setRange(double left_Low, double right_Hight, bool bupdate)
|
||||
{
|
||||
if(left_Low >= right_Hight) return;
|
||||
|
||||
|
|
@ -202,7 +202,8 @@ void TransparentDraggableResult::setRange(double left_Low, double right_Hight)
|
|||
|
||||
updateHandles();
|
||||
//后面统一刷新上方和下方rect
|
||||
//mPlot->replot();
|
||||
if(bupdate)
|
||||
mPlot->replot();
|
||||
}
|
||||
|
||||
void TransparentDraggableResult::setShowProperty(int nCopr, int nSPos, bool bupdate)
|
||||
|
|
@ -212,7 +213,7 @@ void TransparentDraggableResult::setShowProperty(int nCopr, int nSPos, bool bupd
|
|||
|
||||
if (bupdate)
|
||||
{
|
||||
setRange(mRect->topLeft->key(), mRect->bottomRight->key());
|
||||
setRange(mRect->topLeft->key(), mRect->bottomRight->key(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -239,6 +240,11 @@ void TransparentDraggableResult::setColor(const QColor &color) {
|
|||
//mPlot->replot();
|
||||
}
|
||||
|
||||
QString TransparentDraggableResult::getResult()
|
||||
{
|
||||
return m_Result;
|
||||
}
|
||||
|
||||
// 删除框图
|
||||
void TransparentDraggableResult::deleteRect()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public:
|
|||
|
||||
void drawResult(double left_Low, double right_Hight, double lY1, double lY2);
|
||||
// 设置矩形范围
|
||||
void setRange(double left_Low, double right_Hight);
|
||||
void setRange(double left_Low, double right_Hight, bool bupdate = false);
|
||||
// 设置结论占比%
|
||||
void setShowProperty(int nCopr, int nSPos, bool bupdate = false);
|
||||
void setDragRange(double left_Low, double right_Hight);
|
||||
|
|
@ -43,6 +43,8 @@ public:
|
|||
|
||||
// 设置矩形颜色
|
||||
void setColor(const QColor &color);
|
||||
|
||||
QString getResult();
|
||||
|
||||
// 删除框图
|
||||
void deleteRect();
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ void TransparentGroupResult::addAllResultToPlot(LAYER_DATA* pResult)
|
|||
{
|
||||
QMap<QString, QString> zoneOrder = GetZoneOrder();//初始化ZoneOrder 层序号根据层位名来,配置文件在conf\\RESULT.txt
|
||||
|
||||
m_Remark = GBKToUTF8(pResult->Description10);
|
||||
//
|
||||
QDir fexit;
|
||||
QString result_str = QString::number(pResult->Result);
|
||||
|
|
@ -142,6 +143,16 @@ QString TransparentGroupResult::getTitle()
|
|||
return mstrTitle;
|
||||
}
|
||||
|
||||
void TransparentGroupResult::setRemark(QString remark)
|
||||
{
|
||||
m_Remark = remark;
|
||||
}
|
||||
|
||||
QString TransparentGroupResult::getRemark()
|
||||
{
|
||||
return m_Remark;
|
||||
}
|
||||
|
||||
//设置解释结论
|
||||
void TransparentGroupResult::setResult(QString filePath)
|
||||
{
|
||||
|
|
@ -345,6 +356,40 @@ void TransparentGroupResult::setDragRect(int dMode, double dragVal)
|
|||
mPlot->replot();
|
||||
}
|
||||
|
||||
void TransparentGroupResult::setDragResult(int nidx, QString strResult)
|
||||
{
|
||||
if (nidx < 0 || nidx >= m_vecResult.size())
|
||||
return;
|
||||
|
||||
const QString& uid = m_vecResult.at(nidx);
|
||||
TransparentDraggableResult* pDrag = qobject_cast<TransparentDraggableResult*>(m_mapDraggable_Result.value(uid));
|
||||
if (pDrag == NULL)
|
||||
return;
|
||||
pDrag->setResult(strResult);
|
||||
pDrag->setShowProperty(m_nConclusionProportion, m_nShowPos, true);
|
||||
}
|
||||
|
||||
void TransparentGroupResult::setDragDepth(int nidx, double dDepth)
|
||||
{
|
||||
if (nidx < 0 || nidx >= m_vecResult.size())
|
||||
return;
|
||||
|
||||
const QString& uid = m_vecResult.at(nidx);
|
||||
TransparentDraggableResult* pDrag = qobject_cast<TransparentDraggableResult*>(m_mapDraggable_Result.value(uid));
|
||||
if (pDrag == NULL)
|
||||
return;
|
||||
QCPRange rg = pDrag->getRange();
|
||||
pDrag->setRange(rg.lower, -dDepth, true);
|
||||
|
||||
// 上方TransparentDraggableResult,Rect更新
|
||||
TransparentDraggableResult* upDrag = pDrag->getUpResult();
|
||||
if (upDrag)
|
||||
{
|
||||
QCPRange rg = upDrag->getRange();
|
||||
upDrag->setRange(-dDepth, rg.upper, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 删除框图
|
||||
void TransparentGroupResult::deleteRect()
|
||||
{
|
||||
|
|
@ -392,6 +437,37 @@ int TransparentGroupResult::getCursor()
|
|||
return 0;
|
||||
}
|
||||
|
||||
QString TransparentGroupResult::getOilGasConclusion(int nidx)
|
||||
{
|
||||
QString ret = "";
|
||||
if (nidx >= m_vecResult.size())
|
||||
return ret;
|
||||
|
||||
const QString& uid = m_vecResult.at(nidx);
|
||||
|
||||
TransparentDraggableResult* pDrag = qobject_cast<TransparentDraggableResult*>(m_mapDraggable_Result.value(uid));
|
||||
if (pDrag == NULL)
|
||||
return ret;
|
||||
|
||||
QFileInfo fileInfo(pDrag->getResult());
|
||||
return fileInfo.baseName();
|
||||
}
|
||||
|
||||
QString TransparentGroupResult::getOilGasDepth(int nidx)
|
||||
{
|
||||
QString ret = "";
|
||||
if (nidx >= m_vecResult.size())
|
||||
return ret;
|
||||
|
||||
const QString& uid = m_vecResult.at(nidx);
|
||||
|
||||
TransparentDraggableResult* pDrag = qobject_cast<TransparentDraggableResult*>(m_mapDraggable_Result.value(uid));
|
||||
if (pDrag == NULL)
|
||||
return ret;
|
||||
|
||||
return QString("%1").arg(-pDrag->getRange().upper);
|
||||
}
|
||||
|
||||
void TransparentGroupResult::initRect()
|
||||
{
|
||||
// 创建透明矩形
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ public:
|
|||
//设置标题
|
||||
void setTitle(QString strTitle);
|
||||
QString getTitle();
|
||||
|
||||
void setRemark(QString remark);
|
||||
QString getRemark();
|
||||
|
||||
//设置解释结论
|
||||
void setResult(QString filePath);
|
||||
|
|
@ -56,6 +59,10 @@ public:
|
|||
|
||||
//设置顶深, 底深
|
||||
void setDragRect(int dMode, double dragVal);
|
||||
//设置解释结论
|
||||
void setDragResult(int nidx, QString strResult);
|
||||
//设置分段深度
|
||||
void setDragDepth(int nidx, double dDepth);
|
||||
|
||||
// 删除框图
|
||||
void deleteRect();
|
||||
|
|
@ -63,6 +70,12 @@ public:
|
|||
void setSelectRect(bool bselect);
|
||||
|
||||
int getCursor();
|
||||
|
||||
// 获取油气结论
|
||||
QString getOilGasConclusion(int nidx);
|
||||
// 获取分段点深度
|
||||
QString getOilGasDepth(int nidx);
|
||||
|
||||
signals:
|
||||
void rangeChanged(QCPRange newRange);
|
||||
|
||||
|
|
@ -99,6 +112,7 @@ private:
|
|||
QString m_strUuid = "";
|
||||
|
||||
QString m_Result;
|
||||
QString m_Remark="";
|
||||
|
||||
DragMode mDragMode = DragNone;
|
||||
//double mDragStartX = 0;
|
||||
|
|
|
|||
|
|
@ -51,10 +51,12 @@ FileEdit::FileEdit(QWidget *parent)
|
|||
|
||||
void FileEdit::buttonClicked()
|
||||
{
|
||||
QString filePath = QFileDialog::getOpenFileName(this, tr("选择文件"), theLineEdit->text(), theFilter);
|
||||
QString filePath = QFileDialog::getOpenFileName(this, tr("选择文件"), strFilePath, theFilter);
|
||||
if (filePath.isNull())
|
||||
return;
|
||||
theLineEdit->setText(filePath);
|
||||
|
||||
QFileInfo finfo(filePath);
|
||||
theLineEdit->setText(finfo.baseName());
|
||||
emit filePathChanged(filePath);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,15 @@ class FileEdit : public QWidget
|
|||
Q_OBJECT
|
||||
public:
|
||||
FileEdit(QWidget *parent = 0);
|
||||
void setFilePath(const QString &filePath) { if (theLineEdit->text() != filePath) theLineEdit->setText(filePath); }
|
||||
void setValue(const QString &value)
|
||||
{
|
||||
if (theLineEdit->text() != value)
|
||||
theLineEdit->setText(value);
|
||||
}
|
||||
QString filePath() const { return theLineEdit->text(); }
|
||||
|
||||
void setFilePath(const QString &fpath) { strFilePath = fpath; }
|
||||
|
||||
void setFilter(const QString &filter) { theFilter = filter; }
|
||||
QString filter() const { return theFilter; }
|
||||
signals:
|
||||
|
|
@ -47,6 +54,7 @@ private slots:
|
|||
void buttonClicked();
|
||||
private:
|
||||
QLineEdit *theLineEdit;
|
||||
QString strFilePath = "";
|
||||
QString theFilter;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "variantfactory.h"
|
||||
#include "variantmanager.h"
|
||||
#include "fileedit.h"
|
||||
#include "qtvariantproperty.h"
|
||||
|
||||
VariantFactory::~VariantFactory()
|
||||
{
|
||||
|
|
@ -46,9 +47,23 @@ QWidget *VariantFactory::createEditor(QtVariantPropertyManager *manager,
|
|||
QtProperty *property, QWidget *parent)
|
||||
{
|
||||
if (manager->propertyType(property) == VariantManager::filePathTypeId()) {
|
||||
|
||||
FileEdit *editor = new FileEdit(parent);
|
||||
editor->setFilePath(manager->value(property).toString());
|
||||
editor->setFilter(manager->attributeValue(property, QLatin1String("filter")).toString());
|
||||
|
||||
QString strPath = manager->value(property).toString();
|
||||
QString strValue = strPath;
|
||||
QString strFilter = manager->attributeValue(property, QLatin1String("filter")).toString();
|
||||
VariantManager* pMgr = qobject_cast<VariantManager*>(manager);
|
||||
if (pMgr)
|
||||
{
|
||||
strValue = pMgr->value(property).toString();
|
||||
strPath = pMgr->filepath(property).toString();
|
||||
strPath += strValue;
|
||||
strFilter = pMgr->filter(property).toString();
|
||||
}
|
||||
editor->setFilePath(strPath);
|
||||
editor->setValue(strValue);
|
||||
editor->setFilter(strFilter);
|
||||
theCreatedEditors[property].append(editor);
|
||||
theEditorToProperty[editor] = property;
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,20 @@ QVariant VariantManager::value(const QtProperty *property) const
|
|||
return QtVariantPropertyManager::value(property);
|
||||
}
|
||||
|
||||
QVariant VariantManager::filter(const QtProperty *property) const
|
||||
{
|
||||
if (theValues.contains(property))
|
||||
return theValues[property].filter;
|
||||
return QtVariantPropertyManager::value(property);
|
||||
}
|
||||
|
||||
QVariant VariantManager::filepath(const QtProperty *property) const
|
||||
{
|
||||
if (theValues.contains(property))
|
||||
return theValues[property].filepath;
|
||||
return QtVariantPropertyManager::value(property);
|
||||
}
|
||||
|
||||
QStringList VariantManager::attributes(int propertyType) const
|
||||
{
|
||||
if (propertyType == filePathTypeId()) {
|
||||
|
|
@ -113,20 +127,28 @@ void VariantManager::setValue(QtProperty *property, const QVariant &val)
|
|||
void VariantManager::setAttribute(QtProperty *property,
|
||||
const QString &attribute, const QVariant &val)
|
||||
{
|
||||
if (theValues.contains(property)) {
|
||||
if (attribute == QLatin1String("filter")) {
|
||||
if (val.type() != QVariant::String && !val.canConvert(QVariant::String))
|
||||
return;
|
||||
QString str = val.value<QString>();
|
||||
Data d = theValues[property];
|
||||
if (d.filter == str)
|
||||
return;
|
||||
d.filter = str;
|
||||
theValues[property] = d;
|
||||
emit attributeChanged(property, attribute, str);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (theValues.contains(property)) {
|
||||
|
||||
if (val.type() != QVariant::String && !val.canConvert(QVariant::String))
|
||||
return;
|
||||
QString str = val.value<QString>();
|
||||
Data d = theValues[property];
|
||||
if (attribute == QLatin1String("filter")) {
|
||||
if (d.filter == str)
|
||||
return;
|
||||
d.filter = str;
|
||||
}
|
||||
else if (attribute == QLatin1String("filepath"))
|
||||
{
|
||||
if (d.filepath == str)
|
||||
return;
|
||||
d.filepath = str;
|
||||
}
|
||||
theValues[property] = d;
|
||||
emit attributeChanged(property, attribute, str);
|
||||
|
||||
return;
|
||||
}
|
||||
QtVariantPropertyManager::setAttribute(property, attribute, val);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,9 +34,11 @@ class VariantManager : public QtVariantPropertyManager
|
|||
public:
|
||||
VariantManager(QObject *parent = 0)
|
||||
: QtVariantPropertyManager(parent)
|
||||
{ }
|
||||
{ }
|
||||
|
||||
virtual QVariant value(const QtProperty *property) const;
|
||||
virtual QVariant filter(const QtProperty *property) const;
|
||||
virtual QVariant filepath(const QtProperty *property) const;
|
||||
virtual int valueType(int propertyType) const;
|
||||
virtual bool isPropertyTypeSupported(int propertyType) const;
|
||||
|
||||
|
|
@ -58,6 +60,7 @@ private:
|
|||
struct Data {
|
||||
QString value;
|
||||
QString filter;
|
||||
QString filepath;
|
||||
};
|
||||
QMap<const QtProperty *, Data> theValues;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user