Commit f85ade75 authored by CHARRAS's avatar CHARRAS

see changelog

parent ed0265cb
...@@ -3,6 +3,15 @@ Started 2007-June-11 ...@@ -3,6 +3,15 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Dec-16 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
Move Zone outlines added
Zone outline DRC works (needs improvements)
some bugs solved, but polyline.cpp still needs work.
gendrill: code cleaning.
2007-Dec-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2007-Dec-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
+pcbnew: +pcbnew:
......
#define MACHINE "PC"
#define NB_CLES 16
#define POSITION_LICENCE 50
#define POSITION_CLE 250
#define TAILLE_LICENCE 256
...@@ -228,25 +228,40 @@ wxString FullFileName, ShortLibName, mask; ...@@ -228,25 +228,40 @@ wxString FullFileName, ShortLibName, mask;
Update(); Update();
mask = wxT("*") + LibExtBuffer; mask = wxT("*") + LibExtBuffer;
FullFileName = EDA_FileSelector( _("Libraries"),
g_RealLibDirBuffer, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
LibExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
0,
TRUE /* ne chage pas de repertoire courant */
);
if (FullFileName == wxEmptyString ) return;
wxFileDialog FilesDialog(this, _("Library Files:"), g_RealLibDirBuffer,
wxEmptyString, mask,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE);
FilesDialog.ShowModal();
wxArrayString Filenames;
FilesDialog.GetFilenames(Filenames);
if ( Filenames.GetCount() == 0 )
return;
for ( unsigned jj = 0; jj < Filenames.GetCount(); jj ++ )
{
FullFileName = Filenames[jj];
ShortLibName = MakeReducedFileName(FullFileName,g_RealLibDirBuffer,LibExtBuffer); ShortLibName = MakeReducedFileName(FullFileName,g_RealLibDirBuffer,LibExtBuffer);
g_LibName_List.Insert(ShortLibName, ii); //Add or insert new library name
if ( g_LibName_List.Index(ShortLibName) == wxNOT_FOUND)
{
ListModIsModified = 1;
g_LibName_List.Insert(ShortLibName, ii++);
}
else
{
wxString msg;
msg << wxT("<") << ShortLibName << wxT("> : ") << _("Library already in use");
DisplayError(this, msg);
}
}
g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
SetRealLibraryPath( wxT("modules") ); SetRealLibraryPath( wxT("modules") );
listlib(); listlib();
ListModIsModified = 1;
m_Parent->BuildFootprintListBox(); m_Parent->BuildFootprintListBox();
...@@ -282,23 +297,37 @@ wxString FullFileName, ShortLibName, mask; ...@@ -282,23 +297,37 @@ wxString FullFileName, ShortLibName, mask;
Update(); Update();
mask = wxT("*") + g_EquivExtBuffer; mask = wxT("*") + g_EquivExtBuffer;
FullFileName = EDA_FileSelector( _("Equiv"),
g_RealLibDirBuffer, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_EquivExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
0,
TRUE /* ne chage pas de repertoire courant */
);
if (FullFileName == wxEmptyString ) return; wxFileDialog FilesDialog(this, _("Equiv Files:"), g_RealLibDirBuffer,
wxEmptyString, mask,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE);
FilesDialog.ShowModal();
wxArrayString Filenames;
FilesDialog.GetFilenames(Filenames);
if ( Filenames.GetCount() == 0 )
return;
for ( unsigned jj = 0; jj < Filenames.GetCount(); jj ++ )
{
FullFileName = Filenames[jj];
ShortLibName = MakeReducedFileName(FullFileName,g_RealLibDirBuffer,g_EquivExtBuffer); ShortLibName = MakeReducedFileName(FullFileName,g_RealLibDirBuffer,g_EquivExtBuffer);
g_ListName_Equ.Insert(ShortLibName, ii); //Add or insert new equiv library name
if ( g_ListName_Equ.Index(ShortLibName) == wxNOT_FOUND)
{
g_ListName_Equ.Insert(ShortLibName, ii++);
}
else
{
wxString msg;
msg << wxT("<") << ShortLibName << wxT("> : ") << _("Library already in use");
DisplayError(this, msg);
}
}
/* Mise a jour de l'affichage */ /* Update display list */
g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); g_UserLibDirBuffer = m_LibDirCtrl->GetValue();
SetRealLibraryPath( wxT("modules") ); SetRealLibraryPath( wxT("modules") );
listlib(); listlib();
......
...@@ -364,20 +364,21 @@ wxString FullLibName,ShortLibName, Mask; ...@@ -364,20 +364,21 @@ wxString FullLibName,ShortLibName, Mask;
} }
Mask = wxT("*") + g_LibExtBuffer; Mask = wxT("*") + g_LibExtBuffer;
FullLibName = EDA_FileSelector( _("Library files:"),
g_RealLibDirBuffer, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_LibExtBuffer, /* extension par defaut */
Mask, /* Masque d'affichage */
this,
wxFD_OPEN,
TRUE
);
if ( FullLibName.IsEmpty() ) return;
ShortLibName = MakeReducedFileName(FullLibName,g_RealLibDirBuffer,g_LibExtBuffer); wxFileDialog FilesDialog(this, _("Library files:"), g_RealLibDirBuffer,
wxEmptyString, Mask,
wxFD_DEFAULT_STYLE | wxFD_MULTIPLE);
FilesDialog.ShowModal();
wxArrayString Filenames;
FilesDialog.GetFilenames(Filenames);
for ( unsigned jj = 0; jj < Filenames.GetCount(); jj ++ )
{
FullLibName = Filenames[jj];
ShortLibName = MakeReducedFileName(FullLibName,g_RealLibDirBuffer,g_LibExtBuffer);
if ( ShortLibName.IsEmpty() ) //Just in case...
continue;
//Add or insert new library name //Add or insert new library name
if (FindLibrary(ShortLibName) == NULL) if (FindLibrary(ShortLibName) == NULL)
{ {
...@@ -387,7 +388,13 @@ wxString FullLibName,ShortLibName, Mask; ...@@ -387,7 +388,13 @@ wxString FullLibName,ShortLibName, Mask;
m_ListLibr->InsertItems(g_LibName_List, 0); m_ListLibr->InsertItems(g_LibName_List, 0);
} }
else DisplayError(this, _("Library already in use")); else
{
wxString msg;
msg << wxT("<") << ShortLibName << wxT("> : ") << _("Library already in use");
DisplayError(this, msg);
}
}
} }
......
...@@ -561,8 +561,8 @@ enum main_id { ...@@ -561,8 +561,8 @@ enum main_id {
ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE, ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE,
ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE, ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE,
ID_POPUP_PCB_DELETE_ZONE_CUTOUT, ID_POPUP_PCB_DELETE_ZONE_CUTOUT,
ID_POPUP_ZONE_UNUSED2, ID_POPUP_PCB_MOVE_ZONE_OUTLINES,
ID_POPUP_ZONE_UNUSED3, ID_POPUP_PCB_PLACE_ZONE_OUTLINES,
ID_POPUP_ZONE_UNUSED4, ID_POPUP_ZONE_UNUSED4,
ID_POPUP_PCB_DELETE_MARKER, ID_POPUP_PCB_DELETE_MARKER,
......
...@@ -554,13 +554,15 @@ public: ...@@ -554,13 +554,15 @@ public:
bool IsNewCorner ); bool IsNewCorner );
/** /**
* Function End_Move_Zone_Corner * Function End_Move_Zone_Corner_Or_Outlines
* Terminates a move corner in a zone outline * Terminates a move corner in a zone outline, or a move zone outlines
* @param DC = current Device Context (can be NULL)
* @param zone_container: the given zone
*/ */
void End_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container ); void End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container );
/** /**
* Function End_Move_Zone_Corner * Function End_Move_Zone_Corner_Or_Outlines
* Remove the currently selected corner in a zone outline * Remove the currently selected corner in a zone outline
* the .m_CornerSelection is used as corner selection * the .m_CornerSelection is used as corner selection
*/ */
...@@ -577,6 +579,14 @@ public: ...@@ -577,6 +579,14 @@ public:
*/ */
void Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_container ); void Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_container );
/**
* Function Start_Move_Zone_Outlines
* Initialise parametres to move an existing zone outlines.
* @param DC = current Device Context (can be NULL)
* @param zone_container: the given zone to move
*/
void Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container );
// Target handling // Target handling
MIREPCB* Create_Mire( wxDC* DC ); MIREPCB* Create_Mire( wxDC* DC );
void Delete_Mire( MIREPCB* MirePcb, wxDC* DC ); void Delete_Mire( MIREPCB* MirePcb, wxDC* DC );
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
// Purpose: // Purpose:
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Modified by: // Modified by:
// Created: 13/01/2008 17:26:27 // Created: 13/01/2008 17:26:dialog_gendrill
// RCS-ID: // RCS-ID:
// Copyright: License GNU // Copyright: License GNU
// Licence: // Licence:
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 13/01/2008 17:26:27 // Generated by DialogBlocks (unregistered), 13/01/2008 17:26:dialog_gendrill
#ifndef _DIALOG_GENDRILL_H_ #ifndef _DIALOG_GENDRILL_H_
#define _DIALOG_GENDRILL_H_ #define _DIALOG_GENDRILL_H_
...@@ -149,14 +149,15 @@ private: ...@@ -149,14 +149,15 @@ private:
void InitDisplayParams(void); void InitDisplayParams(void);
void SetParams(void); void SetParams(void);
void GenDrillFiles( wxCommandEvent& event ); void GenDrillFiles( wxCommandEvent& event );
void GenDrillMap( int format ); void GenDrillMap( std::vector<DRILL_TOOL> & buffer, int format );
void UpdatePrecisionOptions( wxCommandEvent& event ); void UpdatePrecisionOptions( wxCommandEvent& event );
void UpdateConfig(); void UpdateConfig();
int Plot_Drill_PcbMap( DRILL_TOOL* buffer, int format ); int Plot_Drill_PcbMap( std::vector<DRILL_TOOL> & buffer, int format );
void GenDrillReport(); void GenDrillReport( std::vector<DRILL_TOOL> & buffer );
int Gen_Liste_Forets( DRILL_TOOL* buffer, bool print_header ); int Gen_Liste_Forets( std::vector<DRILL_TOOL> & buffer, bool print_header );
int Create_Drill_File_EXCELLON( DRILL_TOOL* buffer ); int Create_Drill_File_EXCELLON( std::vector<DRILL_TOOL> & buffer );
void Init_Drill(); void Init_Drill();
int Gen_Liste_Tools( std::vector<DRILL_TOOL> & buffer, bool print_header );
}; };
#endif #endif
......
...@@ -364,18 +364,17 @@ wxString mask = wxT("*"); ...@@ -364,18 +364,17 @@ wxString mask = wxT("*");
mask += LibExtBuffer; mask += LibExtBuffer;
g_RealLibDirBuffer.Replace( wxT("\\"), wxT("/")); g_RealLibDirBuffer.Replace( wxT("\\"), wxT("/"));
fullfilename = EDA_FileSelector( _("library files:"), wxFileDialog FilesDialog(this, _("Library Files:"), g_RealLibDirBuffer,
g_RealLibDirBuffer, /* Chemin par defaut */ wxEmptyString, mask,
wxEmptyString, /* nom fichier par defaut */ wxFD_DEFAULT_STYLE | wxFD_MULTIPLE);
LibExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
0,
TRUE
);
if ( fullfilename.IsEmpty() ) return;
FilesDialog.ShowModal();
wxArrayString Filenames;
FilesDialog.GetFilenames(Filenames);
for ( unsigned jj = 0; jj < Filenames.GetCount(); jj ++ )
{
fullfilename = Filenames[jj];
ShortLibName = ShortLibName =
MakeReducedFileName(fullfilename, g_RealLibDirBuffer, LibExtBuffer); MakeReducedFileName(fullfilename, g_RealLibDirBuffer, LibExtBuffer);
...@@ -387,6 +386,12 @@ wxString mask = wxT("*"); ...@@ -387,6 +386,12 @@ wxString mask = wxT("*");
m_ListLibr->Clear(); m_ListLibr->Clear();
m_ListLibr->InsertItems(g_LibName_List, 0); m_ListLibr->InsertItems(g_LibName_List, 0);
} }
else DisplayError(this, _("Library exists! No Change")); else
{
wxString msg;
msg << wxT("<") << ShortLibName << wxT("> : ") << _("Library already in use");
DisplayError(this, msg);
}
}
} }
...@@ -69,8 +69,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -69,8 +69,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_DELETE_EDGE_ZONE: case ID_POPUP_PCB_DELETE_EDGE_ZONE:
case ID_POPUP_PCB_FILL_ALL_ZONES: case ID_POPUP_PCB_FILL_ALL_ZONES:
case ID_POPUP_PCB_PLACE_ZONE_CORNER: case ID_POPUP_PCB_PLACE_ZONE_CORNER:
case ID_POPUP_PCB_PLACE_ZONE_OUTLINES:
case ID_POPUP_PCB_EDIT_ZONE_PARAMS: case ID_POPUP_PCB_EDIT_ZONE_PARAMS:
case ID_POPUP_PCB_DELETE_ZONE: case ID_POPUP_PCB_DELETE_ZONE:
case ID_POPUP_PCB_MOVE_ZONE_CORNER:
case ID_POPUP_PCB_MOVE_ZONE_OUTLINES:
case ID_POPUP_PCB_ADD_ZONE_CORNER:
case ID_POPUP_PCB_DELETE_TRACKSEG: case ID_POPUP_PCB_DELETE_TRACKSEG:
case ID_POPUP_PCB_DELETE_TRACK: case ID_POPUP_PCB_DELETE_TRACK:
case ID_POPUP_PCB_DELETE_TRACKNET: case ID_POPUP_PCB_DELETE_TRACKNET:
...@@ -488,6 +492,14 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -488,6 +492,14 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
} }
case ID_POPUP_PCB_MOVE_ZONE_OUTLINES:
{
DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER * zone_cont = (ZONE_CONTAINER*)GetCurItem();
Start_Move_Zone_Outlines(&dc, zone_cont);
break;
}
case ID_POPUP_PCB_ADD_ZONE_CORNER: case ID_POPUP_PCB_ADD_ZONE_CORNER:
{ {
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
...@@ -505,11 +517,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -505,11 +517,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
} }
case ID_POPUP_PCB_PLACE_ZONE_OUTLINES:
case ID_POPUP_PCB_PLACE_ZONE_CORNER: case ID_POPUP_PCB_PLACE_ZONE_CORNER:
{ {
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER * zone_cont = (ZONE_CONTAINER*)GetCurItem(); ZONE_CONTAINER * zone_cont = (ZONE_CONTAINER*)GetCurItem();
End_Move_Zone_Corner(&dc, zone_cont); End_Move_Zone_Corner_Or_Outlines(&dc, zone_cont);
break; break;
} }
......
This diff is collapsed.
...@@ -39,7 +39,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -39,7 +39,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
switch( DrawStruct->Type() ) switch( DrawStruct->Type() )
{ {
case TYPEZONE_CONTAINER: case TYPEZONE_CONTAINER:
End_Move_Zone_Corner( DC, (ZONE_CONTAINER *) DrawStruct ); End_Move_Zone_Corner_Or_Outlines( DC, (ZONE_CONTAINER *) DrawStruct );
exit = true; exit = true;
break; break;
......
...@@ -644,8 +644,12 @@ void WinEDA_PcbFrame::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu ...@@ -644,8 +644,12 @@ void WinEDA_PcbFrame::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu
{ {
if( edge_zone->m_Flags ) if( edge_zone->m_Flags )
{ {
if( (edge_zone->m_Flags & IN_EDIT ) )
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_PLACE_ZONE_CORNER, ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_PLACE_ZONE_CORNER,
_( "Place Corner" ), apply_xpm ); _( "Place Corner" ), apply_xpm );
else
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_PLACE_ZONE_OUTLINES,
_( "Place Zone" ), apply_xpm );
} }
else else
{ {
...@@ -677,9 +681,13 @@ void WinEDA_PcbFrame::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu ...@@ -677,9 +681,13 @@ void WinEDA_PcbFrame::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_FILL_ZONE, ADD_MENUITEM( zones_menu, ID_POPUP_PCB_FILL_ZONE,
_( "Fill Zone" ), fill_zone_xpm ); _( "Fill Zone" ), fill_zone_xpm );
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_MOVE_ZONE_OUTLINES,
_( "Move Zone" ), move_xpm );
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_EDIT_ZONE_PARAMS, ADD_MENUITEM( zones_menu, ID_POPUP_PCB_EDIT_ZONE_PARAMS,
_( "Edit Zone Params" ), edit_xpm ); _( "Edit Zone Params" ), edit_xpm );
zones_menu->AppendSeparator();
if ( index >= 0 && edge_zone->m_Poly->IsCutoutContour( edge_zone->m_CornerSelection ) ) if ( index >= 0 && edge_zone->m_Poly->IsCutoutContour( edge_zone->m_CornerSelection ) )
ADD_MENUITEM( zones_menu, ID_POPUP_PCB_DELETE_ZONE_CUTOUT, ADD_MENUITEM( zones_menu, ID_POPUP_PCB_DELETE_ZONE_CUTOUT,
_( "Delete Cutout" ), delete_xpm ); _( "Delete Cutout" ), delete_xpm );
......
...@@ -32,15 +32,15 @@ using namespace std; ...@@ -32,15 +32,15 @@ using namespace std;
#include "protos.h" #include "protos.h"
/* Local functions */ bool verbose = false; // false if zone outline diags mst not be shown
// Outline creation: // Outline creation:
static void Abort_Zone_Create_Outline( WinEDA_DrawPanel* Panel, wxDC* DC ); static void Abort_Zone_Create_Outline( WinEDA_DrawPanel* Panel, wxDC* DC );
static void Show_New_Zone_Edge_While_Move_Mouse( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void Show_New_Zone_Edge_While_Move_Mouse( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
// Corner moving // Corner moving
static void Abort_Zone_Move_Corner( WinEDA_DrawPanel* Panel, wxDC* DC ); static void Abort_Zone_Move_Corner_Or_Outlines( WinEDA_DrawPanel* Panel, wxDC* DC );
static void Show_Zone_Corner_While_Move_Mouse( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void Show_Zone_Corner_Or_Outline_While_Move_Mouse( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/* Local variables */ /* Local variables */
static bool Zone_45_Only = FALSE; static bool Zone_45_Only = FALSE;
...@@ -104,9 +104,9 @@ void WinEDA_PcbFrame::Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container ...@@ -104,9 +104,9 @@ void WinEDA_PcbFrame::Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container
} }
/*****************************************************************************/ /**********************************************************************************/
void WinEDA_PcbFrame::Delete_Zone_Fill( wxDC* DC, SEGZONE* aZone, long aTimestamp ) void WinEDA_PcbFrame::Delete_Zone_Fill( wxDC* DC, SEGZONE* aZone, long aTimestamp )
/******************************************************************************/ /**********************************************************************************/
/** Function Delete_Zone_Fill /** Function Delete_Zone_Fill
* Remove the zone fillig which include the segment aZone, or the zone which have the given time stamp. * Remove the zone fillig which include the segment aZone, or the zone which have the given time stamp.
...@@ -254,21 +254,21 @@ void WinEDA_PcbFrame::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_con ...@@ -254,21 +254,21 @@ void WinEDA_PcbFrame::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_con
/** /**
* Function Start_Move_Zone_Corner * Function Start_Move_Zone_Corner
* Initialise parametres to move an existing corner of a zone. * Initialise parametres to move an existing corner of a zone.
* if IsNewCorner is true, the Abort_Zone_Move_Corner will remove this corner, if called * if IsNewCorner is true, the Abort_Zone_Move_Corner_Or_Outlines will remove this corner, if called
*/ */
{ {
/* Show the Net */ /* Show the Net */
if( g_HightLigt_Status ) if( g_HightLigt_Status && DC)
{ {
Hight_Light( DC ); // Remove old hightlight selection Hight_Light( DC ); // Remove old hightlight selection
} }
g_HightLigth_NetCode = s_NetcodeSelection = zone_container->GetNet(); g_HightLigth_NetCode = s_NetcodeSelection = zone_container->GetNet();
Hight_Light( DC ); if ( DC ) Hight_Light( DC );
zone_container->m_Flags = IN_EDIT; zone_container->m_Flags = IN_EDIT;
DrawPanel->ManageCurseur = Show_Zone_Corner_While_Move_Mouse; DrawPanel->ManageCurseur = Show_Zone_Corner_Or_Outline_While_Move_Mouse;
DrawPanel->ForceCloseManageCurseur = Abort_Zone_Move_Corner; DrawPanel->ForceCloseManageCurseur = Abort_Zone_Move_Corner_Or_Outlines;
s_CornerInitialPosition.x = zone_container->m_Poly->GetX( corner_id ); s_CornerInitialPosition.x = zone_container->m_Poly->GetX( corner_id );
s_CornerInitialPosition.y = zone_container->m_Poly->GetY( corner_id ); s_CornerInitialPosition.y = zone_container->m_Poly->GetY( corner_id );
s_CornerIsNew = IsNewCorner; s_CornerIsNew = IsNewCorner;
...@@ -276,19 +276,50 @@ void WinEDA_PcbFrame::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_con ...@@ -276,19 +276,50 @@ void WinEDA_PcbFrame::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_con
s_CurrentZone = NULL; s_CurrentZone = NULL;
} }
/*******************************************************************************************************/
void WinEDA_PcbFrame::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container )
/*******************************************************************************************************/
/***************************************************************************************/ /**
void WinEDA_PcbFrame::End_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container ) * Function Start_Move_Zone_Outlines
/****************************************************************************************/ * Initialise parametres to move an existing zone outlines.
*/
{
/* Show the Net */
if( g_HightLigt_Status )
{
Hight_Light( DC ); // Remove old hightlight selection
}
g_HightLigth_NetCode = s_NetcodeSelection = zone_container->GetNet();
Hight_Light( DC );
zone_container->m_Flags = IS_MOVED;
DrawPanel->ManageCurseur = Show_Zone_Corner_Or_Outline_While_Move_Mouse;
DrawPanel->ForceCloseManageCurseur = Abort_Zone_Move_Corner_Or_Outlines;
s_CornerInitialPosition.x = zone_container->m_Poly->GetX( 0 );
s_CornerInitialPosition.y = zone_container->m_Poly->GetY( 0 );
s_CornerIsNew = false;
s_AddCutoutToCurrentZone = false;
s_CurrentZone = NULL;
}
/*************************************************************************************************/
void WinEDA_PcbFrame::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container )
/*************************************************************************************************/
/** /**
* Function End_Move_Zone_Corner * Function End_Move_Zone_Corner_Or_Outlines
* Terminates a move corner in a zone outline * Terminates a move corner in a zone outline, or a move zone outlines
* @param DC = current Device Context (can be NULL)
* @param zone_container: the given zone
*/ */
{ {
zone_container->m_Flags = 0; zone_container->m_Flags = 0;
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
if ( DC )
zone_container->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); zone_container->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
GetScreen()->SetModify(); GetScreen()->SetModify();
s_AddCutoutToCurrentZone = false; s_AddCutoutToCurrentZone = false;
...@@ -304,15 +335,15 @@ void WinEDA_PcbFrame::End_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_conta ...@@ -304,15 +335,15 @@ void WinEDA_PcbFrame::End_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_conta
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{ {
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii); ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii);
if( layer == edge_zone->GetLayer() ) if( layer == edge_zone->GetLayer() && DC)
edge_zone->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); edge_zone->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
} }
m_Pcb->AreaPolygonModified( zone_container, true, false ); m_Pcb->AreaPolygonModified( zone_container, true, verbose );
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{ {
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii); ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii);
if( layer == edge_zone->GetLayer() ) if( layer == edge_zone->GetLayer() && DC)
edge_zone->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR ); edge_zone->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
} }
...@@ -359,7 +390,7 @@ void WinEDA_PcbFrame::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER * zone_contai ...@@ -359,7 +390,7 @@ void WinEDA_PcbFrame::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER * zone_contai
zone_container->m_Poly->DeleteCorner(zone_container->m_CornerSelection); zone_container->m_Poly->DeleteCorner(zone_container->m_CornerSelection);
// modify zones outlines accordiing to the new zone_container shape // modify zones outlines accordiing to the new zone_container shape
m_Pcb->AreaPolygonModified( zone_container, true, false ); m_Pcb->AreaPolygonModified( zone_container, true, verbose );
if ( DC ) if ( DC )
{ {
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
...@@ -380,12 +411,12 @@ void WinEDA_PcbFrame::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER * zone_contai ...@@ -380,12 +411,12 @@ void WinEDA_PcbFrame::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER * zone_contai
} }
/**************************************************************/ /**************************************************************************/
void Abort_Zone_Move_Corner( WinEDA_DrawPanel* Panel, wxDC* DC ) void Abort_Zone_Move_Corner_Or_Outlines( WinEDA_DrawPanel* Panel, wxDC* DC )
/**************************************************************/ /**************************************************************************/
/** /**
* Function Abort_Zone_Move_Corner * Function Abort_Zone_Move_Corner_Or_Outlines
* cancels the Begin_Zone state if at least one EDGE_ZONE has been created. * cancels the Begin_Zone state if at least one EDGE_ZONE has been created.
*/ */
{ {
...@@ -394,6 +425,15 @@ void Abort_Zone_Move_Corner( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -394,6 +425,15 @@ void Abort_Zone_Move_Corner( WinEDA_DrawPanel* Panel, wxDC* DC )
zone_container->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR ); zone_container->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
if ( zone_container->m_Flags == IS_MOVED )
{
wxPoint offset;
offset.x = s_CornerInitialPosition.x - zone_container->m_Poly->GetX( 0 );
offset.y = s_CornerInitialPosition.y - zone_container->m_Poly->GetY( 0 );
zone_container->Move(offset);
}
else
{
if( s_CornerIsNew ) if( s_CornerIsNew )
{ {
zone_container->m_Poly->DeleteCorner( zone_container->m_CornerSelection ); zone_container->m_Poly->DeleteCorner( zone_container->m_CornerSelection );
...@@ -403,6 +443,7 @@ void Abort_Zone_Move_Corner( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -403,6 +443,7 @@ void Abort_Zone_Move_Corner( WinEDA_DrawPanel* Panel, wxDC* DC )
wxPoint pos = s_CornerInitialPosition; wxPoint pos = s_CornerInitialPosition;
zone_container->m_Poly->MoveCorner( zone_container->m_CornerSelection, pos.x, pos.y ); zone_container->m_Poly->MoveCorner( zone_container->m_CornerSelection, pos.x, pos.y );
} }
}
zone_container->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR ); zone_container->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
...@@ -414,9 +455,9 @@ void Abort_Zone_Move_Corner( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -414,9 +455,9 @@ void Abort_Zone_Move_Corner( WinEDA_DrawPanel* Panel, wxDC* DC )
} }
/**************************************************************************************/ /*************************************************************************************************/
void Show_Zone_Corner_While_Move_Mouse( WinEDA_DrawPanel* Panel, wxDC* DC, bool erase ) void Show_Zone_Corner_Or_Outline_While_Move_Mouse( WinEDA_DrawPanel* Panel, wxDC* DC, bool erase )
/**************************************************************************************/ /*************************************************************************************************/
/* Redraws the zone outline when moving a corner according to the cursor position /* Redraws the zone outline when moving a corner according to the cursor position
*/ */
...@@ -430,7 +471,16 @@ void Show_Zone_Corner_While_Move_Mouse( WinEDA_DrawPanel* Panel, wxDC* DC, bool ...@@ -430,7 +471,16 @@ void Show_Zone_Corner_While_Move_Mouse( WinEDA_DrawPanel* Panel, wxDC* DC, bool
} }
wxPoint pos = pcbframe->GetScreen()->m_Curseur; wxPoint pos = pcbframe->GetScreen()->m_Curseur;
if( zone_container->m_Flags == IS_MOVED )
{
wxPoint offset;
offset.x = pos.x - zone_container->m_Poly->GetX( 0 );
offset.y = pos.y - zone_container->m_Poly->GetY( 0 );
zone_container->Move(offset);
}
else
zone_container->m_Poly->MoveCorner( zone_container->m_CornerSelection, pos.x, pos.y ); zone_container->m_Poly->MoveCorner( zone_container->m_CornerSelection, pos.x, pos.y );
zone_container->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR ); zone_container->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
} }
...@@ -649,7 +699,7 @@ void WinEDA_PcbFrame::End_Zone( wxDC* DC ) ...@@ -649,7 +699,7 @@ void WinEDA_PcbFrame::End_Zone( wxDC* DC )
SetCurItem( NULL ); // This outine can be deleted when merging outlines SetCurItem( NULL ); // This outine can be deleted when merging outlines
// Combine zones if possible : // Combine zones if possible :
m_Pcb->AreaPolygonModified( new_zone_container, true, false ); m_Pcb->AreaPolygonModified( new_zone_container, true, verbose );
// Redraw the real edge zone : // Redraw the real edge zone :
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
...@@ -760,7 +810,7 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container ...@@ -760,7 +810,7 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container
zone_container->m_GridFillValue = g_GridRoutingSize; zone_container->m_GridFillValue = g_GridRoutingSize;
// Combine zones if possible : // Combine zones if possible :
m_Pcb->AreaPolygonModified( zone_container, true, false ); m_Pcb->AreaPolygonModified( zone_container, true, verbose );
// Redraw the real new zone outlines: // Redraw the real new zone outlines:
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
......
...@@ -183,10 +183,10 @@ int BOARD::TestAreaPolygon( ZONE_CONTAINER* CurrArea ) ...@@ -183,10 +183,10 @@ int BOARD::TestAreaPolygon( ZONE_CONTAINER* CurrArea )
if( ret ) if( ret )
{ {
// intersection between non-adjacent sides // intersection between non-adjacent sides
bInt = TRUE; bInt = true;
if( style != CPolyLine::STRAIGHT || style2 != CPolyLine::STRAIGHT ) if( style != CPolyLine::STRAIGHT || style2 != CPolyLine::STRAIGHT )
{ {
bArcInt = TRUE; bArcInt = true;
break; break;
} }
} }
...@@ -219,8 +219,8 @@ int BOARD::TestAreaPolygon( ZONE_CONTAINER* CurrArea ) ...@@ -219,8 +219,8 @@ int BOARD::TestAreaPolygon( ZONE_CONTAINER* CurrArea )
* Function ClipAreaPolygon * Function ClipAreaPolygon
* Process an area that has been modified, by clipping its polygon against itself. * Process an area that has been modified, by clipping its polygon against itself.
* This may change the number and order of copper areas in the net. * This may change the number and order of copper areas in the net.
* @param bMessageBoxInt == TRUE, shows message when clipping occurs. * @param bMessageBoxInt == true, shows message when clipping occurs.
* @param bMessageBoxArc == TRUE, shows message when clipping can't be done due to arcs. * @param bMessageBoxArc == true, shows message when clipping can't be done due to arcs.
* @return: * @return:
* -1 if arcs intersect other sides, so polygon can't be clipped * -1 if arcs intersect other sides, so polygon can't be clipped
* 0 if no intersecting sides * 0 if no intersecting sides
...@@ -230,7 +230,7 @@ int BOARD::TestAreaPolygon( ZONE_CONTAINER* CurrArea ) ...@@ -230,7 +230,7 @@ int BOARD::TestAreaPolygon( ZONE_CONTAINER* CurrArea )
int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea, int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea,
bool bMessageBoxArc, bool bMessageBoxInt, bool bRetainArcs ) bool bMessageBoxArc, bool bMessageBoxInt, bool bRetainArcs )
{ {
CPolyLine* p = CurrArea->m_Poly; CPolyLine* curr_polygon = CurrArea->m_Poly;
int test = TestAreaPolygon( CurrArea ); // this sets utility2 flag int test = TestAreaPolygon( CurrArea ); // this sets utility2 flag
if( test == -1 && !bRetainArcs ) if( test == -1 && !bRetainArcs )
...@@ -241,7 +241,7 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea, ...@@ -241,7 +241,7 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea,
if( bMessageBoxArc && bDontShowSelfIntersectionArcsWarning == false ) if( bMessageBoxArc && bDontShowSelfIntersectionArcsWarning == false )
{ {
wxString str; wxString str;
str.Printf( wxT( "Area %X of net \"%s\" has arcs intersecting other sides.\n" ), str.Printf( wxT( "Area %8.8X of net \"%s\" has arcs intersecting other sides.\n" ),
CurrArea->m_TimeStamp, CurrArea->m_Netname.GetData() ); CurrArea->m_TimeStamp, CurrArea->m_Netname.GetData() );
str += wxT( "This may cause problems with other editing operations,\n" ); str += wxT( "This may cause problems with other editing operations,\n" );
str += wxT( "such as adding cutouts. It can't be fixed automatically.\n" ); str += wxT( "such as adding cutouts. It can't be fixed automatically.\n" );
...@@ -265,7 +265,7 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea, ...@@ -265,7 +265,7 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea,
if( bMessageBoxInt && bDontShowSelfIntersectionWarning == false ) if( bMessageBoxInt && bDontShowSelfIntersectionWarning == false )
{ {
wxString str; wxString str;
str.Printf( wxT( "Area %d of net \"%s\" is self-intersecting and will be clipped.\n" ), str.Printf( wxT( "Area %8.8X of net \"%s\" is self-intersecting and will be clipped.\n" ),
CurrArea->m_TimeStamp, CurrArea->m_Netname.GetData() ); CurrArea->m_TimeStamp, CurrArea->m_Netname.GetData() );
str += wxT( "This may result in splitting the area.\n" ); str += wxT( "This may result in splitting the area.\n" );
str += wxT( "If the area is complex, this may take a few seconds." ); str += wxT( "If the area is complex, this may take a few seconds." );
...@@ -279,25 +279,26 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea, ...@@ -279,25 +279,26 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea,
//** if( test == 1 ) //** if( test == 1 )
{ {
std::vector<CPolyLine*> * pa = new std::vector<CPolyLine*>; std::vector<CPolyLine*> * pa = new std::vector<CPolyLine*>;
p->Undraw(); curr_polygon->Undraw();
int n_poly = CurrArea->m_Poly->NormalizeWithGpc( pa, bRetainArcs ); int n_poly = CurrArea->m_Poly->NormalizeWithGpc( pa, bRetainArcs );
if( n_poly > 1 ) // i.e if clippinf has created some polygons, we must add these new copper areas if( n_poly > 1 ) // i.e if clipping has created some polygons, we must add these new copper areas
{ {
ZONE_CONTAINER* NewArea;
for( int ip = 1; ip < n_poly; ip++ ) for( int ip = 1; ip < n_poly; ip++ )
{ {
// create new copper area and copy poly into it // create new copper area and copy poly into it
CPolyLine* new_p = (*pa)[ip - 1]; CPolyLine* new_p = (*pa)[ip - 1];
CurrArea = AddArea( CurrArea->GetNet(), CurrArea->GetLayer(), 0, 0, 0 ); NewArea = AddArea( CurrArea->GetNet(), CurrArea->GetLayer(), 0, 0, 0 );
// remove the poly that was automatically created for the new area // remove the poly that was automatically created for the new area
// and replace it with a poly from NormalizeWithGpc // and replace it with a poly from NormalizeWithGpc
delete CurrArea->m_Poly; delete NewArea->m_Poly;
CurrArea->m_Poly = new_p; NewArea->m_Poly = new_p;
CurrArea->m_Poly->Draw(); NewArea->m_Poly->Draw();
CurrArea->utility = 1; NewArea->utility = 1;
} }
} }
p->Draw(); curr_polygon->Draw();
delete pa; delete pa;
} }
return test; return test;
...@@ -309,7 +310,7 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea, ...@@ -309,7 +310,7 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea,
* itself and the polygons for any other areas on the same net. * itself and the polygons for any other areas on the same net.
* This may change the number and order of copper areas in the net. * This may change the number and order of copper areas in the net.
* @param modified_area = area to test * @param modified_area = area to test
* @param bMessageBox : if TRUE, shows message boxes when clipping occurs. * @param bMessageBox : if true, shows message boxes when clipping occurs.
* @return : * @return :
* -1 if arcs intersect other sides, so polygon can't be clipped * -1 if arcs intersect other sides, so polygon can't be clipped
* 0 if no intersecting sides * 0 if no intersecting sides
...@@ -328,11 +329,11 @@ int BOARD::AreaPolygonModified( ZONE_CONTAINER* modified_area, ...@@ -328,11 +329,11 @@ int BOARD::AreaPolygonModified( ZONE_CONTAINER* modified_area,
// now see if we need to clip against other areas // now see if we need to clip against other areas
bool bCheckAllAreas = false; bool bCheckAllAreas = false;
if( test == 1 ) if( test == 1 )
bCheckAllAreas = TRUE; bCheckAllAreas = true;
else else
bCheckAllAreas = TestAreaIntersections( modified_area ); bCheckAllAreas = TestAreaIntersections( modified_area );
if( bCheckAllAreas ) if( bCheckAllAreas )
CombineAllAreasInNet( modified_area->GetNet(), bMessageBoxInt, TRUE ); CombineAllAreasInNet( modified_area->GetNet(), bMessageBoxInt, true );
return test; return test;
} }
...@@ -400,7 +401,7 @@ int BOARD::CombineAllAreasInNet( int aNetCode, bool bMessageBox, bool bUseUtilit ...@@ -400,7 +401,7 @@ int BOARD::CombineAllAreasInNet( int aNetCode, bool bMessageBox, bool bUseUtilit
// bDontShowIntersectionWarning = dlg.bDontShowBoxState; // bDontShowIntersectionWarning = dlg.bDontShowBoxState;
} }
mod_ia1 = TRUE; mod_ia1 = true;
} }
else if( ret == 2 ) else if( ret == 2 )
{ {
...@@ -508,12 +509,33 @@ bool BOARD::TestAreaIntersections( ZONE_CONTAINER* area_to_test ) ...@@ -508,12 +509,33 @@ bool BOARD::TestAreaIntersections( ZONE_CONTAINER* area_to_test )
int n_int = FindSegmentIntersections( xi1, yi1, xf1, yf1, style1, int n_int = FindSegmentIntersections( xi1, yi1, xf1, yf1, style1,
xi2, yi2, xf2, yf2, style2 ); xi2, yi2, xf2, yf2, style2 );
if( n_int ) if( n_int )
return TRUE; return true;
} }
} }
} }
} }
// If a contour is inside an other contour, no segments intersects, but the zones can be combined
// test a corner inside an outline (only one corner is enought)
/* for( int ic2 = 0; ic2 < poly2->GetNumCorners(); ic2++ )
{
int x = poly2->GetX( ic2 );
int y = poly2->GetY( ic2 );
if( poly1->TestPointInside( x, y ) )
{
return true;
}
} }
for( int ic1 = 0; ic1 < poly1->GetNumCorners(); ic1++ )
{
int x = poly1->GetX( ic1 );
int y = poly1->GetY( ic1 );
if( poly2->TestPointInside( x, y ) )
{
return true;
}
}
*/ }
return false; return false;
} }
...@@ -594,9 +616,9 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_ ...@@ -594,9 +616,9 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_
xi2, yi2, xf2, yf2, style2 ); xi2, yi2, xf2, yf2, style2 );
if( n_int ) if( n_int )
{ {
bInt = TRUE; bInt = true;
if( style1 != CPolyLine::STRAIGHT || style2 != CPolyLine::STRAIGHT ) if( style1 != CPolyLine::STRAIGHT || style2 != CPolyLine::STRAIGHT )
bArcInt = TRUE; bArcInt = true;
break; break;
} }
} }
...@@ -614,7 +636,32 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_ ...@@ -614,7 +636,32 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_
} }
if( !bInt ) if( !bInt )
return 0; {
/* if( bArcInt ) return 0;
// If a contour is inside an other contour, no segments intersects, but the zones can be combined
// test a corner inside an outline (only one corner is enought)
for( int ic2 = 0; ic2 < poly2->GetNumCorners(); ic2++ )
{
int x = poly2->GetX( ic2 );
int y = poly2->GetY( ic2 );
if( poly1->TestPointInside( x, y ) )
{
return 1;
}
}
for( int ic1 = 0; ic1 < poly1->GetNumCorners(); ic1++ )
{
int x = poly1->GetX( ic1 );
int y = poly1->GetY( ic1 );
if( poly2->TestPointInside( x, y ) )
{
return 1;
}
}
*/ return 0;
}
if( bArcInt ) if( bArcInt )
return 2; return 2;
return 1; return 1;
......
...@@ -10,6 +10,9 @@ using namespace std; ...@@ -10,6 +10,9 @@ using namespace std;
#include <math.h> #include <math.h>
#include <vector> #include <vector>
#include "fctsys.h"
#include "PolyLine.h" #include "PolyLine.h"
#define to_int(x) (int)round((x)) #define to_int(x) (int)round((x))
...@@ -83,8 +86,7 @@ int CPolyLine::NormalizeWithGpc( std::vector<CPolyLine*> * pa, bool bRetainArcs ...@@ -83,8 +86,7 @@ int CPolyLine::NormalizeWithGpc( std::vector<CPolyLine*> * pa, bool bRetainArcs
{ {
// next external contour, create new poly // next external contour, create new poly
CPolyLine * poly = new CPolyLine; CPolyLine * poly = new CPolyLine;
pa->SetSize(n_ext_cont); // put in array pa->push_back(poly); // put in array
(*pa)[n_ext_cont-1] = poly;
for( int i=0; i<m_gpc_poly->contour[ic].num_vertices; i++ ) for( int i=0; i<m_gpc_poly->contour[ic].num_vertices; i++ )
{ {
int x = to_int(((m_gpc_poly->contour)[ic].vertex)[i].x); int x = to_int(((m_gpc_poly->contour)[ic].vertex)[i].x);
...@@ -136,7 +138,7 @@ int CPolyLine::NormalizeWithGpc( std::vector<CPolyLine*> * pa, bool bRetainArcs ...@@ -136,7 +138,7 @@ int CPolyLine::NormalizeWithGpc( std::vector<CPolyLine*> * pa, bool bRetainArcs
} }
} }
if( !ext_poly ) if( !ext_poly )
ASSERT(0); wxASSERT(0);
for( int i=0; i<m_gpc_poly->contour[ic].num_vertices; i++ ) for( int i=0; i<m_gpc_poly->contour[ic].num_vertices; i++ )
{ {
int x = to_int(((m_gpc_poly->contour)[ic].vertex)[i].x); int x = to_int(((m_gpc_poly->contour)[ic].vertex)[i].x);
...@@ -422,7 +424,7 @@ int CPolyLine::MakeGpcPoly( int icontour, std::vector<CArc> * arc_array ) ...@@ -422,7 +424,7 @@ int CPolyLine::MakeGpcPoly( int icontour, std::vector<CArc> * arc_array )
} }
} }
if( n_vertices != ivtx ) if( n_vertices != ivtx )
ASSERT(0); wxASSERT(0);
// add vertex_list to gpc // add vertex_list to gpc
gpc_add_contour( gpc, g_v_list, 0 ); gpc_add_contour( gpc, g_v_list, 0 );
// now clip m_gpc_poly with gpc, put new poly into result // now clip m_gpc_poly with gpc, put new poly into result
...@@ -641,7 +643,7 @@ void CPolyLine::AppendCorner( int x, int y, int style, bool bDraw ) ...@@ -641,7 +643,7 @@ void CPolyLine::AppendCorner( int x, int y, int style, bool bDraw )
else if( style == CPolyLine::ARC_CCW ) else if( style == CPolyLine::ARC_CCW )
dl_type = DL_ARC_CCW; dl_type = DL_ARC_CCW;
else else
ASSERT(0); wxASSERT(0);
if( bDraw ) if( bDraw )
Draw(); Draw();
} }
...@@ -651,7 +653,7 @@ void CPolyLine::AppendCorner( int x, int y, int style, bool bDraw ) ...@@ -651,7 +653,7 @@ void CPolyLine::AppendCorner( int x, int y, int style, bool bDraw )
void CPolyLine::Close( int style, bool bDraw ) void CPolyLine::Close( int style, bool bDraw )
{ {
if( GetClosed() ) if( GetClosed() )
ASSERT(0); wxASSERT(0);
Undraw(); Undraw();
side_style[corner.size()-1] = style; side_style[corner.size()-1] = style;
corner[corner.size()-1].end_contour = TRUE; corner[corner.size()-1].end_contour = TRUE;
...@@ -720,7 +722,7 @@ void CPolyLine::RemoveContour( int icont ) ...@@ -720,7 +722,7 @@ void CPolyLine::RemoveContour( int icont )
if( icont == 0 && GetNumContours() == 1 ) if( icont == 0 && GetNumContours() == 1 )
{ {
// remove the only contour // remove the only contour
ASSERT(0); wxASSERT(0);
} }
else if( icont == GetNumContours()-1 ) else if( icont == GetNumContours()-1 )
{ {
...@@ -919,7 +921,7 @@ int CPolyLine::GetContourStart( int icont ) ...@@ -919,7 +921,7 @@ int CPolyLine::GetContourStart( int icont )
return i+1; return i+1;
} }
} }
ASSERT(0); wxASSERT(0);
return 0; return 0;
} }
...@@ -941,7 +943,7 @@ int CPolyLine::GetContourEnd( int icont ) ...@@ -941,7 +943,7 @@ int CPolyLine::GetContourEnd( int icont )
ncont++; ncont++;
} }
} }
ASSERT(0); wxASSERT(0);
return 0; return 0;
} }
...@@ -1062,7 +1064,7 @@ void CPolyLine::Hatch() ...@@ -1062,7 +1064,7 @@ void CPolyLine::Hatch()
else if( layer < (LAY_TOP_COPPER+16) ) else if( layer < (LAY_TOP_COPPER+16) )
offset = 7*spacing/8; offset = 7*spacing/8;
else else
ASSERT(0); wxASSERT(0);
min_a += offset; min_a += offset;
// now calculate and draw hatch lines // now calculate and draw hatch lines
...@@ -1104,20 +1106,20 @@ void CPolyLine::Hatch() ...@@ -1104,20 +1106,20 @@ void CPolyLine::Hatch()
xx[npts] = (int)x; xx[npts] = (int)x;
yy[npts] = (int)y; yy[npts] = (int)y;
npts++; npts++;
ASSERT( npts<MAXPTS ); // overflow wxASSERT( npts<MAXPTS ); // overflow
} }
if( ok == 2 ) if( ok == 2 )
{ {
xx[npts] = (int)x2; xx[npts] = (int)x2;
yy[npts] = (int)y2; yy[npts] = (int)y2;
npts++; npts++;
ASSERT( npts<MAXPTS ); // overflow wxASSERT( npts<MAXPTS ); // overflow
} }
} }
nloops++; nloops++;
a += PCBU_PER_MIL/100; a += PCBU_PER_MIL/100;
} while( npts%2 != 0 && nloops < 3 ); } while( npts%2 != 0 && nloops < 3 );
ASSERT( npts%2==0 ); // odd number of intersection points, error wxASSERT( npts%2==0 ); // odd number of intersection points, error
// sort points in order of descending x (if more than 2) // sort points in order of descending x (if more than 2)
if( npts>2 ) if( npts>2 )
...@@ -1177,7 +1179,7 @@ bool CPolyLine::TestPointInside( int x, int y ) ...@@ -1177,7 +1179,7 @@ bool CPolyLine::TestPointInside( int x, int y )
{ {
enum { MAXPTS = 100 }; enum { MAXPTS = 100 };
if( !GetClosed() ) if( !GetClosed() )
ASSERT(0); wxASSERT(0);
// define line passing through (x,y), with slope = 2/3; // define line passing through (x,y), with slope = 2/3;
// get intersection points // get intersection points
...@@ -1216,21 +1218,21 @@ bool CPolyLine::TestPointInside( int x, int y ) ...@@ -1216,21 +1218,21 @@ bool CPolyLine::TestPointInside( int x, int y )
xx[npts] = (int)x; xx[npts] = (int)x;
yy[npts] = (int)y; yy[npts] = (int)y;
npts++; npts++;
ASSERT( npts<MAXPTS ); // overflow wxASSERT( npts<MAXPTS ); // overflow
} }
if( ok == 2 ) if( ok == 2 )
{ {
xx[npts] = (int)x2; xx[npts] = (int)x2;
yy[npts] = (int)y2; yy[npts] = (int)y2;
npts++; npts++;
ASSERT( npts<MAXPTS ); // overflow wxASSERT( npts<MAXPTS ); // overflow
} }
} }
} }
nloops++; nloops++;
a += PCBU_PER_MIL/100; a += PCBU_PER_MIL/100;
} while( npts%2 != 0 && nloops < 3 ); } while( npts%2 != 0 && nloops < 3 );
ASSERT( npts%2==0 ); // odd number of intersection points, error wxASSERT( npts%2==0 ); // odd number of intersection points, error
// count intersection points to right of (x,y), if odd (x,y) is inside polyline // count intersection points to right of (x,y), if odd (x,y) is inside polyline
int ncount = 0; int ncount = 0;
...@@ -1256,7 +1258,7 @@ bool CPolyLine::TestPointInsideContour( int icont, int x, int y ) ...@@ -1256,7 +1258,7 @@ bool CPolyLine::TestPointInsideContour( int icont, int x, int y )
enum { MAXPTS = 100 }; enum { MAXPTS = 100 };
if( !GetClosed() ) if( !GetClosed() )
ASSERT(0); wxASSERT(0);
// define line passing through (x,y), with slope = 2/3; // define line passing through (x,y), with slope = 2/3;
// get intersection points // get intersection points
...@@ -1293,20 +1295,20 @@ bool CPolyLine::TestPointInsideContour( int icont, int x, int y ) ...@@ -1293,20 +1295,20 @@ bool CPolyLine::TestPointInsideContour( int icont, int x, int y )
xx[npts] = (int)x; xx[npts] = (int)x;
yy[npts] = (int)y; yy[npts] = (int)y;
npts++; npts++;
ASSERT( npts<MAXPTS ); // overflow wxASSERT( npts<MAXPTS ); // overflow
} }
if( ok == 2 ) if( ok == 2 )
{ {
xx[npts] = (int)x2; xx[npts] = (int)x2;
yy[npts] = (int)y2; yy[npts] = (int)y2;
npts++; npts++;
ASSERT( npts<MAXPTS ); // overflow wxASSERT( npts<MAXPTS ); // overflow
} }
} }
nloops++; nloops++;
a += PCBU_PER_MIL/100; a += PCBU_PER_MIL/100;
} while( npts%2 != 0 && nloops < 3 ); } while( npts%2 != 0 && nloops < 3 );
ASSERT( npts%2==0 ); // odd number of intersection points, error wxASSERT( npts%2==0 ); // odd number of intersection points, error
// count intersection points to right of (x,y), if odd (x,y) is inside polyline // count intersection points to right of (x,y), if odd (x,y) is inside polyline
int ncount = 0; int ncount = 0;
...@@ -1328,9 +1330,9 @@ bool CPolyLine::TestPointInsideContour( int icont, int x, int y ) ...@@ -1328,9 +1330,9 @@ bool CPolyLine::TestPointInsideContour( int icont, int x, int y )
int CPolyLine::TestIntersection( CPolyLine * poly ) int CPolyLine::TestIntersection( CPolyLine * poly )
{ {
if( !GetClosed() ) if( !GetClosed() )
ASSERT(0); wxASSERT(0);
if( !poly->GetClosed() ) if( !poly->GetClosed() )
ASSERT(0); wxASSERT(0);
for( int ic=0; ic<GetNumContours(); ic++ ) for( int ic=0; ic<GetNumContours(); ic++ )
{ {
int istart = GetContourStart(ic); int istart = GetContourStart(ic);
......
...@@ -36,6 +36,4 @@ ...@@ -36,6 +36,4 @@
#define TRACE printf #define TRACE printf
#define ASSERT(x) // todo : change to wxASSERT, under wxWidgets
#endif // ifndef DEFS_MACROS_H #endif // ifndef DEFS_MACROS_H
...@@ -50,6 +50,9 @@ ...@@ -50,6 +50,9 @@
#include <math.h> #include <math.h>
#include "fctsys.h"
#include "php_polygon_vertex.h" #include "php_polygon_vertex.h"
#include "php_polygon.h" #include "php_polygon.h"
...@@ -427,9 +430,9 @@ BOOL polygon::ints( vertex * p1, vertex * p2, vertex * q1, vertex * q2, ...@@ -427,9 +430,9 @@ BOOL polygon::ints( vertex * p1, vertex * p2, vertex * q1, vertex * q2,
double tua = ((tx4-tx3)*(ty1-ty3)-(ty4-ty3)*(tx1-tx3))/td; double tua = ((tx4-tx3)*(ty1-ty3)-(ty4-ty3)*(tx1-tx3))/td;
double tub = ((tx2-tx1)*(ty1-ty3)-(ty2-ty1)*(tx1-tx3))/td; double tub = ((tx2-tx1)*(ty1-ty3)-(ty2-ty1)*(tx1-tx3))/td;
if( abs(tua)<=eps || abs(1.0-tua)<=eps || abs(tub)<=eps || abs(1.0-tub)<=eps ) if( abs(tua)<=eps || abs(1.0-tua)<=eps || abs(tub)<=eps || abs(1.0-tub)<=eps )
ASSERT(0); wxASSERT(0);
else if( (tua > 0 && tua < 1) && (tub > 0 && tub < 1) ) else if( (tua > 0 && tua < 1) && (tub > 0 && tub < 1) )
ASSERT(0); wxASSERT(0);
TRACE( " perturb:\n new s = (%f,%f) to (%f,%f)\n new c = (%f,%f) to (%f,%f)\n new ua = %.17f, ub = %.17f\n", TRACE( " perturb:\n new s = (%f,%f) to (%f,%f)\n new c = (%f,%f) to (%f,%f)\n new ua = %.17f, ub = %.17f\n",
tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4, tua, tub ); tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4, tua, tub );
} }
...@@ -650,7 +653,7 @@ BOOL polygon::isInside( vertex * v ) ...@@ -650,7 +653,7 @@ BOOL polygon::isInside( vertex * v )
{ {
//** modified for testing //** modified for testing
if( v->isIntersect() ) if( v->isIntersect() )
ASSERT(0); wxASSERT(0);
int winding_number = 0; int winding_number = 0;
int winding_number2 = 0; int winding_number2 = 0;
int winding_number3 = 0; int winding_number3 = 0;
...@@ -689,7 +692,7 @@ BOOL polygon::isInside( vertex * v ) ...@@ -689,7 +692,7 @@ BOOL polygon::isInside( vertex * v )
if( winding_number%2 != winding_number2%2 if( winding_number%2 != winding_number2%2
|| winding_number3%2 != winding_number4%2 || winding_number3%2 != winding_number4%2
|| winding_number%2 != winding_number3%2 ) || winding_number%2 != winding_number3%2 )
ASSERT(0); wxASSERT(0);
if( winding_number%2 == 0 ) // Check even or odd if( winding_number%2 == 0 ) // Check even or odd
return FALSE; // even == outside return FALSE; // even == outside
else else
...@@ -780,9 +783,9 @@ polygon * polygon::boolean( polygon * polyB, int oper ) ...@@ -780,9 +783,9 @@ polygon * polygon::boolean( polygon * polyB, int oper )
s = s->Next(); s = s->Next();
} while( s->id() != polyB->m_first->id() ); } while( s->id() != polyB->m_first->id() );
if( n_ints != n_polyB_ints ) if( n_ints != n_polyB_ints )
ASSERT(0); wxASSERT(0);
if( n_ints%2 != 0 ) if( n_ints%2 != 0 )
ASSERT(0); wxASSERT(0);
//** end test //** end test
/* /*
...@@ -817,7 +820,7 @@ polygon * polygon::boolean( polygon * polyB, int oper ) ...@@ -817,7 +820,7 @@ polygon * polygon::boolean( polygon * polyB, int oper )
s = m_first; s = m_first;
//** testing //** testing
if( s->isIntersect() ) if( s->isIntersect() )
ASSERT(0); wxASSERT(0);
//** end test //** end test
BOOL entry; BOOL entry;
if (polyB->isInside(s)) // if we are already inside if (polyB->isInside(s)) // if we are already inside
......
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