void PCB_DRAW_PANEL_GAL::SetTopLayer( LAYER_ID aLayer ) { m_view->ClearTopLayers(); setDefaultLayerOrder(); m_view->SetTopLayer( aLayer ); // Layers that should always have on-top attribute enabled const LAYER_NUM layers[] = { ITEM_GAL_LAYER( VIA_THROUGH_VISIBLE ), ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ), ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), NETNAMES_GAL_LAYER( PADS_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( GP_OVERLAY ), ITEM_GAL_LAYER( RATSNEST_VISIBLE ), Dwgs_User, ITEM_GAL_LAYER( DRC_VISIBLE ) }; for( unsigned int i = 0; i < sizeof( layers ) / sizeof( LAYER_NUM ); ++i ) m_view->SetTopLayer( layers[i] ); // Extra layers that are brought to the top if a F.* or B.* is selected const LAYER_NUM frontLayers[] = { F_Cu, F_Adhes, F_Paste, F_SilkS, F_Mask, F_CrtYd, F_Fab, ITEM_GAL_LAYER( PAD_FR_VISIBLE ), NETNAMES_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), NETNAMES_GAL_LAYER( F_Cu ), -1 }; const LAYER_NUM backLayers[] = { B_Cu, B_Adhes, B_Paste, B_SilkS, B_Mask, B_CrtYd, B_Fab, ITEM_GAL_LAYER( PAD_BK_VISIBLE ), NETNAMES_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), NETNAMES_GAL_LAYER( B_Cu ), -1 }; const LAYER_NUM* extraLayers = NULL; // Bring a few more extra layers to the top depending on the selected board side if( IsFrontLayer( aLayer ) ) extraLayers = frontLayers; else if( IsBackLayer( aLayer ) ) extraLayers = backLayers; if( extraLayers ) { const LAYER_NUM* l = extraLayers; while( *l >= 0 ) m_view->SetTopLayer( *l++ ); // Move the active layer to the top if( !IsCopperLayer( aLayer ) ) m_view->SetLayerOrder( aLayer, m_view->GetLayerOrder( GAL_LAYER_ORDER[0] ) ); } else if( IsCopperLayer( aLayer ) ) { // Display labels for copper layers on the top m_view->SetTopLayer( GetNetnameLayer( aLayer ) ); } m_view->UpdateAllLayersOrder(); }
unsigned int D_PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const { if( aView->GetPrintMode() > 0 ) // In printing mode the pad is always drawable return 0; const int HIDE = std::numeric_limits<unsigned int>::max(); BOARD* board = GetBoard(); // Handle Render tab switches if( ( GetAttribute() == PAD_ATTRIB_STANDARD || GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED ) && !aView->IsLayerVisible( LAYER_PADS_TH ) ) return HIDE; if( !IsFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) ) return HIDE; if( IsFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) ) return HIDE; if( IsFrontLayer( ( PCB_LAYER_ID )aLayer ) && !aView->IsLayerVisible( LAYER_PAD_FR ) ) return HIDE; if( IsBackLayer( ( PCB_LAYER_ID )aLayer ) && !aView->IsLayerVisible( LAYER_PAD_BK ) ) return HIDE; // Only draw the pad if at least one of the layers it crosses is being displayed if( board && !( board->GetVisibleLayers() & GetLayerSet() ).any() ) return HIDE; // Netnames will be shown only if zoom is appropriate if( IsNetnameLayer( aLayer ) ) { int divisor = std::max( m_Size.x, m_Size.y ); // Pad sizes can be zero briefly when someone is typing a number like "0.5" // in the pad properties dialog if( divisor == 0 ) return HIDE; return ( Millimeter2iu( 10 ) / divisor ); } // Other layers are shown without any conditions return 0; }
unsigned int TEXTE_MODULE::ViewGetLOD( int aLayer ) const { const int MAX = std::numeric_limits<unsigned int>::max(); if( !m_view ) return 0; if( m_Type == TEXT_is_VALUE && !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_VALUES_VISIBLE ) ) ) return MAX; if( m_Type == TEXT_is_REFERENCE && !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_REFERENCES_VISIBLE ) ) ) return MAX; if( IsFrontLayer( m_Layer ) && ( !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ) ) || !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_FR_VISIBLE ) ) ) ) return MAX; if( IsBackLayer( m_Layer ) && ( !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ) ) || !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_BK_VISIBLE ) ) ) ) return MAX; return 0; }
unsigned int TEXTE_MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const { const int HIDE = std::numeric_limits<unsigned int>::max(); if( !aView ) return 0; // Hidden text gets put on the LAYER_MOD_TEXT_INVISIBLE for rendering, but // should only render if its native layer is visible. if( !aView->IsLayerVisible( GetLayer() ) ) return HIDE; // Handle Render tab switches if( ( m_Type == TEXT_is_VALUE || m_Text == wxT( "%V" ) ) && !aView->IsLayerVisible( LAYER_MOD_VALUES ) ) return HIDE; if( ( m_Type == TEXT_is_REFERENCE || m_Text == wxT( "%R" ) ) && !aView->IsLayerVisible( LAYER_MOD_REFERENCES ) ) return HIDE; if( !IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) ) return HIDE; if( IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) ) return HIDE; if( IsFrontLayer( m_Layer ) && !aView->IsLayerVisible( LAYER_MOD_TEXT_FR ) ) return HIDE; if( IsBackLayer( m_Layer ) && !aView->IsLayerVisible( LAYER_MOD_TEXT_BK ) ) return HIDE; // Other layers are shown without any conditions return 0; }
void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset ) { if( aPanel == NULL ) return; /* parent must *not* be NULL (a footprint text without a footprint parent has no sense) */ wxASSERT( m_Parent ); BOARD* brd = GetBoard( ); auto frame = static_cast<PCB_BASE_FRAME*> ( aPanel->GetParent() ); auto color = frame->Settings().Colors().GetLayerColor( GetLayer() ); PCB_LAYER_ID text_layer = GetLayer(); if( !brd->IsLayerVisible( m_Layer ) || ( IsFrontLayer( text_layer ) && !brd->IsElementVisible( LAYER_MOD_TEXT_FR ) ) || ( IsBackLayer( text_layer ) && !brd->IsElementVisible( LAYER_MOD_TEXT_BK ) ) ) return; if( !brd->IsElementVisible( LAYER_MOD_REFERENCES ) && GetText() == wxT( "%R" ) ) return; if( !brd->IsElementVisible( LAYER_MOD_VALUES ) && GetText() == wxT( "%V" ) ) return; // Invisible texts are still drawn (not plotted) in LAYER_MOD_TEXT_INVISIBLE // Just because we must have to edit them (at least to make them visible) if( !IsVisible() ) { if( !brd->IsElementVisible( LAYER_MOD_TEXT_INVISIBLE ) ) return; color = frame->Settings().Colors().GetItemColor( LAYER_MOD_TEXT_INVISIBLE ); } auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aPanel->GetDisplayOptions() ); // shade text if high contrast mode is active if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay ) { PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) aPanel->GetScreen() )->m_Active_Layer; if( !IsOnLayer( curr_layer ) ) color = COLOR4D( DARKDARKGRAY ); } // Draw mode compensation for the width int width = GetThickness(); if( displ_opts && displ_opts->m_DisplayModTextFill == SKETCH ) width = -width; GRSetDrawMode( aDC, aDrawMode ); wxPoint pos = GetTextPos() - aOffset; // Draw the text anchor point if( brd->IsElementVisible( LAYER_ANCHOR ) ) { COLOR4D anchor_color = frame->Settings().Colors().GetItemColor( LAYER_ANCHOR ); GRDrawAnchor( aPanel->GetClipBox(), aDC, pos.x, pos.y, DIM_ANCRE_TEXTE, anchor_color ); } // Draw the text proper, with the right attributes wxSize size = GetTextSize(); double orient = GetDrawRotation(); // If the text is mirrored : negate size.x (mirror / Y axis) if( IsMirrored() ) size.x = -size.x; DrawGraphicText( aPanel->GetClipBox(), aDC, pos, color, GetShownText(), orient, size, GetHorizJustify(), GetVertJustify(), width, IsItalic(), IsBold() ); // Enable these line to draw the bounding box (debug test purpose only) #if 0 { EDA_RECT BoundaryBox = GetBoundingBox(); GRRect( aPanel->GetClipBox(), aDC, BoundaryBox, 0, BROWN ); } #endif }
void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset ) { if( aPanel == NULL ) return; /* parent must *not* be NULL (a footprint text without a footprint parent has no sense) */ wxASSERT( m_Parent ); BOARD* brd = GetBoard( ); EDA_COLOR_T color = brd->GetLayerColor( GetLayer() ); LAYER_ID text_layer = GetLayer(); if( !brd->IsLayerVisible( m_Layer ) || (IsFrontLayer( text_layer ) && !brd->IsElementVisible( MOD_TEXT_FR_VISIBLE )) || (IsBackLayer( text_layer ) && !brd->IsElementVisible( MOD_TEXT_BK_VISIBLE )) ) return; // Invisible texts are still drawn (not plotted) in MOD_TEXT_INVISIBLE // Just because we must have to edit them (at least to make them visible) if( m_NoShow ) { if( !brd->IsElementVisible( MOD_TEXT_INVISIBLE ) ) return; color = brd->GetVisibleElementColor( MOD_TEXT_INVISIBLE ); } DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)aPanel->GetDisplayOptions(); // shade text if high contrast mode is active if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay ) { LAYER_ID curr_layer = ( (PCB_SCREEN*) aPanel->GetScreen() )->m_Active_Layer; if( !IsOnLayer( curr_layer ) ) ColorTurnToDarkDarkGray( &color ); } // Draw mode compensation for the width int width = m_Thickness; if( displ_opts && displ_opts->m_DisplayModTextFill == SKETCH ) width = -width; GRSetDrawMode( aDC, aDrawMode ); wxPoint pos = m_Pos - aOffset; // Draw the text anchor point if( brd->IsElementVisible( ANCHOR_VISIBLE ) ) { EDA_COLOR_T anchor_color = brd->GetVisibleElementColor(ANCHOR_VISIBLE); GRDrawAnchor( aPanel->GetClipBox(), aDC, pos.x, pos.y, DIM_ANCRE_TEXTE, anchor_color ); } // Draw the text proper, with the right attributes wxSize size = m_Size; double orient = GetDrawRotation(); // If the text is mirrored : negate size.x (mirror / Y axis) if( m_Mirror ) size.x = -size.x; DrawGraphicText( aPanel->GetClipBox(), aDC, pos, color, GetShownText(), orient, size, m_HJustify, m_VJustify, width, m_Italic, m_Bold ); // Enable these line to draw the bounding box (debug test purpose only) #if 0 { EDA_RECT BoundaryBox = GetBoundingBox(); GRRect( aPanel->GetClipBox(), aDC, BoundaryBox, 0, BROWN ); } #endif }