diff --git a/common/view/view.cpp b/common/view/view.cpp index 5cfe071d9f..08de942811 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -400,6 +400,7 @@ void VIEW::UpdateLayerColor( int aLayer ) updateItemsColor visitor( aLayer, m_painter, m_gal ); m_layers[aLayer].items->Query( r, visitor ); + MarkTargetDirty( m_layers[aLayer].target ); } @@ -459,6 +460,7 @@ void VIEW::ChangeLayerDepth( int aLayer, int aDepth ) changeItemsDepth visitor( aLayer, aDepth, m_gal ); m_layers[aLayer].items->Query( r, visitor ); + MarkTargetDirty( m_layers[aLayer].target ); } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index e47e2b3686..33f44f2dd9 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -66,16 +66,16 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings } // Default colors for specific layers - m_layerColors[ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE )] = COLOR4D( 0.5, 0.4, 0.0, 1.0 ); - m_layerColors[ITEM_GAL_LAYER( PADS_HOLES_VISIBLE )] = COLOR4D( 0.0, 0.5, 0.5, 1.0 ); - m_layerColors[ITEM_GAL_LAYER( VIA_THROUGH_VISIBLE )] = COLOR4D( 0.7, 0.7, 0.7, 1.0 ); - m_layerColors[ITEM_GAL_LAYER( PADS_VISIBLE )] = COLOR4D( 0.7, 0.7, 0.7, 1.0 ); - m_layerColors[NETNAMES_GAL_LAYER( PADS_NETNAMES_VISIBLE )] = COLOR4D( 0.8, 0.8, 0.8, 0.7 ); - m_layerColors[NETNAMES_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE )] = COLOR4D( 0.8, 0.8, 0.8, 0.7 ); - m_layerColors[NETNAMES_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE )] = COLOR4D( 0.8, 0.8, 0.8, 0.7 ); - m_layerColors[ITEM_GAL_LAYER( RATSNEST_VISIBLE )] = COLOR4D( 0.4, 0.4, 0.4, 0.7 ); - m_layerColors[ITEM_GAL_LAYER( WORKSHEET )] = COLOR4D( 0.5, 0.0, 0.0, 1.0 ); - m_layerColors[ITEM_GAL_LAYER( DRC_VISIBLE )] = COLOR4D( 1.0, 0.0, 0.0, 1.0 ); + m_layerColors[ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE )] = COLOR4D( 0.5, 0.4, 0.0, 0.8 ); + m_layerColors[ITEM_GAL_LAYER( PADS_HOLES_VISIBLE )] = COLOR4D( 0.0, 0.5, 0.5, 0.8 ); + m_layerColors[ITEM_GAL_LAYER( VIA_THROUGH_VISIBLE )] = COLOR4D( 0.7, 0.7, 0.7, 0.8 ); + m_layerColors[ITEM_GAL_LAYER( PADS_VISIBLE )] = COLOR4D( 0.7, 0.7, 0.7, 0.8 ); + m_layerColors[NETNAMES_GAL_LAYER( PADS_NETNAMES_VISIBLE )] = COLOR4D( 0.8, 0.8, 0.8, 0.8 ); + m_layerColors[NETNAMES_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE )] = COLOR4D( 0.8, 0.8, 0.8, 0.8 ); + m_layerColors[NETNAMES_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE )] = COLOR4D( 0.8, 0.8, 0.8, 0.8 ); + m_layerColors[ITEM_GAL_LAYER( RATSNEST_VISIBLE )] = COLOR4D( 0.4, 0.4, 0.4, 0.8 ); + m_layerColors[ITEM_GAL_LAYER( WORKSHEET )] = COLOR4D( 0.5, 0.0, 0.0, 0.8 ); + m_layerColors[ITEM_GAL_LAYER( DRC_VISIBLE )] = COLOR4D( 1.0, 0.0, 0.0, 0.8 ); // Netnames for copper layers for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; ++layer ) @@ -175,23 +175,15 @@ const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer void PCB_RENDER_SETTINGS::update() { + RENDER_SETTINGS::update(); + // Calculate darkened/highlighted variants of layer colors for( int i = 0; i < TOTAL_LAYER_COUNT; i++ ) { - m_layerColors[i].a = m_layerOpacity; m_layerColorsHi[i] = m_layerColors[i].Brightened( m_highlightFactor ); m_layerColorsDark[i] = m_layerColors[i].Darkened( 1.0 - m_highlightFactor ); m_layerColorsSel[i] = m_layerColors[i].Brightened( m_selectFactor ); } - - m_hiContrastColor = COLOR4D( m_hiContrastFactor, m_hiContrastFactor, m_hiContrastFactor, - m_layerOpacity ); -} - - -const COLOR4D& PCB_RENDER_SETTINGS::GetLayerColor( int aLayer ) const -{ - return m_layerColors[aLayer]; } diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index 820c4077a5..cdcedb1db7 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -97,7 +97,23 @@ public: * Returns the color used to draw a layer. * @param aLayer is the layer number. */ - const COLOR4D& GetLayerColor( int aLayer ) const; + const COLOR4D& GetLayerColor( int aLayer ) const + { + return m_layerColors[aLayer]; + } + + /** + * Function SetLayerColor + * Changes the color used to draw a layer. + * @param aLayer is the layer number. + * @param aColor is the new color. + */ + void SetLayerColor( int aLayer, const COLOR4D& aColor ) + { + m_layerColors[aLayer] = aColor; + + update(); // recompute other shades of the color + } /** * Function SetSketchMode diff --git a/pcbnew/tools/common_actions.cpp b/pcbnew/tools/common_actions.cpp index 11e527d552..0e998de43a 100644 --- a/pcbnew/tools/common_actions.cpp +++ b/pcbnew/tools/common_actions.cpp @@ -197,11 +197,11 @@ TOOL_ACTION COMMON_ACTIONS::layerPrev( "pcbnew.layerPrev", "", "" ); TOOL_ACTION COMMON_ACTIONS::layerAlphaInc( "pcbnew.layerAlphaInc", - AS_GLOBAL, MD_SHIFT + '[', // shift+[ == { + AS_GLOBAL, MD_SHIFT + ']', // shift+] == } "", "" ); TOOL_ACTION COMMON_ACTIONS::layerAlphaDec( "pcbnew.layerAlphaDec", - AS_GLOBAL, MD_SHIFT + ']', // shift+] == } + AS_GLOBAL, MD_SHIFT + '[', // shift+[ == { "", "" ); diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 92e29f2ee7..0a04fc0f88 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -32,13 +32,14 @@ #include #include #include +#include #include #include #include PCBNEW_CONTROL::PCBNEW_CONTROL() : - TOOL_INTERACTIVE( "pcbnew.Settings" ) + TOOL_INTERACTIVE( "pcbnew.Control" ) { } @@ -340,7 +341,21 @@ int PCBNEW_CONTROL::LayerPrev( TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::LayerAlphaInc( TOOL_EVENT& aEvent ) { - std::cout << __PRETTY_FUNCTION__ << std::endl; + KIGFX::PCB_PAINTER* painter = + static_cast( m_frame->GetGalCanvas()->GetView()->GetPainter() ); + KIGFX::PCB_RENDER_SETTINGS* settings = + static_cast ( painter->GetSettings() ); + + LAYER_NUM currentLayer = m_frame->GetActiveLayer(); + KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer ); + + if( currentColor.a <= 0.95 ) + { + currentColor.a += 0.05; + settings->SetLayerColor( currentLayer, currentColor ); + m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer ); + } + setTransitions(); return 0; @@ -349,7 +364,21 @@ int PCBNEW_CONTROL::LayerAlphaInc( TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::LayerAlphaDec( TOOL_EVENT& aEvent ) { - std::cout << __PRETTY_FUNCTION__ << std::endl; + KIGFX::PCB_PAINTER* painter = + static_cast( m_frame->GetGalCanvas()->GetView()->GetPainter() ); + KIGFX::PCB_RENDER_SETTINGS* settings = + static_cast ( painter->GetSettings() ); + + LAYER_NUM currentLayer = m_frame->GetActiveLayer(); + KIGFX::COLOR4D currentColor = settings->GetLayerColor( currentLayer ); + + if( currentColor.a >= 0.05 ) + { + currentColor.a -= 0.05; + settings->SetLayerColor( currentLayer, currentColor ); + m_frame->GetGalCanvas()->GetView()->UpdateLayerColor( currentLayer ); + } + setTransitions(); return 0; @@ -469,7 +498,10 @@ int PCBNEW_CONTROL::ViaSizeDec( TOOL_EVENT& aEvent ) // Miscellaneous int PCBNEW_CONTROL::ResetCoords( TOOL_EVENT& aEvent ) { - std::cout << __PRETTY_FUNCTION__ << std::endl; + VECTOR2I cursorPos = getViewControls()->GetCursorPosition(); + + m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y ); + m_frame->UpdateStatusBar(); setTransitions(); return 0; @@ -478,7 +510,15 @@ int PCBNEW_CONTROL::ResetCoords( TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::SwitchUnits( TOOL_EVENT& aEvent ) { - std::cout << __PRETTY_FUNCTION__ << std::endl; + // TODO should not it be refactored to pcb_frame member function? + wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED ); + + if( g_UserUnit == INCHES ) + evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM ); + else + evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH ); + + m_frame->ProcessEvent( evt ); setTransitions(); return 0; @@ -487,7 +527,8 @@ int PCBNEW_CONTROL::SwitchUnits( TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::ShowHelp( TOOL_EVENT& aEvent ) { - std::cout << __PRETTY_FUNCTION__ << std::endl; + // TODO + DisplayInfoMessage( m_frame, _( "Not implemented yet." ) ); setTransitions(); return 0;