2008-03-25 10:02:13 +00:00
|
|
|
#include "solvespace.h"
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2008-04-28 07:18:39 +00:00
|
|
|
const TextWindow::Color TextWindow::fgColors[] = {
|
|
|
|
{ 'd', RGB(255, 255, 255) },
|
|
|
|
{ 'l', RGB(100, 100, 255) },
|
|
|
|
{ 't', RGB(255, 200, 0) },
|
2008-05-26 09:56:50 +00:00
|
|
|
{ 'h', RGB( 90, 90, 90) },
|
2008-04-28 07:18:39 +00:00
|
|
|
{ 's', RGB( 40, 255, 40) },
|
|
|
|
{ 'm', RGB(200, 200, 0) },
|
|
|
|
{ 'r', RGB( 0, 0, 0) },
|
2008-05-26 09:56:50 +00:00
|
|
|
{ 'x', RGB(255, 20, 20) },
|
2008-06-01 00:26:41 +00:00
|
|
|
{ 'i', RGB( 0, 255, 255) },
|
2008-02-09 13:52:01 +00:00
|
|
|
{ 'g', RGB(160, 160, 160) },
|
2008-04-28 07:18:39 +00:00
|
|
|
{ 0, 0 },
|
|
|
|
};
|
|
|
|
const TextWindow::Color TextWindow::bgColors[] = {
|
|
|
|
{ 'd', RGB( 0, 0, 0) },
|
2008-05-26 09:56:50 +00:00
|
|
|
{ 't', RGB( 34, 15, 15) },
|
2008-04-28 09:40:02 +00:00
|
|
|
{ 'a', RGB( 20, 20, 20) },
|
2008-04-28 07:18:39 +00:00
|
|
|
{ 'r', RGB(255, 255, 255) },
|
|
|
|
{ 0, 0 },
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
void TextWindow::Init(void) {
|
2008-06-01 00:26:41 +00:00
|
|
|
ClearSuper();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TextWindow::ClearSuper(void) {
|
|
|
|
HideTextEditControl();
|
2008-04-12 14:12:26 +00:00
|
|
|
memset(this, 0, sizeof(*this));
|
2008-06-01 00:26:41 +00:00
|
|
|
ClearScreen();
|
|
|
|
Show();
|
2008-03-26 09:18:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextWindow::ClearScreen(void) {
|
2008-03-25 10:02:13 +00:00
|
|
|
int i, j;
|
|
|
|
for(i = 0; i < MAX_ROWS; i++) {
|
|
|
|
for(j = 0; j < MAX_COLS; j++) {
|
|
|
|
text[i][j] = ' ';
|
2008-04-28 07:18:39 +00:00
|
|
|
meta[i][j].fg = 'd';
|
|
|
|
meta[i][j].bg = 'd';
|
2008-03-25 10:02:13 +00:00
|
|
|
meta[i][j].link = NOT_A_LINK;
|
|
|
|
}
|
2008-04-28 07:18:39 +00:00
|
|
|
top[i] = i*2;
|
2008-03-25 10:02:13 +00:00
|
|
|
}
|
2008-03-26 09:18:12 +00:00
|
|
|
rows = 0;
|
2008-03-25 10:02:13 +00:00
|
|
|
}
|
|
|
|
|
2008-04-28 07:18:39 +00:00
|
|
|
void TextWindow::Printf(bool halfLine, char *fmt, ...) {
|
2008-03-25 10:02:13 +00:00
|
|
|
va_list vl;
|
|
|
|
va_start(vl, fmt);
|
|
|
|
|
2008-04-09 09:35:09 +00:00
|
|
|
if(rows >= MAX_ROWS) return;
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
int r, c;
|
2008-04-09 09:35:09 +00:00
|
|
|
r = rows;
|
2008-04-28 07:18:39 +00:00
|
|
|
top[r] = (r == 0) ? 0 : (top[r-1] + (halfLine ? 3 : 2));
|
2008-04-09 09:35:09 +00:00
|
|
|
rows++;
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
for(c = 0; c < MAX_COLS; c++) {
|
|
|
|
text[r][c] = ' ';
|
|
|
|
meta[r][c].link = NOT_A_LINK;
|
|
|
|
}
|
|
|
|
|
2008-04-28 07:18:39 +00:00
|
|
|
int fg = 'd', bg = 'd';
|
2008-03-28 10:00:37 +00:00
|
|
|
int link = NOT_A_LINK;
|
|
|
|
DWORD data = 0;
|
2008-05-26 09:56:50 +00:00
|
|
|
LinkFunction *f = NULL, *h = NULL;
|
2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
c = 0;
|
|
|
|
while(*fmt) {
|
2008-03-28 10:00:37 +00:00
|
|
|
char buf[1024];
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
if(*fmt == '%') {
|
2008-03-26 09:18:12 +00:00
|
|
|
fmt++;
|
|
|
|
if(*fmt == '\0') goto done;
|
2008-03-28 10:00:37 +00:00
|
|
|
strcpy(buf, "");
|
2008-03-26 09:18:12 +00:00
|
|
|
switch(*fmt) {
|
2008-03-28 10:00:37 +00:00
|
|
|
case 'd': {
|
|
|
|
int v = va_arg(vl, int);
|
|
|
|
sprintf(buf, "%d", v);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'x': {
|
|
|
|
DWORD v = va_arg(vl, DWORD);
|
|
|
|
sprintf(buf, "%08x", v);
|
|
|
|
break;
|
|
|
|
}
|
2008-06-11 04:22:52 +00:00
|
|
|
case '@': {
|
|
|
|
double v = va_arg(vl, double);
|
|
|
|
sprintf(buf, "%.2f", v);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case '2': {
|
|
|
|
double v = va_arg(vl, double);
|
|
|
|
sprintf(buf, "%s%.2f", v < 0 ? "" : " ", v);
|
|
|
|
break;
|
|
|
|
}
|
2008-06-01 00:26:41 +00:00
|
|
|
case '3': {
|
|
|
|
double v = va_arg(vl, double);
|
|
|
|
sprintf(buf, "%s%.3f", v < 0 ? "" : " ", v);
|
|
|
|
break;
|
|
|
|
}
|
2009-09-30 10:02:15 +00:00
|
|
|
case '#': {
|
|
|
|
double v = va_arg(vl, double);
|
|
|
|
sprintf(buf, "%.3f", v);
|
|
|
|
break;
|
|
|
|
}
|
2008-03-26 09:18:12 +00:00
|
|
|
case 's': {
|
|
|
|
char *s = va_arg(vl, char *);
|
2008-03-28 10:00:37 +00:00
|
|
|
memcpy(buf, s, min(sizeof(buf), strlen(s)+1));
|
2008-03-26 09:18:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-06-01 00:26:41 +00:00
|
|
|
case 'c': {
|
|
|
|
char v = va_arg(vl, char);
|
|
|
|
sprintf(buf, "%c", v);
|
|
|
|
break;
|
|
|
|
}
|
2008-03-28 10:00:37 +00:00
|
|
|
case 'E':
|
2008-04-28 07:18:39 +00:00
|
|
|
fg = 'd';
|
|
|
|
// leave the background, though
|
2008-03-28 10:00:37 +00:00
|
|
|
link = NOT_A_LINK;
|
|
|
|
data = 0;
|
|
|
|
f = NULL;
|
2008-05-26 09:56:50 +00:00
|
|
|
h = NULL;
|
2008-03-26 09:18:12 +00:00
|
|
|
break;
|
2008-03-28 10:00:37 +00:00
|
|
|
|
2008-04-28 07:18:39 +00:00
|
|
|
case 'F':
|
|
|
|
case 'B': {
|
|
|
|
int color;
|
2008-03-28 10:00:37 +00:00
|
|
|
if(fmt[1] == '\0') goto done;
|
2008-04-28 07:18:39 +00:00
|
|
|
if(fmt[1] == 'p') {
|
2008-04-11 12:47:14 +00:00
|
|
|
color = va_arg(vl, int);
|
|
|
|
} else {
|
2008-04-28 07:18:39 +00:00
|
|
|
color = fmt[1];
|
2008-04-11 12:47:14 +00:00
|
|
|
}
|
2008-05-30 06:09:41 +00:00
|
|
|
if((color < 0 || color > 255) && !(color & 0x80000000)) {
|
|
|
|
color = 0;
|
|
|
|
}
|
2008-04-28 07:18:39 +00:00
|
|
|
if(*fmt == 'F') {
|
|
|
|
fg = color;
|
|
|
|
} else {
|
|
|
|
bg = color;
|
|
|
|
}
|
|
|
|
fmt++;
|
2008-03-28 10:00:37 +00:00
|
|
|
break;
|
2008-04-28 07:18:39 +00:00
|
|
|
}
|
2008-03-28 10:00:37 +00:00
|
|
|
case 'L':
|
|
|
|
if(fmt[1] == '\0') goto done;
|
|
|
|
fmt++;
|
2009-09-29 11:35:19 +00:00
|
|
|
if(*fmt == 'p') {
|
|
|
|
link = va_arg(vl, int);
|
|
|
|
} else {
|
|
|
|
link = *fmt;
|
|
|
|
}
|
2008-03-28 10:00:37 +00:00
|
|
|
break;
|
|
|
|
|
2008-04-11 12:47:14 +00:00
|
|
|
case 'f':
|
|
|
|
f = va_arg(vl, LinkFunction *);
|
|
|
|
break;
|
|
|
|
|
2008-05-26 09:56:50 +00:00
|
|
|
case 'h':
|
|
|
|
h = va_arg(vl, LinkFunction *);
|
|
|
|
break;
|
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
case 'D':
|
|
|
|
data = va_arg(vl, DWORD);
|
|
|
|
break;
|
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
case '%':
|
2008-03-28 10:00:37 +00:00
|
|
|
strcpy(buf, "%");
|
2008-03-26 09:18:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-03-25 10:02:13 +00:00
|
|
|
} else {
|
2008-03-28 10:00:37 +00:00
|
|
|
buf[0] = *fmt;
|
|
|
|
buf[1]= '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
for(unsigned i = 0; i < strlen(buf); i++) {
|
2008-03-25 10:02:13 +00:00
|
|
|
if(c >= MAX_COLS) goto done;
|
2008-03-28 10:00:37 +00:00
|
|
|
text[r][c] = buf[i];
|
2008-04-28 07:18:39 +00:00
|
|
|
meta[r][c].fg = fg;
|
|
|
|
meta[r][c].bg = bg;
|
2008-03-28 10:00:37 +00:00
|
|
|
meta[r][c].link = link;
|
|
|
|
meta[r][c].data = data;
|
|
|
|
meta[r][c].f = f;
|
2008-05-26 09:56:50 +00:00
|
|
|
meta[r][c].h = h;
|
2008-03-28 10:00:37 +00:00
|
|
|
c++;
|
2008-03-25 10:02:13 +00:00
|
|
|
}
|
2008-03-28 10:00:37 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
fmt++;
|
|
|
|
}
|
2008-04-12 14:12:26 +00:00
|
|
|
while(c < MAX_COLS) {
|
2008-04-28 07:18:39 +00:00
|
|
|
meta[r][c].fg = fg;
|
|
|
|
meta[r][c].bg = bg;
|
2008-04-12 14:12:26 +00:00
|
|
|
c++;
|
|
|
|
}
|
2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
done:
|
|
|
|
va_end(vl);
|
|
|
|
}
|
|
|
|
|
2008-06-01 00:26:41 +00:00
|
|
|
#define gs (SS.GW.gs)
|
2008-04-12 14:12:26 +00:00
|
|
|
void TextWindow::Show(void) {
|
2008-05-05 06:18:01 +00:00
|
|
|
if(!(SS.GW.pending.operation)) SS.GW.ClearPending();
|
2008-04-13 10:57:41 +00:00
|
|
|
|
2008-05-26 09:56:50 +00:00
|
|
|
SS.GW.GroupSelection();
|
2008-04-12 14:12:26 +00:00
|
|
|
|
2008-05-05 06:18:01 +00:00
|
|
|
if(SS.GW.pending.description) {
|
2008-04-13 10:57:41 +00:00
|
|
|
// A pending operation (that must be completed with the mouse in
|
|
|
|
// the graphics window) will preempt our usual display.
|
2008-06-11 04:22:52 +00:00
|
|
|
HideTextEditControl();
|
2008-06-01 00:26:41 +00:00
|
|
|
ShowHeader(false);
|
2008-04-28 07:18:39 +00:00
|
|
|
Printf(false, "");
|
2008-05-05 06:18:01 +00:00
|
|
|
Printf(false, "%s", SS.GW.pending.description);
|
2008-07-14 04:29:43 +00:00
|
|
|
Printf(true, "%Fl%f%Ll(cancel operation)%E",
|
|
|
|
&TextWindow::ScreenUnselectAll);
|
2009-09-24 16:04:46 +00:00
|
|
|
} else if(gs.n > 0 || gs.stylables > 0) {
|
2008-06-30 09:09:17 +00:00
|
|
|
if(edit.meaning != EDIT_TTF_TEXT) HideTextEditControl();
|
2008-06-01 00:26:41 +00:00
|
|
|
ShowHeader(false);
|
|
|
|
DescribeSelection();
|
2008-04-13 10:57:41 +00:00
|
|
|
} else {
|
2008-06-30 09:09:17 +00:00
|
|
|
if(edit.meaning == EDIT_TTF_TEXT) HideTextEditControl();
|
2008-06-01 00:26:41 +00:00
|
|
|
ShowHeader(true);
|
2008-07-10 06:11:56 +00:00
|
|
|
switch(shown.screen) {
|
2008-04-13 10:57:41 +00:00
|
|
|
default:
|
2008-07-10 06:11:56 +00:00
|
|
|
shown.screen = SCREEN_LIST_OF_GROUPS;
|
2008-04-13 10:57:41 +00:00
|
|
|
// fall through
|
2008-04-27 09:03:01 +00:00
|
|
|
case SCREEN_LIST_OF_GROUPS: ShowListOfGroups(); break;
|
|
|
|
case SCREEN_GROUP_INFO: ShowGroupInfo(); break;
|
2008-05-26 09:56:50 +00:00
|
|
|
case SCREEN_GROUP_SOLVE_INFO: ShowGroupSolveInfo(); break;
|
2008-06-11 04:22:52 +00:00
|
|
|
case SCREEN_CONFIGURATION: ShowConfiguration(); break;
|
2008-07-20 11:27:22 +00:00
|
|
|
case SCREEN_STEP_DIMENSION: ShowStepDimension(); break;
|
2008-02-07 09:53:52 +00:00
|
|
|
case SCREEN_MESH_VOLUME: ShowMeshVolume(); break;
|
2009-09-18 08:14:15 +00:00
|
|
|
case SCREEN_LIST_OF_STYLES: ShowListOfStyles(); break;
|
|
|
|
case SCREEN_STYLE_INFO: ShowStyleInfo(); break;
|
2008-04-13 10:57:41 +00:00
|
|
|
}
|
2008-03-25 10:02:13 +00:00
|
|
|
}
|
2008-06-13 04:41:27 +00:00
|
|
|
Printf(false, "");
|
2008-04-12 14:12:26 +00:00
|
|
|
InvalidateText();
|
2008-03-26 09:18:12 +00:00
|
|
|
}
|
|
|
|
|
2008-06-02 05:38:12 +00:00
|
|
|
void TextWindow::ScreenUnselectAll(int link, DWORD v) {
|
|
|
|
GraphicsWindow::MenuEdit(GraphicsWindow::MNU_UNSELECT_ALL);
|
|
|
|
}
|
|
|
|
|
2008-06-30 09:09:17 +00:00
|
|
|
void TextWindow::ScreenEditTtfText(int link, DWORD v) {
|
|
|
|
hRequest hr = { v };
|
2009-04-19 05:53:16 +00:00
|
|
|
Request *r = SK.GetRequest(hr);
|
2008-06-30 09:09:17 +00:00
|
|
|
|
|
|
|
ShowTextEditControl(13, 10, r->str.str);
|
|
|
|
SS.TW.edit.meaning = EDIT_TTF_TEXT;
|
|
|
|
SS.TW.edit.request = hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TextWindow::ScreenSetTtfFont(int link, DWORD v) {
|
|
|
|
int i = (int)v;
|
|
|
|
if(i < 0) return;
|
|
|
|
if(i >= SS.fonts.l.n) return;
|
|
|
|
|
|
|
|
SS.GW.GroupSelection();
|
|
|
|
if(gs.entities != 1 || gs.n != 1) return;
|
|
|
|
|
2009-04-19 05:53:16 +00:00
|
|
|
Entity *e = SK.entity.FindByIdNoOops(gs.entity[0]);
|
2008-06-30 09:09:17 +00:00
|
|
|
if(!e || e->type != Entity::TTF_TEXT || !e->h.isFromRequest()) return;
|
|
|
|
|
2009-04-19 05:53:16 +00:00
|
|
|
Request *r = SK.request.FindByIdNoOops(e->h.request());
|
2008-06-30 09:09:17 +00:00
|
|
|
if(!r) return;
|
|
|
|
|
|
|
|
SS.UndoRemember();
|
|
|
|
r->font.strcpy(SS.fonts.l.elem[i].FontFileBaseName());
|
|
|
|
SS.MarkGroupDirty(r->group);
|
|
|
|
SS.later.generateAll = true;
|
|
|
|
SS.later.showTW = true;
|
|
|
|
}
|
|
|
|
|
2008-06-01 00:26:41 +00:00
|
|
|
void TextWindow::DescribeSelection(void) {
|
|
|
|
Entity *e;
|
|
|
|
Vector p;
|
|
|
|
int i;
|
|
|
|
Printf(false, "");
|
|
|
|
|
|
|
|
if(gs.n == 1 && (gs.points == 1 || gs.entities == 1)) {
|
2009-04-19 05:53:16 +00:00
|
|
|
e = SK.GetEntity(gs.points == 1 ? gs.point[0] : gs.entity[0]);
|
2008-06-01 00:26:41 +00:00
|
|
|
|
2008-06-12 07:31:41 +00:00
|
|
|
#define COSTR(p) \
|
2008-06-14 09:51:25 +00:00
|
|
|
SS.MmToString((p).x), SS.MmToString((p).y), SS.MmToString((p).z)
|
2008-06-01 00:26:41 +00:00
|
|
|
#define PT_AS_STR "(%Fi%s%E, %Fi%s%E, %Fi%s%E)"
|
|
|
|
#define PT_AS_NUM "(%Fi%3%E, %Fi%3%E, %Fi%3%E)"
|
|
|
|
switch(e->type) {
|
|
|
|
case Entity::POINT_IN_3D:
|
|
|
|
case Entity::POINT_IN_2D:
|
|
|
|
case Entity::POINT_N_TRANS:
|
|
|
|
case Entity::POINT_N_ROT_TRANS:
|
|
|
|
case Entity::POINT_N_COPY:
|
|
|
|
case Entity::POINT_N_ROT_AA:
|
|
|
|
p = e->PointGetNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(false, "%FtPOINT%E at " PT_AS_STR, COSTR(p));
|
2008-06-01 00:26:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Entity::NORMAL_IN_3D:
|
|
|
|
case Entity::NORMAL_IN_2D:
|
|
|
|
case Entity::NORMAL_N_COPY:
|
|
|
|
case Entity::NORMAL_N_ROT:
|
|
|
|
case Entity::NORMAL_N_ROT_AA: {
|
|
|
|
Quaternion q = e->NormalGetNum();
|
|
|
|
p = q.RotationN();
|
|
|
|
Printf(false, "%FtNORMAL / COORDINATE SYSTEM%E");
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(true, " basis n = " PT_AS_NUM, CO(p));
|
2008-06-01 00:26:41 +00:00
|
|
|
p = q.RotationU();
|
|
|
|
Printf(false, " u = " PT_AS_NUM, CO(p));
|
|
|
|
p = q.RotationV();
|
|
|
|
Printf(false, " v = " PT_AS_NUM, CO(p));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Entity::WORKPLANE: {
|
2009-04-19 05:53:16 +00:00
|
|
|
p = SK.GetEntity(e->point[0])->PointGetNum();
|
2008-06-01 00:26:41 +00:00
|
|
|
Printf(false, "%FtWORKPLANE%E");
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(true, " origin = " PT_AS_STR, COSTR(p));
|
2008-06-01 00:26:41 +00:00
|
|
|
Quaternion q = e->Normal()->NormalGetNum();
|
|
|
|
p = q.RotationN();
|
|
|
|
Printf(true, " normal = " PT_AS_NUM, CO(p));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Entity::LINE_SEGMENT: {
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector p0 = SK.GetEntity(e->point[0])->PointGetNum();
|
2008-06-01 00:26:41 +00:00
|
|
|
p = p0;
|
|
|
|
Printf(false, "%FtLINE SEGMENT%E");
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(true, " thru " PT_AS_STR, COSTR(p));
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector p1 = SK.GetEntity(e->point[1])->PointGetNum();
|
2008-06-01 00:26:41 +00:00
|
|
|
p = p1;
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(false, " " PT_AS_STR, COSTR(p));
|
2008-06-01 00:26:41 +00:00
|
|
|
Printf(true, " len = %Fi%s%E",
|
2008-06-14 09:51:25 +00:00
|
|
|
SS.MmToString((p1.Minus(p0).Magnitude())));
|
2008-06-01 00:26:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Entity::CUBIC:
|
|
|
|
Printf(false, "%FtCUBIC BEZIER CURVE%E");
|
|
|
|
for(i = 0; i <= 3; i++) {
|
2009-04-19 05:53:16 +00:00
|
|
|
p = SK.GetEntity(e->point[i])->PointGetNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf((i==0), " p%c = " PT_AS_STR, '0'+i, COSTR(p));
|
2008-06-01 00:26:41 +00:00
|
|
|
}
|
|
|
|
break;
|
2008-06-12 07:31:41 +00:00
|
|
|
|
2008-06-01 00:26:41 +00:00
|
|
|
case Entity::ARC_OF_CIRCLE: {
|
|
|
|
Printf(false, "%FtARC OF A CIRCLE%E");
|
2009-04-19 05:53:16 +00:00
|
|
|
p = SK.GetEntity(e->point[0])->PointGetNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(true, " center = " PT_AS_STR, COSTR(p));
|
2009-04-19 05:53:16 +00:00
|
|
|
p = SK.GetEntity(e->point[1])->PointGetNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(true, " endpoints = " PT_AS_STR, COSTR(p));
|
2009-04-19 05:53:16 +00:00
|
|
|
p = SK.GetEntity(e->point[2])->PointGetNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(false, " " PT_AS_STR, COSTR(p));
|
2008-06-01 00:26:41 +00:00
|
|
|
double r = e->CircleGetRadiusNum();
|
2008-06-14 09:51:25 +00:00
|
|
|
Printf(true, " diameter = %Fi%s", SS.MmToString(r*2));
|
|
|
|
Printf(false, " radius = %Fi%s", SS.MmToString(r));
|
2009-01-08 17:22:59 +00:00
|
|
|
double thetas, thetaf, dtheta;
|
|
|
|
e->ArcGetAngles(&thetas, &thetaf, &dtheta);
|
|
|
|
Printf(false, " arc len = %Fi%s", SS.MmToString(dtheta*r));
|
2008-06-01 00:26:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Entity::CIRCLE: {
|
|
|
|
Printf(false, "%FtCIRCLE%E");
|
2009-04-19 05:53:16 +00:00
|
|
|
p = SK.GetEntity(e->point[0])->PointGetNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(true, " center = " PT_AS_STR, COSTR(p));
|
2008-06-01 00:26:41 +00:00
|
|
|
double r = e->CircleGetRadiusNum();
|
2008-06-14 09:51:25 +00:00
|
|
|
Printf(true, " diameter = %Fi%s", SS.MmToString(r*2));
|
|
|
|
Printf(false, " radius = %Fi%s", SS.MmToString(r));
|
2008-06-01 00:26:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-06-02 05:38:12 +00:00
|
|
|
case Entity::FACE_NORMAL_PT:
|
|
|
|
case Entity::FACE_XPROD:
|
|
|
|
case Entity::FACE_N_ROT_TRANS:
|
2008-06-21 22:49:57 +00:00
|
|
|
case Entity::FACE_N_ROT_AA:
|
|
|
|
case Entity::FACE_N_TRANS:
|
2008-06-02 05:38:12 +00:00
|
|
|
Printf(false, "%FtPLANE FACE%E");
|
2008-06-06 09:14:25 +00:00
|
|
|
p = e->FaceGetNormalNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(true, " normal = " PT_AS_NUM, CO(p));
|
|
|
|
p = e->FaceGetPointNum();
|
|
|
|
Printf(false, " thru = " PT_AS_STR, COSTR(p));
|
2008-06-02 05:38:12 +00:00
|
|
|
break;
|
|
|
|
|
2008-06-30 09:09:17 +00:00
|
|
|
case Entity::TTF_TEXT: {
|
|
|
|
Printf(false, "%FtTRUETYPE FONT TEXT%E");
|
|
|
|
Printf(true, " font = '%Fi%s%E'", e->font.str);
|
|
|
|
if(e->h.isFromRequest()) {
|
|
|
|
Printf(false, " text = '%Fi%s%E' %Fl%Ll%f%D[change]%E",
|
|
|
|
e->str.str, &ScreenEditTtfText, e->h.request());
|
|
|
|
Printf(true, " select new font");
|
|
|
|
SS.fonts.LoadAll();
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < SS.fonts.l.n; i++) {
|
|
|
|
TtfFont *tf = &(SS.fonts.l.elem[i]);
|
|
|
|
if(strcmp(e->font.str, tf->FontFileBaseName())==0) {
|
|
|
|
Printf(false, "%Bp %s",
|
|
|
|
(i & 1) ? 'd' : 'a',
|
|
|
|
tf->name.str);
|
|
|
|
} else {
|
|
|
|
Printf(false, "%Bp %f%D%Fl%Ll%s%E%Bp",
|
|
|
|
(i & 1) ? 'd' : 'a',
|
|
|
|
&ScreenSetTtfFont, i,
|
|
|
|
tf->name.str,
|
|
|
|
(i & 1) ? 'd' : 'a');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Printf(false, " text = '%Fi%s%E'", e->str.str);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-06-01 00:26:41 +00:00
|
|
|
default:
|
|
|
|
Printf(true, "%Ft?? ENTITY%E");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-04-19 05:53:16 +00:00
|
|
|
Group *g = SK.GetGroup(e->group);
|
2008-06-01 00:26:41 +00:00
|
|
|
Printf(false, "");
|
|
|
|
Printf(false, "%FtIN GROUP%E %s", g->DescriptionString());
|
|
|
|
if(e->workplane.v == Entity::FREE_IN_3D.v) {
|
2008-06-30 09:09:17 +00:00
|
|
|
Printf(false, "%FtNOT LOCKED IN WORKPLANE%E");
|
2008-06-01 00:26:41 +00:00
|
|
|
} else {
|
2009-04-19 05:53:16 +00:00
|
|
|
Entity *w = SK.GetEntity(e->workplane);
|
2008-06-01 00:26:41 +00:00
|
|
|
Printf(false, "%FtIN WORKPLANE%E %s", w->DescriptionString());
|
|
|
|
}
|
2009-09-22 05:46:30 +00:00
|
|
|
if(e->style.v) {
|
|
|
|
Style *s = Style::Get(e->style);
|
|
|
|
Printf(false, "%FtIN STYLE%E %s", s->DescriptionString());
|
|
|
|
} else {
|
|
|
|
Printf(false, "%FtIN STYLE%E none");
|
|
|
|
}
|
2008-06-01 00:26:41 +00:00
|
|
|
} else if(gs.n == 2 && gs.points == 2) {
|
|
|
|
Printf(false, "%FtTWO POINTS");
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector p0 = SK.GetEntity(gs.point[0])->PointGetNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(true, " at " PT_AS_STR, COSTR(p0));
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector p1 = SK.GetEntity(gs.point[1])->PointGetNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(false, " " PT_AS_STR, COSTR(p1));
|
2008-06-01 00:26:41 +00:00
|
|
|
double d = (p1.Minus(p0)).Magnitude();
|
2008-06-14 09:51:25 +00:00
|
|
|
Printf(true, " d = %Fi%s", SS.MmToString(d));
|
2008-06-12 07:31:41 +00:00
|
|
|
} else if(gs.n == 2 && gs.faces == 1 && gs.points == 1) {
|
|
|
|
Printf(false, "%FtA POINT AND A PLANE FACE");
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector pt = SK.GetEntity(gs.point[0])->PointGetNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(true, " point = " PT_AS_STR, COSTR(pt));
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector n = SK.GetEntity(gs.face[0])->FaceGetNormalNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(true, " plane normal = " PT_AS_NUM, CO(n));
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector pl = SK.GetEntity(gs.face[0])->FaceGetPointNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(false, " plane thru = " PT_AS_STR, COSTR(pl));
|
|
|
|
double dd = n.Dot(pl) - n.Dot(pt);
|
2008-06-14 09:51:25 +00:00
|
|
|
Printf(true, " distance = %Fi%s", SS.MmToString(dd));
|
2008-06-12 07:31:41 +00:00
|
|
|
} else if(gs.n == 3 && gs.points == 2 && gs.vectors == 1) {
|
|
|
|
Printf(false, "%FtTWO POINTS AND A VECTOR");
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector p0 = SK.GetEntity(gs.point[0])->PointGetNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(true, " pointA = " PT_AS_STR, COSTR(p0));
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector p1 = SK.GetEntity(gs.point[1])->PointGetNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
Printf(false, " pointB = " PT_AS_STR, COSTR(p1));
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector v = SK.GetEntity(gs.vector[0])->VectorGetNum();
|
2008-06-12 07:31:41 +00:00
|
|
|
v = v.WithMagnitude(1);
|
|
|
|
Printf(true, " vector = " PT_AS_NUM, CO(v));
|
|
|
|
double d = (p1.Minus(p0)).Dot(v);
|
2008-06-14 09:51:25 +00:00
|
|
|
Printf(true, " proj_d = %Fi%s", SS.MmToString(d));
|
2009-06-07 23:00:57 +00:00
|
|
|
} else if(gs.n == 2 && gs.lineSegments == 1 && gs.points == 1) {
|
|
|
|
Entity *ln = SK.GetEntity(gs.entity[0]);
|
|
|
|
Vector lp0 = SK.GetEntity(ln->point[0])->PointGetNum(),
|
|
|
|
lp1 = SK.GetEntity(ln->point[1])->PointGetNum();
|
|
|
|
Printf(false, "%FtLINE SEGMENT AND POINT%E");
|
|
|
|
Printf(true, " ln thru " PT_AS_STR, COSTR(lp0));
|
|
|
|
Printf(false, " " PT_AS_STR, COSTR(lp1));
|
|
|
|
Vector pp = SK.GetEntity(gs.point[0])->PointGetNum();
|
|
|
|
Printf(true, " point " PT_AS_STR, COSTR(pp));
|
|
|
|
Printf(true, " pt-ln distance = %Fi%s%E",
|
|
|
|
SS.MmToString(pp.DistanceToLine(lp0, lp1.Minus(lp0))));
|
2008-06-13 04:41:27 +00:00
|
|
|
} else if(gs.n == 2 && gs.faces == 2) {
|
|
|
|
Printf(false, "%FtTWO PLANE FACES");
|
|
|
|
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector n0 = SK.GetEntity(gs.face[0])->FaceGetNormalNum();
|
2008-06-13 04:41:27 +00:00
|
|
|
Printf(true, " planeA normal = " PT_AS_NUM, CO(n0));
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector p0 = SK.GetEntity(gs.face[0])->FaceGetPointNum();
|
2008-06-13 04:41:27 +00:00
|
|
|
Printf(false, " planeA thru = " PT_AS_STR, COSTR(p0));
|
|
|
|
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector n1 = SK.GetEntity(gs.face[1])->FaceGetNormalNum();
|
2008-06-13 04:41:27 +00:00
|
|
|
Printf(true, " planeB normal = " PT_AS_NUM, CO(n1));
|
2009-04-19 05:53:16 +00:00
|
|
|
Vector p1 = SK.GetEntity(gs.face[1])->FaceGetPointNum();
|
2008-06-13 04:41:27 +00:00
|
|
|
Printf(false, " planeB thru = " PT_AS_STR, COSTR(p1));
|
|
|
|
|
|
|
|
double theta = acos(n0.Dot(n1));
|
|
|
|
Printf(true, " angle = %Fi%2%E degrees", theta*180/PI);
|
|
|
|
while(theta < PI/2) theta += PI;
|
|
|
|
while(theta > PI/2) theta -= PI;
|
|
|
|
Printf(false, " or angle = %Fi%2%E (mod 180)", theta*180/PI);
|
|
|
|
|
|
|
|
if(fabs(theta) < 0.01) {
|
|
|
|
double d = (p1.Minus(p0)).Dot(n0);
|
2008-06-14 09:51:25 +00:00
|
|
|
Printf(true, " distance = %Fi%s", SS.MmToString(d));
|
2008-06-13 04:41:27 +00:00
|
|
|
}
|
2009-09-24 16:04:46 +00:00
|
|
|
} else if(gs.n == 0) {
|
|
|
|
Printf(true, "%FtSELECTED:%E comment text");
|
2008-06-01 00:26:41 +00:00
|
|
|
} else {
|
|
|
|
Printf(true, "%FtSELECTED:%E %d item%s", gs.n, gs.n == 1 ? "" : "s");
|
|
|
|
}
|
2008-06-02 05:38:12 +00:00
|
|
|
|
2009-09-22 05:46:30 +00:00
|
|
|
if(shown.screen == SCREEN_STYLE_INFO &&
|
|
|
|
shown.style.v >= Style::FIRST_CUSTOM)
|
|
|
|
{
|
|
|
|
// If we are showing a screen for a particular style, then offer the
|
|
|
|
// option to assign our selected entities to that style.
|
|
|
|
Style *s = Style::Get(shown.style);
|
|
|
|
Printf(true, "%Fl%D%f%Ll(assign to style %s)%E",
|
|
|
|
shown.style.v,
|
|
|
|
&ScreenAssignSelectionToStyle,
|
|
|
|
s->DescriptionString());
|
|
|
|
}
|
|
|
|
// If any of the selected entities have an assigned style, then offer
|
|
|
|
// the option to remove that style.
|
2009-09-24 16:04:46 +00:00
|
|
|
bool styleAssigned = false;
|
2009-09-22 05:46:30 +00:00
|
|
|
for(i = 0; i < gs.entities; i++) {
|
|
|
|
Entity *e = SK.GetEntity(gs.entity[i]);
|
|
|
|
if(e->style.v != 0) {
|
2009-09-24 16:04:46 +00:00
|
|
|
styleAssigned = true;
|
2009-09-22 05:46:30 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-24 16:04:46 +00:00
|
|
|
for(i = 0; i < gs.constraints; i++) {
|
|
|
|
Constraint *c = SK.GetConstraint(gs.constraint[i]);
|
|
|
|
if(c->type == Constraint::COMMENT && c->disp.style.v != 0) {
|
|
|
|
styleAssigned = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(styleAssigned) {
|
2009-09-22 05:46:30 +00:00
|
|
|
Printf(true, "%Fl%D%f%Ll(remove assigned style)%E",
|
|
|
|
0,
|
|
|
|
&ScreenAssignSelectionToStyle);
|
|
|
|
}
|
|
|
|
|
2008-06-02 05:38:12 +00:00
|
|
|
Printf(true, "%Fl%f%Ll(unselect all)%E", &TextWindow::ScreenUnselectAll);
|
2008-06-01 00:26:41 +00:00
|
|
|
}
|
|
|
|
|
2008-07-10 06:11:56 +00:00
|
|
|
void TextWindow::GoToScreen(int screen) {
|
|
|
|
shown.screen = screen;
|
2008-03-25 10:02:13 +00:00
|
|
|
}
|
|
|
|
|