#include "PropertyWidget.h" #include #include #include #include "CallManage.h" extern int g_iScale; PropertyWidget::PropertyWidget(const QString &title, QWidget *parent , Qt::WindowFlags flags ) :QDockWidget(title,parent,flags) { // m_pPropertyBrowser = new QtTreePropertyBrowser(); this->setWidget(m_pPropertyBrowser); // m_pVariantManager = new VariantManager();//new QtVariantPropertyManager(); QtVariantEditorFactory *variantFactory = new VariantFactory();//new QtVariantEditorFactory(); m_pPropertyBrowser->setFactoryForManager(m_pVariantManager, variantFactory); // m_pPropertyBrowser->setPropertiesWithoutValueMarked(true); m_pPropertyBrowser->setRootIsDecorated(true); m_pPropertyBrowser->setIndentation(8); connect( m_pVariantManager,SIGNAL(valueChanged(QtProperty *, const QVariant &)), this,SLOT(SlotPropertyChanged(QtProperty *, const QVariant &)) ); } PropertyWidget::~PropertyWidget() { QVector aa; aa.append(m_pPropertyBrowser); qDeleteAll(aa); } PropertyWidget* PropertyService() { static PropertyWidget* singleInstance= new PropertyWidget("", nullptr, 0); return singleInstance; } QWidget* PropertyWidget::GetPropertyWidget() { return m_pPropertyBrowser; } //初始化,清空 void PropertyWidget::InitCurrentViewInfo() { QList propertyList = m_pPropertyBrowser->properties(); m_pPropertyBrowser->clear(); foreach(QtProperty *property, propertyList) { if (property) { delete property; } } //map清空 m_propertyData.clear(); m_mapGroupItem.clear(); m_strSlfName = ""; m_strWellName = ""; m_strTrackName = ""; m_strLineName = ""; // m_strCurrentProperty = ""; } void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant &variant ) { if("深度比例尺" == m_propertyData[pProperty]) { qDebug() << "深度比例尺->改变"; //当前属性类型 if(m_strCurrentProperty == Widget_Property) { int iScale = 200; QString newScale = pProperty->valueText(); qDebug() << "深度比例尺->" << newScale; // int pos = newScale.indexOf(":"); if(pos>-1) { newScale = newScale.mid(pos+1); } else { iScale = 200; } iScale = atoi(newScale.toStdString().c_str()); // g_iScale = iScale; } } else if("左刻度" == m_propertyData[pProperty]) { qDebug() << "左刻度->改变"; //当前属性类型 if(m_strCurrentProperty == Curve_Property) { double newLeftScale = variant.value(); emit CallManage::getInstance()->sig_ChangeLeftScale(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName, newLeftScale); //更新填充 ChangFillProperty(); } } else if("右刻度" == m_propertyData[pProperty]) { qDebug() << "右刻度->改变"; //当前属性类型 if(m_strCurrentProperty == Curve_Property) { double newRightScale = variant.value(); emit CallManage::getInstance()->sig_ChangeRightScale(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName, newRightScale); //更新填充 ChangFillProperty(); } } else if("颜色" == m_propertyData[pProperty]) { qDebug() << "颜色->改变"; //当前属性类型 if(m_strCurrentProperty == Curve_Property) { //曲线颜色 // 假设variant已经被设置为包含QColor QColor newColor = variant.value(); emit CallManage::getInstance()->sig_ChangeLineColor(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName, newColor); } } else if("线宽" == m_propertyData[pProperty]) { qDebug() << "线宽->改变"; //当前属性类型 if(m_strCurrentProperty == Curve_Property) { double newWidth = variant.value(); emit CallManage::getInstance()->sig_ChangeLineWidth(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName, newWidth); } } else if("线型" == m_propertyData[pProperty]) { qDebug() << "线型->改变"; //当前属性类型 if(m_strCurrentProperty == Curve_Property) { Qt::PenStyle newStyle = Qt::SolidLine; int iStyle = variant.value(); switch(iStyle) { case 0: //实线 newStyle = Qt::SolidLine; break; case 1: //虚线 newStyle = Qt::DashLine; break; case 2: //点线 newStyle = Qt::DotLine; break; case 3: //虚点线 newStyle = Qt::DashDotLine; break; case 4: //虚点点线 newStyle = Qt::DashDotDotLine; break; default: break; } emit CallManage::getInstance()->sig_ChangeLineStyle(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName, newStyle); } } else if("填充模式" == m_propertyData[pProperty]) { qDebug() << "填充模式->改变"; //当前属性类型 if(m_strCurrentProperty == Curve_Property) { ChangFillProperty(); } } else if("填充类型" == m_propertyData[pProperty]) { qDebug() << "填充类型->改变"; //当前属性类型 if(m_strCurrentProperty == Curve_Property) { ChangFillProperty(); } } else if("目标曲线" == m_propertyData[pProperty]) { qDebug() << "目标曲线->改变"; //当前属性类型 if(m_strCurrentProperty == Curve_Property) { ChangFillProperty(); } } else if("填充颜色" == m_propertyData[pProperty]) { qDebug() << "填充颜色->改变"; //当前属性类型 if(m_strCurrentProperty == Curve_Property) { ChangFillProperty(); } } else if("填充岩性" == m_propertyData[pProperty]) { qDebug() << "填充岩性->改变"; //当前属性类型 if(m_strCurrentProperty == Curve_Property) { ChangFillProperty(); } } else if("岩性前景色" == m_propertyData[pProperty]) { qDebug() << "岩性前景色->改变"; //当前属性类型 if(m_strCurrentProperty == Curve_Property) { ChangFillProperty(); } } else if("岩性背景色" == m_propertyData[pProperty]) { qDebug() << "岩性背景色->改变"; //当前属性类型 if(m_strCurrentProperty == Curve_Property) { ChangFillProperty(); } } else if("头部图例" == m_propertyData[pProperty]) { qDebug() << "头部图例->改变"; //当前属性类型 if(m_strCurrentProperty == Curve_Property) { ChangFillProperty(); } } } void PropertyWidget::ChangFillProperty() { QString newFillMode = "无填充"; QString newFillType = "岩性模式"; QString newTargetLine = "左界道"; QColor newColor;//填充颜色 QString newLithosImage = "";//岩性图片 QString newHeadFill = "不绘制"; float vMax = 0.0; float vMin = 0.0; QColor frontColor;//岩性前景色 QColor backColor;//岩性背景色 for (auto it = m_propertyData.constBegin(); it != m_propertyData.constEnd(); ++it) { if(it.value()=="填充模式") { QtVariantProperty *pProperty = (QtVariantProperty*)it.key(); if(pProperty->hasValue()) { newFillMode = pProperty->valueText(); qDebug() << "填充模式->" << newFillMode; } } else if(it.value()=="填充类型") { QtVariantProperty *pProperty = (QtVariantProperty*)it.key(); if(pProperty->hasValue()) { newFillType = pProperty->valueText(); qDebug() << "填充类型->" << newFillType; } } else if(it.value()=="目标曲线") { QtVariantProperty *pProperty = (QtVariantProperty*)it.key(); if(pProperty->hasValue()) { newTargetLine = pProperty->valueText(); qDebug() << "目标曲线->" << newTargetLine; // if(newTargetLine=="左界道" || newTargetLine=="右界道" || newTargetLine=="对称线") { } else { for(int i=0; ihasValue()) { newColor = pProperty->value().value(); } qDebug() << "填充颜色->"; } else if(it.value()=="填充岩性") { QtVariantProperty *pProperty = (QtVariantProperty*)it.key(); if(pProperty->hasValue()) { newLithosImage = pProperty->valueText(); } qDebug() << "填充岩性->" << newLithosImage; } else if(it.value()=="岩性前景色") { QtVariantProperty *pProperty = (QtVariantProperty*)it.key(); if(pProperty->hasValue()) { frontColor = pProperty->value().value(); } qDebug() << "岩性前景色->"; } else if(it.value()=="岩性背景色") { QtVariantProperty *pProperty = (QtVariantProperty*)it.key(); if(pProperty->hasValue()) { backColor = pProperty->value().value(); } qDebug() << "岩性背景色->"; } else if(it.value()=="头部图例") { QtVariantProperty *pProperty = (QtVariantProperty*)it.key(); if(pProperty->hasValue()) { newHeadFill = pProperty->valueText(); qDebug() << "头部图例->" << newHeadFill; } } } // if(newFillMode=="无填充") { emit CallManage::getInstance()->sig_ClearFillMode(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName); } else if(newFillMode=="填充") { emit CallManage::getInstance()->sig_ChangeFillMode(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName, newFillType, newTargetLine, newColor, newLithosImage, newHeadFill, vMin, vMax, frontColor, backColor); } } void PropertyWidget::_CreateVariantPropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue, int propertyType) { QtProperty *pGroupItem =NULL; { QMap::Iterator it = m_mapGroupItem.find( strGroup ); if( it != m_mapGroupItem.end() ) { pGroupItem = it.value(); }else { pGroupItem = m_pVariantManager->addProperty(QtVariantPropertyManager::groupTypeId(), strGroup); m_mapGroupItem[strGroup] = pGroupItem ; m_pPropertyBrowser->addProperty( pGroupItem ); } } QtVariantProperty *item = m_pVariantManager->addProperty(propertyType, strPropertyCaption); item->setValue(vtPropertyValue); m_propertyData[item] = strPropertyCaption; pGroupItem->addSubProperty(item); } void PropertyWidget::_CreateVariantPropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue, int propertyType, double dMin, double dMax) { QtProperty *pGroupItem =NULL; { QMap::Iterator it = m_mapGroupItem.find( strGroup ); if( it != m_mapGroupItem.end() ) { pGroupItem = it.value(); }else { pGroupItem = m_pVariantManager->addProperty(QtVariantPropertyManager::groupTypeId(), strGroup); m_mapGroupItem[strGroup] = pGroupItem ; m_pPropertyBrowser->addProperty( pGroupItem ); } } QtVariantProperty *item = m_pVariantManager->addProperty(propertyType, strPropertyCaption); item->setValue(vtPropertyValue); item->setAttribute("minimum", dMin); item->setAttribute("maximum", dMax); m_propertyData[item] = strPropertyCaption; pGroupItem->addSubProperty(item); } void PropertyWidget::_CreateEnumPropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue, QStringList listValue) { QtProperty *pGroupItem =NULL; { QMap::Iterator it = m_mapGroupItem.find( strGroup ); if( it != m_mapGroupItem.end() ) { pGroupItem = it.value(); }else { pGroupItem = m_pVariantManager->addProperty(QtVariantPropertyManager::groupTypeId(), strGroup); m_mapGroupItem[strGroup] = pGroupItem ; m_pPropertyBrowser->addProperty( pGroupItem ); } } QtVariantProperty *item = m_pVariantManager->addProperty(QtVariantPropertyManager::enumTypeId(), strPropertyCaption); m_pVariantManager->setAttribute(item, "enumNames", listValue); item->setValue(vtPropertyValue); m_propertyData[item] = strPropertyCaption; pGroupItem->addSubProperty(item); } void PropertyWidget::initWidgetProperty() { //初始化,清空 InitCurrentViewInfo(); //当前属性类型 m_strCurrentProperty = Widget_Property; QStringList listSize; listSize.append("1:10"); listSize.append("1:20"); listSize.append("1:50"); listSize.append("1:100"); // _CreateEnumPropertyItem("通常", "深度比例尺", 0, listSize); _CreateVariantPropertyItem("通常", "自定义比例尺", "", QVariant::String); // _CreateVariantPropertyItem("水平格线", "粗格线间隔(m)", 10.0, QVariant::Double); _CreateVariantPropertyItem("水平格线", "中格线间隔(m)", 2.0, QVariant::Double); } void PropertyWidget::initCurveProperty(FormInfo *formInfo, QStringList strListOtherLine, QList listMin, QList listMax) //void PropertyWidget::initCurveProperty(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QColor lineColor, double dWidth, QStringList strListOtherLine) { //初始化,清空 InitCurrentViewInfo(); QString strSlfName = formInfo->m_strSlfName; QString strWellName = formInfo->m_strWellName; QString strTrackName = formInfo->m_strTrackName; QString strLineName = formInfo->m_strLineName; QColor lineColor = formInfo->m_lineColor; double dWidth = formInfo->m_dWidth; float vmax = formInfo->m_vmax; float vmin = formInfo->m_vmin; QColor frontColor = formInfo->m_frontColor; QColor backColor = formInfo->m_backColor; // m_strSlfName = strSlfName; m_strWellName = strWellName; m_strTrackName = strTrackName; m_strLineName = strLineName; //其他曲线 m_strListOtherLine.clear(); m_listMin.clear(); m_listMax.clear(); // m_strListOtherLine.append(strListOtherLine); m_listMin.append(listMin); m_listMax.append(listMax); //当前属性类型 m_strCurrentProperty = Curve_Property; QStringList listStyle; listStyle.append("实线"); listStyle.append("虚线"); listStyle.append("点线"); listStyle.append("虚点线"); listStyle.append("虚点点线"); // QStringList listHeadFill; listHeadFill.append("不绘制"); listHeadFill.append("绘制"); // QStringList listTargetLine; listTargetLine.append("左界道"); listTargetLine.append("右界道"); listTargetLine.append("对称线"); listTargetLine.append(strListOtherLine);//其他曲线 // QStringList listFillType; listFillType.append("岩性模式"); listFillType.append("颜色模式"); listFillType.append("成像化"); // QStringList listFillMode; listFillMode.append("无填充"); listFillMode.append("填充"); // _CreateVariantPropertyItem("通常", "井曲线", strLineName + "@"+strSlfName, QVariant::String); _CreateVariantPropertyItem("通常", "显示名称", "", QVariant::String); _CreateVariantPropertyItem("通常", "显示单位", "", QVariant::String); // _CreateVariantPropertyItem("刻度设置", "左刻度", vmin, QVariant::Double); _CreateVariantPropertyItem("刻度设置", "右刻度", vmax, QVariant::Double); // _CreateVariantPropertyItem("曲线线型", "线宽", dWidth, QVariant::Double, 1, 20); _CreateVariantPropertyItem("曲线线型", "颜色", lineColor, QVariant::Color); _CreateEnumPropertyItem("曲线线型", "线型", 0, listStyle); // _CreateEnumPropertyItem("岩性填充", "头部图例", 0, listHeadFill); _CreateEnumPropertyItem("岩性填充", "目标曲线", 0, listTargetLine); _CreateEnumPropertyItem("岩性填充", "填充类型", 0, listFillType); _CreateEnumPropertyItem("岩性填充", "填充模式", 0, listFillMode); _CreateVariantPropertyItem("岩性填充", "填充颜色", lineColor, QVariant::Color); _CreateVariantPropertyItem("岩性填充", "填充岩性", "./image/胜利符号库/岩性符号/砂岩.png", VariantManager::filePathTypeId()); _CreateVariantPropertyItem("岩性填充", "岩性前景色", frontColor, QVariant::Color); _CreateVariantPropertyItem("岩性填充", "岩性背景色", backColor, QVariant::Color); }