diff --git a/change_log.txt b/change_log.txt index bac97a5ee5..fc39aac7b8 100644 --- a/change_log.txt +++ b/change_log.txt @@ -5,6 +5,26 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2008-Mar-1 UPDATE Dick Hollenbeck +================================================================================ ++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(). + Will add a UI for editing those soon as soon class LAYER is stable. The + BOARD::SetLayerXXXX( int layerNdx, VALUE ) functions would simply route to + LAYER::SetXXXX( VALUE ). Then layer specific global variables would migrate + to the BOARD::LAYER[]s. + + Jean-Pierre please have a look at pcbstruct.h's class LAYER which is just a + prototype for now. EDA_BoardDesignSettings::m_LayerColor would go away, + and then I would add ptr_vector to EDA_BoardDesignSettings or BOARD. + Whether EDA_BoardDesignSettings or BOARD I don't have a strong preference. + I understand this is a bunch of work, and there are tricks needed to handle + adding and deleting the number of layers.... + + 2008-Feb-29 UPDATE Dick Hollenbeck ================================================================================ +pcbnew diff --git a/include/pcbstruct.h b/include/pcbstruct.h index d3eb399f19..6c86fcd0f5 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -148,6 +148,38 @@ 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 @@ -266,7 +298,7 @@ public: #include "class_zone.h" -class DISPLAY_OPTIONS +class DISPLAY_OPTIONS { public: bool DisplayPadFill; diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 0f39e01271..cee325e969 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -84,6 +84,27 @@ wxString BOARD::GetLayerName( int aLayerIndex ) const } +bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName ) +{ + // a dummy temporarily. + D(printf("SetLayerName( %d, %s )\n", aLayerIndex, CONV_TO_UTF8(aLayerName) );) + return true; +} + + +LAYER_T BOARD::GetLayerType( int aLayerIndex ) const +{ + return LT_SIGNAL; +} + + +bool BOARD::SetLayerType( int aLayerIndex, LAYER_T aLayerType ) +{ + // a dummy temporarily. + return true; +} + + int BOARD::GetCopperLayerCount() const { return m_BoardSettings->m_CopperLayerCount; @@ -624,7 +645,8 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, } -/* now using PcbGeneralLocateAndDisplay() +/* now using PcbGeneralLocateAndDisplay(), but this remains a useful example + of how the INSPECTOR can be used in a lightweight way. // see pcbstruct.h BOARD_ITEM* BOARD::FindPadOrModule( const wxPoint& refPos, int layer ) { @@ -993,13 +1015,13 @@ void BOARD::Show( int nestLevel, std::ostream& os ) for( ; p; p = p->Next() ) p->Show( nestLevel+2, os ); NestedSpace( nestLevel+1, os ) << "\n"; - /* + /* NestedSpace( nestLevel+1, os ) << "\n"; for( ZONE_CONTAINERS::iterator i=m_ZoneDescriptorList.begin(); i!=m_ZoneDescriptorList.end(); ++i ) (*i)->Show( nestLevel+2, os ); NestedSpace( nestLevel+1, os ) << "\n"; - */ - + */ + p = (BOARD_ITEM*) m_Son; for( ; p; p = p->Next() ) { diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 81ab07cec9..fcab5340ea 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -8,6 +8,19 @@ class ZONE_CONTAINER; class EDA_BoardDesignSettings; + +/** + * Enum LAYER_T + * gives the allowed types of layers, same as Specctra DSN spec. + */ +enum LAYER_T +{ + LT_SIGNAL, + LT_POWER, + LT_MIXED, +}; + + /***********************************************/ /* class BOARD : handle datas to build a board */ /***********************************************/ @@ -134,14 +147,45 @@ public: /** * Function GetLayerName - * returns the name of the requested layer. Hopefully layer names will - * be stored in the BOARD. This function anticipates that. + * returns the name of the copper layer given by aLayerIndex. * * @param aLayerIndex A layer index, like COPPER_LAYER_N, etc. * @return wxString - the layer name. */ wxString GetLayerName( int aLayerIndex ) const; + /** + * Function SetLayerName + * changes the name of the layer given by aLayerIndex. + * + * @param aLayerIndex A layer index, like COPPER_LAYER_N, etc. + * @param aLayerName The new layer name + * @return bool - true if aLayerName was legal and unique amoung other + * layer names at other layer indices and aLayerIndex was within range, else false. + */ + bool SetLayerName( int aLayerIndex, const wxString& aLayerName ); + + /** + * Function GetLayerType + * returns the type of the copper layer given by aLayerIndex. + * + * @param aLayerIndex A layer index, like COPPER_LAYER_N, etc. + * @return LAYER_T - the layer type, or LAYER_T(-1) if the + * index was out of range. + */ + LAYER_T GetLayerType( int aLayerIndex ) const; + + /** + * Function SetLayerName + * changes the name of the layer given by aLayerIndex. + * + * @param aLayerIndex A layer index, like COPPER_LAYER_N, etc. + * @param aLayerType The new layer type. + * @return bool - true if aLayerType was legal and aLayerIndex was within range, else false. + */ + bool SetLayerType( int aLayerIndex, LAYER_T aLayerType ); + + /* Routines de calcul des nombres de segments pistes et zones */ int GetNumSegmTrack(); int GetNumSegmZone(); diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index d6d64ec07b..f0ef418dc5 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -92,14 +92,14 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File, int ii = 0; char line1[256]; char line2[256]; - + TRACK* NewTrack; while( GetLine( File, line1, LineNum ) ) { int makeType; unsigned long timeStamp; - + if( line1[0] == '$' ) { return ii; /* end of segmentlist: OK */ @@ -108,10 +108,10 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File, // Read the 2nd line to determine the exact type, one of: // TYPETRACK, TYPEVIA, or TYPEZONE. The type field in 2nd line // differentiates between TYPETRACK and TYPEVIA. With virtual - // functions in use, it is critical to instantiate the TYPEVIA exactly. + // functions in use, it is critical to instantiate the TYPEVIA exactly. if( GetLine( File, line2, LineNum ) == NULL ) break; - + if( line2[0] == '$' ) break; @@ -123,7 +123,7 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File, makeType = TYPEVIA; else makeType = StructType; - + switch( makeType ) { default: @@ -141,9 +141,9 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File, } NewTrack->Insert( m_Pcb, PtSegm ); - + PtSegm = NewTrack; - + PtSegm->m_TimeStamp = timeStamp; int arg_count = sscanf( line1 + 2, " %d %d %d %d %d %d %d", &shape, @@ -156,11 +156,11 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( FILE* File, if( arg_count < 7 || drill <= 0 ) PtSegm->SetDrillDefault(); - else + else PtSegm->SetDrillValue(drill); PtSegm->SetLayer( layer ); - PtSegm->SetNet( net_code ); + PtSegm->SetNet( net_code ); PtSegm->SetState( flags, ON ); } @@ -291,7 +291,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) data = strtok( NULL, " =\n\r" ); if( data ) gy = atoi( data ); - m_Auxiliary_Axis_Position.x = gx; + m_Auxiliary_Axis_Position.x = gx; m_Auxiliary_Axis_Position.y = gy; continue; } @@ -304,6 +304,18 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) continue; } + const int LAYERKEYZ = sizeof("Layer[")-1; + + if( strncmp( Line, "Layer[", LAYERKEYZ ) == 0 ) + { + const char* cp = Line + LAYERKEYZ; + int layer = atoi(cp); + + wxString layerName = CONV_FROM_UTF8( data ); + m_Pcb->SetLayerName( layer, layerName ); + continue; + } + if( stricmp( Line, "TrackWidth" ) == 0 ) { g_DesignSettings.m_CurrentTrackWidth = atoi( data ); @@ -359,7 +371,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) } else continue; - + data = strtok( NULL, " =\n\r" ); if( data ) { @@ -368,7 +380,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) } else g_UserGrid.y = g_UserGrid.x; - + GetScreen()->m_UserGrid = g_UserGrid; data = strtok( NULL, " =\n\r" ); if( data ) @@ -489,76 +501,92 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum ) #ifdef PCBNEW /***************************************************************/ -static int WriteSetup( FILE* File, WinEDA_BasePcbFrame* frame ) +static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame +#if defined(DEBUG) + , BOARD* aBoard +#endif + ) /***************************************************************/ { char text[1024]; int ii, jj; - fprintf( File, "$SETUP\n" ); + fprintf( aFile, "$SETUP\n" ); sprintf( text, "InternalUnit %f INCH\n", 1.0 / PCB_INTERNAL_UNIT ); - fprintf( File, text ); + fprintf( aFile, text ); - if( frame->GetScreen()->m_UserGridIsON ) + if( aFrame->GetScreen()->m_UserGridIsON ) ii = jj = -1; else { - ii = frame->GetScreen()->GetGrid().x; - jj = frame->GetScreen()->GetGrid().y; + ii = aFrame->GetScreen()->GetGrid().x; + jj = aFrame->GetScreen()->GetGrid().y; } - + sprintf( text, "GridSize %d %d\n", ii, jj ); - fprintf( File, text ); + fprintf( aFile, text ); sprintf( text, "UserGridSize %lf %lf %s\n", - frame->GetScreen()->m_UserGrid.x, frame->GetScreen()->m_UserGrid.y, + aFrame->GetScreen()->m_UserGrid.x, aFrame->GetScreen()->m_UserGrid.y, ( g_UserGrid_Unit == 0 ) ? "INCH" : "mm" ); - fprintf( File, text ); + fprintf( aFile, text ); - fprintf( File, "ZoneGridSize %d\n", g_GridRoutingSize ); + fprintf( aFile, "ZoneGridSize %d\n", g_GridRoutingSize ); - fprintf( File, "Layers %d\n", g_DesignSettings.m_CopperLayerCount ); - fprintf( File, "TrackWidth %d\n", g_DesignSettings.m_CurrentTrackWidth ); + +#if defined(DEBUG) + fprintf( aFile, "Layers %d\n", aBoard->GetCopperLayerCount() ); + for( int layer=0; layerGetCopperLayerCount(); ++layer ) + { + fprintf( aFile, "Layer[%d] %s\n", layer, CONV_TO_UTF8( aBoard->GetLayerName(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++ ) { if( g_DesignSettings.m_TrackWidthHistory[ii] == 0 ) break; - fprintf( File, "TrackWidthHistory %d\n", + fprintf( aFile, "TrackWidthHistory %d\n", g_DesignSettings.m_TrackWidthHistory[ii] ); } - fprintf( File, "TrackClearence %d\n", g_DesignSettings.m_TrackClearence ); - fprintf( File, "ZoneClearence %d\n", g_DesignSettings.m_ZoneClearence ); + fprintf( aFile, "TrackClearence %d\n", g_DesignSettings.m_TrackClearence ); + fprintf( aFile, "ZoneClearence %d\n", g_DesignSettings.m_ZoneClearence ); + + fprintf( aFile, "DrawSegmWidth %d\n", g_DesignSettings.m_DrawSegmentWidth ); + fprintf( aFile, "EdgeSegmWidth %d\n", g_DesignSettings.m_EdgeSegmentWidth ); + fprintf( aFile, "ViaSize %d\n", g_DesignSettings.m_CurrentViaSize ); + fprintf( aFile, "ViaDrill %d\n", g_DesignSettings.m_ViaDrill ); - fprintf( File, "DrawSegmWidth %d\n", g_DesignSettings.m_DrawSegmentWidth ); - fprintf( File, "EdgeSegmWidth %d\n", g_DesignSettings.m_EdgeSegmentWidth ); - fprintf( File, "ViaSize %d\n", g_DesignSettings.m_CurrentViaSize ); - fprintf( File, "ViaDrill %d\n", g_DesignSettings.m_ViaDrill ); for( ii = 0; ii < HISTORY_NUMBER; ii++ ) { if( g_DesignSettings.m_ViaSizeHistory[ii] == 0 ) break; - fprintf( File, "ViaSizeHistory %d\n", g_DesignSettings.m_ViaSizeHistory[ii] ); + fprintf( aFile, "ViaSizeHistory %d\n", g_DesignSettings.m_ViaSizeHistory[ii] ); } - fprintf( File, "MicroViaSize %d\n", g_DesignSettings.m_CurrentMicroViaSize); - fprintf( File, "MicroViaDrill %d\n", g_DesignSettings.m_MicroViaDrill); - fprintf( File, "MicroViasAllowed %d\n", g_DesignSettings.m_MicroViasAllowed); + fprintf( aFile, "MicroViaSize %d\n", g_DesignSettings.m_CurrentMicroViaSize); + fprintf( aFile, "MicroViaDrill %d\n", g_DesignSettings.m_MicroViaDrill); + fprintf( aFile, "MicroViasAllowed %d\n", g_DesignSettings.m_MicroViasAllowed); - fprintf( File, "TextPcbWidth %d\n", g_DesignSettings.m_PcbTextWidth ); - fprintf( File, "TextPcbSize %d %d\n", + fprintf( aFile, "TextPcbWidth %d\n", g_DesignSettings.m_PcbTextWidth ); + fprintf( aFile, "TextPcbSize %d %d\n", g_DesignSettings.m_PcbTextSize.x, g_DesignSettings.m_PcbTextSize.y ); - - fprintf( File, "EdgeModWidth %d\n", ModuleSegmentWidth ); - fprintf( File, "TextModSize %d %d\n", ModuleTextSize.x, ModuleTextSize.y ); - fprintf( File, "TextModWidth %d\n", ModuleTextWidth ); - fprintf( File, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y ); - fprintf( File, "PadDrill %d\n", g_Pad_Master.m_Drill.x ); - fprintf( File, "AuxiliaryAxisOrg %d %d\n", - frame->m_Auxiliary_Axis_Position.x, frame->m_Auxiliary_Axis_Position.y ); - - fprintf( File, "$EndSETUP\n\n" ); + fprintf( aFile, "EdgeModWidth %d\n", ModuleSegmentWidth ); + fprintf( aFile, "TextModSize %d %d\n", ModuleTextSize.x, ModuleTextSize.y ); + fprintf( aFile, "TextModWidth %d\n", ModuleTextWidth ); + fprintf( aFile, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y ); + fprintf( aFile, "PadDrill %d\n", g_Pad_Master.m_Drill.x ); + + fprintf( aFile, "AuxiliaryAxisOrg %d %d\n", + aFrame->m_Auxiliary_Axis_Position.x, aFrame->m_Auxiliary_Axis_Position.y ); + + fprintf( aFile, "$EndSETUP\n\n" ); return 1; } @@ -841,11 +869,11 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append ) if( strnicmp( Line, "$CZONE_OUTLINE", 7 ) == 0 ) { - ZONE_CONTAINER * zone_descr = new ZONE_CONTAINER(m_Pcb); - zone_descr->ReadDescr( File, &LineNum ); - m_Pcb->Add(zone_descr); + ZONE_CONTAINER * zone_descr = new ZONE_CONTAINER(m_Pcb); + zone_descr->ReadDescr( File, &LineNum ); + m_Pcb->Add(zone_descr); continue; - } + } if( strnicmp( Line, "$MODULE", 7 ) == 0 ) { @@ -991,9 +1019,9 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append ) setlocale( LC_NUMERIC, "" ); // revert to the current locale Affiche_Message( wxEmptyString ); - - BestZoom(); - DrawPanel->ReDraw(DC, true); + + BestZoom(); + DrawPanel->ReDraw(DC, true); #ifdef PCBNEW Compile_Ratsnest( DC, TRUE ); @@ -1015,32 +1043,36 @@ int WinEDA_PcbFrame::SavePcbFormatAscii( FILE* aFile ) { bool rc; char line[256]; - + m_Pcb->m_Status_Pcb &= ~CONNEXION_OK; wxBeginBusyCursor(); - + // Switch the locale to standard C (needed to print floating point numbers like 1.3) setlocale( LC_NUMERIC, "C" ); - + /* Ecriture de l'entete PCB : */ fprintf( aFile, "PCBNEW-BOARD Version %d date %s\n\n", g_CurrentVersionPCB, DateAndTime( line ) ); WriteGeneralDescrPcb( aFile ); WriteSheetDescr( m_CurrentScreen, aFile ); - WriteSetup( aFile, this ); + WriteSetup( aFile, this +#if defined(DEBUG) + , m_Pcb +#endif + ); rc = m_Pcb->Save( aFile ); - + setlocale( LC_NUMERIC, "" ); // revert to the current locale wxEndBusyCursor(); - + if( !rc ) DisplayError( this, wxT( "Unable to save PCB file" ) ); else Affiche_Message( wxEmptyString ); - + return rc; } diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 88829775d8..cc847ddb69 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -640,6 +640,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule ) } } +#if 1 // enable image (outline) scopes. static const KICAD_T scanEDGEs[] = { TYPEEDGEMODULE, EOT }; // get all the MODULE's EDGE_MODULEs and convert those to DSN outlines. @@ -707,6 +708,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule ) continue; } } +#endif return image; }