<pre name="code" class="cpp">// 画不固定圆
int UsrFullArcentityCreate(ProDrawing drawing, Pro3dPnt center, double radius, ProColortype color)
{
ProDtlentitydata edata;
ProCurvedata *curve;
ProDtlentity entity;
ProColor entity_color;
int cur_sheet;
ProView view;
ProDtlentitydataAlloc(drawing, &edata);
ProCurvedataAlloc(&curve);
ProVector vector1,vector2;
vector1[0] = 1.0;
vector1[1] = 0.0;
vector1[2] = 0.0;
vector2[0] = 0.0;
vector2[1] = 1.0;
vector2[2] = 0.0;
double start_angle = 0.0;
double end_angle = TWOPI;
ProArcdataInit(vector1,vector2,center,start_angle,end_angle,radius,curve);
ProDtlentitydataCurveSet(edata, curve);
ProDrawingCurrentSheetGet (drawing, &cur_sheet);
ProDrawingBackgroundViewGet (drawing, cur_sheet, &view);
ProDtlentitydataViewSet (edata, view);
entity_color.method = PRO_COLOR_METHOD_TYPE;
entity_color.value.type = color;
ProDtlentitydataColorSet(edata, &entity_color);
ProDtlentityCreate(drawing, NULL, edata, &entity);
ProWindowRepaint (PRO_VALUE_UNUSED);
ProDtlentitydataFree(edata);
return PRO_TK_NO_ERROR;
}
// 画不固定圆
void CTestDlg2::OnBnClickedButton10()
{
ProMdl mdl;
ProError err = ProMdlCurrentGet(&mdl);
ProDrawing drawing = (ProDrawing)mdl;
ProMouseButton expected_button = (ProMouseButton)(PRO_LEFT_BUTTON|PRO_MIDDLE_BUTTON);
ProMouseButton button_pressed;
ProPoint3d position, position1;
int options = 0;
while (1)
{
err = ProMousePickGet(expected_button, &button_pressed, position);
if (button_pressed == PRO_MIDDLE_BUTTON)
{
return ;
}
while (1)
{
err = ProMouseTrack(options, &button_pressed, position1);
if (button_pressed == PRO_LEFT_BUTTON)
{
break ;
}
double radius1 = sqrt(pow((position[0]-position1[0]),2)+pow((position[1]-position1[1]),2));
// 刷新当前窗口
int wid = 0;
err = ProWindowCurrentGet(&wid);
err = ProWindowRefresh(wid);
ProGraphicsCircleDraw(position, radius1); // 画圆,不在工程图中保存
}
double radius = sqrt(pow((position[0]-position1[0]),2)+pow((position[1]-position1[1]),2));
UsrFullArcentityCreate(drawing, position, radius, PRO_COLOR_LETTER);
}
}