eeschema: fixed minor issues.

This commit is contained in:
charras 2010-03-28 14:46:49 +00:00
parent 1fdd229e02
commit c5f41a3a1e
6 changed files with 113 additions and 46 deletions

View File

@ -242,6 +242,49 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDc,
GRSetDrawMode( aDc, aDrawMode );
/* draw background for filled items using background option
* Solid lines will be drawn after the background
* Note also, background is not drawn when:
* printing in black and white
* If the color is not the default color (aColor != -1 )
*/
if( ! (screen->m_IsPrinting && GetGRForceBlackPenState()) && (aColor == -1) )
{
BOOST_FOREACH( LIB_DRAW_ITEM& drawItem, drawings )
{
if( drawItem.m_Fill != FILLED_WITH_BG_BODYCOLOR )
continue;
if( aOnlySelected && drawItem.m_Selected == 0 )
continue;
// Do not draw an item while moving (the cursor handler does that)
if( drawItem.m_Flags & IS_MOVED )
continue;
/* Do not draw items not attached to the current part */
if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) )
continue;
if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
continue;
if( drawItem.Type() == COMPONENT_FIELD_DRAW_TYPE )
continue;
if( drawItem.Type() == COMPONENT_FIELD_DRAW_TYPE )
{
drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode,
(void*) NULL, aTransformMatrix );
}
// Now, draw only the background for items with
// m_Fill == FILLED_WITH_BG_BODYCOLOR:
drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode,
(void*) false, aTransformMatrix );
}
}
BOOST_FOREACH( LIB_DRAW_ITEM& drawItem, drawings )
{
if( aOnlySelected && drawItem.m_Selected == 0 )
@ -273,9 +316,7 @@ void LIB_COMPONENT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDc,
}
else
{
bool forceNoFill = ( screen->m_IsPrinting
&& drawItem.m_Fill == FILLED_WITH_BG_BODYCOLOR
&& GetGRForceBlackPenState() );
bool forceNoFill = drawItem.m_Fill == FILLED_WITH_BG_BODYCOLOR;
drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode,
(void*) forceNoFill, aTransformMatrix );
}

View File

@ -433,7 +433,8 @@ void LIB_ARC::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
if( fill == FILLED_WITH_BG_BODYCOLOR )
GRFilledArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2,
m_Radius, GetPenSize( ), color,
m_Radius, GetPenSize( ),
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ),
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE && !aData )
GRFilledArc( &aPanel->m_ClipBox, aDC, posc.x, posc.y, pt1, pt2,
@ -751,7 +752,8 @@ void LIB_CIRCLE::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
if( fill == FILLED_WITH_BG_BODYCOLOR )
GRFilledCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y,
m_Radius, GetPenSize( ), color,
m_Radius, GetPenSize( ),
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ),
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE )
GRFilledCircle( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y,
@ -991,7 +993,8 @@ void LIB_RECTANGLE::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
if( fill == FILLED_WITH_BG_BODYCOLOR && !aData )
GRFilledRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y,
GetPenSize( ), color,
GetPenSize( ),
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ),
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( m_Fill == FILLED_SHAPE && !aData )
GRFilledRect( &aPanel->m_ClipBox, aDC, pos1.x, pos1.y, pos2.x, pos2.y,
@ -1591,7 +1594,8 @@ void LIB_POLYLINE::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
if( fill == FILLED_WITH_BG_BODYCOLOR )
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(),
Buf_Poly_Drawings, 1, GetPenSize( ), color,
Buf_Poly_Drawings, 1, GetPenSize( ),
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ),
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE )
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(),
@ -1959,7 +1963,8 @@ void LIB_BEZIER::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
if( fill == FILLED_WITH_BG_BODYCOLOR )
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(),
&PolyPointsTraslated[0], 1, GetPenSize(), color,
&PolyPointsTraslated[0], 1, GetPenSize(),
(m_Flags & IS_MOVED) ? color : ReturnLayerColor( LAYER_DEVICE_BACKGROUND ),
ReturnLayerColor( LAYER_DEVICE_BACKGROUND ) );
else if( fill == FILLED_SHAPE )
GRPoly( &aPanel->m_ClipBox, aDC, m_PolyPoints.size(),

View File

@ -14,11 +14,11 @@
#include "gestfich.h"
#include "dialog_SVG_print_base.h"
#include "dcsvg.h"
#include "program.h"
#include "general.h"
#include "libeditframe.h"
// Keys for configuration
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
@ -35,7 +35,6 @@ class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base
{
private:
WinEDA_DrawFrame * m_Parent;
int m_ImageXSize_mm;
wxConfig* m_Config;
public:
@ -51,8 +50,11 @@ private:
void OnSetColorModeSelected( wxCommandEvent& event );
void SetPenWidth();
void PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref );
bool DrawPage( const wxString& FullFileName, BASE_SCREEN* screen,
bool aPrint_Sheet_Ref );
public:
static bool DrawSVGPage( WinEDA_DrawFrame * frame,
const wxString& FullFileName, BASE_SCREEN* screen,
bool aPrintBlackAndWhite = false,
bool aPrint_Sheet_Ref = false);
};
@ -66,6 +68,15 @@ void WinEDA_DrawFrame::SVG_Print( wxCommandEvent& event )
frame.ShowModal();
}
/* Creates the SVG print file for the current edited component.
*/
void WinEDA_LibeditFrame::SVG_Print_Component( const wxString& FullFileName )
{
DIALOG_SVG_PRINT::DrawSVGPage( this, FullFileName, GetScreen() );
}
/*!
* DIALOG_SVG_PRINT functions
@ -82,7 +93,6 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
{
SetFocus(); // Make ESC key working
m_ImageXSize_mm = 270;
if( m_Config )
{
m_Config->Read( PLOTSVGMODECOLOR_KEY, &s_PlotBlackAndWhite );
@ -130,6 +140,9 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
SetPenWidth();
g_DrawDefaultLineThickness =
ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits );
BASE_SCREEN* screen = m_Parent->GetBaseScreen();
BASE_SCREEN* oldscreen = screen;
@ -162,7 +175,8 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
fn = schframe->GetUniqueFilenameForCurrentSheet( ) + wxT( ".svg" );
bool success = DrawPage( fn.GetFullPath(), schscreen,
bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), schscreen,
m_ModeColorOption->GetSelection() == 0 ? false : true,
aPrint_Sheet_Ref );
msg = _( "Create file " ) + fn.GetFullPath();
if( !success )
@ -182,8 +196,11 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
fn = screen->m_FileName;
fn.SetExt( wxT( "svg" ) );
fn.MakeAbsolute( );
bool success = DrawPage( fn.GetFullPath(), screen, aPrint_Sheet_Ref );
bool success = DrawSVGPage( m_Parent, fn.GetFullPath(), screen,
m_ModeColorOption->GetSelection() == 0 ? false : true,
aPrint_Sheet_Ref );
msg = _( "Create file " ) + fn.GetFullPath();
if( !success )
@ -196,16 +213,16 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
ActiveScreen = oldscreen;
}
bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
bool DIALOG_SVG_PRINT::DrawSVGPage( WinEDA_DrawFrame * frame,
const wxString& FullFileName,
BASE_SCREEN* screen,
bool aPrintBlackAndWhite,
bool aPrint_Sheet_Ref)
{
int tmpzoom;
wxPoint tmp_startvisu;
wxSize SheetSize; // Sheet size in internal units
wxPoint old_org;
double dpi;
bool success = true;
tmp_startvisu = screen->m_StartVisu;
@ -216,17 +233,13 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
SheetSize = screen->ReturnPageSize( );
screen->SetScalingFactor( 1.0 );
dpi = (double) SheetSize.x * 25.4 / m_ImageXSize_mm;
WinEDA_DrawPanel* panel = frame->DrawPanel;
WinEDA_DrawPanel* panel = m_Parent->DrawPanel;
wxSVGFileDC dc( FullFileName, SheetSize.x, SheetSize.y, dpi );
wxSVGFileDC dc( FullFileName, SheetSize.x, SheetSize.y );
EDA_Rect tmp = panel->m_ClipBox;
GRResetPenAndBrush( &dc );
g_DrawDefaultLineThickness =
ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits );
GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? false : true );
GRForceBlackPen( aPrintBlackAndWhite );
panel->m_ClipBox.SetX( -0x3FFFFF0 );
@ -237,13 +250,13 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
screen->m_IsPrinting = true;
SetLocaleTo_C_standard( ); // Switch the locale to standard C (needed
// to print floating point numbers like 1.3)
m_Parent->PrintPage( &dc, aPrint_Sheet_Ref, 1, false );
frame->PrintPage( &dc, aPrint_Sheet_Ref, 1, false );
SetLocaleTo_Default( ); // revert to the current locale
screen->m_IsPrinting = false;
panel->m_ClipBox = tmp;
GRForceBlackPen( FALSE );
GRForceBlackPen( false );
screen->m_StartVisu = tmp_startvisu;
screen->m_DrawOrg = old_org;

View File

@ -25,6 +25,9 @@
void WinEDA_LibeditFrame::OnPlotCurrentComponent( wxCommandEvent& event )
{
LIB_COMPONENT* cmp = GetComponent();
wxString FullFileName;
wxString file_ext;
wxString mask;
if( cmp == NULL )
{
@ -38,13 +41,12 @@ void WinEDA_LibeditFrame::OnPlotCurrentComponent( wxCommandEvent& event )
{
bool fmt_is_jpeg = false; // could be selectable later. so keep this option.
wxString file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
wxString mask = wxT( "*." ) + file_ext;
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
mask = wxT( "*." ) + file_ext;
wxFileName fn( cmp->GetName() );
fn.SetExt( file_ext );
wxString FullFileName =
EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, TRUE );
@ -57,7 +59,17 @@ void WinEDA_LibeditFrame::OnPlotCurrentComponent( wxCommandEvent& event )
case ID_LIBEDIT_GEN_SVG_FILE:
{
GetScreen()->m_FileName = cmp->GetName();
file_ext = wxT( "svg" );
mask = wxT( "*." ) + file_ext;
wxFileName fn( cmp->GetName() );
fn.SetExt( file_ext );
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, TRUE );
if( FullFileName.IsEmpty() )
return;
/* Give a size to the SVG draw area = component size + margin
* the margin is 10% the size of the component size
*/
@ -67,9 +79,8 @@ void WinEDA_LibeditFrame::OnPlotCurrentComponent( wxCommandEvent& event )
// Add a small margin to the plot bounding box
componentSize.x = (int)(componentSize.x * 1.2);
componentSize.y = (int)(componentSize.y * 1.2);
GetScreen()->SetPageSize( componentSize );
WinEDA_DrawFrame::SVG_Print( event );
SVG_Print_Component( FullFileName );
GetScreen()->SetPageSize( pagesize );
}
break;

View File

@ -296,6 +296,13 @@ protected:
int aPrintMask, bool aPrintMirrorMode,
void * aData = NULL);
/** function SVG_Print_component
* Creates the SVG print file for the current edited component.
* @param aFullFileName = the full filename of the file
*/
void SVG_Print_Component( const wxString& aFullFileName );
DECLARE_EVENT_TABLE()
};

View File

@ -147,15 +147,6 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
if( item->m_Flags & IS_NEW )
{
if( DC )
{
if( item->Type() == COMPONENT_ARC_DRAW_TYPE )
Panel->GetParent()->DrawPanel->Refresh();
else
item->Draw( Panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
DefaultTransformMatrix );
}
SAFE_DELETE( item );
parent->SetDrawItem( NULL );
}
@ -207,11 +198,10 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC )
RedrawWhileMovingCursor( Panel, DC, TRUE );
Panel->GetScreen()->m_Curseur = curpos;
}
item->Draw( Panel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE, NULL,
DefaultTransformMatrix );
item->m_Flags = 0;
}
Panel->Refresh( );
}