Commit 39bca76d authored by Maciej Suminski's avatar Maciej Suminski

>Added handled hotkeys:

- resetting relative coordinates
- switching units
- not official: changing transparency for layers (works only for main layers, does not work on vias/pads/etc.)
parent 60e9546b
...@@ -400,6 +400,7 @@ void VIEW::UpdateLayerColor( int aLayer ) ...@@ -400,6 +400,7 @@ void VIEW::UpdateLayerColor( int aLayer )
updateItemsColor visitor( aLayer, m_painter, m_gal ); updateItemsColor visitor( aLayer, m_painter, m_gal );
m_layers[aLayer].items->Query( r, visitor ); m_layers[aLayer].items->Query( r, visitor );
MarkTargetDirty( m_layers[aLayer].target );
} }
...@@ -459,6 +460,7 @@ void VIEW::ChangeLayerDepth( int aLayer, int aDepth ) ...@@ -459,6 +460,7 @@ void VIEW::ChangeLayerDepth( int aLayer, int aDepth )
changeItemsDepth visitor( aLayer, aDepth, m_gal ); changeItemsDepth visitor( aLayer, aDepth, m_gal );
m_layers[aLayer].items->Query( r, visitor ); m_layers[aLayer].items->Query( r, visitor );
MarkTargetDirty( m_layers[aLayer].target );
} }
......
...@@ -66,16 +66,16 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings ...@@ -66,16 +66,16 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings
} }
// Default colors for specific layers // 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( 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, 1.0 ); 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, 1.0 ); 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, 1.0 ); 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.7 ); 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.7 ); 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.7 ); 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.7 ); 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, 1.0 ); 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, 1.0 ); m_layerColors[ITEM_GAL_LAYER( DRC_VISIBLE )] = COLOR4D( 1.0, 0.0, 0.0, 0.8 );
// Netnames for copper layers // Netnames for copper layers
for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; ++layer ) 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 ...@@ -175,23 +175,15 @@ const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer
void PCB_RENDER_SETTINGS::update() void PCB_RENDER_SETTINGS::update()
{ {
RENDER_SETTINGS::update();
// Calculate darkened/highlighted variants of layer colors // Calculate darkened/highlighted variants of layer colors
for( int i = 0; i < TOTAL_LAYER_COUNT; i++ ) 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_layerColorsHi[i] = m_layerColors[i].Brightened( m_highlightFactor );
m_layerColorsDark[i] = m_layerColors[i].Darkened( 1.0 - m_highlightFactor ); m_layerColorsDark[i] = m_layerColors[i].Darkened( 1.0 - m_highlightFactor );
m_layerColorsSel[i] = m_layerColors[i].Brightened( m_selectFactor ); 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];
} }
......
...@@ -97,7 +97,23 @@ public: ...@@ -97,7 +97,23 @@ public:
* Returns the color used to draw a layer. * Returns the color used to draw a layer.
* @param aLayer is the layer number. * @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 * Function SetSketchMode
......
...@@ -197,11 +197,11 @@ TOOL_ACTION COMMON_ACTIONS::layerPrev( "pcbnew.layerPrev", ...@@ -197,11 +197,11 @@ TOOL_ACTION COMMON_ACTIONS::layerPrev( "pcbnew.layerPrev",
"", "" ); "", "" );
TOOL_ACTION COMMON_ACTIONS::layerAlphaInc( "pcbnew.layerAlphaInc", TOOL_ACTION COMMON_ACTIONS::layerAlphaInc( "pcbnew.layerAlphaInc",
AS_GLOBAL, MD_SHIFT + '[', // shift+[ == { AS_GLOBAL, MD_SHIFT + ']', // shift+] == }
"", "" ); "", "" );
TOOL_ACTION COMMON_ACTIONS::layerAlphaDec( "pcbnew.layerAlphaDec", TOOL_ACTION COMMON_ACTIONS::layerAlphaDec( "pcbnew.layerAlphaDec",
AS_GLOBAL, MD_SHIFT + ']', // shift+] == } AS_GLOBAL, MD_SHIFT + '[', // shift+[ == {
"", "" ); "", "" );
......
...@@ -32,13 +32,14 @@ ...@@ -32,13 +32,14 @@
#include <class_drawpanel_gal.h> #include <class_drawpanel_gal.h>
#include <class_pcb_screen.h> #include <class_pcb_screen.h>
#include <pcbcommon.h> #include <pcbcommon.h>
#include <confirm.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <view/view_controls.h> #include <view/view_controls.h>
#include <pcb_painter.h> #include <pcb_painter.h>
PCBNEW_CONTROL::PCBNEW_CONTROL() : PCBNEW_CONTROL::PCBNEW_CONTROL() :
TOOL_INTERACTIVE( "pcbnew.Settings" ) TOOL_INTERACTIVE( "pcbnew.Control" )
{ {
} }
...@@ -340,7 +341,21 @@ int PCBNEW_CONTROL::LayerPrev( TOOL_EVENT& aEvent ) ...@@ -340,7 +341,21 @@ int PCBNEW_CONTROL::LayerPrev( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::LayerAlphaInc( TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::LayerAlphaInc( TOOL_EVENT& aEvent )
{ {
std::cout << __PRETTY_FUNCTION__ << std::endl; KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( 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(); setTransitions();
return 0; return 0;
...@@ -349,7 +364,21 @@ int PCBNEW_CONTROL::LayerAlphaInc( TOOL_EVENT& aEvent ) ...@@ -349,7 +364,21 @@ int PCBNEW_CONTROL::LayerAlphaInc( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::LayerAlphaDec( TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::LayerAlphaDec( TOOL_EVENT& aEvent )
{ {
std::cout << __PRETTY_FUNCTION__ << std::endl; KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( 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(); setTransitions();
return 0; return 0;
...@@ -469,7 +498,10 @@ int PCBNEW_CONTROL::ViaSizeDec( TOOL_EVENT& aEvent ) ...@@ -469,7 +498,10 @@ int PCBNEW_CONTROL::ViaSizeDec( TOOL_EVENT& aEvent )
// Miscellaneous // Miscellaneous
int PCBNEW_CONTROL::ResetCoords( TOOL_EVENT& aEvent ) 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(); setTransitions();
return 0; return 0;
...@@ -478,7 +510,15 @@ int PCBNEW_CONTROL::ResetCoords( TOOL_EVENT& aEvent ) ...@@ -478,7 +510,15 @@ int PCBNEW_CONTROL::ResetCoords( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::SwitchUnits( 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(); setTransitions();
return 0; return 0;
...@@ -487,7 +527,8 @@ int PCBNEW_CONTROL::SwitchUnits( TOOL_EVENT& aEvent ) ...@@ -487,7 +527,8 @@ int PCBNEW_CONTROL::SwitchUnits( TOOL_EVENT& aEvent )
int PCBNEW_CONTROL::ShowHelp( TOOL_EVENT& aEvent ) int PCBNEW_CONTROL::ShowHelp( TOOL_EVENT& aEvent )
{ {
std::cout << __PRETTY_FUNCTION__ << std::endl; // TODO
DisplayInfoMessage( m_frame, _( "Not implemented yet." ) );
setTransitions(); setTransitions();
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment