diff --git a/mouse.cpp b/mouse.cpp index b45d139e..9e9590b3 100644 --- a/mouse.cpp +++ b/mouse.cpp @@ -460,6 +460,24 @@ void GraphicsWindow::MouseRightUp(double x, double y) { CMNU_OTHER_ANGLE); } } + if(hover.entity.v) { + Entity *p = SK.GetEntity(hover.entity); + if(p->IsPoint()) { + Constraint *c; + IdList *lc = &(SK.constraint); + for(c = lc->First(); c; c = lc->NextAfter(c)) { + if(c->type != Constraint::POINTS_COINCIDENT) continue; + if(c->ptA.v == p->h.v || c->ptB.v == p->h.v) { + break; + } + } + if(c) { + AddContextMenuItem( + "Hovered: Delete Point-Coincident Constraint", + CMNU_DEL_COINCIDENT); + } + } + } if(hover.HasEndpoints()) { AddContextMenuItem("Hovered: Select Edge Chain", CMNU_SELECT_CHAIN); } @@ -495,7 +513,7 @@ void GraphicsWindow::MouseRightUp(double x, double y) { } int ret = ShowContextMenu(); - if(ret != 0 && selEmpty) { + if(ret != 0 && ret != CMNU_DEL_COINCIDENT && selEmpty) { ToggleSelectionStateOf(&hover); } switch(ret) { @@ -519,6 +537,24 @@ void GraphicsWindow::MouseRightUp(double x, double y) { Constraint::MenuConstrain(MNU_OTHER_ANGLE); break; + case CMNU_DEL_COINCIDENT: { + SS.UndoRemember(); + if(!hover.entity.v) break; + Entity *p = SK.GetEntity(hover.entity); + if(!p->IsPoint()) break; + + SK.constraint.ClearTags(); + Constraint *c; + for(c = SK.constraint.First(); c; c = SK.constraint.NextAfter(c)) { + if(c->type != Constraint::POINTS_COINCIDENT) continue; + if(c->ptA.v == p->h.v || c->ptB.v == p->h.v) { + c->tag = 1; + } + } + SK.constraint.RemoveTagged(); + break; + } + case CMNU_SNAP_TO_GRID: MenuEdit(MNU_SNAP_TO_GRID); break; diff --git a/ui.h b/ui.h index 61835a6e..036e7490 100644 --- a/ui.h +++ b/ui.h @@ -454,13 +454,14 @@ public: void ToggleSelectionStateOf(Selection *s); void ClearSuper(void); - static const int CMNU_UNSELECT_ALL = 0x101; - static const int CMNU_DELETE_SEL = 0x102; - static const int CMNU_NEW_CUSTOM_STYLE = 0x103; - static const int CMNU_NO_STYLE = 0x104; - static const int CMNU_GROUP_INFO = 0x105; - static const int CMNU_REFERENCE_DIM = 0x106; - static const int CMNU_OTHER_ANGLE = 0x107; + static const int CMNU_UNSELECT_ALL = 0x100; + static const int CMNU_DELETE_SEL = 0x101; + static const int CMNU_NEW_CUSTOM_STYLE = 0x102; + static const int CMNU_NO_STYLE = 0x103; + static const int CMNU_GROUP_INFO = 0x104; + static const int CMNU_REFERENCE_DIM = 0x105; + static const int CMNU_OTHER_ANGLE = 0x106; + static const int CMNU_DEL_COINCIDENT = 0x107; static const int CMNU_STYLE_INFO = 0x108; static const int CMNU_SNAP_TO_GRID = 0x109; static const int CMNU_SELECT_CHAIN = 0x10a;