diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 6d42a29d64..fce609d27e 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -223,7 +223,7 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer ) case PCB_LINE_T: case PCB_MODULE_EDGE_T: - draw( (DRAWSEGMENT*) item ); + draw( (DRAWSEGMENT*) item, aLayer ); break; case PCB_TEXT_T: @@ -325,6 +325,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer ) m_gal->SetFillColor( color ); m_gal->SetIsFill( true ); } + m_gal->DrawSegment( start, end, width ); } } @@ -622,14 +623,26 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) } -void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment ) +void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer ) { const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() ); - m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); m_gal->SetStrokeColor( color ); - m_gal->SetLineWidth( aSegment->GetWidth() ); + + if( m_pcbSettings.m_sketchMode[aLayer] ) + { + // Outline mode + m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth ); + m_gal->SetIsFill( false ); + } + else + { + // Filled mode + m_gal->SetLineWidth( aSegment->GetWidth() ); + m_gal->SetFillColor( color ); + m_gal->SetIsFill( true ); + } switch( aSegment->GetShape() ) { @@ -704,12 +717,25 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer ) if( aText->GetText().Length() == 0 ) return; - const COLOR4D& strokeColor = m_pcbSettings.GetColor( aText, aText->GetLayer() ); + const COLOR4D& color = m_pcbSettings.GetColor( aText, aText->GetLayer() ); VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y ); double orientation = aText->GetOrientation() * M_PI / 1800.0; - m_gal->SetStrokeColor( strokeColor ); - m_gal->SetLineWidth( aText->GetThickness() ); + if( m_pcbSettings.m_sketchMode[aLayer] ) + { + // Outline mode + m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth ); + m_gal->SetIsFill( false ); + } + else + { + // Filled mode + m_gal->SetLineWidth( aText->GetThickness() ); + m_gal->SetFillColor( color ); + m_gal->SetIsFill( true ); + } + + m_gal->SetStrokeColor( color ); m_gal->SetTextAttributes( aText ); m_gal->StrokeText( aText->GetText(), position, orientation ); } @@ -720,12 +746,25 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer ) if( aText->GetLength() == 0 ) return; - const COLOR4D& strokeColor = m_pcbSettings.GetColor( aText, aLayer ); + const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer ); VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y ); double orientation = aText->GetDrawRotation() * M_PI / 1800.0; - m_gal->SetStrokeColor( strokeColor ); - m_gal->SetLineWidth( aText->GetThickness() ); + if( m_pcbSettings.m_sketchMode[aLayer] ) + { + // Outline mode + m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth ); + m_gal->SetIsFill( false ); + } + else + { + // Filled mode + m_gal->SetLineWidth( aText->GetThickness() ); + m_gal->SetFillColor( color ); + m_gal->SetIsFill( true ); + } + + m_gal->SetStrokeColor( color ); m_gal->SetTextAttributes( aText ); m_gal->StrokeText( aText->GetText(), position, orientation ); } diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index 93bcb034f7..2b79696ec3 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -124,9 +124,6 @@ public: */ inline void SetSketchMode( int aItemLayer, bool aEnabled ) { - // It is supposed to work only with item layers - assert( aItemLayer >= ITEM_GAL_LAYER( 0 ) ); - m_sketchMode[aItemLayer] = aEnabled; } @@ -137,9 +134,6 @@ public: */ inline bool GetSketchMode( int aItemLayer ) const { - // It is supposed to work only with item layers - assert( aItemLayer >= ITEM_GAL_LAYER( 0 ) ); - return m_sketchMode[aItemLayer]; } @@ -210,7 +204,7 @@ protected: void draw( const TRACK* aTrack, int aLayer ); void draw( const VIA* aVia, int aLayer ); void draw( const D_PAD* aPad, int aLayer ); - void draw( const DRAWSEGMENT* aSegment ); + void draw( const DRAWSEGMENT* aSegment, int aLayer ); void draw( const TEXTE_PCB* aText, int aLayer ); void draw( const TEXTE_MODULE* aText, int aLayer ); void draw( const MODULE* aModule ); diff --git a/pcbnew/tools/common_actions.cpp b/pcbnew/tools/common_actions.cpp index 3e2118eb84..0e1ebc0818 100644 --- a/pcbnew/tools/common_actions.cpp +++ b/pcbnew/tools/common_actions.cpp @@ -284,6 +284,14 @@ TOOL_ACTION COMMON_ACTIONS::pasteItems( "pcbnew.ModuleEditor.pasteItems", AS_GLOBAL, MD_CTRL + int( 'V' ), "Paste items", "Paste items", AF_ACTIVATE ); +TOOL_ACTION COMMON_ACTIONS::moduleEdgeOutlines( "pcbnew.ModuleEditor.graphicOutlines", + AS_GLOBAL, 0, + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::moduleTextOutlines( "pcbnew.ModuleEditor.textOutlines", + AS_GLOBAL, 0, + "", "" ); + // Miscellaneous TOOL_ACTION COMMON_ACTIONS::resetCoords( "pcbnew.Control.resetCoords", @@ -425,14 +433,18 @@ boost::optional COMMON_ACTIONS::TranslateLegacyId( int aId ) case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY: return COMMON_ACTIONS::zoneDisplayOutlines.MakeEvent(); + case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH: + return COMMON_ACTIONS::moduleEdgeOutlines.MakeEvent(); + + case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH: + return COMMON_ACTIONS::moduleTextOutlines.MakeEvent(); + case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE: return COMMON_ACTIONS::highContrastMode.MakeEvent(); case ID_TB_OPTIONS_SELECT_CURSOR: return COMMON_ACTIONS::switchCursor.MakeEvent(); - case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH: - case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH: case ID_PCB_DELETE_ITEM_BUTT: case ID_PCB_HIGHLIGHT_BUTT: case ID_PCB_SHOW_1_RATSNEST_BUTT: diff --git a/pcbnew/tools/common_actions.h b/pcbnew/tools/common_actions.h index a47513acd9..fb53fed993 100644 --- a/pcbnew/tools/common_actions.h +++ b/pcbnew/tools/common_actions.h @@ -186,6 +186,12 @@ public: /// Pasting module items from clipboard static TOOL_ACTION pasteItems; + /// Display module edges as outlines + static TOOL_ACTION moduleEdgeOutlines; + + /// Display module texts as outlines + static TOOL_ACTION moduleTextOutlines; + // Miscellaneous static TOOL_ACTION resetCoords; diff --git a/pcbnew/tools/module_tools.cpp b/pcbnew/tools/module_tools.cpp index a23dec3be3..e9302b6c60 100644 --- a/pcbnew/tools/module_tools.cpp +++ b/pcbnew/tools/module_tools.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -531,10 +532,86 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent ) } +int MODULE_TOOLS::ModuleTextOutlines( TOOL_EVENT& aEvent ) +{ + KIGFX::PCB_PAINTER* painter = + static_cast( m_frame->GetGalCanvas()->GetView()->GetPainter() ); + KIGFX::PCB_RENDER_SETTINGS* settings = + static_cast( painter->GetSettings() ); + + const LAYER_NUM layers[] = { ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ), + ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ), + ITEM_GAL_LAYER( MOD_TEXT_INVISIBLE ), + ITEM_GAL_LAYER( MOD_REFERENCES_VISIBLE ), + ITEM_GAL_LAYER( MOD_VALUES_VISIBLE ) }; + + bool enable = !settings->GetSketchMode( layers[0] ); + + BOOST_FOREACH( LAYER_NUM layer, layers ) + settings->SetSketchMode( layer, enable ); + + for( MODULE* module = getModel()->m_Modules; module; module = module->Next() ) + { + for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item ->Next() ) + { + if( item->Type() == PCB_MODULE_TEXT_T ) + item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); + } + + module->Reference().ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); + module->Value().ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); + } + + m_frame->GetGalCanvas()->Refresh(); + setTransitions(); + + return 0; +} + + +int MODULE_TOOLS::ModuleEdgeOutlines( TOOL_EVENT& aEvent ) +{ + KIGFX::PCB_PAINTER* painter = + static_cast( m_frame->GetGalCanvas()->GetView()->GetPainter() ); + KIGFX::PCB_RENDER_SETTINGS* settings = + static_cast( painter->GetSettings() ); + + const LAYER_NUM layers[] = { ADHESIVE_N_FRONT, ADHESIVE_N_BACK,\ + SOLDERPASTE_N_FRONT, SOLDERPASTE_N_BACK,\ + SILKSCREEN_N_FRONT, SILKSCREEN_N_BACK,\ + SOLDERMASK_N_FRONT, SOLDERMASK_N_BACK,\ + DRAW_N,\ + COMMENT_N,\ + ECO1_N, ECO2_N,\ + EDGE_N }; + + bool enable = !settings->GetSketchMode( layers[0] ); + + BOOST_FOREACH( LAYER_NUM layer, layers ) + settings->SetSketchMode( layer, enable ); + + for( MODULE* module = getModel()->m_Modules; module; module = module->Next() ) + { + for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item ->Next() ) + { + if( item->Type() == PCB_MODULE_EDGE_T ) + item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); + } + } + + m_frame->GetGalCanvas()->Refresh(); + setTransitions(); + + return 0; +} + + void MODULE_TOOLS::setTransitions() { - Go( &MODULE_TOOLS::PlacePad, COMMON_ACTIONS::placePad.MakeEvent() ); - Go( &MODULE_TOOLS::EnumeratePads, COMMON_ACTIONS::enumeratePads.MakeEvent() ); - Go( &MODULE_TOOLS::CopyItems, COMMON_ACTIONS::copyItems.MakeEvent() ); - Go( &MODULE_TOOLS::PasteItems, COMMON_ACTIONS::pasteItems.MakeEvent() ); + Go( &MODULE_TOOLS::PlacePad, COMMON_ACTIONS::placePad.MakeEvent() ); + Go( &MODULE_TOOLS::EnumeratePads, COMMON_ACTIONS::enumeratePads.MakeEvent() ); + Go( &MODULE_TOOLS::CopyItems, COMMON_ACTIONS::copyItems.MakeEvent() ); + Go( &MODULE_TOOLS::PasteItems, COMMON_ACTIONS::pasteItems.MakeEvent() ); + Go( &MODULE_TOOLS::ModuleTextOutlines, COMMON_ACTIONS::moduleTextOutlines.MakeEvent() ); + Go( &MODULE_TOOLS::ModuleEdgeOutlines, COMMON_ACTIONS::moduleEdgeOutlines.MakeEvent() ); } diff --git a/pcbnew/tools/module_tools.h b/pcbnew/tools/module_tools.h index 64899e4182..71d83acc7e 100644 --- a/pcbnew/tools/module_tools.h +++ b/pcbnew/tools/module_tools.h @@ -77,6 +77,20 @@ public: */ int PasteItems( TOOL_EVENT& aEvent ); + /** + * Function ModuleTextOutlines() + * + * Toggles display mode for module texts (outline/filled). + */ + int ModuleTextOutlines( TOOL_EVENT& aEvent ); + + /** + * Function ModuleEdgeOutlines() + * + * Toggles display mode for module edges (outline/filled). + */ + int ModuleEdgeOutlines( TOOL_EVENT& aEvent ); + private: ///> Sets up handlers for various events. void setTransitions();