1 //-----------------------------------------------------------------------------
2 // Declarations relating to our user interface, in both the graphics and
3 // text browser window.
4 //
5 // Copyright 2008-2013 Jonathan Westhues.
6 //-----------------------------------------------------------------------------
7 
8 #ifndef __UI_H
9 #define __UI_H
10 
11 class TextWindow {
12 public:
13     enum {
14         MAX_COLS = 100,
15         MIN_COLS = 45,
16         MAX_ROWS = 2000
17     };
18 
19     typedef struct {
20         char      c;
21         RgbaColor color;
22     } Color;
23     static const Color fgColors[];
24     static const Color bgColors[];
25 
26     float bgColorTable[256*3];
27     float fgColorTable[256*3];
28 
29     enum {
30         CHAR_WIDTH     = 9,
31         CHAR_HEIGHT    = 16,
32         LINE_HEIGHT    = 20,
33         LEFT_MARGIN    = 6,
34     };
35 
36 #define CHECK_FALSE "\xEE\x80\x80" // U+E000
37 #define CHECK_TRUE  "\xEE\x80\x81"
38 #define RADIO_FALSE "\xEE\x80\x82"
39 #define RADIO_TRUE  "\xEE\x80\x83"
40 
41     int scrollPos;      // The scrollbar position, in half-row units
42     int halfRows;       // The height of our window, in half-row units
43 
44     uint32_t text[MAX_ROWS][MAX_COLS];
45     typedef void LinkFunction(int link, uint32_t v);
46     enum { NOT_A_LINK = 0 };
47     struct {
48         char            fg;
49         char            bg;
50         RgbaColor       bgRgb;
51         int             link;
52         uint32_t        data;
53         LinkFunction   *f;
54         LinkFunction   *h;
55     }       meta[MAX_ROWS][MAX_COLS];
56     int hoveredRow, hoveredCol;
57 
58 
59     int top[MAX_ROWS]; // in half-line units, or -1 for unused
60     int rows;
61 
62     // The row of icons at the top of the text window, to hide/show things
63     typedef struct {
64         bool       *var;
65         uint8_t    *icon;
66         const char *tip;
67     } HideShowIcon;
68     static HideShowIcon hideShowIcons[];
69     static bool SPACER;
70 
71     // These are called by the platform-specific code.
72     void Paint(void);
73     void MouseEvent(bool isClick, bool leftDown, double x, double y);
74     void MouseScroll(double x, double y, int delta);
75     void MouseLeave(void);
76     void ScrollbarEvent(int newPos);
77 
78     enum {
79         PAINT = 0,
80         HOVER = 1,
81         CLICK = 2
82     };
83     void DrawOrHitTestIcons(int how, double mx, double my);
84     void TimerCallback(void);
85     Point2d oldMousePos;
86     HideShowIcon *hoveredIcon, *tooltippedIcon;
87 
88     Vector HsvToRgb(Vector hsv);
89     uint8_t *HsvPattern2d(void);
90     uint8_t *HsvPattern1d(double h, double s);
91     void ColorPickerDone(void);
92     bool DrawOrHitTestColorPicker(int how, bool leftDown, double x, double y);
93 
94     void Init(void);
95     void MakeColorTable(const Color *in, float *out);
96     void Printf(bool half, const char *fmt, ...);
97     void ClearScreen(void);
98 
99     void Show(void);
100 
101     // State for the screen that we are showing in the text window.
102     enum {
103         SCREEN_LIST_OF_GROUPS      = 0,
104         SCREEN_GROUP_INFO          = 1,
105         SCREEN_GROUP_SOLVE_INFO    = 2,
106         SCREEN_CONFIGURATION       = 3,
107         SCREEN_STEP_DIMENSION      = 4,
108         SCREEN_LIST_OF_STYLES      = 5,
109         SCREEN_STYLE_INFO          = 6,
110         SCREEN_PASTE_TRANSFORMED   = 7,
111         SCREEN_EDIT_VIEW           = 8,
112         SCREEN_TANGENT_ARC         = 9
113     };
114     typedef struct {
115         int         screen;
116 
117         hGroup      group;
118         hStyle      style;
119 
120         hConstraint constraint;
121         bool        dimIsDistance;
122         double      dimFinish;
123         int         dimSteps;
124 
125         struct {
126             int         times;
127             Vector      trans;
128             double      theta;
129             Vector      origin;
130             double      scale;
131         }           paste;
132     } ShownState;
133     ShownState shown;
134 
135     enum {
136         EDIT_NOTHING               = 0,
137         // For multiple groups
138         EDIT_TIMES_REPEATED        = 1,
139         EDIT_GROUP_NAME            = 2,
140         EDIT_GROUP_SCALE           = 3,
141         EDIT_GROUP_COLOR           = 4,
142         EDIT_GROUP_OPACITY         = 5,
143         // For the configuraiton screen
144         EDIT_LIGHT_DIRECTION       = 100,
145         EDIT_LIGHT_INTENSITY       = 101,
146         EDIT_COLOR                 = 102,
147         EDIT_CHORD_TOLERANCE       = 103,
148         EDIT_MAX_SEGMENTS          = 104,
149         EDIT_CAMERA_TANGENT        = 105,
150         EDIT_GRID_SPACING          = 106,
151         EDIT_DIGITS_AFTER_DECIMAL  = 107,
152         EDIT_EXPORT_SCALE          = 108,
153         EDIT_EXPORT_OFFSET         = 109,
154         EDIT_CANVAS_SIZE           = 110,
155         EDIT_G_CODE_DEPTH          = 120,
156         EDIT_G_CODE_PASSES         = 121,
157         EDIT_G_CODE_FEED           = 122,
158         EDIT_G_CODE_PLUNGE_FEED    = 123,
159         EDIT_AUTOSAVE_INTERVAL     = 124,
160         // For TTF text
161         EDIT_TTF_TEXT              = 300,
162         // For the step dimension screen
163         EDIT_STEP_DIM_FINISH       = 400,
164         EDIT_STEP_DIM_STEPS        = 401,
165         // For the styles stuff
166         EDIT_STYLE_WIDTH           = 500,
167         EDIT_STYLE_TEXT_HEIGHT     = 501,
168         EDIT_STYLE_TEXT_ANGLE      = 502,
169         EDIT_STYLE_COLOR           = 503,
170         EDIT_STYLE_FILL_COLOR      = 504,
171         EDIT_STYLE_NAME            = 505,
172         EDIT_BACKGROUND_COLOR      = 506,
173         EDIT_BACKGROUND_IMG_SCALE  = 507,
174         EDIT_STYLE_STIPPLE_PERIOD  = 508,
175         // For paste transforming
176         EDIT_PASTE_TIMES_REPEATED  = 600,
177         EDIT_PASTE_ANGLE           = 601,
178         EDIT_PASTE_SCALE           = 602,
179         // For view
180         EDIT_VIEW_SCALE            = 700,
181         EDIT_VIEW_ORIGIN           = 701,
182         EDIT_VIEW_PROJ_RIGHT       = 702,
183         EDIT_VIEW_PROJ_UP          = 703,
184         // For tangent arc
185         EDIT_TANGENT_ARC_RADIUS    = 800
186     };
187     struct {
188         bool        showAgain;
189         int         meaning;
190         int         i;
191         hGroup      group;
192         hRequest    request;
193         hStyle      style;
194     } edit;
195 
196     static void ReportHowGroupSolved(hGroup hg);
197 
198     struct {
199         int     halfRow;
200         int     col;
201 
202         struct {
203             RgbaColor rgb;
204             double    h, s, v;
205             bool      show;
206             bool      picker1dActive;
207             bool      picker2dActive;
208         }       colorPicker;
209     } editControl;
210 
211     void HideEditControl(void);
212     void ShowEditControl(int col, const std::string &str, int halfRow = -1);
213     void ShowEditControlWithColorPicker(int col, RgbaColor rgb);
214 
215     void ClearSuper(void);
216 
217     void ShowHeader(bool withNav);
218     // These are self-contained screens, that show some information about
219     // the sketch.
220     void ShowListOfGroups(void);
221     void ShowGroupInfo(void);
222     void ShowGroupSolveInfo(void);
223     void ShowConfiguration(void);
224     void ShowListOfStyles(void);
225     void ShowStyleInfo(void);
226     void ShowStepDimension(void);
227     void ShowPasteTransformed(void);
228     void ShowEditView(void);
229     void ShowTangentArc(void);
230     // Special screen, based on selection
231     void DescribeSelection(void);
232 
233     void GoToScreen(int screen);
234 
235     // All of these are callbacks from the GUI code; first from when
236     // we're describing an entity
237     static void ScreenEditTtfText(int link, uint32_t v);
238     static void ScreenSetTtfFont(int link, uint32_t v);
239     static void ScreenUnselectAll(int link, uint32_t v);
240 
241     // when we're describing a constraint
242     static void ScreenConstraintShowAsRadius(int link, uint32_t v);
243 
244     // and the rest from the stuff in textscreens.cpp
245     static void ScreenSelectGroup(int link, uint32_t v);
246     static void ScreenActivateGroup(int link, uint32_t v);
247     static void ScreenToggleGroupShown(int link, uint32_t v);
248     static void ScreenHowGroupSolved(int link, uint32_t v);
249     static void ScreenShowGroupsSpecial(int link, uint32_t v);
250     static void ScreenDeleteGroup(int link, uint32_t v);
251 
252     static void ScreenHoverConstraint(int link, uint32_t v);
253     static void ScreenHoverRequest(int link, uint32_t v);
254     static void ScreenSelectRequest(int link, uint32_t v);
255     static void ScreenSelectConstraint(int link, uint32_t v);
256 
257     static void ScreenChangeGroupOption(int link, uint32_t v);
258     static void ScreenColor(int link, uint32_t v);
259     static void ScreenOpacity(int link, uint32_t v);
260 
261     static void ScreenShowListOfStyles(int link, uint32_t v);
262     static void ScreenShowStyleInfo(int link, uint32_t v);
263     static void ScreenDeleteStyle(int link, uint32_t v);
264     static void ScreenChangeStylePatternType(int link, uint32_t v);
265     static void ScreenChangeStyleYesNo(int link, uint32_t v);
266     static void ScreenCreateCustomStyle(int link, uint32_t v);
267     static void ScreenLoadFactoryDefaultStyles(int link, uint32_t v);
268     static void ScreenAssignSelectionToStyle(int link, uint32_t v);
269     static void ScreenBackgroundImage(int link, uint32_t v);
270 
271     static void ScreenShowConfiguration(int link, uint32_t v);
272     static void ScreenShowEditView(int link, uint32_t v);
273     static void ScreenGoToWebsite(int link, uint32_t v);
274 
275     static void ScreenChangeFixExportColors(int link, uint32_t v);
276     static void ScreenChangeBackFaces(int link, uint32_t v);
277     static void ScreenChangeCheckClosedContour(int link, uint32_t v);
278     static void ScreenChangePwlCurves(int link, uint32_t v);
279     static void ScreenChangeCanvasSizeAuto(int link, uint32_t v);
280     static void ScreenChangeCanvasSize(int link, uint32_t v);
281     static void ScreenChangeShadedTriangles(int link, uint32_t v);
282 
283     static void ScreenAllowRedundant(int link, uint32_t v);
284 
285     static void ScreenStepDimSteps(int link, uint32_t v);
286     static void ScreenStepDimFinish(int link, uint32_t v);
287     static void ScreenStepDimGo(int link, uint32_t v);
288 
289     static void ScreenChangeTangentArc(int link, uint32_t v);
290 
291     static void ScreenPasteTransformed(int link, uint32_t v);
292 
293     static void ScreenHome(int link, uint32_t v);
294 
295     // These ones do stuff with the edit control
296     static void ScreenChangeExprA(int link, uint32_t v);
297     static void ScreenChangeGroupName(int link, uint32_t v);
298     static void ScreenChangeGroupScale(int link, uint32_t v);
299     static void ScreenChangeLightDirection(int link, uint32_t v);
300     static void ScreenChangeLightIntensity(int link, uint32_t v);
301     static void ScreenChangeColor(int link, uint32_t v);
302     static void ScreenChangeChordTolerance(int link, uint32_t v);
303     static void ScreenChangeMaxSegments(int link, uint32_t v);
304     static void ScreenChangeExportChordTolerance(int link, uint32_t v);
305     static void ScreenChangeExportMaxSegments(int link, uint32_t v);
306     static void ScreenChangeCameraTangent(int link, uint32_t v);
307     static void ScreenChangeGridSpacing(int link, uint32_t v);
308     static void ScreenChangeDigitsAfterDecimal(int link, uint32_t v);
309     static void ScreenChangeExportScale(int link, uint32_t v);
310     static void ScreenChangeExportOffset(int link, uint32_t v);
311     static void ScreenChangeGCodeParameter(int link, uint32_t v);
312     static void ScreenChangeAutosaveInterval(int link, uint32_t v);
313     static void ScreenChangeStyleName(int link, uint32_t v);
314     static void ScreenChangeStyleMetric(int link, uint32_t v);
315     static void ScreenChangeStyleTextAngle(int link, uint32_t v);
316     static void ScreenChangeStyleColor(int link, uint32_t v);
317     static void ScreenChangeBackgroundColor(int link, uint32_t v);
318     static void ScreenChangeBackgroundImageScale(int link, uint32_t v);
319     static void ScreenChangePasteTransformed(int link, uint32_t v);
320     static void ScreenChangeViewScale(int link, uint32_t v);
321     static void ScreenChangeViewOrigin(int link, uint32_t v);
322     static void ScreenChangeViewProjection(int link, uint32_t v);
323 
324     bool EditControlDoneForStyles(const char *s);
325     bool EditControlDoneForConfiguration(const char *s);
326     bool EditControlDoneForPaste(const char *s);
327     bool EditControlDoneForView(const char *s);
328     void EditControlDone(const char *s);
329 };
330 
331 #define SELECTION_RADIUS 10.0
332 
333 class GraphicsWindow {
334 public:
335     void Init(void);
336 
337     // This table describes the top-level menus in the graphics winodw.
338     typedef enum {
339         // File
340         MNU_NEW = 100,
341         MNU_OPEN,
342         MNU_OPEN_RECENT,
343         MNU_SAVE,
344         MNU_SAVE_AS,
345         MNU_EXPORT_PNG,
346         MNU_EXPORT_MESH,
347         MNU_EXPORT_SURFACES,
348         MNU_EXPORT_VIEW,
349         MNU_EXPORT_SECTION,
350         MNU_EXPORT_WIREFRAME,
351         MNU_IMPORT,
352         MNU_EXIT,
353         // View
354         MNU_ZOOM_IN,
355         MNU_ZOOM_OUT,
356         MNU_ZOOM_TO_FIT,
357         MNU_SHOW_GRID,
358         MNU_PERSPECTIVE_PROJ,
359         MNU_ONTO_WORKPLANE,
360         MNU_NEAREST_ORTHO,
361         MNU_NEAREST_ISO,
362         MNU_CENTER_VIEW,
363         MNU_SHOW_MENU_BAR,
364         MNU_SHOW_TOOLBAR,
365         MNU_SHOW_TEXT_WND,
366         MNU_UNITS_INCHES,
367         MNU_UNITS_MM,
368         MNU_FULL_SCREEN,
369         // Edit
370         MNU_UNDO,
371         MNU_REDO,
372         MNU_CUT,
373         MNU_COPY,
374         MNU_PASTE,
375         MNU_PASTE_TRANSFORM,
376         MNU_DELETE,
377         MNU_SELECT_CHAIN,
378         MNU_SELECT_ALL,
379         MNU_SNAP_TO_GRID,
380         MNU_ROTATE_90,
381         MNU_UNSELECT_ALL,
382         MNU_REGEN_ALL,
383         // Request
384         MNU_SEL_WORKPLANE,
385         MNU_FREE_IN_3D,
386         MNU_DATUM_POINT,
387         MNU_WORKPLANE,
388         MNU_LINE_SEGMENT,
389         MNU_CONSTR_SEGMENT,
390         MNU_CIRCLE,
391         MNU_ARC,
392         MNU_RECTANGLE,
393         MNU_CUBIC,
394         MNU_TTF_TEXT,
395         MNU_SPLIT_CURVES,
396         MNU_TANGENT_ARC,
397         MNU_CONSTRUCTION,
398         // Group
399         MNU_GROUP_3D,
400         MNU_GROUP_WRKPL,
401         MNU_GROUP_EXTRUDE,
402         MNU_GROUP_LATHE,
403         MNU_GROUP_ROT,
404         MNU_GROUP_TRANS,
405         MNU_GROUP_LINK,
406         MNU_GROUP_RECENT,
407         // Constrain
408         MNU_DISTANCE_DIA,
409         MNU_REF_DISTANCE,
410         MNU_ANGLE,
411         MNU_REF_ANGLE,
412         MNU_OTHER_ANGLE,
413         MNU_REFERENCE,
414         MNU_EQUAL,
415         MNU_RATIO,
416         MNU_DIFFERENCE,
417         MNU_ON_ENTITY,
418         MNU_SYMMETRIC,
419         MNU_AT_MIDPOINT,
420         MNU_HORIZONTAL,
421         MNU_VERTICAL,
422         MNU_PARALLEL,
423         MNU_PERPENDICULAR,
424         MNU_ORIENTED_SAME,
425         MNU_WHERE_DRAGGED,
426         MNU_COMMENT,
427         // Analyze
428         MNU_VOLUME,
429         MNU_AREA,
430         MNU_INTERFERENCE,
431         MNU_NAKED_EDGES,
432         MNU_SHOW_DOF,
433         MNU_TRACE_PT,
434         MNU_STOP_TRACING,
435         MNU_STEP_DIM,
436         // Help,
437         MNU_WEBSITE,
438         MNU_ABOUT
439     } MenuId;
440     typedef void MenuHandler(int id);
441     enum {
442         ESCAPE_KEY = 27,
443         DELETE_KEY = 127,
444         FUNCTION_KEY_BASE = 0xf0
445     };
446     enum {
447         SHIFT_MASK = 0x100,
448         CTRL_MASK  = 0x200
449     };
450     enum MenuItemKind {
451         MENU_ITEM_NORMAL = 0,
452         MENU_ITEM_CHECK,
453         MENU_ITEM_RADIO
454     };
455     typedef struct {
456         int          level;          // 0 == on menu bar, 1 == one level down
457         const char  *label;          // or NULL for a separator
458         int          id;             // unique ID
459         int          accel;          // keyboard accelerator
460         MenuItemKind kind;
461         MenuHandler  *fn;
462     } MenuEntry;
463     static const MenuEntry menu[];
464     static void MenuView(int id);
465     static void MenuEdit(int id);
466     static void MenuRequest(int id);
467     void DeleteSelection(void);
468     void CopySelection(void);
469     void PasteClipboard(Vector trans, double theta, double scale);
470     static void MenuClipboard(int id);
471 
472     // The width and height (in pixels) of the window.
473     double width, height;
474     // These parameters define the map from 2d screen coordinates to the
475     // coordinates of the 3d sketch points. We will use an axonometric
476     // projection.
477     Vector  offset;
478     Vector  projRight;
479     Vector  projUp;
480     double  scale;
481     struct {
482         bool    mouseDown;
483         Vector  offset;
484         Vector  projRight;
485         Vector  projUp;
486         Point2d mouse;
487         Point2d mouseOnButtonDown;
488         Vector  marqueePoint;
489         bool    startedMoving;
490     }       orig;
491     // We need to detect when the projection is changed to invalidate
492     // caches for drawn items.
493     struct {
494         Vector  offset;
495         Vector  projRight;
496         Vector  projUp;
497         double  scale;
498     }       cached;
499 
500     // Most recent mouse position, updated every time the mouse moves.
501     Point2d currentMousePosition;
502 
503     // When the user is dragging a point, don't solve multiple times without
504     // allowing a paint in between. The extra solves are wasted if they're
505     // not displayed.
506     bool    havePainted;
507     // Similarly, don't draw edges and outlines, since that's too slow
508     // for real-time dragging.
509     bool    isDegraded;
510 
511     // Some state for the context menu.
512     struct {
513         bool        active;
514     }       context;
515 
516     void NormalizeProjectionVectors(void);
517     Point2d ProjectPoint(Vector p);
518     Vector ProjectPoint3(Vector p);
519     Vector ProjectPoint4(Vector p, double *w);
520     Vector UnProjectPoint(Point2d p);
521     Vector UnProjectPoint3(Vector p);
522     void AnimateOnto(Quaternion quatf, Vector offsetf);
523     void AnimateOntoWorkplane(void);
524     Vector VectorFromProjs(Vector rightUpForward);
525     void HandlePointForZoomToFit(Vector p, Point2d *pmax, Point2d *pmin,
526                                            double *wmin, bool usePerspective);
527     void LoopOverPoints(const std::vector<Entity *> &entity, const std::vector<hEntity> &faces, Point2d *pmax, Point2d *pmin,
528                         double *wmin, bool usePerspective, bool includeMesh);
529     void ZoomToFit(bool includingInvisibles, bool useSelection = false);
530 
531     hGroup  activeGroup;
532     void EnsureValidActives(void);
533     bool LockedInWorkplane(void);
534     void SetWorkplaneFreeIn3d(void);
535     hEntity ActiveWorkplane(void);
536     void ForceTextWindowShown(void);
537 
538     // Operations that must be completed by doing something with the mouse
539     // are noted here. These occupy the same space as the menu ids.
540     enum {
541         FIRST_PENDING               = 0x0f000000,
542         DRAGGING_POINTS             = 0x0f000000,
543         DRAGGING_NEW_POINT          = 0x0f000001,
544         DRAGGING_NEW_LINE_POINT     = 0x0f000002,
545         DRAGGING_NEW_CUBIC_POINT    = 0x0f000003,
546         DRAGGING_NEW_ARC_POINT      = 0x0f000004,
547         DRAGGING_CONSTRAINT         = 0x0f000005,
548         DRAGGING_RADIUS             = 0x0f000006,
549         DRAGGING_NORMAL             = 0x0f000007,
550         DRAGGING_NEW_RADIUS         = 0x0f000008,
551         DRAGGING_MARQUEE            = 0x0f000009
552     };
553 
554     enum SuggestedConstraint {
555         SUGGESTED_NONE = 0,
556         SUGGESTED_HORIZONTAL = Constraint::HORIZONTAL,
557         SUGGESTED_VERTICAL = Constraint::VERTICAL,
558     };
559 
560     struct {
561         int                  operation;
562 
563         hRequest             request;
564         hEntity              point;
565         List<hEntity>        points;
566         hEntity              circle;
567         hEntity              normal;
568         hConstraint          constraint;
569 
570         const char          *description;
571 
572         SuggestedConstraint  suggestion;
573     } pending;
574     void ClearPending(void);
575     // The constraint that is being edited with the on-screen textbox.
576     hConstraint constraintBeingEdited;
577 
578     SuggestedConstraint SuggestLineConstraint(hRequest lineSegment);
579 
580     Vector SnapToGrid(Vector p);
581     bool ConstrainPointByHovered(hEntity pt);
582     void DeleteTaggedRequests(void);
583     hRequest AddRequest(int type, bool rememberForUndo);
584     hRequest AddRequest(int type);
585 
586     class ParametricCurve {
587     public:
588         bool isLine; // else circle
589         Vector p0, p1;
590         Vector u, v;
591         double r, theta0, theta1, dtheta;
592 
593         void MakeFromEntity(hEntity he, bool reverse);
594         Vector PointAt(double t);
595         Vector TangentAt(double t);
596         double LengthForAuto(void);
597 
598         hRequest CreateRequestTrimmedTo(double t, bool extraConstraints,
599             hEntity orig, hEntity arc, bool arcFinish);
600         void ConstrainPointIfCoincident(hEntity hpt);
601     };
602     void MakeTangentArc(void);
603     void SplitLinesOrCurves(void);
604     hEntity SplitEntity(hEntity he, Vector pinter);
605     hEntity SplitLine(hEntity he, Vector pinter);
606     hEntity SplitCircle(hEntity he, Vector pinter);
607     hEntity SplitCubic(hEntity he, Vector pinter);
608     void ReplacePointInConstraints(hEntity oldpt, hEntity newpt);
609     void RemoveConstraintsForPointBeingDeleted(hEntity hpt);
610     void FixConstraintsForRequestBeingDeleted(hRequest hr);
611     void FixConstraintsForPointBeingDeleted(hEntity hpt);
612 
613     // The current selection.
614     class Selection {
615     public:
616         int         tag;
617 
618         hEntity     entity;
619         hConstraint constraint;
620         bool        emphasized;
621 
622         void Draw(void);
623 
624         void Clear(void);
625         bool IsEmpty(void);
626         bool Equals(Selection *b);
627         bool HasEndpoints(void);
628     };
629     Selection hover;
630     bool hoverWasSelectedOnMousedown;
631     List<Selection> selection;
632     void HitTestMakeSelection(Point2d mp);
633     void ClearSelection(void);
634     void ClearNonexistentSelectionItems(void);
635     struct {
636         std::vector<hEntity>     point;
637         std::vector<hEntity>     entity;
638         std::vector<hEntity>     anyNormal;
639         std::vector<hEntity>     vector;
640         std::vector<hEntity>     face;
641         std::vector<hConstraint> constraint;
642         int         points;
643         int         entities;
644         int         workplanes;
645         int         faces;
646         int         lineSegments;
647         int         circlesOrArcs;
648         int         arcs;
649         int         cubics;
650         int         periodicCubics;
651         int         anyNormals;
652         int         vectors;
653         int         constraints;
654         int         stylables;
655         int         constraintLabels;
656         int         withEndpoints;
657         int         n;
658     } gs;
659     void GroupSelection(void);
660     bool IsSelected(Selection *s);
661     bool IsSelected(hEntity he);
662     void MakeSelected(hEntity he);
663     void MakeSelected(hConstraint hc);
664     void MakeSelected(Selection *s);
665     void MakeUnselected(hEntity he, bool coincidentPointTrick);
666     void MakeUnselected(Selection *s, bool coincidentPointTrick);
667     void SelectByMarquee(void);
668     void ClearSuper(void);
669 
670     enum {
671         CMNU_UNSELECT_ALL     = 0x100,
672         CMNU_UNSELECT_HOVERED = 0x101,
673         CMNU_CUT_SEL          = 0x102,
674         CMNU_COPY_SEL         = 0x103,
675         CMNU_PASTE            = 0x104,
676         CMNU_PASTE_XFRM       = 0x105,
677         CMNU_DELETE_SEL       = 0x106,
678         CMNU_SELECT_CHAIN     = 0x107,
679         CMNU_NEW_CUSTOM_STYLE = 0x110,
680         CMNU_NO_STYLE         = 0x111,
681         CMNU_GROUP_INFO       = 0x120,
682         CMNU_STYLE_INFO       = 0x121,
683         CMNU_REFERENCE_DIM    = 0x130,
684         CMNU_OTHER_ANGLE      = 0x131,
685         CMNU_DEL_COINCIDENT   = 0x132,
686         CMNU_SNAP_TO_GRID     = 0x140,
687         CMNU_REMOVE_SPLINE_PT = 0x141,
688         CMNU_ADD_SPLINE_PT    = 0x142,
689         CMNU_FIRST_STYLE      = 0x40000000
690     };
691     void ContextMenuListStyles(void);
692     int64_t contextMenuCancelTime;
693 
694     // The toolbar, in toolbar.cpp
695     bool ToolbarDrawOrHitTest(int x, int y, bool paint, int *menuHit);
696     void ToolbarDraw(void);
697     bool ToolbarMouseMoved(int x, int y);
698     bool ToolbarMouseDown(int x, int y);
699     static void TimerCallback(void);
700     int toolbarHovered;
701     int toolbarTooltipped;
702     int toolbarMouseX, toolbarMouseY;
703 
704     // This sets what gets displayed.
705     bool    showWorkplanes;
706     bool    showNormals;
707     bool    showPoints;
708     bool    showConstraints;
709     bool    showTextWindow;
710     bool    showShaded;
711     bool    showEdges;
712     bool    showOutlines;
713     bool    showFaces;
714     bool    showMesh;
715     bool    showHdnLines;
716     void ToggleBool(bool *v);
717 
718     bool    showSnapGrid;
719 
720     void AddPointToDraggedList(hEntity hp);
721     void StartDraggingByEntity(hEntity he);
722     void StartDraggingBySelection(void);
723     void UpdateDraggedNum(Vector *pos, double mx, double my);
724     void UpdateDraggedPoint(hEntity hp, double mx, double my);
725 
726     // These are called by the platform-specific code.
727     void Paint(void);
728     void MouseMoved(double x, double y, bool leftDown, bool middleDown,
729                                 bool rightDown, bool shiftDown, bool ctrlDown);
730     void MouseLeftDown(double x, double y);
731     void MouseLeftUp(double x, double y);
732     void MouseLeftDoubleClick(double x, double y);
733     void MouseMiddleOrRightDown(double x, double y);
734     void MouseRightUp(double x, double y);
735     void MouseScroll(double x, double y, int delta);
736     void MouseLeave(void);
737     bool KeyDown(int c);
738     void EditControlDone(const char *s);
739 
740     int64_t lastSpaceNavigatorTime;
741     hGroup lastSpaceNavigatorGroup;
742     void SpaceNavigatorMoved(double tx, double ty, double tz,
743                              double rx, double ry, double rz, bool shiftDown);
744     void SpaceNavigatorButtonUp(void);
745 };
746 
747 
748 #endif
749