Commit 5eda8a52 authored by CHARRAS's avatar CHARRAS

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

parent ee3d9844
ADD_DEFINITIONS(-DPCBNEW)
INCLUDE_DIRECTORIES(../pcbnew)
INCLUDE_DIRECTORIES(../pcbnew ../polygon)
SET(3D-VIEWER_SRCS
3d_aux.cpp
......
EXTRALIBS =
EXTRACPPFLAGS= -I./ -I../include -I../common -I../pcbnew
EXTRACPPFLAGS= -I./ -I../include -I../common -I../polygon -I../pcbnew
CPPFLAGS += $(EXTRACPPFLAGS)
......
......@@ -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>
================================================================================
......
......@@ -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
......
# 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
......
......@@ -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})
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
......
......@@ -41,7 +41,7 @@ enum KICAD_T {
TYPESCREEN,
TYPEBLOCK,
TYPEEDGEZONE,
TYPEZONE_POLYEDGE,
TYPEZONE_EDGE_CORNER,
TYPEZONE_CONTAINER,
// Draw Items in schematic
......
......@@ -5,7 +5,7 @@
COMMON_GLOBL wxString g_BuildVersion
#ifdef EDA_BASE
(wxT("(2007-12-17)"))
(wxT("(2007-12-22)"))
#endif
;
......
......@@ -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,
......
......@@ -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 );
// Target handling
void Fill_Zone( wxDC* DC, ZONE_CONTAINER * zone_container );
/**
* 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 );
......
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
......
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
......
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
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......@@ -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
};
......@@ -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;
......
This diff is collapsed.
......@@ -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 );
};
/*******************/
......
......@@ -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:
......
......@@ -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:
......
......@@ -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_
......
......@@ -218,7 +218,6 @@
<string name="id-suffix">""</string>
<long name="use-xrc">0</long>
<long name="working-mode">0</long>
<string name="variable-0">"m_OutlinesOpt|int|OutlinesOpt|0|0|0|"</string>
<string name="proxy-Id name">"ID_DIALOG"</string>
<long name="proxy-Id value">10000</long>
<string name="proxy-Class">"WinEDA_ZoneFrame"</string>
......@@ -595,8 +594,8 @@
<bool name="proxy-Hidden">0</bool>
<bool name="proxy-Enabled">1</bool>
<string name="proxy-Platform">"&lt;Any platform&gt;"</string>
<string name="proxy-Data variable">"m_OutlinesOpt"</string>
<string name="proxy-Data validator">"wxGenericValidator(&amp; %VARIABLE%)"</string>
<string name="proxy-Data variable">""</string>
<string name="proxy-Data validator">""</string>
<string name="proxy-Data source">""</string>
<string name="proxy-Data class name">""</string>
<string name="proxy-Data class implementation filename">""</string>
......
......@@ -67,13 +67,13 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE:
case ID_POPUP_PCB_DELETE_EDGE_ZONE:
case ID_POPUP_PCB_DELETE_ZONE_LIMIT:
case ID_POPUP_PCB_EDIT_ZONE:
case ID_POPUP_PCB_PLACE_ZONE_CORNER:
case ID_POPUP_PCB_EDIT_ZONE_PARAMS:
case ID_POPUP_PCB_DELETE_ZONE:
case ID_POPUP_PCB_DELETE_TRACKSEG:
case ID_POPUP_PCB_DELETE_TRACK:
case ID_POPUP_PCB_DELETE_TRACKNET:
case ID_POPUP_PCB_FILL_ZONE:
case ID_POPUP_PCB_SELECT_NET_ZONE:
case ID_POPUP_PCB_SELECT_LAYER:
case ID_POPUP_PCB_SELECT_CU_LAYER:
case ID_POPUP_PCB_SELECT_LAYER_PAIR:
......@@ -445,18 +445,71 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
SetCurItem( NULL );
break;
case ID_POPUP_PCB_EDIT_ZONE:
case ID_POPUP_PCB_EDIT_ZONE_PARAMS:
Edit_Zone_Params( &dc, (ZONE_CONTAINER*) GetCurItem() );
break;
case ID_POPUP_PCB_DELETE_ZONE_CONTAINER:
DrawPanel->MouseToCursorSchema();
if( GetCurItem() == NULL )
break;
Edit_Zone_Width( &dc, (SEGZONE*) GetCurItem() );
((ZONE_CONTAINER*)GetCurItem())->Draw(DrawPanel,&dc, wxPoint(0,0), GR_XOR);
m_Pcb->Delete( GetCurItem() );
SetCurItem( NULL );
break;
case ID_POPUP_PCB_DELETE_ZONE_CORNER:
{
DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER * zone_cont = (ZONE_CONTAINER*)GetCurItem();
zone_cont->Draw(DrawPanel,&dc, wxPoint(0,0), GR_XOR);
zone_cont->DeleteCorner(zone_cont->m_CornerSelection);
zone_cont->Draw(DrawPanel,&dc, wxPoint(0,0), GR_XOR);
SetCurItem( NULL );
break;
}
case ID_POPUP_PCB_MOVE_ZONE_CORNER:
{
DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER * zone_cont = (ZONE_CONTAINER*)GetCurItem();
Start_Move_Zone_Corner(&dc, zone_cont, zone_cont->m_CornerSelection, false);
break;
}
case ID_POPUP_PCB_ADD_ZONE_CORNER:
{
DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER * zone_cont = (ZONE_CONTAINER*)GetCurItem();
wxPoint pos = GetScreen()->m_Curseur;
/* add corner between zone_cont->m_CornerSelection
* and zone_cont->m_CornerSelection+1
* and start move the new corner
*/
zone_cont->Draw(DrawPanel, &dc, wxPoint(0,0), GR_XOR);
zone_cont->InsertCorner( zone_cont->m_CornerSelection, pos.x, pos.y );
zone_cont->m_CornerSelection++;
zone_cont->Draw(DrawPanel, &dc, wxPoint(0,0), GR_XOR);
Start_Move_Zone_Corner(&dc, zone_cont, zone_cont->m_CornerSelection, true);
break;
}
case ID_POPUP_PCB_PLACE_ZONE_CORNER:
{
DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER * zone_cont = (ZONE_CONTAINER*)GetCurItem();
End_Move_Zone_Corner(&dc, zone_cont);
break;
}
case ID_POPUP_PCB_DELETE_ZONE_LIMIT:
DrawPanel->MouseToCursorSchema();
DelLimitesZone( &dc, TRUE );
break;
case ID_POPUP_PCB_FILL_ZONE:
DrawPanel->MouseToCursorSchema();
Fill_Zone( &dc, (ZONE_CONTAINER*)GetCurItem() );
break;
case ID_PCB_DELETE_ITEM_BUTT:
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
break;
......@@ -745,16 +798,6 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
}
break;
case ID_POPUP_PCB_FILL_ZONE:
DrawPanel->MouseToCursorSchema();
Fill_Zone( &dc );
break;
case ID_POPUP_PCB_SELECT_NET_ZONE:
DrawPanel->MouseToCursorSchema();
CaptureNetName( &dc );
break;
case ID_POPUP_PCB_SELECT_WIDTH:
break;
......
/**********************************************/
/* PCBNEW : Routines d'initialisation globale */
/******* Fichier INITPCB.C ********************/
/**********************************************/
/*********************************************/
/******* file initpcb.cpp ********************/
/*********************************************/
#include "fctsys.h"
......@@ -148,6 +147,9 @@ bool WinEDA_BasePcbFrame::Clear_Pcb( bool query )
DelLimitesZone( NULL, FALSE );
m_Pcb->DeleteMARKERs();
m_Pcb->DeleteZONEOutlines();
for( ; g_UnDeleteStackPtr != 0; )
{
g_UnDeleteStackPtr--;
......@@ -221,6 +223,7 @@ void WinEDA_PcbFrame::Erase_Zones( bool query )
}
DelLimitesZone( NULL, FALSE );
m_Pcb->DeleteZONEOutlines();
GetScreen()->SetModify();
}
......
......@@ -815,6 +815,13 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append )
continue;
}
if( strnicmp( Line, "$CZONE_OUTLINE", 7 ) == 0 )
{
ZONE_CONTAINER * zone_descr = new ZONE_CONTAINER(m_Pcb);
zone_descr->ReadDescr( File, &LineNum );
m_Pcb->m_ZoneDescriptorList.push_back(zone_descr);
}
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
{
Module = new MODULE( m_Pcb );
......
EXTRALIBS = ../common/common.a
EXTRALIBS = ../common/common.a ../polygon/lib_polygon.a
EXTRACPPFLAGS += -DPCBNEW -fno-strict-aliasing -I./ -Ibitmaps -I../include -I../share\
-I../pcbnew -I../3d-viewer -I../polygon
......
......@@ -38,6 +38,11 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
switch( DrawStruct->Type() )
{
case TYPEZONE_CONTAINER:
End_Move_Zone_Corner( DC, (ZONE_CONTAINER *) DrawStruct );
exit = true;
break;
case TYPETRACK:
case TYPEVIA:
if( DrawStruct->m_Flags & IS_DRAGGED )
......
......@@ -275,6 +275,41 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
_( "Delete edge zone" ), delete_xpm );
break;
case TYPEZONE_CONTAINER:
{
ZONE_CONTAINER * edge_zone = (ZONE_CONTAINER *) item;
if ( edge_zone->m_Flags )
{
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_PLACE_ZONE_CORNER,
_( "Place Corner" ), apply_xpm );
}
else
{
edge_zone->m_CornerSelection = -1;
int index;
if ( (index = edge_zone->HitTestForCorner( GetScreen()->m_Curseur )) >= 0 )
{
edge_zone->m_CornerSelection = index;
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_ZONE_CORNER,
_( "Move Corner" ), move_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_ZONE_CORNER,
_( "Delete Corner" ), delete_xpm );
}
else if ( (index = edge_zone->HitTestForEdge( GetScreen()->m_Curseur )) >= 0 )
{
edge_zone->m_CornerSelection = index;
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_ADD_ZONE_CORNER,
_( "Create Corner" ), move_xpm );
}
aPopMenu->AppendSeparator();
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_ZONE_PARAMS,
_( "Edit Zone Params" ), edit_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_ZONE_CONTAINER,
_( "Delete Zone Outline" ), delete_xpm );
}
}
break;
case TYPETEXTE:
createPopUpMenuForTexts( (TEXTE_PCB*) item, aPopMenu );
break;
......@@ -286,8 +321,6 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
break;
case TYPEZONE:
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_ZONE,
_( "Edit Zone" ), edit_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_ZONE,
_( "Delete Zone" ), delete_xpm );
break;
......@@ -358,14 +391,6 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_FILL_ZONE,
_( "Fill zone" ), fill_zone_xpm );
if( item
&& ( (item->Type() == TYPEPAD)
|| (item->Type() == TYPETRACK)
|| (item->Type() == TYPEVIA) ) )
{
add_separator = TRUE;
aPopMenu->Append( ID_POPUP_PCB_SELECT_NET_ZONE, _( "Select Net" ) );
}
if( m_Pcb->m_CurrentLimitZone )
{
add_separator = TRUE;
......
......@@ -8,6 +8,8 @@
* Routines d'affichage grille, Boite de coordonnees, Curseurs, marqueurs ...
*/
#include <vector.h>
#include "fctsys.h"
#include "gr_basic.h"
......@@ -18,9 +20,7 @@
#include "protos.h"
/* Routines Locales : */
/* Variables Locales */
using namespace std;
/**********************************************************************/
......@@ -185,6 +185,12 @@ void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode )
Trace_DrawSegmentPcb( DrawPanel, DC, segment, mode );
}
for( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
{
ZONE_CONTAINER* edge_zone = m_Pcb->m_ZoneDescriptorList[ii];
edge_zone->Draw( DrawPanel, DC, wxPoint(0,0), mode);
}
DrawGeneralRatsnest( DC );
m_CurrentScreen->ClrRefreshReq();
......
This diff is collapsed.
This diff is collapsed.
// PolyLine.h ... definition of CPolyLine class
//
// A polyline contains one or more contours, where each contour
// is defined by a list of corners and side-styles
// There may be multiple contours in a polyline.
// The last contour may be open or closed, any others must be closed.
// All of the corners and side-styles are concatenated into 2 arrays,
// separated by setting the end_contour flag of the last corner of
// each contour.
//
// When used for copper areas, the first contour is the outer edge
// of the area, subsequent ones are "holes" in the copper.
//
// If a CDisplayList pointer is provided, the polyline can draw itself
#ifndef POLYLINE_H
#define POLYLINE_H
#include <vector>
#include "defs-macros.h"
#include "GenericPolygonClipperLibrary.h"
#include "php_polygon.h"
#include "php_polygon_vertex.h"
#include "PolyLine2Kicad.h"
#include "freepcb_ids.h"
#include "freepcbDisplayList.h"
#include "math_for_graphics.h"
class CSegment {
public:
int xi, yi, xf, yf;
CSegment() {};
CSegment(int x0, int y0, int x1, int y1) {
xi = x0; yi = y0; xf = x1; yf = y1; }
};
class CArc {
public:
enum{ MAX_STEP = 50*25400 }; // max step is 20 mils
enum{ MIN_STEPS = 18 }; // min step is 5 degrees
int style;
int xi, yi, xf, yf;
int n_steps; // number of straight-line segments in gpc_poly
BOOL bFound;
};
class CPolyPt
{
public:
CPolyPt( int qx=0, int qy=0, BOOL qf=FALSE )
{ x=qx; y=qy; end_contour=qf; utility = 0; };
int x;
int y;
BOOL end_contour;
int utility;
};
class CPolyLine
{
public:
enum { STRAIGHT, ARC_CW, ARC_CCW }; // side styles
enum { NO_HATCH, DIAGONAL_FULL, DIAGONAL_EDGE }; // hatch styles
enum { DEF_SIZE = 50, DEF_ADD = 50 }; // number of array elements to add at a time
// constructors/destructor
CPolyLine( CDisplayList * dl );
CPolyLine();
~CPolyLine();
// functions for modifying polyline
void Start( int layer, int w, int sel_box, int x, int y,
int hatch );
void AppendCorner( int x, int y, int style = STRAIGHT, BOOL bDraw=TRUE );
void InsertCorner( int ic, int x, int y );
void DeleteCorner( int ic, BOOL bDraw=TRUE );
void MoveCorner( int ic, int x, int y );
void Close( int style = STRAIGHT, BOOL bDraw=TRUE );
void RemoveContour( int icont );
// drawing functions
void HighlightSide( int is );
void HighlightCorner( int ic );
void StartDraggingToInsertCorner( CDC * pDC, int ic, int x, int y);
void StartDraggingToMoveCorner( CDC * pDC, int ic, int x, int y);
void CancelDraggingToInsertCorner( int ic );
void CancelDraggingToMoveCorner( int ic );
void Undraw();
void Draw( CDisplayList * dl = NULL );
void Hatch();
void MakeVisible( BOOL visible = TRUE );
void MoveOrigin( int x_off, int y_off );
// misc. functions
CRect GetBounds();
CRect GetCornerBounds();
CRect GetCornerBounds( int icont );
void Copy( CPolyLine * src );
BOOL TestPointInside( int x, int y );
BOOL TestPointInsideContour( int icont, int x, int y );
int TestIntersection( CPolyLine * poly );
void AppendArc( int xi, int yi, int xf, int yf, int xc, int yc, int num );
// access functions
int GetNumCorners();
int GetNumSides();
int GetClosed();
int GetNumContours();
int GetContour( int ic );
int GetContourStart( int icont );
int GetContourEnd( int icont );
int GetContourSize( int icont );
int GetX( int ic );
int GetY( int ic );
int GetEndContour( int ic );
int GetUtility( int ic ){ return corner[ic].utility; };
void SetUtility( int ic, int utility ){ corner[ic].utility = utility; };
int GetW();
int GetSideStyle( int is );
id GetId();
int GetSelBoxSize();
CDisplayList * GetDisplayList(){ return m_dlist; };
int GetHatch(){ return m_HatchStyle; }
void SetHatch( int hatch ){ Undraw(); m_HatchStyle = hatch; Draw(); };
void SetX( int ic, int x );
void SetY( int ic, int y );
void SetEndContour( int ic, BOOL end_contour );
// void SetLayer( int layer );
void SetW( int w );
void SetSideStyle( int is, int style );
void SetSelBoxSize( int sel_box );
void SetDisplayList( CDisplayList * dl );
// GPC functions
int MakeGpcPoly( int icontour=0, std::vector<CArc> * arc_array=NULL );
int FreeGpcPoly();
gpc_polygon * GetGpcPoly(){ return m_gpc_poly; };
int NormalizeWithGpc( std::vector<CPolyLine*> * pa=NULL, BOOL bRetainArcs=FALSE );
int RestoreArcs( std::vector<CArc> * arc_array, std::vector<CPolyLine*> * pa=NULL );
CPolyLine * MakePolylineForPad( int type, int x, int y, int w, int l, int r, int angle );
void AddContourForPadClearance( int type, int x, int y, int w,
int l, int r, int angle, int fill_clearance,
int hole_w, int hole_clearance, BOOL bThermal=FALSE, int spoke_w=0 );
void ClipGpcPolygon( gpc_op op, CPolyLine * poly );
// PHP functions
int MakePhpPoly();
void FreePhpPoly();
void ClipPhpPolygon( int php_op, CPolyLine * poly );
private:
CDisplayList * m_dlist; // display list
int m_layer; // layer to draw on
int m_Width; // line width
int m_sel_box; // corner selection box width/2
public:
std::vector <CPolyPt> corner; // array of points for corners
std::vector <int> side_style; // array of styles for sides
private:
std::vector <dl_element*> dl_side; // graphic elements
std::vector <dl_element*> dl_side_sel;
std::vector <dl_element*> dl_corner_sel;
public:
int m_HatchStyle; // hatch style, see enum above
std::vector <CSegment> m_HatchLines; // hatch lines
private:
gpc_polygon * m_gpc_poly; // polygon in gpc format
polygon * m_php_poly;
BOOL bDrawn;
};
#endif // #ifndef POLYLINE_H
// PolyLine.h ... definition of CPolyLine class
//
// A polyline contains one or more contours, where each contour
// is defined by a list of corners and side-styles
// There may be multiple contours in a polyline.
// The last contour may be open or closed, any others must be closed.
// All of the corners and side-styles are concatenated into 2 arrays,
// separated by setting the end_contour flag of the last corner of
// each contour.
//
// When used for copper areas, the first contour is the outer edge
// of the area, subsequent ones are "holes" in the copper.
//
// If a CDisplayList pointer is provided, the polyline can draw itself
#ifndef POLYLINE2KICAD_H
#define POLYLINE2KICAD_H
#define PCBU_PER_MIL 10
#define MAX_LAYERS 32
#define NM_PER_MIL 10 // 25400
// pad shapes
enum
{
PAD_NONE = 0,
PAD_ROUND,
PAD_SQUARE,
PAD_RECT,
PAD_RRECT,
PAD_OVAL,
PAD_OCTAGON
};
/*
enum
{
// visible layers
LAY_SELECTION = 0,
LAY_BACKGND,
LAY_VISIBLE_GRID,
LAY_HILITE,
LAY_DRC_ERROR,
LAY_BOARD_OUTLINE,
LAY_RAT_LINE,
LAY_SILK_TOP,
LAY_SILK_BOTTOM,
LAY_SM_TOP,
LAY_SM_BOTTOM,
LAY_PAD_THRU,
LAY_TOP_COPPER,
LAY_BOTTOM_COPPER,
// invisible layers
LAY_MASK_TOP = -100,
LAY_MASK_BOTTOM = -101,
LAY_PASTE_TOP = -102,
LAY_PASTE_BOTTOM = -103
};
*/
#define LAY_SELECTION 0
#define LAY_TOP_COPPER 0
#define CDC wxDC
class wxDC;
#if 0
class dl_element;
class CDisplayList {
public:
void Set_visible(void*, int) {};
int Get_x(void) { return 0;};
int Get_y(void) { return 0;};
void StopDragging(void) {};
void CancelHighLight(void) {};
void StartDraggingLineVertex(...) {};
void Add() {};
};
#endif
class CRect {
public:
int left, right, top, bottom;
};
class CPoint {
public:
int x, y;
public:
CPoint(void) { x = y = 0;};
CPoint(int i, int j) { x = i; y = j;};
};
#endif // #ifndef POLYLINE2KICAD_H
/* stuff for class CDisplayList */
#include "PolyLine.h"
dl_element * CDisplayList::Add( id id, void * ptr, int glayer, int gtype, int visible,
int w, int holew, int x, int y, int xf, int yf, int xo, int yo,
int radius, int orig_layer )
{
return NULL;
}
dl_element * CDisplayList::AddSelector( id id, void * ptr, int glayer, int gtype, int visible,
int w, int holew, int x, int y, int xf, int yf, int xo, int yo, int radius )
{
return NULL;
}
void CDisplayList::Set_visible( dl_element * el, int visible )
{
}
int CDisplayList::StopDragging()
{
return 0;
}
int CDisplayList::CancelHighLight()
{
return 0;
}
void CDisplayList::Set_id( dl_element * el, id * id )
{
}
id CDisplayList::Remove( dl_element * element )
{
return 0;
}
int CDisplayList::Get_w( dl_element * el )
{
return 0;
}
int CDisplayList::Get_x( dl_element * el )
{
return 0;
}
int CDisplayList::Get_y( dl_element * el )
{
return 0;
}
int CDisplayList::Get_xf( dl_element * el )
{
return 0;
}
int CDisplayList::Get_yf( dl_element * el )
{
return 0;
}
int CDisplayList::HighLight( int gtype, int x, int y, int xf, int yf, int w, int orig_layer )
{
return 0;
}
int CDisplayList::StartDraggingLineVertex( CDC * pDC, int x, int y, int xi, int yi,
int xf, int yf,
int layer1, int layer2, int w1, int w2,
int style1, int style2,
int layer_no_via, int via_w, int via_holew, int dir,
int crosshair )
{
return 0;
}
int CDisplayList::StartDraggingArc( CDC * pDC, int style, int x, int y, int xi, int yi,
int layer, int w, int crosshair )
{
return 0;
}
This diff is collapsed.
// definition of ID structure used by FreePCB
//
#pragma once
// struct id : this structure is used to identify PCB design elements
// such as instances of parts or nets, and their subelements
// Each element will have its own id.
// An id is attached to each item of the Display List so that it can
// be linked back to the PCB design element which drew it.
// These are mainly used to identify items selected by clicking the mouse
//
// In general:
// id.type = type of PCB element (e.g. part, net, text)
// id.st = subelement type (e.g. part pad, net connection)
// id.i = subelement index (zero-based)
// id.sst = subelement of subelement (e.g. net connection segment)
// id.ii = subsubelement index (zero-based)
//
// For example, the id for segment 0 of connection 4 of net 12 would be
// id = { ID_NET, 12, ID_CONNECT, 4, ID_SEG, 0 };
//
//
class id {
public:
// constructor
id( int qt=0, int qst=0, int qis=0, int qsst=0, int qiis=0 )
{ type=qt; st=qst; i=qis; sst=qsst; ii=qiis; }
// operators
friend int operator ==(id id1, id id2)
{ return (id1.type==id2.type
&& id1.st==id2.st
&& id1.sst==id2.sst
&& id1.i==id2.i
&& id1.ii==id2.ii );
}
// member functions
void Clear()
{ type=0; st=0; i=0; sst=0; ii=0; }
void Set( int qt, int qst=0, int qis=0, int qsst=0, int qiis=0 )
{ type=qt; st=qst; i=qis; sst=qsst; ii=qiis; }
// member variables
unsigned int type; // type of element
unsigned int st; // type of subelement
unsigned int i; // index of subelement
unsigned int sst; // type of subsubelement
unsigned int ii; // index of subsubelement
};
// these are constants used in ids
// root types
enum {
ID_NONE = 0, // an undefined type or st (or an error)
ID_BOARD, // board outline
ID_PART, // part
ID_NET, // net
ID_TEXT, // free-standing text
ID_DRC, // DRC error
ID_SM_CUTOUT, // cutout for solder mask
ID_MULTI // if multiple selections
};
// subtypes of ID_PART
enum {
ID_PAD = 1, // pad_stack in a part
ID_SEL_PAD, // selection rectangle for pad_stack in a part
ID_OUTLINE, // part outline
ID_REF_TXT, // text showing ref num for part
ID_ORIG, // part origin
ID_SEL_RECT, // selection rectangle for part
ID_SEL_REF_TXT // selection rectangle for ref text
};
// subtypes of ID_TEXT
enum {
ID_SEL_TXT = 1, // selection rectangle
ID_STROKE // stroke for text
};
// subtypes of ID_NET
enum {
ID_ENTIRE_NET = 0,
ID_CONNECT, // connection
ID_AREA // copper area
};
// subtypes of ID_BOARD
enum {
ID_BOARD_OUTLINE = 1,
};
// subsubtypes of ID_NET.ID_CONNECT
enum {
ID_ENTIRE_CONNECT = 0,
ID_SEG,
ID_SEL_SEG,
ID_VERTEX,
ID_SEL_VERTEX,
ID_VIA
};
// subsubtypes of ID_NET.ID_AREA, ID_BOARD.ID_BOARD_OUTLINE, ID_SM_CUTOUT
enum {
ID_SIDE = 1,
ID_SEL_SIDE,
ID_SEL_CORNER,
ID_HATCH,
ID_PIN_X, // only used by ID_AREA
ID_STUB_X // only used by ID_AREA
};
// subtypes of ID_DRC
// for subsubtypes, use types in DesignRules.h
enum {
ID_DRE = 1,
ID_SEL_DRE
};
......@@ -9,7 +9,8 @@ OBJECTS= \
php_polygon.o\
php_polygon_vertex.o\
PolyLine.o\
math_for_graphics.o
math_for_graphics.o\
cdisplaylist_stuff.o
GenericPolygonClipperLibrary.o: GenericPolygonClipperLibrary.cpp GenericPolygonClipperLibrary.h
......
This diff is collapsed.
// math stuff for graphics, from FreePCB
typedef struct PointTag
{
double X,Y;
} Point;
typedef struct EllipseTag
{
Point Center; /* ellipse center */
// double MaxRad,MinRad; /* major and minor axis */
// double Phi; /* major axis rotation */
double xrad, yrad; // radii on x and y
double theta1, theta2; // start and end angle for arc
} EllipseKH;
const CPoint zero(0,0);
class my_circle {
public:
my_circle(){};
my_circle( int xx, int yy, int rr )
{
x = xx;
y = yy;
r = rr;
};
int x, y, r;
};
class my_rect {
public:
my_rect(){};
my_rect( int xi, int yi, int xf, int yf )
{
xlo = min(xi,xf);
xhi = max(xi,xf);
ylo = min(yi,yf);
yhi = max(yi,yf);
};
int xlo, ylo, xhi, yhi;
};
class my_seg {
public:
my_seg(){};
my_seg( int xxi, int yyi, int xxf, int yyf )
{
xi = xxi;
yi = yyi;
xf = xxf;
yf = yyf;
};
int xi, yi, xf, yf;
};
// math stuff for graphics
BOOL Quadratic( double a, double b, double c, double *x1, double *x2 );
void DrawArc( CDC * pDC, int shape, int xxi, int yyi, int xxf, int yyf, BOOL bMeta=FALSE );
void RotatePoint( CPoint *p, int angle, CPoint org );
void RotateRect( CRect *r, int angle, CPoint org );
int TestLineHit( int xi, int yi, int xf, int yf, int x, int y, double dist );
int FindLineIntersection( double a, double b, double c, double d, double * x, double * y );
int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int yf, int style,
double * x1, double * y1, double * x2, double * y2, double * dist=NULL );
int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style,
int xi2, int yi2, int xf2, int yf2, int style2,
double x[]=NULL, double y[]=NULL );
BOOL FindLineEllipseIntersections( double a, double b, double c, double d, double *x1, double *x2 );
BOOL FindVerticalLineEllipseIntersections( double a, double b, double x, double *y1, double *y2 );
BOOL TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y1f,
int x2i, int y2i, int x2f, int y2f,
int * x=NULL, int * y=NULL, double * dist=NULL );
void GetPadElements( int type, int x, int y, int wid, int len, int radius, int angle,
int * nr, my_rect r[], int * nc, my_circle c[], int * ns, my_seg s[] );
int GetClearanceBetweenPads( int type1, int x1, int y1, int w1, int l1, int r1, int angle1,
int type2, int x2, int y2, int w2, int l2, int r2, int angle2 );
int GetClearanceBetweenSegmentAndPad( int x1, int y1, int x2, int y2, int w,
int type, int x, int y, int wid, int len,
int radius, int angle );
int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1, int w1,
int x2i, int y2i, int x2f, int y2f, int style2, int w2,
int max_cl, int * x, int * y );
/** Function GetPointToLineSegmentDistance
* Get distance between line segment and point
* @param x,y = point
* @param xi,yi and xf,yf = the end-points of the line segment
* @return the distance
*/
double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int yf );
double GetPointToLineDistance( double a, double b, int x, int y, double * xp=NULL, double * yp=NULL );
BOOL InRange( double x, double xi, double xf );
double Distance( int x1, int y1, int x2, int y2 );
int GetArcIntersections( EllipseKH * el1, EllipseKH * el2,
double * x1=NULL, double * y1=NULL,
double * x2=NULL, double * y2=NULL );
CPoint GetInflectionPoint( CPoint pi, CPoint pf, int mode );
// quicksort (2-way or 3-way)
void quickSort(int numbers[], int index[], int array_size);
void q_sort(int numbers[], int index[], int left, int right);
void q_sort_3way( int a[], int b[], int left, int right );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment