Commit f45836bf authored by Maciej Suminski's avatar Maciej Suminski
parents 7161c5bd c3ed210e
......@@ -228,6 +228,7 @@ set( COMMON_SRCS
math/math_util.cpp
tool/tool_action.cpp
tool/tool_base.cpp
tool/tool_manager.cpp
tool/tool_dispatcher.cpp
......
......@@ -1033,10 +1033,10 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show( aEnable );
m_auimgr.Update();
SetGalCanvasActive( aEnable );
// Reset current tool on switch();
SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
if( aEnable )
GetGalCanvas()->SetFocus();
m_galCanvasActive = aEnable;
}
//-----< BASE_SCREEN API moved here >--------------------------------------------
......
......@@ -41,6 +41,8 @@
#include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h>
#include <boost/foreach.hpp>
#ifdef __WXDEBUG__
#include <profile.h>
#endif /* __WXDEBUG__ */
......@@ -50,8 +52,9 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
GalType aGalType ) :
wxWindow( aParentWindow, aWindowId, aPosition, aSize )
{
m_parent = aParentWindow;
m_gal = NULL;
m_currentGal = GAL_TYPE_NONE;
m_backend = GAL_TYPE_NONE;
m_view = NULL;
m_painter = NULL;
m_eventDispatcher = NULL;
......@@ -67,33 +70,28 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
/* Generic events for the Tool Dispatcher */
Connect( wxEVT_MOTION, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_LEFT_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_LEFT_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_LEFT_DCLICK, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_RIGHT_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_RIGHT_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_RIGHT_DCLICK, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MIDDLE_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MIDDLE_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MIDDLE_DCLICK, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_MOUSEWHEEL, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_CHAR_HOOK, wxEventHandler( EDA_DRAW_PANEL_GAL::skipEvent ) );
Connect( wxEVT_CHAR, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
Connect( KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE,
wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
Connect( wxEVT_ENTER_WINDOW, wxEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), NULL, this );
const wxEventType events[] =
{
wxEVT_LEFT_UP, wxEVT_LEFT_DOWN, wxEVT_LEFT_DCLICK,
wxEVT_RIGHT_UP, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_DCLICK,
wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_DCLICK,
wxEVT_MOTION, wxEVT_MOUSEWHEEL, wxEVT_CHAR, KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE
};
BOOST_FOREACH( wxEventType eventType, events )
{
Connect( eventType, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ),
NULL, m_eventDispatcher );
}
// Set up timer that prevents too frequent redraw commands
m_refreshTimer.SetOwner( this );
m_pendingRefresh = false;
m_drawing = false;
Connect( wxEVT_TIMER, wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this );
this->SetFocus();
}
......@@ -160,7 +158,7 @@ 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 aEraseBackground, const wxRect* aRect )
{
if( m_pendingRefresh )
return;
......@@ -183,6 +181,50 @@ void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect )
}
void EDA_DRAW_PANEL_GAL::SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher )
{
m_eventDispatcher = aEventDispatcher;
#if wxCHECK_VERSION( 3, 0, 0 )
if( m_eventDispatcher )
{
m_parent->Connect( wxEVT_TOOL,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher );
}
else
{
// While loops are used to be sure, that we are removing all event handlers
while( m_parent->Disconnect( wxEVT_TOOL,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher ) );
}
#else
if( m_eventDispatcher )
{
m_parent->Connect( wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher );
m_parent->Connect( wxEVT_COMMAND_TOOL_CLICKED,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher );
}
else
{
// While loops are used to be sure, that we are removing all event handlers
while( m_parent->Disconnect( wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher ) );
while( m_parent->Disconnect( wxEVT_COMMAND_TOOL_CLICKED,
wxCommandEventHandler( TOOL_DISPATCHER::DispatchWxCommand ),
NULL, m_eventDispatcher ) );
}
#endif
}
void EDA_DRAW_PANEL_GAL::StartDrawing()
{
m_pendingRefresh = false;
......@@ -201,10 +243,32 @@ void EDA_DRAW_PANEL_GAL::StopDrawing()
}
void EDA_DRAW_PANEL_GAL::SetHighContrastLayer( LAYER_NUM aLayer )
{
// Set display settings for high contrast mode
KIGFX::RENDER_SETTINGS* rSettings = m_view->GetPainter()->GetSettings();
SetTopLayer( aLayer );
rSettings->ClearActiveLayers();
rSettings->SetActiveLayer( aLayer );
m_view->UpdateAllLayersColor();
}
void EDA_DRAW_PANEL_GAL::SetTopLayer( LAYER_NUM aLayer )
{
m_view->ClearTopLayers();
m_view->SetTopLayer( aLayer );
m_view->UpdateAllLayersOrder();
}
void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
{
// Do not do anything if the currently used GAL is correct
if( aGalType == m_currentGal && m_gal != NULL )
if( aGalType == m_backend && m_gal != NULL )
return;
// Prevent refreshing canvas during backend switch
......@@ -235,21 +299,16 @@ void EDA_DRAW_PANEL_GAL::SwitchBackend( GalType aGalType )
if( m_view )
m_view->SetGAL( m_gal );
m_currentGal = aGalType;
m_backend = aGalType;
}
void EDA_DRAW_PANEL_GAL::onEvent( wxEvent& aEvent )
{
if( !m_eventDispatcher )
{
aEvent.Skip();
return;
}
else
{
m_eventDispatcher->DispatchWxEvent( aEvent );
}
Refresh();
}
......@@ -260,10 +319,3 @@ void EDA_DRAW_PANEL_GAL::onEnter( wxEvent& aEvent )
// Getting focus is necessary in order to receive key events properly
SetFocus();
}
void EDA_DRAW_PANEL_GAL::skipEvent( wxEvent& aEvent )
{
// This is necessary for CHAR_HOOK event to generate KEY_UP and KEY_DOWN events
aEvent.Skip();
}
......@@ -55,6 +55,9 @@ void CAIRO_COMPOSITOR::Resize( unsigned int aWidth, unsigned int aHeight )
{
clean();
assert( m_width > 0 );
assert( m_height > 0 );
m_width = aWidth;
m_height = aHeight;
......
......@@ -75,6 +75,9 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
SetSize( aParent->GetSize() );
screenSize = VECTOR2I( aParent->GetSize() );
cursorPixels = NULL;
cursorPixelsSaved = NULL;
initCursor();
// Grid color settings are different in Cairo and OpenGL
......@@ -808,6 +811,13 @@ void CAIRO_GAL::ClearTarget( RENDER_TARGET aTarget )
}
void CAIRO_GAL::SetCursorSize( unsigned int aCursorSize )
{
GAL::SetCursorSize( aCursorSize );
initCursor();
}
void CAIRO_GAL::DrawCursor( const VECTOR2D& aCursorPosition )
{
// Now we should only store the position of the mouse cursor
......@@ -890,6 +900,12 @@ void CAIRO_GAL::skipMouseEvent( wxMouseEvent& aEvent )
void CAIRO_GAL::initCursor()
{
if( cursorPixels )
delete cursorPixels;
if( cursorPixelsSaved )
delete cursorPixelsSaved;
cursorPixels = new wxBitmap( cursorSize, cursorSize );
cursorPixelsSaved = new wxBitmap( cursorSize, cursorSize );
......
......@@ -134,9 +134,6 @@ void GAL::DrawGrid()
// Draw the grid
// For the drawing the start points, end points and increments have
// to be calculated in world coordinates
gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
(long) gridOrigin.y % (long) gridSize.y );
VECTOR2D worldStartPoint = screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
VECTOR2D worldEndPoint = screenWorldMatrix * VECTOR2D( screenSize );
......@@ -160,10 +157,10 @@ void GAL::DrawGrid()
assert( gridEndY >= gridStartY );
// Correct the index, else some lines are not correctly painted
gridStartX -= ( gridOrigin.x / gridSize.x ) + 1;
gridStartY -= ( gridOrigin.y / gridSize.y ) + 1;
gridEndX += ( gridOrigin.x / gridSize.x ) + 1;
gridEndY += ( gridOrigin.y / gridSize.y ) + 1;
gridStartX -= abs( gridOrigin.x / gridSize.x ) + 1;
gridStartY -= abs( gridOrigin.y / gridSize.y ) + 1;
gridEndX += abs( gridOrigin.x / gridSize.x ) + 1;
gridEndY += abs( gridOrigin.y / gridSize.y ) + 1;
// Draw the grid behind all other layers
SetLayerDepth( depthRange.y * 0.75 );
......
......@@ -35,7 +35,7 @@
using namespace KIGFX;
OPENGL_COMPOSITOR::OPENGL_COMPOSITOR() :
m_initialized( false ), m_current( 0 )
m_initialized( false ), m_current( 0 ), m_currentFbo( DIRECT_RENDERING )
{
}
......@@ -52,9 +52,6 @@ void OPENGL_COMPOSITOR::Initialize()
if( m_initialized )
return;
// Get the maximum number of buffers
glGetIntegerv( GL_MAX_COLOR_ATTACHMENTS, (GLint*) &m_maxBuffers );
// We need framebuffer objects for drawing the screen contents
// Generate framebuffer and a depth buffer
glGenFramebuffersEXT( 1, &m_framebuffer );
......@@ -68,15 +65,13 @@ void OPENGL_COMPOSITOR::Initialize()
// Use here a size of 24 bits for the depth buffer, 8 bits for the stencil buffer
// this is required later for anti-aliasing
glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL, m_width, m_height );
glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, m_width, m_height );
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER_EXT, m_depthBuffer );
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT,
GL_RENDERBUFFER_EXT, m_depthBuffer );
GL_RENDERBUFFER_EXT, m_depthBuffer );
// Unbind the framebuffer, so by default all the rendering goes directly to the display
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, DIRECT_RENDERING );
m_currentFbo = 0;
m_currentFbo = DIRECT_RENDERING;
m_initialized = true;
}
......@@ -96,9 +91,14 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
{
wxASSERT( m_initialized );
if( usedBuffers() >= m_maxBuffers )
unsigned int maxBuffers;
// Get the maximum number of buffers
glGetIntegerv( GL_MAX_COLOR_ATTACHMENTS, (GLint*) &maxBuffers );
if( usedBuffers() >= maxBuffers )
{
DisplayError( NULL, wxT( "Cannot create more framebuffers. OpenGL rendering "
DisplayError( NULL, _( "Cannot create more framebuffers. OpenGL rendering "
"backend requires at least 3 framebuffers. You may try to update/change "
"your graphic drivers." ) );
return 0; // Unfortunately we have no more free buffers left
......@@ -114,7 +114,7 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
// Set texture parameters
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RGBA,
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, m_width, m_height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, NULL );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
......@@ -122,7 +122,8 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
// Bind the texture to the specific attachment point, clear and rebind the screen
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_framebuffer );
m_currentFbo = m_framebuffer;
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachmentPoint, GL_TEXTURE_2D, textureTarget, 0 );
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachmentPoint,
GL_TEXTURE_2D, textureTarget, 0 );
// Check the status, exit if the framebuffer can't be created
GLenum status = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
......@@ -132,38 +133,38 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
switch( status )
{
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
DisplayError( NULL, wxT( "Cannot create the framebuffer." ) );
DisplayError( NULL, _( "Cannot create the framebuffer." ) );
break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
DisplayError( NULL, wxT( "The framebuffer attachment points are incomplete." ) );
DisplayError( NULL, _( "The framebuffer attachment points are incomplete." ) );
break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
DisplayError( NULL, wxT( "The framebuffer does not have at least "
"one image attached to it." ) );
DisplayError( NULL, _( "The framebuffer does not have at least "
"one image attached to it." ) );
break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
DisplayError( NULL, wxT( "The framebuffer read buffer is incomplete." ) );
DisplayError( NULL, _( "The framebuffer read buffer is incomplete." ) );
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
DisplayError( NULL, wxT( "The combination of internal formats of the attached images "
"violates an implementation-dependent set of restrictions." ) );
DisplayError( NULL, _( "The combination of internal formats of the attached images "
"violates an implementation-dependent set of restrictions." ) );
break;
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT:
DisplayError( NULL, wxT( "GL_RENDERBUFFER_SAMPLES is not the same "
"for all attached renderbuffers" ) );
DisplayError( NULL, _( "GL_RENDERBUFFER_SAMPLES is not the same "
"for all attached renderbuffers" ) );
break;
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT:
DisplayError( NULL, wxT( "Framebuffer incomplete layer targets errors." ) );
DisplayError( NULL, _( "Framebuffer incomplete layer targets errors." ) );
break;
default:
DisplayError( NULL, wxT( "Cannot create the framebuffer." ) );
DisplayError( NULL, _( "Cannot create the framebuffer." ) );
break;
}
......@@ -192,7 +193,6 @@ void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
// Change the rendering destination to the selected attachment point
if( aBufferHandle == DIRECT_RENDERING )
{
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, DIRECT_RENDERING );
m_currentFbo = DIRECT_RENDERING;
}
else if( m_currentFbo != m_framebuffer )
......@@ -221,12 +221,7 @@ void OPENGL_COMPOSITOR::ClearBuffer()
void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle )
{
wxASSERT( m_initialized );
if( aBufferHandle == 0 || aBufferHandle > usedBuffers() )
{
DisplayError( NULL, wxT( "Wrong framebuffer handle" ) );
return;
}
wxASSERT( aBufferHandle != 0 && aBufferHandle <= usedBuffers() );
// Switch to the main framebuffer and blit the scene
glBindFramebufferEXT( GL_FRAMEBUFFER, DIRECT_RENDERING );
......@@ -274,8 +269,8 @@ void OPENGL_COMPOSITOR::clean()
{
wxASSERT( m_initialized );
glDeleteFramebuffersEXT( 1, &m_framebuffer );
glDeleteRenderbuffersEXT( 1, &m_depthBuffer );
glBindFramebufferEXT( GL_FRAMEBUFFER, DIRECT_RENDERING );
m_currentFbo = DIRECT_RENDERING;
OPENGL_BUFFERS::const_iterator it;
......@@ -286,8 +281,8 @@ void OPENGL_COMPOSITOR::clean()
m_buffers.clear();
glDeleteFramebuffersEXT( 1, &m_framebuffer );
glDeleteRenderbuffersEXT( 1, &m_depthBuffer );
m_initialized = false;
}
GLuint OPENGL_COMPOSITOR::m_currentFbo = DIRECT_RENDERING;
......@@ -45,6 +45,8 @@ void InitTesselatorCallbacks( GLUtesselator* aTesselator );
const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0 };
wxGLContext* OPENGL_GAL::glContext = NULL;
OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
wxEvtHandler* aPaintListener, const wxString& aName ) :
wxGLCanvas( aParent, wxID_ANY, (int*) glAttributes, wxDefaultPosition, wxDefaultSize,
......@@ -54,7 +56,9 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
overlayManager( false )
{
// Create the OpenGL-Context
glContext = new wxGLContext( this );
if( glContext == NULL )
glContext = new wxGLContext( this );
parentWindow = aParent;
mouseListener = aMouseListener;
paintListener = aPaintListener;
......@@ -113,8 +117,6 @@ OPENGL_GAL::~OPENGL_GAL()
gluDeleteTess( tesselator );
ClearCache();
delete glContext;
}
......@@ -122,23 +124,22 @@ void OPENGL_GAL::BeginDrawing()
{
SetCurrent( *glContext );
clientDC = new wxClientDC( this );
clientDC = new wxPaintDC( this );
// Initialize GLEW, FBOs & VBOs
if( !isGlewInitialized )
initGlew();
if( !isFramebufferInitialized )
{
// Set up the view port
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glViewport( 0, 0, (GLsizei) screenSize.x, (GLsizei) screenSize.y );
// Set up the view port
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glViewport( 0, 0, (GLsizei) screenSize.x, (GLsizei) screenSize.y );
// Create the screen transformation
glOrtho( 0, (GLint) screenSize.x, 0, (GLsizei) screenSize.y,
-depthRange.x, -depthRange.y );
// Create the screen transformation
glOrtho( 0, (GLint) screenSize.x, 0, (GLsizei) screenSize.y, -depthRange.x, -depthRange.y );
if( !isFramebufferInitialized )
{
// Prepare rendering target buffers
compositor.Initialize();
mainBuffer = compositor.CreateBuffer();
......@@ -967,7 +968,7 @@ void OPENGL_GAL::initGlew()
exit( 1 );
}
// Vertex buffer have to be supported
// Vertex buffer has to be supported
if( !GLEW_ARB_vertex_buffer_object )
{
DisplayError( parentWindow, wxT( "Vertex buffer objects are not supported!" ) );
......
......@@ -31,7 +31,8 @@
#include <gal/opengl/cached_container.h>
#include <gal/opengl/noncached_container.h>
#include <gal/opengl/shader.h>
#include <wx/log.h>
#include <cstdlib>
#include <cstring>
using namespace KIGFX;
......@@ -45,9 +46,11 @@ VERTEX_CONTAINER* VERTEX_CONTAINER::MakeContainer( bool aCached )
VERTEX_CONTAINER::VERTEX_CONTAINER( unsigned int aSize ) :
m_freeSpace( aSize ), m_currentSize( aSize ), m_initialSize( aSize ), m_failed( false )
m_freeSpace( aSize ), m_currentSize( aSize ), m_initialSize( aSize ),
m_failed( false ), m_dirty( true )
{
m_vertices = static_cast<VERTEX*>( malloc( aSize * sizeof( VERTEX ) ) );
memset( m_vertices, 0x00, aSize * sizeof( VERTEX ) );
}
......
......@@ -38,6 +38,7 @@ RENDER_SETTINGS::RENDER_SETTINGS()
m_highlightEnabled = false;
m_hiContrastEnabled = false;
m_hiContrastFactor = 0.2;
m_highlightNetcode = -1;
m_outlineWidth = 1;
m_worksheetLineWidth = 100000;
......
......@@ -44,8 +44,6 @@ ACTION_MANAGER::~ACTION_MANAGER()
void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
{
// Check if the TOOL_ACTION was not registered before
assert( aAction->GetId() == -1 );
// TOOL_ACTIONs are supposed to be named [appName.]toolName.actionName (with dots between)
// action name without specifying at least toolName is not valid
assert( aAction->GetName().find( '.', 0 ) != std::string::npos );
......@@ -54,15 +52,14 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
assert( m_actionNameIndex.find( aAction->m_name ) == m_actionNameIndex.end() );
assert( m_actionIdIndex.find( aAction->m_id ) == m_actionIdIndex.end() );
aAction->setId( MakeActionId( aAction->m_name ) );
if( aAction->m_id == -1 )
aAction->m_id = MakeActionId( aAction->m_name );
m_actionNameIndex[aAction->m_name] = aAction;
m_actionIdIndex[aAction->m_id] = aAction;
if( aAction->HasHotKey() )
m_actionHotKeys[aAction->m_currentHotKey].push_back( aAction );
aAction->setActionMgr( this );
}
......@@ -71,10 +68,6 @@ void ACTION_MANAGER::UnregisterAction( TOOL_ACTION* aAction )
m_actionNameIndex.erase( aAction->m_name );
m_actionIdIndex.erase( aAction->m_id );
// Indicate that the ACTION_MANAGER no longer care about the object
aAction->setActionMgr( NULL );
aAction->setId( -1 );
if( aAction->HasHotKey() )
{
std::list<TOOL_ACTION*>& actions = m_actionHotKeys[aAction->m_currentHotKey];
......@@ -96,24 +89,14 @@ int ACTION_MANAGER::MakeActionId( const std::string& aActionName )
}
bool ACTION_MANAGER::RunAction( const std::string& aActionName ) const
TOOL_ACTION* ACTION_MANAGER::FindAction( const std::string& aActionName ) const
{
std::map<std::string, TOOL_ACTION*>::const_iterator it = m_actionNameIndex.find( aActionName );
if( it == m_actionNameIndex.end() )
return false; // no action with given name found
if( it != m_actionNameIndex.end() )
return it->second;
RunAction( it->second );
return true;
}
void ACTION_MANAGER::RunAction( const TOOL_ACTION* aAction ) const
{
TOOL_EVENT event = aAction->MakeEvent();
m_toolMgr->ProcessEvent( event );
return NULL;
}
......@@ -160,6 +143,8 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
if( tool )
{
// Choose the action that goes to the tool with highest priority
// (i.e. is on the top of active tools stack)
priority = m_toolMgr->GetPriority( tool->GetId() );
if( priority >= 0 && priority > highestPriority )
......@@ -170,13 +155,16 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
}
}
if( !global && !context ) // currently there is no valid action to run
return false;
if( context )
RunAction( context );
{
m_toolMgr->RunAction( *context, true );
return true;
}
else if( global )
RunAction( global );
{
m_toolMgr->RunAction( *global, true );
return true;
}
return true;
return false;
}
......@@ -71,6 +71,47 @@ CONTEXT_MENU::CONTEXT_MENU( const CONTEXT_MENU& aMenu ) :
}
CONTEXT_MENU& CONTEXT_MENU::operator=( const CONTEXT_MENU& aMenu )
{
Clear();
m_titleSet = aMenu.m_titleSet;
m_selected = aMenu.m_selected;
m_tool = aMenu.m_tool;
m_toolActions = aMenu.m_toolActions;
m_customHandler = aMenu.m_customHandler;
// Copy all the menu entries
for( unsigned i = 0; i < aMenu.GetMenuItemCount(); ++i )
{
wxMenuItem* item = aMenu.FindItemByPosition( i );
if( item->IsSubMenu() )
{
#ifdef DEBUG
// Submenus of a CONTEXT_MENU are supposed to be CONTEXT_MENUs as well
assert( dynamic_cast<CONTEXT_MENU*>( item->GetSubMenu() ) );
#endif
CONTEXT_MENU* menu = new CONTEXT_MENU( static_cast<const CONTEXT_MENU&>( *item->GetSubMenu() ) );
AppendSubMenu( menu, item->GetItemLabel(), wxEmptyString );
}
else
{
wxMenuItem* newItem = new wxMenuItem( this, item->GetId(), item->GetItemLabel(),
wxEmptyString, item->GetKind() );
Append( newItem );
copyItem( item, newItem );
}
}
setupEvents();
return *this;
}
void CONTEXT_MENU::setupEvents()
{
Connect( wxEVT_MENU_HIGHLIGHT, wxEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this );
......@@ -144,11 +185,12 @@ void CONTEXT_MENU::Clear()
{
m_titleSet = false;
// Remove all the entries from context menu
for( unsigned i = 0; i < GetMenuItemCount(); ++i )
Destroy( FindItemByPosition( 0 ) );
GetMenuItems().DeleteContents( true );
GetMenuItems().Clear();
m_toolActions.clear();
GetMenuItems().DeleteContents( false ); // restore the default so destructor does not go wild
assert( GetMenuItemCount() == 0 );
}
......
/*
* 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
*/
#include <tool/tool_action.h>
std::string TOOL_ACTION::GetToolName() const
{
int dotCount = std::count( m_name.begin(), m_name.end(), '.' );
switch( dotCount )
{
case 0:
assert( false ); // Invalid action name format
return "";
case 1:
return m_name;
case 2:
return m_name.substr( 0, m_name.rfind( '.' ) );
default:
assert( false ); // TODO not implemented
return "";
}
}
......@@ -88,8 +88,8 @@ struct TOOL_DISPATCHER::BUTTON_STATE
};
TOOL_DISPATCHER::TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr, PCB_BASE_FRAME* aEditFrame ) :
m_toolMgr( aToolMgr ), m_editFrame( aEditFrame )
TOOL_DISPATCHER::TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr ) :
m_toolMgr( aToolMgr )
{
m_buttons.push_back( new BUTTON_STATE( BUT_LEFT, wxEVT_LEFT_DOWN,
wxEVT_LEFT_UP, wxEVT_LEFT_DCLICK ) );
......@@ -118,7 +118,7 @@ void TOOL_DISPATCHER::ResetState()
KIGFX::VIEW* TOOL_DISPATCHER::getView()
{
return m_editFrame->GetGalCanvas()->GetView();
return static_cast<PCB_BASE_FRAME*>( m_toolMgr->GetEditFrame() )->GetGalCanvas()->GetView();
}
......@@ -229,7 +229,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
{
motion = true;
m_lastMousePos = pos;
m_editFrame->UpdateStatusBar();
static_cast<PCB_BASE_FRAME*>( m_toolMgr->GetEditFrame() )->UpdateStatusBar();
}
for( unsigned int i = 0; i < m_buttons.size(); i++ )
......@@ -245,7 +245,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
// TODO That's a big ugly workaround, somehow DRAWPANEL_GAL loses focus
// after second LMB click and currently I have no means to do better debugging
if( type == wxEVT_LEFT_UP )
m_editFrame->GetGalCanvas()->SetFocus();
static_cast<PCB_BASE_FRAME*>( m_toolMgr->GetEditFrame() )->GetGalCanvas()->SetFocus();
#endif /* __APPLE__ */
}
......@@ -288,27 +288,10 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent& aEvent )
{
boost::optional<TOOL_EVENT> evt;
switch( aEvent.GetId() )
{
case ID_ZOOM_IN: // toolbar button "Zoom In"
evt = COMMON_ACTIONS::zoomInCenter.MakeEvent();
break;
case ID_ZOOM_OUT: // toolbar button "Zoom In"
evt = COMMON_ACTIONS::zoomOutCenter.MakeEvent();
break;
case ID_ZOOM_PAGE: // toolbar button "Fit on Screen"
evt = COMMON_ACTIONS::zoomFitScreen.MakeEvent();
break;
default:
aEvent.Skip();
break;
}
boost::optional<TOOL_EVENT> evt = COMMON_ACTIONS::TranslateLegacyId( aEvent.GetId() );
if( evt )
m_toolMgr->ProcessEvent( *evt );
else
aEvent.Skip();
}
......@@ -92,6 +92,7 @@ const std::string TOOL_EVENT::Format() const
{ TA_CONTEXT_MENU_CHOICE, "context-menu-choice" },
{ TA_UNDO_REDO, "undo-redo" },
{ TA_ACTION, "action" },
{ TA_ACTIVATE, "activate" },
{ 0, "" }
};
......
This diff is collapsed.
......@@ -252,9 +252,7 @@ void VIEW::SetGAL( GAL* aGal )
clearGroupCache();
// every target has to be refreshed
MarkTargetDirty( TARGET_CACHED );
MarkTargetDirty( TARGET_NONCACHED );
MarkTargetDirty( TARGET_OVERLAY );
MarkDirty();
// force the new GAL to display the current viewport.
SetCenter( m_center );
......@@ -274,12 +272,15 @@ BOX2D VIEW::GetViewport() const
}
void VIEW::SetViewport( const BOX2D& aViewport, bool aKeepAspect )
void VIEW::SetViewport( const BOX2D& aViewport )
{
VECTOR2D ssize = ToWorld( m_gal->GetScreenPixelSize(), false );
wxASSERT( ssize.x > 0 && ssize.y > 0 );
VECTOR2D centre = aViewport.Centre();
VECTOR2D vsize = aViewport.GetSize();
double zoom = 1.0 / std::min( fabs( vsize.x / ssize.x ), fabs( vsize.y / ssize.y ) );
double zoom = 1.0 / std::max( fabs( vsize.x / ssize.x ), fabs( vsize.y / ssize.y ) );
SetCenter( centre );
SetScale( GetScale() * zoom );
......@@ -305,7 +306,7 @@ void VIEW::SetScale( double aScale, const VECTOR2D& aAnchor )
m_scale = aScale;
// Redraw everything after the viewport has changed
MarkTargetDirty( TARGET_CACHED );
MarkDirty();
}
......@@ -317,7 +318,7 @@ void VIEW::SetCenter( const VECTOR2D& aCenter )
m_gal->ComputeWorldScreenMatrix();
// Redraw everything after the viewport has changed
MarkTargetDirty( TARGET_CACHED );
MarkDirty();
}
......@@ -574,7 +575,7 @@ struct VIEW::drawItem
}
VIEW* view;
int layer, layersCount, layers[VIEW_MAX_LAYERS];
int layer, layers[VIEW_MAX_LAYERS];
};
......@@ -734,9 +735,7 @@ void VIEW::ClearTargets()
m_gal->ClearTarget( TARGET_NONCACHED );
m_gal->ClearTarget( TARGET_CACHED );
MarkTargetDirty( TARGET_NONCACHED );
MarkTargetDirty( TARGET_CACHED );
MarkTargetDirty( TARGET_OVERLAY );
MarkDirty();
}
if( IsTargetDirty( TARGET_OVERLAY ) )
......@@ -855,7 +854,7 @@ void VIEW::sortLayers()
sort( m_orderedLayers.begin(), m_orderedLayers.end(), compareRenderingOrder );
MarkTargetDirty( TARGET_CACHED );
MarkDirty();
}
......@@ -1020,33 +1019,34 @@ void VIEW::UpdateItems()
m_needsUpdate.clear();
}
struct VIEW::extentsVisitor {
BOX2I extents;
bool first;
extentsVisitor()
{
first = true;
}
struct VIEW::extentsVisitor
{
BOX2I extents;
bool first;
extentsVisitor()
{
first = true;
}
bool operator()( VIEW_ITEM* aItem )
{
if( first )
extents = aItem->ViewBBox();
else
extents.Merge ( aItem->ViewBBox() );
return false;
}
};
bool operator()( VIEW_ITEM* aItem )
{
if(first)
extents = aItem->ViewBBox();
else
extents.Merge ( aItem->ViewBBox() );
return false;
}
};
const BOX2I VIEW::CalculateExtents()
{
extentsVisitor v;
BOX2I fullScene;
fullScene.SetMaximum();
BOOST_FOREACH( VIEW_LAYER* l, m_orderedLayers )
{
l->items->Query( fullScene, v );
......
......@@ -30,9 +30,9 @@
#ifndef PANELGAL_WXSTRUCT_H
#define PANELGAL_WXSTRUCT_H
#include <wx/wx.h>
#include <wx/window.h>
#include <wx/timer.h>
#include <layers_id_colors_and_visibility.h>
#include <math/vector2d.h>
class BOARD;
......@@ -68,6 +68,15 @@ public:
*/
void SwitchBackend( GalType aGalType );
/**
* Function GetBackend
* Returns the type of backend currently used by GAL canvas.
*/
inline GalType GetBackend() const
{
return m_backend;
}
/**
* Function GetGAL()
* Returns a pointer to the GAL instance used in the panel.
......@@ -99,17 +108,16 @@ public:
}
/// @copydoc wxWindow::Refresh()
void Refresh( bool eraseBackground = true, const wxRect* rect = NULL );
void Refresh( bool aEraseBackground = true, const wxRect* aRect = NULL );
/**
* Function SetEventDispatcher()
* Sets a dispatcher that processes events and forwards them to tools.
* @param aEventDispatcher is the object that will be used for dispatching events.
* DRAW_PANEL_GAL does not take over the ownership. Passing NULL disconnects all event
* handlers from the DRAW_PANEL_GAL and parent frame.
*/
void SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher )
{
m_eventDispatcher = aEventDispatcher;
}
void SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher );
/**
* Function StartDrawing()
......@@ -124,16 +132,30 @@ public:
*/
void StopDrawing();
/**
* Function SetHighContrastLayer
* Takes care of display settings for the given layer to be displayed in high contrast mode.
*/
virtual void SetHighContrastLayer( LAYER_NUM aLayer );
/**
* Function SetTopLayer
* Moves the selected layer to the top, so it is displayed above all others.
*/
virtual void SetTopLayer( LAYER_NUM aLayer );
protected:
void onPaint( wxPaintEvent& WXUNUSED( aEvent ) );
void onSize( wxSizeEvent& aEvent );
void onEvent( wxEvent& aEvent );
void onEnter( wxEvent& aEvent );
void onRefreshTimer ( wxTimerEvent& aEvent );
void skipEvent( wxEvent& aEvent );
void onRefreshTimer( wxTimerEvent& aEvent );
static const int MinRefreshPeriod = 17; ///< 60 FPS.
/// Pointer to the parent window
wxWindow* m_parent;
/// Last timestamp when the panel was refreshed
wxLongLong m_lastRefresh;
......@@ -159,7 +181,7 @@ protected:
KIGFX::WX_VIEW_CONTROLS* m_viewControls;
/// Currently used GAL
GalType m_currentGal;
GalType m_backend;
/// Processes and forwards events to tools
TOOL_DISPATCHER* m_eventDispatcher;
......
......@@ -148,15 +148,15 @@ struct remove_pointer<T*>
* @return true, if aObject type equals T.
*/
template <class T, class I>
bool IsA(const I *aObject)
bool IsA( const I* aObject )
{
return aObject && remove_pointer<T>::type::ClassOf(aObject);
return aObject && remove_pointer<T>::type::ClassOf( aObject );
}
template <class T, class I>
bool IsA(const I& aObject)
bool IsA( const I& aObject )
{
return remove_pointer<T>::type::ClassOf(&aObject);
return remove_pointer<T>::type::ClassOf( &aObject );
}
/**
......@@ -168,7 +168,7 @@ bool IsA(const I& aObject)
* @return down-casted object or NULL if type doesn't match Casted.
*/
template<class Casted, class From>
Casted dyn_cast(From aObject)
Casted dyn_cast( From aObject )
{
if( remove_pointer<Casted>::type::ClassOf ( aObject ) )
return static_cast<Casted>( aObject );
......@@ -177,4 +177,3 @@ Casted dyn_cast(From aObject)
}
#endif // __KICAD_TYPEINFO_H
......@@ -675,7 +675,6 @@ public:
* @return True for GAL-based canvas, false for standard canvas.
*/
bool IsGalCanvasActive() const { return m_galCanvasActive; }
void SetGalCanvasActive( bool aState ) { m_galCanvasActive = aState; }
/**
* Function GetGalCanvas
......
......@@ -229,6 +229,9 @@ public:
// Cursor
// -------
/// @copydoc GAL::SetCursorSize()
virtual void SetCursorSize( unsigned int aCursorSize );
/// @copydoc GAL::DrawCursor()
virtual void DrawCursor( const VECTOR2D& aCursorPosition );
......
......@@ -631,6 +631,9 @@ public:
inline void SetGridOrigin( const VECTOR2D& aGridOrigin )
{
gridOrigin = aGridOrigin;
gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
(long) gridOrigin.y % (long) gridSize.y );
}
/**
......@@ -661,6 +664,9 @@ public:
inline void SetGridSize( const VECTOR2D& aGridSize )
{
gridSize = aGridSize;
gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
(long) gridOrigin.y % (long) gridSize.y );
}
/**
......@@ -777,12 +783,22 @@ public:
cursorColor = aCursorColor;
}
/**
* @brief Returns the cursor size.
*
* @return The current cursor size (in pixels).
*/
inline unsigned int GetCursorSize() const
{
return cursorSize;
}
/**
* @brief Set the cursor size.
*
* @param aCursorSize is the size of the cursor expressed in pixels.
*/
inline void SetCursorSize( unsigned int aCursorSize )
virtual inline void SetCursorSize( unsigned int aCursorSize )
{
cursorSize = aCursorSize;
}
......
......@@ -80,18 +80,17 @@ protected:
GLuint attachmentPoint; ///< Point to which an image from texture is attached
} OPENGL_BUFFER;
bool m_initialized; ///< Initialization status flag
unsigned int m_current; ///< Currently used buffer handle
GLuint m_framebuffer; ///< Main FBO handle
GLuint m_depthBuffer; ///< Depth buffer handle
unsigned int m_maxBuffers; ///< Maximal amount of buffers
bool m_initialized; ///< Initialization status flag
unsigned int m_current; ///< Currently used buffer handle
GLuint m_framebuffer; ///< Main FBO handle
GLuint m_depthBuffer; ///< Depth buffer handle
typedef std::deque<OPENGL_BUFFER> OPENGL_BUFFERS;
/// Stores information about initialized buffers
OPENGL_BUFFERS m_buffers;
OPENGL_BUFFERS m_buffers;
/// Store the currently used FBO name in case there was more than one compositor used
static GLuint m_currentFbo;
GLuint m_currentFbo;
/**
* Function clean()
......@@ -100,7 +99,7 @@ protected:
void clean();
/// Returns number of used buffers
unsigned int usedBuffers()
inline unsigned int usedBuffers()
{
return m_buffers.size();
}
......
......@@ -37,22 +37,12 @@
#include <gal/opengl/noncached_container.h>
#include <gal/opengl/opengl_compositor.h>
#include <wx/wx.h>
#include <wx/glcanvas.h>
#include <cmath>
#include <iterator>
#include <vector>
#include <algorithm>
#include <memory>
#include <map>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/shared_array.hpp>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#ifndef CALLBACK
#define CALLBACK
#endif
......@@ -262,8 +252,8 @@ private:
static const int CIRCLE_POINTS = 64; ///< The number of points for circle approximation
static const int CURVE_POINTS = 32; ///< The number of points for curve approximation
wxClientDC* clientDC; ///< Drawing context
wxGLContext* glContext; ///< OpenGL context of wxWidgets
wxPaintDC* clientDC; ///< Drawing context
static wxGLContext* glContext; ///< OpenGL context of wxWidgets
wxWindow* parentWindow; ///< Parent window
wxEvtHandler* mouseListener;
wxEvtHandler* paintListener;
......
......@@ -163,7 +163,7 @@ protected:
* returns size of the reserved memory space.
* @return Size of the reserved memory space (expressed as a number of vertices).
*/
unsigned int reservedSpace()
inline unsigned int reservedSpace()
{
return m_currentSize - m_freeSpace;
}
......
......@@ -75,20 +75,12 @@ public:
static int MakeActionId( const std::string& aActionName );
/**
* Function RunAction()
* Runs an action with a given name (if there is one available).
* @param aActionName is the name of action to be run.
* @return True if there was an action associated with the name, false otherwise.
* Function FindAction()
* Finds an action with a given name (if there is one available).
* @param aActionName is the searched action.
* @return Pointer to a TOOL_ACTION object or NULL if there is no such action.
*/
bool RunAction( const std::string& aActionName ) const;
/**
* Function RunAction()
* Prepares an appropriate event and sends it to the destination specified in a TOOL_ACTION
* object.
* @param aAction is the action to be run.
*/
void RunAction( const TOOL_ACTION* aAction ) const;
TOOL_ACTION* FindAction( const std::string& aActionName ) const;
/**
* Function RunHotKey()
......
......@@ -47,6 +47,10 @@ public:
///> Copy constructor
CONTEXT_MENU( const CONTEXT_MENU& aMenu );
CONTEXT_MENU& operator=( const CONTEXT_MENU& aMenu );
virtual ~CONTEXT_MENU() {}
/**
* Function SetTitle()
* Sets title for the context menu. The title is shown as a text label shown on the top of
......@@ -72,7 +76,6 @@ public:
*/
void Add( const TOOL_ACTION& aAction );
/**
* Function Clear()
* Removes all the entries from the menu (as well as its title). It leaves the menu in the
......
......@@ -56,11 +56,10 @@ template <class ReturnType, class ArgType>
class COROUTINE
{
public:
COROUTINE()
COROUTINE() :
m_saved( NULL ), m_self( NULL ), m_stack( NULL ), m_stackSize( c_defaultStackSize ),
m_running( false )
{
m_stackSize = c_defaultStackSize;
m_stack = NULL;
m_saved = NULL;
}
/**
......@@ -69,7 +68,8 @@ public:
*/
template <class T>
COROUTINE( T* object, ReturnType(T::* ptr)( ArgType ) ) :
m_func( object, ptr ), m_saved( NULL ), m_stack( NULL ), m_stackSize( c_defaultStackSize )
m_func( object, ptr ), m_self( NULL ), m_saved( NULL ), m_stack( NULL ),
m_stackSize( c_defaultStackSize ), m_running( false )
{
}
......@@ -78,8 +78,10 @@ public:
* Creates a coroutine from a delegate object
*/
COROUTINE( DELEGATE<ReturnType, ArgType> aEntry ) :
m_func( aEntry ), m_saved( NULL ), m_stack( NULL ), m_stackSize( c_defaultStackSize )
{};
m_func( aEntry ), m_saved( NULL ), m_self( NULL ), m_stack( NULL ),
m_stackSize( c_defaultStackSize ), m_running( false )
{
}
~COROUTINE()
{
......@@ -115,7 +117,7 @@ public:
}
/**
* <F11>* Function SetEntry()
* Function SetEntry()
*
* Defines the entry point for the coroutine, if not set in the constructor.
*/
......@@ -138,6 +140,12 @@ public:
// align to 16 bytes
void* sp = (void*) ( ( ( (ptrdiff_t) m_stack ) + m_stackSize - 0xf ) & ( ~0x0f ) );
// correct the stack size
m_stackSize -= ( (size_t) m_stack + m_stackSize - (size_t) sp );
assert( m_self == NULL );
assert( m_saved == NULL );
m_args = &aArgs;
m_self = boost::context::make_fcontext( sp, m_stackSize, callerStub );
m_saved = new boost::context::fcontext_t();
......
......@@ -29,7 +29,6 @@
#include <string>
#include <cassert>
#include <tool/tool_base.h>
#include <tool/tool_manager.h>
/**
......@@ -47,10 +46,10 @@ class TOOL_ACTION
public:
TOOL_ACTION( const std::string& aName, TOOL_ACTION_SCOPE aScope = AS_CONTEXT,
int aDefaultHotKey = 0, const std::string& aMenuItem = std::string( "" ),
const std::string& aMenuDesc = std::string( "" ) ) :
const std::string& aMenuDesc = std::string( "" ), TOOL_ACTION_FLAGS aFlags = AF_NONE ) :
m_name( aName ), m_scope( aScope ), m_defaultHotKey( aDefaultHotKey ),
m_currentHotKey( aDefaultHotKey ), m_menuItem( aMenuItem ),
m_menuDescription( aMenuDesc ), m_id( -1 )
m_menuDescription( aMenuDesc ), m_id( -1 ), m_flags( aFlags )
{
TOOL_MANAGER::GetActionList().push_back( this );
}
......@@ -132,7 +131,6 @@ public:
* Checks if the action has a hot key assigned.
*
* @return True if there is a hot key assigned, false otherwise.
*
*/
bool HasHotKey() const
{
......@@ -141,14 +139,19 @@ public:
/**
* Function MakeEvent()
* Returns the event associated with the action (ie. the event that will be sent after
* Returns the event associated with the action (i.e. the event that will be sent after
* activating the action).
*
* @return The event associated with the action.
*/
TOOL_EVENT MakeEvent() const
{
return TOOL_EVENT( TC_COMMAND, TA_ACTION, m_name, m_scope );
if( IsActivation() )
return TOOL_EVENT( TC_COMMAND, TA_ACTIVATE, m_name, m_scope );
else if( IsNotification() )
return TOOL_EVENT( TC_MESSAGE, TA_ANY, m_name, m_scope );
else
return TOOL_EVENT( TC_COMMAND, TA_ACTION, m_name, m_scope );
}
const std::string& GetMenuItem() const
......@@ -181,30 +184,31 @@ public:
* stripped of the last part (e.g. for "pcbnew.InteractiveDrawing.drawCircle" it is
* "pcbnew.InteractiveDrawing").
*/
std::string GetToolName() const
{
return m_name.substr( 0, m_name.rfind( '.' ) );
}
std::string GetToolName() const;
private:
friend class ACTION_MANAGER;
/// Assigns an unique identifier. It is given by an instance of ACTION_MANAGER.
void setId( int aId )
/**
* Returns true if the action is intended to activate a tool.
*/
bool IsActivation() const
{
m_id = aId;
return m_flags & AF_ACTIVATE;
}
/// Assigns ACTION_MANAGER object that handles the TOOL_ACTION.
void setActionMgr( ACTION_MANAGER* aManager )
/**
* Returns true if the action is a notification.
*/
bool IsNotification() const
{
m_actionMgr = aManager;
return m_flags & AF_NOTIFY;
}
private:
friend class ACTION_MANAGER;
/// Name of the action (convention is: app.[tool.]action.name)
std::string m_name;
/// Scope of the action (ie. the event that is issued after activation).
/// Scope of the action (i.e. the event that is issued after activation).
TOOL_ACTION_SCOPE m_scope;
/// Default hot key that activates the action.
......@@ -225,8 +229,8 @@ private:
/// Unique ID for fast matching. Assigned by ACTION_MANAGER.
int m_id;
/// Action manager that handles this TOOL_ACTION.
ACTION_MANAGER* m_actionMgr;
/// Action flags
TOOL_ACTION_FLAGS m_flags;
/// Origin of the action
// const TOOL_BASE* m_origin;
......
......@@ -26,7 +26,7 @@
#define __TOOL_DISPATCHER_H
#include <vector>
#include <wx/event.h>
#include <tool/tool_event.h>
class TOOL_MANAGER;
......@@ -47,7 +47,7 @@ class VIEW;
* - issues TOOL_EVENTS to the tool manager
*/
class TOOL_DISPATCHER
class TOOL_DISPATCHER : public wxEvtHandler
{
public:
/**
......@@ -56,7 +56,7 @@ public:
* @param aToolMgr: tool manager instance the events will be sent to
* @param aEditFrame: the frame wx events come from
*/
TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr, PCB_BASE_FRAME* aEditFrame );
TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr );
virtual ~TOOL_DISPATCHER();
/**
......@@ -128,9 +128,6 @@ private:
///> Instance of tool manager that cooperates with the dispatcher.
TOOL_MANAGER* m_toolMgr;
///> Instance of wxFrame that is the source of UI events.
PCB_BASE_FRAME* m_editFrame;
};
#endif
......@@ -91,9 +91,12 @@ enum TOOL_ACTIONS
// This event is sent *before* undo/redo command is performed.
TA_UNDO_REDO = 0x10000,
// Tool action (allows to control tools)
// Tool action (allows to control tools).
TA_ACTION = 0x20000,
// Tool activation event.
TA_ACTIVATE = 0x40000,
TA_ANY = 0xffffffff
};
......@@ -123,6 +126,14 @@ enum TOOL_ACTION_SCOPE
AS_GLOBAL ///> Global action (toolbar/main menu event, global shortcut)
};
/// Flags for tool actions
enum TOOL_ACTION_FLAGS
{
AF_NONE = 0,
AF_ACTIVATE = 1, ///> Action activates a tool
AF_NOTIFY = 2 ///> Action is a notification (it is by default passed to all tools)
};
/// Defines when a context menu is opened.
enum CONTEXT_MENU_TRIGGER
{
......@@ -265,6 +276,11 @@ public:
return m_actions == TA_CANCEL_TOOL;
}
bool IsActivate() const
{
return m_actions == TA_ACTIVATE;
}
///> Returns information about key modifiers state (Ctrl, Alt, etc.)
int Modifier( int aMask = MD_MODIFIER_MASK ) const
{
......@@ -313,14 +329,11 @@ public:
if( m_category == TC_COMMAND || m_category == TC_MESSAGE )
{
if( m_commandStr && aEvent.m_commandStr )
if( (bool) m_commandStr && (bool) aEvent.m_commandStr )
return *m_commandStr == *aEvent.m_commandStr;
if( m_commandId && aEvent.m_commandId )
if( (bool) m_commandId && (bool) aEvent.m_commandId )
return *m_commandId == *aEvent.m_commandId;
// Command-type event has to contain either id or string
assert( false );
}
return true;
......@@ -334,11 +347,16 @@ public:
*/
bool IsAction( const TOOL_ACTION* aAction ) const;
boost::optional<int> GetCommandId()
boost::optional<int> GetCommandId() const
{
return m_commandId;
}
boost::optional<std::string> GetCommandStr() const
{
return m_commandStr;
}
private:
friend class TOOL_MANAGER;
......@@ -496,7 +514,6 @@ inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& aEventA, const TOOL_E
return l;
}
inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& aEvent,
const TOOL_EVENT_LIST& aEventList )
{
......
......@@ -26,8 +26,9 @@
#ifndef __TOOL_MANAGER_H
#define __TOOL_MANAGER_H
#include <map>
#include <deque>
#include <typeinfo>
#include <map>
#include <math/vector2d.h>
......@@ -105,17 +106,21 @@ public:
* Runs the specified action. The common format for action names is "application.ToolName.Action".
*
* @param aActionName is the name of action to be invoked.
* @return True if the action finished successfully, false otherwise.
* @param aNow decides if the action has to be run immediately or after the current coroutine
* is preemptied.
* @return False if the action was not found.
*/
bool RunAction( const std::string& aActionName );
bool RunAction( const std::string& aActionName, bool aNow = false );
/**
* Function RunAction()
* Runs the specified action.
*
* @param aAction is the action to be invoked.
* @param aNow decides if the action has to be run immediately or after the current coroutine
* is preemptied.
*/
void RunAction( const TOOL_ACTION& aAction );
void RunAction( const TOOL_ACTION& aAction, bool aNow = false );
/**
* Function FindTool()
......@@ -135,6 +140,21 @@ public:
*/
TOOL_BASE* FindTool( const std::string& aName ) const;
/*
* Function GetTool()
* Returns the tool of given type or NULL if there is no such tool registered.
*/
template<typename T>
T* GetTool()
{
std::map<const char*, TOOL_BASE*>::iterator tool = m_toolTypes.find( typeid( T ).name() );
if( tool != m_toolTypes.end() )
return static_cast<T*>( tool->second );
return NULL;
}
/**
* Function ResetTools()
* Resets all tools (i.e. calls their Reset() method).
......@@ -142,11 +162,20 @@ public:
void ResetTools( TOOL_BASE::RESET_REASON aReason );
/**
* Takes an event from the TOOL_DISPATCHER and propagates it to
* tools that requested events of matching type(s)
* Propagates an event to tools that requested events of matching type(s).
* @param aEvent is the event to be processed.
*/
bool ProcessEvent( TOOL_EVENT& aEvent );
/**
* Puts an event to the event queue to be processed at the end of event processing cycle.
* @param aEvent is the event to be put into the queue.
*/
inline void PostEvent( const TOOL_EVENT& aEvent )
{
m_eventQueue.push_back( aEvent );
}
/**
* Sets the work environment (model, view, view controls and the parent window).
* These are made available to the tool. Called by the parent frame (PCB_EDIT_FRAME)
......@@ -161,17 +190,17 @@ public:
return m_view;
}
KIGFX::VIEW_CONTROLS* GetViewControls() const
inline KIGFX::VIEW_CONTROLS* GetViewControls() const
{
return m_viewControls;
}
EDA_ITEM* GetModel() const
inline EDA_ITEM* GetModel() const
{
return m_model;
}
wxWindow* GetEditFrame() const
inline wxWindow* GetEditFrame() const
{
return m_editFrame;
}
......@@ -181,7 +210,7 @@ public:
* (was invoked the most recently).
* @return Id of the currently used tool.
*/
int GetCurrentToolId() const
inline int GetCurrentToolId() const
{
return m_activeTools.front();
}
......@@ -191,7 +220,7 @@ public:
* (was invoked the most recently).
* @return Pointer to the currently used tool.
*/
TOOL_BASE* GetCurrentTool() const
inline TOOL_BASE* GetCurrentTool() const
{
return FindTool( GetCurrentToolId() );
}
......@@ -241,6 +270,19 @@ public:
m_passEvent = true;
}
/**
* Stores an information to the system clipboard.
* @param aText is the information to be stored.
* @return False if error occured.
*/
bool SaveClipboard( const std::string& aText );
/**
* Returns the information currently stored in the system clipboard. If data stored in the
* clipboard is in non-text format, empty string is returned.
*/
std::string GetClipboard() const;
/**
* Returns list of TOOL_ACTIONs. TOOL_ACTIONs add themselves to the list upon their
* creation.
......@@ -258,6 +300,10 @@ private:
struct TOOL_STATE;
typedef std::pair<TOOL_EVENT_LIST, TOOL_STATE_FUNC> TRANSITION;
/**
* Function dispatchInternal
* Passes an event at first to the active tools, then to all others.
*/
void dispatchInternal( TOOL_EVENT& aEvent );
/**
......@@ -276,6 +322,12 @@ private:
*/
bool dispatchActivation( TOOL_EVENT& aEvent );
/**
* Function dispatchContextMenu()
* Handles context menu related events.
*/
void dispatchContextMenu( TOOL_EVENT& aEvent );
/**
* Function invokeTool()
* Invokes a tool by sending a proper event (in contrary to runTool, which makes the tool run
......@@ -349,6 +401,9 @@ private:
/// Index of the registered tools current states, associated by tools' names.
std::map<std::string, TOOL_STATE*> m_toolNameIndex;
/// Index of the registered tools to easily lookup by their type.
std::map<const char*, TOOL_BASE*> m_toolTypes;
/// Index of the registered tools current states, associated by tools' ID numbers.
std::map<TOOL_ID, TOOL_STATE*> m_toolIdIndex;
......@@ -363,11 +418,11 @@ private:
KIGFX::VIEW_CONTROLS* m_viewControls;
wxWindow* m_editFrame;
/// Queue that stores events to be processed at the end of the event processing cycle.
std::list<TOOL_EVENT> m_eventQueue;
/// Flag saying if the currently processed event should be passed to other tools.
bool m_passEvent;
/// Pointer to the tool on the top of the active tools stack.
TOOL_STATE* m_currentTool;
};
#endif
......@@ -159,9 +159,8 @@ public:
* Function SetViewport()
* Sets the visible area of the VIEW.
* @param aViewport: desired visible area, in world space coordinates.
* @param aKeepProportions: when true, the X/Y size proportions are kept.
*/
void SetViewport( const BOX2D& aViewport, bool aKeepProportions = true );
void SetViewport( const BOX2D& aViewport );
/**
* Function GetViewport()
......@@ -201,7 +200,7 @@ public:
* Function GetScale()
* @return Current scalefactor of this VIEW
*/
double GetScale() const
double GetScale() const
{
return m_scale;
}
......
......@@ -110,10 +110,6 @@ protected:
MODULE* loadFootprint( const FPID& aFootprintId )
throw( IO_ERROR, PARSE_ERROR );
///> Rendering order of layers on GAL-based canvas (lower index in the array
///> means that layer is displayed closer to the user, ie. on the top).
static const LAYER_NUM GAL_LAYER_ORDER[];
public:
PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
......@@ -617,6 +613,24 @@ public:
virtual void SwitchLayer( wxDC* DC, LAYER_ID layer );
/**
* Function SetActiveLayer
* will change the currently active layer to \a aLayer.
*/
virtual void SetActiveLayer( LAYER_ID aLayer )
{
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
}
/**
* Function GetActiveLayer
* returns the active layer
*/
virtual LAYER_ID GetActiveLayer() const
{
return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
}
void LoadSettings( wxConfigBase* aCfg ); // override virtual
void SaveSettings( wxConfigBase* aCfg ); // override virtual
......
......@@ -30,7 +30,7 @@
#define WXPCB_STRUCT_H_
#include <wxBasePcbFrame.h>
#include <pcb_base_edit_frame.h>
#include <config_params.h>
#include <class_macros_record.h>
#include <class_undoredo_container.h>
......@@ -73,7 +73,7 @@ namespace PCB { struct IFACE; } // KIFACE_I is in pcbnew.cpp
*
* See also class PCB_BASE_FRAME(): Basic class for Pcbnew and GerbView.
*/
class PCB_EDIT_FRAME : public PCB_BASE_FRAME
class PCB_EDIT_FRAME : public PCB_BASE_EDIT_FRAME
{
friend class PCB::IFACE;
friend class PCB_LAYER_WIDGET;
......@@ -87,9 +87,6 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME
/// The auxiliary right vertical tool bar used to access the microwave tools.
wxAuiToolBar* m_microWaveToolBar;
/// User defined rotation angle (in tenths of a degree).
int m_rotationAngle;
/**
* Function loadFootprints
* loads the footprints for each #COMPONENT in \a aNetlist from the list of libraries.
......@@ -120,9 +117,8 @@ protected:
bool m_useCmpFileForFpNames; ///< is true, use the .cmp file from CvPcb, else use the netlist
// to know the footprint name of components.
// The Tool Framework initalization
void setupTools();
void destroyTools();
void onGenericCommand( wxCommandEvent& aEvent );
// we'll use lower case function names for private member functions.
void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu );
......@@ -252,6 +248,7 @@ public:
void OnUpdateAutoPlaceModulesMode( wxUpdateUIEvent& aEvent );
void OnUpdateAutoPlaceTracksMode( wxUpdateUIEvent& aEvent );
void OnUpdateMuWaveToolbar( wxUpdateUIEvent& aEvent );
void OnLayerColorChange( wxCommandEvent& aEvent );
/**
* Function RecordMacros.
......@@ -314,9 +311,6 @@ public:
*/
virtual void SetGridColor(EDA_COLOR_T aColor);
int GetRotationAngle() const { return m_rotationAngle; }
void SetRotationAngle( int aRotationAngle );
// Configurations:
void Process_Config( wxCommandEvent& event );
......@@ -531,33 +525,12 @@ public:
*/
virtual void OnModify();
/**
* Function SetHighContrastLayer
* takes care of display settings for the given layer to be displayed in high contrast mode.
*/
void SetHighContrastLayer( LAYER_ID aLayer );
/**
* Function SetTopLayer
* moves the selected layer to the top, so it is displayed above all others.
*/
void SetTopLayer( LAYER_ID aLayer );
/**
* Function SetActiveLayer
* will change the currently active layer to \a aLayer and also
* update the PCB_LAYER_WIDGET.
*/
void SetActiveLayer( LAYER_ID aLayer, bool doLayerWidgetUpdate = true );
/**
* Function GetActiveLayer
* returns the active layer
*/
LAYER_ID GetActiveLayer() const
{
return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
}
virtual void SetActiveLayer( LAYER_ID aLayer );
/**
* Function IsElementVisible
......@@ -679,22 +652,22 @@ public:
bool aRebuildRatsnet = true );
/**
* Function GetBoardFromRedoList
* Function RestoreCopyFromRedoList
* Redo the last edition:
* - Save the current board in Undo list
* - Get an old version of the board from Redo list
* @return none
*/
void GetBoardFromRedoList( wxCommandEvent& aEvent );
void RestoreCopyFromRedoList( wxCommandEvent& aEvent );
/**
* Function GetBoardFromUndoList
* Function RestoreCopyFromUndoList
* Undo the last edition:
* - Save the current board in Redo list
* - Get an old version of the board from Undo list
* @return none
*/
void GetBoardFromUndoList( wxCommandEvent& aEvent );
void RestoreCopyFromUndoList( wxCommandEvent& aEvent );
/* Block operations: */
......@@ -890,12 +863,6 @@ public:
/// @copydoc PCB_BASE_FRAME::SetBoard()
void SetBoard( BOARD* aBoard );
/**
* Function ViewReloadBoard
* adds all items from the current board to the VIEW, so they can be displayed by GAL.
*/
void ViewReloadBoard( const BOARD* aBoard ) const;
// Drc control
/* function GetDrcController
......
......@@ -59,6 +59,8 @@ set( PCBNEW_DIALOGS
dialogs/dialog_edit_module_for_Modedit.cpp
dialogs/dialog_edit_module_text.cpp
dialogs/dialog_edit_module_text_base.cpp
dialogs/dialog_enum_pads.cpp
dialogs/dialog_enum_pads_base.cpp
dialogs/dialog_exchange_modules_base.cpp
dialogs/dialog_export_idf.cpp
dialogs/dialog_export_idf_base.cpp
......@@ -160,6 +162,7 @@ set( PCBNEW_CLASS_SRCS
tool_modview.cpp
modview_frame.cpp
pcbframe.cpp
pcb_base_edit_frame.cpp
attribut.cpp
board_items_to_polygon_shape_transform.cpp
board_undo_redo.cpp
......@@ -221,6 +224,7 @@ set( PCBNEW_CLASS_SRCS
pad_edition_functions.cpp
pcbnew_config.cpp
pcbplot.cpp
pcb_draw_panel_gal.cpp
plot_board_layers.cpp
plot_brditems_plotter.cpp
print_board_functions.cpp
......@@ -254,6 +258,7 @@ set( PCBNEW_CLASS_SRCS
tools/selection_tool.cpp
tools/selection_area.cpp
tools/selection_conditions.cpp
tools/bright_box.cpp
tools/edit_points.cpp
tools/edit_constraints.cpp
......@@ -261,7 +266,9 @@ set( PCBNEW_CLASS_SRCS
tools/drawing_tool.cpp
tools/edit_tool.cpp
tools/pcbnew_control.cpp
tools/pcb_tools.cpp
tools/pcb_editor_control.cpp
tools/module_tools.cpp
tools/placement_tool.cpp
tools/common_actions.cpp
)
......
......@@ -51,7 +51,7 @@
#include <collectors.h>
#include <class_drawpanel.h>
#include <class_draw_panel_gal.h>
#include <pcb_draw_panel_gal.h>
#include <view/view.h>
#include <math/vector2d.h>
#include <trigo.h>
......@@ -75,82 +75,6 @@ static const wxChar DisplayModuleTextEntry[] = wxT( "DiModTx" );
static const wxChar FastGrid1Entry[] = wxT( "FastGrid1" );
static const wxChar FastGrid2Entry[] = wxT( "FastGrid2" );
const LAYER_NUM PCB_BASE_FRAME::GAL_LAYER_ORDER[] =
{
ITEM_GAL_LAYER( GP_OVERLAY ),
ITEM_GAL_LAYER( DRC_VISIBLE ),
NETNAMES_GAL_LAYER( PADS_NETNAMES_VISIBLE ),
Dwgs_User, Cmts_User, Eco1_User, Eco2_User, Edge_Cuts,
// UNUSED_LAYER_29, UNUSED_LAYER_30, UNUSED_LAYER_31,
ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ),
ITEM_GAL_LAYER( MOD_REFERENCES_VISIBLE), ITEM_GAL_LAYER( MOD_VALUES_VISIBLE ),
ITEM_GAL_LAYER( RATSNEST_VISIBLE ),
ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ),
ITEM_GAL_LAYER( VIA_THROUGH_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ),
NETNAMES_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_FR_VISIBLE ), F_Mask,
NETNAMES_GAL_LAYER( F_Cu ), F_Cu,
F_SilkS, F_Paste, F_Adhes,
#if 0 // was:
NETNAMES_GAL_LAYER( LAYER_15_NETNAMES_VISIBLE ), LAYER_N_15,
NETNAMES_GAL_LAYER( LAYER_14_NETNAMES_VISIBLE ), LAYER_N_14,
NETNAMES_GAL_LAYER( LAYER_13_NETNAMES_VISIBLE ), LAYER_N_13,
NETNAMES_GAL_LAYER( LAYER_12_NETNAMES_VISIBLE ), LAYER_N_12,
NETNAMES_GAL_LAYER( LAYER_11_NETNAMES_VISIBLE ), LAYER_N_11,
NETNAMES_GAL_LAYER( LAYER_10_NETNAMES_VISIBLE ), LAYER_N_10,
NETNAMES_GAL_LAYER( LAYER_9_NETNAMES_VISIBLE ), LAYER_N_9,
NETNAMES_GAL_LAYER( LAYER_8_NETNAMES_VISIBLE ), LAYER_N_8,
NETNAMES_GAL_LAYER( LAYER_7_NETNAMES_VISIBLE ), LAYER_N_7,
NETNAMES_GAL_LAYER( LAYER_6_NETNAMES_VISIBLE ), LAYER_N_6,
NETNAMES_GAL_LAYER( LAYER_5_NETNAMES_VISIBLE ), LAYER_N_5,
NETNAMES_GAL_LAYER( LAYER_4_NETNAMES_VISIBLE ), LAYER_N_4,
NETNAMES_GAL_LAYER( LAYER_3_NETNAMES_VISIBLE ), LAYER_N_3,
NETNAMES_GAL_LAYER( LAYER_2_NETNAMES_VISIBLE ), LAYER_N_2,
#else
NETNAMES_GAL_LAYER( In1_Cu ), In1_Cu,
NETNAMES_GAL_LAYER( In2_Cu ), In2_Cu,
NETNAMES_GAL_LAYER( In3_Cu ), In3_Cu,
NETNAMES_GAL_LAYER( In4_Cu ), In4_Cu,
NETNAMES_GAL_LAYER( In5_Cu ), In5_Cu,
NETNAMES_GAL_LAYER( In6_Cu ), In6_Cu,
NETNAMES_GAL_LAYER( In7_Cu ), In7_Cu,
NETNAMES_GAL_LAYER( In8_Cu ), In8_Cu,
NETNAMES_GAL_LAYER( In9_Cu ), In9_Cu,
NETNAMES_GAL_LAYER( In10_Cu ), In10_Cu,
NETNAMES_GAL_LAYER( In11_Cu ), In11_Cu,
NETNAMES_GAL_LAYER( In12_Cu ), In12_Cu,
NETNAMES_GAL_LAYER( In13_Cu ), In13_Cu,
NETNAMES_GAL_LAYER( In14_Cu ), In14_Cu,
NETNAMES_GAL_LAYER( In15_Cu ), In15_Cu,
NETNAMES_GAL_LAYER( In16_Cu ), In16_Cu,
NETNAMES_GAL_LAYER( In17_Cu ), In17_Cu,
NETNAMES_GAL_LAYER( In18_Cu ), In18_Cu,
NETNAMES_GAL_LAYER( In19_Cu ), In19_Cu,
NETNAMES_GAL_LAYER( In20_Cu ), In20_Cu,
NETNAMES_GAL_LAYER( In21_Cu ), In21_Cu,
NETNAMES_GAL_LAYER( In22_Cu ), In22_Cu,
NETNAMES_GAL_LAYER( In23_Cu ), In23_Cu,
NETNAMES_GAL_LAYER( In24_Cu ), In24_Cu,
NETNAMES_GAL_LAYER( In25_Cu ), In25_Cu,
NETNAMES_GAL_LAYER( In26_Cu ), In26_Cu,
NETNAMES_GAL_LAYER( In27_Cu ), In27_Cu,
NETNAMES_GAL_LAYER( In28_Cu ), In28_Cu,
NETNAMES_GAL_LAYER( In29_Cu ), In29_Cu,
NETNAMES_GAL_LAYER( In30_Cu ), In30_Cu,
#endif
NETNAMES_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_BK_VISIBLE ), B_Mask,
NETNAMES_GAL_LAYER( B_Cu ), B_Cu,
B_Adhes, B_Paste, B_SilkS,
ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ),
ITEM_GAL_LAYER( WORKSHEET )
};
BEGIN_EVENT_TABLE( PCB_BASE_FRAME, EDA_DRAW_FRAME )
EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END,
......@@ -193,16 +117,6 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
m_FastGrid1 = 0;
m_FastGrid2 = 0;
SetGalCanvas( new EDA_DRAW_PANEL_GAL(
this, -1, wxPoint( 0, 0 ), m_FrameSize,
EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) );
// GAL should not be active yet
GetGalCanvas()->StopDrawing();
// Hide by default, it has to be explicitly shown
GetGalCanvas()->Hide();
m_auxiliaryToolBar = NULL;
}
......@@ -211,7 +125,10 @@ PCB_BASE_FRAME::~PCB_BASE_FRAME()
{
delete m_Collector;
delete m_Pcb; // is already NULL for FOOTPRINT_EDIT_FRAME
delete m_toolManager;
delete m_toolDispatcher;
delete m_Pcb;
delete GetGalCanvas();
}
......@@ -253,8 +170,11 @@ FP_LIB_TABLE* PROJECT::PcbFootprintLibs()
void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
{
delete m_Pcb;
m_Pcb = aBoard;
if( m_Pcb != aBoard )
{
delete m_Pcb;
m_Pcb = aBoard;
}
}
......@@ -847,52 +767,6 @@ void PCB_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
if( m_DisplayModText < LINE || m_DisplayModText > SKETCH )
m_DisplayModText = FILLED;
// Apply display settings for GAL
KIGFX::VIEW* view = GetGalCanvas()->GetView();
// Set rendering order and properties of layers
for( LAYER_NUM i = 0; i < (int) DIM(GAL_LAYER_ORDER); ++i )
{
LAYER_NUM layer = GAL_LAYER_ORDER[i];
wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
view->SetLayerOrder( layer, i );
if( IsCopperLayer( layer ) )
{
// Copper layers are required for netname layers
view->SetRequired( GetNetnameLayer( layer ), layer );
view->SetLayerTarget( layer, KIGFX::TARGET_CACHED );
}
else if( IsNetnameLayer( layer ) )
{
// Netnames are drawn only when scale is sufficient (level of details)
// so there is no point in caching them
view->SetLayerTarget( layer, KIGFX::TARGET_NONCACHED );
}
}
// Some more required layers settings
view->SetRequired( ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( VIA_THROUGH_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ) );
view->SetRequired( NETNAMES_GAL_LAYER( PADS_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ) );
view->SetRequired( NETNAMES_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( F_Adhes, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( F_Paste, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( F_Mask, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( NETNAMES_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetRequired( B_Adhes, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetRequired( B_Paste, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetRequired( B_Mask, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PAD_FR_VISIBLE ), ITEM_GAL_LAYER( MOD_FR_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PAD_BK_VISIBLE ), ITEM_GAL_LAYER( MOD_BK_VISIBLE ) );
view->SetLayerTarget( ITEM_GAL_LAYER( GP_OVERLAY ), KIGFX::TARGET_OVERLAY );
view->SetLayerTarget( ITEM_GAL_LAYER( RATSNEST_VISIBLE ), KIGFX::TARGET_OVERLAY );
// WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" )
// when reading doubles in config,
// but forget to back to current locale. So we call SetLocaleTo_Default
......
......@@ -630,7 +630,7 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
}
void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& aEvent )
void PCB_EDIT_FRAME::RestoreCopyFromUndoList( wxCommandEvent& aEvent )
{
if( GetScreen()->GetUndoCommandCount() <= 0 )
return;
......@@ -653,7 +653,7 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& aEvent )
}
void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& aEvent )
void PCB_EDIT_FRAME::RestoreCopyFromRedoList( wxCommandEvent& aEvent )
{
if( GetScreen()->GetRedoCommandCount() == 0 )
return;
......
......@@ -106,11 +106,6 @@ BOARD::BOARD() :
// Initialize ratsnest
m_ratsnest = new RN_DATA( this );
m_ratsnestViewItem = new KIGFX::RATSNEST_VIEWITEM( m_ratsnest );
// Initialize view item for displaying worksheet frame
m_worksheetViewItem = new KIGFX::WORKSHEET_VIEWITEM( &m_paper, &m_titles );
m_worksheetViewItem->SetFileName( std::string( m_fileName.mb_str() ) );
}
......@@ -122,8 +117,6 @@ BOARD::~BOARD()
Delete( area_to_remove );
}
delete m_worksheetViewItem;
delete m_ratsnestViewItem;
delete m_ratsnest;
m_FullRatsnest.clear();
......@@ -695,10 +688,12 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
m_Status_Pcb = 0;
break;
case PCB_MODULE_EDGE_T:
assert( false ); // TODO Orson: I am just checking if it is supposed to be here
case PCB_DIMENSION_T:
case PCB_LINE_T:
case PCB_TEXT_T:
case PCB_MODULE_EDGE_T:
case PCB_TARGET_T:
if( aControl & ADD_APPEND )
m_Drawings.PushBack( aBoardItem );
......
......@@ -198,8 +198,6 @@ private:
EDA_RECT m_BoundingBox;
NETINFO_LIST m_NetInfo; ///< net info list (name, design constraints ..
RN_DATA* m_ratsnest;
KIGFX::RATSNEST_VIEWITEM* m_ratsnestViewItem; ///< VIEW_ITEM that draws ratsnest
KIGFX::WORKSHEET_VIEWITEM* m_worksheetViewItem; ///< VIEW_ITEM that draws worksheet frame
BOARD_DESIGN_SETTINGS m_designSettings;
ZONE_SETTINGS m_zoneSettings;
......@@ -313,24 +311,6 @@ public:
return m_ratsnest;
}
/**
* Function GetRatsnestViewItem()
* returns VIEW_ITEM responsible for drawing the ratsnest for the board.
*/
KIGFX::RATSNEST_VIEWITEM* GetRatsnestViewItem() const
{
return m_ratsnestViewItem;
}
/**
* Function GetWorksheetViewItem()
* returns VIEW_ITEM responsible for drawing the worksheet frame.
*/
KIGFX::WORKSHEET_VIEWITEM* GetWorksheetViewItem() const
{
return m_worksheetViewItem;
}
/**
* Function DeleteMARKERs
* deletes ALL MARKERS from the board.
......
......@@ -90,6 +90,25 @@ void EDGE_MODULE::Copy( EDGE_MODULE* source )
}
void EDGE_MODULE::SetLocalCoord()
{
MODULE* module = (MODULE*) m_Parent;
if( module == NULL )
{
m_Start0 = m_Start;
m_End0 = m_End;
return;
}
m_Start0 = m_Start - module->GetPosition();
m_End0 = m_End - module->GetPosition();
double angle = module->GetOrientation();
RotatePoint( &m_Start0.x, &m_Start0.y, -angle );
RotatePoint( &m_End0.x, &m_End0.y, -angle );
}
void EDGE_MODULE::SetDrawCoord()
{
MODULE* module = (MODULE*) m_Parent;
......
......@@ -61,12 +61,23 @@ public:
void Copy( EDGE_MODULE* source ); // copy structure
void Move( const wxPoint& aMoveVector )
{
m_Start += aMoveVector;
m_End += aMoveVector;
SetLocalCoord();
}
void SetStart0( const wxPoint& aPoint ) { m_Start0 = aPoint; }
const wxPoint& GetStart0() const { return m_Start0; }
void SetEnd0( const wxPoint& aPoint ) { m_End0 = aPoint; }
const wxPoint& GetEnd0() const { return m_End0; }
///> Set relative coordinates.
void SetLocalCoord();
///> Set absolute coordinates.
void SetDrawCoord();
/* drawing functions */
......
......@@ -295,6 +295,72 @@ void MODULE::Copy( MODULE* aModule )
}
void MODULE::Add( BOARD_ITEM* aBoardItem, bool doAppend )
{
switch( aBoardItem->Type() )
{
case PCB_MODULE_TEXT_T:
// Only common texts can be added this way. Reference and value are not hold in the DLIST.
assert( static_cast<TEXTE_MODULE*>( aBoardItem )->GetType() == TEXTE_MODULE::TEXT_is_DIVERS );
/* no break */
case PCB_MODULE_EDGE_T:
if( doAppend )
m_Drawings.PushBack( static_cast<BOARD_ITEM*>( aBoardItem ) );
else
m_Drawings.PushFront( static_cast<BOARD_ITEM*>( aBoardItem ) );
break;
case PCB_PAD_T:
if( doAppend )
m_Pads.PushBack( static_cast<D_PAD*>( aBoardItem ) );
else
m_Pads.PushFront( static_cast<D_PAD*>( aBoardItem ) );
break;
default:
{
wxString msg;
msg.Printf( wxT( "MODULE::Add() needs work: BOARD_ITEM type (%d) not handled" ),
aBoardItem->Type() );
wxFAIL_MSG( msg );
return;
}
}
aBoardItem->SetParent( this );
}
BOARD_ITEM* MODULE::Remove( BOARD_ITEM* aBoardItem )
{
switch( aBoardItem->Type() )
{
case PCB_MODULE_TEXT_T:
// Only common texts can be added this way. Reference and value are not hold in the DLIST.
assert( static_cast<TEXTE_MODULE*>( aBoardItem )->GetType() == TEXTE_MODULE::TEXT_is_DIVERS );
/* no break */
case PCB_MODULE_EDGE_T:
return m_Drawings.Remove( static_cast<BOARD_ITEM*>( aBoardItem ) );
case PCB_PAD_T:
return m_Pads.Remove( static_cast<D_PAD*>( aBoardItem ) );
default:
{
wxString msg;
msg.Printf( wxT( "MODULE::Remove() needs work: BOARD_ITEM type (%d) not handled" ),
aBoardItem->Type() );
wxFAIL_MSG( msg );
}
}
return NULL;
}
void MODULE::CopyNetlistSettings( MODULE* aModule )
{
// Don't do anything foolish like trying to copy to yourself.
......@@ -448,8 +514,12 @@ const EDA_RECT MODULE::GetBoundingBox() const
// Add the Clearance shape size: (shape around the pads when the
// clearance is shown. Not optimized, but the draw cost is small
// (perhaps smaller than optimization).
int biggest_clearance = GetBoard()->GetDesignSettings().GetBiggestClearanceValue();
area.Inflate( biggest_clearance );
BOARD* board = GetBoard();
if( board )
{
int biggest_clearance = board->GetDesignSettings().GetBiggestClearanceValue();
area.Inflate( biggest_clearance );
}
return area;
}
......@@ -632,13 +702,6 @@ void MODULE::Add3DModel( S3D_MASTER* a3DModel )
}
void MODULE::AddPad( D_PAD* aPad )
{
aPad->SetParent( this );
m_Pads.PushBack( aPad );
}
// see class_module.h
SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] )
......@@ -734,10 +797,10 @@ EDA_ITEM* MODULE::Clone() const
void MODULE::RunOnChildren( boost::function<void (BOARD_ITEM*)> aFunction )
{
for( D_PAD* pad = m_Pads.GetFirst(); pad; pad = pad->Next() )
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
aFunction( static_cast<BOARD_ITEM*>( pad ) );
for( BOARD_ITEM* drawing = m_Drawings.GetFirst(); drawing; drawing = drawing->Next() )
for( BOARD_ITEM* drawing = m_Drawings; drawing; drawing = drawing->Next() )
aFunction( drawing );
aFunction( static_cast<BOARD_ITEM*>( m_Reference ) );
......@@ -767,6 +830,21 @@ void MODULE::ViewUpdate( int aUpdateFlags )
}
void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 1;
aLayers[0] = ITEM_GAL_LAYER( ANCHOR_VISIBLE );
}
unsigned int MODULE::ViewGetLOD( int aLayer ) const
{
// Currently there is only one layer, so there is nothing to check
// if( aLayer == ITEM_GAL_LAYER( ANCHOR_VISIBLE ) )
return 30;
}
/* Test for validity of the name in a library of the footprint
* ( no spaces, dir separators ... )
* return true if the given name is valid
......
......@@ -91,9 +91,31 @@ public:
* Function Add
* adds the given item to this MODULE and takes ownership of its memory.
* @param aBoardItem The item to add to this board.
* @param doInsert If true, then insert, else append
* void Add( BOARD_ITEM* aBoardItem, bool doInsert = true );
* @param doAppend If true, then append, else insert.
*/
void Add( BOARD_ITEM* aBoardItem, bool doAppend = true );
/**
* Function Delete
* removes the given single item from this MODULE and deletes its memory.
* @param aBoardItem The item to remove from this module and delete
*/
void Delete( BOARD_ITEM* aBoardItem )
{
// developers should run DEBUG versions and fix such calls with NULL
wxASSERT( aBoardItem );
if( aBoardItem )
delete Remove( aBoardItem );
}
/**
* Function Remove
* removes \a aBoardItem from this MODULE and returns it to caller without deleting it.
* @param aBoardItem The item to remove from this module.
* @return BOARD_ITEM* \a aBoardItem which was passed in.
*/
BOARD_ITEM* Remove( BOARD_ITEM* aBoardItem );
/**
* Function CalculateBoundingBox
......@@ -436,14 +458,6 @@ public:
*/
void Add3DModel( S3D_MASTER* a3DModel );
/**
* Function AddPad
* adds \a aPad to the end of the pad list.
*
* @param aPad A pointer to a #D_PAD to add to the list.
*/
void AddPad( D_PAD* aPad );
SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] );
......@@ -469,6 +483,12 @@ public:
/// @copydoc VIEW_ITEM::ViewUpdate()
void ViewUpdate( int aUpdateFlags = KIGFX::VIEW_ITEM::ALL );
/// @copydoc VIEW_ITEM::ViewGetLayers()
virtual void ViewGetLayers( int aLayers[], int& aCount ) const;
/// @copydoc VIEW_ITEM::ViewGetLOD()
virtual unsigned int ViewGetLOD( int aLayer ) const;
/**
* Function CopyNetlistSettings
* copies the netlist settings to \a aModule.
......
......@@ -228,6 +228,37 @@ const EDA_RECT D_PAD::GetBoundingBox() const
}
void D_PAD::SetDrawCoord()
{
MODULE* module = (MODULE*) m_Parent;
m_Pos = m_Pos0;
if( module == NULL )
return;
double angle = module->GetOrientation();
RotatePoint( &m_Pos.x, &m_Pos.y, angle );
m_Pos += module->GetPosition();
}
void D_PAD::SetLocalCoord()
{
MODULE* module = (MODULE*) m_Parent;
if( module == NULL )
{
m_Pos0 = m_Pos;
return;
}
m_Pos0 = m_Pos - module->GetPosition();
RotatePoint( &m_Pos0.x, &m_Pos0.y, -module->GetOrientation() );
}
void D_PAD::SetAttribute( PAD_ATTR_T aAttribute )
{
m_Attribute = aAttribute;
......@@ -797,6 +828,13 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp )
}
void D_PAD::Rotate( const wxPoint& aRotCentre, double aAngle )
{
RotatePoint( &m_Pos, aRotCentre, aAngle );
m_Orient += aAngle;
}
wxString D_PAD::ShowPadShape() const
{
switch( GetShape() )
......@@ -924,7 +962,7 @@ void D_PAD::ViewGetLayers( int aLayers[], int& aCount ) const
unsigned int D_PAD::ViewGetLOD( int aLayer ) const
{
// Netnames and soldermasks will be shown only if zoom is appropriate
// Netnames will be shown only if zoom is appropriate
if( IsNetnameLayer( aLayer ) )
{
return ( 100000000 / std::max( m_Size.x, m_Size.y ) );
......
......@@ -153,7 +153,7 @@ public:
* Function GetOrientation
* returns the rotation angle of the pad in tenths of degrees, but soon degrees.
*/
double GetOrientation() const { return m_Orient; }
double GetOrientation() const { return m_Orient; }
void SetDrillShape( PAD_DRILL_SHAPE_T aDrillShape )
{ m_drillShape = aDrillShape; }
......@@ -381,6 +381,12 @@ public:
// Virtual function:
const EDA_RECT GetBoundingBox() const;
///> Set absolute coordinates.
void SetDrawCoord();
///> Set relative coordinates.
void SetLocalCoord();
/**
* Function Compare
* compares two pads and return 0 if they are equal.
......@@ -391,8 +397,10 @@ public:
void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
SetLocalCoord();
}
void Rotate( const wxPoint& aRotCentre, double aAngle );
wxString GetSelectMenuText() const;
......
......@@ -81,7 +81,7 @@ const LAYER_WIDGET::ROW PCB_LAYER_WIDGET::s_render_rows[] = {
};
PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_EDIT_FRAME* aParent, wxWindow* aFocusOwner, int aPointSize ) :
PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwner, int aPointSize ) :
LAYER_WIDGET( aParent, aFocusOwner, aPointSize ),
myframe( aParent )
{
......@@ -213,7 +213,7 @@ void PCB_LAYER_WIDGET::SetLayersManagerTabsText()
void PCB_LAYER_WIDGET::ReFillRender()
{
BOARD* board = myframe->GetBoard();
BOARD* board = myframe->GetBoard();
ClearRenderRows();
// Add "Render" tab rows to LAYER_WIDGET, after setting color and checkbox state.
......@@ -356,7 +356,6 @@ void PCB_LAYER_WIDGET::ReFill()
void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, EDA_COLOR_T aColor )
{
myframe->GetBoard()->SetLayerColor( ToLAYER_ID( aLayer ), aColor );
myframe->ReCreateLayerBox( false );
if( myframe->IsGalCanvasActive() )
{
......@@ -373,7 +372,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer )
{
// the layer change from the PCB_LAYER_WIDGET can be denied by returning
// false from this function.
myframe->SetActiveLayer( ToLAYER_ID( aLayer ), false );
myframe->SetActiveLayer( ToLAYER_ID( aLayer ) );
if( m_alwaysShowActiveCopperLayer )
OnLayerSelected();
......
......@@ -31,6 +31,8 @@
#ifndef CLASS_PCB_LAYER_WIDGET_H_
#define CLASS_PCB_LAYER_WIDGET_H_
#include <layer_widget.h>
/**
* Class PCB_LAYER_WIDGET
* is here to implement the abtract functions of LAYER_WIDGET so they
......@@ -49,7 +51,7 @@ public:
* effectively sets the overal size of the widget via the row height and bitmap
* button sizes.
*/
PCB_LAYER_WIDGET( PCB_EDIT_FRAME* aParent, wxWindow* aFocusOwner, int aPointSize = 10 );
PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwner, int aPointSize = 10 );
void ReFill();
......@@ -108,7 +110,7 @@ protected:
bool m_alwaysShowActiveCopperLayer; // If true: Only shows the current active layer
// even if it is changed
PCB_EDIT_FRAME* myframe;
PCB_BASE_FRAME* myframe;
// popup menu ids.
#define ID_SHOW_ALL_COPPERS wxID_HIGHEST
......
......@@ -129,7 +129,7 @@ int TEXTE_MODULE::GetLength() const
return m_Text.Len();
}
// Update draw coordinates
void TEXTE_MODULE::SetDrawCoord()
{
MODULE* module = (MODULE*) m_Parent;
......@@ -146,8 +146,6 @@ void TEXTE_MODULE::SetDrawCoord()
}
// Update "local" coordinates (coordinates relatives to the footprint
// anchor point)
void TEXTE_MODULE::SetLocalCoord()
{
MODULE* module = (MODULE*) m_Parent;
......@@ -163,6 +161,7 @@ void TEXTE_MODULE::SetLocalCoord()
RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle );
}
bool TEXTE_MODULE::HitTest( const wxPoint& aPosition ) const
{
wxPoint rel_pos;
......
......@@ -71,7 +71,6 @@ public:
return aItem && PCB_MODULE_TEXT_T == aItem->Type();
}
virtual const wxPoint& GetPosition() const
{
return m_Pos;
......@@ -117,9 +116,11 @@ public:
// Virtual function
const EDA_RECT GetBoundingBox() const;
void SetDrawCoord(); // Set absolute coordinates.
///> Set absolute coordinates.
void SetDrawCoord();
void SetLocalCoord(); // Set relative coordinates.
///> Set relative coordinates.
void SetLocalCoord();
/* drawing functions */
void Draw( EDA_DRAW_PANEL* panel,
......
......@@ -86,7 +86,7 @@ const KICAD_T GENERAL_COLLECTOR::AllButZones[] = {
};
const KICAD_T GENERAL_COLLECTOR::ModuleItems[] = {
const KICAD_T GENERAL_COLLECTOR::Modules[] = {
PCB_MODULE_T,
EOT
};
......@@ -118,12 +118,21 @@ const KICAD_T GENERAL_COLLECTOR::ModulesAndTheirItems[] = {
};
const KICAD_T GENERAL_COLLECTOR::ModuleItems[] = {
PCB_MODULE_TEXT_T,
PCB_MODULE_EDGE_T,
PCB_PAD_T,
EOT
};
const KICAD_T GENERAL_COLLECTOR::Tracks[] = {
PCB_TRACE_T,
PCB_VIA_T,
EOT
};
const KICAD_T GENERAL_COLLECTOR::Zones[] = {
PCB_ZONE_AREA_T,
EOT
......
......@@ -262,7 +262,7 @@ public:
/**
* A scan list for only MODULEs
*/
static const KICAD_T ModuleItems[];
static const KICAD_T Modules[];
/**
......@@ -282,6 +282,12 @@ public:
static const KICAD_T ModulesAndTheirItems[];
/**
* A scan list for primary module items.
*/
static const KICAD_T ModuleItems[];
/**
* A scan list for only TRACKS
*/
......
......@@ -119,7 +119,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode )
else if( GetToolId() == ID_NO_TOOL_SELECTED )
{
if( m_mainToolBar->GetToolToggled( ID_TOOLBARH_PCB_MODE_MODULE ) )
scanList = GENERAL_COLLECTOR::ModuleItems;
scanList = GENERAL_COLLECTOR::Modules;
else
scanList = (DisplayOpt.DisplayZonesMode == 0) ?
GENERAL_COLLECTOR::AllBoardItems :
......@@ -138,7 +138,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode )
break;
case ID_PCB_MODULE_BUTT:
scanList = GENERAL_COLLECTOR::ModuleItems;
scanList = GENERAL_COLLECTOR::Modules;
break;
case ID_PCB_ZONES_BUTT:
......
......@@ -44,34 +44,12 @@
#include <class_module.h>
#include <class_text_mod.h>
#include <dialog_edit_module_text_base.h>
#include <dialog_edit_module_text.h>
extern wxPoint MoveVector; // Move vector for move edge, imported from edtxtmod.cpp
/*************** **************/
/* class DialogEditModuleText */
/*************** **************/
class DialogEditModuleText : public DialogEditModuleText_base
{
private:
PCB_BASE_FRAME* m_parent;
wxDC* m_dc;
MODULE* m_module;
TEXTE_MODULE* m_currentText;
public:
DialogEditModuleText( PCB_BASE_FRAME* aParent, TEXTE_MODULE* aTextMod, wxDC* aDC );
~DialogEditModuleText() {};
private:
void initDlg( );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
};
void PCB_BASE_FRAME::InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, wxDC* DC )
{
m_canvas->SetIgnoreMouseEvents( true );
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Jean-Pierre Charras
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
*/
#ifndef DIALOG_EDIT_MODULE_TEXT_H
#define DIALOG_EDIT_MODULE_TEXT_H
#include <dialog_edit_module_text_base.h>
/*************** **************/
/* class DialogEditModuleText */
/*************** **************/
class DialogEditModuleText : public DialogEditModuleText_base
{
private:
PCB_BASE_FRAME* m_parent;
wxDC* m_dc;
MODULE* m_module;
TEXTE_MODULE* m_currentText;
public:
DialogEditModuleText( PCB_BASE_FRAME* aParent, TEXTE_MODULE* aTextMod, wxDC* aDC );
~DialogEditModuleText() {};
private:
void initDlg( );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
};
#endif /* DIALOG_EDIT_MODULE_TEXT_H */
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 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
*/
#include "dialog_enum_pads.h"
DIALOG_ENUM_PADS::DIALOG_ENUM_PADS( wxWindow* aParent ) :
DIALOG_ENUM_PADS_BASE( aParent )
{
}
int DIALOG_ENUM_PADS::GetStartNumber() const
{
return m_padStartNum->GetValue();
}
wxString DIALOG_ENUM_PADS::GetPrefix() const
{
return m_padPrefix->GetValue();
}
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 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
*/
#ifndef __dialog_enum_pads__
#define __dialog_enum_pads__
/**
@file
Subclass of DIALOG_ENUM_PADS_BASE, which is generated by wxFormBuilder.
*/
#include "dialog_enum_pads_base.h"
/** Implementing DIALOG_ENUM_PADS_BASE */
class DIALOG_ENUM_PADS : public DIALOG_ENUM_PADS_BASE
{
public:
/** Constructor */
DIALOG_ENUM_PADS( wxWindow* parent );
///> Returns the starting number that is going to be used for the first enumerated pad.
int GetStartNumber() const;
///> Returns common prefix for all enumerated pads.
wxString GetPrefix() const;
};
#endif // __dialog_enum_pads__
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 30 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_enum_pads_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_ENUM_PADS_BASE::DIALOG_ENUM_PADS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bMainSizer;
bMainSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bPrefixSizer;
bPrefixSizer = new wxBoxSizer( wxHORIZONTAL );
m_lblPadPrefix = new wxStaticText( this, wxID_ANY, _("Pad name prefix:"), wxDefaultPosition, wxDefaultSize, 0 );
m_lblPadPrefix->Wrap( -1 );
bPrefixSizer->Add( m_lblPadPrefix, 1, wxALL, 5 );
m_padPrefix = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_padPrefix->SetMaxLength( 4 );
bPrefixSizer->Add( m_padPrefix, 0, wxALL, 5 );
bMainSizer->Add( bPrefixSizer, 1, wxEXPAND, 5 );
wxBoxSizer* bPadNumSizer;
bPadNumSizer = new wxBoxSizer( wxHORIZONTAL );
m_lblPadStartNum = new wxStaticText( this, wxID_ANY, _("First pad number:"), wxDefaultPosition, wxDefaultSize, 0 );
m_lblPadStartNum->Wrap( -1 );
bPadNumSizer->Add( m_lblPadStartNum, 1, wxALL, 5 );
m_padStartNum = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 999, 1 );
bPadNumSizer->Add( m_padStartNum, 0, wxALL, 5 );
bMainSizer->Add( bPadNumSizer, 1, wxEXPAND, 5 );
m_lblInfo = new wxStaticText( this, wxID_ANY, _("Pad names are restricted to 4 characters (including number)."), wxDefaultPosition, wxDefaultSize, 0 );
m_lblInfo->Wrap( 320 );
bMainSizer->Add( m_lblInfo, 0, wxALL, 5 );
m_stdButtons = new wxStdDialogButtonSizer();
m_stdButtonsOK = new wxButton( this, wxID_OK );
m_stdButtons->AddButton( m_stdButtonsOK );
m_stdButtonsCancel = new wxButton( this, wxID_CANCEL );
m_stdButtons->AddButton( m_stdButtonsCancel );
m_stdButtons->Realize();
bMainSizer->Add( m_stdButtons, 2, wxEXPAND, 5 );
this->SetSizer( bMainSizer );
this->Layout();
this->Centre( wxBOTH );
}
DIALOG_ENUM_PADS_BASE::~DIALOG_ENUM_PADS_BASE()
{
}
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 30 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_ENUM_PADS_BASE_H__
#define __DIALOG_ENUM_PADS_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/spinctrl.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_ENUM_PADS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_ENUM_PADS_BASE : public wxDialog
{
private:
protected:
wxStaticText* m_lblPadPrefix;
wxTextCtrl* m_padPrefix;
wxStaticText* m_lblPadStartNum;
wxSpinCtrl* m_padStartNum;
wxStaticText* m_lblInfo;
wxStdDialogButtonSizer* m_stdButtons;
wxButton* m_stdButtonsOK;
wxButton* m_stdButtonsCancel;
public:
DIALOG_ENUM_PADS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pad enumeration settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 340,240 ), long style = wxDEFAULT_DIALOG_STYLE );
~DIALOG_ENUM_PADS_BASE();
};
#endif //__DIALOG_ENUM_PADS_BASE_H__
......@@ -154,11 +154,6 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{
int id = event.GetId();
bool state = event.IsChecked();
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*> ( GetGalCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*> ( painter->GetSettings() );
KICAD_T updateType = EOT;
switch( id )
{
......@@ -193,44 +188,33 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SHOW_ZONES:
DisplayOpt.DisplayZonesMode = 0;
updateType = PCB_ZONE_AREA_T;
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
DisplayOpt.DisplayZonesMode = 1;
updateType = PCB_ZONE_AREA_T;
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
DisplayOpt.DisplayZonesMode = 2;
updateType = PCB_ZONE_AREA_T;
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
m_DisplayViaFill = DisplayOpt.DisplayViaFill = !state;
updateType = PCB_VIA_T;
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = !state;
updateType = PCB_TRACE_T;
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
{
DisplayOpt.ContrastModeDisplay = state;
// Apply new display options to the GAL canvas (this is faster than recaching)
settings->LoadDisplayOptions( DisplayOpt );
SetHighContrastLayer( GetActiveLayer() );
m_canvas->Refresh();
break;
}
......@@ -260,21 +244,4 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
wxT( "PCB_EDIT_FRAME::OnSelectOptionToolbar error \n (event not handled!)" ) );
break;
}
if( updateType != EOT )
{
// Apply new display options to the GAL canvas
settings->LoadDisplayOptions( DisplayOpt );
// Find items that require update
KICAD_T scanList[] = { updateType, EOT };
TYPE_COLLECTOR collector;
collector.Collect( GetBoard(), scanList );
for( int i = 0; i < collector.GetCount(); ++i )
collector[i]->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
}
if( IsGalCanvasActive() )
GetGalCanvas()->Refresh();
}
......@@ -254,6 +254,9 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
if( gen_rastnest )
m_Parent->Compile_Ratsnest( NULL, true );
if( m_Parent->IsGalCanvasActive() )
pcb->GetRatsnest()->Recalculate();
}
m_Parent->GetCanvas()->Refresh();
......
......@@ -117,6 +117,8 @@ private:
bool padValuesOK(); ///< test if all values are acceptable for the pad
void redraw();
/**
* Function setPadLayersList
* updates the CheckBox states in pad layers list,
......@@ -174,6 +176,21 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP
else // We are editing a "master" pad, i.e. a pad used to create new pads
m_dummyPad->Copy( m_padMaster );
if( m_parent->IsGalCanvasActive() )
{
m_panelShowPadGal->UseColorScheme( m_board->GetColorsSettings() );
m_panelShowPadGal->SwitchBackend( m_parent->GetGalCanvas()->GetBackend() );
m_panelShowPad->Hide();
m_panelShowPadGal->Show();
m_panelShowPadGal->GetView()->Add( m_dummyPad );
m_panelShowPadGal->StartDrawing();
}
else
{
m_panelShowPad->Show();
m_panelShowPadGal->Hide();
}
initValues();
m_sdbSizer1OK->SetDefault();
......@@ -537,7 +554,7 @@ void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
}
transferDataToPad( m_dummyPad );
m_panelShowPad->Refresh();
redraw();
}
......@@ -566,7 +583,7 @@ void DIALOG_PAD_PROPERTIES::OnDrillShapeSelected( wxCommandEvent& event )
}
transferDataToPad( m_dummyPad );
m_panelShowPad->Refresh();
redraw();
}
......@@ -599,7 +616,7 @@ void DIALOG_PAD_PROPERTIES::PadOrientEvent( wxCommandEvent& event )
m_PadOrientCtrl->SetValue( msg );
transferDataToPad( m_dummyPad );
m_panelShowPad->Refresh();
redraw();
}
......@@ -667,7 +684,7 @@ void DIALOG_PAD_PROPERTIES::setPadLayersList( LSET layer_mask )
void DIALOG_PAD_PROPERTIES::OnSetLayers( wxCommandEvent& event )
{
transferDataToPad( m_dummyPad );
m_panelShowPad->Refresh();
redraw();
}
......@@ -758,6 +775,29 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK()
}
void DIALOG_PAD_PROPERTIES::redraw()
{
if( m_parent->IsGalCanvasActive() )
{
m_dummyPad->ViewUpdate();
BOX2I bbox = m_dummyPad->ViewBBox();
// Autozoom
m_panelShowPadGal->GetView()->SetViewport( BOX2D( bbox.GetOrigin(), bbox.GetSize() ) );
// Add a margin
m_panelShowPadGal->GetView()->SetScale( m_panelShowPadGal->GetView()->GetScale() * 0.7 );
m_panelShowPadGal->Refresh();
}
else
{
m_panelShowPad->Refresh();
}
}
void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
{
if( !padValuesOK() )
......@@ -1132,7 +1172,7 @@ void DIALOG_PAD_PROPERTIES::OnValuesChanged( wxCommandEvent& event )
if( m_canUpdate )
{
transferDataToPad( m_dummyPad );
m_panelShowPad->Refresh();
redraw();
}
}
......
......@@ -536,6 +536,9 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind
bSizerDisplayPad->Add( m_panelShowPad, 4, wxRIGHT|wxTOP|wxEXPAND, 5 );
m_panelShowPadGal = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), wxDefaultSize, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
bSizerDisplayPad->Add( m_panelShowPadGal, 4, wxEXPAND|wxRIGHT|wxTOP, 5 );
bSizerUpper->Add( bSizerDisplayPad, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 );
......
......@@ -8310,6 +8310,91 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxRIGHT|wxTOP</property>
<property name="proportion">4</property>
<object class="CustomControl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="class">PCB_DRAW_PANEL_GAL</property>
<property name="close_button">1</property>
<property name="construction">m_panelShowPadGal = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), wxDefaultSize, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="declaration">PCB_DRAW_PANEL_GAL* m_panelShowPadGal;</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="include">#include &lt;pcb_draw_panel_gal.h&gt;</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_panelShowPadGal</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="settings"></property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
</object>
......
......@@ -30,6 +30,7 @@ class DIALOG_SHIM;
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/notebook.h>
#include <pcb_draw_panel_gal.h>
#include <wx/button.h>
#include <wx/dialog.h>
......@@ -143,6 +144,7 @@ class DIALOG_PAD_PROPERTIES_BASE : public DIALOG_SHIM
wxStaticText* m_ThermalGapUnits;
wxStaticText* m_staticTextWarning;
wxPanel* m_panelShowPad;
PCB_DRAW_PANEL_GAL* m_panelShowPadGal;
wxStaticText* m_staticTextWarningPadFlipped;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
......
......@@ -26,6 +26,7 @@
#include <router/pns_routing_settings.h>
#include <base_units.h>
#include <confirm.h>
#include <boost/optional.hpp>
DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, PNS_ROUTING_SETTINGS& aSettings ) :
DIALOG_TRACK_VIA_SIZE_BASE( aParent ),
......
......@@ -1213,14 +1213,13 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_GEN_IMPORT_DXF_FILE:
InvokeDXFDialogImport( this );
InvokeDXFDialogBoardImport( this );
m_canvas->Refresh();
break;
default:
wxString msg;
msg.Printf( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() unknown event id %d" ),
id );
msg.Printf( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() unknown event id %d" ), id );
DisplayError( this, msg );
break;
}
......@@ -1385,125 +1384,99 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
if( GetToolId() == id )
return;
if( IsGalCanvasActive() )
{
std::string actionName = COMMON_ACTIONS::TranslateLegacyId( id );
INSTALL_UNBUFFERED_DC( dc, m_canvas );
if( !actionName.empty() || id == ID_NO_TOOL_SELECTED )
{
const int MAX_TRIALS = 10;
int trials = 0;
// Cancel the current tool
// TODO while sending a lot of cancel events works for sure, it is not the most
// elegant way to cancel a tool, this should be probably done another way
while( m_toolManager->GetCurrentTool()->GetName() != "pcbnew.InteractiveSelection" &&
trials++ < MAX_TRIALS )
{
TOOL_EVENT cancel( TC_ANY, TA_CANCEL_TOOL );
m_toolManager->ProcessEvent( cancel );
}
// Stop the current command and deselect the current tool.
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
if( !actionName.empty() )
m_toolManager->RunAction( actionName );
}
}
else
switch( id )
{
INSTALL_UNBUFFERED_DC( dc, m_canvas );
case ID_NO_TOOL_SELECTED:
SetToolID( id, m_canvas->GetDefaultCursor(), wxEmptyString );
break;
// Stop the current command and deselect the current tool.
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
case ID_TRACK_BUTT:
if( g_Drc_On )
SetToolID( id, wxCURSOR_PENCIL, _( "Add tracks" ) );
else
SetToolID( id, wxCURSOR_QUESTION_ARROW, _( "Add tracks" ) );
switch( id )
if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
{
case ID_NO_TOOL_SELECTED:
SetToolID( id, m_canvas->GetDefaultCursor(), wxEmptyString );
break;
case ID_TRACK_BUTT:
if( g_Drc_On )
SetToolID( id, wxCURSOR_PENCIL, _( "Add tracks" ) );
else
SetToolID( id, wxCURSOR_QUESTION_ARROW, _( "Add tracks" ) );
if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
{
Compile_Ratsnest( &dc, true );
}
Compile_Ratsnest( &dc, true );
}
break;
break;
case ID_PCB_MODULE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add module" ) );
break;
case ID_PCB_MODULE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add module" ) );
break;
case ID_PCB_ZONES_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add zones" ) );
case ID_PCB_ZONES_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add zones" ) );
if( DisplayOpt.DisplayZonesMode != 0 )
DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) );
if( DisplayOpt.DisplayZonesMode != 0 )
DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) );
if( !GetBoard()->IsHighLightNetON() && (GetBoard()->GetHighLightNetCode() > 0 ) )
HighLight( &dc );
if( !GetBoard()->IsHighLightNetON() && (GetBoard()->GetHighLightNetCode() > 0 ) )
HighLight( &dc );
break;
break;
case ID_PCB_KEEPOUT_AREA_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add keepout" ) );
break;
case ID_PCB_KEEPOUT_AREA_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add keepout" ) );
break;
case ID_PCB_MIRE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
break;
case ID_PCB_MIRE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
break;
case ID_PCB_PLACE_OFFSET_COORD_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Adjust zero" ) );
break;
case ID_PCB_PLACE_OFFSET_COORD_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Adjust zero" ) );
break;
case ID_PCB_PLACE_GRID_COORD_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
break;
case ID_PCB_PLACE_GRID_COORD_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
break;
case ID_PCB_ADD_LINE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic line" ) );
break;
case ID_PCB_ADD_LINE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic line" ) );
break;
case ID_PCB_ARC_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
break;
case ID_PCB_ARC_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
break;
case ID_PCB_CIRCLE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
break;
case ID_PCB_CIRCLE_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
break;
case ID_PCB_ADD_TEXT_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
break;
case ID_PCB_ADD_TEXT_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
break;
case ID_COMPONENT_BUTT:
SetToolID( id, wxCURSOR_HAND, _( "Add module" ) );
break;
case ID_COMPONENT_BUTT:
SetToolID( id, wxCURSOR_HAND, _( "Add module" ) );
break;
case ID_PCB_DIMENSION_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add dimension" ) );
break;
case ID_PCB_DIMENSION_BUTT:
SetToolID( id, wxCURSOR_PENCIL, _( "Add dimension" ) );
break;
case ID_PCB_DELETE_ITEM_BUTT:
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
break;
case ID_PCB_DELETE_ITEM_BUTT:
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
break;
case ID_PCB_HIGHLIGHT_BUTT:
SetToolID( id, wxCURSOR_HAND, _( "Highlight net" ) );
break;
case ID_PCB_HIGHLIGHT_BUTT:
SetToolID( id, wxCURSOR_HAND, _( "Highlight net" ) );
break;
case ID_PCB_SHOW_1_RATSNEST_BUTT:
SetToolID( id, wxCURSOR_HAND, _( "Select rats nest" ) );
case ID_PCB_SHOW_1_RATSNEST_BUTT:
SetToolID( id, wxCURSOR_HAND, _( "Select rats nest" ) );
if( ( GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK ) == 0 )
Compile_Ratsnest( &dc, true );
if( ( GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK ) == 0 )
Compile_Ratsnest( &dc, true );
break;
}
break;
}
}
......@@ -637,7 +637,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) throw( IO_ERROR,
pad->SetShape( PAD_OVAL );
}
module->AddPad( pad );
module->Add( pad );
continue;
}
......@@ -701,7 +701,7 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader ) throw( IO_ERROR,
if( pad->GetShape() == PAD_ROUND && pad->GetSize().x != pad->GetSize().y )
pad->SetShape( PAD_OVAL );
module->AddPad( pad );
module->Add( pad );
continue;
}
}
......
......@@ -27,42 +27,24 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <dialog_dxf_import.h>
//#include <pgm_base.h>
#include <kiface_i.h>
#include <dxf2brd_items.h>
#include <wxPcbStruct.h>
#include <convert_from_iu.h>
#include <dialog_dxf_import_base.h>
#include <class_pcb_layer_box_selector.h>
#include <class_draw_panel_gal.h>
#include <class_board.h>
#include <class_module.h>
#include <class_edge_mod.h>
#include <class_text_mod.h>
#include <class_pcb_text.h>
// Keys to store setup in config
#define DXF_IMPORT_LAYER_OPTION_KEY wxT("DxfImportBrdLayer")
#define DXF_IMPORT_COORD_ORIGIN_KEY wxT("DxfImportCoordOrigin")
#define DXF_IMPORT_LAST_FILE_KEY wxT("DxfImportLastFile")
class DIALOG_DXF_IMPORT : public DIALOG_DXF_IMPORT_BASE
{
private:
PCB_EDIT_FRAME * m_parent;
wxConfigBase* m_config; // Current config
static wxString m_dxfFilename;
static int m_offsetSelection;
static LAYER_NUM m_layer;
public:
DIALOG_DXF_IMPORT( PCB_EDIT_FRAME* aParent );
~DIALOG_DXF_IMPORT();
private:
// Virtual event handlers
void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
void OnOKClick( wxCommandEvent& event );
void OnBrowseDxfFiles( wxCommandEvent& event );
};
// Static members of DIALOG_DXF_IMPORT, to remember
// the user's choices during the session
wxString DIALOG_DXF_IMPORT::m_dxfFilename;
......@@ -70,8 +52,8 @@ int DIALOG_DXF_IMPORT::m_offsetSelection = 4;
LAYER_NUM DIALOG_DXF_IMPORT::m_layer = Dwgs_User;
DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT( PCB_EDIT_FRAME* aParent ) :
DIALOG_DXF_IMPORT_BASE( aParent )
DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent )
: DIALOG_DXF_IMPORT_BASE( aParent )
{
m_parent = aParent;
m_config = Kiface().KifaceSettings();
......@@ -121,16 +103,18 @@ DIALOG_DXF_IMPORT::~DIALOG_DXF_IMPORT()
void DIALOG_DXF_IMPORT::OnBrowseDxfFiles( wxCommandEvent& event )
{
wxString path;
wxString filename;
if( !m_dxfFilename.IsEmpty() )
{
wxFileName fn( m_dxfFilename );
path = fn.GetPath();
filename = fn.GetFullName();
}
wxFileDialog dlg( m_parent,
wxT( "Open File" ),
path, m_dxfFilename,
wxT( "dxf Files (*.dxf)|*.dxf|*.DXF" ),
path, filename,
wxT( "dxf Files (*.dxf)|*.dxf" ),
wxFD_OPEN|wxFD_FILE_MUST_EXIST );
dlg.ShowModal();
......@@ -143,6 +127,7 @@ void DIALOG_DXF_IMPORT::OnBrowseDxfFiles( wxCommandEvent& event )
m_textCtrlFileName->SetValue( fileName );
}
void DIALOG_DXF_IMPORT::OnOKClick( wxCommandEvent& event )
{
m_dxfFilename = m_textCtrlFileName->GetValue();
......@@ -173,41 +158,105 @@ void DIALOG_DXF_IMPORT::OnOKClick( wxCommandEvent& event )
break;
}
BOARD * brd = m_parent->GetBoard();
DXF2BRD_CONVERTER dxf_importer;
// Set coordinates offset for import (offset is given in mm)
dxf_importer.SetOffset( offsetX, offsetY );
m_dxfImporter.SetOffset( offsetX, offsetY );
m_layer = m_SelLayerBox->GetLayerSelection();
dxf_importer.SetBrdLayer( m_layer );
m_dxfImporter.SetBrdLayer( m_layer );
// Read dxf file:
dxf_importer.ImportDxfFile( m_dxfFilename, brd );
m_dxfImporter.ImportDxfFile( m_dxfFilename );
EndModal( wxID_OK );
}
// Prepare the undo list
std::vector<BOARD_ITEM*>& list = dxf_importer.GetItemsList();
PICKED_ITEMS_LIST picklist;
// Build the undo list
for( unsigned ii = 0; ii < list.size(); ii++ )
bool InvokeDXFDialogBoardImport( PCB_BASE_FRAME* aCaller )
{
DIALOG_DXF_IMPORT dlg( aCaller );
bool success = ( dlg.ShowModal() == wxID_OK );
if( success )
{
ITEM_PICKER itemWrapper( list[ii], UR_NEW );
picklist.PushItem( itemWrapper );
}
const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
PICKED_ITEMS_LIST picklist;
m_parent->SaveCopyInUndoList( picklist, UR_NEW, wxPoint(0,0) );
BOARD* board = aCaller->GetBoard();
KIGFX::VIEW* view = aCaller->GetGalCanvas()->GetView();
EndModal( wxID_OK );
std::list<BOARD_ITEM*>::const_iterator it, itEnd;
for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
{
BOARD_ITEM* item = *it;
board->Add( item );
ITEM_PICKER itemWrapper( item, UR_NEW );
picklist.PushItem( itemWrapper );
if( aCaller->IsGalCanvasActive() )
view->Add( item );
}
aCaller->SaveCopyInUndoList( picklist, UR_NEW, wxPoint( 0, 0 ) );
aCaller->OnModify();
}
return success;
}
bool InvokeDXFDialogImport( PCB_EDIT_FRAME* aCaller )
bool InvokeDXFDialogModuleImport( PCB_BASE_FRAME* aCaller, MODULE* aModule )
{
DIALOG_DXF_IMPORT dlg( aCaller );
bool success = dlg.ShowModal() == wxID_OK;
bool success = ( dlg.ShowModal() == wxID_OK );
if( success )
{
const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
MODULE* module = aCaller->GetBoard()->m_Modules;
KIGFX::VIEW* view = aCaller->GetGalCanvas()->GetView();
aCaller->SaveCopyInUndoList( module, UR_MODEDIT );
aCaller->OnModify();
std::list<BOARD_ITEM*>::const_iterator it, itEnd;
for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
{
BOARD_ITEM* item = *it;
BOARD_ITEM* converted = NULL;
// Modules use different types for the same things,
// so we need to convert imported items to appropriate classes.
switch( item->Type() )
{
case PCB_LINE_T:
{
converted = new EDGE_MODULE( module );
*static_cast<DRAWSEGMENT*>( converted ) = *static_cast<DRAWSEGMENT*>( item );
module->Add( converted );
static_cast<EDGE_MODULE*>( converted )->SetLocalCoord();
delete item;
break;
}
case PCB_TEXT_T:
{
converted = new TEXTE_MODULE( module );
*static_cast<TEXTE_PCB*>( converted ) = *static_cast<TEXTE_PCB*>( item );
module->Add( module );
static_cast<TEXTE_MODULE*>( converted )->SetLocalCoord();
delete item;
break;
}
default:
assert( false ); // there is a type that is currently not handled here
break;
}
if( aCaller->IsGalCanvasActive() )
view->Add( converted );
}
}
return success;
}
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
*/
#include <dialog_dxf_import_base.h>
#include <wxPcbStruct.h>
#include <dxf2brd_items.h>
class DIALOG_DXF_IMPORT : public DIALOG_DXF_IMPORT_BASE
{
public:
DIALOG_DXF_IMPORT( PCB_BASE_FRAME* aParent );
~DIALOG_DXF_IMPORT();
/**
* Function GetImportedItems()
*
* Returns a list of items imported from a DXF file.
*/
const std::list<BOARD_ITEM*>& GetImportedItems() const
{
return m_dxfImporter.GetItemsList();
}
private:
PCB_BASE_FRAME* m_parent;
wxConfigBase* m_config; // Current config
DXF2BRD_CONVERTER m_dxfImporter;
static wxString m_dxfFilename;
static int m_offsetSelection;
static LAYER_NUM m_layer;
// Virtual event handlers
void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
void OnOKClick( wxCommandEvent& event );
void OnBrowseDxfFiles( wxCommandEvent& event );
};
This diff is collapsed.
......@@ -28,6 +28,7 @@
#include "drw_interface.h"
#include "wx/wx.h"
#include <list>
class BOARD;
class BOARD_ITEM;
......@@ -41,16 +42,14 @@ class BOARD_ITEM;
class DXF2BRD_CONVERTER : public DRW_Interface
{
private:
std::vector<BOARD_ITEM*> m_newItemsList; // The list of new items added
// to the board
BOARD * m_brd;
std::list<BOARD_ITEM*> m_newItemsList; // The list of new items added to the board
double m_xOffset; // X coord offset for conversion (in mm)
double m_yOffset; // Y coord offset for conversion (in mm)
double m_defaultThickness; // default line thickness for conversion (in mm)
double m_Dfx2mm; // The scale factor to convert DXF units to mm
// Seems DRW_Interface always converts DXF coordinates in mm
// (to be confirmed)
int m_brdLayer; // The board layer to place imported dfx items
int m_brdLayer; // The board layer to place imported dfx items
int m_version; // the dxf version, not used here
std::string m_codePage; // The code page, not used here
......@@ -83,14 +82,13 @@ public:
* with this filter.
*
* @param aFile = the full filename.
* @param aBoard = where to store the graphical items and text
*/
bool ImportDxfFile( const wxString& aFile, BOARD * aBoard );
bool ImportDxfFile( const wxString& aFile );
/**
* @return the list of new BOARD_ITEM
*/
std::vector<BOARD_ITEM*>& GetItemsList()
const std::list<BOARD_ITEM*>& GetItemsList() const
{
return m_newItemsList;
}
......@@ -101,68 +99,63 @@ private:
int mapY( double aDxfCoordY );
int mapDim( double aDxfValue );
// Add aItem the the board
// this item is also added to the list of new items
// (for undo command for instance)
void appendToBoard( BOARD_ITEM * aItem );
// Methods from DRW_CreationInterface:
// They are "call back" fonctions, called when the corresponding object
// is read in dxf file
// Depending of the application, they can do something or not
virtual void addHeader( const DRW_Header* data );
virtual void addLType( const DRW_LType& data ){}
virtual void addLayer( const DRW_Layer& data );
virtual void addDimStyle( const DRW_Dimstyle& data ){}
virtual void addBlock(const DRW_Block& data ){}
virtual void endBlock(){}
virtual void addPoint(const DRW_Point& data ){}
virtual void addLine(const DRW_Line& data);
virtual void addRay(const DRW_Ray& data ){}
virtual void addXline(const DRW_Xline& data ){}
virtual void addCircle(const DRW_Circle& data );
virtual void addArc(const DRW_Arc& data );
virtual void addEllipse(const DRW_Ellipse& data ){}
virtual void addLWPolyline(const DRW_LWPolyline& data );
virtual void addText(const DRW_Text& data );
virtual void addPolyline(const DRW_Polyline& data );
virtual void addSpline(const DRW_Spline* data ){}
virtual void addKnot(const DRW_Entity&) {}
virtual void addInsert(const DRW_Insert& data ){}
virtual void addTrace(const DRW_Trace& data ){}
virtual void addSolid(const DRW_Solid& data ){}
virtual void addMText(const DRW_MText& data);
virtual void addDimAlign(const DRW_DimAligned *data ){}
virtual void addDimLinear(const DRW_DimLinear *data ){}
virtual void addDimRadial(const DRW_DimRadial *data ){}
virtual void addDimDiametric(const DRW_DimDiametric *data ){}
virtual void addDimAngular(const DRW_DimAngular *data ){}
virtual void addDimAngular3P(const DRW_DimAngular3p *data ){}
virtual void addDimOrdinate(const DRW_DimOrdinate *data ){}
virtual void addLeader(const DRW_Leader *data ){}
virtual void addHatch(const DRW_Hatch* data ){}
virtual void addImage(const DRW_Image* data ){}
virtual void linkImage(const DRW_ImageDef* data ){}
virtual void add3dFace(const DRW_3Dface& data ){}
virtual void addComment(const char*){}
virtual void addVport(const DRW_Vport& data) {}
virtual void addTextStyle(const DRW_Textstyle& data);
virtual void addViewport(const DRW_Viewport& data) {}
virtual void setBlock(const int handle) {}
static wxString toDxfString(const wxString& str);
static wxString toNativeString(const wxString& data);
virtual void addHeader( const DRW_Header* aData );
virtual void addLType( const DRW_LType& aData ) {}
virtual void addLayer( const DRW_Layer& aData );
virtual void addDimStyle( const DRW_Dimstyle& aData ) {}
virtual void addBlock( const DRW_Block& aData ) {}
virtual void endBlock() {}
virtual void addPoint( const DRW_Point& aData ) {}
virtual void addLine( const DRW_Line& aData);
virtual void addRay( const DRW_Ray& aData ) {}
virtual void addXline( const DRW_Xline& aData ) {}
virtual void addCircle( const DRW_Circle& aData );
virtual void addArc( const DRW_Arc& aData );
virtual void addEllipse( const DRW_Ellipse& aData ) {}
virtual void addLWPolyline( const DRW_LWPolyline& aData );
virtual void addText( const DRW_Text& aData );
virtual void addPolyline( const DRW_Polyline& aData );
virtual void addSpline( const DRW_Spline* aData ) {}
virtual void addKnot( const DRW_Entity&) {}
virtual void addInsert( const DRW_Insert& aData ){}
virtual void addTrace( const DRW_Trace& aData ){}
virtual void addSolid( const DRW_Solid& aData ){}
virtual void addMText( const DRW_MText& aData);
virtual void addDimAlign( const DRW_DimAligned* aData ) {}
virtual void addDimLinear( const DRW_DimLinear* aData ) {}
virtual void addDimRadial( const DRW_DimRadial* aData ) {}
virtual void addDimDiametric( const DRW_DimDiametric* aData ) {}
virtual void addDimAngular( const DRW_DimAngular* aData ) {}
virtual void addDimAngular3P( const DRW_DimAngular3p* aData ) {}
virtual void addDimOrdinate( const DRW_DimOrdinate* aData ) {}
virtual void addLeader( const DRW_Leader* aData ) {}
virtual void addHatch( const DRW_Hatch* aData ) {}
virtual void addImage( const DRW_Image* aData ) {}
virtual void linkImage( const DRW_ImageDef* aData ) {}
virtual void add3dFace( const DRW_3Dface& aData ) {}
virtual void addComment( const char*) {}
virtual void addVport( const DRW_Vport& aData ) {}
virtual void addTextStyle( const DRW_Textstyle& aData );
virtual void addViewport( const DRW_Viewport& aData ) {}
virtual void setBlock( const int aHandle ) {}
static wxString toDxfString( const wxString& aStr );
static wxString toNativeString( const wxString& aData );
// These functions are not used in Kicad.
// But because they are virtual pure in DRW_Interface, they should be defined
virtual void writeTextstyles() {}
virtual void writeVports() {}
virtual void writeHeader(DRW_Header& data) {}
virtual void writeHeader( DRW_Header& aData ) {}
virtual void writeEntities() {}
virtual void writeLTypes() {}
virtual void writeLayers() {}
......@@ -172,7 +165,6 @@ private:
void writeLine();
void writeMtext();
};
#endif // FILTERDXFRW_H
......@@ -61,9 +61,6 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
// Update display
GetBoard()->SetVisibleLayers( LSET().set() );
// Set currently selected layer to be shown in high contrast mode, when enabled`
SetHighContrastLayer( GetScreen()->m_Active_Layer );
ReFillLayerWidget();
Zoom_Automatique( false );
......
......@@ -49,10 +49,12 @@ class wxSize;
//class wxRealPoint;
class wxString;
class BOARD;
class MODULE;
// Often this is not used in the prototypes, since wxFrame is good enough and would
// represent maximum information hiding.
class PCB_EDIT_FRAME;
class PCB_BASE_FRAME;
class FP_LIB_TABLE;
class BOARD;
class PCB_PLOT_PARAMS;
......@@ -81,13 +83,22 @@ void InvokePluginOptionsEditor( wxTopLevelWindow* aCaller, const wxString& aNick
const wxString& aPluginType, const wxString& aOptions, wxString* aResult );
/**
* Function InvokePcbLibTableEditor
* shows the modal DIALOG_FP_LIB_TABLE for purposes of editing two lib tables.
* Function InvokeDXFDialogBoardImport
* shows the modal DIALOG_DXF_IMPORT for importing a DXF file to a board.
* @param aCaller is the wxTopLevelWindow which is invoking the dialog.
* @return true if the import was made.
*/
bool InvokeDXFDialogBoardImport( PCB_BASE_FRAME* aCaller );
/**
* Function InvokeDXFDialogModuleImport
* shows the modal DIALOG_DXF_IMPORT for importing a DXF file.to a module.
*
* @param aCaller is the wxTopLevelWindow which is invoking the dialog.
* @return true if the ilport was made.
* @return true if the import was made.
*/
bool InvokeDXFDialogImport( PCB_EDIT_FRAME* aCaller );
bool InvokeDXFDialogModuleImport( PCB_BASE_FRAME* aCaller, MODULE* aModule );
/**
* Function InvokeLayerSetup
......
This diff is collapsed.
......@@ -98,6 +98,7 @@ public:
}
};
static const wxEventType EVT_LAYER_COLOR_CHANGE;
protected:
......@@ -226,6 +227,8 @@ public:
wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
virtual ~LAYER_WIDGET();
/**
* Function GetBestSize
* returns the preferred minimum size, taking into consideration the
......
......@@ -274,6 +274,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
PlaceModule( module, NULL );
GetBoard()->m_Status_Pcb = 0;
GetBoard()->BuildListOfNets();
updateView();
return module;
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -1856,7 +1856,7 @@ MODULE* PCB_PARSER::parseMODULE( wxArrayString* aInitialComments ) throw( IO_ERR
RotatePoint( &pt, module->GetOrientation() );
pad->SetPosition( pt + module->GetPosition() );
module->AddPad( pad );
module->Add( pad );
}
break;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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