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:
|
|
|
|
static const int MAX_COLS = 150;
|
|
|
|
static const int MAX_ROWS = 300;
|
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
|
|
|
|
static const int COLOR_BG_DEFAULT = RGB( 15, 15, 0);
|
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
typedef struct {
|
|
|
|
int fg;
|
|
|
|
int bg;
|
|
|
|
} Color;
|
|
|
|
static const Color colors[];
|
2008-04-11 12:47:14 +00:00
|
|
|
static const int COLOR_DEFAULT = 0;
|
|
|
|
static const int COLOR_MEANS_HIDDEN = 1;
|
|
|
|
static const int COLOR_MEANS_SHOWN = 2;
|
|
|
|
static const int COLOR_MEANS_MIXED = 3;
|
2008-03-28 10:00:37 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
// The rest of the window, text displayed in response to typed commands;
|
|
|
|
// some of this might do something if you click on it.
|
|
|
|
|
|
|
|
static const int NOT_A_LINK = 0;
|
|
|
|
|
|
|
|
BYTE text[MAX_ROWS][MAX_COLS];
|
2008-03-28 10:00:37 +00:00
|
|
|
typedef void LinkFunction(int link, DWORD v);
|
2008-03-25 10:02:13 +00:00
|
|
|
struct {
|
2008-03-28 10:00:37 +00:00
|
|
|
int color;
|
|
|
|
int link;
|
|
|
|
DWORD data;
|
|
|
|
LinkFunction *f;
|
2008-03-25 10:02:13 +00:00
|
|
|
} meta[MAX_ROWS][MAX_COLS];
|
|
|
|
|
2008-04-09 09:35:09 +00:00
|
|
|
int rows;
|
2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
void Init(void);
|
|
|
|
void Printf(char *fmt, ...);
|
|
|
|
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-18 07:06:37 +00:00
|
|
|
static const int SCREEN_ALL_GROUPS = 0;
|
|
|
|
static const int SCREEN_REQUESTS_IN_GROUP = 1;
|
2008-04-12 14:12:26 +00:00
|
|
|
typedef struct {
|
|
|
|
int screen;
|
|
|
|
hGroup group;
|
|
|
|
} ShownState;
|
|
|
|
static const int HISTORY_LEN = 16;
|
|
|
|
ShownState showns[HISTORY_LEN];
|
|
|
|
int shownIndex;
|
|
|
|
int history;
|
|
|
|
ShownState *shown;
|
|
|
|
|
2008-04-11 12:47:14 +00:00
|
|
|
void ShowHeader(void);
|
2008-04-08 12:54:53 +00:00
|
|
|
// These are self-contained screens, that show some information about
|
|
|
|
// the sketch.
|
2008-04-18 07:06:37 +00:00
|
|
|
void ShowAllGroups(void);
|
|
|
|
void ShowRequestsInGroup(void);
|
|
|
|
|
2008-04-12 14:12:26 +00:00
|
|
|
void OneScreenForward(void);
|
|
|
|
static void ScreenSelectGroup(int link, DWORD v);
|
|
|
|
static void ScreenNavigaton(int link, DWORD v);
|
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,
|
|
|
|
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,
|
|
|
|
MNU_ORIENT_ONTO,
|
2008-04-14 10:28:32 +00:00
|
|
|
MNU_LOCK_VIEW,
|
2008-04-12 15:17:58 +00:00
|
|
|
MNU_UNSELECT_ALL,
|
2008-04-14 10:28:32 +00:00
|
|
|
// Edit
|
|
|
|
MNU_DELETE,
|
2008-04-13 10:57:41 +00:00
|
|
|
// Request
|
2008-04-18 07:06:37 +00:00
|
|
|
MNU_SEL_CSYS,
|
|
|
|
MNU_NO_CSYS,
|
2008-04-13 10:57:41 +00:00
|
|
|
MNU_DATUM_POINT,
|
|
|
|
MNU_LINE_SEGMENT,
|
2008-04-14 10:28:32 +00:00
|
|
|
// Constrain
|
|
|
|
MNU_DISTANCE_DIA,
|
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-14 10:28:32 +00:00
|
|
|
bool viewLocked;
|
2008-03-27 09:53:51 +00:00
|
|
|
|
|
|
|
void NormalizeProjectionVectors(void);
|
2008-04-12 14:12:26 +00:00
|
|
|
Point2d ProjectPoint(Vector p);
|
2008-04-13 10:57:41 +00:00
|
|
|
|
|
|
|
hGroup activeGroup;
|
2008-04-18 07:06:37 +00:00
|
|
|
hEntity activeCsys;
|
|
|
|
void EnsureValidActives();
|
2008-04-13 10:57:41 +00:00
|
|
|
|
|
|
|
// Operations that must be completed by doing something with the mouse
|
|
|
|
// are noted here.
|
|
|
|
static const int PENDING_OPERATION_DRAGGING_POINT = 0x0f000000;
|
2008-04-19 11:09:47 +00:00
|
|
|
hEntity pendingPoint;
|
2008-04-13 10:57:41 +00:00
|
|
|
int pendingOperation;
|
|
|
|
char *pendingDescription;
|
|
|
|
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-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];
|
|
|
|
void HitTestMakeSelection(Point2d mp, Selection *dest);
|
2008-04-12 15:17:58 +00:00
|
|
|
void ClearSelection(void);
|
|
|
|
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];
|
|
|
|
int points;
|
|
|
|
int entities;
|
|
|
|
int csyss;
|
2008-04-14 10:28:32 +00:00
|
|
|
int lineSegments;
|
2008-04-12 15:17:58 +00:00
|
|
|
int n;
|
|
|
|
} gs;
|
|
|
|
void GroupSelection(void);
|
2008-04-12 14:12:26 +00:00
|
|
|
|
2008-04-11 12:47:14 +00:00
|
|
|
// This sets what gets displayed.
|
|
|
|
bool show2dCsyss;
|
|
|
|
bool showAxes;
|
|
|
|
bool showPoints;
|
|
|
|
bool showAllGroups;
|
|
|
|
bool showConstraints;
|
|
|
|
static void ToggleBool(int link, DWORD v);
|
|
|
|
static void ToggleAnyDatumShown(int link, DWORD v);
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
void UpdateDraggedPoint(Vector *pos, double mx, double my);
|
2008-04-19 11:09:47 +00:00
|
|
|
void UpdateDraggedEntity(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-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-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
|