Merged kicad-gal-orson

This commit is contained in:
tomasz.wlostowski@cern.ch 2013-09-10 19:32:19 +02:00
commit 9eb3916852
78 changed files with 1004 additions and 403 deletions

View File

@ -415,6 +415,6 @@ void CALLBACK tessErrorCB( GLenum errorCode )
errorStr = gluErrorString( errorCode );
// DEBUG //
D( printf( "Tess ERROR: %s\n", errorStr ); )
DBG( printf( "Tess ERROR: %s\n", errorStr ); )
#endif
}

View File

@ -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;
}
@ -207,7 +207,7 @@ int VRML_MODEL_PARSER::readChildren( FILE* file, int* LineNum )
}
else
{
D( printf( "ReadChildren error line %d <%s> \n", *LineNum, text ) );
DBG( printf( "ReadChildren error line %d <%s> \n", *LineNum, text ) );
break;
}
}
@ -241,7 +241,7 @@ int VRML_MODEL_PARSER::readShape( FILE* file, int* LineNum )
}
else
{
D( printf( "ReadShape error line %d <%s> \n", *LineNum, text ) );
DBG( printf( "ReadShape error line %d <%s> \n", *LineNum, text ) );
break;
}
}
@ -271,7 +271,7 @@ int VRML_MODEL_PARSER::readAppearance( FILE* file, int* LineNum )
}
else
{
D( printf( "ReadAppearance error line %d <%s> \n", *LineNum, text ) );
DBG( printf( "ReadAppearance error line %d <%s> \n", *LineNum, text ) );
break;
}
}

View File

@ -197,19 +197,19 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
if( !parseDoubleTriplet( properties[ wxT( "diffuseColor" ) ],
material->m_DiffuseColor ) )
{
D( printf("diffuseColor parsing error") );
DBG( printf("diffuseColor parsing error") );
}
if( !parseDoubleTriplet( properties[ wxT( "specularColor" ) ],
material->m_SpecularColor ) )
{
D( printf("specularColor parsing error") );
DBG( printf("specularColor parsing error") );
}
if( !parseDoubleTriplet( properties[ wxT( "emissiveColor" ) ],
material->m_EmissiveColor ) )
{
D( printf("emissiveColor parsing error") );
DBG( printf("emissiveColor parsing error") );
}
wxStringTokenizer values;
@ -221,7 +221,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
}
else
{
D( printf( "ambienterror" ) );
DBG( printf( "ambienterror" ) );
}
values.SetString( properties[ wxT( "shininess" ) ] );
@ -232,7 +232,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
}
else
{
D( printf( "shininess error" ) );
DBG( printf( "shininess error" ) );
}
values.SetString( properties[ wxT( "transparency" ) ] );
@ -243,7 +243,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
}
else
{
D( printf( "trans error") );
DBG( printf( "trans error") );
}
material->SetMaterial();
@ -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,
tokens.GetNextToken().ToDouble( &rotation.z ) &&
tokens.GetNextToken().ToDouble( &angle ) ) )
{
D( printf("rotation read error") );
DBG( printf("rotation read error") );
}
double vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits *
@ -407,7 +407,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode,
if( points.size() % 3 != 0 )
{
D( printf( "Number of points is incorrect" ) );
DBG( printf( "Number of points is incorrect" ) );
return;
}

View File

@ -222,7 +222,7 @@ void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event )
if( SavePageSettings() )
{
m_screen->SetModify();
m_parent->GetCanvas()->Refresh();
m_parent->RefreshCanvas();
if( m_localPrjConfigChanged )
m_parent->SaveProjectSettings( true );

View File

@ -234,13 +234,14 @@ void EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent()
void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
{
SetGridVisibility( !IsGridVisible() );
if( m_galCanvasActive )
{
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 )
if( m_galCanvasActive )
{
KiGfx::GAL* gal = m_galCanvas->GetGAL();
gal->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x, screen->GetGrid().m_Size.y ) );
m_galCanvas->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x,
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 )
// Switch to GAL rendering
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() );
view->SetScale( zoom );
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
{
@ -1014,6 +1016,8 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show( aEnable );
m_auimgr.Update();
m_galCanvas->SetFocus();
m_galCanvasActive = aEnable;
if( aEnable )
m_galCanvas->SetFocus();
}

View File

@ -736,8 +736,13 @@ void CAIRO_GAL::SetTarget( RenderTarget aTarget )
return;
// Cairo grouping prevents display of overlapping items on the same layer in the lighter color
cairo_pop_group_to_source( currentContext );
cairo_paint_with_alpha( currentContext, fillColor.a );
if( isInitialized )
{
storePath();
cairo_pop_group_to_source( currentContext );
cairo_paint_with_alpha( currentContext, fillColor.a );
}
switch( aTarget )
{
@ -752,7 +757,8 @@ void CAIRO_GAL::SetTarget( RenderTarget aTarget )
break;
}
cairo_push_group( currentContext );
if( isInitialized )
cairo_push_group( currentContext );
currentTarget = aTarget;
}

View File

@ -167,8 +167,9 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
}
}
ClearBuffer();
// Return to direct rendering (we were asked only to create a buffer, not switch to one)
glBindFramebuffer( GL_FRAMEBUFFER, DIRECT_RENDERING );
m_currentFbo = DIRECT_RENDERING;

View File

@ -471,6 +471,7 @@ void OPENGL_GAL::DrawPolygon( const std::deque<VECTOR2D>& aPointList )
// Any non convex polygon needs to be tesselated
// for this purpose the GLU standard functions are used
currentManager->Shader( SHADER_NONE );
currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a );
TessParams params = { currentManager, tessIntersects };
gluTessBeginPolygon( tesselator, &params );

View File

@ -44,7 +44,7 @@ public:
if( type == wxEVT_MENU_HIGHLIGHT )
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() );
m_menu->m_tool->GetManager()->ProcessEvent( evt );
@ -60,8 +60,15 @@ CONTEXT_MENU::CONTEXT_MENU()
m_tool = NULL;
m_menu = new wxMenu();
m_handler = new CMEventHandler( this );
m_menu->Connect( wxEVT_MENU_HIGHLIGHT, wxEventHandler( CMEventHandler::onEvent ), NULL, m_handler );
m_menu->Connect( wxEVT_COMMAND_MENU_SELECTED, wxEventHandler( CMEventHandler::onEvent ), NULL, m_handler );
m_menu->Connect( wxEVT_MENU_HIGHLIGHT, wxEventHandler( CMEventHandler::onEvent ),
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;
}
@ -75,6 +82,7 @@ CONTEXT_MENU::~CONTEXT_MENU()
void CONTEXT_MENU::SetTitle( const wxString& aTitle )
{
// Unfortunately wxMenu::SetTitle() does nothing..
if( m_titleSet )
{
m_menu->Delete( m_menu->FindItemByPosition( 0 ) ); // fixme: this is LAME!
@ -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 ) );
}

View File

@ -210,9 +210,9 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
st->wakeupEvent = aEvent;
st->pendingWait = false;
st->waitEvents.clear();
st->cofunc->Resume();
if( !st->cofunc->Running() )
if( !st->cofunc->Resume() )
{
// The couroutine has finished
finishTool( st );
}
@ -261,6 +261,7 @@ void TOOL_MANAGER::finishTool( TOOL_STATE* aState )
{
wxASSERT( m_activeTools.front() == aState->theTool->GetId() );
// Deactivate the most recent tool and remove it from the active tools queue
aState->idle = true;
m_activeTools.erase( m_activeTools.begin() );

View File

@ -98,9 +98,9 @@ void VIEW::Add( VIEW_ITEM* aItem )
for( int i = 0; i < layers_count; i++ )
{
VIEW_LAYER* l = &m_layers[layers[i]];
l->items->Insert( aItem );
l->dirtyExtents.Merge( aItem->ViewBBox() );
VIEW_LAYER& l = m_layers[layers[i]];
l.items->Insert( aItem );
l.isDirty = true;
}
if( m_dynamic )
@ -386,7 +386,7 @@ struct VIEW::updateItemsColor
void VIEW::UpdateLayerColor( int aLayer )
{
// There is no point in updating non-cached layers
if( !isCached( aLayer ) )
if( !IsCached( aLayer ) )
return;
BOX2I r;
@ -409,7 +409,7 @@ void VIEW::UpdateAllLayersColor()
VIEW_LAYER* l = &( ( *i ).second );
// There is no point in updating non-cached layers
if( !isCached( l->id ) )
if( !IsCached( l->id ) )
continue;
updateItemsColor visitor( l->id, m_painter, m_gal );
@ -441,7 +441,7 @@ struct VIEW::changeItemsDepth
void VIEW::ChangeLayerDepth( int aLayer, int aDepth )
{
// There is no point in updating non-cached layers
if( !isCached( aLayer ) )
if( !IsCached( aLayer ) )
return;
BOX2I r;
@ -564,6 +564,7 @@ void VIEW::redrawRect( const BOX2I& aRect )
m_gal->SetLayerDepth( l->renderingOrder );
l->items->Query( aRect, drawFunc );
}
l->isDirty = false;
}
}
@ -571,7 +572,7 @@ void VIEW::redrawRect( const BOX2I& aRect )
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
int group = aItem->getGroup( aLayer );
@ -697,6 +698,7 @@ void VIEW::Clear()
{
VIEW_LAYER* l = &( ( *i ).second );
unlinkItem v;
if( m_dynamic )
l->items->Query( r, v );
@ -789,6 +791,9 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
int layers[VIEW_MAX_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
for( int i = 0; i < layers_count; i++ )
{
@ -796,12 +801,8 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
if( aUpdateFlags & VIEW_ITEM::GEOMETRY )
{
// Reinsert item in order to update bounding box
Remove( aItem );
Add( aItem );
if( isCached( layerId ) )
updateItemGeometry( aItem, layerId ); /// TODO is it still necessary?
if( IsCached( layerId ) )
updateItemGeometry( aItem, layerId );
}
else if( aUpdateFlags & VIEW_ITEM::COLOR )
{
@ -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
{
wxASSERT( (unsigned) aLayerId < m_layers.size() );
@ -893,13 +909,13 @@ void VIEW::RecacheAllItems( bool aImmediately )
{
VIEW_LAYER* l = &( ( *i ).second );
if( isCached( l->id ) )
if( IsCached( l->id ) )
{
m_gal->SetTarget( l->target );
m_gal->SetLayerDepth( l->renderingOrder );
recacheLayer visitor( this, m_gal, l->id, aImmediately );
l->items->Query( r, visitor );
l->isDirty = false;
l->isDirty = true;
}
}

View File

@ -56,21 +56,18 @@ VIEW_GROUP::~VIEW_GROUP()
void VIEW_GROUP::Add( VIEW_ITEM* aItem )
{
m_items.insert( aItem );
updateBbox();
}
void VIEW_GROUP::Remove( VIEW_ITEM* aItem )
{
m_items.erase( aItem );
updateBbox();
}
void VIEW_GROUP::Clear()
{
m_items.clear();
updateBbox();
}
void VIEW_GROUP::FreeItems()
@ -90,15 +87,9 @@ unsigned int VIEW_GROUP::GetSize() const
const BOX2I VIEW_GROUP::ViewBBox() const
{
BOX2I box;
// Merge all bounding boxes, so the returned one contains all stored items
BOOST_FOREACH( VIEW_ITEM* item, m_items )
{
box.Merge( item->ViewBBox() );
}
return box;
BOX2I maxBox;
maxBox.SetMaximum();
return maxBox;
}
@ -115,19 +106,21 @@ void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal, const BOX2I& aVisibleArea ) co
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] ) )
item->ViewDraw( layers[i], aGal, aVisibleArea ); // Alternative drawing method
if( !painter->Draw( item, layers[i] ) )
item->ViewDraw( layers[i], aGal, aVisibleArea ); // Alternative drawing method
}
}
/// m_view->Draw( item, true );
}
}
void VIEW_GROUP::ViewGetLayers( int aLayers[], int& aCount ) const
{
// Everything is displayed on a single layer
aLayers[0] = m_layer;
aCount = 1;
}

View File

@ -34,11 +34,6 @@ using namespace KiGfx;
WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) :
VIEW_CONTROLS( aView ),
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->Connect( wxEVT_MOTION, wxMouseEventHandler(
@ -49,6 +44,10 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) :
WX_VIEW_CONTROLS::onButton ), NULL, this );
m_parentPanel->Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler(
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
m_parentPanel->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler(
WX_VIEW_CONTROLS::onEnter ), NULL, this );
@ -64,6 +63,12 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
{
m_mousePosition.x = aEvent.GetX();
m_mousePosition.y = aEvent.GetY();
if( m_snappingEnabled )
m_cursorPosition = m_view->GetGAL()->GetGridPoint( m_mousePosition );
else
m_cursorPosition = m_mousePosition;
bool isAutoPanning = false;
if( m_autoPanEnabled )
@ -150,6 +155,11 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
m_lookStartPoint = m_view->GetCenter();
m_state = DRAG_PANNING;
}
if( aEvent.LeftUp() )
{
m_state = IDLE; // Stop autopanning when user release left mouse button
}
break;
case DRAG_PANNING:
@ -187,8 +197,7 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
dir = m_view->ToWorld( dir, false );
m_view->SetCenter( m_view->GetCenter() + dir * m_autoPanSpeed );
wxPaintEvent redrawEvent;
wxPostEvent( m_parentPanel, redrawEvent );
m_parentPanel->Refresh();
}
break;
@ -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 )
{
VECTOR2D p( aEvent.GetX(), aEvent.GetY() );

View File

@ -52,7 +52,7 @@ void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe
if( aWarpPointer )
m_canvas->MoveCursorToCrossHair();
m_canvas->Refresh();
RefreshCanvas();
m_canvas->Update();
}
@ -64,11 +64,20 @@ void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore )
AdjustScrollBars( newCenter );
m_canvas->Refresh();
RefreshCanvas();
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 )
{
BASE_SCREEN* screen = GetScreen();
@ -160,7 +169,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
break;
case ID_ZOOM_REDRAW:
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_POPUP_ZOOM_CENTER:

View File

@ -21,9 +21,9 @@
#define WIN_STRING_DIR_SEP wxT( "\\" )
#ifdef DEBUG
#define D(x) x
#define DBG(x) x
#else
#define D(x) // nothing
#define DBG(x) // nothing
#endif
/**

View File

@ -240,6 +240,7 @@ enum PCB_VISIBLE
PAD_BK_NETNAMES_VISIBLE,
PADS_NETNAMES_VISIBLE,
SELECTION,
GP_OVERLAY, // General purpose overlay
END_PCB_VISIBLE_LIST // sentinel
@ -258,7 +259,7 @@ enum PCB_VISIBLE
/// means that layer is displayed closer to the user, ie. on the top).
const LAYER_NUM GalLayerOrder[] =
{
ITEM_GAL_LAYER( GP_OVERLAY ),
ITEM_GAL_LAYER( GP_OVERLAY ), ITEM_GAL_LAYER( SELECTION ),
ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE ),
DRAW_N, COMMENT_N, ECO1_N, ECO2_N, EDGE_N,
UNUSED_LAYER_29, UNUSED_LAYER_30, UNUSED_LAYER_31,

View File

@ -44,7 +44,7 @@ public:
~CONTEXT_MENU();
void SetTitle( const wxString& aTitle );
void Add ( const wxString& aItem, int aId );
void Add( const wxString& aItem, int aId );
// fixme: unimplemented
// void Add ( const TOOL_ACTION& aAction, int aId = -1 );
@ -61,7 +61,7 @@ private:
friend class TOOL_INTERACTIVE;
void setTool ( TOOL_INTERACTIVE* aTool )
void setTool( TOOL_INTERACTIVE* aTool )
{
m_tool = aTool;
}

View File

@ -36,7 +36,7 @@ class TOOL_MANAGER;
class PCB_BASE_FRAME;
namespace KiGfx {
class VIEW ;
class VIEW;
};
/**

View File

@ -71,6 +71,8 @@ public:
* Function InvokeTool()
* 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
*
* @return True if the requested tool was invoked successfully.
*/
bool InvokeTool( TOOL_ID aToolId );
bool InvokeTool( const std::string& aName );
@ -81,6 +83,8 @@ public:
/**
* Function FindTool()
* 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( const std::string& aName ) const;
@ -100,7 +104,7 @@ public:
/**
* 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)
* when the board is set up
* when the board is set up.
*/
void SetEnvironment( EDA_ITEM* aModel, KiGfx::VIEW* aView,
KiGfx::VIEW_CONTROLS* aViewControls, wxWindow* aFrame );
@ -154,7 +158,7 @@ public:
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()
{

View File

@ -262,13 +262,27 @@ public:
/**
* Function SetLayerVisible()
* Controls the visibility of a particular layer.
* @param aLayer: the layer to show/hide. When ALL_LAYERS constant is given, all layers'
* visibility is updated
* @param aVisible: the obivous
* @param aLayer: the layer to show/hide
* @param aVisible: the obvious
*/
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:
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
private:
@ -432,11 +453,8 @@ private:
bool isDirty; ///* does it contain any dirty items (updated since last redraw)
bool displayOnly; ///* is the layer display only?
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 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
std::set<int> requiredLayers; ///* layers that are required to be enabled to show the layer
};
@ -515,6 +533,9 @@ private:
/// Updates all informations needed to draw an item
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.
static bool compareRenderingOrder( VIEW_LAYER* i, VIEW_LAYER* j )
{
@ -524,12 +545,6 @@ private:
/// Checks if every layer required by the aLayerId layer is enabled.
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
bool m_enableOrderModifier;

View File

@ -46,23 +46,31 @@ class VIEW;
class VIEW_CONTROLS
{
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() {};
/**
* Function Activate
* Determines if all view related events (mouse wheel, right click panning, etc.), should be
* handled or not. If not - they can be processed by the legacy view.
* @param aEnabled tells if events should be handled.
* Function SetSnapping()
* Enables/disables snapping cursor to grid.
*
* @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
* 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.
*/
virtual void SetGrabMouse( bool aEnabled ) {};
virtual void SetGrabMouse( bool aEnabled )
{
m_grabMouse = aEnabled;
}
/**
* Function SetAutoPan
@ -70,36 +78,90 @@ public:
* 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.
*/
virtual void SetAutoPan( bool aEnabled ) {}
virtual void SetAutoPan( bool aEnabled )
{
m_autoPanEnabled = aEnabled;
}
/**
* Function SetPanSpeed
* Sets speed of panning.
* @param aSpeed is a new speed for panning.
* Function SetAutoPanSpeed()
* Sets speed of autopanning.
* @param aSpeed is a new speed for autopanning.
*/
virtual void SetPanSpeed( float aSpeed ) {};
virtual void SetAutoPanSpeed( float aSpeed )
{
m_autoPanSpeed = aSpeed;
}
/**
* Function SetZoomSpeed
* Determines how much zoom factor should be affected on one zoom event (eg. mouse wheel).
* @param aSpeed is a new zooming speed.
* Function SetAutoPanMArgin()
* Sets margin for autopanning (ie. the area when autopanning becomes active).
* @param aSpeed is a new margin for autopanning.
*/
virtual void SetZoomSpeed( float aSpeed ) {};
virtual void SetAutoPanMargin( float aMargin )
{
m_autoPanMargin = aMargin;
};
/**
* Function AnimatedZoom
* // TODO
* 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.
*/
virtual void AnimatedZoom( const BOX2I& aExtents ) {};
virtual const VECTOR2D& GetMousePosition() const
{
return m_mousePosition;
}
virtual void WarpCursor (const VECTOR2D& aPosition ) {};
virtual void ShowCursor (bool aEnabled ) {};
/**
* 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 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:
/// 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

View File

@ -51,11 +51,11 @@ public:
~WX_VIEW_CONTROLS() {};
/// Handler functions
void onWheel( wxMouseEvent& aEvent );
void onMotion( wxMouseEvent& aEvent );
void onButton( wxMouseEvent& aEvent );
void onEnter( wxMouseEvent& aEvent );
void onTimer( wxTimerEvent& aEvent );
void onWheel( wxMouseEvent& aEvent );
void onMotion( wxMouseEvent& aEvent );
void onButton( wxMouseEvent& aEvent );
void onEnter( wxMouseEvent& WXUNUSED( aEvent ) );
void onTimer( wxTimerEvent& WXUNUSED( aEvent ) );
/**
* Function SetGrabMouse()
@ -63,18 +63,7 @@ public:
*
* @param aEnabled says whether the option should be enabled or disabled.
*/
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;
}
void SetGrabMouse( bool aEnabled );
/**
* Function SetAutoPan()
@ -82,36 +71,15 @@ public:
*
* @param aEnabled says whether the option should enabled or disabled.
*/
void SetAutoPan( bool aEnabled )
void SetAutoPan( bool aEnabled )
{
m_autoPanEnabled = aEnabled;
if( m_state == AUTO_PANNING )
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:
/// Possible states for WX_VIEW_CONTROLS
enum State {
IDLE = 1,
DRAG_PANNING,
@ -126,29 +94,11 @@ private:
* @return true if it is currently autopanning (ie. autopanning is active and mouse cursor
* is in the area that causes autopanning to happen).
*/
bool handleAutoPanning( const wxMouseEvent& aEvent );
bool handleAutoPanning( const wxMouseEvent& aEvent );
/// Current state of VIEW_CONTROLS
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
wxWindow* m_parentPanel;

View File

@ -39,7 +39,6 @@ protected:
// to the parent WORKSHEET_DATAITEM item,
// in page layout editor
protected:
WS_DRAW_ITEM_BASE( WORKSHEET_DATAITEM* aParent,
WS_DRAW_TYPE aType, EDA_COLOR_T aColor )
{
@ -53,8 +52,8 @@ public:
virtual ~WS_DRAW_ITEM_BASE() {}
// Accessors:
EDA_COLOR_T GetColor() { return m_color; }
WS_DRAW_TYPE GetType() { return m_type; };
EDA_COLOR_T GetColor() const { return m_color; }
WS_DRAW_TYPE GetType() const { return m_type; };
WORKSHEET_DATAITEM* GetParent() { return m_parent; }

View File

@ -174,6 +174,8 @@ public:
return m_Pcb;
}
void ViewReloadBoard( const BOARD* aBoard ) const;
// General
virtual void OnCloseWindow( wxCloseEvent& Event ) = 0;
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) { }
@ -671,6 +673,8 @@ public:
void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent );
void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent );
virtual void UseGalCanvas( bool aEnable );
DECLARE_EVENT_TABLE()
};

View File

@ -452,8 +452,6 @@ protected:
wxOverlay m_overlay;
#endif
protected:
void SetScreen( BASE_SCREEN* aScreen ) { m_currentScreen = aScreen; }
/**
@ -692,6 +690,12 @@ public:
*/
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
* redraws the screen with best zoom level and the best centering
@ -899,7 +903,7 @@ public:
*
* @param aEnable True for GAL-based canvas, false for standard canvas.
*/
void UseGalCanvas( bool aEnable );
virtual void UseGalCanvas( bool aEnable );
/**
* Function IsNewCanvasActive

View File

@ -221,6 +221,7 @@ set(PCBNEW_CLASS_SRCS
tools/selection_tool.cpp
tools/selection_area.cpp
tools/move_tool.cpp
tools/pcb_tools.cpp
)

View File

@ -293,7 +293,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
if( newList.GetCount() )
SaveCopyInUndoList( newList, UR_CHANGED );
m_canvas->Refresh();
RefreshCanvas();
}

View File

@ -136,71 +136,79 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
if( m_galCanvas )
{
KiGfx::VIEW* view = m_galCanvas->GetView();
view->Clear();
// All of PCB drawing elements should be added to the VIEW
// in order to be displayed
// Load zones
for( int i = 0; i < m_Pcb->GetAreaCount(); ++i )
{
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
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
{
view->Add( track );
}
// Load modules and its additional elements
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() )
{
// Load module's pads
for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
{
view->Add( pad );
}
// Load module's drawing (mostly silkscreen)
for( BOARD_ITEM* drawing = module->GraphicalItems().GetFirst(); drawing;
drawing = drawing->Next() )
{
view->Add( drawing );
}
// Load module's texts (name and value)
view->Add( &module->Reference() );
view->Add( &module->Value() );
// Add the module itself
view->Add( module );
}
// Segzones (equivalent of ZONE_CONTAINER for legacy boards)
for( SEGZONE* zone = m_Pcb->m_Zone; zone; zone = zone->Next() )
{
view->Add( zone );
}
view->RecacheAllItems( true );
if( m_galCanvasActive )
m_galCanvas->Refresh();
ViewReloadBoard( m_Pcb );
// update the tool manager with the new board and its view.
if( m_toolManager )
m_toolManager->SetEnvironment( m_Pcb, view, m_galCanvas->GetViewControls(), this );
}
}
void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
{
KiGfx::VIEW* view = m_galCanvas->GetView();
view->Clear();
// All of PCB drawing elements should be added to the VIEW
// in order to be displayed
// Load zones
for( int i = 0; i < aBoard->GetAreaCount(); ++i )
{
view->Add( (KiGfx::VIEW_ITEM*) ( aBoard->GetArea( i ) ) );
}
// Load drawings
for( BOARD_ITEM* drawing = aBoard->m_Drawings; drawing; drawing = drawing->Next() )
{
view->Add( drawing );
}
// Load tracks
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 );
}
// Load module's drawing (mostly silkscreen)
for( BOARD_ITEM* drawing = module->GraphicalItems().GetFirst(); drawing;
drawing = drawing->Next() )
{
view->Add( drawing );
}
// Load module's texts (name and value)
view->Add( &module->Reference() );
view->Add( &module->Value() );
// Add the module itself
view->Add( module );
}
// 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();
}
void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
{
wxASSERT( m_Pcb );
@ -431,7 +439,7 @@ void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
GetScreen()->m_Active_Layer = layer;
if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh();
RefreshCanvas();
}
@ -455,10 +463,7 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
settings->LoadDisplayOptions( DisplayOpt );
m_galCanvas->GetView()->RecacheAllItems( true );
if( IsGalCanvasActive() )
m_galCanvas->Refresh();
else
m_canvas->Refresh();
RefreshCanvas();
}
@ -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 )
{
int id = aEvent.GetId();
@ -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
// not show proper color when DisplayOpt.ContrastModeDisplay is true.
if( redraw && m_canvas)
m_canvas->Refresh();
if( redraw && m_canvas )
RefreshCanvas();
}
@ -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( 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->SetLayerTarget( ITEM_GAL_LAYER( SELECTION ), KiGfx::TARGET_OVERLAY );
view->SetLayerTarget( ITEM_GAL_LAYER( GP_OVERLAY ), KiGfx::TARGET_OVERLAY );
// Apply layer coloring scheme & display options

View File

@ -143,7 +143,7 @@ void MODULE::TransformGraphicShapesWithClearanceToPolygonSet(
break;
default:
D( printf( "Error: Shape %d not implemented!\n",
DBG( printf( "Error: Shape %d not implemented!\n",
outline->GetShape() ); )
break;
}

View File

@ -367,7 +367,7 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
if( aItem->Type() == PCB_MODULE_T )
if( ((MODULE*)aItem)->GetFlags() & MODULE_to_PLACE )
break;
m_canvas->Refresh();
RefreshCanvas();
#endif
case UR_MOVED:
case UR_FLIPPED:
@ -622,7 +622,7 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& event )
GetScreen()->PushCommandToRedoList( List );
OnModify();
m_canvas->Refresh();
RefreshCanvas();
}
@ -650,7 +650,7 @@ void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& event )
GetScreen()->PushCommandToUndoList( List );
OnModify();
m_canvas->Refresh();
RefreshCanvas();
}

View File

@ -495,7 +495,7 @@ void DIMENSION::ViewGetLayers( int aLayers[], int& aCount ) const
aLayers[0] = m_Layer;
// 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;
}

View File

@ -1028,5 +1028,5 @@ void MODULE::SetOrientation( double newangle )
void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 1;
aLayers[0] = ITEM_GAL_LAYER( GP_OVERLAY ); // Selection box
aLayers[0] = ITEM_GAL_LAYER( SELECTION ); // Selection box
}

View File

@ -346,7 +346,7 @@ void PCB_LAYER_WIDGET::OnLayerColorChange( LAYER_NUM aLayer, EDA_COLOR_T aColor
{
myframe->GetBoard()->SetLayerColor( aLayer, aColor );
myframe->ReCreateLayerBox( NULL );
myframe->GetCanvas()->Refresh();
myframe->RefreshCanvas();
}
@ -359,7 +359,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer )
if( m_alwaysShowActiveCopperLayer )
OnLayerSelected();
else if( DisplayOpt.ContrastModeDisplay )
myframe->GetCanvas()->Refresh();
myframe->RefreshCanvas();
return true;
}
@ -393,7 +393,7 @@ void PCB_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool is
brd->SetVisibleLayers( visibleLayers );
EDA_DRAW_PANEL_GAL *galCanvas = myframe->GetGalCanvas();
EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
if( galCanvas )
{
KiGfx::VIEW* view = galCanvas->GetView();
@ -401,18 +401,13 @@ void PCB_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool is
}
if( isFinal )
{
if( myframe->IsGalCanvasActive() )
galCanvas->Refresh();
else
myframe->GetCanvas()->Refresh();
}
myframe->RefreshCanvas();
}
void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, EDA_COLOR_T aColor )
{
myframe->GetBoard()->SetVisibleElementColor( aId, aColor );
myframe->GetCanvas()->Refresh();
myframe->RefreshCanvas();
}
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() )
galCanvas->Refresh();
else
myframe->GetCanvas()->Refresh();
myframe->RefreshCanvas();
}
//-----</LAYER_WIDGET callbacks>------------------------------------------

View File

@ -231,7 +231,7 @@ void TEXTE_PCB::ViewGetLayers( int aLayers[], int& aCount ) const
aLayers[0] = m_Layer;
// 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;
}

View File

@ -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 )
{
if( source == NULL )
@ -457,7 +473,7 @@ void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
}
// 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;
}

View File

@ -89,6 +89,15 @@ public:
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* Back() const { return (TEXTE_MODULE*) Pback; }

View File

@ -55,7 +55,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack )
{
LAYER_NUM previous_layer = getActiveLayer();
D( g_CurrentTrackList.VerifyListIntegrity(); )
DBG( g_CurrentTrackList.VerifyListIntegrity(); )
// Delete the current trace
ShowNewTrackWhenMovingCursor( m_canvas, DC, wxDefaultPosition, false );
@ -215,7 +215,7 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
next_track = tracksegment->Next();
tracksegment->SetState( BUSY, false );
D( std::cout << __func__ << ": track " << tracksegment << " status=" \
DBG( std::cout << __func__ << ": track " << tracksegment << " status=" \
<< TO_UTF8( TRACK::ShowState( tracksegment->GetStatus() ) ) \
<< std::endl; )

View File

@ -180,7 +180,7 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event)
if( m_Parent->IsGalCanvasActive() )
m_Parent->GetGalCanvas()->Refresh();
else
m_Parent->GetCanvas()->Refresh();
m_Parent->RefreshCanvas();
EndModal( 1 );
}

View File

@ -548,7 +548,7 @@ void DIALOG_DRC_CONTROL::OnUnconnectedSelectionEvent( wxCommandEvent& event )
void DIALOG_DRC_CONTROL::RedrawDrawPanel()
{
m_Parent->GetCanvas()->Refresh();
m_Parent->RefreshCanvas();
}

View File

@ -252,7 +252,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
wxArrayInt cols = m_cur_grid->GetSelectedCols();
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() )
{
@ -284,7 +284,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
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()
@ -353,7 +353,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
break;
case ID_PASTE:
D(printf( "paste\n" );)
DBG(printf( "paste\n" );)
// assume format came from a spreadsheet or us.
if( wxTheClipboard->Open() )
{
@ -471,7 +471,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
m_cur_grid->SetGridCursor( curRow, curCol );
}
D(printf("%s\n", __func__);)
DBG(printf("%s\n", __func__);)
}
void onCancelButtonClick( wxCommandEvent& event )
@ -522,7 +522,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE
m_cur_row = event.GetRow();
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
event.Skip();

View File

@ -185,7 +185,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
if( state && (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
Compile_Ratsnest( NULL, true );
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST:
@ -200,35 +200,35 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
DisplayOpt.DisplayZonesMode = 0;
recache = true;
if( !m_galCanvasActive )
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
DisplayOpt.DisplayZonesMode = 1;
recache = true;
if( !m_galCanvasActive )
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
DisplayOpt.DisplayZonesMode = 2;
recache = true;
if( !m_galCanvasActive )
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
m_DisplayViaFill = DisplayOpt.DisplayViaFill = !state;
recache = true;
if( !m_galCanvasActive )
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = !state;
recache = true;
if( !m_galCanvasActive )
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
@ -244,7 +244,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
if( m_galCanvasActive )
m_galCanvas->Refresh();
else
m_canvas->Refresh();
RefreshCanvas();
break;
}

View File

@ -182,7 +182,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
m_Parent->Compile_Ratsnest( NULL, true );
}
m_Parent->GetCanvas()->Refresh();
m_Parent->RefreshCanvas();
m_Parent->OnModify();
EndModal( 1 );

View File

@ -206,7 +206,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnOkClick( wxCommandEvent& event )
EndModal( 1 );
if( change )
m_Parent->GetCanvas()->Refresh();
m_Parent->RefreshCanvas();
}

View File

@ -136,7 +136,7 @@ void PCB_EDIT_FRAME::OnResetModuleTextSizes( wxCommandEvent& event )
DIALOG_GLOBAL_MODULES_FIELDS_EDITION dlg(this);
dlg.ShowModal();
m_canvas->Refresh();
RefreshCanvas();
}
void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,

View File

@ -104,7 +104,7 @@ void PCB_EDIT_FRAME::OnOrientFootprints( wxCommandEvent& event )
if( ReOrientModules( text, dlg.GetOrientation(), dlg.ApplyToLockedModules() ) )
{
m_canvas->Refresh();
RefreshCanvas();
Compile_Ratsnest( NULL, true );
}
}

View File

@ -216,7 +216,7 @@ bool PCB_BASE_FRAME::InvokeDialogGrid()
if( GetScreen()->GetGridId() == ID_POPUP_GRID_USER )
GetScreen()->SetGrid( ID_POPUP_GRID_USER );
m_canvas->Refresh();
RefreshCanvas();
return true;
}

View File

@ -2674,7 +2674,7 @@ LAYER_NUM EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
case 95: kiLayer = ECO1_N; break;
case 96: kiLayer = ECO2_N; break;
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
}
}

View File

@ -399,7 +399,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
GetDesignSettings().m_CurrentViaType = v_type;
if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh();
RefreshCanvas();
}
break;
@ -572,7 +572,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_FILL_ALL_ZONES:
m_canvas->MoveCursorToCrossHair();
Fill_All_Zones( this );
m_canvas->Refresh();
RefreshCanvas();
SetMsgPanel( GetBoard() );
break;
@ -584,7 +584,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
TestNetConnection( NULL, zone_container->GetNet() );
OnModify();
SetMsgPanel( GetBoard() );
m_canvas->Refresh();
RefreshCanvas();
}
SetCurItem( NULL );
break;
@ -604,7 +604,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
TestForActiveLinksInRatsnest( 0 ); // Recalculate the active ratsnest, i.e. the unconnected links
OnModify();
SetMsgPanel( GetBoard() );
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_POPUP_PCB_FILL_ZONE:
@ -612,7 +612,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
Fill_Zone( (ZONE_CONTAINER*) GetCurItem() );
TestNetConnection( NULL, ( (ZONE_CONTAINER*) GetCurItem() )->GetNet() );
SetMsgPanel( GetBoard() );
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_POPUP_PCB_MOVE_TEXTEPCB_REQUEST:
@ -1040,7 +1040,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
Delete_Drawings_All_Layer( GetCurItem()->GetLayer() );
SetCurItem( NULL );
m_canvas->MoveCursorToCrossHair();
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_POPUP_PCB_EDIT_DRAWING:
@ -1287,7 +1287,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
{
if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh();
RefreshCanvas();
}
// 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 )
setActiveLayer( layer );
if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh();
RefreshCanvas();
}

View File

@ -126,7 +126,7 @@ void PCB_EDIT_FRAME::Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
TextePcb->ClearFlags();
#ifdef USE_WX_OVERLAY
m_canvas->Refresh();
RefreshCanvas();
#endif
}
@ -144,7 +144,7 @@ void PCB_EDIT_FRAME::StartMoveTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC, bool aE
SetMsgPanel( aTextePcb );
#ifdef USE_WX_OVERLAY
m_canvas->Refresh();
RefreshCanvas();
#endif
GetScreen()->SetCrossHairPosition( aTextePcb->GetTextPosition() );
@ -257,7 +257,7 @@ void PCB_EDIT_FRAME::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC )
OnModify();
#ifdef USE_WX_OVERLAY
m_canvas->Refresh();
RefreshCanvas();
#endif
}
@ -281,6 +281,6 @@ void PCB_EDIT_FRAME::FlipTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC )
OnModify();
#ifdef USE_WX_OVERLAY
m_canvas->Refresh();
RefreshCanvas();
#endif
}

View File

@ -68,7 +68,7 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
#ifdef __WXMAC__
// If something edited, push a refresh request
if (retvalue == 0 || retvalue == 1)
m_canvas->Refresh();
RefreshCanvas();
#endif
if( retvalue == 2 )
@ -120,7 +120,7 @@ void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
case PCB_MODULE_EDGE_T:
Delete_Edge_Module( (EDGE_MODULE*) Item );
m_canvas->Refresh();
RefreshCanvas();
break;
case PCB_MODULE_T:

View File

@ -153,11 +153,11 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
GetBoard()->SetHighLightNet( zone->GetNet() );
}
D( g_CurrentTrackList.VerifyListIntegrity() );
DBG( g_CurrentTrackList.VerifyListIntegrity() );
BuildAirWiresTargetsList( LockPoint, wxPoint( 0, 0 ), true );
D( g_CurrentTrackList.VerifyListIntegrity() );
DBG( g_CurrentTrackList.VerifyListIntegrity() );
GetBoard()->HighLightON();
GetBoard()->DrawHighLight( m_canvas, aDC, GetBoard()->GetHighLightNetCode() );
@ -191,7 +191,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
// Create 2nd segment
g_CurrentTrackList.PushBack( (TRACK*)g_CurrentTrackSegment->Clone() );
D( g_CurrentTrackList.VerifyListIntegrity(); );
DBG( g_CurrentTrackList.VerifyListIntegrity(); );
g_CurrentTrackSegment->start = g_FirstTrackSegment;
g_FirstTrackSegment->end = g_CurrentTrackSegment;
@ -199,7 +199,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
g_FirstTrackSegment->SetState( BEGIN_ONPAD | END_ONPAD, false );
}
D( g_CurrentTrackList.VerifyListIntegrity(); );
DBG( g_CurrentTrackList.VerifyListIntegrity(); );
SetMsgPanel( g_CurrentTrackSegment );
SetCurItem( g_CurrentTrackSegment, false );
@ -246,11 +246,11 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
if( CanCreateNewSegment )
{
// Erase old track on screen
D( g_CurrentTrackList.VerifyListIntegrity(); );
DBG( g_CurrentTrackList.VerifyListIntegrity(); );
ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, false );
D( g_CurrentTrackList.VerifyListIntegrity(); );
DBG( g_CurrentTrackList.VerifyListIntegrity(); );
if( g_Raccord_45_Auto )
Add45DegreeSegment( aDC );
@ -273,7 +273,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
newTrack->start = previousTrack->end;
D( g_CurrentTrackList.VerifyListIntegrity(); );
DBG( g_CurrentTrackList.VerifyListIntegrity(); );
newTrack->SetStart( newTrack->GetEnd() );
@ -282,7 +282,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
if( !GetBoard()->GetDesignSettings().m_UseConnectedTrackWidth )
newTrack->SetWidth( GetBoard()->GetCurrentTrackWidth() );
D( g_CurrentTrackList.VerifyListIntegrity(); );
DBG( g_CurrentTrackList.VerifyListIntegrity(); );
// Show the new position
ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, false );
@ -422,7 +422,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC )
// Saving the coordinate of end point of the trace
wxPoint pos = g_CurrentTrackSegment->GetEnd();
D( g_CurrentTrackList.VerifyListIntegrity(); );
DBG( g_CurrentTrackList.VerifyListIntegrity(); );
if( Begin_Route( aTrack, aDC ) == NULL )
return false;
@ -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.
@ -670,7 +670,7 @@ inline void DrawViaCirclesWhenEditingNewTrack( EDA_RECT* aPanelClipBox,
void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
// D( g_CurrentTrackList.VerifyListIntegrity(); );
// DBG( g_CurrentTrackList.VerifyListIntegrity(); );
PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen();
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent();
@ -764,7 +764,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
}
// Redraw the new track
D( g_CurrentTrackList.VerifyListIntegrity(); );
DBG( g_CurrentTrackList.VerifyListIntegrity(); );
DrawTraces( aPanel, aDC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR );
if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )

View File

@ -349,7 +349,7 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC )
text->SetThickness( newThickness );
if( aDC )
m_canvas->Refresh();
RefreshCanvas();
OnModify();
}

View File

@ -118,5 +118,5 @@ void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event )
}*/
//+hp
//Refresh canvas, that we can see changes instantly. I use this because it dont,t throw mouse up-left corner.
m_canvas->Refresh();
RefreshCanvas();
}

View File

@ -117,7 +117,7 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
printf( "footprintWizard->GetModule() returns NULL\n" );
}
m_canvas->Refresh();
RefreshCanvas();
}

View File

@ -408,7 +408,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
ReCreateParameterList();
ReCreateHToolbar();
DisplayWizardInfos();
m_canvas->Refresh();
RefreshCanvas();
}
@ -506,7 +506,7 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event )
return;
ReCreateParameterList();
m_canvas->Refresh();
RefreshCanvas();
DisplayWizardInfos();
}

View File

@ -376,7 +376,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
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() ) );)
continue;
}
@ -393,7 +393,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
}
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()) ) );
continue;
}

View File

@ -357,7 +357,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
DisplayOpt.DisplayPcbTrackFill ^= 1;
DisplayOpt.DisplayPcbTrackFill &= 1;
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
m_canvas->Refresh();
RefreshCanvas();
break;
case HK_DELETE:
@ -454,7 +454,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
{
Other_Layer_Route( NULL, aDC );
if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh();
RefreshCanvas();
break;
}
@ -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
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;
}

View File

@ -542,7 +542,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
GetScreen()->GetCurItem()->ClearFlags();
if( ret > 0 )
m_canvas->Refresh();
RefreshCanvas();
}
break;
@ -572,7 +572,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->MoveCursorToCrossHair();
if( ret > 0 )
m_canvas->Refresh();
RefreshCanvas();
}
break;
@ -661,38 +661,38 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->MoveCursorToCrossHair();
if( edge )
m_canvas->Refresh();
RefreshCanvas();
}
break;
case ID_POPUP_MODEDIT_EDIT_BODY_ITEM :
m_canvas->MoveCursorToCrossHair();
InstallFootprintBodyItemPropertiesDlg( (EDGE_MODULE*) GetScreen()->GetCurItem() );
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_POPUP_MODEDIT_EDIT_WIDTH_CURRENT_EDGE:
m_canvas->MoveCursorToCrossHair();
Edit_Edge_Width( (EDGE_MODULE*) GetScreen()->GetCurItem() );
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE:
m_canvas->MoveCursorToCrossHair();
Edit_Edge_Width( NULL );
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_POPUP_MODEDIT_EDIT_LAYER_CURRENT_EDGE:
m_canvas->MoveCursorToCrossHair();
Edit_Edge_Layer( (EDGE_MODULE*) GetScreen()->GetCurItem() );
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE:
m_canvas->MoveCursorToCrossHair();
Edit_Edge_Layer( NULL );
m_canvas->Refresh();
RefreshCanvas();
break;
case ID_POPUP_PCB_DELETE_EDGE:
@ -775,7 +775,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
}
if( redraw )
m_canvas->Refresh();
RefreshCanvas();
}

View File

@ -97,13 +97,13 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
End_Edge_Module( (EDGE_MODULE*) item );
SetCurItem( NULL );
m_canvas->Refresh();
RefreshCanvas();
}
else if( ( (EDGE_MODULE*) item )->GetShape() == S_ARC )
{
End_Edge_Module( (EDGE_MODULE*) item );
SetCurItem( NULL );
m_canvas->Refresh();
RefreshCanvas();
}
else if( ( (EDGE_MODULE*) item )->GetShape() == S_SEGMENT )
{
@ -150,7 +150,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
// so deselect the active tool
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
SetCurItem( NULL );
m_canvas->Refresh();
RefreshCanvas();
}
break;
@ -436,7 +436,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
m_canvas->MoveCursorToCrossHair();
if( ret > 0 )
m_canvas->Refresh();
RefreshCanvas();
}
break;
@ -448,7 +448,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
case PCB_MODULE_EDGE_T :
m_canvas->MoveCursorToCrossHair();
InstallFootprintBodyItemPropertiesDlg( (EDGE_MODULE*) item );
m_canvas->Refresh();
RefreshCanvas();
break;
default:
@ -463,7 +463,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
{
End_Edge_Module( (EDGE_MODULE*) item );
SetCurItem( NULL );
m_canvas->Refresh();
RefreshCanvas();
}
break;

View File

@ -72,7 +72,7 @@ void FOOTPRINT_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
SetCurItem( NULL );
OnModify();
m_canvas->Refresh();
RefreshCanvas();
}
@ -101,5 +101,5 @@ void FOOTPRINT_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
SetCurItem( NULL );
OnModify();
m_canvas->Refresh();
RefreshCanvas();
}

View File

@ -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.
if( aDC )
m_canvas->Refresh();
RefreshCanvas();
return true;
}
@ -421,7 +421,7 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, wxDC* aDC, bool aDoNotRecreat
Compile_Ratsnest( aDC, true );
if( aDC )
m_canvas->Refresh();
RefreshCanvas();
SetMsgPanel( aModule );
}
@ -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
m_canvas->Refresh();
RefreshCanvas();
}
}

View File

@ -165,7 +165,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
SetCurItem( NULL );
Zoom_Automatique( false );
m_canvas->Refresh();
RefreshCanvas();
Update3D_Frame();
m_FootprintList->SetStringSelection( m_footprintName );
}

View File

@ -411,7 +411,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList()
ReCreateFootprintList();
ReCreateHToolbar();
DisplayLibInfos();
m_canvas->Refresh();
RefreshCanvas();
}
@ -477,7 +477,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& event )
m_libraryName = name;
ReCreateFootprintList();
m_canvas->Refresh();
RefreshCanvas();
DisplayLibInfos();
ReCreateHToolbar();
}
@ -525,7 +525,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
DisplayLibInfos();
Zoom_Automatique( false );
m_canvas->Refresh();
RefreshCanvas();
Update3D_Frame();
}
}

View File

@ -894,7 +894,7 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC )
if( current_net_code > 0 )
TestNetConnection( DC, current_net_code );
m_canvas->Refresh();
RefreshCanvas();
return true;
}

View File

@ -109,7 +109,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
// Rebuild the board connectivity:
Compile_Ratsnest( NULL, true );
SetMsgPanel( GetBoard() );
m_canvas->Refresh();
RefreshCanvas();
}

View File

@ -574,10 +574,40 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
break;
case PAD_RECT:
case PAD_TRAPEZOID:
m_gal->DrawRectangle( VECTOR2D( -size.x, -size.y ), VECTOR2D( size.x, size.y ) );
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:
m_gal->DrawCircle( VECTOR2D( 0.0, 0.0 ), size.x );
break;
@ -672,7 +702,7 @@ void PCB_PAINTER::draw( const MODULE* aModule )
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() )
drawSelectionBox( aText );
@ -696,7 +726,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* 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() )
drawSelectionBox( aText );
@ -790,7 +820,7 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone )
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() )
drawSelectionBox( aDimension );

View File

@ -335,7 +335,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
if( screenHeight <= 900 )
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
@ -792,11 +792,9 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
rSettings->SetActiveLayer( ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ) );
}
}
view->UpdateAllLayersOrder();
view->UpdateAllLayersColor();
if( m_galCanvasActive )
m_galCanvas->Refresh();
}
}

View File

@ -314,6 +314,9 @@ bool EDA_APP::OnInit()
frame->SetFocus();
frame->GetCanvas()->SetFocus();
// Activate the GAL
frame->UseGalCanvas( true );
return true;
}

View File

@ -243,7 +243,7 @@ void PCB_BASE_FRAME::SelectLayerPair()
// because the PAD_SMD pads may change color.
if( result >= 0 && DisplayOpt.ContrastModeDisplay )
{
m_canvas->Refresh();
RefreshCanvas();
}
}

View File

@ -601,7 +601,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
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
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 )
case S_RECT:
case S_ARC:
default:
D( printf( "makeIMAGE(): unsupported shape %s\n",
DBG( printf( "makeIMAGE(): unsupported shape %s\n",
TO_UTF8( BOARD_ITEM::ShowShape( (STROKE_T) graphic->GetShape() ) ) ); )
continue;
}
@ -908,7 +908,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
}
else // remove graphics not on EDGE_N layer
{
D( items[i]->Show( 0, std::cout );)
DBG( items[i]->Show( 0, std::cout );)
++i;
}
}

188
pcbnew/tools/move_tool.cpp Normal file
View File

@ -0,0 +1,188 @@
/*
* 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 );
}

113
pcbnew/tools/move_tool.h Normal file
View File

@ -0,0 +1,113 @@
/*
* 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

View File

@ -35,6 +35,7 @@
#include <pcbnew_id.h>
#include "selection_tool.h"
#include "move_tool.h"
#include <router/router_tool.h>
void PCB_EDIT_FRAME::setupTools()
@ -47,6 +48,7 @@ void PCB_EDIT_FRAME::setupTools()
// register our selection tool.
m_toolManager->RegisterTool( new SELECTION_TOOL );
m_toolManager->RegisterTool( new ROUTER_TOOL );
m_toolManager->RegisterTool( new MOVE_TOOL );
}

View File

@ -28,6 +28,7 @@
#include <class_drawpanel_gal.h>
#include <class_board.h>
#include <class_board_item.h>
#include <class_track.h>
#include <class_module.h>
#include <wxPcbStruct.h>
@ -43,7 +44,7 @@ using namespace KiGfx;
using boost::optional;
SELECTION_TOOL::SELECTION_TOOL() :
TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" )
TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ), m_multiple( false )
{
m_selArea = new SELECTION_AREA;
}
@ -68,6 +69,11 @@ void SELECTION_TOOL::Reset()
int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
{
bool dragging = false;
bool allowMultiple = true;
BOARD* board = getModel<BOARD>( PCB_T );
if( !board )
return 0;
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
@ -86,6 +92,10 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
if( evt->IsClick( MB_Left ) )
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
if( evt->IsDrag( MB_Left ) )
{
@ -96,14 +106,14 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
{
// If nothings has been selected or user wants to select more
// draw the selection box
selectMultiple();
if( allowMultiple )
allowMultiple = !selectMultiple();
}
else
{
// Now user wants to drag the selected items
m_toolMgr->InvokeTool( "pcbnew.InteractiveMove" );
}
}
else if( dragging )
{
@ -131,8 +141,12 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
if( !m_additive )
clearSelection();
aItem->SetSelected();
m_selectedItems.insert( aItem );
// Prevent selection of invisible items
if( selectable( aItem ) )
{
aItem->SetSelected();
m_selectedItems.insert( aItem );
}
}
}
@ -214,22 +228,25 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector
}
void SELECTION_TOOL::handleHighlight( const VECTOR2D& aP )
{
}
void SELECTION_TOOL::selectMultiple()
bool SELECTION_TOOL::selectMultiple()
{
OPT_TOOL_EVENT evt;
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 );
while( evt = Wait() )
{
if( evt->IsCancel() )
{
cancelled = true;
break;
}
if( evt->IsDrag( MB_Left ) )
{
@ -258,19 +275,21 @@ void SELECTION_TOOL::selectMultiple()
{
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first );
// Add only those items which are fully within a selection box
if( selectionBox.Contains( item->ViewBBox() ) )
// Add only those items which are visible and fully within the selection box
if( selectable( item ) && selectionBox.Contains( item->ViewBBox() ) )
{
item->SetSelected();
m_selectedItems.insert( item );
}
}
break;
}
}
v->Remove( m_selArea );
m_multiple = false;
return cancelled;
}
@ -331,3 +350,54 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
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() );
}

View File

@ -35,7 +35,6 @@ class SELECTION_AREA;
class BOARD_ITEM;
class GENERAL_COLLECTOR;
/**
* Class SELECTION_TOOL
*
@ -43,8 +42,6 @@ class GENERAL_COLLECTOR;
* - pick single objects (click LMB)
* - add objects to existing selection (Shift+LMB)
* - draw selection box (drag LMB)
*
* WORK IN PROGRESS. CONSIDER AS A DEMO!
*/
class SELECTION_TOOL : public TOOL_INTERACTIVE
@ -53,26 +50,101 @@ public:
SELECTION_TOOL();
~SELECTION_TOOL();
/**
* Function Reset()
*
* Initializes the selection tool.
*/
void Reset();
/**
* Function Main()
*
* The main loop.
*/
int Main( TOOL_EVENT& aEvent );
/**
* Function GetSelection()
*
* Returns the set of currently selected items.
*/
const std::set<BOARD_ITEM*>& GetSelection() const
{
return m_selectedItems;
}
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 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 );
/**
* 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 );
/**
* Function toggleSelection()
* Changes selection status of a given item.
*
* @param aItem is the item to have selection status changed.
*/
void toggleSelection( BOARD_ITEM* aItem );
/**
* Function clearSelection()
* Clears selections of currently selected items.
*/
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;
/// Visual representation of selection area
SELECTION_AREA* m_selArea;
/// Menu shown in case of selection ambiguity
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;
/// Flag saying if multiple selection mode is active
bool m_multiple;
};
#endif

View File

@ -281,7 +281,7 @@ void DIALOG_EXCHANGE_MODULE::Change_Current_Module()
if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
m_Parent->Compile_Ratsnest( NULL, true );
m_Parent->GetCanvas()->Refresh();
m_Parent->RefreshCanvas();
}
if( pickList.GetCount() )
@ -370,7 +370,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
m_Parent->Compile_Ratsnest( NULL, true );
m_Parent->GetCanvas()->Refresh();
m_Parent->RefreshCanvas();
}
if( pickList.GetCount() )
@ -423,7 +423,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
if( m_Parent->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
m_Parent->Compile_Ratsnest( NULL, true );
m_Parent->GetCanvas()->Refresh();
m_Parent->RefreshCanvas();
}
if( pickList.GetCount() )

View File

@ -333,7 +333,7 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER*
// Combine zones if possible
wxBusyCursor dummy;
GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
m_canvas->Refresh();
RefreshCanvas();
int ii = GetBoard()->GetAreaIndex( aZone ); // test if aZone exists

View File

@ -80,7 +80,7 @@ void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, time_t aTimestamp )
if( modify )
{
OnModify();
m_canvas->Refresh();
RefreshCanvas();
}
}