Fixed continous line drawing.

Outline mode can be set up on any layer.
This commit is contained in:
Maciej Suminski 2014-07-09 15:10:32 +02:00
parent d7c3c7828b
commit b2d0737329
4 changed files with 54 additions and 19 deletions

View File

@ -295,7 +295,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_NEW_MODULE: case ID_MODEDIT_NEW_MODULE:
{ {
if( ! Clear_Pcb( true ) ) if( !Clear_Pcb( true ) )
break; break;
SetCrossHairPosition( wxPoint( 0, 0 ) ); SetCrossHairPosition( wxPoint( 0, 0 ) );
@ -317,6 +317,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
Zoom_Automatique( false ); Zoom_Automatique( false );
} }
if( IsGalCanvasActive() )
updateView();
GetScreen()->ClrModify(); GetScreen()->ClrModify();
} }
break; break;

View File

@ -50,7 +50,7 @@ PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
m_displayZoneMode = DZ_SHOW_FILLED; m_displayZoneMode = DZ_SHOW_FILLED;
// By default everything should be displayed as filled // By default everything should be displayed as filled
for( unsigned int i = 0; i < END_PCB_VISIBLE_LIST; ++i ) for( unsigned int i = 0; i < TOTAL_LAYER_COUNT; ++i )
{ {
m_sketchMode[i] = false; m_sketchMode[i] = false;
} }
@ -102,9 +102,9 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions )
m_padNumbers = aOptions.DisplayPadNum; m_padNumbers = aOptions.DisplayPadNum;
// Whether to draw tracks, vias & pads filled or as outlines // Whether to draw tracks, vias & pads filled or as outlines
m_sketchMode[PADS_VISIBLE] = !aOptions.DisplayPadFill; m_sketchMode[ITEM_GAL_LAYER( PADS_VISIBLE )] = !aOptions.DisplayPadFill;
m_sketchMode[VIA_THROUGH_VISIBLE] = !aOptions.DisplayViaFill; m_sketchMode[ITEM_GAL_LAYER( VIA_THROUGH_VISIBLE )] = !aOptions.DisplayViaFill;
m_sketchMode[TRACKS_VISIBLE] = !aOptions.DisplayPcbTrackFill; m_sketchMode[ITEM_GAL_LAYER( TRACKS_VISIBLE )] = !aOptions.DisplayPcbTrackFill;
switch( aOptions.DisplayNetNamesMode ) switch( aOptions.DisplayNetNamesMode )
{ {
@ -313,7 +313,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
m_gal->SetStrokeColor( color ); m_gal->SetStrokeColor( color );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
if( m_pcbSettings.m_sketchMode[TRACKS_VISIBLE] ) if( m_pcbSettings.m_sketchMode[ITEM_GAL_LAYER( TRACKS_VISIBLE )] )
{ {
// Outline mode // Outline mode
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth ); m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
@ -350,7 +350,7 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer ); const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
if( m_pcbSettings.m_sketchMode[VIA_THROUGH_VISIBLE] ) if( m_pcbSettings.m_sketchMode[ITEM_GAL_LAYER( VIA_THROUGH_VISIBLE )] )
{ {
// Outline mode // Outline mode
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
@ -481,7 +481,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
// Pad drawing // Pad drawing
const COLOR4D& color = m_pcbSettings.GetColor( aPad, aLayer ); const COLOR4D& color = m_pcbSettings.GetColor( aPad, aLayer );
if( m_pcbSettings.m_sketchMode[PADS_VISIBLE] ) if( m_pcbSettings.m_sketchMode[ITEM_GAL_LAYER( PADS_VISIBLE )] )
{ {
// Outline mode // Outline mode
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
@ -544,7 +544,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m = ( size.y - size.x ); m = ( size.y - size.x );
n = size.x; n = size.x;
if( m_pcbSettings.m_sketchMode[PADS_VISIBLE] ) if( m_pcbSettings.m_sketchMode[ITEM_GAL_LAYER( PADS_VISIBLE )] )
{ {
// Outline mode // Outline mode
m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 ); m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
@ -565,7 +565,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m = ( size.x - size.y ); m = ( size.x - size.y );
n = size.y; n = size.y;
if( m_pcbSettings.m_sketchMode[PADS_VISIBLE] ) if( m_pcbSettings.m_sketchMode[ITEM_GAL_LAYER( PADS_VISIBLE )] )
{ {
// Outline mode // Outline mode
m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 ); m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );

View File

@ -76,6 +76,8 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason )
int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent ) int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
{ {
boost::optional<VECTOR2D> startingPoint;
if( m_editModules ) if( m_editModules )
{ {
m_frame->SetToolID( ID_MODEDIT_LINE_TOOL, wxCURSOR_PENCIL, _( "Add graphic line" ) ); m_frame->SetToolID( ID_MODEDIT_LINE_TOOL, wxCURSOR_PENCIL, _( "Add graphic line" ) );
@ -83,7 +85,7 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
MODULE* module = m_board->m_Modules; MODULE* module = m_board->m_Modules;
EDGE_MODULE* line = new EDGE_MODULE( module ); EDGE_MODULE* line = new EDGE_MODULE( module );
while( drawSegment( S_SEGMENT, reinterpret_cast<DRAWSEGMENT*&>( line ) ) ) while( drawSegment( S_SEGMENT, reinterpret_cast<DRAWSEGMENT*&>( line ), startingPoint ) )
{ {
if( line ) if( line )
{ {
@ -92,6 +94,11 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
line->SetLocalCoord(); line->SetLocalCoord();
line->SetParent( module ); line->SetParent( module );
module->GraphicalItems().PushFront( line ); module->GraphicalItems().PushFront( line );
startingPoint = line->GetEnd();
}
else
{
startingPoint = boost::none;
} }
line = new EDGE_MODULE( module ); line = new EDGE_MODULE( module );
@ -103,13 +110,18 @@ int DRAWING_TOOL::DrawLine( TOOL_EVENT& aEvent )
DRAWSEGMENT* line = new DRAWSEGMENT; DRAWSEGMENT* line = new DRAWSEGMENT;
while( drawSegment( S_SEGMENT, line ) ) while( drawSegment( S_SEGMENT, line, startingPoint ) )
{ {
if( line ) if( line )
{ {
m_board->Add( line ); m_board->Add( line );
m_frame->OnModify(); m_frame->OnModify();
m_frame->SaveCopyInUndoList( line, UR_NEW ); m_frame->SaveCopyInUndoList( line, UR_NEW );
startingPoint = line->GetEnd();
}
else
{
startingPoint = boost::none;
} }
line = new DRAWSEGMENT; line = new DRAWSEGMENT;
@ -853,7 +865,8 @@ int DRAWING_TOOL::SetAnchor( TOOL_EVENT& aEvent )
} }
bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic ) bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
boost::optional<VECTOR2D> aStartingPoint )
{ {
// Only two shapes are currently supported // Only two shapes are currently supported
assert( aShape == S_SEGMENT || aShape == S_CIRCLE ); assert( aShape == S_SEGMENT || aShape == S_CIRCLE );
@ -872,12 +885,33 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic )
bool direction45 = false; // 45 degrees only mode bool direction45 = false; // 45 degrees only mode
bool started = false; bool started = false;
VECTOR2I cursorPos = m_controls->GetCursorPosition();
if( aStartingPoint )
{
LAYER_NUM layer = m_frame->GetScreen()->m_Active_Layer;
// Init the new item attributes
aGraphic->SetShape( (STROKE_T) aShape );
aGraphic->SetWidth( m_board->GetDesignSettings().m_DrawSegmentWidth );
aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) );
aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
aGraphic->SetLayer( layer );
if( aShape == S_SEGMENT )
line45 = *aGraphic; // used only for direction 45 mode with lines
preview.Add( aGraphic );
m_controls->SetAutoPan( true );
started = true;
}
// Main loop: keep receiving events // Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() ) while( OPT_TOOL_EVENT evt = Wait() )
{ {
bool updatePreview = false; // should preview be updated bool updatePreview = false; // should preview be updated
VECTOR2I cursorPos = m_controls->GetCursorPosition(); cursorPos = m_controls->GetCursorPosition();
// Enable 45 degrees lines only mode by holding control // Enable 45 degrees lines only mode by holding control
if( direction45 != evt->Modifier( MD_CTRL ) && started && aShape == S_SEGMENT ) if( direction45 != evt->Modifier( MD_CTRL ) && started && aShape == S_SEGMENT )
@ -940,10 +974,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic )
aGraphic->SetLayer( layer ); aGraphic->SetLayer( layer );
if( aShape == S_SEGMENT ) if( aShape == S_SEGMENT )
{
line45 = *aGraphic; // used only for direction 45 mode with lines line45 = *aGraphic; // used only for direction 45 mode with lines
line45.SetLayer( layer );
}
preview.Add( aGraphic ); preview.Add( aGraphic );
m_controls->SetAutoPan( true ); m_controls->SetAutoPan( true );
@ -965,7 +996,6 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic )
{ // a clear sign that the current drawing is finished { // a clear sign that the current drawing is finished
delete aGraphic; // but only if at least one graphic was created delete aGraphic; // but only if at least one graphic was created
aGraphic = NULL; // otherwise - force user to draw more or cancel aGraphic = NULL; // otherwise - force user to draw more or cancel
started = false;
} }
preview.Clear(); preview.Clear();

View File

@ -26,6 +26,7 @@
#define __DRAWING_TOOL_H #define __DRAWING_TOOL_H
#include <tool/tool_interactive.h> #include <tool/tool_interactive.h>
#include <boost/optional.hpp>
namespace KIGFX namespace KIGFX
{ {
@ -150,7 +151,8 @@ private:
///> be already created. The tool deletes the object if it is not added to a BOARD. ///> be already created. The tool deletes the object if it is not added to a BOARD.
///> @return False if the tool was cancelled before the origin was set or origin and end are ///> @return False if the tool was cancelled before the origin was set or origin and end are
///> the same point. ///> the same point.
bool drawSegment( int aShape, DRAWSEGMENT*& aGraphic ); bool drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
boost::optional<VECTOR2D> aStartingPoint = boost::none );
///> Starts drawing an arc. ///> Starts drawing an arc.
///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to ///> @param aGraphic is an object that is going to be used by the tool for drawing. It has to