#include "attribute_dialog_manager.h" #include #include #include #include #include "plan_editor.h" #include "plan_editor_session.h" #include "plan_editor_utils.h" #include "dialog.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "icon_names.h" namespace PlanEditor { using ComboBox = LtsWidgets::LtsComboBox; class AttributeDialogManager::InternalData { public: PlanEditor *m_planEditor; SituationMap::Map *m_map; SituationMap::GeometryModel *m_geoModel; const PlanEditorSession &m_session; bool m_blockUpdateSelectedFeature; AttributeDialogManager *m_self; QColorDialog *m_colorDialog; QPointer m_dlgDrawAttr; QPointer m_dlgTextAttr; QPointer m_dlgSymbolParticipant; QPointer m_dlgSymbolModify; QPointer m_dlgSymbolXML; QToolButton *m_tbColor; QToolButton *m_tbFillColor; QSpinBox *m_sbLineWidth; QCheckBox *m_cbArrowBegin; QCheckBox *m_cbArrowEnd; ComboBox *m_cmbLinePattern; QCheckBox *m_cbFill; ComboBox *m_cmbFillPattern; ComboBox *m_cmbFillStyle; ComboBox *m_cmbFontFace; QToolButton *m_tbStyleBold; QToolButton *m_tbStyleItalic; QToolButton *m_tbFontColor; QToolButton *m_tbTextAnchor[3][3]; QDial *m_slFontRotate; QSpinBox *m_sbFontRotate; QTextEdit *m_teText; QDoubleSpinBox *m_dsbFontSize; SituationMap::GeometryModel::Attribute m_changedAttribute; uint m_lineWidth; QColor m_color; QColor m_fillColor; SituationMap::GeometryModel::LineStyle m_linePattern; SituationMap::GeometryModel::FillPattern m_fillPattern; SituationMap::GeometryModel::FillStyle m_fillStyle; bool m_lineArrowBegin; bool m_lineArrowEnd; QString m_textLines; SituationMap::GeometryModel::Font m_fontFace; double m_fontSize; QPointF m_fontOVec; bool m_fontBold; bool m_fontItalic; QColor m_fontColor; SituationMap::GeometryModel::HorizontalAlign m_fontHAnchor; SituationMap::GeometryModel::VerticalAlign m_fontVAnchor; ComboBox *m_cbPpStatus; ComboBox *m_cbPpTeamColor; ComboBox *m_cbPpTeamDColor; QLineEdit *m_lePpTextW; QLineEdit *m_lePpTextXY; QLineEdit *m_lePpTextV; QLineEdit *m_lePpTextT; QLineEdit *m_lePpTextZ; QLineEdit *m_lePpTextEF; QLineEdit *m_lePpTextG; QLineEdit *m_lePpTextH; QLineEdit *m_lePpTextM; QLineEdit *m_lePpTextJ; QLabel *m_laPpView; SituationMap::SimpleValue m_ppState; SituationMap::SimpleValue m_ppTeamColor; SituationMap::SimpleValue m_ppTeamDColor; QMap> m_ppTextModifier; Logger &m_logger; InternalData(PlanEditor *planEditor, SituationMap::Map *map, SituationMap::GeometryModel *geoModel, const PlanEditorSession &session, AttributeDialogManager *self) : m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("AttributeDialogManager::InternalData")) , m_planEditor(planEditor) , m_map(map) , m_geoModel(geoModel) , m_session(session) , m_blockUpdateSelectedFeature(false) , m_self(self) , m_colorDialog(new QColorDialog()) , m_dlgDrawAttr(nullptr) , m_dlgTextAttr(nullptr) , m_dlgSymbolParticipant(nullptr) , m_dlgSymbolModify(nullptr) , m_tbColor(nullptr) , m_tbFillColor(nullptr) , m_sbLineWidth(nullptr) , m_cbArrowBegin(nullptr) , m_cbArrowEnd(nullptr) , m_cmbLinePattern(nullptr) , m_cbFill(nullptr) , m_cmbFillPattern(nullptr) , m_cmbFillStyle(nullptr) , m_cmbFontFace(nullptr) , m_tbStyleBold(nullptr) , m_tbStyleItalic(nullptr) , m_tbFontColor(nullptr) , m_slFontRotate(nullptr) , m_sbFontRotate(nullptr) , m_teText(nullptr) , m_dsbFontSize(nullptr) , m_changedAttribute(SituationMap::GeometryModel::Attribute::None) , m_lineWidth(1) , m_color(m_session.topLevelWidget()->palette().color(QPalette::ColorRole::Highlight)) , m_fillColor(m_session.topLevelWidget()->palette().color(QPalette::ColorRole::Window)) , m_linePattern(SituationMap::GeometryModel::LineStyle::LineSolid) , m_fillPattern(SituationMap::GeometryModel::FillPattern::None) , m_fillStyle(SituationMap::GeometryModel::FillStyle::Pieslice) , m_lineArrowBegin(false) , m_lineArrowEnd(false) , m_textLines() , m_fontFace(SituationMap::GeometryModel::Font::Serif) , m_fontSize(12.0) , m_fontOVec(1, 0) , m_fontBold(false) , m_fontItalic(false) , m_fontColor(QLatin1String("black")) , m_fontHAnchor(SituationMap::GeometryModel::HorizontalAlign::Left) , m_fontVAnchor(SituationMap::GeometryModel::VerticalAlign::VCenter) , m_cbPpStatus(nullptr) , m_cbPpTeamColor(nullptr) , m_cbPpTeamDColor(nullptr) , m_lePpTextW(nullptr) , m_lePpTextXY(nullptr) , m_lePpTextV(nullptr) , m_lePpTextT(nullptr) , m_lePpTextZ(nullptr) , m_lePpTextEF(nullptr) , m_lePpTextG(nullptr) , m_lePpTextH(nullptr) , m_lePpTextM(nullptr) , m_lePpTextJ(nullptr) , m_laPpView(nullptr) , m_ppState(AdvancedSymbology::Injury::NoInjury) , m_ppTeamColor(-1) , m_ppTeamDColor(-1) , m_ppTextModifier() { m_colorDialog -> setOptions(QColorDialog::ColorDialogOptions({QColorDialog::ShowAlphaChannel, QColorDialog::DontUseNativeDialog})); for (int r = 0; r < 3; ++r) { for (int c = 0; c < 3; ++c) m_tbTextAnchor[r][c] = nullptr; } } ~InternalData() { if (m_colorDialog) { m_colorDialog->deleteLater(); m_colorDialog = nullptr;} if (m_dlgDrawAttr) m_dlgDrawAttr->disconnect(); if (m_dlgTextAttr) m_dlgTextAttr->disconnect(); if (m_dlgSymbolParticipant) m_dlgSymbolParticipant->disconnect(); if (m_dlgSymbolModify) m_dlgSymbolModify->disconnect(); delete m_dlgDrawAttr; delete m_dlgTextAttr; delete m_dlgSymbolParticipant; delete m_dlgSymbolModify; } LtsWidgets::LtsDialog *buildDrawAttrBox(QWidget *parent); LtsWidgets::LtsDialog *buildTextAttrBox(QWidget *parent); LtsWidgets::LtsDialog *buildParticipantBox(QWidget *parent); AdvancedSymbology::Gui::SymbolModificationDialog *buildSymbolModifyDialog(QWidget *parent, bool isParticipant = true); SymbologyXML::SymbolDialog *buildSymbolXMLDialog(QWidget *parent); void symbolXmlUpdateParties(); void updateDefaultColors() { const SituationMap::PartyIdToColorFunctor &partyToColorFunctor = m_map->partyIdToColorFunctor(); const QVector &partyColors = partyToColorFunctor.partyColors(); int customColorCount = QColorDialog::customCount(); if (partyColors.size() > customColorCount) { WARNING_LOG(m_logger) << Q_FUNC_INFO << " To much party colors (" << partyColors.size() << ") color dialog custom colors are limited to " << customColorCount << " colors."; } else customColorCount = partyColors.size(); for (int colorIndex = 0; colorIndex < customColorCount; ++colorIndex) { const QColor &color = partyColors[colorIndex]; QColorDialog::setCustomColor(colorIndex, color); } } void updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute attribute, const QVariant &value) { QString undoToken = tr("Modify Symbol XML Attribute %1", TR_UNDO_TOKEN).arg(m_geoModel->attributeToString(attribute)); m_planEditor->onSymbolXmlAttrModified( undoToken, attribute, value); } static inline void safeSetText(QLineEdit *lineEdit, const QString &text) { if (!lineEdit) return; lineEdit->setText(text); } void updateTextModifierWidget(SituationMap::Participant::TextModifier mod) { const QString &text = m_ppTextModifier[mod].value(); switch (mod) { case SituationMap::Participant::TextModifier::EF_ReinforcedReduced : safeSetText(m_lePpTextEF, text); break; case SituationMap::Participant::TextModifier::M_HigherFormation : safeSetText(m_lePpTextM, text); break; case SituationMap::Participant::TextModifier::T_UniqueDesignation : safeSetText(m_lePpTextT, text); break; case SituationMap::Participant::TextModifier::W_DateTimeGroup : safeSetText(m_lePpTextW, text); break; case SituationMap::Participant::TextModifier::XY_AltitudeLocation : safeSetText(m_lePpTextXY, text); break; case SituationMap::Participant::TextModifier::V_Type : safeSetText(m_lePpTextV, text); break; case SituationMap::Participant::TextModifier::Z_Speed : safeSetText(m_lePpTextZ, text); break; case SituationMap::Participant::TextModifier::G_StaffComments : safeSetText(m_lePpTextG, text); break; case SituationMap::Participant::TextModifier::H_AdditionalInformation : safeSetText(m_lePpTextH, text); break; case SituationMap::Participant::TextModifier::JKLNP : safeSetText(m_lePpTextJ, text); break; default: break; } } void setParticipantState(AdvancedSymbology::Injury injury) { m_ppState = injury; if (m_cbPpStatus) m_cbPpStatus->setCurrentIndex(m_cbPpStatus->findData(static_cast(injury))); m_ppState.reset(); } void setParticipantPartyId(int partyId) { const QVector &partyIds = m_map->partyIdToColorFunctor().partyIds(); if (!partyIds.contains(partyId)) partyId = -1; m_ppTeamColor = partyId; if (m_cbPpTeamColor) m_cbPpTeamColor->setCurrentIndex(m_cbPpTeamColor->findData(partyId)); m_ppTeamColor.reset(); } void setParticipantDamageId(int damagedPartyId) { const QVector &partyIds = m_map->partyIdToColorFunctor().partyIds(); if (!partyIds.contains(damagedPartyId)) damagedPartyId = -1; m_ppTeamDColor = damagedPartyId; if (m_cbPpTeamDColor) m_cbPpTeamDColor->setCurrentIndex(m_cbPpTeamColor->findData(damagedPartyId)); m_ppTeamDColor.reset(); } void setParticipantTextModifier(SituationMap::Participant::TextModifier mod, const QString &text) { m_ppTextModifier[mod] = text; m_ppTextModifier[mod].reset(); updateTextModifierWidget(mod); } void setParticipantTextModifier(const QMap &textMod) { for (auto it = textMod.constBegin(); it != textMod.constEnd(); ++it) { const auto &key = it.key(); m_ppTextModifier[key] = it.value(); m_ppTextModifier[key].reset(); updateTextModifierWidget(key); } } }; const QString &AttributeDialogManager::textLines() const { return m_internal->m_textLines; } AttributeDialogManager::AttributeDialogManager(PlanEditor *planEditor , SituationMap::Map *map , SituationMap::GeometryModel *geoModel , const PlanEditorSession &session) : QObject(planEditor), m_internal(new AttributeDialogManager::InternalData(planEditor, map, geoModel, session, this)) { TRACE_LOG(m_internal->m_logger) << Q_FUNC_INFO << " START"; TRACE_LOG(m_internal->m_logger) << Q_FUNC_INFO << " END"; } AttributeDialogManager::~AttributeDialogManager() { TRACE_LOG(m_internal->m_logger) << Q_FUNC_INFO << " START"; delete m_internal; m_internal = nullptr; } void AttributeDialogManager::onOpenDialog(const SituationMap::GeometryModel::Node &node) { DEBUG_LOG(m_internal->m_logger) << Q_FUNC_INFO << " START, node.connectedId() = " << node.connectedId(); if (!node.isValid()) { if (nullptr == m_internal->m_dlgSymbolXML) { m_internal->m_dlgSymbolXML = m_internal->buildSymbolXMLDialog(m_internal->m_session.topLevelWidget()); m_internal->symbolXmlUpdateParties(); } if (nullptr == m_internal -> m_dlgSymbolParticipant) m_internal->m_dlgSymbolParticipant = m_internal->buildParticipantBox(m_internal->m_session.topLevelWidget()); if (nullptr == m_internal -> m_dlgTextAttr) m_internal -> m_dlgTextAttr = m_internal->buildTextAttrBox(m_internal->m_session.topLevelWidget()); if (nullptr == m_internal -> m_dlgDrawAttr) m_internal -> m_dlgDrawAttr = m_internal->buildDrawAttrBox(m_internal->m_session.topLevelWidget()); return; } SituationMap::GeometryModel::PrimitiveType primitiveType = m_internal->m_geoModel->getType(node); DEBUG_LOG(m_internal->m_logger) << Q_FUNC_INFO << " primitiveType = " << static_cast(primitiveType) << " , m_dlgSymbolModify=" << m_internal->m_dlgSymbolModify << " , m_dlgSymbolXML=" << m_internal->m_dlgSymbolXML; switch (primitiveType) { case SituationMap::GeometryModel::PrimitiveType::Symbol: { const AdvancedSymbology::SymbolDictionary &symbolDict = m_internal->m_map->symbolDictionary(); if ((nullptr == m_internal -> m_dlgSymbolXML) && (symbolDict.isLoaded())) { int symbolId = m_internal->m_geoModel->getAttribute(node, SituationMap::GeometryModel::Attribute::SymbolId).toInt(); m_internal -> m_dlgSymbolXML = m_internal->buildSymbolXMLDialog(m_internal->m_session.topLevelWidget()); m_internal -> symbolXmlUpdateParties(); m_internal -> m_dlgSymbolXML->setNode( symbolId, node ); m_internal -> m_dlgSymbolXML->updateSymbolPixmap(); } else { if (nullptr != m_internal->m_dlgSymbolXML) { int symbolId = m_internal->m_geoModel->getAttribute(node, SituationMap::GeometryModel::Attribute::SymbolId).toInt(); m_internal -> symbolXmlUpdateParties(); m_internal -> m_dlgSymbolXML->setNode( symbolId, node ); m_internal -> m_dlgSymbolXML->updateSymbolPixmap(); } } } break; case SituationMap::GeometryModel::PrimitiveType::ParticipantSymbol: case SituationMap::GeometryModel::PrimitiveType::DictionarySymbol: { const QString &sidc = m_internal->m_geoModel->getAttribute(node, SituationMap::GeometryModel::Attribute::SIDC).toString(); if (sidc.isEmpty() || AdvancedSymbology::SidcCodec::isCivil(sidc) || (AdvancedSymbology::SidcCodec::decodeSymbologyType(sidc) == AdvancedSymbology::SymbologyType::None) ) return; const AdvancedSymbology::SymbolDictionary &symbolDict = m_internal->m_map->symbolDictionary(); if ((nullptr == m_internal -> m_dlgSymbolModify) && (symbolDict.isLoaded())) m_internal -> m_dlgSymbolModify = m_internal->buildSymbolModifyDialog(m_internal->m_session.topLevelWidget(), (SituationMap::GeometryModel::PrimitiveType::ParticipantSymbol == primitiveType)); QSignalBlocker blocker (m_internal->m_dlgSymbolModify->getWidget()); if (m_internal->m_dlgSymbolModify->getWidget()->setSidc(sidc)) { QMap attrMap; const QString &symbolFieldAttr = m_internal->m_geoModel->getAttribute(node, SituationMap::GeometryModel::Attribute::SIDC_Attributes).toString(); m_internal -> m_geoModel->parseSymbolAttributeString(symbolFieldAttr, attrMap); m_internal->m_dlgSymbolModify->getWidget()->setFieldAttributes(attrMap); m_internal->m_dlgSymbolModify->getWidget()->updatePreviewTab(); if (SituationMap::GeometryModel::PrimitiveType::ParticipantSymbol == primitiveType) { m_internal->m_ppState = static_cast(m_internal->m_geoModel->getAttribute(node, SituationMap::GeometryModel::Attribute::Injury).toInt()); m_internal->m_ppTeamColor = m_internal->m_geoModel->getAttribute(node, SituationMap::GeometryModel::Attribute::ForceId).toInt(); m_internal->m_ppTeamDColor = m_internal->m_geoModel->getAttribute(node, SituationMap::GeometryModel::Attribute::DamageForceId).toInt(); if (nullptr == m_internal->m_dlgSymbolParticipant) m_internal->m_dlgSymbolParticipant = m_internal->buildParticipantBox(m_internal->m_session.topLevelWidget()); onChangedParticipant(); if (m_internal->m_dlgSymbolModify) { connect(m_internal->m_dlgSymbolModify.data(), &AdvancedSymbology::Gui::SymbolModificationDialog::changed, this, &AttributeDialogManager::onChangedParticipant); } } } else { m_internal -> m_dlgSymbolModify->deleteLater(); m_internal -> m_dlgSymbolModify = nullptr; } } break; case SituationMap::GeometryModel::PrimitiveType::Text: { if (nullptr == m_internal -> m_dlgTextAttr) { if (nullptr == m_internal->m_dlgDrawAttr) { m_internal->m_dlgDrawAttr = m_internal->buildDrawAttrBox(m_internal->m_session.topLevelWidget()); } m_internal -> m_dlgTextAttr = m_internal->buildTextAttrBox(m_internal->m_session.topLevelWidget()); } m_internal->m_session.focusTab(m_internal -> m_dlgTextAttr, LtsWidgets::LayoutArea::eDialogTab, QStringLiteral("PlanEditor"), QStringLiteral("TextAttributes")); } break; default: { if (nullptr == m_internal -> m_dlgDrawAttr) m_internal -> m_dlgDrawAttr = m_internal->buildDrawAttrBox(m_internal->m_session.topLevelWidget()); } break; } } void AttributeDialogManager::onCloseDialog() { if (m_internal -> m_dlgDrawAttr) { m_internal -> m_dlgDrawAttr -> closeRequest(); } if (m_internal -> m_dlgTextAttr) { m_internal -> m_dlgTextAttr -> closeRequest(); } if (m_internal -> m_dlgSymbolParticipant) { m_internal -> m_dlgSymbolParticipant -> closeRequest(); } if (m_internal -> m_dlgSymbolModify) { m_internal -> m_dlgSymbolModify -> closeRequest(); } if (m_internal -> m_dlgSymbolXML) { m_internal -> m_dlgSymbolXML -> closeRequest(); } onResetWidgets(); onResetDialog(); } void AttributeDialogManager::onResetDialog() { m_internal -> m_dlgDrawAttr = nullptr; m_internal -> m_dlgTextAttr = nullptr; m_internal -> m_dlgSymbolParticipant = nullptr; m_internal -> m_dlgSymbolModify = nullptr; m_internal -> m_dlgSymbolXML = nullptr; } void AttributeDialogManager::onResetWidgets() { if (nullptr == m_internal->m_dlgDrawAttr) { m_internal->m_tbColor = nullptr; m_internal->m_tbFillColor = nullptr; m_internal->m_sbLineWidth = nullptr; m_internal->m_cbArrowBegin = nullptr; m_internal->m_cbArrowEnd = nullptr; m_internal->m_cmbLinePattern = nullptr; m_internal->m_cbFill = nullptr; m_internal->m_cmbFillPattern = nullptr; } if (nullptr == m_internal->m_dlgTextAttr) { m_internal->m_cmbFontFace = nullptr; m_internal->m_tbStyleBold = nullptr; m_internal->m_tbStyleItalic = nullptr; m_internal->m_tbFontColor = nullptr; m_internal->m_slFontRotate = nullptr; m_internal->m_sbFontRotate = nullptr; m_internal->m_teText = nullptr; m_internal->m_dsbFontSize = nullptr; for (int r = 0; r < 3; ++r) { for (int c = 0; c < 3; ++c) m_internal->m_tbTextAnchor[r][c] = nullptr; } } if (nullptr == m_internal->m_dlgSymbolParticipant) { m_internal->m_cbPpStatus = nullptr; m_internal->m_cbPpTeamColor = nullptr; m_internal->m_cbPpTeamDColor = nullptr; m_internal->m_lePpTextW = nullptr; m_internal->m_lePpTextXY = nullptr; m_internal->m_lePpTextV = nullptr; m_internal->m_lePpTextT = nullptr; m_internal->m_lePpTextZ = nullptr; m_internal->m_lePpTextEF = nullptr; m_internal->m_lePpTextG = nullptr; m_internal->m_lePpTextH = nullptr; m_internal->m_lePpTextM = nullptr; m_internal->m_lePpTextJ = nullptr; m_internal->m_laPpView = nullptr; } } AdvancedSymbology::Gui::SymbolModificationDialog *AttributeDialogManager::InternalData::buildSymbolModifyDialog(QWidget *parent, bool isParticipant) { TRACE_LOG(m_logger) << Q_FUNC_INFO << " START " << ", isParticipant=" << isParticipant << ", this=" << this; AdvancedSymbology::Gui::SymbolModificationDialog *dlg = new AdvancedSymbology::Gui::SymbolModificationDialog(m_map, isParticipant, parent); if(!dlg) return nullptr; dlg->removeOkAndApplyButtons(); dlg->setUnchangeable(); dlg->show(); m_session.addWidget(dlg, m_planEditor->title(), tr("Symbol Modification"), LtsWidgets::LayoutArea::eDialogTab); connect(dlg, &AdvancedSymbology::Gui::SymbolModificationDialog::changed, m_self, &AttributeDialogManager::onSymbolChanged); QObject::connect(dlg, &AdvancedSymbology::Gui::SymbolModificationDialog::signalAboutToClose, m_self, [this]() { m_dlgSymbolModify.clear(); m_self->onCloseDialog(); }); return dlg; } static void colorizeButton(QAbstractButton *button, const QColor color) { if (button) { const QString &buttonName = button->objectName(); button -> setStyleSheet(QLatin1String("QToolButton#") + buttonName + QLatin1String(" { background-color: ") + color.name() + QLatin1String(" }")); } } SymbologyXML::SymbolDialog *AttributeDialogManager::InternalData::buildSymbolXMLDialog(QWidget *parent) { TRACE_LOG(m_logger) << Q_FUNC_INFO << " START " << ", this=" << this; SymbologyXML::SymbolDialog *dlg = new SymbologyXML::SymbolDialog(m_map->symbolDictionary(),m_geoModel,true,parent); if(dlg) { dlg->show(); m_session.addOrReplaceWidget(dlg, m_planEditor->title(), tr("Symbol XML"), LtsWidgets::LayoutArea::eDialogTab); QObject::connect(dlg, &SymbologyXML::SymbolDialog::signalAboutToClose, m_self, [this]() { m_dlgSymbolXML.clear(); m_self->onCloseDialog(); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedSymbolAffiliation, m_self, [this](SymbologyXML::SymbolTypes::t_affil v) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::Affiliation ,int(v)); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedSymbolMobility , m_self, [this](SymbologyXML::SymbolTypes::t_mob v) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::Mobility ,int(v)); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedSymbolState , m_self, [this](SymbologyXML::SymbolTypes::t_state v) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::SymbolState ,int(v)); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedSymbolUncertainty, m_self, [this](SymbologyXML::SymbolTypes::t_uncertainty v) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::SymbolUncertainty ,int(v)); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedSymbolVBG , m_self, [this](SituationMap::GeometryModel::t_vbg_et v) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::att_vbg_et ,int(v)); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedParty , m_self, [this](int id) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::ForceId ,id ); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedDamageParty , m_self, [this](int id) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::DamageForceId ,id ); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedScale , m_self, [this](double s) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::SymbolExplicitScale,s ); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedTextW , m_self, [this](const QString & txt) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::Text_W ,txt); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedTextXY, m_self, [this](const QString & txt) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::Text_XY ,txt); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedTextV , m_self, [this](const QString & txt) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::Text_V ,txt); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedTextT , m_self, [this](const QString & txt) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::Text_T ,txt); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedTextZ , m_self, [this](const QString & txt) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::Text_Z ,txt); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedTextEF, m_self, [this](const QString & txt) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::Text_EF ,txt); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedTextG , m_self, [this](const QString & txt) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::Text_G ,txt); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedTextH , m_self, [this](const QString & txt) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::Text_H ,txt); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedTextM , m_self, [this](const QString & txt) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::Text_M ,txt); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedTextJ , m_self, [this](const QString & txt) { updateSymbolXmlAttribute(SituationMap::GeometryModel::Attribute::Text_KLNPJ,txt); }); QObject::connect( dlg, &SymbologyXML::SymbolDialog::changedOffset, m_self, [this]( const QPoint & p) { updateSymbolXmlAttribute( SituationMap::GeometryModel::Attribute::SymbolOffsetX, p.x() ); updateSymbolXmlAttribute( SituationMap::GeometryModel::Attribute::SymbolOffsetY, p.y() ); } ); QObject::connect(dlg, &SymbologyXML::SymbolDialog::changedDirection, m_self, [this](bool valid, int degree) { updateSymbolXmlAttribute( SituationMap::GeometryModel::Attribute::SymbolDirection, (valid) ? degree : 0 ); }); } return dlg; } void AttributeDialogManager::InternalData::symbolXmlUpdateParties() { const QVector &partyIds = m_map->partyIdToColorFunctor().partyIds(); QVector partyColors; QVector partyNames; QVector partyRoles; partyColors.reserve(partyIds.size()); partyNames.reserve(partyIds.size()); partyRoles.reserve(partyIds.size()); for (int partyId : partyIds) { partyColors.append( m_map->partyIdToColorFunctor().partyIdToColor(partyId) ); partyNames.append ( m_map->partyIdToColorFunctor().partyIdToName (partyId) ); partyRoles.append ( m_map->partyIdToColorFunctor().partyIdToRole (partyId) ); } m_dlgSymbolXML->updateParties( partyIds, partyColors, partyNames, partyRoles ); } LtsWidgets::LtsDialog *AttributeDialogManager::InternalData::buildDrawAttrBox(QWidget *parent) { Dialog *dlg = new Dialog(parent); dlg->setObjectName(QLatin1String("PlanEditor::DrawAttributeBox")); dlg->setTitle(tr("Edit Draw Attributes")); dlg->setOnlineHelpFilename(QStringLiteral("Plan_Editor-Create_Graphics")); QVBoxLayout *tabLayout = new QVBoxLayout(dlg); QGroupBox *gbLayer = new QGroupBox(tr("Graphic Attributes"), dlg); LtsWidgets::LtsGridLayout *tmpLay = new LtsWidgets::LtsGridLayout(LtsWidgets::ButtonSize::eDefault, gbLayer, 10); QAction *tmpAction; QToolButton *tbTmp; ComboBox *cmbTmp; QSpinBox *sbTmp; QCheckBox *cbTmp; QLabel *lbTmp; tabLayout -> addWidget(gbLayer); tabLayout -> addStretch(2); tmpLay->setContentsMargins(10, 10, 10, 10); tmpLay->setHorizontalSpacing(10); tmpLay->setVerticalSpacing(10); lbTmp = new QLabel(tr("Color"), gbLayer); { tmpLay -> addWidget(lbTmp, 0, 0, Qt::AlignRight); tbTmp = new QToolButton(gbLayer); tmpLay -> addWidget(tbTmp, 0, 1, Qt::AlignLeft); tmpAction = new QAction(QString(), gbLayer); tmpAction -> setToolTip(tr("Popup color dialog to choose color")); tbTmp -> setDefaultAction(tmpAction); tbTmp -> setObjectName(QLatin1String("ColorButton")); tbTmp -> setMaximumWidth(2000); m_tbColor = tbTmp; colorizeButton(m_tbColor, m_color); connect(tmpAction, &QAction::triggered, m_self, &AttributeDialogManager::onDrawColorEdit); } lbTmp = new QLabel(tr("Line Style"), gbLayer); { tmpLay -> addWidget(lbTmp, 1, 0, Qt::AlignRight); cmbTmp = new ComboBox(gbLayer); tmpLay -> addWidget(cmbTmp, 1, 1); m_cmbLinePattern = cmbTmp; cmbTmp->addItem( Utils::getIcon("line_style_solid") ,tr("Solid") , int(SituationMap::GeometryModel::LineStyle::LineSolid)); cmbTmp->addItem( Utils::getIcon("line_style_dash") ,tr("Dashed") , int(SituationMap::GeometryModel::LineStyle::Dashed)); cmbTmp->addItem( Utils::getIcon("line_style_dotdash"),tr("Dashed Dotted"), int(SituationMap::GeometryModel::LineStyle::DashedDotted)); cmbTmp->addItem( Utils::getIcon("line_style_dot") ,tr("Dotted") , int(SituationMap::GeometryModel::LineStyle::Dotted)); cmbTmp->setCurrentIndex(static_cast(m_linePattern)); connect(cmbTmp, static_cast(&QComboBox::activated), m_self, &AttributeDialogManager::onSetLinePattern); } lbTmp = new QLabel(tr("Line Width"), gbLayer); { tmpLay -> addWidget(lbTmp, 0, 2, Qt::AlignRight); sbTmp = new QSpinBox(gbLayer); tmpLay -> addWidget(sbTmp, 0, 3, 1, 2, Qt::AlignLeft); m_sbLineWidth = sbTmp; sbTmp->setRange(1, 99); sbTmp->setValue(m_lineWidth); connect(sbTmp, static_cast(&QSpinBox::valueChanged), m_self, &AttributeDialogManager::onSetLineWidth); } lbTmp = new QLabel(tr("Line Arrow"), gbLayer); { tmpLay -> addWidget(lbTmp, 1, 2, Qt::AlignRight); m_cbArrowBegin = new QCheckBox(tr("Begin"), gbLayer); m_cbArrowEnd = new QCheckBox(tr("End"), gbLayer); m_cbArrowBegin -> setAcceptDrops(false); m_cbArrowEnd -> setAcceptDrops(false); m_cbArrowBegin -> setChecked(m_lineArrowBegin); m_cbArrowEnd -> setChecked(m_lineArrowEnd); QHBoxLayout *arrowLayout = new QHBoxLayout; arrowLayout -> addWidget(m_cbArrowBegin); arrowLayout -> addSpacing(5); arrowLayout -> addWidget(m_cbArrowEnd); arrowLayout -> addSpacing(5); arrowLayout -> addStretch(2); QButtonGroup *bgArrow = new QButtonGroup(gbLayer); bgArrow -> setExclusive(false); bgArrow -> addButton(m_cbArrowBegin); bgArrow -> addButton(m_cbArrowEnd); tmpLay->addLayout(arrowLayout, 1, 3, Qt::AlignLeft); connect(m_cbArrowBegin, &QCheckBox::toggled, m_self, &AttributeDialogManager::onSetLineArrowBegin); connect(m_cbArrowEnd, &QCheckBox::toggled, m_self, &AttributeDialogManager::onSetLineArrowEnd); } tmpLay -> addWidget(Utils::buildVerticalSeparator(gbLayer), 0, 4, 2, 1); lbTmp = new QLabel(tr("Fill"), gbLayer); { tmpLay -> addWidget(lbTmp, 0, 5, Qt::AlignRight); cbTmp = new QCheckBox(QString(), gbLayer); tmpLay -> addWidget(cbTmp, 0, 6, Qt::AlignLeft); m_cbFill = cbTmp; m_cbFill->setChecked(m_fillPattern != SituationMap::GeometryModel::FillPattern::None); QObject::connect(cbTmp, &QToolButton::toggled, m_self, &AttributeDialogManager::onSetFilling); } lbTmp = new QLabel(tr("Color"), gbLayer); { tmpLay -> addWidget(lbTmp, 0, 7, Qt::AlignRight); tbTmp = new QToolButton(gbLayer); tmpLay -> addWidget(tbTmp, 0, 8, Qt::AlignLeft); tmpAction = new QAction(QString(), gbLayer); tmpAction -> setToolTip(tr("Popup color dialog to choose fill color")); tbTmp -> setDefaultAction(tmpAction); tbTmp -> setObjectName(QLatin1String("FillColorButton")); tbTmp -> setMaximumWidth(2000); m_tbFillColor = tbTmp; colorizeButton(m_tbFillColor, m_fillColor); QObject::connect(tmpAction, &QAction::triggered, m_self, &AttributeDialogManager::onFillColorEdit); } lbTmp = new QLabel(tr("Pattern"), gbLayer); { tmpLay -> addWidget(lbTmp, 1, 7, Qt::AlignRight); cmbTmp = new ComboBox(gbLayer); tmpLay -> addWidget(cmbTmp, 1, 8, Qt::AlignLeft); m_cmbFillPattern = cmbTmp; cmbTmp->addItem( Utils::getIcon("fill_style_none") ,tr("None") , int(SituationMap::GeometryModel::FillPattern::None)); cmbTmp->addItem( Utils::getIcon("fill_style_horizontal"),tr("Horizontal") , int(SituationMap::GeometryModel::FillPattern::Hor2)); cmbTmp->addItem( Utils::getIcon("fill_style_vertical") ,tr("Vertical") , int(SituationMap::GeometryModel::FillPattern::Ver1)); cmbTmp->addItem( Utils::getIcon("fill_style_diagonal_1"),tr("Diagonal //") , int(SituationMap::GeometryModel::FillPattern::Diag1)); cmbTmp->addItem( Utils::getIcon("fill_style_diagonal_2"),tr("Diagonal \\\\"), int(SituationMap::GeometryModel::FillPattern::Diag2)); cmbTmp->addItem( Utils::getIcon("fill_style_solid") ,tr("Solid") , int(SituationMap::GeometryModel::FillPattern::Solid)); cmbTmp->setCurrentIndex(static_cast(m_fillPattern)); QObject::connect(cmbTmp, static_cast(&ComboBox::activated), m_self, &AttributeDialogManager::onSetFillPattern); } tmpLay -> addWidget(Utils::buildVerticalSeparator(gbLayer), 0, 9, 2, 1); lbTmp = new QLabel(tr("Ellipse Style"), gbLayer); { tmpLay -> addWidget(lbTmp, 0, 10, 2, 1, {Qt::AlignRight, Qt::AlignVCenter}); cmbTmp = new ComboBox(gbLayer); tmpLay -> addWidget(cmbTmp, 0, 11, 2, 1, {Qt::AlignLeft, Qt::AlignVCenter}); m_cmbFillStyle = cmbTmp; cmbTmp->addItem( Utils::getIcon(""), tr("Open"), int(SituationMap::GeometryModel::FillStyle::Open)); cmbTmp->addItem( Utils::getIcon(""), tr("Chord"), int(SituationMap::GeometryModel::FillStyle::Chord)); cmbTmp->addItem( Utils::getIcon(""), tr("Pieslice"), int(SituationMap::GeometryModel::FillStyle::Pieslice)); cmbTmp->setCurrentIndex(static_cast(m_fillStyle)); QObject::connect(cmbTmp, static_cast(&ComboBox::activated), m_self, &AttributeDialogManager::onSetFillStyle); } QHBoxLayout *stretch = new QHBoxLayout; stretch->addStretch(2); tmpLay->addLayout(stretch, 0, 12, 2, 1); m_session.addOrReplaceWidget(dlg, m_planEditor->title(), QLatin1String("DrawAttributes"), LtsWidgets::LayoutArea::eDialogTab, true); QObject::connect(dlg, &Dialog::signalAboutToClose, m_self, [this]() { m_dlgDrawAttr.clear(); m_self->onCloseDialog(); }); return dlg; } LtsWidgets::LtsDialog *AttributeDialogManager::InternalData::buildTextAttrBox(QWidget *parent) { Dialog *dlg = new Dialog(parent); dlg->setObjectName(QLatin1String("PlanEditor::TextAttributeBox")); dlg->setTitle(tr("Edit Text Attributes")); dlg->setOnlineHelpFilename(QStringLiteral("Plan_Editor-Create_Graphics")); QVBoxLayout *tabLayout = new QVBoxLayout(dlg); QGroupBox *gbTextAttr = new QGroupBox(tr("Text Attributes"), dlg); tabLayout -> addWidget(gbTextAttr); tabLayout -> addStretch(2); QVBoxLayout *attrTextLayout = new QVBoxLayout(gbTextAttr); { QHBoxLayout *layout = new QHBoxLayout; QFormLayout *layoutL = new QFormLayout; QFormLayout *layoutM = new QFormLayout; QFormLayout *layoutR = new QFormLayout; m_teText = new QTextEdit(gbTextAttr); m_teText -> setAcceptRichText(false); m_teText -> setPlainText(m_textLines); attrTextLayout -> addWidget(m_teText); attrTextLayout -> addSpacing(5); attrTextLayout -> addLayout(layout); attrTextLayout -> addStretch(2); layout -> addSpacing(5); layout -> addLayout(layoutL); layout -> addSpacing(5); layout->addWidget(Utils::buildVerticalSeparator(gbTextAttr)); layout -> addSpacing(5); layout -> addLayout(layoutM); layout -> addSpacing(5); layout->addWidget(Utils::buildVerticalSeparator(gbTextAttr)); layout -> addSpacing(5); layout -> addLayout(layoutR); layout -> addSpacing(5); layout -> addStretch(2); connect(m_teText, &QTextEdit::textChanged, m_self, &AttributeDialogManager::onEditTextLines); QDoubleSpinBox *dspTmp; ComboBox *cmbTmp; QToolButton *tbTmp; QAction *tmpAction; dspTmp = new QDoubleSpinBox(gbTextAttr); dspTmp -> setMinimum(5); dspTmp -> setMaximum(72); dspTmp -> setValue(m_fontSize); layoutL -> addRow(tr("Size"), dspTmp); connect(dspTmp, static_cast(&QDoubleSpinBox::valueChanged), m_self, &AttributeDialogManager::onSetFontSize); m_dsbFontSize = dspTmp; cmbTmp = new ComboBox(gbTextAttr); cmbTmp -> addItem(tr("SansSerif"), int(SituationMap::GeometryModel::Font::SansSerif)); cmbTmp -> addItem(tr("Serif"), int(SituationMap::GeometryModel::Font::Serif)); cmbTmp -> addItem(tr("Fixed"), int(SituationMap::GeometryModel::Font::Fixed)); cmbTmp -> addItem(tr("Decorative"), int(SituationMap::GeometryModel::Font::Decorative)); layoutL -> addRow(tr("Font"), cmbTmp); m_cmbFontFace = cmbTmp; connect(cmbTmp, static_cast(&ComboBox::currentIndexChanged), m_self, [this](int index) { SituationMap::GeometryModel::Font font = (SituationMap::GeometryModel::Font) m_cmbFontFace->itemData(index).toInt(); QString fontName; switch (font) { case SituationMap::GeometryModel::Font::SansSerif : fontName = QLatin1String("Arial"); break; case SituationMap::GeometryModel::Font::Serif : fontName = QLatin1String("Times New Roman"); break; case SituationMap::GeometryModel::Font::Fixed : fontName = QLatin1String("Courier New"); break; case SituationMap::GeometryModel::Font::Decorative : fontName = QLatin1String("Freestyle Script"); break; default : fontName = QLatin1String("Wingdings"); break; } QFont qFont = m_teText->font(); qFont.setFamily(fontName); m_teText->setFont(qFont); }); connect(cmbTmp, static_cast(&ComboBox::activated), m_self, &AttributeDialogManager::onSetFontFace); cmbTmp->setCurrentIndex(1); QWidget *styleWidget = new QWidget(gbTextAttr); QGridLayout *styleLayout = new QGridLayout(styleWidget); m_tbStyleBold = new QToolButton(styleWidget); m_tbStyleItalic = new QToolButton(styleWidget); m_tbStyleBold -> setIcon(Utils::getIcon(QLatin1String(FONT_STYLE_BOLD_ICON_NAME))); m_tbStyleItalic-> setIcon(Utils::getIcon(QLatin1String(FONT_STYLE_ITALIC_ICON_NAME))); m_tbStyleBold -> setCheckable(true); m_tbStyleItalic -> setCheckable(true); m_tbStyleBold -> setChecked(m_fontBold); m_tbStyleItalic -> setChecked(m_fontItalic); connect(m_tbStyleBold, &QToolButton::clicked, m_self, &AttributeDialogManager::onSetFontBold); connect(m_tbStyleItalic, &QToolButton::clicked, m_self, &AttributeDialogManager::onSetFontItalic); styleLayout -> addWidget(m_tbStyleBold, 0, 0); styleLayout -> addWidget(m_tbStyleItalic, 0, 1); layoutL -> addRow(tr("Style"), styleWidget); tbTmp = new QToolButton(gbTextAttr); tmpAction = new QAction(QString(), gbTextAttr); tmpAction -> setToolTip(tr("Popup color dialog to choose text color")); tbTmp -> setDefaultAction(tmpAction); tbTmp -> setObjectName(QLatin1String("TextColorButton")); tbTmp -> setMaximumWidth(2000); m_tbFontColor = tbTmp; QHBoxLayout *stretchHorizontal = new QHBoxLayout; stretchHorizontal->addWidget(m_tbFontColor, 2); layoutM -> addRow(tr("Text Color"), stretchHorizontal); colorizeButton(m_tbFontColor, m_fontColor); connect(tmpAction, &QAction::triggered, m_self, &AttributeDialogManager::onFontColorEdit); QWidget *anchorWidget = new QWidget(gbTextAttr); QGridLayout *anchorLayout = new QGridLayout(anchorWidget); layoutM -> addRow(tr("Anchor"), anchorWidget); for (int r = 0; r < 3; ++r) { for (int c = 0; c < 3; ++c) { QToolButton *anchor = new QToolButton(anchorWidget); connect(anchor, &QRadioButton::clicked, m_self, &AttributeDialogManager::onSetTextAnchor); anchor->setIcon(Utils::getIcon(QLatin1String(FONT_ANCHOR_ICON_NAME[r][c]))); anchor->setCheckable(true); anchor->setChecked(((c == int(m_fontHAnchor)) && ((2 - r) == int(m_fontVAnchor)))); anchorLayout->addWidget(anchor, r, c, Qt::AlignCenter); m_tbTextAnchor[r][c] = anchor; } } m_slFontRotate = new QDial(gbTextAttr); m_slFontRotate->setMinimum(0); m_slFontRotate->setMaximum(360); m_slFontRotate->setWrapping(true); m_slFontRotate->setInvertedControls(true); m_slFontRotate->setValue(90); connect(m_slFontRotate, &QDial::valueChanged, m_self, &AttributeDialogManager::onRotateText); layoutR->addRow(tr("Rotation"), m_slFontRotate); m_sbFontRotate = new QSpinBox(gbTextAttr); m_sbFontRotate->setMinimum(-1); m_sbFontRotate->setMaximum(360); connect(m_sbFontRotate, QOverload::of(&QSpinBox::valueChanged), m_self, &AttributeDialogManager::onRotateTextSp); layoutR->addRow(nullptr, m_sbFontRotate); } m_session.addOrReplaceWidget(dlg, m_planEditor->title(), QLatin1String("TextAttributes"), LtsWidgets::LayoutArea::eDialogTab, true); QObject::connect(dlg, &Dialog::signalAboutToClose, m_self, [this]() { m_dlgTextAttr.clear(); m_self->onCloseDialog(); }); return dlg; } LtsWidgets::LtsDialog * AttributeDialogManager::InternalData::buildParticipantBox(QWidget *parent) { TRACE_LOG(m_logger) << Q_FUNC_INFO << " START, this=" << this; Dialog *dlg = new Dialog(parent); dlg->setObjectName(QLatin1String("PlanEditor::ParticipantData")); dlg->setTitle(tr("Edit Participant Attributes")); dlg->setOnlineHelpFilename(QStringLiteral("Plan_Editor-Create_Graphics")); QVBoxLayout * layout = new QVBoxLayout(dlg); QHBoxLayout * layoutSymbol = new QHBoxLayout(dlg); layout->addLayout(layoutSymbol); { QVBoxLayout * layoutAttr = new QVBoxLayout; QGridLayout * layoutLeftText = new QGridLayout(); QVBoxLayout * layoutSymbolView = new QVBoxLayout; QGridLayout * layoutRightText = new QGridLayout(); layoutSymbol->addStretch(2); layoutSymbol->addSpacing(20); layoutSymbol->addLayout(layoutAttr); { QFormLayout * layoutAttrForm = new QFormLayout(); layoutAttr->addStretch(2); layoutAttr->addLayout(layoutAttrForm); { m_cbPpStatus = new LtsWidgets::LtsComboBox(dlg); m_cbPpTeamColor = new LtsWidgets::LtsComboBox(dlg); m_cbPpTeamDColor = new LtsWidgets::LtsComboBox(dlg); m_cbPpStatus->addItem(tr("No Injury"), static_cast(AdvancedSymbology::Injury::NoInjury)); m_cbPpStatus->addItem(tr("Hit"), static_cast(AdvancedSymbology::Injury::Hit)); m_cbPpStatus->addItem(tr("Mobility Kill"), static_cast(AdvancedSymbology::Injury::MobilityKill)); m_cbPpStatus->addItem(tr("Weapon Kill"), static_cast(AdvancedSymbology::Injury::WeaponKill)); m_cbPpStatus->addItem(tr("Total Kill"), static_cast(AdvancedSymbology::Injury::TotalKill)); layoutAttrForm->addRow(new QLabel(tr("Status"), dlg), m_cbPpStatus); layoutAttrForm->addRow(new QLabel(tr("Team Color:"), dlg), m_cbPpTeamColor); layoutAttrForm->addRow(new QLabel(tr("Damage Team Color:"), dlg), m_cbPpTeamDColor); } layoutAttrForm->setLabelAlignment(Qt::AlignRight); layoutAttr->addStretch(2); } layoutSymbol->addStretch(2); layoutSymbol->addLayout(layoutLeftText); { m_lePpTextW = new QLineEdit(dlg); m_lePpTextW->setToolTip(tr("W")); m_lePpTextXY = new QLineEdit(dlg); m_lePpTextXY->setToolTip(tr("X|Y")); m_lePpTextV = new QLineEdit(dlg); m_lePpTextV->setToolTip(tr("V")); m_lePpTextT = new QLineEdit(dlg); m_lePpTextT->setToolTip(tr("T")); m_lePpTextZ = new QLineEdit(dlg); m_lePpTextZ->setToolTip(tr("Z")); layoutLeftText->setRowStretch(0, 0); layoutLeftText->setRowStretch(1, 0); layoutLeftText->setRowStretch(2, 0); layoutLeftText->setRowStretch(3, 0); layoutLeftText->setRowStretch(4, 0); layoutLeftText->setColumnStretch(0, 0); layoutLeftText->setColumnStretch(1, 2); layoutLeftText->addWidget(new QLabel(QStringLiteral("W")), 0, 0, Qt::Alignment::enum_type::AlignRight); layoutLeftText->addWidget(new QLabel(QStringLiteral("X|Y")), 1, 0, Qt::Alignment::enum_type::AlignRight); layoutLeftText->addWidget(new QLabel(QStringLiteral("V")), 2, 0, Qt::Alignment::enum_type::AlignRight); layoutLeftText->addWidget(new QLabel(QStringLiteral("T")), 3, 0, Qt::Alignment::enum_type::AlignRight); layoutLeftText->addWidget(new QLabel(QStringLiteral("Z")), 4, 0, Qt::Alignment::enum_type::AlignRight); layoutLeftText->addWidget(m_lePpTextW, 0, 1, Qt::Alignment::enum_type::AlignLeft); layoutLeftText->addWidget(m_lePpTextXY, 1, 1, Qt::Alignment::enum_type::AlignLeft); layoutLeftText->addWidget(m_lePpTextV, 2, 1, Qt::Alignment::enum_type::AlignLeft); layoutLeftText->addWidget(m_lePpTextT, 3, 1, Qt::Alignment::enum_type::AlignLeft); layoutLeftText->addWidget(m_lePpTextZ, 4, 1, Qt::Alignment::enum_type::AlignLeft); } layoutSymbol->addLayout(layoutSymbolView); { QPixmap symbolPixmap(QSize(200, 200)); symbolPixmap.fill(QColor(Qt::gray)); m_laPpView = new QLabel(dlg); m_laPpView->setPixmap(symbolPixmap); layoutSymbolView->addStretch(2); layoutSymbolView->addWidget(m_laPpView); layoutSymbolView->addStretch(2); } layoutSymbol->addLayout(layoutRightText); { m_lePpTextEF = new QLineEdit(dlg); m_lePpTextEF->setToolTip(tr("E|F")); m_lePpTextG = new QLineEdit(dlg); m_lePpTextG->setToolTip(tr("G")); m_lePpTextH = new QLineEdit(dlg); m_lePpTextH->setToolTip(tr("H")); m_lePpTextM = new QLineEdit(dlg); m_lePpTextM->setToolTip(tr("M")); m_lePpTextJ = new QLineEdit(dlg); m_lePpTextJ->setToolTip(tr("J|K|L|N|P")); layoutRightText->setRowStretch(0, 0); layoutRightText->setRowStretch(1, 0); layoutRightText->setRowStretch(2, 0); layoutRightText->setRowStretch(3, 0); layoutRightText->setRowStretch(4, 0); layoutRightText->setColumnStretch(0, 2); layoutRightText->setColumnStretch(1, 0); layoutRightText->addWidget(m_lePpTextEF, 0, 0, Qt::Alignment::enum_type::AlignLeft); layoutRightText->addWidget(m_lePpTextG, 1, 0, Qt::Alignment::enum_type::AlignLeft); layoutRightText->addWidget(m_lePpTextH, 2, 0, Qt::Alignment::enum_type::AlignLeft); layoutRightText->addWidget(m_lePpTextM, 3, 0, Qt::Alignment::enum_type::AlignLeft); layoutRightText->addWidget(m_lePpTextJ, 4, 0, Qt::Alignment::enum_type::AlignLeft); layoutRightText->addWidget(new QLabel(QStringLiteral("E|F")), 0, 1, Qt::Alignment::enum_type::AlignLeft); layoutRightText->addWidget(new QLabel(QStringLiteral("G")), 1, 1, Qt::Alignment::enum_type::AlignLeft); layoutRightText->addWidget(new QLabel(QStringLiteral("H")), 2, 1, Qt::Alignment::enum_type::AlignLeft); layoutRightText->addWidget(new QLabel(QStringLiteral("M")), 3, 1, Qt::Alignment::enum_type::AlignLeft); layoutRightText->addWidget(new QLabel(QStringLiteral("J|K|L|N|P")), 4, 1, Qt::Alignment::enum_type::AlignLeft); } layoutSymbol->addStretch(2); } layout->addStretch(2); m_cbPpStatus->connect(m_cbPpStatus, static_cast(&QComboBox::activated), m_self, [this](int idx) { m_ppState = static_cast(m_cbPpStatus->itemData(idx).toInt()); m_self->onChangedParticipant(); }); m_cbPpTeamColor->connect(m_cbPpTeamColor, static_cast(&QComboBox::activated), m_self, [this](int idx) { m_ppTeamColor = m_cbPpTeamColor->itemData(idx).toInt(); m_self->onChangedParticipant(); }); m_cbPpTeamDColor->connect(m_cbPpTeamDColor, static_cast(&QComboBox::activated), m_self, [this](int idx) { m_ppTeamDColor = m_cbPpTeamDColor->itemData(idx).toInt(); m_self->onChangedParticipant(); }); m_lePpTextW->connect(m_lePpTextW, &QLineEdit::textChanged, m_self, [this](const QString &text) { m_ppTextModifier[SituationMap::Participant::TextModifier::W_DateTimeGroup] = text; m_self->onChangedParticipant(); }); m_lePpTextXY->connect(m_lePpTextXY, &QLineEdit::textChanged, m_self, [this](const QString &text) { m_ppTextModifier[SituationMap::Participant::TextModifier::XY_AltitudeLocation] = text; m_self->onChangedParticipant(); }); m_lePpTextV->connect(m_lePpTextV, &QLineEdit::textChanged, m_self, [this](const QString &text) { m_ppTextModifier[SituationMap::Participant::TextModifier::V_Type] = text; m_self->onChangedParticipant(); }); m_lePpTextT->connect(m_lePpTextT, &QLineEdit::textChanged, m_self, [this](const QString &text) { m_ppTextModifier[SituationMap::Participant::TextModifier::T_UniqueDesignation] = text; m_self->onChangedParticipant(); }); m_lePpTextZ->connect(m_lePpTextZ, &QLineEdit::textChanged, m_self, [this](const QString &text) { m_ppTextModifier[SituationMap::Participant::TextModifier::Z_Speed] = text; m_self->onChangedParticipant(); }); m_lePpTextEF->connect(m_lePpTextEF, &QLineEdit::textChanged, m_self, [this](const QString &text) { m_ppTextModifier[SituationMap::Participant::TextModifier::EF_ReinforcedReduced] = text; m_self->onChangedParticipant(); }); m_lePpTextG->connect(m_lePpTextG, &QLineEdit::textChanged, m_self, [this](const QString &text) { m_ppTextModifier[SituationMap::Participant::TextModifier::G_StaffComments] = text; m_self->onChangedParticipant(); }); m_lePpTextH->connect(m_lePpTextH, &QLineEdit::textChanged, m_self, [this](const QString &text) { m_ppTextModifier[SituationMap::Participant::TextModifier::H_AdditionalInformation] = text; m_self->onChangedParticipant(); }); m_lePpTextM->connect(m_lePpTextM, &QLineEdit::textChanged, m_self, [this](const QString &text) { m_ppTextModifier[SituationMap::Participant::TextModifier::M_HigherFormation] = text; m_self->onChangedParticipant(); }); m_lePpTextJ->connect(m_lePpTextJ, &QLineEdit::textChanged, m_self, [this](const QString &text) { m_ppTextModifier[SituationMap::Participant::TextModifier::JKLNP] = text; m_self->onChangedParticipant(); }); m_self->onUpdateParticipantColors(); connect(&m_map->partyIdToColorFunctor() , &SituationMap::PartyIdToColorFunctor::partyChanged , m_self , &AttributeDialogManager::onUpdateParticipantColors); m_session.addOrReplaceWidget(dlg, m_planEditor->title(), QLatin1String("ParticipantAttributes"), LtsWidgets::LayoutArea::eDialogTab, true); QObject::connect(dlg, &Dialog::signalAboutToClose, m_self, [this]() { m_dlgSymbolParticipant.clear(); m_self->onCloseDialog(); }); TRACE_LOG(m_logger) << Q_FUNC_INFO << " END, this=" << this; return dlg; } void AttributeDialogManager::updateSelectedFeature(const QString &undoToken, SituationMap::GeometryModel::Attribute changedAttribute) { if (m_internal->m_blockUpdateSelectedFeature) return; m_internal->m_changedAttribute = changedAttribute; m_internal->m_planEditor->updateSelectedFeature(undoToken); m_internal->m_changedAttribute = SituationMap::GeometryModel::Attribute::None; } bool AttributeDialogManager::attributeNeedsUpdate(SituationMap::GeometryModel::Attribute attribute) { if (SituationMap::GeometryModel::Attribute::None == m_internal->m_changedAttribute) return false; if (SituationMap::GeometryModel::Attribute::Fill == m_internal->m_changedAttribute) { if (SituationMap::GeometryModel::Attribute::FillPattern == attribute) return true; } if (SituationMap::GeometryModel::Attribute::AnchorHorizontal == m_internal->m_changedAttribute) { if (SituationMap::GeometryModel::Attribute::AnchorVertical == attribute) return true; } if (SituationMap::GeometryModel::Attribute::LineColor == attribute) { return (SituationMap::GeometryModel::Attribute::Color == m_internal->m_changedAttribute); } if (SituationMap::GeometryModel::Attribute::Injury == attribute) { return m_internal->m_ppState.changed(); } if (SituationMap::GeometryModel::Attribute::ForceId == attribute) { return m_internal->m_ppTeamColor.changed(); } if (SituationMap::GeometryModel::Attribute::DamageForceId == attribute) { return m_internal->m_ppTeamDColor.changed(); } if (SituationMap::GeometryModel::Attribute::Text_EF == attribute) { return m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::EF_ReinforcedReduced].changed(); } if (SituationMap::GeometryModel::Attribute::Text_G == attribute) { return m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::G_StaffComments].changed(); } if (SituationMap::GeometryModel::Attribute::Text_H == attribute) { return m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::H_AdditionalInformation].changed(); } if (SituationMap::GeometryModel::Attribute::Text_KLNPJ == attribute) { return m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::JKLNP].changed(); } if (SituationMap::GeometryModel::Attribute::Text_M == attribute) { return m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::M_HigherFormation ].changed(); } if (SituationMap::GeometryModel::Attribute::Text_T == attribute) { return m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::T_UniqueDesignation].changed(); } if (SituationMap::GeometryModel::Attribute::Text_V == attribute) { return m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::V_Type].changed(); } if (SituationMap::GeometryModel::Attribute::Text_W == attribute) { return m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::W_DateTimeGroup].changed(); } if (SituationMap::GeometryModel::Attribute::Text_XY == attribute) { return m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::XY_AltitudeLocation].changed(); } if (SituationMap::GeometryModel::Attribute::Text_Z == attribute) { return m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::Z_Speed].changed(); } return (m_internal->m_changedAttribute == attribute); } void AttributeDialogManager::onSymbolChanged() { const QString &newSidc = m_internal->m_dlgSymbolModify->getWidget()->modifiedSidc(); const QString &lastSidc = m_internal->m_dlgSymbolModify->getWidget()->lastModifiedSidc(); AdvancedSymbology::SymbologyType symbologyType = m_internal->m_dlgSymbolModify->getWidget()->symbologyType(); QString sidcPattern; for (int i = 0; i < newSidc.size(); ++i) { sidcPattern += ((i >= lastSidc.size()) || (newSidc[i] != lastSidc[i])) ? newSidc[i] : QLatin1Char('*'); } if (AdvancedSymbology::SymbologyType::APP6B == symbologyType) { const unsigned int rawSidcOffset = AdvancedSymbology::SidcCodec::rawSidcOffset(); if (newSidc.size() > int(rawSidcOffset+11)) { if ((newSidc[rawSidcOffset + 10] != lastSidc[rawSidcOffset + 10]) || (newSidc[rawSidcOffset + 11] != lastSidc[rawSidcOffset + 11])) { sidcPattern[rawSidcOffset + 10] = newSidc[rawSidcOffset + 10]; sidcPattern[rawSidcOffset + 11] = newSidc[rawSidcOffset + 11]; } } } const QMap &fieldAttributes = m_internal->m_dlgSymbolModify->getWidget()->fieldAttributes(); const QString &symbolAttributes = m_internal->m_geoModel->buildSymbolAttributeString(fieldAttributes); m_internal->m_planEditor->onSymbolModified( symbologyType , sidcPattern , symbolAttributes , m_internal->m_ppState , m_internal->m_ppTeamColor , m_internal->m_ppTeamDColor , m_internal->m_ppTextModifier ); } void AttributeDialogManager::onUpdateParticipantColors() { if (!m_internal->m_map || !m_internal->m_cbPpTeamColor || !m_internal->m_cbPpTeamDColor) return; const SituationMap::PartyIdToColorFunctor &partyToColorFunctor = m_internal->m_map->partyIdToColorFunctor(); const QVector &partyColorIds = partyToColorFunctor.partyIds(); m_internal->m_cbPpTeamColor->clear(); m_internal->m_cbPpTeamDColor->clear(); m_internal->m_cbPpTeamColor->addItem(tr("None"), -1); m_internal->m_cbPpTeamDColor->addItem(tr("None"), -1); for (int partyId : partyColorIds) { const QColor &color = partyToColorFunctor.partyIdToColor(partyId); const QString &partyName = partyToColorFunctor.partyIdToName(partyId); const QString &colorLabel = QStringLiteral("%1(%2)").arg(partyName).arg(partyId); QPixmap colorIcon(30, 30); colorIcon.fill(color); m_internal->m_cbPpTeamColor->addItem(colorIcon, colorLabel, partyId); m_internal->m_cbPpTeamDColor->addItem(colorIcon, colorLabel, partyId); } } void AttributeDialogManager::onDrawColorEdit() { m_internal->updateDefaultColors(); m_internal->m_colorDialog->setCurrentColor(m_internal->m_color); if (m_internal->m_colorDialog->exec() == QDialog::Accepted) { m_internal->m_color = m_internal->m_colorDialog->currentColor(); colorizeButton(m_internal->m_tbColor, m_internal->m_color); updateSelectedFeature(tr("modify draw color", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::Color); } } void AttributeDialogManager::onFillColorEdit() { m_internal->updateDefaultColors(); m_internal->m_colorDialog->setCurrentColor(m_internal->m_fillColor); if (m_internal->m_colorDialog->exec() == QDialog::Accepted) { m_internal->m_fillColor = m_internal->m_colorDialog->currentColor(); colorizeButton(m_internal->m_tbFillColor, m_internal->m_fillColor); updateSelectedFeature(tr("modify fill color", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::FillColor); } } void AttributeDialogManager::onFontColorEdit() { m_internal->updateDefaultColors(); m_internal->m_colorDialog->setCurrentColor(m_internal->m_fontColor); if (m_internal->m_colorDialog->exec() == QDialog::Accepted) { m_internal->m_fontColor = m_internal->m_colorDialog->currentColor(); colorizeButton(m_internal->m_tbFontColor, m_internal->m_fontColor); updateSelectedFeature(tr("modify font color", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::Color); } } void AttributeDialogManager::onSetLinePattern(int index) { m_internal->m_linePattern = SituationMap::GeometryModel::LineStyle(m_internal->m_cmbLinePattern->itemData(index).toInt()); updateSelectedFeature(tr("modify line pattern", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::LineStyle); } void AttributeDialogManager::onSetLineWidth(int width) { m_internal->m_lineWidth = width; updateSelectedFeature(tr("modify line width", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::LineWidth); } void AttributeDialogManager::onSetFillPattern(int index) { m_internal->m_fillPattern = SituationMap::GeometryModel::FillPattern(m_internal->m_cmbFillPattern->itemData(index).toInt()); updateSelectedFeature(tr("modify fill pattern", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::FillPattern); } void AttributeDialogManager::onSetFillStyle(int index) { m_internal->m_fillStyle = SituationMap::GeometryModel::FillStyle(m_internal->m_cmbFillStyle->itemData(index).toInt()); updateSelectedFeature(tr("modify ellipse style", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::FillStyle); } void AttributeDialogManager::onSetLineArrowBegin(bool on) { m_internal->m_lineArrowBegin = on; updateSelectedFeature(tr("modify line arrow begin", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::Arrows); } void AttributeDialogManager::onSetLineArrowEnd(bool on) { m_internal->m_lineArrowEnd = on; updateSelectedFeature(tr("modify line arrow end", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::Arrows); } void AttributeDialogManager::onSetFilling(bool on) { if ((on) && (m_internal->m_fillPattern == SituationMap::GeometryModel::FillPattern::None)) { m_internal->m_fillPattern = SituationMap::GeometryModel::FillPattern::Solid; m_internal->m_cmbFillPattern -> setCurrentIndex(m_internal->m_cmbFillPattern->findData(int(m_internal->m_fillPattern))); } if (!on) { m_internal->m_fillPattern = SituationMap::GeometryModel::FillPattern::None; m_internal->m_cmbFillPattern -> setCurrentIndex(m_internal->m_cmbFillPattern->findData(int(m_internal->m_fillPattern))); } QString undoToken(on ? tr("set filling on", TR_UNDO_TOKEN) : tr("set filling off", TR_UNDO_TOKEN)); updateSelectedFeature(undoToken, SituationMap::GeometryModel::Attribute::Fill); } void AttributeDialogManager::onEditTextLines() { m_internal->m_textLines = m_internal->m_teText->toPlainText(); updateSelectedFeature(tr("modify text", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::MaxAttributes); } void AttributeDialogManager::onSetFontSize(double value) { m_internal->m_fontSize = value; updateSelectedFeature(tr("modify font size", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::FontSize); } void AttributeDialogManager::onSetFontFace(int index) { m_internal->m_fontFace = (SituationMap::GeometryModel::Font) m_internal->m_cmbFontFace->itemData(index).toInt(); updateSelectedFeature(tr("modify font face", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::Font); } void AttributeDialogManager::onSetFontBold(bool on) { m_internal->m_fontBold = on; QString undoToken(on ? tr("set text style weight to bold", TR_UNDO_TOKEN) : tr("set text style weight to normal", TR_UNDO_TOKEN)); updateSelectedFeature(undoToken, SituationMap::GeometryModel::Attribute::FontBold); } void AttributeDialogManager::onSetFontItalic(bool on) { m_internal->m_fontItalic = on; QString undoToken(on ? tr("set text style weight italic on", TR_UNDO_TOKEN) : tr("set text style italic off", TR_UNDO_TOKEN)); updateSelectedFeature(undoToken, SituationMap::GeometryModel::Attribute::FontItalic); } void AttributeDialogManager::onSetTextAnchor(bool) { const QToolButton *anchor = dynamic_cast(sender()); for (int r = 0; r < 3; ++r) { for (int c = 0; c < 3; ++c) { if (anchor == m_internal->m_tbTextAnchor[r][c]) { m_internal->m_tbTextAnchor[r][c]->setChecked(true); m_internal->m_fontHAnchor = SituationMap::GeometryModel::HorizontalAlign(c); m_internal->m_fontVAnchor = SituationMap::GeometryModel::VerticalAlign(2 - r); } else m_internal->m_tbTextAnchor[r][c]->setChecked(false); } } updateSelectedFeature(tr("modify text anchor", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::AnchorHorizontal); } void AttributeDialogManager::onRotateText(int value) { double phi = double(value + 90) / 180.0 * MathConst::pi; m_internal->m_slFontRotate->setValue(value); m_internal->m_sbFontRotate->setValue(360 - value); m_internal->m_fontOVec.setX(cos(phi)); m_internal->m_fontOVec.setY(sin(phi)); updateSelectedFeature(tr("modify text rotation", TR_UNDO_TOKEN), SituationMap::GeometryModel::Attribute::Rotate); } void AttributeDialogManager::onRotateTextSp(int value) { if (value == 360) value = 0; if (value == -1) value = 359; onRotateText(360 - value); } void AttributeDialogManager::onChangedParticipant() { if (!m_internal->m_dlgSymbolModify) return; if (!m_internal->m_map) return; const QString &sidc = m_internal->m_dlgSymbolModify->getWidget()->modifiedSidc(); int partyId = m_internal->m_ppTeamColor.value(); int damageId = m_internal->m_ppTeamDColor.value(); const SituationMap::PartyIdToColorFunctor &partyToColorFunctor = m_internal->m_map->partyIdToColorFunctor(); AdvancedSymbology::SymbolResultWatcher *symbolGuard = new AdvancedSymbology::SymbolResultWatcher(this); QLabel *lblToSet = m_internal->m_laPpView; if (!lblToSet) return; QObject::connect(symbolGuard, &AdvancedSymbology::SymbolResultWatcher::resultReady, lblToSet, [lblToSet, symbolGuard]() { QSharedPointer symbolResult = symbolGuard->symbolResult(); if (nullptr != symbolResult) { QPixmap symbolPixmap = QPixmap::fromImage(symbolResult->symbolImage().image()); if (symbolPixmap.width() > 200) symbolPixmap = symbolPixmap.scaledToWidth(200); if (symbolPixmap.height() > 200) symbolPixmap = symbolPixmap.scaledToHeight(200); lblToSet->setPixmap(symbolPixmap); } }); AdvancedSymbology::SymbolDataToRender symDataToRender(sidc); symDataToRender.fillColorReplace = (partyId >= 0); symDataToRender.fillColor = partyToColorFunctor.partyIdToColor(partyId); symDataToRender.injuryColor = partyToColorFunctor.partyIdToColor(damageId); symDataToRender.injury = m_internal->m_ppState.value(); symDataToRender.role = partyToColorFunctor.partyIdToRole(partyId); symbolGuard->setSymbolResult(m_internal->m_map->symbolDictionary().fetchSymbol(symDataToRender)); if (m_internal->m_dlgSymbolModify) { AdvancedSymbology::SymbologyType symbologyType = m_internal->m_dlgSymbolModify->getWidget()->symbologyType(); const QMap &fieldAttributes = m_internal->m_dlgSymbolModify->getWidget()->fieldAttributes(); const QString &symbolAttributes = m_internal->m_geoModel->buildSymbolAttributeString(fieldAttributes); m_internal->m_planEditor->onSymbolModified( symbologyType , QString().fill(QLatin1Char('*'),20) , symbolAttributes , m_internal->m_ppState , m_internal->m_ppTeamColor , m_internal->m_ppTeamDColor , m_internal->m_ppTextModifier); } } void AttributeDialogManager::addStyleAttributes(const SituationMap::GeometryModel::Node &node, bool prepareUndo, bool changedAttrOnly) { SituationMap::GeometryModel::PrimitiveType primitiveType = m_internal->m_geoModel->getType(node); QList supportedStyleAttributes = m_internal->m_geoModel->supportedAttributes(primitiveType); QList::iterator attrIt = supportedStyleAttributes.begin(); while (attrIt != supportedStyleAttributes.end()) { if (attributeNeedsUpdate(*attrIt)) { switch (*attrIt) { case SituationMap::GeometryModel::Attribute::Close: case SituationMap::GeometryModel::Attribute::Width: case SituationMap::GeometryModel::Attribute::Height: { attrIt = supportedStyleAttributes.erase(attrIt); } break; case SituationMap::GeometryModel::Attribute::Rotate: { if (primitiveType != SituationMap::GeometryModel::PrimitiveType::Text) attrIt = supportedStyleAttributes.erase(attrIt); else ++attrIt; } break; default: ++attrIt; break; } } else ++attrIt; } for (attrIt = supportedStyleAttributes.begin(); attrIt != supportedStyleAttributes.end(); ++attrIt) { if (changedAttrOnly && (!attributeNeedsUpdate(*attrIt))) continue; QVariant attrValue; switch (*attrIt) { case SituationMap::GeometryModel::Attribute::Arrows: { if (m_internal->m_lineArrowBegin) { if (m_internal->m_lineArrowEnd) attrValue = int(SituationMap::GeometryModel::Arrows::Both); else attrValue = int(SituationMap::GeometryModel::Arrows::Start); } else { if (m_internal->m_lineArrowEnd) attrValue = int(SituationMap::GeometryModel::Arrows::End); else attrValue = int(SituationMap::GeometryModel::Arrows::NoArrows); } } break; case SituationMap::GeometryModel::Attribute::LineWidth : attrValue = m_internal->m_lineWidth; break; case SituationMap::GeometryModel::Attribute::Color : attrValue = (primitiveType == SituationMap::GeometryModel::PrimitiveType::Text) ? m_internal->m_fontColor : m_internal->m_color; break; case SituationMap::GeometryModel::Attribute::Fill : attrValue = (m_internal->m_fillPattern != SituationMap::GeometryModel::FillPattern::None); break; case SituationMap::GeometryModel::Attribute::FillColor : attrValue = m_internal->m_fillColor; break; case SituationMap::GeometryModel::Attribute::FillPattern : attrValue = int(m_internal->m_fillPattern); break; case SituationMap::GeometryModel::Attribute::FillStyle : attrValue = int(m_internal->m_fillStyle); break; case SituationMap::GeometryModel::Attribute::LineColor : attrValue = m_internal->m_color; break; case SituationMap::GeometryModel::Attribute::LineStyle : attrValue = int(m_internal->m_linePattern); break; case SituationMap::GeometryModel::Attribute::Font : attrValue = int(m_internal->m_fontFace); break; case SituationMap::GeometryModel::Attribute::FontSize : attrValue = m_internal->m_fontSize; break; case SituationMap::GeometryModel::Attribute::FontBold : attrValue = m_internal->m_fontBold; break; case SituationMap::GeometryModel::Attribute::FontItalic : attrValue = m_internal->m_fontItalic; break; case SituationMap::GeometryModel::Attribute::AnchorHorizontal : attrValue = int(m_internal->m_fontHAnchor); break; case SituationMap::GeometryModel::Attribute::AnchorVertical : attrValue = int(m_internal->m_fontVAnchor); break; case SituationMap::GeometryModel::Attribute::Rotate: { if (primitiveType == SituationMap::GeometryModel::PrimitiveType::Text) attrValue = SituationMap::MathUtils::getMathAngle(m_internal->m_fontOVec) * 180.0 / MathConst::pi; } break; case SituationMap::GeometryModel::Attribute::Injury : attrValue = int(m_internal->m_ppState.value()); break; case SituationMap::GeometryModel::Attribute::ForceId : attrValue = m_internal->m_ppTeamColor.value(); break; case SituationMap::GeometryModel::Attribute::DamageForceId : attrValue = m_internal->m_ppTeamDColor.value(); break; case SituationMap::GeometryModel::Attribute::Text_EF : { attrValue = m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::EF_ReinforcedReduced].value(); } break; case SituationMap::GeometryModel::Attribute::Text_G : { attrValue = m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::G_StaffComments].value(); } break; case SituationMap::GeometryModel::Attribute::Text_H : { attrValue = m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::H_AdditionalInformation].value(); } break; case SituationMap::GeometryModel::Attribute::Text_KLNPJ : { attrValue = m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::JKLNP].value(); } break; case SituationMap::GeometryModel::Attribute::Text_M : { attrValue = m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::M_HigherFormation].value(); } break; case SituationMap::GeometryModel::Attribute::Text_T : { attrValue = m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::T_UniqueDesignation].value(); } break; case SituationMap::GeometryModel::Attribute::Text_V : { attrValue = m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::V_Type].value(); } break; case SituationMap::GeometryModel::Attribute::Text_W : { attrValue = m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::W_DateTimeGroup].value(); } break; case SituationMap::GeometryModel::Attribute::Text_XY : { attrValue = m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::XY_AltitudeLocation].value(); } break; case SituationMap::GeometryModel::Attribute::Text_Z : { attrValue = m_internal->m_ppTextModifier[SituationMap::Participant::TextModifier::Z_Speed].value(); } break; default: break; } if (attrValue.isValid()) { if (prepareUndo) { m_internal->m_geoModel->startUndoBlock(); m_internal->m_geoModel->setPrimitiveAttribute(node, *attrIt, attrValue); m_internal->m_geoModel->endUndoBlock(tr("modifiy feature style", TR_UNDO_TOKEN)); } else m_internal->m_geoModel->setPrimitiveAttribute(node, *attrIt, attrValue); } } if (attributeNeedsUpdate(SituationMap::GeometryModel::Attribute::MaxAttributes)) m_internal->m_geoModel->setTextData(node, textLines(), SituationMap::GeometryModel::HorizontalAlign::Left); } void AttributeDialogManager::getStyleAttributes(const SituationMap::GeometryModel::Node &node) { TRACE_LOG(m_internal->m_logger) << Q_FUNC_INFO << " START " << ", m_dlgSymbolModify= " << m_internal->m_dlgSymbolModify << ", m_dlgSymbolXML= " << m_internal->m_dlgSymbolXML; onResetWidgets(); m_internal->m_blockUpdateSelectedFeature = true; SituationMap::GeometryModel::PrimitiveType primitiveType = m_internal->m_geoModel->getType(node); const QList &supportedStyleAttributes = m_internal->m_geoModel->supportedAttributes(primitiveType); for (auto attr : supportedStyleAttributes) { QVariant attrValue = m_internal->m_geoModel->getAttribute(node, attr); if (attrValue.isValid()) { switch (attr) { case SituationMap::GeometryModel::Attribute::Color: { if (SituationMap::GeometryModel::PrimitiveType::Text == primitiveType) { m_internal->m_fontColor = attrValue.value(); colorizeButton(m_internal->m_tbFontColor, m_internal->m_fontColor); } else { m_internal->m_color = attrValue.value(); colorizeButton(m_internal->m_tbColor, m_internal->m_color); } } break; case SituationMap::GeometryModel::Attribute::Fill: { if (m_internal->m_cbFill) m_internal->m_cbFill->setChecked(attrValue.toBool()); } break; case SituationMap::GeometryModel::Attribute::FillColor: { m_internal->m_fillColor = attrValue.value(); colorizeButton(m_internal->m_tbFillColor, m_internal->m_fillColor); } break; case SituationMap::GeometryModel::Attribute::FillPattern: { m_internal->m_fillPattern = SituationMap::GeometryModel::FillPattern(attrValue.toInt()); if (m_internal->m_cmbFillPattern) m_internal->m_cmbFillPattern -> setCurrentIndex(m_internal->m_cmbFillPattern->findData(int(m_internal->m_fillPattern))); } break; case SituationMap::GeometryModel::Attribute::FillStyle: { m_internal->m_fillStyle = SituationMap::GeometryModel::FillStyle(attrValue.toInt()); if (m_internal->m_cmbFillStyle) m_internal->m_cmbFillStyle -> setCurrentIndex(m_internal->m_cmbFillStyle->findData(int(m_internal->m_fillStyle))); } break; case SituationMap::GeometryModel::Attribute::LineColor: { m_internal->m_color = attrValue.value(); colorizeButton(m_internal->m_tbColor, m_internal->m_color); } break; case SituationMap::GeometryModel::Attribute::LineStyle: { m_internal->m_linePattern = SituationMap::GeometryModel::LineStyle(attrValue.toInt()); if (m_internal->m_cmbLinePattern) m_internal->m_cmbLinePattern -> setCurrentIndex(m_internal->m_cmbLinePattern->findData(int(m_internal->m_linePattern))); } break; case SituationMap::GeometryModel::Attribute::LineWidth: { m_internal->m_lineWidth = attrValue.toInt(); if (m_internal->m_sbLineWidth) m_internal->m_sbLineWidth->setValue(m_internal->m_lineWidth); } break; case SituationMap::GeometryModel::Attribute::Arrows: { SituationMap::GeometryModel::Arrows arrows = (SituationMap::GeometryModel::Arrows) attrValue.toInt(); if (m_internal->m_cbArrowBegin && m_internal->m_cbArrowEnd) { m_internal->m_cbArrowBegin -> setChecked(false); m_internal->m_cbArrowEnd -> setChecked(false); switch (arrows) { case SituationMap::GeometryModel::Arrows::Both : m_internal->m_cbArrowEnd -> setChecked(true); Q_FALLTHROUGH(); case SituationMap::GeometryModel::Arrows::Start : m_internal->m_cbArrowBegin -> setChecked(true); break; case SituationMap::GeometryModel::Arrows::End : m_internal->m_cbArrowEnd -> setChecked(true); break; case SituationMap::GeometryModel::Arrows::NoArrows : default: break; } } } break; case SituationMap::GeometryModel::Attribute::Font: { m_internal->m_fontFace = SituationMap::GeometryModel::Font(attrValue.toInt()); if (m_internal->m_cmbFontFace) m_internal->m_cmbFontFace->setCurrentIndex(m_internal->m_cmbFontFace->findData(int(m_internal->m_fontFace))); } break; case SituationMap::GeometryModel::Attribute::FontSize: { bool ok = false; double val = attrValue.toDouble(&ok); if ((ok) && (val > 5.0)) m_internal->m_fontSize = val; if (m_internal->m_dsbFontSize) m_internal->m_dsbFontSize->setValue(m_internal->m_fontSize); } break; case SituationMap::GeometryModel::Attribute::FontBold: { m_internal->m_fontBold = attrValue.toBool(); if (m_internal->m_tbStyleBold) m_internal->m_tbStyleBold->setChecked(m_internal->m_fontBold); } break; case SituationMap::GeometryModel::Attribute::FontItalic: { m_internal->m_fontItalic = attrValue.toBool(); if (m_internal->m_tbStyleItalic) m_internal->m_tbStyleItalic->setChecked(m_internal->m_fontItalic); } break; case SituationMap::GeometryModel::Attribute::AnchorHorizontal: { m_internal->m_fontHAnchor = SituationMap::GeometryModel::HorizontalAlign(attrValue.toInt()); } break; case SituationMap::GeometryModel::Attribute::AnchorVertical: { m_internal->m_fontVAnchor = SituationMap::GeometryModel::VerticalAlign(attrValue.toInt()); } break; case SituationMap::GeometryModel::Attribute::Rotate: { const double phi = attrValue.toDouble() / 180.0 * MathConst::pi; m_internal->m_fontOVec.setX(cos(phi)); m_internal->m_fontOVec.setY(sin(phi)); int value = qRound(attrValue.toDouble() - 90); if (value < 0) value = 360 + value; if (m_internal->m_slFontRotate) m_internal->m_slFontRotate->setValue(value); if (m_internal->m_sbFontRotate) m_internal->m_sbFontRotate->setValue(360 - value); } break; case SituationMap::GeometryModel::Attribute::SIDC: { if (m_internal->m_dlgSymbolModify) { m_internal->m_dlgSymbolModify->getWidget()->blockSignals(true); m_internal->m_dlgSymbolModify->getWidget()->setSidc(attrValue.toString()); m_internal->m_dlgSymbolModify->getWidget()->blockSignals(false); } } break; case SituationMap::GeometryModel::Attribute::SIDC_Attributes: { if (m_internal->m_dlgSymbolModify) { QMap attrMap; const QString &symbolFieldAttr = m_internal->m_geoModel->getAttribute(node, SituationMap::GeometryModel::Attribute::SIDC_Attributes).toString(); m_internal -> m_geoModel->parseSymbolAttributeString(symbolFieldAttr, attrMap); m_internal->m_dlgSymbolModify->getWidget()->blockSignals(true); m_internal->m_dlgSymbolModify->getWidget()->setFieldAttributes(attrMap); m_internal->m_dlgSymbolModify->getWidget()->blockSignals(false); } } break; case SituationMap::GeometryModel::Attribute::Injury: { if (m_internal->m_dlgSymbolModify) { AdvancedSymbology::Injury injury = static_cast(m_internal->m_geoModel->getAttribute(node, SituationMap::GeometryModel::Attribute::Injury).toInt()); m_internal->setParticipantState(injury); } } break; case SituationMap::GeometryModel::Attribute::ForceId: { if (m_internal->m_dlgSymbolModify) { int partyId = m_internal->m_geoModel->getAttribute(node, SituationMap::GeometryModel::Attribute::ForceId).toInt(); m_internal->setParticipantPartyId(partyId); } } break; case SituationMap::GeometryModel::Attribute::DamageForceId: { if (m_internal->m_dlgSymbolModify) { int damageId = m_internal->m_geoModel->getAttribute(node, SituationMap::GeometryModel::Attribute::DamageForceId).toInt(); m_internal->setParticipantDamageId(damageId); } } break; case SituationMap::GeometryModel::Attribute::Text_EF: { if (m_internal->m_dlgSymbolModify) { const QString &text = m_internal->m_geoModel->getAttribute(node, attr).toString(); m_internal->setParticipantTextModifier(SituationMap::Participant::TextModifier::EF_ReinforcedReduced,text); } } break; case SituationMap::GeometryModel::Attribute::Text_G: { if (m_internal->m_dlgSymbolModify) { const QString &text = m_internal->m_geoModel->getAttribute(node, attr).toString(); m_internal->setParticipantTextModifier(SituationMap::Participant::TextModifier::G_StaffComments,text); } } break; case SituationMap::GeometryModel::Attribute::Text_H: { if (m_internal->m_dlgSymbolModify) { const QString &text = m_internal->m_geoModel->getAttribute(node, attr).toString(); m_internal->setParticipantTextModifier(SituationMap::Participant::TextModifier::H_AdditionalInformation,text); } } break; case SituationMap::GeometryModel::Attribute::Text_KLNPJ: { if (m_internal->m_dlgSymbolModify) { const QString &text = m_internal->m_geoModel->getAttribute(node, attr).toString(); m_internal->setParticipantTextModifier(SituationMap::Participant::TextModifier::JKLNP, text); } } break; case SituationMap::GeometryModel::Attribute::Text_M: { if (m_internal->m_dlgSymbolModify) { const QString &text = m_internal->m_geoModel->getAttribute(node, attr).toString(); m_internal->setParticipantTextModifier(SituationMap::Participant::TextModifier::M_HigherFormation, text); } } break; case SituationMap::GeometryModel::Attribute::Text_T: { if (m_internal->m_dlgSymbolModify) { const QString &text = m_internal->m_geoModel->getAttribute(node, attr).toString(); m_internal->setParticipantTextModifier(SituationMap::Participant::TextModifier::T_UniqueDesignation, text); } } break; case SituationMap::GeometryModel::Attribute::Text_V: { if (m_internal->m_dlgSymbolModify) { const QString &text = m_internal->m_geoModel->getAttribute(node, attr).toString(); m_internal->setParticipantTextModifier(SituationMap::Participant::TextModifier::V_Type, text); } } break; case SituationMap::GeometryModel::Attribute::Text_W: { if (m_internal->m_dlgSymbolModify) { const QString &text = m_internal->m_geoModel->getAttribute(node, attr).toString(); m_internal->setParticipantTextModifier(SituationMap::Participant::TextModifier::W_DateTimeGroup, text); } } break; case SituationMap::GeometryModel::Attribute::Text_XY: { if (m_internal->m_dlgSymbolModify) { const QString &text = m_internal->m_geoModel->getAttribute(node, attr).toString(); m_internal->setParticipantTextModifier(SituationMap::Participant::TextModifier::XY_AltitudeLocation, text); } } break; case SituationMap::GeometryModel::Attribute::Text_Z: { if (m_internal->m_dlgSymbolModify) { const QString &text = m_internal->m_geoModel->getAttribute(node, attr).toString(); m_internal->setParticipantTextModifier(SituationMap::Participant::TextModifier::Z_Speed, text); } } break; default: break; } } } for (int r = 0; r < 3; ++r) { for (int c = 0; c < 3; ++c) { if (nullptr != m_internal->m_tbTextAnchor[r][c]) m_internal->m_tbTextAnchor[r][c]->setChecked(((int(m_internal->m_fontHAnchor) == c) && (int(m_internal->m_fontVAnchor) == (2 - r)))); } } if (m_internal->m_teText) m_internal->m_teText->setPlainText(m_internal->m_geoModel->getTextData(node)); m_internal->m_blockUpdateSelectedFeature = false; } }