显示图片 属性左边距宽度
This commit is contained in:
parent
e65b5681d9
commit
60ccf0d0ec
|
|
@ -195,18 +195,20 @@ void PropertyWidget::changedYxzpItemProperty(QtProperty *qtProperty, const QVari
|
||||||
{
|
{
|
||||||
if(m_tdImage)
|
if(m_tdImage)
|
||||||
{
|
{
|
||||||
QString pictureFile = qVariant.value<QString>();
|
QString imagePath = qVariant.toString();
|
||||||
qDebug()<<pictureFile<<"-------------";
|
m_tdImage->setResult(imagePath);
|
||||||
// m_tdImage->setLower(-lower);
|
|
||||||
m_tdImage->mPlot->SaveToSLFImage();
|
m_tdImage->mPlot->SaveToSLFImage();
|
||||||
|
m_tdImage->setRange(m_tdImage->getRange().lower, m_tdImage->getRange().upper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if("左边距%" == m_propertyData[qtProperty])
|
else if("左边距%" == m_propertyData[qtProperty])
|
||||||
{
|
{
|
||||||
if(m_tdImage)
|
if(m_tdImage)
|
||||||
{
|
{
|
||||||
// int lower = qVariant.value<int>();
|
// 左边距
|
||||||
// m_tdImage->setLower(-lower);
|
double yxzpLeftMargin = qVariant.toDouble();
|
||||||
|
m_tdImage->setLeft(yxzpLeftMargin);
|
||||||
|
m_tdImage->setRange(m_tdImage->getRange().lower, m_tdImage->getRange().upper,yxzpLeftMargin, m_tdImage->getWidth());
|
||||||
m_tdImage->mPlot->SaveToSLFImage();
|
m_tdImage->mPlot->SaveToSLFImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -214,8 +216,9 @@ void PropertyWidget::changedYxzpItemProperty(QtProperty *qtProperty, const QVari
|
||||||
{
|
{
|
||||||
if(m_tdImage)
|
if(m_tdImage)
|
||||||
{
|
{
|
||||||
// double lower = qVariant.value<double>();
|
double yxzpLineWidth = qVariant.toDouble();
|
||||||
// m_tdImage->setLower(-lower);
|
m_tdImage->setWidth(yxzpLineWidth);
|
||||||
|
m_tdImage->setRange(m_tdImage->getRange().lower, m_tdImage->getRange().upper, m_tdImage->getLeft(), yxzpLineWidth);
|
||||||
m_tdImage->mPlot->SaveToSLFImage();
|
m_tdImage->mPlot->SaveToSLFImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2782,7 +2785,7 @@ void PropertyWidget::initImageProperty(FormInfo *formInfo)
|
||||||
|
|
||||||
m_strCurrentProperty = Image_Property;
|
m_strCurrentProperty = Image_Property;
|
||||||
}
|
}
|
||||||
void PropertyWidget::initImageItemProperty(TransparentDraggableImage* tdImage, double lower, double upper, QString pictureFile)
|
void PropertyWidget::initImageItemProperty(TransparentDraggableImage* tdImage, double lower, double upper, QString pictureFile,double left, double width)
|
||||||
{
|
{
|
||||||
//初始化,清空
|
//初始化,清空
|
||||||
InitCurrentViewInfo();
|
InitCurrentViewInfo();
|
||||||
|
|
@ -2814,9 +2817,9 @@ void PropertyWidget::initImageItemProperty(TransparentDraggableImage* tdImage, d
|
||||||
_CreateVariantPropertyItem("当前项", "绘制颜色", formInfo->m_yxzpDrawColor, QVariant::Bool);
|
_CreateVariantPropertyItem("当前项", "绘制颜色", formInfo->m_yxzpDrawColor, QVariant::Bool);
|
||||||
_CreateVariantPropertyItem("当前项", "顶深(m)", -upper, QVariant::Double);
|
_CreateVariantPropertyItem("当前项", "顶深(m)", -upper, QVariant::Double);
|
||||||
_CreateVariantPropertyItem("当前项", "底深(m)", -lower, QVariant::Double);
|
_CreateVariantPropertyItem("当前项", "底深(m)", -lower, QVariant::Double);
|
||||||
_CreateVariantPropertyItem("当前项", "图片文件", formInfo->m_yxzpPictureFile, VariantManager::filePathTypeId());
|
_CreateVariantPropertyItem("当前项", "图片文件", pictureFile, VariantManager::filePathTypeId());
|
||||||
_CreateVariantPropertyItem("当前项", "左边距%", formInfo->m_yxzpLeftMargin, QVariant::Int);
|
_CreateVariantPropertyItem("当前项", "左边距%", left, QVariant::Int);
|
||||||
_CreateVariantPropertyItem("当前项", "宽度%", formInfo->m_yxzpWidth, QVariant::Int);
|
_CreateVariantPropertyItem("当前项", "宽度%", width, QVariant::Int);
|
||||||
|
|
||||||
_CreateVariantPropertyItem("边框属性", "线宽", formInfo->m_yxzpLineWidth, QVariant::Int);
|
_CreateVariantPropertyItem("边框属性", "线宽", formInfo->m_yxzpLineWidth, QVariant::Int);
|
||||||
_CreateVariantPropertyItem("边框属性", "颜色", formInfo->m_yxzpColor, QVariant::Color);
|
_CreateVariantPropertyItem("边框属性", "颜色", formInfo->m_yxzpColor, QVariant::Color);
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ public:
|
||||||
|
|
||||||
// 岩心照片属性
|
// 岩心照片属性
|
||||||
void initImageProperty(FormInfo *formInfo);
|
void initImageProperty(FormInfo *formInfo);
|
||||||
void initImageItemProperty(TransparentDraggableImage* tdImage, double lower, double upper, QString strResult);
|
void initImageItemProperty(TransparentDraggableImage* tdImage, double lower, double upper, QString strResult, double left, double width);
|
||||||
|
|
||||||
// 井壁取心属性
|
// 井壁取心属性
|
||||||
void initSwallCoreProperty(FormInfo *formInfo);
|
void initSwallCoreProperty(FormInfo *formInfo);
|
||||||
|
|
|
||||||
|
|
@ -3960,7 +3960,7 @@ bool FormDraw::LoadFromIMAGE_SLF(QMyCustomPlot *widget, QString strSlfName, QStr
|
||||||
filename="";
|
filename="";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
widget->addImageToPlot(-m_Result->EndDepth, -m_Result->StartDepth, filename );
|
widget->addImageToPlot(-m_Result->EndDepth, -m_Result->StartDepth, filename, static_cast<double>(m_Result->Left), static_cast<double>(m_Result->Width));
|
||||||
}
|
}
|
||||||
logio->CloseTable(iIndex);
|
logio->CloseTable(iIndex);
|
||||||
delete buf;
|
delete buf;
|
||||||
|
|
|
||||||
|
|
@ -168,11 +168,11 @@ public:
|
||||||
// 图片文件
|
// 图片文件
|
||||||
QString m_yxzpPictureFile;
|
QString m_yxzpPictureFile;
|
||||||
// 左边距
|
// 左边距
|
||||||
QString m_yxzpLeftMargin;
|
double m_yxzpLeftMargin;
|
||||||
// 宽度
|
// 宽度
|
||||||
QString m_yxzpWidth;
|
double m_yxzpWidth;
|
||||||
// 线宽
|
// 线宽
|
||||||
QString m_yxzpLineWidth;
|
int m_yxzpLineWidth;
|
||||||
// 颜色
|
// 颜色
|
||||||
QString m_yxzpColor;
|
QString m_yxzpColor;
|
||||||
// 线型
|
// 线型
|
||||||
|
|
|
||||||
|
|
@ -1726,8 +1726,8 @@ void QMyCustomPlot::onEditImage()
|
||||||
imagePath = dlg.getImagePath();
|
imagePath = dlg.getImagePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加固井结论
|
// 添加岩心图片
|
||||||
this->addImageToPlot(left_Low, right_Hight, imagePath);
|
this->addImageToPlot(left_Low, right_Hight, imagePath, 0, 100);
|
||||||
|
|
||||||
//保存
|
//保存
|
||||||
this->SaveToSLFImage();
|
this->SaveToSLFImage();
|
||||||
|
|
@ -2722,8 +2722,6 @@ bool QMyCustomPlot::SaveToSLFImage()
|
||||||
for (QMap<QString,QObject *>::Iterator iter = m_mapDraggable_Image.begin(); iter != m_mapDraggable_Image.end(); iter++)
|
for (QMap<QString,QObject *>::Iterator iter = m_mapDraggable_Image.begin(); iter != m_mapDraggable_Image.end(); iter++)
|
||||||
{
|
{
|
||||||
pDraggableRect = (TransparentDraggableImage*)iter.value();
|
pDraggableRect = (TransparentDraggableImage*)iter.value();
|
||||||
QString aaa = pDraggableRect->getMResult();
|
|
||||||
//
|
|
||||||
QCPRange tmpRange = pDraggableRect->getRange();
|
QCPRange tmpRange = pDraggableRect->getRange();
|
||||||
float fSDepth = -tmpRange.upper;
|
float fSDepth = -tmpRange.upper;
|
||||||
if(fSDepth == listSDepth[i])//按顺序写入
|
if(fSDepth == listSDepth[i])//按顺序写入
|
||||||
|
|
@ -2732,16 +2730,12 @@ bool QMyCustomPlot::SaveToSLFImage()
|
||||||
m_Result.StartDepth = -tmpRange.upper;
|
m_Result.StartDepth = -tmpRange.upper;
|
||||||
m_Result.EndDepth = -tmpRange.lower;
|
m_Result.EndDepth = -tmpRange.lower;
|
||||||
m_Result.Order=i+1;
|
m_Result.Order=i+1;
|
||||||
// m_Result.Image = imagePath;
|
|
||||||
// 拷贝字符串到数组,长度为数组长度-1(留1位存'\0'结束符)
|
// 拷贝字符串到数组,长度为数组长度-1(留1位存'\0'结束符)
|
||||||
strncpy(m_Result.Image, pDraggableRect->getMResult().toLocal8Bit().constData(), sizeof(m_Result.Image) - 1);
|
strncpy(m_Result.Image, pDraggableRect->getMResult().toLocal8Bit().constData(), sizeof(m_Result.Image) - 1);
|
||||||
// 手动添加结束符(确保字符串合法)
|
// 手动添加结束符(确保字符串合法)
|
||||||
m_Result.Image[sizeof(m_Result.Image) - 1] = '\0';
|
m_Result.Image[sizeof(m_Result.Image) - 1] = '\0';
|
||||||
//m_Result.RESULT=0;
|
m_Result.Left = static_cast<float>(pDraggableRect->getLeft());
|
||||||
//QString innerresult=GetIntResult_Gujing(pDraggableRect->m_Result);
|
m_Result.Width = static_cast<float>(pDraggableRect->getWidth());
|
||||||
// if(innerresult!="")
|
|
||||||
// m_Result.RESULT=innerresult.toInt();
|
|
||||||
// if(m_Result.RESULT<0) m_Result.RESULT=0;
|
|
||||||
//写入
|
//写入
|
||||||
logio->WriteTable(iIndex,i+1,&m_Result);
|
logio->WriteTable(iIndex,i+1,&m_Result);
|
||||||
break;
|
break;
|
||||||
|
|
@ -3980,6 +3974,28 @@ void QMyCustomPlot::addImageToPlot(double left_Low, double right_Hight, const QS
|
||||||
m_mapDraggable_Image[strUuid] = dragRect;
|
m_mapDraggable_Image[strUuid] = dragRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QMyCustomPlot::addImageToPlot(double left_Low, double right_Hight, const QString imagePath, double left, double width)
|
||||||
|
{
|
||||||
|
QtCommonClass *qtCommon = new QtCommonClass(this);
|
||||||
|
QString strUuid = qtCommon->getUUid();
|
||||||
|
|
||||||
|
// 在初始化代码中
|
||||||
|
TransparentDraggableImage *dragRect = new TransparentDraggableImage(this, strUuid);
|
||||||
|
//图片,提前设值,后面setRange改变
|
||||||
|
dragRect->setResult(imagePath);
|
||||||
|
// 设置初始范围
|
||||||
|
dragRect->setRange(left_Low, right_Hight,left,width);
|
||||||
|
// 可选:设置颜色
|
||||||
|
dragRect->setColor(QColor(255, 255, 255, 80)); // 半透明红色
|
||||||
|
//最小宽度
|
||||||
|
dragRect->setMinWidth(0.1);
|
||||||
|
//dragRect->setTitle(strText);
|
||||||
|
dragRect->setLeft(left);
|
||||||
|
dragRect->setWidth(width);
|
||||||
|
|
||||||
|
m_mapDraggable_Image[strUuid] = dragRect;
|
||||||
|
}
|
||||||
|
|
||||||
void QMyCustomPlot::addSelectRectToPlot(double left_Low, double right_Hight, int left_Low_Number, int right_Hight_Number)
|
void QMyCustomPlot::addSelectRectToPlot(double left_Low, double right_Hight, int left_Low_Number, int right_Hight_Number)
|
||||||
{
|
{
|
||||||
//qDebug() << "QMyCustomPlot addSelectRectToPlot";
|
//qDebug() << "QMyCustomPlot addSelectRectToPlot";
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ public:
|
||||||
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; //亚相
|
||||||
QMap<QString, QObject*> m_mapDraggable_Fac; //相
|
QMap<QString, QObject*> m_mapDraggable_Fac; //相
|
||||||
|
|
@ -278,6 +278,7 @@ public:
|
||||||
|
|
||||||
//岩心照片
|
//岩心照片
|
||||||
void addImageToPlot(double left_Low, double right_Hight, const QString imagePath);
|
void addImageToPlot(double left_Low, double right_Hight, const QString imagePath);
|
||||||
|
void addImageToPlot(double left_Low, double right_Hight, const QString imagePath, double left, double width);
|
||||||
|
|
||||||
//曲线
|
//曲线
|
||||||
void addRandomGraph(QVector<double> x, QVector<double> y, QString strSlfName, QString strLineName, QString strAliasName, QString strUnit,
|
void addRandomGraph(QVector<double> x, QVector<double> y, QString strSlfName, QString strLineName, QString strAliasName, QString strUnit,
|
||||||
|
|
|
||||||
|
|
@ -175,8 +175,13 @@ void TransparentDraggableImage::setRange(double left_Low, double right_Hight)
|
||||||
{
|
{
|
||||||
if(left_Low >= right_Hight) return;
|
if(left_Low >= right_Hight) return;
|
||||||
|
|
||||||
double lY1 = mPlot->yAxis->range().lower;//+10
|
double left;
|
||||||
double lY2 = mPlot->yAxis->range().upper;
|
double width;
|
||||||
|
left = (getLeft()/100) * mPlot->yAxis->range().upper;
|
||||||
|
width = (getWidth()/100) * mPlot->yAxis->range().upper;
|
||||||
|
|
||||||
|
double lY1 = mPlot->yAxis->range().lower+left;
|
||||||
|
double lY2 = width+left;
|
||||||
mRect->topLeft->setCoords(left_Low, lY1);
|
mRect->topLeft->setCoords(left_Low, lY1);
|
||||||
mRect->bottomRight->setCoords(right_Hight, lY2);
|
mRect->bottomRight->setCoords(right_Hight, lY2);
|
||||||
|
|
||||||
|
|
@ -198,6 +203,40 @@ void TransparentDraggableImage::setRange(double left_Low, double right_Hight)
|
||||||
mPlot->replot();
|
mPlot->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置矩形范围
|
||||||
|
void TransparentDraggableImage::setRange(double left_Low, double right_Hight,double leftPercentage, double widthPercentage)
|
||||||
|
{
|
||||||
|
if(left_Low >= right_Hight) return;
|
||||||
|
// qDebug() << "left_Low" << left_Low <<
|
||||||
|
// "right_Hight" << right_Hight <<
|
||||||
|
// "marginLeft" << left <<
|
||||||
|
// "graphHeight" << width;
|
||||||
|
// 百分比转换实际距离
|
||||||
|
double left;
|
||||||
|
double width;
|
||||||
|
left = (leftPercentage/100) * mPlot->yAxis->range().upper;
|
||||||
|
width = (widthPercentage/100) * mPlot->yAxis->range().upper;
|
||||||
|
|
||||||
|
double lY1 = mPlot->yAxis->range().lower+left;
|
||||||
|
double lY2 = width+left;
|
||||||
|
mRect->topLeft->setCoords(left_Low, lY1);
|
||||||
|
mRect->bottomRight->setCoords(right_Hight, lY2);
|
||||||
|
|
||||||
|
//位置与rect不一样,否则图像反转
|
||||||
|
mPixmap->topLeft->setCoords(right_Hight, lY1);
|
||||||
|
mPixmap->bottomRight->setCoords(left_Low, lY2);
|
||||||
|
drawResult(left_Low, right_Hight, lY1, 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,
|
||||||
|
(mRect->topLeft->coords().y() + mRect->bottomRight->coords().y())/2); // 设置文本在矩形中心位置
|
||||||
|
|
||||||
|
updateHandles();
|
||||||
|
mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
// 获取当前范围
|
// 获取当前范围
|
||||||
QCPRange TransparentDraggableImage::getRange()
|
QCPRange TransparentDraggableImage::getRange()
|
||||||
{
|
{
|
||||||
|
|
@ -343,7 +382,9 @@ void TransparentDraggableImage::onMousePress(QMouseEvent *event)
|
||||||
// 显示属性
|
// 显示属性
|
||||||
double low = mRect->topLeft->coords().x();
|
double low = mRect->topLeft->coords().x();
|
||||||
double hight = mRect->bottomRight->coords().x();
|
double hight = mRect->bottomRight->coords().x();
|
||||||
PropertyService()->initImageItemProperty(this, low, hight, m_Result);
|
double left = getLeft();
|
||||||
|
double width = getWidth();
|
||||||
|
PropertyService()->initImageItemProperty(this, low, hight, m_Result, left, width);
|
||||||
|
|
||||||
QMenu menu(nullptr);
|
QMenu menu(nullptr);
|
||||||
QAction *delAction = menu.addAction("删除框图");
|
QAction *delAction = menu.addAction("删除框图");
|
||||||
|
|
@ -497,7 +538,9 @@ void TransparentDraggableImage::onMouseRelease(QMouseEvent *event)
|
||||||
// 显示属性
|
// 显示属性
|
||||||
double low = mRect->topLeft->coords().x();
|
double low = mRect->topLeft->coords().x();
|
||||||
double hight = mRect->bottomRight->coords().x();
|
double hight = mRect->bottomRight->coords().x();
|
||||||
PropertyService()->initImageItemProperty(this, low, hight, m_Result);
|
double left = getLeft();
|
||||||
|
double width = getWidth();
|
||||||
|
PropertyService()->initImageItemProperty(this, low, hight, m_Result, left, width);
|
||||||
|
|
||||||
|
|
||||||
//避免二次绘制框图
|
//避免二次绘制框图
|
||||||
|
|
@ -616,3 +659,25 @@ void TransparentDraggableImage::setLower(double lower)
|
||||||
|
|
||||||
setRange(newRange.lower, newRange.upper);
|
setRange(newRange.lower, newRange.upper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransparentDraggableImage::setMMinWidth(double mMinWidth)
|
||||||
|
{
|
||||||
|
this->mMinWidth = mMinWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransparentDraggableImage::setLeft(double left)
|
||||||
|
{
|
||||||
|
this->m_left = left;
|
||||||
|
}
|
||||||
|
double TransparentDraggableImage::getLeft()
|
||||||
|
{
|
||||||
|
return this->m_left;
|
||||||
|
}
|
||||||
|
void TransparentDraggableImage::setWidth(double width)
|
||||||
|
{
|
||||||
|
this->m_width = width;
|
||||||
|
}
|
||||||
|
double TransparentDraggableImage::getWidth()
|
||||||
|
{
|
||||||
|
return this->m_width;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ public:
|
||||||
|
|
||||||
// 设置矩形范围
|
// 设置矩形范围
|
||||||
void setRange(double left_Low, double right_Hight);
|
void setRange(double left_Low, double right_Hight);
|
||||||
|
void setRange(double left_Low, double right_Hight,double left, double width);
|
||||||
// 获取当前范围
|
// 获取当前范围
|
||||||
QCPRange getRange();
|
QCPRange getRange();
|
||||||
QString getMResult();
|
QString getMResult();
|
||||||
|
|
@ -50,6 +51,11 @@ public:
|
||||||
|
|
||||||
void setUpper(double upper);
|
void setUpper(double upper);
|
||||||
void setLower(double lower);
|
void setLower(double lower);
|
||||||
|
void setMMinWidth(double mMinWidth);
|
||||||
|
void setLeft(double left);
|
||||||
|
double getLeft();
|
||||||
|
void setWidth(double width);
|
||||||
|
double getWidth();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void rangeChanged(QCPRange newRange);
|
void rangeChanged(QCPRange newRange);
|
||||||
|
|
@ -86,6 +92,8 @@ private:
|
||||||
|
|
||||||
// 添加最小宽度成员变量
|
// 添加最小宽度成员变量
|
||||||
double mMinWidth;
|
double mMinWidth;
|
||||||
|
// 左边距 宽度 都是百分比
|
||||||
|
double m_left = 0, m_width = 100;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRANSPARENTDRAGGABLEIMAGE_H
|
#endif // TRANSPARENTDRAGGABLEIMAGE_H
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user