diff --git a/logPlus/TransparentDraggableRect.cpp b/logPlus/TransparentDraggableRect.cpp index 15d5bb0..47b0cbe 100644 --- a/logPlus/TransparentDraggableRect.cpp +++ b/logPlus/TransparentDraggableRect.cpp @@ -50,10 +50,8 @@ void TransparentDraggableRect::setRange(double left_Low, double right_Hight) mPixmap->topLeft->setCoords(right_Hight, lY1); mPixmap->bottomRight->setCoords(left_Low, lY2); - //mItemTitle->position->setCoords(0.5, 0.5); - // 设置父锚点,定位点 - //mItemTitle->position->setParentAnchor(mRect->bottom); - mItemTitle->position->setCoords((mRect->topLeft->coords().x() + mRect->bottomRight->coords().x())/2, + float flNewPos = mPlot->xAxis->coordToPixel((left_Low + right_Hight)/2.0) - 15; + mItemTitle->position->setCoords(mPlot->xAxis->pixelToCoord(flNewPos), (mRect->topLeft->coords().y() + mRect->bottomRight->coords().y())/2); // 设置文本在矩形中心位置 //mRect->topLeft->setCoords(left, mPlot->yAxis->range().upper); @@ -81,12 +79,6 @@ void TransparentDraggableRect::setColor(const QColor &color) void TransparentDraggableRect::deleteRect() { if(mPlot) { - -// mRect->deleteLater(); -// mLeftHandle->deleteLater(); -// mRightHandle->deleteLater(); -// mPixmap->deleteLater(); - mPlot->m_mapDraggable_Rect.remove(m_strUuid); mPlot->removeItem(mRect); @@ -97,15 +89,6 @@ void TransparentDraggableRect::deleteRect() mPlot->replot(); this->deleteLater(); - - // -// //避免二次绘制框图 -// mPlot->m_bDrawRect = false; -// mDragMode = DragNone; -// //取消选中框 -// mPlot->selectionRect()->cancel(); -// mPlot->replot(); -// mPlot->selectionRect()->mActive=true; } } diff --git a/logPlus/TransparentDraggableRect.h b/logPlus/TransparentDraggableRect.h index 9621236..46a248c 100644 --- a/logPlus/TransparentDraggableRect.h +++ b/logPlus/TransparentDraggableRect.h @@ -65,6 +65,25 @@ public: QString mstrTitle=""; QString m_strUuid = ""; + //以下字段为临时添加,后面需要数据组集成 + QFont wordfont; //文字字体 + QColor fontColor; //字体颜色 + QColor backgroundColor; //背景颜色 + int leftAndRightAlign; //左右对齐方式 + int upAndDownAlign; //上下对齐方式 + +// BEGIN_ENUM(LeftAndRightDesc) +// { 0,L"中间对齐" }, +// { 1,L"左对齐" }, +// { 2,L"右对齐" } +// END_ENUM(LeftAndRightDesc); + +// BEGIN_ENUM(UpAndDownDesc) +// { 0,L"上对齐" }, +// { 1,L"中间对齐" }, +// { 2,L"下对齐" } +// END_ENUM(UpAndDownDesc); + enum DragMode { DragNone, DragLeft, DragRight, DragRect }; DragMode mDragMode = DragNone; //double mDragStartX = 0; diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index 70dabcd..190e6f1 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -300,9 +300,9 @@ void FormDraw::DisplayLines(QJsonArray linesArray) } } if (strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT" - || strLineName == "GEO_LITH" || strLineName == "SWALL_CORE") + || strLineName == "WORDS_RELUST" || strLineName == "GEO_LITH" || strLineName == "SWALL_CORE") { - //固井结论/井壁取心/录井剖面 + //固井结论/井壁取心/录井剖面/文字结论 DisplayTable_One(lineObjInfo); } } diff --git a/logPlus/forminfo.cpp b/logPlus/forminfo.cpp index 229b153..ddf589f 100644 --- a/logPlus/forminfo.cpp +++ b/logPlus/forminfo.cpp @@ -161,6 +161,15 @@ QJsonObject FormInfo::makeJson() //item属性写入slf文件,不需要此次记录 return rootObj; } + else if (m_strLineName == "WORDS_RELUST") + { + //文字结论 + rootObj["Type"] = m_strType; + rootObj["curveNameFont"] = m_curveNameFont.toString(); + rootObj["lineColor"] = m_lineColor.name(); + //item属性写入slf文件,不需要此次记录 + return rootObj; + } } rootObj["Unit"] = m_strUnit; diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 981aa49..a4674c2 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -986,21 +986,12 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event) 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/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.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("添加框图"); -// connect(resetAction, &QAction::triggered, this, &QMyCustomPlot::onAddRect); - -// if (selectedGraphs().size() > 0)//选中曲线 -// { -// menu.addAction("删除选中曲线", this, SLOT(removeSelectedGraph())); -// } - } //右键--添加分段线 @@ -2215,20 +2206,7 @@ void QMyCustomPlot::DeleteItems_SWallCore() CopyToSLFFile(m_strSlfName, false, (char *)obj.toStdString().c_str()); AddTableToWellRound(); - //删除对象 - TransparentDraggableSwallCore *pDraggableRect =NULL; - QMap::Iterator it = m_mapDraggable_SwallCore.begin(); - while( it != m_mapDraggable_SwallCore.end() ) - { - pDraggableRect = (TransparentDraggableSwallCore*)it.value(); - it++; - pDraggableRect->deleteRect(); - } - - //保存 - this->SaveToSLF_SwallCore(); - //属性清空 - PropertyService()->InitCurrentViewInfo(); + RefreshItems_SWallCore(); //刷新数据 } //全部清空 @@ -2239,20 +2217,7 @@ void QMyCustomPlot::DeleteItems_GeoLith() CopyToSLFFile(m_strSlfName, false, (char *)obj.toStdString().c_str()); AddTableToWellRound(); - //删除对象 - TransparentDraggableGeoLith *pDraggableRect =NULL; - QMap::Iterator it = m_mapDraggable_GeoLith.begin(); - while( it != m_mapDraggable_GeoLith.end() ) - { - pDraggableRect = (TransparentDraggableGeoLith*)it.value(); - it++; - pDraggableRect->deleteRect(); - } - - //保存 - this->SaveToSLF_GeoLith(); - //属性清空 - PropertyService()->InitCurrentViewInfo(); + RefreshItems_GeoLith(); //刷新数据 } //从剪切板文本数据粘贴 @@ -2923,20 +2888,7 @@ void QMyCustomPlot::DeleteItems_Gujing() CopyToSLFFile(m_strSlfName, false, (char *)obj.toStdString().c_str()); AddTableToWellRound(); - //删除对象 - TransparentDraggableGujing *pDraggableRect =NULL; - QMap::Iterator it = m_mapDraggable_Gujing.begin(); - while( it != m_mapDraggable_Gujing.end() ) - { - pDraggableRect = (TransparentDraggableGujing*)it.value(); - it++; - pDraggableRect->deleteRect(); - } - - //保存 - this->SaveToSLF_Gujing(); - //属性清空 - PropertyService()->InitCurrentViewInfo(); + RefreshItems_Gujing(); //刷新数据 } //刷新数据 @@ -3643,13 +3595,13 @@ void QMyCustomPlot::addTextToPlot(double left_Low, double right_Hight, const QSt QString strUuid = qtCommon->getUUid(); // 在初始化代码中 TransparentDraggableRect *dragRect = new TransparentDraggableRect(this, strUuid); - // 设置初始范围 - dragRect->setRange(left_Low, right_Hight); + dragRect->setTitle(strText); // 可选:设置颜色 dragRect->setColor(crColor); // 半透明白色 + // 设置初始范围 + dragRect->setRange(left_Low, right_Hight); //最小宽度 dragRect->setMinWidth(0.1); - dragRect->setTitle(strText); m_mapDraggable_Rect[strUuid] = dragRect; } @@ -5208,7 +5160,7 @@ bool QMyCustomPlot::LoadFromSLF_Text(QString strSlfName, QString strLineName) // wordfont.setFamily("黑体"); // wordfont.setPointSize(10); - //显示文本 + //插入文本 this->addTextToPlot(-m_Result->EndDepth, -m_Result->StartDepth, QString::fromLocal8Bit(m_Result->Words)); } logio->CloseTable(iIndex); @@ -5218,3 +5170,90 @@ bool QMyCustomPlot::LoadFromSLF_Text(QString strSlfName, QString strLineName) } return true; } + +//从剪切板文本数据粘贴 +void QMyCustomPlot::addItems_Text() +{ + QClipboard *clipboard = QApplication::clipboard(); //获取系统剪贴板指针 + QString originalText = clipboard->text(); //获取剪贴板上文本信息 + int isspace=originalText.indexOf(" "); + int istab=originalText.indexOf("\t"); + int isd=originalText.indexOf(","); + + if((istab>-1|isd>-1)&&isspace>-1) + { + QMessageBox::information(NULL,"提示", "\",\"或制表符与空格键并存,自动分解可能有误!\n建议用单一符号风格!"); + } + originalText.replace("\t"," "); + originalText.replace(","," "); + originalText.replace("\r\n","\n"); + originalText.replace("\r","\n"); + QStringList line=originalText.split("\n"); + line.removeAll(""); + for(int i=0;i=0) coredat.removeAll(""); + if(coredat.size()<1) continue; + if(!coredat[0].isEmpty()&&!coredat[0].at(0).isDigit()) continue; + + //文字结论 + AddItem_Text(coredat); + } + + //保存 + this->SaveToSLF_Text(); + + //属性清空 + PropertyService()->InitCurrentViewInfo(); +} + +void QMyCustomPlot::AddItem_Text(QStringList lists) +{ + if(lists.size()==3) lists.insert(0,"0"); + double top=-9999.0; + double bottom=-9999.0; + if(lists.size()>1) top=lists[1].toDouble(); + if(lists.size()>2) bottom=lists[2].toDouble(); + if(top&&bottom==0) bottom=top; + if(top==bottom&&top==-9999.0) return; + + if(lists.size()<4) + { + this->addTextToPlot(-bottom, -top, ""); + return; + } + + //插入文本 + this->addTextToPlot(-bottom, -top, lists[3]); +} + +//全部清空 +void QMyCustomPlot::DeleteItems_Text() +{ + if(QMessageBox::information(NULL,QObject::tr("提示"),QObject::tr("该功能将清除当前组件展示的全部信息,清除后无法恢复,但会备份到对应的\"_BAK\"中,确定清除吗?"),QMessageBox::Yes|QMessageBox::No)!=QMessageBox::Yes) return; + QString obj=m_strLineName + "BAK"; + CopyToSLFFile(m_strSlfName, false, (char *)obj.toStdString().c_str()); + AddTableToWellRound(); + + //刷新数据 + RefreshItems_Text(); +} + +//刷新数据 +void QMyCustomPlot::RefreshItems_Text() +{ + //删除对象 + TransparentDraggableRect *pDraggableRect =NULL; + QMap::Iterator it = m_mapDraggable_Rect.begin(); + while( it != m_mapDraggable_Rect.end() ) + { + pDraggableRect = (TransparentDraggableRect*)it.value(); + it++; + pDraggableRect->deleteRect(); + } + + //保存 + this->SaveToSLF_Text(); + //属性清空 + PropertyService()->InitCurrentViewInfo(); +} diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index d711272..b835256 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -316,10 +316,10 @@ public slots: //右键--编辑文字结论 void onEditText(); -// void addItems_Text(); //从剪切板文本数据粘贴 -// void DeleteItems_Text(); //全部清空 -// void RefreshItems_Text(); //刷新数据 -// void AddItem_Text(QStringList lists); + void addItems_Text(); //从剪切板文本数据粘贴 + void DeleteItems_Text(); //全部清空 + void RefreshItems_Text(); //刷新数据 + void AddItem_Text(QStringList lists); // void addItems_Core();