void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) { PCB_BASE_FRAME::SetPageSettings( aPageSettings ); if( IsGalCanvasActive() ) { PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() ); // Prepare worksheet template KIGFX::WORKSHEET_VIEWITEM* worksheet; worksheet = new KIGFX::WORKSHEET_VIEWITEM( &m_Pcb->GetPageSettings(), &m_Pcb->GetTitleBlock() ); worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) ); BASE_SCREEN* screen = GetScreen(); if( screen != NULL ) { worksheet->SetSheetNumber( screen->m_ScreenNumber ); worksheet->SetSheetCount( screen->m_NumberOfScreens ); } // PCB_DRAW_PANEL_GAL takes ownership of the worksheet drawPanel->SetWorksheet( worksheet ); } }
void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, double aScalar, const wxString &aFilename, const wxString &aSheetLayer, COLOR4D aColor ) { if( !m_showBorderAndTitleBlock ) return; const PAGE_INFO& pageInfo = GetPageSettings(); wxSize pageSize = pageInfo.GetSizeMils(); // if not printing, draw the page limits: if( !aScreen->m_IsPrinting && m_showPageLimits ) { GRSetDrawMode( aDC, GR_COPY ); GRRect( m_canvas->GetClipBox(), aDC, 0, 0, pageSize.x * aScalar, pageSize.y * aScalar, aLineWidth, m_drawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY ); } TITLE_BLOCK t_block = GetTitleBlock(); COLOR4D color = ( aColor != COLOR4D::UNSPECIFIED ) ? aColor : COLOR4D( RED ); wxPoint origin = aDC->GetDeviceOrigin(); if( aScreen->m_IsPrinting && origin.y > 0 ) { aDC->SetDeviceOrigin( 0, 0 ); aDC->SetAxisOrientation( true, false ); } DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo, GetScreenDesc(), aFilename, t_block, aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, aLineWidth, aScalar, color, aSheetLayer ); if( aScreen->m_IsPrinting && origin.y > 0 ) { aDC->SetDeviceOrigin( origin.x, origin.y ); aDC->SetAxisOrientation( true, true ); } }
void PCB_EDIT_FRAME::SetBoard( BOARD* aBoard ) { PCB_BASE_FRAME::SetBoard( aBoard ); if( IsGalCanvasActive() ) { PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() ); drawPanel->DisplayBoard( aBoard ); aBoard->GetRatsnest()->Recalculate(); // Prepare worksheet template KIGFX::WORKSHEET_VIEWITEM* worksheet; worksheet = new KIGFX::WORKSHEET_VIEWITEM( &aBoard->GetPageSettings(), &aBoard->GetTitleBlock() ); worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) ); BASE_SCREEN* screen = GetScreen(); if( screen != NULL ) { worksheet->SetSheetNumber( screen->m_ScreenNumber ); worksheet->SetSheetCount( screen->m_NumberOfScreens ); } // PCB_DRAW_PANEL_GAL takes ownership of the worksheet drawPanel->SetWorksheet( worksheet ); // update the tool manager with the new board and its view. if( m_toolManager ) { m_toolManager->SetEnvironment( aBoard, drawPanel->GetView(), drawPanel->GetViewControls(), this ); m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); } } }
void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_width ) { if( !m_showBorderAndTitleBlock ) return; const PAGE_INFO& pageInfo = GetPageSettings(); wxSize pageSize = pageInfo.GetSizeMils(); int ii, jj, xg, yg, ipas, gxpas, gypas; wxPoint pos; int refx, refy; EDA_Colors Color; wxString Line; Ki_WorkSheetData* WsItem; int scale = m_internalUnits / 1000; wxSize size( SIZETEXT * scale, SIZETEXT * scale ); #if defined(KICAD_GOST) wxSize size2( SIZETEXT * scale * 2, SIZETEXT * scale * 2); wxSize size3( SIZETEXT * scale * 3, SIZETEXT * scale * 3); wxSize size1_5( SIZETEXT * scale * 1.5, SIZETEXT * scale * 1.5); #endif wxSize size_ref( SIZETEXT_REF * scale, SIZETEXT_REF * scale ); wxString msg; int UpperLimit = VARIABLE_BLOCK_START_POSITION; int width = line_width; Color = RED; // if not printing, draw the page limits: if( !screen->m_IsPrinting && g_ShowPageLimits ) { GRSetDrawMode( DC, GR_COPY ); GRRect( m_canvas->GetClipBox(), DC, 0, 0, pageSize.x * scale, pageSize.y * scale, width, g_DrawBgColor == WHITE ? LIGHTGRAY : DARKDARKGRAY ); } GRSetDrawMode( DC, GR_COPY ); // Draw the border. // Upper left corner refx = pageInfo.GetLeftMarginMils(); refy = pageInfo.GetTopMarginMils(); // lower right corner xg = pageSize.x - pageInfo.GetRightMarginMils(); yg = pageSize.y - pageInfo.GetBottomMarginMils(); #if defined(KICAD_GOST) GRRect( m_canvas->GetClipBox(), DC, refx * scale, refy * scale, xg * scale, yg * scale, width, Color ); #else for( ii = 0; ii < 2; ii++ ) { GRRect( m_canvas->GetClipBox(), DC, refx * scale, refy * scale, xg * scale, yg * scale, width, Color ); refx += GRID_REF_W; refy += GRID_REF_W; xg -= GRID_REF_W; yg -= GRID_REF_W; } #endif // Draw the reference legends. refx = pageInfo.GetLeftMarginMils(); #if defined(KICAD_GOST) refy = pageSize.y - pageInfo.GetBottomMarginMils(); // Lower left corner for( WsItem = &WS_Segm1_LU; WsItem != NULL; WsItem = WsItem->Pnext ) { pos.x = ( refx - WsItem->m_Posx ) * scale; pos.y = ( refy - WsItem->m_Posy ) * scale; msg.Empty(); switch( WsItem->m_Type ) { case WS_CADRE: break; case WS_PODPIS_LU: if( WsItem->m_Legende ) msg = WsItem->m_Legende; DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_VERT, size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_BOTTOM, width, false, false ); break; case WS_SEGMENT_LU: xg = pageInfo.GetLeftMarginMils() - WsItem->m_Endx; yg = pageSize.y - pageInfo.GetBottomMarginMils() - WsItem->m_Endy; GRLine( m_canvas->GetClipBox(), DC, pos.x, pos.y, xg * scale, yg * scale, width, Color ); break; } } refy = pageInfo.GetBottomMarginMils(); // Left Top corner for( WsItem = &WS_Segm1_LT; WsItem != NULL; WsItem = WsItem->Pnext ) { pos.x = ( refx + WsItem->m_Posx ) * scale; pos.y = ( refy + WsItem->m_Posy ) * scale; msg.Empty(); switch( WsItem->m_Type ) { case WS_SEGMENT_LT: xg = pageInfo.GetLeftMarginMils() + WsItem->m_Endx; yg = pageInfo.GetBottomMarginMils() + WsItem->m_Endy; GRLine( m_canvas->GetClipBox(), DC, pos.x, pos.y, xg * scale, yg * scale, width, Color ); break; } } #else // Upper left corner refy = pageInfo.GetTopMarginMils(); // lower right corner xg = pageSize.x - pageInfo.GetRightMarginMils(); yg = pageSize.y - pageInfo.GetBottomMarginMils(); ipas = ( xg - refx ) / PAS_REF; gxpas = ( xg - refx ) / ipas; for( ii = refx + gxpas, jj = 1; ipas > 0; ii += gxpas, jj++, ipas-- ) { Line.Printf( wxT( "%d" ), jj ); if( ii < xg - PAS_REF / 2 ) { GRLine( m_canvas->GetClipBox(), DC, ii * scale, refy * scale, ii * scale, ( refy + GRID_REF_W ) * scale, width, Color ); } DrawGraphicText( m_canvas, DC, wxPoint( ( ii - gxpas / 2 ) * scale, ( refy + GRID_REF_W / 2 ) * scale ), Color, Line, TEXT_ORIENT_HORIZ, size_ref, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); if( ii < xg - PAS_REF / 2 ) { GRLine( m_canvas->GetClipBox(), DC, ii * scale, yg * scale, ii * scale, ( yg - GRID_REF_W ) * scale, width, Color ); } DrawGraphicText( m_canvas, DC, wxPoint( ( ii - gxpas / 2 ) * scale, ( yg - GRID_REF_W / 2) * scale ), Color, Line, TEXT_ORIENT_HORIZ, size_ref, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); } ipas = ( yg - refy ) / PAS_REF; gypas = ( yg - refy ) / ipas; for( ii = refy + gypas, jj = 0; ipas > 0; ii += gypas, jj++, ipas-- ) { if( jj < 26 ) Line.Printf( wxT( "%c" ), jj + 'A' ); else // I hope 52 identifiers are enought... Line.Printf( wxT( "%c" ), 'a' + jj - 26 ); if( ii < yg - PAS_REF / 2 ) { GRLine( m_canvas->GetClipBox(), DC, refx * scale, ii * scale, ( refx + GRID_REF_W ) * scale, ii * scale, width, Color ); } DrawGraphicText( m_canvas, DC, wxPoint( ( refx + GRID_REF_W / 2 ) * scale, ( ii - gypas / 2 ) * scale ), Color, Line, TEXT_ORIENT_HORIZ, size_ref, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); if( ii < yg - PAS_REF / 2 ) { GRLine( m_canvas->GetClipBox(), DC, xg * scale, ii * scale, ( xg - GRID_REF_W ) * scale, ii * scale, width, Color ); } DrawGraphicText( m_canvas, DC, wxPoint( ( xg - GRID_REF_W / 2 ) * scale, ( ii - gxpas / 2 ) * scale ), Color, Line, TEXT_ORIENT_HORIZ, size_ref, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); } #endif #if defined(KICAD_GOST) // lower right corner refx = pageSize.x - pageInfo.GetRightMarginMils(); refy = pageSize.y - pageInfo.GetBottomMarginMils(); if( screen->m_ScreenNumber == 1 ) { for( WsItem = &WS_Date; WsItem != NULL; WsItem = WsItem->Pnext ) { pos.x = (refx - WsItem->m_Posx) * scale; pos.y = (refy - WsItem->m_Posy) * scale; msg.Empty(); switch( WsItem->m_Type ) { case WS_DATE: break; case WS_REV: break; case WS_KICAD_VERSION: break; case WS_PODPIS: if( WsItem->m_Legende ) msg = WsItem->m_Legende; DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); break; case WS_SIZESHEET: break; case WS_IDENTSHEET: if( WsItem->m_Legende ) msg = WsItem->m_Legende; if( screen->m_NumberOfScreen > 1 ) msg << screen->m_ScreenNumber; DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); break; case WS_SHEETS: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg << screen->m_NumberOfScreen; DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); break; case WS_COMPANY_NAME: msg = GetTitleBlock().GetCompany(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size1_5, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); } break; case WS_TITLE: msg = GetTitleBlock().GetTitle(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size1_5, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); } break; case WS_COMMENT1: msg = GetTitleBlock().GetComment1(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size3, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); pos.x = (pageInfo.GetLeftMarginMils() + 1260) * scale; pos.y = (pageInfo.GetTopMarginMils() + 270) * scale; DrawGraphicText( m_canvas, DC, pos, Color, msg, 1800, size2, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); } break; case WS_COMMENT2: msg = GetTitleBlock().GetComment2(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); } break; case WS_COMMENT3: msg = GetTitleBlock().GetComment3(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); } break; case WS_COMMENT4: msg = GetTitleBlock().GetComment4(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); } break; case WS_UPPER_SEGMENT: case WS_LEFT_SEGMENT: WS_MostUpperLine.m_Posy = WS_MostUpperLine.m_Endy = WS_MostLeftLine.m_Posy = STAMP_OY; pos.y = ( refy - WsItem->m_Posy ) * scale; case WS_SEGMENT: xg = pageSize.x - pageInfo.GetRightMarginMils() - WsItem->m_Endx; yg = pageSize.y - pageInfo.GetBottomMarginMils() - WsItem->m_Endy; GRLine( m_canvas->GetClipBox(), DC, pos.x, pos.y, xg * scale, yg * scale, width, Color ); break; } } } else { for( WsItem = &WS_CADRE_D; WsItem != NULL; WsItem = WsItem->Pnext ) { pos.x = ( refx - WsItem->m_Posx ) * scale; pos.y = ( refy - WsItem->m_Posy ) * scale; msg.Empty(); switch( WsItem->m_Type ) { case WS_CADRE: // Begin list number > 1 msg = GetTitleBlock().GetComment1(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size3, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); pos.x = (pageInfo.GetLeftMarginMils() + 1260) * scale; pos.y = (pageInfo.GetTopMarginMils() + 270) * scale; DrawGraphicText( m_canvas, DC, pos, Color, msg, 1800, size2, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); } break; case WS_PODPIS_D: if( WsItem->m_Legende ) msg = WsItem->m_Legende; DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); break; case WS_IDENTSHEET_D: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg << screen->m_ScreenNumber; DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); break; case WS_LEFT_SEGMENT_D: pos.y = ( refy - WsItem->m_Posy ) * scale; case WS_SEGMENT_D: xg = pageSize.x - pageInfo.GetRightMarginMils() - WsItem->m_Endx; yg = pageSize.y - pageInfo.GetBottomMarginMils() - WsItem->m_Endy; GRLine( m_canvas->GetClipBox(), DC, pos.x, pos.y, xg * scale, yg * scale, width, Color ); break; } } } #else refx = pageSize.x - pageInfo.GetRightMarginMils() - GRID_REF_W; refy = pageSize.y - pageInfo.GetBottomMarginMils() - GRID_REF_W; for( WsItem = &WS_Date; WsItem != NULL; WsItem = WsItem->Pnext ) { pos.x = (refx - WsItem->m_Posx) * scale; pos.y = (refy - WsItem->m_Posy) * scale; msg.Empty(); switch( WsItem->m_Type ) { case WS_DATE: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg += GetTitleBlock().GetDate(); DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, true ); break; case WS_REV: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg += GetTitleBlock().GetRevision(); DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GetPenSizeForBold( MIN( size.x, size.y ) ), false, true ); break; case WS_KICAD_VERSION: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg += g_ProductName + wxGetApp().GetAppName(); msg += wxT( " " ) + GetBuildVersion(); DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); break; case WS_SIZESHEET: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg += pageInfo.GetType(); DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); break; case WS_IDENTSHEET: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg << screen->m_ScreenNumber << wxT( "/" ) << screen->m_NumberOfScreen; DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); break; case WS_FILENAME: { wxString fname, fext; wxFileName::SplitPath( screen->GetFileName(), (wxString*) NULL, &fname, &fext ); if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg << fname << wxT( "." ) << fext; DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); } break; case WS_FULLSHEETNAME: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg += GetScreenDesc(); DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); break; case WS_COMPANY_NAME: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg += GetTitleBlock().GetCompany(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GetPenSizeForBold( MIN( size.x, size.y ) ), false, true ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); } break; case WS_TITLE: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg += GetTitleBlock().GetTitle(); DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GetPenSizeForBold( MIN( size.x, size.y ) ), false, true ); break; case WS_COMMENT1: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg += GetTitleBlock().GetComment1(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); } break; case WS_COMMENT2: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg += GetTitleBlock().GetComment2(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); } break; case WS_COMMENT3: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg += GetTitleBlock().GetComment3(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); } break; case WS_COMMENT4: if( WsItem->m_Legende ) msg = WsItem->m_Legende; msg += GetTitleBlock().GetComment4(); if( !msg.IsEmpty() ) { DrawGraphicText( m_canvas, DC, pos, Color, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, width, false, false ); UpperLimit = MAX( UpperLimit, WsItem->m_Posy + SIZETEXT ); } break; case WS_UPPER_SEGMENT: if( UpperLimit == 0 ) break; case WS_LEFT_SEGMENT: WS_MostUpperLine.m_Posy = WS_MostUpperLine.m_Endy = WS_MostLeftLine.m_Posy = UpperLimit; pos.y = (refy - WsItem->m_Posy) * scale; case WS_SEGMENT: xg = pageSize.x - GRID_REF_W - pageInfo.GetRightMarginMils() - WsItem->m_Endx; yg = pageSize.y - GRID_REF_W - pageInfo.GetBottomMarginMils() - WsItem->m_Endy; GRLine( m_canvas->GetClipBox(), DC, pos.x, pos.y, xg * scale, yg * scale, width, Color ); break; } } #endif }
/* return the page layout item found at position aPosition * aPosition = the position (in user units) of the reference point */ WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition ) { const PAGE_INFO& pageInfo = GetPageSettings(); TITLE_BLOCK t_block = GetTitleBlock(); EDA_COLOR_T color = RED; // Needed, not used PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) GetScreen(); screen-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2; WS_DRAW_ITEM_LIST drawList; drawList.SetPenSize( 0 ); drawList.SetMilsToIUfactor( IU_PER_MILS ); drawList.SetSheetNumber( screen->m_ScreenNumber ); drawList.SetSheetCount( screen->m_NumberOfScreens ); drawList.SetFileName( GetCurrFileName() ); // GetScreenDesc() returns a temporary string. Store it to avoid issues. wxString descr = GetScreenDesc(); drawList.SetSheetName( descr ); drawList.BuildWorkSheetGraphicList( pageInfo, t_block, color, color ); // locate items. // We do not use here the COLLECTOR classes in use in pcbnew and eeschema // because the locate requirements are very basic. std::vector <WS_DRAW_ITEM_BASE*> list; drawList.Locate( list, aPosition ); if( list.size() == 0 ) return NULL; WS_DRAW_ITEM_BASE* drawitem = list[0]; // Choose item in list if more than 1 item if( list.size() > 1 ) { wxArrayString choices; wxString text; wxPoint cursPos = GetCrossHairPosition(); for( unsigned ii = 0; ii < list.size(); ++ii ) { drawitem = list[ii]; text = drawitem->GetParent()->m_Name; if( (drawitem->m_Flags & (LOCATE_STARTPOINT|LOCATE_ENDPOINT)) == (LOCATE_STARTPOINT|LOCATE_ENDPOINT) ) text << wxT(" ") << _("(start or end point)"); else { if( (drawitem->m_Flags & LOCATE_STARTPOINT) ) text << wxT(" ") << _("(start point)"); if( (drawitem->m_Flags & LOCATE_ENDPOINT) ) text << wxT(" ") << _("(end point)"); } if( ! drawitem->GetParent()->m_Info.IsEmpty() ) text << wxT(" \"") << drawitem->GetParent()->m_Info << wxT("\""); choices.Add( text ); } int selection = wxGetSingleChoiceIndex ( wxEmptyString, _( "Selection Clarification" ), choices, this ); if( selection < 0 ) return NULL; SetCrossHairPosition( cursPos ); m_canvas->MoveCursorToCrossHair(); drawitem = list[selection]; } WORKSHEET_DATAITEM* item = drawitem->GetParent(); item->ClearFlags(LOCATE_STARTPOINT|LOCATE_ENDPOINT); if( (drawitem->m_Flags & LOCATE_STARTPOINT) ) item->SetFlags( LOCATE_STARTPOINT ); if( (drawitem->m_Flags & LOCATE_ENDPOINT) ) item->SetFlags( LOCATE_ENDPOINT ); return item; }
void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const { KIGFX::VIEW* view = GetGalCanvas()->GetView(); view->Clear(); // All of PCB drawing elements should be added to the VIEW // in order to be displayed // Load zones for( int i = 0; i < aBoard->GetAreaCount(); ++i ) { view->Add( (KIGFX::VIEW_ITEM*) ( aBoard->GetArea( i ) ) ); } // Load drawings for( BOARD_ITEM* drawing = aBoard->m_Drawings; drawing; drawing = drawing->Next() ) { view->Add( drawing ); } // Load tracks for( TRACK* track = aBoard->m_Track; track; track = track->Next() ) { view->Add( track ); } // Load modules and its additional elements for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) { // Load module's pads for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() ) { view->Add( pad ); } // Load module's drawing (mostly silkscreen) for( BOARD_ITEM* drawing = module->GraphicalItems().GetFirst(); drawing; drawing = drawing->Next() ) { view->Add( drawing ); } // Load module's texts (name and value) view->Add( &module->Reference() ); view->Add( &module->Value() ); // Add the module itself view->Add( module ); } // Segzones (equivalent of ZONE_CONTAINER for legacy boards) for( SEGZONE* zone = aBoard->m_Zone; zone; zone = zone->Next() ) { view->Add( zone ); } // Add an entry for the worksheet layout KIGFX::WORKSHEET_VIEWITEM* worksheet = new KIGFX::WORKSHEET_VIEWITEM( std::string( aBoard->GetFileName().mb_str() ), std::string( GetScreenDesc().mb_str() ), &GetPageSettings(), &GetTitleBlock() ); BASE_SCREEN* screen = GetScreen(); if( screen != NULL ) { worksheet->SetSheetNumber( GetScreen()->m_ScreenNumber ); worksheet->SetSheetCount( GetScreen()->m_NumberOfScreens ); } view->Add( worksheet ); // Add an entry for the ratsnest RN_DATA* ratsnest = aBoard->GetRatsnest(); ratsnest->ProcessBoard(); ratsnest->Recalculate(); view->Add( new KIGFX::RATSNEST_VIEWITEM( ratsnest ) ); view->SetPanBoundary( worksheet->ViewBBox() ); view->RecacheAllItems( true ); if( IsGalCanvasActive() ) GetGalCanvas()->Refresh(); }