[TD] fix centerline crashes and bugs

the PR fixes the following things:
- change the way centerlines between 2 lines are calculated. The current implementation leads to many bugs and even crashes (e.g. when the 2 selected lines are parallel ones of a square). There are different forum threads from the last 1.5 years.
The new endpoint line sorting is the one described here: https://forum.freecadweb.org/viewtopic.php?f=35&start=20&t=44255&sid=989a668890f954c13ef81e4a04ee6912#p501179

- as consequence the erroneous and misleading line end flipping can go and is removed (only used internally)

- when creating a new centerline, you see it immediately

- when creating a new or editing an existing centerline and press Cancel, the creation/editing is aborted

- fix crash when the 2 selected lines are bot horizontal and one tries to create a vertical centerline

- fix crash when changing the orientation  of an existing centerline and the result would be invalid

- cleanup the code a bit
This commit is contained in:
donovaly
2021-05-14 23:48:12 +02:00
parent bb434d3ff2
commit 2bc5ac2e4b
5 changed files with 173 additions and 155 deletions

View File

@@ -94,24 +94,16 @@ public:
void saveButtons(QPushButton* btnOK,
QPushButton* btnCancel);
void enableTaskButtons(bool b);
void setFlipped(bool b);
protected Q_SLOTS:
protected:
void changeEvent(QEvent *e);
void blockButtons(bool b);
void setUiConnect(void);
void setUiPrimary(void);
void setUiEdit(void);
void createCenterLine(void);
void create2Lines(void);
void create2Points(void);
void updateCenterLine(void);
void update2Lines(void);
void update2Points(void);
void updateOrientation(void);
double getCenterWidth();
QColor getCenterColor();
@@ -127,7 +119,6 @@ private Q_SLOTS:
void onColorChanged();
void onWeightChanged();
void onStyleChanged();
void onFlipChanged();
private:
std::unique_ptr<Ui_TaskCenterLine> ui;
@@ -144,6 +135,7 @@ private:
double m_extendBy;
int m_geomIndex;
TechDraw::CenterLine* m_cl;
TechDraw::CenterLine orig_cl;
int m_clIdx;
int m_type;
int m_mode;