[TD]fix label generation complex section

This commit is contained in:
wandererfan
2023-09-10 10:10:19 -04:00
committed by WandererFan
parent cf94a892d6
commit 114e6ca2a9
2 changed files with 24 additions and 11 deletions

View File

@@ -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);

View File

@@ -107,6 +107,7 @@ protected Q_SLOTS:
private:
double requiredRotation(double inputAngle);
std::string makeSectionLabel(QString symbol);
void createComplexSection();
void updateComplexSection();