Commit 687a127b authored by jean-pierre charras's avatar jean-pierre charras

Gerbview: remove dependencies from Pcbnew.

Should allow Pcbnew code easier to change and Gerbview code more understandable and easier to maintain.
Code cleaning (remove dead code, add comments).
Minor other enhancements.
parents 2fe9a99b 4125ea77
......@@ -412,6 +412,7 @@ set( BMAPS_MID
pin_to
pin
plot_hpg
plot_pdf
plot_ps
plot
polar_coord
......
......@@ -36,6 +36,7 @@ set(COMMON_SRCS
build_version.cpp
class_bitmap_base.cpp
class_colors_design_settings.cpp
class_layer_box_selector.cpp
class_marker_base.cpp
class_plotter.cpp
class_undoredo_container.cpp
......@@ -89,7 +90,6 @@ set(PCB_COMMON_SRCS
class_page_info.cpp
pcbcommon.cpp
footprint_info.cpp
class_layer_box_selector.cpp
../pcbnew/basepcbframe.cpp
../pcbnew/class_board.cpp
../pcbnew/class_board_connected_item.cpp
......
......@@ -40,7 +40,7 @@
#include <base_units.h>
#if defined( PCBNEW ) || defined( CVPCB ) || defined( EESCHEMA )
#if defined( PCBNEW ) || defined( CVPCB ) || defined( EESCHEMA ) || defined( GERBVIEW )
#define IU_TO_MM( x ) ( x / IU_PER_MM )
#define IU_TO_IN( x ) ( x / IU_PER_MILS / 1000 )
#define MM_TO_IU( x ) ( x * IU_PER_MM )
......
#include <common.h>
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <class_board_design_settings.h>
#include <colors_selection.h>
#include <layers_id_colors_and_visibility.h>
#include <bitmaps.h>
#include <hotkeys.h>
#include <help_common_strings.h>
#include <class_board.h>
#include <colors.h>
#include <wx/wx.h>
#include <wx/ownerdrw.h>
#include <wx/menuitem.h>
#include <wx/bmpcbox.h>
#include <wx/wx.h>
#include <wx/aui/aui.h>
#include <class_layer_box_selector.h>
......@@ -101,79 +95,30 @@ int LAYER_BOX_SELECTOR::SetLayerSelection( int layer )
return -1;
}
// Reload the Layers
void LAYER_BOX_SELECTOR::Resync()
{
PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent();
BOARD* board = pcbFrame->GetBoard();
wxASSERT( board != NULL );
Clear();
static DECLARE_LAYERS_ORDER_LIST( layertranscode );
static DECLARE_LAYERS_HOTKEY( layerhk );
for( int i = 0; i < LAYER_COUNT; i++ )
{
wxBitmap layerbmp( 14, 14 );
wxMemoryDC bmpDC;
wxBrush brush;
wxString layername;
int layerid = i;
if( m_layerorder )
layerid = layertranscode[i];
if( !board->IsLayerEnabled( layerid ) )
continue;
// Prepare Bitmap
bmpDC.SelectObject( layerbmp );
brush.SetColour( MakeColour( board->GetLayerColor( layerid ) ) );
brush.SetStyle( wxSOLID );
bmpDC.SetBrush( brush );
bmpDC.DrawRectangle( 0, 0, layerbmp.GetWidth(), layerbmp.GetHeight() );
bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
bmpDC.SetPen( *wxBLACK_PEN );
bmpDC.DrawRectangle( 0, 0, layerbmp.GetWidth(), layerbmp.GetHeight() );
layername = board->GetLayerName( layerid );
if( m_layerhotkeys && m_hotkeys != NULL )
layername = AddHotkeyName( layername, m_hotkeys, layerhk[layerid], IS_COMMENT );
Append( layername, layerbmp, (void*) layerid );
}
}
void LAYER_BOX_SELECTOR::ResyncBitmapOnly()
{
PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent();
BOARD* board = pcbFrame->GetBoard();
int elements = GetCount();
for( int i = 0; i < elements; i++ )
{
wxBitmap layerbmp( 14, 14 );
wxMemoryDC bmpDC;
wxBrush brush;
wxString layername;
int layerid = i;
// Prepare Bitmap
bmpDC.SelectObject( layerbmp );
brush.SetColour( MakeColour( board->GetLayerColor( layerid ) ) );
brush.SetStyle( wxSOLID );
bmpDC.SetBrush( brush );
bmpDC.DrawRectangle( 0, 0, layerbmp.GetWidth(), layerbmp.GetHeight() );
bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
bmpDC.SetPen( *wxBLACK_PEN );
bmpDC.DrawRectangle( 0, 0, layerbmp.GetWidth(), layerbmp.GetHeight() );
SetItemBitmap(i, layerbmp);
wxBitmap layerbmp( 14, 14 );
SetBitmapLayer( layerbmp, i );
}
}
void LAYER_BOX_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, int aLayerIndex )
{
wxMemoryDC bmpDC;
wxBrush brush;
// Prepare Bitmap
bmpDC.SelectObject( aLayerbmp );
brush.SetColour( MakeColour( GetLayerColor( aLayerIndex ) ) );
brush.SetStyle( wxSOLID );
bmpDC.SetBrush( brush );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
bmpDC.SetPen( *wxBLACK_PEN );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
}
......@@ -151,7 +151,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
AddMenuItem( choice_plot_fmt, ID_GEN_PLOT_PDF,
_( "Plot PDF" ),
_( "Plot schematic sheet in PDF format" ),
KiBitmap( plot_ps_xpm ) );
KiBitmap( plot_pdf_xpm ) );
// Plot HPGL
AddMenuItem( choice_plot_fmt,
......
add_definitions(-DGERBVIEW -DPCBNEW)
add_definitions(-DGERBVIEW)
###
# Includes
......@@ -22,10 +22,11 @@ set(DIALOGS_SRCS
dialogs/gerbview_dialog_display_options_frame_base.cpp
dialogs/gerbview_dialog_display_options_frame.cpp
dialogs/dialog_layers_select_to_pcb_base.cpp
dialogs/dialog_show_page_borders.cpp
dialogs/dialog_show_page_borders_base.cpp
dialogs/dialog_print_using_printer.cpp
dialogs/dialog_print_using_printer_base.cpp
dialogs/dialog_select_one_pcb_layer.cpp
dialogs/dialog_show_page_borders.cpp
dialogs/dialog_show_page_borders_base.cpp
)
set(GERBVIEW_SRCS
......@@ -34,9 +35,11 @@ set(GERBVIEW_SRCS
class_aperture_macro.cpp
class_DCodeSelectionbox.cpp
class_gbr_screen.cpp
class_gbr_layout.cpp
class_GERBER.cpp
class_gerber_draw_item.cpp
class_gerbview_layer_widget.cpp
class_gbr_layer_box_selector.cpp
controle.cpp
dcode.cpp
draw_gerber_screen.cpp
......@@ -53,7 +56,6 @@ set(GERBVIEW_SRCS
menubar.cpp
onleftclick.cpp
onrightclick.cpp
options.cpp
pcbplot.cpp
readgerb.cpp
rs274_read_XY_and_IJ_coordinates.cpp
......@@ -67,10 +69,12 @@ set(GERBVIEW_SRCS
# We need some extra sources from common and pcbnew
###
set(GERBVIEW_EXTRA_SRCS
../common/base_screen.cpp
../common/base_units.cpp
../common/class_layer_box_selector.cpp
../common/class_page_info.cpp
../pcbnew/layer_widget.cpp
../pcbnew/printout_controler.cpp
../pcbnew/class_drc_item.cpp
)
###
......@@ -117,7 +121,7 @@ endif(APPLE)
###
# Link executable target gerbview with correct libraries
###
target_link_libraries(gerbview pcbcommon common 3d-viewer polygon bitmaps kbool
target_link_libraries(gerbview common polygon bitmaps kbool
${OPENGL_LIBRARIES}
${wxWidgets_LIBRARIES}
${GDI_PLUS_LIBRARIES})
......
......@@ -91,27 +91,7 @@ void GERBVIEW_FRAME::HandleBlockPlace( wxDC* DC )
GetScreen()->m_BlockLocate.ClearItemsList();
break;
case BLOCK_COPY: /* Copy */
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
Block_Duplicate( DC );
GetScreen()->m_BlockLocate.ClearItemsList();
break;
case BLOCK_PASTE:
case BLOCK_DRAG:
case BLOCK_PRESELECT_MOVE:
case BLOCK_ZOOM:
case BLOCK_ROTATE:
case BLOCK_FLIP:
case BLOCK_DELETE:
case BLOCK_SAVE:
case BLOCK_ABORT:
case BLOCK_SELECT_ITEMS_ONLY:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_IDLE:
default:
wxFAIL_MSG( wxT("HandleBlockPlace: Unexpected block command") );
break;
}
......@@ -136,7 +116,6 @@ bool GERBVIEW_FRAME::HandleBlockEnd( wxDC* DC )
switch( GetScreen()->m_BlockLocate.GetCommand() )
{
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE );
nextcmd = true;
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
......@@ -144,27 +123,11 @@ bool GERBVIEW_FRAME::HandleBlockEnd( wxDC* DC )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
break;
case BLOCK_DELETE: /* Delete */
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
Block_Delete( DC );
break;
case BLOCK_ZOOM: /* Window Zoom */
zoom_command = true;
break;
case BLOCK_PRESELECT_MOVE: /* Move with preselection list */
case BLOCK_DRAG:
case BLOCK_IDLE:
case BLOCK_MIRROR_X: /* Mirror, unused*/
case BLOCK_ROTATE: /* Unused */
case BLOCK_FLIP: /* Flip, unused */
case BLOCK_SAVE: /* Save (not used)*/
case BLOCK_PASTE:
case BLOCK_ABORT:
case BLOCK_SELECT_ITEMS_ONLY:
case BLOCK_MIRROR_Y:
default:
wxFAIL_MSG( wxT("HandleBlockEnd: Unexpected block command") );
break;
}
......@@ -228,31 +191,6 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
}
void GERBVIEW_FRAME::Block_Delete( wxDC* DC )
{
if( !IsOK( this, _( "Ok to delete block ?" ) ) )
return;
GetScreen()->SetModify();
GetScreen()->m_BlockLocate.Normalize();
GetScreen()->SetCurItem( NULL );
BOARD_ITEM* item = GetBoard()->m_Drawings;
BOARD_ITEM* nextitem;
for( ; item; item = nextitem )
{
nextitem = item->Next();
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) )
gerb_item->DeleteStructure();
}
Refresh();
}
void GERBVIEW_FRAME::Block_Move( wxDC* DC )
{
wxPoint delta;
......@@ -270,9 +208,7 @@ void GERBVIEW_FRAME::Block_Move( wxDC* DC )
delta = GetScreen()->m_BlockLocate.GetMoveVector();
/* Move items in block */
BOARD_ITEM* item = GetBoard()->m_Drawings;
for( ; item; item = item->Next() )
for( GERBER_DRAW_ITEM* item = GetItemsList(); item; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
......@@ -282,38 +218,3 @@ void GERBVIEW_FRAME::Block_Move( wxDC* DC )
m_canvas->Refresh( true );
}
void GERBVIEW_FRAME::Block_Duplicate( wxDC* DC )
{
wxPoint delta;
wxPoint oldpos;
oldpos = GetScreen()->GetCrossHairPosition();
m_canvas->SetMouseCaptureCallback( NULL );
GetScreen()->SetCrossHairPosition( oldpos );
m_canvas->MoveCursorToCrossHair();
GetScreen()->SetModify();
GetScreen()->m_BlockLocate.Normalize();
delta = GetScreen()->m_BlockLocate.GetMoveVector();
/* Copy items in block */
BOARD_ITEM* item = GetBoard()->m_Drawings;
for( ; item; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) )
{
/* this item must be duplicated */
GERBER_DRAW_ITEM* new_item = gerb_item->Copy();
new_item->MoveAB( delta );
GetBoard()->m_Drawings.PushFront( new_item );
}
}
m_canvas->Refresh();
}
......@@ -95,8 +95,6 @@ GERBER_IMAGE::GERBER_IMAGE( GERBVIEW_FRAME* aParent, int aLayer )
for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ )
m_Aperture_List[ii] = 0;
m_Pcb = aParent->GetBoard();
}
......@@ -108,10 +106,16 @@ GERBER_IMAGE::~GERBER_IMAGE()
// m_Aperture_List[ii] = NULL;
}
delete m_Pcb;
}
/*
* Function GetItemsList
* returns the first GERBER_DRAW_ITEM * item of the items list
*/
GERBER_DRAW_ITEM * GERBER_IMAGE::GetItemsList()
{
return m_Parent->GetItemsList();
}
D_CODE* GERBER_IMAGE::GetDCODE( int aDCODE, bool create )
{
......@@ -206,18 +210,16 @@ bool GERBER_IMAGE::HasNegativeItems()
else
{
m_hasNegativeItems = 0;
for( BOARD_ITEM* item = m_Pcb->m_Drawings; item; item = item->Next() )
for( GERBER_DRAW_ITEM* item = GetItemsList(); item; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
if( gerb_item->GetLayer() != m_GraphicLayer )
if( item->GetLayer() != m_GraphicLayer )
continue;
if( gerb_item->HasNegativeItems() )
if( item->HasNegativeItems() )
{
m_hasNegativeItems = 1;
break;
}
}
// TODO search for items in list
}
}
return m_hasNegativeItems == 1;
......@@ -306,7 +308,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->GetBoard()->m_Drawings.Append( dupItem );
m_Parent->GetLayout()->m_Drawings.Append( dupItem );
}
}
}
......
......@@ -17,7 +17,6 @@
|| ( (x) == '-' ) || ( (x) == '+' ) || ( (x) == '.' ) )
class GERBVIEW_FRAME;
class BOARD;
class D_CODE;
/* gerber files have different parameters to define units and how items must be plotted.
......@@ -74,10 +73,9 @@ private:
*/
class GERBER_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
BOARD* m_Pcb;
GERBER_LAYER m_GBRLayerParams; // hold params for the current gerber layer
......@@ -155,6 +153,12 @@ public:
return m_Parent;
}
/**
* Function GetItemsList
* @return the first GERBER_DRAW_ITEM * item of the items list
*/
GERBER_DRAW_ITEM * GetItemsList();
/**
* Function GetLayerParams
* @return the current layers params
......
......@@ -53,7 +53,7 @@ enum drill_G_code_t {
// Helper struct to analyse Excellon commands
struct EXCELLON_CMD
{
string m_Name; // key string
std::string m_Name; // key string
int m_Code; // internal code, used as id in functions
int m_asParams; // 0 = no param, -1 = skip params, 1 = read params
};
......
/**
* @file class_gbr_layer_box_selector.cpp
* @brief a derived class of LAYER_BOX_SELECTOR to handle the layer box selector
* in GerbView
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 Jean-Pierre Charras <jean-pierre.charras@ujf-grenoble.fr>
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2012 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
*/
#include <common.h>
#include <colors_selection.h>
#include <layers_id_colors_and_visibility.h>
#include <gerbview_frame.h>
#include <wx/ownerdrw.h>
#include <wx/menuitem.h>
#include <wx/bmpcbox.h>
#include <wx/wx.h>
#include <class_gbr_layer_box_selector.h>
void GBR_LAYER_BOX_SELECTOR::Resync()
{
Clear();
for( int layerid = 0; layerid < LAYER_COUNT; layerid++ )
{
wxBitmap layerbmp( 14, 14 );
wxString layername;
if( !IsLayerEnabled( layerid ) )
continue;
// Prepare Bitmap
SetBitmapLayer( layerbmp, layerid );
layername = GetLayerName( layerid );
Append( layername, layerbmp, (void*) layerid );
}
}
// Returns a color index from the layer id
int GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayerIndex )
{
GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
return frame->GetLayerColor( aLayerIndex );
}
// Returns the name of the layer id
const wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( int aLayerIndex )
{
wxString name;
name.Printf( _( "Layer %d" ), aLayerIndex + 1 );
return name;
}
#ifndef CLASS_GBR_LAYER_BOX_SELECTOR_H
#define CLASS_GBR_LAYER_BOX_SELECTOR_H 1
#include <class_layer_box_selector.h>
/* class to display a layer list in GerbView.
*
*/
class GBR_LAYER_BOX_SELECTOR : public LAYER_BOX_SELECTOR
{
public:
GBR_LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL )
:LAYER_BOX_SELECTOR( parent, id, pos, size, n, choices )
{
m_layerhotkeys = false;
m_layerorder = false;
}
GBR_LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices )
:LAYER_BOX_SELECTOR( parent, id, pos, size, choices )
{
m_layerhotkeys = false;
m_layerorder = false;
}
// Reload the Layers names and bitmaps
// Virtual function
void Resync();
// Returns a color index from the layer id
// Virtual function
int GetLayerColor( int aLayerIndex );
// Returns true if the layer id is enabled (i.e. is it should be displayed)
// Virtual function
bool IsLayerEnabled( int aLayerIndex ) { return true; };
// Returns the name of the layer id
// Virtual function
const wxString GetLayerName( int aLayerIndex );
};
#endif //CLASS_GBR_LAYER_BOX_SELECTOR_H
/**
* @file class_gbr_layout.cpp
* @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()
{
PAGE_INFO pageInfo( wxT( "GERBER" ) );
SetPageSettings( pageInfo );
m_printLayersMask = -1;
}
GBR_LAYOUT::~GBR_LAYOUT()
{
}
/* Function IsLayerVisible
* tests whether a given layer is visible
* param aLayerIndex = The index of the layer to be tested
* return bool - true if the layer is visible.
*/
bool GBR_LAYOUT::IsLayerVisible( int aLayerIndex ) const
{
return m_printLayersMask & (1 << aLayerIndex );
}
EDA_RECT GBR_LAYOUT::ComputeBoundingBox()
{
EDA_RECT bbox;
for( GERBER_DRAW_ITEM* gerb_item = m_Drawings; gerb_item; gerb_item = gerb_item->Next() )
bbox.Merge( gerb_item->GetBoundingBox() );
SetBoundingBox( bbox );
return bbox;
}
/**
* @file class_gbr_layout.h
* @brief Class CLASS_GBR_LAYOUT to handle a board.
*/
#ifndef CLASS_GBR_LAYOUT_H
#define CLASS_GBR_LAYOUT_H
#include <dlist.h>
// #include <layers_id_colors_and_visibility.h>
#include <class_colors_design_settings.h>
#include <common.h> // PAGE_INFO
#include <class_title_block.h>
#include <class_gerber_draw_item.h>
/**
* Class GBR_LAYOUT
* holds list of GERBER_DRAW_ITEM currently loaded.
*/
class GBR_LAYOUT
{
private:
EDA_RECT m_BoundingBox;
PAGE_INFO m_paper;
TITLE_BLOCK m_titles;
wxPoint m_originAxisPosition;
int m_printLayersMask; // When printing: the list of layers to print
public:
DLIST<GERBER_DRAW_ITEM> m_Drawings; // linked list of Gerber Items
GBR_LAYOUT();
~GBR_LAYOUT();
const PAGE_INFO& GetPageSettings() const { return m_paper; }
void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
const wxPoint& GetOriginAxisPosition() const
{
return m_originAxisPosition;
}
void SetOriginAxisPosition( const wxPoint& aPosition )
{
m_originAxisPosition = aPosition;
}
TITLE_BLOCK& GetTitleBlock()
{
return m_titles;
}
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
{
m_titles = aTitleBlock;
}
/**
* Function ComputeBoundingBox
* calculates the bounding box containing all Gerber items.
* @return EDA_RECT - the full item list bounding box
*/
EDA_RECT ComputeBoundingBox();
/**
* Function GetBoundingBox
* may be called soon after ComputeBoundingBox() to return the same EDA_RECT,
* as long as the CLASS_GBR_LAYOUT has not changed.
*/
EDA_RECT GetBoundingBox() const { return m_BoundingBox; } // override
void SetBoundingBox( const EDA_RECT& aBox ) { m_BoundingBox = aBox; }
/**
* Function Draw.
* Redraw the CLASS_GBR_LAYOUT items but not cursors, axis or grid.
* @param aPanel = the panel relative to the board
* @param aDC = the current device context
* @param aDrawMode = GR_COPY, GR_OR ... (not always used)
* @param aOffset = an draw offset value
*/
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
int aDrawMode, const wxPoint& aOffset );
/**
* Function SetVisibleLayers
* changes the bit-mask of visible layers
* @param aLayerMask = The new bit-mask of visible layers
*/
void SetVisibleLayers( int aLayerMask )
{
m_printLayersMask = aLayerMask;
}
/**
* Function IsLayerVisible
* tests whether a given layer is visible
* @param aLayerIndex = The index of the layer to be tested
* @return bool - true if the layer is visible.
*/
bool IsLayerVisible( int aLayerIndex ) const;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // overload
#endif
};
#endif // #ifndef CLASS_GBR_LAYOUT_H
......@@ -88,18 +88,13 @@ static GRID_TYPE gbrGridList[] =
};
GBR_SCREEN::GBR_SCREEN( const wxSize& aPageSizeIU ) :
PCB_SCREEN( aPageSizeIU )
GBR_SCREEN::GBR_SCREEN( const wxSize& aPageSizeIU ) : BASE_SCREEN( SCREEN_T )
{
// Replace zoom and grid lists already set by PCB_SCREEN ctor
m_ZoomList.Clear();
for( unsigned i = 0; i < DIM( gbrZoomList ); ++i )
m_ZoomList.Add( gbrZoomList[i] );
GRIDS gridlist;
for( unsigned i = 0; i < DIM( gbrGridList ); ++i )
gridlist.push_back( gbrGridList[i] );
SetGridList( gridlist );
AddGrid( gbrGridList[i] );
// Set the working grid size to a reasonnable value (in 1/10000 inch)
SetGrid( DMIL_GRID( 500 ) );
......@@ -107,11 +102,14 @@ GBR_SCREEN::GBR_SCREEN( const wxSize& aPageSizeIU ) :
m_Active_Layer = LAYER_N_BACK; // default active layer = bottom layer
SetZoom( ZOOM_FACTOR( 350 ) ); // a default value for zoom
InitDataPoints( aPageSizeIU );
}
GBR_SCREEN::~GBR_SCREEN()
{
ClearUndoRedoList();
}
......@@ -120,3 +118,13 @@ int GBR_SCREEN::MilsToIuScalar()
{
return (int)IU_PER_MILS;
}
/* Virtual function needed by classes derived from BASE_SCREEN
* this is a virtual pure function in BASE_SCREEN
* do nothing in GerbView
* could be removed later
*/
void GBR_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER&, int )
{
}
......@@ -7,16 +7,16 @@
#include <base_units.h>
#include <class_pcb_screen.h>
#include <class_base_screen.h>
#define ZOOM_FACTOR( x ) ( x * IU_PER_DECIMILS )
/* Handle info to display a board */
class GBR_SCREEN : public PCB_SCREEN
class GBR_SCREEN : public BASE_SCREEN
{
public:
int m_Active_Layer;
/**
* Constructor
* @param aPageSizeIU is the size of the initial paper page in internal units.
......@@ -27,7 +27,18 @@ public:
GBR_SCREEN* Next() { return (GBR_SCREEN*) Pnext; }
// void SetNextZoom();
// void SetPreviousZoom();
// void SetLastZoom();
virtual int MilsToIuScalar();
/**
* Function ClearUndoORRedoList
* virtual pure in BASE_SCREEN, so it must be defined here
*/
void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 );
};
#endif // CLASS_GBR_SCREEN_H_
......@@ -32,18 +32,15 @@
#include <common.h>
#include <trigo.h>
#include <class_drawpanel.h>
#include <drawtxt.h>
#include <macros.h>
#include <gerbview.h>
#include <class_board_design_settings.h>
#include <colors_selection.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER_IMAGE* aGerberparams ) :
BOARD_ITEM( aParent, TYPE_GERBER_DRAW_ITEM )
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( GBR_LAYOUT* aParent, GERBER_IMAGE* aGerberparams ) :
EDA_ITEM( (EDA_ITEM*)aParent, TYPE_GERBER_DRAW_ITEM )
{
m_imageParams = aGerberparams;
m_Layer = 0;
......@@ -64,7 +61,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER_IMAGE* aGerberpa
// Copy constructor
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) :
BOARD_ITEM( aSource )
EDA_ITEM( aSource )
{
m_imageParams = aSource.m_imageParams;
m_Shape = aSource.m_Shape;
......@@ -316,16 +313,16 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode,
int radius;
int halfPenWidth;
static bool show_err;
BOARD* brd = GetBoard();
D_CODE* d_codeDescr = GetDcodeDescr();
GERBVIEW_FRAME* gerbFrame = (GERBVIEW_FRAME*) aPanel->GetParent();
if( d_codeDescr == NULL )
d_codeDescr = &dummyD_CODE;
if( brd->IsLayerVisible( GetLayer() ) == false )
if( gerbFrame->IsLayerVisible( GetLayer() ) == false )
return;
color = brd->GetLayerColor( GetLayer() );
color = gerbFrame->GetLayerColor( GetLayer() );
if( aDrawMode & GR_HIGHLIGHT )
{
......@@ -354,12 +351,12 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode,
GRSetDrawMode( aDC, aDrawMode );
isFilled = DisplayOpt.DisplayPcbTrackFill ? true : false;
isFilled = gerbFrame->m_DisplayOptions.m_DisplayLinesFill;
switch( m_Shape )
{
case GBR_POLYGON:
isFilled = (g_DisplayPolygonsModeSketch == false);
isFilled = gerbFrame->m_DisplayOptions.m_DisplayPolygonsFill;
if( !isDark )
isFilled = true;
......@@ -419,7 +416,7 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode,
case GBR_SPOT_OVAL:
case GBR_SPOT_POLY:
case GBR_SPOT_MACRO:
isFilled = DisplayOpt.DisplayPadFill ? true : false;
isFilled = gerbFrame->m_DisplayOptions.m_DisplayFlashedItemsFill;
d_codeDescr->DrawFlashedShape( this, aPanel->GetClipBox(), aDC, color, alt_color,
m_Start, isFilled );
break;
......
......@@ -30,10 +30,12 @@
#define CLASS_GERBER_DRAW_ITEM_H
#include <base_struct.h>
#include <class_board_item.h>
#include <dlist.h>
class GERBER_IMAGE;
class GBR_LAYOUT;
class D_CODE;
/* Shapes id for basic shapes ( .m_Shape member ) */
......@@ -52,7 +54,7 @@ enum Gbr_Basic_Shapes {
/***/
class GERBER_DRAW_ITEM : public BOARD_ITEM
class GERBER_DRAW_ITEM : public EDA_ITEM
{
// make SetNext() and SetBack() private so that they may not be called from anywhere.
// list management is done on GERBER_DRAW_ITEMs using DLIST<GERBER_DRAW_ITEM> only.
......@@ -86,6 +88,8 @@ public:
* redundancy for these parameters
*/
private:
int m_Layer;
// These values are used to draw this item, according to gerber layers parameters
// Because they can change inside a gerber image, they are stored here
// for each item
......@@ -98,7 +102,7 @@ private:
double m_lyrRotation; // Fine rotation, from OR parameter, in degrees
public:
GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER_IMAGE* aGerberparams );
GERBER_DRAW_ITEM( GBR_LAYOUT* aParent, GERBER_IMAGE* aGerberparams );
GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource );
~GERBER_DRAW_ITEM();
......@@ -113,6 +117,21 @@ public:
GERBER_DRAW_ITEM* Next() const { return (GERBER_DRAW_ITEM*) Pnext; }
GERBER_DRAW_ITEM* Back() const { return (GERBER_DRAW_ITEM*) Pback; }
/**
* Function GetLayer
* returns the layer this item is on.
*/
int GetLayer() const { return m_Layer; }
/**
* Function SetLayer
* sets the layer this item is on.
* @param aLayer The layer number.
* is virtual because some items (in fact: class DIMENSION)
* have a slightly different initialization
*/
void SetLayer( int aLayer ) { m_Layer = aLayer; }
int ReturnMaskLayer()
{
return 1 << m_Layer;
......@@ -203,7 +222,7 @@ public:
void Draw( EDA_DRAW_PANEL* aPanel,
wxDC* aDC,
int aDrawMode,
const wxPoint&aOffset = ZeroOffset );
const wxPoint&aOffset );
/**
* Function ConvertSegmentToPolygon
......@@ -270,6 +289,28 @@ public:
*/
bool Save( FILE* aFile ) const;
/**
* Function UnLink
* detaches this object from its owner.
*/
void UnLink()
{
DLIST<GERBER_DRAW_ITEM>* list = (DLIST<GERBER_DRAW_ITEM>*) GetList();
wxASSERT( list );
if( list )
list->Remove( this );
}
/**
* Function DeleteStructure
* deletes this object after UnLink()ing it from its owner.
*/
void DeleteStructure()
{
UnLink();
delete this;
}
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const; // override
#endif
......
......@@ -34,7 +34,7 @@
#include <class_drawpanel.h>
#include <pcbstruct.h>
#include <macros.h>
#include <class_layer_box_selector.h>
#include <class_gbr_layer_box_selector.h>
#include <gerbview.h>
#include <class_GERBER.h>
......@@ -91,7 +91,6 @@ void GERBER_LAYER_WIDGET::SetLayersManagerTabsText( )
*/
void GERBER_LAYER_WIDGET::ReFillRender()
{
BOARD* board = myframe->GetBoard();
ClearRenderRows();
// Fixed "Rendering" tab rows within the LAYER_WIDGET, only the initial color
......@@ -111,10 +110,9 @@ void GERBER_LAYER_WIDGET::ReFillRender()
{
if( renderRows[row].color != -1 ) // does this row show a color?
{
// this window frame must have an established BOARD, i.e. after SetBoard()
renderRows[row].color = board->GetVisibleElementColor( renderRows[row].id );
renderRows[row].color = myframe->GetVisibleElementColor( renderRows[row].id );
}
renderRows[row].state = board->IsElementVisible( renderRows[row].id );
renderRows[row].state = myframe->IsElementVisible( renderRows[row].id );
}
AppendRenderRows( renderRows, DIM(renderRows) );
......@@ -184,7 +182,7 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
visibleLayers &= ~(1 << row);
}
myframe->GetBoard()->SetVisibleLayers( visibleLayers );
myframe->SetVisibleLayers( visibleLayers );
myframe->GetCanvas()->Refresh();
break;
}
......@@ -194,16 +192,15 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
void GERBER_LAYER_WIDGET::ReFill()
{
BOARD* brd = myframe->GetBoard();
int layer;
ClearLayerRows();
for( layer = 0; layer < LAYER_COUNT; layer++ )
for( layer = 0; layer < GERBVIEW_LAYER_COUNT; layer++ )
{
wxString msg;
msg.Printf( _("Layer %d"), layer+1 );
AppendLayerRow( LAYER_WIDGET::ROW( msg, layer,
brd->GetLayerColor( layer ), wxEmptyString, true ) );
myframe->GetLayerColor( layer ), wxEmptyString, true ) );
}
installRightLayerClickHandler();
......@@ -213,7 +210,7 @@ void GERBER_LAYER_WIDGET::ReFill()
void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, int aColor )
{
myframe->GetBoard()->SetLayerColor( aLayer, aColor );
myframe->SetLayerColor( aLayer, aColor );
myframe->m_SelLayerBox->ResyncBitmapOnly();
myframe->GetCanvas()->Refresh();
}
......@@ -234,15 +231,14 @@ bool GERBER_LAYER_WIDGET::OnLayerSelect( int aLayer )
void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
{
BOARD* brd = myframe->GetBoard();
int visibleLayers = brd->GetVisibleLayers();
int visibleLayers = myframe->GetVisibleLayers();
if( isVisible )
visibleLayers |= (1 << aLayer);
else
visibleLayers &= ~(1 << aLayer);
brd->SetVisibleLayers( visibleLayers );
myframe->SetVisibleLayers( visibleLayers );
if( isFinal )
myframe->GetCanvas()->Refresh();
......@@ -250,15 +246,13 @@ void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFin
void GERBER_LAYER_WIDGET::OnRenderColorChange( int aId, int aColor )
{
myframe->GetBoard()->SetVisibleElementColor( aId, aColor );
myframe->SetVisibleElementColor( aId, aColor );
myframe->GetCanvas()->Refresh();
}
void GERBER_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
{
BOARD* brd = myframe->GetBoard();
brd->SetElementVisibility( aId, isEnabled );
myframe->SetElementVisibility( aId, isEnabled );
myframe->GetCanvas()->Refresh();
}
......
......@@ -286,11 +286,9 @@ void GERBVIEW_FRAME::CopyDCodesSizeToItems()
{
static D_CODE dummy( 999 ); //Used if D_CODE not found in list
BOARD_ITEM* item = GetBoard()->m_Drawings;
for( ; item; item = item->Next() )
GERBER_DRAW_ITEM* gerb_item = GetItemsList();
for( ; gerb_item; gerb_item = gerb_item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
D_CODE* dcode = gerb_item->GetDcodeDescr();
wxASSERT( dcode );
if( dcode == NULL )
......
......@@ -134,7 +134,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
/************************************************************************/
{
SetFocus();
int layer_max = NB_LAYERS;
int layer_max = GERBVIEW_LAYER_COUNT;
wxString msg;
if( g_pageSetupData == NULL )
......@@ -204,17 +204,6 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
}
}
// Disable checkboxes if the corresponding layer is not enabled
BOARD* board = ((PCB_BASE_FRAME*)m_Parent)->GetBoard();
for( int layer = 0; layer<NB_LAYERS; layer++, mask <<= 1 )
{
if( ! board->IsLayerEnabled( layer ) )
{
m_BoxSelectLayer[layer]->Enable( false );
m_BoxSelectLayer[layer]->SetValue( false );
}
}
m_ScaleOption->SetSelection( scale_idx );
scale_idx = m_ScaleOption->GetSelection();
s_Parameters.m_PrintScale = s_ScaleList[scale_idx];
......@@ -274,7 +263,7 @@ int DIALOG_PRINT_USING_PRINTER::SetLayerMaskFromListSelection()
int page_count;
s_Parameters.m_PrintMaskLayer = 0;
int ii;
for( ii = 0, page_count = 0; ii < LAYER_COUNT; ii++ )
for( ii = 0, page_count = 0; ii < GERBVIEW_LAYER_COUNT; ii++ )
{
if( m_BoxSelectLayer[ii]->IsChecked() )
{
......@@ -303,7 +292,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 < LAYER_COUNT; ++layer )
for( int layer = 0; layer < GERBVIEW_LAYER_COUNT; ++layer )
{
layerKey.Printf( OPTKEY_LAYERBASE, layer );
m_Config->Write( layerKey, m_BoxSelectLayer[layer]->IsChecked() );
......
/**
* @file select_pcb_layer.cpp
* @brief Set up a dialog to choose a PCB Layer.
*/
#include <fctsys.h>
#include <gerbview_frame.h>
#include <select_layers_to_pcb.h>
// Exported function
const wxString GetPCBDefaultLayerName( int aLayerNumber );
enum layer_sel_id {
ID_LAYER_SELECT_TOP = 1800,
ID_LAYER_SELECT_BOTTOM,
ID_LAYER_SELECT
};
class SELECT_LAYER_DIALOG : public wxDialog
{
private:
GERBVIEW_FRAME* m_Parent;
wxRadioBox* m_LayerList;
int m_LayerId[NB_LAYERS + 1]; // One extra element for "(Deselect)" radiobutton
public:
// Constructor and destructor
SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLayer,
int aCopperLayerCount, bool aShowDeselectOption );
~SELECT_LAYER_DIALOG() { };
private:
void OnLayerSelected( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE( SELECT_LAYER_DIALOG, wxDialog )
EVT_BUTTON( wxID_OK, SELECT_LAYER_DIALOG::OnLayerSelected )
EVT_BUTTON( wxID_CANCEL, SELECT_LAYER_DIALOG::OnCancelClick )
EVT_RADIOBOX( ID_LAYER_SELECT, SELECT_LAYER_DIALOG::OnLayerSelected )
END_EVENT_TABLE()
/** Install the dialog box for layer selection
* @param aDefaultLayer = Preselection (NB_LAYERS for "(Deselect)" layer)
* @param aCopperLayerCount = number of copper layers
* @param aShowDeselectOption = display a "(Deselect)" radiobutton (when set to true)
* @return new layer value (NB_LAYERS when "(Deselect)" radiobutton selected),
* or -1 if canceled
*
* Providing the option to also display a "(Deselect)" radiobutton makes the
* GerbView's "Export to Pcbnew" command) more "user friendly",
* by permitting any layer to be "deselected" immediately after its
* corresponding radiobutton has been clicked on. (It would otherwise be
* necessary to first cancel the "Select Layer:" dialog box (invoked after a
* different radiobutton is clicked on) prior to then clicking on the "Deselect"
* button provided within the "Layer selection:" dialog box).
*/
int GERBVIEW_FRAME::SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount, bool aShowDeselectOption )
{
int layer;
SELECT_LAYER_DIALOG* frame = new SELECT_LAYER_DIALOG( this, aDefaultLayer,
aCopperLayerCount,
aShowDeselectOption );
layer = frame->ShowModal();
frame->Destroy();
return layer;
}
/*
* The "OK" and "Cancel" buttons are positioned (in a horizontal line)
* beneath the "Layer" radiobox, unless that contains only one column of
* radiobuttons, in which case they are positioned (in a vertical line)
* to the right of that radiobox.
*/
SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent,
int aDefaultLayer, int aCopperLayerCount,
bool aShowDeselectOption ) :
wxDialog( parent, -1, _( "Select Layer:" ), wxPoint( -1, -1 ),
wxSize( 470, 250 ),
DIALOG_STYLE )
{
wxButton* Button;
int ii;
wxString LayerList[NB_LAYERS + 1]; // One extra element for "(Deselect)"
// radiobutton
int LayerCount, LayerSelect = -1;
m_Parent = parent;
// Build the layer list; first build copper layers list
LayerCount = 0;
for( ii = 0; ii < BOARD_COPPER_LAYERS_MAX_COUNT; ii++ )
{
m_LayerId[ii] = 0;
if( ii == 0 || ii == BOARD_COPPER_LAYERS_MAX_COUNT-1 || ii < aCopperLayerCount-1 )
{
LayerList[LayerCount] = GetPCBDefaultLayerName( ii );
if( ii == aDefaultLayer )
LayerSelect = LayerCount;
m_LayerId[LayerCount] = ii;
LayerCount++;
}
}
// Build the layer list; build copper layers list
for( ; ii < NB_LAYERS; ii++ )
{
m_LayerId[ii] = 0;
LayerList[LayerCount] = GetPCBDefaultLayerName( ii );
if( ii == aDefaultLayer )
LayerSelect = LayerCount;
m_LayerId[LayerCount] = ii;
LayerCount++;
}
// When appropriate, also provide a "(Deselect)" radiobutton
if( aShowDeselectOption )
{
LayerList[LayerCount] = _( "(Deselect)" );
if( NB_LAYERS == aDefaultLayer )
LayerSelect = LayerCount;
m_LayerId[LayerCount] = NB_LAYERS;
LayerCount++;
}
m_LayerList = new wxRadioBox( this, ID_LAYER_SELECT, _( "Layer" ),
wxPoint( -1, -1 ), wxSize( -1, -1 ),
LayerCount, LayerList,
(LayerCount < 8) ? LayerCount : 8,
wxRA_SPECIFY_ROWS );
if( LayerSelect >= 0 )
m_LayerList->SetSelection( LayerSelect );
wxBoxSizer* FrameBoxSizer = new wxBoxSizer( wxHORIZONTAL );
SetSizer( FrameBoxSizer );
FrameBoxSizer->Add( m_LayerList, 0, wxALIGN_TOP | wxALL, 5 );
wxBoxSizer* ButtonBoxSizer = new wxBoxSizer( wxVERTICAL );
FrameBoxSizer->Add( ButtonBoxSizer, 0, wxALIGN_BOTTOM | wxALL, 0 );
Button = new wxButton( this, wxID_OK, _( "OK" ) );
Button->SetDefault();
ButtonBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
ButtonBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
SetFocus();
GetSizer()->SetSizeHints( this );
Center();
}
void SELECT_LAYER_DIALOG::OnLayerSelected( wxCommandEvent& event )
{
int ii = m_LayerId[m_LayerList->GetSelection()];
EndModal( ii );
}
void SELECT_LAYER_DIALOG::OnCancelClick( wxCommandEvent& event )
{
EndModal( -1 );
}
const wxString GetPCBDefaultLayerName( int aLayerNumber )
{
const wxChar* txt;
// These are only default layer names. For Pcbnew the copper names
// may be over-ridden in the BOARD (*.brd) file.
// Use a switch to explicitly show the mapping more clearly
switch( aLayerNumber )
{
case LAYER_N_FRONT: txt = _( "Front" ); break;
case LAYER_N_2: txt = _( "Inner2" ); break;
case LAYER_N_3: txt = _( "Inner3" ); break;
case LAYER_N_4: txt = _( "Inner4" ); break;
case LAYER_N_5: txt = _( "Inner5" ); break;
case LAYER_N_6: txt = _( "Inner6" ); break;
case LAYER_N_7: txt = _( "Inner7" ); break;
case LAYER_N_8: txt = _( "Inner8" ); break;
case LAYER_N_9: txt = _( "Inner9" ); break;
case LAYER_N_10: txt = _( "Inner10" ); break;
case LAYER_N_11: txt = _( "Inner11" ); break;
case LAYER_N_12: txt = _( "Inner12" ); break;
case LAYER_N_13: txt = _( "Inner13" ); break;
case LAYER_N_14: txt = _( "Inner14" ); break;
case LAYER_N_15: txt = _( "Inner15" ); break;
case LAYER_N_BACK: txt = _( "Back" ); break;
case ADHESIVE_N_BACK: txt = _( "Adhes_Back" ); break;
case ADHESIVE_N_FRONT: txt = _( "Adhes_Front" ); break;
case SOLDERPASTE_N_BACK: txt = _( "SoldP_Back" ); break;
case SOLDERPASTE_N_FRONT: txt = _( "SoldP_Front" ); break;
case SILKSCREEN_N_BACK: txt = _( "SilkS_Back" ); break;
case SILKSCREEN_N_FRONT: txt = _( "SilkS_Front" ); break;
case SOLDERMASK_N_BACK: txt = _( "Mask_Back" ); break;
case SOLDERMASK_N_FRONT: txt = _( "Mask_Front" ); break;
case DRAW_N: txt = _( "Drawings" ); break;
case COMMENT_N: txt = _( "Comments" ); break;
case ECO1_N: txt = _( "Eco1" ); break;
case ECO2_N: txt = _( "Eco2" ); break;
case EDGE_N: txt = _( "PCB_Edges" ); break;
default: txt = _( "BAD INDEX" ); break;
}
return wxString( txt );
}
......@@ -72,9 +72,6 @@ void DIALOG_PAGE_SHOW_PAGE_BORDERS::OnCancelButtonClick( wxCommandEvent& event )
void DIALOG_PAGE_SHOW_PAGE_BORDERS::OnOKBUttonClick( wxCommandEvent& event )
{
m_Parent->m_DisplayPadFill = m_Parent->m_DisplayViaFill = DisplayOpt.DisplayViaFill;
m_Parent->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
int idx = m_ShowPageLimits->GetSelection();
m_Parent->SetShowBorderAndTitleBlock( idx > 0 ? true : false );
......
......@@ -69,16 +69,16 @@ void DIALOG_DISPLAY_OPTIONS::OnCancelButtonClick( wxCommandEvent& event )
void DIALOG_DISPLAY_OPTIONS::initOptDialog( )
{
m_PolarDisplay->SetSelection( DisplayOpt.DisplayPolarCood ? 1 : 0 );
m_PolarDisplay->SetSelection( m_Parent->m_DisplayOptions.m_DisplayPolarCood ? 1 : 0 );
m_BoxUnits->SetSelection( g_UserUnit ? 1 : 0 );
m_CursorShape->SetSelection( m_Parent->GetCursorShape() ? 1 : 0 );
// Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option
m_OptDisplayLines->SetSelection( DisplayOpt.DisplayPcbTrackFill ? 1 : 0 );
m_OptDisplayFlashedItems->SetSelection( DisplayOpt.DisplayPadFill ? 1 : 0);
m_OptDisplayLines->SetSelection( m_Parent->m_DisplayOptions.m_DisplayLinesFill ? 1 : 0 );
m_OptDisplayFlashedItems->SetSelection( m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill ? 1 : 0);
// Show Option Draw polygons
m_OptDisplayPolygons->SetSelection( g_DisplayPolygonsModeSketch ? 0 : 1 );
m_OptDisplayPolygons->SetSelection( m_Parent->m_DisplayOptions.m_DisplayPolygonsFill ? 1 : 0 );
m_ShowPageLimits->SetSelection(0);
......@@ -106,38 +106,33 @@ void DIALOG_DISPLAY_OPTIONS::initOptDialog( )
void DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick( wxCommandEvent& event )
{
DisplayOpt.DisplayPolarCood =
m_Parent->m_DisplayOptions.m_DisplayPolarCood =
(m_PolarDisplay->GetSelection() == 0) ? false : true;
g_UserUnit = (m_BoxUnits->GetSelection() == 0) ? INCHES : MILLIMETRES;
m_Parent->SetCursorShape( m_CursorShape->GetSelection() );
if( m_OptDisplayLines->GetSelection() == 1 )
DisplayOpt.DisplayPcbTrackFill = true;
m_Parent->m_DisplayOptions.m_DisplayLinesFill = true;
else
DisplayOpt.DisplayPcbTrackFill = false;
m_Parent->m_DisplayOptions.m_DisplayLinesFill = false;
if( m_OptDisplayFlashedItems->GetSelection() == 1 )
{
DisplayOpt.DisplayPadFill = true;
DisplayOpt.DisplayViaFill = true;
m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill = true;
}
else
{
DisplayOpt.DisplayViaFill = false;
DisplayOpt.DisplayPadFill = false;
m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill = false;
}
if( m_OptDisplayPolygons->GetSelection() == 0 )
g_DisplayPolygonsModeSketch = 1;
m_Parent->m_DisplayOptions.m_DisplayPolygonsFill = false;
else
g_DisplayPolygonsModeSketch = 0;
m_Parent->m_DisplayOptions.m_DisplayPolygonsFill = true;
m_Parent->SetElementVisibility( DCODES_VISIBLE, m_OptDisplayDCodes->GetValue() );
m_Parent->m_DisplayPadFill = m_Parent->m_DisplayViaFill = DisplayOpt.DisplayViaFill;
m_Parent->m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
int idx = m_ShowPageLimits->GetSelection();
m_Parent->SetShowBorderAndTitleBlock( idx > 0 ? true : false );
......
......@@ -36,7 +36,6 @@
#include <base_units.h>
#include <gerbview.h>
#include <class_board_design_settings.h>
#include <colors_selection.h>
#include <class_gerber_draw_item.h>
#include <class_GERBER.h>
......@@ -46,35 +45,34 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, int aPrintMasklayer,
bool aPrintMirrorMode, void* aData )
{
// Save current draw options, because print mode has specific options:
int DisplayPolygonsModeImg = g_DisplayPolygonsModeSketch;
int visiblemask = GetBoard()->GetVisibleLayers();
DISPLAY_OPTIONS save_opt = DisplayOpt;
int visiblemask = GetVisibleLayers();
GBR_DISPLAY_OPTIONS imgDisplayOptions = m_DisplayOptions;
// Set draw options for printing:
GetBoard()->SetVisibleLayers( aPrintMasklayer );
DisplayOpt.DisplayPcbTrackFill = FILLED;
DisplayOpt.DisplayDrawItems = FILLED;
DisplayOpt.DisplayZonesMode = 0;
g_DisplayPolygonsModeSketch = 0;
SetVisibleLayers( aPrintMasklayer );
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;
m_canvas->SetPrintMirrored( aPrintMirrorMode );
GetBoard()->Draw( m_canvas, aDC, -1, wxPoint( 0, 0 ) );
GetLayout()->Draw( m_canvas, aDC, -1, wxPoint( 0, 0 ) );
m_canvas->SetPrintMirrored( false );
// Restore draw options:
GetBoard()->SetVisibleLayers( visiblemask );
DisplayOpt = save_opt;
g_DisplayPolygonsModeSketch = DisplayPolygonsModeImg;
SetVisibleLayers( visiblemask );
m_DisplayOptions = imgDisplayOptions;
}
void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
PCB_SCREEN* screen = (PCB_SCREEN*) GetScreen();
GBR_SCREEN* screen = (GBR_SCREEN*) GetScreen();
if( !GetBoard() )
if( !GetLayout() )
return;
wxBusyCursor dummy;
......@@ -97,7 +95,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
}
// Draw according to the current setting. This needs to be GR_COPY or GR_OR.
GetBoard()->Draw( m_canvas, DC, drawMode, wxPoint( 0, 0 ) );
GetLayout()->Draw( m_canvas, DC, drawMode, wxPoint( 0, 0 ) );
// 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
......@@ -123,7 +121,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/*
* Redraw All GerbView layers, using a buffered mode or not
*/
void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoint& aOffset )
void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoint& aOffset )
{
// 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
......@@ -202,7 +200,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
layer = active_layer;
}
if( !GetBoard()->IsLayerVisible( layer ) )
if( !gerbFrame->IsLayerVisible( layer ) )
continue;
GERBER_IMAGE* gerber = g_GERBER_List[layer];
......@@ -259,7 +257,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
if( gerber->m_ImageNegative )
{
// Draw background negative (i.e. in graphic layer color) for negative images.
int color = GetBoard()->GetLayerColor( layer );
int color = gerbFrame->GetLayerColor( layer );
GRSetDrawMode( &layerDC, GR_COPY );
GRFilledRect( &drawBox, plotDC, drawBox.GetX(), drawBox.GetY(),
......@@ -282,19 +280,17 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoin
// Now we can draw the current layer to the bitmap buffer
// When needed, the previous bitmap is already copied to the screen buffer.
for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = item->Next() )
for( GERBER_DRAW_ITEM* item = gerbFrame->GetItemsList(); item; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
if( gerb_item->GetLayer() != layer )
if( item->GetLayer() != layer )
continue;
int drawMode = layerdrawMode;
if( dcode_highlight && dcode_highlight == gerb_item->m_DCode )
if( dcode_highlight && dcode_highlight == item->m_DCode )
drawMode |= GR_HIGHLIGHT;
gerb_item->Draw( aPanel, plotDC, drawMode );
item->Draw( aPanel, plotDC, drawMode, wxPoint(0,0) );
doBlit = true;
}
}
......@@ -355,47 +351,44 @@ void GERBVIEW_FRAME::DrawItemsDCodeID( wxDC* aDC, int aDrawMode )
wxString Line;
GRSetDrawMode( aDC, aDrawMode );
BOARD_ITEM* item = GetBoard()->m_Drawings;
for( ; item != NULL; item = item->Next() )
for( GERBER_DRAW_ITEM* item = GetItemsList(); item != NULL; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
if( GetBoard()->IsLayerVisible( gerb_item->GetLayer() ) == false )
if( IsLayerVisible( item->GetLayer() ) == false )
continue;
if( gerb_item->m_DCode <= 0 )
if( item->m_DCode <= 0 )
continue;
if( gerb_item->m_Flashed || gerb_item->m_Shape == GBR_ARC )
if( item->m_Flashed || item->m_Shape == GBR_ARC )
{
pos = gerb_item->m_Start;
pos = item->m_Start;
}
else
{
pos.x = (gerb_item->m_Start.x + gerb_item->m_End.x) / 2;
pos.y = (gerb_item->m_Start.y + gerb_item->m_End.y) / 2;
pos.x = (item->m_Start.x + item->m_End.x) / 2;
pos.y = (item->m_Start.y + item->m_End.y) / 2;
}
pos = gerb_item->GetABPosition( pos );
pos = item->GetABPosition( pos );
Line.Printf( wxT( "D%d" ), gerb_item->m_DCode );
Line.Printf( wxT( "D%d" ), item->m_DCode );
if( gerb_item->GetDcodeDescr() )
width = gerb_item->GetDcodeDescr()->GetShapeDim( gerb_item );
if( item->GetDcodeDescr() )
width = item->GetDcodeDescr()->GetShapeDim( item );
else
width = min( gerb_item->m_Size.x, gerb_item->m_Size.y );
width = std::min( item->m_Size.x, item->m_Size.y );
orient = TEXT_ORIENT_HORIZ;
if( gerb_item->m_Flashed )
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 = gerb_item->m_Start - gerb_item->m_End;
wxPoint delta = item->m_Start - item->m_End;
if( abs( delta.x ) < abs( delta.y ) )
orient = TEXT_ORIENT_VERT;
......@@ -405,7 +398,7 @@ void GERBVIEW_FRAME::DrawItemsDCodeID( wxDC* aDC, int aDrawMode )
width /= 2;
}
int color = g_ColorsSettings.GetItemColor( DCODES_VISIBLE );
int color = GetVisibleElementColor( DCODES_VISIBLE );
DrawGraphicText( m_canvas, aDC, pos, (EDA_COLOR_T) color, Line,
orient, wxSize( width, width ),
......@@ -413,32 +406,3 @@ void GERBVIEW_FRAME::DrawItemsDCodeID( wxDC* aDC, int aDrawMode )
0, false, false );
}
}
/* Virtual function needed by the PCB_SCREEN class derived from BASE_SCREEN
* this is a virtual pure function in BASE_SCREEN
* do nothing in GerbView
* could be removed later
*/
void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER&, int )
{
}
/* dummy_functions
*
* These functions are used in some classes.
* they are useful in Pcbnew, but have no meaning or are never used
* in CvPcb or GerbView.
* but they must exist because they appear in some classes, and here, no nothing.
*/
TRACK* MarkTrace( BOARD* aPcb,
TRACK* aStartSegm,
int* aSegmCount,
int* aTrackLen,
int* aLenDie,
bool aReorder )
{
return NULL;
}
......@@ -22,7 +22,7 @@
// Event table:
BEGIN_EVENT_TABLE( GERBVIEW_FRAME, PCB_BASE_FRAME )
BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
EVT_CLOSE( GERBVIEW_FRAME::OnCloseWindow )
EVT_SIZE( GERBVIEW_FRAME::OnSize )
......@@ -85,6 +85,7 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, PCB_BASE_FRAME )
GERBVIEW_FRAME::Process_Special_Functions )
// Option toolbar
EVT_TOOL( ID_TB_OPTIONS_SHOW_POLAR_COORD, GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_LINES_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar )
......@@ -94,6 +95,7 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, PCB_BASE_FRAME )
EVT_TOOL_RANGE( ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2,
GERBVIEW_FRAME::OnSelectDisplayMode )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_POLAR_COORD, GERBVIEW_FRAME::OnUpdateCoordType )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH,
GERBVIEW_FRAME::OnUpdateFlashedItemsDrawMode )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_LINES_SKETCH, GERBVIEW_FRAME::OnUpdateLinesDrawMode )
......@@ -310,3 +312,66 @@ void GERBVIEW_FRAME::SetLanguage( wxCommandEvent& event )
ReFillLayerWidget();
}
/**
* Function OnSelectOptionToolbar
* called to validate current choices
*/
void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{
int id = event.GetId();
bool state;
switch( id )
{
case ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG:
state = ! m_show_layer_manager_tools;
id = ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR;
break;
default:
state = m_optionsToolBar->GetToolToggled( id );
break;
}
switch( id )
{
case ID_TB_OPTIONS_SHOW_POLAR_COORD:
m_DisplayOptions.m_DisplayPolarCood = state;
break;
case ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH:
m_DisplayOptions.m_DisplayFlashedItemsFill = not state;
m_canvas->Refresh( true );
break;
case ID_TB_OPTIONS_SHOW_LINES_SKETCH:
m_DisplayOptions.m_DisplayLinesFill = not state;
m_canvas->Refresh( true );
break;
case ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH:
m_DisplayOptions.m_DisplayPolygonsFill = not state;
m_canvas->Refresh( true );
break;
case ID_TB_OPTIONS_SHOW_DCODES:
SetElementVisibility( DCODES_VISIBLE, state );
m_canvas->Refresh( true );
break;
case ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR:
// show/hide auxiliary Vertical layers and visibility manager toolbar
m_show_layer_manager_tools = state;
m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
m_auimgr.Update();
GetMenuBar()->SetLabel( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
m_show_layer_manager_tools ?
_("Hide &Layers Manager" ) : _("Show &Layers Manager" ));
break;
default:
wxMessageBox( wxT( "GERBVIEW_FRAME::OnSelectOptionToolbar error" ) );
break;
}
}
......@@ -475,8 +475,8 @@ bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text )
ReportMessage( msg );
return false;
}
gbritem = new GERBER_DRAW_ITEM( GetParent()->GetBoard(), this );
GetParent()->GetBoard()->m_Drawings.Append( gbritem );
gbritem = new GERBER_DRAW_ITEM( GetParent()->GetLayout(), this );
GetParent()->GetLayout()->m_Drawings.Append( gbritem );
if( m_SlotOn ) // Oval hole
{
fillLineGBRITEM( gbritem,
......
This diff is collapsed.
......@@ -31,14 +31,10 @@
#include <class_drawpanel.h>
#include <confirm.h>
#include <gestfich.h>
#include <gr_basic.h>
//#include <gr_basic.h>
#include <gerbview.h>
#include <gerbview_id.h>
#include <pcbplot.h>
#include <zones.h>
#include <class_board_design_settings.h>
#include <colors_selection.h>
#include <hotkeys.h>
#include <build_version.h>
......@@ -48,9 +44,8 @@
// Colors for layers and items
COLORS_DESIGN_SETTINGS g_ColorsSettings;
int g_Default_GERBER_Format;
int g_DisplayPolygonsModeSketch;
extern int g_DrawBgColor;
int g_Default_GERBER_Format;
const wxChar* g_GerberPageSizeList[] = {
......@@ -114,12 +109,6 @@ bool EDA_APP::OnInit()
/* Gerbview mainframe title */
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() );
// Initialize some display options
DisplayOpt.DisplayPadIsol = false; // Pad clearance has no meaning here
// Track and via clearance has no meaning here.
DisplayOpt.ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE;
SetTopWindow( frame ); // Set GerbView mainframe on top
frame->Show( true ); // Show GerbView mainframe
frame->Zoom_Automatique( true ); // Zoom fit in frame
......@@ -139,7 +128,7 @@ bool EDA_APP::OnInit()
// Load all files specified on the command line.
int jj = 0;
for( int ii = 1; ii < argc && ii <= LAYER_COUNT; ++ii )
for( int ii = 1; ii < argc && ii <= GERBVIEW_LAYER_COUNT; ++ii )
{
fn = wxFileName( argv[ii] );
......
......@@ -16,10 +16,15 @@
#define CURSEUR_OFF_GRILLE 1
class GERBVIEW_FRAME;
//class BOARD;
class GERBER_IMAGE;
class PAGE_INFO;
/**
* size of single line of a text from a gerber file.
* warning: some files can have very long lines, so the buffer must be large.
*/
#define GERBER_BUFZ 4000
#define GERBVIEW_LAYER_COUNT 32 // Number of different layers shown by GerbView
/// List of page sizes
extern const wxChar* g_GerberPageSizeList[8];
......@@ -29,14 +34,14 @@ extern const wxChar* g_GerberPageSizeList[8];
#define GERB_STOP_DRAW 2 // Extinguish light (lift pen)
#define GERB_FLASH 3 // Flash
/*
enum PlotFormat
{
FORMAT_HPGL,
FORMAT_GERBER,
FORMAT_POST
};
*/
/**
* Enum ITEM_VISIBLE
......@@ -49,14 +54,6 @@ enum GERBER_VISIBLE
END_GERBER_VISIBLE_LIST // sentinel
};
/**
* size of single line of a text from a gerber file.
* warning: some files can have very long lines, so the buffer must be large.
*/
#define GERBER_BUFZ 4000
extern int g_DisplayPolygonsModeSketch;
extern const wxString GerbviewProjectFileExt;
extern const wxString GerbviewProjectFileWildcard;
......@@ -110,7 +107,6 @@ enum Gerb_Analyse_Cmd
bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file );
extern GERBER_IMAGE* g_GERBER_List[32];
#include <pcbcommon.h>
#include <gerbview_frame.h>
#endif // ifndef GERBVIEW_H
......@@ -34,13 +34,11 @@
#include <common.h>
#include <class_drawpanel.h>
#include <gestfich.h>
#include <pcbcommon.h>
#include <param_config.h>
#include <colors_selection.h>
#include <gerbview.h>
#include <hotkeys.h>
#include <class_board_design_settings.h>
#include <dialog_hotkeys_editor.h>
......@@ -100,7 +98,7 @@ PARAM_CFG_ARRAY& GERBVIEW_FRAME::GetConfigurationSettings()
m_configSettings.push_back( new PARAM_CFG_BOOL( true,
wxT( "DisplayPolarCoordinates" ),
&DisplayOpt.DisplayPolarCood,
&m_DisplayOptions.m_DisplayPolarCood,
false ) );
// Default colors for layers 0 to 31
......
This diff is collapsed.
This diff is collapsed.
......@@ -136,8 +136,7 @@ void GERBVIEW_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
break;
case HK_SWITCH_GBR_ITEMS_DISPLAY_MODE:
DisplayOpt.DisplayPcbTrackFill ^= 1;
DisplayOpt.DisplayPcbTrackFill &= 1;
m_DisplayOptions.m_DisplayLinesFill = not m_DisplayOptions.m_DisplayLinesFill;
m_canvas->Refresh();
break;
......
......@@ -35,13 +35,13 @@
#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_Pcb( bool query )
{
int layer;
if( GetBoard() == NULL )
if( GetLayout() == NULL )
return false;
if( query && GetScreen()->IsModify() )
......@@ -50,10 +50,9 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query )
return false;
}
SetCurItem( NULL );
GetBoard()->m_Drawings.DeleteAll();
GetLayout()->m_Drawings.DeleteAll();
for( layer = 0; layer < LAYER_COUNT; layer++ )
for( layer = 0; layer < GERBVIEW_LAYER_COUNT; layer++ )
{
if( g_GERBER_List[layer] )
{
......@@ -62,15 +61,11 @@ bool GERBVIEW_FRAME::Clear_Pcb( bool query )
}
}
GetBoard()->SetBoundingBox( EDA_RECT() );
GetBoard()->m_Status_Pcb = 0;
GetBoard()->m_NbNodes = 0;
GetBoard()->m_NbNoconnect = 0;
GetLayout()->SetBoundingBox( EDA_RECT() );
SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) );
setActiveLayer(FIRST_COPPER_LAYER);
setActiveLayer(0);
m_LayersManager->UpdateLayerIcons();
syncLayerBox();
return true;
......@@ -89,18 +84,17 @@ void GERBVIEW_FRAME::Erase_Current_Layer( bool query )
SetCurItem( NULL );
BOARD_ITEM* item = GetBoard()->m_Drawings;
BOARD_ITEM * next;
GERBER_DRAW_ITEM* item = GetLayout()->m_Drawings;
GERBER_DRAW_ITEM * next;
for( ; item; item = next )
{
next = item->Next();
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
if( gerb_item->GetLayer() != layer )
if( item->GetLayer() != layer )
continue;
gerb_item->DeleteStructure();
item->DeleteStructure();
}
if( g_GERBER_List[layer] )
......
......@@ -46,13 +46,10 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc
int layer = getActiveLayer();
// Search first on active layer
BOARD_ITEM* item = GetBoard()->m_Drawings;
GERBER_DRAW_ITEM* gerb_item = NULL;
GERBER_DRAW_ITEM* gerb_item = GetItemsList();
for( ; item; item = item->Next() )
for( ; gerb_item; gerb_item = gerb_item->Next() )
{
gerb_item = (GERBER_DRAW_ITEM*) item;
if( gerb_item->GetLayer()!= layer )
continue;
......@@ -65,12 +62,8 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc
if( !found ) // Search on all layers
{
item = GetBoard()->m_Drawings;
for( ; item; item = item->Next() )
for( gerb_item = GetItemsList(); gerb_item; gerb_item = gerb_item->Next() )
{
gerb_item = (GERBER_DRAW_ITEM*) item;
if( gerb_item->HitTest( ref ) )
{
found = true;
......
......@@ -21,7 +21,7 @@
*/
void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
{
EDA_ITEM* DrawStruct = GetScreen()->GetCurItem();
GERBER_DRAW_ITEM* DrawStruct = (GERBER_DRAW_ITEM*) GetScreen()->GetCurItem();
wxString msg;
if( GetToolId() == ID_NO_TOOL_SELECTED )
......@@ -36,7 +36,7 @@ void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
else
{
DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE );
GetScreen()->SetCurItem( (BOARD_ITEM*)DrawStruct );
GetScreen()->SetCurItem( DrawStruct );
if( DrawStruct == NULL )
{
GERBER_IMAGE* gerber = g_GERBER_List[getActiveLayer() ];
......
......@@ -16,7 +16,7 @@
*/
bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
{
EDA_ITEM* DrawStruct = GetScreen()->GetCurItem();
GERBER_DRAW_ITEM* DrawStruct = (GERBER_DRAW_ITEM*) GetScreen()->GetCurItem();
wxString msg;
bool BlockActive = !GetScreen()->m_BlockLocate.IsIdle();
bool busy = DrawStruct && DrawStruct->GetFlags();
......@@ -71,7 +71,7 @@ bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
return true;
if( DrawStruct )
GetScreen()->SetCurItem( (BOARD_ITEM*)DrawStruct );
GetScreen()->SetCurItem( DrawStruct );
return true;
}
......@@ -35,31 +35,17 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
switch( id )
{
case ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH:
if( state )
DisplayOpt.DisplayPadFill = false;
else
DisplayOpt.DisplayPadFill = true;
m_DisplayPadFill = DisplayOpt.DisplayPadFill;
m_DisplayOptions.m_DisplayFlashedItemsFill = not state;
m_canvas->Refresh( true );
break;
case ID_TB_OPTIONS_SHOW_LINES_SKETCH:
if(state )
DisplayOpt.DisplayPcbTrackFill = false;
else
DisplayOpt.DisplayPcbTrackFill = true;
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
m_DisplayOptions.m_DisplayLinesFill = not state;
m_canvas->Refresh( true );
break;
case ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH:
if( state ) // Polygons filled asked
g_DisplayPolygonsModeSketch = 1;
else
g_DisplayPolygonsModeSketch = 0;
m_DisplayOptions.m_DisplayPolygonsFill = not state;
m_canvas->Refresh( true );
break;
......@@ -79,7 +65,7 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
break;
default:
wxMessageBox( wxT( "WinEDA_PcbFrame::OnSelectOptionToolbar error" ) );
wxMessageBox( wxT( "GERBVIEW_FRAME::OnSelectOptionToolbar error" ) );
break;
}
}
......
......@@ -303,7 +303,6 @@ static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, int aL
* <li> absolute angle 180 to 270 (quadrant 3) or
* <li> absolute angle 270 to 0 (quadrant 4)
* </ul><p>
* @param aPcb is the board.
* @param aGbrItem is the GBRITEM to fill in.
* @param aStart is the starting point
* @param aEnd is the ending point
......@@ -316,7 +315,7 @@ static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, int aL
* false when arc is inside one quadrant
* @param aLayerNegative = true if the current layer is negative
*/
static void fillArcPOLY( BOARD* aPcb, GERBER_DRAW_ITEM* aGbrItem,
static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem,
const wxPoint& aStart, const wxPoint& aEnd,
const wxPoint& rel_center,
bool aClockwise, bool aMultiquadrant,
......@@ -517,10 +516,9 @@ bool GERBER_IMAGE::Execute_G_Command( char*& text, int G_command )
break;
case GC_TURN_OFF_POLY_FILL:
if( m_Exposure && m_Parent->GetBoard()->m_Drawings ) // End of polygon
if( m_Exposure && m_Parent->GetLayout()->m_Drawings ) // End of polygon
{
GERBER_DRAW_ITEM * gbritem =
(GERBER_DRAW_ITEM*)( m_Parent->GetBoard()->m_Drawings.GetLast() );
GERBER_DRAW_ITEM * gbritem = m_Parent->GetLayout()->m_Drawings.GetLast();
StepAndRepeatItem( *gbritem );
}
m_Exposure = false;
......@@ -549,7 +547,7 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
APERTURE_T aperture = APT_CIRCLE;
GERBER_DRAW_ITEM* gbritem;
BOARD* pcb = m_Parent->GetBoard();
GBR_LAYOUT* layout = m_Parent->GetLayout();
int activeLayer = m_Parent->getActiveLayer();
......@@ -587,8 +585,8 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
if( !m_Exposure )
{
m_Exposure = true;
gbritem = new GERBER_DRAW_ITEM( pcb, this );
pcb->m_Drawings.Append( gbritem );
gbritem = new GERBER_DRAW_ITEM( layout, this );
layout->m_Drawings.Append( gbritem );
gbritem->m_Shape = GBR_POLYGON;
gbritem->SetLayer( activeLayer );
gbritem->m_Flashed = false;
......@@ -598,20 +596,20 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
{
case GERB_INTERPOL_ARC_NEG:
case GERB_INTERPOL_ARC_POS:
gbritem = (GERBER_DRAW_ITEM*)( pcb->m_Drawings.GetLast() );
gbritem = layout->m_Drawings.GetLast();
// D( printf( "Add arc poly %d,%d to %d,%d fill %d interpol %d 360_enb %d\n",
// m_PreviousPos.x, m_PreviousPos.y, m_CurrentPos.x,
// m_CurrentPos.y, m_PolygonFillModeState,
// m_Iterpolation, m_360Arc_enbl ); )
fillArcPOLY( pcb, gbritem, m_PreviousPos,
fillArcPOLY( gbritem, m_PreviousPos,
m_CurrentPos, m_IJPos,
( m_Iterpolation == GERB_INTERPOL_ARC_NEG ) ? false : true,
m_360Arc_enbl, GetLayerParams().m_LayerNegative );
break;
default:
gbritem = (GERBER_DRAW_ITEM*)( pcb->m_Drawings.GetLast() );
gbritem = layout->m_Drawings.GetLast();
// D( printf( "Add poly edge %d,%d to %d,%d fill %d\n",
// m_PreviousPos.x, m_PreviousPos.y,
......@@ -631,9 +629,9 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
break;
case 2: // code D2: exposure OFF (i.e. "move to")
if( m_Exposure && pcb->m_Drawings ) // End of polygon
if( m_Exposure && layout->m_Drawings ) // End of polygon
{
gbritem = (GERBER_DRAW_ITEM*)( pcb->m_Drawings.GetLast() );
gbritem = layout->m_Drawings.GetLast();
StepAndRepeatItem( *gbritem );
}
m_Exposure = false;
......@@ -663,8 +661,8 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
switch( m_Iterpolation )
{
case GERB_INTERPOL_LINEAR_1X:
gbritem = new GERBER_DRAW_ITEM( pcb, this );
pcb->m_Drawings.Append( gbritem );
gbritem = new GERBER_DRAW_ITEM( layout, this );
layout->m_Drawings.Append( gbritem );
// D( printf( "Add line %d,%d to %d,%d\n",
// m_PreviousPos.x, m_PreviousPos.y,
......@@ -682,8 +680,8 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
case GERB_INTERPOL_ARC_NEG:
case GERB_INTERPOL_ARC_POS:
gbritem = new GERBER_DRAW_ITEM( pcb, this );
pcb->m_Drawings.Append( gbritem );
gbritem = new GERBER_DRAW_ITEM( layout, this );
layout->m_Drawings.Append( gbritem );
// D( printf( "Add arc %d,%d to %d,%d center %d, %d interpol %d 360_enb %d\n",
// m_PreviousPos.x, m_PreviousPos.y, m_CurrentPos.x,
......@@ -720,8 +718,8 @@ bool GERBER_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
aperture = tool->m_Shape;
}
gbritem = new GERBER_DRAW_ITEM( pcb, this );
pcb->m_Drawings.Append( gbritem );
gbritem = new GERBER_DRAW_ITEM( layout, this );
layout->m_Drawings.Append( gbritem );
fillFlashedGBRITEM( gbritem, aperture,
dcode, activeLayer, m_CurrentPos,
size, GetLayerParams().m_LayerNegative );
......
/*******************************************************/
/* Dialog frame to choose gerber layers and pcb layers */
/*******************************************************/
/**
* @file select_layers_to_pcb.cpp
* @brief Dialog to choose equivalence between gerber layers and pcb layers
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2010 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
*/
#include <fctsys.h>
#include <common.h>
#include <appl_wxstruct.h>
#include <gerbview.h>
#include <gerbview_id.h>
#include <class_board_design_settings.h>
#include <class_GERBER.h>
#include <wx/statline.h>
#include <select_layers_to_pcb.h>
#define LAYER_UNSELECTED NB_LAYERS
// Imported function
extern const wxString GetPCBDefaultLayerName( int aLayerNumber );
enum swap_layer_id {
ID_LAYERS_MAP_DIALOG = ID_GERBER_END_LIST,
ID_BUTTON_0,
ID_TEXT_0 = ID_BUTTON_0 + 32
ID_TEXT_0 = ID_BUTTON_0 + GERBVIEW_LAYER_COUNT
};
/*
......@@ -32,11 +50,12 @@ enum swap_layer_id {
*/
BEGIN_EVENT_TABLE( LAYERS_MAP_DIALOG, LAYERS_MAP_DIALOG_BASE )
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + 31,
EVT_COMMAND_RANGE( ID_BUTTON_0, ID_BUTTON_0 + GERBVIEW_LAYER_COUNT-1,
wxEVT_COMMAND_BUTTON_CLICKED,
LAYERS_MAP_DIALOG::OnSelectLayer )
END_EVENT_TABLE()
int LAYERS_MAP_DIALOG::m_exportBoardCopperLayersCount = 2;
LAYERS_MAP_DIALOG::LAYERS_MAP_DIALOG( GERBVIEW_FRAME* parent ) :
LAYERS_MAP_DIALOG_BASE( parent )
......@@ -80,22 +99,17 @@ void LAYERS_MAP_DIALOG::initDialog()
// the above code should be modified as required in the event that those
// buttons should be some other size in that version.
// Compute a reasonable number of copper layers
m_exportBoardCopperLayersCount = 0;
for( int ii = 0; ii < 32; ii++ )
for( int ii = 0; ii < GERBVIEW_LAYER_COUNT; ii++ )
{
if( g_GERBER_List[ii] != NULL )
m_exportBoardCopperLayersCount++;
// Specify the default value for each member of these arrays.
m_buttonTable[ii] = -1;
m_layersLookUpTable[ii] = LAYER_UNSELECTED;
}
// Ensure we have:
// at least 2 copper layers and NB_COPPER_LAYERS copper layers max
// at least 2 copper layers and BOARD_COPPER_LAYERS_MAX_COUNT copper layers max
// and even layers count because a board *must* have even layers count
// and maxi NB_COPPER_LAYERS copper layers count
// and maxi BOARD_COPPER_LAYERS_MAX_COUNT copper layers count
normalizeBrdLayersCount();
int idx = ( m_exportBoardCopperLayersCount / 2 ) - 1;
......@@ -103,7 +117,7 @@ void LAYERS_MAP_DIALOG::initDialog()
int pcb_layer_num = 0;
m_itemsCount = 0;
for( int ii = 0; ii < 32; ii++ )
for( int ii = 0; ii < GERBVIEW_LAYER_COUNT; ii++ )
{
if( g_GERBER_List[ii] == NULL )
continue;
......@@ -118,7 +132,7 @@ void LAYERS_MAP_DIALOG::initDialog()
pcb_layer_num++;
}
if( m_itemsCount <= 16 ) // Only one list is enough
if( m_itemsCount <= GERBVIEW_LAYER_COUNT/2 ) // Only one list is enough
{
m_staticlineSep->Hide();
}
......@@ -160,7 +174,7 @@ void LAYERS_MAP_DIALOG::initDialog()
// is nb_items; otherwise, the number of rows is 16 (with two
// separate columns of controls being used if nb_items > 16).
if( ii == 16 )
if( ii == GERBVIEW_LAYER_COUNT/2 )
flexColumnBoxSizer = m_flexRightColumnBoxSizer;
// Provide a text string to identify the Gerber layer
......@@ -208,19 +222,19 @@ void LAYERS_MAP_DIALOG::initDialog()
wxDefaultSize, 0 );
goodSize = text->GetSize();
for( int jj = 0; jj < NB_LAYERS; jj++ )
for( int jj = 0; jj < BOARD_LAYERS_MAX_COUNT; jj++ )
{
text->SetLabel( BOARD::GetDefaultLayerName( jj ) );
text->SetLabel( GetPCBDefaultLayerName( jj ) );
if( goodSize.x < text->GetSize().x )
goodSize.x = text->GetSize().x;
}
msg = BOARD::GetDefaultLayerName( m_layersLookUpTable[m_buttonTable[ii]] );
msg = GetPCBDefaultLayerName( m_layersLookUpTable[m_buttonTable[ii]] );
text->SetLabel( msg );
}
else
{
msg = BOARD::GetDefaultLayerName( m_layersLookUpTable[m_buttonTable[ii]] );
msg = GetPCBDefaultLayerName( m_layersLookUpTable[m_buttonTable[ii]] );
text = new wxStaticText( this, item_ID, msg, wxDefaultPosition,
wxDefaultSize, 0 );
}
......@@ -233,7 +247,7 @@ void LAYERS_MAP_DIALOG::initDialog()
}
}
/* Ensure m_exportBoardCopperLayersCount = 2 to NB_COPPER_LAYERS
/* Ensure m_exportBoardCopperLayersCount = 2 to BOARD_COPPER_LAYERS_MAX_COUNT
* and it is an even value because Boards have always an even layer count
*/
void LAYERS_MAP_DIALOG::normalizeBrdLayersCount()
......@@ -241,8 +255,8 @@ void LAYERS_MAP_DIALOG::normalizeBrdLayersCount()
if( ( m_exportBoardCopperLayersCount & 1 ) )
m_exportBoardCopperLayersCount++;
if( m_exportBoardCopperLayersCount > NB_COPPER_LAYERS )
m_exportBoardCopperLayersCount = NB_COPPER_LAYERS;
if( m_exportBoardCopperLayersCount > BOARD_COPPER_LAYERS_MAX_COUNT )
m_exportBoardCopperLayersCount = BOARD_COPPER_LAYERS_MAX_COUNT;
if( m_exportBoardCopperLayersCount < 2 )
m_exportBoardCopperLayersCount = 2;
......@@ -271,7 +285,7 @@ void LAYERS_MAP_DIALOG::OnResetClick( wxCommandEvent& event )
&& (m_exportBoardCopperLayersCount > 1) )
layer = LAYER_N_FRONT;
m_layersLookUpTable[ii] = layer;
msg = BOARD::GetDefaultLayerName( layer );
msg = GetPCBDefaultLayerName( layer );
m_layersList[ii]->SetLabel( msg );
m_layersList[ii]->SetForegroundColour( wxNullColour );
m_buttonTable[ii] = ii;
......@@ -284,10 +298,10 @@ void LAYERS_MAP_DIALOG::OnResetClick( wxCommandEvent& event )
void LAYERS_MAP_DIALOG::OnStoreSetup( wxCommandEvent& event )
{
wxConfig* config = wxGetApp().GetSettings();
config->Write( wxT("BrdLayersCount"), m_itemsCount );
config->Write( wxT("BrdLayersCount"), m_exportBoardCopperLayersCount );
wxString key;
for( int ii = 0; ii < 32; ii++ )
for( int ii = 0; ii < GERBVIEW_LAYER_COUNT; ii++ )
{
key.Printf( wxT("GbrLyr%dToPcb"), ii );
config->Write( key, m_layersLookUpTable[ii] );
......@@ -305,7 +319,7 @@ void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
m_comboCopperLayersCount->SetSelection( idx );
wxString key;
for( int ii = 0; ii < 32; ii++ )
for( int ii = 0; ii < GERBVIEW_LAYER_COUNT; ii++ )
{
key.Printf( wxT("GbrLyr%dToPcb"), ii );
config->Read( key, &m_layersLookUpTable[ii] );
......@@ -321,7 +335,7 @@ void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event )
}
else
{
m_layersList[ii]->SetLabel( BOARD::GetDefaultLayerName( layer ) );
m_layersList[ii]->SetLabel( GetPCBDefaultLayerName( layer ) );
m_layersList[ii]->SetForegroundColour( wxColour( 255, 0, 128 ) );
}
}
......@@ -331,18 +345,19 @@ void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event )
{
int ii, jj;
ii = event.GetId();
ii = event.GetId() - ID_BUTTON_0;
if( ii < ID_BUTTON_0 || ii >= ID_BUTTON_0 + 32 )
if( (ii < 0) || (ii >= GERBVIEW_LAYER_COUNT) )
{
wxFAIL_MSG( wxT("Bad layer id") );
return;
ii = event.GetId() - ID_BUTTON_0;
}
jj = m_layersLookUpTable[m_buttonTable[ii]];
if( ( jj < 0 ) || ( jj > LAYER_UNSELECTED ) )
jj = LAYER_N_BACK; // (Defaults to "Copper" layer.)
jj = m_Parent->SelectLayer( jj, -1, -1, true );
jj = m_Parent->SelectPCBLayer( jj, m_exportBoardCopperLayersCount, true );
if( ( jj < 0 ) || ( jj > LAYER_UNSELECTED ) )
return;
......@@ -360,7 +375,7 @@ void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event )
}
else
{
m_layersList[ii]->SetLabel( BOARD::GetDefaultLayerName( jj ) );
m_layersList[ii]->SetLabel( GetPCBDefaultLayerName( jj ) );
// Change the text color to fuchsia (to highlight
// that this layer *is* being exported)
......@@ -384,7 +399,7 @@ void LAYERS_MAP_DIALOG::OnOkClick( wxCommandEvent& event )
normalizeBrdLayersCount();
int inner_layer_max = 0;
for( int ii = 0; ii < 32; ii++ )
for( int ii = 0; ii < GERBVIEW_LAYER_COUNT; ii++ )
{
if( m_layersLookUpTable[ii] < LAYER_N_FRONT )
{
......@@ -402,6 +417,6 @@ void LAYERS_MAP_DIALOG::OnOkClick( wxCommandEvent& event )
_("The exported board has not enough copper layers to handle selected inner layers") );
return;
}
m_layersLookUpTable[32] = m_exportBoardCopperLayersCount;
m_layersLookUpTable[GERBVIEW_LAYER_COUNT] = m_exportBoardCopperLayersCount;
EndModal( wxID_OK );
}
/*******************************************************/
/* Dialog frame to choose gerber layers and pcb layers */
/*******************************************************/
/**
* @file select_layers_to_pcb.h
*/
......@@ -9,23 +5,23 @@
#ifndef _SELECT_LAYERS_TO_PCB_H_
#define _SELECT_LAYERS_TO_PCB_H_
#include <wx/statline.h>
#include <dialogs/dialog_layers_select_to_pcb_base.h>
#include <layers_id_colors_and_visibility.h>
#define LAYER_UNSELECTED NB_LAYERS
#define BOARD_LAYERS_MAX_COUNT NB_LAYERS
#define BOARD_COPPER_LAYERS_MAX_COUNT NB_COPPER_LAYERS
#define LAYER_UNSELECTED BOARD_LAYERS_MAX_COUNT
/*
* This dialog shows the gerber files loaded, and allows user to choose:
* what gerber file and what board layer are used
* the number of copper layers
* This dialog shows the gerber files loaded, and allows user to choose
* equivalence tbetween gerber layers and pcb layers
*/
class LAYERS_MAP_DIALOG : public LAYERS_MAP_DIALOG_BASE
{
private:
GERBVIEW_FRAME* m_Parent;
int m_itemsCount;
int m_exportBoardCopperLayersCount;
static int m_exportBoardCopperLayersCount;
wxFlexGridSizer* m_flexRightColumnBoxSizer; // An extra wxFlexGridSizer used
// when we have more than 16 gerber files loaded
int m_layersLookUpTable[32+1]; // Indexes Gerber layers to PCB file layers
......
......@@ -37,7 +37,7 @@
#include <gerbview_id.h>
#include <hotkeys.h>
#include <class_GERBER.h>
#include <class_layer_box_selector.h>
#include <class_gbr_layer_box_selector.h>
#include <class_DCodeSelectionbox.h>
#include <dialog_helpers.h>
......@@ -87,16 +87,10 @@ void GERBVIEW_FRAME::ReCreateHToolbar( void )
m_mainToolBar->AddSeparator();
wxArrayString choices;
m_SelLayerBox = new GBR_LAYER_BOX_SELECTOR( m_mainToolBar, ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER,
wxDefaultPosition, wxSize( 150, -1 ), 0,NULL);
m_SelLayerBox->Resync();
for( ii = 0; ii < 32; ii++ )
{
msg.Printf( _( "Layer %d" ), ii + 1 );
choices.Add( msg );
}
m_SelLayerBox = new LAYER_BOX_SELECTOR( m_mainToolBar, ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER,
wxDefaultPosition, wxSize( 150, -1 ), choices );
m_mainToolBar->AddControl( m_SelLayerBox );
m_mainToolBar->AddSeparator();
......@@ -241,21 +235,26 @@ void GERBVIEW_FRAME::OnUpdateDrawMode( wxUpdateUIEvent& aEvent )
}
void GERBVIEW_FRAME::OnUpdateCoordType( wxUpdateUIEvent& aEvent )
{
aEvent.Check( m_DisplayOptions.m_DisplayPolarCood );
}
void GERBVIEW_FRAME::OnUpdateFlashedItemsDrawMode( wxUpdateUIEvent& aEvent )
{
aEvent.Check( !m_DisplayPadFill );
aEvent.Check( !m_DisplayOptions.m_DisplayFlashedItemsFill );
}
void GERBVIEW_FRAME::OnUpdateLinesDrawMode( wxUpdateUIEvent& aEvent )
{
aEvent.Check( !m_DisplayPcbTrackFill );
aEvent.Check( !m_DisplayOptions.m_DisplayLinesFill );
}
void GERBVIEW_FRAME::OnUpdatePolygonsDrawMode( wxUpdateUIEvent& aEvent )
{
aEvent.Check( g_DisplayPolygonsModeSketch != 0 );
aEvent.Check( !m_DisplayOptions.m_DisplayPolygonsFill );
}
......
This diff is collapsed.
......@@ -20,17 +20,17 @@ e2net : ed.h eelibsl.h e2net.o edif.o savelib.o
e2sch : ed.h eelibsl.h e2sch.o edif.o savelib.o
gcc $(CFLAGS) e2sch.o edif.o savelib.o -o e2sch -lm
savelib : fctsys.h eelibsl.h savelib.o
savelib : fctsys.h eelibsl.h savelib.o
gcc $(CFLAGS) -c savelib.c
edif : ed.h eelibsl.h edif.o
edif : ed.h eelibsl.h edif.o
gcc $(CFLAGS) -c edif.c
// main.o : main.c
edif.o : edif.c
edif.c : edif.y
bison -t -v -d edif.y
bison -t -v -d edif.y
cp edif.tab.c edif.c
# mv y.tab.c edif.c
......@@ -39,5 +39,5 @@ edif.c : edif.y
# cat edif.y.1 edif.y.2 > edif.y
clean :
rm *.o edif.c edif.output edif.tab.c edif.tab.h e2sch e2net ppedif
rm *.o edif.c edif.output edif.tab.c edif.tab.h e2sch e2net ppedif
rm e2net.exe e2sch.exe ppedif.exe
......@@ -13,12 +13,10 @@
FILE *FileEdf, *FileNet, *FileEESchema, *FileKiPro ;
extern char FileNameKiPro[], FileNameEESchema[], FileNameLib[];
extern float scale;
char *cwd;
OutPro(LibraryStruct * Libs)
{
int i;
cwd = (char *)get_current_dir_name();
sprintf(FileNameKiPro,"%s.pro", schName);
if( (FileKiPro = fopen( FileNameKiPro, "wt" )) == NULL ) {
......@@ -29,7 +27,6 @@ OutPro(LibraryStruct * Libs)
fprintf(FileKiPro,"last_client=eeschema\n");
fprintf(FileKiPro,"[eeschema]\n");
fprintf(FileKiPro,"version=1\n");
//fprintf(FileKiPro,"LibDir=%s\n", cwd ); //"."
fprintf(FileKiPro,"LibDir=\n"); //"."
fprintf(FileKiPro,"NetFmt=1\n");
fprintf(FileKiPro,"HPGLSpd=20\n");
......@@ -62,7 +59,7 @@ OutPro(LibraryStruct * Libs)
OutHead(LibraryStruct *Libs)
{
OutEnd(); // close if previous open
sprintf(FileNameEESchema,"%s.sch", schName);
if( (FileEESchema = fopen( FileNameEESchema, "wt" )) == NULL ) {
fprintf(stderr, " %s impossible to create\n", FileNameEESchema);
......@@ -143,7 +140,7 @@ int g, x,y;
// modify bus range
for( st=s ; ; s++,t++ ){
if(*s == ':'){
*t++ = '.'; *t = '.';
*t++ = '.'; *t = '.';
}else
*t = *s;
if(*s == '\0')
......@@ -154,7 +151,7 @@ int g, x,y;
st[0] = '{';
for( t=st; *t ; t++){
if( *t == ']' )
*t = '}';
*t = '}';
}
}
fx = OFF + scale * (float)x; fy = OFF + scale * (float)y;
......@@ -287,7 +284,7 @@ LibraryEntryStruct *LibEntry;
int ii;
LibEntry = (LibraryEntryStruct *) CurrentLib->Entries;
ii = CurrentLib->NumOfParts ;
ii = CurrentLib->NumOfParts ;
fprintf(stderr, "%03d #parts %s\n", ii, CurrentLib->Name);
for( ; ii > 0; ii-- ) {
if(LibEntry != NULL) {
......@@ -343,8 +340,8 @@ int x1,y1,x2,y2,r;
LibEntry->NumOfUnits, UNUSED, 'N');
/* Position / orientation / visibilite des champs */
x1 = scale*(float)LibEntry->PrefixPosX;
y1 = scale*(float)LibEntry->PrefixPosY;
x1 = scale*(float)LibEntry->PrefixPosX;
y1 = scale*(float)LibEntry->PrefixPosY;
fprintf(ExportFile,"F0 \"%s\" %d %d %d %c %c\n",
LibEntry->Prefix,
x1, y1,
......@@ -352,8 +349,8 @@ int x1,y1,x2,y2,r;
LibEntry->PrefixOrient == 0 ? 'H' : 'V',
LibEntry->DrawPrefix ? 'V' : 'I' );
x1 = scale*(float)LibEntry->NamePosX;
y1 = scale*(float)LibEntry->NamePosY;
x1 = scale*(float)LibEntry->NamePosX;
y1 = scale*(float)LibEntry->NamePosY;
fprintf(ExportFile,"F1 \"%s\" %d %d %d %c %c\n",
LibEntry->Name,
x1, y1,
......
......@@ -389,6 +389,7 @@ EXTERN_BITMAP( pintype_noconnect_xpm )
EXTERN_BITMAP( pin_to_xpm )
EXTERN_BITMAP( pin_xpm )
EXTERN_BITMAP( plot_hpg_xpm )
EXTERN_BITMAP( plot_pdf_xpm )
EXTERN_BITMAP( plot_ps_xpm )
EXTERN_BITMAP( plot_xpm )
EXTERN_BITMAP( polar_coord_xpm )
......
......@@ -14,9 +14,14 @@ class wxAuiToolBar;
class LAYER_BOX_SELECTOR : public wxBitmapComboBox
{
private:
protected:
bool m_layerhotkeys;
bool m_layerorder;
public:
// Hotkey Info
struct EDA_HOTKEY_CONFIG* m_hotkeys;
public:
LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
......@@ -27,7 +32,19 @@ public:
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices );
// Get Current Item #
// Returns a color index from the layer id
// Virtual function because GerbView uses its own functions in a derived class
virtual int GetLayerColor( int aLayerIndex ) = 0;
// Returns the name of the layer id
// Virtual pure function because GerbView uses its own functions in a derived class
virtual const wxString GetLayerName( int aLayerIndex ) = 0;
// Returns true if the layer id is enabled (i.e. is it should be displayed)
// Virtual function pure because GerbView uses its own functions in a derived class
virtual bool IsLayerEnabled( int aLayerIndex ) = 0;
// Get Current Item #
int GetChoice();
// Get Current Layer
......@@ -37,13 +54,18 @@ public:
int SetLayerSelection(int layer);
// Reload the Layers
void Resync();
// Virtual pure function because GerbView uses its own functions in a derived class
virtual void Resync() = 0;
// Reload the Layers bitmaps colors
void ResyncBitmapOnly();
bool SetLayersOrdered(bool value);
bool SetLayersHotkeys(bool value);
// Hotkey Info
struct EDA_HOTKEY_CONFIG* m_hotkeys;
protected:
// Fills the layer bitmap aLayerbmp with the layer color
void SetBitmapLayer( wxBitmap& aLayerbmp, int aLayerIndex );
};
#define DECLARE_LAYERS_HOTKEY(list) int list[LAYER_COUNT] = \
......@@ -65,5 +87,4 @@ public:
HK_SWITCH_LAYER_TO_INNER14, \
HK_SWITCH_LAYER_TO_COMPONENT \
};
#endif //CLASS_LAYER_BOX_SELECTOR_H
......@@ -32,7 +32,6 @@
#include <wxBasePcbFrame.h>
#include <param_config.h>
#include <class_layer_box_selector.h>
#include <class_macros_record.h>
#include <class_undoredo_container.h>
#include <zones.h>
......@@ -63,6 +62,7 @@ class GENERAL_COLLECTORS_GUIDE;
class PCB_LAYER_WIDGET;
class MARKER_PCB;
class BOARD_ITEM;
class PCB_LAYER_BOX_SELECTOR;
/**
......@@ -201,7 +201,7 @@ protected:
int propagate();
public:
LAYER_BOX_SELECTOR* m_SelLayerBox; // a combo box to display and select active layer
PCB_LAYER_BOX_SELECTOR* m_SelLayerBox; // a combo box to display and select active layer
wxComboBox* m_SelTrackWidthBox; // a combo box to display and select current track width
wxComboBox* m_SelViaSizeBox; // a combo box to display and select current via diameter
......@@ -495,7 +495,7 @@ public:
void ReCreateMicrowaveVToolbar();
void ReCreateOptToolbar();
void ReCreateMenuBar();
LAYER_BOX_SELECTOR* ReCreateLayerBox( wxAuiToolBar* parent );
PCB_LAYER_BOX_SELECTOR* ReCreateLayerBox( wxAuiToolBar* parent );
/**
* Function OnModify
......
......@@ -97,6 +97,7 @@ set(PCBNEW_SRCS
block_module_editor.cpp
build_BOM_from_board.cpp
# class_footprint_library.cpp
class_pcb_layer_box_selector.cpp
class_pcb_layer_widget.cpp
clean.cpp
connect.cpp
......
......@@ -597,60 +597,61 @@ void PCB_BASE_FRAME::UpdateStatusBar()
line.Printf( formatter, To_User_Unit( g_UserUnit, ro ), theta );
SetStatusText( line, 2 );
SetStatusText( line, 3 );
}
else
{
// Display absolute coordinates:
dXpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().x );
dYpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().y );
if ( g_UserUnit == MILLIMETRES )
{
dXpos = RoundTo0( dXpos, 1000.0 );
dYpos = RoundTo0( dYpos, 1000.0 );
}
// Display absolute coordinates:
dXpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().x );
dYpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().y );
// The following sadly is an if Eeschema/if Pcbnew
wxString absformatter;
if ( g_UserUnit == MILLIMETRES )
{
dXpos = RoundTo0( dXpos, 1000.0 );
dYpos = RoundTo0( dYpos, 1000.0 );
}
switch( g_UserUnit )
{
case INCHES:
absformatter = wxT( "X %.4f Y %.4f" );
locformatter = wxT( "dx %.4f dy %.4f d %.4f" );
break;
// The following sadly is an if Eeschema/if Pcbnew
wxString absformatter;
case MILLIMETRES:
absformatter = wxT( "X %.3f Y %.3f" );
locformatter = wxT( "dx %.3f dy %.3f d %.3f" );
break;
switch( g_UserUnit )
{
case INCHES:
absformatter = wxT( "X %.4f Y %.4f" );
locformatter = wxT( "dx %.4f dy %.4f d %.4f" );
break;
case UNSCALED_UNITS:
absformatter = wxT( "X %f Y %f" );
locformatter = wxT( "dx %f dy %f d %f" );
break;
}
case MILLIMETRES:
absformatter = wxT( "X %.3f Y %.3f" );
locformatter = wxT( "dx %.3f dy %.3f d %.3f" );
break;
line.Printf( absformatter, dXpos, dYpos );
SetStatusText( line, 2 );
case UNSCALED_UNITS:
absformatter = wxT( "X %f Y %f" );
locformatter = wxT( "dx %f dy %f d %f" );
break;
}
// Display relative coordinates:
dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y;
dXpos = To_User_Unit( g_UserUnit, dx );
dYpos = To_User_Unit( g_UserUnit, dy );
line.Printf( absformatter, dXpos, dYpos );
SetStatusText( line, 2 );
if ( g_UserUnit == MILLIMETRES )
if( !DisplayOpt.DisplayPolarCood ) // display relative cartesian coordinates
{
dXpos = RoundTo0( dXpos, 1000.0 );
dYpos = RoundTo0( dYpos, 1000.0 );
}
// Display relative coordinates:
dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y;
dXpos = To_User_Unit( g_UserUnit, dx );
dYpos = To_User_Unit( g_UserUnit, dy );
if ( g_UserUnit == MILLIMETRES )
{
dXpos = RoundTo0( dXpos, 1000.0 );
dYpos = RoundTo0( dYpos, 1000.0 );
}
// We already decided the formatter above
line.Printf( locformatter, dXpos, dYpos, sqrt( dXpos * dXpos + dYpos * dYpos ) );
SetStatusText( line, 3 );
// We already decided the formatter above
line.Printf( locformatter, dXpos, dYpos, sqrt( dXpos * dXpos + dYpos * dYpos ) );
SetStatusText( line, 3 );
}
}
......
/**
* @file class_pcb_layer_box_selector.cpp
* @brief a derived class of LAYER_BOX_SELECTOR to handle the layer box selector
* in Pcbnew
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 Jean-Pierre Charras <jean-pierre.charras@ujf-grenoble.fr>
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2012 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
*/
#include <common.h>
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <class_board_design_settings.h>
#include <colors_selection.h>
#include <layers_id_colors_and_visibility.h>
#include <class_board.h>
#include <hotkeys.h>
#include <wx/ownerdrw.h>
#include <wx/menuitem.h>
#include <wx/bmpcbox.h>
#include <wx/wx.h>
#include <class_pcb_layer_box_selector.h>
/* class to display a layer list.
*
*/
// Reload the Layers
void PCB_LAYER_BOX_SELECTOR::Resync()
{
Clear();
static DECLARE_LAYERS_ORDER_LIST( layertranscode );
static DECLARE_LAYERS_HOTKEY( layerhk );
for( int i = 0; i < LAYER_COUNT; i++ )
{
wxBitmap layerbmp( 14, 14 );
wxString layername;
int layerid = i;
if( m_layerorder )
layerid = layertranscode[i];
if( ! IsLayerEnabled( layerid ) )
continue;
SetBitmapLayer( layerbmp, layerid );
layername = GetLayerName( layerid );
if( m_layerhotkeys && m_hotkeys != NULL )
layername = AddHotkeyName( layername, m_hotkeys, layerhk[layerid], IS_COMMENT );
Append( layername, layerbmp, (void*) layerid );
}
}
// Returns true if the layer id is enabled (i.e. is it should be displayed)
bool PCB_LAYER_BOX_SELECTOR::IsLayerEnabled( int aLayerIndex )
{
PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent();
BOARD* board = pcbFrame->GetBoard();
wxASSERT( board != NULL );
return board->IsLayerEnabled( aLayerIndex );
}
// Returns a color index from the layer id
int PCB_LAYER_BOX_SELECTOR::GetLayerColor( int aLayerIndex )
{
PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent();
BOARD* board = pcbFrame->GetBoard();
wxASSERT( board != NULL );
return board->GetLayerColor( aLayerIndex );
}
// Returns the name of the layer id
const wxString PCB_LAYER_BOX_SELECTOR::GetLayerName( int aLayerIndex )
{
PCB_BASE_FRAME* pcbFrame = (PCB_BASE_FRAME*) GetParent()->GetParent();
BOARD* board = pcbFrame->GetBoard();
wxASSERT( board != NULL );
return board->GetLayerName( aLayerIndex );
}
This diff is collapsed.
// Do not edit this file, it is autogenerated by CMake from an HTML file
"<html>"
"<!-- This file is used to autogenerate a *.h file, but you can load it into a browser to preview -->"
"<h1>Freerouter Guidelines:</h1>"
"<ol>"
"<li> in pcbnew, using the Layers Setup dialog:</li><br>"
" <li>choose the number of layers, and enter the name of each layer.</li><br><br>"
" These should look something like this (if a 6 layer board):"
"<ul>"
" <li>Front - signal</li>"
" <li>Ground - power</li>"
" <li>H1_Signal - signal</li>"
" <li>V2_Signal - signal</li>"
" <li>Power - power</li>"
" <li>Back - signal</li>"
"</ul><br>"
" Notice that after the layer name there is a layer type field, either 'signal' or 'power', typically."
" Any layer identified as 'power' will be removed from the layer menu in Freerouter,"
" as this will be assumed to contain a power zone."
"</li><br><br>"
"<li> in pcbnew: establish board perimeter.</li><br>"
"<li> in pcbnew: load in the netlist so you have all the components defined and instantiated.</li><br>"
"<li> in pcbnew: establish any zones, inclusive of net association.</li><br>"
"<li> in pcbnew: do the degree of component placements you are comfortable with."
" It is a little easier to accurately position components in pcbnew than in"
" freerouter, but either will work.</li><br>"
"<li> in pcbnew: set up the netclasses. Power traces might be a little thicker"
" than signal traces. If so, add a netclass called 'power'."
" Make its traces thicker than what you establish for netclass 'Default'."
" Set trace width, spacing and vias for each netclass.</li><br>"
"<li> in pcbnew: export to DSN.</li><br>"
"<li> load up freerouter (keep it running for any subsequent iterations of 5) through 16) here).</li><br>"
"<li> in freerouter: load the project's *.dsn file. Immediately after a load, all"
" components and traces (if any) will initially be 'fixed'. This is a 'lock"
" in place' toggle that you can undo by selecting a region with your mouse"
" and then selecting 'Unfix' from the menu. Occassionally you may want to"
" re-fix a trace or a part, if only temporarily. This keeps it locked in"
" place."
"</li><br>"
"<li> useful, not mandatory: in freerouter: set your move snap modulus, which seems"
" to default to 1 internal unit."
" 20 mils in x and in y is about reasonable.</li><br>"
"<li> in freerouter: finish placing any components, you can change sides of a part"
" here also, rotate, whatever.</li><br>"
"<li> in freerouter: route the board, and save frequently to a *.dsn file while"
" routing in case of power loss. Pick the menu option for saving a full *.dsn"
" file, not a session file (yet). The full freerouter *.dsn file is a superset"
" format, one that can be reloaded in the event of a power loss. Whereas the"
" *.ses file is not a complete design, but only with the *.brd file"
" constitutes a full design. So it is important to backup your work to a"
" *.dsn file while routing in case of power loss.</li><br>"
"<li> in freerouter: when done, or when you want to back import, then save as a session file, *.ses.</li><br>"
"<li> in pcbnew: backimport the session file</li><br>"
"<li> in pcbnew: at this point the zones have to be refilled. One way to do that"
" is to simply run DRC.</li>"
"</ol>"
"</html>"
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment