Now I can rename groups, using that same edit control in the text

window.

[git-p4: depot-paths = "//depot/solvespace/": change = 1750]
This commit is contained in:
Jonathan Westhues 2008-05-27 01:52:36 -08:00
parent 4375c01c51
commit 010a65894d
5 changed files with 74 additions and 14 deletions

View File

@ -161,7 +161,6 @@ public:
void DebugDraw(void);
};
class SMesh {
public:
SList<STriangle> l;
@ -184,5 +183,39 @@ public:
void MakeFromDifference(SMesh *a, SMesh *b);
};
// A linked list of triangles
class STriangleLl {
public:
int tag;
STriangle tri;
STriangleLl *next;
};
// A linked list of linked lists of triangles; extra layer of encapsulation
// required because the same triangle might appear in both branches of the
// tree, if it spans the split plane, and we will need to be able to split
// the triangle into multiple pieces as we remove T intersections.
class STriangleLl2 {
public:
STriangleLl *trl;
STriangleLl2 *next;
};
class SAxisAligned {
public:
static const int BY_X = 1;
static const int BY_Y = 2;
static const int BY_Z = 3;
int which;
double c;
SAxisAligned *gt;
SAxisAligned *lt;
STriangleLl2 *tris;
};
#endif

View File

@ -82,7 +82,7 @@ void Group::MenuGroup(int id) {
case GraphicsWindow::MNU_GROUP_ROT:
g.type = ROTATE;
g.opA = SS.GW.activeGroup;
g.exprA = Expr::FromConstant(7)->DeepCopyKeep();
g.exprA = Expr::FromConstant(3)->DeepCopyKeep();
g.subtype = ONE_SIDED;
g.name.strcpy("rotate");
break;
@ -90,7 +90,7 @@ void Group::MenuGroup(int id) {
case GraphicsWindow::MNU_GROUP_TRANS:
g.type = TRANSLATE;
g.opA = SS.GW.activeGroup;
g.exprA = Expr::FromConstant(7)->DeepCopyKeep();
g.exprA = Expr::FromConstant(3)->DeepCopyKeep();
g.subtype = ONE_SIDED;
g.name.strcpy("translate");
break;

View File

@ -83,6 +83,7 @@ public:
static const int EXTRUDE = 5010;
static const int ROTATE = 5020;
static const int TRANSLATE = 5030;
static const int IMPORTED = 6000;
int type;
hGroup opA;
@ -200,6 +201,7 @@ public:
static const int POINT_N_TRANS = 2010;
static const int POINT_N_ROT_TRANS = 2011;
static const int POINT_N_COPY = 2012;
static const int POINT_N_ROT_AA = 2013;
static const int NORMAL_IN_3D = 3000;
static const int NORMAL_IN_2D = 3001;
@ -211,6 +213,7 @@ public:
static const int NORMAL_IN_PLANE = 3002;
static const int NORMAL_N_COPY = 3010;
static const int NORMAL_N_ROT = 3011;
static const int NORMAL_N_ROT_AA = 3012;
static const int DISTANCE = 4000;
static const int DISTANCE_N_COPY = 4001;

View File

@ -400,17 +400,21 @@ void TextWindow::ScreenChangeExprA(int link, DWORD v) {
SS.TW.edit.meaning = EDIT_TIMES_REPEATED;
SS.TW.edit.group.v = v;
}
void TextWindow::ScreenChangeGroupName(int link, DWORD v) {
Group *g = SS.GetGroup(SS.TW.shown->group);
ShowTextEditControl(7, 13, g->DescriptionString()+5);
SS.TW.edit.meaning = EDIT_GROUP_NAME;
SS.TW.edit.group.v = v;
}
void TextWindow::ShowGroupInfo(void) {
Group *g = SS.group.FindById(shown->group);
char *s, *s2;
if(SS.GW.activeGroup.v == shown->group.v) {
s = "active ";
} else if(shown->group.v == Group::HGROUP_REFERENCES.v) {
s = "special ";
} else {
s = "";
}
Printf(true, "%Ft%sGROUP %E%s", s, g->DescriptionString());
s = (shown->group.v == Group::HGROUP_REFERENCES.v) ? "" : "(rename)";
Printf(true, "%FtGROUP %E%s %Fl%Ll%D%f%s%E",
g->DescriptionString(),
g->h.v, &TextWindow::ScreenChangeGroupName, s);
if(g->type == Group::EXTRUDE) {
s = "EXTRUDE";
@ -431,13 +435,12 @@ void TextWindow::ShowGroupInfo(void) {
(one ? "" : "one side"), (one ? "one side" : ""),
&TextWindow::ScreenChangeOneOrTwoSides,
(!one ? "" : "two sides"), (!one ? "two sides" : ""));
}
if(g->type == Group::ROTATE || g->type == Group::TRANSLATE) {
int times = (int)(g->exprA->Eval());
Printf(true, "%Ft%s%E %d time%s %Fl%Ll%D%f(change)%E",
s2, times, times == 1 ? "" : "s",
g->h, &TextWindow::ScreenChangeExprA);
g->h.v, &TextWindow::ScreenChangeExprA);
}
if(g->type == Group::EXTRUDE) {
bool diff = (g->meshCombine == Group::COMBINE_AS_DIFFERENCE);
@ -532,7 +535,6 @@ void TextWindow::ShowConstraintInfo(void) {
}
void TextWindow::EditControlDone(char *s) {
HideTextEditControl();
switch(edit.meaning) {
case EDIT_TIMES_REPEATED: {
Expr *e = Expr::FromString(s);
@ -547,7 +549,25 @@ void TextWindow::EditControlDone(char *s) {
}
break;
}
case EDIT_GROUP_NAME: {
char *t;
bool invalid = false;
for(t = s; *t; t++) {
if(!(isalnum(*t) || *t == '-' || *t == '_')) {
invalid = true;
}
}
if(invalid || !*s) {
Error("Invalid characters. Allowed are: A-Z a-z 0-9 _ -");
} else {
Group *g = SS.GetGroup(edit.group);
g->name.strcpy(s);
}
SS.TW.Show();
break;
}
}
HideTextEditControl();
edit.meaning = EDIT_NOTHING;
}

4
ui.h
View File

@ -57,6 +57,7 @@ public:
static const int EDIT_NOTHING = 0;
static const int EDIT_TIMES_REPEATED = 1;
static const int EDIT_GROUP_NAME = 2;
struct {
int meaning;
hGroup group;
@ -90,7 +91,10 @@ public:
static void ScreenChangeOneOrTwoSides(int link, DWORD v);
static void ScreenChangeMeshCombine(int link, DWORD v);
// These ones do stuff with the edit control
static void ScreenChangeExprA(int link, DWORD v);
static void ScreenChangeGroupName(int link, DWORD v);
static void ScreenNavigation(int link, DWORD v);