From 8a8ba43bded13a59f5c080f1295c72e4aea01408 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 29 Sep 2013 20:24:38 +0200 Subject: [PATCH] Gerbview: fix incorrect printing of negative objects, when using black and white option. Eeschema: better name for m_SheetList (changed to m_SheetPath) member of class NETLIST_OBJECT. --- eeschema/class_netlist_object.cpp | 12 ++--- eeschema/class_netlist_object.h | 20 ++++++-- eeschema/erc.cpp | 12 ++--- eeschema/netform.cpp | 8 ++-- eeschema/netlist.cpp | 24 +++++----- eeschema/sch_component.cpp | 8 ++-- eeschema/sch_junction.cpp | 4 +- eeschema/sch_line.cpp | 4 +- eeschema/sch_no_connect.cpp | 4 +- eeschema/sch_sheet.cpp | 4 +- eeschema/sch_text.cpp | 4 +- gerbview/class_gbr_layout.h | 5 +- .../dialogs/dialog_print_using_printer.cpp | 32 +++++-------- .../dialog_print_using_printer_base.cpp | 33 +++++++------ .../dialog_print_using_printer_base.fbp | 4 +- .../dialogs/dialog_print_using_printer_base.h | 12 +++-- gerbview/draw_gerber_screen.cpp | 25 +++++++--- gerbview/excellon_read_drill_file.cpp | 48 ++++++++++++++++--- gerbview/gerbview_frame.cpp | 15 +++--- pcbnew/printout_controler.cpp | 20 +++++--- 20 files changed, 185 insertions(+), 113 deletions(-) diff --git a/eeschema/class_netlist_object.cpp b/eeschema/class_netlist_object.cpp index 572a090cc9..4832ffde87 100644 --- a/eeschema/class_netlist_object.cpp +++ b/eeschema/class_netlist_object.cpp @@ -116,7 +116,7 @@ const char* ShowType( NETLIST_ITEM_T aType ) void NETLIST_OBJECT::Show( std::ostream& out, int ndx ) const { - wxString path = m_SheetList.PathHumanReadable(); + wxString path = m_SheetPath.PathHumanReadable(); out << "" << m_Label.mb_str() << "\n"; - out << " " << m_SheetList.PathHumanReadable().mb_str() << "\n"; + out << " " << m_SheetPath.PathHumanReadable().mb_str() << "\n"; switch( m_Type ) { case NET_PIN: /* GetRef() needs to be const - out << " " << ((SCH_COMPONENT*)m_Link)->GetRef(&m_SheetList).mb_str() + out << " " << ((SCH_COMPONENT*)m_Link)->GetRef(&m_SheetPath).mb_str() << "\n"; */ @@ -222,7 +222,7 @@ bool NETLIST_OBJECT::IsLabelConnected( NETLIST_OBJECT* aNetItem ) if( ( at == NET_HIERLABEL || at == NET_HIERBUSLABELMEMBER ) && ( bt == NET_SHEETLABEL || bt == NET_SHEETBUSLABELMEMBER ) ) { - if( m_SheetList == aNetItem->m_SheetListInclude ) + if( m_SheetPath == aNetItem->m_SheetPathInclude ) { return true; //connected! } @@ -325,7 +325,7 @@ wxString NETLIST_OBJECT::GetNetName() const if( !m_netNameCandidate->IsLabelGlobal() ) { // usual net name, prefix it by the sheet path - netName = m_netNameCandidate->m_SheetList.PathHumanReadable(); + netName = m_netNameCandidate->m_SheetPath.PathHumanReadable(); } netName += m_netNameCandidate->m_Label; @@ -351,7 +351,7 @@ wxString NETLIST_OBJECT::GetShortNetName() const if( link ) // Should be always true { netName = wxT("Net-<"); - netName << link->GetRef( &m_netNameCandidate->m_SheetList ); + netName << link->GetRef( &m_netNameCandidate->m_SheetPath ); netName << wxT("-Pad") << LIB_PIN::ReturnPinStringNum( m_netNameCandidate->m_PinNum ) << wxT(">"); diff --git a/eeschema/class_netlist_object.h b/eeschema/class_netlist_object.h index 0c6b57a0f4..d07dcb7291 100644 --- a/eeschema/class_netlist_object.h +++ b/eeschema/class_netlist_object.h @@ -36,6 +36,7 @@ #include // LIB_PIN::ReturnPinStringNum( m_PinNum ) class NETLIST_OBJECT_LIST; +class SCH_COMPONENT; /* Type of Net objects (wires, labels, pins...) */ @@ -97,7 +98,8 @@ public: * that contains this pin */ int m_Flag; /* flag used in calculations */ - SCH_SHEET_PATH m_SheetList; + SCH_SHEET_PATH m_SheetPath; // the sheet path which contains this item + SCH_SHEET_PATH m_SheetPathInclude; // sheet path which contains the hierarchical label int m_ElectricalType; /* Has meaning only for Pins and * hierarchical pins: electrical type */ int m_BusNetCode; /* Used for BUS connections */ @@ -105,7 +107,6 @@ public: * created from the BUS label ) member number. */ NET_CONNECTION_T m_ConnectionType; // Used to store the connection type - SCH_SHEET_PATH m_SheetListInclude; // sheet path which contains the hierarchical label long m_PinNum; // pin number ( 1 long = 4 bytes -> 4 ascii codes) wxString m_Label; // Label text (for labels) or Pin name (for pins) wxPoint m_Start; // Position of object or for segments: starting point @@ -181,6 +182,19 @@ public: return LIB_PIN::ReturnPinStringNum( m_PinNum ); } + /** For Pins (NET_PINS): + * @return the schematic component which contains this pin + * (Note: this is the schematic component, not the library component + * for others items: return NULL + */ + SCH_COMPONENT* GetComponentParent() const + { + if( m_Link && m_Link->Type() == SCH_COMPONENT_T ) + return (SCH_COMPONENT*) m_Link; + + return NULL; + } + /** * Function IsLabelConnected * tests if the net list object is a hierarchical label or sheet label and is @@ -385,7 +399,7 @@ private: */ static bool sortItemsBySheet( const NETLIST_OBJECT* Objet1, const NETLIST_OBJECT* Objet2 ) { - return Objet1->m_SheetList.Cmp( Objet2->m_SheetList ) < 0; + return Objet1->m_SheetPath.Cmp( Objet2->m_SheetPath ) < 0; } /* * Propagate net codes from a parent sheet to an include sheet, diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 6a6c36e731..f08b2ae5e7 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -240,7 +240,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, marker->SetMarkerType( MARK_ERC ); marker->SetErrorLevel( WAR ); - screen = aNetItemRef->m_SheetList.LastScreen(); + screen = aNetItemRef->m_SheetPath.LastScreen(); screen->Append( marker ); wxString msg; @@ -277,7 +277,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, cmp_ref = wxT( "?" ); if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link ) - cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef( &aNetItemRef->m_SheetList ); + cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef( &aNetItemRef->m_SheetPath ); if( aNetItemTst == NULL ) { @@ -296,7 +296,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, { if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link ) cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef( - &aNetItemRef->m_SheetList ); + &aNetItemRef->m_SheetPath ); msg.Printf( _( "Pin %s (%s) of component %s is not driven (Net %d)." ), GetChars( string_pinnum ), MsgPinElectricType[ii], GetChars( cmp_ref ), @@ -336,7 +336,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, alt_cmp = wxT( "?" ); if( aNetItemTst->m_Type == NET_PIN && aNetItemTst->m_Link ) - alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef( &aNetItemTst->m_SheetList ); + alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef( &aNetItemTst->m_SheetPath ); msg.Printf( _( "Pin %s (%s) of component %s is connected to " ), GetChars( string_pinnum ), MsgPinElectricType[ii], GetChars( cmp_ref ) ); @@ -405,9 +405,9 @@ void TestOthersItems( NETLIST_OBJECT_LIST* aList, continue; if( ( (SCH_COMPONENT*) aList->GetItem( aNetItemRef )-> - m_Link )->GetRef( &aList->GetItem( aNetItemRef )-> m_SheetList ) != + m_Link )->GetRef( &aList->GetItem( aNetItemRef )-> m_SheetPath ) != ( (SCH_COMPONENT*) aList->GetItem( duplicate )->m_Link ) - ->GetRef( &aList->GetItem( duplicate )->m_SheetList ) ) + ->GetRef( &aList->GetItem( duplicate )->m_SheetPath ) ) continue; // Same component and same pin. Do dot create error for this pin diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 346f7dc5c9..b54f48c9d9 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -878,7 +878,7 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericListOfNets() comp = (SCH_COMPONENT*) nitem->m_Link; // Get the reference for the net name and the main parent component - ref = comp->GetRef( &nitem->m_SheetList ); + ref = comp->GetRef( &nitem->m_SheetPath ); if( ref[0] == wxChar( '#' ) ) continue; @@ -1520,7 +1520,7 @@ bool NETLIST_EXPORT_TOOL::addPinToComponentPinList( SCH_COMPONENT* aComponent, continue; // most expensive test at the end. - if( pin->m_SheetList != *aSheetPath ) + if( pin->m_SheetPath != *aSheetPath ) continue; m_SortedComponentPinList.push_back( pin ); @@ -1678,7 +1678,7 @@ bool NETLIST_EXPORT_TOOL::writeGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST& comp = (SCH_COMPONENT*) nitem->m_Link; // Get the reference for the net name and the main parent component - ref = comp->GetRef( &nitem->m_SheetList ); + ref = comp->GetRef( &nitem->m_SheetPath ); if( ref[0] == wxChar( '#' ) ) continue; // Pseudo component (Like Power symbol) @@ -1825,7 +1825,7 @@ bool NETLIST_EXPORT_TOOL::writeListOfNetsCADSTAR( FILE* f ) continue; Cmp = (SCH_COMPONENT*) nitem->m_Link; - wxString refstr = Cmp->GetRef( &nitem->m_SheetList ); + wxString refstr = Cmp->GetRef( &nitem->m_SheetPath ); if( refstr[0] == '#' ) continue; // Power supply symbols. diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index 35c217b4ba..e31920a5a9 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -147,16 +147,16 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets ) // Sort objects by Sheet SortListbySheet(); - sheet = &(GetItem( 0 )->m_SheetList); + sheet = &(GetItem( 0 )->m_SheetPath); m_lastNetCode = m_lastBusNetCode = 1; for( unsigned ii = 0, istart = 0; ii < size(); ii++ ) { NETLIST_OBJECT* net_item = GetItem( ii ); - if( net_item->m_SheetList != *sheet ) // Sheet change + if( net_item->m_SheetPath != *sheet ) // Sheet change { - sheet = &(net_item->m_SheetList); + sheet = &(net_item->m_SheetPath); istart = ii; } @@ -377,8 +377,8 @@ static bool evalLabelsPriority( const NETLIST_OBJECT* aLabel1, // use name defined in higher hierarchical sheet // (i.e. shorter path because paths are ///... // and timestamp = 8 letters. - if( aLabel1->m_SheetList.Path().Length() != aLabel2->m_SheetList.Path().Length() ) - return aLabel1->m_SheetList.Path().Length() < aLabel2->m_SheetList.Path().Length(); + if( aLabel1->m_SheetPath.Path().Length() != aLabel2->m_SheetPath.Path().Length() ) + return aLabel1->m_SheetPath.Path().Length() < aLabel2->m_SheetPath.Path().Length(); // Sheet paths have the same length: use alphabetic label name order // For labels on sheets having an equivalent deep in hierarchy, use @@ -386,8 +386,8 @@ static bool evalLabelsPriority( const NETLIST_OBJECT* aLabel1, if( aLabel1->m_Label.Cmp( aLabel2->m_Label ) != 0 ) return aLabel1->m_Label.Cmp( aLabel2->m_Label ) < 0; - return aLabel1->m_SheetList.PathHumanReadable().Cmp( - aLabel2->m_SheetList.PathHumanReadable() ) < 0; + return aLabel1->m_SheetPath.PathHumanReadable().Cmp( + aLabel2->m_SheetPath.PathHumanReadable() ) < 0; } @@ -547,7 +547,7 @@ void NETLIST_OBJECT_LIST::sheetLabelConnect( NETLIST_OBJECT* SheetLabel ) { NETLIST_OBJECT* ObjetNet = GetItem( ii ); - if( ObjetNet->m_SheetList != SheetLabel->m_SheetListInclude ) + if( ObjetNet->m_SheetPath != SheetLabel->m_SheetPathInclude ) continue; //use SheetInclude, not the sheet!! if( (ObjetNet->m_Type != NET_HIERLABEL ) && (ObjetNet->m_Type != NET_HIERBUSLABELMEMBER ) ) @@ -681,7 +681,7 @@ void NETLIST_OBJECT_LIST::pointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus { NETLIST_OBJECT* item = GetItem( i ); - if( item->m_SheetList != aRef->m_SheetList ) //used to be > (why?) + if( item->m_SheetPath != aRef->m_SheetPath ) //used to be > (why?) continue; switch( item->m_Type ) @@ -725,7 +725,7 @@ void NETLIST_OBJECT_LIST::pointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus { NETLIST_OBJECT* item = GetItem( i ); - if( item->m_SheetList != aRef->m_SheetList ) + if( item->m_SheetPath != aRef->m_SheetPath ) continue; switch( item->m_Type ) @@ -779,7 +779,7 @@ void NETLIST_OBJECT_LIST::segmentToPointConnect( NETLIST_OBJECT* aJonction, NETLIST_OBJECT* segment = GetItem( i ); // if different sheets, obviously no physical connection between elements. - if( segment->m_SheetList != aJonction->m_SheetList ) + if( segment->m_SheetPath != aJonction->m_SheetPath ) continue; if( aIsBus == IS_WIRE ) @@ -832,7 +832,7 @@ void NETLIST_OBJECT_LIST::labelConnect( NETLIST_OBJECT* aLabelRef ) if( item->GetNet() == aLabelRef->GetNet() ) continue; - if( item->m_SheetList != aLabelRef->m_SheetList ) + if( item->m_SheetPath != aLabelRef->m_SheetPath ) { if( item->m_Type != NET_PINLABEL && item->m_Type != NET_GLOBLABEL && item->m_Type != NET_GLOBBUSLABELMEMBER ) diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 5608016a16..22861fe5f4 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -1741,9 +1741,9 @@ void SCH_COMPONENT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, wxPoint pos = GetTransform().TransformCoordinate( pin->GetPosition() ) + m_Pos; NETLIST_OBJECT* item = new NETLIST_OBJECT(); - item->m_SheetListInclude = *aSheetPath; + item->m_SheetPathInclude = *aSheetPath; item->m_Comp = (SCH_ITEM*) pin; - item->m_SheetList = *aSheetPath; + item->m_SheetPath = *aSheetPath; item->m_Type = NET_PIN; item->m_Link = (SCH_ITEM*) this; item->m_ElectricalType = pin->GetType(); @@ -1757,9 +1757,9 @@ void SCH_COMPONENT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, { /* There is an associated PIN_LABEL. */ item = new NETLIST_OBJECT(); - item->m_SheetListInclude = *aSheetPath; + item->m_SheetPathInclude = *aSheetPath; item->m_Comp = NULL; - item->m_SheetList = *aSheetPath; + item->m_SheetPath = *aSheetPath; item->m_Type = NET_PINLABEL; item->m_Label = pin->GetName(); item->m_Start = pos; diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 41f4850e01..4b1bcbceb8 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -179,8 +179,8 @@ void SCH_JUNCTION::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, { NETLIST_OBJECT* item = new NETLIST_OBJECT(); - item->m_SheetList = *aSheetPath; - item->m_SheetListInclude = *aSheetPath; + item->m_SheetPath = *aSheetPath; + item->m_SheetPathInclude = *aSheetPath; item->m_Comp = (SCH_ITEM*) this; item->m_Type = NET_JUNCTION; item->m_Start = item->m_End = m_pos; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 4589411657..4cc9821b04 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -524,8 +524,8 @@ void SCH_LINE::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, return; NETLIST_OBJECT* item = new NETLIST_OBJECT(); - item->m_SheetList = *aSheetPath; - item->m_SheetListInclude = *aSheetPath; + item->m_SheetPath = *aSheetPath; + item->m_SheetPathInclude = *aSheetPath; item->m_Comp = (SCH_ITEM*) this; item->m_Start = m_start; item->m_End = m_end; diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index a033292666..662ebd756a 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -193,8 +193,8 @@ void SCH_NO_CONNECT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, { NETLIST_OBJECT* item = new NETLIST_OBJECT(); - item->m_SheetList = *aSheetPath; - item->m_SheetListInclude = *aSheetPath; + item->m_SheetPath = *aSheetPath; + item->m_SheetPathInclude = *aSheetPath; item->m_Comp = this; item->m_Type = NET_NOCONNECT; item->m_Start = item->m_End = m_pos; diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index e504c9e85e..7c0c97e1c8 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -1081,8 +1081,8 @@ void SCH_SHEET::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, for( size_t i = 0; i < m_pins.size(); i++ ) { NETLIST_OBJECT* item = new NETLIST_OBJECT(); - item->m_SheetListInclude = sheetPath; - item->m_SheetList = *aSheetPath; + item->m_SheetPathInclude = sheetPath; + item->m_SheetPath = *aSheetPath; item->m_Comp = &m_pins[i]; item->m_Link = this; item->m_Type = NET_SHEETLABEL; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index c2ec767599..abfc85948b 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -620,8 +620,8 @@ void SCH_TEXT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, return; NETLIST_OBJECT* item = new NETLIST_OBJECT(); - item->m_SheetList = *aSheetPath; - item->m_SheetListInclude = *aSheetPath; + item->m_SheetPath = *aSheetPath; + item->m_SheetPathInclude = *aSheetPath; item->m_Comp = (SCH_ITEM*) this; item->m_Type = NET_LABEL; diff --git a/gerbview/class_gbr_layout.h b/gerbview/class_gbr_layout.h index ac97e87eb2..da0c511604 100644 --- a/gerbview/class_gbr_layout.h +++ b/gerbview/class_gbr_layout.h @@ -81,9 +81,12 @@ public: * @param aDC = the current device context * @param aDrawMode = GR_COPY, GR_OR ... (not always used) * @param aOffset = an draw offset value + * @param aPrintBlackAndWhite = true to force black and white insdeat of color + * useful only to print/plot gebview layers */ void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, - GR_DRAWMODE aDrawMode, const wxPoint& aOffset ); + GR_DRAWMODE aDrawMode, const wxPoint& aOffset, + bool aPrintBlackAndWhite = false ); /** * Function SetVisibleLayers diff --git a/gerbview/dialogs/dialog_print_using_printer.cpp b/gerbview/dialogs/dialog_print_using_printer.cpp index e49e2bdf6c..da67c4989b 100644 --- a/gerbview/dialogs/dialog_print_using_printer.cpp +++ b/gerbview/dialogs/dialog_print_using_printer.cpp @@ -16,7 +16,6 @@ #include #include -#include static long s_SelectedLayers; static double s_ScaleList[] = @@ -34,10 +33,10 @@ static wxPageSetupDialogData* g_pageSetupData = (wxPageSetupDialogData*) NULL; static PRINT_PARAMETERS s_Parameters; -/* Dialog to print schematic. Class derived from DIALOG_PRINT_USING_PRINTER_base +/* Dialog to print schematic. Class derived from DIALOG_PRINT_USING_PRINTER_BASE * created by wxFormBuilder */ -class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_base +class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_BASE { private: GERBVIEW_FRAME* m_Parent; @@ -76,17 +75,17 @@ void GERBVIEW_FRAME::ToPrinter( wxCommandEvent& event ) */ { if( g_PrintData == NULL ) // First print - { g_PrintData = new wxPrintData(); - if( !g_PrintData->Ok() ) - { - DisplayError( this, _( "Error Init Printer info" ) ); - } - g_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGHT; + if( !g_PrintData->Ok() ) + { + DisplayError( this, _( "Error Init Printer info" ) ); + return; } - g_PrintData->SetOrientation( GetPageSettings().IsPortrait() ? wxPORTRAIT : wxLANDSCAPE ); + g_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); + g_PrintData->SetOrientation( GetPageSettings().IsPortrait() ? + wxPORTRAIT : wxLANDSCAPE ); DIALOG_PRINT_USING_PRINTER* frame = new DIALOG_PRINT_USING_PRINTER( this ); @@ -97,24 +96,19 @@ void GERBVIEW_FRAME::ToPrinter( wxCommandEvent& event ) /*************************************************************************************/ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( GERBVIEW_FRAME* parent ) : - DIALOG_PRINT_USING_PRINTER_base( parent ) + DIALOG_PRINT_USING_PRINTER_BASE( parent ) /*************************************************************************************/ { m_Parent = parent; m_Config = wxGetApp().GetSettings(); InitValues( ); + GetSizer()->SetSizeHints( this ); - if( GetSizer() ) - { - GetSizer()->SetSizeHints( this ); - } #ifdef __WXMAC__ /* Problems with modal on wx-2.9 - Anyway preview is standard for OSX */ m_buttonPreview->Hide(); #endif - - m_buttonPrint->SetDefault(); } @@ -130,7 +124,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) { g_pageSetupData = new wxPageSetupDialogData; // Set initial page margins. - // Margins are already set in Pcbnew, so we cans use 0 + // Margins are already set in Pcbnew, so we can use 0 g_pageSetupData->SetMarginTopLeft(wxPoint(0, 0)); g_pageSetupData->SetMarginBottomRight(wxPoint(0, 0)); } @@ -176,7 +170,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) s_Parameters.m_XScaleAdjust = s_Parameters.m_YScaleAdjust = 1.0; s_SelectedLayers = 0; - for( LAYER_NUM layer = FIRST_LAYER; layerSetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); @@ -52,6 +52,7 @@ DIALOG_PRINT_USING_PRINTER_base::DIALOG_PRINT_USING_PRINTER_base( wxWindow* pare bmiddleLeftSizer->Add( m_FineAdjustXscaleTitle, 0, wxRIGHT|wxLEFT, 5 ); m_FineAdjustXscaleOpt = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_FineAdjustXscaleOpt->SetMaxLength( 0 ); m_FineAdjustXscaleOpt->SetToolTip( _("Set X scale adjust for exact scale plotting") ); bmiddleLeftSizer->Add( m_FineAdjustXscaleOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); @@ -61,6 +62,7 @@ DIALOG_PRINT_USING_PRINTER_base::DIALOG_PRINT_USING_PRINTER_base( wxWindow* pare bmiddleLeftSizer->Add( m_FineAdjustYscaleTitle, 0, wxRIGHT|wxLEFT, 5 ); m_FineAdjustYscaleOpt = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_FineAdjustYscaleOpt->SetMaxLength( 0 ); m_FineAdjustYscaleOpt->SetToolTip( _("Set Y scale adjust for exact scale plotting") ); bmiddleLeftSizer->Add( m_FineAdjustYscaleOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); @@ -101,6 +103,7 @@ DIALOG_PRINT_USING_PRINTER_base::DIALOG_PRINT_USING_PRINTER_base( wxWindow* pare b_buttonsSizer->Add( m_buttonPreview, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); m_buttonPrint = new wxButton( this, wxID_PRINT_ALL, _("Print"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonPrint->SetDefault(); b_buttonsSizer->Add( m_buttonPrint, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -114,22 +117,22 @@ DIALOG_PRINT_USING_PRINTER_base::DIALOG_PRINT_USING_PRINTER_base( wxWindow* pare this->Layout(); // Connect Events - this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnCloseWindow ) ); - m_ScaleOption->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnScaleSelectionClick ), NULL, this ); - m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPageSetup ), NULL, this ); - m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintPreview ), NULL, this ); - m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintButtonClick ), NULL, this ); - m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnButtonCancelClick ), NULL, this ); + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) ); + m_ScaleOption->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnScaleSelectionClick ), NULL, this ); + m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPageSetup ), NULL, this ); + m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this ); + m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintButtonClick ), NULL, this ); + m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnButtonCancelClick ), NULL, this ); } -DIALOG_PRINT_USING_PRINTER_base::~DIALOG_PRINT_USING_PRINTER_base() +DIALOG_PRINT_USING_PRINTER_BASE::~DIALOG_PRINT_USING_PRINTER_BASE() { // Disconnect Events - this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnCloseWindow ) ); - m_ScaleOption->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnScaleSelectionClick ), NULL, this ); - m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPageSetup ), NULL, this ); - m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintPreview ), NULL, this ); - m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintButtonClick ), NULL, this ); - m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnButtonCancelClick ), NULL, this ); + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) ); + m_ScaleOption->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnScaleSelectionClick ), NULL, this ); + m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPageSetup ), NULL, this ); + m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this ); + m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintButtonClick ), NULL, this ); + m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnButtonCancelClick ), NULL, this ); } diff --git a/gerbview/dialogs/dialog_print_using_printer_base.fbp b/gerbview/dialogs/dialog_print_using_printer_base.fbp index 4ec6f23826..15aa57c9ec 100644 --- a/gerbview/dialogs/dialog_print_using_printer_base.fbp +++ b/gerbview/dialogs/dialog_print_using_printer_base.fbp @@ -40,7 +40,7 @@ wxID_ANY -1,-1 - DIALOG_PRINT_USING_PRINTER_base + DIALOG_PRINT_USING_PRINTER_BASE 551,314 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER @@ -1002,7 +1002,7 @@ 1 1 - 0 + 1 0 Dock 0 diff --git a/gerbview/dialogs/dialog_print_using_printer_base.h b/gerbview/dialogs/dialog_print_using_printer_base.h index 987c209eb0..9f014ed829 100644 --- a/gerbview/dialogs/dialog_print_using_printer_base.h +++ b/gerbview/dialogs/dialog_print_using_printer_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 10 2012) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -11,6 +11,8 @@ #include #include #include +class DIALOG_SHIM; + #include "dialog_shim.h" #include #include @@ -29,9 +31,9 @@ /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_PRINT_USING_PRINTER_base +/// Class DIALOG_PRINT_USING_PRINTER_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_PRINT_USING_PRINTER_base : public DIALOG_SHIM +class DIALOG_PRINT_USING_PRINTER_BASE : public DIALOG_SHIM { private: @@ -68,8 +70,8 @@ class DIALOG_PRINT_USING_PRINTER_base : public DIALOG_SHIM public: - DIALOG_PRINT_USING_PRINTER_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 551,314 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_PRINT_USING_PRINTER_base(); + DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 551,314 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_PRINT_USING_PRINTER_BASE(); }; diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp index b680f86902..525081a5bb 100644 --- a/gerbview/draw_gerber_screen.cpp +++ b/gerbview/draw_gerber_screen.cpp @@ -39,6 +39,7 @@ #include #include #include +#include void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer, @@ -56,10 +57,13 @@ void GERBVIEW_FRAME::PrintPage( wxDC* aDC, LAYER_MSK aPrintMasklayer, m_DisplayOptions.m_DisplayDCodes = false; m_DisplayOptions.m_IsPrinting = true; - m_canvas->SetPrintMirrored( aPrintMirrorMode ); + PRINT_PARAMETERS* printParameters = (PRINT_PARAMETERS*)aData; - // XXX -1 as drawmode? - GetGerberLayout()->Draw( m_canvas, aDC, UNSPECIFIED_DRAWMODE, wxPoint( 0, 0 ) ); + m_canvas->SetPrintMirrored( aPrintMirrorMode ); + bool printBlackAndWhite = printParameters && printParameters->m_Print_Black_and_White; + + GetGerberLayout()->Draw( m_canvas, aDC, UNSPECIFIED_DRAWMODE, + wxPoint( 0, 0 ), printBlackAndWhite ); m_canvas->SetPrintMirrored( false ); @@ -123,13 +127,13 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) * Redraw All GerbView layers, using a buffered mode or not */ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, - const wxPoint& aOffset ) + const wxPoint& aOffset, bool aPrintBlackAndWhite ) { // Because Images can be negative (i.e with background filled in color) items are drawn // graphic layer per graphic layer, after the background is filled // to a temporary bitmap // at least when aDrawMode = GR_COPY or aDrawMode = GR_OR - // If aDrawMode = -1, items are drawn to the main screen, and therefore + // If aDrawMode = UNSPECIFIED_DRAWMODE, items are drawn to the main screen, and therefore // artifacts can happen with negative items or negative images wxColour bgColor = MakeColour( g_DrawBgColor ); @@ -200,7 +204,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, if( layer == active_layer ) // active layer will be drawn after other layers continue; - if( layer == 32 ) // last loop: draw active layer + if( layer == NB_GERBER_LAYERS ) // last loop: draw active layer { end = true; layer = active_layer; @@ -214,6 +218,12 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, if( gerber == NULL ) // Graphic layer not yet used continue; + EDA_COLOR_T color = gerbFrame->GetLayerColor( layer ); + + // Force black and white draw mode on request: + if( aPrintBlackAndWhite ) + gerbFrame->SetLayerColor( layer, g_DrawBgColor == BLACK ? WHITE : BLACK ); + if( useBufferBitmap ) { // Draw each layer into a bitmap first. Negative Gerber @@ -299,6 +309,9 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode, item->Draw( aPanel, plotDC, drawMode, wxPoint(0,0) ); doBlit = true; } + + if( aPrintBlackAndWhite ) + gerbFrame->SetLayerColor( layer, color ); } if( doBlit && useBufferBitmap ) // Blit is used only if aDrawMode >= 0 diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index e06f59f07b..55aa35f151 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -56,6 +56,12 @@ * T0 * M30 */ + /* + * Note there are some variant of tool definition: + * T1F00S00C... Feed Rate and Spindle Speed of Tool 1 + * Feed Rate and Spindle Speed are just skipped because they are not used in a viwer + */ + #include #include #include @@ -73,6 +79,14 @@ #include +// Default format for dimensions +// number of digits in mantissa: +static int fmtMantissaMM = 3; +static int fmtMantissaInch = 4; +// number of digits, integer part: +static int fmtIntegerMM = 3; +static int fmtIntegerInch = 2; + extern int ReadInt( char*& text, bool aSkipSeparator = true ); extern double ReadDouble( char*& text, bool aSkipSeparator = true ); extern void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem, @@ -426,12 +440,21 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text ) case DRILL_TOOL_INFORMATION: // Read a tool definition like T1C0.02: + // or T1F00S00C0.02000 // Read tool number: iprm = ReadInt( text, false ); + // Skip Feed rate and Spindle speed + while( *text && ( *text == 'F' || *text == 'S' ) ) + { + text++; + ReadInt( text, false ); + } + // Read tool shape if( *text != 'C' ) - ReportMessage( _( "Tool definition <%c> not supported" ) ); + ReportMessage( wxString:: Format( + _( "Tool definition <%c> not supported" ), *text ) ); if( *text ) text++; @@ -622,19 +645,30 @@ bool EXCELLON_IMAGE::Execute_EXCELLON_G_Command( char*& text ) void EXCELLON_IMAGE::SelectUnits( bool aMetric ) { - /* Inches: Default fmt = 2.4 for X and Y axis: 6 digits with 0.0001 resolution (00.0000) - * metric: Default fmt = 3.2 for X and Y axis: 5 digits, 1 micron resolution (00.000) + /* Coordinates are measured either in inch or metric (millimeters). + * Inch coordinates are in six digits (00.0000) with increments + * as small as 0.0001 (1/10,000). + * Metric coordinates can be measured in microns (thousandths of a millimeter) + * in one of the following three ways: + * Five digit 10 micron resolution (000.00) + * Six digit 10 micron resolution (0000.00) + * Six digit micron resolution (000.000) + */ + /* Inches: Default fmt = 2.4 for X and Y axis: 6 digits with 0.0001 resolution + * metric: Default fmt = 3.3 for X and Y axis: 6 digits, 1 micron resolution */ if( aMetric ) { m_GerbMetric = true; - m_FmtScale.x = m_FmtScale.y = 3; // number of digits in mantissa: here 2 - m_FmtLen.x = m_FmtLen.y = 5; // number of digits: here 3+2 + // number of digits in mantissa + m_FmtScale.x = m_FmtScale.y = fmtMantissaMM; + // number of digits (mantissa+interger) + m_FmtLen.x = m_FmtLen.y = fmtIntegerMM+fmtMantissaMM; } else { m_GerbMetric = false; - m_FmtScale.x = m_FmtScale.y = 4; // number of digits in mantissa: here 4 - m_FmtLen.x = m_FmtLen.y = 6; // number of digits: here 2+4 + m_FmtScale.x = m_FmtScale.y = fmtMantissaInch; + m_FmtLen.x = m_FmtLen.y = fmtIntegerInch+fmtMantissaInch; } } diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 9bfac36737..0aaeef6917 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -378,14 +378,14 @@ void GERBVIEW_FRAME::syncLayerBox() UpdateTitleAndInfo(); } - void GERBVIEW_FRAME::Liste_D_Codes() { int ii, jj; D_CODE* pt_D_code; wxString Line; wxArrayString list; - double scale = IU_PER_MILS * 1000; + double scale = g_UserUnit == INCHES ? IU_PER_MILS * 1000 : + IU_PER_MM; LAYER_NUM curr_layer = getActiveLayer(); for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer ) @@ -405,6 +405,7 @@ void GERBVIEW_FRAME::Liste_D_Codes() list.Add( Line ); + const char* units = g_UserUnit == INCHES ? "\"" : "mm"; for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ ) { pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE, false ); @@ -415,19 +416,19 @@ void GERBVIEW_FRAME::Liste_D_Codes() if( !pt_D_code->m_InUse && !pt_D_code->m_Defined ) continue; - Line.Printf( wxT( "tool %2.2d: D%2.2d V %2.4f H %2.4f %s" ), + Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s " ), jj, pt_D_code->m_Num_Dcode, - pt_D_code->m_Size.y / scale, - pt_D_code->m_Size.x / scale, + pt_D_code->m_Size.y / scale, units, + pt_D_code->m_Size.x / scale, units, D_CODE::ShowApertureType( pt_D_code->m_Shape ) ); if( !pt_D_code->m_Defined ) - Line += wxT( " ?" ); + Line += wxT( "(not used)" ); if( !pt_D_code->m_InUse ) - Line += wxT( " *" ); + Line += wxT( "(in use)" ); list.Add( Line ); jj++; diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index 4376d40ef5..755142e107 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -59,7 +59,7 @@ static const wxString tracePrinting( wxT( "KicadPrinting" ) ); PRINT_PARAMETERS::PRINT_PARAMETERS() { - m_PenDefaultSize = Millimeter2iu( 0.2 ); // A reasonable defualt value to draw items + m_PenDefaultSize = Millimeter2iu( 0.2 ); // A reasonable default value to draw items // which do not have a specified line width m_PrintScale = 1.0; m_XScaleAdjust = 1.0; @@ -290,9 +290,6 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() GRResetPenAndBrush( dc ); - if( m_PrintParams.m_Print_Black_and_White ) - GRForceBlackPen( true ); - EDA_DRAW_PANEL* panel = m_Parent->GetCanvas(); EDA_RECT tmp = *panel->GetClipBox(); @@ -358,15 +355,26 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() { // Creates a "local" black background GRForceBlackPen( true ); - m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror, &m_PrintParams ); + m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, + printMirror, &m_PrintParams ); GRForceBlackPen( false ); } + if( m_PrintParams.m_Print_Black_and_White ) + GRForceBlackPen( true ); + if( m_PrintParams.PrintBorderAndTitleBlock() ) m_Parent->DrawWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize, IU_PER_MILS, titleblockFilename ); - m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror, &m_PrintParams ); +#if defined (GERBVIEW) + // In B&W mode, do not force black pen for Gerbview + // because negative objects need a white pen, not a black pen + // B&W mode is handled in print page + GRForceBlackPen( false ); +#endif + m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror, + &m_PrintParams ); g_DrawBgColor = bg_color; screen->m_IsPrinting = false;