[TD]prevent Complex Section with no Base View

This commit is contained in:
wandererfan
2022-11-14 16:03:21 -05:00
committed by WandererFan
parent 33bee19d81
commit 356faf94da
3 changed files with 28 additions and 12 deletions

View File

@@ -801,11 +801,13 @@ Base::Vector3d DrawViewSection::getXDirection() const
//we have an XDirection property
if (DrawUtil::fpCompare(XDirection.getValue().Length(), 0.0)) {
//but it has no value, so we make a value
gp_Ax2 cs = getCSFromBase(SectionDirection.getValueAsString());
gp_Dir gXDir = cs.XDirection();
result = Base::Vector3d(gXDir.X(),
gXDir.Y(),
gXDir.Z());
if (BaseView.getValue()) {
gp_Ax2 cs = getCSFromBase(SectionDirection.getValueAsString());
gp_Dir gXDir = cs.XDirection();
result = Base::Vector3d(gXDir.X(),
gXDir.Y(),
gXDir.Z());
}
} else {
//XDirection is good, so we use it
result = XDirection.getValue();

View File

@@ -737,6 +737,12 @@ void execComplexSection(Gui::Command* cmd)
}
}
if (!baseView) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("I do not know what base view to use."));
return;
}
if (shapes.empty() &&
xShapes.empty() &&
!baseView) {

View File

@@ -91,11 +91,13 @@ TaskComplexSection::TaskComplexSection(TechDraw::DrawPage* page,
m_directionIsSet(false)
{
m_sectionName = std::string();
m_doc = m_baseView->getDocument();
m_saveBaseName = m_baseView->getNameInDocument();
m_savePageName = m_baseView->findParentPage()->getNameInDocument();
if (m_page) {
m_doc = m_page->getDocument();
m_savePageName = m_page->getNameInDocument();
}
if (m_baseView) {
m_saveBaseName = m_baseView->getNameInDocument();
}
ui->setupUi(this);
saveSectionState();
@@ -120,11 +122,14 @@ TaskComplexSection::TaskComplexSection(TechDraw::DrawComplexSection* complexSect
{
m_sectionName = m_section->getNameInDocument();
m_doc = m_section->getDocument();
m_page = m_section->findParentPage();
m_savePageName = m_page->getNameInDocument();
m_baseView = dynamic_cast<TechDraw::DrawViewPart*> (m_section->BaseView.getValue());
if (m_baseView) {
m_saveBaseName = m_baseView->getNameInDocument();
m_savePageName = m_baseView->findParentPage()->getNameInDocument();
}
m_shapes = m_section->Source.getValues();
m_xShapes = m_section->XSource.getValues();
m_profileObject = m_section->CuttingToolWireObject.getValue();
@@ -305,7 +310,10 @@ void TaskComplexSection::slotViewDirectionChanged(Base::Vector3d newDirection)
{
// Base::Console().Message("TCS::slotViewDirectionChanged(%s)\n",
// DrawUtil::formatVector(newDirection).c_str());
Base::Vector3d projectedViewDirection = m_baseView->projectPoint(newDirection, false);
Base::Vector3d projectedViewDirection = newDirection;
if (m_baseView) {
projectedViewDirection = m_baseView->projectPoint(newDirection, false);
}
projectedViewDirection.Normalize();
double viewAngle = atan2(projectedViewDirection.y,
projectedViewDirection.x);