Commit c9199ea8 authored by Maciej Suminski's avatar Maciej Suminski

Fixed high contrast mode in OpenGL. Split display settings loading into more appropriate places.

parent 4076f993
......@@ -111,7 +111,7 @@ void GPU_CACHED_MANAGER::BeginDrawing()
{
wxASSERT( !m_isDrawing );
if( m_container->isDirty() )
if( m_container->IsDirty() )
uploadToGpu();
// Number of vertices to be drawn in the EndDrawing()
......
......@@ -101,12 +101,14 @@ void VERTEX_MANAGER::ChangeItemColor( const VERTEX_ITEM& aItem, const COLOR4D& a
VERTEX* vertex = m_container->GetVertices( offset );
for( unsigned int i = 0; i < size; ++i )
{
vertex->r = aColor.r;
vertex->g = aColor.g;
vertex->b = aColor.b;
vertex->a = aColor.a;
vertex->r = aColor.r * 255.0;
vertex->g = aColor.g * 255.0;
vertex->b = aColor.b * 255.0;
vertex->a = aColor.a * 255.0;
vertex++;
}
m_container->SetDirty();
}
......@@ -121,6 +123,8 @@ void VERTEX_MANAGER::ChangeItemDepth( const VERTEX_ITEM& aItem, GLfloat aDepth )
vertex->z = aDepth;
vertex++;
}
m_container->SetDirty();
}
......
......@@ -111,7 +111,7 @@ public:
* returns information about container cache state. Clears the flag after calling the function.
* @return true in case the vertices have to be reuploaded.
*/
inline bool isDirty()
inline bool IsDirty()
{
bool state = m_dirty;
......@@ -120,6 +120,16 @@ public:
return state;
}
/**
* Function SetDirty()
* sets the dirty flag, so vertices in the container are going to be reuploaded to the GPU on
* the next frame.
*/
inline void SetDirty()
{
m_dirty = true;
}
protected:
VERTEX_CONTAINER( unsigned int aSize = defaultInitSize );
......
......@@ -182,45 +182,6 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
view->Add( zone );
}
// Apply layer coloring scheme & display options
if( view->GetPainter() )
{
KiGfx::PCB_RENDER_SETTINGS* settings = new KiGfx::PCB_RENDER_SETTINGS();
// Load layers' colors from PCB data
settings->ImportLegacyColors( m_Pcb->GetColorsSettings() );
view->GetPainter()->ApplySettings( settings );
// Load display options (such as filled/outline display of items)
settings->LoadDisplayOptions( DisplayOpt );
}
// Set rendering order of layers
for( LAYER_NUM i = 0; i < sizeof(GalLayerOrder) / sizeof(LAYER_NUM); ++i )
{
wxASSERT( i < KiGfx::VIEW::VIEW_MAX_LAYERS );
view->SetLayerOrder( GalLayerOrder[i], i );
}
// Netnames are drawn only when scale is sufficient (level of details)
// so there is no point in caching them
for( LAYER_NUM layer = FIRST_NETNAME_LAYER; layer <= LAST_NETNAME_LAYER; ++layer )
{
view->SetLayerTarget( layer, KiGfx::TARGET_NONCACHED );
}
// Load layer & elements visibility settings
for( LAYER_NUM i = 0; i < NB_LAYERS; ++i )
{
view->SetLayerVisible( i, m_Pcb->IsLayerVisible( i ) );
}
for( LAYER_NUM i = 0; i < END_PCB_VISIBLE_LIST; ++i )
{
view->SetLayerVisible( ITEM_GAL_LAYER( i ), m_Pcb->IsElementVisible( i ) );
}
view->RecacheAllItems( true );
if( m_galCanvasActive )
m_galCanvas->Refresh();
......@@ -827,6 +788,36 @@ void PCB_BASE_FRAME::LoadSettings()
if( m_DisplayModText < LINE || m_DisplayModText > SKETCH )
m_DisplayModText = FILLED;
// Apply display settings for GAL
KiGfx::VIEW* view = m_galCanvas->GetView();
// Set rendering order of layers
for( LAYER_NUM i = 0; i < sizeof(GalLayerOrder) / sizeof(LAYER_NUM); ++i )
{
wxASSERT( i < KiGfx::VIEW::VIEW_MAX_LAYERS );
view->SetLayerOrder( GalLayerOrder[i], i );
}
// Netnames are drawn only when scale is sufficient (level of details)
// so there is no point in caching them
for( LAYER_NUM layer = FIRST_NETNAME_LAYER; layer <= LAST_NETNAME_LAYER; ++layer )
{
view->SetLayerTarget( layer, KiGfx::TARGET_NONCACHED );
}
// Apply layer coloring scheme & display options
if( view->GetPainter() )
{
KiGfx::PCB_RENDER_SETTINGS* settings = new KiGfx::PCB_RENDER_SETTINGS();
// Load layers' colors from PCB data
settings->ImportLegacyColors( m_Pcb->GetColorsSettings() );
view->GetPainter()->ApplySettings( settings );
// Load display options (such as filled/outline display of items)
settings->LoadDisplayOptions( DisplayOpt );
}
// WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" )
// when reading doubles in config,
// but forget to back to current locale. So we call SetLocaleTo_Default
......
......@@ -4,6 +4,9 @@
#include <fctsys.h>
#include <class_drawpanel.h>
#include <class_drawpanel_gal.h>
#include <view/view.h>
#include <pcb_painter.h>
#include <confirm.h>
#include <wxPcbStruct.h>
......@@ -67,9 +70,12 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
// Default copper layers count set to 2: double layer board
GetBoard()->SetCopperLayerCount( 2 );
// Update display:
// Update display
GetBoard()->SetVisibleLayers( ALL_LAYERS );
// Set currently selected layer to be shown in high contrast mode, when enabled`
setHighContrastLayer( GetScreen()->m_Active_Layer );
ReFillLayerWidget();
Zoom_Automatique( false );
......
......@@ -472,7 +472,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
DisplayError( this, msg );
}
}
}
......@@ -813,6 +812,18 @@ void PCB_EDIT_FRAME::syncRenderStates()
void PCB_EDIT_FRAME::syncLayerVisibilities()
{
m_Layers->SyncLayerVisibilities();
KiGfx::VIEW* view = m_galCanvas->GetView();
// Load layer & elements visibility settings
for( LAYER_NUM i = 0; i < NB_LAYERS; ++i )
{
view->SetLayerVisible( i, m_Pcb->IsLayerVisible( i ) );
}
for( LAYER_NUM i = 0; i < END_PCB_VISIBLE_LIST; ++i )
{
view->SetLayerVisible( ITEM_GAL_LAYER( i ), m_Pcb->IsElementVisible( i ) );
}
}
......
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