Commit 9eb39168 authored by tomasz.wlostowski@cern.ch's avatar tomasz.wlostowski@cern.ch

Merged kicad-gal-orson

parents fa817b74 5659dd47
...@@ -415,6 +415,6 @@ void CALLBACK tessErrorCB( GLenum errorCode ) ...@@ -415,6 +415,6 @@ void CALLBACK tessErrorCB( GLenum errorCode )
errorStr = gluErrorString( errorCode ); errorStr = gluErrorString( errorCode );
// DEBUG // // DEBUG //
D( printf( "Tess ERROR: %s\n", errorStr ); ) DBG( printf( "Tess ERROR: %s\n", errorStr ); )
#endif #endif
} }
...@@ -115,7 +115,7 @@ int VRML_MODEL_PARSER::readMaterial( FILE* file, int* LineNum ) ...@@ -115,7 +115,7 @@ int VRML_MODEL_PARSER::readMaterial( FILE* file, int* LineNum )
} }
} }
D( printf( "ReadMaterial error: material not found\n" ) ); DBG( printf( "ReadMaterial error: material not found\n" ) );
return 0; return 0;
} }
...@@ -207,7 +207,7 @@ int VRML_MODEL_PARSER::readChildren( FILE* file, int* LineNum ) ...@@ -207,7 +207,7 @@ int VRML_MODEL_PARSER::readChildren( FILE* file, int* LineNum )
} }
else else
{ {
D( printf( "ReadChildren error line %d <%s> \n", *LineNum, text ) ); DBG( printf( "ReadChildren error line %d <%s> \n", *LineNum, text ) );
break; break;
} }
} }
...@@ -241,7 +241,7 @@ int VRML_MODEL_PARSER::readShape( FILE* file, int* LineNum ) ...@@ -241,7 +241,7 @@ int VRML_MODEL_PARSER::readShape( FILE* file, int* LineNum )
} }
else else
{ {
D( printf( "ReadShape error line %d <%s> \n", *LineNum, text ) ); DBG( printf( "ReadShape error line %d <%s> \n", *LineNum, text ) );
break; break;
} }
} }
...@@ -271,7 +271,7 @@ int VRML_MODEL_PARSER::readAppearance( FILE* file, int* LineNum ) ...@@ -271,7 +271,7 @@ int VRML_MODEL_PARSER::readAppearance( FILE* file, int* LineNum )
} }
else else
{ {
D( printf( "ReadAppearance error line %d <%s> \n", *LineNum, text ) ); DBG( printf( "ReadAppearance error line %d <%s> \n", *LineNum, text ) );
break; break;
} }
} }
......
...@@ -197,19 +197,19 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) ...@@ -197,19 +197,19 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
if( !parseDoubleTriplet( properties[ wxT( "diffuseColor" ) ], if( !parseDoubleTriplet( properties[ wxT( "diffuseColor" ) ],
material->m_DiffuseColor ) ) material->m_DiffuseColor ) )
{ {
D( printf("diffuseColor parsing error") ); DBG( printf("diffuseColor parsing error") );
} }
if( !parseDoubleTriplet( properties[ wxT( "specularColor" ) ], if( !parseDoubleTriplet( properties[ wxT( "specularColor" ) ],
material->m_SpecularColor ) ) material->m_SpecularColor ) )
{ {
D( printf("specularColor parsing error") ); DBG( printf("specularColor parsing error") );
} }
if( !parseDoubleTriplet( properties[ wxT( "emissiveColor" ) ], if( !parseDoubleTriplet( properties[ wxT( "emissiveColor" ) ],
material->m_EmissiveColor ) ) material->m_EmissiveColor ) )
{ {
D( printf("emissiveColor parsing error") ); DBG( printf("emissiveColor parsing error") );
} }
wxStringTokenizer values; wxStringTokenizer values;
...@@ -221,7 +221,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) ...@@ -221,7 +221,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
} }
else else
{ {
D( printf( "ambienterror" ) ); DBG( printf( "ambienterror" ) );
} }
values.SetString( properties[ wxT( "shininess" ) ] ); values.SetString( properties[ wxT( "shininess" ) ] );
...@@ -232,7 +232,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) ...@@ -232,7 +232,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
} }
else else
{ {
D( printf( "shininess error" ) ); DBG( printf( "shininess error" ) );
} }
values.SetString( properties[ wxT( "transparency" ) ] ); values.SetString( properties[ wxT( "transparency" ) ] );
...@@ -243,7 +243,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) ...@@ -243,7 +243,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
} }
else else
{ {
D( printf( "trans error") ); DBG( printf( "trans error") );
} }
material->SetMaterial(); material->SetMaterial();
...@@ -303,7 +303,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode ) ...@@ -303,7 +303,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
} }
} }
D( printf( "ReadMaterial error: material not found\n" ) ); DBG( printf( "ReadMaterial error: material not found\n" ) );
} }
} }
...@@ -373,7 +373,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode, ...@@ -373,7 +373,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode,
tokens.GetNextToken().ToDouble( &rotation.z ) && tokens.GetNextToken().ToDouble( &rotation.z ) &&
tokens.GetNextToken().ToDouble( &angle ) ) ) tokens.GetNextToken().ToDouble( &angle ) ) )
{ {
D( printf("rotation read error") ); DBG( printf("rotation read error") );
} }
double vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * double vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits *
...@@ -407,7 +407,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode, ...@@ -407,7 +407,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode,
if( points.size() % 3 != 0 ) if( points.size() % 3 != 0 )
{ {
D( printf( "Number of points is incorrect" ) ); DBG( printf( "Number of points is incorrect" ) );
return; return;
} }
......
...@@ -222,7 +222,7 @@ void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event ) ...@@ -222,7 +222,7 @@ void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event )
if( SavePageSettings() ) if( SavePageSettings() )
{ {
m_screen->SetModify(); m_screen->SetModify();
m_parent->GetCanvas()->Refresh(); m_parent->RefreshCanvas();
if( m_localPrjConfigChanged ) if( m_localPrjConfigChanged )
m_parent->SaveProjectSettings( true ); m_parent->SaveProjectSettings( true );
......
...@@ -234,13 +234,14 @@ void EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent() ...@@ -234,13 +234,14 @@ void EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent()
void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent ) void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
{ {
SetGridVisibility( !IsGridVisible() ); SetGridVisibility( !IsGridVisible() );
if( m_galCanvasActive ) if( m_galCanvasActive )
{ {
m_galCanvas->GetGAL()->SetGridVisibility( IsGridVisible() ); m_galCanvas->GetGAL()->SetGridVisibility( IsGridVisible() );
m_galCanvas->Refresh(); m_galCanvas->GetView()->MarkTargetDirty( KiGfx::TARGET_NONCACHED );
} }
else
m_canvas->Refresh(); RefreshCanvas();
} }
...@@ -395,11 +396,12 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) ...@@ -395,11 +396,12 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
if( m_galCanvasActive ) if( m_galCanvasActive )
{ {
KiGfx::GAL* gal = m_galCanvas->GetGAL(); m_galCanvas->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x,
gal->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x, screen->GetGrid().m_Size.y ) ); screen->GetGrid().m_Size.y ) );
m_galCanvas->GetView()->MarkTargetDirty( KiGfx::TARGET_NONCACHED );
} }
Refresh(); RefreshCanvas();
} }
...@@ -979,18 +981,18 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) ...@@ -979,18 +981,18 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
// Switch to GAL rendering // Switch to GAL rendering
if( !m_galCanvasActive ) if( !m_galCanvasActive )
{ {
// Change view settings only if GAL was not active previously // Set up grid settings
gal->SetGridVisibility( IsGridVisible() );
gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) );
gal->SetGridOrigin( VECTOR2D( screen->GetGridOrigin() ) );
gal->SetGridOriginMarkerSize( 15 );
gal->SetGridDrawThreshold( 10 );
// Set up viewport
double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() ); double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() );
view->SetScale( zoom ); view->SetScale( zoom );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
} }
// Set up grid settings
gal->SetGridVisibility( IsGridVisible() );
gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) );
gal->SetGridOrigin( VECTOR2D( screen->GetGridOrigin() ) );
gal->SetGridOriginMarkerSize( 15 );
gal->SetGridDrawThreshold( 10 );
} }
else else
{ {
...@@ -1014,6 +1016,8 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) ...@@ -1014,6 +1016,8 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show( aEnable ); m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show( aEnable );
m_auimgr.Update(); m_auimgr.Update();
m_galCanvas->SetFocus();
m_galCanvasActive = aEnable; m_galCanvasActive = aEnable;
if( aEnable )
m_galCanvas->SetFocus();
} }
...@@ -736,8 +736,13 @@ void CAIRO_GAL::SetTarget( RenderTarget aTarget ) ...@@ -736,8 +736,13 @@ void CAIRO_GAL::SetTarget( RenderTarget aTarget )
return; return;
// Cairo grouping prevents display of overlapping items on the same layer in the lighter color // Cairo grouping prevents display of overlapping items on the same layer in the lighter color
cairo_pop_group_to_source( currentContext ); if( isInitialized )
cairo_paint_with_alpha( currentContext, fillColor.a ); {
storePath();
cairo_pop_group_to_source( currentContext );
cairo_paint_with_alpha( currentContext, fillColor.a );
}
switch( aTarget ) switch( aTarget )
{ {
...@@ -752,7 +757,8 @@ void CAIRO_GAL::SetTarget( RenderTarget aTarget ) ...@@ -752,7 +757,8 @@ void CAIRO_GAL::SetTarget( RenderTarget aTarget )
break; break;
} }
cairo_push_group( currentContext ); if( isInitialized )
cairo_push_group( currentContext );
currentTarget = aTarget; currentTarget = aTarget;
} }
......
...@@ -167,8 +167,9 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer() ...@@ -167,8 +167,9 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
} }
} }
ClearBuffer(); ClearBuffer();
// Return to direct rendering (we were asked only to create a buffer, not switch to one)
glBindFramebuffer( GL_FRAMEBUFFER, DIRECT_RENDERING ); glBindFramebuffer( GL_FRAMEBUFFER, DIRECT_RENDERING );
m_currentFbo = DIRECT_RENDERING; m_currentFbo = DIRECT_RENDERING;
......
...@@ -471,6 +471,7 @@ void OPENGL_GAL::DrawPolygon( const std::deque<VECTOR2D>& aPointList ) ...@@ -471,6 +471,7 @@ void OPENGL_GAL::DrawPolygon( const std::deque<VECTOR2D>& aPointList )
// Any non convex polygon needs to be tesselated // Any non convex polygon needs to be tesselated
// for this purpose the GLU standard functions are used // for this purpose the GLU standard functions are used
currentManager->Shader( SHADER_NONE ); currentManager->Shader( SHADER_NONE );
currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a );
TessParams params = { currentManager, tessIntersects }; TessParams params = { currentManager, tessIntersects };
gluTessBeginPolygon( tesselator, &params ); gluTessBeginPolygon( tesselator, &params );
......
...@@ -44,7 +44,7 @@ public: ...@@ -44,7 +44,7 @@ public:
if( type == wxEVT_MENU_HIGHLIGHT ) if( type == wxEVT_MENU_HIGHLIGHT )
evt = TOOL_EVENT( TC_Command, TA_ContextMenuUpdate, aEvent.GetId() ); evt = TOOL_EVENT( TC_Command, TA_ContextMenuUpdate, aEvent.GetId() );
else if ( type == wxEVT_COMMAND_MENU_SELECTED ) else if( type == wxEVT_COMMAND_MENU_SELECTED )
evt = TOOL_EVENT( TC_Command, TA_ContextMenuChoice, aEvent.GetId() ); evt = TOOL_EVENT( TC_Command, TA_ContextMenuChoice, aEvent.GetId() );
m_menu->m_tool->GetManager()->ProcessEvent( evt ); m_menu->m_tool->GetManager()->ProcessEvent( evt );
...@@ -60,8 +60,15 @@ CONTEXT_MENU::CONTEXT_MENU() ...@@ -60,8 +60,15 @@ CONTEXT_MENU::CONTEXT_MENU()
m_tool = NULL; m_tool = NULL;
m_menu = new wxMenu(); m_menu = new wxMenu();
m_handler = new CMEventHandler( this ); m_handler = new CMEventHandler( this );
m_menu->Connect( wxEVT_MENU_HIGHLIGHT, wxEventHandler( CMEventHandler::onEvent ), NULL, m_handler ); m_menu->Connect( wxEVT_MENU_HIGHLIGHT, wxEventHandler( CMEventHandler::onEvent ),
m_menu->Connect( wxEVT_COMMAND_MENU_SELECTED, wxEventHandler( CMEventHandler::onEvent ), NULL, m_handler ); NULL, m_handler );
m_menu->Connect( wxEVT_COMMAND_MENU_SELECTED, wxEventHandler( CMEventHandler::onEvent ),
NULL, m_handler );
// Workaround for the case when mouse cursor never reaches menu (it hangs up tools using menu)
wxMenuEvent menuEvent( wxEVT_MENU_HIGHLIGHT, 0, m_menu );
m_menu->AddPendingEvent( menuEvent );
m_titleSet = false; m_titleSet = false;
} }
...@@ -75,6 +82,7 @@ CONTEXT_MENU::~CONTEXT_MENU() ...@@ -75,6 +82,7 @@ CONTEXT_MENU::~CONTEXT_MENU()
void CONTEXT_MENU::SetTitle( const wxString& aTitle ) void CONTEXT_MENU::SetTitle( const wxString& aTitle )
{ {
// Unfortunately wxMenu::SetTitle() does nothing..
if( m_titleSet ) if( m_titleSet )
{ {
m_menu->Delete( m_menu->FindItemByPosition( 0 ) ); // fixme: this is LAME! m_menu->Delete( m_menu->FindItemByPosition( 0 ) ); // fixme: this is LAME!
...@@ -87,7 +95,7 @@ void CONTEXT_MENU::SetTitle( const wxString& aTitle ) ...@@ -87,7 +95,7 @@ void CONTEXT_MENU::SetTitle( const wxString& aTitle )
} }
void CONTEXT_MENU::Add ( const wxString& aItem, int aId ) void CONTEXT_MENU::Add( const wxString& aItem, int aId )
{ {
m_menu->Append( new wxMenuItem( m_menu, aId, aItem, wxEmptyString, wxITEM_NORMAL ) ); m_menu->Append( new wxMenuItem( m_menu, aId, aItem, wxEmptyString, wxITEM_NORMAL ) );
} }
......
...@@ -210,9 +210,9 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent ) ...@@ -210,9 +210,9 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
st->wakeupEvent = aEvent; st->wakeupEvent = aEvent;
st->pendingWait = false; st->pendingWait = false;
st->waitEvents.clear(); st->waitEvents.clear();
st->cofunc->Resume(); if( !st->cofunc->Resume() )
if( !st->cofunc->Running() )
{ {
// The couroutine has finished
finishTool( st ); finishTool( st );
} }
...@@ -261,6 +261,7 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState ) ...@@ -261,6 +261,7 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState )
{ {
wxASSERT( m_activeTools.front() == aState->theTool->GetId() ); wxASSERT( m_activeTools.front() == aState->theTool->GetId() );
// Deactivate the most recent tool and remove it from the active tools queue
aState->idle = true; aState->idle = true;
m_activeTools.erase( m_activeTools.begin() ); m_activeTools.erase( m_activeTools.begin() );
......
...@@ -98,9 +98,9 @@ void VIEW::Add( VIEW_ITEM* aItem ) ...@@ -98,9 +98,9 @@ void VIEW::Add( VIEW_ITEM* aItem )
for( int i = 0; i < layers_count; i++ ) for( int i = 0; i < layers_count; i++ )
{ {
VIEW_LAYER* l = &m_layers[layers[i]]; VIEW_LAYER& l = m_layers[layers[i]];
l->items->Insert( aItem ); l.items->Insert( aItem );
l->dirtyExtents.Merge( aItem->ViewBBox() ); l.isDirty = true;
} }
if( m_dynamic ) if( m_dynamic )
...@@ -386,7 +386,7 @@ struct VIEW::updateItemsColor ...@@ -386,7 +386,7 @@ struct VIEW::updateItemsColor
void VIEW::UpdateLayerColor( int aLayer ) void VIEW::UpdateLayerColor( int aLayer )
{ {
// There is no point in updating non-cached layers // There is no point in updating non-cached layers
if( !isCached( aLayer ) ) if( !IsCached( aLayer ) )
return; return;
BOX2I r; BOX2I r;
...@@ -409,7 +409,7 @@ void VIEW::UpdateAllLayersColor() ...@@ -409,7 +409,7 @@ void VIEW::UpdateAllLayersColor()
VIEW_LAYER* l = &( ( *i ).second ); VIEW_LAYER* l = &( ( *i ).second );
// There is no point in updating non-cached layers // There is no point in updating non-cached layers
if( !isCached( l->id ) ) if( !IsCached( l->id ) )
continue; continue;
updateItemsColor visitor( l->id, m_painter, m_gal ); updateItemsColor visitor( l->id, m_painter, m_gal );
...@@ -441,7 +441,7 @@ struct VIEW::changeItemsDepth ...@@ -441,7 +441,7 @@ struct VIEW::changeItemsDepth
void VIEW::ChangeLayerDepth( int aLayer, int aDepth ) void VIEW::ChangeLayerDepth( int aLayer, int aDepth )
{ {
// There is no point in updating non-cached layers // There is no point in updating non-cached layers
if( !isCached( aLayer ) ) if( !IsCached( aLayer ) )
return; return;
BOX2I r; BOX2I r;
...@@ -564,6 +564,7 @@ void VIEW::redrawRect( const BOX2I& aRect ) ...@@ -564,6 +564,7 @@ void VIEW::redrawRect( const BOX2I& aRect )
m_gal->SetLayerDepth( l->renderingOrder ); m_gal->SetLayerDepth( l->renderingOrder );
l->items->Query( aRect, drawFunc ); l->items->Query( aRect, drawFunc );
} }
l->isDirty = false; l->isDirty = false;
} }
} }
...@@ -571,7 +572,7 @@ void VIEW::redrawRect( const BOX2I& aRect ) ...@@ -571,7 +572,7 @@ void VIEW::redrawRect( const BOX2I& aRect )
void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate ) const void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate ) const
{ {
if( isCached( aLayer ) && !aImmediate ) if( IsCached( aLayer ) && !aImmediate )
{ {
// Draw using cached information or create one // Draw using cached information or create one
int group = aItem->getGroup( aLayer ); int group = aItem->getGroup( aLayer );
...@@ -697,6 +698,7 @@ void VIEW::Clear() ...@@ -697,6 +698,7 @@ void VIEW::Clear()
{ {
VIEW_LAYER* l = &( ( *i ).second ); VIEW_LAYER* l = &( ( *i ).second );
unlinkItem v; unlinkItem v;
if( m_dynamic ) if( m_dynamic )
l->items->Query( r, v ); l->items->Query( r, v );
...@@ -789,6 +791,9 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags ) ...@@ -789,6 +791,9 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
int layers[VIEW_MAX_LAYERS], layers_count; int layers[VIEW_MAX_LAYERS], layers_count;
aItem->getLayers( layers, layers_count ); aItem->getLayers( layers, layers_count );
if( aUpdateFlags & VIEW_ITEM::GEOMETRY )
updateBbox( aItem );
// Iterate through layers used by the item and recache it immediately // Iterate through layers used by the item and recache it immediately
for( int i = 0; i < layers_count; i++ ) for( int i = 0; i < layers_count; i++ )
{ {
...@@ -796,12 +801,8 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags ) ...@@ -796,12 +801,8 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
if( aUpdateFlags & VIEW_ITEM::GEOMETRY ) if( aUpdateFlags & VIEW_ITEM::GEOMETRY )
{ {
// Reinsert item in order to update bounding box if( IsCached( layerId ) )
Remove( aItem ); updateItemGeometry( aItem, layerId );
Add( aItem );
if( isCached( layerId ) )
updateItemGeometry( aItem, layerId ); /// TODO is it still necessary?
} }
else if( aUpdateFlags & VIEW_ITEM::COLOR ) else if( aUpdateFlags & VIEW_ITEM::COLOR )
{ {
...@@ -860,6 +861,21 @@ void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer ) ...@@ -860,6 +861,21 @@ void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer )
} }
void VIEW::updateBbox( VIEW_ITEM* aItem )
{
int layers[VIEW_MAX_LAYERS], layers_count;
aItem->ViewGetLayers( layers, layers_count );
for( int i = 0; i < layers_count; i++ )
{
VIEW_LAYER& l = m_layers[layers[i]];
l.items->Remove( aItem );
l.items->Insert( aItem );
l.isDirty = true;
}
}
bool VIEW::areRequiredLayersEnabled( int aLayerId ) const bool VIEW::areRequiredLayersEnabled( int aLayerId ) const
{ {
wxASSERT( (unsigned) aLayerId < m_layers.size() ); wxASSERT( (unsigned) aLayerId < m_layers.size() );
...@@ -893,13 +909,13 @@ void VIEW::RecacheAllItems( bool aImmediately ) ...@@ -893,13 +909,13 @@ void VIEW::RecacheAllItems( bool aImmediately )
{ {
VIEW_LAYER* l = &( ( *i ).second ); VIEW_LAYER* l = &( ( *i ).second );
if( isCached( l->id ) ) if( IsCached( l->id ) )
{ {
m_gal->SetTarget( l->target ); m_gal->SetTarget( l->target );
m_gal->SetLayerDepth( l->renderingOrder ); m_gal->SetLayerDepth( l->renderingOrder );
recacheLayer visitor( this, m_gal, l->id, aImmediately ); recacheLayer visitor( this, m_gal, l->id, aImmediately );
l->items->Query( r, visitor ); l->items->Query( r, visitor );
l->isDirty = false; l->isDirty = true;
} }
} }
......
...@@ -56,21 +56,18 @@ VIEW_GROUP::~VIEW_GROUP() ...@@ -56,21 +56,18 @@ VIEW_GROUP::~VIEW_GROUP()
void VIEW_GROUP::Add( VIEW_ITEM* aItem ) void VIEW_GROUP::Add( VIEW_ITEM* aItem )
{ {
m_items.insert( aItem ); m_items.insert( aItem );
updateBbox();
} }
void VIEW_GROUP::Remove( VIEW_ITEM* aItem ) void VIEW_GROUP::Remove( VIEW_ITEM* aItem )
{ {
m_items.erase( aItem ); m_items.erase( aItem );
updateBbox();
} }
void VIEW_GROUP::Clear() void VIEW_GROUP::Clear()
{ {
m_items.clear(); m_items.clear();
updateBbox();
} }
void VIEW_GROUP::FreeItems() void VIEW_GROUP::FreeItems()
...@@ -90,15 +87,9 @@ unsigned int VIEW_GROUP::GetSize() const ...@@ -90,15 +87,9 @@ unsigned int VIEW_GROUP::GetSize() const
const BOX2I VIEW_GROUP::ViewBBox() const const BOX2I VIEW_GROUP::ViewBBox() const
{ {
BOX2I box; BOX2I maxBox;
maxBox.SetMaximum();
// Merge all bounding boxes, so the returned one contains all stored items return maxBox;
BOOST_FOREACH( VIEW_ITEM* item, m_items )
{
box.Merge( item->ViewBBox() );
}
return box;
} }
...@@ -115,19 +106,21 @@ void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal, const BOX2I& aVisibleArea ) co ...@@ -115,19 +106,21 @@ void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal, const BOX2I& aVisibleArea ) co
for( int i = 0; i < layers_count; i++ ) for( int i = 0; i < layers_count; i++ )
{ {
aGal->SetLayerDepth( m_view->GetLayerOrder( layers[i] ) ); if( m_view->IsCached( layers[i] ) && m_view->IsLayerVisible( layers[i] ) )
{
aGal->SetLayerDepth( m_view->GetLayerOrder( layers[i] ) );
if( !painter->Draw( item, layers[i] ) ) if( !painter->Draw( item, layers[i] ) )
item->ViewDraw( layers[i], aGal, aVisibleArea ); // Alternative drawing method item->ViewDraw( layers[i], aGal, aVisibleArea ); // Alternative drawing method
}
} }
/// m_view->Draw( item, true );
} }
} }
void VIEW_GROUP::ViewGetLayers( int aLayers[], int& aCount ) const void VIEW_GROUP::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
// Everything is displayed on a single layer
aLayers[0] = m_layer; aLayers[0] = m_layer;
aCount = 1; aCount = 1;
} }
......
...@@ -34,11 +34,6 @@ using namespace KiGfx; ...@@ -34,11 +34,6 @@ using namespace KiGfx;
WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) : WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) :
VIEW_CONTROLS( aView ), VIEW_CONTROLS( aView ),
m_state( IDLE ), m_state( IDLE ),
m_grabMouse( false ),
m_snappingEnabled( true ),
m_autoPanEnabled( false ),
m_autoPanMargin( 0.1 ),
m_autoPanSpeed( 0.15 ),
m_parentPanel( aParentPanel ) m_parentPanel( aParentPanel )
{ {
m_parentPanel->Connect( wxEVT_MOTION, wxMouseEventHandler( m_parentPanel->Connect( wxEVT_MOTION, wxMouseEventHandler(
...@@ -49,6 +44,10 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) : ...@@ -49,6 +44,10 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) :
WX_VIEW_CONTROLS::onButton ), NULL, this ); WX_VIEW_CONTROLS::onButton ), NULL, this );
m_parentPanel->Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( m_parentPanel->Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler(
WX_VIEW_CONTROLS::onButton ), NULL, this ); WX_VIEW_CONTROLS::onButton ), NULL, this );
m_parentPanel->Connect( wxEVT_LEFT_UP, wxMouseEventHandler(
WX_VIEW_CONTROLS::onButton ), NULL, this );
m_parentPanel->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler(
WX_VIEW_CONTROLS::onButton ), NULL, this );
#if defined _WIN32 || defined _WIN64 #if defined _WIN32 || defined _WIN64
m_parentPanel->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( m_parentPanel->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler(
WX_VIEW_CONTROLS::onEnter ), NULL, this ); WX_VIEW_CONTROLS::onEnter ), NULL, this );
...@@ -64,6 +63,12 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent ) ...@@ -64,6 +63,12 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
{ {
m_mousePosition.x = aEvent.GetX(); m_mousePosition.x = aEvent.GetX();
m_mousePosition.y = aEvent.GetY(); m_mousePosition.y = aEvent.GetY();
if( m_snappingEnabled )
m_cursorPosition = m_view->GetGAL()->GetGridPoint( m_mousePosition );
else
m_cursorPosition = m_mousePosition;
bool isAutoPanning = false; bool isAutoPanning = false;
if( m_autoPanEnabled ) if( m_autoPanEnabled )
...@@ -150,6 +155,11 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent ) ...@@ -150,6 +155,11 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
m_lookStartPoint = m_view->GetCenter(); m_lookStartPoint = m_view->GetCenter();
m_state = DRAG_PANNING; m_state = DRAG_PANNING;
} }
if( aEvent.LeftUp() )
{
m_state = IDLE; // Stop autopanning when user release left mouse button
}
break; break;
case DRAG_PANNING: case DRAG_PANNING:
...@@ -187,8 +197,7 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent ) ...@@ -187,8 +197,7 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
dir = m_view->ToWorld( dir, false ); dir = m_view->ToWorld( dir, false );
m_view->SetCenter( m_view->GetCenter() + dir * m_autoPanSpeed ); m_view->SetCenter( m_view->GetCenter() + dir * m_autoPanSpeed );
wxPaintEvent redrawEvent; m_parentPanel->Refresh();
wxPostEvent( m_parentPanel, redrawEvent );
} }
break; break;
...@@ -210,15 +219,6 @@ void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled ) ...@@ -210,15 +219,6 @@ void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled )
} }
VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition() const
{
if( m_snappingEnabled )
return m_view->GetGAL()->GetGridPoint( m_mousePosition );
return m_mousePosition;
}
bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent ) bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
{ {
VECTOR2D p( aEvent.GetX(), aEvent.GetY() ); VECTOR2D p( aEvent.GetX(), aEvent.GetY() );
......
...@@ -52,7 +52,7 @@ void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe ...@@ -52,7 +52,7 @@ void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe
if( aWarpPointer ) if( aWarpPointer )
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
m_canvas->Refresh(); RefreshCanvas();
m_canvas->Update(); m_canvas->Update();
} }
...@@ -64,11 +64,20 @@ void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore ) ...@@ -64,11 +64,20 @@ void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore )
AdjustScrollBars( newCenter ); AdjustScrollBars( newCenter );
m_canvas->Refresh(); RefreshCanvas();
m_canvas->Update(); m_canvas->Update();
} }
void EDA_DRAW_FRAME::RefreshCanvas()
{
if( m_galCanvasActive )
m_galCanvas->Refresh();
else
m_canvas->Refresh();
}
void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer ) void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
{ {
BASE_SCREEN* screen = GetScreen(); BASE_SCREEN* screen = GetScreen();
...@@ -160,7 +169,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) ...@@ -160,7 +169,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
break; break;
case ID_ZOOM_REDRAW: case ID_ZOOM_REDRAW:
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_POPUP_ZOOM_CENTER: case ID_POPUP_ZOOM_CENTER:
......
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
#define WIN_STRING_DIR_SEP wxT( "\\" ) #define WIN_STRING_DIR_SEP wxT( "\\" )
#ifdef DEBUG #ifdef DEBUG
#define D(x) x #define DBG(x) x
#else #else
#define D(x) // nothing #define DBG(x) // nothing
#endif #endif
/** /**
......
...@@ -240,6 +240,7 @@ enum PCB_VISIBLE ...@@ -240,6 +240,7 @@ enum PCB_VISIBLE
PAD_BK_NETNAMES_VISIBLE, PAD_BK_NETNAMES_VISIBLE,
PADS_NETNAMES_VISIBLE, PADS_NETNAMES_VISIBLE,
SELECTION,
GP_OVERLAY, // General purpose overlay GP_OVERLAY, // General purpose overlay
END_PCB_VISIBLE_LIST // sentinel END_PCB_VISIBLE_LIST // sentinel
...@@ -258,7 +259,7 @@ enum PCB_VISIBLE ...@@ -258,7 +259,7 @@ enum PCB_VISIBLE
/// means that layer is displayed closer to the user, ie. on the top). /// means that layer is displayed closer to the user, ie. on the top).
const LAYER_NUM GalLayerOrder[] = const LAYER_NUM GalLayerOrder[] =
{ {
ITEM_GAL_LAYER( GP_OVERLAY ), ITEM_GAL_LAYER( GP_OVERLAY ), ITEM_GAL_LAYER( SELECTION ),
ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE ),
DRAW_N, COMMENT_N, ECO1_N, ECO2_N, EDGE_N, DRAW_N, COMMENT_N, ECO1_N, ECO2_N, EDGE_N,
UNUSED_LAYER_29, UNUSED_LAYER_30, UNUSED_LAYER_31, UNUSED_LAYER_29, UNUSED_LAYER_30, UNUSED_LAYER_31,
......
...@@ -44,7 +44,7 @@ public: ...@@ -44,7 +44,7 @@ public:
~CONTEXT_MENU(); ~CONTEXT_MENU();
void SetTitle( const wxString& aTitle ); void SetTitle( const wxString& aTitle );
void Add ( const wxString& aItem, int aId ); void Add( const wxString& aItem, int aId );
// fixme: unimplemented // fixme: unimplemented
// void Add ( const TOOL_ACTION& aAction, int aId = -1 ); // void Add ( const TOOL_ACTION& aAction, int aId = -1 );
...@@ -61,7 +61,7 @@ private: ...@@ -61,7 +61,7 @@ private:
friend class TOOL_INTERACTIVE; friend class TOOL_INTERACTIVE;
void setTool ( TOOL_INTERACTIVE* aTool ) void setTool( TOOL_INTERACTIVE* aTool )
{ {
m_tool = aTool; m_tool = aTool;
} }
......
...@@ -36,7 +36,7 @@ class TOOL_MANAGER; ...@@ -36,7 +36,7 @@ class TOOL_MANAGER;
class PCB_BASE_FRAME; class PCB_BASE_FRAME;
namespace KiGfx { namespace KiGfx {
class VIEW ; class VIEW;
}; };
/** /**
......
...@@ -71,6 +71,8 @@ public: ...@@ -71,6 +71,8 @@ public:
* Function InvokeTool() * Function InvokeTool()
* Calls a tool by sending a tool activation event to tool of given ID or name. * Calls a tool by sending a tool activation event to tool of given ID or name.
* An user-defined parameter object can be also passed * An user-defined parameter object can be also passed
*
* @return True if the requested tool was invoked successfully.
*/ */
bool InvokeTool( TOOL_ID aToolId ); bool InvokeTool( TOOL_ID aToolId );
bool InvokeTool( const std::string& aName ); bool InvokeTool( const std::string& aName );
...@@ -81,6 +83,8 @@ public: ...@@ -81,6 +83,8 @@ public:
/** /**
* Function FindTool() * Function FindTool()
* Searches for a tool with given name or ID * Searches for a tool with given name or ID
*
* @return Pointer to the request tool of NULL in case of failure.
*/ */
TOOL_BASE* FindTool( int aId ) const; TOOL_BASE* FindTool( int aId ) const;
TOOL_BASE* FindTool( const std::string& aName ) const; TOOL_BASE* FindTool( const std::string& aName ) const;
...@@ -100,7 +104,7 @@ public: ...@@ -100,7 +104,7 @@ public:
/** /**
* Sets the work environment (model, view, view controls and the parent window). * 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) * These are made available to the tool. Called by the parent frame (PCB_EDIT_FRAME)
* when the board is set up * when the board is set up.
*/ */
void SetEnvironment( EDA_ITEM* aModel, KiGfx::VIEW* aView, void SetEnvironment( EDA_ITEM* aModel, KiGfx::VIEW* aView,
KiGfx::VIEW_CONTROLS* aViewControls, wxWindow* aFrame ); KiGfx::VIEW_CONTROLS* aViewControls, wxWindow* aFrame );
...@@ -154,7 +158,7 @@ public: ...@@ -154,7 +158,7 @@ public:
CONTEXT_MENU_TRIGGER aTrigger ); CONTEXT_MENU_TRIGGER aTrigger );
/** /**
* Allows a tool pass the already handled event to be passed to the next tool on the stack. * Allows a tool to pass the already handled event to the next tool on the stack.
*/ */
void PassEvent() void PassEvent()
{ {
......
...@@ -262,13 +262,27 @@ public: ...@@ -262,13 +262,27 @@ public:
/** /**
* Function SetLayerVisible() * Function SetLayerVisible()
* Controls the visibility of a particular layer. * Controls the visibility of a particular layer.
* @param aLayer: the layer to show/hide. When ALL_LAYERS constant is given, all layers' * @param aLayer: the layer to show/hide
* visibility is updated * @param aVisible: the obvious
* @param aVisible: the obivous
*/ */
inline void SetLayerVisible( int aLayer, bool aVisible = true ) inline void SetLayerVisible( int aLayer, bool aVisible = true )
{ {
m_layers[aLayer].enabled = aVisible; if( m_layers[aLayer].enabled != aVisible )
{
// Target has to be redrawn after changing its visibility
MarkTargetDirty( m_layers[aLayer].target );
m_layers[aLayer].enabled = aVisible;
}
}
/**
* Function IsLayerVisible()
* Returns information about visibility of a particular layer.
* @param aLayer: true if the layer is visible, false otherwise
*/
inline bool IsLayerVisible( int aLayer ) const
{
return m_layers.at( aLayer ).enabled;
} }
/** /**
...@@ -423,6 +437,13 @@ public: ...@@ -423,6 +437,13 @@ public:
m_dirtyTargets[aTarget] = true; m_dirtyTargets[aTarget] = true;
} }
/// Returns true if the layer is cached
inline bool IsCached( int aLayer ) const
{
return ( m_layers.at( aLayer ).target == TARGET_CACHED );
}
static const int VIEW_MAX_LAYERS = 128; ///* maximum number of layers that may be shown static const int VIEW_MAX_LAYERS = 128; ///* maximum number of layers that may be shown
private: private:
...@@ -432,11 +453,8 @@ private: ...@@ -432,11 +453,8 @@ private:
bool isDirty; ///* does it contain any dirty items (updated since last redraw) bool isDirty; ///* does it contain any dirty items (updated since last redraw)
bool displayOnly; ///* is the layer display only? bool displayOnly; ///* is the layer display only?
VIEW_RTREE* items; ///* R-tree indexing all items on this layer. VIEW_RTREE* items; ///* R-tree indexing all items on this layer.
std::vector<VIEW_ITEM*> dirtyItems; ///* set of dirty items collected since last redraw
int renderingOrder; ///* rendering order of this layer int renderingOrder; ///* rendering order of this layer
int id; ///* layer ID int id; ///* layer ID
BOX2I extents; ///* sum of bboxes of all items on the layer
BOX2I dirtyExtents; ///* sum of bboxes of all dirty items on the layer
RenderTarget target; ///* where the layer should be rendered RenderTarget target; ///* where the layer should be rendered
std::set<int> requiredLayers; ///* layers that are required to be enabled to show the layer std::set<int> requiredLayers; ///* layers that are required to be enabled to show the layer
}; };
...@@ -515,6 +533,9 @@ private: ...@@ -515,6 +533,9 @@ private:
/// Updates all informations needed to draw an item /// Updates all informations needed to draw an item
void updateItemGeometry( VIEW_ITEM* aItem, int aLayer ); void updateItemGeometry( VIEW_ITEM* aItem, int aLayer );
/// Updates bounding box of an item
void updateBbox( VIEW_ITEM* aItem );
/// Determines rendering order of layers. Used in display order sorting function. /// Determines rendering order of layers. Used in display order sorting function.
static bool compareRenderingOrder( VIEW_LAYER* i, VIEW_LAYER* j ) static bool compareRenderingOrder( VIEW_LAYER* i, VIEW_LAYER* j )
{ {
...@@ -524,12 +545,6 @@ private: ...@@ -524,12 +545,6 @@ private:
/// Checks if every layer required by the aLayerId layer is enabled. /// Checks if every layer required by the aLayerId layer is enabled.
bool areRequiredLayersEnabled( int aLayerId ) const; bool areRequiredLayersEnabled( int aLayerId ) const;
/// Returns true if the layer is cached
inline bool isCached( int aLayer ) const
{
return ( m_layers.at( aLayer ).target == TARGET_CACHED );
}
///* Whether to use rendering order modifier or not ///* Whether to use rendering order modifier or not
bool m_enableOrderModifier; bool m_enableOrderModifier;
......
...@@ -46,23 +46,31 @@ class VIEW; ...@@ -46,23 +46,31 @@ class VIEW;
class VIEW_CONTROLS class VIEW_CONTROLS
{ {
public: public:
VIEW_CONTROLS( VIEW* aView ) : m_view( aView ) {}; VIEW_CONTROLS( VIEW* aView ) : m_view( aView ), m_snappingEnabled( false ),
m_grabMouse( false ), m_autoPanEnabled( false ), m_autoPanMargin( 0.1 ),
m_autoPanSpeed( 0.15 ) {};
virtual ~VIEW_CONTROLS() {}; virtual ~VIEW_CONTROLS() {};
/** /**
* Function Activate * Function SetSnapping()
* Determines if all view related events (mouse wheel, right click panning, etc.), should be * Enables/disables snapping cursor to grid.
* handled or not. If not - they can be processed by the legacy view. *
* @param aEnabled tells if events should be handled. * @param aEnabled says whether the opion should be enabled or disabled.
*/ */
virtual void Activate( bool aEnabled ) {}; void SetSnapping( bool aEnabled )
{
m_snappingEnabled = aEnabled;
}
/** /**
* Function SetGrabMouse * Function SetGrabMouse
* Turns on/off mouse grabbing. When the mouse is grabbed, it cannot go outside the VIEW. * Turns on/off mouse grabbing. When the mouse is grabbed, it cannot go outside the VIEW.
* @param aEnabled tells if mouse should be grabbed or not. * @param aEnabled tells if mouse should be grabbed or not.
*/ */
virtual void SetGrabMouse( bool aEnabled ) {}; virtual void SetGrabMouse( bool aEnabled )
{
m_grabMouse = aEnabled;
}
/** /**
* Function SetAutoPan * Function SetAutoPan
...@@ -70,36 +78,90 @@ public: ...@@ -70,36 +78,90 @@ public:
* track) and user moves mouse to the VIEW edge - then the view can be translated or not). * track) and user moves mouse to the VIEW edge - then the view can be translated or not).
* @param aEnabled tells if the autopanning should be active. * @param aEnabled tells if the autopanning should be active.
*/ */
virtual void SetAutoPan( bool aEnabled ) {} virtual void SetAutoPan( bool aEnabled )
{
m_autoPanEnabled = aEnabled;
}
/** /**
* Function SetPanSpeed * Function SetAutoPanSpeed()
* Sets speed of panning. * Sets speed of autopanning.
* @param aSpeed is a new speed for panning. * @param aSpeed is a new speed for autopanning.
*/ */
virtual void SetPanSpeed( float aSpeed ) {}; virtual void SetAutoPanSpeed( float aSpeed )
{
m_autoPanSpeed = aSpeed;
}
/** /**
* Function SetZoomSpeed * Function SetAutoPanMArgin()
* Determines how much zoom factor should be affected on one zoom event (eg. mouse wheel). * Sets margin for autopanning (ie. the area when autopanning becomes active).
* @param aSpeed is a new zooming speed. * @param aSpeed is a new margin for autopanning.
*/ */
virtual void SetZoomSpeed( float aSpeed ) {}; virtual void SetAutoPanMargin( float aMargin )
{
m_autoPanMargin = aMargin;
};
/** /**
* Function AnimatedZoom * Function GetMousePosition()
* // TODO * Returns the current mouse pointer position in the screen coordinates. Note, that it may be
* different from the cursor position if snapping is enabled (@see GetCursorPosition()).
*
* @return The current mouse pointer position.
*/ */
virtual void AnimatedZoom( const BOX2I& aExtents ) {}; virtual const VECTOR2D& GetMousePosition() const
{
return m_mousePosition;
}
virtual void WarpCursor (const VECTOR2D& aPosition ) {}; /**
* Function GetCursorPosition()
virtual void ShowCursor (bool aEnabled ) {}; * Returns the current cursor position in the screen coordinates. Note, that it may be
* different from the mouse pointer position if snapping is enabled (@see GetMousePosition()).
*
* @return The current cursor position in screen coordinates.
*/
virtual const VECTOR2D& GetCursorPosition() const
{
return m_cursorPosition;
}
/**
* Function SetCursorPosition()
* Allows to move the cursor to a different location.
*
* @param aPosition is the new location expressed in screen coordinates.
*/
virtual void SetCursorPosition( const VECTOR2D& aPosition )
{
m_cursorPosition = aPosition;
}
protected: protected:
/// Pointer to controlled VIEW. /// Pointer to controlled VIEW.
VIEW* m_view; VIEW* m_view;
/// Current mouse position
VECTOR2D m_mousePosition;
/// Current cursor position
VECTOR2D m_cursorPosition;
/// Should the cursor snap to grid or move freely
bool m_snappingEnabled;
/// Flag for grabbing the mouse cursor
bool m_grabMouse;
/// Flag for turning on autopanning
bool m_autoPanEnabled;
/// Distance from cursor to VIEW edge when panning is active
float m_autoPanMargin;
/// How fast is panning when in auto mode
float m_autoPanSpeed;
}; };
} // namespace KiGfx } // namespace KiGfx
......
...@@ -51,11 +51,11 @@ public: ...@@ -51,11 +51,11 @@ public:
~WX_VIEW_CONTROLS() {}; ~WX_VIEW_CONTROLS() {};
/// Handler functions /// Handler functions
void onWheel( wxMouseEvent& aEvent ); void onWheel( wxMouseEvent& aEvent );
void onMotion( wxMouseEvent& aEvent ); void onMotion( wxMouseEvent& aEvent );
void onButton( wxMouseEvent& aEvent ); void onButton( wxMouseEvent& aEvent );
void onEnter( wxMouseEvent& aEvent ); void onEnter( wxMouseEvent& WXUNUSED( aEvent ) );
void onTimer( wxTimerEvent& aEvent ); void onTimer( wxTimerEvent& WXUNUSED( aEvent ) );
/** /**
* Function SetGrabMouse() * Function SetGrabMouse()
...@@ -63,18 +63,7 @@ public: ...@@ -63,18 +63,7 @@ public:
* *
* @param aEnabled says whether the option should be enabled or disabled. * @param aEnabled says whether the option should be enabled or disabled.
*/ */
void SetGrabMouse( bool aEnabled ); void SetGrabMouse( bool aEnabled );
/**
* Function SetSnapping()
* Enables/disables snapping cursor to grid.
*
* @param aEnabled says whether the opion should be enabled or disabled.
*/
void SetSnapping( bool aEnabled )
{
m_snappingEnabled = aEnabled;
}
/** /**
* Function SetAutoPan() * Function SetAutoPan()
...@@ -82,36 +71,15 @@ public: ...@@ -82,36 +71,15 @@ public:
* *
* @param aEnabled says whether the option should enabled or disabled. * @param aEnabled says whether the option should enabled or disabled.
*/ */
void SetAutoPan( bool aEnabled ) void SetAutoPan( bool aEnabled )
{ {
m_autoPanEnabled = aEnabled; m_autoPanEnabled = aEnabled;
if( m_state == AUTO_PANNING ) if( m_state == AUTO_PANNING )
m_state = IDLE; m_state = IDLE;
} }
/**
* Function GetMousePosition()
* Returns the current mouse pointer position in the screen coordinates. Note, that it may be
* different from the cursor position if snapping is enabled (@see GetCursorPosition()).
*
* @return The current mouse pointer position.
*/
const VECTOR2D& GetMousePosition() const
{
return m_mousePosition;
}
/**
* Function GetCursorPosition()
* Returns the current cursor position in the screen coordinates. Note, that it may be
* different from the mouse pointer position if snapping is enabled (@see GetMousePosition()).
*
* @return The current cursor position.
*/
VECTOR2D GetCursorPosition() const;
private: private:
/// Possible states for WX_VIEW_CONTROLS
enum State { enum State {
IDLE = 1, IDLE = 1,
DRAG_PANNING, DRAG_PANNING,
...@@ -126,29 +94,11 @@ private: ...@@ -126,29 +94,11 @@ private:
* @return true if it is currently autopanning (ie. autopanning is active and mouse cursor * @return true if it is currently autopanning (ie. autopanning is active and mouse cursor
* is in the area that causes autopanning to happen). * is in the area that causes autopanning to happen).
*/ */
bool handleAutoPanning( const wxMouseEvent& aEvent ); bool handleAutoPanning( const wxMouseEvent& aEvent );
/// Current state of VIEW_CONTROLS /// Current state of VIEW_CONTROLS
State m_state; State m_state;
/// Current mouse position
VECTOR2D m_mousePosition;
/// Flag for grabbing the mouse cursor
bool m_grabMouse;
/// Should the cursor snap to grid or move freely
bool m_snappingEnabled;
/// Flag for turning on autopanning
bool m_autoPanEnabled;
/// Distance from cursor to VIEW edge when panning is active
float m_autoPanMargin;
/// How fast is panning when in auto mode
float m_autoPanSpeed;
/// Panel that is affected by VIEW_CONTROLS /// Panel that is affected by VIEW_CONTROLS
wxWindow* m_parentPanel; wxWindow* m_parentPanel;
......
...@@ -39,7 +39,6 @@ protected: ...@@ -39,7 +39,6 @@ protected:
// to the parent WORKSHEET_DATAITEM item, // to the parent WORKSHEET_DATAITEM item,
// in page layout editor // in page layout editor
protected:
WS_DRAW_ITEM_BASE( WORKSHEET_DATAITEM* aParent, WS_DRAW_ITEM_BASE( WORKSHEET_DATAITEM* aParent,
WS_DRAW_TYPE aType, EDA_COLOR_T aColor ) WS_DRAW_TYPE aType, EDA_COLOR_T aColor )
{ {
...@@ -53,8 +52,8 @@ public: ...@@ -53,8 +52,8 @@ public:
virtual ~WS_DRAW_ITEM_BASE() {} virtual ~WS_DRAW_ITEM_BASE() {}
// Accessors: // Accessors:
EDA_COLOR_T GetColor() { return m_color; } EDA_COLOR_T GetColor() const { return m_color; }
WS_DRAW_TYPE GetType() { return m_type; }; WS_DRAW_TYPE GetType() const { return m_type; };
WORKSHEET_DATAITEM* GetParent() { return m_parent; } WORKSHEET_DATAITEM* GetParent() { return m_parent; }
......
...@@ -174,6 +174,8 @@ public: ...@@ -174,6 +174,8 @@ public:
return m_Pcb; return m_Pcb;
} }
void ViewReloadBoard( const BOARD* aBoard ) const;
// General // General
virtual void OnCloseWindow( wxCloseEvent& Event ) = 0; virtual void OnCloseWindow( wxCloseEvent& Event ) = 0;
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) { } virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) { }
...@@ -671,6 +673,8 @@ public: ...@@ -671,6 +673,8 @@ public:
void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ); void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent );
void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent ); void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent );
virtual void UseGalCanvas( bool aEnable );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
......
...@@ -452,8 +452,6 @@ protected: ...@@ -452,8 +452,6 @@ protected:
wxOverlay m_overlay; wxOverlay m_overlay;
#endif #endif
protected:
void SetScreen( BASE_SCREEN* aScreen ) { m_currentScreen = aScreen; } void SetScreen( BASE_SCREEN* aScreen ) { m_currentScreen = aScreen; }
/** /**
...@@ -692,6 +690,12 @@ public: ...@@ -692,6 +690,12 @@ public:
*/ */
void RedrawScreen2( const wxPoint& posBefore ); void RedrawScreen2( const wxPoint& posBefore );
/**
* Function RefreshCanvas
* Depending on the current state of GAL - it refreshes the default canvas of the GAL canvas.
*/
void RefreshCanvas();
/** /**
* Function Zoom_Automatique * Function Zoom_Automatique
* redraws the screen with best zoom level and the best centering * redraws the screen with best zoom level and the best centering
...@@ -899,7 +903,7 @@ public: ...@@ -899,7 +903,7 @@ public:
* *
* @param aEnable True for GAL-based canvas, false for standard canvas. * @param aEnable True for GAL-based canvas, false for standard canvas.
*/ */
void UseGalCanvas( bool aEnable ); virtual void UseGalCanvas( bool aEnable );
/** /**
* Function IsNewCanvasActive * Function IsNewCanvasActive
......
...@@ -221,6 +221,7 @@ set(PCBNEW_CLASS_SRCS ...@@ -221,6 +221,7 @@ set(PCBNEW_CLASS_SRCS
tools/selection_tool.cpp tools/selection_tool.cpp
tools/selection_area.cpp tools/selection_area.cpp
tools/move_tool.cpp
tools/pcb_tools.cpp tools/pcb_tools.cpp
) )
......
...@@ -293,7 +293,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) ...@@ -293,7 +293,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
if( newList.GetCount() ) if( newList.GetCount() )
SaveCopyInUndoList( newList, UR_CHANGED ); SaveCopyInUndoList( newList, UR_CHANGED );
m_canvas->Refresh(); RefreshCanvas();
} }
......
...@@ -136,68 +136,76 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard ) ...@@ -136,68 +136,76 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
if( m_galCanvas ) if( m_galCanvas )
{ {
KiGfx::VIEW* view = m_galCanvas->GetView(); KiGfx::VIEW* view = m_galCanvas->GetView();
view->Clear();
// All of PCB drawing elements should be added to the VIEW ViewReloadBoard( m_Pcb );
// in order to be displayed
// Load zones // update the tool manager with the new board and its view.
for( int i = 0; i < m_Pcb->GetAreaCount(); ++i ) if( m_toolManager )
{ m_toolManager->SetEnvironment( m_Pcb, view, m_galCanvas->GetViewControls(), this );
view->Add( (KiGfx::VIEW_ITEM*) ( m_Pcb->GetArea( i ) ) ); }
} }
// Load drawings
for( BOARD_ITEM* drawing = m_Pcb->m_Drawings; drawing; drawing = drawing->Next() )
{
view->Add( drawing );
}
// Load tracks void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() ) {
{ KiGfx::VIEW* view = m_galCanvas->GetView();
view->Add( track ); view->Clear();
}
// Load modules and its additional elements // All of PCB drawing elements should be added to the VIEW
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() ) // in order to be displayed
{
// Load module's pads
for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
{
view->Add( pad );
}
// Load module's drawing (mostly silkscreen) // Load zones
for( BOARD_ITEM* drawing = module->GraphicalItems().GetFirst(); drawing; for( int i = 0; i < aBoard->GetAreaCount(); ++i )
drawing = drawing->Next() ) {
{ view->Add( (KiGfx::VIEW_ITEM*) ( aBoard->GetArea( i ) ) );
view->Add( drawing ); }
}
// Load module's texts (name and value) // Load drawings
view->Add( &module->Reference() ); for( BOARD_ITEM* drawing = aBoard->m_Drawings; drawing; drawing = drawing->Next() )
view->Add( &module->Value() ); {
view->Add( drawing );
}
// Add the module itself // Load tracks
view->Add( module ); for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
{
view->Add( track );
}
// Load modules and its additional elements
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{
// Load module's pads
for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
{
view->Add( pad );
} }
// Segzones (equivalent of ZONE_CONTAINER for legacy boards) // Load module's drawing (mostly silkscreen)
for( SEGZONE* zone = m_Pcb->m_Zone; zone; zone = zone->Next() ) for( BOARD_ITEM* drawing = module->GraphicalItems().GetFirst(); drawing;
drawing = drawing->Next() )
{ {
view->Add( zone ); view->Add( drawing );
} }
view->RecacheAllItems( true ); // Load module's texts (name and value)
if( m_galCanvasActive ) view->Add( &module->Reference() );
m_galCanvas->Refresh(); view->Add( &module->Value() );
// update the tool manager with the new board and its view. // Add the module itself
if( m_toolManager ) view->Add( module );
m_toolManager->SetEnvironment( m_Pcb, view, m_galCanvas->GetViewControls(), this ); }
// Segzones (equivalent of ZONE_CONTAINER for legacy boards)
for( SEGZONE* zone = aBoard->m_Zone; zone; zone = zone->Next() )
{
view->Add( zone );
} }
view->RecacheAllItems( true );
if( m_galCanvasActive )
m_galCanvas->Refresh();
} }
...@@ -431,7 +439,7 @@ void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer ) ...@@ -431,7 +439,7 @@ void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
GetScreen()->m_Active_Layer = layer; GetScreen()->m_Active_Layer = layer;
if( DisplayOpt.ContrastModeDisplay ) if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh(); RefreshCanvas();
} }
...@@ -455,10 +463,7 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent ) ...@@ -455,10 +463,7 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
settings->LoadDisplayOptions( DisplayOpt ); settings->LoadDisplayOptions( DisplayOpt );
m_galCanvas->GetView()->RecacheAllItems( true ); m_galCanvas->GetView()->RecacheAllItems( true );
if( IsGalCanvasActive() ) RefreshCanvas();
m_galCanvas->Refresh();
else
m_canvas->Refresh();
} }
...@@ -526,6 +531,14 @@ void PCB_BASE_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent ) ...@@ -526,6 +531,14 @@ void PCB_BASE_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
} }
void PCB_BASE_FRAME::UseGalCanvas( bool aEnable )
{
EDA_DRAW_FRAME::UseGalCanvas( aEnable );
ViewReloadBoard( m_Pcb );
}
void PCB_BASE_FRAME::ProcessItemSelection( wxCommandEvent& aEvent ) void PCB_BASE_FRAME::ProcessItemSelection( wxCommandEvent& aEvent )
{ {
int id = aEvent.GetId(); int id = aEvent.GetId();
...@@ -625,8 +638,8 @@ void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg ) ...@@ -625,8 +638,8 @@ void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
// must do this after the tool has been set, otherwise pad::Draw() does // must do this after the tool has been set, otherwise pad::Draw() does
// not show proper color when DisplayOpt.ContrastModeDisplay is true. // not show proper color when DisplayOpt.ContrastModeDisplay is true.
if( redraw && m_canvas) if( redraw && m_canvas )
m_canvas->Refresh(); RefreshCanvas();
} }
...@@ -831,6 +844,7 @@ void PCB_BASE_FRAME::LoadSettings() ...@@ -831,6 +844,7 @@ void PCB_BASE_FRAME::LoadSettings()
view->SetRequired( ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ) ); view->SetRequired( ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_FR_VISIBLE ) ); view->SetRequired( ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_BK_VISIBLE ) ); view->SetRequired( ITEM_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
view->SetLayerTarget( ITEM_GAL_LAYER( SELECTION ), KiGfx::TARGET_OVERLAY );
view->SetLayerTarget( ITEM_GAL_LAYER( GP_OVERLAY ), KiGfx::TARGET_OVERLAY ); view->SetLayerTarget( ITEM_GAL_LAYER( GP_OVERLAY ), KiGfx::TARGET_OVERLAY );
// Apply layer coloring scheme & display options // Apply layer coloring scheme & display options
......
...@@ -143,7 +143,7 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet( ...@@ -143,7 +143,7 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
break; break;
default: default:
D( printf( "Error: Shape %d not implemented!\n", DBG( printf( "Error: Shape %d not implemented!\n",
outline->GetShape() ); ) outline->GetShape() ); )
break; break;
} }
......
...@@ -367,7 +367,7 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem, ...@@ -367,7 +367,7 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
if( aItem->Type() == PCB_MODULE_T ) if( aItem->Type() == PCB_MODULE_T )
if( ((MODULE*)aItem)->GetFlags() & MODULE_to_PLACE ) if( ((MODULE*)aItem)->GetFlags() & MODULE_to_PLACE )
break; break;
m_canvas->Refresh(); RefreshCanvas();
#endif #endif
case UR_MOVED: case UR_MOVED:
case UR_FLIPPED: case UR_FLIPPED:
...@@ -622,7 +622,7 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& event ) ...@@ -622,7 +622,7 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& event )
GetScreen()->PushCommandToRedoList( List ); GetScreen()->PushCommandToRedoList( List );
OnModify(); OnModify();
m_canvas->Refresh(); RefreshCanvas();
} }
...@@ -650,7 +650,7 @@ void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& event ) ...@@ -650,7 +650,7 @@ void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& event )
GetScreen()->PushCommandToUndoList( List ); GetScreen()->PushCommandToUndoList( List );
OnModify(); OnModify();
m_canvas->Refresh(); RefreshCanvas();
} }
......
...@@ -495,7 +495,7 @@ void DIMENSION::ViewGetLayers( int aLayers[], int& aCount ) const ...@@ -495,7 +495,7 @@ void DIMENSION::ViewGetLayers( int aLayers[], int& aCount ) const
aLayers[0] = m_Layer; aLayers[0] = m_Layer;
// On the general purpose overlay there is a selection box displayed // On the general purpose overlay there is a selection box displayed
aLayers[1] = ITEM_GAL_LAYER( GP_OVERLAY ); aLayers[1] = ITEM_GAL_LAYER( SELECTION );
aCount = 2; aCount = 2;
} }
......
...@@ -1028,5 +1028,5 @@ void MODULE::SetOrientation( double newangle ) ...@@ -1028,5 +1028,5 @@ void MODULE::SetOrientation( double newangle )
void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
aCount = 1; aCount = 1;
aLayers[0] = ITEM_GAL_LAYER( GP_OVERLAY ); // Selection box aLayers[0] = ITEM_GAL_LAYER( SELECTION ); // Selection box
} }
...@@ -346,7 +346,7 @@ void PCB_LAYER_WIDGET::OnLayerColorChange( LAYER_NUM aLayer, EDA_COLOR_T aColor ...@@ -346,7 +346,7 @@ void PCB_LAYER_WIDGET::OnLayerColorChange( LAYER_NUM aLayer, EDA_COLOR_T aColor
{ {
myframe->GetBoard()->SetLayerColor( aLayer, aColor ); myframe->GetBoard()->SetLayerColor( aLayer, aColor );
myframe->ReCreateLayerBox( NULL ); myframe->ReCreateLayerBox( NULL );
myframe->GetCanvas()->Refresh(); myframe->RefreshCanvas();
} }
...@@ -359,7 +359,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer ) ...@@ -359,7 +359,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer )
if( m_alwaysShowActiveCopperLayer ) if( m_alwaysShowActiveCopperLayer )
OnLayerSelected(); OnLayerSelected();
else if( DisplayOpt.ContrastModeDisplay ) else if( DisplayOpt.ContrastModeDisplay )
myframe->GetCanvas()->Refresh(); myframe->RefreshCanvas();
return true; return true;
} }
...@@ -393,7 +393,7 @@ void PCB_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool is ...@@ -393,7 +393,7 @@ void PCB_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool is
brd->SetVisibleLayers( visibleLayers ); brd->SetVisibleLayers( visibleLayers );
EDA_DRAW_PANEL_GAL *galCanvas = myframe->GetGalCanvas(); EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
if( galCanvas ) if( galCanvas )
{ {
KiGfx::VIEW* view = galCanvas->GetView(); KiGfx::VIEW* view = galCanvas->GetView();
...@@ -401,18 +401,13 @@ void PCB_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool is ...@@ -401,18 +401,13 @@ void PCB_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool is
} }
if( isFinal ) if( isFinal )
{ myframe->RefreshCanvas();
if( myframe->IsGalCanvasActive() )
galCanvas->Refresh();
else
myframe->GetCanvas()->Refresh();
}
} }
void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, EDA_COLOR_T aColor ) void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, EDA_COLOR_T aColor )
{ {
myframe->GetBoard()->SetVisibleElementColor( aId, aColor ); myframe->GetBoard()->SetVisibleElementColor( aId, aColor );
myframe->GetCanvas()->Refresh(); myframe->RefreshCanvas();
} }
void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled ) void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
...@@ -430,7 +425,7 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled ) ...@@ -430,7 +425,7 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
if( myframe->IsGalCanvasActive() ) if( myframe->IsGalCanvasActive() )
galCanvas->Refresh(); galCanvas->Refresh();
else else
myframe->GetCanvas()->Refresh(); myframe->RefreshCanvas();
} }
//-----</LAYER_WIDGET callbacks>------------------------------------------ //-----</LAYER_WIDGET callbacks>------------------------------------------
...@@ -231,7 +231,7 @@ void TEXTE_PCB::ViewGetLayers( int aLayers[], int& aCount ) const ...@@ -231,7 +231,7 @@ void TEXTE_PCB::ViewGetLayers( int aLayers[], int& aCount ) const
aLayers[0] = m_Layer; aLayers[0] = m_Layer;
// On the general purpose overlay there is a selection box displayed // On the general purpose overlay there is a selection box displayed
aLayers[1] = ITEM_GAL_LAYER( GP_OVERLAY ); aLayers[1] = ITEM_GAL_LAYER( SELECTION );
aCount = 2; aCount = 2;
} }
...@@ -87,6 +87,22 @@ TEXTE_MODULE::~TEXTE_MODULE() ...@@ -87,6 +87,22 @@ TEXTE_MODULE::~TEXTE_MODULE()
} }
void TEXTE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
{
RotatePoint( &m_Pos, aRotCentre, aAngle );
m_Orient += aAngle;
NORMALIZE_ANGLE_360( m_Orient );
}
void TEXTE_MODULE::Flip(const wxPoint& aCentre )
{
m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y );
SetLayer( FlipLayer( GetLayer() ) );
m_Mirror = !m_Mirror;
}
void TEXTE_MODULE::Copy( TEXTE_MODULE* source ) void TEXTE_MODULE::Copy( TEXTE_MODULE* source )
{ {
if( source == NULL ) if( source == NULL )
...@@ -457,7 +473,7 @@ void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const ...@@ -457,7 +473,7 @@ void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
} }
// On the general purpose overlay there is a selection box displayed // On the general purpose overlay there is a selection box displayed
aLayers[1] = ITEM_GAL_LAYER( GP_OVERLAY ); aLayers[1] = ITEM_GAL_LAYER( SELECTION );
aCount = 2; aCount = 2;
} }
...@@ -89,6 +89,15 @@ public: ...@@ -89,6 +89,15 @@ public:
m_Pos = aPos; m_Pos = aPos;
} }
void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
}
void Rotate( const wxPoint& aRotCentre, double aAngle );
void Flip( const wxPoint& aCentre );
TEXTE_MODULE* Next() const { return (TEXTE_MODULE*) Pnext; } TEXTE_MODULE* Next() const { return (TEXTE_MODULE*) Pnext; }
TEXTE_MODULE* Back() const { return (TEXTE_MODULE*) Pback; } TEXTE_MODULE* Back() const { return (TEXTE_MODULE*) Pback; }
......
...@@ -55,7 +55,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack ) ...@@ -55,7 +55,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack )
{ {
LAYER_NUM previous_layer = getActiveLayer(); LAYER_NUM previous_layer = getActiveLayer();
D( g_CurrentTrackList.VerifyListIntegrity(); ) DBG( g_CurrentTrackList.VerifyListIntegrity(); )
// Delete the current trace // Delete the current trace
ShowNewTrackWhenMovingCursor( m_canvas, DC, wxDefaultPosition, false ); ShowNewTrackWhenMovingCursor( m_canvas, DC, wxDefaultPosition, false );
...@@ -215,7 +215,7 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm ) ...@@ -215,7 +215,7 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
next_track = tracksegment->Next(); next_track = tracksegment->Next();
tracksegment->SetState( BUSY, false ); tracksegment->SetState( BUSY, false );
D( std::cout << __func__ << ": track " << tracksegment << " status=" \ DBG( std::cout << __func__ << ": track " << tracksegment << " status=" \
<< TO_UTF8( TRACK::ShowState( tracksegment->GetStatus() ) ) \ << TO_UTF8( TRACK::ShowState( tracksegment->GetStatus() ) ) \
<< std::endl; ) << std::endl; )
......
...@@ -180,7 +180,7 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event) ...@@ -180,7 +180,7 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event)
if( m_Parent->IsGalCanvasActive() ) if( m_Parent->IsGalCanvasActive() )
m_Parent->GetGalCanvas()->Refresh(); m_Parent->GetGalCanvas()->Refresh();
else else
m_Parent->GetCanvas()->Refresh(); m_Parent->RefreshCanvas();
EndModal( 1 ); EndModal( 1 );
} }
...@@ -548,7 +548,7 @@ void DIALOG_DRC_CONTROL::OnUnconnectedSelectionEvent( wxCommandEvent& event ) ...@@ -548,7 +548,7 @@ void DIALOG_DRC_CONTROL::OnUnconnectedSelectionEvent( wxCommandEvent& event )
void DIALOG_DRC_CONTROL::RedrawDrawPanel() void DIALOG_DRC_CONTROL::RedrawDrawPanel()
{ {
m_Parent->GetCanvas()->Refresh(); m_Parent->RefreshCanvas();
} }
......
...@@ -252,7 +252,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -252,7 +252,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
wxArrayInt cols = m_cur_grid->GetSelectedCols(); wxArrayInt cols = m_cur_grid->GetSelectedCols();
wxArrayInt rows = m_cur_grid->GetSelectedRows(); wxArrayInt rows = m_cur_grid->GetSelectedRows();
D(printf("topLeft.Count():%zd botRight:Count():%zd\n", topLeft.Count(), botRight.Count() );) DBG(printf("topLeft.Count():%zd botRight:Count():%zd\n", topLeft.Count(), botRight.Count() );)
if( topLeft.Count() && botRight.Count() ) if( topLeft.Count() && botRight.Count() )
{ {
...@@ -284,7 +284,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -284,7 +284,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
selColCount = 0; selColCount = 0;
} }
// D(printf("selRowStart:%d selColStart:%d selRowCount:%d selColCount:%d\n", selRowStart, selColStart, selRowCount, selColCount );) // DBG(printf("selRowStart:%d selColStart:%d selRowCount:%d selColCount:%d\n", selRowStart, selColStart, selRowCount, selColCount );)
} }
void rightClickCellPopupMenu() void rightClickCellPopupMenu()
...@@ -353,7 +353,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -353,7 +353,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
break; break;
case ID_PASTE: case ID_PASTE:
D(printf( "paste\n" );) DBG(printf( "paste\n" );)
// assume format came from a spreadsheet or us. // assume format came from a spreadsheet or us.
if( wxTheClipboard->Open() ) if( wxTheClipboard->Open() )
{ {
...@@ -471,7 +471,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -471,7 +471,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
m_cur_grid->SetGridCursor( curRow, curCol ); m_cur_grid->SetGridCursor( curRow, curCol );
} }
D(printf("%s\n", __func__);) DBG(printf("%s\n", __func__);)
} }
void onCancelButtonClick( wxCommandEvent& event ) void onCancelButtonClick( wxCommandEvent& event )
...@@ -522,7 +522,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE ...@@ -522,7 +522,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
m_cur_row = event.GetRow(); m_cur_row = event.GetRow();
m_cur_col = event.GetCol(); m_cur_col = event.GetCol();
D(printf("change cursor(%d,%d)\n", m_cur_row, m_cur_col );) DBG(printf("change cursor(%d,%d)\n", m_cur_row, m_cur_col );)
// somebody else wants this // somebody else wants this
event.Skip(); event.Skip();
......
...@@ -185,7 +185,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -185,7 +185,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
if( state && (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 ) if( state && (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
Compile_Ratsnest( NULL, true ); Compile_Ratsnest( NULL, true );
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST: case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST:
...@@ -200,35 +200,35 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -200,35 +200,35 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
DisplayOpt.DisplayZonesMode = 0; DisplayOpt.DisplayZonesMode = 0;
recache = true; recache = true;
if( !m_galCanvasActive ) if( !m_galCanvasActive )
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_TB_OPTIONS_SHOW_ZONES_DISABLE: case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
DisplayOpt.DisplayZonesMode = 1; DisplayOpt.DisplayZonesMode = 1;
recache = true; recache = true;
if( !m_galCanvasActive ) if( !m_galCanvasActive )
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY: case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
DisplayOpt.DisplayZonesMode = 2; DisplayOpt.DisplayZonesMode = 2;
recache = true; recache = true;
if( !m_galCanvasActive ) if( !m_galCanvasActive )
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_TB_OPTIONS_SHOW_VIAS_SKETCH: case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
m_DisplayViaFill = DisplayOpt.DisplayViaFill = !state; m_DisplayViaFill = DisplayOpt.DisplayViaFill = !state;
recache = true; recache = true;
if( !m_galCanvasActive ) if( !m_galCanvasActive )
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH: case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = !state; m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = !state;
recache = true; recache = true;
if( !m_galCanvasActive ) if( !m_galCanvasActive )
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE: case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
...@@ -244,7 +244,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -244,7 +244,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
if( m_galCanvasActive ) if( m_galCanvasActive )
m_galCanvas->Refresh(); m_galCanvas->Refresh();
else else
m_canvas->Refresh(); RefreshCanvas();
break; break;
} }
......
...@@ -182,7 +182,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) ...@@ -182,7 +182,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
m_Parent->Compile_Ratsnest( NULL, true ); m_Parent->Compile_Ratsnest( NULL, true );
} }
m_Parent->GetCanvas()->Refresh(); m_Parent->RefreshCanvas();
m_Parent->OnModify(); m_Parent->OnModify();
EndModal( 1 ); EndModal( 1 );
......
...@@ -206,7 +206,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnOkClick( wxCommandEvent& event ) ...@@ -206,7 +206,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnOkClick( wxCommandEvent& event )
EndModal( 1 ); EndModal( 1 );
if( change ) if( change )
m_Parent->GetCanvas()->Refresh(); m_Parent->RefreshCanvas();
} }
......
...@@ -136,7 +136,7 @@ void PCB_EDIT_FRAME::OnResetModuleTextSizes( wxCommandEvent& event ) ...@@ -136,7 +136,7 @@ void PCB_EDIT_FRAME::OnResetModuleTextSizes( wxCommandEvent& event )
DIALOG_GLOBAL_MODULES_FIELDS_EDITION dlg(this); DIALOG_GLOBAL_MODULES_FIELDS_EDITION dlg(this);
dlg.ShowModal(); dlg.ShowModal();
m_canvas->Refresh(); RefreshCanvas();
} }
void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef, void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
......
...@@ -104,7 +104,7 @@ void PCB_EDIT_FRAME::OnOrientFootprints( wxCommandEvent& event ) ...@@ -104,7 +104,7 @@ void PCB_EDIT_FRAME::OnOrientFootprints( wxCommandEvent& event )
if( ReOrientModules( text, dlg.GetOrientation(), dlg.ApplyToLockedModules() ) ) if( ReOrientModules( text, dlg.GetOrientation(), dlg.ApplyToLockedModules() ) )
{ {
m_canvas->Refresh(); RefreshCanvas();
Compile_Ratsnest( NULL, true ); Compile_Ratsnest( NULL, true );
} }
} }
......
...@@ -216,7 +216,7 @@ bool PCB_BASE_FRAME::InvokeDialogGrid() ...@@ -216,7 +216,7 @@ bool PCB_BASE_FRAME::InvokeDialogGrid()
if( GetScreen()->GetGridId() == ID_POPUP_GRID_USER ) if( GetScreen()->GetGridId() == ID_POPUP_GRID_USER )
GetScreen()->SetGrid( ID_POPUP_GRID_USER ); GetScreen()->SetGrid( ID_POPUP_GRID_USER );
m_canvas->Refresh(); RefreshCanvas();
return true; return true;
} }
......
...@@ -2674,7 +2674,7 @@ LAYER_NUM EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const ...@@ -2674,7 +2674,7 @@ LAYER_NUM EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
case 95: kiLayer = ECO1_N; break; case 95: kiLayer = ECO1_N; break;
case 96: kiLayer = ECO2_N; break; case 96: kiLayer = ECO2_N; break;
default: default:
D( printf( "unsupported eagle layer: %d\n", aEagleLayer );) DBG( printf( "unsupported eagle layer: %d\n", aEagleLayer );)
kiLayer = -1; break; // some layers do not map to KiCad kiLayer = -1; break; // some layers do not map to KiCad
} }
} }
......
...@@ -399,7 +399,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -399,7 +399,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
GetDesignSettings().m_CurrentViaType = v_type; GetDesignSettings().m_CurrentViaType = v_type;
if( DisplayOpt.ContrastModeDisplay ) if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh(); RefreshCanvas();
} }
break; break;
...@@ -572,7 +572,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -572,7 +572,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_FILL_ALL_ZONES: case ID_POPUP_PCB_FILL_ALL_ZONES:
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
Fill_All_Zones( this ); Fill_All_Zones( this );
m_canvas->Refresh(); RefreshCanvas();
SetMsgPanel( GetBoard() ); SetMsgPanel( GetBoard() );
break; break;
...@@ -584,7 +584,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -584,7 +584,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
TestNetConnection( NULL, zone_container->GetNet() ); TestNetConnection( NULL, zone_container->GetNet() );
OnModify(); OnModify();
SetMsgPanel( GetBoard() ); SetMsgPanel( GetBoard() );
m_canvas->Refresh(); RefreshCanvas();
} }
SetCurItem( NULL ); SetCurItem( NULL );
break; break;
...@@ -604,7 +604,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -604,7 +604,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
TestForActiveLinksInRatsnest( 0 ); // Recalculate the active ratsnest, i.e. the unconnected links TestForActiveLinksInRatsnest( 0 ); // Recalculate the active ratsnest, i.e. the unconnected links
OnModify(); OnModify();
SetMsgPanel( GetBoard() ); SetMsgPanel( GetBoard() );
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_POPUP_PCB_FILL_ZONE: case ID_POPUP_PCB_FILL_ZONE:
...@@ -612,7 +612,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -612,7 +612,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
Fill_Zone( (ZONE_CONTAINER*) GetCurItem() ); Fill_Zone( (ZONE_CONTAINER*) GetCurItem() );
TestNetConnection( NULL, ( (ZONE_CONTAINER*) GetCurItem() )->GetNet() ); TestNetConnection( NULL, ( (ZONE_CONTAINER*) GetCurItem() )->GetNet() );
SetMsgPanel( GetBoard() ); SetMsgPanel( GetBoard() );
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST: case ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST:
...@@ -1040,7 +1040,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -1040,7 +1040,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
Delete_Drawings_All_Layer( GetCurItem()->GetLayer() ); Delete_Drawings_All_Layer( GetCurItem()->GetLayer() );
SetCurItem( NULL ); SetCurItem( NULL );
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_POPUP_PCB_EDIT_DRAWING: case ID_POPUP_PCB_EDIT_DRAWING:
...@@ -1287,7 +1287,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer ) ...@@ -1287,7 +1287,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) ) if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
{ {
if( DisplayOpt.ContrastModeDisplay ) if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh(); RefreshCanvas();
} }
// if the via was allowed by DRC, then the layer swap has already // if the via was allowed by DRC, then the layer swap has already
...@@ -1306,7 +1306,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer ) ...@@ -1306,7 +1306,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
setActiveLayer( layer ); setActiveLayer( layer );
if( DisplayOpt.ContrastModeDisplay ) if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh(); RefreshCanvas();
} }
......
...@@ -126,7 +126,7 @@ void PCB_EDIT_FRAME::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) ...@@ -126,7 +126,7 @@ void PCB_EDIT_FRAME::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
TextePcb->ClearFlags(); TextePcb->ClearFlags();
#ifdef USE_WX_OVERLAY #ifdef USE_WX_OVERLAY
m_canvas->Refresh(); RefreshCanvas();
#endif #endif
} }
...@@ -144,7 +144,7 @@ void PCB_EDIT_FRAME::StartMoveTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC, bool aE ...@@ -144,7 +144,7 @@ void PCB_EDIT_FRAME::StartMoveTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC, bool aE
SetMsgPanel( aTextePcb ); SetMsgPanel( aTextePcb );
#ifdef USE_WX_OVERLAY #ifdef USE_WX_OVERLAY
m_canvas->Refresh(); RefreshCanvas();
#endif #endif
GetScreen()->SetCrossHairPosition( aTextePcb->GetTextPosition() ); GetScreen()->SetCrossHairPosition( aTextePcb->GetTextPosition() );
...@@ -257,7 +257,7 @@ void PCB_EDIT_FRAME::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) ...@@ -257,7 +257,7 @@ void PCB_EDIT_FRAME::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
OnModify(); OnModify();
#ifdef USE_WX_OVERLAY #ifdef USE_WX_OVERLAY
m_canvas->Refresh(); RefreshCanvas();
#endif #endif
} }
...@@ -281,6 +281,6 @@ void PCB_EDIT_FRAME::FlipTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC ) ...@@ -281,6 +281,6 @@ void PCB_EDIT_FRAME::FlipTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC )
OnModify(); OnModify();
#ifdef USE_WX_OVERLAY #ifdef USE_WX_OVERLAY
m_canvas->Refresh(); RefreshCanvas();
#endif #endif
} }
...@@ -68,7 +68,7 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC ) ...@@ -68,7 +68,7 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
#ifdef __WXMAC__ #ifdef __WXMAC__
// If something edited, push a refresh request // If something edited, push a refresh request
if (retvalue == 0 || retvalue == 1) if (retvalue == 0 || retvalue == 1)
m_canvas->Refresh(); RefreshCanvas();
#endif #endif
if( retvalue == 2 ) if( retvalue == 2 )
...@@ -120,7 +120,7 @@ void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item ) ...@@ -120,7 +120,7 @@ void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
case PCB_MODULE_EDGE_T: case PCB_MODULE_EDGE_T:
Delete_Edge_Module( (EDGE_MODULE*) Item ); Delete_Edge_Module( (EDGE_MODULE*) Item );
m_canvas->Refresh(); RefreshCanvas();
break; break;
case PCB_MODULE_T: case PCB_MODULE_T:
......
...@@ -153,11 +153,11 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -153,11 +153,11 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
GetBoard()->SetHighLightNet( zone->GetNet() ); GetBoard()->SetHighLightNet( zone->GetNet() );
} }
D( g_CurrentTrackList.VerifyListIntegrity() ); DBG( g_CurrentTrackList.VerifyListIntegrity() );
BuildAirWiresTargetsList( LockPoint, wxPoint( 0, 0 ), true ); BuildAirWiresTargetsList( LockPoint, wxPoint( 0, 0 ), true );
D( g_CurrentTrackList.VerifyListIntegrity() ); DBG( g_CurrentTrackList.VerifyListIntegrity() );
GetBoard()->HighLightON(); GetBoard()->HighLightON();
GetBoard()->DrawHighLight( m_canvas, aDC, GetBoard()->GetHighLightNetCode() ); GetBoard()->DrawHighLight( m_canvas, aDC, GetBoard()->GetHighLightNetCode() );
...@@ -191,7 +191,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -191,7 +191,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
// Create 2nd segment // Create 2nd segment
g_CurrentTrackList.PushBack( (TRACK*)g_CurrentTrackSegment->Clone() ); g_CurrentTrackList.PushBack( (TRACK*)g_CurrentTrackSegment->Clone() );
D( g_CurrentTrackList.VerifyListIntegrity(); ); DBG( g_CurrentTrackList.VerifyListIntegrity(); );
g_CurrentTrackSegment->start = g_FirstTrackSegment; g_CurrentTrackSegment->start = g_FirstTrackSegment;
g_FirstTrackSegment->end = g_CurrentTrackSegment; g_FirstTrackSegment->end = g_CurrentTrackSegment;
...@@ -199,7 +199,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -199,7 +199,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
g_FirstTrackSegment->SetState( BEGIN_ONPAD | END_ONPAD, false ); g_FirstTrackSegment->SetState( BEGIN_ONPAD | END_ONPAD, false );
} }
D( g_CurrentTrackList.VerifyListIntegrity(); ); DBG( g_CurrentTrackList.VerifyListIntegrity(); );
SetMsgPanel( g_CurrentTrackSegment ); SetMsgPanel( g_CurrentTrackSegment );
SetCurItem( g_CurrentTrackSegment, false ); SetCurItem( g_CurrentTrackSegment, false );
...@@ -246,11 +246,11 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -246,11 +246,11 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
if( CanCreateNewSegment ) if( CanCreateNewSegment )
{ {
// Erase old track on screen // Erase old track on screen
D( g_CurrentTrackList.VerifyListIntegrity(); ); DBG( g_CurrentTrackList.VerifyListIntegrity(); );
ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, false ); ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, false );
D( g_CurrentTrackList.VerifyListIntegrity(); ); DBG( g_CurrentTrackList.VerifyListIntegrity(); );
if( g_Raccord_45_Auto ) if( g_Raccord_45_Auto )
Add45DegreeSegment( aDC ); Add45DegreeSegment( aDC );
...@@ -273,7 +273,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -273,7 +273,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
newTrack->start = previousTrack->end; newTrack->start = previousTrack->end;
D( g_CurrentTrackList.VerifyListIntegrity(); ); DBG( g_CurrentTrackList.VerifyListIntegrity(); );
newTrack->SetStart( newTrack->GetEnd() ); newTrack->SetStart( newTrack->GetEnd() );
...@@ -282,7 +282,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -282,7 +282,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
if( !GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth ) if( !GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth )
newTrack->SetWidth( GetBoard()->GetCurrentTrackWidth() ); newTrack->SetWidth( GetBoard()->GetCurrentTrackWidth() );
D( g_CurrentTrackList.VerifyListIntegrity(); ); DBG( g_CurrentTrackList.VerifyListIntegrity(); );
// Show the new position // Show the new position
ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, false ); ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, false );
...@@ -422,7 +422,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -422,7 +422,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC )
// Saving the coordinate of end point of the trace // Saving the coordinate of end point of the trace
wxPoint pos = g_CurrentTrackSegment->GetEnd(); wxPoint pos = g_CurrentTrackSegment->GetEnd();
D( g_CurrentTrackList.VerifyListIntegrity(); ); DBG( g_CurrentTrackList.VerifyListIntegrity(); );
if( Begin_Route( aTrack, aDC ) == NULL ) if( Begin_Route( aTrack, aDC ) == NULL )
return false; return false;
...@@ -439,7 +439,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -439,7 +439,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC )
* } * }
*/ */
D( g_CurrentTrackList.VerifyListIntegrity(); ); DBG( g_CurrentTrackList.VerifyListIntegrity(); );
/* The track here is now chained to the list of track segments. /* The track here is now chained to the list of track segments.
...@@ -670,7 +670,7 @@ inline void DrawViaCirclesWhenEditingNewTrack( EDA_RECT* aPanelClipBox, ...@@ -670,7 +670,7 @@ inline void DrawViaCirclesWhenEditingNewTrack( EDA_RECT* aPanelClipBox,
void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase ) bool aErase )
{ {
// D( g_CurrentTrackList.VerifyListIntegrity(); ); // DBG( g_CurrentTrackList.VerifyListIntegrity(); );
PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen(); PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen();
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent(); PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent();
...@@ -764,7 +764,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo ...@@ -764,7 +764,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
} }
// Redraw the new track // Redraw the new track
D( g_CurrentTrackList.VerifyListIntegrity(); ); DBG( g_CurrentTrackList.VerifyListIntegrity(); );
DrawTraces( aPanel, aDC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR ); DrawTraces( aPanel, aDC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR );
if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS ) if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )
......
...@@ -349,7 +349,7 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC ) ...@@ -349,7 +349,7 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC )
text->SetThickness( newThickness ); text->SetThickness( newThickness );
if( aDC ) if( aDC )
m_canvas->Refresh(); RefreshCanvas();
OnModify(); OnModify();
} }
...@@ -118,5 +118,5 @@ void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) ...@@ -118,5 +118,5 @@ void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event )
}*/ }*/
//+hp //+hp
//Refresh canvas, that we can see changes instantly. I use this because it dont,t throw mouse up-left corner. //Refresh canvas, that we can see changes instantly. I use this because it dont,t throw mouse up-left corner.
m_canvas->Refresh(); RefreshCanvas();
} }
...@@ -117,7 +117,7 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() ...@@ -117,7 +117,7 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
printf( "footprintWizard->GetModule() returns NULL\n" ); printf( "footprintWizard->GetModule() returns NULL\n" );
} }
m_canvas->Refresh(); RefreshCanvas();
} }
......
...@@ -408,7 +408,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() ...@@ -408,7 +408,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
ReCreateParameterList(); ReCreateParameterList();
ReCreateHToolbar(); ReCreateHToolbar();
DisplayWizardInfos(); DisplayWizardInfos();
m_canvas->Refresh(); RefreshCanvas();
} }
...@@ -506,7 +506,7 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event ) ...@@ -506,7 +506,7 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event )
return; return;
ReCreateParameterList(); ReCreateParameterList();
m_canvas->Refresh(); RefreshCanvas();
DisplayWizardInfos(); DisplayWizardInfos();
} }
......
...@@ -376,7 +376,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName, ...@@ -376,7 +376,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
if( module->GetAttributes() & MOD_VIRTUAL ) if( module->GetAttributes() & MOD_VIRTUAL )
{ {
D( printf( "skipping module %s because it's virtual\n", DBG( printf( "skipping module %s because it's virtual\n",
TO_UTF8( module->GetReference() ) );) TO_UTF8( module->GetReference() ) );)
continue; continue;
} }
...@@ -393,7 +393,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName, ...@@ -393,7 +393,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
} }
else else
{ {
D(printf( "skipping %s because its attribute is not CMS and it has non SMD pins\n", DBG(printf( "skipping %s because its attribute is not CMS and it has non SMD pins\n",
TO_UTF8(module->GetReference()) ) ); TO_UTF8(module->GetReference()) ) );
continue; continue;
} }
......
...@@ -357,7 +357,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit ...@@ -357,7 +357,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
DisplayOpt.DisplayPcbTrackFill ^= 1; DisplayOpt.DisplayPcbTrackFill ^= 1;
DisplayOpt.DisplayPcbTrackFill &= 1; DisplayOpt.DisplayPcbTrackFill &= 1;
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
m_canvas->Refresh(); RefreshCanvas();
break; break;
case HK_DELETE: case HK_DELETE:
...@@ -454,7 +454,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit ...@@ -454,7 +454,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
{ {
Other_Layer_Route( NULL, aDC ); Other_Layer_Route( NULL, aDC );
if( DisplayOpt.ContrastModeDisplay ) if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh(); RefreshCanvas();
break; break;
} }
...@@ -538,7 +538,19 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit ...@@ -538,7 +538,19 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
case HK_SWITCH_HIGHCONTRAST_MODE: // switch to high contrast mode and refresh the canvas case HK_SWITCH_HIGHCONTRAST_MODE: // switch to high contrast mode and refresh the canvas
DisplayOpt.ContrastModeDisplay = !DisplayOpt.ContrastModeDisplay; DisplayOpt.ContrastModeDisplay = !DisplayOpt.ContrastModeDisplay;
m_canvas->Refresh(); RefreshCanvas();
break;
case HK_CANVAS_CAIRO:
evt_type = ID_MENU_CANVAS_CAIRO;
break;
case HK_CANVAS_OPENGL:
evt_type = ID_MENU_CANVAS_OPENGL;
break;
case HK_CANVAS_DEFAULT:
evt_type = ID_MENU_CANVAS_DEFAULT;
break; break;
} }
......
...@@ -542,7 +542,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -542,7 +542,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
GetScreen()->GetCurItem()->ClearFlags(); GetScreen()->GetCurItem()->ClearFlags();
if( ret > 0 ) if( ret > 0 )
m_canvas->Refresh(); RefreshCanvas();
} }
break; break;
...@@ -572,7 +572,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -572,7 +572,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
if( ret > 0 ) if( ret > 0 )
m_canvas->Refresh(); RefreshCanvas();
} }
break; break;
...@@ -661,38 +661,38 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -661,38 +661,38 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
if( edge ) if( edge )
m_canvas->Refresh(); RefreshCanvas();
} }
break; break;
case ID_POPUP_MODEDIT_EDIT_BODY_ITEM : case ID_POPUP_MODEDIT_EDIT_BODY_ITEM :
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
InstallFootprintBodyItemPropertiesDlg( (EDGE_MODULE*) GetScreen()->GetCurItem() ); InstallFootprintBodyItemPropertiesDlg( (EDGE_MODULE*) GetScreen()->GetCurItem() );
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_POPUP_MODEDIT_EDIT_WIDTH_CURRENT_EDGE: case ID_POPUP_MODEDIT_EDIT_WIDTH_CURRENT_EDGE:
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
Edit_Edge_Width( (EDGE_MODULE*) GetScreen()->GetCurItem() ); Edit_Edge_Width( (EDGE_MODULE*) GetScreen()->GetCurItem() );
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE: case ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE:
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
Edit_Edge_Width( NULL ); Edit_Edge_Width( NULL );
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_POPUP_MODEDIT_EDIT_LAYER_CURRENT_EDGE: case ID_POPUP_MODEDIT_EDIT_LAYER_CURRENT_EDGE:
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
Edit_Edge_Layer( (EDGE_MODULE*) GetScreen()->GetCurItem() ); Edit_Edge_Layer( (EDGE_MODULE*) GetScreen()->GetCurItem() );
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE: case ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE:
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
Edit_Edge_Layer( NULL ); Edit_Edge_Layer( NULL );
m_canvas->Refresh(); RefreshCanvas();
break; break;
case ID_POPUP_PCB_DELETE_EDGE: case ID_POPUP_PCB_DELETE_EDGE:
...@@ -775,7 +775,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -775,7 +775,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
} }
if( redraw ) if( redraw )
m_canvas->Refresh(); RefreshCanvas();
} }
......
...@@ -97,13 +97,13 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -97,13 +97,13 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{ {
End_Edge_Module( (EDGE_MODULE*) item ); End_Edge_Module( (EDGE_MODULE*) item );
SetCurItem( NULL ); SetCurItem( NULL );
m_canvas->Refresh(); RefreshCanvas();
} }
else if( ( (EDGE_MODULE*) item )->GetShape() == S_ARC ) else if( ( (EDGE_MODULE*) item )->GetShape() == S_ARC )
{ {
End_Edge_Module( (EDGE_MODULE*) item ); End_Edge_Module( (EDGE_MODULE*) item );
SetCurItem( NULL ); SetCurItem( NULL );
m_canvas->Refresh(); RefreshCanvas();
} }
else if( ( (EDGE_MODULE*) item )->GetShape() == S_SEGMENT ) else if( ( (EDGE_MODULE*) item )->GetShape() == S_SEGMENT )
{ {
...@@ -150,7 +150,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -150,7 +150,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
// so deselect the active tool // so deselect the active tool
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
SetCurItem( NULL ); SetCurItem( NULL );
m_canvas->Refresh(); RefreshCanvas();
} }
break; break;
...@@ -436,7 +436,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -436,7 +436,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
if( ret > 0 ) if( ret > 0 )
m_canvas->Refresh(); RefreshCanvas();
} }
break; break;
...@@ -448,7 +448,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -448,7 +448,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
case PCB_MODULE_EDGE_T : case PCB_MODULE_EDGE_T :
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
InstallFootprintBodyItemPropertiesDlg( (EDGE_MODULE*) item ); InstallFootprintBodyItemPropertiesDlg( (EDGE_MODULE*) item );
m_canvas->Refresh(); RefreshCanvas();
break; break;
default: default:
...@@ -463,7 +463,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -463,7 +463,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
{ {
End_Edge_Module( (EDGE_MODULE*) item ); End_Edge_Module( (EDGE_MODULE*) item );
SetCurItem( NULL ); SetCurItem( NULL );
m_canvas->Refresh(); RefreshCanvas();
} }
break; break;
......
...@@ -72,7 +72,7 @@ void FOOTPRINT_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event ) ...@@ -72,7 +72,7 @@ void FOOTPRINT_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
SetCurItem( NULL ); SetCurItem( NULL );
OnModify(); OnModify();
m_canvas->Refresh(); RefreshCanvas();
} }
...@@ -101,5 +101,5 @@ void FOOTPRINT_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event ) ...@@ -101,5 +101,5 @@ void FOOTPRINT_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
SetCurItem( NULL ); SetCurItem( NULL );
OnModify(); OnModify();
m_canvas->Refresh(); RefreshCanvas();
} }
...@@ -285,7 +285,7 @@ bool PCB_EDIT_FRAME::Delete_Module( MODULE* aModule, wxDC* aDC, bool aAskBeforeD ...@@ -285,7 +285,7 @@ bool PCB_EDIT_FRAME::Delete_Module( MODULE* aModule, wxDC* aDC, bool aAskBeforeD
// Redraw the full screen to ensure perfect display of board and ratsnest. // Redraw the full screen to ensure perfect display of board and ratsnest.
if( aDC ) if( aDC )
m_canvas->Refresh(); RefreshCanvas();
return true; return true;
} }
...@@ -421,7 +421,7 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, wxDC* aDC, bool aDoNotRecreat ...@@ -421,7 +421,7 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, wxDC* aDC, bool aDoNotRecreat
Compile_Ratsnest( aDC, true ); Compile_Ratsnest( aDC, true );
if( aDC ) if( aDC )
m_canvas->Refresh(); RefreshCanvas();
SetMsgPanel( aModule ); SetMsgPanel( aModule );
} }
...@@ -490,7 +490,7 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, double angle, bool ...@@ -490,7 +490,7 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, double angle, bool
} }
if( module->GetFlags() == 0 ) // module not in edit: redraw full screen if( module->GetFlags() == 0 ) // module not in edit: redraw full screen
m_canvas->Refresh(); RefreshCanvas();
} }
} }
......
...@@ -165,7 +165,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event ) ...@@ -165,7 +165,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
SetCurItem( NULL ); SetCurItem( NULL );
Zoom_Automatique( false ); Zoom_Automatique( false );
m_canvas->Refresh(); RefreshCanvas();
Update3D_Frame(); Update3D_Frame();
m_FootprintList->SetStringSelection( m_footprintName ); m_FootprintList->SetStringSelection( m_footprintName );
} }
......
...@@ -411,7 +411,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList() ...@@ -411,7 +411,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList()
ReCreateFootprintList(); ReCreateFootprintList();
ReCreateHToolbar(); ReCreateHToolbar();
DisplayLibInfos(); DisplayLibInfos();
m_canvas->Refresh(); RefreshCanvas();
} }
...@@ -477,7 +477,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& event ) ...@@ -477,7 +477,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& event )
m_libraryName = name; m_libraryName = name;
ReCreateFootprintList(); ReCreateFootprintList();
m_canvas->Refresh(); RefreshCanvas();
DisplayLibInfos(); DisplayLibInfos();
ReCreateHToolbar(); ReCreateHToolbar();
} }
...@@ -525,7 +525,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event ) ...@@ -525,7 +525,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
DisplayLibInfos(); DisplayLibInfos();
Zoom_Automatique( false ); Zoom_Automatique( false );
m_canvas->Refresh(); RefreshCanvas();
Update3D_Frame(); Update3D_Frame();
} }
} }
......
...@@ -894,7 +894,7 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) ...@@ -894,7 +894,7 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC )
if( current_net_code > 0 ) if( current_net_code > 0 )
TestNetConnection( DC, current_net_code ); TestNetConnection( DC, current_net_code );
m_canvas->Refresh(); RefreshCanvas();
return true; return true;
} }
...@@ -109,7 +109,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName, ...@@ -109,7 +109,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
// Rebuild the board connectivity: // Rebuild the board connectivity:
Compile_Ratsnest( NULL, true ); Compile_Ratsnest( NULL, true );
SetMsgPanel( GetBoard() ); SetMsgPanel( GetBoard() );
m_canvas->Refresh(); RefreshCanvas();
} }
......
...@@ -574,10 +574,40 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) ...@@ -574,10 +574,40 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
break; break;
case PAD_RECT: case PAD_RECT:
case PAD_TRAPEZOID:
m_gal->DrawRectangle( VECTOR2D( -size.x, -size.y ), VECTOR2D( size.x, size.y ) ); m_gal->DrawRectangle( VECTOR2D( -size.x, -size.y ), VECTOR2D( size.x, size.y ) );
break; break;
case PAD_TRAPEZOID:
{
std::deque<VECTOR2D> pointList;
wxPoint corners[4];
VECTOR2D padSize = VECTOR2D( aPad->GetSize().x, aPad->GetSize().y ) / 2;
VECTOR2D deltaPadSize = size - padSize; // = solder[Paste/Mask]Margin or 0
VECTOR2D delta = VECTOR2D( aPad->GetDelta().x / 2,
aPad->GetDelta().y / 2 );
VECTOR2D inflate = VECTOR2D( delta.y * ( deltaPadSize.x / size.x ),
delta.x * ( deltaPadSize.y / size.y ) );
aPad->BuildPadPolygon( corners, wxSize( deltaPadSize.x, deltaPadSize.y ), 0.0 );
pointList.push_back( VECTOR2D( corners[0] ) );
pointList.push_back( VECTOR2D( corners[1] ) );
pointList.push_back( VECTOR2D( corners[2] ) );
pointList.push_back( VECTOR2D( corners[3] ) );
if( m_pcbSettings->m_sketchModeSelect[PADS_VISIBLE] )
{
// Add the beginning point to close the outline
pointList.push_back( pointList.front() );
m_gal->DrawPolyline( pointList );
}
else
{
m_gal->DrawPolygon( pointList );
}
}
break;
case PAD_CIRCLE: case PAD_CIRCLE:
m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x ); m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x );
break; break;
...@@ -672,7 +702,7 @@ void PCB_PAINTER::draw( const MODULE* aModule ) ...@@ -672,7 +702,7 @@ void PCB_PAINTER::draw( const MODULE* aModule )
void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer ) void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
{ {
if( aLayer == ITEM_GAL_LAYER( GP_OVERLAY ) ) if( aLayer == ITEM_GAL_LAYER( SELECTION ) )
{ {
if( aText->IsSelected() ) if( aText->IsSelected() )
drawSelectionBox( aText ); drawSelectionBox( aText );
...@@ -696,7 +726,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer ) ...@@ -696,7 +726,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer ) void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
{ {
if( aLayer == ITEM_GAL_LAYER( GP_OVERLAY ) ) if( aLayer == ITEM_GAL_LAYER( SELECTION ) )
{ {
if( aText->IsSelected() ) if( aText->IsSelected() )
drawSelectionBox( aText ); drawSelectionBox( aText );
...@@ -790,7 +820,7 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone ) ...@@ -790,7 +820,7 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone )
void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer ) void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
{ {
if( aLayer == ITEM_GAL_LAYER( GP_OVERLAY ) ) if( aLayer == ITEM_GAL_LAYER( SELECTION ) )
{ {
if( aDimension->IsSelected() ) if( aDimension->IsSelected() )
drawSelectionBox( aDimension ); drawSelectionBox( aDimension );
......
...@@ -335,7 +335,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, ...@@ -335,7 +335,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
if( screenHeight <= 900 ) if( screenHeight <= 900 )
pointSize = (pointSize * 8) / 10; pointSize = (pointSize * 8) / 10;
m_Layers = new PCB_LAYER_WIDGET( this, m_canvas, pointSize ); m_Layers = new PCB_LAYER_WIDGET( this, m_galCanvas, pointSize );
m_drc = new DRC( this ); // these 2 objects point to each other m_drc = new DRC( this ); // these 2 objects point to each other
...@@ -792,11 +792,9 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer ) ...@@ -792,11 +792,9 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
rSettings->SetActiveLayer( ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ) ); rSettings->SetActiveLayer( ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ) );
} }
} }
view->UpdateAllLayersOrder(); view->UpdateAllLayersOrder();
view->UpdateAllLayersColor(); view->UpdateAllLayersColor();
if( m_galCanvasActive )
m_galCanvas->Refresh();
} }
} }
......
...@@ -314,6 +314,9 @@ bool EDA_APP::OnInit() ...@@ -314,6 +314,9 @@ bool EDA_APP::OnInit()
frame->SetFocus(); frame->SetFocus();
frame->GetCanvas()->SetFocus(); frame->GetCanvas()->SetFocus();
// Activate the GAL
frame->UseGalCanvas( true );
return true; return true;
} }
......
...@@ -243,7 +243,7 @@ void PCB_BASE_FRAME::SelectLayerPair() ...@@ -243,7 +243,7 @@ void PCB_BASE_FRAME::SelectLayerPair()
// because the PAD_SMD pads may change color. // because the PAD_SMD pads may change color.
if( result >= 0 && DisplayOpt.ContrastModeDisplay ) if( result >= 0 && DisplayOpt.ContrastModeDisplay )
{ {
m_canvas->Refresh(); RefreshCanvas();
} }
} }
......
...@@ -601,7 +601,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) ...@@ -601,7 +601,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
polygon->AppendPoint( lowerRight ); polygon->AppendPoint( lowerRight );
} }
D( printf( "m_DeltaSize: %d,%d\n", aPad->GetDelta().x, aPad->GetDelta().y ); ) DBG( printf( "m_DeltaSize: %d,%d\n", aPad->GetDelta().x, aPad->GetDelta().y ); )
// this string _must_ be unique for a given physical shape // this string _must_ be unique for a given physical shape
snprintf( name, sizeof(name), "Trapz%sPad_%.6gx%.6g_%c%.6gx%c%.6g_um", snprintf( name, sizeof(name), "Trapz%sPad_%.6gx%.6g_%c%.6gx%c%.6g_um",
...@@ -793,7 +793,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule ) ...@@ -793,7 +793,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
case S_RECT: case S_RECT:
case S_ARC: case S_ARC:
default: default:
D( printf( "makeIMAGE(): unsupported shape %s\n", DBG( printf( "makeIMAGE(): unsupported shape %s\n",
TO_UTF8( BOARD_ITEM::ShowShape( (STROKE_T) graphic->GetShape() ) ) ); ) TO_UTF8( BOARD_ITEM::ShowShape( (STROKE_T) graphic->GetShape() ) ) ); )
continue; continue;
} }
...@@ -908,7 +908,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER ...@@ -908,7 +908,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
} }
else // remove graphics not on EDGE_N layer else // remove graphics not on EDGE_N layer
{ {
D( items[i]->Show( 0, std::cout );) DBG( items[i]->Show( 0, std::cout );)
++i; ++i;
} }
} }
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <class_board.h>
#include <class_module.h>
#include <tool/tool_manager.h>
#include <view/view_group.h>
#include <view/view_controls.h>
#include "selection_tool.h"
#include "move_tool.h"
using namespace KiGfx;
using boost::optional;
MOVE_TOOL::MOVE_TOOL() :
TOOL_INTERACTIVE( "pcbnew.InteractiveMove" ), m_selectionTool( NULL )
{
}
MOVE_TOOL::~MOVE_TOOL()
{
}
void MOVE_TOOL::Reset()
{
// Find the selection tool, so they can cooperate
TOOL_BASE* selectionTool = m_toolMgr->FindTool( std::string( "pcbnew.InteractiveSelection" ) );
if( selectionTool )
{
m_selectionTool = static_cast<SELECTION_TOOL*>( selectionTool );
}
else
{
wxLogError( "pcbnew.InteractiveSelection tool is not available" );
return;
}
// the tool launches upon reception of activate ("pcbnew.InteractiveMove")
Go( &MOVE_TOOL::Main, TOOL_EVENT( TC_Command, TA_ActivateTool, GetName() ) ); //"pcbnew.InteractiveMove"));
}
int MOVE_TOOL::Main( TOOL_EVENT& aEvent )
{
VECTOR2D dragPosition;
bool dragging = false;
bool restore = false;
VIEW* view = m_toolMgr->GetView();
std::set<BOARD_ITEM*> selection;
VIEW_GROUP items( view );
view->Add( &items );
m_toolMgr->GetViewControls()->SetSnapping( true );
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
{
if( evt->IsCancel() )
{
restore = true;
m_toolMgr->PassEvent();
break; // Finish
}
if( evt->IsDrag( MB_Left ) )
{
if( dragging )
{
// Dragging is alre
VECTOR2D movement = ( evt->Position() - dragPosition );
std::set<BOARD_ITEM*>::iterator it, it_end;
for( it = selection.begin(), it_end = selection.end(); it != it_end; ++it )
{
(*it)->Move( wxPoint( movement.x, movement.y ) );
}
items.ViewUpdate( VIEW_ITEM::GEOMETRY );
}
else
{
// Begin dragging
selection = m_selectionTool->GetSelection();
std::set<BOARD_ITEM*>::iterator it;
for( it = selection.begin(); it != selection.end(); ++it )
{
viewGroupAdd( *it, &items );
// but if a MODULE was selected, then we need to redraw all of it's parts
if( (*it)->Type() == PCB_MODULE_T )
{
MODULE* module = static_cast<MODULE*>( *it );
// Move everything that belongs to the module
for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
viewGroupAdd( pad, &items );
for( BOARD_ITEM* drawing = module->GraphicalItems().GetFirst(); drawing;
drawing = drawing->Next() )
viewGroupAdd( drawing, &items );
viewGroupAdd( &module->Reference(), &items );
viewGroupAdd( &module->Value(), &items );
}
}
items.ViewUpdate( VIEW_ITEM::GEOMETRY );
dragging = true;
}
dragPosition = evt->Position();
}
else if( evt->Category() == TC_Mouse ) // Filter out other events
{
if( dragging )
{
break; // Finish
}
}
}
// Clean-up after movement
std::deque<ITEM_STATE>::iterator it, it_end;
if( restore )
{
// Movement has to be rollbacked, so restore previous state of items
for( it = m_itemsState.begin(), it_end = m_itemsState.end(); it != it_end; ++it )
it->Restore();
}
else
{
// Apply changes
for( it = m_itemsState.begin(), it_end = m_itemsState.end(); it != it_end; ++it )
{
it->RestoreVisibility();
it->item->ViewUpdate( VIEW_ITEM::GEOMETRY );
}
}
m_itemsState.clear();
items.Clear();
view->Remove( &items );
m_toolMgr->GetViewControls()->SetSnapping( false );
return 0;
}
void MOVE_TOOL::viewGroupAdd( BOARD_ITEM* aItem, KiGfx::VIEW_GROUP* aGroup )
{
// Save the state of the selected items, in case it has to be restored
ITEM_STATE state;
state.Save( aItem );
m_itemsState.push_back( state );
// Add items to the VIEW_GROUP, so they will be displayed on the overlay
// while dragging
aGroup->Add( aItem );
// Set the original item as invisible
aItem->ViewSetVisible( false );
}
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author @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 __MOVE_TOOL_H
#define __MOVE_TOOL_H
#include <math/vector2d.h>
#include <tool/tool_interactive.h>
class BOARD_ITEM;
class SELECTION_TOOL;
namespace KiGfx
{
class VIEW_GROUP;
}
/**
* Class MOVE_TOOL
* /// TODO DOCS!!
* Our sample move tool: currently supports:
* - pick single objects (click LMB)
* - add objects to existing move (Shift+LMB)
* - draw move box (drag LMB)
*
* WORK IN PROGRESS. CONSIDER AS A DEMO!
*/
class MOVE_TOOL : public TOOL_INTERACTIVE
{
public:
MOVE_TOOL();
~MOVE_TOOL();
/**
* Function Reset()
*
* Resets the tool and initializes it.
*/
void Reset();
/**
* Function Main()
*
* Main loop in which events are handled.
*/
int Main( TOOL_EVENT& aEvent );
private:
void viewGroupAdd( BOARD_ITEM* aItem, KiGfx::VIEW_GROUP* aGroup );
/// Structure for (re)storing BOARD_ITEM state
typedef struct
{
BOARD_ITEM* item; /// Pointer to the item
VECTOR2D position; /// Original position of the item
bool visible; /// Original visibility flag
void Save( BOARD_ITEM* aItem )
{
wxPoint pos = aItem->GetPosition();
item = aItem;
position.x = pos.x;
position.y = pos.y;
visible = aItem->ViewIsVisible();
}
void RestorePosition()
{
item->SetPosition( wxPoint( position.x, position.y ) );
}
void RestoreVisibility()
{
item->ViewSetVisible( visible );
}
void Restore()
{
RestorePosition();
RestoreVisibility();
}
} ITEM_STATE;
/// Selection tool used for obtaining selected items
SELECTION_TOOL* m_selectionTool;
std::deque<ITEM_STATE> m_itemsState;
};
#endif
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <pcbnew_id.h> #include <pcbnew_id.h>
#include "selection_tool.h" #include "selection_tool.h"
#include "move_tool.h"
#include <router/router_tool.h> #include <router/router_tool.h>
void PCB_EDIT_FRAME::setupTools() void PCB_EDIT_FRAME::setupTools()
...@@ -47,6 +48,7 @@ void PCB_EDIT_FRAME::setupTools() ...@@ -47,6 +48,7 @@ void PCB_EDIT_FRAME::setupTools()
// register our selection tool. // register our selection tool.
m_toolManager->RegisterTool( new SELECTION_TOOL ); m_toolManager->RegisterTool( new SELECTION_TOOL );
m_toolManager->RegisterTool( new ROUTER_TOOL ); m_toolManager->RegisterTool( new ROUTER_TOOL );
m_toolManager->RegisterTool( new MOVE_TOOL );
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <class_drawpanel_gal.h> #include <class_drawpanel_gal.h>
#include <class_board.h> #include <class_board.h>
#include <class_board_item.h> #include <class_board_item.h>
#include <class_track.h>
#include <class_module.h> #include <class_module.h>
#include <wxPcbStruct.h> #include <wxPcbStruct.h>
...@@ -43,7 +44,7 @@ using namespace KiGfx; ...@@ -43,7 +44,7 @@ using namespace KiGfx;
using boost::optional; using boost::optional;
SELECTION_TOOL::SELECTION_TOOL() : SELECTION_TOOL::SELECTION_TOOL() :
TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ) TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ), m_multiple( false )
{ {
m_selArea = new SELECTION_AREA; m_selArea = new SELECTION_AREA;
} }
...@@ -68,6 +69,11 @@ void SELECTION_TOOL::Reset() ...@@ -68,6 +69,11 @@ void SELECTION_TOOL::Reset()
int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
{ {
bool dragging = false; bool dragging = false;
bool allowMultiple = true;
BOARD* board = getModel<BOARD>( PCB_T );
if( !board )
return 0;
// Main loop: keep receiving events // Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() ) while( OPT_TOOL_EVENT evt = Wait() )
...@@ -86,6 +92,10 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) ...@@ -86,6 +92,10 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
if( evt->IsClick( MB_Left ) ) if( evt->IsClick( MB_Left ) )
selectSingle( evt->Position() ); selectSingle( evt->Position() );
// unlock the multiple selection box
if( evt->IsMouseUp( MB_Left ) )
allowMultiple = true;
// drag with LMB? Select multiple objects (or at least draw a selection box) or drag them // drag with LMB? Select multiple objects (or at least draw a selection box) or drag them
if( evt->IsDrag( MB_Left ) ) if( evt->IsDrag( MB_Left ) )
{ {
...@@ -96,14 +106,14 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) ...@@ -96,14 +106,14 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
{ {
// If nothings has been selected or user wants to select more // If nothings has been selected or user wants to select more
// draw the selection box // draw the selection box
selectMultiple(); if( allowMultiple )
allowMultiple = !selectMultiple();
} }
else else
{ {
// Now user wants to drag the selected items // Now user wants to drag the selected items
m_toolMgr->InvokeTool( "pcbnew.InteractiveMove" ); m_toolMgr->InvokeTool( "pcbnew.InteractiveMove" );
} }
} }
else if( dragging ) else if( dragging )
{ {
...@@ -131,8 +141,12 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem ) ...@@ -131,8 +141,12 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
if( !m_additive ) if( !m_additive )
clearSelection(); clearSelection();
aItem->SetSelected(); // Prevent selection of invisible items
m_selectedItems.insert( aItem ); if( selectable( aItem ) )
{
aItem->SetSelected();
m_selectedItems.insert( aItem );
}
} }
} }
...@@ -214,22 +228,25 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector ...@@ -214,22 +228,25 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector
} }
void SELECTION_TOOL::handleHighlight( const VECTOR2D& aP ) bool SELECTION_TOOL::selectMultiple()
{
}
void SELECTION_TOOL::selectMultiple()
{ {
OPT_TOOL_EVENT evt; OPT_TOOL_EVENT evt;
VIEW* v = getView(); VIEW* v = getView();
bool cancelled = false;
m_multiple = true;
// Those 2 lines remove the blink-in-the-random-place effect
m_selArea->SetOrigin( VECTOR2I( 0, 0 ) );
m_selArea->SetEnd( VECTOR2I( 0, 0 ) );
v->Add( m_selArea ); v->Add( m_selArea );
while( evt = Wait() ) while( evt = Wait() )
{ {
if( evt->IsCancel() ) if( evt->IsCancel() )
{
cancelled = true;
break; break;
}
if( evt->IsDrag( MB_Left ) ) if( evt->IsDrag( MB_Left ) )
{ {
...@@ -258,19 +275,21 @@ void SELECTION_TOOL::selectMultiple() ...@@ -258,19 +275,21 @@ void SELECTION_TOOL::selectMultiple()
{ {
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first ); BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first );
// Add only those items which are fully within a selection box // Add only those items which are visible and fully within the selection box
if( selectionBox.Contains( item->ViewBBox() ) ) if( selectable( item ) && selectionBox.Contains( item->ViewBBox() ) )
{ {
item->SetSelected(); item->SetSelected();
m_selectedItems.insert( item ); m_selectedItems.insert( item );
} }
} }
break; break;
} }
} }
v->Remove( m_selArea ); v->Remove( m_selArea );
m_multiple = false;
return cancelled;
} }
...@@ -331,3 +350,54 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) ...@@ -331,3 +350,54 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
return NULL; return NULL;
} }
bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem )
{
BOARD* board = getModel<BOARD>( PCB_T );
switch( aItem->Type() )
{
case PCB_VIA_T:
{
// For vias it is enough if only one of layers is visible
LAYER_NUM top, bottom;
static_cast<const SEGVIA*>( aItem )->ReturnLayerPair( &top, &bottom );
return ( board->IsLayerVisible( top ) ||
board->IsLayerVisible( bottom ) );
}
break;
case PCB_PAD_T:
{
// Pads are not selectable in multiple selection mode
if( m_multiple )
return false;
// Pads are supposed to be on top, bottom or both at the same time (THT)
if( aItem->IsOnLayer( LAYER_N_FRONT ) && board->IsLayerVisible( LAYER_N_FRONT ) )
return true;
if( aItem->IsOnLayer( LAYER_N_BACK ) && board->IsLayerVisible( LAYER_N_BACK ) )
return true;
return false;
}
break;
case PCB_MODULE_TEXT_T:
// Module texts are not selectable in multiple selection mode
if( m_multiple )
return false;
break;
case PCB_MODULE_EDGE_T:
// These are not selectable, otherwise silkscreen drawings would be easily destroyed
return false;
break;
}
// All other items are selected only if the layer on which they exist is visible
return board->IsLayerVisible( aItem->GetLayer() );
}
...@@ -35,7 +35,6 @@ class SELECTION_AREA; ...@@ -35,7 +35,6 @@ class SELECTION_AREA;
class BOARD_ITEM; class BOARD_ITEM;
class GENERAL_COLLECTOR; class GENERAL_COLLECTOR;
/** /**
* Class SELECTION_TOOL * Class SELECTION_TOOL
* *
...@@ -43,8 +42,6 @@ class GENERAL_COLLECTOR; ...@@ -43,8 +42,6 @@ class GENERAL_COLLECTOR;
* - pick single objects (click LMB) * - pick single objects (click LMB)
* - add objects to existing selection (Shift+LMB) * - add objects to existing selection (Shift+LMB)
* - draw selection box (drag LMB) * - draw selection box (drag LMB)
*
* WORK IN PROGRESS. CONSIDER AS A DEMO!
*/ */
class SELECTION_TOOL : public TOOL_INTERACTIVE class SELECTION_TOOL : public TOOL_INTERACTIVE
...@@ -53,26 +50,101 @@ public: ...@@ -53,26 +50,101 @@ public:
SELECTION_TOOL(); SELECTION_TOOL();
~SELECTION_TOOL(); ~SELECTION_TOOL();
/**
* Function Reset()
*
* Initializes the selection tool.
*/
void Reset(); void Reset();
/**
* Function Main()
*
* The main loop.
*/
int Main( TOOL_EVENT& aEvent ); int Main( TOOL_EVENT& aEvent );
/**
* Function GetSelection()
*
* Returns the set of currently selected items.
*/
const std::set<BOARD_ITEM*>& GetSelection() const const std::set<BOARD_ITEM*>& GetSelection() const
{ {
return m_selectedItems; return m_selectedItems;
} }
private: private:
/**
* Function selectSingle()
* Selects an item pointed by the parameter aWhere. If there is more than one item at that
* place, there is a menu displayed that allows to choose the item.
*
* @param aWhere is the place where the item should be selected.
*/
void selectSingle( const VECTOR2I& aWhere ); void selectSingle( const VECTOR2I& aWhere );
void selectMultiple();
void handleHighlight( const VECTOR2D& aP ); /**
* Function selectMultiple()
* Handles drawing a selection box that allows to select many items at the same time.
*
* @return true if the function was cancelled (ie. CancelEvent was received).
*/
bool selectMultiple();
/**
* Function disambiguationMenu()
* Handles the menu that allows to select one of many items in case there is more than one
* item at the selected point (@see selectSingle()).
*
* @param aItems contains list of items that are displayed to the user.
*/
BOARD_ITEM* disambiguationMenu( GENERAL_COLLECTOR* aItems ); BOARD_ITEM* disambiguationMenu( GENERAL_COLLECTOR* aItems );
/**
* Function pickSmallestComponent()
* Allows to find the smallest (in terms of bounding box area) item from the list.
*
* @param aCollector containes the list of items.
*/
BOARD_ITEM* pickSmallestComponent( GENERAL_COLLECTOR* aCollector ); BOARD_ITEM* pickSmallestComponent( GENERAL_COLLECTOR* aCollector );
/**
* Function toggleSelection()
* Changes selection status of a given item.
*
* @param aItem is the item to have selection status changed.
*/
void toggleSelection( BOARD_ITEM* aItem ); void toggleSelection( BOARD_ITEM* aItem );
/**
* Function clearSelection()
* Clears selections of currently selected items.
*/
void clearSelection(); void clearSelection();
/**
* Function selectable()
* Checks conditions for an item to be selected.
*
* @return True if the item fulfills conditions to be selected.
*/
bool selectable( const BOARD_ITEM* aItem );
/// Container storing currently selected items
std::set<BOARD_ITEM*> m_selectedItems; std::set<BOARD_ITEM*> m_selectedItems;
/// Visual representation of selection area
SELECTION_AREA* m_selArea; SELECTION_AREA* m_selArea;
/// Menu shown in case of selection ambiguity
boost::shared_ptr<CONTEXT_MENU> m_menu; boost::shared_ptr<CONTEXT_MENU> m_menu;
/// Flag saying if items should be added to the current selection or rather replace it
bool m_additive; bool m_additive;
/// Flag saying if multiple selection mode is active
bool m_multiple;
}; };
#endif #endif
...@@ -281,7 +281,7 @@ void DIALOG_EXCHANGE_MODULE::Change_Current_Module() ...@@ -281,7 +281,7 @@ void DIALOG_EXCHANGE_MODULE::Change_Current_Module()
if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
m_Parent->Compile_Ratsnest( NULL, true ); m_Parent->Compile_Ratsnest( NULL, true );
m_Parent->GetCanvas()->Refresh(); m_Parent->RefreshCanvas();
} }
if( pickList.GetCount() ) if( pickList.GetCount() )
...@@ -370,7 +370,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue ) ...@@ -370,7 +370,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
m_Parent->Compile_Ratsnest( NULL, true ); m_Parent->Compile_Ratsnest( NULL, true );
m_Parent->GetCanvas()->Refresh(); m_Parent->RefreshCanvas();
} }
if( pickList.GetCount() ) if( pickList.GetCount() )
...@@ -423,7 +423,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll() ...@@ -423,7 +423,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
m_Parent->Compile_Ratsnest( NULL, true ); m_Parent->Compile_Ratsnest( NULL, true );
m_Parent->GetCanvas()->Refresh(); m_Parent->RefreshCanvas();
} }
if( pickList.GetCount() ) if( pickList.GetCount() )
......
...@@ -333,7 +333,7 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* ...@@ -333,7 +333,7 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER*
// Combine zones if possible // Combine zones if possible
wxBusyCursor dummy; wxBusyCursor dummy;
GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone ); GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
m_canvas->Refresh(); RefreshCanvas();
int ii = GetBoard()->GetAreaIndex( aZone ); // test if aZone exists int ii = GetBoard()->GetAreaIndex( aZone ); // test if aZone exists
......
...@@ -80,7 +80,7 @@ void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, time_t aTimestamp ) ...@@ -80,7 +80,7 @@ void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, time_t aTimestamp )
if( modify ) if( modify )
{ {
OnModify(); OnModify();
m_canvas->Refresh(); RefreshCanvas();
} }
} }
......
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