2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
#ifndef __UI_H
|
|
|
|
#define __UI_H
|
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
class TextWindow {
|
|
|
|
public:
|
2008-04-27 05:00:12 +00:00
|
|
|
static const int MAX_COLS = 100;
|
|
|
|
static const int MAX_ROWS = 200;
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
#ifndef RGB
|
|
|
|
#define RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16))
|
|
|
|
#endif
|
2008-03-28 10:00:37 +00:00
|
|
|
typedef struct {
|
2008-04-25 08:26:15 +00:00
|
|
|
char c;
|
2008-04-28 07:18:39 +00:00
|
|
|
int color;
|
2008-03-28 10:00:37 +00:00
|
|
|
} Color;
|
2008-04-28 07:18:39 +00:00
|
|
|
static const Color fgColors[];
|
|
|
|
static const Color bgColors[];
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-05-30 06:09:41 +00:00
|
|
|
static const int MODEL_COLORS = 8;
|
|
|
|
int modelColor[MODEL_COLORS];
|
2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
BYTE text[MAX_ROWS][MAX_COLS];
|
2008-03-28 10:00:37 +00:00
|
|
|
typedef void LinkFunction(int link, DWORD v);
|
2008-04-28 07:18:39 +00:00
|
|
|
static const int NOT_A_LINK = 0;
|
2008-03-25 10:02:13 +00:00
|
|
|
struct {
|
2008-04-28 07:18:39 +00:00
|
|
|
char fg;
|
2008-05-30 06:09:41 +00:00
|
|
|
int bg;
|
2008-03-28 10:00:37 +00:00
|
|
|
int link;
|
|
|
|
DWORD data;
|
|
|
|
LinkFunction *f;
|
2008-05-26 09:56:50 +00:00
|
|
|
LinkFunction *h;
|
2008-03-25 10:02:13 +00:00
|
|
|
} meta[MAX_ROWS][MAX_COLS];
|
2008-04-28 07:18:39 +00:00
|
|
|
int top[MAX_ROWS]; // in half-line units, or -1 for unused
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-04-09 09:35:09 +00:00
|
|
|
int rows;
|
2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
void Init(void);
|
2008-04-28 07:18:39 +00:00
|
|
|
void Printf(bool half, char *fmt, ...);
|
2008-03-25 10:02:13 +00:00
|
|
|
void ClearScreen(void);
|
2008-04-13 10:57:41 +00:00
|
|
|
|
2008-04-11 12:47:14 +00:00
|
|
|
void Show(void);
|
|
|
|
|
2008-04-12 14:12:26 +00:00
|
|
|
// State for the screen that we are showing in the text window.
|
2008-04-25 08:26:15 +00:00
|
|
|
static const int SCREEN_LIST_OF_GROUPS = 0;
|
|
|
|
static const int SCREEN_GROUP_INFO = 1;
|
2008-05-26 09:56:50 +00:00
|
|
|
static const int SCREEN_GROUP_SOLVE_INFO = 2;
|
2008-04-12 14:12:26 +00:00
|
|
|
typedef struct {
|
2008-04-25 08:26:15 +00:00
|
|
|
int screen;
|
|
|
|
hGroup group;
|
|
|
|
hRequest request;
|
2008-04-27 09:03:01 +00:00
|
|
|
hConstraint constraint;
|
2008-04-12 14:12:26 +00:00
|
|
|
} ShownState;
|
|
|
|
static const int HISTORY_LEN = 16;
|
|
|
|
ShownState showns[HISTORY_LEN];
|
|
|
|
int shownIndex;
|
|
|
|
int history;
|
|
|
|
ShownState *shown;
|
|
|
|
|
2008-05-27 06:36:59 +00:00
|
|
|
static const int EDIT_NOTHING = 0;
|
|
|
|
static const int EDIT_TIMES_REPEATED = 1;
|
2008-05-27 09:52:36 +00:00
|
|
|
static const int EDIT_GROUP_NAME = 2;
|
2008-05-27 06:36:59 +00:00
|
|
|
struct {
|
|
|
|
int meaning;
|
|
|
|
hGroup group;
|
|
|
|
} edit;
|
|
|
|
|
2008-05-26 09:56:50 +00:00
|
|
|
static void ReportHowGroupSolved(hGroup hg);
|
|
|
|
|
2008-06-01 00:26:41 +00:00
|
|
|
void ClearSuper(void);
|
|
|
|
|
|
|
|
void ShowHeader(bool withNav);
|
2008-04-08 12:54:53 +00:00
|
|
|
// These are self-contained screens, that show some information about
|
|
|
|
// the sketch.
|
2008-04-25 08:26:15 +00:00
|
|
|
void ShowListOfGroups(void);
|
|
|
|
void ShowGroupInfo(void);
|
|
|
|
void ShowRequestInfo(void);
|
|
|
|
void ShowEntityInfo(void);
|
2008-04-27 09:03:01 +00:00
|
|
|
void ShowConstraintInfo(void);
|
2008-05-26 09:56:50 +00:00
|
|
|
void ShowGroupSolveInfo(void);
|
2008-06-01 00:26:41 +00:00
|
|
|
// Special screen, based on selection
|
|
|
|
void DescribeSelection(void);
|
2008-04-18 07:06:37 +00:00
|
|
|
|
2008-04-28 09:40:02 +00:00
|
|
|
void OneScreenForwardTo(int screen);
|
2008-05-27 06:36:59 +00:00
|
|
|
|
|
|
|
// All of these are callbacks from the GUI code.
|
2008-04-12 14:12:26 +00:00
|
|
|
static void ScreenSelectGroup(int link, DWORD v);
|
2008-04-27 09:03:01 +00:00
|
|
|
static void ScreenActivateGroup(int link, DWORD v);
|
2008-04-28 07:18:39 +00:00
|
|
|
static void ScreenToggleGroupShown(int link, DWORD v);
|
2008-05-26 09:56:50 +00:00
|
|
|
static void ScreenHowGroupSolved(int link, DWORD v);
|
2008-05-17 08:02:39 +00:00
|
|
|
static void ScreenShowGroupsSpecial(int link, DWORD v);
|
2008-06-02 11:43:27 +00:00
|
|
|
static void ScreenDeleteGroup(int link, DWORD v);
|
2008-04-28 07:18:39 +00:00
|
|
|
|
2008-05-26 09:56:50 +00:00
|
|
|
static void ScreenHoverConstraint(int link, DWORD v);
|
|
|
|
static void ScreenHoverRequest(int link, DWORD v);
|
2008-04-25 08:26:15 +00:00
|
|
|
static void ScreenSelectRequest(int link, DWORD v);
|
2008-04-27 09:03:01 +00:00
|
|
|
static void ScreenSelectConstraint(int link, DWORD v);
|
2008-05-26 09:56:50 +00:00
|
|
|
|
2008-05-27 06:36:59 +00:00
|
|
|
static void ScreenChangeOneOrTwoSides(int link, DWORD v);
|
2008-05-25 13:11:44 +00:00
|
|
|
static void ScreenChangeMeshCombine(int link, DWORD v);
|
2008-05-30 06:09:41 +00:00
|
|
|
static void ScreenColor(int link, DWORD v);
|
2008-05-27 09:52:36 +00:00
|
|
|
|
2008-06-02 05:38:12 +00:00
|
|
|
static void ScreenUnselectAll(int link, DWORD v);
|
|
|
|
|
|
|
|
static void ScreenNavigation(int link, DWORD v);
|
|
|
|
|
2008-05-27 09:52:36 +00:00
|
|
|
// These ones do stuff with the edit control
|
2008-05-27 06:36:59 +00:00
|
|
|
static void ScreenChangeExprA(int link, DWORD v);
|
2008-05-27 09:52:36 +00:00
|
|
|
static void ScreenChangeGroupName(int link, DWORD v);
|
2008-05-17 08:02:39 +00:00
|
|
|
|
2008-05-27 06:36:59 +00:00
|
|
|
void EditControlDone(char *s);
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
class GraphicsWindow {
|
|
|
|
public:
|
2008-04-12 15:17:58 +00:00
|
|
|
void Init(void);
|
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
// This table describes the top-level menus in the graphics winodw.
|
2008-04-12 15:17:58 +00:00
|
|
|
typedef enum {
|
2008-04-18 11:11:48 +00:00
|
|
|
// File
|
|
|
|
MNU_NEW = 100,
|
|
|
|
MNU_OPEN,
|
2008-05-28 10:10:31 +00:00
|
|
|
MNU_OPEN_RECENT,
|
2008-04-18 11:11:48 +00:00
|
|
|
MNU_SAVE,
|
|
|
|
MNU_SAVE_AS,
|
|
|
|
MNU_EXIT,
|
2008-04-13 10:57:41 +00:00
|
|
|
// View
|
2008-04-18 11:11:48 +00:00
|
|
|
MNU_ZOOM_IN,
|
2008-04-12 15:17:58 +00:00
|
|
|
MNU_ZOOM_OUT,
|
|
|
|
MNU_ZOOM_TO_FIT,
|
2008-04-27 05:00:12 +00:00
|
|
|
MNU_SHOW_TEXT_WND,
|
2008-04-22 13:14:15 +00:00
|
|
|
MNU_UNITS_INCHES,
|
|
|
|
MNU_UNITS_MM,
|
2008-04-14 10:28:32 +00:00
|
|
|
// Edit
|
2008-06-04 10:22:30 +00:00
|
|
|
MNU_UNDO,
|
|
|
|
MNU_REDO,
|
2008-04-14 10:28:32 +00:00
|
|
|
MNU_DELETE,
|
2008-04-27 05:00:12 +00:00
|
|
|
MNU_UNSELECT_ALL,
|
2008-04-13 10:57:41 +00:00
|
|
|
// Request
|
2008-04-27 03:26:27 +00:00
|
|
|
MNU_SEL_WORKPLANE,
|
|
|
|
MNU_FREE_IN_3D,
|
2008-04-13 10:57:41 +00:00
|
|
|
MNU_DATUM_POINT,
|
2008-05-05 11:17:00 +00:00
|
|
|
MNU_WORKPLANE,
|
2008-04-13 10:57:41 +00:00
|
|
|
MNU_LINE_SEGMENT,
|
2008-05-05 06:18:01 +00:00
|
|
|
MNU_CIRCLE,
|
2008-05-12 10:01:44 +00:00
|
|
|
MNU_ARC,
|
2008-04-22 10:53:42 +00:00
|
|
|
MNU_RECTANGLE,
|
2008-04-25 12:07:17 +00:00
|
|
|
MNU_CUBIC,
|
2008-05-07 04:17:29 +00:00
|
|
|
MNU_CONSTRUCTION,
|
2008-04-27 09:03:01 +00:00
|
|
|
// Group
|
2008-05-11 02:57:47 +00:00
|
|
|
MNU_GROUP_3D,
|
|
|
|
MNU_GROUP_WRKPL,
|
2008-04-27 09:03:01 +00:00
|
|
|
MNU_GROUP_EXTRUDE,
|
2008-05-11 06:09:46 +00:00
|
|
|
MNU_GROUP_ROT,
|
|
|
|
MNU_GROUP_TRANS,
|
2008-05-28 10:10:31 +00:00
|
|
|
MNU_GROUP_IMPORT,
|
|
|
|
MNU_GROUP_RECENT,
|
2008-04-14 10:28:32 +00:00
|
|
|
// Constrain
|
|
|
|
MNU_DISTANCE_DIA,
|
2008-05-17 11:15:14 +00:00
|
|
|
MNU_ANGLE,
|
|
|
|
MNU_OTHER_ANGLE,
|
2008-04-22 05:00:49 +00:00
|
|
|
MNU_EQUAL,
|
2008-05-11 10:40:37 +00:00
|
|
|
MNU_RATIO,
|
2008-04-21 08:16:38 +00:00
|
|
|
MNU_ON_ENTITY,
|
2008-04-30 08:14:32 +00:00
|
|
|
MNU_SYMMETRIC,
|
|
|
|
MNU_AT_MIDPOINT,
|
2008-04-23 07:29:19 +00:00
|
|
|
MNU_HORIZONTAL,
|
|
|
|
MNU_VERTICAL,
|
2008-05-09 05:33:23 +00:00
|
|
|
MNU_PARALLEL,
|
|
|
|
MNU_ORIENTED_SAME,
|
2008-04-20 11:35:10 +00:00
|
|
|
MNU_SOLVE_NOW,
|
2008-04-12 15:17:58 +00:00
|
|
|
} MenuId;
|
2008-04-14 10:28:32 +00:00
|
|
|
typedef void MenuHandler(int id);
|
2008-03-26 09:18:12 +00:00
|
|
|
typedef struct {
|
2008-04-01 10:48:44 +00:00
|
|
|
int level; // 0 == on menu bar, 1 == one level down
|
2008-03-26 09:18:12 +00:00
|
|
|
char *label; // or NULL for a separator
|
|
|
|
int id; // unique ID
|
2008-04-12 15:17:58 +00:00
|
|
|
int accel; // keyboard accelerator
|
2008-03-26 09:18:12 +00:00
|
|
|
MenuHandler *fn;
|
|
|
|
} MenuEntry;
|
|
|
|
static const MenuEntry menu[];
|
2008-04-14 10:28:32 +00:00
|
|
|
static void MenuView(int id);
|
|
|
|
static void MenuEdit(int id);
|
|
|
|
static void MenuRequest(int id);
|
2008-04-12 14:12:26 +00:00
|
|
|
|
2008-04-01 10:48:44 +00:00
|
|
|
// The width and height (in pixels) of the window.
|
|
|
|
double width, height;
|
2008-03-25 10:02:13 +00:00
|
|
|
// These parameters define the map from 2d screen coordinates to the
|
|
|
|
// coordinates of the 3d sketch points. We will use an axonometric
|
|
|
|
// projection.
|
|
|
|
Vector offset;
|
|
|
|
Vector projRight;
|
2008-04-12 15:17:58 +00:00
|
|
|
Vector projUp;
|
2008-03-27 09:53:51 +00:00
|
|
|
double scale;
|
|
|
|
struct {
|
|
|
|
Vector offset;
|
|
|
|
Vector projRight;
|
2008-04-12 15:17:58 +00:00
|
|
|
Vector projUp;
|
2008-03-27 09:53:51 +00:00
|
|
|
Point2d mouse;
|
|
|
|
} orig;
|
|
|
|
|
2008-04-28 09:40:02 +00:00
|
|
|
// When the user is dragging a point, don't solve multiple times without
|
|
|
|
// allowing a paint in between. The extra solves are wasted if they're
|
|
|
|
// not displayed.
|
|
|
|
bool havePainted;
|
|
|
|
|
2008-03-27 09:53:51 +00:00
|
|
|
void NormalizeProjectionVectors(void);
|
2008-04-12 14:12:26 +00:00
|
|
|
Point2d ProjectPoint(Vector p);
|
2008-05-27 02:22:20 +00:00
|
|
|
void AnimateOntoWorkplane(void);
|
2008-05-02 10:54:22 +00:00
|
|
|
Vector VectorFromProjs(double right, double up, double forward);
|
2008-04-13 10:57:41 +00:00
|
|
|
|
2008-04-22 13:14:15 +00:00
|
|
|
typedef enum {
|
|
|
|
UNIT_MM = 0,
|
|
|
|
UNIT_INCHES,
|
|
|
|
} Unit;
|
|
|
|
Unit viewUnits;
|
2008-06-01 00:26:41 +00:00
|
|
|
char *ToString(double v);
|
|
|
|
double FromString(char *str);
|
2008-04-22 13:14:15 +00:00
|
|
|
|
2008-04-13 10:57:41 +00:00
|
|
|
hGroup activeGroup;
|
2008-05-27 02:22:20 +00:00
|
|
|
void EnsureValidActives(void);
|
|
|
|
bool LockedInWorkplane(void);
|
|
|
|
void SetWorkplaneFreeIn3d(void);
|
|
|
|
hEntity ActiveWorkplane(void);
|
2008-04-13 10:57:41 +00:00
|
|
|
|
|
|
|
// Operations that must be completed by doing something with the mouse
|
2008-05-05 06:18:01 +00:00
|
|
|
// are noted here. These occupy the same space as the menu ids.
|
|
|
|
static const int FIRST_PENDING = 0x0f000000;
|
2008-04-25 12:07:17 +00:00
|
|
|
static const int DRAGGING_POINT = 0x0f000000;
|
|
|
|
static const int DRAGGING_NEW_POINT = 0x0f000001;
|
|
|
|
static const int DRAGGING_NEW_LINE_POINT = 0x0f000002;
|
|
|
|
static const int DRAGGING_NEW_CUBIC_POINT = 0x0f000003;
|
2008-05-12 10:01:44 +00:00
|
|
|
static const int DRAGGING_NEW_ARC_POINT = 0x0f000004;
|
|
|
|
static const int DRAGGING_CONSTRAINT = 0x0f000005;
|
|
|
|
static const int DRAGGING_RADIUS = 0x0f000006;
|
|
|
|
static const int DRAGGING_NORMAL = 0x0f000007;
|
|
|
|
static const int DRAGGING_NEW_RADIUS = 0x0f000008;
|
2008-05-05 06:18:01 +00:00
|
|
|
struct {
|
|
|
|
int operation;
|
|
|
|
|
|
|
|
hEntity point;
|
|
|
|
hEntity circle;
|
|
|
|
hEntity normal;
|
|
|
|
hConstraint constraint;
|
2008-04-13 10:57:41 +00:00
|
|
|
|
2008-05-05 06:18:01 +00:00
|
|
|
char *description;
|
|
|
|
} pending;
|
|
|
|
void ClearPending(void);
|
2008-04-21 10:12:04 +00:00
|
|
|
// The constraint that is being edited with the on-screen textbox.
|
|
|
|
hConstraint constraintBeingEdited;
|
2008-05-05 06:18:01 +00:00
|
|
|
|
2008-05-08 07:30:30 +00:00
|
|
|
bool ConstrainPointByHovered(hEntity pt);
|
2008-06-04 10:22:30 +00:00
|
|
|
hRequest AddRequest(int type, bool rememberForUndo);
|
2008-05-05 06:18:01 +00:00
|
|
|
hRequest AddRequest(int type);
|
2008-04-11 12:47:14 +00:00
|
|
|
|
2008-04-12 14:12:26 +00:00
|
|
|
// The current selection.
|
|
|
|
class Selection {
|
|
|
|
public:
|
|
|
|
hEntity entity;
|
2008-04-14 10:28:32 +00:00
|
|
|
hConstraint constraint;
|
2008-05-26 09:56:50 +00:00
|
|
|
|
|
|
|
bool emphasized;
|
2008-04-12 14:12:26 +00:00
|
|
|
|
|
|
|
void Draw(void);
|
|
|
|
|
|
|
|
void Clear(void);
|
|
|
|
bool IsEmpty(void);
|
|
|
|
bool Equals(Selection *b);
|
|
|
|
};
|
|
|
|
Selection hover;
|
|
|
|
static const int MAX_SELECTED = 32;
|
|
|
|
Selection selection[MAX_SELECTED];
|
2008-04-23 07:29:19 +00:00
|
|
|
void HitTestMakeSelection(Point2d mp);
|
2008-04-12 15:17:58 +00:00
|
|
|
void ClearSelection(void);
|
2008-05-17 11:15:14 +00:00
|
|
|
void ClearNonexistentSelectionItems(void);
|
2008-04-12 15:17:58 +00:00
|
|
|
struct {
|
2008-04-19 11:09:47 +00:00
|
|
|
hEntity point[MAX_SELECTED];
|
2008-04-12 15:17:58 +00:00
|
|
|
hEntity entity[MAX_SELECTED];
|
2008-05-09 05:33:23 +00:00
|
|
|
hEntity anyNormal[MAX_SELECTED];
|
|
|
|
hEntity vector[MAX_SELECTED];
|
2008-06-01 00:26:41 +00:00
|
|
|
hEntity face[MAX_SELECTED];
|
2008-05-17 11:15:14 +00:00
|
|
|
hConstraint constraint[MAX_SELECTED];
|
2008-04-12 15:17:58 +00:00
|
|
|
int points;
|
|
|
|
int entities;
|
2008-04-27 03:26:27 +00:00
|
|
|
int workplanes;
|
2008-06-01 00:26:41 +00:00
|
|
|
int faces;
|
2008-04-14 10:28:32 +00:00
|
|
|
int lineSegments;
|
2008-05-07 08:19:37 +00:00
|
|
|
int circlesOrArcs;
|
2008-05-09 05:33:23 +00:00
|
|
|
int anyNormals;
|
|
|
|
int vectors;
|
2008-05-17 11:15:14 +00:00
|
|
|
int constraints;
|
2008-04-12 15:17:58 +00:00
|
|
|
int n;
|
|
|
|
} gs;
|
|
|
|
void GroupSelection(void);
|
2008-04-12 14:12:26 +00:00
|
|
|
|
2008-05-17 11:15:14 +00:00
|
|
|
void ClearSuper(void);
|
|
|
|
|
2008-04-11 12:47:14 +00:00
|
|
|
// This sets what gets displayed.
|
2008-04-27 03:26:27 +00:00
|
|
|
bool showWorkplanes;
|
2008-05-05 06:18:01 +00:00
|
|
|
bool showNormals;
|
2008-04-11 12:47:14 +00:00
|
|
|
bool showPoints;
|
|
|
|
bool showConstraints;
|
2008-04-27 05:00:12 +00:00
|
|
|
bool showTextWindow;
|
2008-05-28 10:34:55 +00:00
|
|
|
bool showShaded;
|
2008-06-02 05:38:12 +00:00
|
|
|
bool showFaces;
|
2008-05-28 10:34:55 +00:00
|
|
|
bool showMesh;
|
2008-05-02 10:54:22 +00:00
|
|
|
bool showHdnLines;
|
2008-04-11 12:47:14 +00:00
|
|
|
static void ToggleBool(int link, DWORD v);
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-05-05 06:18:01 +00:00
|
|
|
void UpdateDraggedNum(Vector *pos, double mx, double my);
|
|
|
|
void UpdateDraggedPoint(hEntity hp, double mx, double my);
|
2008-04-13 10:57:41 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
// These are called by the platform-specific code.
|
2008-03-27 09:53:51 +00:00
|
|
|
void Paint(int w, int h);
|
2008-03-25 10:02:13 +00:00
|
|
|
void MouseMoved(double x, double y, bool leftDown, bool middleDown,
|
2008-03-27 09:53:51 +00:00
|
|
|
bool rightDown, bool shiftDown, bool ctrlDown);
|
|
|
|
void MouseLeftDown(double x, double y);
|
2008-04-22 10:53:42 +00:00
|
|
|
void MouseLeftUp(double x, double y);
|
2008-03-25 10:02:13 +00:00
|
|
|
void MouseLeftDoubleClick(double x, double y);
|
2008-03-27 09:53:51 +00:00
|
|
|
void MouseMiddleDown(double x, double y);
|
2008-04-01 10:48:44 +00:00
|
|
|
void MouseScroll(double x, double y, int delta);
|
2008-04-21 10:12:04 +00:00
|
|
|
void EditControlDone(char *s);
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
#endif
|