More visibility settings infrastructure
ADDED: Three-state high contrast mode action ADDED: Save contrast mode in local settings Also some initial infrastructure for layer presets
This commit is contained in:
parent
abcbfaa481
commit
5d118b0700
|
@ -434,6 +434,7 @@ COLOR4D& COLOR4D::Saturate( double aFactor )
|
|||
constexpr COLOR4D COLOR4D::UNSPECIFIED( 0, 0, 0, 0 );
|
||||
constexpr COLOR4D COLOR4D::WHITE( 1, 1, 1, 1 );
|
||||
constexpr COLOR4D COLOR4D::BLACK( 0, 0, 0, 1 );
|
||||
constexpr COLOR4D COLOR4D::CLEAR( 1, 0, 1, 0 );
|
||||
|
||||
|
||||
EDA_COLOR_T COLOR4D::FindNearestLegacyColor( int aR, int aG, int aB )
|
||||
|
|
|
@ -107,6 +107,95 @@ PROJECT_FILE::PROJECT_FILE( const std::string& aFullPath ) :
|
|||
}, {} ) );
|
||||
|
||||
m_NetSettings = std::make_shared<NET_SETTINGS>( this, "net_settings" );
|
||||
|
||||
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "board.layer_presets",
|
||||
[&]() -> nlohmann::json
|
||||
{
|
||||
nlohmann::json ret = nlohmann::json::array();
|
||||
|
||||
for( const LAYER_PRESET& preset : m_LayerPresets )
|
||||
{
|
||||
nlohmann::json js = {
|
||||
{ "name", preset.name },
|
||||
{ "activeLayer", preset.activeLayer }
|
||||
};
|
||||
|
||||
nlohmann::json layers = nlohmann::json::array();
|
||||
|
||||
for( PCB_LAYER_ID layer : preset.layers.Seq() )
|
||||
layers.push_back( static_cast<int>( layer ) );
|
||||
|
||||
js["layers"] = layers;
|
||||
|
||||
nlohmann::json renderLayers = nlohmann::json::array();
|
||||
|
||||
for( GAL_LAYER_ID layer : preset.renderLayers.Seq() )
|
||||
renderLayers.push_back( static_cast<int>( layer ) );
|
||||
|
||||
js["renderLayers"] = renderLayers;
|
||||
|
||||
ret.push_back( js );
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
[&]( const nlohmann::json& aVal )
|
||||
{
|
||||
if( aVal.empty() || !aVal.is_array() )
|
||||
return;
|
||||
|
||||
m_LayerPresets.clear();
|
||||
|
||||
for( const nlohmann::json& preset : aVal )
|
||||
{
|
||||
if( preset.contains( "name" ) )
|
||||
{
|
||||
LAYER_PRESET p( preset.at( "name" ).get<wxString>() );
|
||||
|
||||
if( preset.contains( "activeLayer" ) &&
|
||||
preset.at( "activeLayer" ).is_number_integer() )
|
||||
{
|
||||
int active = preset.at( "activeLayer" ).get<int>();
|
||||
|
||||
if( active >= 0 && active < PCB_LAYER_ID_COUNT )
|
||||
p.activeLayer = static_cast<PCB_LAYER_ID>( active );
|
||||
}
|
||||
|
||||
if( preset.contains( "layers" ) && preset.at( "layers" ).is_array() )
|
||||
{
|
||||
for( const nlohmann::json& layer : preset.at( "layers" ) )
|
||||
{
|
||||
if( layer.is_number_integer() )
|
||||
{
|
||||
int layerNum = layer.get<int>();
|
||||
|
||||
if( layerNum >= 0 && layerNum < PCB_LAYER_ID_COUNT )
|
||||
p.layers.set( layerNum );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( preset.contains( "renderLayers" )
|
||||
&& preset.at( "renderLayers" ).is_array() )
|
||||
{
|
||||
for( const nlohmann::json& layer : preset.at( "renderLayers" ) )
|
||||
{
|
||||
if( layer.is_number_integer() )
|
||||
{
|
||||
int layerNum = layer.get<int>();
|
||||
|
||||
if( layerNum >= GAL_LAYER_ID_START
|
||||
&& layerNum < GAL_LAYER_ID_END )
|
||||
p.layers.set( layerNum );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_LayerPresets.emplace_back( p );
|
||||
}
|
||||
}
|
||||
},
|
||||
{} ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -140,9 +140,16 @@ PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS( const std::string& aFilename ) :
|
|||
} ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_ENUM<PCB_LAYER_ID>(
|
||||
"active_layer", &m_ActiveLayer, F_Cu, PCBNEW_LAYER_ID_START, F_Fab ) );
|
||||
"board.active_layer", &m_ActiveLayer, F_Cu, PCBNEW_LAYER_ID_START, F_Fab ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_LIST<wxString>( "hidden_nets", &m_HiddenNets, {} ) );
|
||||
m_params.emplace_back( new PARAM<wxString>( "board.active_layer_preset",
|
||||
&m_ActiveLayerPreset, "" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_ENUM<HIGH_CONTRAST_MODE>( "board.high_contrast_mode",
|
||||
&m_ContrastModeDisplay, HIGH_CONTRAST_MODE::NORMAL, HIGH_CONTRAST_MODE::NORMAL,
|
||||
HIGH_CONTRAST_MODE::HIDDEN ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_LIST<wxString>( "board.hidden_nets", &m_HiddenNets, {} ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -490,6 +490,10 @@ TOOL_ACTION ACTIONS::highContrastMode( "common.Control.highContrastMode",
|
|||
_( "High Contrast Mode" ), _( "Use high contrast display mode" ),
|
||||
contrast_mode_xpm );
|
||||
|
||||
TOOL_ACTION ACTIONS::highContrastModeCycle( "common.Control.highContrastModeCycle",
|
||||
AS_GLOBAL, 0, "", _( "High Contrast Mode (3-state)" ),
|
||||
_( "Toggle inactive layers between normal, dimmed, and hidden" ), contrast_mode_xpm );
|
||||
|
||||
TOOL_ACTION ACTIONS::selectionTool( "common.InteractiveSelection.selectionTool",
|
||||
AS_GLOBAL, 0, "",
|
||||
_( "Select item(s)" ), "",
|
||||
|
|
|
@ -374,6 +374,7 @@ public:
|
|||
// Declare a few color shortcuts that are used for comparisons frequently
|
||||
static const COLOR4D WHITE;
|
||||
static const COLOR4D BLACK;
|
||||
static const COLOR4D CLEAR;
|
||||
};
|
||||
|
||||
/// @brief Equality operator, are two colors equal
|
||||
|
|
|
@ -234,6 +234,44 @@ inline GAL_LAYER_ID operator+( const GAL_LAYER_ID& a, int b )
|
|||
return t;
|
||||
}
|
||||
|
||||
/// Helper for storing and iterating over GAL_LAYER_IDs
|
||||
class GAL_SET : public std::bitset<GAL_LAYER_ID_COUNT>
|
||||
{
|
||||
public:
|
||||
GAL_SET() : std::bitset<GAL_LAYER_ID_COUNT>()
|
||||
{
|
||||
}
|
||||
|
||||
GAL_SET( const GAL_SET& aOther ) : std::bitset<GAL_LAYER_ID_COUNT>( aOther )
|
||||
{
|
||||
}
|
||||
|
||||
GAL_SET& set()
|
||||
{
|
||||
std::bitset<GAL_LAYER_ID_COUNT>::set();
|
||||
return *this;
|
||||
}
|
||||
|
||||
GAL_SET& set( size_t aPos, bool aVal = true )
|
||||
{
|
||||
std::bitset<GAL_LAYER_ID_COUNT>::set( aPos, aVal );
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::vector<GAL_LAYER_ID> Seq() const
|
||||
{
|
||||
std::vector<GAL_LAYER_ID> ret;
|
||||
|
||||
for( size_t i = 0; i < size(); ++i )
|
||||
{
|
||||
if( test( i ) )
|
||||
ret.push_back( static_cast<GAL_LAYER_ID>( i ) );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
/// Eeschema drawing layers
|
||||
enum SCH_LAYER_ID: int
|
||||
{
|
||||
|
@ -404,7 +442,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
typedef std::bitset<GAL_LAYER_ID_COUNT> GAL_SET;
|
||||
|
||||
typedef std::bitset<PCB_LAYER_ID_COUNT> BASE_SET;
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ public:
|
|||
* (for instance solid or sketch mode)
|
||||
*/
|
||||
const PCB_DISPLAY_OPTIONS& GetDisplayOptions() const { return m_DisplayOptions; }
|
||||
void SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions ) { m_DisplayOptions = aOptions; }
|
||||
void SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions );
|
||||
|
||||
const ZONE_SETTINGS& GetZoneSettings() const;
|
||||
void SetZoneSettings( const ZONE_SETTINGS& aSettings );
|
||||
|
@ -369,6 +369,8 @@ public:
|
|||
|
||||
int GetSeverity( int aErrorCode ) const override;
|
||||
|
||||
virtual void OnDisplayOptionsChanged() {}
|
||||
|
||||
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
|
||||
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#ifndef PCB_DISPLAY_OPTIONS_H_
|
||||
#define PCB_DISPLAY_OPTIONS_H_
|
||||
|
||||
#include <project/board_project_settings.h>
|
||||
|
||||
/**
|
||||
* PCB_DISPLAY_OPTIONS
|
||||
* handles display options like enable/disable some optional drawings.
|
||||
|
@ -79,7 +81,9 @@ public:
|
|||
* 3 show netnames on tracks and pads
|
||||
*/
|
||||
|
||||
bool m_ContrastModeDisplay;
|
||||
/// How inactive layers are displayed. @see HIGH_CONTRAST_MODE
|
||||
HIGH_CONTRAST_MODE m_ContrastModeDisplay;
|
||||
|
||||
int m_MaxLinksShowed; // in track creation: number of hairwires shown
|
||||
bool m_ShowModuleRatsnest; // When moving a footprint: allows displaying a ratsnest
|
||||
bool m_ShowGlobalRatsnest; // If true, show all
|
||||
|
|
|
@ -18,8 +18,16 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KICAD_BOARD_LOCAL_SETTINGS_H
|
||||
#define KICAD_BOARD_LOCAL_SETTINGS_H
|
||||
#ifndef KICAD_BOARD_PROJECT_SETTINGS_H
|
||||
#define KICAD_BOARD_PROJECT_SETTINGS_H
|
||||
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
|
||||
/**
|
||||
* This file contains data structures that are saved in the project file or project local settings
|
||||
* file that are specific to PcbNew. This is done so that these structures are available in common.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Selection filtering that applies all the time (not the "filter selection" dialog that modifies
|
||||
|
@ -67,4 +75,50 @@ struct SELECTION_FILTER_OPTIONS
|
|||
}
|
||||
};
|
||||
|
||||
#endif // KICAD_BOARD_LOCAL_SETTINGS_H
|
||||
/**
|
||||
* Determines how inactive layers should be displayed
|
||||
*/
|
||||
enum class HIGH_CONTRAST_MODE
|
||||
{
|
||||
NORMAL = 0, ///> Non-active layers are shown normally (no high-contrast mode)
|
||||
DIMMED, ///> Non-active layers are dimmed (old high-contrast mode)
|
||||
HIDDEN ///> Non-active layers are hidden
|
||||
};
|
||||
|
||||
/**
|
||||
* A saved set of layers that are visible
|
||||
*/
|
||||
struct LAYER_PRESET
|
||||
{
|
||||
wxString name; ///< A name for this layer set
|
||||
LSET layers; ///< Board layers that are visible
|
||||
GAL_SET renderLayers; ///< Render layers (e.g. object types) that are visible
|
||||
PCB_LAYER_ID activeLayer; ///< Optional layer to set active when this preset is loaded
|
||||
|
||||
LAYER_PRESET( const wxString& aName ) :
|
||||
name( aName ),
|
||||
activeLayer( UNSELECTED_LAYER )
|
||||
{
|
||||
}
|
||||
|
||||
LAYER_PRESET( const wxString& aName, const LSET& aSet ) :
|
||||
name( aName ),
|
||||
layers( aSet ),
|
||||
activeLayer( UNSELECTED_LAYER )
|
||||
{
|
||||
}
|
||||
|
||||
LAYER_PRESET( const wxString& aName, const LSET& aSet, PCB_LAYER_ID aActive ) :
|
||||
name( aName ),
|
||||
layers( aSet ),
|
||||
activeLayer( aActive )
|
||||
{
|
||||
}
|
||||
|
||||
bool LayersMatch( const LAYER_PRESET& aOther )
|
||||
{
|
||||
return aOther.layers == layers && aOther.renderLayers == renderLayers;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // KICAD_BOARD_PROJECT_SETTINGS_H
|
|
@ -22,6 +22,7 @@
|
|||
#define KICAD_PROJECT_FILE_H
|
||||
|
||||
#include <common.h>
|
||||
#include <project/board_project_settings.h>
|
||||
#include <settings/json_settings.h>
|
||||
#include <settings/nested_settings.h>
|
||||
|
||||
|
@ -183,6 +184,9 @@ public:
|
|||
* schematics, one netlist partitioned into multiple boards)
|
||||
*/
|
||||
std::shared_ptr<NET_SETTINGS> m_NetSettings;
|
||||
|
||||
/// List of stored layer presets
|
||||
std::vector<LAYER_PRESET> m_LayerPresets;
|
||||
};
|
||||
|
||||
// Specializations to allow directly reading/writing FILE_INFO_PAIRs from JSON
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#define KICAD_PROJECT_LOCAL_SETTINGS_H
|
||||
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
#include <project/board_local_settings.h>
|
||||
#include <project/board_project_settings.h>
|
||||
#include <settings/json_settings.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
|
@ -88,6 +88,12 @@ public:
|
|||
/// The current (active) board layer for editing
|
||||
PCB_LAYER_ID m_ActiveLayer;
|
||||
|
||||
/// The name of a LAYER_PRESET that is currently activated (or blank if none)
|
||||
wxString m_ActiveLayerPreset;
|
||||
|
||||
/// The current contrast mode
|
||||
HIGH_CONTRAST_MODE m_ContrastModeDisplay;
|
||||
|
||||
/**
|
||||
* A list of netnames that have been manually hidden in the board editor.
|
||||
* Currently, hiding nets means hiding the ratsnest for those nets.
|
||||
|
|
|
@ -97,6 +97,7 @@ public:
|
|||
static TOOL_ACTION toggleCursor;
|
||||
static TOOL_ACTION toggleCursorStyle;
|
||||
static TOOL_ACTION highContrastMode;
|
||||
static TOOL_ACTION highContrastModeCycle;
|
||||
|
||||
static TOOL_ACTION refreshPreview; // Similar to a synthetic mouseMoved event, but also
|
||||
// used after a rotate, mirror, etc.
|
||||
|
|
|
@ -60,7 +60,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
case ID_TOOLBARH_PCB_SELECT_LAYER:
|
||||
SetActiveLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) );
|
||||
|
||||
if( displ_opts.m_ContrastModeDisplay )
|
||||
if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
|
||||
GetCanvas()->Refresh();
|
||||
break;
|
||||
|
||||
|
@ -118,7 +118,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, PCB_LAYER_ID layer )
|
|||
|
||||
SetActiveLayer( layer );
|
||||
|
||||
if( displ_opts.m_ContrastModeDisplay )
|
||||
if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
|
||||
GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
|
|
@ -300,8 +300,11 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
case ID_TOOLBARH_PCB_SELECT_LAYER:
|
||||
SetActiveLayer( ToLAYER_ID( m_selLayerBox->GetLayerSelection() ) );
|
||||
|
||||
if( GetDisplayOptions().m_ContrastModeDisplay )
|
||||
if( GetDisplayOptions().m_ContrastModeDisplay !=
|
||||
HIGH_CONTRAST_MODE::NORMAL )
|
||||
{
|
||||
GetCanvas()->Refresh();
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_MODEDIT_CHECK:
|
||||
|
|
|
@ -168,7 +168,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
|||
return !GetDisplayOptions().m_DisplayTextFill;
|
||||
};
|
||||
auto contrastModeCondition = [ this ] ( const SELECTION& aSel ) {
|
||||
return !GetDisplayOptions().m_ContrastModeDisplay;
|
||||
return ( GetDisplayOptions().m_ContrastModeDisplay !=
|
||||
HIGH_CONTRAST_MODE::NORMAL );
|
||||
};
|
||||
auto searchTreeShownCondition = [ this ] ( const SELECTION& aSel ) {
|
||||
return IsSearchTreeShown();
|
||||
|
@ -216,8 +217,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
|||
contrastModeSubMenu->SetIcon( contrast_mode_xpm );
|
||||
|
||||
contrastModeSubMenu->AddCheckItem( ACTIONS::highContrastMode, contrastModeCondition );
|
||||
contrastModeSubMenu->AddItem( PCB_ACTIONS::layerAlphaDec, SELECTION_CONDITIONS::ShowAlways );
|
||||
contrastModeSubMenu->AddItem( PCB_ACTIONS::layerAlphaInc, SELECTION_CONDITIONS::ShowAlways );
|
||||
contrastModeSubMenu->AddItem( PCB_ACTIONS::layerAlphaDec, SELECTION_CONDITIONS::ShowAlways );
|
||||
contrastModeSubMenu->AddItem( PCB_ACTIONS::layerAlphaInc, SELECTION_CONDITIONS::ShowAlways );
|
||||
viewMenu->AddMenu( contrastModeSubMenu );
|
||||
|
||||
viewMenu->AddSeparator();
|
||||
|
|
|
@ -318,7 +318,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
|
|||
};
|
||||
auto contrastModeCondition = [ &disp_opt ]( const SELECTION &aSel )
|
||||
{
|
||||
return !disp_opt.m_ContrastModeDisplay;
|
||||
return disp_opt.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
|
||||
};
|
||||
auto sketchGraphicsCondition = [ &disp_opt ]( const SELECTION &aSel )
|
||||
{
|
||||
|
@ -386,7 +386,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
|
|||
contrastModeSubMenu->SetTitle( _( "&Contrast Mode" ) );
|
||||
contrastModeSubMenu->SetIcon( contrast_mode_xpm );
|
||||
|
||||
contrastModeSubMenu->AddCheckItem( ACTIONS::highContrastMode, contrastModeCondition );
|
||||
contrastModeSubMenu->AddCheckItem( ACTIONS::highContrastMode, contrastModeCondition );
|
||||
contrastModeSubMenu->AddItem( PCB_ACTIONS::layerAlphaDec, SELECTION_CONDITIONS::ShowAlways );
|
||||
contrastModeSubMenu->AddItem( PCB_ACTIONS::layerAlphaInc, SELECTION_CONDITIONS::ShowAlways );
|
||||
viewMenu->AddMenu( contrastModeSubMenu );
|
||||
|
|
|
@ -417,7 +417,7 @@ void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, PCB_LAYER_ID layer )
|
|||
|
||||
SetActiveLayer( layer );
|
||||
|
||||
if( displ_opts.m_ContrastModeDisplay )
|
||||
if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
|
||||
GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
@ -742,3 +742,17 @@ void PCB_BASE_FRAME::ActivateGalCanvas()
|
|||
canvas->StartDrawing();
|
||||
}
|
||||
|
||||
|
||||
void PCB_BASE_FRAME::SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions )
|
||||
{
|
||||
m_DisplayOptions = aOptions;
|
||||
|
||||
EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
|
||||
KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( canvas->GetView() );
|
||||
|
||||
view->UpdateDisplayOptions( aOptions );
|
||||
canvas->SetHighContrastLayer( GetActiveLayer() );
|
||||
OnDisplayOptionsChanged();
|
||||
|
||||
canvas->Refresh();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ PCB_DISPLAY_OPTIONS::PCB_DISPLAY_OPTIONS()
|
|||
* 1 show netnames on pads
|
||||
* 2 show netnames on tracks
|
||||
* 3 show netnames on tracks and pads */
|
||||
m_ContrastModeDisplay = false;
|
||||
m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL;
|
||||
m_MaxLinksShowed = 3; // in track creation: number of hairwires shown
|
||||
m_ShowModuleRatsnest = true; // When moving a footprint: allows displaying a ratsnest
|
||||
m_DisplayRatsnestLinesCurved = false;
|
||||
|
|
|
@ -592,9 +592,12 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer )
|
|||
|
||||
myframe->SetActiveLayer( layer );
|
||||
|
||||
bool hcm = ( myframe->GetDisplayOptions().m_ContrastModeDisplay !=
|
||||
HIGH_CONTRAST_MODE::NORMAL );
|
||||
|
||||
if( m_alwaysShowActiveCopperLayer )
|
||||
OnLayerSelected();
|
||||
else if( myframe->GetDisplayOptions().m_ContrastModeDisplay )
|
||||
else if( hcm )
|
||||
myframe->GetCanvas()->Refresh();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -129,7 +129,8 @@ void PCB_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
|
|||
void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions,
|
||||
bool aShowPageLimits )
|
||||
{
|
||||
m_hiContrastEnabled = aOptions.m_ContrastModeDisplay;
|
||||
m_hiContrastEnabled = ( aOptions.m_ContrastModeDisplay !=
|
||||
HIGH_CONTRAST_MODE::NORMAL );
|
||||
m_padNumbers = aOptions.m_DisplayPadNum;
|
||||
m_sketchGraphics = !aOptions.m_DisplayGraphicsFill;
|
||||
m_sketchText = !aOptions.m_DisplayTextFill;
|
||||
|
@ -214,6 +215,8 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS& aOption
|
|||
if( aOptions.m_DisplayPadIsol )
|
||||
m_clearance |= CL_PADS;
|
||||
|
||||
m_contrastModeDisplay = aOptions.m_ContrastModeDisplay;
|
||||
|
||||
m_showPageLimits = aShowPageLimits;
|
||||
}
|
||||
|
||||
|
@ -247,6 +250,15 @@ const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer
|
|||
const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
|
||||
const BOARD_CONNECTED_ITEM* conItem = dynamic_cast<const BOARD_CONNECTED_ITEM*> ( aItem );
|
||||
|
||||
// Make items invisible in "other layers hidden" contrast mode
|
||||
if( m_contrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN && m_activeLayers.count( aLayer ) == 0 )
|
||||
return COLOR4D::CLEAR;
|
||||
|
||||
// Hide net names in "dimmed" contrast mode
|
||||
if( m_contrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL && IsNetnameLayer( aLayer )
|
||||
&& m_activeLayers.count( aLayer ) == 0 )
|
||||
return COLOR4D::CLEAR;
|
||||
|
||||
if( item )
|
||||
{
|
||||
// Selection disambiguation
|
||||
|
@ -297,8 +309,8 @@ const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer
|
|||
if( m_highlightEnabled && m_highlightNetcodes.count( netCode ) )
|
||||
return m_layerColorsHi[aLayer];
|
||||
|
||||
// Return grayish color for non-highlighted layers in the high contrast mode
|
||||
if( m_hiContrastEnabled && m_activeLayers.count( aLayer ) == 0 )
|
||||
// Return grayish color for non-highlighted layers in the dimmed high contrast mode
|
||||
if( m_contrastModeDisplay == HIGH_CONTRAST_MODE::DIMMED && m_activeLayers.count( aLayer ) == 0 )
|
||||
return m_hiContrastColor[aLayer];
|
||||
|
||||
// Catch the case when highlight and high-contraste modes are enabled
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#define __CLASS_PCB_PAINTER_H
|
||||
|
||||
#include <painter.h>
|
||||
#include <pcb_display_options.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -88,6 +89,7 @@ public:
|
|||
DZ_SHOW_OUTLINED
|
||||
};
|
||||
|
||||
///> Determines how net color overrides should be applied
|
||||
enum class NET_COLOR_MODE
|
||||
{
|
||||
OFF, ///< Net (and netclass) colors are not shown
|
||||
|
@ -250,6 +252,9 @@ protected:
|
|||
|
||||
///> Set of net codes that should not have their ratsnest displayed
|
||||
std::set<int> m_hiddenNets;
|
||||
|
||||
///> How to display inactive layers
|
||||
HIGH_CONTRAST_MODE m_contrastModeDisplay;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -117,6 +117,12 @@ bool PCB_EDIT_FRAME::LoadProjectSettings()
|
|||
filterOpts = localSettings.m_SelectionFilter;
|
||||
m_selectionFilterPanel->SetCheckboxesFromFilter( filterOpts );
|
||||
|
||||
PCB_DISPLAY_OPTIONS opts = GetDisplayOptions();
|
||||
opts.m_ContrastModeDisplay = localSettings.m_ContrastModeDisplay;
|
||||
SetDisplayOptions( opts );
|
||||
|
||||
SetActiveLayer( localSettings.m_ActiveLayer );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -142,6 +148,10 @@ void PCB_EDIT_FRAME::SaveProjectSettings()
|
|||
|
||||
RecordDRCExclusions();
|
||||
|
||||
localSettings.m_ActiveLayer = GetActiveLayer();
|
||||
|
||||
localSettings.m_ContrastModeDisplay = GetDisplayOptions().m_ContrastModeDisplay;
|
||||
|
||||
KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
|
||||
GetCanvas()->GetView()->GetPainter()->GetSettings() );
|
||||
|
||||
|
|
|
@ -198,13 +198,15 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, b
|
|||
|
||||
ITEM* rv = NULL;
|
||||
|
||||
bool highContrast = ( displayOptions().m_ContrastModeDisplay !=
|
||||
HIGH_CONTRAST_MODE::NORMAL );
|
||||
|
||||
for( int i = 0; i < candidateCount; i++ )
|
||||
{
|
||||
ITEM* item = prioritized[i];
|
||||
|
||||
if( displayOptions().m_ContrastModeDisplay )
|
||||
if( item && !item->Layers().Overlaps( tl ) )
|
||||
item = NULL;
|
||||
if( highContrast && item && !item->Layers().Overlaps( tl ) )
|
||||
item = nullptr;
|
||||
|
||||
if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
|
||||
{
|
||||
|
|
|
@ -237,6 +237,8 @@ void FOOTPRINT_EDIT_FRAME::SyncToolbars()
|
|||
m_mainToolBar->Toggle( PCB_ACTIONS::footprintProperties, GetBoard()->GetFirstModule() );
|
||||
m_mainToolBar->Refresh();
|
||||
|
||||
bool hcm = opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
|
||||
|
||||
m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() );
|
||||
m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != EDA_UNITS::INCHES );
|
||||
m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == EDA_UNITS::INCHES );
|
||||
|
@ -244,7 +246,7 @@ void FOOTPRINT_EDIT_FRAME::SyncToolbars()
|
|||
m_optionsToolBar->Toggle( PCB_ACTIONS::padDisplayMode, !opts.m_DisplayPadFill );
|
||||
m_optionsToolBar->Toggle( PCB_ACTIONS::textOutlines, !opts.m_DisplayTextFill );
|
||||
m_optionsToolBar->Toggle( PCB_ACTIONS::graphicsOutlines, !opts.m_DisplayGraphicsFill );
|
||||
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, opts.m_ContrastModeDisplay );
|
||||
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, hcm );
|
||||
m_optionsToolBar->Toggle( PCB_ACTIONS::toggleFootprintTree, IsSearchTreeShown() );
|
||||
m_optionsToolBar->Refresh();
|
||||
|
||||
|
|
|
@ -731,13 +731,15 @@ void PCB_EDIT_FRAME::SyncToolbars()
|
|||
m_optionsToolBar->Toggle( PCB_ACTIONS::showLayersManager, LayerManagerShown() );
|
||||
m_optionsToolBar->Toggle( PCB_ACTIONS::showMicrowaveToolbar, MicrowaveToolbarShown() );
|
||||
|
||||
bool hcm = opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL;
|
||||
|
||||
m_optionsToolBar->Toggle( PCB_ACTIONS::zoneDisplayEnable, zoneMode == 0 );
|
||||
m_optionsToolBar->Toggle( PCB_ACTIONS::zoneDisplayDisable, zoneMode == 1 );
|
||||
m_optionsToolBar->Toggle( PCB_ACTIONS::zoneDisplayOutlines, zoneMode == 2 );
|
||||
m_optionsToolBar->Toggle( PCB_ACTIONS::trackDisplayMode, !opts.m_DisplayPcbTrackFill );
|
||||
m_optionsToolBar->Toggle( PCB_ACTIONS::viaDisplayMode, !opts.m_DisplayViaFill );
|
||||
m_optionsToolBar->Toggle( PCB_ACTIONS::padDisplayMode, !opts.m_DisplayPadFill );
|
||||
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, opts.m_ContrastModeDisplay );
|
||||
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, hcm );
|
||||
m_optionsToolBar->Refresh();
|
||||
|
||||
TOGGLE_TOOL( m_drawToolBar, ACTIONS::selectionTool );
|
||||
|
|
|
@ -519,10 +519,11 @@ int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent )
|
|||
D_PAD* pad = static_cast<D_PAD*>( selection[0] );
|
||||
PCB_LAYER_ID layer = explodePad( pad );
|
||||
|
||||
m_wasHighContrast = opts.m_ContrastModeDisplay;
|
||||
m_wasHighContrast = ( opts.m_ContrastModeDisplay !=
|
||||
HIGH_CONTRAST_MODE::NORMAL );
|
||||
frame()->SetActiveLayer( layer );
|
||||
|
||||
if( !opts.m_ContrastModeDisplay )
|
||||
if( !m_wasHighContrast )
|
||||
m_toolMgr->RunAction( ACTIONS::highContrastMode, false );
|
||||
|
||||
if( PCB_ACTIONS::explodePad.GetHotKey() == PCB_ACTIONS::recombinePad.GetHotKey() )
|
||||
|
@ -540,7 +541,10 @@ int PAD_TOOL::EditPad( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( m_editPad == niluuid )
|
||||
{
|
||||
if( m_wasHighContrast != opts.m_ContrastModeDisplay )
|
||||
bool highContrast = ( opts.m_ContrastModeDisplay !=
|
||||
HIGH_CONTRAST_MODE::NORMAL );
|
||||
|
||||
if( m_wasHighContrast != highContrast )
|
||||
m_toolMgr->RunAction( ACTIONS::highContrastMode, false );
|
||||
|
||||
infoBar->Dismiss();
|
||||
|
|
|
@ -214,10 +214,40 @@ int PCBNEW_CONTROL::HighContrastMode( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
auto opts = displayOptions();
|
||||
|
||||
Flip( opts.m_ContrastModeDisplay );
|
||||
opts.m_ContrastModeDisplay =
|
||||
( opts.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::NORMAL ) ?
|
||||
HIGH_CONTRAST_MODE::DIMMED :
|
||||
HIGH_CONTRAST_MODE::NORMAL;
|
||||
|
||||
m_frame->SetDisplayOptions( opts );
|
||||
view()->UpdateDisplayOptions( opts );
|
||||
canvas()->SetHighContrastLayer( m_frame->GetActiveLayer() );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int PCBNEW_CONTROL::HighContrastModeCycle( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
auto opts = displayOptions();
|
||||
|
||||
switch( opts.m_ContrastModeDisplay )
|
||||
{
|
||||
case HIGH_CONTRAST_MODE::NORMAL:
|
||||
opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::DIMMED;
|
||||
break;
|
||||
|
||||
case HIGH_CONTRAST_MODE::DIMMED:
|
||||
opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::HIDDEN;
|
||||
break;
|
||||
|
||||
case HIGH_CONTRAST_MODE::HIDDEN:
|
||||
opts.m_ContrastModeDisplay = HIGH_CONTRAST_MODE::NORMAL;
|
||||
break;
|
||||
}
|
||||
|
||||
m_frame->SetDisplayOptions( opts );
|
||||
|
||||
// TODO: remove once EVT_UPDATE_UI works
|
||||
m_frame->SyncToolbars();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1023,15 +1053,16 @@ void PCBNEW_CONTROL::setTransitions()
|
|||
Go( &PCBNEW_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
|
||||
|
||||
// Display modes
|
||||
Go( &PCBNEW_CONTROL::TrackDisplayMode, PCB_ACTIONS::trackDisplayMode.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ToggleRatsnest, PCB_ACTIONS::showRatsnest.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ToggleRatsnest, PCB_ACTIONS::ratsnestLineMode.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ViaDisplayMode, PCB_ACTIONS::viaDisplayMode.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayEnable.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayDisable.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayOutlines.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayToggle.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::HighContrastMode, ACTIONS::highContrastMode.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::TrackDisplayMode, PCB_ACTIONS::trackDisplayMode.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ToggleRatsnest, PCB_ACTIONS::showRatsnest.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ToggleRatsnest, PCB_ACTIONS::ratsnestLineMode.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ViaDisplayMode, PCB_ACTIONS::viaDisplayMode.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayEnable.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayDisable.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayOutlines.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::ZoneDisplayMode, PCB_ACTIONS::zoneDisplayToggle.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::HighContrastMode, ACTIONS::highContrastMode.MakeEvent() );
|
||||
Go( &PCBNEW_CONTROL::HighContrastModeCycle, ACTIONS::highContrastModeCycle.MakeEvent() );
|
||||
|
||||
// Layer control
|
||||
Go( &PCBNEW_CONTROL::LayerSwitch, PCB_ACTIONS::layerTop.MakeEvent() );
|
||||
|
@ -1092,5 +1123,3 @@ void PCBNEW_CONTROL::setTransitions()
|
|||
Go( &PCBNEW_CONTROL::UpdateMessagePanel, EVENTS::ClearedEvent );
|
||||
Go( &PCBNEW_CONTROL::UpdateMessagePanel, EVENTS::SelectedItemsModified );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,8 +59,16 @@ public:
|
|||
int ZoneDisplayMode( const TOOL_EVENT& aEvent );
|
||||
int TrackDisplayMode( const TOOL_EVENT& aEvent );
|
||||
int ViaDisplayMode( const TOOL_EVENT& aEvent );
|
||||
|
||||
// Update the view with the new high-contrast mode from the display settings
|
||||
int HighContrastMode( const TOOL_EVENT& aEvent );
|
||||
|
||||
// Rotate through the available high-contrast modes
|
||||
int HighContrastModeCycle( const TOOL_EVENT& aEvent );
|
||||
|
||||
// Layer view presets
|
||||
int ApplyLayerPreset( const TOOL_EVENT& aEvent );
|
||||
|
||||
// Layer control
|
||||
int LayerSwitch( const TOOL_EVENT& aEvent );
|
||||
int LayerNext( const TOOL_EVENT& aEvent );
|
||||
|
|
|
@ -30,12 +30,12 @@
|
|||
#include <memory>
|
||||
|
||||
#include <math/vector2d.h>
|
||||
#include <project/board_local_settings.h>
|
||||
#include <tools/pcb_tool_base.h>
|
||||
#include <project/board_project_settings.h>
|
||||
#include <tool/action_menu.h>
|
||||
#include <tools/pcbnew_selection.h>
|
||||
#include <tools/pcb_selection_conditions.h>
|
||||
#include <tool/tool_menu.h>
|
||||
#include <tools/pcb_selection_conditions.h>
|
||||
#include <tools/pcb_tool_base.h>
|
||||
#include <tools/pcbnew_selection.h>
|
||||
|
||||
class PCB_BASE_FRAME;
|
||||
class BOARD_ITEM;
|
||||
|
|
Loading…
Reference in New Issue