文字结论道,追加6个属性,1个右键菜单

This commit is contained in:
jiayulong 2026-03-09 09:48:28 +08:00
parent 3bb2c89646
commit c4da8b1de9
10 changed files with 517 additions and 105 deletions

View File

@ -289,6 +289,51 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
emit CallManage::getInstance()->sig_changeGeoLithLine(m_formInfo->m_strUuid, m_formInfo->m_strSlfName, m_formInfo->m_strWellName, m_formInfo->m_strTrackName, m_formInfo->m_strLineName, dOilZhan); emit CallManage::getInstance()->sig_changeGeoLithLine(m_formInfo->m_strUuid, m_formInfo->m_strSlfName, m_formInfo->m_strWellName, m_formInfo->m_strTrackName, m_formInfo->m_strLineName, dOilZhan);
} }
} }
else if (m_strCurrentProperty == Text_Property)//文字结论
{
//先处理通用属性
CommonPropertyChanged(pProperty, variant);
}
else if (m_strCurrentProperty == TextItem_Property)
{
//文字结论item
if("顶深(m)" == m_propertyData[pProperty])
{
//qDebug() << "顶深(m)->改变";
if(m_tdText)
{
double upper = variant.value<double>();
m_tdText->setUpper(-upper);
//保存
m_tdText->mPlot->SaveToSLF_Text();
}
}
else if("底深(m)" == m_propertyData[pProperty])
{
//qDebug() << "底深(m)->改变";
if(m_tdText)
{
double lower = variant.value<double>();
m_tdText->setLower(-lower);
//保存
m_tdText->mPlot->SaveToSLF_Text();
}
}
else if("文字结论" == m_propertyData[pProperty])
{
//qDebug() << "文字结论->改变";
if(m_tdText)
{
QString newResult = variant.value<QString>();
m_tdText->setTitle(newResult);
//
QCPRange currentRange = m_tdText->getRange();
m_tdText->setRange(currentRange.lower, currentRange.upper);
//保存
m_tdText->mPlot->SaveToSLF_Text();
}
}
}
else if (m_strCurrentProperty == GujingItem_Property) else if (m_strCurrentProperty == GujingItem_Property)
{ {
//固井结论item //固井结论item
@ -1632,6 +1677,11 @@ void PropertyWidget::initProperty(FormInfo *formInfo)
//录井剖面 //录井剖面
this->initGeoLithProperty(formInfo); this->initGeoLithProperty(formInfo);
} }
else if (m_strLineName == "WORDS_RELUST")
{
//文字结论
this->initTextProperty(formInfo);
}
else{ else{
this->initTableProperty(formInfo); this->initTableProperty(formInfo);
} }
@ -1796,6 +1846,32 @@ void PropertyWidget::initSwallCoreItemProperty(TransparentDraggableSwallCore* td
//_CreateVariantPropertyItem("当前项", "宽度", -Depth, QVariant::Double); //_CreateVariantPropertyItem("当前项", "宽度", -Depth, QVariant::Double);
} }
void PropertyWidget::initTextProperty(FormInfo *formInfo)
{
_CreateVariantPropertyItem("通常", "选择井曲线", m_strLineName + "@" + m_strSlfName, QVariant::String);
_CreateVariantPropertyItem("对象", "显示名称", formInfo->m_strAliasName, QVariant::String);
_CreateVariantPropertyItem("对象", "字体", formInfo->m_curveNameFont, QVariant::Font);
_CreateVariantPropertyItem("对象", "颜色", formInfo->m_lineColor, QVariant::Color);
m_strCurrentProperty = Text_Property;
}
void PropertyWidget::initTextItemProperty(TransparentDraggableRect* tdText, double lower, double upper, QString strResult)
{
//初始化,清空
InitCurrentViewInfo();
//当前属性类型
m_strCurrentProperty = TextItem_Property;
m_tdText = tdText;
//
_CreateVariantPropertyItem("当前项", "顶深(m)", -upper, QVariant::Double);
_CreateVariantPropertyItem("当前项", "底深(m)", -lower, QVariant::Double);
_CreateVariantPropertyItem("当前项", "文字结论", strResult, QVariant::String);
}
void PropertyWidget::initGujingProperty(FormInfo *formInfo) void PropertyWidget::initGujingProperty(FormInfo *formInfo)
{ {
_CreateVariantPropertyItem("通常", "选择井曲线", m_strLineName + "@" + m_strSlfName, QVariant::String); _CreateVariantPropertyItem("通常", "选择井曲线", m_strLineName + "@" + m_strSlfName, QVariant::String);

View File

@ -23,6 +23,7 @@
#include "TransparentDraggableGujing.h" #include "TransparentDraggableGujing.h"
#include "TransparentDraggableSwallCore.h" #include "TransparentDraggableSwallCore.h"
#include "TransparentDraggableGeoLith.h" #include "TransparentDraggableGeoLith.h"
#include "TransparentDraggableRect.h"
//当前曲线类型 //当前曲线类型
#define Widget_Property "Widget_Property" #define Widget_Property "Widget_Property"
@ -39,8 +40,11 @@
#define SwallCore_Property "SwallCore_Property" //井壁取心 #define SwallCore_Property "SwallCore_Property" //井壁取心
#define SwallCoreItem_Property "SwallCoreItem_Property" //井壁取心item #define SwallCoreItem_Property "SwallCoreItem_Property" //井壁取心item
#define GeoLith_Property "GeoLith_Property" //录井剖面 #define GeoLith_Property "GeoLith_Property" //录井剖面
#define GeoLithItem_Property "GeoLithItem_Property" //录井剖面item #define GeoLithItem_Property "GeoLithItem_Property" //录井剖面item
#define Text_Property "Text_Property" //文字结论
#define TextItem_Property "TextItem_Property" //文字结论item
#pragma execution_character_set("utf-8") #pragma execution_character_set("utf-8")
@ -110,6 +114,7 @@ public:
TransparentDraggableGujing* m_tdGujing; TransparentDraggableGujing* m_tdGujing;
TransparentDraggableSwallCore* m_tdSwallCore; TransparentDraggableSwallCore* m_tdSwallCore;
TransparentDraggableGeoLith* m_tdGeoLith; TransparentDraggableGeoLith* m_tdGeoLith;
TransparentDraggableRect* m_tdText;
public: public:
QWidget* GetPropertyWidget(); QWidget* GetPropertyWidget();
@ -149,10 +154,14 @@ public:
void initSwallCoreProperty(FormInfo *formInfo); void initSwallCoreProperty(FormInfo *formInfo);
void initSwallCoreItemProperty(TransparentDraggableSwallCore* tdSwallCore, double Depth, QString LithologyImage, QString OilGasImage, QString ColorImage, double Sideleft, double width, int iColor); void initSwallCoreItemProperty(TransparentDraggableSwallCore* tdSwallCore, double Depth, QString LithologyImage, QString OilGasImage, QString ColorImage, double Sideleft, double width, int iColor);
// 固井结论属性 // 录井剖面属性
void initGeoLithProperty(FormInfo *formInfo); void initGeoLithProperty(FormInfo *formInfo);
void initGeoLithItemProperty(TransparentDraggableGeoLith* tdGeoLith, double lower, double upper, const QString myLith, const QString myOil, const QString myColor); void initGeoLithItemProperty(TransparentDraggableGeoLith* tdGeoLith, double lower, double upper, const QString myLith, const QString myOil, const QString myColor);
// 文字结论属性
void initTextProperty(FormInfo *formInfo);
void initTextItemProperty(TransparentDraggableRect* tdText, double lower, double upper, QString strResult);
void ChangFillProperty();//填充属性改变 void ChangFillProperty();//填充属性改变
void ChangHeadItemProperty();//图头项改变 void ChangHeadItemProperty();//图头项改变

View File

@ -1,4 +1,6 @@
#include "TransparentDraggableRect.h" #include "TransparentDraggableRect.h"
#include "PropertyWidget.h"
#include "CallManage.h"
extern double g_dPixelPerCm;//每厘米像素数 extern double g_dPixelPerCm;//每厘米像素数
//static GeoIndicatorGenerator m_drawGeo; //static GeoIndicatorGenerator m_drawGeo;
@ -174,9 +176,100 @@ void TransparentDraggableRect::onDelRect()
//mDragMode = DragNone; //mDragMode = DragNone;
//删除框图 //删除框图
deleteRect(); deleteRect();
//保存
mPlot->SaveToSLF_Text();
//属性清空
PropertyService()->InitCurrentViewInfo();
} }
//设置深度移动量
void TransparentDraggableRect::setItemDepthOffset()
{
bool ok=0;
double depthshift=QInputDialog::getDouble(NULL,"深度移动","请输入移动的深度量(上移-,下移+)",0.0,-2147483647, 2147483647,4,&ok);
if(!ok) return;
QCPRange currentRange = getRange();
QCPRange newRange = currentRange;
newRange.lower = currentRange.lower-depthshift;
newRange.upper = currentRange.upper-depthshift;
//
double width = currentRange.size();
// //double center = mDragStartRange.center() + dx;
// double center = currentRange.center() - depthshift;
// newRange.lower = center - width/2;
// newRange.upper = center + width/2;
// 检查是否超出轴范围
if(newRange.lower < getMyLower()) {
return;
}
else if(newRange.upper > getMyUpper()) {
return;
}
//
setRange(newRange.lower, newRange.upper);
{
// double low = mRect->topLeft->coords().x();
// double hight = mRect->bottomRight->coords().x();
// PropertyService()->initGujingItemProperty(this, low, hight, m_Result);
//保存
mPlot->SaveToSLF_Text();
//属性清空
PropertyService()->InitCurrentViewInfo();
//取消所有选中单元格
emit CallManage::getInstance()->sig_Raise(mPlot->m_strUuid, "", "", "", "", 0, "");
}
}
//设置顶深
void TransparentDraggableRect::setUpper(double upper)
{
QCPRange currentRange = getRange();
QCPRange newRange = currentRange;
double proposedRight = upper;
// 确保不超出轴范围且不使宽度小于最小值
newRange.upper = qBound(
currentRange.lower + mMinWidth,
proposedRight,
getMyUpper());
// 最终确保宽度不小于最小值(针对整体拖动的情况)
if(newRange.size() < mMinWidth) {
newRange.upper = newRange.lower + mMinWidth;
}
setRange(newRange.lower, newRange.upper);
}
//设置底深
void TransparentDraggableRect::setLower(double lower)
{
QCPRange currentRange = getRange();
QCPRange newRange = currentRange;
double proposedLeft = lower;
// 确保不超出轴范围且不使宽度小于最小值
newRange.lower = qBound(
getMyLower(),
proposedLeft,
currentRange.upper - mMinWidth);
// 最终确保宽度不小于最小值(针对整体拖动的情况)
if(newRange.size() < mMinWidth) {
// 如果是边界拖动,强制设置最小宽度
newRange.lower = newRange.upper - mMinWidth;
}
setRange(newRange.lower, newRange.upper);
}
void TransparentDraggableRect::onMousePress(QMouseEvent *event) void TransparentDraggableRect::onMousePress(QMouseEvent *event)
{ {
if(event->button() != Qt::LeftButton)//右键 if(event->button() != Qt::LeftButton)//右键
@ -200,19 +293,13 @@ void TransparentDraggableRect::onMousePress(QMouseEvent *event)
//event->accept(); //event->accept();
double low = mRect->topLeft->coords().x();
double hight = mRect->bottomRight->coords().x();
PropertyService()->initTextItemProperty(this, low, hight, mstrTitle);
QMenu menu(nullptr); QMenu menu(nullptr);
QAction *delAction = menu.addAction("删除框图"); menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除选中对象", this, &TransparentDraggableRect::onDelRect);
//delAction->installEventFilter(this); menu.addAction(QIcon(::GetImagePath() + "icon/Shift.png"), "设置深度移动量", this, &TransparentDraggableRect::setItemDepthOffset);
connect(delAction, &QAction::triggered, this, &TransparentDraggableRect::onDelRect);
// QAction* pItem = menu.exec(event->globalPos());
// if(pItem == delAction)
// {
// //event->accept();
// int ii=0;
// ii++;
// }
menu.exec(event->globalPos()); menu.exec(event->globalPos());
return; return;
@ -351,6 +438,19 @@ void TransparentDraggableRect::onMouseRelease(QMouseEvent *event)
{ {
if(event->button() == Qt::LeftButton && mDragMode != DragNone) { if(event->button() == Qt::LeftButton && mDragMode != DragNone) {
event->accept(); event->accept();
//属性
//if(mDragMode == DragRect)
{
double low = mRect->topLeft->coords().x();
double hight = mRect->bottomRight->coords().x();
PropertyService()->initTextItemProperty(this, low, hight, mstrTitle);
//保存
mPlot->SaveToSLF_Text();
//取消所有选中单元格
emit CallManage::getInstance()->sig_Raise(mPlot->m_strUuid, "", "", "", "", 0, "");
}
//避免二次绘制框图 //避免二次绘制框图
mPlot->m_bDrawRect = false; mPlot->m_bDrawRect = false;
//emit rangeChanged(getRange()); //emit rangeChanged(getRange());

View File

@ -33,6 +33,11 @@ public:
// 删除框图 // 删除框图
void deleteRect(); void deleteRect();
//设置顶深
void setUpper(double upper);
//设置底深
void setLower(double lower);
signals: signals:
void rangeChanged(QCPRange newRange); void rangeChanged(QCPRange newRange);
@ -41,14 +46,15 @@ private:
void updateHandles() ; void updateHandles() ;
private slots: private slots:
void onDelRect(); void onDelRect(); //删除
void setItemDepthOffset(); //设置深度移动量
void onMousePress(QMouseEvent *event); void onMousePress(QMouseEvent *event);
void onMouseMove(QMouseEvent *event); void onMouseMove(QMouseEvent *event);
void onMouseRelease(QMouseEvent *event); void onMouseRelease(QMouseEvent *event);
double getMyLower(); double getMyLower();
double getMyUpper(); double getMyUpper();
private: public:
QMyCustomPlot *mPlot; QMyCustomPlot *mPlot;
QCPItemRect *mRect; QCPItemRect *mRect;
QCPItemRect *mLeftHandle; QCPItemRect *mLeftHandle;

View File

@ -871,7 +871,17 @@ QMyCustomPlot* FormDraw::addTableLine(QString strUuid, QString strSlfName, QStri
else if (strLineName == "WORDS_RELUST") else if (strLineName == "WORDS_RELUST")
{ {
//文字结论 //文字结论
initWords(curv, strSlfName, strLineName); if(listOtherProperty.size()>=3)
{
QString strAliasName = listOtherProperty[0];
QColor newlineColor=QColor(0,0,0);
newlineColor.setNamedColor(listOtherProperty[1]);
initWords(curv, strSlfName, strLineName, strAliasName, newlineColor, listOtherProperty);
}
else
{
initWords(curv, strSlfName, strLineName);
}
} }
else if (strLineName == "RESULT") else if (strLineName == "RESULT")
{ {
@ -3400,7 +3410,7 @@ void FormDraw::initTableLine(QMyCustomPlot *widget, QString strSlfName, QString
} }
void FormDraw::initWords(QMyCustomPlot *widget, QString strSlfName, QString strLineName) void FormDraw::initWords(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName, QColor newlineColor, QStringList listOtherProperty)
{ {
int iMyWidth = widget->axisRect(0)->width(); int iMyWidth = widget->axisRect(0)->width();
@ -3433,15 +3443,18 @@ void FormDraw::initWords(QMyCustomPlot *widget, QString strSlfName, QString strL
widget->xAxis2->setTicks(false); widget->xAxis2->setTicks(false);
widget->yAxis2->setTicks(false); widget->yAxis2->setTicks(false);
// //
LoadFromSLF(widget, strSlfName, strLineName); widget->LoadFromSLF_Text(strSlfName, strLineName);
QString strAliasName = ""; if(listOtherProperty.size()>=3)
{
strAliasName = listOtherProperty[0];
newlineColor.setNamedColor(listOtherProperty[1]);
}
QString strUnit = ""; QString strUnit = "";
QColor newlineColor=QColor(0,0,0);
double width=2; double width=2;
QString strScaleType = ""; QString strScaleType = "";
//道-对象 //道-对象
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject"); m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject", listOtherProperty);
} }
void FormDraw::initIMAGE_DATA(QMyCustomPlot *widget, QString strSlfName, QString strLineName) void FormDraw::initIMAGE_DATA(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
@ -3489,75 +3502,6 @@ void FormDraw::initIMAGE_DATA(QMyCustomPlot *widget, QString strSlfName, QString
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject");//yanxinImageObject m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject");//yanxinImageObject
} }
bool FormDraw::LoadFromSLF(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
{
QString FieldName="RESULT";
{
QString ss=strSlfName;
CMemRdWt *logio=new CMemRdWt();
if(ss==""||!logio->Open(ss.toStdString().c_str(),CSlfIO::modeRead))
{
delete logio;
// QMessageBox::information(NULL,"提示","SLF文件打开失败请检查",QMessageBox::Yes);
return false;
}
int iIndex=logio->OpenTable(strLineName.toStdString().c_str());
if(iIndex>-1) {
int len=logio->GetTableRecordLength(iIndex);
if(len<sizeof(WORDS_DATA)) len=sizeof(WORDS_DATA);
char*buf=new char[len+1];
WORDS_DATA *m_Result=(WORDS_DATA *)buf;
int count=logio->GetTableRecordCount(iIndex);
for(int i=0;i<count;i++) {
memset(m_Result,0,sizeof(WORDS_DATA));
logio->ReadTable(iIndex,i+1,m_Result);
// WelllogItem* item=AddItem(m_Result->StartDepth,m_Result->EndDepth);
// if(!item) continue;
// OGWordsResultItem* pResult = dynamic_cast<OGWordsResultItem*>(item);
logio->GetTableFieldData(iIndex,(char*)FieldName.toStdString().c_str(),m_Result->Words,i+1);
if(strstr(m_Result->Words,"$L")) {
char *s=strstr(m_Result->Words,"$L");
if(strstr(s+2,"$U")) {
char *p=strstr(s+1,"$U");
int len=p-s-2;
char buf1[100];
strncpy(buf1,s+2,len);
buf1[len]=0;
// SetLeftAndRightAlign(atoi(buf1));
// SetUpAndDownAlign(atoi(p+2));
}
else {
// SetLeftAndRightAlign(atoi(s+2));
}
*s=0;
}
else if(strstr(m_Result->Words,"$U")){
char *p=strstr(m_Result->Words,"$U");
// SetUpAndDownAlign(atoi(p+2));
*p=0;
}
// SetCharacters(m_Result->Words);
// fontColor=QColor(0,0,0,255);
// backgroundColor=QColor(255,255,255,255);
// wordfont.setFamily("黑体");
// wordfont.setPointSize(10);
//显示文本
widget->addTextToPlot(-m_Result->EndDepth, -m_Result->StartDepth, QString::fromLocal8Bit(m_Result->Words));
//widget->addTextToPlot(-2910, -2900, "你好");//QString(m_Result->Words)
}
logio->CloseTable(iIndex);
delete buf;
}
delete logio;
}
return true;
}
bool FormDraw::LoadFromIMAGE_SLF(QMyCustomPlot *widget, QString strSlfName, QString strLineName) bool FormDraw::LoadFromIMAGE_SLF(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
{ {
{ {
@ -4157,8 +4101,6 @@ void FormDraw::initGujing(QMyCustomPlot *widget, QString strSlfName, QString str
// //
widget->LoadFromSLF_Gujing(strSlfName, strLineName); widget->LoadFromSLF_Gujing(strSlfName, strLineName);
//QString strAliasName = "固井结论";
//QColor newlineColor=QColor(0,0,0);
if(listOtherProperty.size()>=3) if(listOtherProperty.size()>=3)
{ {
strAliasName = listOtherProperty[0]; strAliasName = listOtherProperty[0];

View File

@ -182,8 +182,7 @@ public:
QColor m_crPointFillDenv; QColor m_crPointFillDenv;
//文字结论 //文字结论
void initWords(QMyCustomPlot *widget, QString strSlfName, QString strLineName); void initWords(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName = "文字结论", QColor newlineColor=QColor(0,0,0), QStringList listOtherProperty={});
bool LoadFromSLF(QMyCustomPlot *widget, QString strSlfName, QString strLineName);
//解释结论 //解释结论
void initResult(QMyCustomPlot *widget, QString strSlfName, QString strLineName); void initResult(QMyCustomPlot *widget, QString strSlfName, QString strLineName);

View File

@ -421,7 +421,7 @@ void FormInfo::paintEvent(QPaintEvent* event)
if(m_strLineName=="WORDS_RELUST") if(m_strLineName=="WORDS_RELUST")
{ {
//文字结论,不绘制左右范围 //文字结论,不绘制左右范围
painter.drawText(rect.left(), rect.top()+rect.height()/3, rect.width(), rect.height()/3 ,Qt::AlignCenter, "文字结论"); //painter.drawText(rect.left(), rect.top()+rect.height()/3, rect.width(), rect.height()/3 ,Qt::AlignCenter, "文字结论");
} }
else if(m_strLineName=="RESULT") else if(m_strLineName=="RESULT")
{ {

View File

@ -577,7 +577,8 @@ void FormTrack::s_AddTableLine(QString strSlfName, QString strWellName, QString
formInfo->setFrontColor(QColor(0,0,0)); formInfo->setFrontColor(QColor(0,0,0));
formInfo->setBackColor(QColor(255,255,255)); formInfo->setBackColor(QColor(255,255,255));
if(strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT" if(strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT"
|| strLineName == "GEO_LITH" || strLineName == "SWALL_CORE") || strLineName == "GEO_LITH" || strLineName == "SWALL_CORE"
|| strLineName == "WORDS_RELUST" )
{ {
//固井结论 / 井壁取心 / 录井剖面 //固井结论 / 井壁取心 / 录井剖面
if(listOtherProperty.size()>=3) if(listOtherProperty.size()>=3)

View File

@ -981,6 +981,17 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_GeoLith); menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_GeoLith);
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
else if (m_strLineName == "WORDS_RELUST")
{
QMenu menu(this);
//岩性描述,文字结论
menu.addAction(QIcon(::GetImagePath() + "curve.png"), "开始编辑文字结论", this, &QMyCustomPlot::onEditText);
//menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Text);
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
//menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Text);
//menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Text);
menu.exec(event->globalPos());
}
// QAction *resetAction = menu.addAction("添加框图"); // QAction *resetAction = menu.addAction("添加框图");
// connect(resetAction, &QAction::triggered, this, &QMyCustomPlot::onAddRect); // connect(resetAction, &QAction::triggered, this, &QMyCustomPlot::onAddRect);
@ -1106,6 +1117,86 @@ void QMyCustomPlot::onEditLine()
} }
} }
//右键--添加文字结论
void QMyCustomPlot::onEditText()
{
this->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式
this->setSelectionRectMode(QCP::srmCustom); // 鼠标框选
if(m_bFirstTimeConnect)
{
//信号槽只绑定一次,避免重复绑定
m_bFirstTimeConnect = false;
for (int i=0; i < this->graphCount(); ++i) {
QCPGraph *graph = this->graph(i);
graph->setSelectable(QCP::stDataRange);
break;
}
connect(this->selectionRect(), &QCPSelectionRect::accepted, [this](){
if(this->m_bDrawRect == false)
{
this->m_bDrawRect = true;
return;
}
// 当选择完成时,获取矩形范围并放大
QRectF rect = this->selectionRect()->rect(); // 获取选择的矩形区域(像素坐标)
m_bEditRect=true;//当前是否正在编辑曲线。
// 转换为坐标轴范围
double top = rect.top();
double bottom = rect.bottom();
double right_Hight = this->xAxis->pixelToCoord(top);
double left_Low = this->xAxis->pixelToCoord(bottom);
//追加判断,避免框选重叠
TransparentDraggableRect *pDraggableRect =NULL;
{
QMap<QString,QObject *>::Iterator it = m_mapDraggable_Rect.begin();
while( it != m_mapDraggable_Rect.end() )
{
pDraggableRect = (TransparentDraggableRect*)it.value();
//
QCPRange tmpRange = pDraggableRect->getRange();
if(tmpRange.lower >= left_Low && tmpRange.upper <= right_Hight)
{
return;
}
if(tmpRange.upper >= left_Low && tmpRange.upper <= right_Hight)
{
return;
}
if(tmpRange.lower >= left_Low && tmpRange.lower <= right_Hight)
{
return;
}
it++;
}
}
{
//添加文字结论
this->addTextToPlot(left_Low, right_Hight, "");
//保存
this->SaveToSLF_Text();
//属性清空
PropertyService()->InitCurrentViewInfo();
//取消框选
this->setInteractions(QCP::iSelectLegend | QCP::iSelectPlottables);
this->setSelectionRectMode(QCP::srmNone);
}
});
}
}
//右键--添加固井 //右键--添加固井
void QMyCustomPlot::onEditGujing() void QMyCustomPlot::onEditGujing()
{ {
@ -1668,6 +1759,116 @@ bool QMyCustomPlot::SaveToSLF_GeoLith()
return true; return true;
} }
//保存文字结论
bool QMyCustomPlot::SaveToSLF_Text()
{
static int isrun=false;
if(isrun) return false;
QString ss=m_strSlfName;
if(ss=="") return false;
isrun=true;
CMemRdWt *logio=new CMemRdWt();
if(!logio->Open(ss.toStdString().c_str(),CSlfIO::modeReadWrite))
{
delete logio;
QMessageBox::information(NULL,"提示","SLF文件打开失败请检查",QMessageBox::Yes);
isrun=false;
return false;
}
QString name=m_strLineName;
bool isfirst=false;
int iIndex=logio->OpenTable(name.toStdString().c_str());
if (iIndex < 0)
{
if(!m_mapDraggable_Rect.size()) {
delete logio;
isrun=false;
return false;
}
iIndex=logio->Open_Set_Table(m_strLineName.toStdString().c_str(),0,4,
"NO,SDEP,EDEP,RESULT",
"4,4,4,100",//字段长度
"1,4,4,6",//字段类型
"0,0,0,0");//字段备注
isfirst=true;
}
logio->SetTableRecordCount(iIndex,m_mapDraggable_Rect.size());
if(!m_mapDraggable_Rect.size()) {
delete logio;
if(isfirst)AddTableToWellRound();
isrun=false;
return false;
}
int len=logio->GetTableRecordLength(iIndex);
if(len<sizeof(WORDS_DATA)) len=sizeof(WORDS_DATA)+1;
char *buf=new char[len+1];
WORDS_DATA *m_Result=(WORDS_DATA*)buf;
TransparentDraggableRect *pDraggableRect =NULL;
//排序
QList<float> listSDepth;
for (QMap<QString,QObject *>::Iterator iter = m_mapDraggable_Rect.begin(); iter != m_mapDraggable_Rect.end(); iter++)
{
pDraggableRect = (TransparentDraggableRect*)iter.value();
//
QCPRange tmpRange = pDraggableRect->getRange();
//
float fSDepth = -tmpRange.upper;
listSDepth.append(fSDepth);
}
qSort(listSDepth);
//
for(int i=0; i<listSDepth.size(); i++)
{
for (QMap<QString,QObject *>::Iterator iter = m_mapDraggable_Rect.begin(); iter != m_mapDraggable_Rect.end(); iter++)
{
pDraggableRect = (TransparentDraggableRect*)iter.value();
//
QCPRange tmpRange = pDraggableRect->getRange();
float fSDepth = -tmpRange.upper;
if(fSDepth == listSDepth[i])//按顺序写入
{
memset(m_Result,0,sizeof(WORDS_DATA));
m_Result->StartDepth=-tmpRange.upper;
m_Result->EndDepth=-tmpRange.lower;
m_Result->Order=i+1;
int l=strlen(pDraggableRect->mstrTitle.toStdString().c_str());
if(l>100) l=100;
strncpy(m_Result->Words,pDraggableRect->mstrTitle.toLocal8Bit().data(),l);
if(l<100) m_Result->Words[l]=0;
float yy=m_Result->Order;
// if(pResult->GetLeftAndRightAlign()) {
// strcat(m_Result->Words,"$L");
// QString s=QString::number(pResult->GetLeftAndRightAlign());
// strcat(m_Result->Words,s.toStdString().c_str());
// }
// if(pResult->GetUpAndDownAlign()!=1) {
// strcat(m_Result->Words,"$U");
// QString s=QString::number(pResult->GetUpAndDownAlign());
// strcat(m_Result->Words,s.toStdString().c_str());
// }
logio->SetTableFieldData(iIndex,0,(char*)&yy,i+1);
logio->SetTableFieldData(iIndex,1,(char*)&m_Result->StartDepth,i+1);
logio->SetTableFieldData(iIndex,2,(char*)&m_Result->EndDepth,i+1);
QString FieldName = "RESULT";
logio->SetTableFieldData(iIndex,(char*)FieldName.toStdString().c_str(),(char*)&m_Result->Words,i+1);
}
}
}
logio->CloseTable(iIndex);
delete logio;
if(isfirst)AddTableToWellRound();
delete buf;
isrun=false;
return true;
}
//保存固井结论道 //保存固井结论道
bool QMyCustomPlot::SaveToSLF_Gujing() bool QMyCustomPlot::SaveToSLF_Gujing()
{ {
@ -4949,3 +5150,71 @@ void QMyCustomPlot::s_changeGeoLithLine(QString strUuid, QString strSlfName, QSt
//不清空属性窗口 //不清空属性窗口
} }
bool QMyCustomPlot::LoadFromSLF_Text(QString strSlfName, QString strLineName)
{
QString FieldName="RESULT";
{
QString ss=strSlfName;
CMemRdWt *logio=new CMemRdWt();
if(ss==""||!logio->Open(ss.toStdString().c_str(),CSlfIO::modeRead))
{
delete logio;
// QMessageBox::information(NULL,"提示","SLF文件打开失败请检查",QMessageBox::Yes);
return false;
}
int iIndex=logio->OpenTable(strLineName.toStdString().c_str());
if(iIndex>-1) {
int len=logio->GetTableRecordLength(iIndex);
if(len<sizeof(WORDS_DATA)) len=sizeof(WORDS_DATA);
char*buf=new char[len+1];
WORDS_DATA *m_Result=(WORDS_DATA *)buf;
int count=logio->GetTableRecordCount(iIndex);
for(int i=0;i<count;i++) {
memset(m_Result,0,sizeof(WORDS_DATA));
logio->ReadTable(iIndex,i+1,m_Result);
// WelllogItem* item=AddItem(m_Result->StartDepth,m_Result->EndDepth);
// if(!item) continue;
// OGWordsResultItem* pResult = dynamic_cast<OGWordsResultItem*>(item);
logio->GetTableFieldData(iIndex,(char*)FieldName.toStdString().c_str(),m_Result->Words,i+1);
if(strstr(m_Result->Words,"$L")) {
char *s=strstr(m_Result->Words,"$L");
if(strstr(s+2,"$U")) {
char *p=strstr(s+1,"$U");
int len=p-s-2;
char buf1[100];
strncpy(buf1,s+2,len);
buf1[len]=0;
// SetLeftAndRightAlign(atoi(buf1));
// SetUpAndDownAlign(atoi(p+2));
}
else {
// SetLeftAndRightAlign(atoi(s+2));
}
*s=0;
}
else if(strstr(m_Result->Words,"$U")){
char *p=strstr(m_Result->Words,"$U");
// SetUpAndDownAlign(atoi(p+2));
*p=0;
}
// SetCharacters(m_Result->Words);
// fontColor=QColor(0,0,0,255);
// backgroundColor=QColor(255,255,255,255);
// wordfont.setFamily("黑体");
// wordfont.setPointSize(10);
//显示文本
this->addTextToPlot(-m_Result->EndDepth, -m_Result->StartDepth, QString::fromLocal8Bit(m_Result->Words));
}
logio->CloseTable(iIndex);
delete buf;
}
delete logio;
}
return true;
}

View File

@ -141,11 +141,11 @@ public:
// 组 // 组
QMap<QString, QObject*> m_mapDragGroup; QMap<QString, QObject*> m_mapDragGroup;
QMap<QString, QObject*> m_mapDraggable_Rect; QMap<QString, QObject*> m_mapDraggable_Rect; //文字结论
QMap<QString, QObject*> m_mapDraggable_Result; QMap<QString, QObject*> m_mapDraggable_Result; //解释结论
QMap<QString, QObject*> m_mapDraggable_GeoLith; QMap<QString, QObject*> m_mapDraggable_GeoLith; //录井剖面
QMap<QString, QObject*> m_mapDraggable_SwallCore; QMap<QString, QObject*> m_mapDraggable_SwallCore; //井壁取心
QMap<QString, QObject*> m_mapDraggable_Gujing; QMap<QString, QObject*> m_mapDraggable_Gujing; //固井
QMap<QString, QObject*> m_mapDraggable_Image; QMap<QString, QObject*> m_mapDraggable_Image;
QMap<QString, QObject*> m_mapDraggable_MFac; QMap<QString, QObject*> m_mapDraggable_MFac;
QMap<QString, QObject*> m_mapDraggable_Phase; QMap<QString, QObject*> m_mapDraggable_Phase;
@ -181,13 +181,16 @@ public:
QMap<QString,QString> ColorOrder; QMap<QString,QString> ColorOrder;
QMap<QString,QString> ColorInds; QMap<QString,QString> ColorInds;
QStringList LithWidth; QStringList LithWidth;
double m_dOilZhan=8; //含油占比
QString GetIntLith(QString Lith); QString GetIntLith(QString Lith);
QString GetIntOil(QString Oil); QString GetIntOil(QString Oil);
QString GetIntColor(QString Color); QString GetIntColor(QString Color);
bool SaveToSLF_GeoLith(); bool SaveToSLF_GeoLith();
bool LoadFromSLF_GeoLith(QString strSlfName, QString strLineName); bool LoadFromSLF_GeoLith(QString strSlfName, QString strLineName);
//录井剖面
double m_dOilZhan=8; //含油占比 //文字结论
bool SaveToSLF_Text();
bool LoadFromSLF_Text(QString strSlfName, QString strLineName);
public slots: public slots:
void slot_time(); void slot_time();
@ -311,6 +314,13 @@ public slots:
void RefreshItems_GeoLith(); //刷新数据 void RefreshItems_GeoLith(); //刷新数据
void AddItem_GeoLith(QStringList lists); void AddItem_GeoLith(QStringList lists);
//右键--编辑文字结论
void onEditText();
// void addItems_Text(); //从剪切板文本数据粘贴
// void DeleteItems_Text(); //全部清空
// void RefreshItems_Text(); //刷新数据
// void AddItem_Text(QStringList lists);
// //
void addItems_Core(); void addItems_Core();