1、实现选择井时,直接给出哪些井已经被选中了;

feature/ribbon-menu-20240927
simonyan 3 weeks ago
parent 64a9d89ce1
commit 5adffb3c20

@ -6,6 +6,8 @@
#include <QPointF> #include <QPointF>
class nmObjBase; class nmObjBase;
class nmObjPointWell;
class ZxDataWell;
// 数值试井绘图载体的样例 // 数值试井绘图载体的样例
class NM_PLOT_EXPORT nmGuiPlot : public iGuiPlot class NM_PLOT_EXPORT nmGuiPlot : public iGuiPlot
@ -94,6 +96,12 @@ public:
QVector<QPointF> getOutlinePoints(); QVector<QPointF> getOutlinePoints();
// 获取所有井的信息,包括点和半径 // 获取所有井的信息,包括点和半径
QVector<QVector<double>> getWellsInformation(); QVector<QVector<double>> getWellsInformation();
// 获取所有井的图元
QVector<nmObjPointWell*> getWellPlots();
// 获取所有井的数据指针
QVector<ZxDataWell*> getWellDatas();
// 获取所有井的名称
QStringList getWellNames();
protected: protected:
// 绘制Painter函数重载 // 绘制Painter函数重载

@ -73,6 +73,7 @@ public:
QVector<double> getWellInformation(); QVector<double> getWellInformation();
const QString &getWellID() const; const QString &getWellID() const;
ZxDataWell *getWellData() const; ZxDataWell *getWellData() const;
private: private:
// 存储井的IDproject数据结构里数据存储 // 存储井的IDproject数据结构里数据存储
// 如果是选择井,则坐标等信息不能修改 // 如果是选择井,则坐标等信息不能修改

@ -40,14 +40,21 @@ class NM_SUB_WXS_EXPORT nmWxSelectWellsWidget : public QWidget
public: public:
nmWxSelectWellsWidget(QWidget* aParent = NULL); nmWxSelectWellsWidget(QWidget* aParent = NULL);
public: public:
// 添加多项
void addItems(QStringList items, QList<QVariant> values); void addItems(QStringList items, QList<QVariant> values);
// 添加单项
void addItem(QString name, QVariant value); void addItem(QString name, QVariant value);
// 获取选中的items
QStringList getItems(); QStringList getItems();
// 设置被选中的items
void setSelectedItems(QStringList selectItems);
private: private:
QListWidget* m_pListWidget; QListWidget* m_pListWidget;
QTextEdit* m_pLineEdit; QTextEdit* m_pLineEdit;
QStringList m_items; QStringList m_items;
QList<QVariant> m_values; QList<QVariant> m_values;
// 已经被选中的items
QStringList m_selectItems;
private slots: private slots:
void onUpdateSelections(); void onUpdateSelections();

@ -304,6 +304,42 @@ QVector<QVector<double>> nmGuiPlot::getWellsInformation()
return wellsList; return wellsList;
} }
QVector<nmObjPointWell *> nmGuiPlot::getWellPlots()
{
QVector<ZxObjBase*> objList = this->getObjsByTag("nObjPointWell");
QVector<nmObjPointWell*> wellPlots;
if (objList.count() > 0) {
for (int i = 0; i < objList.count() ; i++ ) {
wellPlots.append((nmObjPointWell*) objList[i]);
}
}
return wellPlots;
}
QVector<ZxDataWell *> nmGuiPlot::getWellDatas()
{
QVector<ZxObjBase*> objList = this->getObjsByTag("nObjPointWell");
QVector<ZxDataWell*> wellDatas;
if (objList.count() > 0) {
for (int i = 0; i < objList.count() ; i++ ) {
wellDatas.append(((nmObjPointWell*) objList[i])->getWellData());
}
}
return wellDatas;
}
QStringList nmGuiPlot::getWellNames()
{
QVector<ZxObjBase*> objList = this->getObjsByTag("nObjPointWell");
QStringList wellNames;
if (objList.count() > 0) {
for (int i = 0; i < objList.count() ; i++ ) {
wellNames.append(((nmObjPointWell*) objList[i])->getWellData()->getName());
}
}
return wellNames;
}
void nmGuiPlot::paintEvent(QPaintEvent* e) void nmGuiPlot::paintEvent(QPaintEvent* e)
{ {
iGuiPlot::paintEvent(e); iGuiPlot::paintEvent(e);

@ -631,11 +631,35 @@ void nmSubWndMain::updateSelectedWells(QList<ZxDataWell *> wellObjList)
if (wellObjList.count() == 0) { if (wellObjList.count() == 0) {
return; return;
} }
// TODO 1如果已经画在油藏地图上了则不需要添加 // setp 1获取现在画布上所有的井信息
// TODO 2如何不在需要添加 QVector<nmObjPointWell*> pWellPlotList = m_pWxPlot->getWellPlots();
// TODO 3如果以前在现在不在需要删除 QMap<ZxDataWell*, nmObjPointWell*> pWellDataToPlotMap;
for (int i = 0; i < wellObjList.count(); i++ ) { // setp 2在图元里不在wellObjList里是要删除的图元
ZxDataWell* wellObj = wellObjList[i]; QVector<nmObjPointWell*> vDeleteWellPlotList;
for (int i = 0; i < pWellPlotList.count(); i++) {
ZxDataWell *pWellData = pWellPlotList[i]->getWellData();
pWellDataToPlotMap.insert(pWellData, pWellPlotList[i]);
if (!wellObjList.contains(pWellData)) {
vDeleteWellPlotList.append(pWellPlotList[i]);
}
}
// TODO 3在wellObjList 不在 图元pWellPlotDataList里 需要添加
QList<ZxDataWell*> pWellPlotDataList = pWellDataToPlotMap.keys();
QVector<ZxDataWell*> vAddWellPlotList;
for (int i = 0; i < wellObjList.count() ; i++ ) {
ZxDataWell *pWellData = wellObjList[i];
if (!pWellPlotDataList.contains(pWellData)) {
vAddWellPlotList.append(pWellData);
}
}
// setp 4将vDeleteWellPlotList中的图元删除
for (int i = 0; i < vDeleteWellPlotList.count() ; i++ ) {
nmObjPointWell* pWellPlot = vDeleteWellPlotList[i];
m_pWxPlot->m_pPlot->removeObjByName(pWellPlot->getName());
}
// setp 5将vAddWellPlotList中的井数据构建图元添加到画布上
for (int i = 0; i < vAddWellPlotList.count(); i++ ) {
ZxDataWell* wellObj = vAddWellPlotList[i];
QString sName = tr("nmObj"); QString sName = tr("nmObj");
QVector<QPointF> points; QVector<QPointF> points;
points.append(QPointF(wellObj->getLocationX(), wellObj->getLocationY())); points.append(QPointF(wellObj->getLocationX(), wellObj->getLocationY()));
@ -724,6 +748,8 @@ void nmSubWndMain::drawFault()
void nmSubWndMain::selectWell() void nmSubWndMain::selectWell()
{ {
// 先获取已经添加到的界面中井
QStringList wellPlotNameList = m_pWxPlot->getWellNames();
// 先找到所有的井 // 先找到所有的井
int wellCount = zxCurProject->getChildrenCount(iDataModelType::sTypeWell); int wellCount = zxCurProject->getChildrenCount(iDataModelType::sTypeWell);
ZxDataObjectList wellList = zxCurProject->getChildren(iDataModelType::sTypeWell); ZxDataObjectList wellList = zxCurProject->getChildren(iDataModelType::sTypeWell);
@ -745,6 +771,7 @@ void nmSubWndMain::selectWell()
// 展示dialog供选择 // 展示dialog供选择
nmWxSelectWellsDlg dlg; nmWxSelectWellsDlg dlg;
nmWxSelectWellsWidget wellListWidget; nmWxSelectWellsWidget wellListWidget;
wellListWidget.setSelectedItems(wellPlotNameList);
wellListWidget.addItems(wellNames, wellCodes); wellListWidget.addItems(wellNames, wellCodes);
dlg.setWidget(&wellListWidget); dlg.setWidget(&wellListWidget);
if(dlg.exec() == QDialog::Accepted) { if(dlg.exec() == QDialog::Accepted) {

@ -47,6 +47,9 @@ void nmWxSelectWellsWidget::addItem(QString name, QVariant value)
nmWxSelectWellItemWidget* itemWidget = new nmWxSelectWellItemWidget(NULL, name, value); nmWxSelectWellItemWidget* itemWidget = new nmWxSelectWellItemWidget(NULL, name, value);
itemWidget->setFixedHeight(25); itemWidget->setFixedHeight(25);
itemWidget->setFixedWidth(200); itemWidget->setFixedWidth(200);
if (m_selectItems.contains(name)) {
itemWidget->setSelected(true);
}
// itemWidget->setMinimumWidth(m_pListWidget->viewport()->width()); // 设置widget的最小宽度为列表视图的宽度 // itemWidget->setMinimumWidth(m_pListWidget->viewport()->width()); // 设置widget的最小宽度为列表视图的宽度
QListWidgetItem* item = new QListWidgetItem; QListWidgetItem* item = new QListWidgetItem;
nmDataLogFile::getInstance()->writeLog(QString(" %1 ").arg(item->sizeHint().width())); nmDataLogFile::getInstance()->writeLog(QString(" %1 ").arg(item->sizeHint().width()));
@ -61,6 +64,11 @@ QStringList nmWxSelectWellsWidget::getItems()
return m_pLineEdit->toPlainText().split("\n"); return m_pLineEdit->toPlainText().split("\n");
} }
void nmWxSelectWellsWidget::setSelectedItems(QStringList selectItems)
{
m_selectItems = selectItems;
}
void nmWxSelectWellsWidget::onUpdateSelections() void nmWxSelectWellsWidget::onUpdateSelections()
{ {
QStringList nameList; QStringList nameList;

Loading…
Cancel
Save