黑白图,通过共享内存控制svg图形颜色

This commit is contained in:
jiayulong 2026-05-21 14:01:46 +08:00
parent c7adedde28
commit 0e9fdeab6e
4 changed files with 110 additions and 14 deletions

View File

@ -15,6 +15,7 @@
#include <QDebug> #include <QDebug>
#include "customtabbar.h" #include "customtabbar.h"
#include "PropertyWidget.h" #include "PropertyWidget.h"
#include "mainwindowsplitter.h"
CustomTabWidget::CustomTabWidget(QWidget *parent) CustomTabWidget::CustomTabWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
@ -141,6 +142,17 @@ void CustomTabWidget::setCurrentIndex(int index)
//属性清空 //属性清空
PropertyService()->InitCurrentViewInfo(); PropertyService()->InitCurrentViewInfo();
QWidget *selectWidget = tabWidget(index);
if (selectWidget == NULL)
return;
QString objectName = selectWidget->objectName();
if(objectName == "MainWindowSplitter")
{
MainWindowSplitter *tmpWindow = (MainWindowSplitter*)selectWidget;
tmpWindow->getMainWindowCurve()->SetNo();
}
} }
void CustomTabWidget::setAutoDelete(bool bAuto) void CustomTabWidget::setAutoDelete(bool bAuto)

View File

@ -207,10 +207,51 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
// m_propertyWidget->setWindowTitle("属性编辑器"); // m_propertyWidget->setWindowTitle("属性编辑器");
// m_propertyWidget->setParent(this); // m_propertyWidget->setParent(this);
// addDockWidget( Qt::TopDockWidgetArea, m_propertyWidget); // addDockWidget( Qt::TopDockWidgetArea, m_propertyWidget);
//黑白图,针对共享内存,使用老版本代码,需要以下定义
mNo=rand();
zoomRatio=1.0;
zoomXRatio=1.0;
zoomYRatio=1.0;
m_isColorPrint=1;
m_isPrint=false;
m_isBMP=0;
//
m_SharedMemory.setKey("SharedName");
m_SharedMemory.attach();
if(!m_SharedMemory.isAttached()) {
m_SharedMemory.create(sizeof(int));
m_SharedMemory.attach();
}
int *isNo=(int*)m_SharedMemory.data();
*isNo=mNo;
QString cs=QString::number(*isNo)+"isScaleAndColor";
m_isScale.setKey(cs);
m_isScale.create(5*sizeof(float));
m_isScale.attach();
float *isScale=(float*)m_isScale.data();
isScale[0]=zoomXRatio*zoomRatio;
isScale[1]=zoomYRatio*zoomRatio;
isScale[2]=m_isColorPrint;
isScale[3]=m_isPrint;
isScale[4]=m_isBMP;
} }
void MainWindowCurve::SetNo()
{
if(m_SharedMemory.isAttached()) {
int *isNo=(int*)m_SharedMemory.data();
*isNo=mNo;
}
}
MainWindowCurve::~MainWindowCurve() MainWindowCurve::~MainWindowCurve()
{ {
if(m_SharedMemory.isAttached()){
int *isNo=(int*)m_SharedMemory.data();
m_SharedMemory.detach();
}
if(m_isScale.isAttached()) m_isScale.detach();
delete ui; delete ui;
} }
@ -2630,6 +2671,19 @@ void MainWindowCurve::s_Save()
} }
} }
bool MainWindowCurve::GetIsColorPrint()
{
return m_isColorPrint;
}
void MainWindowCurve::SetIsColorPrint(bool iscolorprint)
{
m_isColorPrint=iscolorprint;
if(!m_isScale.isAttached()) return;
float *isScale=(float*)m_isScale.data();
isScale[2]=m_isColorPrint;
}
//黑白图 //黑白图
void MainWindowCurve::s_Black() void MainWindowCurve::s_Black()
{ {
@ -2639,6 +2693,10 @@ void MainWindowCurve::s_Black()
{ {
bBlack = true; bBlack = true;
} }
//
SetNo();//切换共享内存编号到当前页面
SetIsColorPrint(!bBlack);
emit CallManage::getInstance()->sig_changeBlack(m_strUuid, bBlack); emit CallManage::getInstance()->sig_changeBlack(m_strUuid, bBlack);
} }

View File

@ -58,6 +58,7 @@ public slots:
//自定义滚动条 //自定义滚动条
void vertScrollBarChanged(int value); void vertScrollBarChanged(int value);
public: public:
MainWindowSplitter* m_pParentWin = NULL; MainWindowSplitter* m_pParentWin = NULL;
@ -95,6 +96,24 @@ public:
int m_iCurPage = 1;//当前页 int m_iCurPage = 1;//当前页
//图像自滚定时器 //图像自滚定时器
QTimer *m_clockTimer = nullptr; QTimer *m_clockTimer = nullptr;
public:
//黑白图,针对共享内存,使用老版本代码,需要以下定义
//整图放大缩小比例
double zoomRatio;
double zoomXRatio;
double zoomYRatio;
QSharedMemory m_isScale;
QSharedMemory m_SharedMemory;
int mNo;
bool m_isColorPrint;
bool m_isPrint;
bool m_isBMP;
void SetIsColorPrint(bool iscolorprint);
bool GetIsColorPrint();
void SetNo();
public: public:
//展示所有井 //展示所有井
void DisplayWells(QJsonArray wellsArray); void DisplayWells(QJsonArray wellsArray);

View File

@ -1921,7 +1921,7 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_SWallCore); menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_SWallCore);
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems); menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_SWallCore); menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_SWallCore);
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_SWallCore); menu.addAction(QIcon(::GetImagePath() + "icon/load.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_SWallCore);
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
else if (m_strLineName == "GEO_LITH") else if (m_strLineName == "GEO_LITH")
@ -1938,7 +1938,7 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_GeoLith); menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_GeoLith);
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems); menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_GeoLith); menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_GeoLith);
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_GeoLith); menu.addAction(QIcon(::GetImagePath() + "icon/load.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_GeoLith);
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
else if (m_strLineName == "WORDS_RELUST") else if (m_strLineName == "WORDS_RELUST")
@ -1955,7 +1955,7 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Text); menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Text);
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems); menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Text); menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Text);
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Text); menu.addAction(QIcon(::GetImagePath() + "icon/load.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Text);
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
else if (m_strLineName == "LAYER_DATA") else if (m_strLineName == "LAYER_DATA")
@ -1972,7 +1972,7 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Layer); menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Layer);
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems); menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Layer); menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Layer);
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Layer); menu.addAction(QIcon(::GetImagePath() + "icon/load.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Layer);
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
else if (m_strLineName == "RESULT") // 解释结论 else if (m_strLineName == "RESULT") // 解释结论
@ -1991,7 +1991,7 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems); menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除选中对象", this, &QMyCustomPlot::DeleteItemGroup); menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除选中对象", this, &QMyCustomPlot::DeleteItemGroup);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Layer); menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Layer);
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Layer); menu.addAction(QIcon(::GetImagePath() + "icon/load.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Layer);
menu.addAction(QIcon(::GetImagePath() + "icon/SetZone.png"), "更新层号", this, &QMyCustomPlot::updateGroupZone); menu.addAction(QIcon(::GetImagePath() + "icon/SetZone.png"), "更新层号", this, &QMyCustomPlot::updateGroupZone);
menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "分割为层内层", this, &QMyCustomPlot::segmentationInnerLayer); menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "分割为层内层", this, &QMyCustomPlot::segmentationInnerLayer);
@ -2021,7 +2021,7 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "设置深度移动量", this, &QMyCustomPlot::setImageDepth); menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "设置深度移动量", this, &QMyCustomPlot::setImageDepth);
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "删除选中对象", this, &QMyCustomPlot::deleteItemsImage); menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "删除选中对象", this, &QMyCustomPlot::deleteItemsImage);
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems); menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::refreshItemsImage); menu.addAction(QIcon(::GetImagePath() + "icon/load.png"), "刷新数据", this, &QMyCustomPlot::refreshItemsImage);
} }
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
@ -2033,7 +2033,7 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::pasteCorePhysics); menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::pasteCorePhysics);
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems); menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::deleteCorePhysics); menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::deleteCorePhysics);
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::refreshCorePhysics); menu.addAction(QIcon(::GetImagePath() + "icon/load.png"), "刷新数据", this, &QMyCustomPlot::refreshCorePhysics);
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
@ -2055,7 +2055,7 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Jiegutext); menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Jiegutext);
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems); menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Jiegutext); menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Jiegutext);
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Jiegutext); menu.addAction(QIcon(::GetImagePath() + "icon/load.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Jiegutext);
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
else if (m_strType == "gujingObject") else if (m_strType == "gujingObject")
@ -2072,7 +2072,7 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Gujing); menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Gujing);
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems); menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_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() + "icon/load.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Gujing);
menu.addAction(QIcon(::GetImagePath() + "development.png"), "合并结论", this, &QMyCustomPlot::MegResult_Gujing); menu.addAction(QIcon(::GetImagePath() + "development.png"), "合并结论", this, &QMyCustomPlot::MegResult_Gujing);
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
@ -2105,7 +2105,7 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Tubing); menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Tubing);
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems); menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Tubing); menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Tubing);
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Tubing); menu.addAction(QIcon(::GetImagePath() + "icon/load.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Tubing);
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
@ -14247,8 +14247,6 @@ void QMyCustomPlot::s_changeBlack(QString strUuid, bool bBlack)
QPen pen = graph->pen(); QPen pen = graph->pen();
pen.setColor(QColor(0,0,0)); pen.setColor(QColor(0,0,0));
graph->setPen(pen); graph->setPen(pen);
//
replot();
} }
} }
else { else {
@ -14260,8 +14258,17 @@ void QMyCustomPlot::s_changeBlack(QString strUuid, bool bBlack)
QPen pen = graph->pen(); QPen pen = graph->pen();
pen.setColor(pInfo->m_lineColor); pen.setColor(pInfo->m_lineColor);
graph->setPen(pen); graph->setPen(pen);
//
replot();
} }
} }
//固井结论
resetPosition_Gujing();
//井壁取心
resetPosition_SwallCore();
//录井剖面
resetPosition_GeoLith();
//地质层位
resetPosition_Layer();
//
replot();
} }