You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
5.4 KiB

* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
14 years ago
14 years ago
14 years ago
  1. /*
  2. * @file zones_by_polygon_fill_functions.cpp
  3. */
  4. /*
  5. * This program source code file is part of KiCad, a free EDA CAD application.
  6. *
  7. * Copyright (C) 2009 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
  8. * Copyright (C) 2007 KiCad Developers, see change_log.txt for contributors.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version 2
  13. * of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, you may find one here:
  22. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  23. * or you may search the http://www.gnu.org website for the version 2 license,
  24. * or you may write to the Free Software Foundation, Inc.,
  25. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  26. */
  27. #include <wx/progdlg.h>
  28. #include <fctsys.h>
  29. #include <pgm_base.h>
  30. #include <class_drawpanel.h>
  31. #include <class_draw_panel_gal.h>
  32. #include <ratsnest_data.h>
  33. #include <wxPcbStruct.h>
  34. #include <macros.h>
  35. #include <class_board.h>
  36. #include <class_track.h>
  37. #include <class_zone.h>
  38. #include <pcbnew.h>
  39. #include <zones.h>
  40. #include <view/view.h>
  41. #define FORMAT_STRING _( "Filling zone %d out of %d (net %s)..." )
  42. /**
  43. * Function Delete_OldZone_Fill (obsolete)
  44. * Used for compatibility with old boards
  45. * Remove the zone filling which include the segment aZone, or the zone which have the
  46. * given time stamp.
  47. * A zone is a group of segments which have the same TimeStamp
  48. * @param aZone = zone segment within the zone to delete. Can be NULL
  49. * @param aTimestamp = Timestamp for the zone to delete, used if aZone == NULL
  50. */
  51. void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, time_t aTimestamp )
  52. {
  53. bool modify = false;
  54. time_t TimeStamp;
  55. if( aZone == NULL )
  56. TimeStamp = aTimestamp;
  57. else
  58. TimeStamp = aZone->GetTimeStamp(); // Save reference time stamp (aZone will be deleted)
  59. SEGZONE* next;
  60. for( SEGZONE* zone = GetBoard()->m_Zone; zone != NULL; zone = next )
  61. {
  62. next = zone->Next();
  63. if( zone->GetTimeStamp() == TimeStamp )
  64. {
  65. modify = true;
  66. // remove item from linked list and free memory
  67. zone->DeleteStructure();
  68. }
  69. }
  70. if( modify )
  71. {
  72. OnModify();
  73. m_canvas->Refresh();
  74. }
  75. }
  76. int PCB_EDIT_FRAME::Fill_Zone( ZONE_CONTAINER* aZone )
  77. {
  78. aZone->ClearFilledPolysList();
  79. aZone->UnFill();
  80. // Cannot fill keepout zones:
  81. if( aZone->GetIsKeepout() )
  82. return 1;
  83. wxString msg;
  84. ClearMsgPanel();
  85. // Shows the net
  86. ZONE_SETTINGS zoneInfo = GetZoneSettings();
  87. zoneInfo.m_NetcodeSelection = aZone->GetNetCode();
  88. SetZoneSettings( zoneInfo );
  89. msg = aZone->GetNetname();
  90. if( msg.IsEmpty() )
  91. msg = wxT( "No net" );
  92. AppendMsgPanel( _( "NetName" ), msg, RED );
  93. wxBusyCursor dummy; // Shows an hourglass cursor (removed by its destructor)
  94. aZone->BuildFilledSolidAreasPolygons( GetBoard() );
  95. GetGalCanvas()->GetView()->Update( aZone, KIGFX::ALL );
  96. GetBoard()->GetRatsnest()->Update( aZone );
  97. OnModify();
  98. return 0;
  99. }
  100. int PCB_EDIT_FRAME::Fill_All_Zones( wxWindow * aActiveWindow, bool aVerbose )
  101. {
  102. int errorLevel = 0;
  103. int areaCount = GetBoard()->GetAreaCount();
  104. wxBusyCursor dummyCursor;
  105. wxString msg;
  106. wxProgressDialog * progressDialog = NULL;
  107. // Create a message with a long net name, and build a wxProgressDialog
  108. // with a correct size to show this long net name
  109. msg.Printf( FORMAT_STRING, 000, areaCount, wxT("XXXXXXXXXXXXXXXXX" ) );
  110. if( aActiveWindow )
  111. progressDialog = new wxProgressDialog( _( "Fill All Zones" ), msg,
  112. areaCount+2, aActiveWindow,
  113. wxPD_AUTO_HIDE | wxPD_CAN_ABORT |
  114. wxPD_APP_MODAL | wxPD_ELAPSED_TIME );
  115. // Display the actual message
  116. if( progressDialog )
  117. progressDialog->Update( 0, _( "Starting zone fill..." ) );
  118. // Remove segment zones
  119. GetBoard()->m_Zone.DeleteAll();
  120. int ii;
  121. for( ii = 0; ii < areaCount; ii++ )
  122. {
  123. ZONE_CONTAINER* zoneContainer = GetBoard()->GetArea( ii );
  124. if( zoneContainer->GetIsKeepout() )
  125. continue;
  126. msg.Printf( FORMAT_STRING, ii + 1, areaCount, GetChars( zoneContainer->GetNetname() ) );
  127. if( progressDialog )
  128. {
  129. if( !progressDialog->Update( ii+1, msg ) )
  130. break; // Aborted by user
  131. }
  132. errorLevel = Fill_Zone( zoneContainer );
  133. if( errorLevel && !aVerbose )
  134. break;
  135. }
  136. if( progressDialog )
  137. {
  138. progressDialog->Update( ii+2, _( "Updating ratsnest..." ) );
  139. #ifdef __WXMAC__
  140. // Work around a dialog z-order issue on OS X
  141. aActiveWindow->Raise();
  142. #endif
  143. }
  144. TestConnections();
  145. // Recalculate the active ratsnest, i.e. the unconnected links
  146. TestForActiveLinksInRatsnest( 0 );
  147. if( progressDialog )
  148. progressDialog->Destroy();
  149. return errorLevel;
  150. }