Commit 587f22e1 authored by Maciej Suminski's avatar Maciej Suminski

Outline display mode for module edges & texts in the module editor.

parent 3b5ece39
...@@ -223,7 +223,7 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer ) ...@@ -223,7 +223,7 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
case PCB_LINE_T: case PCB_LINE_T:
case PCB_MODULE_EDGE_T: case PCB_MODULE_EDGE_T:
draw( (DRAWSEGMENT*) item ); draw( (DRAWSEGMENT*) item, aLayer );
break; break;
case PCB_TEXT_T: case PCB_TEXT_T:
...@@ -325,6 +325,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer ) ...@@ -325,6 +325,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
m_gal->SetFillColor( color ); m_gal->SetFillColor( color );
m_gal->SetIsFill( true ); m_gal->SetIsFill( true );
} }
m_gal->DrawSegment( start, end, width ); m_gal->DrawSegment( start, end, width );
} }
} }
...@@ -622,14 +623,26 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) ...@@ -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() ); const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetStrokeColor( color ); 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() ) switch( aSegment->GetShape() )
{ {
...@@ -704,12 +717,25 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer ) ...@@ -704,12 +717,25 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
if( aText->GetText().Length() == 0 ) if( aText->GetText().Length() == 0 )
return; 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 ); VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y );
double orientation = aText->GetOrientation() * M_PI / 1800.0; double orientation = aText->GetOrientation() * M_PI / 1800.0;
m_gal->SetStrokeColor( strokeColor ); if( m_pcbSettings.m_sketchMode[aLayer] )
m_gal->SetLineWidth( aText->GetThickness() ); {
// 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->SetTextAttributes( aText );
m_gal->StrokeText( aText->GetText(), position, orientation ); m_gal->StrokeText( aText->GetText(), position, orientation );
} }
...@@ -720,12 +746,25 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer ) ...@@ -720,12 +746,25 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
if( aText->GetLength() == 0 ) if( aText->GetLength() == 0 )
return; 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 ); VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y );
double orientation = aText->GetDrawRotation() * M_PI / 1800.0; double orientation = aText->GetDrawRotation() * M_PI / 1800.0;
m_gal->SetStrokeColor( strokeColor ); if( m_pcbSettings.m_sketchMode[aLayer] )
m_gal->SetLineWidth( aText->GetThickness() ); {
// 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->SetTextAttributes( aText );
m_gal->StrokeText( aText->GetText(), position, orientation ); m_gal->StrokeText( aText->GetText(), position, orientation );
} }
......
...@@ -124,9 +124,6 @@ public: ...@@ -124,9 +124,6 @@ public:
*/ */
inline void SetSketchMode( int aItemLayer, bool aEnabled ) 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; m_sketchMode[aItemLayer] = aEnabled;
} }
...@@ -137,9 +134,6 @@ public: ...@@ -137,9 +134,6 @@ public:
*/ */
inline bool GetSketchMode( int aItemLayer ) const 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]; return m_sketchMode[aItemLayer];
} }
...@@ -210,7 +204,7 @@ protected: ...@@ -210,7 +204,7 @@ protected:
void draw( const TRACK* aTrack, int aLayer ); void draw( const TRACK* aTrack, int aLayer );
void draw( const VIA* aVia, int aLayer ); void draw( const VIA* aVia, int aLayer );
void draw( const D_PAD* aPad, 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_PCB* aText, int aLayer );
void draw( const TEXTE_MODULE* aText, int aLayer ); void draw( const TEXTE_MODULE* aText, int aLayer );
void draw( const MODULE* aModule ); void draw( const MODULE* aModule );
......
...@@ -284,6 +284,14 @@ TOOL_ACTION COMMON_ACTIONS::pasteItems( "pcbnew.ModuleEditor.pasteItems", ...@@ -284,6 +284,14 @@ TOOL_ACTION COMMON_ACTIONS::pasteItems( "pcbnew.ModuleEditor.pasteItems",
AS_GLOBAL, MD_CTRL + int( 'V' ), AS_GLOBAL, MD_CTRL + int( 'V' ),
"Paste items", "Paste items", AF_ACTIVATE ); "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 // Miscellaneous
TOOL_ACTION COMMON_ACTIONS::resetCoords( "pcbnew.Control.resetCoords", TOOL_ACTION COMMON_ACTIONS::resetCoords( "pcbnew.Control.resetCoords",
...@@ -425,14 +433,18 @@ boost::optional<TOOL_EVENT> COMMON_ACTIONS::TranslateLegacyId( int aId ) ...@@ -425,14 +433,18 @@ boost::optional<TOOL_EVENT> COMMON_ACTIONS::TranslateLegacyId( int aId )
case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY: case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
return COMMON_ACTIONS::zoneDisplayOutlines.MakeEvent(); 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: case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
return COMMON_ACTIONS::highContrastMode.MakeEvent(); return COMMON_ACTIONS::highContrastMode.MakeEvent();
case ID_TB_OPTIONS_SELECT_CURSOR: case ID_TB_OPTIONS_SELECT_CURSOR:
return COMMON_ACTIONS::switchCursor.MakeEvent(); 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_DELETE_ITEM_BUTT:
case ID_PCB_HIGHLIGHT_BUTT: case ID_PCB_HIGHLIGHT_BUTT:
case ID_PCB_SHOW_1_RATSNEST_BUTT: case ID_PCB_SHOW_1_RATSNEST_BUTT:
......
...@@ -186,6 +186,12 @@ public: ...@@ -186,6 +186,12 @@ public:
/// Pasting module items from clipboard /// Pasting module items from clipboard
static TOOL_ACTION pasteItems; static TOOL_ACTION pasteItems;
/// Display module edges as outlines
static TOOL_ACTION moduleEdgeOutlines;
/// Display module texts as outlines
static TOOL_ACTION moduleTextOutlines;
// Miscellaneous // Miscellaneous
static TOOL_ACTION resetCoords; static TOOL_ACTION resetCoords;
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <class_draw_panel_gal.h> #include <class_draw_panel_gal.h>
#include <view/view_controls.h> #include <view/view_controls.h>
#include <view/view_group.h> #include <view/view_group.h>
#include <pcb_painter.h>
#include <kicad_plugin.h> #include <kicad_plugin.h>
#include <pcbnew_id.h> #include <pcbnew_id.h>
...@@ -531,10 +532,86 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent ) ...@@ -531,10 +532,86 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
} }
int MODULE_TOOLS::ModuleTextOutlines( TOOL_EVENT& aEvent )
{
KIGFX::PCB_PAINTER* painter =
static_cast<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( 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<BOARD>()->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<KIGFX::PCB_PAINTER*>( m_frame->GetGalCanvas()->GetView()->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( 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<BOARD>()->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() void MODULE_TOOLS::setTransitions()
{ {
Go( &MODULE_TOOLS::PlacePad, COMMON_ACTIONS::placePad.MakeEvent() ); Go( &MODULE_TOOLS::PlacePad, COMMON_ACTIONS::placePad.MakeEvent() );
Go( &MODULE_TOOLS::EnumeratePads, COMMON_ACTIONS::enumeratePads.MakeEvent() ); Go( &MODULE_TOOLS::EnumeratePads, COMMON_ACTIONS::enumeratePads.MakeEvent() );
Go( &MODULE_TOOLS::CopyItems, COMMON_ACTIONS::copyItems.MakeEvent() ); Go( &MODULE_TOOLS::CopyItems, COMMON_ACTIONS::copyItems.MakeEvent() );
Go( &MODULE_TOOLS::PasteItems, COMMON_ACTIONS::pasteItems.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() );
} }
...@@ -77,6 +77,20 @@ public: ...@@ -77,6 +77,20 @@ public:
*/ */
int PasteItems( TOOL_EVENT& aEvent ); 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: private:
///> Sets up handlers for various events. ///> Sets up handlers for various events.
void setTransitions(); void setTransitions();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment