diff --git a/common/geometryutils.cpp b/common/geometryutils.cpp index fa2f217..50c7b1c 100644 --- a/common/geometryutils.cpp +++ b/common/geometryutils.cpp @@ -1149,6 +1149,10 @@ QString GetGujingSymbolDir(QString cs) { return GetSymbolDir()+"固井结论符号"+cs; } +QString GetImageSymbolDir(QString cs) +{ + return GetSymbolDir()+"岩心照片符号"+cs; +} QString GetLithSymbolDir(QString cs) { return GetSymbolDir()+"岩性符号"+cs; diff --git a/common/geometryutils.h b/common/geometryutils.h index 429efb0..3692528 100644 --- a/common/geometryutils.h +++ b/common/geometryutils.h @@ -235,6 +235,7 @@ QString GetMudSymbolDir(QString cs=QDir::separator()); QString GetOilSymbolDir(QString cs=QDir::separator()); QString GetLithSymbolDir(QString cs=QDir::separator()); QString GetGujingSymbolDir(QString cs=QDir::separator()); +QString GetImageSymbolDir(QString cs=QDir::separator()); int GetLineWidth(QPainter * painter,int flWidth); QString GBKToUTF8(const QByteArray& gbkData); diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 2f16773..aa3516d 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -1102,9 +1102,9 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event) menu.addAction(QIcon(::GetImagePath() + "curve.png"), "开始编辑岩心图片", this, &QMyCustomPlot::onEditImage); menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItemsImage); menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems); - menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItemsImage); - menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItemsImage); - menu.addAction(QIcon(::GetImagePath() + "development.png"), "合并结论", this, &QMyCustomPlot::MegResultImage); + menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::deleteItemsImage); + menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::refreshItemsImage); + menu.addAction(QIcon(::GetImagePath() + "development.png"), "合并结论", this, &QMyCustomPlot::megResultImage); menu.exec(event->globalPos()); } } @@ -1464,6 +1464,7 @@ void QMyCustomPlot::onEditGujing() } } +// 岩心图片 void QMyCustomPlot::onEditImage() { this->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式 @@ -1537,7 +1538,7 @@ void QMyCustomPlot::onEditImage() this->addImageToPlot(left_Low, right_Hight, imagePath); //保存 - this->SaveToSLF_Gujing(); + this->SaveToSLFImage(imagePath); //属性清空 PropertyService()->InitCurrentViewInfo(); @@ -1552,10 +1553,99 @@ void QMyCustomPlot::onEditImage() } } -void QMyCustomPlot::addItemsImage(){} -void QMyCustomPlot::DeleteItemsImage(){} -void QMyCustomPlot::RefreshItemsImage(){} -void QMyCustomPlot::MegResultImage(){} +// 岩心图片 +void QMyCustomPlot::addItemsImage(){ + 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(","," "); + originalText.replace("\t"," "); + originalText.replace("\r\n","\n"); + originalText.replace("\r","\n"); + QStringList line=originalText.split("\n"); + QStringList old; + for(int i=0;i=0) coredat.removeAll(""); + if(coredat.size()<1) continue; + if(!coredat[0].isEmpty()&&!coredat[0].at(0).isDigit()) continue; + if(coredat.size()<3) { + if(old.size()<1) { + old=coredat; + continue; + } + else { + QStringList cs; + cs.append(old[0]); + cs.append(old[1]); + cs.append(coredat[1]); +// cs.append(old[2]); + old=coredat; + coredat=cs; + } + } + //添加固井结论 + int NO = coredat[0].toInt(); + float SDEP = coredat[1].toDouble(); + float EDEP = coredat[2].toDouble(); + int iRESULT = 0; + QString result = ""; + if(coredat.size()>3) { + if(coredat[3].at(0).isDigit()) { + iRESULT = coredat[3].toInt(); + QString iconshotname=zoneOrderImage.key(QString::number(iRESULT)); + if(iconshotname!="") + result=::GetImageSymbolDir()+iconshotname+".svg"; + } + else + { + QStringList vals=zoneOrderImage.keys(); + coredat[3].trimmed(); + int j=vals.indexOf(coredat[3]); + if(j>-1) { + result=::GetImageSymbolDir()+vals[j]+".svg"; + } + } + } + + // + int len=2; + int pos=result.indexOf(".//"); + if(pos<0) pos=result.indexOf("./"); + else len=3; + QString svg; + if(pos==0) + { + svg=QCoreApplication::applicationDirPath()+ QDir::separator(); + svg+=result.mid(len-1); + } + else svg=result; + QDir ss; + if(!ss.exists(svg)) + { + QString path=svg.left(svg.lastIndexOf('.')+1); + svg=path+"png"; + } + result=QDir::toNativeSeparators(svg); + + //显示固井 + addImageToPlot(-EDEP, -SDEP, result); + } + //保存 + //this->SaveToSLFImage(); + //属性清空 + PropertyService()->InitCurrentViewInfo(); +} +void QMyCustomPlot::deleteItemsImage(){} +void QMyCustomPlot::refreshItemsImage(){} +void QMyCustomPlot::megResultImage(){} //右键--添加录井剖面 void QMyCustomPlot::onEditGeoLith() @@ -2366,6 +2456,108 @@ bool QMyCustomPlot::SaveToSLF_Gujing() return true; } +//保存岩心图片 +bool QMyCustomPlot::SaveToSLFImage(QString imagePath) +{ + static int isrun=false; + if(isrun) return false; + QString ss=m_strSlfName; + if(ss=="") return false; + isrun=true; + + IMAGE_DATA m_Result; + CMemRdWt *logio=new CMemRdWt(); + if(ss==""||!logio->Open(ss.toStdString().c_str(),CSlfIO::modeReadWrite)) + { + delete logio; + QMessageBox::information(NULL,"提示","SLF文件打开失败,请检查!!",QMessageBox::Yes); + isrun=false; + return false; + } + + //QString ssss = m_strLineName.toStdString().c_str(); + int iIndex=logio->OpenTable(m_strLineName.toStdString().c_str()); + bool isfirst=false; + if (iIndex < 0) + { + if(!m_mapDraggable_Image.size()) { + delete logio; + isrun=false; + return false; + } + iIndex=logio->Open_Set_Table(m_strLineName.toStdString().c_str(),GUJING_OBJECT,4, + "NO,SDEP,EDEP,RESULT", + "4,4,4,4",//字段长度 + "1,4,4,1",//字段类型 + "0,0,0,2");//字段备注 + isfirst=true; + } + logio->SetTableRecordCount(iIndex,m_mapDraggable_Image.size()); + //int j=0; + if(!m_mapDraggable_Image.size()) { + delete logio; + if(isfirst)AddTableToWellRound(); + isrun=false; + return false; + } + + TransparentDraggableImage *pDraggableRect =NULL; + + //排序 + QList listSDepth; + for (QMap::Iterator iter = m_mapDraggable_Image.begin(); iter != m_mapDraggable_Image.end(); iter++) + { + pDraggableRect = (TransparentDraggableImage*)iter.value(); + // + QCPRange tmpRange = pDraggableRect->getRange(); + // + float fSDepth = -tmpRange.upper; + listSDepth.append(fSDepth); + } + qSort(listSDepth); + + // + for(int i=0; i::Iterator iter = m_mapDraggable_Image.begin(); iter != m_mapDraggable_Image.end(); iter++) + { + pDraggableRect = (TransparentDraggableImage*)iter.value(); + QString aaa = pDraggableRect->getMResult(); + // + QCPRange tmpRange = pDraggableRect->getRange(); + float fSDepth = -tmpRange.upper; + if(fSDepth == listSDepth[i])//按顺序写入 + { + memset(&m_Result,0,sizeof(GUJING_DATA)); + m_Result.StartDepth = -tmpRange.upper; + m_Result.EndDepth = -tmpRange.lower; + m_Result.Order=i+1; + // m_Result.Image = imagePath; + // 拷贝字符串到数组,长度为数组长度-1(留1位存'\0'结束符) + strncpy(m_Result.Image, pDraggableRect->getMResult().toLocal8Bit().constData(), sizeof(m_Result.Image) - 1); + // 手动添加结束符(确保字符串合法) + m_Result.Image[sizeof(m_Result.Image) - 1] = '\0'; + //m_Result.RESULT=0; + //QString innerresult=GetIntResult_Gujing(pDraggableRect->m_Result); + // if(innerresult!="") + // m_Result.RESULT=innerresult.toInt(); + // if(m_Result.RESULT<0) m_Result.RESULT=0; + //写入 + logio->WriteTable(iIndex,i+1,&m_Result); + break; + } + } + } + logio->CloseTable(iIndex); + delete logio; + if(isfirst)AddTableToWellRound(); + isrun=false; + + // 写到slf文件 + + return true; +} + QString QMyCustomPlot::GetIntResult_Gujing(QString result) { if(result=="") return ""; diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index 1123fd6..ed7ffbf 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -176,6 +176,10 @@ public: bool CopyToSLFFile(QString targetSLFFileName, bool deleteFromSrc, char*newCurveName); bool LoadFromSLF_Gujing(QString strSlfName, QString strLineName); + // 岩心图片 + QMap zoneOrderImage; + bool SaveToSLFImage(QString imagePath); + //井壁取心 QStringList liths_SWallCore; QStringList oils_SWallCore; @@ -341,6 +345,13 @@ public slots: void RefreshItems_Gujing(); //刷新数据 void MegResult_Gujing(); //合并结论 + //右键--编辑岩心照片 + void onEditImage(); + void addItemsImage(); //从剪切板文本数据粘贴 + void deleteItemsImage(); //全部清空 + void refreshItemsImage(); //刷新数据 + void megResultImage(); //合并结论 + //右键--编辑井壁取心 void addItem_SWallCore(); //增加井壁取心 void moveItems_SWallCore(); //平移水平位置 @@ -373,13 +384,6 @@ public slots: //右键--气测-管柱-文本-FMT-射孔 void RefreshItems_Jiegutext(QString strAliasName = "气测-FMT-射孔-文本"); //刷新数据 - //右键--编辑岩心照片 - void onEditImage(); - void addItemsImage(); //从剪切板文本数据粘贴 - void DeleteItemsImage(); //全部清空 - void RefreshItemsImage(); //刷新数据 - void MegResultImage(); //合并结论 - // void addItems_Core(); diff --git a/logPlus/transparentdraggableimage.cpp b/logPlus/transparentdraggableimage.cpp index 4917ae7..180222a 100644 --- a/logPlus/transparentdraggableimage.cpp +++ b/logPlus/transparentdraggableimage.cpp @@ -203,6 +203,10 @@ QCPRange TransparentDraggableImage::getRange() return QCPRange(mRect->topLeft->coords().x(), mRect->bottomRight->coords().x()); } +QString TransparentDraggableImage::getMResult(){ + return this->m_Result; +} + // 设置矩形颜色 void TransparentDraggableImage::setColor(const QColor &color) { diff --git a/logPlus/transparentdraggableimage.h b/logPlus/transparentdraggableimage.h index ea56248..990fd05 100644 --- a/logPlus/transparentdraggableimage.h +++ b/logPlus/transparentdraggableimage.h @@ -38,6 +38,7 @@ public: void setRange(double left_Low, double right_Hight); // 获取当前范围 QCPRange getRange(); + QString getMResult(); // 设置矩形颜色 void setColor(const QColor &color);