Gerbview: fix regression: missing DCode highlight commands.
DCode selected by context menu or from toolbar is now highlighted.
This commit is contained in:
parent
18470693fe
commit
c1197903e4
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
|
* Copyright (C) 2011-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -120,13 +120,15 @@ void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
|
||||||
|
|
||||||
if( gerber_image )
|
if( gerber_image )
|
||||||
{
|
{
|
||||||
int tool = m_DCodeSelector->GetSelectedDCodeId();
|
int d_code = m_DCodeSelector->GetSelectedDCodeId();
|
||||||
|
|
||||||
if( tool != gerber_image->m_Selected_Tool )
|
auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>(
|
||||||
{
|
GetCanvas()->GetView()->GetPainter() )->GetSettings();
|
||||||
gerber_image->m_Selected_Tool = tool;
|
gerber_image->m_Selected_Tool = d_code;
|
||||||
GetCanvas()->Refresh();
|
settings->m_dcodeHighlightValue = d_code;
|
||||||
}
|
|
||||||
|
GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
|
||||||
|
GetCanvas()->Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +139,14 @@ void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
|
||||||
|
|
||||||
// Rebuild the DCode list in toolbar (but not the Layer Box) after change
|
// Rebuild the DCode list in toolbar (but not the Layer Box) after change
|
||||||
syncLayerBox( false );
|
syncLayerBox( false );
|
||||||
|
|
||||||
|
// Reinit highlighted dcode
|
||||||
|
auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>
|
||||||
|
( GetCanvas()->GetView()->GetPainter() )->GetSettings();
|
||||||
|
int dcodeSelected = m_DCodeSelector->GetSelectedDCodeId();
|
||||||
|
settings->m_dcodeHighlightValue = dcodeSelected;
|
||||||
|
GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
|
||||||
|
GetCanvas()->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Jon Evans <jon@craftyjon.com>
|
* Copyright (C) 2017 Jon Evans <jon@craftyjon.com>
|
||||||
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by the
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
@ -46,6 +46,7 @@ GERBVIEW_RENDER_SETTINGS::GERBVIEW_RENDER_SETTINGS()
|
||||||
m_componentHighlightString = "";
|
m_componentHighlightString = "";
|
||||||
m_netHighlightString = "";
|
m_netHighlightString = "";
|
||||||
m_attributeHighlightString = "";
|
m_attributeHighlightString = "";
|
||||||
|
m_dcodeHighlightValue = -1;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -139,6 +140,10 @@ COLOR4D GERBVIEW_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer )
|
||||||
m_attributeHighlightString == gbrItem->GetDcodeDescr()->m_AperFunction )
|
m_attributeHighlightString == gbrItem->GetDcodeDescr()->m_AperFunction )
|
||||||
return m_layerColorsHi[aLayer];
|
return m_layerColorsHi[aLayer];
|
||||||
|
|
||||||
|
if( m_dcodeHighlightValue> 0 && gbrItem && gbrItem->GetDcodeDescr() &&
|
||||||
|
m_dcodeHighlightValue == gbrItem->GetDcodeDescr()->m_Num_Dcode )
|
||||||
|
return m_layerColorsHi[aLayer];
|
||||||
|
|
||||||
// Return grayish color for non-highlighted layers in the high contrast mode
|
// Return grayish color for non-highlighted layers in the high contrast mode
|
||||||
if( m_hiContrastEnabled && m_highContrastLayers.count( aLayer ) == 0)
|
if( m_hiContrastEnabled && m_highContrastLayers.count( aLayer ) == 0)
|
||||||
return m_hiContrastColor[aLayer];
|
return m_hiContrastColor[aLayer];
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Jon Evans <jon@craftyjon.com>
|
* Copyright (C) 2017 Jon Evans <jon@craftyjon.com>
|
||||||
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by the
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
@ -136,6 +136,10 @@ public:
|
||||||
/// If set to anything but an empty string, will highlight items with matching attribute
|
/// If set to anything but an empty string, will highlight items with matching attribute
|
||||||
wxString m_attributeHighlightString;
|
wxString m_attributeHighlightString;
|
||||||
|
|
||||||
|
/// If set to anything but >0 (in fact 10 the min dcode value),
|
||||||
|
/// will highlight items with matching dcode
|
||||||
|
int m_dcodeHighlightValue;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Flag determining if spots should be drawn with fill
|
/// Flag determining if spots should be drawn with fill
|
||||||
bool m_spotFill;
|
bool m_spotFill;
|
||||||
|
|
|
@ -887,6 +887,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff,
|
||||||
|
|
||||||
dcode->m_Shape = APT_MACRO;
|
dcode->m_Shape = APT_MACRO;
|
||||||
dcode->SetMacro( pam );
|
dcode->SetMacro( pam );
|
||||||
|
dcode->m_Defined = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -105,7 +105,8 @@ TOOL_ACTION GERBVIEW_ACTIONS::layerChanged( "gerbview.Control.layerChanged",
|
||||||
|
|
||||||
TOOL_ACTION GERBVIEW_ACTIONS::highlightClear( "gerbview.Control.highlightClear",
|
TOOL_ACTION GERBVIEW_ACTIONS::highlightClear( "gerbview.Control.highlightClear",
|
||||||
AS_GLOBAL, 0, "",
|
AS_GLOBAL, 0, "",
|
||||||
_( "Clear Highlight" ), "" );
|
_( "Clear Highlight" ), "",
|
||||||
|
BITMAPS::cancel );
|
||||||
|
|
||||||
TOOL_ACTION GERBVIEW_ACTIONS::highlightNet( "gerbview.Control.highlightNet",
|
TOOL_ACTION GERBVIEW_ACTIONS::highlightNet( "gerbview.Control.highlightNet",
|
||||||
AS_GLOBAL, 0, "",
|
AS_GLOBAL, 0, "",
|
||||||
|
@ -122,6 +123,11 @@ TOOL_ACTION GERBVIEW_ACTIONS::highlightAttribute( "gerbview.Control.highlightAtt
|
||||||
_( "Highlight Attribute" ), "",
|
_( "Highlight Attribute" ), "",
|
||||||
BITMAPS::flag );
|
BITMAPS::flag );
|
||||||
|
|
||||||
|
TOOL_ACTION GERBVIEW_ACTIONS::highlightDCode( "gerbview.Control.highlightDCode",
|
||||||
|
AS_GLOBAL, 0, "",
|
||||||
|
_( "Highlight DCode" ), "",
|
||||||
|
BITMAPS::show_dcodenumber );
|
||||||
|
|
||||||
TOOL_ACTION GERBVIEW_ACTIONS::layerNext( "gerbview.Control.layerNext",
|
TOOL_ACTION GERBVIEW_ACTIONS::layerNext( "gerbview.Control.layerNext",
|
||||||
AS_GLOBAL,
|
AS_GLOBAL,
|
||||||
'+', LEGACY_HK_NAME( "Switch to Next Layer" ),
|
'+', LEGACY_HK_NAME( "Switch to Next Layer" ),
|
||||||
|
|
|
@ -90,6 +90,7 @@ public:
|
||||||
static TOOL_ACTION highlightNet;
|
static TOOL_ACTION highlightNet;
|
||||||
static TOOL_ACTION highlightComponent;
|
static TOOL_ACTION highlightComponent;
|
||||||
static TOOL_ACTION highlightAttribute;
|
static TOOL_ACTION highlightAttribute;
|
||||||
|
static TOOL_ACTION highlightDCode;
|
||||||
|
|
||||||
///< @copydoc COMMON_ACTIONS::TranslateLegacyId()
|
///< @copydoc COMMON_ACTIONS::TranslateLegacyId()
|
||||||
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override { return OPT<TOOL_EVENT>(); }
|
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override { return OPT<TOOL_EVENT>(); }
|
||||||
|
|
|
@ -166,18 +166,24 @@ int GERBVIEW_CONTROL::HighlightControl( const TOOL_EVENT& aEvent )
|
||||||
settings->m_netHighlightString = "";
|
settings->m_netHighlightString = "";
|
||||||
settings->m_componentHighlightString = "";
|
settings->m_componentHighlightString = "";
|
||||||
settings->m_attributeHighlightString = "";
|
settings->m_attributeHighlightString = "";
|
||||||
|
settings->m_dcodeHighlightValue = -1;
|
||||||
|
|
||||||
|
GERBER_FILE_IMAGE* gerber = m_frame->GetGbrImage( m_frame->GetActiveLayer() );
|
||||||
|
|
||||||
|
if( gerber )
|
||||||
|
gerber->m_Selected_Tool = settings->m_dcodeHighlightValue;
|
||||||
}
|
}
|
||||||
else if( item && aEvent.IsAction( &GERBVIEW_ACTIONS::highlightNet ) )
|
else if( item && aEvent.IsAction( &GERBVIEW_ACTIONS::highlightNet ) )
|
||||||
{
|
{
|
||||||
auto string = item->GetNetAttributes().m_Netname;
|
wxString net_name = item->GetNetAttributes().m_Netname;
|
||||||
settings->m_netHighlightString = string;
|
settings->m_netHighlightString = net_name;
|
||||||
m_frame->m_SelNetnameBox->SetStringSelection( UnescapeString( string ) );
|
m_frame->m_SelNetnameBox->SetStringSelection( UnescapeString( net_name ) );
|
||||||
}
|
}
|
||||||
else if( item && aEvent.IsAction( &GERBVIEW_ACTIONS::highlightComponent ) )
|
else if( item && aEvent.IsAction( &GERBVIEW_ACTIONS::highlightComponent ) )
|
||||||
{
|
{
|
||||||
auto string = item->GetNetAttributes().m_Cmpref;
|
wxString net_attr = item->GetNetAttributes().m_Cmpref;
|
||||||
settings->m_componentHighlightString = string;
|
settings->m_componentHighlightString = net_attr;
|
||||||
m_frame->m_SelComponentBox->SetStringSelection( string );
|
m_frame->m_SelComponentBox->SetStringSelection( net_attr );
|
||||||
}
|
}
|
||||||
else if( item && aEvent.IsAction( &GERBVIEW_ACTIONS::highlightAttribute ) )
|
else if( item && aEvent.IsAction( &GERBVIEW_ACTIONS::highlightAttribute ) )
|
||||||
{
|
{
|
||||||
|
@ -185,9 +191,29 @@ int GERBVIEW_CONTROL::HighlightControl( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( apertDescr )
|
if( apertDescr )
|
||||||
{
|
{
|
||||||
auto string = apertDescr->m_AperFunction;
|
wxString ap_name = apertDescr->m_AperFunction;
|
||||||
settings->m_attributeHighlightString = string;
|
settings->m_attributeHighlightString = ap_name;
|
||||||
m_frame->m_SelAperAttributesBox->SetStringSelection( string );
|
m_frame->m_SelAperAttributesBox->SetStringSelection( ap_name );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( item && aEvent.IsAction( &GERBVIEW_ACTIONS::highlightDCode ) )
|
||||||
|
{
|
||||||
|
D_CODE* apertDescr = item->GetDcodeDescr();
|
||||||
|
|
||||||
|
if( apertDescr )
|
||||||
|
{
|
||||||
|
int dcodeSelected = -1;
|
||||||
|
GERBER_FILE_IMAGE* gerber = m_frame->GetGbrImage( m_frame->GetActiveLayer() );
|
||||||
|
|
||||||
|
if( gerber )
|
||||||
|
dcodeSelected = apertDescr->m_Num_Dcode;
|
||||||
|
|
||||||
|
if( dcodeSelected > 0 )
|
||||||
|
{
|
||||||
|
settings->m_dcodeHighlightValue = dcodeSelected;
|
||||||
|
gerber->m_Selected_Tool = dcodeSelected;
|
||||||
|
m_frame->syncLayerBox( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,6 +396,7 @@ void GERBVIEW_CONTROL::setTransitions()
|
||||||
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightNet.MakeEvent() );
|
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightNet.MakeEvent() );
|
||||||
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightComponent.MakeEvent() );
|
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightComponent.MakeEvent() );
|
||||||
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightAttribute.MakeEvent() );
|
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightAttribute.MakeEvent() );
|
||||||
|
Go( &GERBVIEW_CONTROL::HighlightControl, GERBVIEW_ACTIONS::highlightDCode.MakeEvent() );
|
||||||
|
|
||||||
Go( &GERBVIEW_CONTROL::LayerNext, GERBVIEW_ACTIONS::layerNext.MakeEvent() );
|
Go( &GERBVIEW_CONTROL::LayerNext, GERBVIEW_ACTIONS::layerNext.MakeEvent() );
|
||||||
Go( &GERBVIEW_CONTROL::LayerPrev, GERBVIEW_ACTIONS::layerPrev.MakeEvent() );
|
Go( &GERBVIEW_CONTROL::LayerPrev, GERBVIEW_ACTIONS::layerPrev.MakeEvent() );
|
||||||
|
|
|
@ -89,6 +89,14 @@ private:
|
||||||
apertDescr->m_AperFunction ) );
|
apertDescr->m_AperFunction ) );
|
||||||
addSeparator = true;
|
addSeparator = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( apertDescr )
|
||||||
|
{
|
||||||
|
auto menuEntry = Add( GERBVIEW_ACTIONS::highlightDCode );
|
||||||
|
menuEntry->SetItemLabel( wxString::Format( _( "Highlight DCode D%d" ),
|
||||||
|
apertDescr->m_Num_Dcode ) );
|
||||||
|
addSeparator = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( addSeparator )
|
if( addSeparator )
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "layer_widget.h"
|
#include "layer_widget.h"
|
||||||
#include "gbr_layer_box_selector.h"
|
#include "gbr_layer_box_selector.h"
|
||||||
#include "gerbview_layer_widget.h"
|
#include "gerbview_layer_widget.h"
|
||||||
|
#include "dcode_selection_box.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GERBER_LAYER_WIDGET
|
* GERBER_LAYER_WIDGET
|
||||||
|
@ -273,7 +274,14 @@ bool GERBER_LAYER_WIDGET::OnLayerSelect( int aLayer )
|
||||||
if( layer != myframe->GetActiveLayer() )
|
if( layer != myframe->GetActiveLayer() )
|
||||||
{
|
{
|
||||||
if( ! OnLayerSelected() )
|
if( ! OnLayerSelected() )
|
||||||
|
{
|
||||||
|
auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>
|
||||||
|
( myframe->GetCanvas()->GetView()->GetPainter() )->GetSettings();
|
||||||
|
int dcodeSelected = myframe->m_DCodeSelector->GetSelectedDCodeId();
|
||||||
|
settings->m_dcodeHighlightValue = dcodeSelected;
|
||||||
|
myframe->GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
|
||||||
myframe->GetCanvas()->Refresh();
|
myframe->GetCanvas()->Refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue