/*
Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/
#include <ProToolkit.h>
#include <ProDtlentity.h>
#include <ProGraphic.h>
/*====================================================================*\
FUNCTION : UsrLineentityCreate()
PURPOSE : Utility to create a line entity between specified points
\*====================================================================*/
int UsrLineentityCreate(
ProDrawing drawing,
ProDtlsymdef *symbol,
ProVector start,
ProVector end,
ProColortype color)
{
ProDtlentitydata edata;
ProCurvedata *curve;
ProDtlentity entity;
ProColor entity_color;
int cur_sheet;
ProView view;
/*--------------------------------------------------------------------*\
Allocate data for the draft entity
\*--------------------------------------------------------------------*/
ProDtlentitydataAlloc(drawing, &edata);
/*--------------------------------------------------------------------*\
Allocate and initialize a curve description
\*--------------------------------------------------------------------*/
ProCurvedataAlloc(&curve);
ProLinedataInit(start, end, curve);
/*--------------------------------------------------------------------*\
Use the curve description to set the entity data curve
\*--------------------------------------------------------------------*/
ProDtlentitydataCurveSet(edata, curve);
/*--------------------------------------------------------------------*\
Set the view to the current background view for this sheet
\*--------------------------------------------------------------------*/
ProDrawingCurrentSheetGet (drawing, &cur_sheet);
ProDrawingBackgroundViewGet (drawing, cur_sheet, &view);
ProDtlentitydataViewSet (edata, view);
/*--------------------------------------------------------------------*\
Set the color to the specified Pro/ENGINEER predefined color
\*--------------------------------------------------------------------*/
entity_color.method = PRO_COLOR_METHOD_TYPE;
entity_color.value.type = color;
ProDtlentitydataColorSet(edata, &entity_color);
/*--------------------------------------------------------------------*\
Create the entity
\*--------------------------------------------------------------------*/
ProDtlentityCreate(drawing, symbol, edata, &entity);
/*--------------------------------------------------------------------*\
Display the entity
\*--------------------------------------------------------------------*/
ProWindowRepaint (PRO_VALUE_UNUSED);
/*--------------------------------------------------------------------*\
Release the entity data memory
\*--------------------------------------------------------------------*/
ProDtlentitydataFree(edata);
return 0;
}
int UsrLineentityCreateWrapper ()
{
ProDrawing drawing;
ProMouseButton button;
ProVector start, end;
ProFileName msgfil;
ProStringToWstring (msgfil, "msg_ugdrawing.txt");
ProMdlCurrentGet((ProMdl*)&drawing);
ProMessageDisplay(msgfil,"USER Select ends of line");
if(ProMousePickGet(PRO_ANY_BUTTON, &button, start) != PRO_TK_NO_ERROR)
return(0);
if(ProMousePickGet(PRO_ANY_BUTTON, &button, end) != PRO_TK_NO_ERROR)
return(0);
UsrLineentityCreate(drawing, NULL, start, end, PRO_COLOR_WARNING);
return PRO_TK_NO_ERROR;
}