Gerbview: more code cleanup. Rename class GERBER_IMAGE GERBER_FILE_IMAGE, because it handles the gerber image and the gerber file info.

This commit is contained in:
jean-pierre charras 2016-05-25 16:48:38 +02:00
parent 1c21410f1f
commit 8c8a1238f1
26 changed files with 382 additions and 387 deletions

View File

@ -28,7 +28,7 @@ set( GERBVIEW_SRCS
class_DCodeSelectionbox.cpp
class_gbr_screen.cpp
class_gbr_layout.cpp
class_GERBER.cpp
class_gerber_file_image.cpp
class_gerber_draw_item.cpp
class_gerbview_layer_widget.cpp
class_gbr_layer_box_selector.cpp

View File

@ -34,7 +34,7 @@
#include <gr_basic.h>
#include <gerbview.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>

View File

@ -80,13 +80,13 @@ struct EXCELLON_CMD
/* EXCELLON_IMAGE handle a drill image
* It is derived from GERBER_IMAGE because there is a lot of likeness
* It is derived from GERBER_FILE_IMAGE because there is a lot of likeness
* between EXCELLON files and GERBER files
* DCode aperture are also similat to T Codes.
* So we can reuse GERBER_IMAGE to handle EXCELLON_IMAGE with very few new functions
* So we can reuse GERBER_FILE_IMAGE to handle EXCELLON_IMAGE with very few new functions
*/
class EXCELLON_IMAGE : public GERBER_IMAGE
class EXCELLON_IMAGE : public GERBER_FILE_IMAGE
{
private:
enum excellon_state {
@ -97,7 +97,7 @@ private:
bool m_SlotOn; // true during an oblong drill definition
public: EXCELLON_IMAGE( GERBVIEW_FRAME* aParent, int layer ) :
GERBER_IMAGE( aParent, layer )
GERBER_FILE_IMAGE( aParent, layer )
{
m_State = READ_HEADER_STATE;
m_SlotOn = false;
@ -108,7 +108,7 @@ public: EXCELLON_IMAGE( GERBVIEW_FRAME* aParent, int layer ) :
virtual void ResetDefaultValues()
{
GERBER_IMAGE::ResetDefaultValues();
GERBER_FILE_IMAGE::ResetDefaultValues();
SelectUnits( false );
}

View File

@ -32,7 +32,7 @@
#include <common.h>
#include <colors_selection.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <class_gbr_layer_box_selector.h>

View File

@ -28,7 +28,12 @@
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <drawtxt.h>
#include <gerbview_frame.h>
#include <class_drawpanel.h>
#include <class_gbr_layout.h>
#include <class_gerber_file_image.h>
GBR_LAYOUT::GBR_LAYOUT()
{
@ -51,3 +56,243 @@ EDA_RECT GBR_LAYOUT::ComputeBoundingBox()
SetBoundingBox( bbox );
return bbox;
}
// 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 )
{
GERBVIEW_FRAME* gerbFrame = (GERBVIEW_FRAME*) aPanel->GetParent();
// Because Images can be negative (i.e with background filled in color) items are drawn
// graphic layer per graphic layer, after the background is filled
// to a temporary bitmap
// at least when aDrawMode = GR_COPY or aDrawMode = GR_OR
// 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;
aPanel->GetClientSize( &bitmapWidth, &bitmapHeight );
wxBitmap* layerBitmap = NULL;
wxBitmap* screenBitmap = NULL;
wxMemoryDC layerDC; // used sequentially for each gerber layer
wxMemoryDC screenDC;
// When each image must be drawn using GR_OR (transparency mode)
// or GR_COPY (stacked mode) we must use a temporary bitmap
// to draw gerber images.
// this is due to negative objects (drawn using background color) that create artifacts
// on other images when drawn on screen
bool useBufferBitmap = false;
#ifndef __WXMAC__
// Can't work with MAC
// Don't try this with retina display
if( (aDrawMode == GR_COPY) || ( aDrawMode == GR_OR ) )
useBufferBitmap = true;
#endif
// these parameters are saved here, because they are modified
// and restored later
EDA_RECT drawBox = *aPanel->GetClipBox();
double scale;
aDC->GetUserScale(&scale, &scale);
wxPoint dev_org = aDC->GetDeviceOrigin();
wxPoint logical_org = aDC->GetLogicalOrigin( );
if( useBufferBitmap )
{
layerBitmap = new wxBitmap( bitmapWidth, bitmapHeight );
screenBitmap = new wxBitmap( bitmapWidth, bitmapHeight );
layerDC.SelectObject( *layerBitmap );
aPanel->DoPrepareDC( layerDC );
aPanel->SetClipBox( drawBox );
layerDC.SetBackground( bgBrush );
layerDC.SetBackgroundMode( wxSOLID );
layerDC.Clear();
screenDC.SelectObject( *screenBitmap );
screenDC.SetBackground( bgBrush );
screenDC.SetBackgroundMode( wxSOLID );
screenDC.Clear();
plotDC = &layerDC;
}
bool doBlit = false; // this flag requests an image transfer to actual screen when true.
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
for( int layer = GERBER_DRAWLAYERS_COUNT-1; !end; --layer )
{
int active_layer = gerbFrame->getActiveLayer();
if( layer == active_layer ) // active layer will be drawn after other layers
continue;
if( layer < 0 ) // last loop: draw active layer
{
end = true;
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( useBufferBitmap )
{
// Draw each layer into a bitmap first. Negative Gerber
// layers are drawn in background color.
if( gerber->HasNegativeItems() && doBlit )
{
// Set Device origin, logical origin and scale to default values
// This is needed by Blit function when using a mask.
// Beside, for Blit call, both layerDC and screenDc must have the same settings
layerDC.SetDeviceOrigin(0,0);
layerDC.SetLogicalOrigin( 0, 0 );
layerDC.SetUserScale( 1, 1 );
if( aDrawMode == GR_COPY )
{
// Use the layer bitmap itself as a mask when blitting. The bitmap
// cannot be referenced by a device context when setting the mask.
layerDC.SelectObject( wxNullBitmap );
layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) );
layerDC.SelectObject( *layerBitmap );
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
}
else if( aDrawMode == GR_OR )
{
// On Linux with a large screen, this version is much faster and without
// flicker, but gives a Pcbnew look where layer colors blend together.
// Plus it works only because the background color is black. But it may
// be more usable for some. The difference is due in part because of
// the cpu cycles needed to create the monochromatic bitmap above, and
// the extra time needed to do bit indexing into the monochromatic bitmap
// on the blit above.
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR );
}
// Restore actual values and clear bitmap for next drawing
layerDC.SetDeviceOrigin( dev_org.x, dev_org.y );
layerDC.SetLogicalOrigin( logical_org.x, logical_org.y );
layerDC.SetUserScale( scale, scale );
layerDC.SetBackground( bgBrush );
layerDC.SetBackgroundMode( wxSOLID );
layerDC.Clear();
doBlit = false;
}
}
if( gerber->m_ImageNegative )
{
// Draw background negative (i.e. in graphic layer color) for negative images.
EDA_COLOR_T neg_color = gerbFrame->GetLayerColor( layer );
GRSetDrawMode( &layerDC, GR_COPY );
GRFilledRect( &drawBox, plotDC, drawBox.GetX(), drawBox.GetY(),
drawBox.GetRight(), drawBox.GetBottom(),
0, neg_color, neg_color );
GRSetDrawMode( plotDC, GR_COPY );
doBlit = true;
}
int dcode_highlight = 0;
if( layer == gerbFrame->getActiveLayer() )
dcode_highlight = gerber->m_Selected_Tool;
GR_DRAWMODE layerdrawMode = GR_COPY;
if( aDrawMode == GR_OR && !gerber->HasNegativeItems() )
layerdrawMode = GR_OR;
EDA_COLOR_T item_color = gerbFrame->GetLayerColor( layer );
// Now we can draw the current layer to the bitmap buffer
// When needed, the previous bitmap is already copied to the screen buffer.
for( GERBER_DRAW_ITEM* item = gerbFrame->GetItemsList(); item; item = item->Next() )
{
if( item->GetLayer() != layer )
continue;
GR_DRAWMODE drawMode = layerdrawMode;
if( dcode_highlight && dcode_highlight == item->m_DCode )
DrawModeAddHighlight( &drawMode);
item->Draw( aPanel, plotDC, drawMode, wxPoint(0,0) );
doBlit = true;
}
if( aPrintBlackAndWhite )
gerbFrame->SetLayerColor( layer, item_color );
}
if( doBlit && useBufferBitmap ) // Blit is used only if aDrawMode >= 0
{
// For this Blit call, layerDC and screenDC must have the same settings
// So we set device origin, logical origin and scale to default values
// in layerDC
layerDC.SetDeviceOrigin(0,0);
layerDC.SetLogicalOrigin( 0, 0 );
layerDC.SetUserScale( 1, 1 );
// this is the last transfer to screenDC. If there are no negative items, this is
// the only one
if( aDrawMode == GR_COPY )
{
layerDC.SelectObject( wxNullBitmap );
layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) );
layerDC.SelectObject( *layerBitmap );
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
}
else if( aDrawMode == GR_OR )
{
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR );
}
}
if( useBufferBitmap )
{
// For this Blit call, aDC and screenDC must have the same settings
// So we set device origin, logical origin and scale to default values
// in aDC
aDC->SetDeviceOrigin( 0, 0);
aDC->SetLogicalOrigin( 0, 0 );
aDC->SetUserScale( 1, 1 );
aDC->Blit( 0, 0, bitmapWidth, bitmapHeight, &screenDC, 0, 0, wxCOPY );
// Restore aDC values
aDC->SetDeviceOrigin(dev_org.x, dev_org.y);
aDC->SetLogicalOrigin( logical_org.x, logical_org.y );
aDC->SetUserScale( scale, scale );
layerDC.SelectObject( wxNullBitmap );
screenDC.SelectObject( wxNullBitmap );
delete layerBitmap;
delete screenBitmap;
}
}

View File

@ -35,10 +35,10 @@
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( GBR_LAYOUT* aParent, GERBER_IMAGE* aGerberparams ) :
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( GBR_LAYOUT* aParent, GERBER_FILE_IMAGE* aGerberparams ) :
EDA_ITEM( (EDA_ITEM*)aParent, TYPE_GERBER_DRAW_ITEM )
{
m_imageParams = aGerberparams;
@ -223,7 +223,7 @@ D_CODE* GERBER_DRAW_ITEM::GetDcodeDescr()
if( (m_DCode < FIRST_DCODE) || (m_DCode > LAST_DCODE) )
return NULL;
GERBER_IMAGE* gerber = g_GERBER_List.GetGbrImage( m_Layer );
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( m_Layer );
if( gerber == NULL )
return NULL;

View File

@ -34,7 +34,7 @@
#include <layers_id_colors_and_visibility.h>
#include <gr_basic.h>
class GERBER_IMAGE;
class GERBER_FILE_IMAGE;
class GBR_LAYOUT;
class D_CODE;
class MSG_PANEL_ITEM;
@ -82,7 +82,7 @@ public:
// 0 for items that do not use DCodes (polygons)
// or when unknown and normal values are 10 to 999
// values 0 to 9 can be used for special purposes
GERBER_IMAGE* m_imageParams; /* main GERBER info for this item
GERBER_FILE_IMAGE* m_imageParams; /* main GERBER info for this item
* Note: some params stored in this class are common
* to the whole gerber file (i.e) the whole graphic
* layer and some can change when reaging the file,
@ -104,7 +104,7 @@ private:
double m_lyrRotation; // Fine rotation, from OR parameter, in degrees
public:
GERBER_DRAW_ITEM( GBR_LAYOUT* aParent, GERBER_IMAGE* aGerberparams );
GERBER_DRAW_ITEM( GBR_LAYOUT* aParent, GERBER_FILE_IMAGE* aGerberparams );
GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource );
~GERBER_DRAW_ITEM();

View File

@ -1,5 +1,5 @@
/**
* @file class_GERBER.cpp
* @file class_gerber_file_image.cpp
* a GERBER class handle for a given layer info about used D_CODES and how the layer is drawn
*/
@ -34,7 +34,7 @@
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <class_X2_gerber_attributes.h>
#include <algorithm>
@ -87,9 +87,9 @@ void GERBER_LAYER::ResetDefaultValues()
}
GERBER_IMAGE::GERBER_IMAGE( GERBVIEW_FRAME* aParent, int aLayer )
GERBER_FILE_IMAGE::GERBER_FILE_IMAGE( GERBVIEW_FRAME* aParent, int aLayer )
{
m_Parent = aParent;
//m_parent = aParent;
m_GraphicLayer = aLayer; // Graphic layer Number
m_Selected_Tool = FIRST_DCODE;
@ -102,7 +102,7 @@ GERBER_IMAGE::GERBER_IMAGE( GERBVIEW_FRAME* aParent, int aLayer )
}
GERBER_IMAGE::~GERBER_IMAGE()
GERBER_FILE_IMAGE::~GERBER_FILE_IMAGE()
{
for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ )
{
@ -116,12 +116,12 @@ GERBER_IMAGE::~GERBER_IMAGE()
* Function GetItemsList
* returns the first GERBER_DRAW_ITEM * item of the items list
*/
GERBER_DRAW_ITEM * GERBER_IMAGE::GetItemsList()
GERBER_DRAW_ITEM * GERBER_FILE_IMAGE::GetItemsList()
{
return m_Parent->GetItemsList();
return m_parent->GetItemsList();
}
D_CODE* GERBER_IMAGE::GetDCODE( int aDCODE, bool aCreateIfNoExist )
D_CODE* GERBER_FILE_IMAGE::GetDCODE( int aDCODE, bool aCreateIfNoExist )
{
unsigned ndx = aDCODE - FIRST_DCODE;
@ -141,7 +141,7 @@ D_CODE* GERBER_IMAGE::GetDCODE( int aDCODE, bool aCreateIfNoExist )
}
APERTURE_MACRO* GERBER_IMAGE::FindApertureMacro( const APERTURE_MACRO& aLookup )
APERTURE_MACRO* GERBER_FILE_IMAGE::FindApertureMacro( const APERTURE_MACRO& aLookup )
{
APERTURE_MACRO_SET::iterator iter = m_aperture_macros.find( aLookup );
@ -155,7 +155,7 @@ APERTURE_MACRO* GERBER_IMAGE::FindApertureMacro( const APERTURE_MACRO& aLookup )
}
void GERBER_IMAGE::ResetDefaultValues()
void GERBER_FILE_IMAGE::ResetDefaultValues()
{
m_InUse = false;
m_GBRLayerParams.ResetDefaultValues();
@ -216,7 +216,7 @@ void GERBER_IMAGE::ResetDefaultValues()
* return true if at least one item must be drawn in background color
* used to optimize screen refresh
*/
bool GERBER_IMAGE::HasNegativeItems()
bool GERBER_FILE_IMAGE::HasNegativeItems()
{
if( m_hasNegativeItems < 0 ) // negative items are not yet searched: find them if any
{
@ -240,7 +240,7 @@ bool GERBER_IMAGE::HasNegativeItems()
return m_hasNegativeItems == 1;
}
int GERBER_IMAGE::UsedDcodeNumber()
int GERBER_FILE_IMAGE::UsedDcodeNumber()
{
int count = 0;
@ -255,7 +255,7 @@ int GERBER_IMAGE::UsedDcodeNumber()
}
void GERBER_IMAGE::InitToolTable()
void GERBER_FILE_IMAGE::InitToolTable()
{
for( int count = 0; count < TOOLS_MAX_COUNT; count++ )
{
@ -276,9 +276,9 @@ void GERBER_IMAGE::InitToolTable()
* for instance when reading a Gerber file
* @param aMessage = the straing to add in list
*/
void GERBER_IMAGE::ReportMessage( const wxString aMessage )
void GERBER_FILE_IMAGE::ReportMessage( const wxString aMessage )
{
m_Parent->ReportMessage( aMessage );
m_parent->ReportMessage( aMessage );
}
@ -287,9 +287,9 @@ void GERBER_IMAGE::ReportMessage( const wxString aMessage )
* Clear the message list
* Call it before reading a Gerber file
*/
void GERBER_IMAGE::ClearMessageList()
void GERBER_FILE_IMAGE::ClearMessageList()
{
m_Parent->ClearMessageList();
m_parent->ClearMessageList();
}
@ -301,7 +301,7 @@ void GERBER_IMAGE::ClearMessageList()
* (i.e when m_XRepeatCount or m_YRepeatCount are > 1)
* @param aItem = the item to repeat
*/
void GERBER_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem )
void GERBER_FILE_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem )
{
if( GetLayerParams().m_XRepeatCount < 2 &&
GetLayerParams().m_YRepeatCount < 2 )
@ -323,7 +323,7 @@ void GERBER_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem )
move_vector.y = scaletoIU( jj * GetLayerParams().m_StepForRepeat.y,
GetLayerParams().m_StepForRepeatMetric );
dupItem->MoveXY( move_vector );
m_Parent->GetGerberLayout()->m_Drawings.Append( dupItem );
m_parent->GetGerberLayout()->m_Drawings.Append( dupItem );
}
}
}
@ -337,34 +337,34 @@ void GERBER_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem )
* These parameters are valid for the entire file, and must set only once
* (If more than once, only the last value is used)
*/
void GERBER_IMAGE::DisplayImageInfo( void )
void GERBER_FILE_IMAGE::DisplayImageInfo( void )
{
wxString msg;
m_Parent->ClearMsgPanel();
m_parent->ClearMsgPanel();
// Display Image name (Image specific)
m_Parent->AppendMsgPanel( _( "Image name" ), m_ImageName, CYAN );
m_parent->AppendMsgPanel( _( "Image name" ), m_ImageName, CYAN );
// Display graphic layer number used to draw this Image
// (not a Gerber parameter but is also image specific)
msg.Printf( wxT( "%d" ), m_GraphicLayer + 1 );
m_Parent->AppendMsgPanel( _( "Graphic layer" ), msg, BROWN );
m_parent->AppendMsgPanel( _( "Graphic layer" ), msg, BROWN );
// Display Image rotation (Image specific)
msg.Printf( wxT( "%d" ), m_ImageRotation );
m_Parent->AppendMsgPanel( _( "Img Rot." ), msg, CYAN );
m_parent->AppendMsgPanel( _( "Img Rot." ), msg, CYAN );
// Display Image polarity (Image specific)
msg = m_ImageNegative ? _("Negative") : _("Normal");
m_Parent->AppendMsgPanel( _( "Polarity" ), msg, BROWN );
m_parent->AppendMsgPanel( _( "Polarity" ), msg, BROWN );
// Display Image justification and offset for justification (Image specific)
msg = m_ImageJustifyXCenter ? _("Center") : _("Normal");
m_Parent->AppendMsgPanel( _( "X Justify" ), msg, DARKRED );
m_parent->AppendMsgPanel( _( "X Justify" ), msg, DARKRED );
msg = m_ImageJustifyYCenter ? _("Center") : _("Normal");
m_Parent->AppendMsgPanel( _( "Y Justify" ), msg, DARKRED );
m_parent->AppendMsgPanel( _( "Y Justify" ), msg, DARKRED );
if( g_UserUnit == INCHES )
msg.Printf( wxT( "X=%f Y=%f" ), (double) m_ImageJustifyOffset.x/10000,
@ -372,11 +372,11 @@ void GERBER_IMAGE::DisplayImageInfo( void )
else
msg.Printf( wxT( "X=%f Y=%f" ), (double) m_ImageJustifyOffset.x*2.54/1000,
(double) m_ImageJustifyOffset.y*2.54/1000 );
m_Parent->AppendMsgPanel( _( "Image Justify Offset" ), msg, DARKRED );
m_parent->AppendMsgPanel( _( "Image Justify Offset" ), msg, DARKRED );
}
// GERBER_IMAGE_LIST is a helper class to handle a list of GERBER_IMAGE files
GERBER_IMAGE_LIST::GERBER_IMAGE_LIST()
// GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files
GERBER_FILE_IMAGE_LIST::GERBER_FILE_IMAGE_LIST()
{
m_GERBER_List.reserve( GERBER_DRAWLAYERS_COUNT );
@ -384,7 +384,7 @@ GERBER_IMAGE_LIST::GERBER_IMAGE_LIST()
m_GERBER_List.push_back( NULL );
}
GERBER_IMAGE_LIST::~GERBER_IMAGE_LIST()
GERBER_FILE_IMAGE_LIST::~GERBER_FILE_IMAGE_LIST()
{
ClearList();
@ -395,7 +395,7 @@ GERBER_IMAGE_LIST::~GERBER_IMAGE_LIST()
}
}
GERBER_IMAGE* GERBER_IMAGE_LIST::GetGbrImage( int aIdx )
GERBER_FILE_IMAGE* GERBER_FILE_IMAGE_LIST::GetGbrImage( int aIdx )
{
if( (unsigned)aIdx < m_GERBER_List.size() )
return m_GERBER_List[aIdx];
@ -404,12 +404,12 @@ GERBER_IMAGE* GERBER_IMAGE_LIST::GetGbrImage( int aIdx )
}
/**
* creates a new, empty GERBER_IMAGE* at index aIdx
* creates a new, empty GERBER_FILE_IMAGE* at index aIdx
* or at the first free location if aIdx < 0
* @param aIdx = the location to use ( 0 ... GERBER_DRAWLAYERS_COUNT-1 )
* @return true if the index used, or -1 if no room to add image
*/
int GERBER_IMAGE_LIST::AddGbrImage( GERBER_IMAGE* aGbrImage, int aIdx )
int GERBER_FILE_IMAGE_LIST::AddGbrImage( GERBER_FILE_IMAGE* aGbrImage, int aIdx )
{
int idx = aIdx;
@ -433,14 +433,14 @@ int GERBER_IMAGE_LIST::AddGbrImage( GERBER_IMAGE* aGbrImage, int aIdx )
// remove all loaded data in list, but do not delete empty images
// (can be reused)
void GERBER_IMAGE_LIST::ClearList()
void GERBER_FILE_IMAGE_LIST::ClearList()
{
for( unsigned layer = 0; layer < m_GERBER_List.size(); ++layer )
ClearImage( layer );
}
// remove the loaded data of image aIdx, but do not delete it
void GERBER_IMAGE_LIST::ClearImage( int aIdx )
void GERBER_FILE_IMAGE_LIST::ClearImage( int aIdx )
{
if( aIdx >= 0 && aIdx < (int)m_GERBER_List.size() && m_GERBER_List[aIdx] )
{
@ -451,11 +451,11 @@ void GERBER_IMAGE_LIST::ClearImage( int aIdx )
}
// Build a name for image aIdx which can be used in layers manager
const wxString GERBER_IMAGE_LIST::GetDisplayName( int aIdx )
const wxString GERBER_FILE_IMAGE_LIST::GetDisplayName( int aIdx )
{
wxString name;
GERBER_IMAGE* gerber = NULL;
GERBER_FILE_IMAGE* gerber = NULL;
if( aIdx >= 0 && aIdx < (int)m_GERBER_List.size() )
gerber = m_GERBER_List[aIdx];
@ -506,7 +506,7 @@ const wxString GERBER_IMAGE_LIST::GetDisplayName( int aIdx )
}
// return true if image is used (loaded and not cleared)
bool GERBER_IMAGE_LIST::IsUsed( int aIdx )
bool GERBER_FILE_IMAGE_LIST::IsUsed( int aIdx )
{
if( aIdx >= 0 && aIdx < (int)m_GERBER_List.size() )
return m_GERBER_List[aIdx] != NULL && m_GERBER_List[aIdx]->m_InUse;
@ -517,7 +517,7 @@ bool GERBER_IMAGE_LIST::IsUsed( int aIdx )
// Helper function, for std::sort.
// Sort loaded images by Z order priority, if they have the X2 FileFormat info
// returns true if the first argument (ref) is ordered before the second (test).
static bool sortZorder( const GERBER_IMAGE* const& ref, const GERBER_IMAGE* const& test )
static bool sortZorder( const GERBER_FILE_IMAGE* const& ref, const GERBER_FILE_IMAGE* const& test )
{
if( !ref && !test )
return false; // do not change order: no criteria to sort items
@ -543,7 +543,7 @@ static bool sortZorder( const GERBER_IMAGE* const& ref, const GERBER_IMAGE* cons
return ref->m_FileFunction->GetZSubOrder() > test->m_FileFunction->GetZSubOrder();
}
void GERBER_IMAGE_LIST::SortImagesByZOrder( GERBER_DRAW_ITEM* aDrawList )
void GERBER_FILE_IMAGE_LIST::SortImagesByZOrder( GERBER_DRAW_ITEM* aDrawList )
{
std::sort( m_GERBER_List.begin(), m_GERBER_List.end(), sortZorder );
@ -572,4 +572,4 @@ void GERBER_IMAGE_LIST::SortImagesByZOrder( GERBER_DRAW_ITEM* aDrawList )
// The global image list:
GERBER_IMAGE_LIST g_GERBER_List;
GERBER_FILE_IMAGE_LIST g_GERBER_List;

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010-2013 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2013 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2010-2016 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.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
@ -50,22 +50,22 @@ class D_CODE;
* in GERBER_ITEM items, when instancied.
*
* In GerbView, to handle these parameters, there are 2 classes:
* GERBER_IMAGE : the main class containing most of parameters and data to plot a graphic layer
* GERBER_FILE_IMAGE : the main class containing most of parameters and data to plot a graphic layer
* Some of them can change along the file
* There is one GERBER_IMAGE per file and one graphic layer per file or GERBER_IMAGE
* There is one GERBER_FILE_IMAGE per file and one graphic layer per file or GERBER_FILE_IMAGE
* GerbView does not read and merge 2 gerber file in one graphic layer:
* I believe this is not possible due to the constraints in Image parameters.
* GERBER_LAYER : containing the subset of parameters that is layer speficic
* A GERBER_IMAGE must include one GERBER_LAYER to define all parameters to plot a file.
* But a GERBER_IMAGE can use more than one GERBER_LAYER.
* A GERBER_FILE_IMAGE must include one GERBER_LAYER to define all parameters to plot a file.
* But a GERBER_FILE_IMAGE can use more than one GERBER_LAYER.
*/
class GERBER_IMAGE;
class GERBER_FILE_IMAGE;
class X2_ATTRIBUTE_FILEFUNCTION;
class GERBER_LAYER
{
friend class GERBER_IMAGE;
friend class GERBER_FILE_IMAGE;
public:
// These parameters are layer specfic:
@ -88,13 +88,13 @@ private:
};
/**
* Class GERBER_IMAGE
* Class GERBER_FILE_IMAGE
* holds the Image data and parameters for one gerber file
* and layer parameters (TODO: move them in GERBER_LAYER class
*/
class GERBER_IMAGE
class GERBER_FILE_IMAGE
{
GERBVIEW_FRAME* m_Parent; // the parent GERBVIEW_FRAME (used to display messages...)
GERBVIEW_FRAME* m_parent; // the parent GERBVIEW_FRAME (used to display messages...)
D_CODE* m_Aperture_List[TOOLS_MAX_COUNT]; ///< Dcode (Aperture) List for this layer (max 999)
bool m_Exposure; ///< whether an aperture macro tool is flashed on or off
@ -164,19 +164,19 @@ private:
// 1 = have negative items found
public:
GERBER_IMAGE( GERBVIEW_FRAME* aParent, int layer );
virtual ~GERBER_IMAGE();
void Clear_GERBER_IMAGE();
GERBER_FILE_IMAGE( GERBVIEW_FRAME* aParent, int layer );
virtual ~GERBER_FILE_IMAGE();
void Clear_GERBER_FILE_IMAGE();
int UsedDcodeNumber();
virtual void ResetDefaultValues();
/**
* Function GetParent
* @return the GERBVIEW_FRAME parent of this GERBER_IMAGE
* @return the GERBVIEW_FRAME parent of this GERBER_FILE_IMAGE
*/
GERBVIEW_FRAME* GetParent() const
{
return m_Parent;
return m_parent;
}
/**
@ -313,30 +313,30 @@ public:
};
/**
* @brief GERBER_IMAGE_LIST is a helper class to handle a list of GERBER_IMAGE files
* @brief GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files
* which are loaded and can be displayed
* there are 32 images max which can be loaded
*/
class GERBER_IMAGE_LIST
class GERBER_FILE_IMAGE_LIST
{
// the list of loaded images (1 image = 1 gerber file)
std::vector<GERBER_IMAGE*> m_GERBER_List;
std::vector<GERBER_FILE_IMAGE*> m_GERBER_List;
public:
GERBER_IMAGE_LIST();
~GERBER_IMAGE_LIST();
GERBER_FILE_IMAGE_LIST();
~GERBER_FILE_IMAGE_LIST();
//Accessor
GERBER_IMAGE* GetGbrImage( int aIdx );
GERBER_FILE_IMAGE* GetGbrImage( int aIdx );
/**
* Add a GERBER_IMAGE* at index aIdx
* Add a GERBER_FILE_IMAGE* at index aIdx
* or at the first free location if aIdx < 0
* @param aGbrImage = the image to add
* @param aIdx = the location to use ( 0 ... GERBER_DRAWLAYERS_COUNT-1 )
* @return true if the index used, or -1 if no room to add image
*/
int AddGbrImage( GERBER_IMAGE* aGbrImage, int aIdx );
int AddGbrImage( GERBER_FILE_IMAGE* aGbrImage, int aIdx );
/**
@ -378,6 +378,6 @@ public:
};
extern GERBER_IMAGE_LIST g_GERBER_List;
extern GERBER_FILE_IMAGE_LIST g_GERBER_List;
#endif // ifndef _CLASS_GERBER_H_

View File

@ -37,7 +37,7 @@
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <layer_widget.h>
#include <class_gerbview_layer_widget.h>

View File

@ -34,7 +34,7 @@
#include <trigo.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <convert_to_biu.h>
#define DCODE_DEFAULT_SIZE Millimeter2iu( 0.1 )

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2010-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
@ -22,9 +22,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
// Set this to 1 if you want to test PostScript printing under MSW.
#define wxTEST_POSTSCRIPT_IN_MSW 1
#include <fctsys.h>
#include <kiface_i.h>
@ -37,7 +34,7 @@
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <pcbplot.h>
static double s_ScaleList[] =
@ -91,13 +88,7 @@ public:
};
/*******************************************************/
void GERBVIEW_FRAME::ToPrinter( wxCommandEvent& event )
/*******************************************************/
/* Virtual function:
* Display the print dialog
*/
{
if( s_printData == NULL ) // First print
s_printData = new wxPrintData();
@ -119,10 +110,8 @@ void GERBVIEW_FRAME::ToPrinter( wxCommandEvent& event )
}
/*************************************************************************************/
DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( GERBVIEW_FRAME* parent ) :
DIALOG_PRINT_USING_PRINTER_BASE( parent )
/*************************************************************************************/
{
m_Parent = parent;
m_Config = Kiface().KifaceSettings();
@ -139,9 +128,7 @@ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( GERBVIEW_FRAME* parent )
}
/************************************************************************/
void DIALOG_PRINT_USING_PRINTER::InitValues( )
/************************************************************************/
{
SetFocus();
wxString msg;
@ -234,6 +221,7 @@ int DIALOG_PRINT_USING_PRINTER::SetLayerSetFromListSelection()
{
int page_count = 0;
std::bitset <GERBER_DRAWLAYERS_COUNT> layerMask;
for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii )
{
if( m_BoxSelectLayer[ii]->IsChecked() && m_BoxSelectLayer[ii]->IsEnabled() )
@ -264,6 +252,7 @@ void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
m_Config->Write( OPTKEY_PRINT_PAGE_FRAME, s_Parameters.m_Print_Sheet_Ref);
m_Config->Write( OPTKEY_PRINT_MONOCHROME_MODE, s_Parameters.m_Print_Black_and_White);
wxString layerKey;
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
{
layerKey.Printf( OPTKEY_LAYERBASE, layer );
@ -271,7 +260,7 @@ void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
}
}
EndModal( 0 );
event.Skip();
}
@ -297,6 +286,7 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters()
DisplayInfoMessage( NULL, _( "Warning: Scale option set to a very large value" ) );
m_FineAdjustXscaleOpt->GetValue().ToDouble( &s_Parameters.m_XScaleAdjust );
}
if( m_FineAdjustYscaleOpt )
{
// Test for a reasonnable scale value
@ -311,8 +301,10 @@ void DIALOG_PRINT_USING_PRINTER::OnScaleSelectionClick( wxCommandEvent& event )
{
double scale = s_ScaleList[m_ScaleOption->GetSelection()];
bool enable = (scale == 1.0);
if( m_FineAdjustXscaleOpt )
m_FineAdjustXscaleOpt->Enable(enable);
if( m_FineAdjustYscaleOpt )
m_FineAdjustYscaleOpt->Enable(enable);
}

View File

@ -37,7 +37,7 @@
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <printout_controler.h>
@ -148,248 +148,6 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
}
/*
* 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 )
{
GERBVIEW_FRAME* gerbFrame = (GERBVIEW_FRAME*) aPanel->GetParent();
// Because Images can be negative (i.e with background filled in color) items are drawn
// graphic layer per graphic layer, after the background is filled
// to a temporary bitmap
// at least when aDrawMode = GR_COPY or aDrawMode = GR_OR
// 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;
aPanel->GetClientSize( &bitmapWidth, &bitmapHeight );
wxBitmap* layerBitmap = NULL;
wxBitmap* screenBitmap = NULL;
wxMemoryDC layerDC; // used sequentially for each gerber layer
wxMemoryDC screenDC;
// When each image must be drawn using GR_OR (transparency mode)
// or GR_COPY (stacked mode) we must use a temporary bitmap
// to draw gerber images.
// this is due to negative objects (drawn using background color) that create artifacts
// on other images when drawn on screen
bool useBufferBitmap = false;
#ifndef __WXMAC__
// Can't work with MAC
// Don't try this with retina display
if( (aDrawMode == GR_COPY) || ( aDrawMode == GR_OR ) )
useBufferBitmap = true;
#endif
// these parameters are saved here, because they are modified
// and restored later
EDA_RECT drawBox = *aPanel->GetClipBox();
double scale;
aDC->GetUserScale(&scale, &scale);
wxPoint dev_org = aDC->GetDeviceOrigin();
wxPoint logical_org = aDC->GetLogicalOrigin( );
if( useBufferBitmap )
{
layerBitmap = new wxBitmap( bitmapWidth, bitmapHeight );
screenBitmap = new wxBitmap( bitmapWidth, bitmapHeight );
layerDC.SelectObject( *layerBitmap );
aPanel->DoPrepareDC( layerDC );
aPanel->SetClipBox( drawBox );
layerDC.SetBackground( bgBrush );
layerDC.SetBackgroundMode( wxSOLID );
layerDC.Clear();
screenDC.SelectObject( *screenBitmap );
screenDC.SetBackground( bgBrush );
screenDC.SetBackgroundMode( wxSOLID );
screenDC.Clear();
plotDC = &layerDC;
}
bool doBlit = false; // this flag requests an image transfer to actual screen when true.
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
for( int layer = GERBER_DRAWLAYERS_COUNT-1; !end; --layer )
{
int active_layer = gerbFrame->getActiveLayer();
if( layer == active_layer ) // active layer will be drawn after other layers
continue;
if( layer < 0 ) // last loop: draw active layer
{
end = true;
layer = active_layer;
}
if( !gerbFrame->IsLayerVisible( layer ) )
continue;
GERBER_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( useBufferBitmap )
{
// Draw each layer into a bitmap first. Negative Gerber
// layers are drawn in background color.
if( gerber->HasNegativeItems() && doBlit )
{
// Set Device origin, logical origin and scale to default values
// This is needed by Blit function when using a mask.
// Beside, for Blit call, both layerDC and screenDc must have the same settings
layerDC.SetDeviceOrigin(0,0);
layerDC.SetLogicalOrigin( 0, 0 );
layerDC.SetUserScale( 1, 1 );
if( aDrawMode == GR_COPY )
{
// Use the layer bitmap itself as a mask when blitting. The bitmap
// cannot be referenced by a device context when setting the mask.
layerDC.SelectObject( wxNullBitmap );
layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) );
layerDC.SelectObject( *layerBitmap );
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
}
else if( aDrawMode == GR_OR )
{
// On Linux with a large screen, this version is much faster and without
// flicker, but gives a Pcbnew look where layer colors blend together.
// Plus it works only because the background color is black. But it may
// be more usable for some. The difference is due in part because of
// the cpu cycles needed to create the monochromatic bitmap above, and
// the extra time needed to do bit indexing into the monochromatic bitmap
// on the blit above.
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR );
}
// Restore actual values and clear bitmap for next drawing
layerDC.SetDeviceOrigin( dev_org.x, dev_org.y );
layerDC.SetLogicalOrigin( logical_org.x, logical_org.y );
layerDC.SetUserScale( scale, scale );
layerDC.SetBackground( bgBrush );
layerDC.SetBackgroundMode( wxSOLID );
layerDC.Clear();
doBlit = false;
}
}
if( gerber->m_ImageNegative )
{
// Draw background negative (i.e. in graphic layer color) for negative images.
EDA_COLOR_T neg_color = gerbFrame->GetLayerColor( layer );
GRSetDrawMode( &layerDC, GR_COPY );
GRFilledRect( &drawBox, plotDC, drawBox.GetX(), drawBox.GetY(),
drawBox.GetRight(), drawBox.GetBottom(),
0, neg_color, neg_color );
GRSetDrawMode( plotDC, GR_COPY );
doBlit = true;
}
int dcode_highlight = 0;
if( layer == gerbFrame->getActiveLayer() )
dcode_highlight = gerber->m_Selected_Tool;
GR_DRAWMODE layerdrawMode = GR_COPY;
if( aDrawMode == GR_OR && !gerber->HasNegativeItems() )
layerdrawMode = GR_OR;
EDA_COLOR_T item_color = gerbFrame->GetLayerColor( layer );
// Now we can draw the current layer to the bitmap buffer
// When needed, the previous bitmap is already copied to the screen buffer.
for( GERBER_DRAW_ITEM* item = gerbFrame->GetItemsList(); item; item = item->Next() )
{
if( item->GetLayer() != layer )
continue;
GR_DRAWMODE drawMode = layerdrawMode;
if( dcode_highlight && dcode_highlight == item->m_DCode )
DrawModeAddHighlight( &drawMode);
item->Draw( aPanel, plotDC, drawMode, wxPoint(0,0) );
doBlit = true;
}
if( aPrintBlackAndWhite )
gerbFrame->SetLayerColor( layer, item_color );
}
if( doBlit && useBufferBitmap ) // Blit is used only if aDrawMode >= 0
{
// For this Blit call, layerDC and screenDC must have the same settings
// So we set device origin, logical origin and scale to default values
// in layerDC
layerDC.SetDeviceOrigin(0,0);
layerDC.SetLogicalOrigin( 0, 0 );
layerDC.SetUserScale( 1, 1 );
// this is the last transfer to screenDC. If there are no negative items, this is
// the only one
if( aDrawMode == GR_COPY )
{
layerDC.SelectObject( wxNullBitmap );
layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) );
layerDC.SelectObject( *layerBitmap );
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
}
else if( aDrawMode == GR_OR )
{
screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxOR );
}
}
if( useBufferBitmap )
{
// For this Blit call, aDC and screenDC must have the same settings
// So we set device origin, logical origin and scale to default values
// in aDC
aDC->SetDeviceOrigin( 0, 0);
aDC->SetLogicalOrigin( 0, 0 );
aDC->SetUserScale( 1, 1 );
aDC->Blit( 0, 0, bitmapWidth, bitmapHeight, &screenDC, 0, 0, wxCOPY );
// Restore aDC values
aDC->SetDeviceOrigin(dev_org.x, dev_org.y);
aDC->SetLogicalOrigin( logical_org.x, logical_org.y );
aDC->SetUserScale( scale, scale );
layerDC.SelectObject( wxNullBitmap );
screenDC.SelectObject( wxNullBitmap );
delete layerBitmap;
delete screenBitmap;
}
}
void GERBVIEW_FRAME::DrawItemsDCodeID( wxDC* aDC, GR_DRAWMODE aDrawMode )
{
wxPoint pos;

View File

@ -36,7 +36,7 @@
#include <gerbview_frame.h>
#include <kicad_device_context.h>
#include <gerbview_id.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <dialog_helpers.h>
#include <class_DCodeSelectionbox.h>
#include <class_gerbview_layer_widget.h>
@ -221,7 +221,7 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
{
GERBER_IMAGE* gerber_image = g_GERBER_List.GetGbrImage( getActiveLayer() );
GERBER_FILE_IMAGE* gerber_image = g_GERBER_List.GetGbrImage( getActiveLayer() );
if( gerber_image )
{
@ -253,7 +253,7 @@ void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event )
{
int layer = getActiveLayer();
GERBER_IMAGE* gerber_layer = g_GERBER_List.GetGbrImage( layer );
GERBER_FILE_IMAGE* gerber_layer = g_GERBER_List.GetGbrImage( layer );
if( gerber_layer )
{

View File

@ -68,7 +68,7 @@
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <class_excellon.h>
#include <kicad_string.h>
#include <class_X2_gerber_attributes.h>

View File

@ -36,7 +36,7 @@
#include <trigo.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <select_layers_to_pcb.h>
#include <build_version.h>
#include <wildcards_and_files_ext.h>

View File

@ -42,7 +42,7 @@
#include <gerbview_frame.h>
#include <gerbview_id.h>
#include <hotkeys.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <dialog_helpers.h>
#include <class_DCodeSelectionbox.h>
#include <class_gerbview_layer_widget.h>
@ -360,7 +360,7 @@ int GERBVIEW_FRAME::getNextAvailableLayer( int aLayer ) const
for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; ++i )
{
GERBER_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
if( gerber == NULL || gerber->m_FileName.IsEmpty() )
return layer;
@ -390,7 +390,7 @@ void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
m_SelLayerBox->SetSelection( getActiveLayer() );
int dcodeSelected = -1;
GERBER_IMAGE* gerber = g_GERBER_List.GetGbrImage( getActiveLayer() );
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( getActiveLayer() );
if( gerber )
dcodeSelected = gerber->m_Selected_Tool;
@ -417,7 +417,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
{
GERBER_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
if( gerber == NULL )
continue;
@ -472,7 +472,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
void GERBVIEW_FRAME::UpdateTitleAndInfo()
{
GERBER_IMAGE* gerber = g_GERBER_List.GetGbrImage( getActiveLayer() );
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( getActiveLayer() );
wxString text;
// Display the gerber filename

View File

@ -31,7 +31,7 @@
#include <confirm.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <class_gerbview_layer_widget.h>
bool GERBVIEW_FRAME::Clear_DrawLayers( bool query )

View File

@ -27,7 +27,7 @@
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <dialog_helpers.h>
/* Process the command triggered by the left button of the mouse
@ -41,7 +41,7 @@ void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
if( DrawStruct == NULL )
{
GERBER_IMAGE* gerber = g_GERBER_List.GetGbrImage( getActiveLayer() );
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( getActiveLayer() );
if( gerber )
gerber->DisplayImageInfo( );

View File

@ -231,10 +231,10 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
// To plot mirror, we reverse the x axis, and modify the plot x origin
dc->SetAxisOrientation( false, false );
/* Plot offset x is moved by the x plot area size in order to have
* the old draw area in the new draw area, because the draw origin has not moved
* (this is the upper left corner) but the X axis is reversed, therefore the plotting area
* is the x coordinate values from - PlotAreaSize.x to 0 */
/* Change plot offset in order to have the draw area at the same location.
* The plot origin X is just moved from 0 to PlotAreaSizeInPixels.x.
* just set offset x at PlotAreaSizeInPixels.x.
*/
int x_dc_offset = PlotAreaSizeInPixels.x;
x_dc_offset = KiROUND( x_dc_offset * userscale );
dc->SetDeviceOrigin( x_dc_offset, 0 );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.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
@ -28,7 +28,7 @@
#include <kicad_string.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <html_messagebox.h>
#include <macros.h>
@ -47,11 +47,11 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName )
int layer; // current layer used in GerbView
layer = getActiveLayer();
GERBER_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
if( gerber == NULL )
{
gerber = new GERBER_IMAGE( this, layer );
gerber = new GERBER_FILE_IMAGE( this, layer );
g_GERBER_List.AddGbrImage( gerber, layer );
}

View File

@ -25,7 +25,7 @@
#include <fctsys.h>
#include <common.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <base_units.h>
@ -69,7 +69,7 @@ int scaletoIU( double aCoord, bool isMetric )
}
wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text )
wxPoint GERBER_FILE_IMAGE::ReadXYCoord( char*& Text )
{
wxPoint pos;
int type_coord = 0, current_coord, nbdigits;
@ -169,7 +169,7 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text )
* These coordinates are relative, so if coordinate is absent, it's value
* defaults to 0
*/
wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text )
wxPoint GERBER_FILE_IMAGE::ReadIJCoord( char*& Text )
{
wxPoint pos( 0, 0 );

View File

@ -32,7 +32,7 @@
#include <gerbview.h>
#include <gerbview_frame.h>
#include <trigo.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <class_X2_gerber_attributes.h>
#include <cmath>
@ -407,7 +407,7 @@ static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem,
/* Read the Gnn sequence and returns the value nn.
*/
int GERBER_IMAGE::GCodeNumber( char*& Text )
int GERBER_FILE_IMAGE::GCodeNumber( char*& Text )
{
int ii = 0;
char* text;
@ -430,7 +430,7 @@ int GERBER_IMAGE::GCodeNumber( char*& Text )
/* Get the sequence Dnn and returns the value nn
*/
int GERBER_IMAGE::DCodeNumber( char*& Text )
int GERBER_FILE_IMAGE::DCodeNumber( char*& Text )
{
int ii = 0;
char* text;
@ -450,7 +450,7 @@ int GERBER_IMAGE::DCodeNumber( char*& Text )
}
bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_command )
bool GERBER_FILE_IMAGE::Execute_G_Command( char*& text, int G_command )
{
// D( printf( "%22s: G_CODE<%d>\n", __func__, G_command ); )
@ -550,9 +550,9 @@ bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_command )
break;
case GC_TURN_OFF_POLY_FILL:
if( m_Exposure && m_Parent->GetGerberLayout()->m_Drawings ) // End of polygon
if( m_Exposure && m_parent->GetGerberLayout()->m_Drawings ) // End of polygon
{
GERBER_DRAW_ITEM * gbritem = m_Parent->GetGerberLayout()->m_Drawings.GetLast();
GERBER_DRAW_ITEM * gbritem = m_parent->GetGerberLayout()->m_Drawings.GetLast();
StepAndRepeatItem( *gbritem );
}
m_Exposure = false;
@ -575,15 +575,15 @@ bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_command )
}
bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
{
wxSize size( 15, 15 );
APERTURE_T aperture = APT_CIRCLE;
GERBER_DRAW_ITEM* gbritem;
GBR_LAYOUT* layout = m_Parent->GetGerberLayout();
GBR_LAYOUT* layout = m_parent->GetGerberLayout();
int activeLayer = m_Parent->getActiveLayer();
int activeLayer = m_parent->getActiveLayer();
int dcode = 0;
D_CODE* tool = NULL;

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2007-2016 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2016 KiCad Developers, see AUTHOR.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
@ -32,7 +32,7 @@
#include <base_units.h>
#include <gerbview.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <class_X2_gerber_attributes.h>
extern int ReadInt( char*& text, bool aSkipSeparator = true );
@ -128,7 +128,7 @@ static int ReadXCommand( char*& text )
}
bool GERBER_IMAGE::ReadRS274XCommand( char* buff, char*& text )
bool GERBER_FILE_IMAGE::ReadRS274XCommand( char* buff, char*& text )
{
bool ok = true;
int code_command;
@ -181,7 +181,7 @@ exit:
}
bool GERBER_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& text )
bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& text )
{
int code;
int seq_len; // not used, just provided
@ -884,7 +884,7 @@ static char* GetNextLine( char *aBuff, char* aText, FILE* aFile )
}
bool GERBER_IMAGE::ReadApertureMacro( char *buff,
bool GERBER_FILE_IMAGE::ReadApertureMacro( char *buff,
char*& text,
FILE* gerber_file )
{

View File

@ -6,7 +6,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.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
@ -31,7 +31,7 @@
#include <gerbview.h>
#include <gerbview_frame.h>
#include <gerbview_id.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <select_layers_to_pcb.h>

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.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
@ -36,7 +36,7 @@
#include <bitmaps.h>
#include <gerbview_id.h>
#include <hotkeys.h>
#include <class_GERBER.h>
#include <class_gerber_file_image.h>
#include <class_gbr_layer_box_selector.h>
#include <class_DCodeSelectionbox.h>
#include <dialog_helpers.h>
@ -295,7 +295,7 @@ void GERBVIEW_FRAME::OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent )
void GERBVIEW_FRAME::OnUpdateSelectDCode( wxUpdateUIEvent& aEvent )
{
int layer = getActiveLayer();
GERBER_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
GERBER_FILE_IMAGE* gerber = g_GERBER_List.GetGbrImage( layer );
int selected = ( gerber ) ? gerber->m_Selected_Tool : 0;
if( m_DCodeSelector && m_DCodeSelector->GetSelectedDCodeId() != selected )