const EDA_RECT ZONE_CONTAINER::GetBoundingBox() const { const int PRELOAD = 0x7FFFFFFF; // Biggest integer (32 bits) int ymax = -PRELOAD; int ymin = PRELOAD; int xmin = PRELOAD; int xmax = -PRELOAD; int count = GetNumCorners(); for( int i = 0; i<count; ++i ) { wxPoint corner = GetCornerPosition( i ); ymax = std::max( ymax, corner.y ); xmax = std::max( xmax, corner.x ); ymin = std::min( ymin, corner.y ); xmin = std::min( xmin, corner.x ); } EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) ); return ret; }
const wxPoint WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPositionUi( unsigned aIdx, int aRepeat ) const { DPOINT pos = GetCornerPosition( aIdx, aRepeat ); pos = pos * m_WSunits2Iu; return wxPoint( int(pos.x), int(pos.y) ); }
void ZONE_CONTAINER::MoveEdge( const wxPoint& offset, int aEdge ) { // Move the start point of the selected edge: SetCornerPosition( aEdge, GetCornerPosition( aEdge ) + offset ); // Move the end point of the selected edge: if( m_Poly->m_CornersList.IsEndContour( aEdge ) || aEdge == GetNumCorners() - 1 ) { int icont = m_Poly->GetContour( aEdge ); aEdge = m_Poly->GetContourStart( icont ); } else { aEdge++; } SetCornerPosition( aEdge, GetCornerPosition( aEdge ) + offset ); m_Poly->Hatch(); }
void ZONE_CONTAINER::MoveEdge( const wxPoint& offset ) { int ii = m_CornerSelection; // Move the start point of the selected edge: SetCornerPosition( ii, GetCornerPosition( ii ) + offset ); // Move the end point of the selected edge: if( m_Poly->m_CornersList.IsEndContour( ii ) || ii == GetNumCorners() - 1 ) { int icont = m_Poly->GetContour( ii ); ii = m_Poly->GetContourStart( icont ); } else { ii++; } SetCornerPosition( ii, GetCornerPosition( ii ) + offset ); m_Poly->Hatch(); }
void ZONE_CONTAINER::Move( const wxPoint& offset ) { /* move outlines */ for( unsigned ii = 0; ii < m_Poly->m_CornersList.GetCornersCount(); ii++ ) { SetCornerPosition( ii, GetCornerPosition( ii ) + offset ); } m_Poly->Hatch(); m_FilledPolysList.Move( VECTOR2I( offset.x, offset.y ) ); for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ ) { m_FillSegmList[ic].m_Start += offset; m_FillSegmList[ic].m_End += offset; } }
void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode ) { GR_DRAWMODE current_gr_mode = draw_mode; bool is_close_segment = false; wxPoint seg_start, seg_end; if( DC == NULL ) return; LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; BOARD* brd = GetBoard(); EDA_COLOR_T color = brd->GetLayerColor( m_Layer ); if( DisplayOpt.ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) ColorTurnToDarkDarkGray( &color ); } // draw the lines wxPoint start_contour_pos = GetCornerPosition( 0 ); int icmax = GetNumCorners() - 1; for( int ic = 0; ic <= icmax; ic++ ) { int xi = GetCornerPosition( ic ).x; int yi = GetCornerPosition( ic ).y; int xf, yf; if( !m_Poly->m_CornersList.IsEndContour( ic ) && ic < icmax ) { is_close_segment = false; xf = GetCornerPosition( ic + 1 ).x; yf = GetCornerPosition( ic + 1 ).y; if( m_Poly->m_CornersList.IsEndContour( ic + 1 ) || (ic == icmax - 1) ) current_gr_mode = GR_XOR; else current_gr_mode = draw_mode; } else // Draw the line from last corner to the first corner of the current contour { is_close_segment = true; current_gr_mode = GR_XOR; xf = start_contour_pos.x; yf = start_contour_pos.y; // Prepare the next contour for drawing, if exists if( ic < icmax ) start_contour_pos = GetCornerPosition( ic + 1 ); } GRSetDrawMode( DC, current_gr_mode ); if( is_close_segment ) GRLine( panel->GetClipBox(), DC, xi, yi, xf, yf, 0, WHITE ); else GRLine( panel->GetClipBox(), DC, xi, yi, xf, yf, 0, color ); } }
void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& offset ) { if( DC == NULL ) return; wxPoint seg_start, seg_end; LAYER_NUM curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; BOARD* brd = GetBoard(); EDA_COLOR_T color = brd->GetLayerColor( m_Layer ); if( brd->IsLayerVisible( m_Layer ) == false && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG ) return; GRSetDrawMode( DC, aDrawMode ); if( DisplayOpt.ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) ColorTurnToDarkDarkGray( &color ); } if( aDrawMode & GR_HIGHLIGHT ) ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) ); ColorApplyHighlightFlag( &color ); SetAlpha( &color, 150 ); // draw the lines int i_start_contour = 0; std::vector<wxPoint> lines; lines.reserve( (GetNumCorners() * 2) + 2 ); for( int ic = 0; ic < GetNumCorners(); ic++ ) { seg_start = GetCornerPosition( ic ) + offset; if( !m_Poly->m_CornersList.IsEndContour( ic ) && ic < GetNumCorners() - 1 ) { seg_end = GetCornerPosition( ic + 1 ) + offset; } else { seg_end = GetCornerPosition( i_start_contour ) + offset; i_start_contour = ic + 1; } lines.push_back( seg_start ); lines.push_back( seg_end ); } GRLineArray( panel->GetClipBox(), DC, lines, 0, color ); // draw hatches lines.clear(); lines.reserve( (m_Poly->m_HatchLines.size() * 2) + 2 ); for( unsigned ic = 0; ic < m_Poly->m_HatchLines.size(); ic++ ) { seg_start = m_Poly->m_HatchLines[ic].m_Start + offset; seg_end = m_Poly->m_HatchLines[ic].m_End + offset; lines.push_back( seg_start ); lines.push_back( seg_end ); } GRLineArray( panel->GetClipBox(), DC, lines, 0, color ); }
const wxPoint& ZONE_CONTAINER::GetPosition() const { static const wxPoint dummy; return m_Poly ? GetCornerPosition( 0 ) : dummy; }
void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& offset ) { if( !DC ) return; wxPoint seg_start, seg_end; LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer; BOARD* brd = GetBoard(); COLOR4D color = brd->GetLayerColor( m_Layer ); if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) ) return; GRSetDrawMode( DC, aDrawMode ); DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); if( displ_opts->m_ContrastModeDisplay ) { if( !IsOnLayer( curr_layer ) ) color = COLOR4D( DARKDARKGRAY ); } if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) ) color.SetToLegacyHighlightColor(); color.a = 0.588; // draw the lines int i_start_contour = 0; std::vector<wxPoint> lines; lines.reserve( (GetNumCorners() * 2) + 2 ); for( int ic = 0; ic < GetNumCorners(); ic++ ) { seg_start = GetCornerPosition( ic ) + offset; if( !m_Poly->m_CornersList.IsEndContour( ic ) && ic < GetNumCorners() - 1 ) { seg_end = GetCornerPosition( ic + 1 ) + offset; } else { seg_end = GetCornerPosition( i_start_contour ) + offset; i_start_contour = ic + 1; } lines.push_back( seg_start ); lines.push_back( seg_end ); } GRLineArray( panel->GetClipBox(), DC, lines, 0, color ); // draw hatches lines.clear(); lines.reserve( (m_Poly->m_HatchLines.size() * 2) + 2 ); for( unsigned ic = 0; ic < m_Poly->m_HatchLines.size(); ic++ ) { seg_start = m_Poly->m_HatchLines[ic].m_Start + offset; seg_end = m_Poly->m_HatchLines[ic].m_End + offset; lines.push_back( seg_start ); lines.push_back( seg_end ); } GRLineArray( panel->GetClipBox(), DC, lines, 0, color ); }