From 684ba7deb1cf64d8add35570fb6dccc4b56d8c06 Mon Sep 17 00:00:00 2001 From: Jonathan Westhues Date: Sun, 21 Jun 2009 12:39:42 -0800 Subject: [PATCH] Add a menu item to rotate an imported part by ninety degrees about the coordinate axis closest to the screen normal. [git-p4: depot-paths = "//depot/solvespace/": change = 1994] --- graphicswin.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ srf/boolean.cpp | 6 +++++- ui.h | 1 + 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/graphicswin.cpp b/graphicswin.cpp index 3d3dd4c..0990332 100644 --- a/graphicswin.cpp +++ b/graphicswin.cpp @@ -32,7 +32,9 @@ const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = { { 1, "&Redo\tCtrl+Y", MNU_REDO, 'Y'|C, mEdit }, { 1, "Re&generate All\tSpace", MNU_REGEN_ALL, ' ', mEdit }, { 1, NULL, 0, NULL }, +{ 1, "Rotate Imported &90°\t9", MNU_ROTATE_90, '9', mEdit }, { 1, "&Delete\tDel", MNU_DELETE, 127, mEdit }, + { 1, NULL, 0, NULL }, { 1, "&Unselect All\tEsc", MNU_UNSELECT_ALL, 27, mEdit }, @@ -610,6 +612,53 @@ void GraphicsWindow::MenuEdit(int id) { break; } + case MNU_ROTATE_90: { + SS.GW.GroupSelection(); + Entity *e = NULL; + if(SS.GW.gs.n == 1 && SS.GW.gs.points == 1) { + e = SK.GetEntity(SS.GW.gs.point[0]); + } else if(SS.GW.gs.n == 1 && SS.GW.gs.entities == 1) { + e = SK.GetEntity(SS.GW.gs.entity[0]); + } + SS.GW.ClearSelection(); + + hGroup hg = e ? e->group : SS.GW.activeGroup; + Group *g = SK.GetGroup(hg); + if(g->type != Group::IMPORTED) { + Error("To use this command, select a point or other " + "entity from an imported part, or make an import " + "group the active group."); + break; + } + + hParam qw, qx, qy, qz; + qw = g->h.param(3); + qx = g->h.param(4); + qy = g->h.param(5); + qz = g->h.param(6); + + SS.UndoRemember(); + // Rotate by ninety degrees about the coordinate axis closest + // to the screen normal. + Quaternion q = Quaternion::From(qw, qx, qy, qz); + Vector norm = SS.GW.projRight.Cross(SS.GW.projUp); + norm = norm.ClosestOrtho(); + norm = norm.WithMagnitude(1); + Quaternion qaa = Quaternion::From(norm, PI/2); + q = qaa.Times(q); + + // And write the new quaternion + SK.GetParam(qw)->val = q.w; + SK.GetParam(qx)->val = q.vx; + SK.GetParam(qy)->val = q.vy; + SK.GetParam(qz)->val = q.vz; + + // and regenerate as necessary. + SS.MarkGroupDirty(hg); + SS.GenerateAll(); + break; + } + case MNU_UNDO: SS.UndoUndo(); break; diff --git a/srf/boolean.cpp b/srf/boolean.cpp index 4ee97e0..a27451f 100644 --- a/srf/boolean.cpp +++ b/srf/boolean.cpp @@ -241,7 +241,11 @@ static void TagByClassifiedEdge(int bspclass, int *indir, int *outdir) *outdir = SShell::INSIDE; break; - default: oops(); + default: + dbp("TagByClassifiedEdge: fail!"); + *indir = SShell::OUTSIDE; + *outdir = SShell::OUTSIDE; + break; } } diff --git a/ui.h b/ui.h index 0594961..630f1c6 100644 --- a/ui.h +++ b/ui.h @@ -204,6 +204,7 @@ public: MNU_UNDO, MNU_REDO, MNU_DELETE, + MNU_ROTATE_90, MNU_UNSELECT_ALL, MNU_REGEN_ALL, // Request