Gerbview: code cleanup (with the help of Mark Roszko's work)

This commit is contained in:
jean-pierre charras 2016-05-25 11:45:55 +02:00
parent 75c551f305
commit 1c21410f1f
36 changed files with 44 additions and 202 deletions

View File

@ -31,17 +31,9 @@
#include <fctsys.h>
#include <common.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <gr_basic.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
#include <wx/debug.h>
#define BLOCK_COLOR BROWN
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool erase );
@ -211,7 +203,7 @@ void GERBVIEW_FRAME::Block_Move( wxDC* DC )
/* Move items in block */
for( GERBER_DRAW_ITEM* item = GetItemsList(); item; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
GERBER_DRAW_ITEM* gerb_item = item;
if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) )
gerb_item->MoveAB( delta );

View File

@ -25,8 +25,6 @@
#include <fctsys.h>
#include <pgm_base.h>
#include <wxstruct.h>
#include <class_drawpanel.h>
#include <gerbview.h>
#include <dcode.h>
#include <class_DCodeSelectionbox.h>

View File

@ -30,7 +30,6 @@
#include <fctsys.h>
#include <common.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <macros.h>
#include <gerbview.h>
@ -307,8 +306,8 @@ void GERBER_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem )
if( GetLayerParams().m_XRepeatCount < 2 &&
GetLayerParams().m_YRepeatCount < 2 )
return; // Nothing to repeat
// Duplicate item:
wxString msg;
for( int ii = 0; ii < GetLayerParams().m_XRepeatCount; ii++ )
{
for( int jj = 0; jj < GetLayerParams().m_YRepeatCount; jj++ )

View File

@ -248,14 +248,14 @@ public:
* Function ReadRS274XCommand
* reads a single RS274X command terminated with a %
*/
bool ReadRS274XCommand( char aBuff[GERBER_BUFZ], char* & text );
bool ReadRS274XCommand( char *aBuff, char* & text );
/**
* Function ExecuteRS274XCommand
* executes 1 command
*/
bool ExecuteRS274XCommand( int command, char aBuff[GERBER_BUFZ],
char* & text );
bool ExecuteRS274XCommand( int command, char* aBuff,
char*& text );
/**
@ -268,7 +268,7 @@ public:
* @param gerber_file Which file to read from for continuation.
* @return bool - true if a macro was read in successfully, else false.
*/
bool ReadApertureMacro( char aBuff[GERBER_BUFZ], char* & text,
bool ReadApertureMacro( char *aBuff, char* & text,
FILE * gerber_file );

View File

@ -46,7 +46,7 @@
/*
* class X2_ATTRIBUTE
* The attribute value consists of a number of substrings separated by a ","
* The attribute value consists of a number of substrings separated by a comma
*/
X2_ATTRIBUTE::X2_ATTRIBUTE()

View File

@ -48,7 +48,7 @@
/**
* class X2_ATTRIBUTE
* The attribute value consists of a number of substrings separated by a ","
* The attribute value consists of a number of substrings separated by a comma
*/
class X2_ATTRIBUTE

View File

@ -31,10 +31,8 @@
#include <common.h>
#include <colors_selection.h>
#include <layers_id_colors_and_visibility.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
#include <class_X2_gerber_attributes.h>
#include <class_gbr_layer_box_selector.h>

View File

@ -27,11 +27,7 @@
* @brief GBR_LAYOUT class functions.
*/
#include <limits.h>
#include <algorithm>
#include <fctsys.h>
#include <common.h>
#include <class_gbr_layout.h>
GBR_LAYOUT::GBR_LAYOUT()

View File

@ -30,9 +30,9 @@
#include <common.h>
#include <macros.h>
#include <class_gbr_screen.h>
#include <base_units.h>
#include <gerbview_id.h>
#define DMIL_GRID( x ) wxRealPoint( x * IU_PER_DECIMILS,\
x * IU_PER_DECIMILS )
#define MM_GRID( x ) wxRealPoint( x * IU_PER_MM,\

View File

@ -29,14 +29,13 @@
#ifndef CLASS_GBR_SCREEN_H_
#define CLASS_GBR_SCREEN_H_
#include <base_units.h>
#include <class_base_screen.h>
#include <layers_id_colors_and_visibility.h>
#define ZOOM_FACTOR( x ) ( x * IU_PER_DECIMILS )
/* Handle info to display a board */
class GBR_SCREEN : public BASE_SCREEN
{
@ -47,15 +46,10 @@ public:
* @param aPageSizeIU is the size of the initial paper page in internal units.
*/
GBR_SCREEN( const wxSize& aPageSizeIU );
~GBR_SCREEN();
GBR_SCREEN* Next() const { return static_cast<GBR_SCREEN*>( Pnext ); }
// void SetNextZoom();
// void SetPreviousZoom();
// void SetLastZoom();
virtual int MilsToIuScalar();
/**

View File

@ -31,11 +31,9 @@
#include <common.h>
#include <trigo.h>
#include <class_drawpanel.h>
#include <macros.h>
#include <msgpanel.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2004-2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 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
@ -32,7 +32,6 @@
#include <fctsys.h>
#include <common.h>
#include <class_drawpanel.h>
#include <pcbstruct.h>
#include <macros.h>
#include <class_gbr_layer_box_selector.h>
@ -41,7 +40,6 @@
#include <class_GERBER.h>
#include <layer_widget.h>
#include <class_gerbview_layer_widget.h>
#include <class_X2_gerber_attributes.h>
/*

View File

@ -27,9 +27,7 @@
*/
#include <fctsys.h>
#include <common.h>
#include <class_drawpanel.h>
#include <gerbview.h>
#include <gerbview_frame.h>

View File

@ -31,18 +31,13 @@
#include <fctsys.h>
#include <common.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <macros.h>
#include <trigo.h>
#include <gr_basic.h>
#include <base_units.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>
#include <convert_to_biu.h>
#define DEFAULT_SIZE 100
#define DCODE_DEFAULT_SIZE Millimeter2iu( 0.1 )
/* Format Gerber: NOTES:
* Tools and D_CODES
@ -82,8 +77,8 @@ D_CODE::~D_CODE()
void D_CODE::Clear_D_CODE_Data()
{
m_Size.x = DEFAULT_SIZE;
m_Size.y = DEFAULT_SIZE;
m_Size.x = DCODE_DEFAULT_SIZE;
m_Size.y = DCODE_DEFAULT_SIZE;
m_Shape = APT_CIRCLE;
m_Drill.x = m_Drill.y = 0;
m_DrillShape = APT_DEF_NO_HOLE;
@ -155,62 +150,6 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
}
void GERBVIEW_FRAME::CopyDCodesSizeToItems()
{
static D_CODE dummy( 999 ); //Used if D_CODE not found in list
GERBER_DRAW_ITEM* gerb_item = GetItemsList();
for( ; gerb_item; gerb_item = gerb_item->Next() )
{
D_CODE* dcode = gerb_item->GetDcodeDescr();
wxASSERT( dcode );
if( dcode == NULL )
dcode = &dummy;
dcode->m_InUse = true;
gerb_item->m_Size = dcode->m_Size;
if( // Line Item
(gerb_item->m_Shape == GBR_SEGMENT ) /* rectilinear segment */
|| (gerb_item->m_Shape == GBR_ARC ) /* segment arc (rounded tips) */
|| (gerb_item->m_Shape == GBR_CIRCLE ) /* segment in a circle (ring) */
)
{
}
else // Spots ( Flashed Items )
{
switch( dcode->m_Shape )
{
case APT_CIRCLE: /* spot round */
gerb_item->m_Shape = GBR_SPOT_CIRCLE;
break;
case APT_OVAL: /* spot oval*/
gerb_item->m_Shape = GBR_SPOT_OVAL;
break;
case APT_RECT: /* spot rect*/
gerb_item->m_Shape = GBR_SPOT_RECT;
break;
case APT_POLYGON:
gerb_item->m_Shape = GBR_SPOT_POLY;
break;
case APT_MACRO: /* spot defined by a macro */
gerb_item->m_Shape = GBR_SPOT_MACRO;
break;
default:
wxMessageBox( wxT( "GERBVIEW_FRAME::CopyDCodesSizeToItems() error" ) );
break;
}
}
}
}
void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor,
EDA_COLOR_T aAltColor,

View File

@ -37,8 +37,6 @@
#include <gerbview.h>
#include <gerbview_frame.h>
#include <colors_selection.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>
#include <printout_controler.h>

View File

@ -30,8 +30,6 @@
#include <fctsys.h>
#include <pgm_base.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <common.h>
#include <gestfich.h>
#include <gerbview.h>

View File

@ -68,10 +68,6 @@
#include <gerbview.h>
#include <gerbview_frame.h>
#include <trigo.h>
#include <macros.h>
#include <base_units.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>
#include <class_excellon.h>
#include <kicad_string.h>

View File

@ -33,12 +33,9 @@
#include <common.h>
#include <confirm.h>
#include <macros.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <trigo.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>
#include <select_layers_to_pcb.h>
#include <build_version.h>
@ -50,8 +47,6 @@ extern const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber );
#define TO_PCB_UNIT( x ) ( x / IU_PER_MM)
#define TRACK_TYPE 0
/* A helper class to export a Gerber set of files to Pcbnew
*/
class GBR_TO_PCB_EXPORTER

View File

@ -29,10 +29,7 @@
#include <fctsys.h>
#include <common.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <gestfich.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <gerbview_id.h>
#include <class_gerbview_layer_widget.h>
@ -186,7 +183,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
setActiveLayer( layer, false );
if( Read_GERBER_File( filename.GetFullPath(), filename.GetFullPath() ) )
if( Read_GERBER_File( filename.GetFullPath() ) )
{
UpdateFileHistory( m_lastFileName );

View File

@ -30,19 +30,11 @@
#include <kiface_i.h>
#include <pgm_base.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <gestfich.h>
#include <gerbview.h>
#include <gerbview_id.h>
#include <hotkeys.h>
#include <gerbview_frame.h>
#include <build_version.h>
#include <wx/file.h>
#include <wx/snglinst.h>
// Colors for layers and items
COLORS_DESIGN_SETTINGS g_ColorsSettings;
@ -122,7 +114,7 @@ KIFACE_I& Kiface() { return kiface; }
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
{
process = (PGM_BASE*) aProgram;
process = aProgram;
return &kiface;
}

View File

@ -41,11 +41,6 @@
/// List of page sizes
extern const wxChar* g_GerberPageSizeList[8];
// Type of photoplotter action:
#define GERB_ACTIVE_DRAW 1 // Activate light (lower pen)
#define GERB_STOP_DRAW 2 // Extinguish light (lift pen)
#define GERB_FLASH 3 // Flash
// number fo draw layers in Gerbview
#define GERBER_DRAWLAYERS_COUNT 32

View File

@ -33,7 +33,6 @@
#include <id.h>
#include <common.h>
#include <class_drawpanel.h>
#include <gestfich.h>
#include <config_params.h>
#include <colors_selection.h>
@ -49,7 +48,6 @@
void GERBVIEW_FRAME::Process_Config( wxCommandEvent& event )
{
int id = event.GetId();
wxString FullFileName;
switch( id )
{

View File

@ -32,7 +32,6 @@
#include <wxstruct.h>
#include <class_drawpanel.h>
#include <build_version.h>
#include <macros.h>
#include <trigo.h>
#include <base_units.h>
#include <colors_selection.h>
@ -41,15 +40,12 @@
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
#include <pcbplot.h>
#include <gerbview_id.h>
#include <hotkeys.h>
#include <class_GERBER.h>
#include <dialog_helpers.h>
#include <class_DCodeSelectionbox.h>
#include <class_gerbview_layer_widget.h>
#include <class_gbr_screen.h>
// Config keywords

View File

@ -118,7 +118,7 @@ public:
{
GERBER_DRAW_ITEM* item = GetGerberLayout()->m_Drawings;
return (GERBER_DRAW_ITEM*) item;
return item;
}
/**
@ -525,10 +525,8 @@ public:
*/
bool OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem = NULL );
GERBER_DRAW_ITEM* GerberGeneralLocateAndDisplay();
GERBER_DRAW_ITEM* Locate( const wxPoint& aPosition, int typeloc );
void Process_Settings( wxCommandEvent& event );
void Process_Config( wxCommandEvent& event );
void InstallGerberOptionsDialog( wxCommandEvent& event );
@ -618,9 +616,7 @@ public:
* @return true if file was opened successfully.
*/
bool LoadGerberFiles( const wxString& aFileName );
int ReadGerberFile( FILE* File, bool Append );
bool Read_GERBER_File( const wxString& GERBER_FullFileName,
const wxString& D_Code_FullFileName );
bool Read_GERBER_File( const wxString& GERBER_FullFileName );
/**
* function LoadDrllFiles
@ -638,7 +634,6 @@ public:
/**
* Set Size Items (Lines, Flashes) from DCodes List
*/
void CopyDCodesSizeToItems();
void Liste_D_Codes();
// PCB handling

View File

@ -28,14 +28,12 @@
#include <fctsys.h>
#include <common.h>
#include <kicad_device_context.h>
#include <id.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_drawpanel.h>
#include <hotkeys.h>
#include <gerbview_id.h>
/* How to add a new hotkey:

View File

@ -27,16 +27,12 @@
*/
#include <fctsys.h>
#include <common.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>
#include <class_gerbview_layer_widget.h>
#include <class_gbr_layout.h>
bool GERBVIEW_FRAME::Clear_DrawLayers( bool query )
{

View File

@ -32,7 +32,6 @@
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_gerber_draw_item.h>
/* localize a gerber item and return a pointer to it.

View File

@ -30,13 +30,12 @@
#include <kiface_i.h>
#include <menus_helpers.h>
#include <pgm_base.h>
#include "gerbview.h"
#include "gerbview_frame.h"
#include "gerbview_id.h"
#include "hotkeys.h"
#include <menus_helpers.h>
void GERBVIEW_FRAME::ReCreateMenuBar()

View File

@ -24,14 +24,11 @@
#include <fctsys.h>
#include <class_drawpanel.h>
#include <common.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <gerbview_id.h>
#include <class_GERBER.h>
#include <dialog_helpers.h>
#include <class_DCodeSelectionbox.h>
/* Process the command triggered by the left button of the mouse
* currently: just display info in the message panel.

View File

@ -28,18 +28,13 @@
*/
// Set this to 1 if you want to test PostScript printing under MSW.
#define wxTEST_POSTSCRIPT_IN_MSW 1
#include <fctsys.h>
#include <pgm_base.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <base_units.h>
#include <wxstruct.h>
#include <class_base_screen.h>
#include <layers_id_colors_and_visibility.h>
#include <gerbview_frame.h>
@ -190,10 +185,6 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
double scalex, scaley;
dc->GetUserScale( &scalex, &scaley );
wxSize PlotAreaSizeInUserUnits;
PlotAreaSizeInUserUnits.x = KiROUND( PlotAreaSizeInPixels.x / scalex );
PlotAreaSizeInUserUnits.y = KiROUND( PlotAreaSizeInPixels.y / scaley );
// In some cases the plot origin is the centre of the board outline rather than the center
// of the selected paper size.
if( m_PrintParams.CenterOnBoardOutline() )

View File

@ -26,7 +26,6 @@
#include <common.h>
#include <confirm.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <class_GERBER.h>
@ -36,8 +35,7 @@
/* Read a gerber file, RS274D, RS274X or RS274X2 format.
*/
bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName,
const wxString& D_Code_FullFileName )
bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName )
{
int G_command = 0; // command number for G commands like G04
int D_commande = 0; // command number for D commands like D02

View File

@ -25,8 +25,6 @@
#include <fctsys.h>
#include <common.h>
#include <gerbview.h>
#include <macros.h>
#include <class_GERBER.h>
#include <base_units.h>

View File

@ -6,7 +6,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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
@ -32,8 +32,6 @@
#include <gerbview.h>
#include <gerbview_frame.h>
#include <trigo.h>
#include <macros.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>
#include <class_X2_gerber_attributes.h>

View File

@ -37,7 +37,7 @@
extern int ReadInt( char*& text, bool aSkipSeparator = true );
extern double ReadDouble( char*& text, bool aSkipSeparator = true );
extern bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file );
extern bool GetEndOfBlock( char* buff, char*& text, FILE* gerber_file );
#define CODE( x, y ) ( ( (x) << 8 ) + (y) )
@ -128,7 +128,7 @@ static int ReadXCommand( char*& text )
}
bool GERBER_IMAGE::ReadRS274XCommand( char buff[GERBER_BUFZ], char*& text )
bool GERBER_IMAGE::ReadRS274XCommand( char* buff, char*& text )
{
bool ok = true;
int code_command;
@ -181,9 +181,7 @@ exit:
}
bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
char buff[GERBER_BUFZ],
char*& text )
bool GERBER_IMAGE::ExecuteRS274XCommand( int command, char* buff, char*& text )
{
int code;
int seq_len; // not used, just provided
@ -807,7 +805,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
}
dcode->m_Shape = APT_MACRO;
dcode->SetMacro( (APERTURE_MACRO*) pam );
dcode->SetMacro( pam );
}
break;
@ -824,7 +822,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
}
bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file )
bool GetEndOfBlock( char* buff, char*& text, FILE* gerber_file )
{
for( ; ; )
{
@ -860,7 +858,7 @@ bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file )
* @param aFile = the opened GERBER file to read
* @return a pointer to the beginning of the next line or NULL if end of file
*/
static char* GetNextLine( char aBuff[GERBER_BUFZ], char* aText, FILE* aFile )
static char* GetNextLine( char *aBuff, char* aText, FILE* aFile )
{
for( ; ; )
{
@ -886,7 +884,7 @@ static char* GetNextLine( char aBuff[GERBER_BUFZ], char* aText, FILE* aFile )
}
bool GERBER_IMAGE::ReadApertureMacro( char buff[GERBER_BUFZ],
bool GERBER_IMAGE::ReadApertureMacro( char *buff,
char*& text,
FILE* gerber_file )
{

View File

@ -31,7 +31,6 @@
#include <fctsys.h>
#include <common.h>
#include <macros.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <bitmaps.h>

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2016 KiCad Developers, see CHANGELOG.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
@ -27,8 +27,9 @@
* @brief Handle colors used to draw all items or layers.
*/
#ifndef _COLORS_DESIGN_SETTING_H
#define _COLORS_DESIGN_SETTING_H
#ifndef COLORS_DESIGN_SETTING_H
#define COLORS_DESIGN_SETTING_H
#include <colors.h> // definition of EDA_COLOR_T
#include <layers_id_colors_and_visibility.h>
@ -86,4 +87,4 @@ public:
void SetAllColorsAs( EDA_COLOR_T aColor);
};
#endif // _COLORS_DESIGN_SETTING_H
#endif // COLORS_DESIGN_SETTING_H