7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 09:51:40 +00:00

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.
This commit is contained in:
jean-pierre charras 2012-05-04 19:44:42 +02:00
parent 2fe9a99b8f
commit 4125ea7789
61 changed files with 2406 additions and 2256 deletions

View File

@ -412,6 +412,7 @@ set( BMAPS_MID
pin_to
pin
plot_hpg
plot_pdf
plot_ps
plot
polar_coord

View File

@ -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

View File

@ -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 )

View File

@ -1,19 +1,13 @@
#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() );
}

View File

@ -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,

View File

@ -1,4 +1,4 @@
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})

View File

@ -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();
}

View File

@ -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 );
}
}
}

View File

@ -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

View File

@ -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
};

View File

@ -0,0 +1,80 @@
/**
* @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;
}

View File

@ -0,0 +1,51 @@
#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

View File

@ -0,0 +1,45 @@
/**
* @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;
}

112
gerbview/class_gbr_layout.h Normal file
View File

@ -0,0 +1,112 @@
/**
* @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

View File

@ -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 )
{
}

View File

@ -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_

View File

@ -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;

View File

@ -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

View File

@ -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();
}

View File

@ -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 )

View File

@ -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() );

View File

@ -0,0 +1,229 @@
/**
* @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 );
}

View File

@ -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 );

View File

@ -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 );

View File

@ -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;
}

Some files were not shown because too many files have changed in this diff Show More