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.

155 lines
4.1 KiB

  1. /***************************************************************/
  2. /* Edition des pistes: Routines de modification de dimensions: */
  3. /* Modif de largeurs de segment, piste, net , zone et diam Via */
  4. /***************************************************************/
  5. #include "fctsys.h"
  6. #include "gr_basic.h"
  7. #include "common.h"
  8. #include "pcbnew.h"
  9. #include "autorout.h"
  10. #include "protos.h"
  11. /* Routines Locales */
  12. /*********************************************************************/
  13. int WinEDA_PcbFrame::Edit_TrackSegm_Width(wxDC * DC, TRACK * pt_segm)
  14. /*********************************************************************/
  15. /* Routine de modification de la largeur d'un segment ( ou via) de piste
  16. Routine de base utilisee par les autres routines
  17. */
  18. {
  19. int errdrc = OK_DRC;
  20. int old_w, consigne ;
  21. pt_segm->Draw(DrawPanel, DC, GR_XOR) ; // effacement a l'ecran
  22. /* Test DRC et mise a la largeur */
  23. old_w = pt_segm->m_Width;
  24. consigne = pt_segm->m_Width = g_DesignSettings.m_CurrentTrackWidth;
  25. if( pt_segm->Type() == TYPEVIA )
  26. {
  27. consigne = pt_segm->m_Width = g_DesignSettings.m_CurrentViaSize;
  28. }
  29. if ( old_w < consigne) /* DRC utile puisque augm de dimension */
  30. {
  31. if(Drc_On) errdrc = Drc(this, DC, pt_segm, m_Pcb->m_Track,1);
  32. if(errdrc == BAD_DRC) pt_segm->m_Width = old_w;
  33. else GetScreen()->SetModify();
  34. }
  35. else GetScreen()->SetModify(); /* Correction systematiquement faite si reduction */
  36. pt_segm->Draw(DrawPanel, DC, GR_OR) ;
  37. return(errdrc);
  38. }
  39. /*****************************************************************/
  40. void WinEDA_PcbFrame::Edit_Track_Width(wxDC * DC,TRACK * pt_segm)
  41. /*****************************************************************/
  42. {
  43. int ii;
  44. TRACK * pt_track;
  45. int errdrc;
  46. int nb_segm, nb_segm_modifies = 0, nb_segm_non_modifies = 0;
  47. if( pt_segm == NULL) return;
  48. pt_track = Marque_Une_Piste(this, DC, pt_segm, &nb_segm, 0);
  49. for(ii = 0; ii < nb_segm; ii++, pt_track = (TRACK*) pt_track->Pnext)
  50. {
  51. pt_track->SetState(BUSY,OFF);
  52. errdrc = Edit_TrackSegm_Width(DC, pt_track);
  53. if(errdrc == BAD_DRC) nb_segm_non_modifies++;
  54. else nb_segm_modifies++;
  55. }
  56. }
  57. /***********************************************************/
  58. void WinEDA_PcbFrame::Edit_Net_Width(wxDC * DC, int Netcode)
  59. /***********************************************************/
  60. {
  61. TRACK *pt_segm;
  62. int errdrc;
  63. int nb_segm_modifies = 0;
  64. int nb_segm_non_modifies = 0;
  65. if (Netcode <= 0 ) return;
  66. if( ! IsOK(this, "Change largeur NET ?") ) return;
  67. /* balayage des segments */
  68. for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext )
  69. {
  70. if ( Netcode != pt_segm->m_NetCode ) /* mauvaise piste */
  71. continue ;
  72. /* piste d'un net trouvee */
  73. errdrc = Edit_TrackSegm_Width(DC, pt_segm);
  74. if(errdrc == BAD_DRC) nb_segm_non_modifies++;
  75. else nb_segm_modifies++;
  76. }
  77. }
  78. /*************************************************************************/
  79. bool WinEDA_PcbFrame::Resize_Pistes_Vias(wxDC * DC, bool Track, bool Via)
  80. /*************************************************************************/
  81. /* remet a jour la largeur des pistes et/ou le diametre des vias
  82. Si piste == 0 , pas de cht sur les pistes
  83. Si via == 0 , pas de cht sur les vias
  84. */
  85. {
  86. TRACK * pt_segm ;
  87. int errdrc;
  88. int nb_segm_modifies = 0;
  89. int nb_segm_non_modifies = 0;
  90. if ( Track && Via)
  91. {
  92. if( ! IsOK(this, _("Edit All Tracks and Vias Sizes")) ) return FALSE;
  93. }
  94. else if ( Via )
  95. {
  96. if( ! IsOK(this, _("Edit All Via Sizes")) ) return FALSE;
  97. }
  98. else if( Track )
  99. {
  100. if( ! IsOK(this, _("Edit All Track Sizes")) ) return FALSE;
  101. }
  102. pt_segm = m_Pcb->m_Track ;
  103. for ( ; pt_segm != NULL; pt_segm = (TRACK*) pt_segm->Pnext )
  104. {
  105. if( pt_segm->Type() == TYPEVIA ) /* mise a jour du diametre de la via */
  106. {
  107. if ( Via )
  108. {
  109. errdrc = Edit_TrackSegm_Width(DC, pt_segm);
  110. if(errdrc == BAD_DRC) nb_segm_non_modifies++;
  111. else nb_segm_modifies++;
  112. }
  113. }
  114. else /* mise a jour de la largeur du segment */
  115. {
  116. if ( Track )
  117. {
  118. errdrc = Edit_TrackSegm_Width(DC, pt_segm);
  119. if(errdrc == BAD_DRC) nb_segm_non_modifies++;
  120. else nb_segm_modifies++;
  121. }
  122. }
  123. }
  124. if ( nb_segm_modifies ) return TRUE;
  125. return FALSE;
  126. }