Compare commits

..

No commits in common. "0a7170a58f7decfdf072f9b7fa225c9a9c361052" and "309e7c05a9d9ca9de49344395d82637fa63d385e" have entirely different histories.

7 changed files with 35 additions and 161 deletions

View File

@ -226,57 +226,27 @@ void PropertyWidget::changedYxzpItemProperty(QtProperty *qtProperty, const QVari
{ {
if(m_tdImage) if(m_tdImage)
{ {
int borderWidth = qVariant.toInt(); // double lower = qVariant.value<double>();
m_tdImage->setBorderWidth(borderWidth); // m_tdImage->setLower(-lower);
m_tdImage->setRange(m_tdImage->getRange().lower, m_tdImage->getRange().upper); m_tdImage->mPlot->SaveToSLFImage();
} }
} }
else if("颜色" == m_propertyData[qtProperty]) else if("颜色" == m_propertyData[qtProperty])
{ {
if(m_tdImage) if(m_tdImage)
{ {
QColor newColor = qVariant.value<QColor>(); // double lower = qVariant.value<double>();
m_tdImage->setBorderColor(newColor); // m_tdImage->setLower(-lower);
m_tdImage->setRange(m_tdImage->getRange().lower, m_tdImage->getRange().upper); m_tdImage->mPlot->SaveToSLFImage();
} }
} }
else if("线型" == m_propertyData[qtProperty]) else if("线型" == m_propertyData[qtProperty])
{ {
if(m_tdImage) if(m_tdImage)
{ {
Qt::PenStyle newStyle = Qt::SolidLine; // double lower = qVariant.value<double>();
int iStyle = qVariant.value<int>(); // m_tdImage->setLower(-lower);
switch(iStyle) m_tdImage->mPlot->SaveToSLFImage();
{
case 0:
//无
newStyle = Qt::NoPen;
break;
case 1:
//实线
newStyle = Qt::SolidLine;
break;
case 2:
//虚线
newStyle = Qt::DashLine;
break;
case 3:
//点线
newStyle = Qt::DotLine;
break;
case 4:
//虚点线
newStyle = Qt::DashDotLine;
break;
case 5:
//虚点点线
newStyle = Qt::DashDotDotLine;
break;
default:
break;
}
m_tdImage->setBorderStyle(newStyle);
m_tdImage->setRange(m_tdImage->getRange().lower, m_tdImage->getRange().upper);
} }
} }
} }
@ -2852,8 +2822,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)
double left, double width, QColor borderColor, Qt::PenStyle borderStyle, int borderWidth)
{ {
//初始化,清空 //初始化,清空
InitCurrentViewInfo(); InitCurrentViewInfo();
@ -2889,17 +2858,9 @@ void PropertyWidget::initImageItemProperty(TransparentDraggableImage* tdImage, d
_CreateVariantPropertyItem("当前项", "左边距%", left, QVariant::Int); _CreateVariantPropertyItem("当前项", "左边距%", left, QVariant::Int);
_CreateVariantPropertyItem("当前项", "宽度%", width, QVariant::Int); _CreateVariantPropertyItem("当前项", "宽度%", width, QVariant::Int);
_CreateVariantPropertyItem("边框属性", "线宽", borderWidth, QVariant::Int); _CreateVariantPropertyItem("边框属性", "线宽", formInfo->m_yxzpLineWidth, QVariant::Int);
_CreateVariantPropertyItem("边框属性", "颜色", borderColor, QVariant::Color); _CreateVariantPropertyItem("边框属性", "颜色", formInfo->m_yxzpColor, QVariant::Color);
// _CreateVariantPropertyItem("边框属性", "线型", borderStyle, QVariant::String); _CreateVariantPropertyItem("边框属性", "线型", formInfo->m_yxzpLineshape, QVariant::String);
QStringList listStyle;
listStyle.append("");
listStyle.append("实线");
listStyle.append("虚线");
listStyle.append("点线");
listStyle.append("虚点线");
listStyle.append("虚点点线");
_CreateEnumPropertyItem("边框属性", "线型", (int)borderStyle, listStyle);
} }
//当前属性类型 //当前属性类型

View File

@ -80,7 +80,6 @@
class PropertyWidget:public QDockWidget class PropertyWidget:public QDockWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
PropertyWidget(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0); PropertyWidget(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
~PropertyWidget(); ~PropertyWidget();
@ -183,7 +182,7 @@ public:
// 岩心照片属性 // 岩心照片属性
void initImageProperty(FormInfo *formInfo); void initImageProperty(FormInfo *formInfo);
void initImageItemProperty(TransparentDraggableImage* tdImage, double lower, double upper, QString strResult, double left, double width, QColor borderColor, Qt::PenStyle borderStyle, int borderWidth); void initImageItemProperty(TransparentDraggableImage* tdImage, double lower, double upper, QString strResult, double left, double width);
// 井壁取心属性 // 井壁取心属性
void initSwallCoreProperty(FormInfo *formInfo); void initSwallCoreProperty(FormInfo *formInfo);

View File

@ -169,7 +169,18 @@ public:
bool m_yxzpTwoEndDrawing; bool m_yxzpTwoEndDrawing;
// 绘制颜色 // 绘制颜色
bool m_yxzpDrawColor; bool m_yxzpDrawColor;
// 图片文件
QString m_yxzpPictureFile;
// 左边距
double m_yxzpLeftMargin;
// 宽度
double m_yxzpWidth;
// 线宽
int m_yxzpLineWidth;
// 颜色
QString m_yxzpColor;
// 线型
QString m_yxzpLineshape;
//气测/FMT/射孔/文本 //气测/FMT/射孔/文本
QStringList m_FieldNameList; QStringList m_FieldNameList;

View File

@ -4001,33 +4001,7 @@ 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, void QMyCustomPlot::addImageToPlot(double left_Low, double right_Hight, const QString imagePath, double left, double width)
double left, double width)
{
QtCommonClass *qtCommon = new QtCommonClass(this);
QString strUuid = qtCommon->getUUid();
// 在初始化代码中
TransparentDraggableImage *dragRect = new TransparentDraggableImage(this, strUuid);
//图片提前设值后面setRange改变
dragRect->setResult(imagePath);
// 可选:设置颜色
dragRect->setColor(QColor(255, 255, 255, 80)); // 半透明红色
//最小宽度
dragRect->setMinWidth(0.1);
//dragRect->setTitle(strText);
dragRect->setLeft(left);
dragRect->setWidth(width);
// 设置初始范围
dragRect->setRange(left_Low, right_Hight,left,width);
m_mapDraggable_Image[strUuid] = dragRect;
}
void QMyCustomPlot::addImageToPlot(double left_Low, double right_Hight, const QString imagePath,
double left, double width, QColor borderColor, Qt::PenStyle borderStyle, int borderWidth)
{ {
QtCommonClass *qtCommon = new QtCommonClass(this); QtCommonClass *qtCommon = new QtCommonClass(this);
QString strUuid = qtCommon->getUUid(); QString strUuid = qtCommon->getUUid();

View File

@ -291,8 +291,6 @@ 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 addImageToPlot(double left_Low, double right_Hight, const QString imagePath, double left, double width);
// left_Low底, right_Hight高 imagePath图片 left左边距 width宽 mBorderColor边框颜色、 mBorderStyle边框样式 mBorderWidth边框宽
void addImageToPlot(double left_Low, double right_Hight, const QString imagePath, double left, double width, QColor mBorderColor, Qt::PenStyle mBorderStyle, int mBorderWidth);
//曲线 //曲线
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,

View File

@ -199,13 +199,6 @@ void TransparentDraggableImage::setRange(double left_Low, double right_Hight)
//mRect->topLeft->setCoords(left, mPlot->yAxis->range().upper); //mRect->topLeft->setCoords(left, mPlot->yAxis->range().upper);
//mRect->bottomRight->setCoords(right, mPlot->yAxis->range().lower); //mRect->bottomRight->setCoords(right, mPlot->yAxis->range().lower);
if(m_BorderColor == nullptr){
this->m_BorderColor = QColor(0, 0, 0, 200); // 边框颜色
this->m_BorderStyle = Qt::SolidLine; // 边框线型
this->m_BorderWidth = 1; // 边框线宽(像素)
}
// 应用边框样式到主矩形
mRect->setPen(QPen(m_BorderColor, m_BorderWidth, m_BorderStyle));
updateHandles(); updateHandles();
mPlot->replot(); mPlot->replot();
} }
@ -251,7 +244,6 @@ void TransparentDraggableImage::setRange(double left_Low, double right_Hight,dou
mItemTitle->position->setCoords((mRect->topLeft->coords().x() + mRect->bottomRight->coords().x())/2, mItemTitle->position->setCoords((mRect->topLeft->coords().x() + mRect->bottomRight->coords().x())/2,
(mRect->topLeft->coords().y() + mRect->bottomRight->coords().y())/2); // 设置文本在矩形中心位置 (mRect->topLeft->coords().y() + mRect->bottomRight->coords().y())/2); // 设置文本在矩形中心位置
mRect->setPen(QPen(m_BorderColor, m_BorderWidth, m_BorderStyle));
updateHandles(); updateHandles();
mPlot->replot(); mPlot->replot();
} }
@ -313,17 +305,7 @@ void TransparentDraggableImage::initRect()
mRect = new QCPItemRect(mPlot); mRect = new QCPItemRect(mPlot);
mRect->setLayer("overlay"); // 确保在最上层 mRect->setLayer("overlay"); // 确保在最上层
mRect->setBrush(QBrush(QColor(255, 255, 255, 50))); // 半透明蓝色 mRect->setBrush(QBrush(QColor(255, 255, 255, 50))); // 半透明蓝色
// mRect->setPen(QPen(QColor(70, 70, 255, 200))); mRect->setPen(QPen(QColor(70, 70, 255, 200)));
// 左边距 宽度 都是百分比
this->m_left = 0;
this->m_width = 100;
// ========== 新增:边框样式成员变量 ==========
this->m_BorderColor = QColor(0, 0, 0, 200); // 边框颜色
this->m_BorderStyle = Qt::SolidLine; // 边框线型
this->m_BorderWidth = 1; // 边框线宽(像素)
// 应用边框样式到主矩形
mRect->setPen(QPen(this->m_BorderColor, this->m_BorderWidth, this->m_BorderStyle));
// 创建左右边界控制点 // 创建左右边界控制点
mLeftHandle = new QCPItemRect(mPlot); mLeftHandle = new QCPItemRect(mPlot);
@ -414,10 +396,7 @@ void TransparentDraggableImage::onMousePress(QMouseEvent *event)
double hight = mRect->bottomRight->coords().x(); double hight = mRect->bottomRight->coords().x();
double left = getLeft(); double left = getLeft();
double width = getWidth(); double width = getWidth();
QColor borderColor = this->m_BorderColor; // 边框颜色 PropertyService()->initImageItemProperty(this, low, hight, m_Result, left, width);
Qt::PenStyle borderStyle = this->m_BorderStyle; // 边框线型
int borderWidth = this->m_BorderWidth; // 边框线宽(像素)
PropertyService()->initImageItemProperty(this, low, hight, m_Result, left, width,borderColor,borderStyle,borderWidth);
QMenu menu(nullptr); QMenu menu(nullptr);
QAction *delAction = menu.addAction("删除框图"); QAction *delAction = menu.addAction("删除框图");
@ -519,6 +498,7 @@ void TransparentDraggableImage::onMouseMove(QMouseEvent *event)
newRange.upper = getMyUpper(); newRange.upper = getMyUpper();
newRange.lower = newRange.upper - width; newRange.lower = newRange.upper - width;
} }
// QCPRange axisRange = mPlot->xAxis->range(); // QCPRange axisRange = mPlot->xAxis->range();
// if(newRange.lower < axisRange.lower) { // if(newRange.lower < axisRange.lower) {
// newRange.lower = axisRange.lower; // newRange.lower = axisRange.lower;
@ -560,6 +540,7 @@ void TransparentDraggableImage::onMouseMove(QMouseEvent *event)
} }
setRange(newRange.lower, newRange.upper); setRange(newRange.lower, newRange.upper);
} }
void TransparentDraggableImage::onMouseRelease(QMouseEvent *event) void TransparentDraggableImage::onMouseRelease(QMouseEvent *event)
@ -569,12 +550,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();
double left = this->getLeft(); double left = getLeft();
double width = this->getWidth(); double width = getWidth();
QColor borderColor = this->m_BorderColor; // 边框颜色 PropertyService()->initImageItemProperty(this, low, hight, m_Result, left, width);
Qt::PenStyle borderStyle = this->m_BorderStyle; // 边框线型
int borderWidth = this->m_BorderWidth; // 边框线宽(像素)
PropertyService()->initImageItemProperty(this, low, hight, m_Result, left, width, borderColor, borderStyle, borderWidth);
//避免二次绘制框图 //避免二次绘制框图
@ -715,34 +693,3 @@ double TransparentDraggableImage::getWidth()
{ {
return this->m_width; return this->m_width;
} }
// 设置边框颜色
void TransparentDraggableImage::setBorderColor(const QColor &color)
{
this->m_BorderColor = color;
}
// 设置边框线型
void TransparentDraggableImage::setBorderStyle(Qt::PenStyle style)
{
this->m_BorderStyle = style;
}
// 设置边框线宽
void TransparentDraggableImage::setBorderWidth(int width)
{
// 线宽不能小于1像素避免无效值
if (width < 1) width = 1;
this->m_BorderWidth = width;
}
QColor TransparentDraggableImage::geBorderColor()
{
return this->m_BorderColor;
}
Qt::PenStyle TransparentDraggableImage::getBorderStyle()
{
return this->m_BorderStyle;
}
int TransparentDraggableImage::getBorderWidth()
{
return this->m_BorderWidth;
}

View File

@ -58,17 +58,6 @@ public:
void setWidth(double width); void setWidth(double width);
double getWidth(); double getWidth();
// 设置边框颜色
void setBorderColor(const QColor &color);
// 设置边框线型(实线、虚线、点线等)
void setBorderStyle(Qt::PenStyle style);
// 设置边框线宽
void setBorderWidth(int width);
QColor geBorderColor();
Qt::PenStyle getBorderStyle();
int getBorderWidth();
signals: signals:
void rangeChanged(QCPRange newRange); void rangeChanged(QCPRange newRange);
@ -106,11 +95,6 @@ private:
double mMinWidth; double mMinWidth;
// 左边距 宽度 都是百分比 // 左边距 宽度 都是百分比
double m_left = 0, m_width = 100; double m_left = 0, m_width = 100;
// ========== 新增:边框样式成员变量 ==========
QColor m_BorderColor; // 边框颜色
Qt::PenStyle m_BorderStyle; // 边框线型
int m_BorderWidth; // 边框线宽(像素)
}; };
#endif // TRANSPARENTDRAGGABLEIMAGE_H #endif // TRANSPARENTDRAGGABLEIMAGE_H