// start dragging new corner to be inserted into side, make side and hatching invisible // void CPolyLine::StartDraggingToInsertCorner( CDC * pDC, int ic, int x, int y, int crosshair ) { if( !m_dlist ) ASSERT(0); int icont = GetContour( ic ); int istart = GetContourStart( icont ); int iend = GetContourEnd( icont ); int post_c; if( ic == iend ) post_c = istart; else post_c = ic + 1; int xi = corner[ic].x; int yi = corner[ic].y; int xf = corner[post_c].x; int yf = corner[post_c].y; m_dlist->StartDraggingLineVertex( pDC, x, y, xi, yi, xf, yf, LAY_SELECTION, LAY_SELECTION, 1, 1, DSS_STRAIGHT, DSS_STRAIGHT, 0, 0, 0, 0, crosshair ); m_dlist->CancelHighLight(); m_dlist->Set_visible( dl_side[ic], 0 ); for( int ih=0; ih<m_nhatch; ih++ ) m_dlist->Set_visible( dl_hatch[ih], 0 ); }
// delete corner and adjust arrays // void CPolyLine::DeleteCorner( int ic, BOOL bDraw ) { Undraw(); int icont = GetContour( ic ); int istart = GetContourStart( icont ); int iend = GetContourEnd( icont ); BOOL bClosed = icont < GetNumContours()-1 || GetClosed(); if( !bClosed ) { // open contour, must be last contour corner.RemoveAt( ic ); if( ic != istart ) side_style.RemoveAt( ic-1 ); m_ncorners--; } else { // closed contour corner.RemoveAt( ic ); side_style.RemoveAt( ic ); if( ic == iend ) corner[ic-1].end_contour = TRUE; m_ncorners--; } if( bClosed && GetContourSize(icont) < 3 ) { // delete the entire contour RemoveContour( icont ); } if( bDraw ) Draw(); }
// delete corner and adjust arrays // void CPolyLine::DeleteCorner( int ic ) { UnHatch(); int icont = GetContour( ic ); int iend = GetContourEnd( icont ); bool closed = icont < GetContoursCount() - 1 || GetClosed(); if( !closed ) { // open contour, must be last contour m_CornersList.DeleteCorner( ic ); } else { // closed contour m_CornersList.DeleteCorner( ic ); if( ic == iend ) m_CornersList[ic - 1].end_contour = true; } if( closed && GetContourSize( icont ) < 3 ) { // delete the entire contour RemoveContour( icont ); } }
/* * return true if the corner aCornerIdx is on a hole inside the main outline * and false if it is on the main outline */ bool CPolyLine::IsCutoutContour( int aCornerIdx ) { int ncont = GetContour( aCornerIdx ); if( ncont == 0 ) // the first contour is the main outline, not an hole return false; return true; }
// start dragging corner to new position, make adjacent sides and hatching invisible // void CPolyLine::StartDraggingToMoveCorner( CDC * pDC, int ic, int x, int y, int crosshair ) { if( !m_dlist ) ASSERT(0); // see if corner is the first or last corner of an open contour int icont = GetContour( ic ); int istart = GetContourStart( icont ); int iend = GetContourEnd( icont ); if( !GetClosed() && icont == GetNumContours() - 1 && (ic == istart || ic == iend) ) { // yes int style, xi, yi, iside; if( ic == istart ) { // first corner iside = ic; xi = GetX( ic+1 ); yi = GetY( ic+1 ); style = GetSideStyle( iside ); // reverse arc since we are drawing from corner 1 to 0 if( style == CPolyLine::ARC_CW ) style = CPolyLine::ARC_CCW; else if( style == CPolyLine::ARC_CCW ) style = CPolyLine::ARC_CW; } else { // last corner iside = ic - 1; xi = GetX( ic-1 ); yi = GetY( ic-1); style = GetSideStyle( iside ); } m_dlist->StartDraggingArc( pDC, style, GetX(ic), GetY(ic), xi, yi, LAY_SELECTION, 1, crosshair ); m_dlist->CancelHighLight(); m_dlist->Set_visible( dl_side[iside], 0 ); for( int ih=0; ih<m_nhatch; ih++ ) m_dlist->Set_visible( dl_hatch[ih], 0 ); } else { // no // get indexes for preceding and following corners int pre_c, post_c; int poly_side_style1, poly_side_style2; int style1, style2; if( ic == istart ) { pre_c = iend; post_c = istart+1; poly_side_style1 = side_style[iend]; poly_side_style2 = side_style[istart]; } else if( ic == iend ) { // last side pre_c = ic-1; post_c = istart; poly_side_style1 = side_style[ic-1]; poly_side_style2 = side_style[ic]; } else { pre_c = ic-1; post_c = ic+1; poly_side_style1 = side_style[ic-1]; poly_side_style2 = side_style[ic]; } if( poly_side_style1 == STRAIGHT ) style1 = DSS_STRAIGHT; else if( poly_side_style1 == ARC_CW ) style1 = DSS_ARC_CW; else if( poly_side_style1 == ARC_CCW ) style1 = DSS_ARC_CCW; if( poly_side_style2 == STRAIGHT ) style2 = DSS_STRAIGHT; else if( poly_side_style2 == ARC_CW ) style2 = DSS_ARC_CW; else if( poly_side_style2 == ARC_CCW ) style2 = DSS_ARC_CCW; int xi = corner[pre_c].x; int yi = corner[pre_c].y; int xf = corner[post_c].x; int yf = corner[post_c].y; m_dlist->StartDraggingLineVertex( pDC, x, y, xi, yi, xf, yf, LAY_SELECTION, LAY_SELECTION, 1, 1, style1, style2, 0, 0, 0, 0, crosshair ); m_dlist->CancelHighLight(); m_dlist->Set_visible( dl_side[pre_c], 0 ); m_dlist->Set_visible( dl_side[ic], 0 ); for( int ih=0; ih<m_nhatch; ih++ ) m_dlist->Set_visible( dl_hatch[ih], 0 ); } }