Gerbview: serious code cleanup (with the serious help of Mark Roszko's work on Gerbview)
This commit is contained in:
parent
0ccd3bb3c2
commit
368bd1477b
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012-2016 Jean-Pierre Charras jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file class_gbr_display_options.h
|
||||
* @brief Class GBR_DISPLAY_OPTIONS is a helper class to handle display options
|
||||
* (filling modes and afew other options
|
||||
*/
|
||||
|
||||
#ifndef CLASS_GBR_DISPLAY_OPTIONS_H
|
||||
#define CLASS_GBR_DISPLAY_OPTIONS_H
|
||||
|
||||
#include <colors.h>
|
||||
|
||||
/**
|
||||
* @note Some of these parameters are used only for printing, some others only
|
||||
* for drawing on screen.
|
||||
*/
|
||||
|
||||
class GBR_DISPLAY_OPTIONS
|
||||
{
|
||||
public:
|
||||
bool m_DisplayFlashedItemsFill; ///< Option to draw flashed items (filled/sketch)
|
||||
bool m_DisplayLinesFill; ///< Option to draw line items (filled/sketch)
|
||||
bool m_DisplayPolygonsFill; ///< Option to draw polygons (filled/sketch)
|
||||
bool m_DisplayPolarCood; ///< Option to display coordinates in status bar in X,Y or Polar coords
|
||||
bool m_DisplayDCodes; ///< Option to show dcode values on items drawn with a dcode tool
|
||||
bool m_DisplayNegativeObjects; ///< Option to draw negative objects in a specific color
|
||||
bool m_IsPrinting; ///< true when printing a page, false when drawing on screen
|
||||
bool m_ForceBlackAndWhite; ///< Option print in blackand white (ont used id draw mode
|
||||
EDA_COLOR_T m_NegativeDrawColor; ///< The color used to draw negative objects, usually the
|
||||
///< background color, but not always, when negative objects
|
||||
///< must be visible
|
||||
EDA_COLOR_T m_BgDrawColor; ///< The background color
|
||||
|
||||
public:
|
||||
GBR_DISPLAY_OPTIONS()
|
||||
{
|
||||
m_DisplayFlashedItemsFill = true;
|
||||
m_DisplayLinesFill = true;
|
||||
m_DisplayPolygonsFill = true;
|
||||
m_DisplayPolarCood = false;
|
||||
m_DisplayDCodes = true;
|
||||
m_IsPrinting = false;
|
||||
m_DisplayNegativeObjects = false;
|
||||
m_ForceBlackAndWhite = false;
|
||||
m_NegativeDrawColor = DARKGRAY;
|
||||
m_BgDrawColor = BLACK;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // #ifndef CLASS_GBR_DISPLAY_OPTIONS_H
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
GBR_LAYOUT::GBR_LAYOUT()
|
||||
{
|
||||
m_printLayersMask.set();
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,6 +45,16 @@ GBR_LAYOUT::~GBR_LAYOUT()
|
|||
{
|
||||
}
|
||||
|
||||
bool GBR_LAYOUT::IsLayerPrintable( int aLayer ) const
|
||||
{
|
||||
for( unsigned ii = 0; ii < m_printLayersList.size(); ++ii )
|
||||
{
|
||||
if( m_printLayersList[ii] == aLayer )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
EDA_RECT GBR_LAYOUT::ComputeBoundingBox()
|
||||
{
|
||||
|
@ -69,7 +78,7 @@ EDA_RECT GBR_LAYOUT::ComputeBoundingBox()
|
|||
|
||||
// Redraw All GerbView layers, using a buffered mode or not
|
||||
void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
||||
const wxPoint& aOffset, bool aPrintBlackAndWhite )
|
||||
const wxPoint& aOffset, GBR_DISPLAY_OPTIONS* aDisplayOptions )
|
||||
{
|
||||
GERBVIEW_FRAME* gerbFrame = (GERBVIEW_FRAME*) aPanel->GetParent();
|
||||
|
||||
|
@ -80,9 +89,6 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
|||
// If aDrawMode = UNSPECIFIED_DRAWMODE, items are drawn to the main screen, and therefore
|
||||
// artifacts can happen with negative items or negative images
|
||||
|
||||
wxColour bgColor = MakeColour( gerbFrame->GetDrawBgColor() );
|
||||
wxBrush bgBrush( bgColor, wxBRUSHSTYLE_SOLID );
|
||||
|
||||
int bitmapWidth, bitmapHeight;
|
||||
wxDC* plotDC = aDC;
|
||||
|
||||
|
@ -115,6 +121,8 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
|||
wxPoint dev_org = aDC->GetDeviceOrigin();
|
||||
wxPoint logical_org = aDC->GetLogicalOrigin( );
|
||||
|
||||
wxColour bgColor = MakeColour( aDisplayOptions->m_BgDrawColor );
|
||||
wxBrush bgBrush( bgColor, wxBRUSHSTYLE_SOLID );
|
||||
|
||||
if( useBufferBitmap )
|
||||
{
|
||||
|
@ -139,12 +147,10 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
|||
|
||||
bool end = false;
|
||||
|
||||
// Draw layers from bottom to top, and active layer last
|
||||
// in non transparent modes, the last layer drawn mask mask previously drawn layer
|
||||
// Draw graphic layers from bottom to top, and the active layer is on the top of others.
|
||||
// In non transparent modes, the last layer drawn masks others layers
|
||||
for( int layer = GERBER_DRAWLAYERS_COUNT-1; !end; --layer )
|
||||
{
|
||||
EDA_COLOR_T layer_color = gerbFrame->GetLayerColor( layer );
|
||||
|
||||
int active_layer = gerbFrame->getActiveLayer();
|
||||
|
||||
if( layer == active_layer ) // active layer will be drawn after other layers
|
||||
|
@ -156,17 +162,24 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
|||
layer = active_layer;
|
||||
}
|
||||
|
||||
if( !gerbFrame->IsLayerVisible( layer ) )
|
||||
continue;
|
||||
|
||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
||||
|
||||
if( gerber == NULL ) // Graphic layer not yet used
|
||||
continue;
|
||||
|
||||
// Force black and white draw mode on request:
|
||||
if( aPrintBlackAndWhite )
|
||||
gerbFrame->SetLayerColor( layer, gerbFrame->GetDrawBgColor() == BLACK ? WHITE : BLACK );
|
||||
if( aDisplayOptions->m_IsPrinting )
|
||||
gerber->m_IsVisible = IsLayerPrintable( layer );
|
||||
else
|
||||
gerber->m_IsVisible = gerbFrame->IsLayerVisible( layer );
|
||||
|
||||
if( !gerber->m_IsVisible )
|
||||
continue;
|
||||
|
||||
gerber->m_PositiveDrawColor = gerbFrame->GetLayerColor( layer );
|
||||
|
||||
// Force black and white draw mode on request:
|
||||
if( aDisplayOptions->m_ForceBlackAndWhite )
|
||||
gerber->m_PositiveDrawColor = ( aDisplayOptions->m_BgDrawColor == BLACK ) ? WHITE : BLACK;
|
||||
|
||||
if( useBufferBitmap )
|
||||
{
|
||||
|
@ -217,7 +230,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
|||
if( gerber->m_ImageNegative )
|
||||
{
|
||||
// Draw background negative (i.e. in graphic layer color) for negative images.
|
||||
EDA_COLOR_T neg_color = gerbFrame->GetLayerColor( layer );
|
||||
EDA_COLOR_T neg_color = gerber->GetPositiveDrawColor();
|
||||
|
||||
GRSetDrawMode( &layerDC, GR_COPY );
|
||||
GRFilledRect( &drawBox, plotDC, drawBox.GetX(), drawBox.GetY(),
|
||||
|
@ -250,12 +263,9 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
|||
if( dcode_highlight && dcode_highlight == item->m_DCode )
|
||||
DrawModeAddHighlight( &drawMode);
|
||||
|
||||
item->Draw( aPanel, plotDC, drawMode, wxPoint(0,0) );
|
||||
item->Draw( aPanel, plotDC, drawMode, wxPoint(0,0), aDisplayOptions );
|
||||
doBlit = true;
|
||||
}
|
||||
|
||||
if( aPrintBlackAndWhite )
|
||||
gerbFrame->SetLayerColor( layer, layer_color );
|
||||
}
|
||||
|
||||
if( doBlit && useBufferBitmap ) // Blit is used only if aDrawMode >= 0
|
||||
|
@ -305,3 +315,75 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
|||
delete screenBitmap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GBR_LAYOUT::DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
||||
GR_DRAWMODE aDrawMode, EDA_COLOR_T aDrawColor )
|
||||
{
|
||||
wxPoint pos;
|
||||
int width;
|
||||
wxString Line;
|
||||
|
||||
GRSetDrawMode( aDC, aDrawMode );
|
||||
|
||||
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
||||
{
|
||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
||||
|
||||
if( gerber == NULL ) // Graphic layer not yet used
|
||||
continue;
|
||||
|
||||
if( ! gerber->m_IsVisible )
|
||||
continue;
|
||||
|
||||
for( GERBER_DRAW_ITEM* item = gerber->GetItemsList(); item != NULL; item = item->Next() )
|
||||
{
|
||||
|
||||
if( item->m_DCode <= 0 )
|
||||
continue;
|
||||
|
||||
if( item->m_Flashed || item->m_Shape == GBR_ARC )
|
||||
{
|
||||
pos = item->m_Start;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.x = (item->m_Start.x + item->m_End.x) / 2;
|
||||
pos.y = (item->m_Start.y + item->m_End.y) / 2;
|
||||
}
|
||||
|
||||
pos = item->GetABPosition( pos );
|
||||
|
||||
Line.Printf( wxT( "D%d" ), item->m_DCode );
|
||||
|
||||
if( item->GetDcodeDescr() )
|
||||
width = item->GetDcodeDescr()->GetShapeDim( item );
|
||||
else
|
||||
width = std::min( item->m_Size.x, item->m_Size.y );
|
||||
|
||||
double orient = TEXT_ORIENT_HORIZ;
|
||||
|
||||
if( item->m_Flashed )
|
||||
{
|
||||
// A reasonable size for text is width/3 because most of time this text has 3 chars.
|
||||
width /= 3;
|
||||
}
|
||||
else // this item is a line
|
||||
{
|
||||
wxPoint delta = item->m_Start - item->m_End;
|
||||
|
||||
if( abs( delta.x ) < abs( delta.y ) )
|
||||
orient = TEXT_ORIENT_VERT;
|
||||
|
||||
// A reasonable size for text is width/2 because text needs margin below and above it.
|
||||
// a margin = width/4 seems good
|
||||
width /= 2;
|
||||
}
|
||||
|
||||
DrawGraphicText( aPanel->GetClipBox(), aDC, pos, aDrawColor, Line,
|
||||
orient, wxSize( width, width ),
|
||||
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
|
||||
0, false, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <gerbview.h> // GERBER_DRAWLAYERS_COUNT
|
||||
#include <class_title_block.h>
|
||||
#include <class_gerber_draw_item.h>
|
||||
#include <class_gbr_display_options.h>
|
||||
|
||||
#include <gr_basic.h>
|
||||
|
||||
|
@ -52,7 +53,8 @@ private:
|
|||
EDA_RECT m_BoundingBox;
|
||||
TITLE_BLOCK m_titles;
|
||||
wxPoint m_originAxisPosition;
|
||||
std::bitset <GERBER_DRAWLAYERS_COUNT> m_printLayersMask; // When printing: the list of layers to print
|
||||
std::vector<int> m_printLayersList; // When printing: the list of graphic layers Id to print
|
||||
|
||||
public:
|
||||
|
||||
GBR_LAYOUT();
|
||||
|
@ -97,45 +99,72 @@ public:
|
|||
/**
|
||||
* Function Draw.
|
||||
* Redraw the CLASS_GBR_LAYOUT items but not cursors, axis or grid.
|
||||
* @param aPanel = the panel relative to the board
|
||||
* @param aPanel = the draw canvas
|
||||
* @param aDC = the current device context
|
||||
* @param aDrawMode = GR_COPY, GR_OR ... (not always used)
|
||||
* @param aOffset = an draw offset value
|
||||
* @param aPrintBlackAndWhite = true to force black and white insdeat of color
|
||||
* useful only to print/plot gebview layers
|
||||
* @param aDisplayOptions = a GBR_DISPLAY_OPTIONS for draw/print display opts
|
||||
*/
|
||||
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
||||
GR_DRAWMODE aDrawMode, const wxPoint& aOffset,
|
||||
bool aPrintBlackAndWhite = false );
|
||||
GBR_DISPLAY_OPTIONS* aDisplayOptions );
|
||||
|
||||
/**
|
||||
* Function DrawItemsDCodeID
|
||||
* Draw the DCode value (if exists) corresponding to gerber item
|
||||
* (polygons do not have a DCode)
|
||||
* @param aPanel = the draw canvas
|
||||
* @param aDC = the current device context
|
||||
* @param aDrawMode = GR_COPY, GR_OR ...
|
||||
* @param aDrawColor = the color of dcode texts
|
||||
*/
|
||||
void DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
||||
GR_DRAWMODE aDrawMode, EDA_COLOR_T aDrawColor );
|
||||
|
||||
|
||||
/**
|
||||
* Function SetPrintableLayers
|
||||
* changes the list of printable layers
|
||||
* @param aLayerMask = The new bit-mask of printable layers
|
||||
*/
|
||||
void SetPrintableLayers( const std::bitset <GERBER_DRAWLAYERS_COUNT>& aLayerMask )
|
||||
void SetPrintableLayers( const std::vector<int>& aLayerList )
|
||||
{
|
||||
m_printLayersMask = aLayerMask;
|
||||
m_printLayersList = aLayerList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetPrintableLayers
|
||||
* @return the bit-mask of printable layers
|
||||
*/
|
||||
std::bitset <GERBER_DRAWLAYERS_COUNT> GetPrintableLayers()
|
||||
std::vector<int> GetPrintableLayers()
|
||||
{
|
||||
return m_printLayersMask;
|
||||
return m_printLayersList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function ClearPrintableLayers
|
||||
*/
|
||||
void ClearPrintableLayers()
|
||||
{
|
||||
m_printLayersList.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function AddLayerToPrintableList
|
||||
*/
|
||||
void AddLayerToPrintableList( int aLayer)
|
||||
{
|
||||
m_printLayersList.push_back( aLayer );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function IsLayerPrintable
|
||||
* tests whether a given layer is visible
|
||||
* @param aLayer = The layer to be tested
|
||||
* @return bool - true if the layer is visible.
|
||||
* @return bool - true if the layer is in print list.
|
||||
*/
|
||||
bool IsLayerPrintable( int aLayer ) const
|
||||
{
|
||||
return m_printLayersMask[ aLayer ];
|
||||
}
|
||||
bool IsLayerPrintable( int aLayer ) const;
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Show( int nestLevel, std::ostream& os ) const; // overload
|
||||
|
|
|
@ -57,46 +57,11 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberImageFile ) :
|
|||
}
|
||||
|
||||
|
||||
// Copy constructor
|
||||
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) :
|
||||
EDA_ITEM( aSource )
|
||||
{
|
||||
m_GerberImageFile = aSource.m_GerberImageFile;
|
||||
m_Shape = aSource.m_Shape;
|
||||
|
||||
m_Flags = aSource.m_Flags;
|
||||
SetTimeStamp( aSource.m_TimeStamp );
|
||||
|
||||
SetStatus( aSource.GetStatus() );
|
||||
m_Start = aSource.m_Start;
|
||||
m_End = aSource.m_End;
|
||||
m_Size = aSource.m_Size;
|
||||
m_Shape = aSource.m_Shape;
|
||||
m_Flashed = aSource.m_Flashed;
|
||||
m_DCode = aSource.m_DCode;
|
||||
m_PolyCorners = aSource.m_PolyCorners;
|
||||
m_UnitsMetric = aSource.m_UnitsMetric;
|
||||
m_LayerNegative = aSource.m_LayerNegative;
|
||||
m_swapAxis = aSource.m_swapAxis;
|
||||
m_mirrorA = aSource.m_mirrorA;
|
||||
m_mirrorB = aSource.m_mirrorB;
|
||||
m_layerOffset = aSource.m_layerOffset;
|
||||
m_drawScale = aSource.m_drawScale;
|
||||
m_lyrRotation = aSource.m_lyrRotation;
|
||||
}
|
||||
|
||||
|
||||
GERBER_DRAW_ITEM::~GERBER_DRAW_ITEM()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
GERBER_DRAW_ITEM* GERBER_DRAW_ITEM::Copy() const
|
||||
{
|
||||
return new GERBER_DRAW_ITEM( *this );
|
||||
}
|
||||
|
||||
|
||||
int GERBER_DRAW_ITEM::GetLayer() const
|
||||
{
|
||||
// returns the layer this item is on, or 0 if the m_GerberImageFile is NULL.
|
||||
|
@ -272,11 +237,6 @@ void GERBER_DRAW_ITEM::MoveXY( const wxPoint& aMoveVector )
|
|||
}
|
||||
|
||||
|
||||
bool GERBER_DRAW_ITEM::Save( FILE* aFile ) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GERBER_DRAW_ITEM::HasNegativeItems()
|
||||
{
|
||||
bool isClear = m_LayerNegative ^ m_GerberImageFile->m_ImageNegative;
|
||||
|
@ -306,7 +266,7 @@ bool GERBER_DRAW_ITEM::HasNegativeItems()
|
|||
|
||||
|
||||
void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
||||
const wxPoint& aOffset )
|
||||
const wxPoint& aOffset, GBR_DISPLAY_OPTIONS* aDrawOptions )
|
||||
{
|
||||
// used when a D_CODE is not found. default D_CODE to draw a flashed item
|
||||
static D_CODE dummyD_CODE( 0 );
|
||||
|
@ -316,22 +276,18 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra
|
|||
int halfPenWidth;
|
||||
static bool show_err;
|
||||
D_CODE* d_codeDescr = GetDcodeDescr();
|
||||
GERBVIEW_FRAME* gerbFrame = (GERBVIEW_FRAME*) aPanel->GetParent();
|
||||
|
||||
if( d_codeDescr == NULL )
|
||||
d_codeDescr = &dummyD_CODE;
|
||||
|
||||
if( gerbFrame->IsLayerVisible( GetLayer() ) == false )
|
||||
return;
|
||||
|
||||
color = gerbFrame->GetLayerColor( GetLayer() );
|
||||
color = m_GerberImageFile->GetPositiveDrawColor();
|
||||
|
||||
if( aDrawMode & GR_HIGHLIGHT )
|
||||
ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
|
||||
|
||||
ColorApplyHighlightFlag( &color );
|
||||
|
||||
alt_color = gerbFrame->GetNegativeItemsColor();
|
||||
alt_color = aDrawOptions->m_NegativeDrawColor;
|
||||
|
||||
/* isDark is true if flash is positive and should use a drawing
|
||||
* color other than the background color, else use the background color
|
||||
|
@ -347,12 +303,12 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra
|
|||
|
||||
GRSetDrawMode( aDC, aDrawMode );
|
||||
|
||||
isFilled = gerbFrame->DisplayLinesSolidMode();
|
||||
isFilled = aDrawOptions->m_DisplayLinesFill;
|
||||
|
||||
switch( m_Shape )
|
||||
{
|
||||
case GBR_POLYGON:
|
||||
isFilled = gerbFrame->DisplayPolygonsSolidMode();
|
||||
isFilled = aDrawOptions->m_DisplayPolygonsFill;
|
||||
|
||||
if( !isDark )
|
||||
isFilled = true;
|
||||
|
@ -411,7 +367,7 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra
|
|||
case GBR_SPOT_OVAL:
|
||||
case GBR_SPOT_POLY:
|
||||
case GBR_SPOT_MACRO:
|
||||
isFilled = gerbFrame->DisplayFlashedItemsSolidMode();
|
||||
isFilled = aDrawOptions->m_DisplayFlashedItemsFill;
|
||||
d_codeDescr->DrawFlashedShape( this, aPanel->GetClipBox(), aDC, color, alt_color,
|
||||
m_Start, isFilled );
|
||||
break;
|
||||
|
|
|
@ -38,6 +38,7 @@ class GERBER_FILE_IMAGE;
|
|||
class GBR_LAYOUT;
|
||||
class D_CODE;
|
||||
class MSG_PANEL_ITEM;
|
||||
class GBR_DISPLAY_OPTIONS;
|
||||
|
||||
|
||||
/* Shapes id for basic shapes ( .m_Shape member ) */
|
||||
|
@ -103,17 +104,8 @@ private:
|
|||
|
||||
public:
|
||||
GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberparams );
|
||||
GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource );
|
||||
~GERBER_DRAW_ITEM();
|
||||
|
||||
/**
|
||||
* Function Copy
|
||||
* will copy this object
|
||||
* the corresponding type.
|
||||
* @return - GERBER_DRAW_ITEM*
|
||||
*/
|
||||
GERBER_DRAW_ITEM* Copy() const;
|
||||
|
||||
GERBER_DRAW_ITEM* Next() const { return static_cast<GERBER_DRAW_ITEM*>( Pnext ); }
|
||||
GERBER_DRAW_ITEM* Back() const { return static_cast<GERBER_DRAW_ITEM*>( Pback ); }
|
||||
|
||||
|
@ -206,7 +198,7 @@ public:
|
|||
|
||||
/* Display on screen: */
|
||||
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
||||
GR_DRAWMODE aDrawMode, const wxPoint&aOffset );
|
||||
GR_DRAWMODE aDrawMode, const wxPoint&aOffset, GBR_DISPLAY_OPTIONS* aDrawOptions );
|
||||
|
||||
/**
|
||||
* Function ConvertSegmentToPolygon
|
||||
|
@ -257,13 +249,6 @@ public:
|
|||
return wxT( "GERBER_DRAW_ITEM" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function Save.
|
||||
* currently: no nothing, but must be defined to meet requirements
|
||||
* of the basic class
|
||||
*/
|
||||
bool Save( FILE* aFile ) const;
|
||||
|
||||
/**
|
||||
* Function UnLink
|
||||
* detaches this object from its owner.
|
||||
|
|
|
@ -92,6 +92,8 @@ GERBER_FILE_IMAGE::GERBER_FILE_IMAGE( GERBVIEW_FRAME* aParent, int aLayer )
|
|||
{
|
||||
m_parent = aParent;
|
||||
m_GraphicLayer = aLayer; // Graphic layer Number
|
||||
m_IsVisible = true; // must be drawn
|
||||
m_PositiveDrawColor = WHITE; // The color used to draw positive items for this image
|
||||
|
||||
m_Selected_Tool = FIRST_DCODE;
|
||||
m_FileFunction = NULL; // file function parameters
|
||||
|
|
|
@ -105,6 +105,9 @@ public:
|
|||
|
||||
bool m_InUse; // true if this image is currently in use
|
||||
// (a file is loaded in it)
|
||||
bool m_IsVisible; // true if the draw layer is visible and must be drawn
|
||||
// false if it must be not drawn
|
||||
EDA_COLOR_T m_PositiveDrawColor; // The color used to draw positive items
|
||||
wxString m_FileName; // Full File Name for this layer
|
||||
wxString m_ImageName; // Image name, from IN <name>* command
|
||||
bool m_IsX2_file; // true if a X2 gerber attribute was found in file
|
||||
|
@ -172,6 +175,8 @@ public:
|
|||
int UsedDcodeNumber();
|
||||
virtual void ResetDefaultValues();
|
||||
|
||||
EDA_COLOR_T GetPositiveDrawColor() const { return m_PositiveDrawColor; }
|
||||
|
||||
/**
|
||||
* Function GetParent
|
||||
* @return the GERBVIEW_FRAME parent of this GERBER_FILE_IMAGE
|
||||
|
|
|
@ -231,24 +231,18 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
|
|||
|
||||
int DIALOG_PRINT_USING_PRINTER::SetLayerSetFromListSelection()
|
||||
{
|
||||
int page_count = 0;
|
||||
std::bitset <GERBER_DRAWLAYERS_COUNT> layerMask;
|
||||
std::vector<int> layerList;
|
||||
|
||||
for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
|
||||
{
|
||||
if( m_BoxSelectLayer[ii]->IsChecked() && m_BoxSelectLayer[ii]->IsEnabled() )
|
||||
{
|
||||
page_count++;
|
||||
layerMask[ii] = true;
|
||||
}
|
||||
else
|
||||
layerMask[ii] = false;
|
||||
layerList.push_back( ii );
|
||||
}
|
||||
|
||||
m_Parent->GetGerberLayout()->SetPrintableLayers( layerMask );
|
||||
s_Parameters.m_PageCount = page_count;
|
||||
m_Parent->GetGerberLayout()->SetPrintableLayers( layerList );
|
||||
s_Parameters.m_PageCount = layerList.size();
|
||||
|
||||
return page_count;
|
||||
return s_Parameters.m_PageCount;
|
||||
}
|
||||
|
||||
|
||||
|
@ -354,7 +348,7 @@ bool DIALOG_PRINT_USING_PRINTER::PreparePrintPrms()
|
|||
|
||||
// If no layer selected, we have no plot. prompt user if it happens
|
||||
// because he could think there is a bug in Pcbnew:
|
||||
if( m_Parent->GetGerberLayout()->GetPrintableLayers().none() )
|
||||
if( m_Parent->GetGerberLayout()->GetPrintableLayers().size() == 0 )
|
||||
{
|
||||
DisplayError( this, _( "No layer selected" ) );
|
||||
return false;
|
||||
|
|
|
@ -47,46 +47,43 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
|
|||
{
|
||||
wxCHECK_RET( aData != NULL, wxT( "aData cannot be NULL." ) );
|
||||
|
||||
// Save current draw options, because print mode has specific options:
|
||||
GBR_DISPLAY_OPTIONS imgDisplayOptions = m_DisplayOptions;
|
||||
std::bitset <GERBER_DRAWLAYERS_COUNT> printLayersMask = GetGerberLayout()->GetPrintableLayers();
|
||||
|
||||
// Set draw options for printing:
|
||||
m_DisplayOptions.m_DisplayFlashedItemsFill = true;
|
||||
m_DisplayOptions.m_DisplayLinesFill = true;
|
||||
m_DisplayOptions.m_DisplayPolygonsFill = true;
|
||||
m_DisplayOptions.m_DisplayDCodes = false;
|
||||
m_DisplayOptions.m_IsPrinting = true;
|
||||
|
||||
PRINT_PARAMETERS* printParameters = (PRINT_PARAMETERS*) aData;
|
||||
|
||||
// Find the layer to be printed
|
||||
int page = printParameters->m_Flags; // contains the page number (not necessarily graphic layer number)
|
||||
int layer = 0;
|
||||
// Build a suitable draw options for printing:
|
||||
GBR_DISPLAY_OPTIONS displayOptions;
|
||||
displayOptions.m_DisplayFlashedItemsFill = true;
|
||||
displayOptions.m_DisplayLinesFill = true;
|
||||
displayOptions.m_DisplayPolygonsFill = true;
|
||||
displayOptions.m_DisplayDCodes = false;
|
||||
displayOptions.m_IsPrinting = true;
|
||||
displayOptions.m_ForceBlackAndWhite = printParameters->m_Print_Black_and_White;
|
||||
displayOptions.m_NegativeDrawColor = GetDrawBgColor();
|
||||
displayOptions.m_BgDrawColor = GetDrawBgColor();
|
||||
|
||||
// Find the layer number for the printed page (search through the mask and count bits)
|
||||
while( page > 0 )
|
||||
{
|
||||
if( printLayersMask[layer++] )
|
||||
--page;
|
||||
}
|
||||
--layer;
|
||||
// Find the graphic layer to be printed
|
||||
int page_number = printParameters->m_Flags; // contains the page number (not necessarily graphic layer number)
|
||||
|
||||
std::bitset <GERBER_DRAWLAYERS_COUNT> printCurrLayerMask;
|
||||
printCurrLayerMask.reset();
|
||||
printCurrLayerMask.set( layer );
|
||||
GetGerberLayout()->SetPrintableLayers( printCurrLayerMask );
|
||||
// Find the graphic layer number for the printed page (search through the mask and count bits)
|
||||
std::vector<int> printList = GetGerberLayout()->GetPrintableLayers();
|
||||
|
||||
if( printList.size() < 1 )
|
||||
return;
|
||||
|
||||
int graphiclayer = printList[page_number-1];
|
||||
|
||||
// In Gerbview, only one graphic layer is printed by page.
|
||||
// So we temporary set the graphic layer list to print with only onle layer id
|
||||
GetGerberLayout()->ClearPrintableLayers();
|
||||
GetGerberLayout()->AddLayerToPrintableList( graphiclayer );
|
||||
m_canvas->SetPrintMirrored( aPrintMirrorMode );
|
||||
bool printBlackAndWhite = printParameters->m_Print_Black_and_White;
|
||||
|
||||
GetGerberLayout()->Draw( m_canvas, aDC, (GR_DRAWMODE) 0,
|
||||
wxPoint( 0, 0 ), printBlackAndWhite );
|
||||
wxPoint( 0, 0 ), &displayOptions );
|
||||
|
||||
m_canvas->SetPrintMirrored( false );
|
||||
|
||||
// Restore draw options:
|
||||
GetGerberLayout()->SetPrintableLayers( printLayersMask );
|
||||
m_DisplayOptions = imgDisplayOptions;
|
||||
// Restore the list of printable graphic layers list:
|
||||
GetGerberLayout()->SetPrintableLayers( printList );
|
||||
}
|
||||
|
||||
|
||||
|
@ -117,16 +114,21 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
|||
}
|
||||
|
||||
// Draw according to the current setting. This needs to be GR_COPY or GR_OR.
|
||||
GetGerberLayout()->Draw( m_canvas, DC, drawMode, wxPoint( 0, 0 ) );
|
||||
m_DisplayOptions.m_NegativeDrawColor = GetNegativeItemsColor();
|
||||
m_DisplayOptions.m_BgDrawColor = GetDrawBgColor();
|
||||
GetGerberLayout()->Draw( m_canvas, DC, drawMode, wxPoint( 0, 0 ), &m_DisplayOptions );
|
||||
|
||||
if( m_DisplayOptions.m_DisplayDCodes )
|
||||
{
|
||||
EDA_COLOR_T dcode_color = GetVisibleElementColor( DCODES_VISIBLE );
|
||||
GetGerberLayout()->DrawItemsDCodeID( m_canvas, DC, GR_COPY, dcode_color );
|
||||
}
|
||||
|
||||
// Draw the "background" now, i.e. grid and axis after gerber layers
|
||||
// because most of time the actual background is erased by successive drawings of each gerber
|
||||
// layer mainly in COPY mode
|
||||
m_canvas->DrawBackGround( DC );
|
||||
|
||||
if( IsElementVisible( DCODES_VISIBLE ) )
|
||||
DrawItemsDCodeID( DC, GR_COPY );
|
||||
|
||||
DrawWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );
|
||||
|
||||
#ifdef USE_WX_OVERLAY
|
||||
|
@ -147,77 +149,3 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
|||
// relative to the active layer
|
||||
UpdateTitleAndInfo();
|
||||
}
|
||||
|
||||
|
||||
void GERBVIEW_FRAME::DrawItemsDCodeID( wxDC* aDC, GR_DRAWMODE aDrawMode )
|
||||
{
|
||||
wxPoint pos;
|
||||
int width;
|
||||
double orient;
|
||||
wxString Line;
|
||||
|
||||
GRSetDrawMode( aDC, aDrawMode );
|
||||
|
||||
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
||||
{
|
||||
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
|
||||
|
||||
if( gerber == NULL ) // Graphic layer not yet used
|
||||
continue;
|
||||
|
||||
if( IsLayerVisible( layer ) == false )
|
||||
continue;
|
||||
|
||||
for( GERBER_DRAW_ITEM* item = gerber->GetItemsList(); item != NULL; item = item->Next() )
|
||||
{
|
||||
|
||||
if( item->m_DCode <= 0 )
|
||||
continue;
|
||||
|
||||
if( item->m_Flashed || item->m_Shape == GBR_ARC )
|
||||
{
|
||||
pos = item->m_Start;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.x = (item->m_Start.x + item->m_End.x) / 2;
|
||||
pos.y = (item->m_Start.y + item->m_End.y) / 2;
|
||||
}
|
||||
|
||||
pos = item->GetABPosition( pos );
|
||||
|
||||
Line.Printf( wxT( "D%d" ), item->m_DCode );
|
||||
|
||||
if( item->GetDcodeDescr() )
|
||||
width = item->GetDcodeDescr()->GetShapeDim( item );
|
||||
else
|
||||
width = std::min( item->m_Size.x, item->m_Size.y );
|
||||
|
||||
orient = TEXT_ORIENT_HORIZ;
|
||||
|
||||
if( item->m_Flashed )
|
||||
{
|
||||
// A reasonable size for text is width/3 because most of time this text has 3 chars.
|
||||
width /= 3;
|
||||
}
|
||||
else // this item is a line
|
||||
{
|
||||
wxPoint delta = item->m_Start - item->m_End;
|
||||
|
||||
if( abs( delta.x ) < abs( delta.y ) )
|
||||
orient = TEXT_ORIENT_VERT;
|
||||
|
||||
// A reasonable size for text is width/2 because text needs margin below and above it.
|
||||
// a margin = width/4 seems good
|
||||
width /= 2;
|
||||
}
|
||||
|
||||
int color = GetVisibleElementColor( DCODES_VISIBLE );
|
||||
|
||||
DrawGraphicText( m_canvas->GetClipBox(), aDC, pos, (EDA_COLOR_T) color, Line,
|
||||
orient, wxSize( width, width ),
|
||||
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
|
||||
0, false, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <class_gbr_layout.h>
|
||||
#include <class_gbr_screen.h>
|
||||
#include <class_page_info.h>
|
||||
#include <class_gbr_display_options.h>
|
||||
|
||||
#define NO_AVAILABLE_LAYERS UNDEFINED_LAYER
|
||||
|
||||
|
@ -47,35 +48,6 @@ class GBR_LAYER_BOX_SELECTOR;
|
|||
class GERBER_DRAW_ITEM;
|
||||
|
||||
|
||||
/**
|
||||
* Class GBR_DISPLAY_OPTIONS
|
||||
* A helper class to handle display options.
|
||||
*/
|
||||
class GBR_DISPLAY_OPTIONS
|
||||
{
|
||||
public:
|
||||
bool m_DisplayFlashedItemsFill;
|
||||
bool m_DisplayLinesFill;
|
||||
bool m_DisplayPolygonsFill;
|
||||
bool m_DisplayPolarCood;
|
||||
bool m_DisplayDCodes;
|
||||
bool m_DisplayNegativeObjects;
|
||||
bool m_IsPrinting;
|
||||
|
||||
public:
|
||||
GBR_DISPLAY_OPTIONS()
|
||||
{
|
||||
m_DisplayFlashedItemsFill = true;
|
||||
m_DisplayLinesFill = true;
|
||||
m_DisplayPolygonsFill = true;
|
||||
m_DisplayPolarCood = false;
|
||||
m_DisplayDCodes = true;
|
||||
m_IsPrinting = false;
|
||||
m_DisplayNegativeObjects = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Class GERBVIEW_FRAME
|
||||
* is the main window used in GerbView.
|
||||
|
@ -659,15 +631,6 @@ public:
|
|||
virtual void PrintPage( wxDC* aDC, LSET aPrintMasklayer, bool aPrintMirrorMode,
|
||||
void* aData = NULL );
|
||||
|
||||
/**
|
||||
* Function DrawItemsDCodeID
|
||||
* Draw the DCode value (if exists) corresponding to gerber item
|
||||
* (polygons do not have a DCode)
|
||||
* @param aDC = the current device context
|
||||
* @param aDrawMode = GR_COPY, GR_OR ...
|
||||
*/
|
||||
void DrawItemsDCodeID( wxDC* aDC, GR_DRAWMODE aDrawMode );
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue