diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index 992a6cf..8ea75c8 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -1193,6 +1193,12 @@ void PropertyWidget::initCurveProperty(FormInfo *formInfo, QStringList strListOt _CreateVariantPropertyItem("曲线线型", "线宽", formInfo->m_dWidth, QVariant::Double, 1, 20); _CreateVariantPropertyItem("曲线线型", "颜色", formInfo->m_lineColor, QVariant::Color); _CreateEnumPropertyItem("曲线线型", "线型", (int)formInfo->m_lineStyle, listStyle); + //绘制方式 +// _CreateVariantPropertyItem("绘制方式", "曲线", formInfo->m_bDrawLine, QVariant::Bool); +// _CreateVariantPropertyItem("绘制方式", "绘制对称曲线", formInfo->m_bDrawSymmetry, QVariant::Bool); +// _CreateVariantPropertyItem("绘制方式", "杆状", formInfo->m_bDrawGan, QVariant::Bool); +// _CreateVariantPropertyItem("绘制方式", "点状", formInfo->m_bDrawPoint, QVariant::Bool); + // _CreateEnumPropertyItem("岩性填充", "头部图例", listHeadFill.indexOf(formInfo->m_newHeadFill), listHeadFill); _CreateEnumPropertyItem("岩性填充", "目标曲线", listTargetLine.indexOf(formInfo->m_newTargetLine), listTargetLine); @@ -1323,7 +1329,14 @@ void PropertyWidget::initProperty(FormInfo *formInfo) if (formInfo->m_strType == "tableObject") { - this->initTableProperty(formInfo); + if (m_strLineName == "GUJING1_RESULT" || m_strLineName == "GUJING2_RESULT" || m_strLineName == "GUJING3_RESULT") + { + //固井结论 + this->initGujingProperty(formInfo); + } + else{ + this->initTableProperty(formInfo); + } } else if (formInfo->m_strType == "depthObject") { @@ -1336,16 +1349,6 @@ void PropertyWidget::initProperty(FormInfo *formInfo) else if (formInfo->m_strType == "waveObject") { this->initWaveProperty(formInfo, formInfo->m_nDrawType); - } - else if (formInfo->m_strType == "tableObject") - { - if (m_strLineName == "GUJING1_RESULT" || m_strLineName == "GUJING2_RESULT" || m_strLineName == "GUJING3_RESULT") - { - //固井结论 - this->initGujingProperty(formInfo); - } - - } } diff --git a/logPlus/TransparentDraggableGujing.cpp b/logPlus/TransparentDraggableGujing.cpp index f5f949f..bc738d2 100644 --- a/logPlus/TransparentDraggableGujing.cpp +++ b/logPlus/TransparentDraggableGujing.cpp @@ -334,14 +334,8 @@ void TransparentDraggableGujing::onDelRect() deleteRect(); //保存 mPlot->SaveToSLF_Gujing(); -} - -//全部清空 -void TransparentDraggableGujing::onDelAll() -{ - if(QMessageBox::information(NULL,QObject::tr("提示"),QObject::tr("该功能将清除当前组件展示的全部信息,清除后无法恢复,但会备份到对应的\"_BAK\"中,确定清除吗?"),QMessageBox::Yes|QMessageBox::No)!=QMessageBox::Yes) return; - QString obj=mPlot->m_strLineName + "BAK"; - + //属性清空 + PropertyService()->InitCurrentViewInfo(); } //设置深度移动量 @@ -460,7 +454,6 @@ void TransparentDraggableGujing::onMousePress(QMouseEvent *event) menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "分割", this, &TransparentDraggableGujing::onSplitRect); menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除选中对象", this, &TransparentDraggableGujing::onDelRect); menu.addAction(QIcon(::GetImagePath() + "icon/Shift.png"), "设置深度移动量", this, &TransparentDraggableGujing::setItemDepthOffset); - menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &TransparentDraggableGujing::onDelAll); menu.exec(event->globalPos()); return; diff --git a/logPlus/TransparentDraggableGujing.h b/logPlus/TransparentDraggableGujing.h index 12b43df..cea6478 100644 --- a/logPlus/TransparentDraggableGujing.h +++ b/logPlus/TransparentDraggableGujing.h @@ -60,7 +60,6 @@ private: private slots: void onSplitRect(); //分割 void onDelRect(); //删除 - void onDelAll(); //全部清空 void setItemDepthOffset(); //设置深度移动量 void onMousePress(QMouseEvent *event); void onMouseMove(QMouseEvent *event); diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index 8dfd7ea..3eeb0d2 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -4034,7 +4034,7 @@ void FormDraw::initGujing(QMyCustomPlot *widget, QString strSlfName, QString str widget->xAxis2->setTicks(false); widget->yAxis2->setTicks(false); // - LoadFromSLF_Gujing(widget, strSlfName, strLineName); + widget->LoadFromSLF_Gujing(strSlfName, strLineName); QString strAliasName = "固井结论"; QString strUnit = ""; @@ -4045,86 +4045,6 @@ void FormDraw::initGujing(QMyCustomPlot *widget, QString strSlfName, QString str m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject"); } -bool FormDraw::LoadFromSLF_Gujing(QMyCustomPlot *widget, QString strSlfName, QString strLineName) -{ - CMemRdWt *logio=new CMemRdWt(); - if(!logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead)) - { - delete logio; - // QMessageBox::information(NULL,"提示","SLF文件打开失败,请检查!!",QMessageBox::Yes); - return false; - } - - QString configfile=GetConfPath()+GetOilFieldName()+"GujingOrder.ini"; - QStringList lines; - QFile file( configfile ); - if ( file.open( QIODevice::ReadOnly ) ) { - QTextStream stream( &file ); - stream.setCodec("UTF-8"); // 设置UTF-8编码 - QString line; - int n = 1; - while ( !stream.atEnd() ) { - line = stream.readLine(); // 不包括“\n”的一行文本 - lines += line; - } - file.close(); - } - - //QMap zoneOrder; - for(int i=0;izoneOrder_Gujing.insert(lines[i],QString::number(i)); - } - - int iIndex=logio->OpenTable(strLineName.toStdString().c_str()); - if(iIndex>-1) { - int len=logio->GetTableRecordLength(iIndex); - int sl=sizeof(GUJING_DATA); - if(sl>len) len=sl; - GUJING_DATA *m_Result; - m_Result=(GUJING_DATA *)new char[len+1]; - int count=logio->GetTableRecordCount(iIndex); - for(int i=0;iReadTable(iIndex,i+1,m_Result); - - int NO = m_Result->NO; - float SDEP = m_Result->SDEP; - float EDEP = m_Result->EDEP; - int iRESULT = m_Result->RESULT; - QString result = ""; - - // - QString iconshotname=widget->zoneOrder_Gujing.key(QString::number(m_Result->RESULT)); - if(iconshotname!="") - result=::GetGujingSymbolDir()+iconshotname+".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); - - //显示固井 - widget->addGujingToPlot(-EDEP, -SDEP, result); - } - logio->CloseTable(iIndex); - delete m_Result; - } - delete logio; - return true; -} void FormDraw::initDepth(QMyCustomPlot *curv) { diff --git a/logPlus/formdraw.h b/logPlus/formdraw.h index ff913ad..335797c 100644 --- a/logPlus/formdraw.h +++ b/logPlus/formdraw.h @@ -189,7 +189,6 @@ public: //固井结论 void initGujing(QMyCustomPlot *widget, QString strSlfName, QString strLineName); - bool LoadFromSLF_Gujing(QMyCustomPlot *widget, QString strSlfName, QString strLineName); //岩心实验数据 void initCorePhysics(QMyCustomPlot *widget, QString strSlfName, QString strLineName); diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 793dbb7..3d4426b 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -19,6 +19,7 @@ #include "qtcommonclass.h" #include "slf.h" #include "MemRdWt.h" +#include "PropertyWidget.h" //是否隐藏刻度 extern int g_iShow; @@ -883,6 +884,10 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event) QMenu menu(this); //固井 menu.addAction(QIcon(::GetImagePath() + "curve.png"), "开始编辑固井结论", this, &QMyCustomPlot::onEditGujing); + menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Gujing); + menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Gujing); + menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Gujing); + menu.addAction(QIcon(::GetImagePath() + "development.png"), "合并结论", this, &QMyCustomPlot::MegResult_Gujing); menu.exec(event->globalPos()); } @@ -1074,11 +1079,14 @@ void QMyCustomPlot::onEditGujing() { //添加固井结论 - this->addGujingToPlot(left_Low, right_Hight, ::GetGujingSymbolDir());//left_Low, right_Hight + this->addGujingToPlot(left_Low, right_Hight, ::GetGujingSymbolDir()); //保存 this->SaveToSLF_Gujing(); + //属性清空 + PropertyService()->InitCurrentViewInfo(); + //取消框选 this->setInteractions(QCP::iSelectLegend | QCP::iSelectPlottables); this->setSelectionRectMode(QCP::srmNone); @@ -1124,7 +1132,7 @@ bool QMyCustomPlot::SaveToSLF_Gujing() isfirst=true; } logio->SetTableRecordCount(iIndex,m_mapDraggable_Gujing.size()); - int j=0; + //int j=0; if(!m_mapDraggable_Gujing.size()) { delete logio; if(isfirst)AddTableToWellRound(); @@ -1133,22 +1141,45 @@ bool QMyCustomPlot::SaveToSLF_Gujing() } TransparentDraggableGujing *pDraggableRect =NULL; - for (QMap::Iterator iter = m_mapDraggable_Gujing.begin(); iter != m_mapDraggable_Gujing.end(); iter++,j++) + + //排序 + QList listSDepth; + for (QMap::Iterator iter = m_mapDraggable_Gujing.begin(); iter != m_mapDraggable_Gujing.end(); iter++) { pDraggableRect = (TransparentDraggableGujing*)iter.value(); // QCPRange tmpRange = pDraggableRect->getRange(); + // + float fSDepth = -tmpRange.upper; + listSDepth.append(fSDepth); + } + qSort(listSDepth); - memset(&m_Result,0,sizeof(GUJING_DATA)); - m_Result.SDEP = -tmpRange.upper; - m_Result.EDEP = -tmpRange.lower; - m_Result.NO=j+1; - 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,j+1,&m_Result); + // + for(int i=0; i::Iterator iter = m_mapDraggable_Gujing.begin(); iter != m_mapDraggable_Gujing.end(); iter++) + { + pDraggableRect = (TransparentDraggableGujing*)iter.value(); + // + QCPRange tmpRange = pDraggableRect->getRange(); + float fSDepth = -tmpRange.upper; + if(fSDepth == listSDepth[i])//按顺序写入 + { + memset(&m_Result,0,sizeof(GUJING_DATA)); + m_Result.SDEP = -tmpRange.upper; + m_Result.EDEP = -tmpRange.lower; + m_Result.NO=i+1; + 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; @@ -1172,6 +1203,323 @@ void QMyCustomPlot::AddTableToWellRound() emit CallManage::getInstance()->sig_AddGujingToTree(m_strSlfName, m_strWellName, m_strLineName); } +//从剪切板文本数据粘贴 +void QMyCustomPlot::addItems_Gujing() +{ + 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=zoneOrder_Gujing.key(QString::number(iRESULT)); + if(iconshotname!="") + result=::GetGujingSymbolDir()+iconshotname+".svg"; + } + else + { + QStringList vals=zoneOrder_Gujing.keys(); + coredat[3].trimmed(); + int j=vals.indexOf(coredat[3]); + if(j>-1) { + result=::GetGujingSymbolDir()+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); + + //显示固井 + addGujingToPlot(-EDEP, -SDEP, result); + } + //保存 + this->SaveToSLF_Gujing(); + //属性清空 + PropertyService()->InitCurrentViewInfo(); +} + +//全部清空 +void QMyCustomPlot::DeleteItems_Gujing() +{ + 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(); + + //删除对象 + 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(); +} + +//刷新数据 +void QMyCustomPlot::RefreshItems_Gujing() +{ + //删除对象 + TransparentDraggableGujing *pDraggableRect =NULL; + QMap::Iterator it = m_mapDraggable_Gujing.begin(); + while( it != m_mapDraggable_Gujing.end() ) + { + pDraggableRect = (TransparentDraggableGujing*)it.value(); + it++; + pDraggableRect->deleteRect(); + } + + //重新加载 + LoadFromSLF_Gujing(m_strSlfName, m_strLineName); + //属性清空 + PropertyService()->InitCurrentViewInfo(); +} + +//合并结论 +void QMyCustomPlot::MegResult_Gujing() +{ + typedef struct ss_struct{ + int NO; + float SDEP,EDEP; + int RESULT; + } GUJING; + CMemRdWt *MemRdWt=new CMemRdWt(); + if(!MemRdWt->Open(m_strSlfName.toStdString().c_str(),CMemRdWt::modeReadWrite)) { + delete MemRdWt; + return; + } + int itable2=MemRdWt->OpenOG_RESULT(m_strLineName.toStdString().c_str()); + if(itable2<1) { + delete MemRdWt; + return; + } + GUJING *pg1=NULL; + GUJING *pgb=NULL; + int rec1=0; + int j=0; + int jj=0; + + //////////////////////////////////////////// + rec1=MemRdWt->GetTableRecordCount(itable2); + if(rec1<=0) { + QMessageBox::information(NULL,"提示","没有数据,终止运行!"); + return; + } + pg1=new GUJING[rec1]; + pgb=new GUJING[rec1]; + for(j=0;jReadTable(itable2,j+1,&pg1[j]); + } + jj=0; + for(j=0;jSetTableRecordCount(itable2,0); + jj=0; + for(j=0;jWriteTable(itable2,jj+1,&pgb[j]); + jj++; + } + } + + delete pg1; + delete pgb; + delete MemRdWt; + + //刷新数据 + RefreshItems_Gujing(); +} + +//加载固井slf数据 +bool QMyCustomPlot::LoadFromSLF_Gujing(QString strSlfName, QString strLineName) +{ + CMemRdWt *logio=new CMemRdWt(); + if(!logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead)) + { + delete logio; + // QMessageBox::information(NULL,"提示","SLF文件打开失败,请检查!!",QMessageBox::Yes); + return false; + } + + QString configfile=GetConfPath()+GetOilFieldName()+"GujingOrder.ini"; + QStringList lines; + QFile file( configfile ); + if ( file.open( QIODevice::ReadOnly ) ) { + QTextStream stream( &file ); + stream.setCodec("UTF-8"); // 设置UTF-8编码 + QString line; + int n = 1; + while ( !stream.atEnd() ) { + line = stream.readLine(); // 不包括“\n”的一行文本 + lines += line; + } + file.close(); + } + + //QMap zoneOrder; + for(int i=0;iOpenTable(strLineName.toStdString().c_str()); + if(iIndex>-1) { + int len=logio->GetTableRecordLength(iIndex); + int sl=sizeof(GUJING_DATA); + if(sl>len) len=sl; + GUJING_DATA *m_Result; + m_Result=(GUJING_DATA *)new char[len+1]; + int count=logio->GetTableRecordCount(iIndex); + for(int i=0;iReadTable(iIndex,i+1,m_Result); + + int NO = m_Result->NO; + float SDEP = m_Result->SDEP; + float EDEP = m_Result->EDEP; + int iRESULT = m_Result->RESULT; + QString result = ""; + + // + QString iconshotname=zoneOrder_Gujing.key(QString::number(m_Result->RESULT)); + if(iconshotname!="") + result=::GetGujingSymbolDir()+iconshotname+".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); + + //显示固井 + addGujingToPlot(-EDEP, -SDEP, result); + } + logio->CloseTable(iIndex); + delete m_Result; + } + delete logio; + return true; +} + +bool QMyCustomPlot::CopyToSLFFile(QString targetSLFFileName, bool deleteFromSrc, char*newCurveName) +{ + if(m_strSlfName=="") return false; + CLogIO a_cslfio; + CLogIO * logio=new CLogIO(); + if(!logio->Open(targetSLFFileName.toStdString().c_str(),CSlfIO::modeReadWrite)) + { + delete logio; + //AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!"); + return false; + }; + if(!a_cslfio.Open(m_strSlfName.toStdString().c_str(),CSlfIO::modeReadWrite)) + { + //AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!"); + delete logio; + return false; + }; + char* curvename=new char[65]; + curvename[64]='\0'; + strcpy(curvename, m_strLineName.toStdString().c_str()); + if(newCurveName) logio->CopyFromFile(a_cslfio, curvename, newCurveName); + else logio->CopyFromFile(a_cslfio,curvename); + delete[] curvename; + delete logio; +} + void QMyCustomPlot::onAddRect() { double right_Hight = xAxis->pixelToCoord(m_event->pos().y());//x轴展示深度 diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index fb67706..b20c2b2 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -141,7 +141,13 @@ public: QMap zoneOrder_Gujing; bool SaveToSLF_Gujing(); QString GetIntResult_Gujing(QString result); - void AddTableToWellRound();//将固井结论表,添加到左侧树图 + void AddTableToWellRound(); //将固井结论表,添加到左侧树图 + void addItems_Gujing(); //从剪切板文本数据粘贴 + void DeleteItems_Gujing(); //全部删除 + void RefreshItems_Gujing(); //刷新数据 + void MegResult_Gujing(); //合并结论 + bool CopyToSLFFile(QString targetSLFFileName, bool deleteFromSrc, char*newCurveName); + bool LoadFromSLF_Gujing(QString strSlfName, QString strLineName); public slots: void slot_time();