00001
00025 #include "register_functions.c"
00026 #include "cappr.h"
00027
00028
00035 int
00036 cappr_create_element ()
00037 {
00038 gdouble xmax;
00039 gdouble xmin;
00040 gdouble ymax;
00041 gdouble ymin;
00042 gdouble x_text;
00043 gdouble y_text;
00044 gdouble dx;
00045 gint pin_number;
00046 gchar *pin_pad_name = g_strdup ("");
00047 FlagType pad_flag;
00048 ElementTypePtr element;
00049
00050 if (!element)
00051 {
00052 if (verbose)
00053 {
00054 g_log ("", G_LOG_LEVEL_WARNING,
00055 (_("[%s] could not create a valid element pointer for an element.")),
00056 footprint_type);
00057 }
00058 return (EXIT_FAILURE);
00059 }
00060
00061
00062 element->MarkX = 0;
00063 element->MarkY = 0;
00064
00065
00066 if (pad_shapes_type == ROUND_ELONGATED)
00067 {
00068 xmin = multiplier *
00069 (
00070 (-pitch_x / 2.0) -
00071 (pad_length / 2.0) -
00072 pad_solder_mask_clearance
00073 );
00074 xmax = multiplier *
00075 (
00076 (pitch_x / 2.0) +
00077 (pad_length / 2.0) +
00078 pad_solder_mask_clearance
00079 );
00080 ymin = multiplier *
00081 (
00082 (-pitch_y / 2.0) -
00083 (pad_width / 2.0) -
00084 pad_solder_mask_clearance
00085 );
00086 ymax = multiplier *
00087 (
00088 (pitch_y / 2.0) +
00089 (pad_width / 2.0) +
00090 pad_solder_mask_clearance
00091 );
00092 }
00093 else
00094 {
00095 xmin = multiplier *
00096 (
00097 (-pitch_x / 2.0) -
00098 (pad_diameter / 2.0) -
00099 pad_solder_mask_clearance
00100 );
00101 xmax = multiplier *
00102 (
00103 (pitch_x / 2.0) +
00104 (pad_diameter / 2.0) +
00105 pad_solder_mask_clearance
00106 );
00107 ymin = multiplier *
00108 (
00109 (-pitch_y / 2.0) -
00110 (pad_diameter / 2.0) -
00111 pad_solder_mask_clearance
00112 );
00113 ymax = multiplier *
00114 (
00115 (pitch_y / 2.0) +
00116 (pad_diameter / 2.0) +
00117 pad_solder_mask_clearance
00118 );
00119 }
00120
00121
00122 if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin)
00123 {
00124 xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package));
00125 }
00126 if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax)
00127 {
00128 xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package));
00129 }
00130 if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin)
00131 {
00132 ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package));
00133 }
00134 if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax)
00135 {
00136 ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package));
00137 }
00138
00139 if (multiplier * (-courtyard_length / 2.0) < xmin)
00140 {
00141 xmin = multiplier * (-courtyard_length / 2.0);
00142 }
00143 if (multiplier * (courtyard_length / 2.0) > xmax)
00144 {
00145 xmax = multiplier * (courtyard_length / 2.0);
00146 }
00147 if (multiplier * (-courtyard_width / 2.0) < ymin)
00148 {
00149 ymin = multiplier * (-courtyard_width / 2.0);
00150 }
00151 if (multiplier * (courtyard_width / 2.0) > ymax)
00152 {
00153 ymax = multiplier * (courtyard_width / 2.0);
00154 }
00155
00156 element->Name[1].Scale = 100;
00157 element->Name[1].X = 0.0 ;
00158 element->Name[1].Y = (ymin - 10000.0);
00159 element->Name[1].TextString = footprint_name;
00160 element->Name[1].Element = element;
00161 element->Name[1].Direction = EAST;
00162 element->Name[1].ID = ID++;
00163
00164 element->Name[2].Scale = 100;
00165 element->Name[2].X = 0.0 ;
00166 element->Name[2].Y = (ymin - 10000.0);
00167 element->Name[2].TextString = footprint_refdes;
00168 element->Name[2].Element = element;
00169 element->Name[2].Direction = EAST;
00170 element->Name[2].ID = ID++;
00171
00172 element->Name[3].Scale = 100;
00173 element->Name[3].X = 0.0 ;
00174 element->Name[3].Y = (ymin - 10000.0);
00175 element->Name[3].TextString = footprint_value;
00176 element->Name[3].Element = element;
00177 element->Name[3].Direction = EAST;
00178 element->Name[3].ID = ID++;
00179
00180 if (pad_shapes_type == SQUARE)
00181 {
00182 pad_flag.f = SQUARE;
00183 }
00184 else if (pad_shapes_type == OCTAGONAL)
00185 {
00186 pad_flag.f = OCTAGON;
00187 }
00188 else
00189 {
00190 pad_flag.f = CLEAR;
00191 }
00192 create_new_pin
00193 (
00194 element,
00195 (int) (multiplier * ((pitch_x + pad_diameter) / 2.0)),
00196 0,
00197 (int) (multiplier * pad_diameter),
00198 (int) (multiplier * pad_clearance),
00199 (int) (multiplier * (pad_diameter + pad_solder_mask_clearance)),
00200 (int) (multiplier * pin_drill_diameter),
00201 "N",
00202 "2",
00203 pad_flag
00204 );
00205
00206 if (pin1_square)
00207 {
00208 pad_flag.f = SQUARE;
00209 }
00210 create_new_pin
00211 (
00212 element,
00213 (int) (multiplier * ((-pitch_x - pad_diameter) / 2.0)),
00214 0,
00215 (int) (multiplier * pad_diameter),
00216 (int) (multiplier * pad_clearance),
00217 (int) (multiplier * (pad_diameter + pad_solder_mask_clearance)),
00218 (int) (multiplier * pin_drill_diameter),
00219 "P",
00220 "1",
00221 pad_flag
00222 );
00223 if (pad_shapes_type == ROUND_ELONGATED)
00224 {
00225
00226 pad_flag.f = CLEAR;
00227 create_new_pad
00228 (
00229 element,
00230 (int) (multiplier * ((-pitch_x - pad_length + pad_width) / 2.0)),
00231 0,
00232 (int) (multiplier * ((-pitch_x + pad_length - pad_width) / 2.0)),
00233 0,
00234 (int) (multiplier * pad_width),
00235 (int) (multiplier * pad_clearance),
00236 (int) (multiplier * ((pad_length > pad_width ? pad_width : pad_length) + (2 * pad_solder_mask_clearance))),
00237 "P",
00238 "1",
00239 pad_flag
00240 );
00241 create_new_pad
00242 (
00243 element,
00244 (int) (multiplier * ((pitch_x + pad_length - pad_width) / 2.0)),
00245 0,
00246 (int) (multiplier * ((pitch_x - pad_length + pad_width) / 2.0)),
00247 0,
00248 (int) (multiplier * pad_width),
00249 (int) (multiplier * pad_clearance),
00250 (int) (multiplier * ((pad_length > pad_width ? pad_width : pad_length) + (2 * pad_solder_mask_clearance))),
00251 "N",
00252 "2",
00253 pad_flag
00254 );
00255
00256 pad_flag.f = ONSOLDER;
00257 create_new_pad
00258 (
00259 element,
00260 (int) (multiplier * ((-pitch_x - pad_length + pad_width) / 2.0)),
00261 0,
00262 (int) (multiplier * ((-pitch_x + pad_length - pad_width) / 2.0)),
00263 0,
00264 (int) (multiplier * pad_width),
00265 (int) (multiplier * pad_clearance),
00266 (int) (multiplier * ((pad_length > pad_width ? pad_width : pad_length) + (2 * pad_solder_mask_clearance))),
00267 "P",
00268 "1",
00269 pad_flag
00270 );
00271 create_new_pad
00272 (
00273 element,
00274 (int) (multiplier * ((pitch_x + pad_length - pad_width) / 2.0)),
00275 0,
00276 (int) (multiplier * ((pitch_x - pad_length + pad_width) / 2.0)),
00277 0,
00278 (int) (multiplier * pad_width),
00279 (int) (multiplier * pad_clearance),
00280 (int) (multiplier * ((pad_length > pad_width ? pad_width : pad_length) + (2 * pad_solder_mask_clearance))),
00281 "N",
00282 "2",
00283 pad_flag
00284 );
00285 }
00286
00287 if (silkscreen_package_outline)
00288 {
00289 if (package_is_radial)
00290 {
00291 create_new_arc
00292 (
00293 element,
00294 0,
00295 0,
00296 (int) (multiplier * package_body_length),
00297 (int) (multiplier * package_body_length),
00298 0,
00299 360,
00300 (int) (multiplier * silkscreen_line_width)
00301 );
00302 }
00303 else
00304 {
00305 create_new_line
00306 (
00307 element,
00308 (int) (multiplier * (-package_body_length / 2.0)),
00309 (int) (multiplier * (-package_body_width / 2.0)),
00310 (int) (multiplier * (-package_body_length / 2.0)),
00311 (int) (multiplier * (package_body_width / 2.0)),
00312 (int) (multiplier * silkscreen_line_width)
00313 );
00314 create_new_line
00315 (
00316 element,
00317 (int) (multiplier * (package_body_length / 2.0)),
00318 (int) (multiplier * (-package_body_width / 2.0)),
00319 (int) (multiplier * (package_body_length / 2.0)),
00320 (int) (multiplier * (package_body_width / 2.0)),
00321 (int) (multiplier * silkscreen_line_width)
00322 );
00323 create_new_line
00324 (
00325 element,
00326 (int) (multiplier * (-package_body_length / 2.0)),
00327 (int) (multiplier * (-package_body_width / 2.0)),
00328 (int) (multiplier * (package_body_length / 2.0)),
00329 (int) (multiplier * (-package_body_width / 2.0)),
00330 (int) (multiplier * silkscreen_line_width)
00331 );
00332 create_new_line
00333 (
00334 element,
00335 (int) (multiplier * (package_body_length / 2.0)),
00336 (int) (multiplier * (package_body_width / 2.0)),
00337 (int) (multiplier * (-package_body_length / 2.0)),
00338 (int) (multiplier * (package_body_width / 2.0)),
00339 (int) (multiplier * silkscreen_line_width)
00340 );
00341 }
00342 }
00343
00344 if (silkscreen_indicate_1)
00345 {
00346
00347 if (package_body_length < ((pitch_x - pad_diameter - pad_solder_mask_clearance) / 2.0) - silkscreen_line_width)
00348 {
00349 create_new_line
00350 (
00351 element,
00352 (int) (multiplier * ((-pitch_x / 2.0) - (3 * silkscreen_line_width))),
00353 (int) (multiplier * (((-pad_diameter - pad_solder_mask_clearance) / 2.0) - (3 * silkscreen_line_width))),
00354 (int) (multiplier * ((-pitch_x / 2.0) + (3 * silkscreen_line_width))),
00355 (int) (multiplier * (((-pad_diameter - pad_solder_mask_clearance) / 2.0) - (3 * silkscreen_line_width))),
00356 (int) (multiplier * silkscreen_line_width)
00357 );
00358 create_new_line
00359 (
00360 element,
00361 (int) (multiplier * (-pitch_x / 2.0)),
00362 (int) (multiplier * (((-pad_diameter - pad_solder_mask_clearance) / 2.0) - (silkscreen_line_width))),
00363 (int) (multiplier * (-pitch_x / 2.0)),
00364 (int) (multiplier * (((-pad_diameter - pad_solder_mask_clearance) / 2.0) - (6 * silkscreen_line_width))),
00365 (int) (multiplier * silkscreen_line_width)
00366 );
00367 }
00368 }
00369
00370 if (courtyard)
00371 {
00372 if (package_is_radial)
00373 {
00374 create_new_arc
00375 (
00376 element,
00377 0,
00378 0,
00379 (int) (2 * xmax),
00380 (int) (2 * ymax),
00381 0,
00382 360,
00383 (int) (multiplier * courtyard_line_width)
00384 );
00385 }
00386 else
00387 {
00388 create_new_line
00389 (
00390 element,
00391 (int) (xmin),
00392 (int) (ymin),
00393 (int) (xmin),
00394 (int) (ymax),
00395 (int) (multiplier * courtyard_line_width)
00396 );
00397 create_new_line
00398 (
00399 element,
00400 (int) (xmax),
00401 (int) (ymin),
00402 (int) (xmax),
00403 (int) (ymax),
00404 (int) (multiplier * courtyard_line_width)
00405 );
00406 create_new_line
00407 (
00408 element,
00409 (int) (xmin),
00410 (int) (ymin),
00411 (int) (xmax),
00412 (int) (ymin),
00413 (int) (multiplier * courtyard_line_width)
00414 );
00415 create_new_line
00416 (
00417 element,
00418 (int) (xmax),
00419 (int) (ymax),
00420 (int) (xmin),
00421 (int) (ymax),
00422 (int) (multiplier * courtyard_line_width)
00423 );
00424 }
00425 }
00426
00427 if (attributes_in_footprint)
00428 {
00429 element = create_attributes_in_element (element);
00430 }
00431
00432 if (verbose)
00433 {
00434 g_log ("", G_LOG_LEVEL_INFO,
00435 (_("[%s] created an element for element: %s.")),
00436 footprint_type,
00437 footprint_filename);
00438 }
00439 current_element = (ElementTypePtr) &element;
00440 return (EXIT_SUCCESS);
00441 }
00442
00443
00453 int
00454 cappr_create_packages_list ()
00455 {
00456 g_list_free (packages_list);
00457 packages_list = g_list_append (packages_list, "CAPPR");
00458 return (EXIT_SUCCESS);
00459 }
00460
00461
00491 int
00492 cappr_drc ()
00493 {
00494 int result = EXIT_SUCCESS;
00495 if (verbose)
00496 {
00497 g_log ("", G_LOG_LEVEL_INFO,
00498 (_("[%s] DRC Check: checking package %s.")),
00499 footprint_type, footprint_name);
00500 }
00501
00502 switch (pad_shapes_type)
00503 {
00504 case NO_SHAPE:
00505 {
00506 if (verbose)
00507 {
00508 g_log ("", G_LOG_LEVEL_WARNING,
00509 (_("[%s] DRC Error: NO_SHAPE specified for check for allowed pad shapes.")),
00510 footprint_type);
00511 }
00512 result = EXIT_FAILURE;
00513 break;
00514 }
00515 case ROUND:
00516 {
00517 break;
00518 }
00519 case SQUARE:
00520 {
00521 break;
00522 }
00523 case OCTAGONAL:
00524 {
00525 break;
00526 }
00527 case ROUND_ELONGATED:
00528 {
00529 break;
00530 }
00531 default:
00532 {
00533 if (verbose)
00534 {
00535 g_log ("", G_LOG_LEVEL_WARNING,
00536 (_("[%s] DRC Error: no valid pad shape type specified.")),
00537 footprint_type);
00538 }
00539 result = EXIT_FAILURE;
00540 break;
00541 }
00542 }
00543
00544 if (package_body_length <= 0.0)
00545 {
00546 if (verbose)
00547 {
00548 g_log ("", G_LOG_LEVEL_WARNING,
00549 (_("[%s] DRC Error: specified package body length is too small.")),
00550 footprint_type);
00551 }
00552 result = EXIT_FAILURE;
00553 }
00554 if (package_body_width <= 0.0)
00555 {
00556 if (verbose)
00557 {
00558 g_log ("", G_LOG_LEVEL_WARNING,
00559 (_("[%s] DRC Error: specified package body width is too small.")),
00560 footprint_type);
00561 }
00562 result = EXIT_FAILURE;
00563 }
00564 if (package_body_height <= 0.0)
00565 {
00566 if (verbose)
00567 {
00568 g_log ("", G_LOG_LEVEL_WARNING,
00569 (_("[%s] DRC Error: specified package body height is too small.")),
00570 footprint_type);
00571 }
00572 result = EXIT_FAILURE;
00573 }
00574
00575 if (courtyard_length <= 0.0)
00576 {
00577 if (verbose)
00578 {
00579 g_log ("", G_LOG_LEVEL_WARNING,
00580 (_("[%s] DRC Error: specified courtyard length is too small.")),
00581 footprint_type);
00582 }
00583 result = EXIT_FAILURE;
00584 }
00585 if (courtyard_width <= 0.0)
00586 {
00587 if (verbose)
00588 {
00589 g_log ("", G_LOG_LEVEL_WARNING,
00590 (_("[%s] DRC Error: specified courtyard width is too small.")),
00591 footprint_type);
00592 }
00593 return (EXIT_FAILURE);
00594 }
00595
00596 if ((pitch_x - pad_diameter < pad_clearance)
00597 || (pitch_x - pad_length < pad_clearance))
00598 {
00599 if (verbose)
00600 {
00601 g_log ("", G_LOG_LEVEL_WARNING,
00602 (_("[%s] DRC Error: minimum clearance between copper (X-direction) is too small.")),
00603 footprint_type);
00604 }
00605 result = EXIT_FAILURE;
00606 }
00607
00608 if (pitch_y != 0.0)
00609 {
00610 if (verbose)
00611 {
00612 g_log ("", G_LOG_LEVEL_WARNING,
00613 (_("[%s] DRC Error: pitch in Y-direction should be 0.")),
00614 footprint_type);
00615 }
00616 result = EXIT_FAILURE;
00617 }
00618
00619 if (fiducial)
00620 {
00621 if (verbose)
00622 {
00623 g_log ("", G_LOG_LEVEL_WARNING,
00624 (_("[%s] DRC Error: package should not have a fiducial pad.")),
00625 footprint_type);
00626 }
00627 result = EXIT_FAILURE;
00628 }
00629
00630
00631 if (package_body_length - courtyard_length < courtyard_clearance_with_package)
00632 {
00633 if (verbose)
00634 {
00635 g_log ("", G_LOG_LEVEL_WARNING,
00636 (_("[%s] DRC Error: check for clearance of the package length with regard to the courtyard dimensions.")),
00637 footprint_type);
00638 }
00639 result = EXIT_FAILURE;
00640 }
00641
00642
00643 if (package_body_width - courtyard_width < courtyard_clearance_with_package)
00644 {
00645 if (verbose)
00646 {
00647 g_log ("", G_LOG_LEVEL_WARNING,
00648 (_("[%s] DRC Error: check for clearance of the package width with regard to the courtyard dimensions.")),
00649 footprint_type);
00650 }
00651 result = EXIT_FAILURE;
00652 }
00658
00659 if (silkscreen_package_outline && (silkscreen_line_width == 0.0))
00660 {
00661 if (verbose)
00662 {
00663 g_log ("", G_LOG_LEVEL_WARNING,
00664 (_("[%s] DRC Error: silkscreen line width is too small.")),
00665 footprint_type);
00666 }
00667 result = EXIT_FAILURE;
00668 }
00669 switch (units_type)
00670 {
00671 case NO_UNITS:
00672 {
00673 if (verbose)
00674 {
00675 g_log ("", G_LOG_LEVEL_WARNING,
00676 (_("[%s] DRC Error: no units specified.")),
00677 footprint_type);
00678 }
00679 result = EXIT_FAILURE;
00680 break;
00681 }
00682 case MIL:
00683 if (silkscreen_package_outline && (silkscreen_line_width > 40.0))
00684 {
00685 if (verbose)
00686 {
00687 g_log ("", G_LOG_LEVEL_WARNING,
00688 (_("[%s] DRC Error: silkscreen line width too wide.")),
00689 footprint_type);
00690 }
00691 result = EXIT_FAILURE;
00692 break;
00693 }
00694 case MIL_100:
00695 if (silkscreen_package_outline && (silkscreen_line_width > 4000.0))
00696 {
00697 if (verbose)
00698 {
00699 g_log ("", G_LOG_LEVEL_WARNING,
00700 (_("[%s] DRC Error: silkscreen line width too wide.")),
00701 footprint_type);
00702 }
00703 result = EXIT_FAILURE;
00704 break;
00705 }
00706 case MM:
00707 if (silkscreen_package_outline && (silkscreen_line_width > 1.0))
00708 {
00709 if (verbose)
00710 {
00711 g_log ("", G_LOG_LEVEL_WARNING,
00712 (_("[%s] DRC Error: silkscreen line width too wide.")),
00713 footprint_type);
00714 }
00715 result = EXIT_FAILURE;
00716 break;
00717 }
00718 default:
00719 {
00720 if (verbose)
00721 {
00722 g_log ("", G_LOG_LEVEL_WARNING,
00723 (_("[%s] DRC Error: no valid units type specified.")),
00724 footprint_type);
00725 }
00726 result = EXIT_FAILURE;
00727 break;
00728 }
00729 }
00730
00731 if (verbose && (result == EXIT_SUCCESS))
00732 {
00733 g_log ("", G_LOG_LEVEL_INFO,
00734 (_("[%s] DRC Check: no errors while checking package %s.")),
00735 footprint_type, footprint_name);
00736 }
00737 return result;
00738 }
00739
00740
00755 int
00756 cappr_get_default_footprint_values ()
00757 {
00758 if (!strcmp (footprint_name, "?CAPPR"))
00759 {
00760 footprint_units = g_strdup ("mm");
00761 package_body_length = 0.0;
00762 package_body_width = 0.0;
00763 package_body_height = 0.0;
00764 package_is_radial = FALSE;
00765 number_of_pins = 2;
00766 number_of_columns = 2;
00767 number_of_rows = 1;
00768 pitch_x = 0.0;
00769 pitch_y = 0.0;
00770 count_x = 0;
00771 count_y = 0;
00772 pad_diameter = 0.0;
00773 pin_drill_diameter = 0.0;
00774 pad_length = 0.0;
00775 pad_width = 0.0;
00776 pad_shape = g_strdup ("circular pad");
00777 pad_shapes_type = ROUND;
00778 thermal = FALSE;
00779 thermal_length = 0.0;
00780 thermal_width = 0.0;
00781 fiducial = FALSE;
00782 fiducial_pad_diameter = 0.0;
00783 fiducial_pad_solder_mask_clearance = 0.0;
00784 silkscreen_package_outline = TRUE;
00785 silkscreen_length = 0.0;
00786 silkscreen_width = 0.0;
00787 silkscreen_line_width = 0.20;
00788 courtyard = FALSE;
00789 courtyard_length = 0.00;
00790 courtyard_width = 0.00;
00791 courtyard_line_width = 0.05;
00792 g_free (footprint_name);
00793 footprint_name = g_strdup ("CAPPR");
00794 return (EXIT_SUCCESS);
00795 }
00796 else
00797 {
00798 g_log ("", G_LOG_LEVEL_WARNING,
00799 (_("default values for footprint %s not found.\n")),
00800 footprint_name);
00801 return (EXIT_FAILURE);
00802 }
00803 }
00804
00805
00806 #if GUI
00807
00814 int
00815 cappr_set_gui_constraints ()
00816 {
00817
00818 GtkWidget *package_is_radial_checkbutton = lookup_widget (GTK_WIDGET (widget),
00819 "package_is_radial_checkbutton");
00820 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (package_is_radial_checkbutton), TRUE);
00821 gtk_widget_set_sensitive (package_is_radial_checkbutton, TRUE);
00822
00823
00824 GtkWidget *number_of_columns_entry = lookup_widget (GTK_WIDGET (widget),
00825 "number_of_columns_entry");
00826 gtk_entry_set_text (GTK_ENTRY (number_of_columns_entry), "2");
00827 gtk_widget_set_sensitive (number_of_columns_entry, FALSE);
00828 GtkWidget *number_of_rows_entry = lookup_widget (GTK_WIDGET (widget),
00829 "number_of_rows_entry");
00830 gtk_entry_set_text (GTK_ENTRY (number_of_rows_entry), "");
00831 gtk_widget_set_sensitive (number_of_rows_entry, TRUE);
00832 GtkWidget *pitch_y_entry = lookup_widget (GTK_WIDGET (widget),
00833 "pitch_y_entry");
00834 gtk_entry_set_text (GTK_ENTRY (pitch_y_entry), "");
00835 gtk_widget_set_sensitive (pitch_y_entry, FALSE);
00836 GtkWidget *count_x_entry = lookup_widget (GTK_WIDGET (widget),
00837 "count_x_entry");
00838 gtk_entry_set_text (GTK_ENTRY (count_x_entry), "");
00839 gtk_widget_set_sensitive (count_x_entry, FALSE);
00840 GtkWidget *count_y_entry = lookup_widget (GTK_WIDGET (widget),
00841 "count_y_entry");
00842 gtk_entry_set_text (GTK_ENTRY (count_y_entry), "");
00843 gtk_widget_set_sensitive (count_y_entry, FALSE);
00844 GtkWidget *number_1_position_entry = lookup_widget (GTK_WIDGET (widget),
00845 "number_1_position_entry");
00846 gtk_combo_box_set_active (GTK_COMBO_BOX (number_1_position_entry), UPPER_LEFT);
00847 gtk_widget_set_sensitive (number_1_position_entry, FALSE);
00848
00849
00850 gui_constraints_disable_thermal_tab_widgets (widget);
00851
00852
00853 gui_constraints_disable_heel_and_toe_goals_tab_widgets (widget);
00854 return (EXIT_SUCCESS);
00855 }
00856 #endif
00857
00858
00865 int
00866 cappr_write_footprint ()
00867 {
00868 gdouble xmax;
00869 gdouble xmin;
00870 gdouble ymax;
00871 gdouble ymin;
00872 gdouble x_text;
00873 gdouble y_text;
00874 gchar *pin_pad_flags = g_strdup ("");
00875
00876
00877 fp = fopen (footprint_filename, "w");
00878 if (!fp)
00879 {
00880 g_log ("", G_LOG_LEVEL_WARNING,
00881 (_("could not open file for %s footprint: %s.")),
00882 footprint_type, footprint_filename);
00883 fclose (fp);
00884 return (EXIT_FAILURE);
00885 }
00886
00887 if (license_in_footprint)
00888 {
00889 write_license ();
00890 }
00891
00892
00893 if (pad_shapes_type == ROUND_ELONGATED)
00894 {
00895 xmin = multiplier *
00896 (
00897 (-pitch_x / 2.0) -
00898 (pad_length / 2.0) -
00899 pad_solder_mask_clearance
00900 );
00901 xmax = multiplier *
00902 (
00903 (pitch_x / 2.0) +
00904 (pad_length / 2.0) +
00905 pad_solder_mask_clearance
00906 );
00907 ymin = multiplier *
00908 (
00909 (-pitch_y / 2.0) -
00910 (pad_width / 2.0) -
00911 pad_solder_mask_clearance
00912 );
00913 ymax = multiplier *
00914 (
00915 (pitch_y / 2.0) +
00916 (pad_width / 2.0) +
00917 pad_solder_mask_clearance
00918 );
00919 }
00920 else
00921 {
00922 xmin = multiplier *
00923 (
00924 (-pitch_x / 2.0) -
00925 (pad_diameter / 2.0) -
00926 pad_solder_mask_clearance
00927 );
00928 xmax = multiplier *
00929 (
00930 (pitch_x / 2.0) +
00931 (pad_diameter / 2.0) +
00932 pad_solder_mask_clearance
00933 );
00934 ymin = multiplier *
00935 (
00936 (-pitch_y / 2.0) -
00937 (pad_diameter / 2.0) -
00938 pad_solder_mask_clearance
00939 );
00940 ymax = multiplier *
00941 (
00942 (pitch_y / 2.0) +
00943 (pad_diameter / 2.0) +
00944 pad_solder_mask_clearance
00945 );
00946 }
00947
00948
00949 if ((multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package)) < xmin)
00950 {
00951 xmin = (multiplier * ((-package_body_length / 2.0) - courtyard_clearance_with_package));
00952 }
00953 if ((multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package)) > xmax)
00954 {
00955 xmax = (multiplier * ((package_body_length / 2.0) + courtyard_clearance_with_package));
00956 }
00957 if ((multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package)) < ymin)
00958 {
00959 ymin = (multiplier * ((-package_body_width / 2.0) - courtyard_clearance_with_package));
00960 }
00961 if ((multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package)) > ymax)
00962 {
00963 ymax = (multiplier * ((package_body_width / 2.0) + courtyard_clearance_with_package));
00964 }
00965
00966 if (multiplier * (-courtyard_length / 2.0) < xmin)
00967 {
00968 xmin = multiplier * (-courtyard_length / 2.0);
00969 }
00970 if (multiplier * (courtyard_length / 2.0) > xmax)
00971 {
00972 xmax = multiplier * (courtyard_length / 2.0);
00973 }
00974 if (multiplier * (-courtyard_width / 2.0) < ymin)
00975 {
00976 ymin = multiplier * (-courtyard_width / 2.0);
00977 }
00978 if (multiplier * (courtyard_width / 2.0) > ymax)
00979 {
00980 ymax = multiplier * (courtyard_width / 2.0);
00981 }
00982
00983
00984 x_text = 0.0 ;
00985 y_text = (ymin - 10000.0);
00986 write_element_header (x_text, y_text);
00987
00988 if (pad_shapes_type == SQUARE)
00989 {
00990 pin_pad_flags = g_strdup ("square");
00991 }
00992 else if (pad_shapes_type == OCTAGONAL)
00993 {
00994 pin_pad_flags = g_strdup ("octagon");
00995 }
00996 else
00997 {
00998 pin_pad_flags = g_strdup ("");
00999 }
01000 write_pin
01001 (
01002 2,
01003 "N",
01004 multiplier * ((pitch_x + pad_diameter) / 2.0),
01005 0,
01006 multiplier * pad_diameter,
01007 multiplier * pad_clearance,
01008 multiplier * (pad_diameter + pad_solder_mask_clearance),
01009 multiplier * pin_drill_diameter,
01010 pin_pad_flags
01011 );
01012
01013 if (pin1_square)
01014 {
01015 pin_pad_flags = g_strdup ("square");
01016 }
01017 write_pin
01018 (
01019 1,
01020 "P",
01021 multiplier * ((-pitch_x - pad_diameter) / 2.0),
01022 0,
01023 multiplier * pad_diameter,
01024 multiplier * pad_clearance,
01025 multiplier * (pad_diameter + pad_solder_mask_clearance),
01026 multiplier * pin_drill_diameter,
01027 pin_pad_flags
01028 );
01029 if (pad_shapes_type == ROUND_ELONGATED)
01030 {
01031
01032 pin_pad_flags = g_strdup ("");
01033 write_pad
01034 (
01035 1,
01036 "P",
01037 multiplier * ((-pitch_x - pad_length + pad_width) / 2.0),
01038 0,
01039 multiplier * ((-pitch_x + pad_length - pad_width) / 2.0),
01040 0,
01041 multiplier * pad_width,
01042 multiplier * pad_clearance,
01043 multiplier * (pad_width + (2 * pad_solder_mask_clearance)),
01044 pin_pad_flags
01045 );
01046 write_pad
01047 (
01048 2,
01049 "N",
01050 multiplier * ((pitch_x - pad_length + pad_width) / 2.0),
01051 0,
01052 multiplier * ((pitch_x + pad_length - pad_width) / 2.0),
01053 0,
01054 multiplier * pad_width,
01055 multiplier * pad_clearance,
01056 multiplier * ((pad_length > pad_width ? pad_width : pad_length) + (2 * pad_solder_mask_clearance)),
01057 pin_pad_flags
01058 );
01059
01060 pin_pad_flags = g_strdup ("onsolder");
01061 write_pad
01062 (
01063 1,
01064 "P",
01065 multiplier * ((-pitch_x - pad_length + pad_width) / 2.0),
01066 0,
01067 multiplier * ((-pitch_x + pad_length - pad_width) / 2.0),
01068 0,
01069 multiplier * pad_width,
01070 multiplier * pad_clearance,
01071 multiplier * (pad_width + (2 * pad_solder_mask_clearance)),
01072 pin_pad_flags
01073 );
01074 write_pad
01075 (
01076 2,
01077 "N",
01078 multiplier * ((pitch_x - pad_length + pad_width) / 2.0),
01079 0,
01080 multiplier * ((pitch_x + pad_length - pad_width) / 2.0),
01081 0,
01082 multiplier * pad_width,
01083 multiplier * pad_clearance,
01084 multiplier * ((pad_length > pad_width ? pad_width : pad_length) + (2 * pad_solder_mask_clearance)),
01085 pin_pad_flags
01086 );
01087 }
01088
01089 if (silkscreen_package_outline)
01090 {
01091 fprintf (fp, (_("# Write a package body on the silkscreen\n")));
01092 if (package_is_radial)
01093 {
01094
01095 write_element_arc
01096 (
01097 0,
01098 0,
01099 multiplier * package_body_length,
01100 multiplier * package_body_length,
01101 0,
01102 360,
01103 multiplier * silkscreen_line_width
01104 );
01105 }
01106 else
01107 {
01108 write_rectangle
01109 (
01110 multiplier * (-package_body_length / 2.0),
01111 multiplier * (-package_body_width / 2.0),
01112 multiplier * (package_body_length / 2.0),
01113 multiplier * (package_body_width / 2.0),
01114 multiplier * silkscreen_line_width
01115 );
01116 }
01117 }
01118
01119 if (silkscreen_indicate_1)
01120 {
01121
01122 if (package_body_length < ((pitch_x - pad_diameter - pad_solder_mask_clearance) / 2.0) - silkscreen_line_width)
01123 {
01124 write_element_line
01125 (
01126 multiplier * ((-pitch_x / 2.0) - (3 * silkscreen_line_width)),
01127 multiplier * (((-pad_diameter - pad_solder_mask_clearance) / 2.0) - (3 * silkscreen_line_width)),
01128 multiplier * ((-pitch_x / 2.0) + (3 * silkscreen_line_width)),
01129 multiplier * (((-pad_diameter - pad_solder_mask_clearance) / 2.0) - (3 * silkscreen_line_width)),
01130 multiplier * silkscreen_line_width
01131 );
01132 write_element_line
01133 (
01134 multiplier * (-pitch_x / 2.0),
01135 multiplier * (((-pad_diameter - pad_solder_mask_clearance) / 2.0) - (silkscreen_line_width)),
01136 multiplier * (-pitch_x / 2.0),
01137 multiplier * (((-pad_diameter - pad_solder_mask_clearance) / 2.0) - (6 * silkscreen_line_width)),
01138 multiplier * silkscreen_line_width
01139 );
01140 }
01141 }
01142
01143 if (courtyard)
01144 {
01145 fprintf (fp, (_("# Write a courtyard on the silkscreen\n")));
01146 if (package_is_radial)
01147 {
01148 write_element_arc
01149 (
01150 0,
01151 0,
01152 2 * xmax,
01153 2 * ymax,
01154 0,
01155 360,
01156 multiplier * courtyard_line_width
01157 );
01158 }
01159 else
01160 {
01161 write_rectangle
01162 (
01163 xmin,
01164 ymin,
01165 xmax,
01166 ymax,
01167 multiplier * courtyard_line_width
01168 );
01169 }
01170 }
01171
01172 if (attributes_in_footprint)
01173 {
01174 write_attributes ();
01175 }
01176
01177 fprintf (fp, "\n");
01178 fprintf (fp, ")\n");
01179 fclose (fp);
01180
01181 if (verbose)
01182 {
01183 g_log ("", G_LOG_LEVEL_INFO,
01184 (_("wrote a footprint for a %s package: %s.")),
01185 footprint_type,
01186 footprint_filename);
01187 }
01188 return (EXIT_SUCCESS);
01189 }
01190
01191
01195 static fpw_function_t
01196 cappr_function_list[] =
01197 {
01198 #if GUI
01199 {
01200 "Set GUI constraints",
01201 cappr_set_gui_constraints,
01202 "Set GUI constraints for a CAPPR package",
01203 NULL
01204 },
01205 #endif
01206 {
01207 "Create element",
01208 cappr_create_element,
01209 "Create an element for a CAPPR package",
01210 NULL
01211 },
01212 {
01213 "Packages list",
01214 cappr_create_packages_list,
01215 "Create a list of known CAPPR packages",
01216 NULL
01217 },
01218 {
01219 "DRC CAPPR Element",
01220 cappr_drc,
01221 "Design Rule Check for a CAPPR package",
01222 NULL
01223 },
01224 {
01225 "Default Element Values",
01226 cappr_get_default_footprint_values,
01227 "Get default values for a selected CAPPR package",
01228 NULL
01229 },
01230 {
01231 "Write footprint",
01232 cappr_write_footprint,
01233 "Write a footprint for a CAPPR package",
01234 NULL
01235 }
01236 };
01237
01238
01242 REGISTER_FUNCTIONS (cappr_function_list)
01243
01244
01245
01248 void
01249 cappr_init ()
01250 {
01251 register_cappr_function_list ();
01252 }
01253
01254
01255