From 2ae9983f9eed9a8408e7622be210e7fa8169a0db Mon Sep 17 00:00:00 2001 From: Jonathan Westhues Date: Tue, 3 Nov 2009 19:46:06 -0800 Subject: [PATCH] Add context menu item to delete a point-coincident constraint, which can't be selected with the mouse and would otherwise have to get deleted by selecting it in the text window. [git-p4: depot-paths = "//depot/solvespace/": change = 2065] --- mouse.cpp | 38 +++++++++++++++++++++++++++++++++++++- ui.h | 15 ++++++++------- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/mouse.cpp b/mouse.cpp index b45d139..9e9590b 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 61835a6..036e749 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;