/* Public domain */ #ifndef _FREESG_SK_SK_VIEW_H_ #define _FREESG_SK_SK_VIEW_H_ #include #include struct sk; struct sk_point; struct ag_pane; typedef struct sk_view { struct ag_glview _inherit; Uint flags; #define SK_VIEW_HFILL 0x01 #define SK_VIEW_VFILL 0x02 #define SK_VIEW_EXPAND (SK_VIEW_HFILL|SK_VIEW_VFILL) struct sk *sk; /* Sketch object */ M_Matrix44 mView; /* Viewing matrix */ M_Matrix44 mProj; /* Projection matrix */ M_Real wPixel, hPixel; /* Display pixel ratio */ AG_Event *scale_ev; /* Scaling/movement event */ AG_Event *keydown_ev, *keyup_ev; /* Keyboard events */ AG_Event *btndown_ev, *btnup_ev; /* Mouse button events */ AG_Event *motion_ev; /* Mouse motion event */ char status[128]; /* Status text buffer */ struct { M_Vector3 last; /* Last coordinates */ int panning; /* Panning mode */ } mouse; SK_Tool *curtool; /* Selected tool */ SK_Tool *deftool; /* Default tool if any */ AG_PopupMenu *popup; /* Popup menu for context */ struct ag_pane *editPane; /* Edition pane */ struct ag_pane *viewPane; /* Visualization pane */ struct ag_widget *editBox; /* Widget container */ M_Real rSnap; /* Snapping radius */ AG_TAILQ_HEAD(, sk_tool) tools; /* Sketching tools */ AG_Tbl tblNodeData; /* Per-node data */ } SK_View; #define SKVIEW(p) ((SK_View *)(p)) #define SK_VIEW_X(skv,px) ((M_Real)(px - WIDGET(skv)->w/2)) / \ ((M_Real)WIDGET(skv)->w/2.0) #define SK_VIEW_Y(skv,py) ((M_Real)(py - WIDGET(skv)->h/2)) / \ ((M_Real)WIDGET(skv)->h/2.0) #define SK_VIEW_X_SNAP(skv,px) (px) #define SK_VIEW_Y_SNAP(skv,py) (py) #define SK_VIEW_SCALE_X(skv) (skv)->mView.m[0][0] #define SK_VIEW_SCALE_Y(skv) (skv)->mView.m[1][1] __BEGIN_DECLS extern AG_WidgetClass skViewClass; SK_View *SK_ViewNew(void *, struct sk *, Uint); void SK_ViewZoom(SK_View *, M_Real); void SK_ViewSelectTool(SK_View *, SK_Tool *, void *); SK_Tool *SK_ViewFindTool(SK_View *, const char *); SK_Tool *SK_ViewFindToolByOps(SK_View *, const SK_ToolOps *); SK_Tool *SK_ViewRegTool(SK_View *, const SK_ToolOps *, void *); void SK_ViewSetDefaultTool(SK_View *, SK_Tool *); void SK_ViewPopupMenu(SK_View *); void SK_ViewClearEditPane(SK_View *); void SK_ViewSetEditPane(SK_View *, struct ag_pane *); void SK_ViewSetViewPane(SK_View *, struct ag_pane *); void SK_ViewResizePanes(SK_View *); struct sk_point *SK_ViewOverPoint(SK_View *, M_Vector3 *, M_Vector3 *, void *); void *SK_ViewGetNodeData(SK_View *, void *); void SK_ViewSetNodeData(SK_View *, void *, void *); __END_DECLS #include #endif /* _FREESG_SK_SK_VIEW_H_ */