Added high contrast display mode using GAL rendering.
New methods in VIEW class: SetTopLayer(), EnableTopLayer() for managing the top layer display. New method in PCB_RENDER_SETTINGS class: LoadDisplayOptions() for applying display settings like high-contrast, outline display of items, etc.
This commit is contained in:
parent
52ec277592
commit
850c0a8473
|
@ -37,7 +37,9 @@
|
|||
|
||||
using namespace KiGfx;
|
||||
|
||||
// Static constants
|
||||
const unsigned int VIEW::VIEW_MAX_LAYERS = 64;
|
||||
const int VIEW::TOP_LAYER = -1;
|
||||
|
||||
void VIEW::AddLayer( int aLayer, bool aDisplayOnly )
|
||||
{
|
||||
|
@ -134,12 +136,15 @@ int VIEW::Query( const BOX2I& aRect, std::vector<LayerItemPair>& aResult )
|
|||
|
||||
|
||||
VIEW::VIEW( bool aIsDynamic, bool aUseGroups ) :
|
||||
m_enableTopLayer( false ),
|
||||
m_scale ( 1.0 ),
|
||||
m_painter( NULL ),
|
||||
m_gal( NULL ),
|
||||
m_dynamic( aIsDynamic ),
|
||||
m_useGroups( aUseGroups )
|
||||
{
|
||||
// By default there is not layer on the top
|
||||
m_topLayer.enabled = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -292,6 +297,57 @@ void VIEW::SetLayerOrder( int aLayer, int aRenderingOrder )
|
|||
}
|
||||
|
||||
|
||||
void VIEW::SetTopLayer( int aLayer )
|
||||
{
|
||||
// Restore previous order
|
||||
if( m_topLayer.enabled )
|
||||
m_layers[m_topLayer.id].renderingOrder = m_topLayer.renderingOrder;
|
||||
|
||||
if( aLayer >= 0 && aLayer < VIEW_MAX_LAYERS )
|
||||
{
|
||||
// Save settings, so it can be restored later
|
||||
m_topLayer.renderingOrder = m_layers[aLayer].renderingOrder;
|
||||
m_topLayer.id = m_layers[aLayer].id;
|
||||
|
||||
// Apply new settings only if the option is enabled
|
||||
if( m_enableTopLayer )
|
||||
m_layers[aLayer].renderingOrder = TOP_LAYER;
|
||||
|
||||
// Set the flag saying that settings stored in m_topLayer are valid
|
||||
m_topLayer.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// There are no valid settings in m_topLayer
|
||||
m_topLayer.enabled = false;
|
||||
}
|
||||
|
||||
sortLayers();
|
||||
}
|
||||
|
||||
|
||||
void VIEW::EnableTopLayer( bool aEnable )
|
||||
{
|
||||
if( aEnable == m_enableTopLayer ) return;
|
||||
|
||||
// Use stored settings only if applicable
|
||||
// (topLayer.enabled == false means there are no valid settings stored)
|
||||
if( m_topLayer.enabled )
|
||||
{
|
||||
if( aEnable )
|
||||
{
|
||||
m_layers[m_topLayer.id].renderingOrder = TOP_LAYER;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_layers[m_topLayer.id].renderingOrder = m_topLayer.renderingOrder;
|
||||
}
|
||||
}
|
||||
|
||||
m_enableTopLayer = aEnable;
|
||||
}
|
||||
|
||||
|
||||
struct VIEW::drawItem
|
||||
{
|
||||
drawItem( VIEW* aView, int aCurrentLayer ) :
|
||||
|
|
|
@ -264,6 +264,23 @@ public:
|
|||
*/
|
||||
void SetLayerOrder( int aLayer, int aRenderingOrder );
|
||||
|
||||
/**
|
||||
* Function SetTopLayer()
|
||||
* Sets given layer to be displayed on the top or sets back the default order of layers.
|
||||
* @param aLayer: the layer or -1 in case when no particular layer should
|
||||
* be displayed on the top.
|
||||
*/
|
||||
void SetTopLayer( int aLayer );
|
||||
|
||||
/**
|
||||
* Function EnableTopLayer()
|
||||
* Enables or disables display of the top layer. When disabled - layers are rendered as usual
|
||||
* with no influence from SetTopLayer function. Otherwise on the top there is displayed the
|
||||
* layer set previously with SetTopLayer function.
|
||||
* @param aEnabled: whether to enable or disable display of the top layer.
|
||||
*/
|
||||
void EnableTopLayer( bool aEnable );
|
||||
|
||||
/**
|
||||
* Function Redraw()
|
||||
* Immediately redraws the whole view.
|
||||
|
@ -285,6 +302,7 @@ public:
|
|||
bool IsDynamic() const { return m_dynamic; }
|
||||
|
||||
static const unsigned int VIEW_MAX_LAYERS; ///* maximum number of layers that may be shown
|
||||
static const int TOP_LAYER; ///* layer number for displaying items on the top
|
||||
|
||||
private:
|
||||
|
||||
|
@ -312,6 +330,12 @@ private:
|
|||
struct unlinkItem;
|
||||
struct drawItem;
|
||||
|
||||
///* Saves current top layer settings in order to restore it when it's not top anymore
|
||||
VIEW_LAYER m_topLayer;
|
||||
|
||||
///* Whether to use top layer settings or not
|
||||
bool m_enableTopLayer;
|
||||
|
||||
///* Redraws contents within rect aRect
|
||||
void redrawRect( const BOX2I& aRect );
|
||||
|
||||
|
|
|
@ -237,6 +237,8 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
|
|||
{
|
||||
view->SetLayerVisible( ITEM_GAL_LAYER( i ), m_Pcb->IsElementVisible( i ) );
|
||||
}
|
||||
|
||||
view->SetTopLayer( m_Pcb->GetLayer() );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -344,7 +344,10 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer )
|
|||
myframe->setActiveLayer( aLayer, false );
|
||||
|
||||
#ifdef KICAD_GAL
|
||||
myframe->GetGalCanvas()->GetView()->GetPainter()->GetSettings()->SetActiveLayer( aLayer );
|
||||
// Set display settings for high contrast mode
|
||||
KiGfx::VIEW* view = myframe->GetGalCanvas()->GetView();
|
||||
view->GetPainter()->GetSettings()->SetActiveLayer( aLayer );
|
||||
view->SetTopLayer( aLayer );
|
||||
#endif /* KICAD_GAL */
|
||||
|
||||
if(DisplayOpt.ContrastModeDisplay)
|
||||
|
@ -353,7 +356,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer )
|
|||
if( myframe->IsGalCanvasActive() )
|
||||
myframe->GetGalCanvas()->Refresh();
|
||||
else
|
||||
#endif
|
||||
#endif /* KICAD_GAL */
|
||||
myframe->GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,11 @@
|
|||
#include <class_board.h>
|
||||
|
||||
#include <dialog_general_options.h>
|
||||
|
||||
#ifdef KICAD_GAL
|
||||
#include <class_drawpanel_gal.h>
|
||||
#include <view/view.h>
|
||||
#include <pcb_painter.h>
|
||||
#endif /* KICAD_GAL */
|
||||
|
||||
DIALOG_GENERALOPTIONS::DIALOG_GENERALOPTIONS( PCB_EDIT_FRAME* parent ) :
|
||||
DIALOG_GENERALOPTIONS_BOARDEDITOR_BASE( parent )
|
||||
|
@ -217,6 +221,9 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
|
|||
|
||||
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
|
||||
DisplayOpt.ContrastModeDisplay = state;
|
||||
#ifdef KICAD_GAL
|
||||
m_galCanvas->GetView()->EnableTopLayer( state );
|
||||
#endif /* KICAD_GAL */
|
||||
m_canvas->Refresh();
|
||||
break;
|
||||
|
||||
|
@ -242,4 +249,18 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
|
|||
wxT( "PCB_EDIT_FRAME::OnSelectOptionToolbar error \n (event not handled!)" ) );
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef KICAD_GAL
|
||||
// Apply new display options to the GAL canvas
|
||||
KiGfx::PCB_PAINTER* painter =
|
||||
static_cast<KiGfx::PCB_PAINTER*> ( m_galCanvas->GetView()->GetPainter() );
|
||||
KiGfx::PCB_RENDER_SETTINGS* settings =
|
||||
static_cast<KiGfx::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
|
||||
settings->LoadDisplayOptions( DisplayOpt );
|
||||
|
||||
if( IsGalCanvasActive() )
|
||||
{
|
||||
m_galCanvas->Refresh();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <class_marker_pcb.h>
|
||||
#include <class_dimension.h>
|
||||
#include <class_mire.h>
|
||||
#include <pcbstruct.h>
|
||||
|
||||
#include <view/view.h>
|
||||
#include <pcb_painter.h>
|
||||
|
@ -69,6 +70,12 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings
|
|||
}
|
||||
|
||||
|
||||
void PCB_RENDER_SETTINGS::LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions )
|
||||
{
|
||||
m_hiContrastEnabled = aOptions.ContrastModeDisplay;
|
||||
}
|
||||
|
||||
|
||||
void PCB_RENDER_SETTINGS::Update()
|
||||
{
|
||||
// Calculate darkened/highlighted variants of layer colors
|
||||
|
@ -88,7 +95,7 @@ void PCB_RENDER_SETTINGS::Update()
|
|||
m_itemColorsSel[i] = m_itemColors[i].Highlighted( m_selectFactor );
|
||||
}
|
||||
|
||||
m_hiContrastColor = COLOR4D( m_hiContrastFactor, m_hiContrastFactor, m_highlightFactor,
|
||||
m_hiContrastColor = COLOR4D( m_hiContrastFactor, m_hiContrastFactor, m_hiContrastFactor,
|
||||
m_layerOpacity );
|
||||
}
|
||||
|
||||
|
@ -101,10 +108,6 @@ PCB_PAINTER::PCB_PAINTER( GAL* aGal ) :
|
|||
|
||||
const COLOR4D& PCB_PAINTER::getLayerColor( int aLayer, int aNetCode ) const
|
||||
{
|
||||
// For item layers (vias, texts, and so on)
|
||||
if( aLayer >= LAYER_COUNT )
|
||||
return getItemColor( aLayer - LAYER_COUNT, aNetCode );
|
||||
|
||||
if( m_pcbSettings->m_hiContrastEnabled && m_pcbSettings->m_activeLayer != aLayer )
|
||||
{
|
||||
return m_pcbSettings->m_hiContrastColor;
|
||||
|
@ -122,6 +125,10 @@ const COLOR4D& PCB_PAINTER::getLayerColor( int aLayer, int aNetCode ) const
|
|||
}
|
||||
else
|
||||
{
|
||||
// For item layers (vias, texts, and so on)
|
||||
if( aLayer >= LAYER_COUNT )
|
||||
return getItemColor( aLayer - LAYER_COUNT, aNetCode );
|
||||
|
||||
return m_pcbSettings->m_layerColors[aLayer];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
class EDA_ITEM;
|
||||
class COLORS_DESIGN_SETTINGS;
|
||||
class DISPLAY_OPTIONS;
|
||||
|
||||
class BOARD_ITEM;
|
||||
class BOARD;
|
||||
class SEGVIA;
|
||||
|
@ -76,6 +78,14 @@ public:
|
|||
/// @copydoc RENDER_SETTINGS::ImportLegacyColors()
|
||||
void ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings );
|
||||
|
||||
/**
|
||||
* Function LoadDisplayOptions
|
||||
* Loads settings related to display options (high-contrast mode, full or outline modes
|
||||
* for vias/pads/tracks and so on).
|
||||
* @param aOptions are settings that you want to use for displaying items.
|
||||
*/
|
||||
void LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions );
|
||||
|
||||
protected:
|
||||
|
||||
/// Colors for all layers (including special, highlighted & darkened versions)
|
||||
|
|
Loading…
Reference in New Issue