void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) { int rowCount; int menuId = event.GetId(); bool visible; bool force_active_layer_visible; visible = menuId == ID_SHOW_ALL_COPPERS; m_alwaysShowActiveCopperLayer = ( menuId == ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE ); force_active_layer_visible = ( menuId == ID_SHOW_NO_COPPERS_BUT_ACTIVE || menuId == ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE ); switch( menuId ) { case ID_SHOW_ALL_COPPERS: case ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE: case ID_SHOW_NO_COPPERS_BUT_ACTIVE: case ID_SHOW_NO_COPPERS: // Search the last copper layer row index: int lastCu = -1; rowCount = GetLayerRowCount(); for( int row = rowCount-1; row>=0; --row ) { wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB ); LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) ); if( IsCopperLayer( layer ) ) { lastCu = row; break; } } // Enable/disable the copper layers visibility: for( int row=0; row<rowCount; ++row ) { wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB ); LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) ); if( IsCopperLayer( layer ) ) { bool loc_visible = visible; if( force_active_layer_visible && (layer == myframe->GetActiveLayer() ) ) loc_visible = true; cb->SetValue( loc_visible ); bool isLastCopperLayer = (row==lastCu); OnLayerVisible( layer, loc_visible, isLastCopperLayer ); if( isLastCopperLayer ) break; } } break; } }
void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) { int rowCount; int menuId = event.GetId(); bool visible; switch( menuId ) { case ID_SHOW_ALL_COPPERS: visible = true; goto L_change_coppers; case ID_SHOW_NO_COPPERS_BUT_ACTIVE: case ID_SHOW_NO_COPPERS: visible = false; L_change_coppers: int lastCu = -1; rowCount = GetLayerRowCount(); for( int row=rowCount-1; row>=0; --row ) { wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 ); int layer = getDecodedId( cb->GetId() ); if( IsValidCopperLayerIndex( layer ) ) { lastCu = row; break; } } for( int row=0; row<rowCount; ++row ) { wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 ); int layer = getDecodedId( cb->GetId() ); if( IsValidCopperLayerIndex( layer ) ) { bool loc_visible = visible; if( (menuId == ID_SHOW_NO_COPPERS_BUT_ACTIVE ) && (layer == myframe->getActiveLayer() ) ) loc_visible = true; cb->SetValue( loc_visible ); bool isLastCopperLayer = (row==lastCu); OnLayerVisible( layer, loc_visible, isLastCopperLayer ); if( isLastCopperLayer ) break; } } break; } }
void LAYER_WIDGET::OnRenderCheckBox( wxCommandEvent& event ) { wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject(); LAYER_NUM id = getDecodedId( eventSource->GetId() ); OnRenderEnable( id, eventSource->IsChecked() ); passOnFocus(); }
void PCB_LAYER_WIDGET::SyncLayerAlphaIndicators() { int count = GetLayerRowCount(); TOOL_MANAGER* mgr = myframe->GetToolManager(); KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( mgr->GetView()->GetPainter() ); KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings(); for( int row = 0; row < count; ++row ) { // this utilizes more implementation knowledge than ideal, eventually // add member ROW getRow() or similar to base LAYER_WIDGET. wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE ); PCB_LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) ); KIGFX::COLOR4D screenColor = settings->GetLayerColor( layerId ); COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, COLUMN_COLORBM ) ); KIGFX::COLOR4D layerColor = swatch->GetSwatchColor(); INDICATOR_ICON* indicator = static_cast<INDICATOR_ICON*>( getLayerComp( row, COLUMN_ALPHA_INDICATOR ) ); if( std::abs( screenColor.a - layerColor.a ) > ALPHA_EPSILON ) { if( screenColor.a < layerColor.a ) indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::DOWN ); else indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::UP ); } else indicator->SetIndicatorState( ROW_ICON_PROVIDER::STATE::OFF ); } }
void LAYER_WIDGET::OnLayerCheckBox( wxCommandEvent& event ) { wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject(); LAYER_NUM layer = getDecodedId( eventSource->GetId() ); OnLayerVisible( layer, eventSource->IsChecked() ); passOnFocus(); }
void LAYER_WIDGET::OnLeftDownLayers( wxMouseEvent& event ) { int row; LAYER_NUM layer; wxWindow* eventSource = (wxWindow*) event.GetEventObject(); // if mouse event is coming from the m_LayerScrolledWindow and not one // of its children, we have to find the row manually based on y coord. if( eventSource == m_LayerScrolledWindow ) { int y = event.GetY(); wxArrayInt heights = m_LayersFlexGridSizer->GetRowHeights(); int height = 0; int rowCount = GetLayerRowCount(); for( row = 0; row<rowCount; ++row ) { if( y < height + heights[row] ) break; height += heights[row]; } if( row >= rowCount ) row = rowCount - 1; layer = getDecodedId( getLayerComp( row, 0 )->GetId() ); } else { // all nested controls on a given row will have their ID encoded with // encodeId(), and the corresponding decoding is getDecodedId() int id = eventSource->GetId(); layer = getDecodedId( id ); row = findLayerRow( layer ); } if( OnLayerSelect( layer ) ) // if client allows this change. SelectLayerRow( row ); passOnFocus(); }
LAYER_NUM LAYER_WIDGET::GetSelectedLayer() { wxWindow* w = getLayerComp( m_CurrentRow, 0 ); if( w ) return getDecodedId( w->GetId() ); return UNDEFINED_LAYER; }
void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) { int rowCount; int menuId = event.GetId(); bool visible = (menuId == ID_SHOW_ALL_LAYERS) ? true : false; long visibleLayers = 0; bool force_active_layer_visible; switch( menuId ) { case ID_SHOW_ALL_LAYERS: case ID_SHOW_NO_LAYERS: case ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE: case ID_SHOW_NO_LAYERS_BUT_ACTIVE: // Set the display layers options. Sorting layers has no effect to these options m_alwaysShowActiveLayer = ( menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE ); force_active_layer_visible = ( menuId == ID_SHOW_NO_LAYERS_BUT_ACTIVE || menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE ); // Update icons and check boxes rowCount = GetLayerRowCount(); for( int row=0; row < rowCount; ++row ) { wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB ); int layer = getDecodedId( cb->GetId() ); bool loc_visible = visible; if( force_active_layer_visible && (layer == myframe->GetActiveLayer() ) ) { loc_visible = true; } cb->SetValue( loc_visible ); if( loc_visible ) visibleLayers |= 1 << row; else visibleLayers &= ~( 1 << row ); } myframe->SetVisibleLayers( visibleLayers ); myframe->GetCanvas()->Refresh(); break; case ID_SORT_GBR_LAYERS: myframe->SortLayersByX2Attributes(); break; } }
void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) { int rowCount; int menuId = event.GetId(); bool visible = (menuId == ID_SHOW_ALL_LAYERS) ? true : false; long visibleLayers = 0; bool force_active_layer_visible; m_alwaysShowActiveLayer = ( menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE ); force_active_layer_visible = ( menuId == ID_SHOW_NO_LAYERS_BUT_ACTIVE || menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE ); switch( menuId ) { case ID_SHOW_ALL_LAYERS: case ID_SHOW_NO_LAYERS: case ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE: case ID_SHOW_NO_LAYERS_BUT_ACTIVE: rowCount = GetLayerRowCount(); for( int row=0; row < rowCount; ++row ) { wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB ); int layer = getDecodedId( cb->GetId() ); bool loc_visible = visible; if( force_active_layer_visible && (layer == myframe->getActiveLayer() ) ) loc_visible = true; cb->SetValue( loc_visible ); if( loc_visible ) visibleLayers |= 1 << row; else visibleLayers &= ~( 1 << row ); } myframe->SetVisibleLayers( visibleLayers ); myframe->GetCanvas()->Refresh(); break; case ID_SORT_GBR_LAYERS: g_GERBER_List.SortImagesByZOrder( myframe->GetItemsList() ); myframe->ReFillLayerWidget(); myframe->syncLayerBox( true ); myframe->GetCanvas()->Refresh(); break; } }
int LAYER_WIDGET::findRenderRow( int aId ) const { int count = GetRenderRowCount(); for( int row = 0; row < count; ++row ) { // column 0 in the layer scroll window has a wxStaticBitmap, get its ID. wxWindow* w = getRenderComp( row, 0 ); wxASSERT( w ); if( aId == getDecodedId( w->GetId() )) return row; } return -1; }
void LAYER_WIDGET::OnLayerSwatchChanged( wxCommandEvent& aEvent ) { auto eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() ); COLOR4D newColor = eventSource->GetSwatchColor(); LAYER_NUM layer = getDecodedId( eventSource->GetId() ); // tell the client code. OnLayerColorChange( layer, newColor ); // notify others wxCommandEvent event( EVT_LAYER_COLOR_CHANGE ); wxPostEvent( this, event ); passOnFocus(); }
void PCB_LAYER_WIDGET::SyncLayerVisibilities() { BOARD* board = myframe->GetBoard(); int count = GetLayerRowCount(); for( int row=0; row<count; ++row ) { // this utilizes more implementation knowledge than ideal, eventually // add member ROW getRow() or similar to base LAYER_WIDGET. wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE ); LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) ); // this does not fire a UI event SetLayerVisible( layerId, board->IsLayerVisible( layerId ) ); } }
void LAYER_WIDGET::OnRenderSwatchChanged( wxCommandEvent& aEvent ) { auto eventSource = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() ); COLOR4D newColor = eventSource->GetSwatchColor(); LAYER_NUM id = getDecodedId( eventSource->GetId() ); if( id == LAYER_PCB_BACKGROUND ) { // Update all swatch backgrounds int count = GetLayerRowCount(); int row; int col = 1; // bitmap button is column 1 in layers tab for( row = 0; row < count; ++row ) { COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getLayerComp( row, col ) ); if( swatch ) swatch->SetSwatchBackground( newColor ); } count = GetRenderRowCount(); col = 0; // bitmap button is column 0 in render tab for( row = 0; row < count; ++row ) { COLOR_SWATCH* swatch = dynamic_cast<COLOR_SWATCH*>( getRenderComp( row, col ) ); if( swatch ) swatch->SetSwatchBackground( newColor ); } } // tell the client code. OnRenderColorChange( id, newColor ); passOnFocus(); }
void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) { int rowCount; int menuId = event.GetId(); bool visible; bool force_active_layer_visible; m_alwaysShowActiveCopperLayer = ( menuId == ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE ); force_active_layer_visible = ( menuId == ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE || menuId == ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE ); switch( menuId ) { case ID_SHOW_NO_LAYERS: case ID_SHOW_ALL_LAYERS: { visible = ( menuId == ID_SHOW_ALL_LAYERS ); rowCount = GetLayerRowCount(); for( int row=0; row<rowCount; ++row ) { bool isLast; wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB ); PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) ); cb->SetValue( visible ); isLast = row == rowCount-1; OnLayerVisible( layer, visible, isLast ); if( isLast ) break; } break; } case ID_SHOW_ALL_COPPER_LAYERS: case ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE: case ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE: case ID_SHOW_NO_COPPER_LAYERS: case ID_HIDE_ALL_NON_COPPER: case ID_SHOW_ALL_NON_COPPER: { // Search the last copper layer row index: int lastCu = -1; rowCount = GetLayerRowCount(); for( int row = rowCount-1; row>=0; --row ) { wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB ); PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) ); if( IsCopperLayer( layer ) ) { lastCu = row; break; } } // Enable/disable the copper layers visibility: int startrow = 0; if( ( menuId == ID_SHOW_ALL_NON_COPPER ) || ( menuId == ID_HIDE_ALL_NON_COPPER ) ) { startrow = lastCu + 1; } for( int row = startrow; row<rowCount; ++row ) { wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB ); PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) ); visible = ( ( menuId == ID_SHOW_ALL_COPPER_LAYERS ) || ( menuId == ID_SHOW_ALL_NON_COPPER ) ); if( force_active_layer_visible && (layer == myframe->GetActiveLayer() ) ) visible = true; cb->SetValue( visible ); bool isLastLayer = (row == lastCu); if( ( menuId == ID_SHOW_ALL_NON_COPPER ) || ( menuId == ID_HIDE_ALL_NON_COPPER ) ) { isLastLayer = false; } OnLayerVisible( layer, visible, isLastLayer ); if( isLastLayer ) break; } break; } case ID_SHOW_ALL_FRONT: { visible = false; rowCount = GetLayerRowCount(); for( int row=0; row<rowCount; ++row ) { bool isLast; wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB ); PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) ); isLast = ( row == rowCount-1 ); if( layer == F_Paste || layer == F_SilkS || layer == F_Mask || layer == F_Cu || layer == F_Fab || layer == F_CrtYd || layer == Edge_Cuts ) { visible = true; } else { visible = false; } cb->SetValue( visible ); OnLayerVisible( layer, visible, isLast ); if( isLast ) break; } break; } case ID_SHOW_ALL_BACK: { visible = false; rowCount = GetLayerRowCount(); for( int row=0; row<rowCount; ++row ) { bool isLast; wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB ); PCB_LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) ); isLast = ( row == rowCount-1 ); if( layer == B_Paste || layer == B_SilkS || layer == B_Mask || layer == B_Cu || layer == B_Fab || layer == B_CrtYd || layer == Edge_Cuts ) { visible = true; } else { visible = false; } cb->SetValue( visible ); OnLayerVisible( layer, visible, isLast ); if( isLast ) break; } break; } } }