diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index 6980986..f1db884 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -17,6 +17,7 @@ #include "DrawTvd.h" #include "DepthProgress.h" #include "CallGlobalManage.h" +#include "mainwindowcurve.h" // #include "CylinderImagePlot.h" //以下参数从配置文件读取 @@ -117,6 +118,11 @@ FormDraw::~FormDraw() delete ui; } +void FormDraw::setMainWinCurve(MainWindowCurve* pWin) +{ + m_pMinCurve = pWin; +} + void FormDraw::s_setDrawData(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QStringList listdt) { //井名&道名不一致 @@ -166,7 +172,8 @@ void FormDraw::setDrawData(QStringList listdt, QJsonObject objInfo) { FormWave *pwave = new FormWave(this, strSlfName, strWellName, m_strTrackName, strLineName); pwave->setDepthY(m_iY1, m_iY2); - pwave->initGeometry(m_strUuid, m_iScale, dW, m_nObjDrawH); + pwave->initGeometry(m_strUuid, m_iScale, dW, m_pMinCurve->m_nObjDrawH); + pwave->initBottomDepth(m_pMinCurve->m_dBottomDepth); pwave->m_formTrack = m_formTrack; pwave->m_strObjUuid = pInfo->m_strObjUuid; pwave->show(); @@ -175,7 +182,8 @@ void FormDraw::setDrawData(QStringList listdt, QJsonObject objInfo) { FormImage *pimg = new FormImage(this, strSlfName, strWellName, m_strTrackName, strLineName); pimg->setDepthY(m_iY1, m_iY2); - pimg->initGeometry(m_strUuid, m_iScale, dW, m_nObjDrawH); + pimg->initGeometry(m_strUuid, m_iScale, dW, m_pMinCurve->m_nObjDrawH); + pimg->initBottomDepth(m_pMinCurve->m_dBottomDepth); pimg->m_formTrack = m_formTrack; pimg->show(); } @@ -3644,7 +3652,8 @@ void FormDraw::s_addWave(QString strUuid, QString strSlfName, QString strWellNam FormWave *pwave = new FormWave(this, strSlfName, strWellName, strTrackName, strWaveName); pwave->setDepthY(m_iY1, m_iY2); strObjUuid = pwave->m_strObjUuid; - pwave->initGeometry(m_strUuid, m_iScale, nW, m_nObjDrawH); + pwave->initGeometry(m_strUuid, m_iScale, nW, m_pMinCurve->m_nObjDrawH); + pwave->initBottomDepth(m_pMinCurve->m_dBottomDepth); pwave->m_formTrack = m_formTrack; pwave->show(); //pwave->replot(); @@ -4334,7 +4343,7 @@ void FormDraw::s_addDrawImage(QString strUuid, QString strSlfName, QString strWe { FormImage *pImg = new FormImage(this, strSlfName, strWellName, strTrackName, strLineName); pImg->setDepthY(m_iY1, m_iY2); - pImg->initGeometry(m_strUuid, m_iScale, nW, m_nObjDrawH); + pImg->initGeometry(m_strUuid, m_iScale, nW, m_pMinCurve->m_nObjDrawH); pImg->m_formTrack = m_formTrack; pImg->show(); _nSamples = 264; diff --git a/logPlus/formdraw.h b/logPlus/formdraw.h index 5afbef5..8df7368 100644 --- a/logPlus/formdraw.h +++ b/logPlus/formdraw.h @@ -19,7 +19,7 @@ namespace Ui { class FormDraw; } - +class MainWindowCurve; class FormDraw : public FormBase { Q_OBJECT @@ -28,6 +28,8 @@ public: explicit FormDraw(QWidget *parent, QString strSlfName, QString m_strWellName="", QString strTrackName=""); ~FormDraw(); + void setMainWinCurve(MainWindowCurve* pWin); + void setDrawData(QStringList slist, QJsonObject objInfo); void setDrawPropert(QJsonObject obj); @@ -119,9 +121,9 @@ public slots: void setColWidth(float fNewWidth); public: + MainWindowCurve* m_pMinCurve = NULL; QString m_strTrackName; double m_nTrackW = 0; - int m_nObjDrawH = 0; int m_iScale=200; double m_iY1=0; diff --git a/logPlus/formimage.cpp b/logPlus/formimage.cpp index 332582b..8f3d76f 100644 --- a/logPlus/formimage.cpp +++ b/logPlus/formimage.cpp @@ -73,6 +73,12 @@ void FormImage::updateDepthY(float fy1, float fy2) update(); } +void FormImage::initBottomDepth(double dep) +{ + m_fDepthLowerY = qAbs(dep); + m_fAddY = m_fDepthLowerY - m_fTopY; +} + bool FormImage::LoadFromSLF_wave() { CLogIO * logio = new CLogIO(); diff --git a/logPlus/formimage.h b/logPlus/formimage.h index 6a6b139..23e2ce3 100644 --- a/logPlus/formimage.h +++ b/logPlus/formimage.h @@ -29,6 +29,8 @@ public: void setDepthY(float fy1, float fy2); //改变深度更新绘图 void updateDepthY(float fy1, float fy2); + //初始显示区域底部深度值 + void initBottomDepth(double dep); bool LoadFromSLF_wave(); // 改变色板 diff --git a/logPlus/formwave.cpp b/logPlus/formwave.cpp index 040b429..ba518a8 100644 --- a/logPlus/formwave.cpp +++ b/logPlus/formwave.cpp @@ -92,7 +92,6 @@ void FormWave::setDepthY(float fy1, float fy2) m_PlotSdep = qAbs(this->m_iY2); m_fTopY = m_PlotSdep; - qDebug() << " 111###### m_fTopY " << m_fTopY; } void FormWave::updateDepthY(float fy1, float fy2) @@ -101,7 +100,12 @@ void FormWave::updateDepthY(float fy1, float fy2) this->m_iY2 = fy2; m_fTopY = qAbs(this->m_iY2); update(); - qDebug() << " 222###### m_fTopY " << m_fTopY; +} + +void FormWave::initBottomDepth(double dep) +{ + m_fDepthLowerY = qAbs(dep); + m_fAddY = m_fDepthLowerY - m_fTopY; } bool FormWave::LoadFromSLF_wave() @@ -376,7 +380,6 @@ void FormWave::vertScrollBarChanged(QString strUuid, double value, double low, d return; } m_fTopY = value; - qDebug() << " 333###### m_fTopY " << m_fTopY; update(); } @@ -407,7 +410,6 @@ void FormWave::vertScrollBarChanged_setGeometry(QString strUuid, double value, d return; } m_fTopY = ddepth; - qDebug() << " 444###### m_fTopY " << m_fTopY; update(); } @@ -497,7 +499,7 @@ void FormWave::DrawWave(QPainter* pdc, QRectF mrt1) flDepthScale = 1; float te00 = 0; - qDebug() << "FormWave : m_fTopY " << m_fTopY; + //qDebug() << "FormWave : m_fTopY " << m_fTopY; // 计算显示深度 float sdepc = m_fTopY, edepc = m_fTopY + m_fAddY; QRectF rt;// = mrt1; diff --git a/logPlus/formwave.h b/logPlus/formwave.h index 6db14b1..385dad9 100644 --- a/logPlus/formwave.h +++ b/logPlus/formwave.h @@ -29,6 +29,8 @@ public: void setDepthY(float fy1, float fy2); //改变深度更新绘图 void updateDepthY(float fy1, float fy2); + //初始显示区域底部深度值 + void initBottomDepth(double dep); bool LoadFromSLF_wave(); bool SaveToSLF_LogMud(); @@ -91,7 +93,7 @@ public: int PickFlag = 0; float m_fTopY = 0.0f; float m_fDepthLowerY = 0.0f; - float m_fAddY = 29.0f; + float m_fAddY = 19.0f; int schemIndex = 1; int colornum = 256; diff --git a/logPlus/formwell.cpp b/logPlus/formwell.cpp index 6152c17..0f7e620 100644 --- a/logPlus/formwell.cpp +++ b/logPlus/formwell.cpp @@ -30,7 +30,8 @@ FormWell::FormWell(QWidget *parent, QString strWellName) : ui(new Ui::FormWell) { ui->setupUi(this); - m_parent = parent; + + m_pMainWinCurve = (MainWindowCurve *)parent; m_strWellName = strWellName; m_cuProperty.m_nInv = 10; @@ -296,6 +297,7 @@ QVector FormWell::new_track(QStringList listdt, QString strTrackName) //曲线绘制栏 FormDraw *formDraw = new FormDraw(this, strSlfName, strWellName, strTrackName); + formDraw->setMainWinCurve(m_pMainWinCurve); formDraw->setBorderFlags(BorderFlags(BottomBorder | RightBorder)); vec << formDraw; // @@ -309,7 +311,6 @@ QVector FormWell::new_track(QStringList listdt, QString strTrackName) formDraw->m_formTrack = formTrack; formDraw->m_iScale = m_iScale; formDraw->m_nTrackW = dW; - formDraw->m_nObjDrawH = m_nObjDrawH; //多井的打开工程,使用模板的井名和slf名 formDraw->m_bMultiProject = m_bMultiProject; @@ -772,8 +773,7 @@ void FormWell::setWellProperty(QVariantList listVal) ui->tableWidget->hideRow(0); ui->tableWidget->update(); } - MainWindowCurve *parent = (MainWindowCurve *)m_parent; - parent->SetScrollBar_Geometry(); + m_pMainWinCurve->SetScrollBar_Geometry(); } return; } @@ -1094,10 +1094,7 @@ void FormWell::resizeWindow() ui->tableWidget->setGeometry(0, 2, tempWidth, tempHight); } -// m_parent = parent; - - MainWindowCurve *parent = (MainWindowCurve *)m_parent; - parent->resizeItem(m_strWellName, tempWidth, tempHight); + m_pMainWinCurve->resizeItem(m_strWellName, tempWidth, tempHight); } //获取头2行的宽高,方便输出图 @@ -1356,9 +1353,8 @@ void FormWell::onSectionResized(int logicalIndex, int oldSize, int newSize) { if(newSize!=0) { - MainWindowCurve *parent = (MainWindowCurve *)m_parent; - parent->SetScrollBar_Geometry(); - parent->vertScrollBarChanged_Head(0); + m_pMainWinCurve->SetScrollBar_Geometry(); + m_pMainWinCurve->vertScrollBarChanged_Head(0); } } } diff --git a/logPlus/formwell.h b/logPlus/formwell.h index 20380d2..45eba18 100644 --- a/logPlus/formwell.h +++ b/logPlus/formwell.h @@ -13,6 +13,7 @@ namespace Ui { class FormWell; } class WellHeader; +class MainWindowCurve; class FormWell : public QWidget { Q_OBJECT @@ -64,7 +65,7 @@ public: int m_iScale=200; double m_iY1=0; double m_iY2=0; - QWidget *m_parent; + MainWindowCurve *m_pMainWinCurve = NULL; bool m_bShowTrackHead = true; //显示道头 bool m_bMultiProject = false; //多井的打开工程,使用模板的井名和slf名 diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index 860fd9a..91064bf 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -451,50 +451,17 @@ MainWindowCurve::~MainWindowCurve() void MainWindowCurve::resizeEvent(QResizeEvent *event) { - int nhei = 0; - Qt::ToolBarArea area = this->toolBarArea(ui->mainToolBar); - if (area == Qt::BottomToolBarArea || area == Qt::TopToolBarArea) - { - nhei = ui->mainToolBar->height(); - if (ui->centralwidget->layout()) - { - int left, top, right, bottom; - ui->centralwidget->layout()->getContentsMargins(&left, &top, &right, &bottom); - nhei += top; - nhei += bottom; - } - } - QSize sz = event->size(); - m_nObjDrawH = sz.height() - nhei - m_nObjLayerH - 100 - 100; - // nhei mainToolBar的高度 m_nObjLyrH,对象单元格高度 100头高度,100井头高度 int che = ui->centralwidget->height(); - emit CallManage::getInstance()->sig_ResizeHeight(m_strUuid, che); + m_dBottomDepth = this->getVisibleBottomDepth(); + emit CallManage::getInstance()->sig_ResizeDepth(m_strUuid, m_nObjDrawH, m_dBottomDepth); emit sig_resizeWindow(); //2个滚动条位置 SetScrollBar_Geometry(); - QRect rect2 = ui->centralwidget->geometry(); - int left, top, right, bottom; - if (ui->centralwidget->layout()) - { - ui->centralwidget->layout()->getContentsMargins(&left, &top, &right, &bottom); - } - //获取井well前2行的高度 - int iTableSize_Head = 100 + m_nObjLayerH; -// int iTableSize_Head = 0; -// getTableSize_Head(iTableSize_Head); - int iTableWellTrack_height = ui->tableWidget_2->rowHeight(0) + (5) + iTableSize_Head -1; + //可视区域高度 - int iScreenHeight = 0; - //锁头 - if(m_fixwellsectionHeaderAc->isChecked()) - { - iScreenHeight = (double)(rect2.height()-10- top -bottom - iTableWellTrack_height)/g_dPixelPerCm * m_iScale; - } - else{ - iScreenHeight = (double)(rect2.height()-10- top -bottom - 4)/g_dPixelPerCm * m_iScale; - } + int iScreenHeight = this->getScreenHeight(); //下方滚动条高度 int iHScrollBarHeight = 0; if(!ui->tableWidget_2->horizontalScrollBar()->isVisible()) @@ -728,9 +695,57 @@ void MainWindowCurve::vertScrollBarChanged(int iValue) //通知界面重设范围(三图一表) emit CallManage::getInstance()->sig_vertScrollBarChanged_santuyibiao(m_strUuid, value, -m_iY1, -m_iY2); + double dv = getVisibleBottomDepth(); + qDebug() << "dv " << dv; //AppendConsole(PAI_INFO, "鼠标滚动结束"); } +// 获取 centralwidget 可视区域顶部深度(米) +// 原理:滚动条值 value = -(当前顶部深度), 即 topDepth = -value +double MainWindowCurve::getVisibleTopDepth() const +{ + double value = (double)ui->verticalScrollBar->value() / 100.0; + return -value; // 顶部深度(浅端,较小值) +} + +// 获取 centralwidget 可视区域底部深度(米) +// 原理:bottomDepth = topDepth + 可视高度(深度单位) +double MainWindowCurve::getVisibleBottomDepth() +{ + double value = (double)ui->verticalScrollBar->value() / 100.0; + double topDepth = -value; + + int iScreenHeight = getScreenHeight(); + // iScreenHeight 单位是 0.01m,除以100转为米 + double visibleDepthRange = (double)iScreenHeight / 100.0; + return topDepth - visibleDepthRange; +} + +int MainWindowCurve::getScreenHeight() +{ + // 计算可视区域对应的深度范围(与 vertScrollBarChanged 保持一致) + QRect rect2 = ui->centralwidget->geometry(); + int left = 0, top = 0, right = 0, bottom = 0; + if (ui->centralwidget->layout()) + ui->centralwidget->layout()->getContentsMargins(&left, &top, &right, &bottom); + + + int iScreenHeight = 0; + if (m_fixwellsectionHeaderAc->isChecked()) + { + int iTableSize_Head = 100 + m_nObjLayerH; + int iTableWellTrack_height = ui->tableWidget_2->rowHeight(0) + 5 + iTableSize_Head - 1; + m_nObjDrawH = rect2.height() - 10 - top - bottom - iTableWellTrack_height; + iScreenHeight = (double)(m_nObjDrawH) / g_dPixelPerCm * m_iScale; + } + else + { + m_nObjDrawH = rect2.height() - 10 - top - bottom - 4; + iScreenHeight = (double)(m_nObjDrawH) / g_dPixelPerCm * m_iScale; + } + return iScreenHeight; +} + //初始化工具栏 void MainWindowCurve::initMainToolBar() { @@ -4763,7 +4778,7 @@ void MainWindowCurve::s_NewWell(QString strWellName, QString strSlfName, bool bS //此处还没有生成well,所以不能这样获取 //getTableSize_Head(iTableSize_Head); // - ui->tableWidget_2->setRowHeight(i, (int)iHeightOfScreen+iTableSize_Head+(3+1)+10); + ui->tableWidget_2->setRowHeight(i, (int)iHeightOfScreen+iTableSize_Head+(3+1)+10-400); // FormWell *widgetWell = new FormWell(this, strWellName); widgetWell->setBorderFlags(BorderFlags(BottomBorder | LeftBorder | RightBorder)); diff --git a/logPlus/mainwindowcurve.h b/logPlus/mainwindowcurve.h index f10a696..c41ec61 100644 --- a/logPlus/mainwindowcurve.h +++ b/logPlus/mainwindowcurve.h @@ -52,6 +52,11 @@ public: void getTableSize_Head(int &iHight); void getTableSize_Head_Biggest(int &iHight, int &iHight1, int &iHight2);//展开FormIndo后,获取真正的高度最大值 void setTableSize_Well(); + // 获取 centralwidget 可视区域顶部/底部深度(米) + double getVisibleTopDepth() const; + double getVisibleBottomDepth(); + // 获取绘图区域显示厘米 + int getScreenHeight(); //隐藏道头/对象头 void HideTableHead(); void ShowTableHead(); @@ -109,6 +114,7 @@ public: QLineEdit *spinbox2; QLineEdit *spinbox3; + double m_dBottomDepth = 0.0; // 绘制区域底部深度 int m_nObjDrawH = 0; // 绘制层高度 int m_nObjLayerH = 104; // 对象层高度 int m_iScale=200; diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 9f9cd17..2e308fb 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -146,7 +146,7 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel connect(CallManage::getInstance(), SIGNAL(sig_vertScrollBarChanged(QString, double, double, double)), this, SLOT(vertScrollBarChanged(QString, double, double, double))); connect(CallManage::getInstance(), SIGNAL(sig_vertScrollBarChanged_setGeometry(QString, double, double, double, double)), this, SLOT(vertScrollBarChanged_setGeometry(QString, double, double, double, double))); - connect(CallManage::getInstance(), SIGNAL(sig_ResizeHeight(QString, int)), this, SLOT(s_ResizeHeight(QString, int))); + //connect(CallManage::getInstance(), SIGNAL(sig_ResizeHeight(QString, int)), this, SLOT(s_ResizeHeight(QString, int))); //曲线选中,置顶 connect(CallManage::getInstance(), SIGNAL(sig_Raise(QString, QString, QString, QString, QString, int, QString)), this, SLOT(s_Raise(QString, QString, QString, QString, QString, int, QString))); @@ -12326,18 +12326,18 @@ float QMyCustomPlot::visibleBottomDepth() const return (float)yAxis->pixelToCoord(pixBottom); } -void QMyCustomPlot::s_ResizeHeight(QString strUuid, int nPixVal) -{ - if (m_strUuid == strUuid) - { - if (m_bX2Y) - m_fBottomY = xAxis->pixelToCoord(nPixVal); - else - m_fBottomY = yAxis->pixelToCoord(nPixVal); - - emit CallManage::getInstance()->sig_ResizeDepth(m_strUuid, nPixVal, m_fBottomY); - } -} +//void QMyCustomPlot::s_ResizeHeight(QString strUuid, int nPixVal) +//{ +// if (m_strUuid == strUuid) +// { +// if (m_bX2Y) +// m_fBottomY = xAxis->pixelToCoord(nPixVal); +// else +// m_fBottomY = yAxis->pixelToCoord(nPixVal); +// +// emit CallManage::getInstance()->sig_ResizeDepth(m_strUuid, nPixVal, m_fBottomY); +// } +//} //自定义滚动条 void QMyCustomPlot::vertScrollBarChanged(QString strUuid, double value, double low, double upper) diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index cae0bbb..f085436 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -398,7 +398,7 @@ public slots: void vertScrollBarChanged(QString strUuid, double value, double low, double upper); void vertScrollBarChanged_setGeometry(QString strUuid, double value, double low, double upper, double ddepth); - void s_ResizeHeight(QString strUuid, int nPixVal); + //void s_ResizeHeight(QString strUuid, int nPixVal); //信号槽刷新 void slot_replot();