highlight zone containers

This commit is contained in:
dickelbeck 2008-02-19 16:54:57 +00:00
parent 7750cf6d4f
commit 1b39dfc7c9
5 changed files with 135 additions and 113 deletions

View File

@ -5,6 +5,13 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2008-Feb-19 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
Add ZONE_CONTAINER support to the ID_PCB_HIGHLIGHT_BUTT tool and
WinEDA_PcbFrame::DrawHightLight()
2008-Feb-18 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew

View File

@ -331,7 +331,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int
// if PAD_SMD pad and high contrast mode
if( m_Attribut==PAD_SMD && DisplayOpt.ContrastModeDisplay )
if( (m_Attribut==PAD_SMD || m_Attribut==PAD_CONN) && DisplayOpt.ContrastModeDisplay )
{
// when routing tracks
if( frame && frame->m_ID_current_state == ID_TRACK_BUTT )

View File

@ -93,11 +93,12 @@ const KICAD_T GENERAL_COLLECTOR::PadsOrModules[] = {
};
const KICAD_T GENERAL_COLLECTOR::PadsOrTracks[] = {
const KICAD_T GENERAL_COLLECTOR::PadsTracksOrZones[] = {
TYPEPAD,
TYPEVIA,
TYPETRACK,
TYPEZONE,
TYPEZONE_CONTAINER,
EOT
};
@ -368,20 +369,20 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
// see collectors.h
SEARCH_RESULT TYPE_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void* testData )
{
// The Vist() function only visits the testItem if its type was in the
// The Vist() function only visits the testItem if its type was in the
// the scanList, so therefore we can collect anything given to us here.
Append( testItem );
return SEARCH_CONTINUE; // always when collecting
}
void TYPE_COLLECTOR::Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[] )
{
Empty(); // empty any existing collection
// visit the board with the INSPECTOR (me).
aBoard->Visit( this, // INSPECTOR* inspector
NULL, // const void* testData,
NULL, // const void* testData,
aScanList );
}

View File

@ -3,22 +3,22 @@
*
* Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2004-2007 Kicad Developers, see change_log.txt for contributors.
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
@ -37,26 +37,26 @@
/**
* Class COLLECTORS_GUIDE
* is an abstract base class whose derivatives may be passed to a GENERAL_COLLECTOR,
* telling GENERAL_COLLECTOR what should be collected (aside from HitTest()ing
* and KICAD_T scanTypes[], information which are provided to the GENERAL_COLLECTOR
* through attributes or arguments separately).
* is an abstract base class whose derivatives may be passed to a GENERAL_COLLECTOR,
* telling GENERAL_COLLECTOR what should be collected (aside from HitTest()ing
* and KICAD_T scanTypes[], information which are provided to the GENERAL_COLLECTOR
* through attributes or arguments separately).
* <p>
* A justification for this class is to keep the structural storage details of
* the program's "global preferences" or "configuration options" out 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
* 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).
* <p>
* This class introduces the notion of layer locking.
*/
class COLLECTORS_GUIDE
class COLLECTORS_GUIDE
{
public:
virtual ~COLLECTORS_GUIDE() {}
@ -65,25 +65,25 @@ public:
* @return bool - true if the given layer is locked, else false.
*/
virtual bool IsLayerLocked( int layer ) const = 0;
/**
* Function IsLayerVisible
* @return bool - true if the given layer is visible, else false.
*/
virtual bool IsLayerVisible( int layer ) const = 0;
/**
* Function IgnoreLockedLayers
* @return bool - true if should ignore locked layers, else false.
*/
virtual bool IgnoreLockedLayers() const = 0;
/**
* Function IgnoredNonVisibleLayers
* @return bool - true if should ignore non-visible layers, else false.
*/
virtual bool IgnoreNonVisibleLayers() const = 0;
/**
* Function GetPreferredLayer
* @return int - the preferred layer for HitTest()ing.
@ -116,7 +116,7 @@ public:
* @return bool - true if MTexts marked as "no show" should be ignored.
*/
virtual bool IgnoreMTextsMarkedNoShow() const = 0;
/**
* Function IgnoreZones
* @return bool - true if should ignore zones.
@ -134,7 +134,7 @@ public:
* @return bool - true if should ignore MTexts on component layer.
*/
virtual bool IgnoreMTextsOnCmp() const = 0;
/**
* Function IgnoreModulesOnCu
* @return bool - true if should ignore MODULEs on copper layer.
@ -147,7 +147,7 @@ public:
*/
virtual bool IgnoreModulesOnCmp() const = 0;
/**
* Function UseHitTesting
* @return bool - true if Inspect() should use BOARD_ITEM::HitTest()
@ -160,40 +160,40 @@ public:
/**
* Class GENERAL_COLLECTOR
* is intended for use when the right click button is pressed, or when the
* 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.
*
* Philosophy: this class knows nothing of the context in which a BOARD is used
* and that means it knows nothing about which layers are visible or current,
* and that means it knows nothing about which layers are visible or current,
* but can handle those concerns by the SetPreferredLayer() function and the
* SetLayerMask() fuction.
*/
class GENERAL_COLLECTOR : public COLLECTOR
{
protected:
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
* 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<BOARD_ITEM*> m_List2nd;
/**
* Determines which items are to be collected by Inspect()
*/
const COLLECTORS_GUIDE* m_Guide;
/**
* The number of items that were originally in the primary list before the
* The number of items that were originally in the primary list before the
* m_List2nd was concatonated onto the end of it.
*/
int m_PrimaryLength;
public:
/**
@ -206,9 +206,9 @@ public:
* A scan list for all editable board items, except zones
*/
static const KICAD_T AllButZones[];
/**
/**
* A scan list for all primary board items, omitting items which are subordinate to
* a MODULE, such as D_PAD and TEXTEMODULE.
static const KICAD_T PrimaryItems[];
@ -229,9 +229,9 @@ public:
/**
* A scan list for PADs, TRACKs, VIAs, or ZONEs
*/
static const KICAD_T PadsOrTracks[];
static const KICAD_T PadsTracksOrZones[];
/**
* A scan list for MODULEs and their items (for Modedit)
*/
@ -242,11 +242,11 @@ public:
* A scan list for only TRACKS
*/
static const KICAD_T Tracks[];
/**
* Constructor GENERALCOLLECTOR
*/
*/
GENERAL_COLLECTOR()
{
SetScanTypes( AllBoardItems );
@ -269,8 +269,8 @@ public:
* @param aGuide Which guide to use in the collection.
*/
void SetGuide( const COLLECTORS_GUIDE* aGuide ) { m_Guide = aGuide; }
/**
* Function operator[int]
* overloads COLLECTOR::operator[](int) to return a BOARD_ITEM* instead of
@ -285,39 +285,39 @@ public:
return NULL;
}
/**
* Function GetPrimaryCount
* @return int - The number if items which met the primary search criteria
*/
int GetPrimaryCount() { return m_PrimaryLength; }
/**
* Function Inspect
* is the examining function within the INSPECTOR which is passed to the
* is the examining function within the INSPECTOR which is passed to the
* Iterate function.
*
* @param testItem An EDA_BaseStruct to examine.
* @param testData is not used in this class.
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* else SCAN_CONTINUE;
*/
*/
SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData );
/**
* Function Collect
* scans a BOARD_ITEM using this class's Inspector method, which does the collection.
* @param aItem A BOARD_ITEM to scan, may be a BOARD or MODULE, or whatever.
* @param aScanList A list of KICAD_Ts with a terminating EOT, that specs
* what is to be collected and the priority order of the resultant
* @param aScanList A list of KICAD_Ts with a terminating EOT, that specs
* what is to be collected and the priority order of the resultant
* collection in "m_List".
* @param aRefPos A wxPoint to use in hit-testing.
* @param aGuide The COLLECTORS_GUIDE to use in collecting items.
*/
void Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
const wxPoint& aRefPos, const COLLECTORS_GUIDE& aGuide );
void Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
const wxPoint& aRefPos, const COLLECTORS_GUIDE& aGuide );
};
@ -325,31 +325,31 @@ public:
* 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
// 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
int m_LayerVisible; ///< bit-mapped layer visible bits
bool m_IgnoreNonVisibleLayers;
bool m_IgnoreLockedItems;
bool m_IgnoreLockedItems;
bool m_IncludeSecondary;
bool m_IgnoreMTextsMarkedNoShow;
bool m_IgnoreMTextsOnCopper;
bool m_IgnoreMTextsOnCmp;
bool m_IgnoreModulesOnCu;
bool m_IgnoreModulesOnCmp;
public:
/**
@ -363,16 +363,16 @@ public:
m_PreferredLayer = LAYER_CMP_N;
m_IgnorePreferredLayer = false;
m_LayerLocked = 0;
m_LayerVisible = aVisibleLayerMask;
m_LayerVisible = aVisibleLayerMask;
m_IgnoreLockedLayers = true;
m_IgnoreNonVisibleLayers = true;
m_IgnoreLockedItems = false;
#if defined(USE_MATCH_LAYER)
m_IncludeSecondary = false;
#else
#else
m_IncludeSecondary = true;
#endif
#endif
m_PreferredLayer = aPreferredLayer;
@ -382,14 +382,14 @@ public:
m_IgnoreModulesOnCu = true; // !Show_Modules_Cmp;
m_IgnoreModulesOnCmp = false;
}
/**
* Function IsLayerLocked
* @return bool - true if the given layer is locked, else false.
*/
bool IsLayerLocked( int aLayer ) const { return (1<<aLayer) & m_LayerLocked; }
void SetLayerLocked( int aLayer, bool isLocked )
void SetLayerLocked( int aLayer, bool isLocked )
{
if( isLocked )
m_LayerLocked |= 1 << aLayer;
@ -397,7 +397,7 @@ public:
m_LayerLocked &= ~(1 << aLayer);
}
/**
* Function IsLayerVisible
* @return bool - true if the given layer is visible, else false.
@ -412,15 +412,15 @@ public:
}
void SetLayerVisibleBits( int aLayerBits ) { m_LayerVisible = aLayerBits; }
/**
* Function IgnoreLockedLayers
* @return bool - true if should ignore locked layers, else false.
*/
bool IgnoreLockedLayers() const { return m_IgnoreLockedLayers; }
void SetIgnoreLockedLayers( bool ignore ) { m_IgnoreLockedLayers = ignore; }
/**
* Function IgnoredNonVisibleLayers
* @return bool - true if should ignore non-visible layers, else false.
@ -428,7 +428,7 @@ public:
bool IgnoreNonVisibleLayers() const { return m_IgnoreNonVisibleLayers; }
void SetIgnoreNonVisibleLayers( bool ignore ) { m_IgnoreLockedLayers = ignore; }
/**
* Function GetPreferredLayer
* @return int - the preferred layer for HitTest()ing.
@ -436,7 +436,7 @@ public:
int GetPreferredLayer() const { return m_PreferredLayer; }
void SetPreferredLayer( int aLayer ) { m_PreferredLayer = aLayer; }
/**
* Function IgnorePreferredLayer
* provides wildcard behavior regarding the preferred layer.
@ -444,7 +444,7 @@ public:
*/
bool IgnorePreferredLayer() const { return m_IgnorePreferredLayer; }
void SetIgnorePreferredLayer( bool ignore ) { m_IgnorePreferredLayer = ignore; }
/**
* Function IgnoreLockedItems
@ -463,14 +463,14 @@ public:
bool IncludeSecondary() const { return m_IncludeSecondary; }
void SetIncludeSecondary( bool include ) { m_IncludeSecondary = include; }
/**
* Function IgnoreMTextsMarkedNoShow
* @return bool - true if MTexts marked as "no show" should be ignored.
*/
bool IgnoreMTextsMarkedNoShow() const { return m_IgnoreMTextsMarkedNoShow; }
void SetIgnoreMTextsMarkedNoShow( bool ignore ) { m_IgnoreMTextsMarkedNoShow = ignore; }
/**
* Function IgnoreMTextsOnCu
* @return bool - true if should ignore MTexts on copper layer.
@ -483,8 +483,8 @@ public:
* @return bool - true if should ignore MTexts on component layer.
*/
bool IgnoreMTextsOnCmp() const { return m_IgnoreMTextsOnCmp; }
void SetIgnoreMTextsOnCmp( bool ignore ) { m_IgnoreMTextsOnCmp = ignore; }
void SetIgnoreMTextsOnCmp( bool ignore ) { m_IgnoreMTextsOnCmp = ignore; }
/**
* Function IgnoreModulesOnCu
* @return bool - true if should ignore MODULEs on copper layer.
@ -508,7 +508,7 @@ public:
*/
class TYPE_COLLECTOR : public COLLECTOR
{
public:
/**
@ -524,24 +524,24 @@ public:
return (BOARD_ITEM*) m_List[ ndx ];
return NULL;
}
/**
* Function Inspect
* is the examining function within the INSPECTOR which is passed to the
* is the examining function within the INSPECTOR which is passed to the
* Iterate function.
*
* @param testItem An EDA_BaseStruct to examine.
* @param testData is not used in this class.
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
* else SCAN_CONTINUE;
*/
*/
SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData );
/**
* Function Collect
* scans a BOARD_ITEM using this class's Inspector method, which does
* scans a BOARD_ITEM using this class's Inspector method, which does
* the collection.
* @param aBoard The BOARD_ITEM to scan.
* @param aScanList The KICAD_Ts to gather up.

View File

@ -92,22 +92,22 @@ int WinEDA_PcbFrame::Select_High_Light( wxDC* DC )
{
if( g_HightLigt_Status )
Hight_Light( DC );
// use this scheme because of pad is higher priority than tracks in the
// search, and finding a pad, instead of a track on a pad,
// allows us to fire a message to eescema.
GENERAL_COLLECTORS_GUIDE guide = GetCollectorsGuide();
// optionally, modify the "guide" here as needed using its member functions
m_Collector->Collect( m_Pcb, GENERAL_COLLECTOR::PadsOrTracks,
m_Collector->Collect( m_Pcb, GENERAL_COLLECTOR::PadsTracksOrZones,
GetScreen()->RefPos( true ), guide );
BOARD_ITEM* item = (*m_Collector)[0];
if( item )
{
switch( item->Type() )
@ -117,7 +117,7 @@ int WinEDA_PcbFrame::Select_High_Light( wxDC* DC )
Hight_Light( DC );
SendMessageToEESCHEMA( item );
return g_HightLigth_NetCode;
case TYPETRACK:
case TYPEVIA:
case TYPEZONE:
@ -126,13 +126,18 @@ int WinEDA_PcbFrame::Select_High_Light( wxDC* DC )
g_HightLigth_NetCode = ((TRACK*)item)->GetNet();
Hight_Light( DC );
return g_HightLigth_NetCode;
case TYPEZONE_CONTAINER:
g_HightLigth_NetCode = ((ZONE_CONTAINER*)item)->GetNet();
Hight_Light( DC );
return g_HightLigth_NetCode;
default:
; // until somebody changes GENERAL_COLLECTOR::PadsOrTracks,
// this should not happen.
}
}
return -1; // HitTest() failed.
}
@ -158,30 +163,37 @@ void WinEDA_PcbFrame::DrawHightLight( wxDC* DC, int NetCode )
/* Turn On or OFF the HightLight for trcak and pads with the netcode "NetCode'
*/
{
TRACK* pts;
MODULE* Module;
if( g_HightLigt_Status )
draw_mode = GR_SURBRILL | GR_OR;
else
draw_mode = GR_AND | GR_SURBRILL;
Module = m_Pcb->m_Modules;
/* Redraw pads */
for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() )
{
Pad_Surbrillance( DrawPanel, DC, Module, NetCode );
Pad_Surbrillance( DrawPanel, DC, module, NetCode );
}
/* Redraw track and vias: */
for( pts = m_Pcb->m_Track; pts != NULL; pts = (TRACK*) pts->Pnext )
for( TRACK* pts = m_Pcb->m_Track; pts; pts = pts->Next() )
{
if( pts->GetNet() == NetCode )
{
pts->Draw( DrawPanel, DC, draw_mode );
}
}
wxPoint zero(0,0); // construct outside loop for speed
// Redraw ZONE_CONTAINERS
BOARD::ZONE_CONTAINERS& zones = m_Pcb->m_ZoneDescriptorList;
for( BOARD::ZONE_CONTAINERS::iterator zc = zones.begin(); zc!=zones.end(); ++zc )
{
if( (*zc)->GetNet() == NetCode )
{
(*zc)->Draw( DrawPanel, DC, zero, draw_mode );
}
}
}
@ -193,12 +205,14 @@ static void Pad_Surbrillance( WinEDA_DrawPanel* panel,
{
D_PAD* pt_pad;
wxPoint zero(0,0); // construct outside loop for speed
/* trace des pastilles */
for( pt_pad = Module->m_Pads; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{
if( pt_pad->GetNet() == NetCode )
{
pt_pad->Draw( panel, DC, wxPoint( 0, 0 ), draw_mode );
pt_pad->Draw( panel, DC, zero, draw_mode );
}
}
}