Commit 886a3e93 authored by tomasz.wlostowski@cern.ch's avatar tomasz.wlostowski@cern.ch

Merged Orson's branch

parents 299f4243 9adbdd80
...@@ -32,6 +32,7 @@ set(GAL_SRCS ...@@ -32,6 +32,7 @@ set(GAL_SRCS
# Common part # Common part
drawpanel_gal.cpp drawpanel_gal.cpp
painter.cpp painter.cpp
worksheet_item.cpp
gal/graphics_abstraction_layer.cpp gal/graphics_abstraction_layer.cpp
gal/stroke_font.cpp gal/stroke_font.cpp
gal/color4d.cpp gal/color4d.cpp
...@@ -166,7 +167,7 @@ set(COMMON_SRCS ...@@ -166,7 +167,7 @@ set(COMMON_SRCS
geometry/seg.cpp geometry/seg.cpp
geometry/shape_line_chain.cpp geometry/shape_line_chain.cpp
geometry/shape_collisions.cpp geometry/shape_collisions.cpp
) )
add_library(common STATIC ${COMMON_SRCS}) add_library(common STATIC ${COMMON_SRCS})
......
...@@ -981,18 +981,16 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) ...@@ -981,18 +981,16 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
// Switch to GAL rendering // Switch to GAL rendering
if( !m_galCanvasActive ) if( !m_galCanvasActive )
{ {
// Set up grid settings
gal->SetGridVisibility( IsGridVisible() );
gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) );
gal->SetGridOrigin( VECTOR2D( screen->GetGridOrigin() ) );
gal->SetGridOriginMarkerSize( 15 );
gal->SetGridDrawThreshold( 10 );
// Set up viewport // Set up viewport
double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() ); double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() );
view->SetScale( zoom ); view->SetScale( zoom );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
} }
// Set up grid settings
gal->SetGridVisibility( IsGridVisible() );
gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) );
gal->SetGridOrigin( VECTOR2D( screen->GetGridOrigin() ) );
} }
else else
{ {
......
...@@ -90,8 +90,9 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin ...@@ -90,8 +90,9 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
Connect( wxEVT_CHAR_HOOK, wxEventHandler( EDA_DRAW_PANEL_GAL::skipEvent ) ); Connect( wxEVT_CHAR_HOOK, wxEventHandler( EDA_DRAW_PANEL_GAL::skipEvent ) );
Connect( wxEVT_KEY_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); Connect( wxEVT_KEY_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_KEY_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); Connect( wxEVT_KEY_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_ENTER_WINDOW, wxEventHandler (EDA_DRAW_PANEL_GAL::onEnter ), NULL, this ); Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
Connect( TOOL_DISPATCHER::EVT_REFRESH_MOUSE, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ),
NULL, this );
m_refreshTimer.SetOwner( this ); m_refreshTimer.SetOwner( this );
Connect( wxEVT_TIMER, wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this ); Connect( wxEVT_TIMER, wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this );
...@@ -130,7 +131,7 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) ...@@ -130,7 +131,7 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
m_gal->SetBackgroundColor( KiGfx::COLOR4D( 0.0, 0.0, 0.0, 1.0 ) ); m_gal->SetBackgroundColor( KiGfx::COLOR4D( 0.0, 0.0, 0.0, 1.0 ) );
m_gal->ClearScreen(); m_gal->ClearScreen();
m_view->PrepareTargets(); m_view->ClearTargets();
// Grid has to be redrawn only when the NONCACHED target is redrawn // Grid has to be redrawn only when the NONCACHED target is redrawn
if( m_view->IsTargetDirty( KiGfx::TARGET_NONCACHED ) ) if( m_view->IsTargetDirty( KiGfx::TARGET_NONCACHED ) )
m_gal->DrawGrid(); m_gal->DrawGrid();
...@@ -164,19 +165,22 @@ void EDA_DRAW_PANEL_GAL::onRefreshTimer( wxTimerEvent& aEvent ) ...@@ -164,19 +165,22 @@ void EDA_DRAW_PANEL_GAL::onRefreshTimer( wxTimerEvent& aEvent )
void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect ) void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect )
{ {
if(m_pendingRefresh) if( m_pendingRefresh )
return; return;
wxLongLong t = wxGetLocalTimeMillis(); wxLongLong t = wxGetLocalTimeMillis();
wxLongLong delta = t - m_lastRefresh; wxLongLong delta = t - m_lastRefresh;
if(t >= MinRefreshPeriod) if( delta >= MinRefreshPeriod )
{ {
wxPaintEvent redrawEvent; wxPaintEvent redrawEvent;
wxPostEvent( this, redrawEvent ); wxPostEvent( this, redrawEvent );
m_pendingRefresh = true; m_pendingRefresh = true;
} else { }
m_refreshTimer.Start ( (MinRefreshPeriod - t).ToLong(), true ); else
{
// One shot timer
m_refreshTimer.Start( ( MinRefreshPeriod - delta ).ToLong(), true );
m_pendingRefresh = true; m_pendingRefresh = true;
} }
} }
...@@ -236,16 +240,17 @@ void EDA_DRAW_PANEL_GAL::onEvent( wxEvent& aEvent ) ...@@ -236,16 +240,17 @@ void EDA_DRAW_PANEL_GAL::onEvent( wxEvent& aEvent )
m_eventDispatcher->DispatchWxEvent( aEvent ); m_eventDispatcher->DispatchWxEvent( aEvent );
} }
if(m_view->IsDirty())
Refresh(); Refresh();
} }
void EDA_DRAW_PANEL_GAL::onEnter ( wxEvent& aEvent ) void EDA_DRAW_PANEL_GAL::onEnter( wxEvent& aEvent )
{ {
// Getting focus is necessary in order to receive key events properly
SetFocus(); SetFocus();
} }
void EDA_DRAW_PANEL_GAL::skipEvent( wxEvent& aEvent ) void EDA_DRAW_PANEL_GAL::skipEvent( wxEvent& aEvent )
{ {
// This is necessary for CHAR_HOOK event to generate KEY_UP and KEY_DOWN events // This is necessary for CHAR_HOOK event to generate KEY_UP and KEY_DOWN events
......
...@@ -30,9 +30,9 @@ using namespace KiGfx; ...@@ -30,9 +30,9 @@ using namespace KiGfx;
COLOR4D::COLOR4D( EDA_COLOR_T aColor ) COLOR4D::COLOR4D( EDA_COLOR_T aColor )
{ {
r = g_ColorRefs[aColor].m_Red; r = g_ColorRefs[aColor].m_Red / 255.0;
g = g_ColorRefs[aColor].m_Green; g = g_ColorRefs[aColor].m_Green / 255.0;
b = g_ColorRefs[aColor].m_Blue; b = g_ColorRefs[aColor].m_Blue / 255.0;
a = 1.0; a = 1.0;
} }
...@@ -59,7 +59,8 @@ const bool COLOR4D::operator!=( const COLOR4D& aColor ) ...@@ -59,7 +59,8 @@ const bool COLOR4D::operator!=( const COLOR4D& aColor )
return a != aColor.a || r != aColor.r || g != aColor.g || b != aColor.b; return a != aColor.a || r != aColor.r || g != aColor.g || b != aColor.b;
} }
void COLOR4D::ToHSV(double& out_h, double& out_s, double& out_v) const
void COLOR4D::ToHSV( double& aOutH, double& aOutS, double& aOutV ) const
{ {
double min, max, delta; double min, max, delta;
...@@ -69,81 +70,91 @@ void COLOR4D::ToHSV(double& out_h, double& out_s, double& out_v) const ...@@ -69,81 +70,91 @@ void COLOR4D::ToHSV(double& out_h, double& out_s, double& out_v) const
max = r > g ? r : g; max = r > g ? r : g;
max = max > b ? max : b; max = max > b ? max : b;
out_v = max; // v aOutV = max; // v
delta = max - min; delta = max - min;
if( max > 0.0 ) { if( max > 0.0 )
out_s = (delta / max); // s {
} else { aOutS = ( delta / max ); // s
}
else
{
// r = g = b = 0 // s = 0, v is undefined // r = g = b = 0 // s = 0, v is undefined
out_s = 0.0; aOutS = 0.0;
out_h = NAN; // its now undefined aOutH = NAN; // its now undefined
return; return;
} }
if( r >= max ) // > is bogus, just keeps compilor happy
out_h = ( g - b ) / delta; // between yellow & magenta if( r >= max ) // > is bogus, just keeps compiler happy
else aOutH = ( g - b ) / delta; // between yellow & magenta
if( g >= max ) else if( g >= max )
out_h = 2.0 + ( b - r ) / delta; // between cyan & yellow aOutH = 2.0 + ( b - r ) / delta; // between cyan & yellow
else else
out_h = 4.0 + ( r - g ) / delta; // between magenta & cyan aOutH = 4.0 + ( r - g ) / delta; // between magenta & cyan
out_h *= 60.0; // degrees aOutH *= 60.0; // degrees
if( out_h < 0.0 ) if( aOutH < 0.0 )
out_h += 360.0; aOutH += 360.0;
} }
void COLOR4D::FromHSV(double in_h, double in_s, double in_v)
void COLOR4D::FromHSV( double aInH, double aInS, double aInV )
{ {
double hh, p, q, t, ff; double hh, p, q, t, ff;
long i; long i;
if(in_s <= 0.0) { // < is bogus, just shuts up warnings if( aInS <= 0.0 ) // < is bogus, just shuts up warnings
r = in_v; {
g = in_v; r = aInV;
b = in_v; g = aInV;
b = aInV;
return; return;
} }
hh = in_h;
if(hh >= 360.0) hh = 0.0; hh = aInH;
if( hh >= 360.0 )
hh = 0.0;
hh /= 60.0; hh /= 60.0;
i = (long)hh;
i = (long) hh;
ff = hh - i; ff = hh - i;
p = in_v * (1.0 - in_s);
q = in_v * (1.0 - (in_s * ff));
t = in_v * (1.0 - (in_s * (1.0 - ff)));
switch(i) { p = aInV * ( 1.0 - aInS );
q = aInV * ( 1.0 - ( aInS * ff ) );
t = aInV * ( 1.0 - ( aInS * ( 1.0 - ff ) ) );
switch (i)
{
case 0: case 0:
r = in_v; r = aInV;
g = t; g = t;
b = p; b = p;
break; break;
case 1: case 1:
r = q; r = q;
g = in_v; g = aInV;
b = p; b = p;
break; break;
case 2: case 2:
r = p; r = p;
g = in_v; g = aInV;
b = t; b = t;
break; break;
case 3: case 3:
r = p; r = p;
g = q; g = q;
b = in_v; b = aInV;
break; break;
case 4: case 4:
r = t; r = t;
g = p; g = p;
b = in_v; b = aInV;
break; break;
case 5: case 5:
default: default:
r = in_v; r = aInV;
g = p; g = p;
b = q; b = q;
break; break;
...@@ -151,11 +162,12 @@ void COLOR4D::FromHSV(double in_h, double in_s, double in_v) ...@@ -151,11 +162,12 @@ void COLOR4D::FromHSV(double in_h, double in_s, double in_v)
} }
COLOR4D& COLOR4D::Saturate( double aFactor ) COLOR4D& COLOR4D::Saturate( double aFactor )
{ {
double h, s, v; double h, s, v;
ToHSV(h, s, v); ToHSV( h, s, v );
FromHSV(h, aFactor, 1.0); FromHSV( h, aFactor, 1.0 );
return *this; return *this;
} }
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <gal/definitions.h> #include <gal/definitions.h>
using namespace KiGfx; using namespace KiGfx;
GAL::GAL() : GAL::GAL() :
...@@ -41,19 +40,21 @@ GAL::GAL() : ...@@ -41,19 +40,21 @@ GAL::GAL() :
SetFillColor( COLOR4D( 0.0, 0.0, 0.0, 0.0 ) ); SetFillColor( COLOR4D( 0.0, 0.0, 0.0, 0.0 ) );
SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) ); SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
SetZoomFactor( 1.0 ); SetZoomFactor( 1.0 );
SetDepthRange( VECTOR2D( -2048, 2047 ) ); SetDepthRange( VECTOR2D( GAL::MIN_DEPTH, GAL::MAX_DEPTH ) );
SetFlip( false, false ); SetFlip( false, false );
SetLineWidth( 1.0 ); SetLineWidth( 1.0 );
// Set grid defaults // Set grid defaults
SetGridVisibility( true ); SetGridVisibility( true );
SetGridStyle( GRID_STYLE_LINES ); SetGridStyle( GRID_STYLE_LINES );
SetGridOriginMarkerSize( 15 );
SetGridDrawThreshold( 10 );
SetCoarseGrid( 10 ); SetCoarseGrid( 10 );
SetGridLineWidth( 0.5 ); SetGridLineWidth( 0.5 );
// Initialize the cursor shape // Initialize the cursor shape
SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) ); SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
SetCursorSize( 20 ); SetCursorSize( 15 );
SetCursorEnabled( true ); SetCursorEnabled( true );
strokeFont.LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize ); strokeFont.LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize );
...@@ -112,7 +113,7 @@ void GAL::DrawGrid() ...@@ -112,7 +113,7 @@ void GAL::DrawGrid()
// Draw the origin marker // Draw the origin marker
double origSize = static_cast<double>( gridOriginMarkerSize ) / worldScale; double origSize = static_cast<double>( gridOriginMarkerSize ) / worldScale;
SetLayerDepth( 0.0 ); SetLayerDepth( GAL::GRID_DEPTH );
SetIsFill( false ); SetIsFill( false );
SetIsStroke( true ); SetIsStroke( true );
SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) ); SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
using namespace KiGfx; using namespace KiGfx;
CACHED_CONTAINER::CACHED_CONTAINER( unsigned int aSize ) : CACHED_CONTAINER::CACHED_CONTAINER( unsigned int aSize ) :
VERTEX_CONTAINER( aSize ) VERTEX_CONTAINER( aSize ), m_item( NULL )
{ {
// In the beginning there is only free space // In the beginning there is only free space
m_freeChunks.insert( Chunk( aSize, 0 ) ); m_freeChunks.insert( Chunk( aSize, 0 ) );
...@@ -51,11 +51,29 @@ CACHED_CONTAINER::CACHED_CONTAINER( unsigned int aSize ) : ...@@ -51,11 +51,29 @@ CACHED_CONTAINER::CACHED_CONTAINER( unsigned int aSize ) :
void CACHED_CONTAINER::SetItem( VERTEX_ITEM* aItem ) void CACHED_CONTAINER::SetItem( VERTEX_ITEM* aItem )
{ {
if( aItem == NULL ) wxASSERT( aItem != NULL );
{
m_item = aItem;
m_itemSize = m_item->GetSize();
m_chunkSize = m_itemSize;
if( m_itemSize == 0 )
m_items.insert( m_item ); // The item was not stored before
else
m_chunkOffset = m_item->GetOffset();
#if CACHED_CONTAINER_TEST > 1
wxLogDebug( wxT( "Adding/editing item 0x%08lx (size %d)" ), (long) m_item, m_itemSize );
#endif
}
void CACHED_CONTAINER::FinishItem()
{
wxASSERT( m_item != NULL ); wxASSERT( m_item != NULL );
wxASSERT( m_item->GetSize() == m_itemSize );
// Finishing the item // Finishing the previously edited item
if( m_itemSize < m_chunkSize ) if( m_itemSize < m_chunkSize )
{ {
// There is some not used but reserved memory left, so we should return it to the pool // There is some not used but reserved memory left, so we should return it to the pool
...@@ -64,22 +82,14 @@ void CACHED_CONTAINER::SetItem( VERTEX_ITEM* aItem ) ...@@ -64,22 +82,14 @@ void CACHED_CONTAINER::SetItem( VERTEX_ITEM* aItem )
// Add the not used memory back to the pool // Add the not used memory back to the pool
m_freeChunks.insert( Chunk( m_chunkSize - m_itemSize, itemOffset + m_itemSize ) ); m_freeChunks.insert( Chunk( m_chunkSize - m_itemSize, itemOffset + m_itemSize ) );
m_freeSpace += ( m_chunkSize - m_itemSize ); m_freeSpace += ( m_chunkSize - m_itemSize );
// mergeFreeChunks(); // mergeFreeChunks(); // veery slow and buggy
}
m_item = NULL;
} }
else
{
m_item = aItem;
m_itemSize = m_item->GetSize();
m_chunkSize = m_itemSize;
if( m_itemSize == 0 ) #if CACHED_CONTAINER_TEST > 1
m_items.insert( m_item ); // The item was not stored before wxLogDebug( wxT( "Finishing item 0x%08lx (size %d)" ), (long) m_item, m_itemSize );
else test();
m_chunkOffset = m_item->GetOffset(); m_item = NULL; // electric fence
} #endif
} }
...@@ -109,6 +119,7 @@ VERTEX* CACHED_CONTAINER::Allocate( unsigned int aSize ) ...@@ -109,6 +119,7 @@ VERTEX* CACHED_CONTAINER::Allocate( unsigned int aSize )
VERTEX* reserved = &m_vertices[m_chunkOffset + m_itemSize]; VERTEX* reserved = &m_vertices[m_chunkOffset + m_itemSize];
m_itemSize += aSize; m_itemSize += aSize;
// Now the item officially possesses the memory chunk
m_item->setSize( m_itemSize ); m_item->setSize( m_itemSize );
// The content has to be updated // The content has to be updated
...@@ -117,16 +128,40 @@ VERTEX* CACHED_CONTAINER::Allocate( unsigned int aSize ) ...@@ -117,16 +128,40 @@ VERTEX* CACHED_CONTAINER::Allocate( unsigned int aSize )
#if CACHED_CONTAINER_TEST > 1 #if CACHED_CONTAINER_TEST > 1
test(); test();
#endif #endif
#if CACHED_CONTAINER_TEST > 2
showFreeChunks();
showReservedChunks();
#endif
return reserved; return reserved;
} }
void CACHED_CONTAINER::Erase() void CACHED_CONTAINER::Delete( VERTEX_ITEM* aItem )
{ {
wxASSERT( m_item != NULL ); wxASSERT( aItem != NULL );
wxASSERT( m_items.find( aItem ) != m_items.end() );
int size = aItem->GetSize();
int offset = aItem->GetOffset();
freeItem( m_item ); #if CACHED_CONTAINER_TEST > 1
wxLogDebug( wxT( "Removing 0x%08lx (size %d offset %d)" ), (long) aItem, size, offset );
#endif
// Insert a free memory chunk entry in the place where item was stored
if( size > 0 )
{
m_freeChunks.insert( Chunk( size, offset ) );
m_freeSpace += size;
// Indicate that the item is not stored in the container anymore
aItem->setSize( 0 );
}
m_items.erase( aItem );
#if CACHED_CONTAINER_TEST > 1
test();
#endif
// Dynamic memory freeing, there is no point in holding // Dynamic memory freeing, there is no point in holding
// a large amount of memory when there is no use for it // a large amount of memory when there is no use for it
...@@ -176,10 +211,10 @@ VERTEX* CACHED_CONTAINER::GetVertices( const VERTEX_ITEM* aItem ) const ...@@ -176,10 +211,10 @@ VERTEX* CACHED_CONTAINER::GetVertices( const VERTEX_ITEM* aItem ) const
unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize ) unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize )
{ {
wxASSERT( aSize > 0 );
#if CACHED_CONTAINER_TEST > 2 #if CACHED_CONTAINER_TEST > 2
wxLogDebug( wxT( "Resize 0x%08x to %d" ), (int) m_item, aSize ); wxLogDebug( wxT( "Resize 0x%08lx from %d to %d" ), (long) m_item, m_itemSize, aSize );
showFreeChunks();
showReservedChunks();
#endif #endif
// Is there enough space to store vertices? // Is there enough space to store vertices?
...@@ -203,7 +238,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize ) ...@@ -203,7 +238,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize )
return UINT_MAX; return UINT_MAX;
} }
// Look for the free space of at least given size // Look for the free space chunk of at least given size
FreeChunkMap::iterator newChunk = m_freeChunks.lower_bound( aSize ); FreeChunkMap::iterator newChunk = m_freeChunks.lower_bound( aSize );
if( newChunk == m_freeChunks.end() ) if( newChunk == m_freeChunks.end() )
...@@ -240,6 +275,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize ) ...@@ -240,6 +275,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize )
m_itemSize * VertexSize ); m_itemSize * VertexSize );
// Free the space previously used by the chunk // Free the space previously used by the chunk
wxASSERT( m_itemSize > 0 );
m_freeChunks.insert( Chunk( m_itemSize, m_chunkOffset ) ); m_freeChunks.insert( Chunk( m_itemSize, m_chunkOffset ) );
m_freeSpace += m_itemSize; m_freeSpace += m_itemSize;
} }
...@@ -254,15 +290,10 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize ) ...@@ -254,15 +290,10 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize )
} }
m_freeSpace -= aSize; m_freeSpace -= aSize;
// mergeFreeChunks(); // mergeFreeChunks(); // veery slow and buggy
m_item->setOffset( chunkOffset ); m_item->setOffset( chunkOffset );
#if CACHED_CONTAINER_TEST > 2
showFreeChunks();
showReservedChunks();
#endif
return chunkOffset; return chunkOffset;
} }
...@@ -271,11 +302,10 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget ) ...@@ -271,11 +302,10 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget )
{ {
#if CACHED_CONTAINER_TEST > 0 #if CACHED_CONTAINER_TEST > 0
wxLogDebug( wxT( "Defragmenting" ) ); wxLogDebug( wxT( "Defragmenting" ) );
#endif
#ifdef __WXDEBUG__
prof_counter totalTime; prof_counter totalTime;
prof_start( &totalTime, false ); prof_start( &totalTime, false );
#endif /* __WXDEBUG__ */ #endif
if( aTarget == NULL ) if( aTarget == NULL )
{ {
...@@ -313,14 +343,15 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget ) ...@@ -313,14 +343,15 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget )
// Now there is only one big chunk of free memory // Now there is only one big chunk of free memory
m_freeChunks.clear(); m_freeChunks.clear();
wxASSERT( m_freeSpace > 0 );
m_freeChunks.insert( Chunk( m_freeSpace, m_currentSize - m_freeSpace ) ); m_freeChunks.insert( Chunk( m_freeSpace, m_currentSize - m_freeSpace ) );
#ifdef __WXDEBUG__ #if CACHED_CONTAINER_TEST > 0
prof_end( &totalTime ); prof_end( &totalTime );
wxLogDebug( wxT( "Defragmented the container storing %d vertices / %.1f ms" ), wxLogDebug( wxT( "Defragmented the container storing %d vertices / %.1f ms" ),
m_currentSize - m_freeSpace, (double) totalTime.value / 1000.0 ); m_currentSize - m_freeSpace, (double) totalTime.value / 1000.0 );
#endif /* __WXDEBUG__ */ #endif
return true; return true;
} }
...@@ -331,10 +362,10 @@ void CACHED_CONTAINER::mergeFreeChunks() ...@@ -331,10 +362,10 @@ void CACHED_CONTAINER::mergeFreeChunks()
if( m_freeChunks.size() <= 1 ) // There are no chunks that can be merged if( m_freeChunks.size() <= 1 ) // There are no chunks that can be merged
return; return;
#ifdef __WXDEBUG__ #ifdef CACHED_CONTAINER_TEST > 0
prof_counter totalTime; prof_counter totalTime;
prof_start( &totalTime, false ); prof_start( &totalTime, false );
#endif /* __WXDEBUG__ */ #endif
// Reversed free chunks map - this one stores chunk size with its offset as the key // Reversed free chunks map - this one stores chunk size with its offset as the key
std::list<Chunk> freeChunks; std::list<Chunk> freeChunks;
...@@ -375,11 +406,11 @@ void CACHED_CONTAINER::mergeFreeChunks() ...@@ -375,11 +406,11 @@ void CACHED_CONTAINER::mergeFreeChunks()
// Add the last one // Add the last one
m_freeChunks.insert( std::make_pair( size, offset ) ); m_freeChunks.insert( std::make_pair( size, offset ) );
#ifdef __WXDEBUG__ #ifdef CACHED_CONTAINER_TEST > 0
prof_end( &totalTime ); prof_end( &totalTime );
wxLogDebug( wxT( "Merged free chunks / %.1f ms" ), (double) totalTime.value / 1000.0 ); wxLogDebug( wxT( "Merged free chunks / %.1f ms" ), (double) totalTime.value / 1000.0 );
#endif /* __WXDEBUG__ */ #endif
test(); test();
} }
...@@ -387,6 +418,8 @@ void CACHED_CONTAINER::mergeFreeChunks() ...@@ -387,6 +418,8 @@ void CACHED_CONTAINER::mergeFreeChunks()
bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize ) bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )
{ {
wxASSERT( aNewSize != m_currentSize );
#if CACHED_CONTAINER_TEST > 0 #if CACHED_CONTAINER_TEST > 0
wxLogDebug( wxT( "Resizing container from %d to %d" ), m_currentSize, aNewSize ); wxLogDebug( wxT( "Resizing container from %d to %d" ), m_currentSize, aNewSize );
#endif #endif
...@@ -413,6 +446,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize ) ...@@ -413,6 +446,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )
// We have to correct freeChunks after defragmentation // We have to correct freeChunks after defragmentation
m_freeChunks.clear(); m_freeChunks.clear();
wxASSERT( aNewSize - reservedSpace() > 0 );
m_freeChunks.insert( Chunk( aNewSize - reservedSpace(), reservedSpace() ) ); m_freeChunks.insert( Chunk( aNewSize - reservedSpace(), reservedSpace() ) );
} }
else else
...@@ -439,21 +473,6 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize ) ...@@ -439,21 +473,6 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )
} }
void CACHED_CONTAINER::freeItem( VERTEX_ITEM* aItem )
{
int size = aItem->GetSize();
int offset = aItem->GetOffset();
// Insert a free memory chunk entry in the place where item was stored
m_freeChunks.insert( Chunk( size, offset ) );
m_freeSpace += size;
m_items.erase( aItem );
// Indicate that the item is not stored in the container anymore
aItem->setSize( 0 );
}
unsigned int CACHED_CONTAINER::getPowerOf2( unsigned int aNumber ) const unsigned int CACHED_CONTAINER::getPowerOf2( unsigned int aNumber ) const
{ {
unsigned int power = 1; unsigned int power = 1;
...@@ -476,6 +495,7 @@ void CACHED_CONTAINER::showFreeChunks() ...@@ -476,6 +495,7 @@ void CACHED_CONTAINER::showFreeChunks()
{ {
unsigned int offset = getChunkOffset( *it ); unsigned int offset = getChunkOffset( *it );
unsigned int size = getChunkSize( *it ); unsigned int size = getChunkSize( *it );
wxASSERT( size > 0 );
wxLogDebug( wxT( "[0x%08x-0x%08x] (size %d)" ), wxLogDebug( wxT( "[0x%08x-0x%08x] (size %d)" ),
offset, offset + size - 1, size ); offset, offset + size - 1, size );
...@@ -494,9 +514,10 @@ void CACHED_CONTAINER::showReservedChunks() ...@@ -494,9 +514,10 @@ void CACHED_CONTAINER::showReservedChunks()
VERTEX_ITEM* item = *it; VERTEX_ITEM* item = *it;
unsigned int offset = item->GetOffset(); unsigned int offset = item->GetOffset();
unsigned int size = item->GetSize(); unsigned int size = item->GetSize();
wxASSERT( size > 0 );
wxLogDebug( wxT( "[0x%08x-0x%08x] @ 0x%08x (size %d)" ), wxLogDebug( wxT( "[0x%08x-0x%08x] @ 0x%08lx (size %d)" ),
offset, offset + size - 1, (int) item, size ); offset, offset + size - 1, (long) item, size );
} }
} }
......
...@@ -82,11 +82,6 @@ VERTEX* NONCACHED_CONTAINER::Allocate( unsigned int aSize ) ...@@ -82,11 +82,6 @@ VERTEX* NONCACHED_CONTAINER::Allocate( unsigned int aSize )
} }
void NONCACHED_CONTAINER::Erase()
{
}
void NONCACHED_CONTAINER::Clear() void NONCACHED_CONTAINER::Clear()
{ {
m_freePtr = 0; m_freePtr = 0;
......
...@@ -233,8 +233,11 @@ void OPENGL_GAL::DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoin ...@@ -233,8 +233,11 @@ void OPENGL_GAL::DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoin
drawLineQuad( aStartPoint, aEndPoint ); drawLineQuad( aStartPoint, aEndPoint );
// Line caps // Line caps
if( lineWidth > 1.0 )
{
drawFilledSemiCircle( aStartPoint, lineWidth / 2, lineAngle + M_PI / 2 ); drawFilledSemiCircle( aStartPoint, lineWidth / 2, lineAngle + M_PI / 2 );
drawFilledSemiCircle( aEndPoint, lineWidth / 2, lineAngle - M_PI / 2 ); drawFilledSemiCircle( aEndPoint, lineWidth / 2, lineAngle - M_PI / 2 );
}
} }
...@@ -638,6 +641,7 @@ int OPENGL_GAL::BeginGroup() ...@@ -638,6 +641,7 @@ int OPENGL_GAL::BeginGroup()
void OPENGL_GAL::EndGroup() void OPENGL_GAL::EndGroup()
{ {
cachedManager.FinishItem();
isGrouping = false; isGrouping = false;
} }
...@@ -662,6 +666,7 @@ void OPENGL_GAL::ChangeGroupDepth( int aGroupNumber, int aDepth ) ...@@ -662,6 +666,7 @@ void OPENGL_GAL::ChangeGroupDepth( int aGroupNumber, int aDepth )
void OPENGL_GAL::DeleteGroup( int aGroupNumber ) void OPENGL_GAL::DeleteGroup( int aGroupNumber )
{ {
// Frees memory in the container as well
groups.erase( aGroupNumber ); groups.erase( aGroupNumber );
} }
......
...@@ -88,10 +88,15 @@ void VERTEX_MANAGER::SetItem( VERTEX_ITEM& aItem ) const ...@@ -88,10 +88,15 @@ void VERTEX_MANAGER::SetItem( VERTEX_ITEM& aItem ) const
} }
void VERTEX_MANAGER::FinishItem() const
{
m_container->FinishItem();
}
void VERTEX_MANAGER::FreeItem( VERTEX_ITEM& aItem ) const void VERTEX_MANAGER::FreeItem( VERTEX_ITEM& aItem ) const
{ {
m_container->SetItem( &aItem ); m_container->Delete( &aItem );
m_container->Erase();
} }
......
...@@ -1488,12 +1488,12 @@ bool ColorIsLight( EDA_COLOR_T aColor ) ...@@ -1488,12 +1488,12 @@ bool ColorIsLight( EDA_COLOR_T aColor )
EDA_COLOR_T ColorFindNearest( const wxColour &aColor ) EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
{ {
EDA_COLOR_T candidate = BLACK; return ColorFindNearest( aColor.Red(), aColor.Green(), aColor.Blue() );
}
// These are ints because we will subtract them later EDA_COLOR_T ColorFindNearest( int aR, int aG, int aB )
int r = aColor.Red(); {
int g = aColor.Green(); EDA_COLOR_T candidate = BLACK;
int b = aColor.Blue();
/* Find the 'nearest' color in the palette. This is fun. There is /* Find the 'nearest' color in the palette. This is fun. There is
a gazilion of metrics for the color space and no one of the a gazilion of metrics for the color space and no one of the
...@@ -1511,11 +1511,11 @@ EDA_COLOR_T ColorFindNearest( const wxColour &aColor ) ...@@ -1511,11 +1511,11 @@ EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) ) for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
{ {
const StructColors &c = g_ColorRefs[trying]; const StructColors &c = g_ColorRefs[trying];
int distance = (r - c.m_Red) * (r - c.m_Red) + int distance = (aR - c.m_Red) * (aR - c.m_Red) +
(g - c.m_Green) * (g - c.m_Green) + (aG - c.m_Green) * (aG - c.m_Green) +
(b - c.m_Blue) * (b - c.m_Blue); (aB - c.m_Blue) * (aB - c.m_Blue);
if( distance < nearest_distance && c.m_Red >= r && if( distance < nearest_distance && c.m_Red >= aR &&
c.m_Green >= g && c.m_Blue >= b ) c.m_Green >= aG && c.m_Blue >= aB )
{ {
nearest_distance = distance; nearest_distance = distance;
candidate = trying; candidate = trying;
......
...@@ -39,6 +39,7 @@ RENDER_SETTINGS::RENDER_SETTINGS() ...@@ -39,6 +39,7 @@ RENDER_SETTINGS::RENDER_SETTINGS()
m_hiContrastEnabled = false; m_hiContrastEnabled = false;
m_hiContrastFactor = 0.2; m_hiContrastFactor = 0.2;
m_outlineWidth = 1; m_outlineWidth = 1;
m_worksheetLineWidth = 100000;
// Store the predefined colors used in KiCad in format used by GAL // Store the predefined colors used in KiCad in format used by GAL
for( int i = 0; i < NBCOLORS; i++ ) for( int i = 0; i < NBCOLORS; i++ )
...@@ -64,14 +65,13 @@ void RENDER_SETTINGS::update() ...@@ -64,14 +65,13 @@ void RENDER_SETTINGS::update()
PAINTER::PAINTER( GAL* aGal ) : PAINTER::PAINTER( GAL* aGal ) :
m_gal( aGal ), m_settings( NULL ), m_brightenedColor( 0.0, 1.0, 0.0, 0.9 ) m_gal( aGal ), m_brightenedColor( 0.0, 1.0, 0.0, 0.9 )
{ {
} }
PAINTER::~PAINTER() PAINTER::~PAINTER()
{ {
delete m_settings;
} }
...@@ -91,7 +91,7 @@ void PAINTER::DrawBrightened( const VIEW_ITEM* aItem ) ...@@ -91,7 +91,7 @@ void PAINTER::DrawBrightened( const VIEW_ITEM* aItem )
m_gal->PushDepth(); m_gal->PushDepth();
m_gal->SetLayerDepth( -1.0 ); m_gal->SetLayerDepth( -1.0 );
// Draw semitransparent box that marks items as brightened // Draw an outline that marks items as brightened
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetLineWidth( 100000.0 ); m_gal->SetLineWidth( 100000.0 );
m_gal->SetStrokeColor( m_brightenedColor ); m_gal->SetStrokeColor( m_brightenedColor );
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
else if( type == wxEVT_COMMAND_MENU_SELECTED ) else if( type == wxEVT_COMMAND_MENU_SELECTED )
evt = TOOL_EVENT( TC_Command, TA_ContextMenuChoice, aEvent.GetId() ); evt = TOOL_EVENT( TC_Command, TA_ContextMenuChoice, aEvent.GetId() );
if(m_menu->m_tool) if( m_menu->m_tool )
m_menu->m_tool->GetManager()->ProcessEvent( evt ); m_menu->m_tool->GetManager()->ProcessEvent( evt );
} }
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
using boost::optional; using boost::optional;
const wxEventType TOOL_DISPATCHER::EVT_REFRESH_MOUSE = wxNewEventType();
struct TOOL_DISPATCHER::ButtonState struct TOOL_DISPATCHER::ButtonState
{ {
ButtonState( TOOL_MouseButtons aButton, const wxEventType& aDownEvent, ButtonState( TOOL_MouseButtons aButton, const wxEventType& aDownEvent,
...@@ -119,14 +121,16 @@ int TOOL_DISPATCHER::decodeModifiers( const wxKeyboardState* aState ) const ...@@ -119,14 +121,16 @@ int TOOL_DISPATCHER::decodeModifiers( const wxKeyboardState* aState ) const
return mods; return mods;
} }
wxPoint TOOL_DISPATCHER::getCurrentMousePos()
wxPoint TOOL_DISPATCHER::getCurrentMousePos() const
{ {
wxPoint msp = wxGetMousePosition() ; wxPoint msp = wxGetMousePosition();
wxPoint winp = m_editFrame->GetGalCanvas()->GetScreenPosition(); wxPoint winp = m_editFrame->GetGalCanvas()->GetScreenPosition();
return wxPoint(msp.x - winp.x, msp.y - winp.y); return wxPoint( msp.x - winp.x, msp.y - winp.y );
} }
bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMotion ) bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMotion )
{ {
ButtonState* st = m_buttons[aIndex]; ButtonState* st = m_buttons[aIndex];
...@@ -157,7 +161,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti ...@@ -157,7 +161,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
{ {
wxLongLong t = wxGetLocalTimeMillis(); wxLongLong t = wxGetLocalTimeMillis();
if( t - st->downTimestamp < DragTimeThreshold || if( t - st->downTimestamp < DragTimeThreshold &&
st->dragMaxDelta < DragDistanceThreshold ) st->dragMaxDelta < DragDistanceThreshold )
isClick = true; isClick = true;
else else
...@@ -181,7 +185,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti ...@@ -181,7 +185,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
wxLongLong t = wxGetLocalTimeMillis(); wxLongLong t = wxGetLocalTimeMillis();
if( t - st->downTimestamp > DragTimeThreshold && st->dragMaxDelta > DragDistanceThreshold ) if( t - st->downTimestamp > DragTimeThreshold || st->dragMaxDelta > DragDistanceThreshold )
{ {
evt = TOOL_EVENT( TC_Mouse, TA_MouseDrag, args ); evt = TOOL_EVENT( TC_Mouse, TA_MouseDrag, args );
evt->SetMouseDragOrigin( st->dragOrigin ); evt->SetMouseDragOrigin( st->dragOrigin );
...@@ -213,13 +217,11 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) ...@@ -213,13 +217,11 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
if( type == wxEVT_MOTION || type == wxEVT_MOUSEWHEEL || if( type == wxEVT_MOTION || type == wxEVT_MOUSEWHEEL ||
type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP || type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP ||
type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP || type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP ||
type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP ) type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP ||
type == EVT_REFRESH_MOUSE )
{ {
wxMouseEvent* me = static_cast<wxMouseEvent*>( &aEvent );
pos = getView()->ToWorld ( getCurrentMousePos() ); pos = getView()->ToWorld ( getCurrentMousePos() );
if( pos != m_lastMousePos ) if( pos != m_lastMousePos || type == EVT_REFRESH_MOUSE )
{ {
motion = true; motion = true;
m_lastMousePos = pos; m_lastMousePos = pos;
...@@ -262,7 +264,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) ...@@ -262,7 +264,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
} }
void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent &aEvent ) void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent& aEvent )
{ {
bool activateTool = false; bool activateTool = false;
std::string toolName; std::string toolName;
......
...@@ -82,13 +82,25 @@ struct TOOL_MANAGER::TOOL_STATE ...@@ -82,13 +82,25 @@ struct TOOL_MANAGER::TOOL_STATE
TOOL_MANAGER::TOOL_MANAGER() : TOOL_MANAGER::TOOL_MANAGER() :
m_model (NULL), m_model( NULL ), m_view( NULL )
m_view (NULL)
{ {
} }
TOOL_MANAGER::~TOOL_MANAGER()
{
std::map<TOOL_BASE*, TOOL_STATE*>::iterator it, it_end;
for( it = m_toolState.begin(), it_end = m_toolState.end(); it != it_end; ++it )
{
delete it->second->cofunc; // delete cofunction
delete it->second; // delete TOOL_STATE
delete it->first; // delete the tool itself
}
}
void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool ) void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
{ {
TOOL_STATE* st = new TOOL_STATE; TOOL_STATE* st = new TOOL_STATE;
...@@ -282,13 +294,13 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent ) ...@@ -282,13 +294,13 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
if( st->contextMenuTrigger != CMENU_OFF ) if( st->contextMenuTrigger != CMENU_OFF )
{ {
if(st->contextMenuTrigger == CMENU_BUTTON && !aEvent.IsClick( MB_Right ) ) if( st->contextMenuTrigger == CMENU_BUTTON && !aEvent.IsClick( MB_Right ) )
break; break;
st->pendingWait = true; st->pendingWait = true;
st->waitEvents = TOOL_EVENT( TC_Any, TA_Any ); st->waitEvents = TOOL_EVENT( TC_Any, TA_Any );
if(st->contextMenuTrigger == CMENU_NOW) if( st->contextMenuTrigger == CMENU_NOW )
st->contextMenuTrigger = CMENU_OFF; st->contextMenuTrigger = CMENU_OFF;
GetEditFrame()->PopupMenu( st->contextMenu->GetMenu() ); GetEditFrame()->PopupMenu( st->contextMenu->GetMenu() );
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
using namespace KiGfx; using namespace KiGfx;
VIEW::VIEW( bool aIsDynamic ) : VIEW::VIEW( bool aIsDynamic ) :
m_enableOrderModifier( false ), m_enableOrderModifier( true ),
m_scale( 1.0 ), m_scale( 1.0 ),
m_painter( NULL ), m_painter( NULL ),
m_gal( NULL ), m_gal( NULL ),
...@@ -80,7 +80,6 @@ void VIEW::AddLayer( int aLayer, bool aDisplayOnly ) ...@@ -80,7 +80,6 @@ void VIEW::AddLayer( int aLayer, bool aDisplayOnly )
m_layers[aLayer].items = new VIEW_RTREE(); m_layers[aLayer].items = new VIEW_RTREE();
m_layers[aLayer].renderingOrder = aLayer; m_layers[aLayer].renderingOrder = aLayer;
m_layers[aLayer].enabled = true; m_layers[aLayer].enabled = true;
m_layers[aLayer].isDirty = false;
m_layers[aLayer].displayOnly = aDisplayOnly; m_layers[aLayer].displayOnly = aDisplayOnly;
m_layers[aLayer].target = TARGET_CACHED; m_layers[aLayer].target = TARGET_CACHED;
} }
...@@ -100,7 +99,7 @@ void VIEW::Add( VIEW_ITEM* aItem ) ...@@ -100,7 +99,7 @@ void VIEW::Add( VIEW_ITEM* aItem )
{ {
VIEW_LAYER& l = m_layers[layers[i]]; VIEW_LAYER& l = m_layers[layers[i]];
l.items->Insert( aItem ); l.items->Insert( aItem );
l.isDirty = true; MarkTargetDirty( l.target );
} }
if( m_dynamic ) if( m_dynamic )
...@@ -120,7 +119,6 @@ void VIEW::Remove( VIEW_ITEM* aItem ) ...@@ -120,7 +119,6 @@ void VIEW::Remove( VIEW_ITEM* aItem )
{ {
VIEW_LAYER& l = m_layers[layers[i]]; VIEW_LAYER& l = m_layers[layers[i]];
l.items->Remove( aItem ); l.items->Remove( aItem );
l.isDirty = true;
} }
} }
...@@ -370,7 +368,7 @@ struct VIEW::updateItemsColor ...@@ -370,7 +368,7 @@ struct VIEW::updateItemsColor
void operator()( VIEW_ITEM* aItem ) void operator()( VIEW_ITEM* aItem )
{ {
// Obtain the color that should be used for coloring the item // Obtain the color that should be used for coloring the item
const COLOR4D color = painter->GetColor( aItem, layer ); const COLOR4D color = painter->GetSettings()->GetColor( aItem, layer );
int group = aItem->getGroup( layer ); int group = aItem->getGroup( layer );
if( group >= 0 ) if( group >= 0 )
...@@ -415,6 +413,8 @@ void VIEW::UpdateAllLayersColor() ...@@ -415,6 +413,8 @@ void VIEW::UpdateAllLayersColor()
updateItemsColor visitor( l->id, m_painter, m_gal ); updateItemsColor visitor( l->id, m_painter, m_gal );
l->items->Query( r, visitor ); l->items->Query( r, visitor );
} }
MarkDirty();
} }
...@@ -525,6 +525,8 @@ void VIEW::UpdateAllLayersOrder() ...@@ -525,6 +525,8 @@ void VIEW::UpdateAllLayersOrder()
{ {
ChangeLayerDepth( l.first, l.second.renderingOrder ); ChangeLayerDepth( l.first, l.second.renderingOrder );
} }
MarkDirty();
} }
...@@ -564,8 +566,6 @@ void VIEW::redrawRect( const BOX2I& aRect ) ...@@ -564,8 +566,6 @@ void VIEW::redrawRect( const BOX2I& aRect )
m_gal->SetLayerDepth( l->renderingOrder ); m_gal->SetLayerDepth( l->renderingOrder );
l->items->Query( aRect, drawFunc ); l->items->Query( aRect, drawFunc );
} }
l->isDirty = false;
} }
} }
...@@ -586,7 +586,7 @@ void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate ) const ...@@ -586,7 +586,7 @@ void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate ) const
group = m_gal->BeginGroup(); group = m_gal->BeginGroup();
aItem->setGroup( aLayer, group ); aItem->setGroup( aLayer, group );
if( !m_painter->Draw( aItem, aLayer ) ) if( !m_painter->Draw( aItem, aLayer ) )
aItem->ViewDraw( aLayer, m_gal, BOX2I() ); // Alternative drawing method aItem->ViewDraw( aLayer, m_gal ); // Alternative drawing method
m_gal->EndGroup(); m_gal->EndGroup();
} }
} }
...@@ -594,7 +594,7 @@ void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate ) const ...@@ -594,7 +594,7 @@ void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate ) const
{ {
// Immediate mode // Immediate mode
if( !m_painter->Draw( aItem, aLayer ) ) if( !m_painter->Draw( aItem, aLayer ) )
aItem->ViewDraw( aLayer, m_gal, BOX2I() ); // Alternative drawing method aItem->ViewDraw( aLayer, m_gal ); // Alternative drawing method
} }
// Draws a bright contour around the item // Draws a bright contour around the item
...@@ -672,7 +672,8 @@ struct VIEW::recacheLayer ...@@ -672,7 +672,8 @@ struct VIEW::recacheLayer
{ {
int group = gal->BeginGroup(); int group = gal->BeginGroup();
aItem->setGroup( layer, group ); aItem->setGroup( layer, group );
view->m_painter->Draw( static_cast<EDA_ITEM*>( aItem ), layer ); if( !view->m_painter->Draw( aItem, layer ) )
aItem->ViewDraw( layer, gal ); // Alternative drawing method
gal->EndGroup(); gal->EndGroup();
} }
else else
...@@ -709,7 +710,7 @@ void VIEW::Clear() ...@@ -709,7 +710,7 @@ void VIEW::Clear()
} }
void VIEW::PrepareTargets() void VIEW::ClearTargets()
{ {
if( IsTargetDirty( TARGET_CACHED ) || IsTargetDirty( TARGET_NONCACHED ) ) if( IsTargetDirty( TARGET_CACHED ) || IsTargetDirty( TARGET_NONCACHED ) )
{ {
...@@ -810,8 +811,7 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags ) ...@@ -810,8 +811,7 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
} }
// Mark those layers as dirty, so the VIEW will be refreshed // Mark those layers as dirty, so the VIEW will be refreshed
m_layers[layerId].isDirty = true; MarkTargetDirty( m_layers[layerId].target );
MarkTargetDirty( m_layers[layerId].target ); // TODO remove?
} }
} }
...@@ -836,7 +836,7 @@ void VIEW::updateItemColor( VIEW_ITEM* aItem, int aLayer ) ...@@ -836,7 +836,7 @@ void VIEW::updateItemColor( VIEW_ITEM* aItem, int aLayer )
wxASSERT( (unsigned) aLayer < m_layers.size() ); wxASSERT( (unsigned) aLayer < m_layers.size() );
// Obtain the color that should be used for coloring the item on the specific layerId // Obtain the color that should be used for coloring the item on the specific layerId
const COLOR4D color = m_painter->GetColor( aItem, aLayer ); const COLOR4D color = m_painter->GetSettings()->GetColor( aItem, aLayer );
int group = aItem->getGroup( aLayer ); int group = aItem->getGroup( aLayer );
// Change the color, only if it has group assigned // Change the color, only if it has group assigned
...@@ -871,7 +871,7 @@ void VIEW::updateBbox( VIEW_ITEM* aItem ) ...@@ -871,7 +871,7 @@ void VIEW::updateBbox( VIEW_ITEM* aItem )
VIEW_LAYER& l = m_layers[layers[i]]; VIEW_LAYER& l = m_layers[layers[i]];
l.items->Remove( aItem ); l.items->Remove( aItem );
l.items->Insert( aItem ); l.items->Insert( aItem );
l.isDirty = true; MarkTargetDirty( l.target );
} }
} }
...@@ -915,7 +915,7 @@ void VIEW::RecacheAllItems( bool aImmediately ) ...@@ -915,7 +915,7 @@ void VIEW::RecacheAllItems( bool aImmediately )
m_gal->SetLayerDepth( l->renderingOrder ); m_gal->SetLayerDepth( l->renderingOrder );
recacheLayer visitor( this, m_gal, l->id, aImmediately ); recacheLayer visitor( this, m_gal, l->id, aImmediately );
l->items->Query( r, visitor ); l->items->Query( r, visitor );
l->isDirty = true; MarkTargetDirty( l->target );
} }
} }
...@@ -936,12 +936,5 @@ bool VIEW::IsTargetDirty( int aTarget ) const ...@@ -936,12 +936,5 @@ bool VIEW::IsTargetDirty( int aTarget ) const
if( m_dirtyTargets[aTarget] ) if( m_dirtyTargets[aTarget] )
return true; return true;
// Check if any of layers belonging to the target is dirty
BOOST_FOREACH( VIEW_LAYER* l, m_orderedLayers )
{
if( l->target == aTarget && l->isDirty )
return true;
}
return false; return false;
} }
...@@ -70,6 +70,7 @@ void VIEW_GROUP::Clear() ...@@ -70,6 +70,7 @@ void VIEW_GROUP::Clear()
m_items.clear(); m_items.clear();
} }
void VIEW_GROUP::FreeItems() void VIEW_GROUP::FreeItems()
{ {
BOOST_FOREACH( VIEW_ITEM* item, m_items ) BOOST_FOREACH( VIEW_ITEM* item, m_items )
...@@ -79,6 +80,7 @@ void VIEW_GROUP::FreeItems() ...@@ -79,6 +80,7 @@ void VIEW_GROUP::FreeItems()
m_items.clear(); m_items.clear();
} }
unsigned int VIEW_GROUP::GetSize() const unsigned int VIEW_GROUP::GetSize() const
{ {
return m_items.size(); return m_items.size();
...@@ -93,7 +95,7 @@ const BOX2I VIEW_GROUP::ViewBBox() const ...@@ -93,7 +95,7 @@ const BOX2I VIEW_GROUP::ViewBBox() const
} }
void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal, const BOX2I& aVisibleArea ) const void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal ) const
{ {
PAINTER* painter = m_view->GetPainter(); PAINTER* painter = m_view->GetPainter();
...@@ -111,7 +113,7 @@ void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal, const BOX2I& aVisibleArea ) co ...@@ -111,7 +113,7 @@ void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal, const BOX2I& aVisibleArea ) co
aGal->SetLayerDepth( m_view->GetLayerOrder( layers[i] ) ); aGal->SetLayerDepth( m_view->GetLayerOrder( layers[i] ) );
if( !painter->Draw( item, layers[i] ) ) if( !painter->Draw( item, layers[i] ) )
item->ViewDraw( layers[i], aGal, aVisibleArea ); // Alternative drawing method item->ViewDraw( layers[i], aGal ); // Alternative drawing method
} }
} }
} }
......
...@@ -48,17 +48,12 @@ void VIEW_ITEM::ViewSetVisible( bool aIsVisible ) ...@@ -48,17 +48,12 @@ void VIEW_ITEM::ViewSetVisible( bool aIsVisible )
} }
void VIEW_ITEM::ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw ) void VIEW_ITEM::ViewUpdate( int aUpdateFlags )
{ {
if( !m_view ) if( !m_view )
return; return;
m_view->invalidateItem( this, aUpdateFlags ); m_view->invalidateItem( this, aUpdateFlags );
if( aForceImmediateRedraw )
{
m_view->Redraw();
}
} }
...@@ -142,9 +137,3 @@ void VIEW_ITEM::deleteGroups() ...@@ -142,9 +137,3 @@ void VIEW_ITEM::deleteGroups()
m_groups = NULL; m_groups = NULL;
m_groupsSize = 0; m_groupsSize = 0;
} }
bool VIEW_ITEM::storesGroups() const
{
return ( m_groupsSize > 0 );
}
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <view/view.h> #include <view/view.h>
#include <view/wx_view_controls.h> #include <view/wx_view_controls.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <tool/tool_dispatcher.h>
using namespace KiGfx; using namespace KiGfx;
...@@ -196,7 +197,10 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent ) ...@@ -196,7 +197,10 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
dir = m_view->ToWorld( dir, false ); dir = m_view->ToWorld( dir, false );
m_view->SetCenter( m_view->GetCenter() + dir * m_autoPanSpeed ); m_view->SetCenter( m_view->GetCenter() + dir * m_autoPanSpeed );
m_view->MakeDirty();
// Notify tools that the cursor position has changed in the world coordinates
wxCommandEvent moveEvent( TOOL_DISPATCHER::EVT_REFRESH_MOUSE );
wxPostEvent( m_parentPanel, moveEvent );
} }
break; break;
......
...@@ -101,7 +101,7 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi ...@@ -101,7 +101,7 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi
} }
wxString EDA_DRAW_FRAME::GetScreenDesc() wxString EDA_DRAW_FRAME::GetScreenDesc() const
{ {
// Virtual function. In basic class, returns // Virtual function. In basic class, returns
// an empty string. // an empty string.
......
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file worksheet_item.cpp
* @brief Class that handles properties and drawing of worksheet layout.
*/
#include <worksheet_item.h>
#include <worksheet_shape_builder.h>
#include <gal/graphics_abstraction_layer.h>
#include <painter.h>
#include <layers_id_colors_and_visibility.h>
#include <boost/foreach.hpp>
using namespace KiGfx;
WORKSHEET_ITEM::WORKSHEET_ITEM( const std::string& aFileName, const std::string& aSheetName,
const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) :
EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type
m_fileName( aFileName ), m_sheetName( aSheetName ),
m_titleBlock( aTitleBlock ), m_pageInfo( aPageInfo ), m_sheetNumber( 1 ), m_sheetCount( 1 ) {}
void WORKSHEET_ITEM::SetPageInfo( const PAGE_INFO* aPageInfo )
{
m_pageInfo = aPageInfo;
ViewUpdate( GEOMETRY );
}
void WORKSHEET_ITEM::SetTitleBlock( const TITLE_BLOCK* aTitleBlock )
{
m_titleBlock = aTitleBlock;
ViewUpdate( GEOMETRY );
}
const BOX2I WORKSHEET_ITEM::ViewBBox() const
{
BOX2I bbox;
if( m_pageInfo != NULL )
{
bbox.SetOrigin( VECTOR2I( 0, 0 ) );
bbox.SetEnd( VECTOR2I( m_pageInfo->GetWidthMils() * 25400,
m_pageInfo->GetHeightMils() * 25400 ) );
}
else
{
bbox.SetMaximum();
}
return bbox;
}
void WORKSHEET_ITEM::ViewDraw( int aLayer, GAL* aGal ) const
{
RENDER_SETTINGS* settings = m_view->GetPainter()->GetSettings();
wxString fileName( m_fileName );
wxString sheetName( m_sheetName );
WS_DRAW_ITEM_LIST drawList;
drawList.SetPenSize( settings->GetWorksheetLineWidth() );
// Sorry, but I don't get this multi #ifdef from include/convert_to_biu.h, so here goes a magic
// number. IU_PER_MILS should be 25400 (as in a different compilation unit), but somehow
// it equals 1 in this case..
drawList.SetMilsToIUfactor( 25400 /* IU_PER_MILS */ );
drawList.SetSheetNumber( m_sheetNumber );
drawList.SetSheetCount( m_sheetCount );
drawList.SetFileName( fileName );
drawList.SetSheetName( sheetName );
COLOR4D color = settings->GetColor( this, aLayer );
EDA_COLOR_T edaColor = ColorFindNearest( color.r * 255, color.g * 255, color.b * 255 );
drawList.BuildWorkSheetGraphicList( *m_pageInfo, *m_titleBlock, edaColor, edaColor );
// Draw gray line that outlines the sheet size
drawBorder( aGal );
// Draw all the components that make the page layout
WS_DRAW_ITEM_BASE* item = drawList.GetFirst();
while( item )
{
switch( item->GetType() )
{
case WS_DRAW_ITEM_BASE::wsg_line:
draw( static_cast<const WS_DRAW_ITEM_LINE*>( item ), aGal );
break;
case WS_DRAW_ITEM_BASE::wsg_rect:
draw( static_cast<const WS_DRAW_ITEM_RECT*>( item ), aGal );
break;
case WS_DRAW_ITEM_BASE::wsg_poly:
draw( static_cast<const WS_DRAW_ITEM_POLYGON*>( item ), aGal );
break;
case WS_DRAW_ITEM_BASE::wsg_text:
draw( static_cast<const WS_DRAW_ITEM_TEXT*>( item ), aGal );
break;
}
item = drawList.GetNext();
}
}
void WORKSHEET_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 1;
aLayers[0] = ITEM_GAL_LAYER( WORKSHEET );
}
void WORKSHEET_ITEM::draw( const WS_DRAW_ITEM_LINE* aItem, GAL* aGal ) const
{
aGal->SetIsStroke( true );
aGal->SetIsFill( false );
aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) );
aGal->SetLineWidth( aItem->GetPenWidth() );
aGal->DrawLine( VECTOR2D( aItem->GetStart() ), VECTOR2D( aItem->GetEnd() ) );
}
void WORKSHEET_ITEM::draw( const WS_DRAW_ITEM_RECT* aItem, GAL* aGal ) const
{
aGal->SetIsStroke( true );
aGal->SetIsFill( false );
aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) );
aGal->SetLineWidth( aItem->GetPenWidth() );
aGal->DrawRectangle( VECTOR2D( aItem->GetStart() ), VECTOR2D( aItem->GetEnd() ) );
}
void WORKSHEET_ITEM::draw( const WS_DRAW_ITEM_POLYGON* aItem, GAL* aGal ) const
{
std::deque<VECTOR2D> corners;
BOOST_FOREACH( wxPoint point, aItem->m_Corners )
{
corners.push_back( VECTOR2D( point ) );
}
if( aItem->IsFilled() )
{
aGal->SetFillColor( COLOR4D( aItem->GetColor() ) );
aGal->SetIsFill( true );
aGal->SetIsStroke( false );
aGal->DrawPolygon( corners );
}
else
{
aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) );
aGal->SetIsFill( false );
aGal->SetIsStroke( true );
aGal->SetLineWidth( aItem->GetPenWidth() );
aGal->DrawPolyline( corners );
}
}
void WORKSHEET_ITEM::draw( const WS_DRAW_ITEM_TEXT* aItem, GAL* aGal ) const
{
VECTOR2D position( aItem->GetTextPosition().x, aItem->GetTextPosition().y );
aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) );
aGal->SetLineWidth( aItem->GetThickness() );
aGal->SetTextAttributes( aItem );
aGal->StrokeText( std::string( aItem->GetText().mb_str() ), position, 0.0 );
}
void WORKSHEET_ITEM::drawBorder( GAL* aGal ) const
{
VECTOR2D origin = VECTOR2D( 0.0, 0.0 );
VECTOR2D end = VECTOR2D( m_pageInfo->GetWidthMils() * 25400,
m_pageInfo->GetHeightMils() * 25400 );
aGal->SetIsStroke( true );
aGal->SetIsFill( false );
aGal->SetStrokeColor( COLOR4D( 0.5, 0.5, 0.5, 1.0 ) );
aGal->DrawRectangle( origin, end );
}
...@@ -188,7 +188,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow ...@@ -188,7 +188,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& event ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& event )
{ {
D( printf( "OnListItemDeselected()\n" ); ) DBG( printf( "OnListItemDeselected()\n" ); )
if( !m_skipCopyFromPanel ) if( !m_skipCopyFromPanel )
{ {
...@@ -200,7 +200,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& even ...@@ -200,7 +200,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& even
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemSelected( wxListEvent& event ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemSelected( wxListEvent& event )
{ {
D( printf( "OnListItemSelected()\n" ); ) DBG( printf( "OnListItemSelected()\n" ); )
// remember the selected row, statically // remember the selected row, statically
s_SelectedRow = event.GetIndex(); s_SelectedRow = event.GetIndex();
...@@ -448,7 +448,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler( wxCommandEvent& ev ...@@ -448,7 +448,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler( wxCommandEvent& ev
// and in the fieldListCtrl // and in the fieldListCtrl
SCH_FIELD tmp = m_FieldsBuf[fieldNdx - 1]; SCH_FIELD tmp = m_FieldsBuf[fieldNdx - 1];
D( printf( "tmp.m_Text=\"%s\" tmp.m_Name=\"%s\"\n", DBG( printf( "tmp.m_Text=\"%s\" tmp.m_Name=\"%s\"\n",
TO_UTF8( tmp.GetText() ), TO_UTF8( tmp.GetName( false ) ) ); ) TO_UTF8( tmp.GetText() ), TO_UTF8( tmp.GetName( false ) ) ); )
m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx]; m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx];
...@@ -866,12 +866,12 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel() ...@@ -866,12 +866,12 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
if( mirror == CMP_MIRROR_X ) if( mirror == CMP_MIRROR_X )
{ {
mirrorRadioBox->SetSelection( 1 ); mirrorRadioBox->SetSelection( 1 );
D( printf( "mirror=X,1\n" ); ) DBG( printf( "mirror=X,1\n" ); )
} }
else if( mirror == CMP_MIRROR_Y ) else if( mirror == CMP_MIRROR_Y )
{ {
mirrorRadioBox->SetSelection( 2 ); mirrorRadioBox->SetSelection( 2 );
D( printf( "mirror=Y,2\n" ); ) DBG( printf( "mirror=Y,2\n" ); )
} }
else else
mirrorRadioBox->SetSelection( 0 ); mirrorRadioBox->SetSelection( 0 );
...@@ -891,7 +891,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel() ...@@ -891,7 +891,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
// Show the "Parts Locked" option? // Show the "Parts Locked" option?
if( !m_LibEntry || !m_LibEntry->UnitsLocked() ) if( !m_LibEntry || !m_LibEntry->UnitsLocked() )
{ {
D( printf( "partsAreLocked->false\n" ); ) DBG( printf( "partsAreLocked->false\n" ); )
partsAreLockedLabel->Show( false ); partsAreLockedLabel->Show( false );
} }
......
...@@ -472,7 +472,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() ...@@ -472,7 +472,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers()
// fixed fields: // fixed fields:
for( int i=0; i<MANDATORY_FIELDS; ++i ) for( int i=0; i<MANDATORY_FIELDS; ++i )
{ {
D( printf( "add fixed:%s\n", TO_UTF8( cmpFields[i].GetName() ) ); ) DBG( printf( "add fixed:%s\n", TO_UTF8( cmpFields[i].GetName() ) ); )
m_FieldsBuf.push_back( cmpFields[i] ); m_FieldsBuf.push_back( cmpFields[i] );
} }
...@@ -497,7 +497,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() ...@@ -497,7 +497,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers()
// values from the component will be set. // values from the component will be set.
if( !libField ) if( !libField )
{ {
D( printf( "add template:%s\n", TO_UTF8( it->m_Name ) ); ) DBG( printf( "add template:%s\n", TO_UTF8( it->m_Name ) ); )
fld.SetName( it->m_Name ); fld.SetName( it->m_Name );
fld.SetText( it->m_Value ); // empty? ok too. fld.SetText( it->m_Value ); // empty? ok too.
...@@ -509,7 +509,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() ...@@ -509,7 +509,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers()
} }
else else
{ {
D( printf( "match template:%s\n", TO_UTF8( libField->GetName() ) ); ) DBG( printf( "match template:%s\n", TO_UTF8( libField->GetName() ) ); )
fld = *libField; // copy values from component, m_Name too fld = *libField; // copy values from component, m_Name too
} }
...@@ -525,7 +525,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() ...@@ -525,7 +525,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers()
if( !buf ) if( !buf )
{ {
D( printf( "add cmp:%s\n", TO_UTF8( cmp->GetName() ) ); ) DBG( printf( "add cmp:%s\n", TO_UTF8( cmp->GetName() ) ); )
m_FieldsBuf.push_back( *cmp ); m_FieldsBuf.push_back( *cmp );
} }
} }
...@@ -721,11 +721,11 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField() ...@@ -721,11 +721,11 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
if( field.GetId() >= MANDATORY_FIELDS ) if( field.GetId() >= MANDATORY_FIELDS )
{ {
wxString name = fieldNameTextCtrl->GetValue(); wxString name = fieldNameTextCtrl->GetValue();
D( printf("name:%s\n", TO_UTF8( name ) ); ) DBG( printf("name:%s\n", TO_UTF8( name ) ); )
field.SetName( name ); field.SetName( name );
} }
D( printf("setname:%s\n", TO_UTF8( field.GetName() ) ); ) DBG( printf("setname:%s\n", TO_UTF8( field.GetName() ) ); )
setRowItem( fieldNdx, field ); // update fieldListCtrl setRowItem( fieldNdx, field ); // update fieldListCtrl
......
...@@ -292,7 +292,7 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event ) ...@@ -292,7 +292,7 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event )
for( unsigned i=0; i<tfnames.size(); ++i ) for( unsigned i=0; i<tfnames.size(); ++i )
{ {
D(printf("dlg.SetFieldName(%d, '%s')\n", i, TO_UTF8( tfnames[i].m_Name) );) DBG(printf("dlg.SetFieldName(%d, '%s')\n", i, TO_UTF8( tfnames[i].m_Name) );)
dlg.SetFieldName( i, tfnames[i].m_Name ); dlg.SetFieldName( i, tfnames[i].m_Name );
} }
...@@ -680,7 +680,7 @@ void SCH_EDIT_FRAME::LoadSettings() ...@@ -680,7 +680,7 @@ void SCH_EDIT_FRAME::LoadSettings()
catch( IO_ERROR& e ) catch( IO_ERROR& e )
{ {
// @todo show error msg // @todo show error msg
D( printf( "templatefieldnames parsing error: '%s'\n", DBG( printf( "templatefieldnames parsing error: '%s'\n",
TO_UTF8( e.errorText ) ); ) TO_UTF8( e.errorText ) ); )
} }
} }
...@@ -751,7 +751,7 @@ void SCH_EDIT_FRAME::SaveSettings() ...@@ -751,7 +751,7 @@ void SCH_EDIT_FRAME::SaveSettings()
m_TemplateFieldNames.Format( &sf, 0 ); m_TemplateFieldNames.Format( &sf, 0 );
D(printf("saving formatted template fieldnames:'%s'\n", sf.GetString().c_str() );) DBG(printf("saving formatted template fieldnames:'%s'\n", sf.GetString().c_str() );)
wxString record = FROM_UTF8( sf.GetString().c_str() ); wxString record = FROM_UTF8( sf.GetString().c_str() );
record.Replace( wxT("\n"), wxT(""), true ); // strip all newlines record.Replace( wxT("\n"), wxT(""), true ); // strip all newlines
......
...@@ -640,7 +640,7 @@ void LIB_FIELD::SetName( const wxString& aName ) ...@@ -640,7 +640,7 @@ void LIB_FIELD::SetName( const wxString& aName )
// Besides, m_id is a relic that is untrustworthy now. // Besides, m_id is a relic that is untrustworthy now.
if( m_id >=0 && m_id < MANDATORY_FIELDS ) if( m_id >=0 && m_id < MANDATORY_FIELDS )
{ {
D(printf( "trying to set a MANDATORY_FIELD's name\n" );) DBG(printf( "trying to set a MANDATORY_FIELD's name\n" );)
return; return;
} }
......
...@@ -417,7 +417,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam ...@@ -417,7 +417,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
wxFileName tmpFile = aFullFileName; wxFileName tmpFile = aFullFileName;
tmpFile.SetExt( INTERMEDIATE_NETLIST_EXT ); tmpFile.SetExt( INTERMEDIATE_NETLIST_EXT );
D(printf("tmpFile:'%s'\n", TO_UTF8( tmpFile.GetFullPath() ) );) DBG(printf("tmpFile:'%s'\n", TO_UTF8( tmpFile.GetFullPath() ) );)
ret = helper.WriteGENERICNetList( tmpFile.GetFullPath() ); ret = helper.WriteGENERICNetList( tmpFile.GetFullPath() );
if( !ret ) if( !ret )
...@@ -435,7 +435,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam ...@@ -435,7 +435,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
tmpFile.GetFullPath(), tmpFile.GetFullPath(),
aFullFileName ); aFullFileName );
D(printf("commandLine:'%s'\n", TO_UTF8( commandLine ) );) DBG(printf("commandLine:'%s'\n", TO_UTF8( commandLine ) );)
ProcessExecute( commandLine, wxEXEC_SYNC ); ProcessExecute( commandLine, wxEXEC_SYNC );
......
...@@ -324,7 +324,7 @@ SCH_SCREEN* SCH_EDIT_FRAME::GetScreen() const ...@@ -324,7 +324,7 @@ SCH_SCREEN* SCH_EDIT_FRAME::GetScreen() const
} }
wxString SCH_EDIT_FRAME::GetScreenDesc() wxString SCH_EDIT_FRAME::GetScreenDesc() const
{ {
wxString s = m_CurrentSheet->PathHumanReadable(); wxString s = m_CurrentSheet->PathHumanReadable();
......
...@@ -151,7 +151,7 @@ int TEMPLATES::AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName ) ...@@ -151,7 +151,7 @@ int TEMPLATES::AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName )
{ {
if( m_Fields[i].m_Name == aFieldName.m_Name ) if( m_Fields[i].m_Name == aFieldName.m_Name )
{ {
D( printf( "inserting template fieldname:'%s' at %d\n", DBG( printf( "inserting template fieldname:'%s' at %d\n",
TO_UTF8( aFieldName.m_Name ), i ); ) TO_UTF8( aFieldName.m_Name ), i ); )
m_Fields[i] = aFieldName; m_Fields[i] = aFieldName;
...@@ -159,7 +159,7 @@ int TEMPLATES::AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName ) ...@@ -159,7 +159,7 @@ int TEMPLATES::AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName )
} }
} }
// D(printf("appending template fieldname:'%s'\n", aFieldName.m_Name.utf8_str() );) // DBG(printf("appending template fieldname:'%s'\n", aFieldName.m_Name.utf8_str() );)
// the name is legal and not previously added to the config container, append // the name is legal and not previously added to the config container, append
// it and return its index within the container. // it and return its index within the container.
......
...@@ -409,7 +409,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent, ...@@ -409,7 +409,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
case AMP_UNKNOWN: case AMP_UNKNOWN:
default: default:
D( printf( "AM_PRIMITIVE::DrawBasicShape() err: unknown prim id %d\n",primitive_id) ); DBG( printf( "AM_PRIMITIVE::DrawBasicShape() err: unknown prim id %d\n",primitive_id) );
break; break;
} }
} }
......
...@@ -167,7 +167,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, ...@@ -167,7 +167,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
if( m_GerbMetric ) if( m_GerbMetric )
conv_scale /= 25.4; conv_scale /= 25.4;
// D( printf( "%22s: Command <%c%c>\n", __func__, (command >> 8) & 0xFF, command & 0xFF ); ) // DBG( printf( "%22s: Command <%c%c>\n", __func__, (command >> 8) & 0xFF, command & 0xFF ); )
switch( command ) switch( command )
{ {
...@@ -521,7 +521,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, ...@@ -521,7 +521,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
m_ImageNegative = true; m_ImageNegative = true;
else else
m_ImageNegative = false; m_ImageNegative = false;
D( printf( "%22s: IMAGE_POLARITY m_ImageNegative=%s\n", __func__, DBG( printf( "%22s: IMAGE_POLARITY m_ImageNegative=%s\n", __func__,
m_ImageNegative ? "true" : "false" ); ) m_ImageNegative ? "true" : "false" ); )
break; break;
...@@ -531,7 +531,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command, ...@@ -531,7 +531,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
else else
GetLayerParams().m_LayerNegative = false; GetLayerParams().m_LayerNegative = false;
D( printf( "%22s: LAYER_POLARITY m_LayerNegative=%s\n", __func__, DBG( printf( "%22s: LAYER_POLARITY m_LayerNegative=%s\n", __func__,
GetLayerParams().m_LayerNegative ? "true" : "false" ); ) GetLayerParams().m_LayerNegative ? "true" : "false" ); )
break; break;
......
...@@ -139,6 +139,14 @@ EDA_COLOR_T ColorByName( const wxChar *aName ); ...@@ -139,6 +139,14 @@ EDA_COLOR_T ColorByName( const wxChar *aName );
/// Find the nearest color match /// Find the nearest color match
EDA_COLOR_T ColorFindNearest( const wxColour &aColor ); EDA_COLOR_T ColorFindNearest( const wxColour &aColor );
/**
* Find the nearest color match
* @param aR is the red component of the color to be matched (in range 0-255)
* @param aG is the green component of the color to be matched (in range 0-255)
* @param aG is the blue component of the color to be matched (in range 0-255)
*/
EDA_COLOR_T ColorFindNearest( int aR, int aG, int aB );
/** /**
* Check if a color is light i.e. if black would be more readable than * Check if a color is light i.e. if black would be more readable than
* white on it * white on it
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#define COLOR4D_H_ #define COLOR4D_H_
#include <colors.h> #include <colors.h>
#include <cassert>
namespace KiGfx namespace KiGfx
{ {
...@@ -55,6 +56,10 @@ public: ...@@ -55,6 +56,10 @@ public:
COLOR4D( double aRed, double aGreen, double aBlue, double aAlpha ) : COLOR4D( double aRed, double aGreen, double aBlue, double aAlpha ) :
r( aRed ), g( aGreen ), b( aBlue ), a( aAlpha ) r( aRed ), g( aGreen ), b( aBlue ), a( aAlpha )
{ {
assert( r >= 0.0 && r <= 1.0 );
assert( g >= 0.0 && g <= 1.0 );
assert( b >= 0.0 && b <= 1.0 );
assert( a >= 0.0 && a <= 1.0 );
} }
/** /**
...@@ -82,6 +87,8 @@ public: ...@@ -82,6 +87,8 @@ public:
*/ */
COLOR4D& Brighten( double aFactor ) COLOR4D& Brighten( double aFactor )
{ {
assert( aFactor >= 0.0 && aFactor <= 1.0 );
r = r * ( 1.0 - aFactor ) + aFactor; r = r * ( 1.0 - aFactor ) + aFactor;
g = g * ( 1.0 - aFactor ) + aFactor; g = g * ( 1.0 - aFactor ) + aFactor;
b = b * ( 1.0 - aFactor ) + aFactor; b = b * ( 1.0 - aFactor ) + aFactor;
...@@ -97,6 +104,8 @@ public: ...@@ -97,6 +104,8 @@ public:
*/ */
COLOR4D& Darken( double aFactor ) COLOR4D& Darken( double aFactor )
{ {
assert( aFactor >= 0.0 && aFactor <= 1.0 );
r = r * ( 1.0 - aFactor ); r = r * ( 1.0 - aFactor );
g = g * ( 1.0 - aFactor ); g = g * ( 1.0 - aFactor );
b = b * ( 1.0 - aFactor ); b = b * ( 1.0 - aFactor );
...@@ -131,6 +140,8 @@ public: ...@@ -131,6 +140,8 @@ public:
*/ */
COLOR4D Brightened( double aFactor ) const COLOR4D Brightened( double aFactor ) const
{ {
assert( aFactor >= 0.0 && aFactor <= 1.0 );
return COLOR4D( r * ( 1.0 - aFactor ) + aFactor, return COLOR4D( r * ( 1.0 - aFactor ) + aFactor,
g * ( 1.0 - aFactor ) + aFactor, g * ( 1.0 - aFactor ) + aFactor,
b * ( 1.0 - aFactor ) + aFactor, b * ( 1.0 - aFactor ) + aFactor,
...@@ -145,6 +156,8 @@ public: ...@@ -145,6 +156,8 @@ public:
*/ */
COLOR4D Darkened( double aFactor ) const COLOR4D Darkened( double aFactor ) const
{ {
assert( aFactor >= 0.0 && aFactor <= 1.0 );
return COLOR4D( r * ( 1.0 - aFactor ), return COLOR4D( r * ( 1.0 - aFactor ),
g * ( 1.0 - aFactor ), g * ( 1.0 - aFactor ),
b * ( 1.0 - aFactor ), b * ( 1.0 - aFactor ),
...@@ -172,9 +185,25 @@ public: ...@@ -172,9 +185,25 @@ public:
return ( r * 0.299 + g * 0.587 + b * 0.117 ); return ( r * 0.299 + g * 0.587 + b * 0.117 );
} }
void ToHSV(double& out_h, double& out_s, double& out_v) const; /**
void FromHSV(double in_h, double in_s, double in_v); * Function ToHSV()
* Converts current color (stored in RGB) to HSV format.
*
* @param aOutH is conversion result for hue component.
* @param aOutS is conversion result for saturation component.
* @param aOutV is conversion result for value component.
*/
void ToHSV( double& aOutH, double& aOutS, double& aOutV ) const;
/**
* Function FromHSV()
* Changes currently used color to the one given by hue, saturation and value parameters.
*
* @param aOutH is hue component.
* @param aOutS is saturation component.
* @param aOutV is value component.
*/
void FromHSV( double aInH, double aInS, double aInV );
/// @brief Equality operator, are two colors equal /// @brief Equality operator, are two colors equal
const bool operator==( const COLOR4D& aColor ); const bool operator==( const COLOR4D& aColor );
......
...@@ -818,6 +818,9 @@ public: ...@@ -818,6 +818,9 @@ public:
depthStack.pop(); depthStack.pop();
} }
/// Depth level on which the grid is drawn
static const int GRID_DEPTH = 1024;
protected: protected:
std::stack<double> depthStack; ///< Stored depth values std::stack<double> depthStack; ///< Stored depth values
VECTOR2D screenSize; ///< Screen size in screen coordinates VECTOR2D screenSize; ///< Screen size in screen coordinates
...@@ -884,6 +887,9 @@ protected: ...@@ -884,6 +887,9 @@ protected:
* @param aCursorSize is the size of the cursor. * @param aCursorSize is the size of the cursor.
*/ */
virtual void initCursor( int aCursorSize ) = 0; virtual void initCursor( int aCursorSize ) = 0;
static const int MIN_DEPTH = -2048;
static const int MAX_DEPTH = 2047;
}; };
} // namespace KiGfx } // namespace KiGfx
......
...@@ -36,10 +36,8 @@ ...@@ -36,10 +36,8 @@
#include <map> #include <map>
#include <set> #include <set>
#ifdef __WXDEBUG__
// Debug messages verbosity level // Debug messages verbosity level
// #define CACHED_CONTAINER_TEST 2 //#define CACHED_CONTAINER_TEST 1
#endif
namespace KiGfx namespace KiGfx
{ {
...@@ -54,11 +52,14 @@ public: ...@@ -54,11 +52,14 @@ public:
///< @copydoc VERTEX_CONTAINER::SetItem() ///< @copydoc VERTEX_CONTAINER::SetItem()
virtual void SetItem( VERTEX_ITEM* aItem ); virtual void SetItem( VERTEX_ITEM* aItem );
///< @copydoc VERTEX_CONTAINER::FinishItem()
virtual void FinishItem();
///< @copydoc VERTEX_CONTAINER::Allocate() ///< @copydoc VERTEX_CONTAINER::Allocate()
virtual VERTEX* Allocate( unsigned int aSize ); virtual VERTEX* Allocate( unsigned int aSize );
///< @copydoc VERTEX_CONTAINER::Erase() ///< @copydoc VERTEX_CONTAINER::Delete()
virtual void Erase(); virtual void Delete( VERTEX_ITEM* aItem );
///< @copydoc VERTEX_CONTAINER::Clear() ///< @copydoc VERTEX_CONTAINER::Clear()
virtual void Clear(); virtual void Clear();
...@@ -130,14 +131,6 @@ protected: ...@@ -130,14 +131,6 @@ protected:
*/ */
virtual bool resizeContainer( unsigned int aNewSize ); virtual bool resizeContainer( unsigned int aNewSize );
/**
* Function freeItem()
* frees the space occupied by the item and returns it to the free space pool.
*
* @param aItem is the item to be freed.
*/
virtual void freeItem( VERTEX_ITEM* aItem );
/** /**
* Function getPowerOf2() * Function getPowerOf2()
* returns the nearest power of 2, bigger than aNumber. * returns the nearest power of 2, bigger than aNumber.
...@@ -170,7 +163,7 @@ private: ...@@ -170,7 +163,7 @@ private:
} }
/// Debug & test functions /// Debug & test functions
#ifdef CACHED_CONTAINER_TEST #if CACHED_CONTAINER_TEST > 0
void showFreeChunks(); void showFreeChunks();
void showReservedChunks(); void showReservedChunks();
void test(); void test();
......
...@@ -50,8 +50,8 @@ public: ...@@ -50,8 +50,8 @@ public:
///< @copydoc VERTEX_CONTAINER::Allocate() ///< @copydoc VERTEX_CONTAINER::Allocate()
virtual VERTEX* Allocate( unsigned int aSize ); virtual VERTEX* Allocate( unsigned int aSize );
///< @copydoc VERTEX_CONTAINER::Erase() ///< @copydoc VERTEX_CONTAINER::Delete()
virtual void Erase(); void Delete( VERTEX_ITEM* aItem ) {};
///< @copydoc VERTEX_CONTAINER::Clear() ///< @copydoc VERTEX_CONTAINER::Clear()
virtual void Clear(); virtual void Clear();
......
...@@ -54,6 +54,12 @@ public: ...@@ -54,6 +54,12 @@ public:
*/ */
virtual void SetItem( VERTEX_ITEM* aItem ) = 0; virtual void SetItem( VERTEX_ITEM* aItem ) = 0;
/**
* Function FinishItem()
* does the cleaning after adding an item.
*/
virtual void FinishItem() {};
/** /**
* Function Allocate() * Function Allocate()
* returns allocated space (possibly resizing the reserved memory chunk or allocating a new * returns allocated space (possibly resizing the reserved memory chunk or allocating a new
...@@ -66,10 +72,12 @@ public: ...@@ -66,10 +72,12 @@ public:
virtual VERTEX* Allocate( unsigned int aSize ) = 0; virtual VERTEX* Allocate( unsigned int aSize ) = 0;
/** /**
* Function Erase() * Function Delete()
* erases all vertices associated with the current item (set by SetItem()). * erases the selected item.
*
* @param aItem is the item to be erased.
*/ */
virtual void Erase() = 0; virtual void Delete( VERTEX_ITEM* aItem ) = 0;
/** /**
* Function Clear() * Function Clear()
......
...@@ -232,6 +232,12 @@ public: ...@@ -232,6 +232,12 @@ public:
*/ */
void SetItem( VERTEX_ITEM& aItem ) const; void SetItem( VERTEX_ITEM& aItem ) const;
/**
* Function FinishItem()
* does the cleaning after adding an item.
*/
void FinishItem() const;
/** /**
* Function FreeItem() * Function FreeItem()
* frees the memory occupied by the item, so it is no longer stored in the container. * frees the memory occupied by the item, so it is no longer stored in the container.
......
...@@ -241,6 +241,7 @@ enum PCB_VISIBLE ...@@ -241,6 +241,7 @@ enum PCB_VISIBLE
PADS_NETNAMES_VISIBLE, PADS_NETNAMES_VISIBLE,
SELECTION, SELECTION,
WORKSHEET,
GP_OVERLAY, // General purpose overlay GP_OVERLAY, // General purpose overlay
END_PCB_VISIBLE_LIST // sentinel END_PCB_VISIBLE_LIST // sentinel
...@@ -290,7 +291,8 @@ const LAYER_NUM GalLayerOrder[] = ...@@ -290,7 +291,8 @@ const LAYER_NUM GalLayerOrder[] =
ITEM_GAL_LAYER( LAYER_1_NETNAMES_VISIBLE ), LAYER_N_BACK, ITEM_GAL_LAYER( LAYER_1_NETNAMES_VISIBLE ), LAYER_N_BACK,
ADHESIVE_N_BACK, SOLDERPASTE_N_BACK, SILKSCREEN_N_BACK, ADHESIVE_N_BACK, SOLDERPASTE_N_BACK, SILKSCREEN_N_BACK,
ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ) ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ),
ITEM_GAL_LAYER( WORKSHEET )
}; };
/** /**
......
...@@ -418,8 +418,8 @@ public: ...@@ -418,8 +418,8 @@ public:
{ {
ecoord_type x2 = m_Pos.x + m_Size.x; ecoord_type x2 = m_Pos.x + m_Size.x;
ecoord_type y2 = m_Pos.y + m_Size.y; ecoord_type y2 = m_Pos.y + m_Size.y;
ecoord_type xdiff = std::max(aP.x < m_Pos.x ? m_Pos.x - aP.x : m_Pos.x - x2, (ecoord_type)0); ecoord_type xdiff = std::max( aP.x < m_Pos.x ? m_Pos.x - aP.x : m_Pos.x - x2, (ecoord_type)0 );
ecoord_type ydiff = std::max(aP.y < m_Pos.y ? m_Pos.y - aP.y : m_Pos.y - y2, (ecoord_type)0); ecoord_type ydiff = std::max( aP.y < m_Pos.y ? m_Pos.y - aP.y : m_Pos.y - y2, (ecoord_type)0 );
return xdiff * xdiff + ydiff * ydiff; return xdiff * xdiff + ydiff * ydiff;
} }
......
...@@ -32,7 +32,8 @@ ...@@ -32,7 +32,8 @@
#include <gal/color4d.h> #include <gal/color4d.h>
#include <colors.h> #include <colors.h>
#include <worksheet_shape_builder.h>
#include <boost/shared_ptr.hpp>
class EDA_ITEM; class EDA_ITEM;
class COLORS_DESIGN_SETTINGS; class COLORS_DESIGN_SETTINGS;
...@@ -113,6 +114,21 @@ public: ...@@ -113,6 +114,21 @@ public:
m_hiContrastEnabled = aEnabled; m_hiContrastEnabled = aEnabled;
} }
/**
* Function GetColor
* Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer
* using currently used render settings.
* @param aItem is the VIEW_ITEM.
* @param aLayer is the layer.
* @return The color.
*/
virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const = 0;
float GetWorksheetLineWidth() const
{
return m_worksheetLineWidth;
}
protected: protected:
/** /**
* Function update * Function update
...@@ -137,6 +153,7 @@ protected: ...@@ -137,6 +153,7 @@ protected:
float m_selectFactor; ///< Specifies how color of selected items is changed float m_selectFactor; ///< Specifies how color of selected items is changed
float m_layerOpacity; ///< Determines opacity of all layers float m_layerOpacity; ///< Determines opacity of all layers
float m_outlineWidth; ///< Line width used when drawing outlines float m_outlineWidth; ///< Line width used when drawing outlines
float m_worksheetLineWidth; ///< Line width used when drawing worksheet
/// Map of colors that were usually used for display /// Map of colors that were usually used for display
std::map<EDA_COLOR_T, COLOR4D> m_legacyColorMap; std::map<EDA_COLOR_T, COLOR4D> m_legacyColorMap;
...@@ -177,10 +194,7 @@ public: ...@@ -177,10 +194,7 @@ public:
*/ */
virtual void ApplySettings( RENDER_SETTINGS* aSettings ) virtual void ApplySettings( RENDER_SETTINGS* aSettings )
{ {
if( m_settings ) m_settings.reset( aSettings );
delete m_settings;
m_settings = aSettings;
} }
/** /**
...@@ -195,9 +209,9 @@ public: ...@@ -195,9 +209,9 @@ public:
* Returns pointer to current settings that are going to be used when drawing items. * Returns pointer to current settings that are going to be used when drawing items.
* @return Current rendering settings. * @return Current rendering settings.
*/ */
virtual RENDER_SETTINGS* GetSettings() virtual RENDER_SETTINGS* GetSettings() const
{ {
return m_settings; return m_settings.get();
} }
/** /**
...@@ -217,23 +231,13 @@ public: ...@@ -217,23 +231,13 @@ public:
*/ */
virtual void DrawBrightened( const VIEW_ITEM* aItem ); virtual void DrawBrightened( const VIEW_ITEM* aItem );
/**
* Function GetColor
* Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer
* using currently used render settings.
* @param aItem is the VIEW_ITEM.
* @param aLayer is the layer.
* @return The color.
*/
virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) = 0;
protected: protected:
/// Instance of graphic abstraction layer that gives an interface to call /// Instance of graphic abstraction layer that gives an interface to call
/// commands used to draw (eg. DrawLine, DrawCircle, etc.) /// commands used to draw (eg. DrawLine, DrawCircle, etc.)
GAL* m_gal; GAL* m_gal;
/// Colors and display modes settings that are going to be used when drawing items. /// Colors and display modes settings that are going to be used when drawing items.
RENDER_SETTINGS* m_settings; boost::shared_ptr<RENDER_SETTINGS> m_settings;
/// Color of brightened item frame /// Color of brightened item frame
COLOR4D m_brightenedColor; COLOR4D m_brightenedColor;
......
...@@ -65,6 +65,9 @@ public: ...@@ -65,6 +65,9 @@ public:
virtual void DispatchWxEvent( wxEvent& aEvent ); virtual void DispatchWxEvent( wxEvent& aEvent );
virtual void DispatchWxCommand( wxCommandEvent& aEvent ); virtual void DispatchWxCommand( wxCommandEvent& aEvent );
/// Event that forces mouse move event in the dispatcher
static const wxEventType EVT_REFRESH_MOUSE;
private: private:
static const int MouseButtonCount = 3; static const int MouseButtonCount = 3;
static const int DragTimeThreshold = 300; static const int DragTimeThreshold = 300;
...@@ -73,7 +76,7 @@ private: ...@@ -73,7 +76,7 @@ private:
bool handleMouseButton( wxEvent& aEvent, int aIndex, bool aMotion ); bool handleMouseButton( wxEvent& aEvent, int aIndex, bool aMotion );
bool handlePopupMenu( wxEvent& aEvent ); bool handlePopupMenu( wxEvent& aEvent );
wxPoint getCurrentMousePos(); wxPoint getCurrentMousePos() const;
int decodeModifiers( const wxKeyboardState* aState ) const; int decodeModifiers( const wxKeyboardState* aState ) const;
......
...@@ -229,6 +229,16 @@ public: ...@@ -229,6 +229,16 @@ public:
return m_keyCode; return m_keyCode;
} }
bool IsKeyUp() const
{
return m_actions == TA_KeyUp;
}
bool IsKeyDown() const
{
return m_actions == TA_KeyDown;
}
void Ignore(); void Ignore();
void SetMouseDragOrigin( const VECTOR2D &aP ) void SetMouseDragOrigin( const VECTOR2D &aP )
......
...@@ -377,10 +377,10 @@ public: ...@@ -377,10 +377,10 @@ public:
void UpdateAllLayersOrder(); void UpdateAllLayersOrder();
/** /**
* Function PrepareTargets() * Function ClearTargets()
* Clears targets that are marked as dirty. * Clears targets that are marked as dirty.
*/ */
void PrepareTargets(); void ClearTargets();
/** /**
* Function Redraw() * Function Redraw()
...@@ -443,9 +443,13 @@ public: ...@@ -443,9 +443,13 @@ public:
return ( m_layers.at( aLayer ).target == TARGET_CACHED ); return ( m_layers.at( aLayer ).target == TARGET_CACHED );
} }
void MakeDirty() /**
* Function MarkDirty()
* Forces redraw of view on the next rendering.
*/
void MarkDirty()
{ {
for(int i = 0; i < TARGETS_NUMBER; i++) for( int i = 0; i < TARGETS_NUMBER; ++i )
m_dirtyTargets[i] = true; m_dirtyTargets[i] = true;
} }
...@@ -455,7 +459,6 @@ private: ...@@ -455,7 +459,6 @@ private:
struct VIEW_LAYER struct VIEW_LAYER
{ {
bool enabled; ///* is the layer to be rendered? bool enabled; ///* is the layer to be rendered?
bool isDirty; ///* does it contain any dirty items (updated since last redraw)
bool displayOnly; ///* is the layer display only? bool displayOnly; ///* is the layer display only?
VIEW_RTREE* items; ///* R-tree indexing all items on this layer. VIEW_RTREE* items; ///* R-tree indexing all items on this layer.
int renderingOrder; ///* rendering order of this layer int renderingOrder; ///* rendering order of this layer
......
...@@ -107,9 +107,8 @@ public: ...@@ -107,9 +107,8 @@ public:
* *
* @param aLayer is the layer which should be drawn. * @param aLayer is the layer which should be drawn.
* @param aGal is the GAL that should be used for drawing. * @param aGal is the GAL that should be used for drawing.
* @param aVisibleArea is limiting the drawing area.
*/ */
virtual void ViewDraw( int aLayer, GAL* aGal, const BOX2I& aVisibleArea ) const; virtual void ViewDraw( int aLayer, GAL* aGal ) const;
/** /**
* Function ViewGetLayers() * Function ViewGetLayers()
...@@ -120,9 +119,6 @@ public: ...@@ -120,9 +119,6 @@ public:
*/ */
virtual void ViewGetLayers( int aLayers[], int& aCount ) const; virtual void ViewGetLayers( int aLayers[], int& aCount ) const;
/// @copydoc VIEW_ITEM::ViewUpdate()
//virtual void ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw );
/** /**
* Function SetLayer() * Function SetLayer()
* Sets layer used to draw the group. * Sets layer used to draw the group.
...@@ -134,8 +130,18 @@ public: ...@@ -134,8 +130,18 @@ public:
m_layer = aLayer; m_layer = aLayer;
} }
/**
* Function FreeItems()
* Frees all the items that were added to the group.
*/
void FreeItems(); void FreeItems();
/**
* Function GetView()
* Returns pointer to the VIEW instance used by items.
*
* @return Pointer to the VIEW instance.
*/
KiGfx::VIEW *GetView() const KiGfx::VIEW *GetView() const
{ {
return m_view; return m_view;
......
...@@ -70,8 +70,7 @@ public: ...@@ -70,8 +70,7 @@ public:
ALL = 0xff ALL = 0xff
}; };
VIEW_ITEM() : m_view( NULL ), m_visible( true ), m_groups( NULL ), VIEW_ITEM() : m_view( NULL ), m_visible( true ), m_groups( NULL ), m_groupsSize( 0 ) {}
m_groupsSize( 0 ) {}
/** /**
* Destructor. For dynamic views, removes the item from the view. * Destructor. For dynamic views, removes the item from the view.
...@@ -101,11 +100,8 @@ public: ...@@ -101,11 +100,8 @@ public:
* *
* @param aLayer: current drawing layer * @param aLayer: current drawing layer
* @param aGal: pointer to the GAL device we are drawing on * @param aGal: pointer to the GAL device we are drawing on
* @param aVisibleArea: area (in world space coordinates) that is relevant for drawing. For
* example, when drawing a bitmap, one can clip the blitting area to aVisibleArea, reducing
* drawing time.
*/ */
virtual void ViewDraw( int aLayer, GAL* aGal, const BOX2I& aVisibleArea ) const { }; virtual void ViewDraw( int aLayer, GAL* aGal ) const {};
/** /**
* Function ViewGetLayers() * Function ViewGetLayers()
...@@ -155,10 +151,8 @@ public: ...@@ -155,10 +151,8 @@ public:
* this item has changed. For static views calling has no effect. * this item has changed. For static views calling has no effect.
* *
* @param aUpdateFlags: how much the object has changed * @param aUpdateFlags: how much the object has changed
* @param aForceImmediateRedraw: when true, the VIEW is redrawn immediately,
* otherwise, it will be redrawn upon next call of VIEW::Update()
*/ */
virtual void ViewUpdate( int aUpdateFlags = ALL, bool aForceImmediateRedraw = false ); virtual void ViewUpdate( int aUpdateFlags = ALL );
/** /**
* Function ViewRelease() * Function ViewRelease()
...@@ -241,7 +235,10 @@ protected: ...@@ -241,7 +235,10 @@ protected:
* *
* @returns true in case it is cached at least for one layer. * @returns true in case it is cached at least for one layer.
*/ */
virtual bool storesGroups() const; inline virtual bool storesGroups() const
{
return ( m_groupsSize > 0 );
}
/// Stores layer numbers used by the item. /// Stores layer numbers used by the item.
std::bitset<VIEW::VIEW_MAX_LAYERS> m_layers; std::bitset<VIEW::VIEW_MAX_LAYERS> m_layers;
...@@ -258,7 +255,7 @@ protected: ...@@ -258,7 +255,7 @@ protected:
m_layers.reset(); m_layers.reset();
for( int i = 0; i < aCount; ++i ) for( int i = 0; i < aCount; ++i )
m_layers.set(aLayers[i]); m_layers.set( aLayers[i] );
} }
}; };
......
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file worksheet_item.h
* @brief Class that handles properties and drawing of worksheet layout.
*/
#ifndef WORKSHEET_ITEM_H
#define WORKSHEET_ITEM_H
#include <base_struct.h>
class BOARD;
class PAGE_INFO;
class TITLE_BLOCK;
class WS_DRAW_ITEM_LINE;
class WS_DRAW_ITEM_RECT;
class WS_DRAW_ITEM_POLYGON;
class WS_DRAW_ITEM_TEXT;
namespace KiGfx
{
class GAL;
class WORKSHEET_ITEM : public EDA_ITEM
{
public:
WORKSHEET_ITEM( const std::string& aFileName, const std::string& aSheetName,
const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock );
~WORKSHEET_ITEM() {}
/**
* Function SetFileName()
* Sets the file name displayed in the title block.
*
* @param aFileName is the new file name.
*/
void SetFileName( const std::string& aFileName )
{
m_fileName = aFileName;
ViewUpdate( GEOMETRY );
}
/**
* Function SetSheetName()
* Sets the sheet name displayed in the title block.
*
* @param aSheetName is the new sheet name.
*/
void SetSheetName( const std::string& aSheetName )
{
m_sheetName = aSheetName;
ViewUpdate( GEOMETRY );
}
/**
* Function SetPageInfo()
* Changes the PAGE_INFO object used to draw the worksheet.
*
* @param aPageInfo is the new PAGE_INFO object.
*/
void SetPageInfo( const PAGE_INFO* aPageInfo );
/**
* Function SetTitleBlock()
* Changes the TITLE_BLOCK object used to draw the worksheet.
*
* @param aTitleBlock is the new TITLE_BLOCK object.
*/
void SetTitleBlock( const TITLE_BLOCK* aTitleBlock );
/**
* Function SetSheetNumber()
* Changes the sheet number displayed in the title block.
*
* @param aSheetNumber is the new sheet number.
*/
void SetSheetNumber( int aSheetNumber )
{
m_sheetNumber = aSheetNumber;
ViewUpdate( GEOMETRY );
}
/**
* Function SetSheetCount()
* Changes the sheets count number displayed in the title block.
*
* @param aSheetCount is the new sheets count number.
*/
void SetSheetCount( int aSheetCount )
{
m_sheetCount = aSheetCount;
ViewUpdate( GEOMETRY );
}
/// @copydoc VIEW_ITEM::ViewBBox()
const BOX2I ViewBBox() const;
/// @copydoc VIEW_ITEM::ViewDraw()
void ViewDraw( int aLayer, GAL* aGal ) const;
/// @copydoc VIEW_ITEM::ViewGetLayers()
void ViewGetLayers( int aLayers[], int& aCount ) const;
/// @copydoc EDA_ITEM::Show()
void Show( int x, std::ostream& st ) const
{
}
protected:
/// File name displayed in the title block
std::string m_fileName;
/// Sheet name displayed in the title block
std::string m_sheetName;
/// Title block that contains properties of the title block displayed in the worksheet.
const TITLE_BLOCK* m_titleBlock;
/// Worksheet page information.
const PAGE_INFO* m_pageInfo;
/// Sheet number displayed in the title block.
int m_sheetNumber;
/// Sheets count number displayed in the title block.
int m_sheetCount;
// Functions for drawing items that makes a worksheet
void draw( const WS_DRAW_ITEM_LINE* aItem, GAL* aGal ) const;
void draw( const WS_DRAW_ITEM_RECT* aItem, GAL* aGal ) const;
void draw( const WS_DRAW_ITEM_POLYGON* aItem, GAL* aGal ) const;
void draw( const WS_DRAW_ITEM_TEXT* aItem, GAL* aGal ) const;
/// Draws a border that determines the page size.
void drawBorder( GAL* aGal ) const;
};
}
#endif /* WORKSHEET_ITEM_H */
...@@ -108,9 +108,9 @@ public: ...@@ -108,9 +108,9 @@ public:
} }
// Accessors: // Accessors:
int GetPenWidth() { return m_penWidth; } int GetPenWidth() const { return m_penWidth; }
const wxPoint& GetStart() { return m_start; } const wxPoint& GetStart() const { return m_start; }
const wxPoint& GetEnd() { return m_end; } const wxPoint& GetEnd() const { return m_end; }
/** The function to draw a WS_DRAW_ITEM_LINE /** The function to draw a WS_DRAW_ITEM_LINE
*/ */
...@@ -158,9 +158,9 @@ public: ...@@ -158,9 +158,9 @@ public:
} }
// Accessors: // Accessors:
int GetPenWidth() { return m_penWidth; } int GetPenWidth() const { return m_penWidth; }
bool IsFilled() { return m_fill; } bool IsFilled() const { return m_fill; }
const wxPoint& GetPosition() { return m_pos; } const wxPoint& GetPosition() const { return m_pos; }
/** The function to draw a WS_DRAW_ITEM_POLYGON /** The function to draw a WS_DRAW_ITEM_POLYGON
*/ */
......
...@@ -95,8 +95,8 @@ protected: ...@@ -95,8 +95,8 @@ protected:
/// main window. /// main window.
wxAuiToolBar* m_auxiliaryToolBar; wxAuiToolBar* m_auxiliaryToolBar;
TOOL_MANAGER *m_toolManager; TOOL_MANAGER* m_toolManager;
TOOL_DISPATCHER *m_toolDispatcher; TOOL_DISPATCHER* m_toolDispatcher;
void updateGridSelectBox(); void updateGridSelectBox();
void updateZoomSelectBox(); void updateZoomSelectBox();
......
...@@ -356,7 +356,7 @@ public: ...@@ -356,7 +356,7 @@ public:
*/ */
void OnModify(); void OnModify();
virtual wxString GetScreenDesc(); virtual wxString GetScreenDesc() const;
void InstallConfigFrame( wxCommandEvent& event ); void InstallConfigFrame( wxCommandEvent& event );
......
...@@ -118,6 +118,7 @@ protected: ...@@ -118,6 +118,7 @@ protected:
// to know the footprint name of components. // to know the footprint name of components.
void setupTools(); void setupTools();
void destroyTools();
void onGenericCommand( wxCommandEvent& aEvent ); void onGenericCommand( wxCommandEvent& aEvent );
// we'll use lower case function names for private member functions. // we'll use lower case function names for private member functions.
...@@ -135,21 +136,13 @@ protected: ...@@ -135,21 +136,13 @@ protected:
* will change the currently active layer to \a aLayer and also * will change the currently active layer to \a aLayer and also
* update the PCB_LAYER_WIDGET. * update the PCB_LAYER_WIDGET.
*/ */
void setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate = true ) void setCurrentLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate = true );
{
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
setHighContrastLayer( aLayer );
if( doLayerWidgetUpdate )
syncLayerWidgetLayer();
}
/** /**
* Function getActiveLayer * Function getActiveLayer
* returns the active layer * returns the active layer
*/ */
LAYER_NUM getActiveLayer() LAYER_NUM getCurrentLayer()
{ {
return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer; return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
} }
...@@ -160,6 +153,12 @@ protected: ...@@ -160,6 +153,12 @@ protected:
*/ */
void setHighContrastLayer( LAYER_NUM aLayer ); void setHighContrastLayer( LAYER_NUM aLayer );
/**
* Function setTopLayer
* moves the selected layer to the top, so it is displayed above all others.
*/
void setTopLayer( LAYER_NUM aLayer );
/** /**
* Function syncLayerWidgetLayer * Function syncLayerWidgetLayer
* updates the currently layer "selection" within the PCB_LAYER_WIDGET. * updates the currently layer "selection" within the PCB_LAYER_WIDGET.
......
...@@ -499,7 +499,7 @@ public: ...@@ -499,7 +499,7 @@ public:
EDA_DRAW_PANEL* GetCanvas() { return m_canvas; } EDA_DRAW_PANEL* GetCanvas() { return m_canvas; }
virtual wxString GetScreenDesc(); virtual wxString GetScreenDesc() const;
/** /**
* Function GetScreen * Function GetScreen
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include <math/vector2d.h> #include <math/vector2d.h>
#include <trigo.h> #include <trigo.h>
#include <pcb_painter.h> #include <pcb_painter.h>
#include <worksheet_item.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h> #include <tool/tool_dispatcher.h>
...@@ -202,6 +203,20 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const ...@@ -202,6 +203,20 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
view->Add( zone ); view->Add( zone );
} }
// Add an entry for the worksheet layout
KiGfx::WORKSHEET_ITEM* worksheet = new KiGfx::WORKSHEET_ITEM(
std::string( aBoard->GetFileName().mb_str() ),
std::string( GetScreenDesc().mb_str() ),
&GetPageSettings(), &GetTitleBlock() );
BASE_SCREEN* screen = GetScreen();
if( screen != NULL )
{
worksheet->SetSheetNumber( GetScreen()->m_ScreenNumber );
worksheet->SetSheetCount( GetScreen()->m_NumberOfScreens );
}
view->Add( worksheet );
view->RecacheAllItems( true ); view->RecacheAllItems( true );
if( m_galCanvasActive ) if( m_galCanvasActive )
...@@ -828,7 +843,7 @@ void PCB_BASE_FRAME::LoadSettings() ...@@ -828,7 +843,7 @@ void PCB_BASE_FRAME::LoadSettings()
{ {
// Copper layers are required for netname layers // Copper layers are required for netname layers
view->SetRequired( GetNetnameLayer( layer ), layer ); view->SetRequired( GetNetnameLayer( layer ), layer );
view->SetLayerTarget( layer, KiGfx::TARGET_NONCACHED ); view->SetLayerTarget( layer, KiGfx::TARGET_CACHED );
} }
else if( IsNetnameLayer( layer ) ) else if( IsNetnameLayer( layer ) )
{ {
......
...@@ -183,7 +183,7 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) ...@@ -183,7 +183,7 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
if( IsCopperLayer( layer ) ) if( IsCopperLayer( layer ) )
{ {
bool loc_visible = visible; bool loc_visible = visible;
if( force_active_layer_visible && (layer == myframe->getActiveLayer() ) ) if( force_active_layer_visible && (layer == myframe->getCurrentLayer() ) )
loc_visible = true; loc_visible = true;
cb->SetValue( loc_visible ); cb->SetValue( loc_visible );
...@@ -354,7 +354,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer ) ...@@ -354,7 +354,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer )
{ {
// the layer change from the PCB_LAYER_WIDGET can be denied by returning // the layer change from the PCB_LAYER_WIDGET can be denied by returning
// false from this function. // false from this function.
myframe->setActiveLayer( aLayer, false ); myframe->setCurrentLayer( aLayer, false );
if( m_alwaysShowActiveCopperLayer ) if( m_alwaysShowActiveCopperLayer )
OnLayerSelected(); OnLayerSelected();
......
...@@ -53,7 +53,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack ) ...@@ -53,7 +53,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack )
{ {
if( g_CurrentTrackList.GetCount() > 0 ) if( g_CurrentTrackList.GetCount() > 0 )
{ {
LAYER_NUM previous_layer = getActiveLayer(); LAYER_NUM previous_layer = getCurrentLayer();
DBG( g_CurrentTrackList.VerifyListIntegrity(); ) DBG( g_CurrentTrackList.VerifyListIntegrity(); )
...@@ -86,7 +86,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack ) ...@@ -86,7 +86,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack )
// Correct active layer which could change if a via // Correct active layer which could change if a via
// has been erased // has been erased
setActiveLayer( previous_layer ); setCurrentLayer( previous_layer );
UpdateStatusBar(); UpdateStatusBar();
......
...@@ -238,8 +238,8 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -238,8 +238,8 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
// Apply new display options to the GAL canvas (this is faster than recaching) // Apply new display options to the GAL canvas (this is faster than recaching)
settings->LoadDisplayOptions( DisplayOpt ); settings->LoadDisplayOptions( DisplayOpt );
setHighContrastLayer( getActiveLayer() ); setHighContrastLayer( getCurrentLayer() );
m_galCanvas->GetView()->EnableTopLayer( state ); // m_galCanvas->GetView()->EnableTopLayer( state );
if( m_galCanvasActive ) if( m_galCanvasActive )
m_galCanvas->Refresh(); m_galCanvas->Refresh();
......
...@@ -37,7 +37,7 @@ DIALOG_GLOBAL_DELETION::DIALOG_GLOBAL_DELETION( PCB_EDIT_FRAME* parent ) ...@@ -37,7 +37,7 @@ DIALOG_GLOBAL_DELETION::DIALOG_GLOBAL_DELETION( PCB_EDIT_FRAME* parent )
void PCB_EDIT_FRAME::InstallPcbGlobalDeleteFrame( const wxPoint& pos ) void PCB_EDIT_FRAME::InstallPcbGlobalDeleteFrame( const wxPoint& pos )
{ {
DIALOG_GLOBAL_DELETION dlg( this ); DIALOG_GLOBAL_DELETION dlg( this );
dlg.SetCurrentLayer( getActiveLayer() ); dlg.SetCurrentLayer( getCurrentLayer() );
dlg.ShowModal(); dlg.ShowModal();
} }
......
...@@ -669,11 +669,11 @@ void PCB_EDIT_FRAME::InstallDialogLayerSetup() ...@@ -669,11 +669,11 @@ void PCB_EDIT_FRAME::InstallDialogLayerSetup()
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return; return;
wxLogDebug( wxT( "Current layer selected %d." ), getActiveLayer() ); wxLogDebug( wxT( "Current layer selected %d." ), getCurrentLayer() );
// If the current active layer was removed, find the next avaiable layer to set as the // If the current active layer was removed, find the next avaiable layer to set as the
// active layer. // active layer.
if( !( GetLayerMask( getActiveLayer() ) & GetBoard()->GetEnabledLayers() ) ) if( !( GetLayerMask( getCurrentLayer() ) & GetBoard()->GetEnabledLayers() ) )
{ {
for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i ) for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i )
{ {
...@@ -684,14 +684,14 @@ void PCB_EDIT_FRAME::InstallDialogLayerSetup() ...@@ -684,14 +684,14 @@ void PCB_EDIT_FRAME::InstallDialogLayerSetup()
if( GetLayerMask( tmp ) & GetBoard()->GetEnabledLayers() ) if( GetLayerMask( tmp ) & GetBoard()->GetEnabledLayers() )
{ {
wxLogDebug( wxT( "Setting current layer to %d." ), getActiveLayer() ); wxLogDebug( wxT( "Setting current layer to %d." ), getCurrentLayer() );
setActiveLayer( tmp, true ); setCurrentLayer( tmp, true );
break; break;
} }
} }
} }
else else
{ {
setActiveLayer( getActiveLayer(), true ); setCurrentLayer( getCurrentLayer(), true );
} }
} }
...@@ -245,7 +245,7 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC ) ...@@ -245,7 +245,7 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC )
aDimension = new DIMENSION( GetBoard() ); aDimension = new DIMENSION( GetBoard() );
aDimension->SetFlags( IS_NEW ); aDimension->SetFlags( IS_NEW );
aDimension->SetLayer( getActiveLayer() ); aDimension->SetLayer( getCurrentLayer() );
aDimension->m_crossBarO = aDimension->m_crossBarF = pos; aDimension->m_crossBarO = aDimension->m_crossBarF = pos;
aDimension->m_featureLineDO = aDimension->m_featureLineDF = pos; aDimension->m_featureLineDO = aDimension->m_featureLineDF = pos;
......
...@@ -917,10 +917,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -917,10 +917,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_SELECT_LAYER: case ID_POPUP_PCB_SELECT_LAYER:
itmp = SelectLayer( getActiveLayer(), UNDEFINED_LAYER, UNDEFINED_LAYER ); itmp = SelectLayer( getCurrentLayer(), UNDEFINED_LAYER, UNDEFINED_LAYER );
if( itmp >= 0 ) if( itmp >= 0 )
setActiveLayer( itmp ); setCurrentLayer( itmp );
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
break; break;
...@@ -930,19 +930,19 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -930,19 +930,19 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_SELECT_NO_CU_LAYER: case ID_POPUP_PCB_SELECT_NO_CU_LAYER:
itmp = SelectLayer( getActiveLayer(), FIRST_NON_COPPER_LAYER, UNDEFINED_LAYER ); itmp = SelectLayer( getCurrentLayer(), FIRST_NON_COPPER_LAYER, UNDEFINED_LAYER );
if( itmp >= 0 ) if( itmp >= 0 )
setActiveLayer( itmp ); setCurrentLayer( itmp );
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
break; break;
case ID_POPUP_PCB_SELECT_CU_LAYER: case ID_POPUP_PCB_SELECT_CU_LAYER:
itmp = SelectLayer( getActiveLayer(), UNDEFINED_LAYER, LAST_COPPER_LAYER ); itmp = SelectLayer( getCurrentLayer(), UNDEFINED_LAYER, LAST_COPPER_LAYER );
if( itmp >= 0 ) if( itmp >= 0 )
setActiveLayer( itmp ); setCurrentLayer( itmp );
break; break;
...@@ -952,7 +952,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -952,7 +952,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_TOOLBARH_PCB_SELECT_LAYER: case ID_TOOLBARH_PCB_SELECT_LAYER:
setActiveLayer( m_SelLayerBox->GetLayerSelection() ); setCurrentLayer( m_SelLayerBox->GetLayerSelection() );
if( DisplayOpt.ContrastModeDisplay ) if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh( true ); m_canvas->Refresh( true );
...@@ -1240,7 +1240,7 @@ void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC ) ...@@ -1240,7 +1240,7 @@ void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer ) void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
{ {
LAYER_NUM curLayer = getActiveLayer(); LAYER_NUM curLayer = getCurrentLayer();
// Check if the specified layer matches the present layer // Check if the specified layer matches the present layer
if( layer == curLayer ) if( layer == curLayer )
...@@ -1282,7 +1282,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer ) ...@@ -1282,7 +1282,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
GetScreen()->m_Route_Layer_TOP = curLayer; GetScreen()->m_Route_Layer_TOP = curLayer;
GetScreen()->m_Route_Layer_BOTTOM = layer; GetScreen()->m_Route_Layer_BOTTOM = layer;
setActiveLayer( curLayer ); setCurrentLayer( curLayer );
if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) ) if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
{ {
...@@ -1303,7 +1303,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer ) ...@@ -1303,7 +1303,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
// and a non-copper layer, or vice-versa? // and a non-copper layer, or vice-versa?
// ... // ...
setActiveLayer( layer ); setCurrentLayer( layer );
if( DisplayOpt.ContrastModeDisplay ) if( DisplayOpt.ContrastModeDisplay )
RefreshCanvas(); RefreshCanvas();
......
...@@ -246,7 +246,7 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T s ...@@ -246,7 +246,7 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T s
s_large = GetDesignSettings().m_DrawSegmentWidth; s_large = GetDesignSettings().m_DrawSegmentWidth;
if( getActiveLayer() == EDGE_N ) if( getCurrentLayer() == EDGE_N )
{ {
s_large = GetDesignSettings().m_EdgeSegmentWidth; s_large = GetDesignSettings().m_EdgeSegmentWidth;
} }
...@@ -255,7 +255,7 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T s ...@@ -255,7 +255,7 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T s
{ {
SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) ); SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) );
Segment->SetFlags( IS_NEW ); Segment->SetFlags( IS_NEW );
Segment->SetLayer( getActiveLayer() ); Segment->SetLayer( getCurrentLayer() );
Segment->SetWidth( s_large ); Segment->SetWidth( s_large );
Segment->SetShape( shape ); Segment->SetShape( shape );
Segment->SetAngle( 900 ); Segment->SetAngle( 900 );
......
...@@ -52,10 +52,10 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) ...@@ -52,10 +52,10 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
if( aTrack == NULL ) if( aTrack == NULL )
{ {
if( getActiveLayer() != ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP ) if( getCurrentLayer() != ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP )
setActiveLayer( ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP ); setCurrentLayer( ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP );
else else
setActiveLayer(((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM ); setCurrentLayer(((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM );
UpdateStatusBar(); UpdateStatusBar();
return true; return true;
...@@ -109,7 +109,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) ...@@ -109,7 +109,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
via->SetLayerPair( LAYER_N_BACK, LAYER_N_FRONT ); via->SetLayerPair( LAYER_N_BACK, LAYER_N_FRONT );
via->SetDrill( GetBoard()->GetCurrentViaDrill() ); via->SetDrill( GetBoard()->GetCurrentViaDrill() );
LAYER_NUM first_layer = getActiveLayer(); LAYER_NUM first_layer = getCurrentLayer();
LAYER_NUM last_layer; LAYER_NUM last_layer;
// prepare switch to new active layer: // prepare switch to new active layer:
...@@ -172,7 +172,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) ...@@ -172,7 +172,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
return false; return false;
} }
setActiveLayer( last_layer ); setCurrentLayer( last_layer );
TRACK* lastNonVia = g_CurrentTrackSegment; TRACK* lastNonVia = g_CurrentTrackSegment;
...@@ -194,7 +194,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC ) ...@@ -194,7 +194,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
*/ */
// set the layer to the new value // set the layer to the new value
track->SetLayer( getActiveLayer() ); track->SetLayer( getCurrentLayer() );
/* the start point is the via position and the end point is the cursor /* the start point is the via position and the end point is the cursor
* which also is on the via (will change when moving mouse) * which also is on the via (will change when moving mouse)
......
...@@ -243,7 +243,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit ...@@ -243,7 +243,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
break; break;
case HK_SWITCH_LAYER_TO_PREVIOUS: case HK_SWITCH_LAYER_TO_PREVIOUS:
ll = getActiveLayer(); ll = getCurrentLayer();
if( (ll <= LAYER_N_BACK) || (ll > LAYER_N_FRONT) ) if( (ll <= LAYER_N_BACK) || (ll > LAYER_N_FRONT) )
break; break;
...@@ -259,7 +259,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit ...@@ -259,7 +259,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
break; break;
case HK_SWITCH_LAYER_TO_NEXT: case HK_SWITCH_LAYER_TO_NEXT:
ll = getActiveLayer(); ll = getCurrentLayer();
if( (ll < LAYER_N_BACK) || (ll >= LAYER_N_FRONT) ) if( (ll < LAYER_N_BACK) || (ll >= LAYER_N_FRONT) )
break; break;
...@@ -365,7 +365,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit ...@@ -365,7 +365,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
break; break;
case HK_BACK_SPACE: case HK_BACK_SPACE:
if( /*m_ID_current_state == ID_TRACK_BUTT &&*/ (getActiveLayer() <= LAYER_N_FRONT) ) if( /*m_ID_current_state == ID_TRACK_BUTT &&*/ (getCurrentLayer() <= LAYER_N_FRONT) )
{ {
if( !itemCurrentlyEdited ) if( !itemCurrentlyEdited )
{ {
...@@ -572,7 +572,7 @@ bool PCB_EDIT_FRAME::OnHotkeyDeleteItem( wxDC* aDC ) ...@@ -572,7 +572,7 @@ bool PCB_EDIT_FRAME::OnHotkeyDeleteItem( wxDC* aDC )
switch( GetToolId() ) switch( GetToolId() )
{ {
case ID_TRACK_BUTT: case ID_TRACK_BUTT:
if( getActiveLayer() > LAYER_N_FRONT ) if( getCurrentLayer() > LAYER_N_FRONT )
return false; return false;
if( ItemFree ) if( ItemFree )
...@@ -941,7 +941,7 @@ bool PCB_EDIT_FRAME::OnHotkeyPlaceItem( wxDC* aDC ) ...@@ -941,7 +941,7 @@ bool PCB_EDIT_FRAME::OnHotkeyPlaceItem( wxDC* aDC )
*/ */
TRACK * PCB_EDIT_FRAME::OnHotkeyBeginRoute( wxDC* aDC ) TRACK * PCB_EDIT_FRAME::OnHotkeyBeginRoute( wxDC* aDC )
{ {
if( getActiveLayer() > LAYER_N_FRONT ) if( getCurrentLayer() > LAYER_N_FRONT )
return NULL; return NULL;
bool itemCurrentlyEdited = (GetCurItem() && GetCurItem()->GetFlags()); bool itemCurrentlyEdited = (GetCurItem() && GetCurItem()->GetFlags());
......
...@@ -243,7 +243,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -243,7 +243,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
if( GetToolId() == ID_PCB_ARC_BUTT ) if( GetToolId() == ID_PCB_ARC_BUTT )
shape = S_ARC; shape = S_ARC;
if( IsCopperLayer( getActiveLayer() ) ) if( IsCopperLayer( getCurrentLayer() ) )
{ {
DisplayError( this, _( "Graphic not allowed on Copper layers" ) ); DisplayError( this, _( "Graphic not allowed on Copper layers" ) );
break; break;
...@@ -267,7 +267,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -267,7 +267,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break; break;
case ID_TRACK_BUTT: case ID_TRACK_BUTT:
if( !IsCopperLayer( getActiveLayer() ) ) if( !IsCopperLayer( getCurrentLayer() ) )
{ {
DisplayError( this, _( "Tracks on Copper layers only " ) ); DisplayError( this, _( "Tracks on Copper layers only " ) );
break; break;
...@@ -367,7 +367,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -367,7 +367,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break; break;
case ID_PCB_DIMENSION_BUTT: case ID_PCB_DIMENSION_BUTT:
if( IsCopperLayer( getActiveLayer() ) ) if( IsCopperLayer( getCurrentLayer() ) )
{ {
DisplayError( this, _( "Dimension not allowed on Copper layers" ) ); DisplayError( this, _( "Dimension not allowed on Copper layers" ) );
break; break;
......
...@@ -75,6 +75,7 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings ...@@ -75,6 +75,7 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings
m_layerColors[ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE )] = COLOR4D( 0.8, 0.8, 0.8, 0.7 ); m_layerColors[ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE )] = COLOR4D( 0.8, 0.8, 0.8, 0.7 );
m_layerColors[ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE )] = COLOR4D( 0.8, 0.8, 0.8, 0.7 ); m_layerColors[ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE )] = COLOR4D( 0.8, 0.8, 0.8, 0.7 );
m_layerColors[ITEM_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE )] = COLOR4D( 0.8, 0.8, 0.8, 0.7 ); m_layerColors[ITEM_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE )] = COLOR4D( 0.8, 0.8, 0.8, 0.7 );
m_layerColors[ITEM_GAL_LAYER( WORKSHEET )] = COLOR4D( 0.5, 0.0, 0.0, 1.0 );
// 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 )
...@@ -137,29 +138,7 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions ) ...@@ -137,29 +138,7 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions )
} }
void PCB_RENDER_SETTINGS::update() const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
{
// Calculate darkened/highlighted variants of layer colors
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_layerColorsDark[i] = m_layerColors[i].Darkened( 1.0 - m_highlightFactor );
m_layerColorsSel[i] = m_layerColors[i].Brightened( m_selectFactor );
}
m_hiContrastColor = COLOR4D( m_hiContrastFactor, m_hiContrastFactor, m_hiContrastFactor,
m_layerOpacity );
}
PCB_PAINTER::PCB_PAINTER( GAL* aGal ) :
PAINTER( aGal )
{
}
const COLOR4D& PCB_PAINTER::GetColor( const VIEW_ITEM* aItem, int aLayer )
{ {
int netCode = -1; int netCode = -1;
...@@ -167,7 +146,7 @@ const COLOR4D& PCB_PAINTER::GetColor( const VIEW_ITEM* aItem, int aLayer ) ...@@ -167,7 +146,7 @@ const COLOR4D& PCB_PAINTER::GetColor( const VIEW_ITEM* aItem, int aLayer )
{ {
if( static_cast<const EDA_ITEM*>( aItem )->IsSelected() ) if( static_cast<const EDA_ITEM*>( aItem )->IsSelected() )
{ {
return m_pcbSettings->m_layerColorsSel[aLayer]; return m_layerColorsSel[aLayer];
} }
// Try to obtain the netcode for the item // Try to obtain the netcode for the item
...@@ -177,27 +156,53 @@ const COLOR4D& PCB_PAINTER::GetColor( const VIEW_ITEM* aItem, int aLayer ) ...@@ -177,27 +156,53 @@ const COLOR4D& PCB_PAINTER::GetColor( const VIEW_ITEM* aItem, int 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_pcbSettings->m_hiContrastEnabled && m_pcbSettings->m_activeLayers.count( aLayer ) == 0 ) if( m_hiContrastEnabled && m_activeLayers.count( aLayer ) == 0 )
return m_pcbSettings->m_hiContrastColor; return m_hiContrastColor;
// Single net highlight mode // Single net highlight mode
if( m_pcbSettings->m_highlightEnabled ) if( m_highlightEnabled )
{ {
if( netCode == m_pcbSettings->m_highlightNetcode ) if( netCode == m_highlightNetcode )
return m_pcbSettings->m_layerColorsHi[aLayer]; return m_layerColorsHi[aLayer];
else else
return m_pcbSettings->m_layerColorsDark[aLayer]; return m_layerColorsDark[aLayer];
} }
// No special modificators enabled // No special modificators enabled
return m_pcbSettings->m_layerColors[aLayer]; return m_layerColors[aLayer];
}
void PCB_RENDER_SETTINGS::update()
{
// Calculate darkened/highlighted variants of layer colors
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_layerColorsDark[i] = m_layerColors[i].Darkened( 1.0 - m_highlightFactor );
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 const COLOR4D& PCB_RENDER_SETTINGS::GetLayerColor( int aLayer ) const
{ {
return m_layerColors[aLayer]; return m_layerColors[aLayer];
} }
PCB_PAINTER::PCB_PAINTER( GAL* aGal ) :
PAINTER( aGal )
{
m_settings.reset( new PCB_RENDER_SETTINGS() );
m_pcbSettings = (PCB_RENDER_SETTINGS*) m_settings.get();
}
bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer ) bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
{ {
const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( aItem ); const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( aItem );
...@@ -284,8 +289,8 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer ) ...@@ -284,8 +289,8 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
double textSize = std::min( static_cast<double>( width ), length / netName.length() ); double textSize = std::min( static_cast<double>( width ), length / netName.length() );
// Set a proper color for the label // Set a proper color for the label
color = GetColor( aTrack, aTrack->GetLayer() ); color = m_pcbSettings->GetColor( aTrack, aTrack->GetLayer() );
COLOR4D labelColor = GetColor( NULL, aLayer ); COLOR4D labelColor = m_pcbSettings->GetColor( NULL, aLayer );
if( color.GetBrightness() > 0.5 ) if( color.GetBrightness() > 0.5 )
m_gal->SetStrokeColor( labelColor.Inverted() ); m_gal->SetStrokeColor( labelColor.Inverted() );
...@@ -305,7 +310,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer ) ...@@ -305,7 +310,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
else if( IsCopperLayer( aLayer )) else if( IsCopperLayer( aLayer ))
{ {
// Draw a regular track // Draw a regular track
color = GetColor( aTrack, aLayer ); color = m_pcbSettings->GetColor( aTrack, aLayer );
m_gal->SetStrokeColor( color ); m_gal->SetStrokeColor( color );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
...@@ -344,7 +349,7 @@ void PCB_PAINTER::draw( const SEGVIA* aVia, int aLayer ) ...@@ -344,7 +349,7 @@ void PCB_PAINTER::draw( const SEGVIA* aVia, int aLayer )
else else
return; return;
color = GetColor( aVia, aLayer ); color = m_pcbSettings->GetColor( aVia, aLayer );
if( m_pcbSettings->m_sketchModeSelect[VIAS_VISIBLE] ) if( m_pcbSettings->m_sketchModeSelect[VIAS_VISIBLE] )
{ {
...@@ -423,8 +428,8 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) ...@@ -423,8 +428,8 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m_gal->SetMirrored( false ); m_gal->SetMirrored( false );
// Set a proper color for the label // Set a proper color for the label
color = GetColor( aPad, aPad->GetLayer() ); color = m_pcbSettings->GetColor( aPad, aPad->GetLayer() );
COLOR4D labelColor = GetColor( NULL, aLayer ); COLOR4D labelColor = m_pcbSettings->GetColor( NULL, aLayer );
if( color.GetBrightness() > 0.5 ) if( color.GetBrightness() > 0.5 )
m_gal->SetStrokeColor( labelColor.Inverted() ); m_gal->SetStrokeColor( labelColor.Inverted() );
...@@ -470,7 +475,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) ...@@ -470,7 +475,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
} }
// Pad drawing // Pad drawing
color = GetColor( aPad, aLayer ); color = m_pcbSettings->GetColor( aPad, aLayer );
if( m_pcbSettings->m_sketchModeSelect[PADS_VISIBLE] ) if( m_pcbSettings->m_sketchModeSelect[PADS_VISIBLE] )
{ {
// Outline mode // Outline mode
...@@ -623,7 +628,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) ...@@ -623,7 +628,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment ) void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment )
{ {
COLOR4D color = GetColor( NULL, aSegment->GetLayer() ); COLOR4D color = m_pcbSettings->GetColor( NULL, aSegment->GetLayer() );
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
...@@ -712,7 +717,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer ) ...@@ -712,7 +717,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
if( aText->GetText().Length() == 0 ) if( aText->GetText().Length() == 0 )
return; return;
COLOR4D strokeColor = GetColor( NULL, aText->GetLayer() ); COLOR4D strokeColor = m_pcbSettings->GetColor( NULL, aText->GetLayer() );
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y ); VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y );
double orientation = aText->GetOrientation() * M_PI / 1800.0; double orientation = aText->GetOrientation() * M_PI / 1800.0;
...@@ -736,8 +741,8 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer ) ...@@ -736,8 +741,8 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
if( aText->GetLength() == 0 ) if( aText->GetLength() == 0 )
return; return;
COLOR4D strokeColor = GetColor( NULL, aLayer ); COLOR4D strokeColor = m_pcbSettings->GetColor( NULL, aLayer );
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y); VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y );
double orientation = aText->GetDrawRotation() * M_PI / 1800.0; double orientation = aText->GetDrawRotation() * M_PI / 1800.0;
m_gal->SetStrokeColor( strokeColor ); m_gal->SetStrokeColor( strokeColor );
...@@ -751,7 +756,7 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer ) ...@@ -751,7 +756,7 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone ) void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone )
{ {
COLOR4D color = GetColor( NULL, aZone->GetLayer() ); COLOR4D color = m_pcbSettings->GetColor( NULL, aZone->GetLayer() );
std::deque<VECTOR2D> corners; std::deque<VECTOR2D> corners;
PCB_RENDER_SETTINGS::DisplayZonesMode displayMode = m_pcbSettings->m_displayZoneMode; PCB_RENDER_SETTINGS::DisplayZonesMode displayMode = m_pcbSettings->m_displayZoneMode;
...@@ -828,7 +833,7 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer ) ...@@ -828,7 +833,7 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
else else
{ {
int layer = aDimension->GetLayer(); int layer = aDimension->GetLayer();
COLOR4D strokeColor = GetColor( NULL, layer ); COLOR4D strokeColor = m_pcbSettings->GetColor( NULL, layer );
m_gal->SetStrokeColor( strokeColor ); m_gal->SetStrokeColor( strokeColor );
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
...@@ -854,7 +859,7 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer ) ...@@ -854,7 +859,7 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
void PCB_PAINTER::draw( const PCB_TARGET* aTarget ) void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
{ {
COLOR4D strokeColor = GetColor( NULL, aTarget->GetLayer() ); COLOR4D strokeColor = m_pcbSettings->GetColor( NULL, aTarget->GetLayer() );
VECTOR2D position( aTarget->GetPosition() ); VECTOR2D position( aTarget->GetPosition() );
double size, radius; double size, radius;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#define __CLASS_PCB_PAINTER_H #define __CLASS_PCB_PAINTER_H
#include <layers_id_colors_and_visibility.h> #include <layers_id_colors_and_visibility.h>
#include <boost/shared_ptr.hpp>
#include <painter.h> #include <painter.h>
class EDA_ITEM; class EDA_ITEM;
...@@ -85,7 +86,10 @@ public: ...@@ -85,7 +86,10 @@ public:
*/ */
void LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions ); void LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions );
const COLOR4D& GetLayerColor ( int aLayer ) const; /// @copydoc RENDER_SETTINGS::GetColor()
virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const;
const COLOR4D& GetLayerColor( int aLayer ) const;
protected: protected:
/// @copydoc RENDER_SETTINGS::Update() /// @copydoc RENDER_SETTINGS::Update()
...@@ -129,13 +133,11 @@ public: ...@@ -129,13 +133,11 @@ public:
PAINTER::ApplySettings( aSettings ); PAINTER::ApplySettings( aSettings );
// Store PCB specific render settings // Store PCB specific render settings
m_pcbSettings = dynamic_cast<PCB_RENDER_SETTINGS*>( aSettings ); m_pcbSettings = (PCB_RENDER_SETTINGS*) m_settings.get(); //dynamic_cast<PCB_RENDER_SETTINGS*>( aSettings );
} }
/// @copydoc PAINTER::GetColor()
virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer );
protected: protected:
/// Just a properly casted pointer to settings
PCB_RENDER_SETTINGS* m_pcbSettings; PCB_RENDER_SETTINGS* m_pcbSettings;
// Drawing functions for various types of PCB-specific items // Drawing functions for various types of PCB-specific items
......
...@@ -487,6 +487,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, ...@@ -487,6 +487,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
PCB_EDIT_FRAME::~PCB_EDIT_FRAME() PCB_EDIT_FRAME::~PCB_EDIT_FRAME()
{ {
destroyTools();
m_RecordingMacros = -1; m_RecordingMacros = -1;
for( int i = 0; i < 10; i++ ) for( int i = 0; i < 10; i++ )
...@@ -729,7 +730,7 @@ void PCB_EDIT_FRAME::SetGridColor(EDA_COLOR_T aColor) ...@@ -729,7 +730,7 @@ void PCB_EDIT_FRAME::SetGridColor(EDA_COLOR_T aColor)
bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void ) bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void )
{ {
int copperlayercnt = GetBoard()->GetCopperLayerCount( ); int copperlayercnt = GetBoard()->GetCopperLayerCount( );
LAYER_NUM currLayer = getActiveLayer(); LAYER_NUM currLayer = getCurrentLayer();
if( !GetDesignSettings().m_MicroViasAllowed ) if( !GetDesignSettings().m_MicroViasAllowed )
return false; // Obvious.. return false; // Obvious..
...@@ -753,10 +754,7 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer ) ...@@ -753,10 +754,7 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
KiGfx::VIEW* view = m_galCanvas->GetView(); KiGfx::VIEW* view = m_galCanvas->GetView();
KiGfx::RENDER_SETTINGS* rSettings = view->GetPainter()->GetSettings(); KiGfx::RENDER_SETTINGS* rSettings = view->GetPainter()->GetSettings();
if( DisplayOpt.ContrastModeDisplay ) setTopLayer( aLayer );
{
view->ClearTopLayers();
view->SetTopLayer( aLayer );
rSettings->ClearActiveLayers(); rSettings->ClearActiveLayers();
rSettings->SetActiveLayer( aLayer ); rSettings->SetActiveLayer( aLayer );
...@@ -764,16 +762,58 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer ) ...@@ -764,16 +762,58 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
if( IsCopperLayer( aLayer ) ) if( IsCopperLayer( aLayer ) )
{ {
// Bring some other layers to the front in case of copper layers and make them colored // Bring some other layers to the front in case of copper layers and make them colored
// fixme do not like the idea of storing the list of layers here,
// should be done in some other way I guess..
LAYER_NUM layers[] = { LAYER_NUM layers[] = {
GetNetnameLayer( aLayer ), ITEM_GAL_LAYER( VIAS_VISIBLE ), GetNetnameLayer( aLayer ), ITEM_GAL_LAYER( VIAS_VISIBLE ),
ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ), ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ),
ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE ) ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE ),
ITEM_GAL_LAYER( SELECTION )
};
for( unsigned int i = 0; i < sizeof( layers ) / sizeof( LAYER_NUM ); ++i )
rSettings->SetActiveLayer( layers[i] );
// Pads should be shown too
if( aLayer == FIRST_COPPER_LAYER )
{
rSettings->SetActiveLayer( ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
rSettings->SetActiveLayer( ITEM_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ) );
}
else if( aLayer == LAST_COPPER_LAYER )
{
rSettings->SetActiveLayer( ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
rSettings->SetActiveLayer( ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ) );
}
}
view->UpdateAllLayersColor();
}
void PCB_EDIT_FRAME::setTopLayer( LAYER_NUM aLayer )
{
// Set display settings for high contrast mode
KiGfx::VIEW* view = m_galCanvas->GetView();
view->ClearTopLayers();
view->SetTopLayer( aLayer );
if( IsCopperLayer( aLayer ) )
{
// Bring some other layers to the front in case of copper layers and make them colored
// fixme do not like the idea of storing the list of layers here,
// should be done in some other way I guess..
LAYER_NUM layers[] = {
GetNetnameLayer( aLayer ), ITEM_GAL_LAYER( VIAS_VISIBLE ),
ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ),
ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE ),
ITEM_GAL_LAYER( SELECTION )
}; };
for( unsigned int i = 0; i < sizeof( layers ) / sizeof( LAYER_NUM ); ++i ) for( unsigned int i = 0; i < sizeof( layers ) / sizeof( LAYER_NUM ); ++i )
{ {
view->SetTopLayer( layers[i] ); view->SetTopLayer( layers[i] );
rSettings->SetActiveLayer( layers[i] );
} }
// Pads should be shown too // Pads should be shown too
...@@ -781,27 +821,35 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer ) ...@@ -781,27 +821,35 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
{ {
view->SetTopLayer( ITEM_GAL_LAYER( PAD_BK_VISIBLE ) ); view->SetTopLayer( ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetTopLayer( ITEM_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ) ); view->SetTopLayer( ITEM_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ) );
rSettings->SetActiveLayer( ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
rSettings->SetActiveLayer( ITEM_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ) );
} }
else if( aLayer == LAST_COPPER_LAYER ) else if( aLayer == LAST_COPPER_LAYER )
{ {
view->SetTopLayer( ITEM_GAL_LAYER( PAD_FR_VISIBLE ) ); view->SetTopLayer( ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetTopLayer( ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ) ); view->SetTopLayer( ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ) );
rSettings->SetActiveLayer( ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
rSettings->SetActiveLayer( ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ) );
} }
} }
view->UpdateAllLayersOrder(); view->UpdateAllLayersOrder();
view->UpdateAllLayersColor(); }
}
void PCB_EDIT_FRAME::setCurrentLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate )
{
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
setHighContrastLayer( aLayer );
if( doLayerWidgetUpdate )
syncLayerWidgetLayer();
if( m_galCanvasActive )
m_galCanvas->Refresh();
} }
void PCB_EDIT_FRAME::syncLayerWidgetLayer() void PCB_EDIT_FRAME::syncLayerWidgetLayer()
{ {
m_Layers->SelectLayer( getActiveLayer() ); m_Layers->SelectLayer( getCurrentLayer() );
m_Layers->OnLayerSelected(); m_Layers->OnLayerSelected();
} }
......
...@@ -105,7 +105,7 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator() ...@@ -105,7 +105,7 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator()
previous_Route_Layer_BOTTOM_color, previous_via_color; previous_Route_Layer_BOTTOM_color, previous_via_color;
/* get colors, and redraw bitmap button only on changes */ /* get colors, and redraw bitmap button only on changes */
active_layer_color = GetBoard()->GetLayerColor(getActiveLayer()); active_layer_color = GetBoard()->GetLayerColor(getCurrentLayer());
if( previous_active_layer_color != active_layer_color ) if( previous_active_layer_color != active_layer_color )
{ {
......
...@@ -96,7 +96,7 @@ void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent ) ...@@ -96,7 +96,7 @@ void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
void PCB_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent ) void PCB_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
{ {
m_SelLayerBox->SetLayerSelection( getActiveLayer() ); m_SelLayerBox->SetLayerSelection( getCurrentLayer() );
} }
......
...@@ -61,7 +61,7 @@ void MOVE_TOOL::Reset() ...@@ -61,7 +61,7 @@ void MOVE_TOOL::Reset()
} }
// the tool launches upon reception of activate ("pcbnew.InteractiveMove") // the tool launches upon reception of activate ("pcbnew.InteractiveMove")
Go( &MOVE_TOOL::Main, TOOL_EVENT( TC_Command, TA_ActivateTool, GetName() ) ); //"pcbnew.InteractiveMove")); Go( &MOVE_TOOL::Main, TOOL_EVENT( TC_Command, TA_ActivateTool, GetName() ) );
} }
......
...@@ -89,7 +89,8 @@ private: ...@@ -89,7 +89,8 @@ private:
void RestorePosition() void RestorePosition()
{ {
item->SetPosition( wxPoint( position.x, position.y ) ); wxPoint curPosition = item->GetPosition();
item->Move( wxPoint( position.x - curPosition.x, position.y - curPosition.y ) );
} }
void RestoreVisibility() void RestoreVisibility()
......
...@@ -40,18 +40,25 @@ ...@@ -40,18 +40,25 @@
void PCB_EDIT_FRAME::setupTools() void PCB_EDIT_FRAME::setupTools()
{ {
// create the manager and dispatcher. Route draw panel events to the dispatcher. // Create the manager and dispatcher & route draw panel events to the dispatcher
m_toolManager = new TOOL_MANAGER; m_toolManager = new TOOL_MANAGER;
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, this ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, this );
m_galCanvas->SetEventDispatcher( m_toolDispatcher ); m_galCanvas->SetEventDispatcher( m_toolDispatcher );
// register our selection tool. // Register tools.
m_toolManager->RegisterTool( new SELECTION_TOOL ); m_toolManager->RegisterTool( new SELECTION_TOOL );
m_toolManager->RegisterTool( new ROUTER_TOOL ); m_toolManager->RegisterTool( new ROUTER_TOOL );
m_toolManager->RegisterTool( new MOVE_TOOL ); m_toolManager->RegisterTool( new MOVE_TOOL );
} }
void PCB_EDIT_FRAME::destroyTools()
{
delete m_toolDispatcher;
delete m_toolManager;
}
void PCB_EDIT_FRAME::onGenericCommand( wxCommandEvent &aEvent ) void PCB_EDIT_FRAME::onGenericCommand( wxCommandEvent &aEvent )
{ {
m_toolDispatcher->DispatchWxCommand( aEvent ); m_toolDispatcher->DispatchWxCommand( aEvent );
......
...@@ -47,7 +47,7 @@ void SELECTION_AREA::ViewGetLayers( int aLayers[], int& aCount ) const ...@@ -47,7 +47,7 @@ void SELECTION_AREA::ViewGetLayers( int aLayers[], int& aCount ) const
} }
void SELECTION_AREA::ViewDraw( int aLayer, GAL* aGal, const BOX2I& aVisibleArea ) const void SELECTION_AREA::ViewDraw( int aLayer, GAL* aGal ) const
{ {
aGal->SetLineWidth( 1.0 ); aGal->SetLineWidth( 1.0 );
aGal->SetStrokeColor( COLOR4D( 1.0, 1.0, 0.4, 1.0 ) ); aGal->SetStrokeColor( COLOR4D( 1.0, 1.0, 0.4, 1.0 ) );
......
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
virtual const BOX2I ViewBBox() const; virtual const BOX2I ViewBBox() const;
void ViewDraw( int aLayer, KiGfx::GAL* aGal, const BOX2I& aVisibleArea ) const; void ViewDraw( int aLayer, KiGfx::GAL* aGal ) const;
void ViewGetLayers( int aLayers[], int& aCount ) const; void ViewGetLayers( int aLayers[], int& aCount ) const;
void SetOrigin ( VECTOR2I aOrigin ) void SetOrigin ( VECTOR2I aOrigin )
...@@ -63,7 +63,7 @@ public: ...@@ -63,7 +63,7 @@ public:
m_end = aEnd; m_end = aEnd;
} }
void Show( int x, std::ostream& st) const void Show( int x, std::ostream& st ) const
{ {
} }
......
...@@ -111,8 +111,28 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) ...@@ -111,8 +111,28 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
} }
else else
{ {
// Now user wants to drag the selected items bool runTool = false;
// Check if dragging event started within the currently selected items bounding box
std::set<BOARD_ITEM*>::iterator it, it_end;
for( it = m_selectedItems.begin(), it_end = m_selectedItems.end(); it != it_end; ++it )
{
BOX2I itemBox = (*it)->ViewBBox();
itemBox.Inflate( 500000 ); // Give some margin for gripping an item
if( itemBox.Contains( evt->Position() ) )
{
// Click event occurred within a selected item bounding box
// -> user wants to drag selected items
runTool = true;
break;
}
}
if( runTool )
m_toolMgr->InvokeTool( "pcbnew.InteractiveMove" ); m_toolMgr->InvokeTool( "pcbnew.InteractiveMove" );
else
clearSelection();
} }
} }
else if( dragging ) else if( dragging )
...@@ -184,9 +204,26 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere ) ...@@ -184,9 +204,26 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere )
break; break;
default: default:
// Remove footprints, they have to be selected by clicking on area that does not
// contain anything but footprint
for( int i = 0; i < collector.GetCount(); ++i )
{
BOARD_ITEM* boardItem = ( collector )[i];
if( boardItem->Type() == PCB_MODULE_T )
collector.Remove( i );
}
// Let's see if there is still disambiguation in selection..
if( collector.GetCount() == 1 )
{
toggleSelection( collector[0] );
}
else
{
item = disambiguationMenu( &collector ); item = disambiguationMenu( &collector );
if( item ) if( item )
toggleSelection( item ); toggleSelection( item );
}
break; break;
} }
} }
...@@ -306,7 +343,7 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) ...@@ -306,7 +343,7 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
for( int i = 0; i < limit; ++i ) for( int i = 0; i < limit; ++i )
{ {
wxString text; wxString text;
BOARD_ITEM *item = ( *aCollector )[i]; BOARD_ITEM* item = ( *aCollector )[i];
text = item->GetSelectMenuText(); text = item->GetSelectMenuText();
m_menu->Add( text, i ); m_menu->Add( text, i );
} }
......
...@@ -518,7 +518,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) ...@@ -518,7 +518,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
if( !GetBoard()->m_CurrentZoneContour ) if( !GetBoard()->m_CurrentZoneContour )
{ {
if( GetToolId() == ID_PCB_KEEPOUT_AREA_BUTT && if( GetToolId() == ID_PCB_KEEPOUT_AREA_BUTT &&
getActiveLayer() >= FIRST_NON_COPPER_LAYER ) getCurrentLayer() >= FIRST_NON_COPPER_LAYER )
{ {
DisplayError( this, DisplayError( this,
_( "Error: a keepout area is allowed only on copper layers" ) ); _( "Error: a keepout area is allowed only on copper layers" ) );
...@@ -537,7 +537,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) ...@@ -537,7 +537,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
ZONE_EDIT_T edited; ZONE_EDIT_T edited;
// Init zone params to reasonable values // Init zone params to reasonable values
zone->SetLayer( getActiveLayer() ); zone->SetLayer( getCurrentLayer() );
// Prompt user for parameters: // Prompt user for parameters:
m_canvas->SetIgnoreMouseEvents( true ); m_canvas->SetIgnoreMouseEvents( true );
...@@ -602,7 +602,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) ...@@ -602,7 +602,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
return 0; return 0;
// Switch active layer to the selected zone layer // Switch active layer to the selected zone layer
setActiveLayer( zoneInfo.m_CurrentZone_Layer ); setCurrentLayer( zoneInfo.m_CurrentZone_Layer );
SetZoneSettings( zoneInfo ); SetZoneSettings( zoneInfo );
} }
...@@ -612,7 +612,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) ...@@ -612,7 +612,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
// zone (add cutout or similar zone) // zone (add cutout or similar zone)
zoneInfo.m_CurrentZone_Layer = s_CurrentZone->GetLayer(); zoneInfo.m_CurrentZone_Layer = s_CurrentZone->GetLayer();
setActiveLayer( s_CurrentZone->GetLayer() ); setCurrentLayer( s_CurrentZone->GetLayer() );
zoneInfo << *s_CurrentZone; zoneInfo << *s_CurrentZone;
......
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