/*****************************************************************************\ FILE : UgLineCreate.c PURPOSE : Pro/TOOLKIT User Guide Example - Create a line draft entity HISTORY.. DATE BUILD AUTHOR MODIFICATIONS 04-Dec-97 H-02-02 Philippe $$1 Created 10-Dec-97 H-03-31 Philippe $$2 add includes \*****************************************************************************/ /*-------------------------- Pro/Develop includes ---------------------------*/ #include #include /*-------------------------- Pro/Toolkit includes ---------------------------*/ #include #include #include /*-------------------------- Application includes ---------------------------*/ #include /*---------------------------Function Prototypes-----------------------------*/ Prodtl_entity * UserLineSetup (); extern ProError UserPickPosition(); /*================================================================*\ FUNCTION : UserLineCreate PURPOSE : Create a line draft entity \*================================================================*/ UserLineCreate() { int status; int ent_id; int button; double end1[3], end2[3]; ProMdl p_draw; Prodtl_entity *p_line; ProFileName WMSGFIL = {'m','s','g','_','u','g','d','w','g','.','t','x','t','\0'}; /*------------------------------------------------------------*\ Get the current model \*------------------------------------------------------------*/ status = ProMdlCurrentGet(&p_draw); ERROR_CHECK("UserViewCreate","ProMdlCurrentGet",status); /*------------------------------------------------------------*\ Ask the user for the ends of the line. \*------------------------------------------------------------*/ status = UserPickPosition(WMSGFIL,"Pick the first end of the line.", end1); ERROR_CHECK("UserViewCreate","UserPickPosition",status); if (status != PRO_TK_NO_ERROR) return(status); status = UserPickPosition(WMSGFIL,"Pick the second end of the line.", end2); ERROR_CHECK("UserViewCreate","UserPickPosition",status); if (status != PRO_TK_NO_ERROR) return(status); /*------------------------------------------------------------*\ Set up the C structure for the line. \*------------------------------------------------------------*/ p_line = UserLineSetup ((Prohandle) p_draw, end1, end2); /*------------------------------------------------------------*\ Add the line to the drawing. \*------------------------------------------------------------*/ ent_id = prodtl_create ((Prohandle) p_draw, NULL, (Prodtl_item*)p_line); ERROR_CHECK("UserLineEntityCreate","prodtl_create",(ent_id < 0)); if (ent_id < 0) return(PRO_TK_GENERAL_ERROR); status = prodtl_display ((Prohandle) p_draw, PRODTL_ENTITY, ent_id, PRODTL_SHOW); ERROR_CHECK("UserLineEntityCreate","prodtl_display", (status <= 0)); if (status <= 0) return(PRO_TK_GENERAL_ERROR); return (PRO_TK_NO_ERROR); } /*================================================================*\ Function that sets up a C structure for a draft entity line \*================================================================*/ Prodtl_entity * UserLineSetup ( ProMdl p_draw, ProPoint3d end1, ProPoint3d end2) { int status; int sheet, view_id, line_id; Prodtl_entity *p_line; /*----------------------------------------------------------------*\ Claim the line memory and initialize it. \*----------------------------------------------------------------*/ p_line = (Prodtl_entity*) calloc (1, sizeof(Prodtl_entity)); p_line->type = PRODTL_ENTITY; p_line->id = -1; /*----------------------------------------------------------------*\ Set the geometry of the entity. \*----------------------------------------------------------------*/ p_line->curve.line.type = PTC_LINE; p_line->curve.line.end1[0] = end1[0]; p_line->curve.line.end1[1] = end1[1]; p_line->curve.line.end1[2] = 0.0; p_line->curve.line.end2[0] = end2[0]; p_line->curve.line.end2[1] = end2[1]; p_line->curve.line.end2[2] = 0.0; /*----------------------------------------------------------------*\ Set the color to the default for entities. \*----------------------------------------------------------------*/ p_line->color.type = PTC_COLOR_INDEX; p_line->color.color = DRAWING_COLOR; /*----------------------------------------------------------------*\ Set the other attributes. \*----------------------------------------------------------------*/ p_line->attributes = 0; pro_str_to_wstr (p_line->font, "SOLIDFONT"); p_line->width = 0.0; sheet = prodrw_get_current_sheet ((Prohandle) p_draw); ERROR_CHECK("UserLineSetup","prodrw_get_current_sheet", (sheet<=0)); view_id = prodrw_get_overlay_view_id ((Prohandle) p_draw, sheet); ERROR_CHECK("UserLineSetup","prodrw_get_overlay_view_id", (view_id<0)); p_line->view_id = view_id; return (p_line); }