Commit 10e13ae5 authored by dickelbeck's avatar dickelbeck

layer names in *.brd file

parent 7c482f68
......@@ -5,16 +5,27 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2008-Mar-3 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
Completed transision to BOARD::GetLayerName() and away from ReturnPcbLayerName().
LayerNames and LAYER_T are saved int the *.brd file and may be edited
there with a text editor until the UI is in place to edit them in PCBNEW.
To understand the strategy, see BOARD::GetLayerName() in class_board.cpp
and see WinEDA_BasePcbFrame::ReadSetup(). I will be adding "Board" menu
item to Preferences, but there is more to come before the UI gets done:
net classes.
2008-mars-03 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
3d display:
Added Jonas Diemer's patch (enhanced movings from mouse and tools)
2008-Mar-1 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
Changed ioascii.cpp to save and load board specific layer names, for DEBUG
build only. I want to add class LAYER, see below. Added
BOARD::SetLayerName(), BOARD::SetLayerType(), and BOARD::GetLayerType().
......
......@@ -265,8 +265,6 @@ void MyFree( void* pt_mem )
}
/**************************************************************/
wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding )
/**************************************************************/
......@@ -276,32 +274,11 @@ wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding )
* (not internatinalized, no space)
*/
{
#if 1 && defined(DEBUG)
// Dick: this code is working fine, but we have no place to store the layer names yet.
const unsigned LAYER_LIMIT = 29;
// @todo: these layer names should be configurable on a per project basis.
// In anticipation of that enhancement, here is a different strategy for
// deriving the file names from the "configured" layer names.
// The main idea is to use a single array of names, and then remove
// spaces on the fly from the names when writing to disk.
// These are only default layer names. For PCBNEW, the copper names
// may be over-ridden in the BOARD file *.brd.
#if 1 // my specific layer names
static const wxString layer_name_list[] = {
_( "H2 Bottom" ), _( "Power" ), _( "V2 Signal" ), _( "H1 Signal" ),
_( "Ground" ), _( "Inner L5" ), _( "Inner L6" ), _( "Inner L7" ),
_( "Inner L8" ), _( "Inner L9" ), _( "Inner L10" ), _( "Inner L11" ),
_( "Inner L12" ), _( "Inner L13" ), _( "Inner L14" ), _( "Component" ),
_( "Adhes Cop" ), _( "Adhes Cmp" ), _( "SoldP Cop" ), _( "SoldP Cmp" ),
_( "SilkS Cop" ), _( "SilkS Cmp" ), _( "Mask Cop" ), _( "Mask Cmp" ),
_( "Drawings " ), _( "Comments" ), _( "Eco1" ), _( "Eco2" ),
_( "Edges Pcb" ), _( "BAD INDEX" ),
};
#else
static const wxString layer_name_list[] = {
_( "Copper " ), _( "Inner L1 " ), _( "Inner L2 " ), _( "Inner L3 " ),
_( "Inner L4 " ), _( "Inner L5 " ), _( "Inner L6 " ), _( "Inner L7 " ),
......@@ -313,8 +290,6 @@ wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding )
_( "Edges Pcb" ), _( "BAD INDEX" ),
};
#endif
if( (unsigned) layer_number > LAYER_LIMIT )
layer_number = LAYER_LIMIT;
......@@ -332,42 +307,6 @@ wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding )
}
else
return *p;
#else // long standing established code:
static const wxString layer_name_list[] = {
_( "Copper " ), _( "Inner L1 " ), _( "Inner L2 " ), _( "Inner L3 " ),
_( "Inner L4 " ), _( "Inner L5 " ), _( "Inner L6 " ), _( "Inner L7 " ),
_( "Inner L8 " ), _( "Inner L9 " ), _( "Inner L10" ), _( "Inner L11" ),
_( "Inner L12" ), _( "Inner L13" ), _( "Inner L14" ), _( "Component" ),
_( "Adhes Cop" ), _( "Adhes Cmp" ), _( "SoldP Cop" ), _( "SoldP Cmp" ),
_( "SilkS Cop" ), _( "SilkS Cmp" ), _( "Mask Cop " ), _( "Mask Cmp " ),
_( "Drawings " ), _( "Comments " ), _( "Eco1 " ), _( "Eco2 " ),
_( "Edges Pcb" ), _( "--- " ), _( "--- " ), _( "--- " )
};
// Same as layer_name_list, without space, not internationalized
static const wxString layer_name_list_for_filename[] = {
wxT( "Copper" ), wxT( "InnerL1" ), wxT( "InnerL2" ), wxT( "InnerL3" ),
wxT( "InnerL4" ), wxT( "InnerL5" ), wxT( "InnerL6" ), wxT( "InnerL7" ),
wxT( "InnerL8" ), wxT( "InnerL9" ), wxT( "InnerL10" ), wxT( "InnerL11" ),
wxT( "InnerL12" ), wxT( "InnerL13" ), wxT( "InnerL14" ), wxT( "Component" ),
wxT( "AdhesCop" ), wxT( "AdhesCmp" ), wxT( "SoldPCop" ), wxT( "SoldPCmp" ),
wxT( "SilkSCop" ), wxT( "SilkSCmp" ), wxT( "MaskCop" ), wxT( "MaskCmp" ),
wxT( "Drawings" ), wxT( "Comments" ), wxT( "Eco1" ), wxT( "Eco2" ),
wxT( "EdgesPcb" ), wxT( "---" ), wxT( "---" ), wxT( "---" )
};
if( (unsigned) layer_number >= 31u )
layer_number = 31;
return omitSpacePadding ?
layer_name_list_for_filename[layer_number] :
layer_name_list[layer_number];
#endif
}
......
......@@ -319,7 +319,8 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename,
{
#undef PTCFG
#define PTCFG ( (PARAM_CFG_DOUBLE*) pt_cfg )
double ftmp = 0; wxString msg;
double ftmp = 0;
wxString msg;
if( pt_cfg->m_Setup )
msg = m_EDA_Config->Read( pt_cfg->m_Ident, wxT( "" ) );
else
......
/***************************************/
/** cfg.cpp : configuration de CVPCB **/
/***************************************/
/***************************************/
/** cfg.cpp : configuration de CVPCB **/
/***************************************/
/* lit ou met a jour la configuration de CVPCB */
......@@ -18,57 +18,64 @@
/**************************************************/
void Read_Config( const wxString & FileName )
void Read_Config( const wxString& FileName )
/**************************************************/
/* lit la configuration
1 - lit cvpcb.cnf
2 - si non trouve lit <chemin de cvpcb.exe>/cvpcb.cnf
3 - si non trouve: init des variables aux valeurs par defaut
Remarque:
le chemin de l'executable cvpcb.exe doit etre dans BinDir
*/
/* lit la configuration
* 1 - lit cvpcb.cnf
* 2 - si non trouve lit <chemin de cvpcb.exe>/cvpcb.cnf
* 3 - si non trouve: init des variables aux valeurs par defaut
*
* Remarque:
* le chemin de l'executable cvpcb.exe doit etre dans BinDir
*/
{
wxString FullFileName = FileName ;
wxString FullFileName = FileName;
/* Init des valeurs par defaut */
g_LibName_List.Clear();
g_ListName_Equ.Clear();
g_EDA_Appl->ReadProjectConfig(FullFileName,
GROUP, ParamCfgList, FALSE);
g_EDA_Appl->ReadProjectConfig( FullFileName,
GROUP, ParamCfgList, FALSE );
if ( PkgInExtBuffer.IsEmpty() ) PkgInExtBuffer = wxT(".pkg");
if ( NetInExtBuffer.IsEmpty() ) NetInExtBuffer = wxT(".net"),
if( PkgInExtBuffer.IsEmpty() )
PkgInExtBuffer = wxT( ".pkg" );
if( NetInExtBuffer.IsEmpty() )
NetInExtBuffer = wxT( ".net" );
/* Inits autres variables */
SetRealLibraryPath( wxT("modules"));
SetRealLibraryPath( wxT( "modules" ) );
}
/************************************************************/
void WinEDA_CvpcbFrame::Update_Config(wxCommandEvent& event)
void WinEDA_CvpcbFrame::Update_Config( wxCommandEvent& event )
/************************************************************/
/* fonction relai d'appel a Save_Config,
la vraie fonction de sauvegarde de la config
*/
* la vraie fonction de sauvegarde de la config
*/
{
Save_Config(this);
Save_Config( this );
}
/************************************/
void Save_Config(wxWindow * parent)
void Save_Config( wxWindow* parent )
/************************************/
/* enregistrement de la config */
{
wxString path, FullFileName;
wxString mask( wxT("*"));
wxString path, FullFileName;
wxString mask( wxT( "*" ) );
FullFileName = FFileName;
ChangeFileNameExt( FullFileName, g_Prj_Config_Filename_ext );
path = wxGetCwd();
FullFileName = EDA_FileSelector(_("Save preferences"),
FullFileName = EDA_FileSelector( _( "Save preferences" ),
path, /* Chemin par defaut */
FullFileName, /* nom fichier par defaut */
g_Prj_Config_Filename_ext, /* extension par defaut */
......@@ -77,9 +84,10 @@ wxString mask( wxT("*"));
wxFD_SAVE,
TRUE
);
if ( FullFileName.IsEmpty()) return;
if( FullFileName.IsEmpty() )
return;
/* ecriture de la configuration */
g_EDA_Appl->WriteProjectConfig(FullFileName, GROUP, ParamCfgList);
g_EDA_Appl->WriteProjectConfig( FullFileName, GROUP, ParamCfgList );
}
......@@ -55,8 +55,6 @@ bool WinEDA_App::OnInit()
SetTopWindow( m_GerberFrame );
m_GerberFrame->Show( TRUE );
m_GerberFrame->m_Pcb = new BOARD( NULL, m_GerberFrame );
m_GerberFrame->Zoom_Automatique( TRUE );
if( argc > 1 )
......
......@@ -16,11 +16,14 @@
#include "protos.h"
#define HOTKEY_FILENAME wxT( "gerbview" )
/* Routines Locales */
/* Variables locales */
#define HOTKEY_FILENAME wxT( "gerbview" )
/* Variables locales */
/*************************************************************/
......@@ -32,7 +35,8 @@ void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event )
wxString FullFileName;
pos = GetPosition();
pos.x += 20; pos.y += 20;
pos.x += 20;
pos.y += 20;
switch( id )
{
......
......@@ -14,6 +14,7 @@
/* Variables locales */
#define LAYER_UNSELECTED NB_LAYERS
static int ButtonTable[32]; // Indexes buttons to Gerber layers
static int LayerLookUpTable[32]; // Indexes Gerber layers to PCB file layers
wxStaticText* layer_list[32]; // Indexes text strings to buttons
......@@ -75,6 +76,7 @@ int * InstallDialogLayerPairChoice(WinEDA_GerberFrame * parent)
*/
{
WinEDA_SwapLayerFrame * frame = new WinEDA_SwapLayerFrame(parent);
int ii = frame->ShowModal();
frame->Destroy();
if( ii >= 0 )
......@@ -138,7 +140,6 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame(WinEDA_GerberFrame *parent) :
int pcb_layer_number = 0;
for( nb_items = 0, ii = 0; ii < 32; ii++ )
{
if( g_GERBER_Descr_List[ii] == NULL )
continue;
......@@ -353,8 +354,8 @@ void WinEDA_SwapLayerFrame::OnCancelClick(wxCommandEvent& event)
void WinEDA_SwapLayerFrame::OnOkClick(wxCommandEvent& event)
/*********************************************************/
{
int ii;
bool AsCmpLayer = false;
int ii;
bool AsCmpLayer = false;
/* Compute the number of copper layers
* this is the max layer number + 1 (if some internal layers exist)
......
......@@ -148,38 +148,6 @@ struct CHEVELU;
/* Class to handle a board */
#include "class_board.h"
/**
* Class LAYER
* holds information pertinent to a layer of a BOARD.
*/
class LAYER
{
wxString m_Name;
LAYER_T m_Type;
int m_Color;
bool m_Visible; // ? use flags in m_Color instead ?
public:
bool SetName( const wxString& aLayerName );
const wxString& GetName();
bool SetType( LAYER_T aLayerType );
LAYER_T GetType();
int GetColor() { return m_Color; }
void SetColor( int aColor ) { m_Color = aColor; }
bool IsVisible();
void SetVisible( bool isVisible );
};
// Class for handle current printed board design settings
#define HISTORY_NUMBER 8
class EDA_BoardDesignSettings
......@@ -207,7 +175,9 @@ public:
// Color options for screen display of the Printed Board:
int m_PcbGridColor; // Grid color
int m_LayerColor[32]; // Layer colors (tracks and graphic items)
int m_ViaColor[4]; // Via color (depending on is type)
int m_ModuleTextCMPColor; // Text module color for modules on the COMPONENT layer
int m_ModuleTextCUColor; // Text module color for modules on the COPPER layer
......
......@@ -74,6 +74,14 @@ public:
~WinEDA_BasePcbFrame();
/**
* Function SetBOARD
* sets the m_Pcb member in such as way as to ensure deleting any previous
* BOARD.
* @param aBoard The BOARD to put into the frame.
*/
void SetBOARD( BOARD* aBoard );
// General
virtual void OnCloseWindow( wxCloseEvent& Event ) = 0;
virtual void Process_Special_Functions( wxCommandEvent& event ) = 0;
......
......@@ -66,6 +66,13 @@ WinEDA_BasePcbFrame::~WinEDA_BasePcbFrame( void )
}
void WinEDA_BasePcbFrame::SetBOARD( BOARD* aBoard )
{
delete m_Pcb;
m_Pcb = aBoard;
}
/**************************************/
int WinEDA_BasePcbFrame::BestZoom( void )
/**************************************/
......
......@@ -38,6 +38,12 @@ BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
m_LocalRatsnest = NULL; // pointeur liste rats local
m_CurrentZoneContour = NULL; // This ZONE_CONTAINER handle the zone contour cuurently in progress
// de determination des contours de zone
for( int layer=0; layer<NB_COPPER_LAYERS; ++layer )
{
m_Layer[layer].m_Name = ReturnPcbLayerName( layer );
m_Layer[layer].m_Type = LT_SIGNAL;
}
}
......@@ -80,28 +86,96 @@ BOARD::~BOARD()
wxString BOARD::GetLayerName( int aLayerIndex ) const
{
// copper layer names are stored in the BOARD.
if( (unsigned) aLayerIndex < (unsigned) GetCopperLayerCount() )
{
// default names were set in BOARD::BOARD() but they may be
// over-ridden by BOARD::SetLayerName()
return m_Layer[aLayerIndex].m_Name;
}
return ReturnPcbLayerName( aLayerIndex, true );
}
bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )
{
// a dummy temporarily.
D(printf("SetLayerName( %d, %s )\n", aLayerIndex, CONV_TO_UTF8(aLayerName) );)
if( (unsigned) aLayerIndex < (unsigned) GetCopperLayerCount() )
{
if( aLayerName == wxEmptyString || aLayerName.Len() > 20 )
return false;
// no quote chars in the name allowed
if( aLayerName.Find( wxChar('"') ) != wxNOT_FOUND )
return false;
// ensure unique-ness of layer names
for( int layer=0; layer<GetCopperLayerCount(); ++layer )
{
if( layer!=aLayerIndex && aLayerName == m_Layer[layer].m_Name )
return false;
}
m_Layer[aLayerIndex].m_Name = aLayerName;
// replace any spaces with underscores
m_Layer[aLayerIndex].m_Name.Replace( wxT(" "), wxT("_") );
return true;
}
return false;
}
LAYER_T BOARD::GetLayerType( int aLayerIndex ) const
{
if( (unsigned) aLayerIndex < (unsigned) GetCopperLayerCount() )
return m_Layer[aLayerIndex].m_Type;
return LT_SIGNAL;
}
bool BOARD::SetLayerType( int aLayerIndex, LAYER_T aLayerType )
{
// a dummy temporarily.
if( (unsigned) aLayerIndex < (unsigned) GetCopperLayerCount() )
{
m_Layer[aLayerIndex].m_Type = aLayerType;
return true;
}
return false;
}
const char* LAYER::ShowType( LAYER_T aType )
{
const char* cp;
switch( aType )
{
default:
case LT_SIGNAL: cp = "signal"; break;
case LT_POWER: cp = "power"; break;
case LT_MIXED: cp = "mixed"; break;
case LT_JUMPER: cp = "jumper"; break;
}
return cp;
}
LAYER_T LAYER::ParseType( const char* aType )
{
if( strcmp( aType, "signal" ) == 0 )
return LT_SIGNAL;
else if( strcmp( aType, "power" ) == 0 )
return LT_POWER;
else if( strcmp( aType, "mixed" ) == 0 )
return LT_MIXED;
else if( strcmp( aType, "jumper" ) == 0 )
return LT_JUMPER;
else
return LAYER_T(-1);
}
......
......@@ -18,14 +18,49 @@ enum LAYER_T
LT_SIGNAL,
LT_POWER,
LT_MIXED,
LT_JUMPER,
};
/***********************************************/
/* class BOARD : handle datas to build a board */
/***********************************************/
/**
* Struct LAYER
* holds information pertinent to a layer of a BOARD.
*/
struct LAYER
{
/** The name of the layer, there should be no spaces in this name. */
wxString m_Name;
/** The type of the layer */
LAYER_T m_Type;
// int m_Color;
// bool m_Visible; // ? use flags in m_Color instead ?
/**
* Function ShowType
* converts a LAYER_T enum to a const char*
* @param aType The LAYER_T to convert
* @return const char* - The string representation of the layer type.
*/
static const char* ShowType( LAYER_T aType );
/**
* Function ParseType
* converts a string to a LAYER_T
* @param aType The const char* to convert
* @return LAYER_T - The binary representation of the layer type, or
* LAYER_T(-1) if the string is invalid
*/
static LAYER_T ParseType( const char* aType );
};
/**
* Class BOARD
* holds information pertinent to a PCBNEW printed circuit board.
*/
class BOARD : public BOARD_ITEM
{
friend class WinEDA_PcbFrame;
......@@ -37,6 +72,8 @@ private:
typedef std::vector<ZONE_CONTAINER*> ZONE_CONTAINERS; // @todo: switch to boost::ptr_vector, and change ~BOARD()
ZONE_CONTAINERS m_ZoneDescriptorList; ///< edge zone descriptors, owned by pointer
LAYER m_Layer[NB_COPPER_LAYERS];
public:
WinEDA_BasePcbFrame* m_PcbFrame; // Window de visualisation
EDA_Rect m_BoundaryBox; // Board size and position
......@@ -294,6 +331,7 @@ public:
return wxT( "BOARD" );
}
#if defined(DEBUG)
/**
* Function Show
......
......@@ -150,6 +150,9 @@ void DRAWSEGMENT::Display_Infos( WinEDA_DrawFrame* frame )
int itype;
wxString msg;
BOARD* board = (BOARD*) m_Parent;
wxASSERT( board );
frame->MsgPanel->EraseMsgBox();
itype = m_Type & 0x0F;
......@@ -173,7 +176,7 @@ void DRAWSEGMENT::Display_Infos( WinEDA_DrawFrame* frame )
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Segment" ), RED );
Affiche_1_Parametre( frame, 48, _( "Layer" ),
ReturnPcbLayerName( m_Layer ), BROWN );
board->GetLayerName( m_Layer ), BROWN );
valeur_param( (unsigned) m_Width, msg );
Affiche_1_Parametre( frame, 60, _( "Width" ), msg, DARKCYAN );
......
......@@ -1135,15 +1135,6 @@ bool MODULE::HitTest( const wxPoint& refPos )
if( m_BoundaryBox.Inside( spot_cX, spot_cY ) )
return true;
/* no
// The GENERAL_COLLECTOR needs these two tests in order to find a MODULE
// when the user clicks on its text. Keep these 2, needed in OnRightClick().
if( m_Reference->HitTest( refPos ) )
return true;
if( m_Value->HitTest( refPos ) )
return true;
*/
return false;
}
......@@ -1173,6 +1164,25 @@ bool MODULE::HitTest( EDA_Rect& refArea )
}
D_PAD* MODULE::FindPadByName( const wxString& aPadName ) const
{
wxString buf;
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
pad->ReturnStringPadName( buf );
#if 1
if( buf.CmpNoCase( aPadName ) == 0 ) // why case insensitive?
#else
if( buf == aPadName )
#endif
return pad;
}
return NULL;
}
// see class_module.h
SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData,
const KICAD_T scanTypes[] )
......
......@@ -197,6 +197,17 @@ public:
return m_Value->m_Text;
}
/**
* Function FindPadByName
* returns a D_PAD* with a matching name. Note that names may not be
* unique, depending on how the foot print was created.
* @param
* @return D_PAD* - The first matching name is returned, or NULL if not found.
*/
D_PAD* FindPadByName( const wxString& aPadName ) const;
/**
* Function Visit
* should be re-implemented for each derived class in order to handle
......
......@@ -167,6 +167,9 @@ void TEXTE_PCB::Display_Infos( WinEDA_DrawFrame* frame )
{
wxString msg;
BOARD* board = (BOARD*) m_Parent;
wxASSERT( board );
frame->MsgPanel->EraseMsgBox();
if( m_Parent && m_Parent->Type() == TYPECOTATION )
......@@ -175,7 +178,7 @@ void TEXTE_PCB::Display_Infos( WinEDA_DrawFrame* frame )
Affiche_1_Parametre( frame, 1, _( "PCB Text" ), m_Text, DARKGREEN );
Affiche_1_Parametre( frame, 28, _( "Layer" ),
ReturnPcbLayerName( m_Layer ),
board->GetLayerName( m_Layer ),
g_DesignSettings.m_LayerColor[m_Layer] & MASKCOLOR );
Affiche_1_Parametre( frame, 36, _( "Mirror" ), wxEmptyString, GREEN );
......
......@@ -338,9 +338,14 @@ void TEXTE_MODULE::Display_Infos( WinEDA_DrawFrame* frame )
MODULE* module = (MODULE*) m_Parent;
wxASSERT( module );
if( !module )
return;
BOARD* board = (BOARD*) module->m_Parent;
wxASSERT( board );
static const wxString text_type_msg[3] = {
_( "Ref." ), _( "Value" ), _( "Text" ) };
......@@ -366,7 +371,7 @@ void TEXTE_MODULE::Display_Infos( WinEDA_DrawFrame* frame )
ii = m_Layer;
if( ii < NB_LAYERS )
Affiche_1_Parametre( frame, 28, _( "Layer" ), ReturnPcbLayerName( ii ), DARKGREEN );
Affiche_1_Parametre( frame, 28, _( "Layer" ), board->GetLayerName( ii ), DARKGREEN );
else
{
msg.Printf( wxT( "%d" ), ii );
......
......@@ -514,6 +514,10 @@ void ZONE_CONTAINER::Display_Infos( WinEDA_DrawFrame* frame )
wxString msg;
int text_pos;
BOARD* board = (BOARD*) m_Parent;
wxASSERT( board );
frame->MsgPanel->EraseMsgBox();
msg = _( "Zone Outline" );
......@@ -551,7 +555,7 @@ void ZONE_CONTAINER::Display_Infos( WinEDA_DrawFrame* frame )
Affiche_1_Parametre( frame, text_pos, _( "NetCode" ), msg, RED );
text_pos += 8;
msg = ReturnPcbLayerName( m_Layer );
msg = board->GetLayerName( m_Layer );
Affiche_1_Parametre( frame, text_pos, _( "Layer" ), msg, BROWN );
text_pos += 8;
......
......@@ -156,6 +156,7 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings()
m_MicroViaDrill = 50; // micro via drill (for the entire board)
m_CurrentMicroViaSize = 150; // Current micro via size
m_MicroViasAllowed = false; // true to allow micro vias
for( ii = 0; ii < HISTORY_NUMBER; ii++ )
{
m_TrackWidthHistory[ii] = 0; // Last HISTORY_NUMBER used track widths
......@@ -171,6 +172,7 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings()
m_MaskMargin = 150; // Solder mask margin
/* Color options for screen display of the Printed Board: */
m_PcbGridColor = DARKGRAY; // Grid color
for( ii = 0; ii < 32; ii++ )
m_LayerColor[ii] = default_layer_color[ii];
......@@ -179,6 +181,7 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings()
m_ViaColor[VIA_MICROVIA] = CYAN;
m_ViaColor[VIA_BLIND_BURIED] = BROWN;
m_ViaColor[VIA_THROUGH] = WHITE;
m_ModuleTextCMPColor = LIGHTGRAY; // Text module color for modules on the COMPONENT layer
m_ModuleTextCUColor = MAGENTA; // Text module color for modules on the COPPER layer
m_ModuleTextNOVColor = DARKGRAY; // Text module color for "invisible" texts (must be BLACK if really not displayed)
......
......@@ -135,10 +135,10 @@ WinEDA_CotationPropertiesFrame::WinEDA_CotationPropertiesFrame( WinEDA_PcbFrame*
m_SelLayerBox = new WinEDAChoiceBox( this, ID_TEXTPCB_SELECT_LAYER,
wxDefaultPosition, wxDefaultSize );
LeftBoxSizer->Add( m_SelLayerBox, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
int ii;
for( ii = FIRST_NO_COPPER_LAYER; ii < NB_LAYERS; ii++ )
for( int layer = FIRST_NO_COPPER_LAYER; layer<NB_LAYERS; layer++ )
{
m_SelLayerBox->Append( ReturnPcbLayerName( ii ) );
m_SelLayerBox->Append( parent->m_Pcb->GetLayerName( layer ) );
}
m_SelLayerBox->SetSelection( Cotation->GetLayer() - FIRST_NO_COPPER_LAYER );
......
......@@ -48,7 +48,7 @@ void RemoteCommand( const char* cmdline )
{
modName = CONV_FROM_UTF8( text );
module = ReturnModule( frame->m_Pcb, modName );
module = frame->m_Pcb->FindModuleByReference( modName );
if( module )
msg.Printf( _( "%s found" ), modName.GetData() );
......@@ -86,9 +86,9 @@ void RemoteCommand( const char* cmdline )
modName = CONV_FROM_UTF8( text );
module = ReturnModule( frame->m_Pcb, modName );
module = frame->m_Pcb->FindModuleByReference( modName );
if( module )
pad = ReturnPad( module, pinName );
pad = module->FindPadByName( pinName );
if( pad )
netcode = pad->GetNet();
......
......@@ -133,6 +133,8 @@ bool WinEDA_ZoneFrame::Create( wxWindow* parent,
void WinEDA_ZoneFrame::CreateControls()
{
BOARD* board = m_Parent->m_Pcb;
SetFont( *g_DialogFont );
////@begin WinEDA_ZoneFrame content construction
......@@ -310,19 +312,23 @@ void WinEDA_ZoneFrame::CreateControls()
break;
}
int layer_cnt = g_DesignSettings.m_CopperLayerCount;
for( int ii = 0; ii < g_DesignSettings.m_CopperLayerCount; ii++ )
int layer_cnt = board->GetCopperLayerCount();
for( int ii = 0; ii < board->GetCopperLayerCount(); ii++ )
{
wxString msg;
int layer_number = COPPER_LAYER_N;
if( layer_cnt == 0 || ii < layer_cnt - 1 )
layer_number = ii;
else if( ii == layer_cnt - 1 )
layer_number = LAYER_CMP_N;
m_LayerId[ii] = layer_number;
msg = ReturnPcbLayerName( layer_number ).Trim();
msg = board->GetLayerName( layer_number ).Trim();
m_LayerSelectionCtrl->InsertItems( 1, &msg, ii );
if ( m_Zone_Container )
if( m_Zone_Container )
{
if( m_Zone_Container->GetLayer() == layer_number )
m_LayerSelectionCtrl->SetSelection( ii );
......@@ -335,21 +341,24 @@ void WinEDA_ZoneFrame::CreateControls()
}
m_NetSortingOption->SetSelection(m_NetSorting == BOARD::ALPHA_SORT ? 0 : 1 );
wxString NetNameFilter;
if( m_Parent->m_Parent->m_EDA_Config )
{
NetNameFilter = m_Parent->m_Parent->m_EDA_Config->Read( ZONE_NET_FILTER_STRING_KEY, wxT("N_0*") );
}
m_NetNameFilter->SetValue(NetNameFilter);
wxArrayString ListNetName;
m_Parent->m_Pcb->ReturnSortedNetnamesList( ListNetName,
m_NetSorting == 0 ? BOARD::ALPHA_SORT : BOARD::PAD_CNT_SORT );
if ( m_NetSorting != 0 )
{
wxString Filter = m_NetNameFilter->GetValue();
for (unsigned ii = 0; ii < ListNetName.GetCount(); ii ++ )
for( unsigned ii = 0; ii < ListNetName.GetCount(); ii++ )
{
if ( ListNetName[ii].Matches(Filter.GetData() ) )
if( ListNetName[ii].Matches(Filter.GetData() ) )
{
ListNetName. RemoveAt(ii);
ii--;
......@@ -361,8 +370,9 @@ void WinEDA_ZoneFrame::CreateControls()
// Select net:
int net_select = g_HightLigth_NetCode;
if ( m_Zone_Container )
if( m_Zone_Container )
net_select = m_Zone_Container->GetNet();
if( net_select > 0 )
{
EQUIPOT* equipot = m_Parent->m_Pcb->FindNet( net_select );
......@@ -563,7 +573,6 @@ void WinEDA_ZoneFrame::OnNetSortingOptionSelected( wxCommandEvent& event )
m_Parent->m_Parent->m_EDA_Config->Write( ZONE_NET_SORT_OPTION_KEY, (long) m_NetSorting );
m_Parent->m_Parent->m_EDA_Config->Write( ZONE_NET_FILTER_STRING_KEY, m_NetNameFilter->GetValue() );
}
}
......
......@@ -174,7 +174,7 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
return;
}
wxString msg = _( "Delete Layer " ) + ReturnPcbLayerName( layer );
wxString msg = _( "Delete Layer " ) + m_Pcb->GetLayerName( layer );
if( !IsOK( this, msg ) )
return;
......
......@@ -127,26 +127,9 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( bool query )
}
}
/* Suppression des listes chainees */
m_Pcb->m_Equipots->DeleteStructList();
m_Pcb->m_Equipots = NULL;
m_Pcb->m_Drawings->DeleteStructList();
m_Pcb->m_Drawings = NULL;
m_Pcb->m_Modules->DeleteStructList();
m_Pcb->m_Modules = NULL;
m_Pcb->m_Track->DeleteStructList();
m_Pcb->m_Track = NULL;
m_Pcb->m_NbSegmTrack = 0;
m_Pcb->m_Zone->DeleteStructList();
m_Pcb->m_Zone = NULL;
m_Pcb->m_NbSegmZone = 0;
m_Pcb->DeleteMARKERs();
m_Pcb->DeleteZONEOutlines();
// delete the old BOARD and create a new BOARD so that the default
// layer names are put into the BOARD.
SetBOARD( new BOARD( NULL, this ) );
for( ; g_UnDeleteStackPtr != 0; )
{
......@@ -159,30 +142,6 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( bool query )
memset( buf_work, 0, BUFMEMSIZE );
adr_lowmem = adr_max = buf_work;
if( m_Pcb->m_Pads )
{
MyFree( m_Pcb->m_Pads );
m_Pcb->m_Pads = NULL;
}
if( m_Pcb->m_Ratsnest )
MyFree( m_Pcb->m_Ratsnest );
if( m_Pcb->m_LocalRatsnest )
MyFree( m_Pcb->m_LocalRatsnest );
m_Pcb->m_Ratsnest = NULL;
m_Pcb->m_LocalRatsnest = NULL;
/* remise a 0 ou a une valeur initiale des variables de la structure */
m_Pcb->m_BoundaryBox.SetOrigin( wxPoint( 0, 0 ) );
m_Pcb->m_BoundaryBox.SetSize( wxSize( 0, 0 ) );
m_Pcb->m_Status_Pcb = 0;
m_Pcb->m_NbLoclinks = 0;
m_Pcb->m_NbLinks = 0;
m_Pcb->m_NbPads = 0;
m_Pcb->m_NbNets = 0;
m_Pcb->m_NbNodes = 0;
m_Pcb->m_NbNoconnect = 0;
m_Pcb->m_NbSegmTrack = 0;
m_Pcb->m_NbSegmZone = 0;
SetCurItem( NULL );
/* Init parametres de gestion */
......
......@@ -308,11 +308,25 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
if( strncmp( Line, "Layer[", LAYERKEYZ ) == 0 )
{
const char* cp = Line + LAYERKEYZ;
// parse:
// Layer[n] "a Layer name" <LAYER_T>
char* cp = Line + LAYERKEYZ;
int layer = atoi(cp);
if( data )
{
wxString layerName = CONV_FROM_UTF8( data );
m_Pcb->SetLayerName( layer, layerName );
data = strtok( NULL, " " );
if( data )
{
LAYER_T type = LAYER::ParseType( data );
m_Pcb->SetLayerType( layer, type );
}
}
continue;
}
......@@ -500,13 +514,9 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
#ifdef PCBNEW
/***************************************************************/
static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame
#if defined(DEBUG)
, BOARD* aBoard
#endif
)
/***************************************************************/
/******************************************************************************/
static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
/******************************************************************************/
{
char text[1024];
int ii, jj;
......@@ -533,18 +543,14 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame
fprintf( aFile, "ZoneGridSize %d\n", g_GridRoutingSize );
#if defined(DEBUG)
fprintf( aFile, "Layers %d\n", aBoard->GetCopperLayerCount() );
for( int layer=0; layer<aBoard->GetCopperLayerCount(); ++layer )
{
fprintf( aFile, "Layer[%d] %s\n", layer, CONV_TO_UTF8( aBoard->GetLayerName(layer) ) );
fprintf( aFile, "Layer[%d] %s %s\n", layer,
CONV_TO_UTF8( aBoard->GetLayerName(layer) ),
LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
}
#else
fprintf( aFile, "Layers %d\n", g_DesignSettings.m_CopperLayerCount );
#endif
fprintf( aFile, "TrackWidth %d\n", g_DesignSettings.m_CurrentTrackWidth );
for( ii = 0; ii < HISTORY_NUMBER; ii++ )
{
......@@ -1057,11 +1063,7 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile )
WriteGeneralDescrPcb( aFile );
WriteSheetDescr( m_CurrentScreen, aFile );
WriteSetup( aFile, this
#if defined(DEBUG)
, m_Pcb
#endif
);
WriteSetup( aFile, this, m_Pcb );
rc = m_Pcb->Save( aFile );
......
......@@ -27,55 +27,6 @@ wxPoint inline RefPos( int typeloc )
}
/*************************************************************/
MODULE* ReturnModule( BOARD* pcb, const wxString& reference )
/*************************************************************/
/*
* Recherche d'un module par sa reference
* Retourne:
* un pointeur sur le module
* Null si pas localis�
*/
{
MODULE* Module = pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{
if( reference.CmpNoCase( Module->m_Reference->m_Text ) == 0 )
return Module;
}
return NULL;
}
/********************************************************/
D_PAD* ReturnPad( MODULE* module, const wxString& name )
/********************************************************/
/* Recherche d'un pad par son nom, pour le module Module
*/
{
D_PAD* pt_pad;
wxString buf;
if( module == NULL )
return NULL;
pt_pad = module->m_Pads;
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{
pt_pad->ReturnStringPadName( buf );
if( buf.CmpNoCase( name ) == 0 )
return pt_pad;
}
return NULL;
}
/*******************************************************************/
TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer )
/*******************************************************************/
......
......@@ -201,6 +201,8 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent,
m_drc = new DRC( this ); // these 2 objects point to each other
SetBOARD( new BOARD( NULL, this ) );
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
m_DisplayPadFill = DisplayOpt.DisplayPadFill;
m_DisplayPadNum = DisplayOpt.DisplayPadNum;
......@@ -247,6 +249,7 @@ WinEDA_PcbFrame::~WinEDA_PcbFrame()
m_Parent->m_PcbFrame = NULL;
m_CurrentScreen = ScreenPcb;
delete m_drc;
delete m_Pcb;
}
......
......@@ -75,7 +75,6 @@ bool WinEDA_App::OnInit()
wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
m_PcbFrame->SetTitle( Title );
ActiveScreen = ScreenPcb;
m_PcbFrame->m_Pcb = new BOARD( NULL, m_PcbFrame );
SetTopWindow( m_PcbFrame );
m_PcbFrame->Show( TRUE );
......
/***********************/
/* fichier pcbplot.cpp */
/***********************/
/***********************/
/* fichier pcbplot.cpp */
/***********************/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -17,9 +17,9 @@
#define PLOT_DEFAULT_MARGE 300 // mils
/* Keywords to r/w options in config */
#define EDGELAYER_GERBER_OPT_KEY wxT("EdgeLayerGerberOpt")
#define PLOT_XFINESCALE_ADJ_KEY wxT("PlotXFineScaleAdj")
#define PLOT_YFINESCALE_ADJ_KEY wxT("PlotYFineScaleAdj")
#define EDGELAYER_GERBER_OPT_KEY wxT( "EdgeLayerGerberOpt" )
#define PLOT_XFINESCALE_ADJ_KEY wxT( "PlotXFineScaleAdj" )
#define PLOT_YFINESCALE_ADJ_KEY wxT( "PlotYFineScaleAdj" )
// variables locale :
static long s_SelectedLayers = CUIVRE_LAYER | CMP_LAYER |
......@@ -28,8 +28,7 @@ static bool s_PlotOriginIsAuxAxis = FALSE;
// Routines Locales
enum id_plotps
{
enum id_plotps {
ID_CLOSE_PLOT = 8020,
ID_DRILL_SHAPE_OPT,
ID_SCALE_OPT,
......@@ -54,61 +53,62 @@ enum id_plotps
};
/*******************************/
/* Dialog box for plot control */
/*******************************/
/*******************************/
/* Dialog box for plot control */
/*******************************/
class WinEDA_PlotFrame: public wxDialog
class WinEDA_PlotFrame : public wxDialog
{
public:
WinEDA_BasePcbFrame * m_Parent;
wxButton * m_MergePlotButton;
wxCheckBox * m_BoxSelecLayer[32];
wxRadioBox * m_PlotFormatOpt;
wxRadioBox * m_Choice_Plot_Offset;
wxRadioBox * m_Drill_Shape_Opt;
wxRadioBox * m_Scale_Opt;
wxRadioBox * m_PlotModeOpt;
wxCheckBox * m_PlotMirorOpt;
wxCheckBox * m_PlotNoViaOnMaskOpt;
wxCheckBox * m_HPGL_PlotCenter_Opt;
wxCheckBox * m_Exclude_Edges_Pcb;
wxCheckBox * m_Plot_Sheet_Ref;
wxCheckBox * m_Plot_Invisible_Text;
wxCheckBox * m_Plot_Text_Value;
wxCheckBox * m_Plot_Text_Ref;
wxCheckBox * m_Plot_Text_Div;
wxCheckBox * m_Plot_Pads_on_Silkscreen;
wxCheckBox * m_Force_Plot_Pads;
wxCheckBox * m_Plot_PS_Negative;
WinEDA_ValueCtrl * m_GerbSpotSizeMinOpt;
WinEDA_ValueCtrl * m_LinesWidth;
WinEDA_ValueCtrl * m_HPGLPenSizeOpt;
WinEDA_ValueCtrl * m_HPGLPenSpeedOpt;
WinEDA_ValueCtrl * m_HPGLPenOverlayOpt;
WinEDA_DFloatValueCtrl * m_FineAdjustXscaleOpt, * m_FineAdjustYscaleOpt;
WinEDA_BasePcbFrame* m_Parent;
wxButton* m_MergePlotButton;
wxCheckBox* m_BoxSelecLayer[32];
wxRadioBox* m_PlotFormatOpt;
wxRadioBox* m_Choice_Plot_Offset;
wxRadioBox* m_Drill_Shape_Opt;
wxRadioBox* m_Scale_Opt;
wxRadioBox* m_PlotModeOpt;
wxCheckBox* m_PlotMirorOpt;
wxCheckBox* m_PlotNoViaOnMaskOpt;
wxCheckBox* m_HPGL_PlotCenter_Opt;
wxCheckBox* m_Exclude_Edges_Pcb;
wxCheckBox* m_Plot_Sheet_Ref;
wxCheckBox* m_Plot_Invisible_Text;
wxCheckBox* m_Plot_Text_Value;
wxCheckBox* m_Plot_Text_Ref;
wxCheckBox* m_Plot_Text_Div;
wxCheckBox* m_Plot_Pads_on_Silkscreen;
wxCheckBox* m_Force_Plot_Pads;
wxCheckBox* m_Plot_PS_Negative;
WinEDA_ValueCtrl* m_GerbSpotSizeMinOpt;
WinEDA_ValueCtrl* m_LinesWidth;
WinEDA_ValueCtrl* m_HPGLPenSizeOpt;
WinEDA_ValueCtrl* m_HPGLPenSpeedOpt;
WinEDA_ValueCtrl* m_HPGLPenOverlayOpt;
WinEDA_DFloatValueCtrl* m_FineAdjustXscaleOpt, * m_FineAdjustYscaleOpt;
double m_XScaleAdjust, m_YScaleAdjust;
int m_PlotFormat;
public:
WinEDA_PlotFrame(WinEDA_BasePcbFrame * parent);
WinEDA_PlotFrame( WinEDA_BasePcbFrame * parent );
private:
void Plot(wxCommandEvent & event);
void OnQuit(wxCommandEvent & event);
void OnClose(wxCloseEvent & event);
void SetCommands(wxCommandEvent & event);
void SaveOptPlot(wxCommandEvent & event);
void CreateDrillFile(wxCommandEvent & event);
void Plot( wxCommandEvent& event );
void OnQuit( wxCommandEvent& event );
void OnClose( wxCloseEvent& event );
void SetCommands( wxCommandEvent& event );
void SaveOptPlot( wxCommandEvent& event );
void CreateDrillFile( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(WinEDA_PlotFrame, wxDialog)
EVT_CLOSE(WinEDA_PlotFrame::OnClose)
EVT_BUTTON(ID_CLOSE_PLOT, WinEDA_PlotFrame::OnQuit)
EVT_BUTTON(ID_EXEC_PLOT, WinEDA_PlotFrame::Plot)
EVT_BUTTON(ID_SAVE_OPT_PLOT, WinEDA_PlotFrame::SaveOptPlot)
EVT_BUTTON(ID_CREATE_DRILL_FILE, WinEDA_PlotFrame::CreateDrillFile)
EVT_RADIOBOX(ID_SEL_PLOT_FORMAT, WinEDA_PlotFrame::SetCommands)
BEGIN_EVENT_TABLE( WinEDA_PlotFrame, wxDialog )
EVT_CLOSE( WinEDA_PlotFrame::OnClose )
EVT_BUTTON( ID_CLOSE_PLOT, WinEDA_PlotFrame::OnQuit )
EVT_BUTTON( ID_EXEC_PLOT, WinEDA_PlotFrame::Plot )
EVT_BUTTON( ID_SAVE_OPT_PLOT, WinEDA_PlotFrame::SaveOptPlot )
EVT_BUTTON( ID_CREATE_DRILL_FILE, WinEDA_PlotFrame::CreateDrillFile )
EVT_RADIOBOX( ID_SEL_PLOT_FORMAT, WinEDA_PlotFrame::SetCommands )
END_EVENT_TABLE()
......@@ -116,48 +116,63 @@ const int UNITS_MILS = 1000;
/********************************************************************/
WinEDA_PlotFrame::WinEDA_PlotFrame(WinEDA_BasePcbFrame * parent):
wxDialog(parent, -1, _("Plot"),
wxPoint(-1,-1), wxDefaultSize,
wxDEFAULT_DIALOG_STYLE)
WinEDA_PlotFrame::WinEDA_PlotFrame( WinEDA_BasePcbFrame* parent ) :
wxDialog( parent, -1, _( "Plot" ),
wxPoint( -1, -1 ), wxDefaultSize,
wxDEFAULT_DIALOG_STYLE )
/********************************************************************/
{
wxButton * Button;
int ii;
wxButton* Button;
int ii;
m_Parent = parent;
SetFont(*g_DialogFont);
BOARD* board = parent->m_Pcb;
SetFont( *g_DialogFont );
Centre();
m_PlotFormat = format_plot;
m_Plot_Sheet_Ref = NULL;
wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
SetSizer(MainBoxSizer);
wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * MidRightBoxSizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * MidLeftBoxSizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL);
MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5);
MainBoxSizer->Add(MidLeftBoxSizer, 0, wxGROW|wxALL, 5);
MainBoxSizer->Add(MidRightBoxSizer, 0, wxGROW|wxALL, 5);
MainBoxSizer->Add(RightBoxSizer, 0, wxGROW|wxALL, 5);
wxBoxSizer * LayersBoxSizer = new wxBoxSizer(wxHORIZONTAL);
LeftBoxSizer->Add(LayersBoxSizer, 0, wxGROW|wxALL, 5);
wxString fmtmsg[4] = { wxT("HPGL"), wxT("Gerber"), wxT("Postscript"), wxT("Postscript A4") };
m_PlotFormatOpt = new wxRadioBox(this, ID_SEL_PLOT_FORMAT,
_("Plot Format"), wxDefaultPosition, wxSize(-1,-1),
4, fmtmsg, 1, wxRA_SPECIFY_COLS);
MidRightBoxSizer->Add(m_PlotFormatOpt, 0, wxGROW|wxALL, 5);
switch ( m_PlotFormat )
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
SetSizer( MainBoxSizer );
wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* MidRightBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* MidLeftBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add( MidLeftBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add( MidRightBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add( RightBoxSizer, 0, wxGROW | wxALL, 5 );
wxBoxSizer* LayersBoxSizer = new wxBoxSizer( wxHORIZONTAL );
LeftBoxSizer->Add( LayersBoxSizer, 0, wxGROW | wxALL, 5 );
static const wxString fmtmsg[4] = {
wxT( "HPGL" ), wxT( "Gerber" ), wxT( "Postscript" ), wxT( "Postscript A4" )
};
m_PlotFormatOpt = new wxRadioBox( this, ID_SEL_PLOT_FORMAT,
_( "Plot Format" ), wxDefaultPosition, wxSize( -1, -1 ),
4, fmtmsg, 1, wxRA_SPECIFY_COLS );
MidRightBoxSizer->Add( m_PlotFormatOpt, 0, wxGROW | wxALL, 5 );
switch( m_PlotFormat )
{
case PLOT_FORMAT_HPGL:
m_PlotFormatOpt->SetSelection(0);
m_PlotFormatOpt->SetSelection( 0 );
break;
case PLOT_FORMAT_GERBER:
m_PlotFormatOpt->SetSelection(1);
m_PlotFormatOpt->SetSelection( 1 );
break;
default: // ( PLOT_FORMAT_POST or PLOT_FORMAT_POST_A4 )
......@@ -166,250 +181,295 @@ wxString fmtmsg[4] = { wxT("HPGL"), wxT("Gerber"), wxT("Postscript"), wxT("Posts
// "Postscript" or "Postscipt A4" radiobutton had been selected
// previously (and thus which button should be reselected now).
if( g_ForcePlotPS_On_A4 )
m_PlotFormatOpt->SetSelection(3);
m_PlotFormatOpt->SetSelection( 3 );
else
m_PlotFormatOpt->SetSelection(2);
m_PlotFormatOpt->SetSelection( 2 );
break;
}
// Creation des menus d'option du format GERBER
m_GerbSpotSizeMinOpt = new WinEDA_ValueCtrl(this, _("Spot min"),
spot_mini, g_UnitMetric, MidRightBoxSizer, UNITS_MILS);
m_GerbSpotSizeMinOpt = new WinEDA_ValueCtrl( this, _( "Spot min" ),
spot_mini, g_UnitMetric, MidRightBoxSizer,
UNITS_MILS );
// Creation des menus d'option du format HPGL
m_HPGLPenSizeOpt = new WinEDA_ValueCtrl(this, _("Pen Size"),
g_HPGL_Pen_Diam, g_UnitMetric, MidRightBoxSizer, UNITS_MILS);
m_HPGLPenSizeOpt = new WinEDA_ValueCtrl( this, _( "Pen Size" ),
g_HPGL_Pen_Diam, g_UnitMetric, MidRightBoxSizer,
UNITS_MILS );
// unites standards = cm pour vitesse plume en HPGL
m_HPGLPenSpeedOpt = new WinEDA_ValueCtrl(this, _("Pen Speed (cm/s)"),
g_HPGL_Pen_Speed, CENTIMETRE, MidRightBoxSizer, 1);
m_HPGLPenSpeedOpt->SetToolTip(_("Set pen speed in cm/s"));
m_HPGLPenSpeedOpt = new WinEDA_ValueCtrl( this, _( "Pen Speed (cm/s)" ),
g_HPGL_Pen_Speed, CENTIMETRE, MidRightBoxSizer,
1 );
m_HPGLPenSpeedOpt->SetToolTip( _( "Set pen speed in cm/s" ) );
m_HPGLPenOverlayOpt = new WinEDA_ValueCtrl( this, _( "Pen Ovr" ),
g_HPGL_Pen_Recouvrement, g_UnitMetric,
MidRightBoxSizer, UNITS_MILS );
m_HPGLPenOverlayOpt->SetToolTip( _( "Set plot overlay for filling" ) );
m_HPGLPenOverlayOpt = new WinEDA_ValueCtrl(this, _("Pen Ovr"),
g_HPGL_Pen_Recouvrement, g_UnitMetric, MidRightBoxSizer, UNITS_MILS);
m_HPGLPenOverlayOpt->SetToolTip(_("Set plot overlay for filling"));
m_LinesWidth = new WinEDA_ValueCtrl( this, _( "Lines Width" ),
g_PlotLine_Width, g_UnitMetric, MidRightBoxSizer,
PCB_INTERNAL_UNIT );
m_LinesWidth = new WinEDA_ValueCtrl(this, _("Lines Width"),
g_PlotLine_Width, g_UnitMetric, MidRightBoxSizer, PCB_INTERNAL_UNIT);
m_LinesWidth->SetToolTip(_("Set width for lines in Line plot mode"));
m_LinesWidth->SetToolTip( _( "Set width for lines in Line plot mode" ) );
// Create the right column commands
wxString choice_plot_offset_msg[] =
{_("Absolute"), _("Auxiliary axis")};
m_Choice_Plot_Offset = new wxRadioBox(this, ID_SEL_PLOT_OFFSET_OPTION,
_("Plot Origin"),
wxDefaultPosition,wxSize(-1,-1),
2,choice_plot_offset_msg,1,wxRA_SPECIFY_COLS);
static const wxString choice_plot_offset_msg[] =
{ _( "Absolute" ), _( "Auxiliary axis" ) };
m_Choice_Plot_Offset = new wxRadioBox( this, ID_SEL_PLOT_OFFSET_OPTION,
_( "Plot Origin" ),
wxDefaultPosition, wxSize( -1, -1 ),
2, choice_plot_offset_msg, 1, wxRA_SPECIFY_COLS );
if( s_PlotOriginIsAuxAxis )
m_Choice_Plot_Offset->SetSelection(1);
RightBoxSizer->Add(m_Choice_Plot_Offset, 0, wxGROW|wxALL, 5);
m_Choice_Plot_Offset->SetSelection( 1 );
RightBoxSizer->Add( m_Choice_Plot_Offset, 0, wxGROW | wxALL, 5 );
/* Add a spacer for a better look */
RightBoxSizer->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 20);
RightBoxSizer->Add( 5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 20 );
/* Create the command buttons */
Button = new wxButton(this, ID_EXEC_PLOT, _("Plot"));
Button->SetForegroundColour(*wxRED);
RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5);
Button = new wxButton( this, ID_EXEC_PLOT, _( "Plot" ) );
Button->SetForegroundColour( *wxRED );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton( this, ID_CLOSE_PLOT, _( "Close" ) );
Button = new wxButton(this, ID_CLOSE_PLOT, _("Close"));
Button->SetForegroundColour(*wxBLUE);
RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5);
Button->SetForegroundColour( *wxBLUE );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton(this, ID_SAVE_OPT_PLOT, _("Save options"));
Button->SetForegroundColour(wxColour(0,80,0) );
RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5);
Button = new wxButton( this, ID_SAVE_OPT_PLOT, _( "Save options" ) );
Button = new wxButton(this, ID_CREATE_DRILL_FILE, _("Create Drill File"));
Button->SetForegroundColour(wxColour(0,80,80) );
RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5);
Button->SetForegroundColour( wxColour( 0, 80, 0 ) );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton( this, ID_CREATE_DRILL_FILE, _( "Create Drill File" ) );
Button->SetForegroundColour( wxColour( 0, 80, 80 ) );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
// Create scale adjust option
m_XScaleAdjust = m_YScaleAdjust = 1.0;
if( m_Parent->m_Parent->m_EDA_Config )
{
m_Parent->m_Parent->m_EDA_Config->Read( EDGELAYER_GERBER_OPT_KEY, &g_Exclude_Edges_Pcb);
m_Parent->m_Parent->m_EDA_Config->Read( PLOT_XFINESCALE_ADJ_KEY, &m_XScaleAdjust);
m_Parent->m_Parent->m_EDA_Config->Read( PLOT_XFINESCALE_ADJ_KEY, &m_YScaleAdjust);
m_Parent->m_Parent->m_EDA_Config->Read( EDGELAYER_GERBER_OPT_KEY, &g_Exclude_Edges_Pcb );
m_Parent->m_Parent->m_EDA_Config->Read( PLOT_XFINESCALE_ADJ_KEY, &m_XScaleAdjust );
m_Parent->m_Parent->m_EDA_Config->Read( PLOT_XFINESCALE_ADJ_KEY, &m_YScaleAdjust );
}
m_FineAdjustXscaleOpt = new WinEDA_DFloatValueCtrl(this, _("X Scale Adjust"), m_XScaleAdjust, RightBoxSizer);
m_FineAdjustXscaleOpt->SetToolTip(_("Set X scale adjust for exact scale plotting"));
m_FineAdjustYscaleOpt = new WinEDA_DFloatValueCtrl(this, _("Y Scale Adjust"), m_YScaleAdjust, RightBoxSizer);
m_FineAdjustYscaleOpt->SetToolTip(_("Set Y scale adjust for exact scale plotting"));
m_FineAdjustXscaleOpt = new WinEDA_DFloatValueCtrl( this, _(
"X Scale Adjust" ), m_XScaleAdjust,
RightBoxSizer );
m_FineAdjustXscaleOpt->SetToolTip( _( "Set X scale adjust for exact scale plotting" ) );
m_FineAdjustYscaleOpt = new WinEDA_DFloatValueCtrl( this, _(
"Y Scale Adjust" ), m_YScaleAdjust,
RightBoxSizer );
m_FineAdjustYscaleOpt->SetToolTip( _( "Set Y scale adjust for exact scale plotting" ) );
m_Plot_PS_Negative = new wxCheckBox(this, -1, _("Plot Negative") );
m_Plot_PS_Negative->SetValue(g_Plot_PS_Negative);
RightBoxSizer->Add(m_Plot_PS_Negative, 0, wxGROW|wxALL, 5);
m_Plot_PS_Negative = new wxCheckBox( this, -1, _( "Plot Negative" ) );
m_Plot_PS_Negative->SetValue( g_Plot_PS_Negative );
RightBoxSizer->Add( m_Plot_PS_Negative, 0, wxGROW | wxALL, 5 );
// Creation de la liste des layers
int mask = 1;
wxBoxSizer * OneColonLayerBoxSizer = new wxBoxSizer(wxVERTICAL);
LayersBoxSizer->Add(OneColonLayerBoxSizer, 0, wxGROW|wxALL, 5);
for ( ii = 0; ii < NB_LAYERS; ii++, mask <<= 1 )
wxBoxSizer* OneColonLayerBoxSizer = new wxBoxSizer( wxVERTICAL );
LayersBoxSizer->Add( OneColonLayerBoxSizer, 0, wxGROW | wxALL, 5 );
for( ii = 0; ii < NB_LAYERS; ii++, mask <<= 1 )
{
if( ii == 16 )
{
OneColonLayerBoxSizer = new wxBoxSizer(wxVERTICAL);
LayersBoxSizer->Add(OneColonLayerBoxSizer, 0, wxGROW|wxALL, 5);
OneColonLayerBoxSizer = new wxBoxSizer( wxVERTICAL );
LayersBoxSizer->Add( OneColonLayerBoxSizer, 0, wxGROW | wxALL, 5 );
}
m_BoxSelecLayer[ii] = new wxCheckBox(this, -1, ReturnPcbLayerName(ii));
m_BoxSelecLayer[ii] = new wxCheckBox( this, -1, board->GetLayerName (ii) );
if( mask & s_SelectedLayers )
m_BoxSelecLayer[ii]->SetValue(true);
OneColonLayerBoxSizer->Add(m_BoxSelecLayer[ii], 0, wxGROW|wxALL, 1);
m_BoxSelecLayer[ii]->SetValue( true );
OneColonLayerBoxSizer->Add( m_BoxSelecLayer[ii], 0, wxGROW | wxALL, 1 );
}
// Option for excluding contents of "Edges Pcb" layer
m_Exclude_Edges_Pcb = new wxCheckBox(this,
ID_EXCLUDE_EDGES_PCB, _("Exclude Edges Pcb Layer") );
m_Exclude_Edges_Pcb->SetValue(g_Exclude_Edges_Pcb);
m_Exclude_Edges_Pcb = new wxCheckBox( this,
ID_EXCLUDE_EDGES_PCB, _( "Exclude Edges Pcb Layer" ) );
m_Exclude_Edges_Pcb->SetValue( g_Exclude_Edges_Pcb );
m_Exclude_Edges_Pcb->SetToolTip(
_("Exclude contents of Edges Pcb layer from all other layers") );
LeftBoxSizer->Add(m_Exclude_Edges_Pcb, 0, wxGROW|wxALL, 1);
_( "Exclude contents of Edges Pcb layer from all other layers" ) );
LeftBoxSizer->Add( m_Exclude_Edges_Pcb, 0, wxGROW | wxALL, 1 );
// Option d'impression du cartouche:
if( m_Parent->m_Print_Sheet_Ref )
{
m_Plot_Sheet_Ref = new wxCheckBox(this, ID_PRINT_REF, _("Print Sheet Ref") );
m_Plot_Sheet_Ref->SetValue(Plot_Sheet_Ref);
LeftBoxSizer->Add(m_Plot_Sheet_Ref, 0, wxGROW|wxALL, 1);
m_Plot_Sheet_Ref = new wxCheckBox( this, ID_PRINT_REF, _( "Print Sheet Ref" ) );
m_Plot_Sheet_Ref->SetValue( Plot_Sheet_Ref );
LeftBoxSizer->Add( m_Plot_Sheet_Ref, 0, wxGROW | wxALL, 1 );
}
else
Plot_Sheet_Ref = false;
// Option d'impression des pads sur toutes les couches
m_Plot_Pads_on_Silkscreen = new wxCheckBox(this,
ID_PRINT_PAD_ON_SILKSCREEN, _("Print Pads on Silkscreen") );
m_Plot_Pads_on_Silkscreen->SetValue(PlotPadsOnSilkLayer);
m_Plot_Pads_on_Silkscreen = new wxCheckBox( this,
ID_PRINT_PAD_ON_SILKSCREEN, _(
"Print Pads on Silkscreen" ) );
m_Plot_Pads_on_Silkscreen->SetValue( PlotPadsOnSilkLayer );
m_Plot_Pads_on_Silkscreen->SetToolTip(
_("Enable/disable print/plot pads on Silkscreen layers") );
LeftBoxSizer->Add(m_Plot_Pads_on_Silkscreen, 0, wxGROW|wxALL, 1);
_( "Enable/disable print/plot pads on Silkscreen layers" ) );
LeftBoxSizer->Add( m_Plot_Pads_on_Silkscreen, 0, wxGROW | wxALL, 1 );
m_Force_Plot_Pads = new wxCheckBox(this, ID_FORCE_PRINT_PAD,
_("Always Print Pads") );
m_Force_Plot_Pads->SetValue(Plot_Pads_All_Layers);
m_Force_Plot_Pads->SetToolTip(_("Force print/plot pads on ALL layers") );
LeftBoxSizer->Add(m_Force_Plot_Pads, 0, wxGROW|wxALL, 1);
m_Force_Plot_Pads = new wxCheckBox( this, ID_FORCE_PRINT_PAD,
_( "Always Print Pads" ) );
m_Force_Plot_Pads->SetValue( Plot_Pads_All_Layers );
m_Force_Plot_Pads->SetToolTip( _( "Force print/plot pads on ALL layers" ) );
LeftBoxSizer->Add( m_Force_Plot_Pads, 0, wxGROW | wxALL, 1 );
// Options d'impression des textes modules
m_Plot_Text_Value = new wxCheckBox(this, ID_PRINT_VALUE, _("Print Module Value") );
m_Plot_Text_Value->SetValue(Sel_Texte_Valeur);
m_Plot_Text_Value = new wxCheckBox( this, ID_PRINT_VALUE, _( "Print Module Value" ) );
m_Plot_Text_Value->SetValue( Sel_Texte_Valeur );
m_Plot_Text_Value->SetToolTip(
_("Enable/disable print/plot module value on Silkscreen layers") );
LeftBoxSizer->Add(m_Plot_Text_Value, 0, wxGROW|wxALL, 1);
_( "Enable/disable print/plot module value on Silkscreen layers" ) );
LeftBoxSizer->Add( m_Plot_Text_Value, 0, wxGROW | wxALL, 1 );
m_Plot_Text_Ref = new wxCheckBox(this, ID_PRINT_REF, _("Print Module Reference"));
m_Plot_Text_Ref->SetValue(Sel_Texte_Reference);
m_Plot_Text_Ref = new wxCheckBox( this, ID_PRINT_REF, _( "Print Module Reference" ) );
m_Plot_Text_Ref->SetValue( Sel_Texte_Reference );
m_Plot_Text_Ref->SetToolTip(
_("Enable/disable print/plot module reference on Silkscreen layers") );
LeftBoxSizer->Add(m_Plot_Text_Ref, 0, wxGROW|wxALL, 1);
_( "Enable/disable print/plot module reference on Silkscreen layers" ) );
LeftBoxSizer->Add( m_Plot_Text_Ref, 0, wxGROW | wxALL, 1 );
m_Plot_Text_Div = new wxCheckBox( this, ID_PRINT_MODULE_TEXTS,
_( "Print other Module texts" ) );
m_Plot_Text_Div = new wxCheckBox(this, ID_PRINT_MODULE_TEXTS,
_("Print other Module texts") );
m_Plot_Text_Div->SetValue(Sel_Texte_Divers);
m_Plot_Text_Div->SetValue( Sel_Texte_Divers );
m_Plot_Text_Div->SetToolTip(
_("Enable/disable print/plot module field texts on Silkscreen layers") );
LeftBoxSizer->Add(m_Plot_Text_Div, 0, wxGROW|wxALL, 1);
_( "Enable/disable print/plot module field texts on Silkscreen layers" ) );
LeftBoxSizer->Add( m_Plot_Text_Div, 0, wxGROW | wxALL, 1 );
m_Plot_Invisible_Text = new wxCheckBox(this,
ID_FORCE_PRINT_INVISIBLE_TEXT, _("Force Print Invisible Texts") );
m_Plot_Invisible_Text->SetValue(Sel_Texte_Invisible);
m_Plot_Invisible_Text = new wxCheckBox( this,
ID_FORCE_PRINT_INVISIBLE_TEXT, _(
"Force Print Invisible Texts" ) );
m_Plot_Invisible_Text->SetValue( Sel_Texte_Invisible );
m_Plot_Invisible_Text->SetToolTip(
_("Force print/plot module invisible texts on Silkscreen layers") );
LeftBoxSizer->Add(m_Plot_Invisible_Text, 0, wxGROW|wxALL, 1);
wxString drillmsg[3] = { _("No Drill mark"), _("Small mark"), _("Real Drill") };
m_Drill_Shape_Opt = new wxRadioBox(this, ID_DRILL_SHAPE_OPT,
_("Pads Drill Opt"), wxDefaultPosition, wxSize(-1,-1),
3, drillmsg, 1, wxRA_SPECIFY_COLS);
m_Drill_Shape_Opt->SetSelection(g_DrillShapeOpt);
MidLeftBoxSizer->Add(m_Drill_Shape_Opt, 0, wxGROW|wxALL, 5);
wxString scalemsg[5] =
{ _("Auto scale"), _("Scale 1"), _("Scale 1.5"), _("Scale 2"), _("Scale 3") };
m_Scale_Opt = new wxRadioBox(this, ID_SCALE_OPT,
_("Scale Opt"), wxDefaultPosition, wxSize(-1,-1),
5, scalemsg, 1, wxRA_SPECIFY_COLS);
m_Scale_Opt->SetSelection(g_PlotScaleOpt);
MidLeftBoxSizer->Add(m_Scale_Opt, 0, wxGROW|wxALL, 5);
wxString list_opt3[3] = {_("Line"), _("Filled"), _("Sketch") };
m_PlotModeOpt = new wxRadioBox(this, ID_PLOT_MODE_OPT, _("Plot Mode"),
_( "Force print/plot module invisible texts on Silkscreen layers" ) );
LeftBoxSizer->Add( m_Plot_Invisible_Text, 0, wxGROW | wxALL, 1 );
static const wxString drillmsg[3] = { _( "No Drill mark" ), _( "Small mark" ), _( "Real Drill" ) };
m_Drill_Shape_Opt = new wxRadioBox( this, ID_DRILL_SHAPE_OPT,
_( "Pads Drill Opt" ), wxDefaultPosition, wxSize( -1, -1 ),
3, drillmsg, 1, wxRA_SPECIFY_COLS );
m_Drill_Shape_Opt->SetSelection( g_DrillShapeOpt );
MidLeftBoxSizer->Add( m_Drill_Shape_Opt, 0, wxGROW | wxALL, 5 );
static const wxString scalemsg[5] =
{ _( "Auto scale" ), _( "Scale 1" ), _( "Scale 1.5" ), _( "Scale 2" ), _( "Scale 3" ) };
m_Scale_Opt = new wxRadioBox( this, ID_SCALE_OPT,
_( "Scale Opt" ), wxDefaultPosition, wxSize( -1, -1 ),
5, scalemsg, 1, wxRA_SPECIFY_COLS );
m_Scale_Opt->SetSelection( g_PlotScaleOpt );
MidLeftBoxSizer->Add( m_Scale_Opt, 0, wxGROW | wxALL, 5 );
static const wxString list_opt3[3] = { _( "Line" ), _( "Filled" ), _( "Sketch" ) };
m_PlotModeOpt = new wxRadioBox( this, ID_PLOT_MODE_OPT, _( "Plot Mode" ),
wxDefaultPosition, wxDefaultSize,
3, list_opt3, 1);
m_PlotModeOpt->SetSelection(Plot_Mode);
MidLeftBoxSizer->Add(m_PlotModeOpt, 0, wxGROW|wxALL, 5);
m_PlotMirorOpt = new wxCheckBox(this, ID_MIROR_OPT,
_("Plot Mirror"));
m_PlotMirorOpt->SetValue(Plot_Set_MIROIR);
MidLeftBoxSizer->Add(m_PlotMirorOpt, 0, wxGROW|wxALL, 5);
m_PlotNoViaOnMaskOpt = new wxCheckBox(this, ID_MASKVIA_OPT,
_("Vias on Mask"));
m_PlotNoViaOnMaskOpt->SetValue(g_DrawViaOnMaskLayer);
3, list_opt3, 1 );
m_PlotModeOpt->SetSelection( Plot_Mode );
MidLeftBoxSizer->Add( m_PlotModeOpt, 0, wxGROW | wxALL, 5 );
m_PlotMirorOpt = new wxCheckBox( this, ID_MIROR_OPT,
_( "Plot Mirror" ) );
m_PlotMirorOpt->SetValue( Plot_Set_MIROIR );
MidLeftBoxSizer->Add( m_PlotMirorOpt, 0, wxGROW | wxALL, 5 );
m_PlotNoViaOnMaskOpt = new wxCheckBox( this, ID_MASKVIA_OPT,
_( "Vias on Mask" ) );
m_PlotNoViaOnMaskOpt->SetValue( g_DrawViaOnMaskLayer );
m_PlotNoViaOnMaskOpt->SetToolTip(
_("Print/plot vias on mask layers. They are in this case not protected") );
MidLeftBoxSizer->Add(m_PlotNoViaOnMaskOpt, 0, wxGROW|wxALL, 5);
m_HPGL_PlotCenter_Opt = new wxCheckBox(this, ID_PLOT_CENTRE_OPT,
_("Org = Centre"));
m_HPGL_PlotCenter_Opt->SetValue(HPGL_Org_Centre);
m_HPGL_PlotCenter_Opt->SetToolTip(_("Draw origin ( 0,0 ) in sheet center") );
MidLeftBoxSizer->Add(m_HPGL_PlotCenter_Opt, 0, wxGROW|wxALL, 5);
_( "Print/plot vias on mask layers. They are in this case not protected" ) );
MidLeftBoxSizer->Add( m_PlotNoViaOnMaskOpt, 0, wxGROW | wxALL, 5 );
m_HPGL_PlotCenter_Opt = new wxCheckBox( this, ID_PLOT_CENTRE_OPT,
_( "Org = Centre" ) );
m_HPGL_PlotCenter_Opt->SetValue( HPGL_Org_Centre );
m_HPGL_PlotCenter_Opt->SetToolTip( _( "Draw origin ( 0,0 ) in sheet center" ) );
MidLeftBoxSizer->Add( m_HPGL_PlotCenter_Opt, 0, wxGROW | wxALL, 5 );
// Mise a jour des activations des menus:
wxCommandEvent event;
SetCommands(event);
wxCommandEvent event;
SetCommands( event );
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
}
/***************************************************************/
void WinEDA_PlotFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
void WinEDA_PlotFrame::OnQuit( wxCommandEvent& WXUNUSED (event) )
/***************************************************************/
/* Called by the close button
*/
{
Close(true); // true is to force the frame to close
Close( true ); // true is to force the frame to close
}
/****************************************************/
void WinEDA_PlotFrame::OnClose(wxCloseEvent & event)
void WinEDA_PlotFrame::OnClose( wxCloseEvent& event )
/****************************************************/
/* Called when WinEDA_PlotFrame is closed
*/
{
EndModal(0);
EndModal( 0 );
}
/*********************************************************/
void WinEDA_PlotFrame::CreateDrillFile(wxCommandEvent & event)
void WinEDA_PlotFrame::CreateDrillFile( wxCommandEvent& event )
/*********************************************************/
/* Create the board drill file used with gerber documents
*/
{
((WinEDA_PcbFrame * )m_Parent)->InstallDrillFrame(event);
( (WinEDA_PcbFrame*) m_Parent )->InstallDrillFrame( event );
}
/*********************************************************/
void WinEDA_PlotFrame::SetCommands(wxCommandEvent & event)
void WinEDA_PlotFrame::SetCommands( wxCommandEvent& event )
/*********************************************************/
/* active ou dsactive les diffrents menus d'option selon le standard choisi
*/
{
int format;
int format_list[] =
{PLOT_FORMAT_HPGL, PLOT_FORMAT_GERBER, PLOT_FORMAT_POST, PLOT_FORMAT_POST_A4
int format;
static const int format_list[] = {
PLOT_FORMAT_HPGL, PLOT_FORMAT_GERBER,
PLOT_FORMAT_POST, PLOT_FORMAT_POST_A4
};
format = format_list[m_PlotFormatOpt->GetSelection()];
......@@ -419,72 +479,73 @@ int format_list[] =
case PLOT_FORMAT_POST_A4:
case PLOT_FORMAT_POST:
default:
m_Drill_Shape_Opt->Enable(true);
m_PlotModeOpt->Enable(true);
m_PlotMirorOpt->Enable(true);
m_GerbSpotSizeMinOpt->Enable(false);
m_Choice_Plot_Offset->Enable(false);
m_LinesWidth->Enable(true);
m_HPGLPenSizeOpt->Enable(false);
m_HPGLPenSpeedOpt->Enable(false);
m_HPGLPenOverlayOpt->Enable(false);
m_HPGL_PlotCenter_Opt->Enable(false);
m_Exclude_Edges_Pcb->Enable(false);
m_Plot_Sheet_Ref->Enable(true);
m_Scale_Opt->Enable(true);
m_FineAdjustXscaleOpt->Enable(true);
m_FineAdjustYscaleOpt->Enable(true);
m_Drill_Shape_Opt->Enable( true );
m_PlotModeOpt->Enable( true );
m_PlotMirorOpt->Enable( true );
m_GerbSpotSizeMinOpt->Enable( false );
m_Choice_Plot_Offset->Enable( false );
m_LinesWidth->Enable( true );
m_HPGLPenSizeOpt->Enable( false );
m_HPGLPenSpeedOpt->Enable( false );
m_HPGLPenOverlayOpt->Enable( false );
m_HPGL_PlotCenter_Opt->Enable( false );
m_Exclude_Edges_Pcb->Enable( false );
m_Plot_Sheet_Ref->Enable( true );
m_Scale_Opt->Enable( true );
m_FineAdjustXscaleOpt->Enable( true );
m_FineAdjustYscaleOpt->Enable( true );
m_PlotFormat = PLOT_FORMAT_POST;
g_ForcePlotPS_On_A4 = (format == PLOT_FORMAT_POST_A4);
m_Plot_PS_Negative->Enable(true);
m_Plot_PS_Negative->Enable( true );
break;
case PLOT_FORMAT_GERBER:
m_Drill_Shape_Opt->Enable(false);
m_PlotModeOpt->Enable(false);
m_PlotMirorOpt->Enable(false);
m_GerbSpotSizeMinOpt->Enable(true);
m_Choice_Plot_Offset->Enable(true);
m_LinesWidth->Enable(true);
m_HPGLPenSizeOpt->Enable(false);
m_HPGLPenSpeedOpt->Enable(false);
m_HPGLPenOverlayOpt->Enable(false);
m_HPGL_PlotCenter_Opt->Enable(false);
m_Exclude_Edges_Pcb->Enable(true);
m_Plot_Sheet_Ref->Enable(false);
m_Scale_Opt->Enable(false);
m_FineAdjustXscaleOpt->Enable(false);
m_FineAdjustYscaleOpt->Enable(false);
m_Drill_Shape_Opt->Enable( false );
m_PlotModeOpt->Enable( false );
m_PlotMirorOpt->Enable( false );
m_GerbSpotSizeMinOpt->Enable( true );
m_Choice_Plot_Offset->Enable( true );
m_LinesWidth->Enable( true );
m_HPGLPenSizeOpt->Enable( false );
m_HPGLPenSpeedOpt->Enable( false );
m_HPGLPenOverlayOpt->Enable( false );
m_HPGL_PlotCenter_Opt->Enable( false );
m_Exclude_Edges_Pcb->Enable( true );
m_Plot_Sheet_Ref->Enable( false );
m_Scale_Opt->Enable( false );
m_FineAdjustXscaleOpt->Enable( false );
m_FineAdjustYscaleOpt->Enable( false );
m_PlotFormat = PLOT_FORMAT_GERBER;
m_Plot_PS_Negative->Enable(false);
m_Plot_PS_Negative->Enable( false );
break;
case PLOT_FORMAT_HPGL:
m_PlotMirorOpt->Enable(true);
m_Drill_Shape_Opt->Enable(false);
m_PlotModeOpt->Enable(true);
m_GerbSpotSizeMinOpt->Enable(false);
m_Choice_Plot_Offset->Enable(false);
m_LinesWidth->Enable(false);
m_HPGLPenSizeOpt->Enable(true);
m_HPGLPenSpeedOpt->Enable(true);
m_HPGLPenOverlayOpt->Enable(true);
m_HPGL_PlotCenter_Opt->Enable(true);
m_Exclude_Edges_Pcb->Enable(false);
m_Plot_Sheet_Ref->Enable(true);
m_Scale_Opt->Enable(true);
m_FineAdjustXscaleOpt->Enable(false);
m_FineAdjustYscaleOpt->Enable(false);
m_PlotMirorOpt->Enable( true );
m_Drill_Shape_Opt->Enable( false );
m_PlotModeOpt->Enable( true );
m_GerbSpotSizeMinOpt->Enable( false );
m_Choice_Plot_Offset->Enable( false );
m_LinesWidth->Enable( false );
m_HPGLPenSizeOpt->Enable( true );
m_HPGLPenSpeedOpt->Enable( true );
m_HPGLPenOverlayOpt->Enable( true );
m_HPGL_PlotCenter_Opt->Enable( true );
m_Exclude_Edges_Pcb->Enable( false );
m_Plot_Sheet_Ref->Enable( true );
m_Scale_Opt->Enable( true );
m_FineAdjustXscaleOpt->Enable( false );
m_FineAdjustYscaleOpt->Enable( false );
m_PlotFormat = PLOT_FORMAT_HPGL;
m_Plot_PS_Negative->Enable(false);
m_Plot_PS_Negative->Enable( false );
break;
}
format_plot = m_PlotFormat;
}
/*********************************************************/
void WinEDA_PlotFrame::SaveOptPlot(wxCommandEvent & event)
void WinEDA_PlotFrame::SaveOptPlot( wxCommandEvent& event )
/*********************************************************/
{
g_Exclude_Edges_Pcb = m_Exclude_Edges_Pcb->GetValue();
......@@ -523,9 +584,9 @@ void WinEDA_PlotFrame::SaveOptPlot(wxCommandEvent & event)
if( m_Parent->m_Parent->m_EDA_Config )
{
m_Parent->m_Parent->m_EDA_Config->Write( EDGELAYER_GERBER_OPT_KEY, g_Exclude_Edges_Pcb);
m_Parent->m_Parent->m_EDA_Config->Write( PLOT_XFINESCALE_ADJ_KEY, m_XScaleAdjust);
m_Parent->m_Parent->m_EDA_Config->Write( PLOT_YFINESCALE_ADJ_KEY, m_YScaleAdjust);
m_Parent->m_Parent->m_EDA_Config->Write( EDGELAYER_GERBER_OPT_KEY, g_Exclude_Edges_Pcb );
m_Parent->m_Parent->m_EDA_Config->Write( PLOT_XFINESCALE_ADJ_KEY, m_XScaleAdjust );
m_Parent->m_Parent->m_EDA_Config->Write( PLOT_YFINESCALE_ADJ_KEY, m_YScaleAdjust );
}
g_Plot_PS_Negative = m_Plot_PS_Negative->GetValue();
......@@ -533,14 +594,16 @@ void WinEDA_PlotFrame::SaveOptPlot(wxCommandEvent & event)
/***************************************************/
void WinEDA_PlotFrame::Plot(wxCommandEvent & event)
void WinEDA_PlotFrame::Plot( wxCommandEvent& event )
/***************************************************/
{
int layer_to_plot;
wxString FullFileName, BaseFileName;
wxString ext;
int layer_to_plot;
wxString FullFileName, BaseFileName;
wxString ext;
SaveOptPlot(event);
BOARD* board = m_Parent->m_Pcb;
SaveOptPlot( event );
switch( g_PlotScaleOpt )
{
......@@ -565,20 +628,20 @@ wxString ext;
Scale_Y *= m_YScaleAdjust;
BaseFileName = m_Parent->GetScreen()->m_FileName;
ChangeFileNameExt( BaseFileName, wxT("-") );
ChangeFileNameExt( BaseFileName, wxT( "-" ) );
switch( m_PlotFormat)
switch( m_PlotFormat )
{
case PLOT_FORMAT_POST:
ext = wxT(".ps");
ext = wxT( ".ps" );
break;
case PLOT_FORMAT_GERBER:
ext = wxT(".pho");
ext = wxT( ".pho" );
break;
case PLOT_FORMAT_HPGL:
ext = wxT(".plt");
ext = wxT( ".plt" );
break;
}
......@@ -590,33 +653,36 @@ wxString ext;
if( m_BoxSelecLayer[layer_to_plot]->GetValue() )
{
s_SelectedLayers |= mask;
// Calcul du nom du fichier
FullFileName = BaseFileName + ReturnPcbLayerName(layer_to_plot, true) + ext;
switch ( m_PlotFormat)
FullFileName = BaseFileName + board->GetLayerName( layer_to_plot ) + ext;
switch( m_PlotFormat )
{
case PLOT_FORMAT_POST:
m_Parent->Genere_PS(FullFileName, layer_to_plot);
m_Parent->Genere_PS( FullFileName, layer_to_plot );
break;
case PLOT_FORMAT_GERBER:
m_Parent->Genere_GERBER(FullFileName, layer_to_plot, s_PlotOriginIsAuxAxis);
m_Parent->Genere_GERBER( FullFileName, layer_to_plot, s_PlotOriginIsAuxAxis );
break;
case PLOT_FORMAT_HPGL:
m_Parent->Genere_HPGL(FullFileName, layer_to_plot);
m_Parent->Genere_HPGL( FullFileName, layer_to_plot );
break;
}
}
}
// Close(true);
}
/**************************************************************/
void WinEDA_BasePcbFrame::ToPlotter(wxCommandEvent& event)
void WinEDA_BasePcbFrame::ToPlotter( wxCommandEvent& event )
/***************************************************************/
{
WinEDA_PlotFrame * frame = new WinEDA_PlotFrame(this);
WinEDA_PlotFrame* frame = new WinEDA_PlotFrame( this );
frame->ShowModal(); frame->Destroy();
}
......@@ -90,8 +90,11 @@ WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame( WinEDA_PcbFrame* p
/************************************************************************************/
{
wxButton* Button;
BOARD* board = parent->m_Pcb;
m_Parent = parent;
SetFont( *g_DialogFont );
m_DC = DC;
Centre();
......@@ -139,16 +142,17 @@ WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame( WinEDA_PcbFrame* p
wxDefaultPosition, wxDefaultSize );
MiddleBoxSizer->Add( m_SelLayerBox, 0, wxGROW | wxALL, 5 );
int ii;
for( ii = 0; ii < NB_LAYERS; ii++ )
for( int layer=0; layer<NB_LAYERS; ++layer )
{
m_SelLayerBox->Append( ReturnPcbLayerName( ii ) );
m_SelLayerBox->Append( board->GetLayerName( layer ) );
}
m_SelLayerBox->SetSelection( TextPCB->GetLayer() );
wxString orient_msg[4] = { wxT( "0" ), wxT( "90" ), wxT( "180" ), wxT( "-90" ) };
static const wxString orient_msg[4] = {
wxT( "0" ), wxT( "90" ), wxT( "180" ), wxT( "-90" ) };
m_Orient = new wxRadioBox( this, -1, _( "Orientation" ),
wxDefaultPosition, wxSize( -1, -1 ), 4, orient_msg,
1, wxRA_SPECIFY_COLS );
......
......@@ -71,12 +71,8 @@ void Trace_Pads_Only( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module, int ox,
/* LOCATE.CPP : */
/****************/
MODULE* ReturnModule( BOARD* Pcb, const wxString& name );
/* Recherche d'une empreinte par son nom */
D_PAD* ReturnPad( MODULE* Module, const wxString& name );
/* Recherche d'un pad par son nom, pour le module Module */
TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer = -1 );
......@@ -417,7 +413,7 @@ MODULE* ListAndSelectModuleName( COMMAND* Cmd );
/*****************/
/* SET_COLOR.CPP */
/*****************/
void DisplayColorSetupFrame( WinEDA_DrawFrame* parent,
void DisplayColorSetupFrame( WinEDA_PcbFrame* parent,
const wxPoint& framepos );
......
......@@ -101,6 +101,7 @@ WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent,
* to the right of that radiobox.
*/
{
BOARD* board = parent->m_Pcb;
wxButton* Button;
int ii;
wxString LayerList[NB_LAYERS + 1]; // One extra element for "(Deselect)" radiobutton
......@@ -123,7 +124,7 @@ WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent,
if( (max_layer >= 0) && (max_layer < ii) )
break;
LayerList[LayerCount] = ReturnPcbLayerName( ii );
LayerList[LayerCount] = board->GetLayerName( ii );
if( ii == default_layer )
LayerSelect = LayerCount;
......@@ -264,6 +265,7 @@ WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame( WinEDA_BasePcbFrame* parent
wxSize( 470, 250 ), DIALOG_STYLE )
/*******************************************************************************/
{
BOARD* board = parent->m_Pcb;
wxButton* Button;
int ii, LayerCount;
wxString LayerList[NB_COPPER_LAYERS];
......@@ -281,7 +283,7 @@ WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame( WinEDA_BasePcbFrame* parent
m_LayerId[ii] = 0;
if( (g_TabOneLayerMask[ii] & Masque_Layer) )
{
LayerList[LayerCount] = ReturnPcbLayerName( ii );
LayerList[LayerCount] = board->GetLayerName( ii );
if( ii == screen->m_Route_Layer_TOP )
LayerTopSelect = LayerCount;
if( ii == screen->m_Route_Layer_BOTTOM )
......
......@@ -51,7 +51,7 @@ END_EVENT_TABLE()
/*****************************************************/
void DisplayColorSetupFrame( WinEDA_DrawFrame* parent,
void DisplayColorSetupFrame( WinEDA_PcbFrame* parent,
const wxPoint& framepos )
/*****************************************************/
{
......@@ -72,7 +72,7 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame()
// Standard Constructor
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent,
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_PcbFrame* parent,
const wxPoint& framepos )
{
m_Parent = parent;
......@@ -225,7 +225,7 @@ void WinEDA_SetColorsFrame::CreateControls()
if( laytool_list[lyr]->m_Title == wxT( "*" ) )
msg = g_ViaType_Name[laytool_list[lyr]->m_LayerNumber];
else
msg = ReturnPcbLayerName( laytool_list[lyr]->m_LayerNumber );
msg = m_Parent->m_Pcb->GetLayerName( laytool_list[lyr]->m_LayerNumber );
}
else
msg = wxGetTranslation( laytool_list[lyr]->m_Title.GetData() );
......
......@@ -526,7 +526,7 @@ private:
DECLARE_DYNAMIC_CLASS( WinEDA_SetColorsFrame )
DECLARE_EVENT_TABLE()
WinEDA_DrawFrame* m_Parent;
WinEDA_PcbFrame* m_Parent;
wxBoxSizer* OuterBoxSizer;
wxBoxSizer* MainBoxSizer;
wxFlexGridSizer* FlexColumnBoxSizer;
......@@ -566,7 +566,7 @@ private:
public:
// Constructors and destructor
WinEDA_SetColorsFrame();
WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent, const wxPoint& framepos );
WinEDA_SetColorsFrame( WinEDA_PcbFrame* parent, const wxPoint& framepos );
~WinEDA_SetColorsFrame();
};
......
......@@ -826,6 +826,17 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IOError )
layer->name = layerIds[pcbNdx];
DSN_T layerType;
switch( aBoard->GetLayerType( pcbLayer2kicad[pcbNdx] ) )
{
default:
case LT_SIGNAL: layerType = T_signal; break;
case LT_POWER: layerType = T_power; break;
case LT_MIXED: layerType = T_mixed; break;
}
layer->layer_type = layerType;
layer->properties.push_back( PROPERTY() );
PROPERTY* property = &layer->properties.back();
property->name = "index";
......
......@@ -71,6 +71,8 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_BasePcbFrame* parent ) :
wxDefaultSize, wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER )
/*************************************************************************/
{
BOARD* board = parent->m_Pcb;
OuterBoxSizer = NULL;
MainBoxSizer = NULL;
FlexColumnBoxSizer = NULL;
......@@ -154,7 +156,8 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_BasePcbFrame* parent ) :
}
// Provide a text string to identify this layer (with trailing spaces within that string being purged)
label = new wxStaticText( this, wxID_STATIC, ReturnPcbLayerName( ii ).Trim(), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
label = new wxStaticText( this, wxID_STATIC, board->GetLayerName( ii ),
wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
FlexColumnBoxSizer->Add(label, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxBOTTOM, 5);
// Provide a button for this layer (which will invoke a child dialog box)
......@@ -177,11 +180,11 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_BasePcbFrame* parent ) :
// strings to be truncated after different layers are selected.)
if( ii == 0 )
{
text = new wxStaticText( this, item_ID, ReturnPcbLayerName( 0 ), wxDefaultPosition, wxDefaultSize, 0 );
text = new wxStaticText( this, item_ID, board->GetLayerName( 0 ), wxDefaultPosition, wxDefaultSize, 0 );
goodSize = text->GetSize();
for( int jj = 1; jj < NB_LAYERS; jj++ )
{
text->SetLabel( ReturnPcbLayerName( jj ) );
text->SetLabel( board->GetLayerName( jj ) );
if( goodSize.x < text->GetSize().x )
goodSize.x = text->GetSize().x;
}
......@@ -280,7 +283,7 @@ void WinEDA_SwapLayerFrame::Sel_Layer( wxCommandEvent& event )
}
else
{
layer_list[ii]->SetLabel( ReturnPcbLayerName( jj ) );
layer_list[ii]->SetLabel( m_Parent->m_Pcb->GetLayerName( jj ) );
// Change the text color to fushia (to highlight
// that this layer *is* being swapped)
layer_list[ii]->SetForegroundColour( wxColour(255, 0, 128) );
......
......@@ -691,7 +691,7 @@ WinEDAChoiceBox* WinEDA_PcbFrame::ReCreateLayerBox( WinEDA_Toolbar* parent )
if( (g_TabOneLayerMask[ii] & Masque_Layer) )
{
wxString msg = ReturnPcbLayerName( ii, false );
wxString msg = m_Pcb->GetLayerName( ii );
msg = AddHotkeyName( msg, s_Board_Editor_Hokeys_Descr, HK_SwitchLayer[ii] );
m_SelLayerBox->Append( msg );
m_SelLayerBox->SetClientData( jj, (void*) ii );
......
......@@ -55,7 +55,7 @@ extern float Scale_X, Scale_Y;
static long s_SelectedLayers = CUIVRE_LAYER | CMP_LAYER |
SILKSCREEN_LAYER_CMP | SILKSCREEN_LAYER_CU;
static double s_ScaleList[] =
{ 0, 0.5, 0.7, 0.999, 1.0, 1.4, 2.0, 3.0, 4.0 };
{ 0, 0.5, 0.7, 0.999, 1.0, 1.4, 2.0, 3.0, 4.0 };
#endif
#include "protos.h"
......@@ -70,7 +70,7 @@ static double s_ScaleList[] =
#define WIDTH_MIN_VALUE 1
// static print data and page setup data, to remember settings during the session
static wxPrintData * g_PrintData;
static wxPrintData* g_PrintData;
// Variables locales
static int s_PrintPenMinWidth = 6; /* Minimum pen width (in internal units) for printing */
......@@ -82,76 +82,82 @@ static int s_Scale_Select = 3; // default selected scale = ScaleList[3] = 1
static bool s_PrintMirror;
static bool s_Print_Sheet_Ref = TRUE;
/****************************************************************/
/* frame de Preparation de l'impression (options, selections... */
/****************************************************************/
/****************************************************************/
/* frame de Preparation de l'impression (options, selections... */
/****************************************************************/
#include "dialog_print.cpp"
/***************************/
/* Gestion de l'impression */
/***************************/
/***************************/
/* Gestion de l'impression */
/***************************/
class EDA_Printout: public wxPrintout
class EDA_Printout : public wxPrintout
{
public:
bool m_Print_Sheet_Ref;
public:
WinEDA_DrawFrame * m_Parent;
WinEDA_PrintFrame * m_PrintFrame;
EDA_Printout(WinEDA_PrintFrame * print_frame, WinEDA_DrawFrame * parent, const wxString & title, bool print_ref):
wxPrintout(title)
{
WinEDA_DrawFrame* m_Parent;
WinEDA_PrintFrame* m_PrintFrame;
EDA_Printout( WinEDA_PrintFrame * print_frame,
WinEDA_DrawFrame * parent,
const wxString &title,
bool print_ref ) :
wxPrintout( title ) {
m_PrintFrame = print_frame;
m_Parent = parent;
s_PrintMaskLayer = 0xFFFFFFFF;
m_Print_Sheet_Ref = print_ref;
}
bool OnPrintPage(int page);
bool HasPage(int page);
bool OnBeginDocument(int startPage, int endPage);
void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
bool OnPrintPage( int page );
bool HasPage( int page );
bool OnBeginDocument( int startPage, int endPage );
void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo );
void DrawPage();
};
/*******************************************************/
void WinEDA_DrawFrame::ToPrinter(wxCommandEvent& event)
void WinEDA_DrawFrame::ToPrinter( wxCommandEvent& event )
/*******************************************************/
/* Prepare les structures de donn�es de gestion de l'impression
et affiche la fenetre de dialogue de gestion de l'impression des feuilles
*/
* et affiche la fenetre de dialogue de gestion de l'impression des feuilles
*/
{
wxPoint pos = GetPosition();
bool PrinterError = FALSE;
wxPoint pos = GetPosition();
bool PrinterError = FALSE;
// Stop the pending comand (if any...)
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
{
wxClientDC dc(DrawPanel);
DrawPanel->PrepareDC(dc);
DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc);
wxClientDC dc( DrawPanel );
DrawPanel->PrepareDC( dc );
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
}
SetToolID(0, wxCURSOR_ARROW,wxEmptyString);
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
if ( g_PrintData == NULL ) // First print
if( g_PrintData == NULL ) // First print
{
g_PrintData = new wxPrintData();
if ( ! g_PrintData->Ok() )
if( !g_PrintData->Ok() )
{
PrinterError = TRUE;
DisplayError( this, _("Error Init Printer info") );
DisplayError( this, _( "Error Init Printer info" ) );
}
g_PrintData->SetQuality(wxPRINT_QUALITY_HIGH); // Default resolution = HIGHT;
g_PrintData->SetOrientation(DEFAULT_ORIENTATION_PAPER);
g_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGHT;
g_PrintData->SetOrientation( DEFAULT_ORIENTATION_PAPER );
}
pos.x += 10; pos.y += 10;
WinEDA_PrintFrame * frame = new WinEDA_PrintFrame(this);
WinEDA_PrintFrame* frame = new WinEDA_PrintFrame( this );
frame->ShowModal(); frame->Destroy();
#ifdef EESCHEMA
g_PrintFillMask = 0;
......@@ -164,220 +170,246 @@ void WinEDA_PrintFrame::SetOthersDatas()
/*******************************************/
{
#ifndef PCBNEW
m_Print_Mirror->Enable(false);
m_Print_Mirror->Enable( false );
#endif
m_FineAdjustXscaleOpt->SetToolTip(_("Set X scale adjust for exact scale plotting"));
m_FineAdjustYscaleOpt->SetToolTip(_("Set Y scale adjust for exact scale plotting"));
if ( s_Print_Black_and_White ) m_ColorOption->SetSelection(1);
m_FineAdjustXscaleOpt->SetToolTip( _( "Set X scale adjust for exact scale plotting" ) );
m_FineAdjustYscaleOpt->SetToolTip( _( "Set Y scale adjust for exact scale plotting" ) );
if( s_Print_Black_and_White )
m_ColorOption->SetSelection( 1 );
#ifdef PCBNEW
m_PagesOptionEeschema->Show(false);
m_PagesOptionEeschema->Show( false );
m_PagesOption = m_PagesOptionPcb;
/* Create layer list */
int mask = 1, ii;
for ( ii = 0; ii < NB_LAYERS; ii++, mask <<= 1 )
for( ii = 0; ii < NB_LAYERS; ii++, mask <<= 1 )
{
m_BoxSelecLayer[ii] = new wxCheckBox(this, -1,
ReturnPcbLayerName(ii));
if ( mask & s_SelectedLayers) m_BoxSelecLayer[ii]->SetValue(TRUE);
if ( ii < 16 )
m_CopperLayersBoxSizer->Add(m_BoxSelecLayer[ii],
wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE);
m_BoxSelecLayer[ii] = new wxCheckBox( this, -1,
#if defined(PCBNEW)
((WinEDA_PcbFrame*)m_Parent)->m_Pcb->GetLayerName(ii) );
#else
ReturnLayerName( ii ) );
#endif
if( mask & s_SelectedLayers )
m_BoxSelecLayer[ii]->SetValue( TRUE );
if( ii < 16 )
m_CopperLayersBoxSizer->Add( m_BoxSelecLayer[ii],
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE );
else
m_TechLayersBoxSizer->Add(m_BoxSelecLayer[ii],
wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE);
m_TechLayersBoxSizer->Add( m_BoxSelecLayer[ii],
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE );
}
// Read the scale adjust option
if ( m_Parent->m_Parent->m_EDA_Config )
if( m_Parent->m_Parent->m_EDA_Config )
{
m_Parent->m_Parent->m_EDA_Config->Read( wxT("PrintXFineScaleAdj"), &m_XScaleAdjust);
m_Parent->m_Parent->m_EDA_Config->Read( wxT("PrintYFineScaleAdj"), &m_YScaleAdjust);
m_Parent->m_Parent->m_EDA_Config->Read( wxT("PrintScale"), &s_Scale_Select);
m_Parent->m_Parent->m_EDA_Config->Read( wxT( "PrintXFineScaleAdj" ), &m_XScaleAdjust );
m_Parent->m_Parent->m_EDA_Config->Read( wxT( "PrintYFineScaleAdj" ), &m_YScaleAdjust );
m_Parent->m_Parent->m_EDA_Config->Read( wxT( "PrintScale" ), &s_Scale_Select );
}
m_ScaleOption->SetSelection(s_Scale_Select);
m_ScaleOption->SetSelection( s_Scale_Select );
// Create scale adjust option
wxString msg;
msg.Printf(wxT("%lf"), m_XScaleAdjust);
m_FineAdjustXscaleOpt->SetValue(msg);
msg.Printf(wxT("%lf"), m_YScaleAdjust);
m_FineAdjustYscaleOpt->SetValue(msg);
msg.Printf( wxT( "%lf" ), m_XScaleAdjust );
m_FineAdjustXscaleOpt->SetValue( msg );
msg.Printf( wxT( "%lf" ), m_YScaleAdjust );
m_FineAdjustYscaleOpt->SetValue( msg );
#else
m_PagesOption = m_PagesOptionEeschema;
m_PagesOptionPcb->Show(false);
m_ScaleOption->Show(false);
m_FineAdjustXscaleTitle->Show(false);
m_FineAdjustXscaleOpt->Show(false);
m_FineAdjustYscaleTitle->Show(false);
m_FineAdjustYscaleOpt->Show(false);
m_PagesOptionPcb->Show( false );
m_ScaleOption->Show( false );
m_FineAdjustXscaleTitle->Show( false );
m_FineAdjustXscaleOpt->Show( false );
m_FineAdjustYscaleTitle->Show( false );
m_FineAdjustYscaleOpt->Show( false );
#endif
}
/**********************************************************/
int WinEDA_PrintFrame::SetLayerMaskFromListSelection()
/**********************************************************/
{
int page_count;
int page_count;
s_PrintMaskLayer = 0;
#ifdef PCBNEW
int ii;
for ( ii = 0, page_count = 0; ii < NB_LAYERS; ii++ )
int ii;
for( ii = 0, page_count = 0; ii < NB_LAYERS; ii++ )
{
if ( m_BoxSelecLayer[ii]->IsChecked() )
if( m_BoxSelecLayer[ii]->IsChecked() )
{
page_count++;
s_PrintMaskLayer |= 1 << ii;
}
}
#else
page_count = 1;
#endif
return page_count;
}
/************************************************************/
void WinEDA_PrintFrame::SetColorOrBlack(wxCommandEvent& event)
void WinEDA_PrintFrame::SetColorOrBlack( wxCommandEvent& event )
/************************************************************/
{
s_Print_Black_and_White = m_ColorOption->GetSelection();
}
/****************************************************/
void WinEDA_PrintFrame::OnClosePrintDialog()
/****************************************************/
/* called when WinEDA_PrintFrame is closed
*/
*/
{
wxConfig * Config = m_Parent->m_Parent->m_EDA_Config;
if ( Config )
wxConfig* Config = m_Parent->m_Parent->m_EDA_Config;
if( Config )
{
Config->Write(wxT("PrintPenWidth"), s_PrintPenMinWidth);
Config->Write( wxT( "PrintPenWidth" ), s_PrintPenMinWidth );
}
if ( m_FineAdjustXscaleOpt )
m_FineAdjustXscaleOpt->GetValue().ToDouble(&m_XScaleAdjust);
if ( m_FineAdjustYscaleOpt )
m_FineAdjustYscaleOpt->GetValue().ToDouble(&m_YScaleAdjust);
if( m_FineAdjustXscaleOpt )
m_FineAdjustXscaleOpt->GetValue().ToDouble( &m_XScaleAdjust );
if( m_FineAdjustYscaleOpt )
m_FineAdjustYscaleOpt->GetValue().ToDouble( &m_YScaleAdjust );
SetPenWidth();
#ifdef PCBNEW
if ( Config )
if( Config )
{
Config->Write(wxT("PrintXFineScaleAdj"), m_XScaleAdjust);
Config->Write(wxT("PrintYFineScaleAdj"), m_YScaleAdjust);
Config->Write(wxT("PrintScale"), s_Scale_Select);
Config->Write( wxT( "PrintXFineScaleAdj" ), m_XScaleAdjust );
Config->Write( wxT( "PrintYFineScaleAdj" ), m_YScaleAdjust );
Config->Write( wxT( "PrintScale" ), s_Scale_Select );
}
#endif
EndModal(0);
EndModal( 0 );
}
/************************************************/
wxString WinEDA_PrintFrame::BuildPrintTitle()
/************************************************/
/* return a valid filename to create a print file
*/
*/
{
wxString name, ext;
wxString name, ext;
wxFileName::SplitPath(m_Parent->GetScreen()->m_FileName,
(wxString*) NULL, & name, & ext);
name += wxT("-") + ext;
wxFileName::SplitPath( m_Parent->GetScreen()->m_FileName,
(wxString*) NULL, &name, &ext );
name += wxT( "-" ) + ext;
return name;
}
/******************************************************/
void WinEDA_PrintFrame::SetScale(wxCommandEvent& event)
void WinEDA_PrintFrame::SetScale( wxCommandEvent& event )
/******************************************************/
{
#ifdef PCBNEW
s_Scale_Select = m_ScaleOption->GetSelection();
Scale_X = Scale_Y = s_ScaleList[s_Scale_Select];
if ( m_FineAdjustXscaleOpt )
m_FineAdjustXscaleOpt->GetValue().ToDouble(&m_XScaleAdjust);
if ( m_FineAdjustYscaleOpt )
m_FineAdjustYscaleOpt->GetValue().ToDouble(&m_YScaleAdjust);
if( m_FineAdjustXscaleOpt )
m_FineAdjustXscaleOpt->GetValue().ToDouble( &m_XScaleAdjust );
if( m_FineAdjustYscaleOpt )
m_FineAdjustYscaleOpt->GetValue().ToDouble( &m_YScaleAdjust );
Scale_X *= m_XScaleAdjust;
Scale_Y *= m_YScaleAdjust;
#endif
}
/****************************************/
void WinEDA_PrintFrame::SetPenWidth()
/****************************************/
/* Get the new pen width value, and verify min et max value
NOTE: s_PrintPenMinWidth is in internal units
*/
* NOTE: s_PrintPenMinWidth is in internal units
*/
{
s_PrintPenMinWidth = m_DialogPenWidth->GetValue();
if ( s_PrintPenMinWidth > WIDTH_MAX_VALUE )
if( s_PrintPenMinWidth > WIDTH_MAX_VALUE )
{
s_PrintPenMinWidth = WIDTH_MAX_VALUE;
}
if ( s_PrintPenMinWidth < WIDTH_MIN_VALUE )
if( s_PrintPenMinWidth < WIDTH_MIN_VALUE )
{
s_PrintPenMinWidth = WIDTH_MIN_VALUE;
}
m_DialogPenWidth->SetValue(s_PrintPenMinWidth);
m_DialogPenWidth->SetValue( s_PrintPenMinWidth );
}
/**********************************************************/
void WinEDA_PrintFrame::OnPrintSetup(wxCommandEvent& event)
void WinEDA_PrintFrame::OnPrintSetup( wxCommandEvent& event )
/**********************************************************/
/* Open a dialog box for printer setup (printer options, page size ...)
*/
*/
{
wxPrintDialogData printDialogData(*g_PrintData);
if ( printDialogData.Ok() )
wxPrintDialogData printDialogData( * g_PrintData );
if( printDialogData.Ok() )
{
wxPrintDialog printerDialog(this, & printDialogData);
wxPrintDialog printerDialog( this,& printDialogData );
printerDialog.ShowModal();
* g_PrintData = printerDialog.GetPrintDialogData().GetPrintData();
*g_PrintData = printerDialog.GetPrintDialogData().GetPrintData();
}
else DisplayError(this, _("Printer Problem!") );
else
DisplayError( this, _( "Printer Problem!" ) );
}
/************************************************************/
void WinEDA_PrintFrame::OnPrintPreview(wxCommandEvent& event)
void WinEDA_PrintFrame::OnPrintPreview( wxCommandEvent& event )
/************************************************************/
/* Open and display a previewer frame for printing
*/
*/
{
wxSize WSize;
wxPoint WPos;
int x, y;
bool print_ref = TRUE;
wxSize WSize;
wxPoint WPos;
int x, y;
bool print_ref = TRUE;
SetScale(event);
SetScale( event );
SetPenWidth();
if ( m_PagesOption )
if( m_PagesOption )
s_OptionPrintPage = m_PagesOption->GetSelection();
if ( (m_Print_Sheet_Ref == NULL) || (m_Print_Sheet_Ref->GetValue() == FALSE) )
if( (m_Print_Sheet_Ref == NULL) || (m_Print_Sheet_Ref->GetValue() == FALSE) )
print_ref = FALSE;
// Pass two printout objects: for preview, and possible printing.
wxString title = BuildPrintTitle();
wxPrintPreview *preview =
new wxPrintPreview(new EDA_Printout(this, m_Parent, title, print_ref),
new EDA_Printout(this, m_Parent, title, print_ref), g_PrintData);
if ( preview == NULL )
wxString title = BuildPrintTitle();
wxPrintPreview* preview =
new wxPrintPreview( new EDA_Printout (this, m_Parent, title, print_ref),
new EDA_Printout (this, m_Parent, title, print_ref), g_PrintData );
if( preview == NULL )
{
DisplayError(this, _("There was a problem previewing"));
DisplayError( this, _( "There was a problem previewing" ) );
return;
}
#ifdef PCBNEW
if ( s_OptionPrintPage ) SetLayerMaskFromListSelection();
if( s_OptionPrintPage )
SetLayerMaskFromListSelection();
#endif
m_Parent->GetPosition(&x, &y);
m_Parent->GetPosition( &x, &y );
WPos.x = x + 4;
WPos.y = y + 25;
......@@ -385,83 +417,86 @@ wxString title = BuildPrintTitle();
WSize.x -= 3;
WSize.y += 6;
wxPreviewFrame *frame = new wxPreviewFrame(preview, this,
title, WPos, WSize);
wxPreviewFrame* frame = new wxPreviewFrame( preview, this,
title, WPos, WSize );
frame->Initialize();
frame->Show(TRUE);
frame->Show( TRUE );
}
/**********************************************************/
void WinEDA_PrintFrame::EDA_PrintPage(wxCommandEvent& event)
void WinEDA_PrintFrame::EDA_PrintPage( wxCommandEvent& event )
/**********************************************************/
/* Called on activate "Print CURRENT" button
*/
*/
{
bool print_ref = TRUE;
bool print_ref = TRUE;
SetScale(event);
SetScale( event );
s_OptionPrintPage = 0;
if ( m_PagesOption )
if( m_PagesOption )
s_OptionPrintPage = m_PagesOption->GetSelection();
if ( (m_Print_Sheet_Ref == NULL) || (m_Print_Sheet_Ref->GetValue() == FALSE) )
if( (m_Print_Sheet_Ref == NULL) || (m_Print_Sheet_Ref->GetValue() == FALSE) )
print_ref = FALSE;
#ifdef PCBNEW
if ( s_OptionPrintPage ) SetLayerMaskFromListSelection();
if( s_OptionPrintPage )
SetLayerMaskFromListSelection();
#endif
SetPenWidth();
wxPrintDialogData printDialogData( * g_PrintData);
wxPrintDialogData printDialogData( * g_PrintData );
wxPrinter printer(& printDialogData);
wxPrinter printer(& printDialogData );
wxString title = BuildPrintTitle();
EDA_Printout printout(this, m_Parent, title, print_ref);
wxString title = BuildPrintTitle();
EDA_Printout printout( this, m_Parent, title, print_ref );
#ifndef __WINDOWS__
wxDC * dc = printout.GetDC();
((wxPostScriptDC*)dc)->SetResolution(600); // Postscript DC resolution is 600 ppi
wxDC* dc = printout.GetDC();
( (wxPostScriptDC*) dc )->SetResolution( 600 ); // Postscript DC resolution is 600 ppi
#endif
if (!printer.Print(this, &printout, TRUE))
if( !printer.Print( this, &printout, TRUE ) )
{
if (wxPrinter::GetLastError() == wxPRINTER_ERROR)
DisplayError(this, _("There was a problem printing") );
if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
DisplayError( this, _( "There was a problem printing" ) );
return;
}
else
{
* g_PrintData = printer.GetPrintDialogData().GetPrintData();
*g_PrintData = printer.GetPrintDialogData().GetPrintData();
}
}
/***************************************/
bool EDA_Printout::OnPrintPage(int page)
bool EDA_Printout::OnPrintPage( int page )
/***************************************/
{
wxString msg;
wxString msg;
msg.Printf(_("Print page %d"), page);
m_Parent->Affiche_Message(msg);
msg.Printf( _( "Print page %d" ), page );
m_Parent->Affiche_Message( msg );
#ifdef EESCHEMA
BASE_SCREEN * screen = m_Parent->GetScreen();
BASE_SCREEN *oldscreen = screen;
BASE_SCREEN* screen = m_Parent->GetScreen();
BASE_SCREEN* oldscreen = screen;
if( s_OptionPrintPage == 1 )
{
EDA_ScreenList ScreenList;
screen = ScreenList.GetScreen(page -1);
screen = ScreenList.GetScreen( page - 1 );
}
if (screen == NULL) return FALSE;
if( screen == NULL )
return FALSE;
ActiveScreen = (SCH_SCREEN*) screen;
DrawPage();
ActiveScreen = (SCH_SCREEN*) oldscreen;
......@@ -469,24 +504,27 @@ BASE_SCREEN *oldscreen = screen;
#endif
#ifdef PCBNEW
if ( (m_Parent->m_Ident == PCB_FRAME) || (m_Parent->m_Ident == GERBER_FRAME) )
if( (m_Parent->m_Ident == PCB_FRAME) || (m_Parent->m_Ident == GERBER_FRAME) )
{
m_PrintFrame->SetLayerMaskFromListSelection();
if ( s_OptionPrintPage == 0 )
if( s_OptionPrintPage == 0 )
{
// compute layer mask from page number
int ii, jj, mask = 1;
for ( ii = 0, jj = 0; ii < NB_LAYERS; ii++)
for( ii = 0, jj = 0; ii < NB_LAYERS; ii++ )
{
if ( s_PrintMaskLayer & mask ) jj++;
if ( jj == page )
if( s_PrintMaskLayer & mask )
jj++;
if( jj == page )
{
s_PrintMaskLayer = mask;
break;
}
mask <<= 1;
}
if ( ii == NB_LAYERS ) return FALSE;
if( ii == NB_LAYERS )
return FALSE;
}
}
DrawPage();
......@@ -495,12 +533,14 @@ BASE_SCREEN *oldscreen = screen;
return TRUE;
}
/*********************************************************/
void EDA_Printout::GetPageInfo(int *minPage, int *maxPage,
int *selPageFrom, int *selPageTo)
void EDA_Printout::GetPageInfo( int* minPage, int* maxPage,
int* selPageFrom, int* selPageTo )
/*********************************************************/
{
int ii = 1;
int ii = 1;
*minPage = 1;
*selPageFrom = 1;
......@@ -513,15 +553,18 @@ int ii = 1;
#endif
#ifdef PCBNEW
switch( s_OptionPrintPage )
{
case 0 :ii = m_PrintFrame->SetLayerMaskFromListSelection();
case 0:
ii = m_PrintFrame->SetLayerMaskFromListSelection();
break;
case 1:
ii = 1;
break;
}
#endif
*maxPage = ii;
......@@ -530,15 +573,16 @@ int ii = 1;
/**************************************/
bool EDA_Printout::HasPage(int pageNum)
bool EDA_Printout::HasPage( int pageNum )
/**************************************/
{
#ifdef EESCHEMA
int PageCount;
int PageCount;
EDA_ScreenList ScreenList;
PageCount = ScreenList.GetCount();
if( PageCount >= pageNum ) return TRUE;
if( PageCount >= pageNum )
return TRUE;
return FALSE;
#endif
......@@ -548,47 +592,50 @@ int PageCount;
#endif
}
/*************************************************************/
bool EDA_Printout::OnBeginDocument(int startPage, int endPage)
bool EDA_Printout::OnBeginDocument( int startPage, int endPage )
/*************************************************************/
{
if (!wxPrintout::OnBeginDocument(startPage, endPage))
if( !wxPrintout::OnBeginDocument( startPage, endPage ) )
return FALSE;
return TRUE;
}
/********************************/
void EDA_Printout::DrawPage()
/********************************/
/*
This is the real print function: print the active screen
*/
* This is the real print function: print the active screen
*/
{
int tmpzoom;
wxPoint tmp_startvisu;
wxSize PageSize_in_mm;
wxSize SheetSize; // Page size in internal units
wxSize PlotAreaSize; // plot area size in pixels
double scaleX, scaleY, scale;
wxPoint old_org;
wxPoint DrawOffset; // Offset de trace
double userscale;
int DrawZoom = 1;
wxDC * dc = GetDC();
int tmpzoom;
wxPoint tmp_startvisu;
wxSize PageSize_in_mm;
wxSize SheetSize; // Page size in internal units
wxSize PlotAreaSize; // plot area size in pixels
double scaleX, scaleY, scale;
wxPoint old_org;
wxPoint DrawOffset; // Offset de trace
double userscale;
int DrawZoom = 1;
wxDC* dc = GetDC();
s_PrintMirror = m_PrintFrame->m_Print_Mirror->GetValue();
wxBusyCursor dummy;
GetPageSizeMM(&PageSize_in_mm.x, &PageSize_in_mm.y);
GetPageSizeMM( &PageSize_in_mm.x, &PageSize_in_mm.y );
/* Save old draw scale and draw offset */
tmp_startvisu = ActiveScreen->m_StartVisu;
tmpzoom = ActiveScreen->GetZoom();
old_org = ActiveScreen->m_DrawOrg;
/* Change draw scale and offset to draw the whole page */
ActiveScreen->SetZoom(DrawZoom);
ActiveScreen->SetZoom( DrawZoom );
ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0;
ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0;
......@@ -597,14 +644,14 @@ wxDC * dc = GetDC();
SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in pixels
// Get the size of the DC in pixels
dc->GetSize(&PlotAreaSize.x, &PlotAreaSize.y);
dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y );
#ifdef PCBNEW
WinEDA_BasePcbFrame * pcbframe = (WinEDA_BasePcbFrame*) m_Parent;
WinEDA_BasePcbFrame* pcbframe = (WinEDA_BasePcbFrame*) m_Parent;
pcbframe->m_Pcb->ComputeBoundaryBox();
/* Compute the PCB size in internal units*/
userscale = s_ScaleList[s_Scale_Select];
if (userscale == 0) // fit in page
if( userscale == 0 ) // fit in page
{
int extra_margin = 8000; // Margin = 8000/2 units pcb = 0,4 inch
SheetSize.x = pcbframe->m_Pcb->m_BoundaryBox.GetWidth() + extra_margin;
......@@ -612,8 +659,8 @@ wxDC * dc = GetDC();
userscale = 0.99;
}
if ( (s_ScaleList[s_Scale_Select] > 1.0) || // scale > 1 -> Recadrage
(s_ScaleList[s_Scale_Select] == 0) ) // fit in page
if( (s_ScaleList[s_Scale_Select] > 1.0) // scale > 1 -> Recadrage
|| (s_ScaleList[s_Scale_Select] == 0) ) // fit in page
{
DrawOffset.x += pcbframe->m_Pcb->m_BoundaryBox.Centre().x;
DrawOffset.y += pcbframe->m_Pcb->m_BoundaryBox.Centre().y;
......@@ -623,26 +670,27 @@ wxDC * dc = GetDC();
#endif
// Calculate a suitable scaling factor
scaleX = (double)SheetSize.x / PlotAreaSize.x;
scaleY = (double)SheetSize.y / PlotAreaSize.y;
scale = wxMax(scaleX,scaleY) / userscale; // Use x or y scaling factor, whichever fits on the DC
scaleX = (double) SheetSize.x / PlotAreaSize.x;
scaleY = (double) SheetSize.y / PlotAreaSize.y;
scale = wxMax( scaleX, scaleY ) / userscale; // Use x or y scaling factor, whichever fits on the DC
// ajust the real draw scale
#ifdef PCBNEW
double accurate_Xscale, accurate_Yscale;
dc->SetUserScale(DrawZoom / scale * m_PrintFrame->m_XScaleAdjust,
DrawZoom / scale * m_PrintFrame->m_YScaleAdjust);
double accurate_Xscale, accurate_Yscale;
dc->SetUserScale( DrawZoom / scale * m_PrintFrame->m_XScaleAdjust,
DrawZoom / scale * m_PrintFrame->m_YScaleAdjust );
// Compute Accurate scale 1
{
int w, h;
GetPPIPrinter(&w, &h);
accurate_Xscale = ((double)(DrawZoom * w))/ PCB_INTERNAL_UNIT;
accurate_Yscale = ((double)(DrawZoom * h))/ PCB_INTERNAL_UNIT;
if ( IsPreview() ) // Scale must take in account the DC size in Preview
GetPPIPrinter( &w, &h );
accurate_Xscale = ( (double) (DrawZoom * w) ) / PCB_INTERNAL_UNIT;
accurate_Yscale = ( (double) (DrawZoom * h) ) / PCB_INTERNAL_UNIT;
if( IsPreview() ) // Scale must take in account the DC size in Preview
{
// Get the size of the DC in pixels
dc->GetSize(&PlotAreaSize.x, &PlotAreaSize.y);
GetPageSizePixels(&w, &h);
dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y );
GetPageSizePixels( &w, &h );
accurate_Xscale *= PlotAreaSize.x; accurate_Xscale /= w;
accurate_Yscale *= PlotAreaSize.y; accurate_Yscale /= h;
}
......@@ -650,46 +698,49 @@ double accurate_Xscale, accurate_Yscale;
accurate_Yscale *= m_PrintFrame->m_YScaleAdjust;
}
#else
dc->SetUserScale(DrawZoom / scale, DrawZoom / scale);
dc->SetUserScale( DrawZoom / scale, DrawZoom / scale );
#endif
#ifdef PCBNEW
if ( (s_ScaleList[s_Scale_Select] > 1.0) || // scale > 1 -> Recadrage
(s_ScaleList[s_Scale_Select] == 0) ) // fit in page
if( (s_ScaleList[s_Scale_Select] > 1.0) // scale > 1 -> Recadrage
|| (s_ScaleList[s_Scale_Select] == 0) ) // fit in page
{
DrawOffset.x -= (int)( (PlotAreaSize.x/2) * scale);
DrawOffset.y -= (int)( (PlotAreaSize.y/3) * scale);
DrawOffset.x -= (int) ( (PlotAreaSize.x / 2) * scale );
DrawOffset.y -= (int) ( (PlotAreaSize.y / 3) * scale );
}
DrawOffset.x += (int)( (SheetSize.x/2) * (m_PrintFrame->m_XScaleAdjust -1.0));
DrawOffset.y += (int)( (SheetSize.y/2) * (m_PrintFrame->m_YScaleAdjust -1.0));
DrawOffset.x += (int) ( (SheetSize.x / 2) * (m_PrintFrame->m_XScaleAdjust - 1.0) );
DrawOffset.y += (int) ( (SheetSize.y / 2) * (m_PrintFrame->m_YScaleAdjust - 1.0) );
#endif
ActiveScreen->m_DrawOrg = DrawOffset;
GRResetPenAndBrush(dc);
if( s_Print_Black_and_White ) GRForceBlackPen(TRUE);
GRResetPenAndBrush( dc );
if( s_Print_Black_and_White )
GRForceBlackPen( TRUE );
#ifdef EESCHEMA
/* set Pen min width */
double ftmp, xdcscale, ydcscale;
double ftmp, xdcscale, ydcscale;
// s_PrintPenMinWidth is in internal units ( 1/1000 inch), and must be converted in pixels
ftmp = (float)s_PrintPenMinWidth * 25.4 / EESCHEMA_INTERNAL_UNIT; // ftmp est en mm
ftmp *= (float)PlotAreaSize.x / PageSize_in_mm.x; /* ftmp is in pixels */
ftmp = (float) s_PrintPenMinWidth * 25.4 / EESCHEMA_INTERNAL_UNIT; // ftmp est en mm
ftmp *= (float) PlotAreaSize.x / PageSize_in_mm.x; /* ftmp is in pixels */
/* because the pen size will be scaled by the dc scale, we modify the size
in order to keep the requested value */
dc->GetUserScale(&xdcscale, &ydcscale);
* in order to keep the requested value */
dc->GetUserScale( &xdcscale, &ydcscale );
ftmp /= xdcscale;
SetPenMinWidth((int)round(ftmp));
SetPenMinWidth( (int) round( ftmp ) );
#else
SetPenMinWidth(1); // min width = 1 pixel
SetPenMinWidth( 1 ); // min width = 1 pixel
#endif
WinEDA_DrawPanel * panel = m_Parent->DrawPanel;
EDA_Rect tmp = panel->m_ClipBox;
WinEDA_DrawPanel* panel = m_Parent->DrawPanel;
EDA_Rect tmp = panel->m_ClipBox;
panel->m_ClipBox.SetOrigin(wxPoint(0,0));
panel->m_ClipBox.SetSize(wxSize(0x7FFFFF0, 0x7FFFFF0));
panel->m_ClipBox.SetOrigin( wxPoint( 0, 0 ) );
panel->m_ClipBox.SetSize( wxSize( 0x7FFFFF0, 0x7FFFFF0 ) );
g_IsPrinting = TRUE;
#ifdef EESCHEMA
......@@ -697,47 +748,50 @@ EDA_Rect tmp = panel->m_ClipBox;
g_PrintFillMask = FILLED_WITH_BG_BODYCOLOR;
#endif
#ifdef PCBNEW
if ( m_Print_Sheet_Ref )
m_Parent->TraceWorkSheet( dc, ActiveScreen, 0);
if( m_Print_Sheet_Ref )
m_Parent->TraceWorkSheet( dc, ActiveScreen, 0 );
if ( userscale == 1.0 ) // Draw the Sheet refs at optimum scale, and board at 1.0 scale
if( userscale == 1.0 ) // Draw the Sheet refs at optimum scale, and board at 1.0 scale
{
m_Print_Sheet_Ref = FALSE;
dc->SetUserScale( accurate_Yscale, accurate_Yscale);
dc->SetUserScale( accurate_Yscale, accurate_Yscale );
}
if ( s_PrintMirror )
if( s_PrintMirror )
{ // To plot mirror, we revere the y axis, and modify the plot y origin
double sx, sy;
dc->GetUserScale(&sx, &sy);
dc->SetAxisOrientation(TRUE, TRUE);
if ( userscale < 1.0 ) sy /= userscale;
dc->GetUserScale( &sx, &sy );
dc->SetAxisOrientation( TRUE, TRUE );
if( userscale < 1.0 )
sy /= userscale;
/* Plot offset y is moved by the y plot area size in order to have
the old draw area in the new draw area, because the draw origin has not moved
(this is the upper left corner) but the Y axis is reversed, therefore the plotting area
is the y coordinate values from - PlotAreaSize.y to 0 */
int ysize = (int)( PlotAreaSize.y / sy );
* the old draw area in the new draw area, because the draw origin has not moved
* (this is the upper left corner) but the Y axis is reversed, therefore the plotting area
* is the y coordinate values from - PlotAreaSize.y to 0 */
int ysize = (int) ( PlotAreaSize.y / sy );
DrawOffset.y += ysize;
/* in order to keep the board position in the sheet
(when user scale <= 1) the y offset in moved by the distance between
the middle of the page and the middle of the board
This is equivalent to put the mirror axis to the board centre
for scales > 1, the DrawOffset was already computed to have the board centre
to the middle of the page.
* (when user scale <= 1) the y offset in moved by the distance between
* the middle of the page and the middle of the board
* This is equivalent to put the mirror axis to the board centre
* for scales > 1, the DrawOffset was already computed to have the board centre
* to the middle of the page.
*/
wxPoint pcb_centre = pcbframe->m_Pcb->m_BoundaryBox.Centre();
if ( userscale <= 1.0 )
DrawOffset.y += pcb_centre.y - (ysize/2);
if( userscale <= 1.0 )
DrawOffset.y += pcb_centre.y - (ysize / 2);
ActiveScreen->m_DrawOrg = DrawOffset;
panel->m_ClipBox.SetOrigin(wxPoint(-0x7FFFFF,-0x7FFFFF));
panel->m_ClipBox.SetOrigin( wxPoint( -0x7FFFFF, -0x7FFFFF ) );
}
panel->PrintPage(dc, 0, s_PrintMaskLayer);
panel->PrintPage( dc, 0, s_PrintMaskLayer );
#else
panel->PrintPage(dc, m_Print_Sheet_Ref, s_PrintMaskLayer);
panel->PrintPage( dc, m_Print_Sheet_Ref, s_PrintMaskLayer );
#endif
#ifdef EESCHEMA
......@@ -747,11 +801,10 @@ EDA_Rect tmp = panel->m_ClipBox;
g_IsPrinting = FALSE;
panel->m_ClipBox = tmp;
SetPenMinWidth(1);
GRForceBlackPen(FALSE);
SetPenMinWidth( 1 );
GRForceBlackPen( FALSE );
ActiveScreen->m_StartVisu = tmp_startvisu;
ActiveScreen->m_DrawOrg = old_org;
ActiveScreen->SetZoom(tmpzoom);
ActiveScreen->SetZoom( tmpzoom );
}
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