<pre name="code" class="cpp">// 画不固定直线
int UsrPartLineentityCreate(ProDrawing drawing, ProVector start, ProVector end, ProColortype color)
{
ProDtlentitydata edata;
ProCurvedata *curve;
ProDtlentity entity;
ProColor entity_color;
int cur_sheet;
ProView view;
ProDtlentitydataAlloc(drawing, &edata);
ProCurvedataAlloc(&curve);
ProLinedataInit(start, end, 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::OnBnClickedButton11()
{
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);
ProGraphicsPenPosition(position);
if (button_pressed == PRO_MIDDLE_BUTTON)
{
return ;
}
while (1)
{
err = ProMouseTrack(options, &button_pressed, position1);
if (button_pressed == PRO_LEFT_BUTTON)
{
break ;
}
// 刷新当前窗口
int wid = 0;
err = ProWindowCurrentGet(&wid);
err = ProWindowRefresh(wid);
ProGraphicsPenPosition(position);
ProGraphicsLineDraw(position1); // 画直线,不在工程图中保存
}
UsrPartLineentityCreate(drawing,position,position1,PRO_COLOR_LETTER);
}
}