From 726a8ab4df841d5b378492fbb5d3ee5955c39342 Mon Sep 17 00:00:00 2001 From: dickelbeck Date: Thu, 30 Aug 2007 22:20:52 +0000 Subject: [PATCH] collector work --- 3d-viewer/3d_draw.cpp | 2 +- change_log.txt | 36 ++++-- common/base_struct.cpp | 2 +- include/base_struct.h | 51 ++++---- include/class_collector.h | 94 +++++++++------ include/pcbstruct.h | 56 ++++----- include/wxstruct.h | 4 +- pcbnew/block.cpp | 3 +- pcbnew/class_board.cpp | 80 +++++++++++-- pcbnew/class_cotation.h | 2 +- pcbnew/class_edge_mod.h | 4 +- pcbnew/class_module.cpp | 7 +- pcbnew/class_module.h | 4 +- pcbnew/class_pad.cpp | 7 ++ pcbnew/class_pad.h | 16 ++- pcbnew/class_pcb_text.h | 2 +- pcbnew/class_text_mod.h | 4 +- pcbnew/class_track.cpp | 63 ++++++---- pcbnew/class_track.h | 41 +++++-- pcbnew/classpcb.cpp | 2 +- pcbnew/collectors.cpp | 164 ++++++++++++++++++-------- pcbnew/collectors.h | 241 ++++++++++++++++++++++++++++++++------ pcbnew/controle.cpp | 20 ++-- pcbnew/editrack-part2.cpp | 7 +- pcbnew/editrack.cpp | 8 +- pcbnew/files.cpp | 2 +- pcbnew/ioascii.cpp | 72 ++++++++---- pcbnew/locate.cpp | 2 +- pcbnew/pcbframe.cpp | 2 +- 29 files changed, 712 insertions(+), 286 deletions(-) diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index fb0977924e..056a2862d8 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -530,7 +530,7 @@ int color; break; case RECT : - case SPECIAL_PAD: +// case SPECIAL_PAD: case TRAPEZE: { int ddx, ddy ; diff --git a/change_log.txt b/change_log.txt index 68b17e01c6..be32cede1f 100644 --- a/change_log.txt +++ b/change_log.txt @@ -4,14 +4,34 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2007-Aug-30 UPDATE Dick Hollenbeck +================================================================================ ++ pcbnew + * Removed SEGVIA::IsViaOnLayer, and instead implemented an override to + virtual BOARD_ITEM::IsOnLayer() called SEGVIA::IsOnLayer(). + * Tweaked TRACK::Visit() to not traverse the KICAD_T scan list and a + corresponding change to BOARD::Vist() so we can now get VIA priority + if desired. (Have to traverse m_Tracks twice, wonder if we could use + two lists: m_Tracks and a new m_Vias?) + * Changed signature of MODULE::Display_Infos( WinEDA_DrawFrame* frame ) so + it gets called virtually with any BOARD_ITEM* which is actually a MODULE*. + This was a bug. + * With virtual functions, it is now critical that the correct object type + be instantiated. This was not happening in ioascii.cpp when reading + the vias. Bug fixed. + * GENERAL_COLLECTOR getting closer to useable. + @todo search further for new TRACK( TRACK* ) and make sure no vias are + being made this way. + + 2007-aug-30 UPDATE Jean-Pierre Charras ================================================================================ + eeschema & pcbnew - more about programmable hotkeys. - Most existing hotkeys are programmable and displayed in popup menus or tools - Work still in progress but most features are ok. - some features are not fixed (mainly the configuration files path, which is - currently the home directory under unix systems and kicad/template under windows)) + more about programmable hotkeys. + Most existing hotkeys are programmable and displayed in popup menus or tools + Work still in progress but most features are ok. + some features are not fixed (mainly the configuration files path, which is + currently the home directory under unix systems and kicad/template under windows)) 2007-Aug-29 UPDATE Dick Hollenbeck @@ -26,7 +46,7 @@ email address. 2007-aug-27 UPDATE Jean-Pierre Charras ================================================================================ + all - Display grid size in mils or mm in popup menu according to the current unit choice + Display grid size in mils or mm in popup menu according to the current unit choice 2007-Aug-24 UPDATE Dick Hollenbeck @@ -93,8 +113,8 @@ email address. 2007-aug-21 UPDATE Jean-Pierre Charras ================================================================================ + eeschema & pcbnew - First version of programmable hotkeys by editing hotkey configuration files. - some hotkeys are not programmable (Zoom)(work in progress) + First version of programmable hotkeys by editing hotkey configuration files. + some hotkeys are not programmable (Zoom)(work in progress) 2007-Aug-21 UPDATE Dick Hollenbeck diff --git a/common/base_struct.cpp b/common/base_struct.cpp index 2a9f8d3ac3..4109ee86df 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -211,7 +211,7 @@ SEARCH_RESULT EDA_BaseStruct::Visit( INSPECTOR* inspector, const void* testData, { KICAD_T stype; -#if defined(DEBUG) +#if 0 && defined(DEBUG) std::cout << GetClass().mb_str() << ' '; #endif diff --git a/include/base_struct.h b/include/base_struct.h index a529a9069f..57b51d0665 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -160,7 +160,7 @@ private: int m_Status; private: - void InitVars( void ); + void InitVars(); public: @@ -174,7 +174,7 @@ public: int GetState( int type ); void SetState( int type, int state ); - int ReturnStatus( void ) const + int ReturnStatus() const { return m_Status; } @@ -347,11 +347,11 @@ public: public: EDA_TextStruct( const wxString& text = wxEmptyString ); - virtual ~EDA_TextStruct( void ); - void CreateDrawData( void ); + virtual ~EDA_TextStruct(); + void CreateDrawData(); - int GetLength( void ) { return m_Text.Length(); }; - int Pitch( void );/* retourne le pas entre 2 caracteres */ + int GetLength() { return m_Text.Length(); }; + int Pitch();/* retourne le pas entre 2 caracteres */ void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int color, int draw_mode, int display_mode = FILAIRE, int anchor_color = -1 ); @@ -364,13 +364,13 @@ public: */ bool HitTest( const wxPoint& ref_pos ); - int Len_Size( void ); // Return the text lenght in internal units + int Len_Size(); // Return the text lenght in internal units }; /** * Class BOARD_ITEM - * is an abstract base class for any item which can be embedded within the BOARD + * is a base class for any item which can be embedded within the BOARD * container class, and therefore instances of derived classes should only be * found in PCBNEW or other programs that use class BOARD and its contents. * The corresponding class in EESCHEMA seems to be DrawPartStruct. @@ -441,7 +441,7 @@ public: /** * Function IsLocked - * @returns bool - true if the object is locked, else false + * @return bool - true if the object is locked, else false */ virtual bool IsLocked() const { @@ -469,11 +469,11 @@ public: public: DrawPickedStruct( EDA_BaseStruct* pickedstruct = NULL ); - ~DrawPickedStruct( void ); + ~DrawPickedStruct(); void Place( WinEDA_DrawFrame* frame, wxDC* DC ) { }; - void DeleteWrapperList( void ); + void DeleteWrapperList(); - DrawPickedStruct* Next( void ) { return (DrawPickedStruct*) Pnext; } + DrawPickedStruct* Next() { return (DrawPickedStruct*) Pnext; } }; @@ -490,27 +490,28 @@ public: wxSize m_Size; // Rectangle Size public: - EDA_Rect( void ) { }; - wxPoint Centre( void ) + EDA_Rect() { }; + + wxPoint Centre() { return wxPoint( m_Pos.x + (m_Size.x >> 1), m_Pos.y + (m_Size.y >> 1) ); } - void Normalize( void ); // Ensure the height ant width are >= 0 + void Normalize(); // Ensure the height and width are >= 0 bool Inside( const wxPoint& point ); // Return TRUE if point is in Rect bool Inside( int x, int y ) { return Inside( wxPoint( x, y ) ); } - wxSize GetSize( void ) { return m_Size; } - int GetX( void ) { return m_Pos.x; } - int GetY( void ) { return m_Pos.y; } - wxPoint GetOrigin( void ) { return m_Pos; } - wxPoint GetPosition( void ) { return m_Pos; } - wxPoint GetEnd( void ) { return wxPoint( GetRight(), GetBottom() ); } - int GetWidth( void ) { return m_Size.x; } - int GetHeight( void ) { return m_Size.y; } - int GetRight( void ) { return m_Pos.x + m_Size.x; } - int GetBottom( void ) { return m_Pos.y + m_Size.y; } + wxSize GetSize() { return m_Size; } + int GetX() { return m_Pos.x; } + int GetY() { return m_Pos.y; } + wxPoint GetOrigin() { return m_Pos; } + wxPoint GetPosition() { return m_Pos; } + wxPoint GetEnd() { return wxPoint( GetRight(), GetBottom() ); } + int GetWidth() { return m_Size.x; } + int GetHeight() { return m_Size.y; } + int GetRight() { return m_Pos.x + m_Size.x; } + int GetBottom() { return m_Pos.y + m_Size.y; } void SetOrigin( const wxPoint& pos ) { m_Pos = pos; } void SetOrigin( int x, int y ) { m_Pos.x = x; m_Pos.y = y; } void SetSize( const wxSize& size ) { m_Size = size; } diff --git a/include/class_collector.h b/include/class_collector.h index 2915ed910b..5acbadbcca 100644 --- a/include/class_collector.h +++ b/include/class_collector.h @@ -54,15 +54,15 @@ protected: /// Which object types to scan const KICAD_T* m_ScanTypes; - /// The layer that is desired as a primary search criterion - int m_PreferredLayer; - /// A place to hold collected objects without taking ownership of their memory. - std::vector list; + std::vector m_List; - /// The point at which the snapshot was taken. + /// A point to test against, andt that was used to make the collection. wxPoint m_RefPos; + /// A bounding box to test against, and that was used to make the collection. + EDA_Rect m_RefBox; + /// The time at which the collection was made. int m_TimeAtCollection; @@ -71,7 +71,6 @@ public: COLLECTOR() { - m_PreferredLayer = 0; m_ScanTypes = 0; } @@ -80,19 +79,13 @@ public: } - void SetPreferredLayer( int aPreferredLayer ) - { - m_PreferredLayer = aPreferredLayer; - } - - /** * Function GetCount * returns the number of objects in the list */ unsigned GetCount() const { - return list.size(); + return m_List.size(); } @@ -102,7 +95,7 @@ public: */ void Empty() { - list.clear(); + m_List.clear(); } @@ -113,7 +106,7 @@ public: */ void Append( EDA_BaseStruct* item ) { - list.push_back( item ); + m_List.push_back( item ); } @@ -126,22 +119,23 @@ public: EDA_BaseStruct* operator[]( int ndx ) const { if( (unsigned)ndx < GetCount() ) - return list[ ndx ]; + return m_List[ ndx ]; return NULL; } + + /** + * Function SetScanTypes + * records the list of KICAD_T types to consider for collection by + * the Inspect() function. + * @param scanTypes An array of KICAD_T, terminated by EOT. No copy is + * is made of this array (so cannot come from caller's stack). + */ void SetScanTypes( const KICAD_T* scanTypes ) { m_ScanTypes = scanTypes; } - wxPoint GetRefPos() const { return m_RefPos; } - - void SetRefPos( const wxPoint& arefPos ) - { - m_RefPos = arefPos; - } - void SetTimeNow() { m_TimeAtCollection = GetTimeStamp(); @@ -151,6 +145,12 @@ public: return m_TimeAtCollection; } + void SetRefPos( const wxPoint& aRefPos ) { m_RefPos = aRefPos; } + const wxPoint& GetRefPos() const { return m_RefPos; } + + void SetBoundingBox( const EDA_Rect& aRefBox ) { m_RefBox = aRefBox; } + const EDA_Rect& GetBoundingBox() const { return m_RefBox; } + /** * Function IsSimilarPointAndTime @@ -196,28 +196,56 @@ public: /** - * Function Scan - * scans a BOARD using this class's Inspector method, which does the collection. - * @param board A BOARD to scan. - * @param refPos A wxPoint to use in hit-testing. + * Function Collect + * scans an EDA_BaseStruct using this class's Inspector method, which does + * the collection. + * @param container An EDA_BaseStruct to scan, including those items it contains. + * @param aRefPos A wxPoint to use in hit-testing. * * example implementation, in derived class: * - virtual void Scan( BOARD* board, const wxPoint& refPos ) + virtual void Collect( EDA_BaseStruct* container, const wxPoint& aRefPos ) { example implementation: - SetRefPos( refPos ); // remember where the snapshot was taken from + SetRefPos( aRefPos ); // remember where the snapshot was taken from Empty(); // empty the collection // visit the board with the INSPECTOR (me). - board->Visit( this, // INSPECTOR* inspector - NULL, // const void* testData, - m_ScanTypes); - SetTimeNow(); // when it was taken + container->Visit( this, // INSPECTOR* inspector + NULL, // const void* testData, + m_ScanTypes); + SetTimeNow(); // when it was taken } */ + + + /** + * Function Collect + * scans an EDA_BaseStruct using this class's Inspector method, which does + * the collection. + * @param container An EDA_BaseStruct to scan, including those items it contains. + * @param aRefBox An EDA_Rect to use in bounds-testing. + * + * example implementation, in derived class: + * + virtual void Collect( EDA_BaseStruct* container, const EDA_Rect& aRefBox ) + { + example implementation: + + SetBoundingBox( aRefBox ); // pass box to Inspect() + + Empty(); // empty the collection + + // visit the board with the INSPECTOR (me). + container->Visit( this, // INSPECTOR* inspector + NULL, // const void* testData, + m_ScanTypes); + SetTimeNow(); // when it was taken + } + */ + }; #endif // COLLECTOR_H diff --git a/include/pcbstruct.h b/include/pcbstruct.h index 14c3b5a3a6..47cef6345b 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -175,14 +175,14 @@ public: int m_RatsnestColor; // Ratsnest color public: - EDA_BoardDesignSettings( void ); + EDA_BoardDesignSettings(); /** * Function GetVisibleLayers * returns a bit-map of all the layers that are visible. * @return int - the visible layers in bit-mapped form. */ - int GetVisibleLayers(); + int GetVisibleLayers() const; }; @@ -226,20 +226,20 @@ public: * de delimitation de la zone en cours de trace */ BOARD( EDA_BaseStruct* StructFather, WinEDA_BasePcbFrame* frame ); - ~BOARD( void ); + ~BOARD(); /* supprime du chainage la structure Struct */ - void UnLink( void ); + void UnLink(); /* Routines de calcul des nombres de segments pistes et zones */ - int GetNumSegmTrack( void ); - int GetNumSegmZone( void ); - int GetNumNoconnect( void ); // retourne le nombre de connexions manquantes - int GetNumRatsnests( void ); // retourne le nombre de chevelus - int GetNumNodes( void ); // retourne le nombre de pads a netcode > 0 + int GetNumSegmTrack(); + int GetNumSegmZone(); + int GetNumNoconnect(); // retourne le nombre de connexions manquantes + int GetNumRatsnests(); // retourne le nombre de chevelus + int GetNumNodes(); // retourne le nombre de pads a netcode > 0 // Calcul du rectangle d'encadrement: - bool ComputeBoundaryBox( void ); + bool ComputeBoundaryBox(); /** @@ -247,9 +247,9 @@ public: * has knowledge about the frame and how and where to put status information * about this object into the frame's message panel. * Is virtual from EDA_BaseStruct. - * @param frame A WinEDA_BasePcbFrame in which to print status information. + * @param frame A WinEDA_DrawFrame in which to print status information. */ - void Display_Infos( WinEDA_DrawFrame* frame ); + void Display_Infos( WinEDA_DrawFrame* frame ); /** @@ -284,10 +284,10 @@ public: /** * Function FindNet * searches for a net with the given netcode. - * @param anetcode A netcode to search for. + * @param aNetcode A netcode to search for. * @return EQUIPOT* - the net or NULL if not found. */ - EQUIPOT* FindNet( int anetcode ); + EQUIPOT* FindNet( int aNetcode ); #if defined(DEBUG) @@ -305,11 +305,11 @@ public: * Function Show * is used to output the object tree, currently for debugging only. * @param nestLevel An aid to prettier tree indenting, and is the level - * of nesting of this object within the overall tree. + * of nesting of this object within the overall tree. * @param os The ostream& to output to. */ void Show( int nestLevel, std::ostream& os ); - + #endif }; @@ -324,12 +324,12 @@ public: public: PCB_SCREEN( int idscreen ); - ~PCB_SCREEN( void ); - PCB_SCREEN* Next( void ) { return (PCB_SCREEN*) Pnext; } - void Init( void ); - void SetNextZoom( void ); - void SetPreviousZoom( void ); - void SetLastZoom( void ); + ~PCB_SCREEN(); + PCB_SCREEN* Next() { return (PCB_SCREEN*) Pnext; } + void Init(); + void SetNextZoom(); + void SetPreviousZoom(); + void SetLastZoom(); }; /***************************/ @@ -360,14 +360,14 @@ public: public: DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype = TYPEDRAWSEGMENT ); - ~DRAWSEGMENT( void ); + ~DRAWSEGMENT(); // Read/write data bool WriteDrawSegmentDescr( FILE* File ); bool ReadDrawSegmentDescr( FILE* File, int* LineNum ); /* supprime du chainage la structure Struct */ - void UnLink( void ); + void UnLink(); void Copy( DRAWSEGMENT* source ); @@ -419,7 +419,7 @@ class EDGE_ZONE : public DRAWSEGMENT public: EDGE_ZONE( BOARD_ITEM* StructFather ); EDGE_ZONE( const EDGE_ZONE& edgezone ); - ~EDGE_ZONE( void ); + ~EDGE_ZONE(); }; @@ -439,8 +439,8 @@ public: public: MARQUEUR( BOARD_ITEM* StructFather ); - ~MARQUEUR( void ); - void UnLink( void ); + ~MARQUEUR(); + void UnLink(); void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode ); }; @@ -471,7 +471,7 @@ public: bool ContrastModeDisplay; public: - DISPLAY_OPTIONS( void ); + DISPLAY_OPTIONS(); }; diff --git a/include/wxstruct.h b/include/wxstruct.h index 17bdea0811..ad2c3fac47 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -96,7 +96,7 @@ class WinEDA3D_DrawFrame; class PARAM_CFG_BASE; class Ki_PageDescr; class Ki_HotkeyInfo; -class GENERALCOLLECTOR; +class GENERAL_COLLECTOR; enum id_librarytype { @@ -374,7 +374,7 @@ private: #if defined(DEBUG) protected: - GENERALCOLLECTOR* m_Collector; + GENERAL_COLLECTOR* m_Collector; #endif diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index e140578ea7..16bb1d19f7 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -1288,7 +1288,8 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) { next_track = track->Next(); if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) - { /* la piste est ici bonne a etre deplacee */ + { + /* la piste est ici bonne a etre deplacee */ new_track = new TRACK( m_Pcb ); new_track = track->Copy( 1 ); new_track->Insert( m_Pcb, NULL ); diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 87ec8d01e8..2e2c0073b7 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -46,12 +46,12 @@ BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) : /***************/ /* Destructeur */ /***************/ -BOARD::~BOARD( void ) +BOARD::~BOARD() { } -void BOARD::UnLink( void ) +void BOARD::UnLink() { /* Modification du chainage arriere */ if( Pback ) @@ -75,7 +75,7 @@ void BOARD::UnLink( void ) /* Routines de calcul des nombres de segments pistes et zones */ -int BOARD::GetNumSegmTrack( void ) +int BOARD::GetNumSegmTrack() { TRACK* CurTrack = m_Track; int ii = 0; @@ -88,7 +88,7 @@ int BOARD::GetNumSegmTrack( void ) } -int BOARD::GetNumSegmZone( void ) +int BOARD::GetNumSegmZone() { TRACK* CurTrack = m_Zone; int ii = 0; @@ -102,28 +102,28 @@ int BOARD::GetNumSegmZone( void ) // retourne le nombre de connexions manquantes -int BOARD::GetNumNoconnect( void ) +int BOARD::GetNumNoconnect() { return m_NbNoconnect; } // retourne le nombre de chevelus -int BOARD::GetNumRatsnests( void ) +int BOARD::GetNumRatsnests() { return m_NbLinks; } // retourne le nombre de pads a netcode > 0 -int BOARD::GetNumNodes( void ) +int BOARD::GetNumNodes() { return m_NbNodes; } /***********************************/ -bool BOARD::ComputeBoundaryBox( void ) +bool BOARD::ComputeBoundaryBox() /***********************************/ /* Determine le rectangle d'encadrement du pcb @@ -313,7 +313,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, const KICAD_T* p = scanTypes; bool done=false; -#if defined(DEBUG) +#if 0 && defined(DEBUG) std::cout << GetClass().mb_str() << ' '; #endif @@ -380,7 +380,10 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, } ; break; - + +#if 0 // both these are on same list, so we must scan it twice in order to get VIA priority, + // using new #else code below. + // @todo: consider why we are not using separte lists for TRACKs and SEGVIAs. case TYPEVIA: case TYPETRACK: result = IterateForward( m_Track, inspector, testData, p ); @@ -396,7 +399,18 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData, } break; } - break; + break; +#else + case TYPEVIA: + result = IterateForward( m_Track, inspector, testData, p ); + ++p; + break; + + case TYPETRACK: + result = IterateForward( m_Track, inspector, testData, p ); + ++p; + break; +#endif case PCB_EQUIPOT_STRUCT_TYPE: result = IterateForward( m_Equipots, inspector, testData, p ); @@ -586,4 +600,48 @@ void BOARD::Show( int nestLevel, std::ostream& os ) NestedSpace( nestLevel, os ) << "\n"; } + +/* wrote this before discovering ReturnLayerName() +const char* BOARD::ShowLayer( int aLayer ) +{ + const char* rs; + + switch( aLayer ) + { + case LAYER_CUIVRE_N: rs = "cu"; break; + case LAYER_N_2: rs = "layer2"; break; + case LAYER_N_3: rs = "layer3"; break; + case LAYER_N_4: rs = "layer4"; break; + case LAYER_N_5: rs = "layer5"; break; + case LAYER_N_6: rs = "layer6"; break; + case LAYER_N_7: rs = "layer7"; break; + case LAYER_N_8: rs = "layer8"; break; + case LAYER_N_9: rs = "layer9"; break; + case LAYER_N_10: rs = "layer10"; break; + case LAYER_N_11: rs = "layer11"; break; + case LAYER_N_12: rs = "layer12"; break; + case LAYER_N_13: rs = "layer13"; break; + case LAYER_N_14: rs = "layer14"; break; + case LAYER_N_15: rs = "layer15"; break; + case LAYER_CMP_N: rs = "cmp"; break; + case ADHESIVE_N_CU: rs = "cu/adhesive"; break; + case ADHESIVE_N_CMP: rs = "cmp/adhesive"; break; + case SOLDERPASTE_N_CU: rs = "cu/sldrpaste"; break; + case SOLDERPASTE_N_CMP: rs = "cmp/sldrpaste"; break; + case SILKSCREEN_N_CU: rs = "cu/silkscreen"; break; + case SILKSCREEN_N_CMP: rs = "cmp/silkscreen"; break; + case SOLDERMASK_N_CU: rs = "cu/sldrmask"; break; + case SOLDERMASK_N_CMP: rs = "cmp/sldrmask"; break; + case DRAW_N: rs = "drawing"; break; + case COMMENT_N: rs = "comment"; break; + case ECO1_N: rs = "eco_1"; break; + case ECO2_N: rs = "eco_2"; break; + case EDGE_N: rs = "edge"; break; + default: rs = "???"; break; + } + + return rs; +} +*/ + #endif diff --git a/pcbnew/class_cotation.h b/pcbnew/class_cotation.h index a6605001cd..319f29690f 100644 --- a/pcbnew/class_cotation.h +++ b/pcbnew/class_cotation.h @@ -47,7 +47,7 @@ public: * has knowledge about the frame and how and where to put status information * about this object into the frame's message panel. * Is virtual from EDA_BaseStruct. - * @param frame A WinEDA_BasePcbFrame in which to print status information. + * @param frame A WinEDA_DrawFrame in which to print status information. */ void Display_Infos( WinEDA_DrawFrame* frame ); diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h index a8db4863d4..4ddecfad26 100644 --- a/pcbnew/class_edge_mod.h +++ b/pcbnew/class_edge_mod.h @@ -52,9 +52,9 @@ public: * has knowledge about the frame and how and where to put status information * about this object into the frame's message panel. * Is virtual from EDA_BaseStruct. - * @param frame A WinEDA_BasePcbFrame in which to print status information. + * @param frame A WinEDA_DrawFrame in which to print status information. */ - void Display_Infos( WinEDA_DrawFrame* frame ); + void Display_Infos( WinEDA_DrawFrame* frame ); /** diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 726ed828cc..b13d670fc6 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -1077,7 +1077,7 @@ void MODULE::SetRectangleExinscrit( void ) /*******************************************************/ -void MODULE::Display_Infos( WinEDA_BasePcbFrame* frame ) +void MODULE::Display_Infos( WinEDA_DrawFrame* frame ) /*******************************************************/ { int nbpad; @@ -1183,7 +1183,7 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR* inspector, const void* testData, const KICAD_T* p = scanTypes; bool done = false; -#if defined(DEBUG) +#if 0 && defined(DEBUG) std::cout << GetClass().mb_str() << ' '; #endif @@ -1256,8 +1256,9 @@ void MODULE::Show( int nestLevel, std::ostream& os ) NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << " ref=\"" << m_Reference->m_Text.mb_str() << '"' << " value=\"" << m_Value->m_Text.mb_str() << '"' << + " layer=\"" << ReturnPcbLayerName(m_Layer,true,false).mb_str() << '"' << ">\n"; - + NestedSpace( nestLevel+1, os ) << "\n"; diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index eb6c70d55e..56364dee55 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -134,9 +134,9 @@ public: * Function Display_Infos * has knowledge about the frame and how and where to put status information * about this object into the frame's message panel. - * @param frame A WinEDA_BasePcbFrame in which to print status information. + * @param frame A WinEDA_DrawFrame in which to print status information. */ - void Display_Infos( WinEDA_BasePcbFrame* frame ); + void Display_Infos( WinEDA_DrawFrame* frame ); /** diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 217384bef3..d9b70d76b8 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -958,6 +958,13 @@ void D_PAD::Display_Infos( WinEDA_DrawFrame* frame ) } +// see class_pad.h +bool D_PAD::IsOnLayer( int aLayer ) const +{ + return (1<Inspect( this, testData ) ) + return SEARCH_QUIT; + } + + return SEARCH_CONTINUE; +} + + +// see class_track.h +bool SEGVIA::IsOnLayer( int layer_number ) const { int via_type = Shape(); if( via_type == VIA_NORMALE ) { if( layer_number <= LAYER_CMP_N ) - return TRUE; + return true; else - return FALSE; + return false; } // VIA_BORGNE ou VIA_ENTERREE: int bottom_layer, top_layer; + ReturnLayerPair( &top_layer, &bottom_layer ); - if( (bottom_layer <= layer_number) && (top_layer >= layer_number) ) - return TRUE; + + if( bottom_layer <= layer_number && top_layer >= layer_number ) + return true; else - return FALSE; + return false; } /***********************************/ -int TRACK::ReturnMaskLayer( void ) +int TRACK::ReturnMaskLayer() /***********************************/ /* Retourne le masque (liste bit a bit ) des couches occupees par le segment @@ -217,7 +238,7 @@ void SEGVIA::SetLayerPair( int top_layer, int bottom_layer ) /***************************************************************/ -void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) +void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const /***************************************************************/ /* Retourne les 2 couches limitant la via @@ -239,7 +260,7 @@ void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) /* supprime du chainage la structure Struct * les structures arrieres et avant sont chainees directement */ -void TRACK::UnLink( void ) +void TRACK::UnLink() { /* Modification du chainage arriere */ if( Pback ) @@ -503,15 +524,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode ) if( DisplayOpt.ContrastModeDisplay ) { - if( m_StructType == TYPEVIA ) - { - if( !( (SEGVIA*) this )->IsViaOnLayer( curr_layer ) ) - { - color &= ~MASKCOLOR; - color |= DARKDARKGRAY; - } - } - else if( m_Layer != curr_layer ) + if( !IsOnLayer( curr_layer ) ) { color &= ~MASKCOLOR; color |= DARKDARKGRAY; diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 3baf3d2ff4..9777760ba4 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -49,7 +49,7 @@ public: /* supprime du chainage la structure Struct */ - void UnLink( void ); + void UnLink(); // Read/write data bool WriteTrackDescr( FILE* File ); @@ -74,11 +74,11 @@ public: void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode ); /* divers */ - int Shape( void ) { return m_Shape & 0xFF; } + int Shape() const { return m_Shape & 0xFF; } - int ReturnMaskLayer( void ); + int ReturnMaskLayer(); int IsPointOnEnds( const wxPoint& point, int min_dist = 0 ); - bool IsNull( void ); // return TRUE if segment lenght = 0 + bool IsNull(); // return TRUE if segment lenght = 0 /** @@ -86,11 +86,28 @@ public: * has knowledge about the frame and how and where to put status information * about this object into the frame's message panel. * Is virtual from EDA_BaseStruct. - * @param frame A WinEDA_BasePcbFrame in which to print status information. + * @param frame A WinEDA_DrawFrame in which to print status information. */ void Display_Infos( WinEDA_DrawFrame* frame ); + /** + * Function Visit + * is re-implemented here because TRACKs and SEGVIAs are in the same list + * within BOARD. If that were not true, then we could inherit the + * version from EDA_BaseStruct. This one does not iterate through scanTypes + * but only looks at the first item in the list. + * @param inspector An INSPECTOR instance to use in the inspection. + * @param testData Arbitrary data used by the inspector. + * @param scanTypes Which KICAD_T types are of interest and the order + * is significant too, terminated by EOT. + * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, + * else SCAN_CONTINUE, and determined by the inspector. + */ + SEARCH_RESULT Visit( INSPECTOR* inspector, const void* testData, + const KICAD_T scanTypes[] ); + + /** * Function HitTest * tests if the given wxPoint is within the bounds of this object. @@ -146,9 +163,19 @@ class SEGVIA : public TRACK { public: SEGVIA( BOARD_ITEM* StructFather ); - bool IsViaOnLayer( int layer ); + + /** + * Function IsOnLayer + * tests to see if this object is on the given layer. Is virtual + * from BOARD_ITEM. Tests the starting and ending range of layers for the + * via. + * @param aLayer The layer to test for. + * @return bool - true if on given layer, else false. + */ + bool IsOnLayer( int aLayer ) const; + void SetLayerPair( int top_layer, int bottom_layer ); - void ReturnLayerPair( int* top_layer, int* bottom_layer ); + void ReturnLayerPair( int* top_layer, int* bottom_layer ) const; #if defined(DEBUG) /** diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp index f9bb8cedf5..9f64597f40 100644 --- a/pcbnew/classpcb.cpp +++ b/pcbnew/classpcb.cpp @@ -432,7 +432,7 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings( void ) // see pcbstruct.h -int EDA_BoardDesignSettings::GetVisibleLayers() +int EDA_BoardDesignSettings::GetVisibleLayers() const { int layerMask = 0; diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 7ec3ee0727..936f3dcd8e 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -34,7 +34,7 @@ // see collectors.h -const KICAD_T GENERALCOLLECTOR::AllBoardItems[] = { +const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = { TYPETEXTE, TYPEDRAWSEGMENT, TYPECOTATION, @@ -59,7 +59,7 @@ const KICAD_T GENERALCOLLECTOR::AllBoardItems[] = { * @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, * else SCAN_CONTINUE; */ -SEARCH_RESULT GENERALCOLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* notUsed ) +SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* notUsed ) { BOARD_ITEM* item = (BOARD_ITEM*) testItem; @@ -94,7 +94,12 @@ SEARCH_RESULT GENERALCOLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* n } break; case TYPEMODULE: - breakhere++; + MODULE* m; + m = (MODULE*) item; + if( m->GetReference() == wxT("L1") ) + { + breakhere++; + } break; default: breakhere++; @@ -102,47 +107,96 @@ SEARCH_RESULT GENERALCOLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* n } #endif - switch( item->m_StructType ) + +#if 1 + +/* + int m_PreferredLayer; x + bool m_IgnorePreferredLayer + int m_LayerVisible; x + bool m_IgnoreNonVisibleLayers; + + int m_LayerLocked; x + bool m_IgnoreLockedLayers; + + bool m_IgnoreLockedItems; x + + bool m_IncludeSecondary; +*/ + + if( item->IsOnLayer( m_Guide->GetPreferredLayer() ) || m_Guide->IgnorePreferredLayer() ) { - case TYPEPAD: - case TYPEVIA: - case TYPETRACK: - case TYPETEXTE: - case TYPEDRAWSEGMENT: - case TYPECOTATION: - case TYPETEXTEMODULE: - case TYPEMODULE: + int layer = item->GetLayer(); - // The primary search criteria: - if( item->IsOnLayer( m_PreferredLayer ) ) + if( m_Guide->IsLayerVisible( layer ) || !m_Guide->IgnoreNonVisibleLayers() ) { - if( item->HitTest( m_RefPos ) ) + if( !m_Guide->IsLayerLocked(layer) || !m_Guide->IgnoreLockedLayers() ) { - if( !item->IsLocked() ) - Append( item ); - else - Append2nd( item ); // 2nd if locked. + if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() ) + { + if( item->HitTest( m_RefPos ) ) + { + Append( item ); + goto exit; + } + } } } - - // The secondary search criteria - else if( item->IsOnOneOfTheseLayers( m_LayerMask ) ) - { - if( item->HitTest( m_RefPos ) ) - Append2nd( item ); - } - break; - - default: - printf("OOPS, not expecting class type %d\n", item->m_StructType ); } - return SEARCH_CONTINUE; + if( m_Guide->IncludeSecondary() ) + { + // for now, "secondary" means "tolerate any layer". It has + // no effect on other criteria, since there is a separate "ignore" control for + // those in the COLLECTORS_GUIDE + + int layer = item->GetLayer(); + + if( m_Guide->IsLayerVisible( layer ) || !m_Guide->IgnoreNonVisibleLayers() ) + { + if( !m_Guide->IsLayerLocked(layer) || !m_Guide->IgnoreLockedLayers() ) + { + if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() ) + { + if( item->HitTest( m_RefPos ) ) + { + Append2nd( item ); + goto exit; + } + } + } + } + } + +#else + // The primary search criteria: + if( item->IsOnLayer( m_PreferredLayer ) ) + { + if( item->HitTest( m_RefPos ) ) + { + if( !item->IsLocked() ) + Append( item ); + else + Append2nd( item ); // 2nd if locked. + } + } + + // The secondary search criteria + else if( item->IsOnOneOfTheseLayers( m_LayerMask ) ) + { + if( item->HitTest( m_RefPos ) ) + Append2nd( item ); + } +#endif + +exit: + return SEARCH_CONTINUE; // always when collecting } -// see collectors.h -void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos, +// see collectors.h +/* +void GENERAL_COLLECTOR::Collect( BOARD* board, const wxPoint& refPos, int aPreferredLayer, int aLayerMask ) { Empty(); // empty the collection, primary criteria list @@ -151,9 +205,7 @@ void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos, SetPreferredLayer( aPreferredLayer ); SetLayerMask( aLayerMask ); - /* remember where the snapshot was taken from and pass refPos to - the Inspect() function. - */ + // remember refPos, pass to Inspect() SetRefPos( refPos ); #if defined(DEBUG) @@ -173,25 +225,23 @@ void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos, Empty2nd(); } +*/ // see collectors.h -void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos, - const COLLECTORS_GUIDE& guide ) +void GENERAL_COLLECTOR::Collect( BOARD* board, const wxPoint& refPos, + const COLLECTORS_GUIDE* guide ) { Empty(); // empty the collection, primary criteria list Empty2nd(); // empty the collection, secondary criteria list + // remember guide, pass it to Inspect() + SetGuide( guide ); - // @todo: remember the guide here, pass it to Inspect() - - - /* remember where the snapshot was taken from and pass refPos to - the Inspect() function. - */ + // remember where the snapshot was taken from and pass refPos to + // the Inspect() function. SetRefPos( refPos ); - // visit the board with the INSPECTOR (me). board->Visit( this, // INSPECTOR* inspector NULL, // const void* testData, not used here @@ -199,14 +249,32 @@ void GENERALCOLLECTOR::Scan( BOARD* board, const wxPoint& refPos, SetTimeNow(); // when snapshot was taken - // append 2nd list onto end of the first "list" - for( unsigned i=0; i + * A justification for this class is to keep the structural storage details of + * the program's "global preferences" or "configuration options" out of + * GENERAL_COLLECTOR::Inspect(). This class carries all the necessary details + * in with it to the Inspect() call. The constructors or other functions of + * this class's derivatives are then the only place where knowledge of the + * specific structure of the global preference storage is needed. Thus, + * GENERAL_COLLECTOR::Inspect() can be kept as simple as possible, and insulated + * from changes in global preference storage (and even then it is + * not simple enough). *

* This class introduces the notion of layer locking. */ @@ -55,18 +66,6 @@ public: */ virtual bool IsLayerLocked( int layer ) const = 0; - /** - * Function IsCopperLayerVisible - * @return bool - true if the copper layer is visible. - */ - virtual bool IsCopperLayerVisible() const = 0; - - /** - * Function IsComponentLayerVisible - * @return bool - true if the component layer is visible, else false. - */ - virtual bool IsComponentLayerVisible() const = 0; - /** * Function IsLayerVisible * @return bool - true if the given layer is visible, else false. @@ -75,7 +74,7 @@ public: /** * Function IgnoreLockedLayers - * @return bool - true if should ignored locked layers, else false. + * @return bool - true if should ignore locked layers, else false. */ virtual bool IgnoreLockedLayers() const = 0; @@ -90,15 +89,43 @@ public: * @return int - the preferred layer for HitTest()ing. */ virtual int GetPreferredLayer() const = 0; + + /** + * Function IgnorePreferredLayer + * provides wildcard behavior regarding the preferred layer. + * @return bool - true if should ignore preferred layer, else false. + */ + virtual bool IgnorePreferredLayer() const = 0; + + /** + * Function IgnoreLockedItems + * @return bool - true if should ignore locked items, else false. + */ + virtual bool IgnoreLockedItems() const = 0; + + + /** + * Function IncludeSecondary + * determines if the secondary criteria, or 2nd choice items should be + * included. + * @return bool - true if should include, else false. + */ + virtual bool IncludeSecondary() const = 0; - // more soon + /** + * Function UseHitTesting + * @return bool - true if Inspect() should use BOARD_ITEM::HitTest() + * or false if Inspect() should use BOARD_ITEM::BoundsTest(). + virtual bool UseHitTesting() const = 0; + */ + }; /** - * Class GENERALCOLLECTOR + * Class GENERAL_COLLECTOR * is intended for use when the right click button is pressed, or when the * plain "arrow" tool is in effect. This class can be used by window classes * such as WinEDA_PcbFrame. @@ -108,23 +135,23 @@ public: * but can handle those concerns by the SetPreferredLayer() function and the * SetLayerMask() fuction. */ -class GENERALCOLLECTOR : public COLLECTOR +class GENERAL_COLLECTOR : public COLLECTOR { +protected: /** * A place to hold collected objects which don't match precisely the search * criteria, but would be acceptable if nothing else is found. * "2nd" choice, which will be appended to the end of COLLECTOR's prime * "list" at the end of the search. */ - std::vector list2nd; + std::vector m_List2nd; + - /** - * A bit-mapped layer mask that defines any layers which are acceptable - * on a secondary search criterion basis. + * Determines which items are to be collected by Inspect() */ - int m_LayerMask; - + const COLLECTORS_GUIDE* m_Guide; + public: @@ -135,22 +162,29 @@ public: /** * Constructor GENERALCOLLECTOR */ - GENERALCOLLECTOR() + GENERAL_COLLECTOR() { - m_LayerMask = 0; SetScanTypes( AllBoardItems ); } void Empty2nd() { - list2nd.clear(); + m_List2nd.clear(); } void Append2nd( BOARD_ITEM* item ) { - list2nd.push_back( item ); + m_List2nd.push_back( item ); } + + /** + * Function SetGuide + * records which COLLECTORS_GUIDE to used. + * @param aGuide Which guide to use in the collection. + */ + void SetGuide( const COLLECTORS_GUIDE* aGuide ) { m_Guide = aGuide; } + /** * Function SetLayerMask @@ -164,11 +198,11 @@ public: * layers are acceptable. Caller must pay attention to which layers are * visible, selected, etc. All those concerns are handled outside this * class, as stated in the class Philosophy above. - */ void SetLayerMask( int aLayerMask ) { m_LayerMask = aLayerMask; } + */ /** @@ -181,7 +215,7 @@ public: BOARD_ITEM* operator[]( int ndx ) const { if( (unsigned)ndx < (unsigned)GetCount() ) - return (BOARD_ITEM*) list[ ndx ]; + return (BOARD_ITEM*) m_List[ ndx ]; return NULL; } @@ -200,25 +234,154 @@ public: /** - * Function Scan + * Function Collect * scans a BOARD using this class's Inspector method, which does the collection. * @param board A BOARD to scan. * @param refPos A wxPoint to use in hit-testing. * @param aPreferredLayer The layer meeting the primary search criterion. * @param aLayerMask The layers, in bit-mapped form, meeting the secondary search criterion. + void Collect( BOARD* board, const wxPoint& refPos, int aPreferredLayer, int aLayerMask ); */ - void Scan( BOARD* board, const wxPoint& refPos, int aPreferredLayer, int aLayerMask ); /** - * Function Scan + * Function Collect * scans a BOARD using this class's Inspector method, which does the collection. - * @param board A BOARD to scan. - * @param refPos A wxPoint to use in hit-testing. - * @param guide The COLLECTORS_GUIDE to use in collecting items. + * @param aBoard A BOARD to scan. + * @param aRefPos A wxPoint to use in hit-testing. + * @param aGuide The COLLECTORS_GUIDE to use in collecting items. */ - void Scan( BOARD* board, const wxPoint& refPos, const COLLECTORS_GUIDE& guide ); + void Collect( BOARD* aBoard, const wxPoint& aRefPos, const COLLECTORS_GUIDE* aGuide ); }; +/** + * Class GENERAL_COLLECTORS_GUIDE + * is a general implementation of a COLLECTORS_GUIDE. One of its constructors is + * entitled to grab information from the program's global preferences. + */ +class GENERAL_COLLECTORS_GUIDE : public COLLECTORS_GUIDE +{ +private: + // the storage architecture here is not important, since this is only + // a carrier object and its functions are what is used, and data only indirectly. + + int m_PreferredLayer; + bool m_IgnorePreferredLayer; + + int m_LayerLocked; ///< bit-mapped layer locked bits + bool m_IgnoreLockedLayers; + + int m_LayerVisible; ///< bit-mapped layer visible bits + bool m_IgnoreNonVisibleLayers; + + bool m_IgnoreLockedItems; + bool m_IncludeSecondary; + +public: + + /** + * Constructor GENERAL_COLLECTORS_GUIDE + * grabs stuff from global preferences and uses reasonable defaults. + * Add more constructors as needed. + * @param settings The EDA_BoardDesignSettings to reference. + */ + GENERAL_COLLECTORS_GUIDE( const EDA_BoardDesignSettings* settings ) + { + m_PreferredLayer = LAYER_CMP_N; + m_IgnorePreferredLayer = false; + m_LayerLocked = 0; + m_LayerVisible = settings->GetVisibleLayers(); + m_IgnoreLockedLayers = true; + m_IgnoreNonVisibleLayers = true; + m_IgnoreLockedItems = true; + +#if defined(USE_MATCH_LAYER) + m_IncludeSecondary = false; +#else + m_IncludeSecondary = true; +#endif + } + + /** + * Function IsLayerLocked + * @return bool - true if the given layer is locked, else false. + */ + bool IsLayerLocked( int aLayer ) const { return (1<Scan( m_Pcb, + // test scaffolding for Collect(): + GENERAL_COLLECTORS_GUIDE guide( m_Pcb->m_BoardSettings ); + + guide.SetIgnoreLockedItems( false ); + guide.SetPreferredLayer( GetScreen()->m_Active_Layer ); + + m_Collector->Collect( m_Pcb, GetScreen()->RefPos(true), - - // these two are inadequate, because the layer support - // in Kicad is not elegant or easily understood. - // The final solution will be a new class COLLECTORS_GUIDE! - GetScreen()->m_Active_Layer, - g_DesignSettings.GetVisibleLayers() - ); + &guide ); // use only the first one collected for now. item = (*m_Collector)[0]; // grab first one, may be NULL @@ -150,7 +149,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay() { item->Display_Infos( this ); - // debugging: print out the collected items, showing their order too. + // debugging: print out the collected items, showing their priority order too. for( unsigned i=0; iGetCount(); ++i ) (*m_Collector)[i]->Show( 0, std::cout ); } @@ -170,7 +169,6 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay() void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) /*****************************************************************/ { - int ll; wxSize delta; int zoom = GetScreen()->GetZoom(); wxPoint curpos, oldpos; diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index 3d190623ca..385c8ec12e 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -228,7 +228,8 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) Via->SetLayer( 0x0F ); if( Drc_On &&( Drc( this, DC, Via, m_Pcb->m_Track, 1 ) == BAD_DRC ) ) - { /* Via impossible a placer ici */ + { + /* Via impossible a placer ici */ delete Via; GetScreen()->m_Active_Layer = g_CurrentTrackSegment->GetLayer(); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); @@ -245,8 +246,10 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC ) g_TrackSegmentCount++; g_CurrentTrackSegment->Pback = Via; Via->Pnext = g_CurrentTrackSegment; + if( g_TwoSegmentTrackBuild ) - { // Create a second segment (we must have 2 track segments to adjust) + { + // Create a second segment (we must have 2 track segments to adjust) TRACK* track = g_CurrentTrackSegment; g_CurrentTrackSegment = new TRACK( *track ); g_TrackSegmentCount++; diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 291da721ea..a865b80917 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -114,6 +114,7 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC ) if( LockPoint->m_StructType == TYPEPAD ) { pt_pad = (D_PAD*) LockPoint; + /* le debut de la piste est remis sur le centre du pad */ pos = pt_pad->m_Pos; g_HightLigth_NetCode = pt_pad->m_NetCode; @@ -144,7 +145,8 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* track, wxDC* DC ) g_CurrentTrackSegment->start = adr_buf; if( g_TwoSegmentTrackBuild ) - { // Create 2 segments + { + // Create 2 segments g_CurrentTrackSegment = new TRACK( *g_CurrentTrackSegment ); g_TrackSegmentCount++; g_CurrentTrackSegment->Pback = g_FirstTrackSegment; @@ -793,13 +795,15 @@ void EnsureEndTrackOnPad( D_PAD* Pad ) TRACK* lasttrack = g_CurrentTrackSegment; if( !g_CurrentTrackSegment->IsNull() ) - { /* Must create a new segment, from track end to pad center */ + { + /* Must create a new segment, from track end to pad center */ g_CurrentTrackSegment = new TRACK( *lasttrack ); g_TrackSegmentCount++; lasttrack->Pnext = g_CurrentTrackSegment; g_CurrentTrackSegment->Pback = lasttrack; lasttrack->end = g_CurrentTrackSegment; } + g_CurrentTrackSegment->m_End = Pad->m_Pos; g_CurrentTrackSegment->SetState( END_ONPAD, OFF ); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index be5c056108..71236c0a02 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -235,7 +235,7 @@ int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, wxDC* DC, boo g_SaveTime = time( NULL ); -#if 0 && defined(DEBUG) +#if 1 && defined(DEBUG) // note this seems to freeze up pcbnew when run under the kicad project // manager. runs fine from command prompt. // output the board object tree to stdout: diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index d4f4096128..1af839f53c 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -80,8 +80,7 @@ int NbDraw, NbTrack, NbZone, NbMod, NbNets; /**********************************************************************/ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File, - TRACK* PtSegm, int StructType, - int* LineNum, int NumSegm ) + TRACK* PtSegm, int StructType, int* LineNum, int NumSegm ) /**********************************************************************/ /* Lecture de la description d'une liste de segments (Tracks, zones) @@ -90,12 +89,16 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File, * si pas de fin de block ($..) - nombre. */ { - int shape, width, layer, type, flags, net_code; - int ii = 0, PerCent, Pas; - char Line[256]; + int shape, width, layer, type, flags, net_code; + int ii = 0, PerCent, Pas; + char line1[256]; + char line2[256]; + TRACK* NewTrack; - PerCent = 0; Pas = NumSegm / 99; + PerCent = 0; + + Pas = NumSegm / 99; #ifdef PCBNEW switch( StructType ) @@ -111,14 +114,36 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File, } #endif - while( GetLine( File, Line, LineNum ) ) + while( GetLine( File, line1, LineNum ) ) { - if( Line[0] == '$' ) + int makeType; + unsigned long timeStamp; + + if( line1[0] == '$' ) { return ii; /* fin de liste OK */ } - switch( StructType ) + // 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. + if( GetLine( File, line2, LineNum ) == NULL ) + break; + + if( line2[0] == '$' ) + break; + + // parse the 2nd line first to determine the type of object + sscanf( line2 + 2, " %d %d %d %lX %X", &layer, &type, &net_code, + &timeStamp, &flags ); + + if( StructType==TYPETRACK && type==1 ) + makeType = TYPEVIA; + else + makeType = StructType; + + switch( makeType ) { default: case TYPETRACK: @@ -134,29 +159,27 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File, break; } - NewTrack->Insert( m_Pcb, PtSegm ); PtSegm = NewTrack; + NewTrack->Insert( m_Pcb, PtSegm ); + + PtSegm = NewTrack; + + PtSegm->m_TimeStamp = timeStamp; - int arg_count = sscanf( Line + 2, " %d %d %d %d %d %d %d", &shape, + int arg_count = sscanf( line1 + 2, " %d %d %d %d %d %d %d", &shape, &PtSegm->m_Start.x, &PtSegm->m_Start.y, &PtSegm->m_End.x, &PtSegm->m_End.y, &width, &PtSegm->m_Drill ); - PtSegm->m_Width = width; PtSegm->m_Shape = shape; + PtSegm->m_Width = width; + PtSegm->m_Shape = shape; + if( arg_count < 7 ) PtSegm->m_Drill = -1; - if( GetLine( File, Line, LineNum ) == NULL ) - break; - if( Line[0] == '$' ) - break; - - sscanf( Line + 2, " %d %d %d %lX %X", &layer, &type, &net_code, - &PtSegm->m_TimeStamp, &flags ); - if( type == 1 ) - PtSegm->m_StructType = TYPEVIA; - PtSegm->SetLayer( layer ); - PtSegm->m_NetCode = net_code; PtSegm->SetState( flags, ON ); + PtSegm->m_NetCode = net_code; + PtSegm->SetState( flags, ON ); + #ifdef PCBNEW PtSegm->Draw( DrawPanel, DC, GR_OR ); #endif @@ -166,7 +189,7 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File, PerCent++; #ifdef PCBNEW - switch( StructType ) + switch( makeType ) { case TYPETRACK: case TYPEVIA: @@ -178,7 +201,6 @@ int WinEDA_BasePcbFrame::ReadListeSegmentDescr( wxDC* DC, FILE* File, break; } #endif - } } diff --git a/pcbnew/locate.cpp b/pcbnew/locate.cpp index df38a13543..f7dc3ab3b8 100644 --- a/pcbnew/locate.cpp +++ b/pcbnew/locate.cpp @@ -240,7 +240,7 @@ TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer ) continue; if( layer < 0 ) return Track; - if( ( (SEGVIA*) Track )->IsViaOnLayer( layer ) ) + if( Track->IsOnLayer( layer ) ) return Track; } diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 2e40aae584..c4d8b558d4 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -193,7 +193,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent, m_SelViaSizeBox_Changed = FALSE; #if defined(DEBUG) - m_Collector = new GENERALCOLLECTOR(); + m_Collector = new GENERAL_COLLECTOR(); #endif m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;