void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) { wxPoint pos1, pos2; EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE ); if( aColor < 0 ) // Used normal color or selected color { if( IsSelected() ) color = GetItemSelectedColor(); } else { color = aColor; } pos1 = aTransform.TransformCoordinate( m_Pos ) + aOffset; pos2 = aTransform.TransformCoordinate( m_End ) + aOffset; FILL_T fill = aData ? NO_FILL : m_Fill; if( aColor >= 0 ) fill = NO_FILL; GRSetDrawMode( aDC, aDrawMode ); EDA_RECT* const clipbox = aPanel? aPanel->GetClipBox() : NULL; if( fill == FILLED_WITH_BG_BODYCOLOR && !aData ) GRFilledRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize( ), (m_Flags & IS_MOVED) ? color : GetLayerColor( LAYER_DEVICE_BACKGROUND ), GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); else if( m_Fill == FILLED_SHAPE && !aData ) GRFilledRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize(), color, color ); else GRRect( clipbox, aDC, pos1.x, pos1.y, pos2.x, pos2.y, GetPenSize(), color ); /* Set to one (1) to draw bounding box around rectangle to validate * bounding box calculation. */ #if 0 EDA_RECT bBox = GetBoundingBox(); bBox.RevertYAxis(); bBox = aTransform.TransformCoordinate( bBox ); bBox.Move( aOffset ); GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA ); #endif }
void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor, wxPoint aShapePos, bool aFilledShape ) { int radius; switch( m_Shape ) { case APT_MACRO: GetMacro()->DrawApertureMacroShape( aParent, aClipBox, aDC, aColor, aShapePos, aFilledShape); break; case APT_CIRCLE: radius = m_Size.x >> 1; if( !aFilledShape ) GRCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos), radius, 0, aColor ); else if( m_DrillShape == APT_DEF_NO_HOLE ) { GRFilledCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos), radius, aColor ); } else if( m_DrillShape == APT_DEF_ROUND_HOLE ) // round hole in shape { int width = (m_Size.x - m_Drill.x ) / 2; GRCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos), radius - (width / 2), width, aColor ); } else // rectangular hole { if( m_Polygon.OutlineCount() == 0 ) ConvertShapeToPolygon(); DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos ); } break; case APT_RECT: { wxPoint start; start.x = aShapePos.x - m_Size.x / 2; start.y = aShapePos.y - m_Size.y / 2; wxPoint end = start + m_Size; start = aParent->GetABPosition( start ); end = aParent->GetABPosition( end ); if( !aFilledShape ) { GRRect( aClipBox, aDC, start.x, start.y, end.x, end.y, 0, aColor ); } else if( m_DrillShape == APT_DEF_NO_HOLE ) { GRFilledRect( aClipBox, aDC, start.x, start.y, end.x, end.y, 0, aColor, aColor ); } else { if( m_Polygon.OutlineCount() == 0 ) ConvertShapeToPolygon(); DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos ); } } break; case APT_OVAL: { wxPoint start = aShapePos; wxPoint end = aShapePos; if( m_Size.x > m_Size.y ) // horizontal oval { int delta = (m_Size.x - m_Size.y) / 2; start.x -= delta; end.x += delta; radius = m_Size.y; } else // horizontal oval { int delta = (m_Size.y - m_Size.x) / 2; start.y -= delta; end.y += delta; radius = m_Size.x; } start = aParent->GetABPosition( start ); end = aParent->GetABPosition( end ); if( !aFilledShape ) { GRCSegm( aClipBox, aDC, start.x, start.y, end.x, end.y, radius, aColor ); } else if( m_DrillShape == APT_DEF_NO_HOLE ) { GRFillCSegm( aClipBox, aDC, start.x, start.y, end.x, end.y, radius, aColor ); } else { if( m_Polygon.OutlineCount() == 0 ) ConvertShapeToPolygon(); DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos ); } } break; case APT_POLYGON: if( m_Polygon.OutlineCount() == 0 ) ConvertShapeToPolygon(); DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos ); break; } }
void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample() { int lyWidth, lyHeight; wxSize clamped_layout_size( Clamp( MIN_PAGE_SIZE, m_layout_size.x, m_maxPageSizeMils.x ), Clamp( MIN_PAGE_SIZE, m_layout_size.y, m_maxPageSizeMils.y ) ); double lyRatio = clamped_layout_size.x < clamped_layout_size.y ? (double) clamped_layout_size.y / clamped_layout_size.x : (double) clamped_layout_size.x / clamped_layout_size.y; if( clamped_layout_size.x < clamped_layout_size.y ) { lyHeight = MAX_PAGE_EXAMPLE_SIZE; lyWidth = KiROUND( (double) lyHeight / lyRatio ); } else { lyWidth = MAX_PAGE_EXAMPLE_SIZE; lyHeight = KiROUND( (double) lyWidth / lyRatio ); } if( m_page_bitmap ) { m_PageLayoutExampleBitmap->SetBitmap( wxNullBitmap ); delete m_page_bitmap; } m_page_bitmap = new wxBitmap( lyWidth + 1, lyHeight + 1 ); if( m_page_bitmap->IsOk() ) { double scaleW = (double) lyWidth / clamped_layout_size.x; double scaleH = (double) lyHeight / clamped_layout_size.y; // Prepare DC. wxSize example_size( lyWidth + 1, lyHeight + 1 ); wxMemoryDC memDC; memDC.SelectObject( *m_page_bitmap ); memDC.SetClippingRegion( wxPoint( 0, 0 ), example_size ); memDC.Clear(); memDC.SetUserScale( scaleW, scaleH ); // Get logical page size and margins. PAGE_INFO pageDUMMY; // Get page type int idx = m_paperSizeComboBox->GetSelection(); if( idx < 0 ) idx = 0; wxString pageFmtName = m_pageFmt[idx].BeforeFirst( ' ' ); bool portrait = clamped_layout_size.x < clamped_layout_size.y; pageDUMMY.SetType( pageFmtName, portrait ); if( m_customFmt ) { pageDUMMY.SetWidthMils( clamped_layout_size.x ); pageDUMMY.SetHeightMils( clamped_layout_size.y ); } // Draw layout preview. wxString emptyString; GRResetPenAndBrush( &memDC ); WORKSHEET_LAYOUT::SetAltInstance( m_pagelayout ); GRFilledRect( NULL, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, WHITE, WHITE ); DrawPageLayout( &memDC, NULL, pageDUMMY, emptyString, emptyString, m_tb, m_screen->m_NumberOfScreens, m_screen->m_ScreenNumber, 1, 1, DARKGRAY, RED ); memDC.SelectObject( wxNullBitmap ); m_PageLayoutExampleBitmap->SetBitmap( *m_page_bitmap ); WORKSHEET_LAYOUT::SetAltInstance( NULL ); // Refresh the dialog. Layout(); Refresh(); } }
void Trace_Segment(WinEDA_DrawPanel * panel, wxDC * DC, TRACK* track, int draw_mode) /***********************************************************************************/ /* routine de trace de 1 segment de piste. Parametres : pt_piste = adresse de la description de la piste en buflib draw_mode = mode ( GR_XOR, GR_OR..) */ { int l_piste; int color; int zoom; int rayon; int fillopt; static bool show_err; color = g_DesignSettings.m_LayerColor[track->m_Layer]; if(color & ITEM_NOT_SHOW ) return ; zoom = panel->GetZoom(); GRSetDrawMode(DC, draw_mode); if( draw_mode & GR_SURBRILL) { if( draw_mode & GR_AND) color &= ~HIGHT_LIGHT_FLAG; else color |= HIGHT_LIGHT_FLAG; } if ( color & HIGHT_LIGHT_FLAG) color = ColorRefs[color & MASKCOLOR].m_LightColor; rayon = l_piste = track->m_Width >> 1; fillopt = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH; switch (track->m_Shape) { case S_CIRCLE: rayon = (int)hypot((double)(track->m_End.x-track->m_Start.x), (double)(track->m_End.y-track->m_Start.y) ); if ( (l_piste/zoom) < L_MIN_DESSIN) { GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, rayon , color) ; } if( fillopt == SKETCH) { GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, rayon-l_piste, color); GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, rayon+l_piste, color); } else { GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, rayon, track->m_Width,color); } break; case S_ARC: { if( fillopt == SKETCH) { GRArc1(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, track->m_End.x, track->m_End.y, track->m_Param, track->m_Sous_Netcode, color); } else { GRArc1(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, track->m_End.x, track->m_End.y, track->m_Param,track->m_Sous_Netcode, track->m_Width, color); } } break; case S_SPOT_CIRCLE: fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; if ( (rayon/zoom) < L_MIN_DESSIN) { GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, rayon , color) ; } else if( fillopt == SKETCH ) { GRCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, rayon, color); } else { GRFilledCircle(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, rayon, color, color); } break; case S_SPOT_RECT: case S_RECT: fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; if ( (l_piste/zoom) < L_MIN_DESSIN) { GRLine(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, track->m_End.x, track->m_End.y, color); } else if( fillopt == SKETCH ) { GRRect(&panel->m_ClipBox, DC, track->m_Start.x - l_piste, track->m_Start.y - l_piste, track->m_End.x + l_piste, track->m_End.y + l_piste, color) ; } else { GRFilledRect(&panel->m_ClipBox, DC, track->m_Start.x - l_piste, track->m_Start.y - l_piste, track->m_End.x + l_piste, track->m_End.y + l_piste, color, color) ; } break; case S_SPOT_OVALE: fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH; case S_SEGMENT: if ( (l_piste/zoom) < L_MIN_DESSIN) { GRLine(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, track->m_End.x, track->m_End.y, color); break; } if( fillopt == SKETCH ) { GRCSegm(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, track->m_End.x, track->m_End.y, track->m_Width, color) ; } else { GRFillCSegm(&panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y, track->m_End.x, track->m_End.y, track->m_Width, color) ; } break; default: if ( ! show_err ) { DisplayError(panel, wxT("Trace_Segment() type error")); show_err = TRUE; } break; } }