From 6405273059d431f61131516cc1f0e5318644606d Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 3 Sep 2013 13:51:53 +0200 Subject: [PATCH 01/25] Support for trapezoidal pads. --- pcbnew/pcb_painter.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 36ab6588ee..59da4f9770 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -570,10 +570,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 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; From 446a0a174e06d119c0babfe514b08c62412059de Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 3 Sep 2013 14:15:37 +0200 Subject: [PATCH 02/25] Module texts are now moveable, rotatable and flippable. --- pcbnew/class_text_mod.cpp | 16 ++++++++++++++++ pcbnew/class_text_mod.h | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index d84cac4860..37b9a63c3c 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -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 ) diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index 635cef14de..b693298159 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -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; } From 1a1416aaa401f667e83f63755f7648b60ecf1fbb Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 3 Sep 2013 17:46:05 +0200 Subject: [PATCH 03/25] Fixed Cairo's render target setting. --- common/gal/cairo/cairo_gal.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/common/gal/cairo/cairo_gal.cpp b/common/gal/cairo/cairo_gal.cpp index 4ed047b24c..d66a2cb725 100644 --- a/common/gal/cairo/cairo_gal.cpp +++ b/common/gal/cairo/cairo_gal.cpp @@ -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; } From 55dddb69f721b48c959485d620d057d1d19ab13b Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 4 Sep 2013 10:56:06 +0200 Subject: [PATCH 04/25] Improved selection rules. Added some comments to the selection tool. --- pcbnew/tools/selection_tool.cpp | 59 +++++++++++++++++++++---- pcbnew/tools/selection_tool.h | 78 +++++++++++++++++++++++++++++++-- 2 files changed, 124 insertions(+), 13 deletions(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 198541afca..d1b702244b 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -68,6 +69,10 @@ void SELECTION_TOOL::Reset() int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) { bool dragging = false; + m_board = static_cast( m_toolMgr->GetEditFrame() )->GetBoard(); + + if( !m_board ) + return 0; // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) @@ -131,8 +136,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,11 +223,6 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector } -void SELECTION_TOOL::handleHighlight( const VECTOR2D& aP ) -{ -} - - void SELECTION_TOOL::selectMultiple() { OPT_TOOL_EVENT evt; @@ -258,8 +262,8 @@ void SELECTION_TOOL::selectMultiple() { BOARD_ITEM* item = static_cast( 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 ); @@ -331,3 +335,40 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) return NULL; } + + +bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const +{ + 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( aItem )->ReturnLayerPair( &top, &bottom ); + + return ( m_board->IsLayerVisible( top ) || + m_board->IsLayerVisible( bottom ) ); + } + break; + + case PCB_PAD_T: + // Pads are supposed to be on top, bottom or both at the same time (THT) + if( aItem->IsOnLayer( LAYER_N_FRONT ) && m_board->IsLayerVisible( LAYER_N_FRONT ) ) + return true; + + if( aItem->IsOnLayer( LAYER_N_BACK ) && m_board->IsLayerVisible( LAYER_N_BACK ) ) + return true; + + 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 + return m_board->IsLayerVisible( aItem->GetLayer() ); +} diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index 6d485395fa..7a59d31921 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -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,25 +50,98 @@ 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& 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 ); + + /** + * Function selectMultiple() + * Handles drawing a selection box that allows to select many items at the same time. + */ void selectMultiple(); - void handleHighlight( const VECTOR2D& aP ); + + /** + * 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 ) const; + + /// Currently used PCB + BOARD* m_board; + + /// Container storing currently selected items std::set m_selectedItems; + + /// Visual representation of selection area SELECTION_AREA* m_selArea; + + /// Menu shown in case of selection ambiguity boost::shared_ptr m_menu; + + /// Flag saying if items should be added to the current selection or rather replace it bool m_additive; }; From 9a032e742264679f8eb228ba05fed498b1b84664 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 4 Sep 2013 16:18:37 +0200 Subject: [PATCH 05/25] Moved selection marking boxes to a different layer. --- include/layers_id_colors_and_visibility.h | 3 ++- pcbnew/basepcbframe.cpp | 1 + pcbnew/class_dimension.cpp | 2 +- pcbnew/class_module.cpp | 2 +- pcbnew/class_pcb_text.cpp | 2 +- pcbnew/class_text_mod.cpp | 2 +- pcbnew/pcb_painter.cpp | 6 +++--- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index bb1b13a243..3ab011d3b5 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -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, diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 1308addc82..1c4c6a65e1 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -831,6 +831,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 diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 6cd8c58bec..c6dab49476 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -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; } diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index cf61f31493..0b68f61e64 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -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 } diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index 2ce86606aa..15920fa968 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -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; } diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 37b9a63c3c..e4f28f31b1 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -473,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; } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 59da4f9770..45841207ed 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -698,7 +698,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 ); @@ -722,7 +722,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 ); @@ -816,7 +816,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 ); From a1089c9dd68c1ed57d8b797bf4ec6264c3b98ef3 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 4 Sep 2013 16:23:26 +0200 Subject: [PATCH 06/25] More effective way of updating bounding boxes. IsCached() method made public. Removed some of unused fields from the layer description structure. --- common/view/view.cpp | 44 ++++++++++++++++++++++++++++++-------------- include/view/view.h | 19 ++++++++++--------- 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/common/view/view.cpp b/common/view/view.cpp index 4fcd86b9ba..72d8cf79c7 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -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,7 +909,7 @@ 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 ); diff --git a/include/view/view.h b/include/view/view.h index 4ad11828f5..d5a1b9348c 100644 --- a/include/view/view.h +++ b/include/view/view.h @@ -423,6 +423,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 +439,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 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 requiredLayers; ///* layers that are required to be enabled to show the layer }; @@ -515,6 +519,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 +531,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; From 7e4eba9eed1097bdd65ce641dbeee01700270bf7 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 4 Sep 2013 16:25:57 +0200 Subject: [PATCH 07/25] Some comments. --- common/gal/opengl/opengl_compositor.cpp | 3 ++- common/tool/tool_manager.cpp | 5 +++-- include/tool/tool_manager.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common/gal/opengl/opengl_compositor.cpp b/common/gal/opengl/opengl_compositor.cpp index 3485131aa7..0a212af554 100644 --- a/common/gal/opengl/opengl_compositor.cpp +++ b/common/gal/opengl/opengl_compositor.cpp @@ -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; diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 1601b7aece..03250f8fff 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -207,9 +207,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 ); } @@ -258,6 +258,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() ); diff --git a/include/tool/tool_manager.h b/include/tool/tool_manager.h index 765e5cd606..f0830263de 100644 --- a/include/tool/tool_manager.h +++ b/include/tool/tool_manager.h @@ -154,7 +154,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() { From 7716d4592d425e276eff0d007b146723fcfd2611 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 6 Sep 2013 10:19:53 +0200 Subject: [PATCH 08/25] Fixed hotkeys for switching rendering backends. --- pcbnew/hotkeys_board_editor.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 0a155643f4..691346005a 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -540,6 +540,18 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit DisplayOpt.ContrastModeDisplay = !DisplayOpt.ContrastModeDisplay; m_canvas->Refresh(); 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; } if( evt_type != 0 ) From 345e97f2961484ead8b8bab9301b57f8ca7be59d Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 6 Sep 2013 11:31:16 +0200 Subject: [PATCH 09/25] Solved refreshing issues. --- common/dialogs/dialog_page_settings.cpp | 2 +- common/drawframe.cpp | 7 ++--- common/view/view.cpp | 2 +- common/view/view_group.cpp | 28 ++++++++----------- common/zoom.cpp | 15 ++++++++-- include/view/view.h | 15 ++++++++-- include/wxstruct.h | 8 ++++-- pcbnew/autorouter/automove.cpp | 2 +- pcbnew/basepcbframe.cpp | 11 +++----- pcbnew/board_undo_redo.cpp | 6 ++-- pcbnew/class_pcb_layer_widget.cpp | 10 +++---- pcbnew/dialogs/dialog_display_options.cpp | 2 +- pcbnew/dialogs/dialog_drc.cpp | 2 +- pcbnew/dialogs/dialog_general_options.cpp | 14 +++++----- pcbnew/dialogs/dialog_global_deletion.cpp | 2 +- .../dialog_global_edit_tracks_and_vias.cpp | 2 +- .../dialog_global_modules_fields_edition.cpp | 2 +- pcbnew/dialogs/dialog_orient_footprints.cpp | 2 +- pcbnew/dialogs/dialog_set_grid.cpp | 2 +- pcbnew/edit.cpp | 16 +++++------ pcbnew/edit_pcb_text.cpp | 8 +++--- pcbnew/editmod.cpp | 4 +-- pcbnew/edtxtmod.cpp | 2 +- pcbnew/event_handlers_tracks_vias_sizes.cpp | 2 +- pcbnew/footprint_wizard.cpp | 2 +- pcbnew/footprint_wizard_frame.cpp | 4 +-- pcbnew/hotkeys_board_editor.cpp | 6 ++-- pcbnew/modedit.cpp | 18 ++++++------ pcbnew/modedit_onclick.cpp | 12 ++++---- pcbnew/modedit_undo_redo.cpp | 4 +-- pcbnew/modules.cpp | 6 ++-- pcbnew/modview.cpp | 2 +- pcbnew/modview_frame.cpp | 6 ++-- pcbnew/move_or_drag_track.cpp | 2 +- pcbnew/netlist.cpp | 2 +- pcbnew/pcbframe.cpp | 4 +-- pcbnew/sel_layer.cpp | 2 +- pcbnew/xchgmod.cpp | 6 ++-- pcbnew/zones_by_polygon.cpp | 2 +- pcbnew/zones_by_polygon_fill_functions.cpp | 2 +- 40 files changed, 128 insertions(+), 118 deletions(-) diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index 7ab002480b..961024e065 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -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 ); diff --git a/common/drawframe.cpp b/common/drawframe.cpp index a38908e970..a8857896c2 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -235,12 +235,9 @@ void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent ) { SetGridVisibility( !IsGridVisible() ); if( m_galCanvasActive ) - { m_galCanvas->GetGAL()->SetGridVisibility( IsGridVisible() ); - m_galCanvas->Refresh(); - } - else - m_canvas->Refresh(); + + RefreshCanvas(); } diff --git a/common/view/view.cpp b/common/view/view.cpp index 72d8cf79c7..f8ba2db28f 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -915,7 +915,7 @@ void VIEW::RecacheAllItems( bool aImmediately ) m_gal->SetLayerDepth( l->renderingOrder ); recacheLayer visitor( this, m_gal, l->id, aImmediately ); l->items->Query( r, visitor ); - l->isDirty = false; + l->isDirty = true; } } diff --git a/common/view/view_group.cpp b/common/view/view_group.cpp index f7ff19da96..3b740e01b5 100644 --- a/common/view/view_group.cpp +++ b/common/view/view_group.cpp @@ -82,15 +82,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; } @@ -107,31 +101,33 @@ 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; } -void VIEW_GROUP::ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw ) +/*void VIEW_GROUP::ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw ) { BOOST_FOREACH( VIEW_ITEM* item, m_items ) { item->ViewUpdate( aUpdateFlags, aForceImmediateRedraw ); } -} +}*/ void VIEW_GROUP::updateBbox() diff --git a/common/zoom.cpp b/common/zoom.cpp index a537256eea..9e1175c3b8 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -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: diff --git a/include/view/view.h b/include/view/view.h index d5a1b9348c..f5eb6b13ca 100644 --- a/include/view/view.h +++ b/include/view/view.h @@ -262,15 +262,24 @@ 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; } + /** + * 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; + } + /** * Function SetLayerTarget() * Changes the rendering target for a particular layer. diff --git a/include/wxstruct.h b/include/wxstruct.h index 938e15c24b..76e5987b50 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -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 diff --git a/pcbnew/autorouter/automove.cpp b/pcbnew/autorouter/automove.cpp index 401b7d8606..cd8e191927 100644 --- a/pcbnew/autorouter/automove.cpp +++ b/pcbnew/autorouter/automove.cpp @@ -293,7 +293,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) if( newList.GetCount() ) SaveCopyInUndoList( newList, UR_CHANGED ); - m_canvas->Refresh(); + RefreshCanvas(); } diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 1c4c6a65e1..bd5e71781a 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -431,7 +431,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 +455,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(); } @@ -625,8 +622,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(); } diff --git a/pcbnew/board_undo_redo.cpp b/pcbnew/board_undo_redo.cpp index 88cfaa49b1..1b132fa1a2 100644 --- a/pcbnew/board_undo_redo.cpp +++ b/pcbnew/board_undo_redo.cpp @@ -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(); } diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp index 54fb33d740..3ac5b7f640 100644 --- a/pcbnew/class_pcb_layer_widget.cpp +++ b/pcbnew/class_pcb_layer_widget.cpp @@ -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; } @@ -405,14 +405,14 @@ void PCB_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool is 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 +430,7 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled ) if( myframe->IsGalCanvasActive() ) galCanvas->Refresh(); else - myframe->GetCanvas()->Refresh(); + myframe->RefreshCanvas(); } //----------------------------------------------- diff --git a/pcbnew/dialogs/dialog_display_options.cpp b/pcbnew/dialogs/dialog_display_options.cpp index 8b44757d90..4f5fb1cbea 100644 --- a/pcbnew/dialogs/dialog_display_options.cpp +++ b/pcbnew/dialogs/dialog_display_options.cpp @@ -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 ); } diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index d65d497784..0a779540b3 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -548,7 +548,7 @@ void DIALOG_DRC_CONTROL::OnUnconnectedSelectionEvent( wxCommandEvent& event ) void DIALOG_DRC_CONTROL::RedrawDrawPanel() { - m_Parent->GetCanvas()->Refresh(); + m_Parent->RefreshCanvas(); } diff --git a/pcbnew/dialogs/dialog_general_options.cpp b/pcbnew/dialogs/dialog_general_options.cpp index 3c86cd8d4a..37854ac88f 100644 --- a/pcbnew/dialogs/dialog_general_options.cpp +++ b/pcbnew/dialogs/dialog_general_options.cpp @@ -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; } diff --git a/pcbnew/dialogs/dialog_global_deletion.cpp b/pcbnew/dialogs/dialog_global_deletion.cpp index cce6a7b4b5..3048f5b7c0 100644 --- a/pcbnew/dialogs/dialog_global_deletion.cpp +++ b/pcbnew/dialogs/dialog_global_deletion.cpp @@ -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 ); diff --git a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp index b5114a0ce8..8fd7b9f040 100644 --- a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp +++ b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp @@ -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(); } diff --git a/pcbnew/dialogs/dialog_global_modules_fields_edition.cpp b/pcbnew/dialogs/dialog_global_modules_fields_edition.cpp index aa8f2c9186..55fa8efdc7 100644 --- a/pcbnew/dialogs/dialog_global_modules_fields_edition.cpp +++ b/pcbnew/dialogs/dialog_global_modules_fields_edition.cpp @@ -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, diff --git a/pcbnew/dialogs/dialog_orient_footprints.cpp b/pcbnew/dialogs/dialog_orient_footprints.cpp index 4c6dd832d5..20b31aab44 100644 --- a/pcbnew/dialogs/dialog_orient_footprints.cpp +++ b/pcbnew/dialogs/dialog_orient_footprints.cpp @@ -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 ); } } diff --git a/pcbnew/dialogs/dialog_set_grid.cpp b/pcbnew/dialogs/dialog_set_grid.cpp index 36527c6df6..5c37f16f5c 100644 --- a/pcbnew/dialogs/dialog_set_grid.cpp +++ b/pcbnew/dialogs/dialog_set_grid.cpp @@ -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; } diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 0a2fb5434f..47e60041ba 100755 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -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(); } diff --git a/pcbnew/edit_pcb_text.cpp b/pcbnew/edit_pcb_text.cpp index c7a62aaa01..72901a5a56 100644 --- a/pcbnew/edit_pcb_text.cpp +++ b/pcbnew/edit_pcb_text.cpp @@ -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 } diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp index 1f217d6194..9f4e01a7f0 100644 --- a/pcbnew/editmod.cpp +++ b/pcbnew/editmod.cpp @@ -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: diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp index 01869ae06f..4da20c4956 100644 --- a/pcbnew/edtxtmod.cpp +++ b/pcbnew/edtxtmod.cpp @@ -349,7 +349,7 @@ void PCB_BASE_FRAME::ResetTextSize( BOARD_ITEM* aItem, wxDC* aDC ) text->SetThickness( newThickness ); if( aDC ) - m_canvas->Refresh(); + RefreshCanvas(); OnModify(); } diff --git a/pcbnew/event_handlers_tracks_vias_sizes.cpp b/pcbnew/event_handlers_tracks_vias_sizes.cpp index 52428a3834..33f975b07c 100644 --- a/pcbnew/event_handlers_tracks_vias_sizes.cpp +++ b/pcbnew/event_handlers_tracks_vias_sizes.cpp @@ -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(); } diff --git a/pcbnew/footprint_wizard.cpp b/pcbnew/footprint_wizard.cpp index 75560423a0..451d7964dc 100644 --- a/pcbnew/footprint_wizard.cpp +++ b/pcbnew/footprint_wizard.cpp @@ -117,7 +117,7 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint() printf( "footprintWizard->GetModule() returns NULL\n" ); } - m_canvas->Refresh(); + RefreshCanvas(); } diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 73fe27b054..c48e6ebcf2 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -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(); } diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 691346005a..30b07f55b2 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -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,7 @@ 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: diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index fb1b5f1035..e8fb7e2bba 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -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(); } diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index 4628f1ba80..07f9fd35ab 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -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; diff --git a/pcbnew/modedit_undo_redo.cpp b/pcbnew/modedit_undo_redo.cpp index 5e1fc518cc..8d4fea8620 100644 --- a/pcbnew/modedit_undo_redo.cpp +++ b/pcbnew/modedit_undo_redo.cpp @@ -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(); } diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index f19e944a9b..edaae23008 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -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(); } } diff --git a/pcbnew/modview.cpp b/pcbnew/modview.cpp index 2fb378ef84..bfeed514cc 100644 --- a/pcbnew/modview.cpp +++ b/pcbnew/modview.cpp @@ -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 ); } diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index a051ea942d..5ec3ed8ae2 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -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(); } } diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 877edfcd03..82f9cac46f 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -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; } diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index 5b40506808..f358c5fcc6 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -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(); } diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index fe9e5ee01d..7e29efb5ed 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -790,11 +790,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(); } } diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp index 5e265a26dc..e2e524beb2 100644 --- a/pcbnew/sel_layer.cpp +++ b/pcbnew/sel_layer.cpp @@ -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(); } } diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index 32ee549465..67bb2edb3a 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -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() ) diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 9effa3977c..8973ffccb3 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -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 diff --git a/pcbnew/zones_by_polygon_fill_functions.cpp b/pcbnew/zones_by_polygon_fill_functions.cpp index 61324cb6c7..2697f03e6e 100644 --- a/pcbnew/zones_by_polygon_fill_functions.cpp +++ b/pcbnew/zones_by_polygon_fill_functions.cpp @@ -80,7 +80,7 @@ void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, time_t aTimestamp ) if( modify ) { OnModify(); - m_canvas->Refresh(); + RefreshCanvas(); } } From 6054e7be0abd6c765bd975d71a2169a180944383 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 6 Sep 2013 16:01:46 +0200 Subject: [PATCH 10/25] Added a few comments. --- common/tool/tool_dispatcher.cpp | 3 +-- include/tool/tool_manager.h | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/common/tool/tool_dispatcher.cpp b/common/tool/tool_dispatcher.cpp index 89da297fa9..d87a7248fd 100644 --- a/common/tool/tool_dispatcher.cpp +++ b/common/tool/tool_dispatcher.cpp @@ -155,7 +155,6 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti } else isClick = true; - if( isClick ) { @@ -256,7 +255,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) } -void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent &aEvent ) +void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent& aEvent ) { bool activateTool = false; std::string toolName; diff --git a/include/tool/tool_manager.h b/include/tool/tool_manager.h index f0830263de..cfafb609c0 100644 --- a/include/tool/tool_manager.h +++ b/include/tool/tool_manager.h @@ -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 ); From bc67fc338e8219f45b7acb5aeee1560f331a0b47 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 6 Sep 2013 16:04:12 +0200 Subject: [PATCH 11/25] Smarter selection algorithm (does not allow to select both whole MODULE and its parts at the same time). Cancel event works better (selection box does not appear after cancelling the selection tool). Removed blinking selection box effect. Model is accessed in more appropriate way (getModel() method). --- pcbnew/tools/selection_tool.cpp | 63 ++++++++++++++++++++++++++------- pcbnew/tools/selection_tool.h | 13 ++++--- 2 files changed, 60 insertions(+), 16 deletions(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index d1b702244b..c1a68a1914 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -69,9 +69,10 @@ void SELECTION_TOOL::Reset() int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) { bool dragging = false; - m_board = static_cast( m_toolMgr->GetEditFrame() )->GetBoard(); + bool allowMultiple = true; + BOARD* board = getModel( PCB_T ); - if( !m_board ) + if( !board ) return 0; // Main loop: keep receiving events @@ -91,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 ) ) { @@ -101,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 ) { @@ -223,17 +228,24 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector } -void SELECTION_TOOL::selectMultiple() +bool SELECTION_TOOL::selectMultiple() { OPT_TOOL_EVENT evt; VIEW* v = getView(); + bool cancelled = false; + // 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 ) ) { @@ -269,12 +281,15 @@ void SELECTION_TOOL::selectMultiple() m_selectedItems.insert( item ); } } + handleModules(); break; } } v->Remove( m_selArea ); + + return cancelled; } @@ -337,8 +352,10 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) } -bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const +bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) { + BOARD* board = getModel( PCB_T ); + switch( aItem->Type() ) { case PCB_VIA_T: @@ -347,17 +364,17 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const LAYER_NUM top, bottom; static_cast( aItem )->ReturnLayerPair( &top, &bottom ); - return ( m_board->IsLayerVisible( top ) || - m_board->IsLayerVisible( bottom ) ); + return ( board->IsLayerVisible( top ) || + board->IsLayerVisible( bottom ) ); } break; case PCB_PAD_T: // Pads are supposed to be on top, bottom or both at the same time (THT) - if( aItem->IsOnLayer( LAYER_N_FRONT ) && m_board->IsLayerVisible( LAYER_N_FRONT ) ) + if( aItem->IsOnLayer( LAYER_N_FRONT ) && board->IsLayerVisible( LAYER_N_FRONT ) ) return true; - if( aItem->IsOnLayer( LAYER_N_BACK ) && m_board->IsLayerVisible( LAYER_N_BACK ) ) + if( aItem->IsOnLayer( LAYER_N_BACK ) && board->IsLayerVisible( LAYER_N_BACK ) ) return true; return false; @@ -369,6 +386,28 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const break; } - // All other items - return m_board->IsLayerVisible( aItem->GetLayer() ); + // All other items are selected only if the layer on which they exist is visible + return board->IsLayerVisible( aItem->GetLayer() ); +} + + +void SELECTION_TOOL::handleModules() +{ + std::set::iterator it, it_end; + + for( it = m_selectedItems.begin(), it_end = m_selectedItems.end(); it != it_end; ) + { + BOARD_ITEM* parent = (*it)->GetParent(); + + // Do not allow to select MODULE and it's parts at the same time + if( parent != NULL && parent->IsSelected() ) + { + (*it)->ClearSelected(); + m_selectedItems.erase( it++ ); + } + else + { + ++it; + } + } } diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index 7a59d31921..e198542b78 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -87,8 +87,10 @@ private: /** * 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). */ - void selectMultiple(); + bool selectMultiple(); /** * Function disambiguationMenu() @@ -127,10 +129,13 @@ private: * * @return True if the item fulfills conditions to be selected. */ - bool selectable( const BOARD_ITEM* aItem ) const; + bool selectable( const BOARD_ITEM* aItem ); - /// Currently used PCB - BOARD* m_board; + /** + * Prevents from selecting both MODULEs and it's parts at the same time. The right way is + * to select a MODULE *or* some of it's parts. + */ + void handleModules(); /// Container storing currently selected items std::set m_selectedItems; From 7e73dad7b05de911eaa9317a4585f4e9238310e7 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 6 Sep 2013 17:06:02 +0200 Subject: [PATCH 12/25] Some more spots where the GAL refresh was required. --- common/drawframe.cpp | 15 +++++++++++---- include/view/view.h | 7 ++++++- pcbnew/class_pcb_layer_widget.cpp | 9 ++------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/common/drawframe.cpp b/common/drawframe.cpp index a8857896c2..88f73d7c44 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -234,8 +234,12 @@ void EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent() void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent ) { SetGridVisibility( !IsGridVisible() ); + if( m_galCanvasActive ) + { m_galCanvas->GetGAL()->SetGridVisibility( IsGridVisible() ); + m_galCanvas->GetView()->MarkTargetDirty( KiGfx::TARGET_NONCACHED ); + } RefreshCanvas(); } @@ -392,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(); } @@ -1011,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(); } diff --git a/include/view/view.h b/include/view/view.h index f5eb6b13ca..29cb5ecb0e 100644 --- a/include/view/view.h +++ b/include/view/view.h @@ -267,7 +267,12 @@ public: */ 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; + } } /** diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp index 3ac5b7f640..07b46f4fa9 100644 --- a/pcbnew/class_pcb_layer_widget.cpp +++ b/pcbnew/class_pcb_layer_widget.cpp @@ -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,12 +401,7 @@ void PCB_LAYER_WIDGET::OnLayerVisible( LAYER_NUM aLayer, bool isVisible, bool is } if( isFinal ) - { - if( myframe->IsGalCanvasActive() ) - galCanvas->Refresh(); - else - myframe->RefreshCanvas(); - } + myframe->RefreshCanvas(); } void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, EDA_COLOR_T aColor ) From cbbc2f42e8d004aa268b2347d47c64dae5fdcf82 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 6 Sep 2013 17:06:33 +0200 Subject: [PATCH 13/25] Starts the GAL by default. --- pcbnew/pcbnew.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 061f465d4a..285a0ba1d5 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -314,6 +314,9 @@ bool EDA_APP::OnInit() frame->SetFocus(); frame->GetCanvas()->SetFocus(); + // Activate the GAL + frame->UseGalCanvas( true ); + return true; } From 02f7e9c800221b247a40ca09aa3cb3fae2903a90 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 6 Sep 2013 17:53:01 +0200 Subject: [PATCH 14/25] Changed focus owner of LayerWidget to EDA_DRAW_PANEL_GAL to make keyboard events work (apparently everything works fine, to be tested more extensively). Removed unnecessary event hook from EDA_DRAW_PANEL_GAL. --- common/drawpanel_gal.cpp | 8 -------- include/class_drawpanel_gal.h | 1 - pcbnew/pcbframe.cpp | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/common/drawpanel_gal.cpp b/common/drawpanel_gal.cpp index 6df67bb3a0..3b354506bf 100644 --- a/common/drawpanel_gal.cpp +++ b/common/drawpanel_gal.cpp @@ -87,7 +87,6 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin Connect( wxEVT_MIDDLE_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); Connect( wxEVT_MIDDLE_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); Connect( wxEVT_MOUSEWHEEL, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); - Connect( wxEVT_CHAR_HOOK, wxEventHandler( EDA_DRAW_PANEL_GAL::skipEvent ), NULL, this ); Connect( wxEVT_KEY_UP, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); Connect( wxEVT_KEY_DOWN, wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this ); } @@ -208,10 +207,3 @@ void EDA_DRAW_PANEL_GAL::onEvent( wxEvent& aEvent ) Refresh(); } - - -void EDA_DRAW_PANEL_GAL::skipEvent( wxEvent& aEvent ) -{ - // This is necessary for CHAR_HOOK event to generate KEY_UP and KEY_DOWN events - aEvent.Skip(); -} diff --git a/include/class_drawpanel_gal.h b/include/class_drawpanel_gal.h index 542787fd0d..9206c69338 100644 --- a/include/class_drawpanel_gal.h +++ b/include/class_drawpanel_gal.h @@ -115,7 +115,6 @@ protected: void onPaint( wxPaintEvent& WXUNUSED( aEvent ) ); void onSize( wxSizeEvent& aEvent ); void onEvent( wxEvent& aEvent ); - void skipEvent( wxEvent& aEvent ); KiGfx::GAL* m_gal; ///< Interface for drawing objects on a 2D-surface KiGfx::VIEW* m_view; ///< Stores view settings (scale, center, etc.) diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 7e29efb5ed..7a7a6f6e4e 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -333,7 +333,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 From 77fc1aecb29cbdb3aa6f722d46c651b8addf30dd Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 9 Sep 2013 09:34:52 +0200 Subject: [PATCH 15/25] First version of the move tool. --- common/view/view_group.cpp | 12 --- include/view/view_group.h | 3 - pcbnew/CMakeLists.txt | 1 + pcbnew/tools/move_tool.cpp | 185 +++++++++++++++++++++++++++++++++++++ pcbnew/tools/move_tool.h | 113 ++++++++++++++++++++++ pcbnew/tools/pcb_tools.cpp | 6 +- 6 files changed, 303 insertions(+), 17 deletions(-) create mode 100644 pcbnew/tools/move_tool.cpp create mode 100644 pcbnew/tools/move_tool.h diff --git a/common/view/view_group.cpp b/common/view/view_group.cpp index 3b740e01b5..d4cc2472bc 100644 --- a/common/view/view_group.cpp +++ b/common/view/view_group.cpp @@ -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(); } @@ -121,15 +118,6 @@ void VIEW_GROUP::ViewGetLayers( int aLayers[], int& aCount ) const } -/*void VIEW_GROUP::ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw ) -{ - BOOST_FOREACH( VIEW_ITEM* item, m_items ) - { - item->ViewUpdate( aUpdateFlags, aForceImmediateRedraw ); - } -}*/ - - void VIEW_GROUP::updateBbox() { // Save the used VIEW, as it used nulled during Remove() diff --git a/include/view/view_group.h b/include/view/view_group.h index 4439234e0d..ab48e80028 100644 --- a/include/view/view_group.h +++ b/include/view/view_group.h @@ -120,9 +120,6 @@ public: */ virtual void ViewGetLayers( int aLayers[], int& aCount ) const; - /// @copydoc VIEW_ITEM::ViewUpdate() - virtual void ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw ); - /** * Function SetLayer() * Sets layer used to draw the group. diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 79b78b9b1a..d86f9dbf54 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -219,6 +219,7 @@ set(PCBNEW_CLASS_SRCS tools/selection_tool.cpp tools/selection_area.cpp + tools/move_tool.cpp tools/pcb_tools.cpp ) diff --git a/pcbnew/tools/move_tool.cpp b/pcbnew/tools/move_tool.cpp new file mode 100644 index 0000000000..54e5afe7af --- /dev/null +++ b/pcbnew/tools/move_tool.cpp @@ -0,0 +1,185 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2013 CERN + * @author Maciej Suminski + * + * 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 +#include +#include +#include + +#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( 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 selection; + VIEW_GROUP items( view ); + + view->Add( &items ); + + // 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::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::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( *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::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 ); + + 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 ); +} diff --git a/pcbnew/tools/move_tool.h b/pcbnew/tools/move_tool.h new file mode 100644 index 0000000000..1022230a69 --- /dev/null +++ b/pcbnew/tools/move_tool.h @@ -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 + * + * 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 +#include + +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 m_itemsState; +}; + +#endif diff --git a/pcbnew/tools/pcb_tools.cpp b/pcbnew/tools/pcb_tools.cpp index 4ee70cde94..0dc342a17d 100644 --- a/pcbnew/tools/pcb_tools.cpp +++ b/pcbnew/tools/pcb_tools.cpp @@ -35,16 +35,18 @@ #include #include "selection_tool.h" +#include "move_tool.h" void PCB_EDIT_FRAME::setupTools() { - // create the manager and dispatcher. Route draw panel events to the dispatcher. + // Create the manager and dispatcher. Route draw panel events to the dispatcher m_toolManager = new TOOL_MANAGER; m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, this ); m_galCanvas->SetEventDispatcher( m_toolDispatcher ); - // register our selection tool. + // Register tools m_toolManager->RegisterTool( new SELECTION_TOOL ); + m_toolManager->RegisterTool( new MOVE_TOOL ); } From c6d9a04dbac69b70c63d11d7e78e1e72a17ee105 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 9 Sep 2013 10:10:02 +0200 Subject: [PATCH 16/25] Parts of MODULEs are not selectable in multiple selection mode. --- pcbnew/tools/selection_tool.cpp | 40 +++++++++++++-------------------- pcbnew/tools/selection_tool.h | 9 +++----- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index c1a68a1914..63689482b5 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -44,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; } @@ -233,6 +233,7 @@ 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 ) ); @@ -281,13 +282,12 @@ bool SELECTION_TOOL::selectMultiple() m_selectedItems.insert( item ); } } - handleModules(); - break; } } v->Remove( m_selArea ); + m_multiple = false; return cancelled; } @@ -370,6 +370,11 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) 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; @@ -378,6 +383,13 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) 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: @@ -389,25 +401,3 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) // All other items are selected only if the layer on which they exist is visible return board->IsLayerVisible( aItem->GetLayer() ); } - - -void SELECTION_TOOL::handleModules() -{ - std::set::iterator it, it_end; - - for( it = m_selectedItems.begin(), it_end = m_selectedItems.end(); it != it_end; ) - { - BOARD_ITEM* parent = (*it)->GetParent(); - - // Do not allow to select MODULE and it's parts at the same time - if( parent != NULL && parent->IsSelected() ) - { - (*it)->ClearSelected(); - m_selectedItems.erase( it++ ); - } - else - { - ++it; - } - } -} diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index e198542b78..c76743d266 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -131,12 +131,6 @@ private: */ bool selectable( const BOARD_ITEM* aItem ); - /** - * Prevents from selecting both MODULEs and it's parts at the same time. The right way is - * to select a MODULE *or* some of it's parts. - */ - void handleModules(); - /// Container storing currently selected items std::set m_selectedItems; @@ -148,6 +142,9 @@ private: /// 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 From 7bbd31fa2a666f38810e3b1a2a4ce57553b9df5c Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 9 Sep 2013 10:53:46 +0200 Subject: [PATCH 17/25] Modified interfaces for [WX_]VIEW_CONTROLS. --- common/view/wx_view_controls.cpp | 20 ++---- include/view/view_controls.h | 108 ++++++++++++++++++++++++------- include/view/wx_view_controls.h | 68 +++---------------- 3 files changed, 100 insertions(+), 96 deletions(-) diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index 22a0af5b0e..49817951d4 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -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( @@ -64,6 +59,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 ) @@ -210,15 +211,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() ); diff --git a/include/view/view_controls.h b/include/view/view_controls.h index 0774d7ef69..3b686d966c 100644 --- a/include/view/view_controls.h +++ b/include/view/view_controls.h @@ -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 diff --git a/include/view/wx_view_controls.h b/include/view/wx_view_controls.h index 556338bd9e..1df1590745 100644 --- a/include/view/wx_view_controls.h +++ b/include/view/wx_view_controls.h @@ -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& aEvent ); + void onTimer( wxTimerEvent& 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; From cea4d8969720154af35638c9899598b0e8e09cb7 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 9 Sep 2013 10:54:11 +0200 Subject: [PATCH 18/25] Tools are enabled to switch snapping cursor to grid. --- common/tool/tool_dispatcher.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/tool/tool_dispatcher.cpp b/common/tool/tool_dispatcher.cpp index d87a7248fd..7138f14774 100644 --- a/common/tool/tool_dispatcher.cpp +++ b/common/tool/tool_dispatcher.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -199,7 +200,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) { bool motion = false, buttonEvents = false; - VECTOR2D pos; + VECTOR2D pos, screenPos; optional evt; int type = aEvent.GetEventType(); @@ -210,8 +211,9 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP || type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP ) { - wxMouseEvent* me = static_cast( &aEvent ); - pos = getView()->ToWorld( VECTOR2D( me->GetX(), me->GetY() ) ); + screenPos = m_toolMgr->GetViewControls()->GetCursorPosition(); + pos = getView()->ToWorld( screenPos ); + if( pos != m_lastMousePos ) { motion = true; @@ -271,3 +273,4 @@ void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent& aEvent ) if( activateTool && m_editFrame->IsGalCanvasActive() ) m_toolMgr->InvokeTool( toolName ); } + From 940689372262a097c74998f826bc1b8ac9b0f3b8 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 9 Sep 2013 11:45:20 +0200 Subject: [PATCH 19/25] Enabled snapping for the move tool. --- pcbnew/tools/move_tool.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pcbnew/tools/move_tool.cpp b/pcbnew/tools/move_tool.cpp index 54e5afe7af..f0783f6a40 100644 --- a/pcbnew/tools/move_tool.cpp +++ b/pcbnew/tools/move_tool.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "selection_tool.h" #include "move_tool.h" @@ -74,6 +75,7 @@ int MOVE_TOOL::Main( TOOL_EVENT& aEvent ) VIEW_GROUP items( view ); view->Add( &items ); + m_toolMgr->GetViewControls()->SetSnapping( true ); // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) @@ -164,6 +166,7 @@ int MOVE_TOOL::Main( TOOL_EVENT& aEvent ) m_itemsState.clear(); items.Clear(); view->Remove( &items ); + m_toolMgr->GetViewControls()->SetSnapping( false ); return 0; } From dd1ad34cea789423abb842e6a7815f8ac6682f59 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 9 Sep 2013 13:57:56 +0200 Subject: [PATCH 20/25] Stops autopanning on left mouse button release. --- common/view/wx_view_controls.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index 49817951d4..5f3950ea15 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -44,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 ); @@ -151,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: From b319b710df729af6a0e98dcdeae3ccbd3986d6ac Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 9 Sep 2013 14:31:13 +0200 Subject: [PATCH 21/25] Fixed color for drawing polygons on overlay. --- common/gal/opengl/opengl_gal.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 5b584ff10e..4d40e28978 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -471,6 +471,7 @@ void OPENGL_GAL::DrawPolygon( const std::deque& 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, ¶ms ); From 881cbd6d2f85e4d318f8b5fa06ccfbc4dc229f9c Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 9 Sep 2013 14:31:27 +0200 Subject: [PATCH 22/25] Small refactoring. --- common/view/wx_view_controls.cpp | 3 +-- include/tool/tool_dispatcher.h | 2 +- include/view/wx_view_controls.h | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index 5f3950ea15..838f5b82a0 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -197,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; diff --git a/include/tool/tool_dispatcher.h b/include/tool/tool_dispatcher.h index 8072274dfe..d4057c68b0 100644 --- a/include/tool/tool_dispatcher.h +++ b/include/tool/tool_dispatcher.h @@ -36,7 +36,7 @@ class TOOL_MANAGER; class PCB_BASE_FRAME; namespace KiGfx { - class VIEW ; + class VIEW; }; /** diff --git a/include/view/wx_view_controls.h b/include/view/wx_view_controls.h index 1df1590745..7c905f2f9c 100644 --- a/include/view/wx_view_controls.h +++ b/include/view/wx_view_controls.h @@ -54,8 +54,8 @@ public: void onWheel( wxMouseEvent& aEvent ); void onMotion( wxMouseEvent& aEvent ); void onButton( wxMouseEvent& aEvent ); - void onEnter( wxMouseEvent& aEvent ); - void onTimer( wxTimerEvent& aEvent ); + void onEnter( wxMouseEvent& WXUNUSED( aEvent ) ); + void onTimer( wxTimerEvent& WXUNUSED( aEvent ) ); /** * Function SetGrabMouse() From 0cf8221e623590b92310abed02673da2f728fcfe Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 9 Sep 2013 17:12:03 +0200 Subject: [PATCH 23/25] Fixed hanging up of menu loop when user never moves mouse cursor into popup menu area. --- common/tool/context_menu.cpp | 16 ++++++++++++---- include/tool/context_menu.h | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/common/tool/context_menu.cpp b/common/tool/context_menu.cpp index 0a38f5bb0c..a2247efe4d 100644 --- a/common/tool/context_menu.cpp +++ b/common/tool/context_menu.cpp @@ -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 ) ); } diff --git a/include/tool/context_menu.h b/include/tool/context_menu.h index 909798534a..b62a55a041 100644 --- a/include/tool/context_menu.h +++ b/include/tool/context_menu.h @@ -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; } From bd6bb510f8e5d44495004ba98568e867cec167c8 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 10 Sep 2013 10:47:42 +0200 Subject: [PATCH 24/25] Changed D() macro to DBG() because of conflict with glm::D(). Added const to GetColor() and GetType() functions in WS_DRAW_ITEM. --- 3d-viewer/3d_draw_basic_functions.cpp | 2 +- 3d-viewer/vrmlmodelparser.cpp | 8 +++---- 3d-viewer/x3dmodelparser.cpp | 18 +++++++------- include/fctsys.h | 4 ++-- include/worksheet_shape_builder.h | 5 ++-- ...board_items_to_polygon_shape_transform.cpp | 2 +- pcbnew/deltrack.cpp | 4 ++-- pcbnew/dialogs/dialog_fp_lib_table.cpp | 10 ++++---- pcbnew/eagle_plugin.cpp | 2 +- pcbnew/editrack.cpp | 24 +++++++++---------- pcbnew/gen_modules_placefile.cpp | 4 ++-- pcbnew/specctra_export.cpp | 6 ++--- 12 files changed, 44 insertions(+), 45 deletions(-) diff --git a/3d-viewer/3d_draw_basic_functions.cpp b/3d-viewer/3d_draw_basic_functions.cpp index bb08b572b3..fbe1fb6277 100644 --- a/3d-viewer/3d_draw_basic_functions.cpp +++ b/3d-viewer/3d_draw_basic_functions.cpp @@ -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 } diff --git a/3d-viewer/vrmlmodelparser.cpp b/3d-viewer/vrmlmodelparser.cpp index 20ec219991..fa90c6ada8 100644 --- a/3d-viewer/vrmlmodelparser.cpp +++ b/3d-viewer/vrmlmodelparser.cpp @@ -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; } } diff --git a/3d-viewer/x3dmodelparser.cpp b/3d-viewer/x3dmodelparser.cpp index 8205726ce1..0ca02d9157 100644 --- a/3d-viewer/x3dmodelparser.cpp +++ b/3d-viewer/x3dmodelparser.cpp @@ -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; } diff --git a/include/fctsys.h b/include/fctsys.h index 2d07a11413..ff239ce9de 100644 --- a/include/fctsys.h +++ b/include/fctsys.h @@ -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 /** diff --git a/include/worksheet_shape_builder.h b/include/worksheet_shape_builder.h index af6051c353..a7d4644172 100644 --- a/include/worksheet_shape_builder.h +++ b/include/worksheet_shape_builder.h @@ -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; } diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 9b801d452e..c18dbc3d19 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -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; } diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index f85c787f69..2a77f9faec 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -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; ) diff --git a/pcbnew/dialogs/dialog_fp_lib_table.cpp b/pcbnew/dialogs/dialog_fp_lib_table.cpp index 34eccd06f2..4bc9fc9d7e 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table.cpp @@ -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(); diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index 00df1c0879..e9b77f57d1 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -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 } } diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index ab538b6a9c..8df058fddf 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -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 ) diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp index f78316ef81..950b3e0758 100644 --- a/pcbnew/gen_modules_placefile.cpp +++ b/pcbnew/gen_modules_placefile.cpp @@ -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; } diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 96b027c217..36ed48d018 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -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; } } From 57a1201b118491106ca550df9b4f6e519cbdf5f6 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 10 Sep 2013 13:57:28 +0200 Subject: [PATCH 25/25] PCB items are refreshed on GAL switching (changes made using default renderer are displayed by GAL). --- common/drawframe.cpp | 16 ++--- include/wxBasePcbFrame.h | 4 ++ include/wxstruct.h | 2 +- pcbnew/basepcbframe.cpp | 128 ++++++++++++++++++++++----------------- 4 files changed, 85 insertions(+), 65 deletions(-) diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 88f73d7c44..9c0e500778 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -981,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 { diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 1912d2a755..874349dfd0 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -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() }; diff --git a/include/wxstruct.h b/include/wxstruct.h index 76e5987b50..6cdd0fec65 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -903,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 diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index bd5e71781a..4d418d0e57 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -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 ); @@ -523,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();