[TD]code review changes for dgh, dpg, dpgi, dra

This commit is contained in:
Wanderer Fan
2022-08-18 15:24:21 -04:00
committed by WandererFan
parent 644b4991e2
commit e8a25a8fdf
4 changed files with 40 additions and 31 deletions

View File

@@ -186,8 +186,8 @@ void DrawGeomHatch::makeLineSets()
std::vector<LineSet> DrawGeomHatch::makeLineSets(std::string fileSpec, std::string myPattern)
{
std::vector<LineSet> lineSets;
if ((!fileSpec.empty()) &&
(!myPattern.empty())) {
if (!fileSpec.empty() &&
!myPattern.empty()) {
std::vector<PATLineSpec> specs =
DrawGeomHatch::getDecodedSpecsFromFile(fileSpec,
myPattern);

View File

@@ -131,13 +131,14 @@ void DrawProjGroup::onChanged(const App::Property* prop)
return;
}
if ( (prop == &Source) ||
(prop == &XSource) ) {
if ( prop == &Source ||
prop == &XSource ) {
updateChildrenSource();
return;
}
if ((prop == &spacingX) || (prop == &spacingY)) {
if ( prop == &spacingX ||
prop == &spacingY ) {
updateChildrenEnforce();
return;
}
@@ -148,21 +149,21 @@ void DrawProjGroup::onChanged(const App::Property* prop)
}
if (prop == &ScaleType) {
if (ScaleType.isValue("Automatic")) {
//Nothing in particular
} else if (ScaleType.isValue("Page")) {
if (ScaleType.isValue("Page")) {
double newScale = page->Scale.getValue();
if(std::abs(getScale() - newScale) > FLT_EPSILON) {
Scale.setValue(newScale);
updateChildrenScale();
}
} else {
//ScaleType = Custom
}
//DrawView will sort out Scale hidden/readonly/etc
TechDraw::DrawViewCollection::onChanged(prop);
}
// if ( ScaleType.isValue("Automatic") ||
// ScaleType.isValue("Custom") ){
// //just documenting that nothing is required here
// //DrawView::onChanged will sort out Scale hidden/readonly/etc
// }
if (prop == &Rotation) {
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
Rotation.setValue(0.0);
@@ -284,8 +285,8 @@ bool DrawProjGroup::checkFit(DrawPage* page) const
}
QRectF bigBox = getRect(false);
if ( (bigBox.width() <= page->getPageWidth()) &&
(bigBox.height() <= page->getPageHeight()) ) {
if ( bigBox.width() <= page->getPageWidth() &&
bigBox.height() <= page->getPageHeight() ) {
return true;
}
return false;

View File

@@ -344,16 +344,23 @@ double DrawProjGroupItem::getScale(void) const
void DrawProjGroupItem::unsetupObject()
{
if (getPGroup()) {
if (getPGroup()->hasProjection(Type.getValueAsString()) ) {
if ((getPGroup()->getAnchor() == this) &&
!getPGroup()->isUnsetting() ) {
Base::Console().Warning("Warning - DPG (%s/%s) may be corrupt - Anchor deleted\n",
getPGroup()->getNameInDocument(),getPGroup()->Label.getValue());
getPGroup()->Anchor.setValue(nullptr); //this catches situation where DPGI is deleted w/o DPG::removeProjection
}
}
if (!getPGroup()) {
DrawViewPart::unsetupObject();
return;
}
if (!getPGroup()->hasProjection(Type.getValueAsString()) ) {
DrawViewPart::unsetupObject();
return;
}
if ( getPGroup()->getAnchor() == this &&
!getPGroup()->isUnsetting() ) {
Base::Console().Warning("Warning - DPG (%s/%s) may be corrupt - Anchor deleted\n",
getPGroup()->getNameInDocument(),getPGroup()->Label.getValue());
getPGroup()->Anchor.setValue(nullptr); //this catches situation where DPGI is deleted w/o DPG::removeProjection
}
DrawViewPart::unsetupObject();
}

View File

@@ -94,7 +94,7 @@ App::DocumentObjectExecReturn *DrawRichAnno::execute()
// Base::Console().Message("DRA::execute() - @ (%.3f, %.3f)\n", X.getValue(), Y.getValue());
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
}
overrideKeepUpdated(false);
return DrawView::execute();
}
@@ -111,15 +111,16 @@ DrawView* DrawRichAnno::getBaseView() const
DrawPage* DrawRichAnno::findParentPage() const
{
// Base::Console().Message("DRA::findParentPage()\n");
DrawPage *page = nullptr;
if (AnnoParent.getValue() != nullptr) {
DrawView* parent = dynamic_cast<DrawView*>(AnnoParent.getValue());
page = parent->findParentPage();
} else {
page = DrawView::findParentPage();
if (!AnnoParent.getValue()) {
return DrawView::findParentPage();
}
return page;
DrawView* parent = dynamic_cast<DrawView*>(AnnoParent.getValue());
if (parent) {
return parent->findParentPage();
}
return nullptr;
}
PyObject *DrawRichAnno::getPyObject()