7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-11 00:30:01 +00:00

First draft (and first code..) about new zone handling

This commit is contained in:
CHARRAS 2007-12-29 19:15:58 +00:00
parent ee3d984445
commit 5eda8a52ce
43 changed files with 5444 additions and 376 deletions

View File

@ -1,6 +1,6 @@
ADD_DEFINITIONS(-DPCBNEW)
INCLUDE_DIRECTORIES(../pcbnew)
INCLUDE_DIRECTORIES(../pcbnew ../polygon)
SET(3D-VIEWER_SRCS
3d_aux.cpp

View File

@ -1,5 +1,5 @@
EXTRALIBS =
EXTRACPPFLAGS= -I./ -I../include -I../common -I../pcbnew
EXTRACPPFLAGS= -I./ -I../include -I../common -I../polygon -I../pcbnew
CPPFLAGS += $(EXTRACPPFLAGS)

View File

@ -4,6 +4,14 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2007-Dec-29 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
First draft (and code..) about new zone handling, using polygons to define an outline.
Now currently not useable because the fill function (and many other important functions) is not implemented.
Many functions are not yet implemented: merging zones, cutout, DRC ...
Nevertheless, one can create, modify edit and save zone outlines
2007-Dec-23 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================

View File

@ -4,6 +4,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
bitmaps
../3d-viewer
../polygon
../pcbnew)
SET(CVPCB_SRCS
@ -35,6 +36,7 @@ SET(CVPCB_SRCS
SET(CVPCB_EXTRA_SRCS
../pcbnew/basepcbframe.cpp
../pcbnew/class_board.cpp
../pcbnew/class_zone.cpp
../pcbnew/class_cotation.cpp
../pcbnew/class_edge_mod.cpp
../pcbnew/class_equipot.cpp

View File

@ -1,8 +1,12 @@
# makefile pour cvpcb (mingw)
OBJSUFF = o
EXTRACPPFLAGS += -DCVPCB -fno-strict-aliasing -I./ -I../cvpcb -I../include -Ibitmaps -I../pcbnew -I../3d-viewer
EXTRALIBS = ../common/common.a
EXTRACPPFLAGS += -DCVPCB -fno-strict-aliasing\
-I./ -I../cvpcb -I../include -Ibitmaps\
-I../pcbnew -I../3d-viewer\
-I../polygon
EXTRALIBS = ../common/common.a ../polygon/lib_polygon.a
LIBVIEWER3D = ../3d-viewer/3d-viewer.a
@ -10,6 +14,7 @@ LIBVIEWER3D = ../3d-viewer/3d-viewer.a
OBJECTS = $(TARGET).o \
class_cvpcb.o\
class_zone.o\
memoire.o \
cvframe.o\
listboxes.o\
@ -69,6 +74,9 @@ classpcb.o: ../pcbnew/classpcb.cpp $(DEPEND)
class_mire.o: ../pcbnew/class_mire.cpp ../pcbnew/class_mire.h $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_zone.o: ../pcbnew/class_zone.cpp ../pcbnew/class_zone.h $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_cotation.o: ../pcbnew/class_cotation.cpp ../pcbnew/class_cotation.h $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp

View File

@ -4,7 +4,8 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
../3d-viewer
../cvpcb
../pcbnew)
../pcbnew
../polygon)
SET(GERBVIEW_SRCS
affiche.cpp
@ -41,6 +42,7 @@ SET(GERBVIEW_SRCS
SET(GERBVIEW_EXTRA_SRCS
../pcbnew/basepcbframe.cpp
../pcbnew/class_board.cpp
../pcbnew/class_zone.cpp
../pcbnew/class_drc_item.cpp
../pcbnew/class_marker.cpp
../pcbnew/class_pcb_text.cpp
@ -74,6 +76,6 @@ ENDIF(APPLE)
ADD_EXECUTABLE(gerbview WIN32 MACOSX_BUNDLE ${GERBVIEW_SRCS} ${GERBVIEW_EXTRA_SRCS} ${GERBVIEW_RESOURCES})
TARGET_LINK_LIBRARIES(gerbview common 3d-viewer ${wxWidgets_LIBRARIES})
TARGET_LINK_LIBRARIES(gerbview common 3d-viewer lib_polygon ${wxWidgets_LIBRARIES})
INSTALL(TARGETS gerbview RUNTIME DESTINATION ${KICAD_BIN})

View File

@ -1,12 +1,17 @@
EXTRALIBS = ../common/common.a
EXTRACPPFLAGS= -DGERBVIEW -DPCBNEW -fno-strict-aliasing -I./ -I../gerbview -I../include\
-I../share -I../pcbnew -I../3d-viewer
EXTRALIBS = ../common/common.a ../polygon/lib_polygon.a
EXTRACPPFLAGS= -DGERBVIEW -DPCBNEW -fno-strict-aliasing\
-I./ -I../gerbview -I../include\
-I../share -I../pcbnew -I../3d-viewer\
-I../polygon
#COMMON = pcbnew.h struct.h
OBJECTS= \
$(TARGET).o\
classpcb.o\
class_zone.o\
select_layers_to_pcb.o\
sel_layer.o\
lay2plot.o\
@ -69,6 +74,9 @@ files.o: files.cpp $(COMMON)
class_marker.o: ../pcbnew/class_marker.cpp ../pcbnew/class_marker.h $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_zone.o: ../pcbnew/class_zone.cpp ../pcbnew/class_zone.h $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_drc_item.o: ../pcbnew/class_drc_item.cpp $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp

View File

@ -41,7 +41,7 @@ enum KICAD_T {
TYPESCREEN,
TYPEBLOCK,
TYPEEDGEZONE,
TYPEZONE_POLYEDGE,
TYPEZONE_EDGE_CORNER,
TYPEZONE_CONTAINER,
// Draw Items in schematic

View File

@ -5,7 +5,7 @@
COMMON_GLOBL wxString g_BuildVersion
#ifdef EDA_BASE
(wxT("(2007-12-17)"))
(wxT("(2007-12-22)"))
#endif
;

View File

@ -546,8 +546,21 @@ enum main_id {
ID_POPUP_PCB_DELETE_TRACK,
ID_POPUP_PCB_DELETE_TRACKNET,
ID_POPUP_PCB_DELETE_TRACK_MNU,
ID_POPUP_PCB_EDIT_ZONE,
ID_POPUP_PCB_EDIT_ZONE_PARAMS,
ID_POPUP_PCB_DELETE_ZONE,
ID_POPUP_PCB_MOVE_ZONE_CORNER,
ID_POPUP_PCB_ADD_ZONE_CORNER,
ID_POPUP_PCB_DELETE_ZONE_CORNER,
ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE,
ID_POPUP_PCB_DELETE_EDGE_ZONE,
ID_POPUP_PCB_DELETE_ZONE_LIMIT,
ID_POPUP_PCB_FILL_ZONE,
ID_POPUP_PCB_DELETE_ZONE_CONTAINER,
ID_POPUP_PCB_PLACE_ZONE_CORNER,
ID_POPUP_ZONE_UNUSED2,
ID_POPUP_ZONE_UNUSED3,
ID_POPUP_ZONE_UNUSED4,
ID_POPUP_PCB_DELETE_MARKER,
ID_POPUP_PCB_DELETE_COTATION,
@ -565,12 +578,6 @@ enum main_id {
ID_POPUP_PCB_IMPORT_PAD_SETTINGS,
ID_POPUP_PCB_EXPORT_PAD_SETTINGS,
ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE,
ID_POPUP_PCB_DELETE_EDGE_ZONE,
ID_POPUP_PCB_DELETE_ZONE_LIMIT,
ID_POPUP_PCB_FILL_ZONE,
ID_POPUP_PCB_SELECT_NET_ZONE,
ID_POPUP_PCB_SELECT_WIDTH,
ID_POPUP_PCB_SELECT_WIDTH1,
ID_POPUP_PCB_SELECT_WIDTH2,

View File

@ -102,6 +102,7 @@ class Ki_HotkeyInfo;
class GENERAL_COLLECTOR;
class GENERAL_COLLECTORS_GUIDE;
class DRC;
class ZONE_CONTAINER;
enum id_librarytype {
@ -728,10 +729,8 @@ public:
TRACK* Delete_Segment( wxDC* DC, TRACK* Track );
void Delete_Track( wxDC* DC, TRACK* Track );
void Delete_net( wxDC* DC, TRACK* Track );
void Delete_Zone( wxDC* DC, SEGZONE* Track );
void Supprime_Une_Piste( wxDC* DC, TRACK* pt_segm );
bool Resize_Pistes_Vias( wxDC* DC, bool Track, bool Via );
void Edit_Zone_Width( wxDC* DC, SEGZONE* pt_ref );
void Edit_Net_Width( wxDC* DC, int Netcode );
void Edit_Track_Width( wxDC* DC, TRACK* Track );
int Edit_TrackSegm_Width( wxDC* DC, TRACK* segm );
@ -749,8 +748,13 @@ public:
bool Genere_Pad_Connexion( wxDC* DC, int layer );
// zone handling
void Delete_Zone( wxDC* DC, SEGZONE* Track );
EDGE_ZONE* Del_SegmEdgeZone( wxDC* DC, EDGE_ZONE* edge_zone );
void CaptureNetName( wxDC* DC );
/**
* Function Begin_Zone
* initiates a zone edge creation process,
* or terminates the current zone edge and creates a new zone edge stub
*/
EDGE_ZONE* Begin_Zone( wxDC* DC );
/**
@ -761,14 +765,30 @@ public:
/**
* Function Fill_Zone
* creates a number zone segments by using a flood fill algorithm. The
* "high-lighted" net is used to determine the netcode of all the zone
* segments and what can be connected to and what must be avoided on the
* current layer as the flooding occurs.
* Fills an outline.
*/
void Fill_Zone( wxDC* DC );
void Fill_Zone( wxDC* DC, ZONE_CONTAINER * zone_container );
// Target handling
/**
* Function Edit_Zone_Params
* Edit params (layer, clearance, ...) for a zone outline
*/
void Edit_Zone_Params( wxDC* DC , ZONE_CONTAINER * zone_container );
/**
* Function Start_Move_Zone_Corner
* Prepares a move corner in a zone outline,
* called from a move corner command (IsNewCorner = false),
* or a create new cornet command (IsNewCorner = true )
*/
void Start_Move_Zone_Corner( wxDC* DC , ZONE_CONTAINER * zone_container, int corner_id, bool IsNewCorner );
/**
* Function End_Move_Zone_Corner
* Terminates a move corner in a zone outline
*/
void End_Move_Zone_Corner( wxDC* DC , ZONE_CONTAINER * zone_container );
// Target handling
MIREPCB* Create_Mire( wxDC* DC );
void Delete_Mire( MIREPCB* MirePcb, wxDC* DC );
void StartMove_Mire( MIREPCB* MirePcb, wxDC* DC );

View File

@ -1,4 +1,4 @@
KICAD_SUBDIRS = common 3d-viewer eeschema eeschema/plugins pcbnew kicad cvpcb gerbview
KICAD_SUBDIRS = common 3d-viewer polygon eeschema eeschema/plugins pcbnew kicad cvpcb gerbview
KICAD_SUBDIRS_BIN = eeschema eeschema/plugins pcbnew cvpcb kicad gerbview
# How to invoke make:
MAKE = make -k -f makefile.g95

View File

@ -1,6 +1,6 @@
MAKEGTK = $(MAKE) -f makefile.gtk
KICAD_SUBDIRS = common 3d-viewer pcbnew eeschema eeschema/plugins cvpcb kicad gerbview
KICAD_SUBDIRS = common 3d-viewer polygon pcbnew eeschema eeschema/plugins cvpcb kicad gerbview
KICAD_SUBDIRS_BIN = eeschema eeschema/plugins pcbnew cvpcb kicad gerbview
KICAD_SUBDIRS_RES = internat modules template library
KICAD_SUBDIRS_HELP = help

View File

@ -1,4 +1,4 @@
KICAD_SUBDIRS = common 3d-viewer eeschema pcbnew cvpcb kicad gerbview
KICAD_SUBDIRS = common 3d-viewer polygon eeschema pcbnew cvpcb kicad gerbview
KICAD_SUBDIRS_BIN = eeschema pcbnew cvpcb kicad gerbview
# How to invoke make:
MAKE = make -f makefile.macosx

View File

@ -6,8 +6,6 @@
#include "pcbnew.h"
//#include "bitmaps.h"
/*****************/
/* Class BOARD: */
@ -76,6 +74,7 @@ BOARD::~BOARD()
m_LocalRatsnest = 0;
DeleteMARKERs();
DeleteZONEOutlines();
}
@ -128,11 +127,11 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
void BOARD::Delete( BOARD_ITEM* aBoardItem )
{
if ( aBoardItem == NULL ) return;
switch( aBoardItem->Type() )
{
// this one uses a vector
case TYPEMARKER:
case TYPEMARKER: // this one uses a vector
// find the item in the vector, then delete then erase it.
for( unsigned i=0; i<m_markers.size(); ++i )
{
@ -143,6 +142,19 @@ void BOARD::Delete( BOARD_ITEM* aBoardItem )
}
}
break;
case TYPEZONE_CONTAINER: // this one uses a vector
// find the item in the vector, then delete then erase it.
for( unsigned i=0; i<m_ZoneDescriptorList.size(); ++i )
{
if( m_ZoneDescriptorList[i] == (ZONE_CONTAINER*) aBoardItem )
{
delete m_ZoneDescriptorList[i];
m_ZoneDescriptorList.erase(m_ZoneDescriptorList.begin() + i);
break;
}
}
break;
// other types may use linked list
default:
@ -170,6 +182,15 @@ void BOARD::DeleteMARKERs()
m_markers.clear();
}
void BOARD::DeleteZONEOutlines()
{
// the vector does not know how to delete the ZONE Outlines, it holds pointers
for( unsigned i=0; i<m_ZoneDescriptorList.size(); ++i )
delete m_ZoneDescriptorList[i];
m_ZoneDescriptorList.clear();
}
/* Calculate the track segment count */
int BOARD::GetNumSegmTrack()
@ -522,6 +543,17 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
++p;
break;
case TYPEZONE_CONTAINER:
// TYPEZONE_CONTAINER are in the m_ZoneDescriptorList std::vector
for( unsigned i=0; i< m_ZoneDescriptorList.size(); ++i )
{
result = m_ZoneDescriptorList[i]->Visit( inspector, testData, p );
if( result == SEARCH_QUIT )
break;
}
++p;
break;
case PCB_EQUIPOT_STRUCT_TYPE:
result = IterateForward( m_Equipots, inspector, testData, p );
++p;
@ -782,16 +814,12 @@ bool BOARD::Save( FILE* aFile ) const
fprintf( aFile, "$EndZONE\n" );
// save the zone edges
/*
if( m_CurrentLimitZone )
{
fprintf( aFile, "$ZONE_EDGE\n" );
for( item = m_CurrentLimitZone; item; item=item->Next() )
if( !item->Save( aFile ) )
goto out;
fprintf( aFile, "$EndZONE_EDGE\n" );
}
*/
for( unsigned ii = 0; ii < m_ZoneDescriptorList.size(); ii++ )
{
ZONE_CONTAINER* edge_zone = m_ZoneDescriptorList[ii];
edge_zone->Save( aFile );
}
if( fprintf( aFile, "$EndBOARD\n" ) != sizeof("$EndBOARD\n")-1 )
goto out;

View File

@ -20,7 +20,6 @@ class BOARD : public BOARD_ITEM
private:
std::vector<MARKER*> m_markers; ///< MARKERs for clearance problems, owned by pointer
// std::vector<MARKER*> m_markersUnconnected; ///< MARKERs for unconnected problems, owned by pointer
std::vector<ZONE_CONTAINER*> m_ZoneDescriptorList; ///< edge zone descriptors, owned by pointer
@ -86,6 +85,12 @@ public:
*/
void DeleteMARKERs();
/**
* Function DeleteZONEOutlines
* deletes ALL zone outlines from the board.
*/
void DeleteZONEOutlines();
/**
* Function DeleteMARKER

View File

@ -149,8 +149,25 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
}
break;
case TYPEZONE:
text << _( "Zone" ) << wxT( " " );
case TYPEZONE_CONTAINER:
text = _( "Zone Outline" );
text << wxT( " " );
{
wxString TimeStampText;
TimeStampText.Printf( wxT( "(%8.8X)" ), item->m_TimeStamp );
text << TimeStampText;
}
net = aPcb->FindNet( ( (ZONE_CONTAINER*) item )->GetNet() );
if( net )
{
text << wxT( " [" ) << net->m_Netname << wxT( "]" );
}
text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim();
break;
case TYPEZONE:
text = _( "Zone" );
text << wxT( " " );
{
wxString TimeStampText;
TimeStampText.Printf( wxT( "(%8.8X)" ), item->m_TimeStamp );
@ -268,6 +285,7 @@ const char** BOARD_ITEM::MenuIcon() const
xpm = showtrack_xpm;
break;
case TYPEZONE_CONTAINER:
case TYPEZONE:
xpm = add_zone_xpm;
break;

View File

@ -44,6 +44,7 @@ EQUIPOT::~EQUIPOT()
}
wxPoint& EQUIPOT::GetPosition()
{
static wxPoint dummy;
@ -172,3 +173,5 @@ void EQUIPOT::Show( int nestLevel, std::ostream& os )
" netcode=\"" << GetNet() << "\"/>\n";
}
#endif

View File

@ -61,7 +61,7 @@ public:
*/
int GetNet() const { return m_NetCode; }
void SetNet( int aNetCode ) { m_NetCode = aNetCode; }
/**
* Function GetClass
@ -86,3 +86,4 @@ public:
#endif
};

View File

@ -93,27 +93,9 @@ bool MIREPCB::ReadMirePcbDescr( FILE* File, int* LineNum )
return FALSE;
}
#if 0 // replaced by Save()
/************************************************/
bool MIREPCB::WriteMirePcbDescr( FILE* File )
/************************************************/
{
if( GetState( DELETED ) )
return FALSE;
fprintf( File, "$MIREPCB\n" );
fprintf( File, "Po %X %d %d %d %d %d %8.8lX\n",
m_Shape, m_Layer,
m_Pos.x, m_Pos.y,
m_Size, m_Width, m_TimeStamp );
fprintf( File, "$EndMIREPCB\n" );
return TRUE;
}
#endif
/**************************************/
bool MIREPCB::Save( FILE* aFile ) const
/**************************************/
{
if( GetState( DELETED ) )
return true;

View File

@ -14,10 +14,13 @@
/* class ZONE_CONTAINER */
/************************/
ZONE_CONTAINER::ZONE_CONTAINER (BOARD * parent):
BOARD_ITEM (parent, TYPEZONE_CONTAINER)
ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
BOARD_ITEM( parent, TYPEZONE_CONTAINER )
, CPolyLine( NULL )
{
m_NetCode = -1; // Net number for fast comparisons
m_CornerSelection = -1;
}
@ -25,11 +28,6 @@ ZONE_CONTAINER::~ZONE_CONTAINER()
{
}
bool ZONE_CONTAINER::Save( FILE* aFile ) const
{
return true;
}
/**********************/
/* Class EDGE_ZONE */
@ -49,19 +47,367 @@ EDGE_ZONE:: ~EDGE_ZONE()
}
/****************************************/
bool EDGE_ZONE::Save( FILE* aFile ) const
/****************************************/
{
return true;
}
/********************************************/
bool ZONE_CONTAINER::Save( FILE* aFile ) const
/********************************************/
{
if( GetState( DELETED ) )
return true;
int ret = fprintf( aFile, "ZE %d %d %d %d %d %lX %X\n",
m_Start.x, m_Start.y,
m_End.x, m_End.y,
m_Angle,
m_TimeStamp,
ReturnStatus()
);
return (ret > 14 );
unsigned item_pos;
int ret;
unsigned corners_count = corner.size();
int outline_hatch;
fprintf( aFile, "$CZONE_OUTLINE\n");
// Save the outline main info
ret = fprintf( aFile, "ZInfo %8.8lX %d \"%s\"\n",
m_TimeStamp, m_NetCode,
CONV_TO_UTF8(m_Netname) );
if ( ret < 3 ) return false;
// Save the ouline layer info
ret = fprintf( aFile, "ZLayer %d\n", m_Layer );
if ( ret < 1 ) return false;
// Save the ouline aux info
switch ( m_HatchStyle )
{
default:
case NO_HATCH:
outline_hatch = 'N';
break;
case DIAGONAL_EDGE:
outline_hatch = 'E';
break;
case DIAGONAL_FULL:
outline_hatch = 'F';
break;
}
ret = fprintf( aFile, "ZAux %d %c\n", corners_count, outline_hatch );
if ( ret < 2 ) return false;
// Save the corner list
for ( item_pos = 0; item_pos < corners_count; item_pos++ )
{
ret = fprintf( aFile, "ZCorner %d %d %d \n",
corner[item_pos].x, corner[item_pos].y,
corner[item_pos].end_contour );
if ( ret < 3 ) return false;
}
fprintf( aFile, "$endCZONE_OUTLINE\n");
return true;
}
/**********************************************************/
int ZONE_CONTAINER::ReadDescr( FILE* aFile, int* aLineNum )
/**********************************************************/
/** Function ReadDescr
* @param aFile = opened file
* @param aLineNum = pointer on a line number counter (can be NULL or missing)
* @return 0 if ok or NULL
*/
{
char Line[1024], * text;
char netname_buffer[1024];
int ret;
int n_corner_item = 0;
int outline_hatch = NO_HATCH;
bool error = false, has_corner = false;
netname_buffer[0] = 0;
while( GetLine( aFile, Line, aLineNum, sizeof(Line) - 1 ) != NULL )
{
if( strnicmp(Line, "ZCorner", 7 ) == 0 ) // new corner found
{
int x = 0, y = 0, flag = 0;
text = Line + 7;
ret = sscanf( text, "%d %d %d", &x, &y, &flag);
if (ret < 3 ) error = true;
else
{
if ( ! has_corner )
Start( m_Layer, 0, 0,
x, y,
outline_hatch );
else
AppendCorner( x, y );
has_corner = true;
if ( flag ) Close();
}
}
if( strnicmp(Line, "ZInfo", 5 ) == 0 ) // general info found
{
int ts = 0, netcode = 0;
text = Line + 5;
ret = sscanf( text, "%X %d %s", &ts, &netcode, netname_buffer);
if (ret < 3 ) error = true;
else
{
m_TimeStamp = ts;
m_NetCode = netcode;
ReadDelimitedText( netname_buffer, netname_buffer, 1024 );
m_Netname = CONV_FROM_UTF8(netname_buffer);
}
}
if( strnicmp(Line, "ZLayer", 6 ) == 0 ) // layer found
{
int x = 0;
text = Line + 6;
ret = sscanf( text, "%d", &x);
if (ret < 1 ) error = true;
else m_Layer = x;
}
if( strnicmp(Line, "ZAux", 4 ) == 0 ) // aux info found
{
int x = 0;
char hopt[10];
text = Line + 4;
ret = sscanf( text, "%d %c", &x, hopt );
if (ret < 2 ) error = true;
else
{
n_corner_item = x;
switch ( hopt[0] )
{
case 'n':
case 'N':
outline_hatch = NO_HATCH;
break;
case 'e':
case 'E':
outline_hatch = DIAGONAL_EDGE;
break;
case 'f':
case 'F':
outline_hatch = DIAGONAL_FULL;
break;
}
}
}
if( strnicmp(Line, "$end", 4 ) == 0 ) // end of description
{
break;
}
}
return error ? 0 : 1;
}
/****************************************************************************************************/
void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode )
/****************************************************************************************************/
/** Function Draw
* @param panel = current Draw Panel
* @param DC = current Device Context
* @param offset = Draw offset (usually wxPoint(0,0))
* @param draw_mode = draw mode: OR, XOR ..
*/
{
int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
int color = g_DesignSettings.m_LayerColor[m_Layer];
if( ( color & (ITEM_NOT_SHOW | HIGHT_LIGHT_FLAG) ) == ITEM_NOT_SHOW )
return;
GRSetDrawMode( DC, draw_mode );
if( DisplayOpt.ContrastModeDisplay )
{
if( !IsOnLayer( curr_layer ) )
{
color &= ~MASKCOLOR;
color |= DARKDARKGRAY;
}
}
if( draw_mode & GR_SURBRILL )
{
if( draw_mode & GR_AND )
color &= ~HIGHT_LIGHT_FLAG;
else
color |= HIGHT_LIGHT_FLAG;
}
if( color & HIGHT_LIGHT_FLAG )
color = ColorRefs[color & MASKCOLOR].m_LightColor;
// draw the lines
int i_start_contour = 0;
for( unsigned ic = 0; ic < corner.size(); ic++ )
{
int xi = corner[ic].x + offset.x;
int yi = corner[ic].y + offset.y;
int xf, yf;
if( corner[ic].end_contour == FALSE && ic < corner.size() - 1 )
{
xf = corner[ic + 1].x + offset.x;
yf = corner[ic + 1].y + offset.y;
}
else
{
xf = corner[i_start_contour].x + offset.x;
yf = corner[i_start_contour].y + offset.y;
i_start_contour = ic + 1;
}
GRLine( &panel->m_ClipBox, DC, xi, yi, xf, yf, 0, color );
}
// draw hatches
for( unsigned ic = 0; ic < m_HatchLines.size(); ic++ )
{
int xi = m_HatchLines[ic].xi + offset.x;
int yi = m_HatchLines[ic].yi + offset.y;
int xf = m_HatchLines[ic].xf + offset.x;
int yf =m_HatchLines[ic].yf + offset.y;
GRLine( &panel->m_ClipBox, DC, xi, yi, xf, yf, 0, color );
}
}
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
* return true if refPos is near a corner or an edge
*/
bool ZONE_CONTAINER::HitTest( const wxPoint& refPos )
{
if( HitTestForCorner( refPos ) >= 0 )
return true;
if( HitTestForEdge( refPos ) >= 0 )
return true;
return false;
}
/**
* Function HitTestForCorner
* tests if the given wxPoint near a corner, or near the segment define by 2 corners.
* "near" means MIN_DIST_IN_PIXELS pixels
* @return -1 if none, corner index in .corner <vector>
* @param refPos : A wxPoint to test
*/
int ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
{
#define MIN_DIST_IN_PIXELS 5
int dist;
unsigned item_pos, lim;
lim = corner.size();
// Min distance to hit = MIN_DIST_IN_PIXELS pixels :
WinEDA_BasePcbFrame* frame = ((BOARD*)GetParent())->m_PcbFrame;
int min_dist = frame ? frame->GetZoom() * MIN_DIST_IN_PIXELS : 3;
for ( item_pos = 0; item_pos < lim; item_pos++ )
{
dist = abs( corner[item_pos].x - refPos.x ) + abs( corner[item_pos].y - refPos.y );
if( dist <= min_dist )
return item_pos;
}
return -1;
}
/**
* Function HitTestForEdge
* tests if the given wxPoint near a corner, or near the segment define by 2 corners.
* "near" means MIN_DIST_IN_PIXELS pixels
* @return -1 if none, or index of the starting corner in .corner <vector>
* @param refPos : A wxPoint to test
*/
int ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
{
#define MIN_DIST_IN_PIXELS 5
int dist;
unsigned item_pos, lim;
lim = corner.size();
// Min distance to hit = MIN_DIST_IN_PIXELS pixels :
WinEDA_BasePcbFrame* frame = ((BOARD*)GetParent())->m_PcbFrame;
int min_dist = frame ? frame->GetZoom() * MIN_DIST_IN_PIXELS : 3;
/* Test for an entire segment */
unsigned first_corner_pos = 0, end_segm;
for ( item_pos = 0; item_pos < lim; item_pos++ )
{
end_segm = item_pos+1;
/* the last corner of the current outline is tested
* the last segment of the current outline starts at current corner, and ends
* at the first corner of the outline
*/
if( corner[item_pos].end_contour || end_segm >= lim)
{
unsigned tmp = first_corner_pos;
first_corner_pos = end_segm; // first_corner_pos is now the beginning of the next outline
end_segm = tmp; // end_segm is the beginning of the current outline
}
/* test the dist between segment and ref point */
dist = (int) GetPointToLineSegmentDistance( refPos.x,
refPos.y,
corner[item_pos].x,
corner[item_pos].y,
corner[end_segm].x,
corner[end_segm].y );
if( dist <= min_dist )
return item_pos;
}
return -1;
}
/************************************************************/
void ZONE_CONTAINER::Display_Infos( WinEDA_DrawFrame* frame )
/************************************************************/
{
wxString msg;
int text_pos;
frame->MsgPanel->EraseMsgBox();
msg = _( "Zone Outline" );
text_pos = 1;
Affiche_1_Parametre( frame, text_pos, _( "Type" ), msg, DARKCYAN );
text_pos += 15;
EQUIPOT* equipot = ( (WinEDA_PcbFrame*) frame )->m_Pcb->FindNet( GetNet() );
if( equipot )
msg = equipot->m_Netname;
else
msg = wxT( "<noname>" );
Affiche_1_Parametre( frame, text_pos, _( "NetName" ), msg, RED );
/* Display net code : (usefull in test or debug) */
text_pos += 18;
msg.Printf( wxT( "%d" ), GetNet());
Affiche_1_Parametre( frame, text_pos, _( "NetCode" ), msg, RED );
text_pos += 8;
msg = ReturnPcbLayerName( m_Layer );
Affiche_1_Parametre( frame, text_pos, _( "Layer" ), msg, BROWN );
text_pos += 8;
msg.Printf( wxT( "%d" ), corner.size() );
Affiche_1_Parametre( frame, text_pos, _( "Corners" ), msg, BLUE );
text_pos += 8;
msg.Printf( wxT( "%d" ), m_HatchLines.size() );
Affiche_1_Parametre( frame, text_pos, _( "Hatch lines" ), msg, BLUE );
}

View File

@ -5,6 +5,8 @@
#ifndef CLASS_ZONE_H
#define CLASS_ZONE_H
#include "PolyLine.h"
/************************/
/* class ZONE_CONTAINER */
/************************/
@ -13,10 +15,11 @@
* others polygons inside this main polygon are holes.
*/
class ZONE_CONTAINER : public BOARD_ITEM // Not sure BOARD_ITEM is better than EDA_BaseStruct
class ZONE_CONTAINER : public BOARD_ITEM, public CPolyLine
{
public:
wxString m_Netname; /* Net Name */
int m_CornerSelection; // For corner moving, corner index to drag, or -1 if no selection
private:
int m_NetCode; // Net number for fast comparisons
@ -26,7 +29,47 @@ public:
~ZONE_CONTAINER();
bool Save( FILE* aFile ) const;
int ReadDescr( FILE* aFile, int* aLineNum = NULL );
wxPoint & GetPosition( ) { static wxPoint pos ;return pos; }
void UnLink(void) {};
void Display_Infos( WinEDA_DrawFrame* frame );
/** Function Draw
* Draws the zone outline.
* @param panel = current Draw Panel
* @param DC = current Device Context
* @param offset = Draw offset (usually wxPoint(0,0))
* @param draw_mode = draw mode: OR, XOR ..
*/
void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode );
int GetNet( void ) { return m_NetCode; }
void SetNet( int anet_code ) { m_NetCode = anet_code; }
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool HitTest( const wxPoint& refPos );
/**
* Function HitTestForCorner
* tests if the given wxPoint near a corner, or near the segment define by 2 corners.
* @return -1 if none, corner index in .corner <vector>
* @param refPos : A wxPoint to test
*/
int HitTestForCorner( const wxPoint& refPos );
/**
* Function HitTestForEdge
* tests if the given wxPoint near a corner, or near the segment define by 2 corners.
* @return -1 if none, or index of the starting corner in .corner <vector>
* @param refPos : A wxPoint to test
*/
int HitTestForEdge( const wxPoint& refPos );
};
/*******************/

View File

@ -47,6 +47,7 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
TYPETEXTEMODULE,
TYPEMODULE,
TYPEZONE,
TYPEZONE_CONTAINER,
EOT
};
@ -212,6 +213,8 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_BaseStruct* testItem, const void*
break;
case TYPEZONE:
break;
case TYPEZONE_CONTAINER:
break;
case TYPETEXTE:
break;
case TYPEDRAWSEGMENT:

View File

@ -68,6 +68,7 @@ WinEDA_ZoneFrame::WinEDA_ZoneFrame()
WinEDA_ZoneFrame::WinEDA_ZoneFrame( WinEDA_PcbFrame* parent,
ZONE_CONTAINER * zone_container,
wxWindowID id,
const wxString& caption,
const wxPoint& pos,
@ -75,6 +76,7 @@ WinEDA_ZoneFrame::WinEDA_ZoneFrame( WinEDA_PcbFrame* parent,
long style )
{
m_Parent = parent;
m_Zone_Container = zone_container;
if( m_Parent->m_Parent->m_EDA_Config )
{
@ -98,7 +100,6 @@ bool WinEDA_ZoneFrame::Create( wxWindow* parent,
long style )
{
////@begin WinEDA_ZoneFrame member initialisation
m_OutlinesOpt = 0;
m_GridCtrl = NULL;
m_ClearanceValueTitle = NULL;
m_ZoneClearanceCtrl = NULL;
@ -135,7 +136,7 @@ void WinEDA_ZoneFrame::CreateControls()
SetFont( *g_DialogFont );
////@begin WinEDA_ZoneFrame content construction
// Generated by DialogBlocks, 20/12/2007 15:46:22 (unregistered)
// Generated by DialogBlocks, 29/12/2007 14:29:53 (unregistered)
WinEDA_ZoneFrame* itemDialog1 = this;
@ -231,10 +232,11 @@ void WinEDA_ZoneFrame::CreateControls()
itemBoxSizer20->Add(m_LayerSelectionCtrl, 0, wxGROW|wxALL, 5);
// Set validators
m_OutlineAppearanceCtrl->SetValidator( wxGenericValidator(& m_OutlinesOpt) );
m_NetSortingOption->SetValidator( wxGenericValidator(& m_NetSorting) );
////@end WinEDA_ZoneFrame content construction
wxString title = _( "Zone clearance value:" ) + ReturnUnitSymbol( g_UnitMetric );
// Initialise options
wxString title = _( "Zone clearance value:" ) + ReturnUnitSymbol( g_UnitMetric );
m_ClearanceValueTitle->SetLabel( title );
title = _( "Grid :" ) + ReturnUnitSymbol( g_UnitMetric );;
@ -250,7 +252,7 @@ void WinEDA_ZoneFrame::CreateControls()
if( Zone_45_Only )
m_OrientEdgesOpt->SetSelection( 1 );
static const int GridList[4] = { 50, 100, 250 };
static const int GridList[3] = { 50, 100, 250 };
int selection = 0;
for( unsigned ii = 0; ii < (unsigned) m_GridCtrl->GetCount(); ii++ )
@ -263,7 +265,6 @@ void WinEDA_ZoneFrame::CreateControls()
selection = ii;
}
// Initialise options
m_GridCtrl->SetSelection( selection );
if( Zone_Exclude_Pads )
@ -274,6 +275,21 @@ void WinEDA_ZoneFrame::CreateControls()
m_FillOpt->SetSelection( 2 );
}
switch( s_Zone_Hatching )
{
case CPolyLine::NO_HATCH:
m_OutlineAppearanceCtrl->SetSelection(0);
break;
case CPolyLine::DIAGONAL_EDGE:
m_OutlineAppearanceCtrl->SetSelection(1);
break;
case CPolyLine::DIAGONAL_FULL:
m_OutlineAppearanceCtrl->SetSelection(2);
break;
}
m_NetSortingOption->SetSelection(m_NetSorting == 0 ? 0 : 1 );
int layer_cnt = g_DesignSettings.m_CopperLayerCount;
@ -288,8 +304,12 @@ void WinEDA_ZoneFrame::CreateControls()
m_LayerId[ii] = layer_number;
msg = ReturnPcbLayerName( layer_number ).Trim();
m_LayerSelectionCtrl->InsertItems( 1, &msg, ii );
if( m_Parent->GetScreen()->m_Active_Layer == layer_number )
m_LayerSelectionCtrl->SetSelection( ii );
if ( m_Zone_Container )
if( m_Zone_Container->GetLayer() == layer_number )
m_LayerSelectionCtrl->SetSelection( ii );
else
if( m_Parent->GetScreen()->m_Active_Layer == layer_number )
m_LayerSelectionCtrl->SetSelection( ii );
}
wxArrayString ListNetName;
@ -298,9 +318,12 @@ void WinEDA_ZoneFrame::CreateControls()
m_ListNetNameSelection->InsertItems( ListNetName, 0 );
// Select net:
if( g_HightLigth_NetCode > 0 )
int net_select = g_HightLigth_NetCode;
if ( m_Zone_Container )
net_select = m_Zone_Container->GetNet();
if( net_select > 0 )
{
EQUIPOT* equipot = m_Parent->m_Pcb->FindNet( g_HightLigth_NetCode );
EQUIPOT* equipot = m_Parent->m_Pcb->FindNet( net_select );
if( equipot ) // Search net in list and select it
{
for( unsigned ii = 0; ii < ListNetName.GetCount(); ii++ )
@ -389,6 +412,21 @@ bool WinEDA_ZoneFrame::AcceptOptions(bool aPromptForErrors)
break;
}
switch( m_OutlineAppearanceCtrl->GetSelection() )
{
case 0:
s_Zone_Hatching = CPolyLine::NO_HATCH;
break;
case 1:
s_Zone_Hatching = CPolyLine::DIAGONAL_EDGE;
break;
case 2:
s_Zone_Hatching = CPolyLine::DIAGONAL_FULL;
break;
}
switch( m_GridCtrl->GetSelection() )
{
case 0:

View File

@ -75,7 +75,13 @@ class WinEDA_ZoneFrame: public wxDialog
public:
/// Constructors
WinEDA_ZoneFrame( );
WinEDA_ZoneFrame( WinEDA_PcbFrame* parent, wxWindowID id = SYMBOL_WINEDA_ZONEFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_ZONEFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_ZONEFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_ZONEFRAME_SIZE, long style = SYMBOL_WINEDA_ZONEFRAME_STYLE );
WinEDA_ZoneFrame( WinEDA_PcbFrame* parent,
ZONE_CONTAINER * zone_container = NULL,
wxWindowID id = SYMBOL_WINEDA_ZONEFRAME_IDNAME,
const wxString& caption = SYMBOL_WINEDA_ZONEFRAME_TITLE,
const wxPoint& pos = SYMBOL_WINEDA_ZONEFRAME_POSITION,
const wxSize& size = SYMBOL_WINEDA_ZONEFRAME_SIZE,
long style = SYMBOL_WINEDA_ZONEFRAME_STYLE );
/// Creation
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_ZONEFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_ZONEFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_ZONEFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_ZONEFRAME_SIZE, long style = SYMBOL_WINEDA_ZONEFRAME_STYLE );
@ -98,9 +104,6 @@ public:
////@begin WinEDA_ZoneFrame member function declarations
int GetOutlinesOpt() const { return m_OutlinesOpt ; }
void SetOutlinesOpt(int value) { m_OutlinesOpt = value ; }
/// Retrieves bitmap resources
wxBitmap GetBitmapResource( const wxString& name );
@ -125,13 +128,13 @@ public:
wxRadioBox* m_NetSortingOption;
wxListBox* m_ListNetNameSelection;
wxListBox* m_LayerSelectionCtrl;
int m_OutlinesOpt;
////@end WinEDA_ZoneFrame member variables
WinEDA_PcbFrame * m_Parent;
int m_NetSorting;
int m_LayerId[LAYER_COUNT]; // Handle the real layer number from layer name position in m_LayerSelectionCtrl
ZONE_CONTAINER * m_Zone_Container;
};
#endif // DIALOG_ZONES_H_

Some files were not shown because too many files have changed in this diff Show More