[TD]Fix section snapping (fix #15961) (#15450)

* [TD]Add view snapping preferences

* [TD]fix section snapping algo

- snap sections to section normal line.
- snap views to other views in X&Y

* [TD]fix snapping to ProjectionGroups
This commit is contained in:
WandererFan
2024-09-02 12:41:25 -04:00
committed by GitHub
parent 57cf34828b
commit 140bcf605e
12 changed files with 404 additions and 119 deletions

View File

@@ -42,9 +42,10 @@
#include "DrawUtil.h"
#include "DrawViewClip.h"
#include "DrawViewCollection.h"
#include "DrawProjGroup.h"
#include "DrawProjGroupItem.h"
#include "Preferences.h"
using namespace TechDraw;
using DU = DrawUtil;
@@ -652,6 +653,22 @@ void DrawView::setScaleAttribute()
}
}
//! due to changes made for the "intelligent" view creation tool, testing for a view being an
//! instance of DrawProjGroupItem is no longer reliable, as views not in a group are sometimes
//! created as DrawProjGroupItem without belonging to a group. We now need to test for the existance
//! of the parent DrawProjGroup
bool DrawView::isProjGroupItem(DrawViewPart* item)
{
auto dpgi = dynamic_cast<DrawProjGroupItem*>(item);
if (!dpgi) {
return false;
}
auto group = dpgi->getPGroup();
if (!group) {
return false;
}
return true;
}
int DrawView::prefScaleType()
{
return Preferences::getPreferenceGroup("General")->GetInt("DefaultScaleType", 0);