diff --git a/src/Mod/TechDraw/Gui/TaskComplexSection.cpp b/src/Mod/TechDraw/Gui/TaskComplexSection.cpp index 0f397a47f7..9b997a18f0 100644 --- a/src/Mod/TechDraw/Gui/TaskComplexSection.cpp +++ b/src/Mod/TechDraw/Gui/TaskComplexSection.cpp @@ -561,19 +561,20 @@ void TaskComplexSection::createComplexSection() Command::doCommand(Command::Doc, "App.ActiveDocument.addObject('TechDraw::DrawComplexSection', '%s')", m_sectionName.c_str()); - std::string uniqueSuffix{m_sectionName.substr(objectName.length(), std::string::npos)}; - std::string uniqueLabel = "Section" + uniqueSuffix; - Command::doCommand(Command::Doc, "App.activeDocument().%s.translateLabel('DrawComplexSection', 'Section', '%s')", - m_sectionName.c_str(), uniqueLabel.c_str()); - - Command::doCommand(Command::Doc, "App.ActiveDocument.%s.addView(App.ActiveDocument.%s)", - m_page->getNameInDocument(), m_sectionName.c_str()); - + // section labels (Section A-A) are not unique, and are not the same as the object name (SectionView) + // we pluck the generated suffix from the object name and append it to "Section" to generate + // unique Labels QString qTemp = ui->leSymbol->text(); std::string temp = Base::Tools::toStdString(qTemp); Command::doCommand(Command::Doc, "App.ActiveDocument.%s.SectionSymbol = '%s'", m_sectionName.c_str(), temp.c_str()); + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Label = '%s'", + m_sectionName.c_str(), + makeSectionLabel(qTemp).c_str()); + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.addView(App.ActiveDocument.%s)", + m_page->getNameInDocument(), m_sectionName.c_str()); + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Scale = %0.6f", m_sectionName.c_str(), ui->sbScale->value()); int scaleType = ui->cmbScaleType->currentIndex(); @@ -646,10 +647,12 @@ void TaskComplexSection::updateComplexSection() std::string temp = Base::Tools::toStdString(qTemp); Command::doCommand(Command::Doc, "App.ActiveDocument.%s.SectionSymbol = '%s'", m_sectionName.c_str(), temp.c_str()); - std::string lblText = std::string(m_section->Label.getValue()) + " " + temp + " - " + temp; - Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Label = '%s'", - m_sectionName.c_str(), lblText.c_str()); + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Label = '%s'", + m_sectionName.c_str(), + makeSectionLabel(qTemp).c_str()); + Command::doCommand(Command::Doc, "App.activeDocument().%s.translateLabel('DrawViewSection', 'Section', '%s')", + m_sectionName.c_str(), makeSectionLabel(qTemp).c_str()); Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Scale = %0.6f", m_sectionName.c_str(), ui->sbScale->value()); @@ -684,6 +687,15 @@ void TaskComplexSection::updateComplexSection() Gui::Command::commitCommand(); } +std::string TaskComplexSection::makeSectionLabel(QString symbol) +{ + const std::string objectName{QT_TR_NOOP("ComplexSection")}; + std::string uniqueSuffix{m_sectionName.substr(objectName.length(), std::string::npos)}; + std::string uniqueLabel = "Section" + uniqueSuffix; + std::string temp = Base::Tools::toStdString(symbol); + return ( uniqueLabel + " " + temp + " - " + temp ); +} + void TaskComplexSection::failNoObject(void) { QString qsectionName = Base::Tools::fromStdString(m_sectionName); diff --git a/src/Mod/TechDraw/Gui/TaskComplexSection.h b/src/Mod/TechDraw/Gui/TaskComplexSection.h index 4adaeb1a1b..9a95780ea7 100644 --- a/src/Mod/TechDraw/Gui/TaskComplexSection.h +++ b/src/Mod/TechDraw/Gui/TaskComplexSection.h @@ -107,6 +107,7 @@ protected Q_SLOTS: private: double requiredRotation(double inputAngle); + std::string makeSectionLabel(QString symbol); void createComplexSection(); void updateComplexSection();