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